renderer: remove winsys_adjust.zw (DepthRange scale, trans)

Previously, vrend_shader insterted a scale & bias to emulate
glDepthRange in all vertex shaders.  This approach will fail
to match the gl spec in some situations.   glDepthRange() is also
called, causing the transformation to be applied twice.  The
winsys_adjust uniform is now a scalar to implement the y-flip only.

This bug was discovered and tested using the
dEQP-GLES2.functional.depth_range test suite.  This test now passes
all but one case, which appears to be a separate issue.

Signed-off-by: Joe M. Kniss <djmk@google.com>
[airlied: fixes some piglit tests as well - no regressions]
Signed-off-by: Dave Airlie <airlied@redhat.com>
macos/master
Joe M. Kniss 7 years ago committed by Dave Airlie
parent 9b77920452
commit 678df551b3
  1. 4
      src/vrend_renderer.c
  2. 10
      src/vrend_shader.c

@ -945,7 +945,7 @@ static struct vrend_linked_shader_program *add_shader_program(struct vrend_conte
sprog->fs_stipple_loc = glGetUniformLocation(prog_id, "pstipple_sampler"); sprog->fs_stipple_loc = glGetUniformLocation(prog_id, "pstipple_sampler");
else else
sprog->fs_stipple_loc = -1; sprog->fs_stipple_loc = -1;
sprog->vs_ws_adjust_loc = glGetUniformLocation(prog_id, "winsys_adjust"); sprog->vs_ws_adjust_loc = glGetUniformLocation(prog_id, "winsys_adjust_y");
for (id = PIPE_SHADER_VERTEX; id <= last_shader; id++) { for (id = PIPE_SHADER_VERTEX; id <= last_shader; id++) {
if (sprog->ss[id]->sel->sinfo.samplers_used_mask) { if (sprog->ss[id]->sel->sinfo.samplers_used_mask) {
uint32_t mask = sprog->ss[id]->sel->sinfo.samplers_used_mask; uint32_t mask = sprog->ss[id]->sel->sinfo.samplers_used_mask;
@ -2945,7 +2945,7 @@ void vrend_draw_vbo(struct vrend_context *ctx,
fprintf(stderr,"illegal VE setup - skipping renderering\n"); fprintf(stderr,"illegal VE setup - skipping renderering\n");
return; return;
} }
glUniform4f(ctx->sub->prog->vs_ws_adjust_loc, 0.0, ctx->sub->viewport_is_negative ? -1.0 : 1.0, ctx->sub->depth_scale, ctx->sub->depth_transform); glUniform1f(ctx->sub->prog->vs_ws_adjust_loc, ctx->sub->viewport_is_negative ? -1.0 : 1.0);
if (ctx->sub->rs_state.clip_plane_enable) { if (ctx->sub->rs_state.clip_plane_enable) {
for (i = 0 ; i < 8; i++) { for (i = 0 ; i < 8; i++) {

@ -882,11 +882,7 @@ static int emit_prescale(struct dump_ctx *ctx)
char buf[255]; char buf[255];
char *sret; char *sret;
snprintf(buf, 255, "gl_Position.y = gl_Position.y * winsys_adjust.y;\n"); snprintf(buf, 255, "gl_Position.y = gl_Position.y * winsys_adjust_y;\n");
sret = add_str_to_glsl_main(ctx, buf);
if (!sret)
return ENOMEM;
snprintf(buf, 255, "gl_Position.z = dot(gl_Position, vec4(0.0, 0.0, winsys_adjust.zw));\n");
sret = add_str_to_glsl_main(ctx, buf); sret = add_str_to_glsl_main(ctx, buf);
if (!sret) if (!sret)
return ENOMEM; return ENOMEM;
@ -2402,7 +2398,7 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
} }
if (ctx->prog_type == TGSI_PROCESSOR_VERTEX) { if (ctx->prog_type == TGSI_PROCESSOR_VERTEX) {
snprintf(buf, 255, "uniform vec4 winsys_adjust;\n"); snprintf(buf, 255, "uniform float winsys_adjust_y;\n");
STRCAT_WITH_RET(glsl_hdr, buf); STRCAT_WITH_RET(glsl_hdr, buf);
if (ctx->has_clipvertex) { if (ctx->has_clipvertex) {
@ -2429,7 +2425,7 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
} }
if (ctx->prog_type == TGSI_PROCESSOR_GEOMETRY) { if (ctx->prog_type == TGSI_PROCESSOR_GEOMETRY) {
snprintf(buf, 255, "uniform vec4 winsys_adjust;\n"); snprintf(buf, 255, "uniform float winsys_adjust_y;\n");
STRCAT_WITH_RET(glsl_hdr, buf); STRCAT_WITH_RET(glsl_hdr, buf);
if (ctx->num_in_clip_dist || ctx->key->clip_plane_enable || ctx->key->vs_has_pervertex) { if (ctx->num_in_clip_dist || ctx->key->clip_plane_enable || ctx->key->vs_has_pervertex) {
int clip_dist; int clip_dist;

Loading…
Cancel
Save