On 08/05/2014 10:16 AM, Roland Scheidegger wrote:
Am 04.08.2014 18:08, schrieb Brian Paul:
Specify the quad's Z position in clip coordinate space, not
normalized Z space.  Use viewport scale, translation = 0.5, 0.5.

Before, we were specifying the quad's Z position in [0,1] and using
viewport scale=1.0, translate=0.0.  That works fine, unless your
driver needs to work in clip coordinate space and needs to
reconstruct viewport near/far values from the scale/translation
factors.  The VMware svga driver falls into that category.

When we did that reconstruction we wound up with near=-1 and far=1
which are outside the limits of [0,1].  In some cases, this caused
the quad to be drawn at the wrong depth.  In other cases it was
clipped away.

Fixes some scissored depth clears with VMware driver.  This should
have no effect on other drivers.
---
  src/mesa/state_tracker/st_cb_clear.c |    7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_clear.c 
b/src/mesa/state_tracker/st_cb_clear.c
index 4bfa8d7..4ca6de3 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -173,6 +173,9 @@ draw_quad(struct st_context *st,
        return;
     }

+   /* Convert Z from [0,1] to [-1,1] range */
+   z = z * 2.0f - 1.0f;
+
     /* positions */
     vertices[0][0][0] = x0;
     vertices[0][0][1] = y0;
@@ -319,11 +322,11 @@ clear_with_quad(struct gl_context *ctx, unsigned 
clear_buffers)
        struct pipe_viewport_state vp;
        vp.scale[0] = 0.5f * fb_width;
        vp.scale[1] = fb_height * (invert ? -0.5f : 0.5f);
-      vp.scale[2] = 1.0f;
+      vp.scale[2] = 0.5;
0.5f for consistency? Same below.

Done.



        vp.scale[3] = 1.0f;
        vp.translate[0] = 0.5f * fb_width;
        vp.translate[1] = 0.5f * fb_height;
-      vp.translate[2] = 0.0f;
+      vp.translate[2] = 0.5;
        vp.translate[3] = 0.0f;
        cso_set_viewport(st->cso_context, &vp);
     }


Other than that,
Reviewed-by: Roland Scheidegger <srol...@vmware.com>

Thanks!


I thought though the same math is used in other places too, but I could
be wrong.

We're already using the 0.5 value for scale and translate in the glBitmap, glDrawPixels, glCopyPixels functions. So, I'm really just making the glClear code work the same way. I can note that in the commit msg.

-Brian

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to