From 1905b38207cf8090fb85dc9b68a66ee60b1511e5 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Tue, 2 Oct 2018 17:41:09 +0200 Subject: [PATCH] shader: correct swizzles from TGSI_SEMANTIC_SAMPLEPOS TGSI defines TGSI_SEMANTIC_SAMPLEPOS as a 4-component vector with Z and W set to 0. However, if we ever try to reach thez and w compoents, we run into trouble because this is implemented as a swizzle on gl_SamplePosition instead. And gl_SamplePosition only has x and y. It seems that recent versions of mesa does just this, causing shader-compilation errors during dEQP tests. This fixes regressions in the following tests: dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.singlesample_texture dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.multisample_texture_1 dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.multisample_texture_2 dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.multisample_texture_4 dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.multisample_texture_8 dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.singlesample_rbo dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.multisample_rbo_1 dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.multisample_rbo_2 dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.multisample_rbo_4 dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.multisample_rbo_8 dEQP-GLES31.functional.shaders.sample_variables.sample_pos.distribution.multisample_texture_1 dEQP-GLES31.functional.shaders.sample_variables.sample_pos.distribution.multisample_texture_2 dEQP-GLES31.functional.shaders.sample_variables.sample_pos.distribution.multisample_texture_4 dEQP-GLES31.functional.shaders.sample_variables.sample_pos.distribution.multisample_texture_8 dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_offset.at_sample_position.default_framebuffer Signed-off-by: Erik Faye-Lund Reviewed-by: Jakob Bornecrantz Reviewed-by: Gurchetan Singh Signed-off-by: Dave Airlie --- src/vrend_shader.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/vrend_shader.c b/src/vrend_shader.c index 6ae9891..bf6bd87 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -3289,8 +3289,20 @@ get_source_info(struct dump_ctx *ctx, ctx->system_values[j].glsl_name, src->Register.SwizzleY, ctx->system_values[j].glsl_name, src->Register.SwizzleZ, ctx->system_values[j].glsl_name, src->Register.SwizzleW); - } else if (ctx->system_values[j].name == TGSI_SEMANTIC_SAMPLEPOS || - ctx->system_values[j].name == TGSI_SEMANTIC_TESSCOORD) { + } else if (ctx->system_values[j].name == TGSI_SEMANTIC_SAMPLEPOS) { + /* gl_SamplePosition is a vec2, but TGSI_SEMANTIC_SAMPLEPOS + * is a vec4 with z = w = 0 + */ + const char *components[4] = { + "gl_SamplePosition.x", "gl_SamplePosition.y", "0.0", "0.0" + }; + snprintf(srcs[i], 255, "%s(vec4(%s, %s, %s, %s))", + prefix, + components[src->Register.SwizzleX], + components[src->Register.SwizzleY], + components[src->Register.SwizzleZ], + components[src->Register.SwizzleW]); + } else if (ctx->system_values[j].name == TGSI_SEMANTIC_TESSCOORD) { snprintf(srcs[i], 255, "%s(vec4(%s.%c, %s.%c, %s.%c, %s.%c))", prefix, ctx->system_values[j].glsl_name, get_swiz_char(src->Register.SwizzleX),