Mesa (master): st/mesa: flush bitmap cache if Z value changes

Brian Paul brianp at kemper.freedesktop.org
Mon Aug 24 19:06:08 UTC 2009


Module: Mesa
Branch: master
Commit: 4eb72568541803fe45d04d9e230212f4f0928ec9
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4eb72568541803fe45d04d9e230212f4f0928ec9

Author: Brian Paul <brianp at vmware.com>
Date:   Fri Aug 21 10:24:50 2009 -0600

st/mesa: flush bitmap cache if Z value changes

When adding a new bitmap to the cache we have to check if the Z value is
changing and flush first if it is.

This is a modified version of a patch from Justin Dou <justin.dou at intel.com>

---

 src/mesa/state_tracker/st_cb_bitmap.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index 8709633..ccf972f 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -94,6 +94,9 @@ struct bitmap_cache
 
    GLfloat color[4];
 
+   /** Bitmap's Z position */
+   GLfloat zpos;
+
    struct pipe_texture *texture;
    struct pipe_transfer *trans;
 
@@ -104,6 +107,8 @@ struct bitmap_cache
 };
 
 
+/** Epsilon for Z comparisons */
+#define Z_EPSILON 1e-06
 
 
 /**
@@ -538,9 +543,7 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
    }
 
    /* draw textured quad */
-   offset = setup_bitmap_vertex_data(st, x, y, width, height,
-                                     ctx->Current.RasterPos[2],
-                                     color);
+   offset = setup_bitmap_vertex_data(st, x, y, width, height, z, color);
 
    util_draw_vertex_buffer(pipe, st->bitmap.vbuf, offset,
                            PIPE_PRIM_TRIANGLE_FAN,
@@ -647,7 +650,7 @@ st_flush_bitmap_cache(struct st_context *st)
          draw_bitmap_quad(st->ctx,
                           cache->xpos,
                           cache->ypos,
-                          st->ctx->Current.RasterPos[2],
+                          cache->zpos,
                           BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT,
                           cache->texture,
                           cache->color);
@@ -687,6 +690,7 @@ accum_bitmap(struct st_context *st,
 {
    struct bitmap_cache *cache = st->bitmap.cache;
    int px = -999, py;
+   const GLfloat z = st->ctx->Current.RasterPos[2];
 
    if (width > BITMAP_CACHE_WIDTH ||
        height > BITMAP_CACHE_HEIGHT)
@@ -697,7 +701,8 @@ accum_bitmap(struct st_context *st,
       py = y - cache->ypos;
       if (px < 0 || px + width > BITMAP_CACHE_WIDTH ||
           py < 0 || py + height > BITMAP_CACHE_HEIGHT ||
-          !TEST_EQ_4V(st->ctx->Current.RasterColor, cache->color)) {
+          !TEST_EQ_4V(st->ctx->Current.RasterColor, cache->color) ||
+          ((fabs(z - cache->zpos) > Z_EPSILON))) {
          /* This bitmap would extend beyond cache bounds, or the bitmap
           * color is changing
           * so flush and continue.
@@ -712,6 +717,7 @@ accum_bitmap(struct st_context *st,
       py = (BITMAP_CACHE_HEIGHT - height) / 2;
       cache->xpos = x;
       cache->ypos = y - py;
+      cache->zpos = z;
       cache->empty = GL_FALSE;
       COPY_4FV(cache->color, st->ctx->Current.RasterColor);
    }




More information about the mesa-commit mailing list