From 579ef8ab1984d895867f547afa60b3bec4c4599a Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 4 Mar 2009 16:06:05 +0000 Subject: vbo: avoid getting buffer_ptr and buffer_map out of sync --- src/mesa/vbo/vbo_exec_api.c | 3 +++ src/mesa/vbo/vbo_exec_draw.c | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 9c2d065913..a1e66aec63 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -675,6 +675,7 @@ void vbo_use_buffer_objects(GLcontext *ctx) if (exec->vtx.buffer_map) { _mesa_align_free(exec->vtx.buffer_map); exec->vtx.buffer_map = NULL; + exec->vtx.buffer_ptr = NULL; } /* Allocate a real buffer object now */ @@ -700,6 +701,7 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) ASSERT(!exec->vtx.buffer_map); exec->vtx.buffer_map = (GLfloat *)ALIGN_MALLOC(VBO_VERT_BUFFER_SIZE, 64); + exec->vtx.buffer_ptr = exec->vtx.buffer_map; vbo_exec_vtxfmt_init( exec ); @@ -735,6 +737,7 @@ void vbo_exec_vtx_destroy( struct vbo_exec_context *exec ) if (exec->vtx.buffer_map) { ALIGN_FREE(exec->vtx.buffer_map); exec->vtx.buffer_map = NULL; + exec->vtx.buffer_ptr = NULL; } } } diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index 38b6c56f47..4b44b30b32 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -243,7 +243,10 @@ static void vbo_exec_vtx_unmap( struct vbo_exec_context *exec ) exec->vtx.buffer_used += (exec->vtx.buffer_ptr - exec->vtx.buffer_map) * sizeof(float); - + + + assert(exec->vtx.buffer_ptr != NULL); + ctx->Driver.UnmapBuffer(ctx, target, exec->vtx.bufferobj); exec->vtx.buffer_map = NULL; exec->vtx.buffer_ptr = NULL; @@ -296,6 +299,7 @@ void vbo_exec_vtx_map( struct vbo_exec_context *exec ) (GLfloat *)ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj); } + exec->vtx.buffer_ptr = exec->vtx.buffer_map; if (0) _mesa_printf("map %d..\n", exec->vtx.buffer_used); } -- cgit v1.2.3 From fba923ff4415ce8a14c890dea65bcb07b2f87fb5 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 4 Mar 2009 16:09:14 +0000 Subject: Revert "vbo: avoid getting buffer_ptr and buffer_map out of sync" This fixed a minor bug but broke everything else. This reverts commit 579ef8ab1984d895867f547afa60b3bec4c4599a. --- src/mesa/vbo/vbo_exec_api.c | 3 --- src/mesa/vbo/vbo_exec_draw.c | 6 +----- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index a1e66aec63..9c2d065913 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -675,7 +675,6 @@ void vbo_use_buffer_objects(GLcontext *ctx) if (exec->vtx.buffer_map) { _mesa_align_free(exec->vtx.buffer_map); exec->vtx.buffer_map = NULL; - exec->vtx.buffer_ptr = NULL; } /* Allocate a real buffer object now */ @@ -701,7 +700,6 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) ASSERT(!exec->vtx.buffer_map); exec->vtx.buffer_map = (GLfloat *)ALIGN_MALLOC(VBO_VERT_BUFFER_SIZE, 64); - exec->vtx.buffer_ptr = exec->vtx.buffer_map; vbo_exec_vtxfmt_init( exec ); @@ -737,7 +735,6 @@ void vbo_exec_vtx_destroy( struct vbo_exec_context *exec ) if (exec->vtx.buffer_map) { ALIGN_FREE(exec->vtx.buffer_map); exec->vtx.buffer_map = NULL; - exec->vtx.buffer_ptr = NULL; } } } diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index 4b44b30b32..38b6c56f47 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -243,10 +243,7 @@ static void vbo_exec_vtx_unmap( struct vbo_exec_context *exec ) exec->vtx.buffer_used += (exec->vtx.buffer_ptr - exec->vtx.buffer_map) * sizeof(float); - - - assert(exec->vtx.buffer_ptr != NULL); - + ctx->Driver.UnmapBuffer(ctx, target, exec->vtx.bufferobj); exec->vtx.buffer_map = NULL; exec->vtx.buffer_ptr = NULL; @@ -299,7 +296,6 @@ void vbo_exec_vtx_map( struct vbo_exec_context *exec ) (GLfloat *)ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj); } - exec->vtx.buffer_ptr = exec->vtx.buffer_map; if (0) _mesa_printf("map %d..\n", exec->vtx.buffer_used); } -- cgit v1.2.3 From ca06c0c16d09d58f96736aa095e1a592862a9427 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 4 Mar 2009 09:34:46 -0700 Subject: cell: update cell driver after gallium reference count changes --- src/gallium/drivers/cell/ppu/cell_state_shader.c | 4 +--- src/gallium/drivers/cell/ppu/cell_texture.c | 5 ++--- src/gallium/winsys/xlib/xlib_cell.c | 15 +++++++-------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/gallium/drivers/cell/ppu/cell_state_shader.c b/src/gallium/drivers/cell/ppu/cell_state_shader.c index bf517ea563..6568c784fe 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_shader.c +++ b/src/gallium/drivers/cell/ppu/cell_state_shader.c @@ -193,9 +193,7 @@ cell_set_constant_buffer(struct pipe_context *pipe, draw_flush(cell->draw); /* note: reference counting */ - pipe_buffer_reference(pipe->screen, - &cell->constants[shader].buffer, - buf->buffer); + pipe_buffer_reference(&cell->constants[shader].buffer, buf->buffer); if (shader == PIPE_SHADER_VERTEX) cell->dirty |= CELL_NEW_VS_CONSTANTS; diff --git a/src/gallium/drivers/cell/ppu/cell_texture.c b/src/gallium/drivers/cell/ppu/cell_texture.c index bc6afa94a8..e26594448f 100644 --- a/src/gallium/drivers/cell/ppu/cell_texture.c +++ b/src/gallium/drivers/cell/ppu/cell_texture.c @@ -129,7 +129,7 @@ cell_texture_destroy(struct pipe_texture *pt) struct cell_texture *ct = cell_texture(pt); if (ct->mapped) { - pipe_buffer_unmap(screen, ct->buffer); + pipe_buffer_unmap(ct->buffer->screen, ct->buffer); ct->mapped = NULL; } @@ -308,7 +308,7 @@ cell_get_tex_surface(struct pipe_screen *screen, static void -cell_tex_surface_destroy(struct pipe_surface *s) +cell_tex_surface_destroy(struct pipe_surface *surf) { pipe_texture_reference(&surf->texture, NULL); FREE(surf); @@ -336,7 +336,6 @@ cell_get_tex_transfer(struct pipe_screen *screen, ctrans = CALLOC_STRUCT(cell_transfer); if (ctrans) { struct pipe_transfer *pt = &ctrans->base; - pipe_reference_init(&pt->reference, 1); pipe_texture_reference(&pt->texture, texture); pt->format = texture->format; pt->block = texture->block; diff --git a/src/gallium/winsys/xlib/xlib_cell.c b/src/gallium/winsys/xlib/xlib_cell.c index a5dbdf30f6..13e609f58f 100644 --- a/src/gallium/winsys/xlib/xlib_cell.c +++ b/src/gallium/winsys/xlib/xlib_cell.c @@ -107,22 +107,21 @@ xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf) } static void -xm_buffer_destroy(struct pipe_winsys *pws, +xm_buffer_destroy(/*struct pipe_winsys *pws,*/ struct pipe_buffer *buf) { struct xm_buffer *oldBuf = xm_buffer(buf); - if (oldBuf->data) { - { + if (oldBuf) { + if (oldBuf->data) { if (!oldBuf->userBuffer) { align_free(oldBuf->data); } - } - oldBuf->data = NULL; + oldBuf->data = NULL; + } + free(oldBuf); } - - free(oldBuf); } @@ -371,7 +370,7 @@ xlib_create_cell_winsys( void ) static struct pipe_screen * -xlib_create_cell_screen( struct pipe_winsys *pws ) +xlib_create_cell_screen( void ) { struct pipe_winsys *winsys; struct pipe_screen *screen; -- cgit v1.2.3 From 89f1f8f0b8fb684a7b1fce5bfbb961e4521745d7 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 4 Mar 2009 16:43:13 +0000 Subject: mesa: Clear cache->trans after destroying the transfer. --- src/mesa/state_tracker/st_cb_bitmap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index f77ac14762..eecedc20f0 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -624,6 +624,7 @@ st_flush_bitmap_cache(struct st_context *st) cache->buffer = NULL; screen->tex_transfer_destroy(cache->trans); + cache->trans = NULL; draw_bitmap_quad(st->ctx, cache->xpos, -- cgit v1.2.3