Skip to content

Commit

Permalink
Also consider NonSemantic ExtInst in block_is_noop.
Browse files Browse the repository at this point in the history
  • Loading branch information
HansKristian-Work committed Jan 12, 2023
1 parent 9d8ef6b commit bcbe33a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 22 deletions.
14 changes: 2 additions & 12 deletions reference/shaders-no-opt/comp/loop-resolve-debug-semantics.gV.comp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

3 changes: 2 additions & 1 deletion spirv_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,8 @@ struct SPIRExtension : IVariant
SPV_AMD_shader_trinary_minmax,
SPV_AMD_gcn_shader,
NonSemanticDebugPrintf,
NonSemanticShaderDebugInfo
NonSemanticShaderDebugInfo,
NonSemanticGeneric
};

explicit SPIRExtension(Extension ext_)
Expand Down
24 changes: 16 additions & 8 deletions spirv_cross.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion spirv_glsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
Expand Down
2 changes: 2 additions & 0 deletions spirv_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit bcbe33a

Please sign in to comment.