mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-25 07:05:48 +00:00
Enable vulkan shader debugging on a hidden config setting
This commit is contained in:
@@ -30,6 +30,13 @@
|
||||
|
||||
namespace rdcspv
|
||||
{
|
||||
class DebugAPIWrapper
|
||||
{
|
||||
public:
|
||||
virtual ~DebugAPIWrapper() {}
|
||||
virtual void AddDebugMessage(MessageCategory c, MessageSeverity sv, MessageSource src, rdcstr d) = 0;
|
||||
};
|
||||
|
||||
struct GlobalState
|
||||
{
|
||||
public:
|
||||
@@ -69,8 +76,8 @@ public:
|
||||
Debugger();
|
||||
~Debugger();
|
||||
virtual void Parse(const rdcarray<uint32_t> &spirvWords);
|
||||
ShaderDebugTrace *BeginDebug(const ShaderStage stage, const rdcstr &entryPoint,
|
||||
const rdcarray<SpecConstant> &specInfo,
|
||||
ShaderDebugTrace *BeginDebug(DebugAPIWrapper *apiWrapper, const ShaderStage stage,
|
||||
const rdcstr &entryPoint, const rdcarray<SpecConstant> &specInfo,
|
||||
const std::map<size_t, uint32_t> &instructionLines,
|
||||
uint32_t activeIndex);
|
||||
|
||||
@@ -83,6 +90,8 @@ private:
|
||||
virtual void PostParse();
|
||||
virtual void RegisterOp(Iter it);
|
||||
|
||||
DebugAPIWrapper *apiWrapper = NULL;
|
||||
|
||||
GlobalState global;
|
||||
rdcarray<ThreadState> workgroup;
|
||||
|
||||
@@ -90,6 +99,7 @@ private:
|
||||
rdcarray<size_t> instructionOffsets;
|
||||
|
||||
uint32_t activeLaneIndex = 0;
|
||||
ShaderStage stage;
|
||||
|
||||
int steps = 0;
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ Debugger::Debugger()
|
||||
|
||||
Debugger::~Debugger()
|
||||
{
|
||||
SAFE_DELETE(apiWrapper);
|
||||
}
|
||||
|
||||
void Debugger::Parse(const rdcarray<uint32_t> &spirvWords)
|
||||
@@ -48,7 +49,8 @@ void Debugger::Parse(const rdcarray<uint32_t> &spirvWords)
|
||||
Processor::Parse(spirvWords);
|
||||
}
|
||||
|
||||
ShaderDebugTrace *Debugger::BeginDebug(const ShaderStage stage, const rdcstr &entryPoint,
|
||||
ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *apiWrapper, const ShaderStage stage,
|
||||
const rdcstr &entryPoint,
|
||||
const rdcarray<SpecConstant> &specInfo,
|
||||
const std::map<size_t, uint32_t> &instructionLines,
|
||||
uint32_t activeIndex)
|
||||
@@ -56,6 +58,8 @@ ShaderDebugTrace *Debugger::BeginDebug(const ShaderStage stage, const rdcstr &en
|
||||
ShaderDebugTrace *ret = new ShaderDebugTrace;
|
||||
ret->debugger = this;
|
||||
this->activeLaneIndex = activeIndex;
|
||||
this->stage = stage;
|
||||
this->apiWrapper = apiWrapper;
|
||||
|
||||
int workgroupSize = stage == ShaderStage::Pixel ? 4 : 1;
|
||||
for(int i = 0; i < workgroupSize; i++)
|
||||
|
||||
@@ -275,7 +275,6 @@ private:
|
||||
|
||||
rdcarray<DebugMessage> GetDebugMessages();
|
||||
void AddDebugMessage(DebugMessage msg);
|
||||
void AddDebugMessage(MessageCategory c, MessageSeverity sv, MessageSource src, rdcstr d);
|
||||
|
||||
CaptureState m_State;
|
||||
bool m_AppControlledCapture = false;
|
||||
@@ -962,6 +961,8 @@ public:
|
||||
uint32_t GetQueueFamilyIndex() const { return m_QueueFamilyIdx; }
|
||||
bool ReleaseResource(WrappedVkRes *res);
|
||||
|
||||
void AddDebugMessage(MessageCategory c, MessageSeverity sv, MessageSource src, rdcstr d);
|
||||
|
||||
ReplayStatus Initialise(VkInitParams ¶ms, uint64_t sectionVersion, const ReplayOptions &opts);
|
||||
uint64_t GetLogVersion() { return m_SectionVersion; }
|
||||
void SetStructuredExport(uint64_t sectionVersion)
|
||||
|
||||
@@ -187,6 +187,11 @@ APIProperties VulkanReplay::GetAPIProperties()
|
||||
ret.rgpCapture =
|
||||
m_DriverInfo.vendor == GPUVendor::AMD && m_RGP != NULL && m_RGP->DriverSupportsInterop();
|
||||
|
||||
// Enable shader debugging if specified in the config
|
||||
rdcstr setting = strlower(RenderDoc::Inst().GetConfigSetting("vulkanShaderDebugging"));
|
||||
if(!strcmp(setting.c_str(), "true") || setting == "1")
|
||||
ret.shaderDebugging = true;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,20 @@
|
||||
#include "vk_core.h"
|
||||
#include "vk_replay.h"
|
||||
|
||||
class VulkanAPIWrapper : public rdcspv::DebugAPIWrapper
|
||||
{
|
||||
public:
|
||||
VulkanAPIWrapper(WrappedVulkan *vk) { m_pDriver = vk; }
|
||||
virtual void AddDebugMessage(MessageCategory c, MessageSeverity sv, MessageSource src,
|
||||
rdcstr d) override
|
||||
{
|
||||
m_pDriver->AddDebugMessage(c, sv, src, d);
|
||||
}
|
||||
|
||||
private:
|
||||
WrappedVulkan *m_pDriver = NULL;
|
||||
};
|
||||
|
||||
ShaderDebugTrace *VulkanReplay::DebugVertex(uint32_t eventId, uint32_t vertid, uint32_t instid,
|
||||
uint32_t idx)
|
||||
{
|
||||
@@ -49,11 +63,12 @@ ShaderDebugTrace *VulkanReplay::DebugVertex(uint32_t eventId, uint32_t vertid, u
|
||||
shader.GetReflection(entryPoint, state.graphics.pipeline);
|
||||
|
||||
shadRefl.PopulateDisassembly(shader.spirv);
|
||||
VulkanAPIWrapper *apiWrapper = new VulkanAPIWrapper(m_pDriver);
|
||||
|
||||
rdcspv::Debugger *debugger = new rdcspv::Debugger;
|
||||
debugger->Parse(shader.spirv.GetSPIRV());
|
||||
ShaderDebugTrace *ret =
|
||||
debugger->BeginDebug(ShaderStage::Vertex, entryPoint, spec, shadRefl.instructionLines, 0);
|
||||
ShaderDebugTrace *ret = debugger->BeginDebug(apiWrapper, ShaderStage::Vertex, entryPoint, spec,
|
||||
shadRefl.instructionLines, 0);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user