From 49745cfa37b247c3e49bfae126bafbe41e166bc6 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Wed, 19 May 2021 18:15:26 -0300 Subject: 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 --- .../CodeGen/Glsl/CodeGenContext.cs | 45 ++++++++++------------ 1 file changed, 20 insertions(+), 25 deletions(-) (limited to 'Ryujinx.Graphics.Shader/CodeGen/Glsl/CodeGenContext.cs') 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 CBufferDescriptors { get; } - public List SBufferDescriptors { get; } - public List TextureDescriptors { get; } - public List 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(); - SBufferDescriptors = new List(); - TextureDescriptors = new List(); - ImageDescriptors = new List(); - OperandManager = new OperandManager(); _sb = new StringBuilder(); @@ -84,23 +70,32 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl AppendLine("}" + suffix); } - private int FindDescriptorIndex(List 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) -- cgit v1.2.3