mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-08-20 15:48:43 +02:00
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 commit25ec4eddfa
. * Revert "Revert "Remove indexed path."" This reverts commit7cd52fecb5
.
This commit is contained in:
parent
b18ef8e3a0
commit
f9c859c8ba
1 changed files with 11 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue