mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-23 06:05:45 +00:00
Create virtual distinction between Vulkan & GL SPIR-V. Closes #2798
* This distinction unfortunately does not exist in SPIR-V so we have to carry around this metadata ourselves. Rather than allowing free specification of tools based on API, instead pretend that Vulkan and GL SPIR-V are separate format, and duplicate all SPIR-V tools to handle "both" types. This allows appropriate tool selection based on the encoding.
This commit is contained in:
@@ -694,13 +694,17 @@ rdcstr ShaderProcessingTool::DefaultArguments() const
|
||||
{
|
||||
if(tool == KnownShaderTool::SPIRV_Cross)
|
||||
return "--vulkan-semantics --entry {entry_point} --stage {glsl_stage4}";
|
||||
else if(tool == KnownShaderTool::spirv_dis)
|
||||
else if(tool == KnownShaderTool::SPIRV_Cross_OpenGL)
|
||||
return "--entry {entry_point} --stage {glsl_stage4}";
|
||||
else if(tool == KnownShaderTool::spirv_dis || tool == KnownShaderTool::spirv_dis_OpenGL)
|
||||
return "--no-color";
|
||||
else if(tool == KnownShaderTool::glslangValidatorGLSL)
|
||||
return "-g -V -S {glsl_stage4}";
|
||||
else if(tool == KnownShaderTool::glslangValidatorGLSL_OpenGL)
|
||||
return "-g -G -S {glsl_stage4}";
|
||||
else if(tool == KnownShaderTool::glslangValidatorHLSL)
|
||||
return "-D -g -V -S {glsl_stage4} -e {entry_point}";
|
||||
else if(tool == KnownShaderTool::spirv_as)
|
||||
else if(tool == KnownShaderTool::spirv_as || tool == KnownShaderTool::spirv_as_OpenGL)
|
||||
return "";
|
||||
else if(tool == KnownShaderTool::dxcSPIRV)
|
||||
return "-T {hlsl_stage2}_6_0 -E {entry_point} -spirv";
|
||||
@@ -714,15 +718,16 @@ rdcstr ShaderProcessingTool::DefaultArguments() const
|
||||
|
||||
rdcstr ShaderProcessingTool::IOArguments() const
|
||||
{
|
||||
if(tool == KnownShaderTool::SPIRV_Cross)
|
||||
if(tool == KnownShaderTool::SPIRV_Cross || tool == KnownShaderTool::SPIRV_Cross_OpenGL)
|
||||
return "--output {output_file} {input_file}";
|
||||
else if(tool == KnownShaderTool::spirv_dis)
|
||||
else if(tool == KnownShaderTool::spirv_dis || tool == KnownShaderTool::spirv_dis_OpenGL)
|
||||
return "-o {output_file} {input_file}";
|
||||
else if(tool == KnownShaderTool::glslangValidatorGLSL)
|
||||
else if(tool == KnownShaderTool::glslangValidatorGLSL ||
|
||||
tool == KnownShaderTool::glslangValidatorGLSL_OpenGL)
|
||||
return "-o {output_file} {input_file}";
|
||||
else if(tool == KnownShaderTool::glslangValidatorHLSL)
|
||||
return "-o {output_file} {input_file}";
|
||||
else if(tool == KnownShaderTool::spirv_as)
|
||||
else if(tool == KnownShaderTool::spirv_as || tool == KnownShaderTool::spirv_as_OpenGL)
|
||||
return "-o {output_file} {input_file}";
|
||||
else if(tool == KnownShaderTool::dxcSPIRV)
|
||||
return "-Fo {output_file} {input_file}";
|
||||
|
||||
@@ -1109,7 +1109,8 @@ void PipelineStateViewer::SetupShaderEditButton(QToolButton *button, ResourceId
|
||||
{
|
||||
QString label = tr("Edit Generated Stub");
|
||||
|
||||
if(shaderDetails->encoding == ShaderEncoding::SPIRV)
|
||||
if(shaderDetails->encoding == ShaderEncoding::SPIRV ||
|
||||
shaderDetails->encoding == ShaderEncoding::OpenGLSPIRV)
|
||||
label = tr("Edit Pseudocode");
|
||||
|
||||
QAction *action = new QAction(label, menu);
|
||||
@@ -1120,7 +1121,8 @@ void PipelineStateViewer::SetupShaderEditButton(QToolButton *button, ResourceId
|
||||
QString entry;
|
||||
QString src;
|
||||
|
||||
if(shaderDetails->encoding == ShaderEncoding::SPIRV)
|
||||
if(shaderDetails->encoding == ShaderEncoding::SPIRV ||
|
||||
shaderDetails->encoding == ShaderEncoding::OpenGLSPIRV)
|
||||
{
|
||||
m_Ctx.Replay().AsyncInvoke([this, pipelineId, shaderId, shaderDetails](IReplayController *r) {
|
||||
rdcstr disasm = r->DisassembleShader(pipelineId, shaderDetails, "");
|
||||
@@ -1516,8 +1518,10 @@ bool PipelineStateViewer::SaveShaderFile(const ShaderReflection *shader)
|
||||
case ShaderEncoding::DXBC: filter = tr("DXBC Shader files (*.dxbc)"); break;
|
||||
case ShaderEncoding::HLSL: filter = tr("HLSL files (*.hlsl)"); break;
|
||||
case ShaderEncoding::GLSL: filter = tr("GLSL files (*.glsl)"); break;
|
||||
case ShaderEncoding::SPIRV: filter = tr("SPIR-V files (*.spv)"); break;
|
||||
case ShaderEncoding::SPIRVAsm: filter = tr("SPIR-V assembly files (*.spvasm)"); break;
|
||||
case ShaderEncoding::SPIRV:
|
||||
case ShaderEncoding::OpenGLSPIRV: filter = tr("SPIR-V files (*.spv)"); break;
|
||||
case ShaderEncoding::SPIRVAsm:
|
||||
case ShaderEncoding::OpenGLSPIRVAsm: filter = tr("SPIR-V assembly files (*.spvasm)"); break;
|
||||
case ShaderEncoding::DXIL: filter = tr("DXIL Shader files (*.dxbc)"); break;
|
||||
case ShaderEncoding::Unknown:
|
||||
case ShaderEncoding::Count: filter = tr("All files (*.*)"); break;
|
||||
|
||||
@@ -446,7 +446,7 @@ void ShaderViewer::debugShader(const ShaderBindpointMapping *bind, const ShaderR
|
||||
// add any custom decompiling tools we have after the first one
|
||||
for(const ShaderProcessingTool &d : m_Ctx.Config().ShaderProcessors)
|
||||
{
|
||||
if(d.input == m_ShaderDetails->encoding)
|
||||
if(d.input == m_ShaderDetails->encoding && IsTextRepresentation(d.output))
|
||||
targetNames << targetName(d);
|
||||
}
|
||||
}
|
||||
@@ -5391,7 +5391,7 @@ float2 RD_SelectedRange();
|
||||
|
||||
)");
|
||||
}
|
||||
else if(encoding == ShaderEncoding::SPIRVAsm)
|
||||
else if(encoding == ShaderEncoding::SPIRVAsm || encoding == ShaderEncoding::OpenGLSPIRVAsm)
|
||||
{
|
||||
text = lit("; Can't insert snippets for SPIR-V ASM");
|
||||
}
|
||||
@@ -5417,7 +5417,7 @@ SamplerState linearSampler : register(RD_LINEAR_SAMPLER_BINDING);
|
||||
|
||||
)"));
|
||||
}
|
||||
else
|
||||
else if(encoding == ShaderEncoding::GLSL)
|
||||
{
|
||||
insertSnippet(lit(R"(
|
||||
|
||||
@@ -5435,6 +5435,10 @@ layout(binding = RD_LINEAR_SAMPLER_BINDING) uniform sampler linearSampler;
|
||||
/////////////////////////////////////
|
||||
)"));
|
||||
}
|
||||
else if(encoding == ShaderEncoding::SPIRVAsm || encoding == ShaderEncoding::OpenGLSPIRVAsm)
|
||||
{
|
||||
insertSnippet(lit("; Can't insert snippets for SPIR-V ASM"));
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderViewer::snippet_resources()
|
||||
@@ -5538,6 +5542,10 @@ layout (binding = RD_UINT_2DMS_BINDING) uniform usampler2DMS texUInt2DMS;
|
||||
/////////////////////////////////////
|
||||
)"));
|
||||
}
|
||||
else if(encoding == ShaderEncoding::SPIRVAsm || encoding == ShaderEncoding::OpenGLSPIRVAsm)
|
||||
{
|
||||
insertSnippet(lit("; Can't insert snippets for SPIR-V ASM"));
|
||||
}
|
||||
}
|
||||
|
||||
bool ShaderViewer::eventFilter(QObject *watched, QEvent *event)
|
||||
|
||||
@@ -60,6 +60,7 @@ static QMap<QString, ShaderEncoding> encodingExtensions = {
|
||||
{lit("glsl"), ShaderEncoding::GLSL},
|
||||
{lit("frag"), ShaderEncoding::GLSL},
|
||||
{lit("spvasm"), ShaderEncoding::SPIRVAsm},
|
||||
{lit("spvasm"), ShaderEncoding::OpenGLSPIRVAsm},
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(Following);
|
||||
@@ -4537,7 +4538,7 @@ void TextureViewer::on_customCreate_clicked()
|
||||
" color_out = vec4(0,0,0,1);\n"
|
||||
"}\n");
|
||||
}
|
||||
else if(enc == ShaderEncoding::SPIRVAsm)
|
||||
else if(enc == ShaderEncoding::SPIRVAsm || enc == ShaderEncoding::OpenGLSPIRVAsm)
|
||||
{
|
||||
src = lit("; SPIR-V");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user