Add simple way to add debug annotation in the middle of the command stream. Vulkan-only.

This commit is contained in:
Henrik Rydgård 2022-10-13 22:34:21 +02:00
parent 61e7c3e62c
commit 4d1da5859c
6 changed files with 32 additions and 1 deletions

View File

@ -1579,6 +1579,15 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c
}
break;
}
case VKRRenderCommand::DEBUG_ANNOTATION:
if (vulkan_->Extensions().EXT_debug_utils) {
VkDebugUtilsLabelEXT labelInfo{ VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT };
labelInfo.pLabelName = c.debugAnnotation.annotation;
vkCmdInsertDebugUtilsLabelEXT(cmd, &labelInfo);
}
break;
default:
ERROR_LOG(G3D, "Unimpl queue command");
}

View File

@ -38,6 +38,7 @@ enum class VKRRenderCommand : uint8_t {
DRAW_INDEXED,
PUSH_CONSTANTS,
SELF_DEPENDENCY_BARRIER,
DEBUG_ANNOTATION,
NUM_RENDER_COMMANDS,
};
@ -136,6 +137,9 @@ struct VkRenderData {
uint8_t size;
uint8_t data[40]; // Should be enough for now.
} push;
struct {
const char *annotation;
} debugAnnotation;
};
};

View File

@ -429,6 +429,13 @@ public:
curRenderStep_->render.numDraws++;
}
// These can be useful both when inspecting in RenderDoc, and when manually inspecting recorded commands
// in the debugger.
void DebugAnnotate(const char *annotation) {
VkRenderData data{ VKRRenderCommand::DEBUG_ANNOTATION };
data.debugAnnotation.annotation = annotation;
}
VkCommandBuffer GetInitCmd();
// Gets a frame-unique ID of the current step being recorded. Can be used to figure out

View File

@ -367,6 +367,8 @@ public:
VKContext(VulkanContext *vulkan);
virtual ~VKContext();
void DebugAnnotate(const char *annotation) override;
const DeviceCaps &GetDeviceCaps() const override {
return caps_;
}
@ -1010,6 +1012,8 @@ VkDescriptorSet VKContext::GetOrCreateDescriptorSet(VkBuffer buf) {
return VK_NULL_HANDLE;
}
vulkan_->SetDebugName(descSet, VK_OBJECT_TYPE_DESCRIPTOR_SET, "(thin3d desc set)");
VkDescriptorBufferInfo bufferDesc;
bufferDesc.buffer = buf;
bufferDesc.offset = 0;
@ -1651,4 +1655,8 @@ uint64_t VKContext::GetNativeObject(NativeObject obj, void *srcObject) {
}
}
void VKContext::DebugAnnotate(const char *annotation) {
renderManager_.DebugAnnotate(annotation);
}
} // namespace Draw

View File

@ -616,6 +616,8 @@ public:
virtual void SetErrorCallback(ErrorCallbackFn callback, void *userdata) {}
virtual void DebugAnnotate(const char *annotation) {}
// Partial pipeline state, used to create pipelines. (in practice, in d3d11 they'll use the native state objects directly).
// TODO: Possibly ditch these and just put the descs directly in PipelineDesc since only D3D11 benefits.
virtual DepthStencilState *CreateDepthStencilState(const DepthStencilStateDesc &desc) = 0;

View File

@ -120,8 +120,9 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu
bool isModeClear = id.Bit(FS_BIT_CLEARMODE);
const char *shading = "";
if (compat.glslES30 || compat.shaderLanguage == ShaderLanguage::GLSL_VULKAN)
if (compat.glslES30 || compat.shaderLanguage == ShaderLanguage::GLSL_VULKAN) {
shading = doFlatShading ? "flat" : "";
}
bool useDiscardStencilBugWorkaround = id.Bit(FS_BIT_NO_DEPTH_CANNOT_DISCARD_STENCIL);