Add partial support for array of samplers, and add pass to identify them from bindless texture accesses

This commit is contained in:
gdk 2019-11-02 23:07:21 -03:00 committed by Thog
parent 63345a3098
commit 3ab5c23f49
10 changed files with 210 additions and 39 deletions

View file

@ -231,7 +231,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
foreach (AstTextureOperation texOp in info.Samplers.OrderBy(x => x.Handle))
{
string samplerName = OperandManager.GetSamplerName(context.Config.Stage, texOp);
string indexExpr = NumberFormatter.FormatInt(texOp.ArraySize);
string samplerName = OperandManager.GetSamplerName(context.Config.Stage, texOp, indexExpr);
if (!samplers.TryAdd(samplerName, texOp))
{
@ -257,12 +259,25 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
desc = new TextureDescriptor(samplerName, texOp.Type, operand.CbufSlot, operand.CbufOffset);
}
else if ((texOp.Type & SamplerType.Indexed) != 0)
{
for (int index = 0; index < texOp.ArraySize; index++)
{
string indexExpr = NumberFormatter.FormatInt(index);
string indexedSamplerName = OperandManager.GetSamplerName(context.Config.Stage, texOp, indexExpr);
desc = new TextureDescriptor(indexedSamplerName, texOp.Type, texOp.Handle + index * 2);
context.TextureDescriptors.Add(desc);
}
}
else
{
desc = new TextureDescriptor(samplerName, texOp.Type, texOp.Handle);
}
context.TextureDescriptors.Add(desc);
context.TextureDescriptors.Add(desc);
}
}
}
@ -272,7 +287,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
foreach (AstTextureOperation texOp in info.Images.OrderBy(x => x.Handle))
{
string imageName = OperandManager.GetImageName(context.Config.Stage, texOp);
string indexExpr = NumberFormatter.FormatInt(texOp.ArraySize);
string imageName = OperandManager.GetImageName(context.Config.Stage, texOp, indexExpr);
if (!images.TryAdd(imageName, texOp))
{
@ -290,9 +307,25 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
AstTextureOperation texOp = kv.Value;
TextureDescriptor desc = new TextureDescriptor(imageName, texOp.Type, texOp.Handle);
if ((texOp.Type & SamplerType.Indexed) != 0)
{
for (int index = 0; index < texOp.ArraySize; index++)
{
string indexExpr = NumberFormatter.FormatInt(index);
context.ImageDescriptors.Add(desc);
string indexedSamplerName = OperandManager.GetSamplerName(context.Config.Stage, texOp, indexExpr);
var desc = new TextureDescriptor(indexedSamplerName, texOp.Type, texOp.Handle + index * 2);
context.TextureDescriptors.Add(desc);
}
}
else
{
var desc = new TextureDescriptor(imageName, texOp.Type, texOp.Handle);
context.ImageDescriptors.Add(desc);
}
}
}