From e8a22a7cf655c1d259973de350e872bfc7aa606b Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Tue, 8 Nov 2022 12:14:51 +0100 Subject: [PATCH] Handle ShaderDebugInfo non-semantic extension. --- spirv_common.hpp | 3 ++- spirv_cross.cpp | 2 +- spirv_glsl.cpp | 3 ++- spirv_parser.cpp | 22 +++++++++++++--------- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/spirv_common.hpp b/spirv_common.hpp index 32f91c72..71b1eada 100644 --- a/spirv_common.hpp +++ b/spirv_common.hpp @@ -643,7 +643,8 @@ struct SPIRExtension : IVariant SPV_AMD_shader_explicit_vertex_parameter, SPV_AMD_shader_trinary_minmax, SPV_AMD_gcn_shader, - NonSemanticDebugPrintf + NonSemanticDebugPrintf, + NonSemanticShaderDebugInfo }; explicit SPIRExtension(Extension ext_) diff --git a/spirv_cross.cpp b/spirv_cross.cpp index 3b8bc87b..77bb0819 100644 --- a/spirv_cross.cpp +++ b/spirv_cross.cpp @@ -725,7 +725,7 @@ bool Compiler::InterfaceVariableAccessHandler::handle(Op opcode, const uint32_t case OpExtInst: { - if (length < 5) + if (length < 3) return false; auto &extension_set = compiler.get(args[2]); switch (extension_set.ext) diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp index 31af3b2d..4d2254f9 100644 --- a/spirv_glsl.cpp +++ b/spirv_glsl.cpp @@ -13283,7 +13283,8 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) { emit_spv_amd_gcn_shader_op(ops[0], ops[1], ops[3], &ops[4], length - 4); } - else if (ext == SPIRExtension::SPV_debug_info) + else if (ext == SPIRExtension::SPV_debug_info || + ext == SPIRExtension::NonSemanticShaderDebugInfo) { break; // Ignore SPIR-V debug information extended instructions. } diff --git a/spirv_parser.cpp b/spirv_parser.cpp index 49eb1933..39bd1adf 100644 --- a/spirv_parser.cpp +++ b/spirv_parser.cpp @@ -275,24 +275,28 @@ void Parser::parse(const Instruction &instruction) case OpExtInstImport: { uint32_t id = ops[0]; + + SPIRExtension::Extension spirv_ext = SPIRExtension::Unsupported; + auto ext = extract_string(ir.spirv, instruction.offset + 1); if (ext == "GLSL.std.450") - set(id, SPIRExtension::GLSL); + spirv_ext = SPIRExtension::GLSL; else if (ext == "DebugInfo") - set(id, SPIRExtension::SPV_debug_info); + spirv_ext = SPIRExtension::SPV_debug_info; else if (ext == "SPV_AMD_shader_ballot") - set(id, SPIRExtension::SPV_AMD_shader_ballot); + spirv_ext = SPIRExtension::SPV_AMD_shader_ballot; else if (ext == "SPV_AMD_shader_explicit_vertex_parameter") - set(id, SPIRExtension::SPV_AMD_shader_explicit_vertex_parameter); + spirv_ext = SPIRExtension::SPV_AMD_shader_explicit_vertex_parameter; else if (ext == "SPV_AMD_shader_trinary_minmax") - set(id, SPIRExtension::SPV_AMD_shader_trinary_minmax); + spirv_ext = SPIRExtension::SPV_AMD_shader_trinary_minmax; else if (ext == "SPV_AMD_gcn_shader") - set(id, SPIRExtension::SPV_AMD_gcn_shader); + spirv_ext = SPIRExtension::SPV_AMD_gcn_shader; else if (ext == "NonSemantic.DebugPrintf") - set(id, SPIRExtension::NonSemanticDebugPrintf); - else - set(id, SPIRExtension::Unsupported); + spirv_ext = SPIRExtension::NonSemanticDebugPrintf; + else if (ext == "NonSemantic.Shader.DebugInfo.100") + spirv_ext = SPIRExtension::NonSemanticShaderDebugInfo; + set(id, spirv_ext); // Other SPIR-V extensions which have ExtInstrs are currently not supported. break;