gallium: check ctx->DrawBuffer before flushing bitmap cache.

During context unbind, we may not have a draw buffer.
This fixes demos/tunnel2.c
This commit is contained in:
Brian Paul 2008-04-07 16:45:17 -06:00
parent d28a2004b8
commit 985134211d
1 changed files with 27 additions and 25 deletions

View File

@ -547,36 +547,38 @@ void
st_flush_bitmap_cache(struct st_context *st) st_flush_bitmap_cache(struct st_context *st)
{ {
if (!st->bitmap.cache->empty) { if (!st->bitmap.cache->empty) {
struct bitmap_cache *cache = st->bitmap.cache; if (st->ctx->DrawBuffer) {
struct pipe_context *pipe = st->pipe; struct bitmap_cache *cache = st->bitmap.cache;
struct pipe_screen *screen = pipe->screen; struct pipe_context *pipe = st->pipe;
struct pipe_surface *surf; struct pipe_screen *screen = pipe->screen;
void *dest; struct pipe_surface *surf;
void *dest;
assert(cache->xmin <= cache->xmax); assert(cache->xmin <= cache->xmax);
/* /*
printf("flush size %d x %d at %d, %d\n", printf("flush size %d x %d at %d, %d\n",
cache->xmax - cache->xmin, cache->xmax - cache->xmin,
cache->ymax - cache->ymin, cache->ymax - cache->ymin,
cache->xpos, cache->ypos); cache->xpos, cache->ypos);
*/ */
/* update the texture map image */ /* update the texture map image */
surf = screen->get_tex_surface(screen, cache->texture, 0, 0, 0); surf = screen->get_tex_surface(screen, cache->texture, 0, 0, 0);
dest = pipe_surface_map(surf); dest = pipe_surface_map(surf);
memcpy(dest, cache->buffer, sizeof(cache->buffer)); memcpy(dest, cache->buffer, sizeof(cache->buffer));
pipe_surface_unmap(surf); pipe_surface_unmap(surf);
pipe_surface_reference(&surf, NULL); pipe_surface_reference(&surf, NULL);
pipe->texture_update(pipe, cache->texture, 0, 0x1); pipe->texture_update(pipe, cache->texture, 0, 0x1);
draw_bitmap_quad(st->ctx, draw_bitmap_quad(st->ctx,
cache->xpos, cache->xpos,
cache->ypos, cache->ypos,
st->ctx->Current.RasterPos[2], st->ctx->Current.RasterPos[2],
BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT, BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT,
cache->texture); cache->texture);
}
reset_cache(st); reset_cache(st);
} }
} }