From 7cd52fecb529dcb9e1a574533bd38531319f1268 Mon Sep 17 00:00:00 2001 From: riperiperi Date: Sun, 29 Mar 2020 17:03:54 +0100 Subject: [PATCH] Revert "Remove indexed path." This reverts commit 25ec4eddfa441e802bd957dfaabc83b23c6bae38. --- .../CodeGen/Glsl/OperandManager.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs index 2de55b2ddd..f734580b4e 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs @@ -116,12 +116,20 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl private static string GetVec4Indexed(string vectorName, string indexExpr) { - string result = $"{vectorName}.x"; - for (int i = 1; i < 4; i++) + bool canIndexVec4 = false; + if (canIndexVec4) { - result = $"(({indexExpr}) == {i}) ? ({vectorName}.{GetSwizzleMask(i)}) : ({result})"; + return $"{vectorName}[{indexExpr}]"; + } + else + { + string result = $"{vectorName}.x"; + for (int i = 1; i < 4; i++) + { + result = $"(({indexExpr}) == {i}) ? ({vectorName}.{GetSwizzleMask(i)}) : ({result})"; + } + return $"({result})"; } - return $"({result})"; } public static string GetConstantBufferName(IAstNode slot, string offsetExpr, ShaderStage stage)