Skip to content
Snippets Groups Projects
Verified Commit a716e7e6 authored by Tobias Frisch's avatar Tobias Frisch
Browse files

[#104] Added methods to add debug labels to handles

parent a7e3a227
No related branches found
No related tags found
1 merge request!87Resolve "Pass Debug Profiling"
Pipeline #26937 passed
......@@ -318,6 +318,14 @@ namespace vkcv
void recordBlitImage(const CommandStreamHandle& cmdStream, const ImageHandle& src, const ImageHandle& dst,
SamplerFilterType filterType);
void setDebugLabel(const BufferHandle &handle, const std::string &label);
void setDebugLabel(const PassHandle &handle, const std::string &label);
void setDebugLabel(const PipelineHandle &handle, const std::string &label);
void setDebugLabel(const DescriptorSetHandle &handle, const std::string &label);
void setDebugLabel(const SamplerHandle &handle, const std::string &label);
void setDebugLabel(const ImageHandle &handle, const std::string &label);
void setDebugLabel(const CommandStreamHandle &handle, const std::string &label);
};
}
......@@ -32,6 +32,8 @@ int main(int argc, const char** argv) {
uint16_t indices[3] = { 0, 1, 2 };
triangleIndexBuffer.fill(&indices[0], sizeof(indices));
core.setDebugLabel(triangleIndexBuffer.getHandle(), "Triangle Index Buffer");
// an example attachment for passes that output to the window
const vkcv::AttachmentDescription present_color_attachment(
vkcv::AttachmentOperation::STORE,
......@@ -46,6 +48,8 @@ int main(int argc, const char** argv) {
std::cout << "Error. Could not create renderpass. Exiting." << std::endl;
return EXIT_FAILURE;
}
core.setDebugLabel(trianglePass, "Triangle Pass");
vkcv::ShaderProgram triangleShaderProgram;
vkcv::shader::GLSLCompiler compiler;
......@@ -78,12 +82,15 @@ int main(int argc, const char** argv) {
return EXIT_FAILURE;
}
core.setDebugLabel(trianglePipeline, "Triangle Pipeline");
auto start = std::chrono::system_clock::now();
const vkcv::Mesh renderMesh({}, triangleIndexBuffer.getVulkanHandle(), 3);
vkcv::DrawcallInfo drawcall(renderMesh, {},1);
const vkcv::ImageHandle swapchainInput = vkcv::ImageHandle::createSwapchainImageHandle();
core.setDebugLabel(swapchainInput, "Swapchain Image");
vkcv::camera::CameraManager cameraManager(window);
uint32_t camIndex0 = cameraManager.addCamera(vkcv::camera::ControllerType::PILOT);
......@@ -113,6 +120,7 @@ int main(int argc, const char** argv) {
pushConstants.appendDrawcall(mvp);
auto cmdStream = core.createCommandStream(vkcv::QueueType::Graphics);
core.setDebugLabel(cmdStream, "Render Commands");
core.recordDrawcallsToCmdStream(
cmdStream,
......
......@@ -832,4 +832,141 @@ namespace vkcv
}, nullptr);
}
static void setDebugObjectLabel(const vk::Device& device, const vk::ObjectType& type,
uint64_t handle, const std::string& label) {
#ifndef NDEBUG
static PFN_vkSetDebugUtilsObjectNameEXT setDebugLabel = reinterpret_cast<PFN_vkSetDebugUtilsObjectNameEXT>(
device.getProcAddr("vkSetDebugUtilsObjectNameEXT")
);
if (!setDebugLabel) {
return;
}
const vk::DebugUtilsObjectNameInfoEXT debug (
type,
handle,
label.c_str()
);
setDebugLabel(device, &(static_cast<const VkDebugUtilsObjectNameInfoEXT&>(debug)));
#endif
}
void Core::setDebugLabel(const BufferHandle &handle, const std::string &label) {
if (!handle) {
vkcv_log(LogLevel::WARNING, "Can't set debug label to invalid handle");
return;
}
setDebugObjectLabel(
m_Context.getDevice(),
vk::ObjectType::eBuffer,
reinterpret_cast<uint64_t>(static_cast<VkBuffer>(
m_BufferManager->getBuffer(handle)
)),
label
);
}
void Core::setDebugLabel(const PassHandle &handle, const std::string &label) {
if (!handle) {
vkcv_log(LogLevel::WARNING, "Can't set debug label to invalid handle");
return;
}
setDebugObjectLabel(
m_Context.getDevice(),
vk::ObjectType::eRenderPass,
reinterpret_cast<uint64_t>(static_cast<VkRenderPass>(
m_PassManager->getVkPass(handle)
)),
label
);
}
void Core::setDebugLabel(const PipelineHandle &handle, const std::string &label) {
if (!handle) {
vkcv_log(LogLevel::WARNING, "Can't set debug label to invalid handle");
return;
}
setDebugObjectLabel(
m_Context.getDevice(),
vk::ObjectType::ePipeline,
reinterpret_cast<uint64_t>(static_cast<VkPipeline>(
m_PipelineManager->getVkPipeline(handle)
)),
label
);
}
void Core::setDebugLabel(const DescriptorSetHandle &handle, const std::string &label) {
if (!handle) {
vkcv_log(LogLevel::WARNING, "Can't set debug label to invalid handle");
return;
}
setDebugObjectLabel(
m_Context.getDevice(),
vk::ObjectType::eDescriptorSet,
reinterpret_cast<uint64_t>(static_cast<VkDescriptorSet>(
m_DescriptorManager->getDescriptorSet(handle).vulkanHandle
)),
label
);
}
void Core::setDebugLabel(const SamplerHandle &handle, const std::string &label) {
if (!handle) {
vkcv_log(LogLevel::WARNING, "Can't set debug label to invalid handle");
return;
}
setDebugObjectLabel(
m_Context.getDevice(),
vk::ObjectType::eSampler,
reinterpret_cast<uint64_t>(static_cast<VkSampler>(
m_SamplerManager->getVulkanSampler(handle)
)),
label
);
}
void Core::setDebugLabel(const ImageHandle &handle, const std::string &label) {
if (!handle) {
vkcv_log(LogLevel::WARNING, "Can't set debug label to invalid handle");
return;
} else
if (handle.isSwapchainImage()) {
vkcv_log(LogLevel::WARNING, "Can't set debug label to swapchain image");
return;
}
setDebugObjectLabel(
m_Context.getDevice(),
vk::ObjectType::eImage,
reinterpret_cast<uint64_t>(static_cast<VkImage>(
m_ImageManager->getVulkanImage(handle)
)),
label
);
}
void Core::setDebugLabel(const CommandStreamHandle &handle, const std::string &label) {
if (!handle) {
vkcv_log(LogLevel::WARNING, "Can't set debug label to invalid handle");
return;
}
setDebugObjectLabel(
m_Context.getDevice(),
vk::ObjectType::eCommandBuffer,
reinterpret_cast<uint64_t>(static_cast<VkCommandBuffer>(
m_CommandStreamManager->getStreamCommandBuffer(handle)
)),
label
);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment