aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Gal/Shader
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2018-06-26 02:10:54 -0300
committergdkchan <gab.dark.100@gmail.com>2018-06-26 02:10:54 -0300
commit09dfefed1f84585e2b305cd16482f899b93fe629 (patch)
tree2e24e24f969376056228e8679020f459f4f68dc1 /Ryujinx.Graphics/Gal/Shader
parentb8be89ab2dad2e2ba5145f64425fa49526f81596 (diff)
Implementation of UBOs instead of uniform constant arrays (#186)
* Sort uniform binding to avoid possible failures in drivers fewer bindings * Throw exception for Cbuf overflow * Search for free bindings instead of using locked ones * EnsureAllocated when binding buffers * Fix uniform bindings * Remove spaces * Use 64 KiB UBOs when available * Remove double colon * Use IdentationStr and avoid division in Cbuf offset * Add spaces
Diffstat (limited to 'Ryujinx.Graphics/Gal/Shader')
-rw-r--r--Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs14
1 files changed, 8 insertions, 6 deletions
diff --git a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs
index 24db303f..576358c7 100644
--- a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs
+++ b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs
@@ -145,7 +145,9 @@ namespace Ryujinx.Graphics.Gal.Shader
foreach (ShaderDeclInfo DeclInfo in Decl.Uniforms.Values.OrderBy(DeclKeySelector))
{
- SB.AppendLine($"uniform {GetDecl(DeclInfo)}[{DeclInfo.Index + 1}];");
+ SB.AppendLine($"layout (std140) uniform {DeclInfo.Name} {{");
+ SB.AppendLine($"{IdentationStr}vec4 {DeclInfo.Name}_data[{DeclInfo.Index / 4 + 1}];");
+ SB.AppendLine($"}};");
}
if (Decl.Uniforms.Count > 0)
@@ -530,15 +532,15 @@ namespace Ryujinx.Graphics.Gal.Shader
if (Cbuf.Offs != null)
{
- //Note: We assume that the register value is always a multiple of 4.
- //This may not be aways the case.
- string Offset = "(floatBitsToInt(" + GetSrcExpr(Cbuf.Offs) + ") >> 2)";
+ string Offset = "floatBitsToInt(" + GetSrcExpr(Cbuf.Offs) + ")";
- return DeclInfo.Name + "[" + Cbuf.Pos + " + " + Offset + "]";
+ string Index = "(" + Cbuf.Pos * 4 + " + " + Offset + ")";
+
+ return $"{DeclInfo.Name}_data[{Index} / 16][({Index} / 4) % 4]";
}
else
{
- return DeclInfo.Name + "[" + Cbuf.Pos + "]";
+ return $"{DeclInfo.Name}_data[{Cbuf.Pos / 4}][{Cbuf.Pos % 4}]";
}
}