Also consider NonSemantic ExtInst in block_is_noop.

This commit is contained in:
Hans-Kristian Arntzen 2023-01-12 12:41:19 +01:00
parent 9d8ef6b36c
commit bcbe33ad11
5 changed files with 24 additions and 22 deletions

View File

@ -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;
}
}

View File

@ -644,7 +644,8 @@ struct SPIRExtension : IVariant
SPV_AMD_shader_trinary_minmax,
SPV_AMD_gcn_shader,
NonSemanticDebugPrintf,
NonSemanticShaderDebugInfo
NonSemanticShaderDebugInfo,
NonSemanticGeneric
};
explicit SPIRExtension(Extension ext_)

View File

@ -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;
}

View File

@ -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.
}

View File

@ -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.