Skip to content

Draft: Initial debug utils naming implementation #1419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/vsg/state/GraphicsPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace vsg

struct Implementation : public Inherit<Object, Implementation>
{
Implementation(Context& context, Device* device, const RenderPass* renderPass, const PipelineLayout* pipelineLayout, const ShaderStages& shaderStages, const GraphicsPipelineStates& pipelineStates, uint32_t subpass);
Implementation(Context& context, Device* device, const RenderPass* renderPass, const PipelineLayout* pipelineLayout, const ShaderStages& shaderStages, const GraphicsPipelineStates& pipelineStates, uint32_t subpass, const GraphicsPipeline& parent);

virtual ~Implementation();

Expand Down
2 changes: 1 addition & 1 deletion include/vsg/state/PipelineLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace vsg

struct Implementation : public Inherit<Object, Implementation>
{
Implementation(Device* device, const DescriptorSetLayouts& descriptorSetLayouts, const PushConstantRanges& pushConstantRanges, VkPipelineLayoutCreateFlags flags = 0);
Implementation(Device* device, const DescriptorSetLayouts& descriptorSetLayouts, const PushConstantRanges& pushConstantRanges, const PipelineLayout& parent, VkPipelineLayoutCreateFlags flags = 0);

virtual ~Implementation();

Expand Down
2 changes: 2 additions & 0 deletions src/vsg/io/glsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ ref_ptr<Object> glsl::createShader(const Path& found_filename, std::string& sour

auto sm = ShaderModule::create(source);

sm->setValue("DebugUtilsName", found_filename.string());

if (stageFlagBits != VK_SHADER_STAGE_ALL)
{
return ShaderStage::create(stageFlagBits, "main", sm);
Expand Down
19 changes: 17 additions & 2 deletions src/vsg/state/GraphicsPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,15 @@ void GraphicsPipeline::compile(Context& context)
shaderStage->compile(context);
}

_implementation[viewID] = GraphicsPipeline::Implementation::create(context, context.device, context.renderPass, layout, stages, combined_pipelineStates, subpass);
_implementation[viewID] = GraphicsPipeline::Implementation::create(context, context.device, context.renderPass, layout, stages, combined_pipelineStates, subpass, *this);
}
}

////////////////////////////////////////////////////////////////////////
//
// GraphicsPipeline::Implementation
//
GraphicsPipeline::Implementation::Implementation(Context& context, Device* device, const RenderPass* renderPass, const PipelineLayout* pipelineLayout, const ShaderStages& shaderStages, const GraphicsPipelineStates& pipelineStates, uint32_t subpass) :
GraphicsPipeline::Implementation::Implementation(Context& context, Device* device, const RenderPass* renderPass, const PipelineLayout* pipelineLayout, const ShaderStages& shaderStages, const GraphicsPipelineStates& pipelineStates, uint32_t subpass, const GraphicsPipeline& parent) :
_pipelineStates(pipelineStates),
_device(device)
{
Expand Down Expand Up @@ -238,6 +238,21 @@ GraphicsPipeline::Implementation::Implementation(Context& context, Device* devic
{
throw Exception{"Error: vsg::GraphicsPipeline failed to create VkPipeline.", result};
}

if (isExtensionSupported(VK_EXT_DEBUG_UTILS_EXTENSION_NAME) && device->getInstance()->getExtensions()->vkSetDebugUtilsObjectNameEXT)
{
std::string name = "A GraphicsPipeline";
parent.getValue("DebugUtilsName", name);
std::stringstream nameStream;
nameStream << name << " (" << std::hex << _pipeline << ")";
name = nameStream.str();
VkDebugUtilsObjectNameInfoEXT nameInfo = {};
nameInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
nameInfo.objectType = VK_OBJECT_TYPE_PIPELINE;
nameInfo.objectHandle = reinterpret_cast<uint64_t>(_pipeline);
nameInfo.pObjectName = name.c_str();
device->getInstance()->getExtensions()->vkSetDebugUtilsObjectNameEXT(*device, &nameInfo);
}
}

GraphicsPipeline::Implementation::~Implementation()
Expand Down
19 changes: 17 additions & 2 deletions src/vsg/state/PipelineLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ void PipelineLayout::compile(Context& context)
{
if (dsl) dsl->compile(context);
}
_implementation[context.deviceID] = PipelineLayout::Implementation::create(context.device, setLayouts, pushConstantRanges, flags);
_implementation[context.deviceID] = PipelineLayout::Implementation::create(context.device, setLayouts, pushConstantRanges, *this, flags);
}
}

