From 27a8e4259ecc7859bf3b2706a9bcc0b6cd8b979c Mon Sep 17 00:00:00 2001 From: Triang3l Date: Sat, 12 Jan 2019 18:52:06 +0300 Subject: [PATCH] [D3D12] DXBC: Fix 0*anything check with negated operands --- src/xenia/gpu/dxbc_shader_translator.cc | 26 +++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/xenia/gpu/dxbc_shader_translator.cc b/src/xenia/gpu/dxbc_shader_translator.cc index 5d4204f89..2475b6c26 100644 --- a/src/xenia/gpu/dxbc_shader_translator.cc +++ b/src/xenia/gpu/dxbc_shader_translator.cc @@ -1942,12 +1942,15 @@ uint32_t DxbcShaderTranslator::DxbcSourceOperandLength( // totally invalid operand replaced by a literal. return 5; } - // Apply both the operand negation and the usage negation (for subtraction) - // and absolute from both sources. - if (operand.is_negated) { - negate = !negate; + // Apply overrides (for instance, for subtraction). Xenos operand modifiers + // are ignored when forcing absolute value (though negated absolute can still + // be forced in this case). + if (!absolute) { + if (operand.is_negated) { + negate = !negate; + } + absolute |= operand.is_absolute_value; } - absolute |= operand.is_absolute_value; // Modifier extension - neg/abs or non-uniform binding index. if (negate || absolute) { ++length; @@ -1981,12 +1984,15 @@ void DxbcShaderTranslator::UseDxbcSourceOperand( (swizzle << D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_SHIFT); } - // Apply both the operand negation and the usage negation (for subtraction) - // and absolute value from both sources. - if (operand.is_negated) { - negate = !negate; + // Apply overrides (for instance, for subtraction). Xenos operand modifiers + // are ignored when forcing absolute value (though negated absolute can still + // be forced in this case). + if (!absolute) { + if (operand.is_negated) { + negate = !negate; + } + absolute |= operand.is_absolute_value; } - absolute |= operand.is_absolute_value; // Build OperandToken1 for modifiers (negate, absolute, minimum precision, // non-uniform binding index) - if it has any, it will be non-zero. // NOTE: AMD GPUs or drivers do NOT support non-uniform constant buffer