aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/CodeGen/Glsl/CodeGenContext.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Graphics.Shader/CodeGen/Glsl/CodeGenContext.cs')
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Glsl/CodeGenContext.cs45
1 files changed, 20 insertions, 25 deletions
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/CodeGenContext.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/CodeGenContext.cs
index e20df384..f0f8ea35 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/CodeGenContext.cs
+++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/CodeGenContext.cs
@@ -1,7 +1,5 @@
-using Ryujinx.Graphics.Shader.IntermediateRepresentation;
using Ryujinx.Graphics.Shader.StructuredIr;
using Ryujinx.Graphics.Shader.Translation;
-using System.Collections.Generic;
using System.Text;
namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
@@ -10,22 +8,15 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
{
public const string Tab = " ";
- private readonly StructuredProgramInfo _info;
-
public StructuredFunction CurrentFunction { get; set; }
public ShaderConfig Config { get; }
- public bool CbIndexable => _info.UsesCbIndexing;
-
- public List<BufferDescriptor> CBufferDescriptors { get; }
- public List<BufferDescriptor> SBufferDescriptors { get; }
- public List<TextureDescriptor> TextureDescriptors { get; }
- public List<TextureDescriptor> ImageDescriptors { get; }
-
public OperandManager OperandManager { get; }
- private StringBuilder _sb;
+ private readonly StructuredProgramInfo _info;
+
+ private readonly StringBuilder _sb;
private int _level;
@@ -36,11 +27,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
_info = info;
Config = config;
- CBufferDescriptors = new List<BufferDescriptor>();
- SBufferDescriptors = new List<BufferDescriptor>();
- TextureDescriptors = new List<TextureDescriptor>();
- ImageDescriptors = new List<TextureDescriptor>();
-
OperandManager = new OperandManager();
_sb = new StringBuilder();
@@ -84,23 +70,32 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
AppendLine("}" + suffix);
}
- private int FindDescriptorIndex(List<TextureDescriptor> list, AstTextureOperation texOp)
+ private static int FindDescriptorIndex(TextureDescriptor[] array, AstTextureOperation texOp)
{
- return list.FindIndex(descriptor =>
- descriptor.Type == texOp.Type &&
- descriptor.CbufSlot == texOp.CbufSlot &&
- descriptor.HandleIndex == texOp.Handle &&
- descriptor.Format == texOp.Format);
+ for (int i = 0; i < array.Length; i++)
+ {
+ var descriptor = array[i];
+
+ if (descriptor.Type == texOp.Type &&
+ descriptor.CbufSlot == texOp.CbufSlot &&
+ descriptor.HandleIndex == texOp.Handle &&
+ descriptor.Format == texOp.Format)
+ {
+ return i;
+ }
+ }
+
+ return -1;
}
public int FindTextureDescriptorIndex(AstTextureOperation texOp)
{
- return FindDescriptorIndex(TextureDescriptors, texOp);
+ return FindDescriptorIndex(Config.GetTextureDescriptors(), texOp);
}
public int FindImageDescriptorIndex(AstTextureOperation texOp)
{
- return FindDescriptorIndex(ImageDescriptors, texOp);
+ return FindDescriptorIndex(Config.GetImageDescriptors(), texOp);
}
public StructuredFunction GetFunction(int id)