From aa7ab46a064a5e1aa1fd4a0098ed46fa8f294963 Mon Sep 17 00:00:00 2001 From: Urja Rannikko Date: Fri, 17 Jul 2020 19:26:30 +0000 Subject: [PATCH] GAL: Round the incoming mode parameter in fragment shader This fixes some letters being randomly boxes and some circles being randomly triangles on the Mali T760. --- common/gal/opengl/gl_builtin_shaders.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/common/gal/opengl/gl_builtin_shaders.cpp b/common/gal/opengl/gl_builtin_shaders.cpp index dea41429a6..ab0a57c2f3 100644 --- a/common/gal/opengl/gl_builtin_shaders.cpp +++ b/common/gal/opengl/gl_builtin_shaders.cpp @@ -354,19 +354,23 @@ float median( vec3 v ) void main() { - if( shaderParams[0] == SHADER_LINE_A ) + // VS to FS pipeline does math that means we can't rely on the mode + // parameter being bit-exact without rounding it first. + float mode = floor( shaderParams[0] + 0.5 ); + + if( mode == SHADER_LINE_A ) { drawLine( gl_TexCoord[0].st ); } - else if( shaderParams[0] == SHADER_FILLED_CIRCLE ) + else if( mode == SHADER_FILLED_CIRCLE ) { filledCircle( circleCoords ); } - else if( shaderParams[0] == SHADER_STROKED_CIRCLE ) + else if( mode == SHADER_STROKED_CIRCLE ) { strokedCircle( circleCoords, shaderParams[2], shaderParams[3] ); } - else if( shaderParams[0] == SHADER_FONT ) + else if( mode == SHADER_FONT ) { vec2 tex = shaderParams.yz;