aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorriperiperi <rhy3756547@hotmail.com>2020-03-29 17:24:54 +0100
committerGitHub <noreply@github.com>2020-03-29 13:24:54 -0300
commitf9c859c8ba46113896f0e3be43b590a44d45692a (patch)
treec66fa198b1b1daad339670cdec43768728960ca4
parentb18ef8e3a00980595f45c7fe184dcb160dcc3cb9 (diff)
Index constant buffer vec4s using ternary expressions. (#1015)
* Index constant buffer vec4s using ternary expressions. * Remove indexed path. We determined that it had negligible impact. * Revert "Remove indexed path." This reverts commit 25ec4eddfa441e802bd957dfaabc83b23c6bae38. * Revert "Revert "Remove indexed path."" This reverts commit 7cd52fecb529dcb9e1a574533bd38531319f1268.
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs13
1 files changed, 11 insertions, 2 deletions
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs
index 4c9d5b55..2de55b2d 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs
+++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs
@@ -114,6 +114,16 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
return ubName + "." + GetSwizzleMask(offset & 3);
}
+ private static string GetVec4Indexed(string vectorName, string indexExpr)
+ {
+ string result = $"{vectorName}.x";
+ for (int i = 1; i < 4; i++)
+ {
+ result = $"(({indexExpr}) == {i}) ? ({vectorName}.{GetSwizzleMask(i)}) : ({result})";
+ }
+ return $"({result})";
+ }
+
public static string GetConstantBufferName(IAstNode slot, string offsetExpr, ShaderStage stage)
{
// Non-constant slots are not supported.
@@ -124,9 +134,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
string ubName = GetUbName(stage, operand.Value);
string index0 = "[" + offsetExpr + " >> 2]";
- string index1 = "[" + offsetExpr + " & 3]";
- return ubName + index0 + index1;
+ return GetVec4Indexed(ubName + index0, offsetExpr + " & 3");
}
public static string GetOutAttributeName(AstOperand attr, ShaderStage stage)