[D3D12] Tiny HLSL control flow cleanup
This commit is contained in:
parent
0900036795
commit
b0993fa3f0
|
@ -451,13 +451,13 @@ void HlslShaderTranslator::ProcessExecInstructionBegin(
|
||||||
|
|
||||||
void HlslShaderTranslator::ProcessExecInstructionEnd(
|
void HlslShaderTranslator::ProcessExecInstructionEnd(
|
||||||
const ParsedExecInstruction& instr) {
|
const ParsedExecInstruction& instr) {
|
||||||
|
Unindent();
|
||||||
|
EmitSourceDepth("}\n");
|
||||||
if (instr.is_end) {
|
if (instr.is_end) {
|
||||||
EmitSourceDepth("xe_pc = 0xFFFFu;\n");
|
EmitSourceDepth("xe_pc = 0xFFFFu;\n");
|
||||||
EmitSourceDepth("break;\n");
|
EmitSourceDepth("break;\n");
|
||||||
cf_wrote_pc_ = true;
|
cf_wrote_pc_ = true;
|
||||||
}
|
}
|
||||||
Unindent();
|
|
||||||
EmitSourceDepth("}\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HlslShaderTranslator::ProcessLoopStartInstruction(
|
void HlslShaderTranslator::ProcessLoopStartInstruction(
|
||||||
|
@ -551,34 +551,35 @@ void HlslShaderTranslator::ProcessJumpInstruction(
|
||||||
EmitSourceDepth("// ");
|
EmitSourceDepth("// ");
|
||||||
instr.Disassemble(&source_inner_);
|
instr.Disassemble(&source_inner_);
|
||||||
|
|
||||||
bool needs_fallthrough = false;
|
bool conditional = false;
|
||||||
switch (instr.type) {
|
switch (instr.type) {
|
||||||
case ParsedJumpInstruction::Type::kUnconditional:
|
case ParsedJumpInstruction::Type::kUnconditional:
|
||||||
EmitSourceDepth("{\n");
|
|
||||||
break;
|
break;
|
||||||
case ParsedJumpInstruction::Type::kConditional:
|
case ParsedJumpInstruction::Type::kConditional:
|
||||||
EmitSourceDepth("if ((xe_bool_constants[%u].x & (1u << %uu)) %c= 0u) {\n",
|
EmitSourceDepth("if ((xe_bool_constants[%u].x & (1u << %uu)) %c= 0u) {\n",
|
||||||
instr.bool_constant_index >> 5,
|
instr.bool_constant_index >> 5,
|
||||||
instr.bool_constant_index & 31,
|
instr.bool_constant_index & 31,
|
||||||
instr.condition ? '!' : '=');
|
instr.condition ? '!' : '=');
|
||||||
needs_fallthrough = true;
|
conditional = true;
|
||||||
break;
|
break;
|
||||||
case ParsedJumpInstruction::Type::kPredicated:
|
case ParsedJumpInstruction::Type::kPredicated:
|
||||||
EmitSourceDepth("if (%cxe_p0) {\n", instr.condition ? ' ' : '!');
|
EmitSourceDepth("if (%cxe_p0) {\n", instr.condition ? ' ' : '!');
|
||||||
needs_fallthrough = true;
|
conditional = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (conditional) {
|
||||||
Indent();
|
Indent();
|
||||||
|
}
|
||||||
EmitSourceDepth("xe_pc = %uu; // L%u\n", instr.target_address,
|
EmitSourceDepth("xe_pc = %uu; // L%u\n", instr.target_address,
|
||||||
instr.target_address);
|
instr.target_address);
|
||||||
|
if (conditional) {
|
||||||
Unindent();
|
Unindent();
|
||||||
if (needs_fallthrough) {
|
|
||||||
uint32_t next_address = instr.dword_index + 1;
|
uint32_t next_address = instr.dword_index + 1;
|
||||||
EmitSourceDepth("} else {\n");
|
EmitSourceDepth("} else {\n");
|
||||||
EmitSourceDepth(" xe_pc = %uu; // Fallthrough to L%u\n", next_address,
|
EmitSourceDepth(" xe_pc = %uu; // Fallthrough to L%u\n", next_address,
|
||||||
next_address);
|
next_address);
|
||||||
}
|
|
||||||
EmitSourceDepth("}\n");
|
EmitSourceDepth("}\n");
|
||||||
|
}
|
||||||
EmitSourceDepth("break;\n");
|
EmitSourceDepth("break;\n");
|
||||||
cf_wrote_pc_ = true;
|
cf_wrote_pc_ = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue