summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Kristian Arntzen <post@arntzen-software.no>2023-01-12 12:41:19 +0100
committerHans-Kristian Arntzen <post@arntzen-software.no>2023-01-12 12:41:53 +0100
commitbcbe33ad11512b67662490ecddec16b6aa342836 (patch)
tree7292628d7f03bc38f8f9c7ad796f022248e7d496
parent9d8ef6b36c512a0a5c13290eef92836c6cb42759 (diff)
downloadSPIRV-Cross-bcbe33ad11512b67662490ecddec16b6aa342836.tar.gz
SPIRV-Cross-bcbe33ad11512b67662490ecddec16b6aa342836.tar.bz2
SPIRV-Cross-bcbe33ad11512b67662490ecddec16b6aa342836.zip
Also consider NonSemantic ExtInst in block_is_noop.
-rw-r--r--reference/shaders-no-opt/comp/loop-resolve-debug-semantics.gV.comp14
-rw-r--r--spirv_common.hpp3
-rw-r--r--spirv_cross.cpp24
-rw-r--r--spirv_glsl.cpp3
-rw-r--r--spirv_parser.cpp2
5 files changed, 24 insertions, 22 deletions
diff --git a/reference/shaders-no-opt/comp/loop-resolve-debug-semantics.gV.comp b/reference/shaders-no-opt/comp/loop-resolve-debug-semantics.gV.comp
index 0d72cc1d..8b6a0321 100644
--- a/reference/shaders-no-opt/comp/loop-resolve-debug-semantics.gV.comp
+++ b/reference/shaders-no-opt/comp/loop-resolve-debug-semantics.gV.comp
@@ -8,19 +8,9 @@ layout(binding = 0, std430) buffer SSBO
void main()
{
- int i = 0;
- for (;;)
+ for (int i = 0; i < 4; i++)
{
- if (i < 4)
- {
- _64.v[i] += 10;
- i++;
- continue;
- }
- else
- {
- break;
- }
+ _64.v[i] += 10;
}
}
diff --git a/spirv_common.hpp b/spirv_common.hpp
index 71b1eada..ba420e1d 100644
--- a/spirv_common.hpp
+++ b/spirv_common.hpp
@@ -644,7 +644,8 @@ struct SPIRExtension : IVariant
SPV_AMD_shader_trinary_minmax,
SPV_AMD_gcn_shader,
NonSemanticDebugPrintf,
- NonSemanticShaderDebugInfo
+ NonSemanticShaderDebugInfo,
+ NonSemanticGeneric
};
explicit SPIRExtension(Extension ext_)
diff --git a/spirv_cross.cpp b/spirv_cross.cpp
index e55de88c..a126c287 100644
--- a/spirv_cross.cpp
+++ b/spirv_cross.cpp
@@ -1481,18 +1481,26 @@ bool Compiler::block_is_noop(const SPIRBlock &block) const
switch (op)
{
// Non-Semantic instructions.
- case OpNop:
- case OpSourceContinued:
- case OpSource:
- case OpSourceExtension:
- case OpName:
- case OpMemberName:
- case OpString:
case OpLine:
case OpNoLine:
- case OpModuleProcessed:
break;
+ case OpExtInst:
+ {
+ auto *ops = stream(i);
+ auto ext = get<SPIRExtension>(ops[2]).ext;
+
+ bool ext_is_nonsemantic_only =
+ ext == SPIRExtension::NonSemanticShaderDebugInfo ||
+ ext == SPIRExtension::SPV_debug_info ||
+ ext == SPIRExtension::NonSemanticGeneric;
+
+ if (!ext_is_nonsemantic_only)
+ return false;
+
+ break;
+ }
+
default:
return false;
}
diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp
index 19ad07e7..6ec2c7a6 100644
--- a/spirv_glsl.cpp
+++ b/spirv_glsl.cpp
@@ -13320,7 +13320,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 ||
- ext == SPIRExtension::NonSemanticShaderDebugInfo)
+ ext == SPIRExtension::NonSemanticShaderDebugInfo ||
+ ext == SPIRExtension::NonSemanticGeneric)
{
break; // Ignore SPIR-V debug information extended instructions.
}
diff --git a/spirv_parser.cpp b/spirv_parser.cpp
index 39bd1adf..01c2e381 100644
--- a/spirv_parser.cpp
+++ b/spirv_parser.cpp
@@ -295,6 +295,8 @@ void Parser::parse(const Instruction &instruction)
spirv_ext = SPIRExtension::NonSemanticDebugPrintf;
else if (ext == "NonSemantic.Shader.DebugInfo.100")
spirv_ext = SPIRExtension::NonSemanticShaderDebugInfo;
+ else if (ext.find("NonSemantic.") == 0)
+ spirv_ext = SPIRExtension::NonSemanticGeneric;
set<SPIRExtension>(id, spirv_ext);
// Other SPIR-V extensions which have ExtInstrs are currently not supported.