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 <erik.faye-lund@collabora.com>
Reviewed-by: Jakob Bornecrantz <jakob@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
macos/master
Erik Faye-Lund 6 years ago committed by Dave Airlie
parent efba840386
commit 1905b38207
  1. 16
      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),

Loading…
Cancel
Save