[D3D12] HLSL control flow fixes (still broken)

This commit is contained in:
Triang3l 2018-08-12 01:08:19 +03:00
parent ede9055ca5
commit 0900036795
1 changed files with 16 additions and 8 deletions

View File

@ -393,10 +393,11 @@ void HlslShaderTranslator::ProcessLabel(uint32_t cf_index) {
// 0 is always added in the beginning.
if (cf_index != 0) {
if (!cf_wrote_pc_) {
EmitSourceDepth("xe_pc = %uu;\n", cf_index);
EmitSourceDepth("break;\n");
EmitSourceDepth(" xe_pc = %uu;\n", cf_index);
EmitSourceDepth(" break;\n");
}
EmitSourceDepth("case %uu:\n", cf_index);
cf_wrote_pc_ = false;
}
}
@ -406,13 +407,21 @@ void HlslShaderTranslator::ProcessControlFlowNopInstruction(uint32_t cf_index) {
void HlslShaderTranslator::ProcessControlFlowInstructionBegin(
uint32_t cf_index) {
if (cf_wrote_pc_) {
// In case there are instructions after setting the PC and breaking (if
// there's an `if` setting the PC, there's an `else` setting the PC as well
// for falling through).
EmitSourceDepth("case %uu:\n", cf_index);
cf_wrote_pc_ = false;
}
Indent();
}
void HlslShaderTranslator::ProcessControlFlowInstructionEnd(uint32_t cf_index) {
if (!cf_wrote_pc_) {
EmitSourceDepth("// Falling through to L%u\n", cf_index + 1);
}
Unindent();
}
void HlslShaderTranslator::ProcessExecInstructionBegin(
@ -560,11 +569,8 @@ void HlslShaderTranslator::ProcessJumpInstruction(
break;
}
Indent();
EmitSourceDepth("xe_pc = %uu; // L%u\n", instr.target_address,
instr.target_address);
EmitSourceDepth("break;\n");
Unindent();
if (needs_fallthrough) {
uint32_t next_address = instr.dword_index + 1;
@ -573,6 +579,8 @@ void HlslShaderTranslator::ProcessJumpInstruction(
next_address);
}
EmitSourceDepth("}\n");
EmitSourceDepth("break;\n");
cf_wrote_pc_ = true;
}
void HlslShaderTranslator::ProcessAllocInstruction(