diff options
author | Michel Dänzer <daenzer@vmware.com> | 2009-03-04 11:58:48 +0100 |
---|---|---|
committer | Michel Dänzer <daenzer@vmware.com> | 2009-03-04 11:58:48 +0100 |
commit | 5e27cd46c04a9e7b5904cc014bffd0f4daae31fe (patch) | |
tree | a57289f14d69f1977dfaee592af908052d726b8c /src/gallium/auxiliary | |
parent | 60041203d5847de8ab71842a6ce5d33d96cc4930 (diff) |
gallium: Unify reference counting.
The core reference counting code is centralized in p_refcnt.h.
This has some consequences related to struct pipe_buffer:
* The screen member of struct pipe_buffer must be initialized, or
pipe_buffer_reference() will crash trying to destroy a buffer with reference
count 0. u_simple_screen takes care of this, but I may have missed some of
the drivers not using it.
* Except for rare exceptions deep in winsys code, buffers must always be
allocated via pipe_buffer_create() or via screen->*buffer_create() rather
than via winsys->*buffer_create().
Diffstat (limited to 'src/gallium/auxiliary')
19 files changed, 91 insertions, 84 deletions
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c index 80c9c918a9..e83a075794 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c +++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c @@ -446,7 +446,7 @@ aaline_create_texture(struct aaline_stage *aaline) /* unmap */ screen->transfer_unmap(screen, transfer); - screen->tex_transfer_release(screen, &transfer); + screen->tex_transfer_destroy(transfer); } return TRUE; } @@ -728,7 +728,7 @@ aaline_destroy(struct draw_stage *stage) aaline->pipe->delete_sampler_state(aaline->pipe, aaline->sampler_cso); if (aaline->texture) - pipe_texture_release(&aaline->texture); + pipe_texture_reference(&aaline->texture, NULL); draw_free_temp_verts( stage ); diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c index e68c824c86..fa7bc67476 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c +++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c @@ -406,7 +406,7 @@ pstip_update_texture(struct pstip_stage *pstip) /* unmap */ screen->transfer_unmap(screen, transfer); - screen->tex_transfer_release(screen, &transfer); + screen->tex_transfer_destroy(transfer); } @@ -572,7 +572,7 @@ pstip_destroy(struct draw_stage *stage) pstip->pipe->delete_sampler_state(pstip->pipe, pstip->sampler_cso); - pipe_texture_release(&pstip->texture); + pipe_texture_reference(&pstip->texture, NULL); draw_free_temp_verts( stage ); FREE( stage ); diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer.h b/src/gallium/auxiliary/pipebuffer/pb_buffer.h index e6b0b30ff4..be1654c654 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer.h +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer.h @@ -159,7 +159,7 @@ pb_map(struct pb_buffer *buf, assert(buf); if(!buf) return NULL; - assert(buf->base.refcount > 0); + assert(buf->base.reference.count > 0); return buf->vtbl->map(buf, flags); } @@ -170,7 +170,7 @@ pb_unmap(struct pb_buffer *buf) assert(buf); if(!buf) return; - assert(buf->base.refcount > 0); + assert(buf->base.reference.count > 0); buf->vtbl->unmap(buf); } @@ -186,7 +186,7 @@ pb_get_base_buffer( struct pb_buffer *buf, offset = 0; return; } - assert(buf->base.refcount > 0); + assert(buf->base.reference.count > 0); assert(buf->vtbl->get_base_buffer); buf->vtbl->get_base_buffer(buf, base_buf, offset); assert(*base_buf); @@ -222,29 +222,18 @@ pb_destroy(struct pb_buffer *buf) assert(buf); if(!buf) return; - assert(buf->base.refcount == 0); + assert(buf->base.reference.count == 0); buf->vtbl->destroy(buf); } - -/* XXX: thread safety issues! - */ static INLINE void pb_reference(struct pb_buffer **dst, struct pb_buffer *src) { - if (src) { - assert(src->base.refcount); - src->base.refcount++; - } - - if (*dst) { - assert((*dst)->base.refcount); - if(--(*dst)->base.refcount == 0) - pb_destroy( *dst ); - } + struct pb_buffer *old = *dst; - *dst = src; + if (pipe_reference((struct pipe_reference**)dst, &src->base.reference)) + pb_destroy( old ); } diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c index 17ff61b675..e4adf8aad7 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c @@ -115,7 +115,7 @@ _fenced_buffer_add(struct fenced_buffer *fenced_buf) { struct fenced_buffer_list *fenced_list = fenced_buf->list; - assert(fenced_buf->base.base.refcount); + assert(fenced_buf->base.base.reference.count); assert(fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE); assert(fenced_buf->fence); @@ -137,7 +137,7 @@ _fenced_buffer_destroy(struct fenced_buffer *fenced_buf) { struct fenced_buffer_list *fenced_list = fenced_buf->list; - assert(!fenced_buf->base.base.refcount); + assert(!fenced_buf->base.base.reference.count); assert(!fenced_buf->fence); #ifdef DEBUG assert(fenced_buf->head.prev); @@ -177,7 +177,7 @@ _fenced_buffer_remove(struct fenced_buffer_list *fenced_list, ++fenced_list->numUnfenced; #endif - if(!fenced_buf->base.base.refcount) + if(!fenced_buf->base.base.reference.count) _fenced_buffer_destroy(fenced_buf); } @@ -253,7 +253,7 @@ fenced_buffer_destroy(struct pb_buffer *buf) struct fenced_buffer_list *fenced_list = fenced_buf->list; pipe_mutex_lock(fenced_list->mutex); - assert(fenced_buf->base.base.refcount == 0); + assert(fenced_buf->base.base.reference.count == 0); if (fenced_buf->fence) { struct pb_fence_ops *ops = fenced_list->ops; if(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) { @@ -461,7 +461,7 @@ fenced_buffer_create(struct fenced_buffer_list *fenced_list, return NULL; } - buf->base.base.refcount = 1; + pipe_reference_init(&buf->base.base.reference, 1); buf->base.base.alignment = buffer->base.alignment; buf->base.base.usage = buffer->base.usage; buf->base.base.size = buffer->base.size; @@ -527,7 +527,7 @@ fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list) pipe_mutex_lock(fenced_list->mutex); debug_printf("%10s %7s %10s %s\n", - "buffer", "refcount", "fence", "signalled"); + "buffer", "reference.count", "fence", "signalled"); curr = fenced_list->unfenced.next; next = curr->next; @@ -536,7 +536,7 @@ fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list) assert(!fenced_buf->fence); debug_printf("%10p %7u\n", fenced_buf, - fenced_buf->base.base.refcount); + fenced_buf->base.base.reference.count); curr = next; next = curr->next; } @@ -549,7 +549,7 @@ fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list) signaled = ops->fence_signalled(ops, fenced_buf->fence, 0); debug_printf("%10p %7u %10p %s\n", fenced_buf, - fenced_buf->base.base.refcount, + fenced_buf->base.base.reference.count, fenced_buf->fence, signaled == 0 ? "y" : "n"); curr = next; diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c index 282802b171..689fd74771 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c @@ -132,7 +132,7 @@ pb_malloc_buffer_create(size_t size, if(!buf) return NULL; - buf->base.base.refcount = 1; + pipe_reference_init(&buf->base.base.reference, 1); buf->base.base.alignment = desc->alignment; buf->base.base.usage = desc->usage; buf->base.base.size = size; diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c index 29117efe9b..06ed0002ca 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c @@ -112,7 +112,7 @@ _pb_cache_buffer_destroy(struct pb_cache_buffer *buf) LIST_DEL(&buf->head); assert(mgr->numDelayed); --mgr->numDelayed; - assert(!buf->base.base.refcount); + assert(!buf->base.base.reference.count); pb_reference(&buf->buffer, NULL); FREE(buf); } @@ -153,7 +153,7 @@ pb_cache_buffer_destroy(struct pb_buffer *_buf) struct pb_cache_manager *mgr = buf->mgr; pipe_mutex_lock(mgr->mutex); - assert(buf->base.base.refcount == 0); + assert(buf->base.base.reference.count == 0); _pb_cache_buffer_list_check_free(mgr); @@ -293,7 +293,8 @@ pb_cache_manager_create_buffer(struct pb_manager *_mgr, if(buf) { LIST_DEL(&buf->head); pipe_mutex_unlock(mgr->mutex); - ++buf->base.base.refcount; + /* Increase refcount */ + pb_reference((struct pb_buffer**)&buf, &buf->base); return &buf->base; } @@ -309,12 +310,12 @@ pb_cache_manager_create_buffer(struct pb_manager *_mgr, return NULL; } - assert(buf->buffer->base.refcount >= 1); + assert(buf->buffer->base.reference.count >= 1); assert(pb_check_alignment(desc->alignment, buf->buffer->base.alignment)); assert(pb_check_usage(desc->usage, buf->buffer->base.usage)); assert(buf->buffer->base.size >= size); - buf->base.base.refcount = 1; + pipe_reference_init(&buf->base.base.reference, 1); buf->base.base.alignment = buf->buffer->base.alignment; buf->base.base.usage = buf->buffer->base.usage; buf->base.base.size = buf->buffer->base.size; diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c index 21079b8bfd..37ed64b84f 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c @@ -206,9 +206,9 @@ pb_debug_buffer_check(struct pb_debug_buffer *buf) static void pb_debug_buffer_destroy(struct pb_buffer *_buf) { - struct pb_debug_buffer *buf = pb_debug_buffer(_buf); + struct pb_debug_buffer *buf = pb_debug_buffer(_buf); - assert(!buf->base.base.refcount); + assert(!buf->base.base.reference.count); pb_debug_buffer_check(buf); @@ -315,12 +315,12 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr, return NULL; } - assert(buf->buffer->base.refcount >= 1); + assert(buf->buffer->base.reference.count >= 1); assert(pb_check_alignment(real_desc.alignment, buf->buffer->base.alignment)); assert(pb_check_usage(real_desc.usage, buf->buffer->base.usage)); assert(buf->buffer->base.size >= real_size); - buf->base.base.refcount = 1; + pipe_reference_init(&buf->base.base.reference, 1); buf->base.base.alignment = desc->alignment; buf->base.base.usage = desc->usage; buf->base.base.size = size; diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c index 85ff3a09de..9b0f77bedb 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c @@ -97,11 +97,11 @@ mm_buffer_destroy(struct pb_buffer *buf) struct mm_buffer *mm_buf = mm_buffer(buf); struct mm_pb_manager *mm = mm_buf->mgr; - assert(buf->base.refcount == 0); + assert(mm_buf->base.base.reference.count == 0); pipe_mutex_lock(mm->mutex); u_mmFreeMem(mm_buf->block); - FREE(buf); + FREE(mm_buf); pipe_mutex_unlock(mm->mutex); } @@ -189,7 +189,7 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr, return NULL; } - mm_buf->base.base.refcount = 1; + pipe_reference_init(&mm_buf->base.base.reference, 1); mm_buf->base.base.alignment = desc->alignment; mm_buf->base.base.usage = desc->usage; mm_buf->base.base.size = size; diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c index 3d9c7bba0b..4f7e6b1c4d 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c @@ -242,7 +242,7 @@ pb_ondemand_manager_create_buffer(struct pb_manager *_mgr, if(!buf) return NULL; - buf->base.base.refcount = 1; + pipe_reference_init(&buf->base.base.reference, 1); buf->base.base.alignment = desc->alignment; buf->base.base.usage = desc->usage; buf->base.base.size = size; diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c index 12447acfd9..ca6c14a627 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c @@ -108,7 +108,7 @@ pool_buffer_destroy(struct pb_buffer *buf) struct pool_buffer *pool_buf = pool_buffer(buf); struct pool_pb_manager *pool = pool_buf->mgr; - assert(pool_buf->base.base.refcount == 0); + assert(pool_buf->base.base.reference.count == 0); pipe_mutex_lock(pool->mutex); LIST_ADD(&pool_buf->head, &pool->free); @@ -216,8 +216,8 @@ pool_bufmgr_create_buffer(struct pb_manager *mgr, pipe_mutex_unlock(pool->mutex); pool_buf = LIST_ENTRY(struct pool_buffer, item, head); - assert(pool_buf->base.base.refcount == 0); - pool_buf->base.base.refcount = 1; + assert(pool_buf->base.base.reference.count == 0); + pipe_reference_init(&pool_buf->base.base.reference, 1); pool_buf->base.base.alignment = desc->alignment; pool_buf->base.base.usage = desc->usage; @@ -295,7 +295,7 @@ pool_bufmgr_create(struct pb_manager *provider, pool_buf = pool->bufs; for (i = 0; i < numBufs; ++i) { - pool_buf->base.base.refcount = 0; + pipe_reference_init(&pool_buf->base.base.reference, 0); pool_buf->base.base.alignment = 0; pool_buf->base.base.usage = 0; pool_buf->base.base.size = bufSize; diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c index a3259351b9..2cdb5a5e29 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c @@ -202,7 +202,7 @@ pb_slab_buffer_destroy(struct pb_buffer *_buf) pipe_mutex_lock(mgr->mutex); - assert(buf->base.base.refcount == 0); + assert(buf->base.base.reference.count == 0); buf->mapCount = 0; @@ -340,7 +340,7 @@ pb_slab_create(struct pb_slab_manager *mgr) buf = slab->buffers; for (i=0; i < numBuffers; ++i) { - buf->base.base.refcount = 0; + pipe_reference_init(&buf->base.base.reference, 0); buf->base.base.size = mgr->bufSize; buf->base.base.alignment = 0; buf->base.base.usage = 0; @@ -419,7 +419,7 @@ pb_slab_manager_create_buffer(struct pb_manager *_mgr, pipe_mutex_unlock(mgr->mutex); buf = LIST_ENTRY(struct pb_slab_buffer, list, head); - ++buf->base.base.refcount; + pipe_reference_init(&buf->base.base.reference, 1); buf->base.base.alignment = desc->alignment; buf->base.base.usage = desc->usage; diff --git a/src/gallium/auxiliary/sct/sct.c b/src/gallium/auxiliary/sct/sct.c index 49bb7ea92e..fcfa04ef7d 100644 --- a/src/gallium/auxiliary/sct/sct.c +++ b/src/gallium/auxiliary/sct/sct.c @@ -372,7 +372,7 @@ sct_flush_textures(struct surface_context_tracker *sct, for (tl = ci->textures_used; tl; tl = next) { next = tl->next; - pipe_texture_release(&tl->texture); + pipe_texture_reference(&tl->texture, NULL); FREE(tl); } ci->textures_used = NULL; diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index 4cc720269d..813e41f1b1 100644 --- a/src/gallium/auxiliary/util/u_blit.c +++ b/src/gallium/auxiliary/util/u_blit.c @@ -38,6 +38,7 @@ #include "pipe/p_defines.h" #include "pipe/p_inlines.h" #include "pipe/p_shader_tokens.h" +#include "pipe/p_state.h" #include "util/u_blit.h" #include "util/u_draw_quad.h" @@ -166,7 +167,7 @@ util_destroy_blit(struct blit_state *ctx) FREE((void*) ctx->vert_shader.tokens); FREE((void*) ctx->frag_shader.tokens); - pipe_buffer_reference(pipe->screen, &ctx->vbuf, NULL); + pipe_buffer_reference(&ctx->vbuf, NULL); FREE(ctx); } @@ -368,7 +369,7 @@ util_blit_pixels(struct blit_state *ctx, /* free the surface, update the texture if necessary. */ - screen->tex_surface_release(screen, &texSurf); + pipe_surface_reference(&texSurf, NULL); /* save state (restored below) */ cso_save_blend(ctx->cso); @@ -429,7 +430,7 @@ util_blit_pixels(struct blit_state *ctx, cso_restore_vertex_shader(ctx->cso); cso_restore_viewport(ctx->cso); - screen->texture_release(screen, &tex); + pipe_texture_reference(&tex, NULL); } @@ -438,7 +439,7 @@ util_blit_pixels(struct blit_state *ctx, */ void util_blit_flush( struct blit_state *ctx ) { - pipe_buffer_reference(ctx->pipe->screen, &ctx->vbuf, NULL); + pipe_buffer_reference(&ctx->vbuf, NULL); ctx->vbuf_slot = 0; } @@ -461,8 +462,6 @@ util_blit_pixels_tex(struct blit_state *ctx, int dstX1, int dstY1, float z, uint filter) { - struct pipe_context *pipe = ctx->pipe; - struct pipe_screen *screen = pipe->screen; struct pipe_framebuffer_state fb; float s0, t0, s1, t1; unsigned offset; @@ -478,8 +477,10 @@ util_blit_pixels_tex(struct blit_state *ctx, t0 = srcY0 / (float)tex->height[0]; t1 = srcY1 / (float)tex->height[0]; - assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)); + assert(ctx->pipe->screen->is_format_supported(ctx->pipe->screen, dst->format, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_RENDER_TARGET, + 0)); /* save state (restored below) */ cso_save_blend(ctx->cso); diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c index e05c419b2f..f96e27e09f 100644 --- a/src/gallium/auxiliary/util/u_debug.c +++ b/src/gallium/auxiliary/util/u_debug.c @@ -680,7 +680,7 @@ void debug_dump_surface(const char *prefix, screen->transfer_unmap(screen, transfer); error: - screen->tex_transfer_release(screen, &transfer); + screen->tex_transfer_destroy(transfer); } @@ -785,7 +785,7 @@ debug_dump_surface_bmp(const char *filename, } } - screen->tex_transfer_release(screen, &transfer); + screen->tex_transfer_destroy(transfer); util_stream_close(stream); error2: diff --git a/src/gallium/auxiliary/util/u_draw_quad.c b/src/gallium/auxiliary/util/u_draw_quad.c index f0bcd75899..4110485fb1 100644 --- a/src/gallium/auxiliary/util/u_draw_quad.c +++ b/src/gallium/auxiliary/util/u_draw_quad.c @@ -129,6 +129,6 @@ util_draw_texquad(struct pipe_context *pipe, util_draw_vertex_buffer(pipe, vbuf, 0, PIPE_PRIM_TRIANGLE_FAN, 4, 2); } - pipe_buffer_reference(pipe->screen, &vbuf, NULL); + pipe_buffer_reference(&vbuf, NULL); } } diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index 1857a71dd8..2b675e71b2 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -39,6 +39,7 @@ #include "pipe/p_defines.h" #include "pipe/p_inlines.h" #include "pipe/p_shader_tokens.h" +#include "pipe/p_state.h" #include "util/u_memory.h" #include "util/u_draw_quad.h" @@ -1138,8 +1139,8 @@ make_1d_mipmap(struct gen_mipmap_state *ctx, screen->transfer_unmap(screen, srcTrans); screen->transfer_unmap(screen, dstTrans); - screen->tex_transfer_release(screen, &srcTrans); - screen->tex_transfer_release(screen, &dstTrans); + screen->tex_transfer_destroy(srcTrans); + screen->tex_transfer_destroy(dstTrans); } } @@ -1183,8 +1184,8 @@ make_2d_mipmap(struct gen_mipmap_state *ctx, screen->transfer_unmap(screen, srcTrans); screen->transfer_unmap(screen, dstTrans); - screen->tex_transfer_release(screen, &srcTrans); - screen->tex_transfer_release(screen, &dstTrans); + screen->tex_transfer_destroy(srcTrans); + screen->tex_transfer_destroy(dstTrans); } } @@ -1228,8 +1229,8 @@ make_3d_mipmap(struct gen_mipmap_state *ctx, screen->transfer_unmap(screen, srcTrans); screen->transfer_unmap(screen, dstTrans); - screen->tex_transfer_release(screen, &srcTrans); - screen->tex_transfer_release(screen, &dstTrans); + screen->tex_transfer_destroy(srcTrans); + screen->tex_transfer_destroy(dstTrans); } #else (void) reduce_3d; @@ -1414,7 +1415,7 @@ util_destroy_gen_mipmap(struct gen_mipmap_state *ctx) FREE((void*) ctx->vert_shader.tokens); FREE((void*) ctx->frag_shader.tokens); - pipe_buffer_reference(pipe->screen, &ctx->vbuf, NULL); + pipe_buffer_reference(&ctx->vbuf, NULL); FREE(ctx); } @@ -1426,7 +1427,7 @@ util_destroy_gen_mipmap(struct gen_mipmap_state *ctx) */ void util_gen_mipmap_flush( struct gen_mipmap_state *ctx ) { - pipe_buffer_reference(ctx->pipe->screen, &ctx->vbuf, NULL); + pipe_buffer_reference(&ctx->vbuf, NULL); ctx->vbuf_slot = 0; } diff --git a/src/gallium/auxiliary/util/u_rect.c b/src/gallium/auxiliary/util/u_rect.c index 6e24e594e4..74259d453b 100644 --- a/src/gallium/auxiliary/util/u_rect.c +++ b/src/gallium/auxiliary/util/u_rect.c @@ -218,8 +218,8 @@ util_surface_copy(struct pipe_context *pipe, pipe->screen->transfer_unmap(pipe->screen, src_trans); pipe->screen->transfer_unmap(pipe->screen, dst_trans); - screen->tex_transfer_release(screen, &src_trans); - screen->tex_transfer_release(screen, &dst_trans); + screen->tex_transfer_destroy(src_trans); + screen->tex_transfer_destroy(dst_trans); } @@ -297,5 +297,5 @@ util_surface_fill(struct pipe_context *pipe, } pipe->screen->transfer_unmap(pipe->screen, dst_trans); - screen->tex_transfer_release(screen, &dst_trans); + screen->tex_transfer_destroy(dst_trans); } diff --git a/src/gallium/auxiliary/util/u_simple_screen.c b/src/gallium/auxiliary/util/u_simple_screen.c index 089bbbc48a..8114b53cd0 100644 --- a/src/gallium/auxiliary/util/u_simple_screen.c +++ b/src/gallium/auxiliary/util/u_simple_screen.c @@ -28,6 +28,7 @@ #include "u_simple_screen.h" #include "pipe/p_screen.h" +#include "pipe/p_state.h" #include "pipe/internal/p_winsys_screen.h" @@ -37,8 +38,12 @@ pass_buffer_create(struct pipe_screen *screen, unsigned usage, unsigned size) { - return screen->winsys->buffer_create(screen->winsys, - alignment, usage, size); + struct pipe_buffer *buffer = + screen->winsys->buffer_create(screen->winsys, alignment, usage, size); + + buffer->screen = screen; + + return buffer; } static struct pipe_buffer * @@ -46,8 +51,13 @@ pass_user_buffer_create(struct pipe_screen *screen, void *ptr, unsigned bytes) { - return screen->winsys->user_buffer_create(screen->winsys, + struct pipe_buffer *buffer = + screen->winsys->user_buffer_create(screen->winsys, ptr, bytes); + + buffer->screen = screen; + + return buffer; } static struct pipe_buffer * @@ -57,9 +67,14 @@ pass_surface_buffer_create(struct pipe_screen *screen, unsigned usage, unsigned *stride) { - return screen->winsys->surface_buffer_create(screen->winsys, + struct pipe_buffer *buffer = + screen->winsys->surface_buffer_create(screen->winsys, width, height, format, usage, stride); + + buffer->screen = screen; + + return buffer; } static void * @@ -79,10 +94,9 @@ pass_buffer_unmap(struct pipe_screen *screen, } static void -pass_buffer_destroy(struct pipe_screen *screen, - struct pipe_buffer *buf) +pass_buffer_destroy(struct pipe_buffer *buf) { - screen->winsys->buffer_destroy(screen->winsys, buf); + buf->screen->winsys->buffer_destroy(buf); } diff --git a/src/gallium/auxiliary/util/u_timed_winsys.c b/src/gallium/auxiliary/util/u_timed_winsys.c index f237e12d73..77b2a3a1c8 100644 --- a/src/gallium/auxiliary/util/u_timed_winsys.c +++ b/src/gallium/auxiliary/util/u_timed_winsys.c @@ -29,6 +29,7 @@ * Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com> */ +#include "pipe/p_state.h" #include "pipe/internal/p_winsys_screen.h" #include "u_timed_winsys.h" #include "util/u_memory.h" @@ -178,13 +179,13 @@ timed_buffer_unmap(struct pipe_winsys *winsys, static void -timed_buffer_destroy(struct pipe_winsys *winsys, - struct pipe_buffer *buf) +timed_buffer_destroy(struct pipe_buffer *buf) { + struct pipe_winsys *winsys = buf->screen->winsys; struct pipe_winsys *backend = timed_winsys(winsys)->backend; uint64_t start = time_start(); - backend->buffer_destroy( backend, buf ); + backend->buffer_destroy( buf ); time_finish(winsys, start, 4, __FUNCTION__); } |