From 581875b3391932bde995a1cbb947f5378346876d Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Tue, 14 Mar 2017 21:41:50 -0500 Subject: [PATCH] SPIR-V: Load operands after handling predicated blocks. --- src/xenia/gpu/spirv_shader_translator.cc | 46 ++++++++++++------------ 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/xenia/gpu/spirv_shader_translator.cc b/src/xenia/gpu/spirv_shader_translator.cc index fc35c4a19..b7feb21e2 100644 --- a/src/xenia/gpu/spirv_shader_translator.cc +++ b/src/xenia/gpu/spirv_shader_translator.cc @@ -1635,13 +1635,6 @@ void SpirvShaderTranslator::ProcessVectorAluInstruction( const ParsedAluInstruction& instr) { auto& b = *builder_; - // TODO: If we have identical operands, reuse previous one. - Id sources[3] = {0}; - Id dest = vec4_float_zero_; - for (size_t i = 0; i < instr.operand_count; i++) { - sources[i] = LoadFromOperand(instr.operands[i]); - } - // Close the open predicated block if this instr isn't predicated or the // conditions do not match. if (open_predicated_block_ && @@ -1669,6 +1662,13 @@ void SpirvShaderTranslator::ProcessVectorAluInstruction( b.setBuildPoint(block); } + // TODO: If we have identical operands, reuse previous one. + Id sources[3] = {0}; + Id dest = vec4_float_zero_; + for (size_t i = 0; i < instr.operand_count; i++) { + sources[i] = LoadFromOperand(instr.operands[i]); + } + bool close_predicated_block = false; switch (instr.vector_opcode) { case AluVectorOpcode::kAdd: { @@ -2048,22 +2048,6 @@ void SpirvShaderTranslator::ProcessScalarAluInstruction( const ParsedAluInstruction& instr) { auto& b = *builder_; - // TODO: If we have identical operands, reuse previous one. - Id sources[3] = {0}; - Id dest = b.makeFloatConstant(0); - for (size_t i = 0, x = 0; i < instr.operand_count; i++) { - auto src = LoadFromOperand(instr.operands[i]); - - // Pull components out of the vector operands and use them as sources. - if (instr.operands[i].component_count > 1) { - for (int j = 0; j < instr.operands[i].component_count; j++) { - sources[x++] = b.createCompositeExtract(src, float_type_, j); - } - } else { - sources[x++] = src; - } - } - // Close the open predicated block if this instr isn't predicated or the // conditions do not match. if (open_predicated_block_ && @@ -2091,6 +2075,22 @@ void SpirvShaderTranslator::ProcessScalarAluInstruction( b.setBuildPoint(block); } + // TODO: If we have identical operands, reuse previous one. + Id sources[3] = {0}; + Id dest = b.makeFloatConstant(0); + for (size_t i = 0, x = 0; i < instr.operand_count; i++) { + auto src = LoadFromOperand(instr.operands[i]); + + // Pull components out of the vector operands and use them as sources. + if (instr.operands[i].component_count > 1) { + for (int j = 0; j < instr.operands[i].component_count; j++) { + sources[x++] = b.createCompositeExtract(src, float_type_, j); + } + } else { + sources[x++] = src; + } + } + bool close_predicated_block = false; switch (instr.scalar_opcode) { case AluScalarOpcode::kAdds: