Przeglądaj źródła

Avoid adding shader buffer descriptors for constant buffers that are not used (#3478)

* Avoid adding shader buffer descriptors for constant buffers that are not used

* Shader cache version
gdkchan 3 lat temu
rodzic
commit
b34de74f81

+ 1 - 1
Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs

@@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
         private const ushort FileFormatVersionMajor = 1;
         private const ushort FileFormatVersionMajor = 1;
         private const ushort FileFormatVersionMinor = 1;
         private const ushort FileFormatVersionMinor = 1;
         private const uint FileFormatVersionPacked = ((uint)FileFormatVersionMajor << 16) | FileFormatVersionMinor;
         private const uint FileFormatVersionPacked = ((uint)FileFormatVersionMajor << 16) | FileFormatVersionMinor;
-        private const uint CodeGenVersion = 3457;
+        private const uint CodeGenVersion = 3478;
 
 
         private const string SharedTocFileName = "shared.toc";
         private const string SharedTocFileName = "shared.toc";
         private const string SharedDataFileName = "shared.data";
         private const string SharedDataFileName = "shared.data";

+ 3 - 3
Ryujinx.Graphics.Shader/Instructions/InstEmitHelper.cs

@@ -45,12 +45,12 @@ namespace Ryujinx.Graphics.Shader.Instructions
             if (isFP64)
             if (isFP64)
             {
             {
                 return context.PackDouble2x32(
                 return context.PackDouble2x32(
-                    context.Config.CreateCbuf(cbufSlot, cbufOffset),
-                    context.Config.CreateCbuf(cbufSlot, cbufOffset + 1));
+                    Cbuf(cbufSlot, cbufOffset),
+                    Cbuf(cbufSlot, cbufOffset + 1));
             }
             }
             else
             else
             {
             {
-                return context.Config.CreateCbuf(cbufSlot, cbufOffset);
+                return Cbuf(cbufSlot, cbufOffset);
             }
             }
         }
         }
 
 

+ 5 - 0
Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs

@@ -300,6 +300,11 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
 
 
             if (operand.Type != OperandType.LocalVariable)
             if (operand.Type != OperandType.LocalVariable)
             {
             {
+                if (operand.Type == OperandType.ConstantBuffer)
+                {
+                    Config.SetUsedConstantBuffer(operand.GetCbufSlot());
+                }
+
                 return new AstOperand(operand);
                 return new AstOperand(operand);
             }
             }
 
 

+ 2 - 2
Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs

@@ -68,7 +68,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
             {
             {
                 Operand addrLow = operation.GetSource(0);
                 Operand addrLow = operation.GetSource(0);
 
 
-                Operand baseAddrLow = config.CreateCbuf(0, GetStorageCbOffset(config.Stage, storageIndex));
+                Operand baseAddrLow = Cbuf(0, GetStorageCbOffset(config.Stage, storageIndex));
 
 
                 Operand baseAddrTrunc = Local();
                 Operand baseAddrTrunc = Local();
 
 
@@ -152,7 +152,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
             {
             {
                 Operand addrLow = operation.GetSource(0);
                 Operand addrLow = operation.GetSource(0);
 
 
-                Operand baseAddrLow = config.CreateCbuf(0, UbeBaseOffset + storageIndex * StorageDescSize);
+                Operand baseAddrLow = Cbuf(0, UbeBaseOffset + storageIndex * StorageDescSize);
 
 
                 Operand baseAddrTrunc = Local();
                 Operand baseAddrTrunc = Local();
 
 

+ 3 - 3
Ryujinx.Graphics.Shader/Translation/Rewriter.cs

@@ -75,9 +75,9 @@ namespace Ryujinx.Graphics.Shader.Translation
 
 
                 int cbOffset = GetStorageCbOffset(config.Stage, slot);
                 int cbOffset = GetStorageCbOffset(config.Stage, slot);
 
 
-                Operand baseAddrLow  = config.CreateCbuf(0, cbOffset);
-                Operand baseAddrHigh = config.CreateCbuf(0, cbOffset + 1);
-                Operand size         = config.CreateCbuf(0, cbOffset + 2);
+                Operand baseAddrLow  = Cbuf(0, cbOffset);
+                Operand baseAddrHigh = Cbuf(0, cbOffset + 1);
+                Operand size         = Cbuf(0, cbOffset + 2);
 
 
                 Operand offset = PrependOperation(Instruction.Subtract,       addrLow, baseAddrLow);
                 Operand offset = PrependOperation(Instruction.Subtract,       addrLow, baseAddrLow);
                 Operand borrow = PrependOperation(Instruction.CompareLessU32, addrLow, baseAddrLow);
                 Operand borrow = PrependOperation(Instruction.CompareLessU32, addrLow, baseAddrLow);

+ 0 - 6
Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs

@@ -360,12 +360,6 @@ namespace Ryujinx.Graphics.Shader.Translation
             UsedFeatures |= flags;
             UsedFeatures |= flags;
         }
         }
 
 
-        public Operand CreateCbuf(int slot, int offset)
-        {
-            SetUsedConstantBuffer(slot);
-            return OperandHelper.Cbuf(slot, offset);
-        }
-
         public void SetUsedConstantBuffer(int slot)
         public void SetUsedConstantBuffer(int slot)
         {
         {
             _usedConstantBuffers |= 1 << slot;
             _usedConstantBuffers |= 1 << slot;