Brian Paul wrote:

Thomas & Jose, I think you are most familiar with this code...

The attached patch fixes a bug I found with softpipe and glDrawPixels(GL_STENCIL_INDEX).

The failing case was basically:

glClear(GL_STENCIL_BUFFER_BIT);
...
glDrawPixels(GL_STENCIL_INDEX).

Drawing stencil images is done by mapping the stencil buffer, writing the stencil values then unmapping the stencil buffer.

With softpipe, a glClear() call just sets tile 'clear' flags; it doesn't actually write to the framebuffer.

So when we mapped the stencil buffer to do the glDrawPixels we weren't getting the glClear()'d values. Later, the tile cache was getting flushed and that would overwrite the glDrawPixels() values.

The attached patch flushes the driver's render cache when we get a pipe_transfer object. Also, I think the PIPE_TEXTURE_USAGE_RENDER_TARGET flag needs to be set on the z/stencil buffer (since we do render to it).

Of course, I forgot the attachment...

-Brian
diff --git a/src/mesa/state_tracker/st_inlines.h 
b/src/mesa/state_tracker/st_inlines.h
index a41cfeb..1d0099d 100644
--- a/src/mesa/state_tracker/st_inlines.h
+++ b/src/mesa/state_tracker/st_inlines.h
@@ -56,6 +56,8 @@ st_cond_flush_get_tex_transfer(struct st_context *st,
    struct pipe_screen *screen = st->pipe->screen;
 
    st_teximage_flush_before_map(st, pt, face, level, usage);
+   if (pt->tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET)
+      st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL);
    return screen->get_tex_transfer(screen, pt, face, level, zslice, usage,
                                   x, y, w, h);
 }
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to