mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-21 05:49:57 -04:00
Import the base tree (MIT, see LICENSE)
This commit is contained in:
32
tools/xlate/patches/0013-funnel-shift-by-zero.patch
Normal file
32
tools/xlate/patches/0013-funnel-shift-by-zero.patch
Normal file
@@ -0,0 +1,32 @@
|
||||
--- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitShift.cs
|
||||
+++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitShift.cs
|
||||
@@ -119,6 +119,10 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
bool signedShift = maxShift == MaxShift.S64;
|
||||
int maxShiftConst = isLongShift ? 64 : 32;
|
||||
|
||||
+ // NX2NAVI: the shift amount as a constant, when it is one (taken before the mask makes it an operation).
|
||||
+ bool constantShift = srcB.Type == OperandType.Constant;
|
||||
+ int shiftValue = constantShift ? (mask ? srcB.Value & (maxShiftConst - 1) : srcB.Value) : 0;
|
||||
+
|
||||
if (mask)
|
||||
{
|
||||
srcB = context.BitwiseAnd(srcB, Const(maxShiftConst - 1));
|
||||
@@ -159,6 +163,18 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
}
|
||||
}
|
||||
|
||||
+ // NX2NAVI: a shift by 0 shifts the other word by 32, which SPIR-V leaves undefined; AMD's shift instructions take
|
||||
+ // the amount's low 5 bits and give A | C. Maxwell gives the unshifted word: C for SHF.L, A for SHF.R, 32- and
|
||||
+ // 64-bit alike. NX2NAVI's Depths terrain vertex shaders shift by registers (SHF.L.R, SHF.R.R).
|
||||
+ if (!constantShift)
|
||||
+ {
|
||||
+ res = context.ConditionalSelect(context.ICompareEqual(srcB, Const(0)), left ? srcC : srcA, res);
|
||||
+ }
|
||||
+ else if (shiftValue == 0)
|
||||
+ {
|
||||
+ res = left ? srcC : srcA;
|
||||
+ }
|
||||
+
|
||||
if (!mask)
|
||||
{
|
||||
// Clamped shift value.
|
||||
Reference in New Issue
Block a user