//////////////////////////////////////
//
// PipelineLayout::Implementation
//
PipelineLayout::Implementation::Implementation(Device* device, const DescriptorSetLayouts& descriptorSetLayouts, const PushConstantRanges& pushConstantRanges, VkPipelineLayoutCreateFlags flags) :
PipelineLayout::Implementation::Implementation(Device* device, const DescriptorSetLayouts& descriptorSetLayouts, const PushConstantRanges& pushConstantRanges, const PipelineLayout& parent, VkPipelineLayoutCreateFlags flags) :
_device(device)
{
std::vector<VkDescriptorSetLayout> layouts;
Expand All @@ -140,6 +140,21 @@ PipelineLayout::Implementation::Implementation(Device* device, const DescriptorS
{
throw Exception{"Error: Failed to create PipelineLayout.", result};
}

if (isExtensionSupported(VK_EXT_DEBUG_UTILS_EXTENSION_NAME) && device->getInstance()->getExtensions()->vkSetDebugUtilsObjectNameEXT)
{
std::string name = "A PipelineLayout";
parent.getValue("DebugUtilsName", name);
std::stringstream nameStream;
nameStream << name << " (" << std::hex << _pipelineLayout << ")";
name = nameStream.str();
VkDebugUtilsObjectNameInfoEXT nameInfo = {};
nameInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
nameInfo.objectType = VK_OBJECT_TYPE_PIPELINE_LAYOUT;
nameInfo.objectHandle = reinterpret_cast<uint64_t>(_pipelineLayout);
nameInfo.pObjectName = name.c_str();
device->getInstance()->getExtensions()->vkSetDebugUtilsObjectNameEXT(*device, &nameInfo);
}
}

PipelineLayout::Implementation::~Implementation()
Expand Down
29 changes: 29 additions & 0 deletions src/vsg/state/ShaderModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,35 @@ ShaderModule::Implementation::Implementation(Device* device, ShaderModule* shade
{
throw Exception{"Error: vsg::ShaderModule::create(...) failed to create shader module.", result};
}

if (isExtensionSupported(VK_EXT_DEBUG_UTILS_EXTENSION_NAME) && device->getInstance()->getExtensions()->vkSetDebugUtilsObjectNameEXT)
{
std::string name = "A shader module";
shaderModule->getValue("DebugUtilsName", name);
std::stringstream nameStream;
nameStream << name;
if (shaderModule->hints && !shaderModule->hints->defines.empty())
{
nameStream << " with defines: ";
for (const auto& define : shaderModule->hints->defines)
{
nameStream << define << " ";
}
}
else
{
nameStream << " ";
}
nameStream << "(" << std::hex << _shaderModule << ")";
name = nameStream.str();

VkDebugUtilsObjectNameInfoEXT nameInfo = {};
nameInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
nameInfo.objectType = VK_OBJECT_TYPE_SHADER_MODULE;
nameInfo.objectHandle = reinterpret_cast<uint64_t>(_shaderModule);
nameInfo.pObjectName = name.c_str();
device->getInstance()->getExtensions()->vkSetDebugUtilsObjectNameEXT(*device, &nameInfo);
}
}

ShaderModule::Implementation::~Implementation()
Expand Down
Loading
Loading