From 16dc6e41008efbbe0cc27e59067aed2630d2c42b Mon Sep 17 00:00:00 2001 From: Triang3l Date: Sun, 7 Oct 2018 21:51:18 +0300 Subject: [PATCH] [D3D12] DXBC: In getWeights, apply the offset for unnormalized coordinates only when needed --- src/xenia/gpu/dxbc_shader_translator.cc | 41 ++++++++++++++----------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/src/xenia/gpu/dxbc_shader_translator.cc b/src/xenia/gpu/dxbc_shader_translator.cc index ac52c4865..f61fffe79 100644 --- a/src/xenia/gpu/dxbc_shader_translator.cc +++ b/src/xenia/gpu/dxbc_shader_translator.cc @@ -4137,24 +4137,29 @@ void DxbcShaderTranslator::ProcessTextureFetchInstruction( // unnormalized coordinates. if (instr.attributes.unnormalized_coordinates) { - // Apply the offset. - shader_code_.push_back( - ENCODE_D3D10_SB_OPCODE_TYPE(D3D10_SB_OPCODE_ADD) | - ENCODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(10)); - shader_code_.push_back(EncodeVectorMaskedOperand( - D3D10_SB_OPERAND_TYPE_TEMP, coord_mask, 1)); - shader_code_.push_back(system_temp_pv_); - shader_code_.push_back(EncodeVectorSwizzledOperand( - D3D10_SB_OPERAND_TYPE_TEMP, kSwizzleXYZW, 1)); - shader_code_.push_back(system_temp_pv_); - shader_code_.push_back(EncodeVectorSwizzledOperand( - D3D10_SB_OPERAND_TYPE_IMMEDIATE32, kSwizzleXYZW, 0)); - shader_code_.push_back(*reinterpret_cast(&offset_x)); - shader_code_.push_back(*reinterpret_cast(&offset_y)); - shader_code_.push_back(*reinterpret_cast(&offset_z)); - shader_code_.push_back(0); - ++stat_.instruction_count; - ++stat_.float_instruction_count; + if (has_offset) { + // Apply the offset. + shader_code_.push_back( + ENCODE_D3D10_SB_OPCODE_TYPE(D3D10_SB_OPCODE_ADD) | + ENCODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(10)); + shader_code_.push_back(EncodeVectorMaskedOperand( + D3D10_SB_OPERAND_TYPE_TEMP, coord_mask, 1)); + shader_code_.push_back(system_temp_pv_); + shader_code_.push_back(EncodeVectorSwizzledOperand( + D3D10_SB_OPERAND_TYPE_TEMP, kSwizzleXYZW, 1)); + shader_code_.push_back(system_temp_pv_); + shader_code_.push_back(EncodeVectorSwizzledOperand( + D3D10_SB_OPERAND_TYPE_IMMEDIATE32, kSwizzleXYZW, 0)); + shader_code_.push_back( + *reinterpret_cast(&offset_x)); + shader_code_.push_back( + *reinterpret_cast(&offset_y)); + shader_code_.push_back( + *reinterpret_cast(&offset_z)); + shader_code_.push_back(0); + ++stat_.instruction_count; + ++stat_.float_instruction_count; + } } else { // Unnormalize the coordinates and apply the offset. shader_code_.push_back(