From 75e4e42e56bbb6a89e373dc03407cdafb19b22d5 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 13 Aug 2016 00:54:55 +1000 Subject: [PATCH] ShaderGen: Work around issue with glslang and dynamic vector subscripts Seems that vec[eye] will select vec.x no matter what the value of eye is. --- Source/Core/VideoCommon/GeometryShaderGen.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Core/VideoCommon/GeometryShaderGen.cpp b/Source/Core/VideoCommon/GeometryShaderGen.cpp index 6aefdf3e69..99e546a363 100644 --- a/Source/Core/VideoCommon/GeometryShaderGen.cpp +++ b/Source/Core/VideoCommon/GeometryShaderGen.cpp @@ -240,7 +240,8 @@ ShaderCode GenerateGeometryShaderCode(APIType ApiType, const geometry_shader_uid // the depth value. This results in objects at a distance smaller than the convergence // distance to seemingly appear in front of the screen. // This formula is based on page 13 of the "Nvidia 3D Vision Automatic, Best Practices Guide" - out.Write("\tf.pos.x += " I_STEREOPARAMS "[eye] * (f.pos.w - " I_STEREOPARAMS "[2]);\n"); + out.Write("\tfloat hoffset = (eye == 0) ? " I_STEREOPARAMS ".x : " I_STEREOPARAMS ".y;\n"); + out.Write("\tf.pos.x += hoffset * (f.pos.w - " I_STEREOPARAMS ".z);\n"); } if (uid_data->primitive_type == PRIMITIVE_LINES)