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:
baldurk
2022-12-27 13:39:44 +00:00
parent b5545d52f8
commit 0acb955e19
13 changed files with 151 additions and 63 deletions
+11 -6
View File
@@ -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;
+11 -3
View File
@@ -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)
+2 -1
View File
@@ -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");
}
+6
View File
@@ -1032,6 +1032,8 @@ rdcstr DoStringise(const ShaderEncoding &el)
STRINGISE_ENUM_CLASS_NAMED(SPIRVAsm, "SPIR-V Asm");
STRINGISE_ENUM_CLASS(HLSL);
STRINGISE_ENUM_CLASS(DXIL);
STRINGISE_ENUM_CLASS_NAMED(OpenGLSPIRV, "SPIR-V (OpenGL)");
STRINGISE_ENUM_CLASS_NAMED(OpenGLSPIRVAsm, "SPIR-V Asm (OpenGL)");
}
END_ENUM_STRINGISE();
}
@@ -1050,6 +1052,10 @@ rdcstr DoStringise(const KnownShaderTool &el)
STRINGISE_ENUM_CLASS_NAMED(dxcSPIRV, "dxc (SPIR-V)");
STRINGISE_ENUM_CLASS_NAMED(dxcDXIL, "dxc (DXIL)");
STRINGISE_ENUM_CLASS_NAMED(fxc, "fxc");
STRINGISE_ENUM_CLASS_NAMED(glslangValidatorGLSL_OpenGL, "glslang (GLSL to OpenGL SPIR-V)");
STRINGISE_ENUM_CLASS_NAMED(SPIRV_Cross_OpenGL, "SPIRV-Cross (OpenGL SPIR-V)");
STRINGISE_ENUM_CLASS_NAMED(spirv_as_OpenGL, "spirv-as (OpenGL SPIR-V)");
STRINGISE_ENUM_CLASS_NAMED(spirv_dis_OpenGL, "spirv-dis (OpenGL SPIR-V)");
}
END_ENUM_STRINGISE();
}
+88 -33
View File
@@ -1803,12 +1803,24 @@ DOCUMENT(R"(Identifies a shader encoding used to pass shader code to an API.
.. data:: SPIRV
SPIR-V binary shader, used by Vulkan and with an extension by OpenGL.
SPIR-V binary shader, as used by Vulkan. This format is technically not distinct from
:data:`OpenGLSPIRV` but is considered unique here since it really *should* have been a different
format, and introducing a separation allows better selection of tools automatically.
.. data:: SPIRVAsm
Canonical SPIR-V assembly form, used (indirectly via :data:`SPIRV`) by Vulkan and with an
extension by OpenGL.
Canonical SPIR-V assembly form, used (indirectly via :data:`SPIRV`) by Vulkan. See :data:`SPIRV`.
.. data:: OpenGLSPIRV
SPIR-V binary shader, as used by OpenGL. This format is technically not distinct from
:data:`VulkanSPIRV` but is considered unique here since it really *should* have been a different
format, and introducing a separation allows better selection of tools automatically.
.. data:: OpenGLSPIRVAsm
Canonical SPIR-V assembly form, used (indirectly via :data:`OpenGLSPIRV`) by OpenGL. See
:data:`OpenGLSPIRV` and note that it's artificially differentiated from :data:`SPIRVAsm`.
.. data:: HLSL
@@ -1830,6 +1842,8 @@ enum class ShaderEncoding : uint32_t
SPIRVAsm,
HLSL,
DXIL,
OpenGLSPIRV,
OpenGLSPIRVAsm,
Count,
};
@@ -1844,15 +1858,33 @@ DOCUMENT(R"(Identifies a particular known tool used for shader processing.
.. data:: SPIRV_Cross
`SPIRV-Cross <https://github.com/KhronosGroup/SPIRV-Cross>`_.
`SPIRV-Cross <https://github.com/KhronosGroup/SPIRV-Cross>`_
targetting normal Vulkan flavoured SPIR-V.
.. data:: SPIRV_Cross_OpenGL
`SPIRV-Cross <https://github.com/KhronosGroup/SPIRV-Cross>`_
targetting OpenGL extension flavoured SPIR-V.
.. data:: spirv_dis
`spirv-dis from SPIRV-Tools <https://github.com/KhronosGroup/SPIRV-Tools>`_.
`spirv-dis from SPIRV-Tools <https://github.com/KhronosGroup/SPIRV-Tools>`_
targetting normal Vulkan flavoured SPIR-V.
.. data:: spirv_dis_OpenGL
`spirv-dis from SPIRV-Tools <https://github.com/KhronosGroup/SPIRV-Tools>`_
targetting OpenGL extension flavoured SPIR-V.
.. data:: glslangValidatorGLSL
`glslang compiler (GLSL) <https://github.com/KhronosGroup/glslang>`_.
`glslang compiler (GLSL) <https://github.com/KhronosGroup/glslang>`_
targetting normal Vulkan flavoured SPIR-V.
.. data:: glslangValidatorGLSL_OpenGL
`glslang compiler (GLSL) <https://github.com/KhronosGroup/glslang>`_
targetting OpenGL extension flavoured SPIR-V.
.. data:: glslangValidatorHLSL
@@ -1860,11 +1892,18 @@ DOCUMENT(R"(Identifies a particular known tool used for shader processing.
.. data:: spirv_as
`spirv-as from SPIRV-Tools <https://github.com/KhronosGroup/SPIRV-Tools>`_.
`spirv-as from SPIRV-Tools <https://github.com/KhronosGroup/SPIRV-Tools>`_
targetting normal Vulkan flavoured SPIR-V.
.. data:: spirv_as_OpenGL
`spirv-as from SPIRV-Tools <https://github.com/KhronosGroup/SPIRV-Tools>`_
targetting OpenGL extension flavoured SPIR-V.
.. data:: dxcSPIRV
`DirectX Shader Compiler <https://github.com/microsoft/DirectXShaderCompiler>`_ with SPIR-V output.
`DirectX Shader Compiler <https://github.com/microsoft/DirectXShaderCompiler>`_ with Vulkan SPIR-V
output.
.. data:: dxcDXIL
@@ -1887,6 +1926,10 @@ enum class KnownShaderTool : uint32_t
dxcSPIRV,
dxcDXIL,
fxc,
glslangValidatorGLSL_OpenGL,
SPIRV_Cross_OpenGL,
spirv_as_OpenGL,
spirv_dis_OpenGL,
Count,
};
@@ -1908,14 +1951,18 @@ constexpr inline const char *ToolExecutable(KnownShaderTool tool)
// temporarily disable clang-format to make this more readable.
// Ideally we'd use a simple switch() but VS2015 doesn't support that :(.
// clang-format off
return tool == KnownShaderTool::SPIRV_Cross ? "spirv-cross" :
tool == KnownShaderTool::spirv_dis ? "spirv-dis" :
tool == KnownShaderTool::glslangValidatorGLSL ? "glslangValidator" :
tool == KnownShaderTool::glslangValidatorHLSL ? "glslangValidator" :
tool == KnownShaderTool::spirv_as ? "spirv-as" :
tool == KnownShaderTool::dxcSPIRV ? "dxc" :
tool == KnownShaderTool::dxcDXIL ? "dxc" :
tool == KnownShaderTool::fxc ? "fxc" :
return tool == KnownShaderTool::SPIRV_Cross ? "spirv-cross" :
tool == KnownShaderTool::SPIRV_Cross_OpenGL ? "spirv-cross" :
tool == KnownShaderTool::spirv_dis ? "spirv-dis" :
tool == KnownShaderTool::spirv_dis_OpenGL ? "spirv-dis" :
tool == KnownShaderTool::glslangValidatorGLSL ? "glslangValidator" :
tool == KnownShaderTool::glslangValidatorGLSL_OpenGL ? "glslangValidator" :
tool == KnownShaderTool::glslangValidatorHLSL ? "glslangValidator" :
tool == KnownShaderTool::spirv_as ? "spirv-as" :
tool == KnownShaderTool::spirv_as_OpenGL ? "spirv-as" :
tool == KnownShaderTool::dxcSPIRV ? "dxc" :
tool == KnownShaderTool::dxcDXIL ? "dxc" :
tool == KnownShaderTool::fxc ? "fxc" :
"";
// clang-format on
}
@@ -1933,14 +1980,18 @@ constexpr inline ShaderEncoding ToolInput(KnownShaderTool tool)
// temporarily disable clang-format to make this more readable.
// Ideally we'd use a simple switch() but VS2015 doesn't support that :(.
// clang-format off
return tool == KnownShaderTool::SPIRV_Cross ? ShaderEncoding::SPIRV :
tool == KnownShaderTool::spirv_dis ? ShaderEncoding::SPIRV :
tool == KnownShaderTool::glslangValidatorGLSL ? ShaderEncoding::GLSL :
tool == KnownShaderTool::glslangValidatorHLSL ? ShaderEncoding::HLSL :
tool == KnownShaderTool::spirv_as ? ShaderEncoding::SPIRVAsm :
tool == KnownShaderTool::dxcSPIRV ? ShaderEncoding::HLSL :
tool == KnownShaderTool::dxcDXIL ? ShaderEncoding::HLSL :
tool == KnownShaderTool::fxc ? ShaderEncoding::HLSL :
return tool == KnownShaderTool::SPIRV_Cross ? ShaderEncoding::SPIRV :
tool == KnownShaderTool::SPIRV_Cross_OpenGL ? ShaderEncoding::OpenGLSPIRV :
tool == KnownShaderTool::spirv_dis ? ShaderEncoding::SPIRV :
tool == KnownShaderTool::spirv_dis_OpenGL ? ShaderEncoding::OpenGLSPIRV :
tool == KnownShaderTool::glslangValidatorGLSL ? ShaderEncoding::GLSL :
tool == KnownShaderTool::glslangValidatorGLSL_OpenGL ? ShaderEncoding::GLSL :
tool == KnownShaderTool::glslangValidatorHLSL ? ShaderEncoding::HLSL :
tool == KnownShaderTool::spirv_as ? ShaderEncoding::SPIRVAsm :
tool == KnownShaderTool::spirv_as_OpenGL ? ShaderEncoding::OpenGLSPIRVAsm :
tool == KnownShaderTool::dxcSPIRV ? ShaderEncoding::HLSL :
tool == KnownShaderTool::dxcDXIL ? ShaderEncoding::HLSL :
tool == KnownShaderTool::fxc ? ShaderEncoding::HLSL :
ShaderEncoding::Unknown;
// clang-format on
}
@@ -1958,14 +2009,18 @@ constexpr inline ShaderEncoding ToolOutput(KnownShaderTool tool)
// temporarily disable clang-format to make this more readable.
// Ideally we'd use a simple switch() but VS2015 doesn't support that :(.
// clang-format off
return tool == KnownShaderTool::SPIRV_Cross ? ShaderEncoding::GLSL :
tool == KnownShaderTool::spirv_dis ? ShaderEncoding::SPIRVAsm :
tool == KnownShaderTool::glslangValidatorGLSL ? ShaderEncoding::SPIRV :
tool == KnownShaderTool::glslangValidatorHLSL ? ShaderEncoding::SPIRV :
tool == KnownShaderTool::spirv_as ? ShaderEncoding::SPIRV :
tool == KnownShaderTool::dxcSPIRV ? ShaderEncoding::SPIRV :
tool == KnownShaderTool::dxcDXIL ? ShaderEncoding::DXIL :
tool == KnownShaderTool::fxc ? ShaderEncoding::DXBC :
return tool == KnownShaderTool::SPIRV_Cross ? ShaderEncoding::GLSL :
tool == KnownShaderTool::SPIRV_Cross_OpenGL ? ShaderEncoding::GLSL :
tool == KnownShaderTool::spirv_dis ? ShaderEncoding::SPIRVAsm :
tool == KnownShaderTool::spirv_dis_OpenGL ? ShaderEncoding::OpenGLSPIRVAsm :
tool == KnownShaderTool::glslangValidatorGLSL ? ShaderEncoding::SPIRV :
tool == KnownShaderTool::glslangValidatorGLSL_OpenGL ? ShaderEncoding::OpenGLSPIRV :
tool == KnownShaderTool::glslangValidatorHLSL ? ShaderEncoding::SPIRV :
tool == KnownShaderTool::spirv_as ? ShaderEncoding::SPIRV :
tool == KnownShaderTool::spirv_as_OpenGL ? ShaderEncoding::OpenGLSPIRV :
tool == KnownShaderTool::dxcSPIRV ? ShaderEncoding::SPIRV :
tool == KnownShaderTool::dxcDXIL ? ShaderEncoding::DXIL :
tool == KnownShaderTool::fxc ? ShaderEncoding::DXBC :
ShaderEncoding::Unknown;
// clang-format on
}
@@ -1979,7 +2034,7 @@ DOCUMENT(R"(Check whether or not this is a human readable text representation.
constexpr inline bool IsTextRepresentation(ShaderEncoding encoding)
{
return encoding == ShaderEncoding::HLSL || encoding == ShaderEncoding::GLSL ||
encoding == ShaderEncoding::SPIRVAsm;
encoding == ShaderEncoding::SPIRVAsm || encoding == ShaderEncoding::OpenGLSPIRVAsm;
}
DOCUMENT(R"(A primitive topology used for processing vertex data.
+1 -1
View File
@@ -294,7 +294,7 @@ void main() {
compile(ShaderStage::Fragment, source, "main", refl, mapping);
if(testType == ShaderType::GLSPIRV)
CHECK(refl.encoding == ShaderEncoding::SPIRV);
CHECK(refl.encoding == ShaderEncoding::OpenGLSPIRV);
else
CHECK(refl.encoding == ShaderEncoding::GLSL);
+1 -1
View File
@@ -1195,7 +1195,7 @@ bool GLResourceManager::Serialise_InitialState(SerialiserType &ser, ResourceId i
const auto &shadDetails = m_Driver->m_Shaders[details.stageShaders[i]];
IsProgramSPIRV |= shadDetails.reflection->encoding == ShaderEncoding::SPIRV;
IsProgramSPIRV |= shadDetails.reflection->encoding == ShaderEncoding::OpenGLSPIRV;
GLuint shad = drv.glCreateShader(shadDetails.type);
+2 -2
View File
@@ -82,7 +82,7 @@ bool GLReplay::CreateOverlayProgram(GLuint Program, GLuint Pipeline, GLuint frag
const WrappedOpenGL::ShaderData &shadDetails =
m_pDriver->m_Shaders[pipeDetails.stageShaders[i]];
if(shadDetails.reflection->encoding == ShaderEncoding::SPIRV)
if(shadDetails.reflection->encoding == ShaderEncoding::OpenGLSPIRV)
HasSPIRVShaders = true;
else
HasGLSLShaders = true;
@@ -144,7 +144,7 @@ bool GLReplay::CreateOverlayProgram(GLuint Program, GLuint Pipeline, GLuint frag
const WrappedOpenGL::ShaderData &shadDetails =
m_pDriver->m_Shaders[progDetails.stageShaders[i]];
if(shadDetails.reflection->encoding == ShaderEncoding::SPIRV)
if(shadDetails.reflection->encoding == ShaderEncoding::OpenGLSPIRV)
HasSPIRVShaders = true;
else
HasGLSLShaders = true;
+2 -2
View File
@@ -492,7 +492,7 @@ void GLReplay::InitPostVSBuffers(uint32_t eventId)
}
}
if(vsRefl->encoding == ShaderEncoding::SPIRV)
if(vsRefl->encoding == ShaderEncoding::OpenGLSPIRV)
{
// SPIR-V path
vsOrigShader = stageShaders[0];
@@ -1189,7 +1189,7 @@ void GLReplay::InitPostVSBuffers(uint32_t eventId)
lastIndex = 2;
}
bool lastSPIRV = (lastRefl->encoding == ShaderEncoding::SPIRV);
bool lastSPIRV = (lastRefl->encoding == ShaderEncoding::OpenGLSPIRV);
RDCASSERT(lastRefl);
+7 -5
View File
@@ -570,11 +570,13 @@ static void ForAllProgramUniforms(SerialiserType *ser, CaptureState state,
// skip fetching or applying UBO bindings etc.
bool IsSrcProgramSPIRV = false;
for(size_t i = 0; i < 6; i++)
IsSrcProgramSPIRV |= srcStages.refls[i] && srcStages.refls[i]->encoding == ShaderEncoding::SPIRV;
IsSrcProgramSPIRV |=
srcStages.refls[i] && srcStages.refls[i]->encoding == ShaderEncoding::OpenGLSPIRV;
bool IsDstProgramSPIRV = false;
for(size_t i = 0; i < 6; i++)
IsDstProgramSPIRV |= dstStages.refls[i] && dstStages.refls[i]->encoding == ShaderEncoding::SPIRV;
IsDstProgramSPIRV |=
dstStages.refls[i] && dstStages.refls[i]->encoding == ShaderEncoding::OpenGLSPIRV;
RDCASSERTMSG("Expect both programs to be SPIR-V in ForAllProgramUniforms",
IsSrcProgramSPIRV == IsDstProgramSPIRV, IsSrcProgramSPIRV, IsDstProgramSPIRV);
@@ -1196,7 +1198,7 @@ bool CopyProgramAttribBindings(GLuint progsrc, GLuint progdst, ShaderReflection
{
// don't try to copy bindings for SPIR-V shaders. The queries by name may fail, and the bindings
// are immutable anyway
if(refl->encoding == ShaderEncoding::SPIRV)
if(refl->encoding == ShaderEncoding::OpenGLSPIRV)
return false;
// copy over attrib bindings
@@ -1218,7 +1220,7 @@ bool CopyProgramFragDataBindings(GLuint progsrc, GLuint progdst, ShaderReflectio
{
// don't try to copy bindings for SPIR-V shaders. The queries by name may fail, and the bindings
// are immutable anyway
if(refl->encoding == ShaderEncoding::SPIRV)
if(refl->encoding == ShaderEncoding::OpenGLSPIRV)
return false;
uint64_t used = 0;
@@ -1271,7 +1273,7 @@ bool SerialiseProgramBindings(SerialiserType &ser, CaptureState state,
// compatible way.
bool IsProgramSPIRV = false;
for(size_t i = 0; i < 6; i++)
IsProgramSPIRV |= stages.refls[i] && stages.refls[i]->encoding == ShaderEncoding::SPIRV;
IsProgramSPIRV |= stages.refls[i] && stages.refls[i]->encoding == ShaderEncoding::OpenGLSPIRV;
const bool hasVert = stages.refls[0] != NULL;
const bool hasFrag = stages.refls[5] != NULL;
+3 -3
View File
@@ -68,7 +68,7 @@ static bool CheckForSupport(ShaderEncoding encoding)
return true;
}
if(encoding == ShaderEncoding::SPIRV)
if(encoding == ShaderEncoding::SPIRV || encoding == ShaderEncoding::OpenGLSPIRV)
{
// TODO need to check if an AMD context is running
rdcstr amdspv = LocatePluginFile(pluginPath, amdspv_name);
@@ -104,7 +104,7 @@ static void GetEncodings(GraphicsAPI api, ShaderEncoding &primary, ShaderEncodin
else if(api == GraphicsAPI::OpenGL)
{
primary = ShaderEncoding::GLSL;
secondary = ShaderEncoding::SPIRV;
secondary = ShaderEncoding::OpenGLSPIRV;
}
else if(api == GraphicsAPI::Vulkan)
{
@@ -531,7 +531,7 @@ rdcstr Disassemble(ShaderEncoding encoding, ShaderStage stage, const bytebuf &sh
if(encoding == ShaderEncoding::DXBC)
return DisassembleDXBC(shaderBytes, target);
if(encoding == ShaderEncoding::SPIRV)
if(encoding == ShaderEncoding::SPIRV || encoding == ShaderEncoding::OpenGLSPIRV)
return DisassembleSPIRV(stage, shaderBytes, target);
if(encoding == ShaderEncoding::GLSL)
@@ -806,7 +806,8 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st
// set global properties
reflection.entryPoint = entryPoint;
reflection.stage = stage;
reflection.encoding = ShaderEncoding::SPIRV;
reflection.encoding =
sourceAPI == GraphicsAPI::OpenGL ? ShaderEncoding::OpenGLSPIRV : ShaderEncoding::SPIRV;
reflection.rawBytes.assign((byte *)m_SPIRV.data(), m_SPIRV.size() * sizeof(uint32_t));
CheckDebuggable(reflection.debugInfo.debuggable, reflection.debugInfo.debugStatus);
@@ -899,9 +900,15 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st
reflection.debugInfo.compiler = reflection.debugInfo.encoding == ShaderEncoding::HLSL
? KnownShaderTool::glslangValidatorHLSL
: KnownShaderTool::glslangValidatorGLSL;
if(sourceAPI == GraphicsAPI::OpenGL &&
reflection.debugInfo.compiler == KnownShaderTool::glslangValidatorGLSL)
reflection.debugInfo.compiler = KnownShaderTool::glslangValidatorGLSL_OpenGL;
break;
case Generator::SPIRVToolsAssembler:
reflection.debugInfo.compiler = KnownShaderTool::spirv_as;
reflection.debugInfo.compiler = sourceAPI == GraphicsAPI::OpenGL
? KnownShaderTool::spirv_as_OpenGL
: KnownShaderTool::spirv_as;
break;
case Generator::spiregg: reflection.debugInfo.compiler = KnownShaderTool::dxcSPIRV; break;
default: reflection.debugInfo.compiler = KnownShaderTool::Unknown; break;