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
This commit is contained in:
gdkchan 2021-05-19 18:15:26 -03:00 committed by GitHub
parent b5c72b44de
commit 49745cfa37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 565 additions and 516 deletions

View file

@ -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)