[virglrenderer-devel] [PATCH] Remove winsys_adjust.zw (DepthRange scale, trans)
Joe M. Kniss
djmk at chromium.org
Thu Feb 22 23:57:19 UTC 2018
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 at google.com>
---
src/vrend_renderer.c | 4 ++--
src/vrend_shader.c | 10 +++-------
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index ec37fc8..ebfecd1 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -944,7 +944,7 @@ static struct vrend_linked_shader_program *add_shader_program(struct vrend_conte
sprog->fs_stipple_loc = glGetUniformLocation(prog_id, "pstipple_sampler");
else
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++) {
if (sprog->ss[id]->sel->sinfo.samplers_used_mask) {
uint32_t mask = sprog->ss[id]->sel->sinfo.samplers_used_mask;
@@ -2890,7 +2890,7 @@ void vrend_draw_vbo(struct vrend_context *ctx,
fprintf(stderr,"illegal VE setup - skipping renderering\n");
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) {
for (i = 0 ; i < 8; i++) {
diff --git a/src/vrend_shader.c b/src/vrend_shader.c
index 8e925d3..1581877 100644
--- a/src/vrend_shader.c
+++ b/src/vrend_shader.c
@@ -853,11 +853,7 @@ static int emit_prescale(struct dump_ctx *ctx)
char buf[255];
char *sret;
- 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");
+ 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;
@@ -2284,7 +2280,7 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
}
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);
if (ctx->has_clipvertex) {
@@ -2311,7 +2307,7 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
}
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);
if (ctx->num_in_clip_dist || ctx->key->clip_plane_enable || ctx->key->vs_has_pervertex) {
int clip_dist;
--
2.16.1.291.g4437f3f132-goog
More information about the virglrenderer-devel
mailing list