I read through the documentation of Renderdoc:
On Vulkan RenderDoc supports source-level debugging via the NonSemantic.Shader.DebugInfo.100 extended instruction set. This information can be generated by glslang using -gVS to specify debug information, and by dxc using -fspv-debug=vulkan-with-source. In both cases this will embed the necessary debug information in the SPIR-V blob to debug at source level.
So I added the following options to my dxc compiler:
std::vector<LPCWSTR> arguments;
//COMPILATION ARGUMENTS
arguments.push_back(L"-spirv");
arguments.push_back(L"-fspv-target-env=vulkan1.3");
arguments.push_back(L"-fspv-debug=vulkan-with-source"); //Include source code info
//put your shader name here
arguments.push_back(wstr.data());
arguments.push_back(DXC_ARG_WARNINGS_ARE_ERRORS); //-WX
arguments.push_back(DXC_ARG_DEBUG); //-Zi
arguments.push_back(DXC_ARG_PACK_MATRIX_COLUMN_MAJOR); //-Zpc
arguments.push_back(DXC_ARG_SKIP_OPTIMIZATIONS); //
arguments.push_back(L"-HV"); //hlsl version
arguments.push_back(L"2021");
arguments.push_back(L"-T"); //target stage
switch (stage)
{
case VK_SHADER_STAGE_VERTEX_BIT:
arguments.push_back(L"vs_6_0");
break;
case VK_SHADER_STAGE_FRAGMENT_BIT:
arguments.push_back(L"ps_6_0");
break;
default:
throw std::runtime_error("Unknown shader stage!");
}
arguments.push_back(L"-E"); //entry point
arguments.push_back(L"main");
ComPtr<IDxcResult> compile_result;
hres = dxc_compiler->Compile(&src_buffer, arguments.data(), (uint32_t) arguments.size(), nullptr, IID_PPV_ARGS(&compile_result));
But I still can’t debug at HLSL level: “Go to source” option is gray.
Is this caused by not having a disassembler in Renderdoc? It seems like I don’t have a disassembler to disassemble from spirv to hlsl. If it is, which executable I’m supposed to choose to do so?