[D3D12] DXBC: In getWeights, apply the offset for unnormalized coordinates only when needed

This commit is contained in:
Triang3l 2018-10-07 21:51:18 +03:00
parent 685d3074f4
commit 16dc6e4100
1 changed files with 23 additions and 18 deletions

View File

@ -4137,24 +4137,29 @@ void DxbcShaderTranslator::ProcessTextureFetchInstruction(
// unnormalized coordinates. // unnormalized coordinates.
if (instr.attributes.unnormalized_coordinates) { if (instr.attributes.unnormalized_coordinates) {
// Apply the offset. if (has_offset) {
shader_code_.push_back( // Apply the offset.
ENCODE_D3D10_SB_OPCODE_TYPE(D3D10_SB_OPCODE_ADD) | shader_code_.push_back(
ENCODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(10)); ENCODE_D3D10_SB_OPCODE_TYPE(D3D10_SB_OPCODE_ADD) |
shader_code_.push_back(EncodeVectorMaskedOperand( ENCODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(10));
D3D10_SB_OPERAND_TYPE_TEMP, coord_mask, 1)); shader_code_.push_back(EncodeVectorMaskedOperand(
shader_code_.push_back(system_temp_pv_); D3D10_SB_OPERAND_TYPE_TEMP, coord_mask, 1));
shader_code_.push_back(EncodeVectorSwizzledOperand( shader_code_.push_back(system_temp_pv_);
D3D10_SB_OPERAND_TYPE_TEMP, kSwizzleXYZW, 1)); shader_code_.push_back(EncodeVectorSwizzledOperand(
shader_code_.push_back(system_temp_pv_); D3D10_SB_OPERAND_TYPE_TEMP, kSwizzleXYZW, 1));
shader_code_.push_back(EncodeVectorSwizzledOperand( shader_code_.push_back(system_temp_pv_);
D3D10_SB_OPERAND_TYPE_IMMEDIATE32, kSwizzleXYZW, 0)); shader_code_.push_back(EncodeVectorSwizzledOperand(
shader_code_.push_back(*reinterpret_cast<const uint32_t*>(&offset_x)); D3D10_SB_OPERAND_TYPE_IMMEDIATE32, kSwizzleXYZW, 0));
shader_code_.push_back(*reinterpret_cast<const uint32_t*>(&offset_y)); shader_code_.push_back(
shader_code_.push_back(*reinterpret_cast<const uint32_t*>(&offset_z)); *reinterpret_cast<const uint32_t*>(&offset_x));
shader_code_.push_back(0); shader_code_.push_back(
++stat_.instruction_count; *reinterpret_cast<const uint32_t*>(&offset_y));
++stat_.float_instruction_count; shader_code_.push_back(
*reinterpret_cast<const uint32_t*>(&offset_z));
shader_code_.push_back(0);
++stat_.instruction_count;
++stat_.float_instruction_count;
}
} else { } else {
// Unnormalize the coordinates and apply the offset. // Unnormalize the coordinates and apply the offset.
shader_code_.push_back( shader_code_.push_back(