aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/CodeGen/Glsl/CodeGenContext.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2021-05-19 18:15:26 -0300
committerGitHub <noreply@github.com>2021-05-19 23:15:26 +0200
commit49745cfa37b247c3e49bfae126bafbe41e166bc6 (patch)
tree1a37f2f2c23791244b22529f6e228f008f984409 /Ryujinx.Graphics.Shader/CodeGen/Glsl/CodeGenContext.cs
parentb5c72b44dee2fd977d7cca5aa3c29ef1e2286aa7 (diff)
Move shader resource descriptor creation out of the backend (#2290)
* Move shader resource descriptor creation out of the backend * Remove now unused code, and other nits * Shader cache version bump * Nits * Set format for bindless image load/store * Fix buffer write flag
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)