aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
diff options
context:
space:
mode:
authorgdk <gab.dark.100@gmail.com>2019-11-02 23:07:21 -0300
committerThog <thog@protonmail.com>2020-01-09 02:13:00 +0100
commit3ab5c23f492183ae6f5cf8f62c4239bf181d2630 (patch)
tree288daa576efbbe3220d835834acd562dff7d6cbd /Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
parent63345a3098e05e0d0692bc46852dfbfccfdcfae2 (diff)
Add partial support for array of samplers, and add pass to identify them from bindless texture accesses
Diffstat (limited to 'Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs')
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs45
1 files changed, 39 insertions, 6 deletions
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
index 7c67bc13..6c4ba949 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
+++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
@@ -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);
+
+ 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);
+ context.ImageDescriptors.Add(desc);
+ }
}
}