Просмотр исходного кода

Fix FLO.SH shader instruction with a input of 0 (#2876)

* Fix FLO.SH shader instruction with a input of 0

* Shader cache version bump
gdkchan 4 лет назад
Родитель
Сommit
acc0b0f313

+ 1 - 1
Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs

@@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
         /// <summary>
         /// <summary>
         /// Version of the codegen (to be changed when codegen or guest format change).
         /// Version of the codegen (to be changed when codegen or guest format change).
         /// </summary>
         /// </summary>
-        private const ulong ShaderCodeGenVersion = 2816;
+        private const ulong ShaderCodeGenVersion = 2876;
 
 
         // Progress reporting helpers
         // Progress reporting helpers
         private volatile int _shaderCount;
         private volatile int _shaderCount;

+ 3 - 2
Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenHelper.cs

@@ -71,8 +71,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
             Add(Instruction.ExponentB2,               InstType.CallUnary,      "exp2");
             Add(Instruction.ExponentB2,               InstType.CallUnary,      "exp2");
             Add(Instruction.FSIBegin,                 InstType.Special);
             Add(Instruction.FSIBegin,                 InstType.Special);
             Add(Instruction.FSIEnd,                   InstType.Special);
             Add(Instruction.FSIEnd,                   InstType.Special);
-            Add(Instruction.FindFirstSetS32,          InstType.CallUnary,      "findMSB");
-            Add(Instruction.FindFirstSetU32,          InstType.CallUnary,      "findMSB");
+            Add(Instruction.FindLSB,                  InstType.CallUnary,      "findLSB");
+            Add(Instruction.FindMSBS32,               InstType.CallUnary,      "findMSB");
+            Add(Instruction.FindMSBU32,               InstType.CallUnary,      "findMSB");
             Add(Instruction.Floor,                    InstType.CallUnary,      "floor");
             Add(Instruction.Floor,                    InstType.CallUnary,      "floor");
             Add(Instruction.FusedMultiplyAdd,         InstType.CallTernary,    "fma");
             Add(Instruction.FusedMultiplyAdd,         InstType.CallTernary,    "fma");
             Add(Instruction.GroupMemoryBarrier,       InstType.CallNullary,    "groupMemoryBarrier");
             Add(Instruction.GroupMemoryBarrier,       InstType.CallNullary,    "groupMemoryBarrier");

+ 8 - 4
Ryujinx.Graphics.Shader/Instructions/InstEmitBitfield.cs

@@ -166,13 +166,17 @@ namespace Ryujinx.Graphics.Shader.Instructions
         {
         {
             Operand srcB = context.BitwiseNot(src, invert);
             Operand srcB = context.BitwiseNot(src, invert);
 
 
-            Operand res = isSigned
-                ? context.FindFirstSetS32(srcB)
-                : context.FindFirstSetU32(srcB);
+            Operand res;
 
 
             if (sh)
             if (sh)
             {
             {
-                res = context.BitwiseExclusiveOr(res, Const(31));
+                res = context.FindLSB(context.BitfieldReverse(srcB));
+            }
+            else
+            {
+                res = isSigned
+                    ? context.FindMSBS32(srcB)
+                    : context.FindMSBU32(srcB);
             }
             }
 
 
             context.Copy(GetDest(rd), res);
             context.Copy(GetDest(rd), res);

+ 3 - 2
Ryujinx.Graphics.Shader/IntermediateRepresentation/Instruction.cs

@@ -68,8 +68,9 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
         ExponentB2,
         ExponentB2,
         FSIBegin,
         FSIBegin,
         FSIEnd,
         FSIEnd,
-        FindFirstSetS32,
-        FindFirstSetU32,
+        FindLSB,
+        FindMSBS32,
+        FindMSBU32,
         Floor,
         Floor,
         FusedMultiplyAdd,
         FusedMultiplyAdd,
         GroupMemoryBarrier,
         GroupMemoryBarrier,

+ 3 - 2
Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs

@@ -79,8 +79,9 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
             Add(Instruction.Ddy,                      VariableType.F32,    VariableType.F32);
             Add(Instruction.Ddy,                      VariableType.F32,    VariableType.F32);
             Add(Instruction.Divide,                   VariableType.Scalar, VariableType.Scalar, VariableType.Scalar);
             Add(Instruction.Divide,                   VariableType.Scalar, VariableType.Scalar, VariableType.Scalar);
             Add(Instruction.ExponentB2,               VariableType.Scalar, VariableType.Scalar);
             Add(Instruction.ExponentB2,               VariableType.Scalar, VariableType.Scalar);
-            Add(Instruction.FindFirstSetS32,          VariableType.S32,    VariableType.S32);
-            Add(Instruction.FindFirstSetU32,          VariableType.S32,    VariableType.U32);
+            Add(Instruction.FindLSB,                  VariableType.Int,    VariableType.Int);
+            Add(Instruction.FindMSBS32,               VariableType.S32,    VariableType.S32);
+            Add(Instruction.FindMSBU32,               VariableType.S32,    VariableType.U32);
             Add(Instruction.Floor,                    VariableType.Scalar, VariableType.Scalar);
             Add(Instruction.Floor,                    VariableType.Scalar, VariableType.Scalar);
             Add(Instruction.FusedMultiplyAdd,         VariableType.Scalar, VariableType.Scalar, VariableType.Scalar, VariableType.Scalar);
             Add(Instruction.FusedMultiplyAdd,         VariableType.Scalar, VariableType.Scalar, VariableType.Scalar, VariableType.Scalar);
             Add(Instruction.ImageLoad,                VariableType.F32);
             Add(Instruction.ImageLoad,                VariableType.F32);

+ 9 - 4
Ryujinx.Graphics.Shader/Translation/EmitterContextInsts.cs

@@ -181,14 +181,19 @@ namespace Ryujinx.Graphics.Shader.Translation
             return context.Add(Instruction.EndPrimitive);
             return context.Add(Instruction.EndPrimitive);
         }
         }
 
 
-        public static Operand FindFirstSetS32(this EmitterContext context, Operand a)
+        public static Operand FindLSB(this EmitterContext context, Operand a)
         {
         {
-            return context.Add(Instruction.FindFirstSetS32, Local(), a);
+            return context.Add(Instruction.FindLSB, Local(), a);
         }
         }
 
 
-        public static Operand FindFirstSetU32(this EmitterContext context, Operand a)
+        public static Operand FindMSBS32(this EmitterContext context, Operand a)
         {
         {
-            return context.Add(Instruction.FindFirstSetU32, Local(), a);
+            return context.Add(Instruction.FindMSBS32, Local(), a);
+        }
+
+        public static Operand FindMSBU32(this EmitterContext context, Operand a)
+        {
+            return context.Add(Instruction.FindMSBU32, Local(), a);
         }
         }
 
 
         public static Operand FP32ConvertToFP64(this EmitterContext context, Operand a)
         public static Operand FP32ConvertToFP64(this EmitterContext context, Operand a)