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().
/* unmap */
screen->transfer_unmap(screen, transfer);
- screen->tex_transfer_release(screen, &transfer);
+ screen->tex_transfer_destroy(transfer);
}
return TRUE;
}
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 );
/* unmap */
screen->transfer_unmap(screen, transfer);
- screen->tex_transfer_release(screen, &transfer);
+ screen->tex_transfer_destroy(transfer);
}
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 );
assert(buf);
if(!buf)
return NULL;
- assert(buf->base.refcount > 0);
+ assert(buf->base.reference.count > 0);
return buf->vtbl->map(buf, flags);
}
assert(buf);
if(!buf)
return;
- assert(buf->base.refcount > 0);
+ assert(buf->base.reference.count > 0);
buf->vtbl->unmap(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);
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 );
}
{
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);
{
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);
++fenced_list->numUnfenced;
#endif
- if(!fenced_buf->base.base.refcount)
+ if(!fenced_buf->base.base.reference.count)
_fenced_buffer_destroy(fenced_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) {
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;
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;
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;
}
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;
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;
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);
}
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);
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;
}
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;
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);
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;
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);
}
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;
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;
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);
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;
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;
pipe_mutex_lock(mgr->mutex);
- assert(buf->base.base.refcount == 0);
+ assert(buf->base.base.reference.count == 0);
buf->mapCount = 0;
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;
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;
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;
#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"
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);
}
/* 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);
cso_restore_vertex_shader(ctx->cso);
cso_restore_viewport(ctx->cso);
- screen->texture_release(screen, &tex);
+ pipe_texture_reference(&tex, NULL);
}
*/
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;
}
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;
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);
screen->transfer_unmap(screen, transfer);
error:
- screen->tex_transfer_release(screen, &transfer);
+ screen->tex_transfer_destroy(transfer);
}
}
}
- screen->tex_transfer_release(screen, &transfer);
+ screen->tex_transfer_destroy(transfer);
util_stream_close(stream);
error2:
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);
}
}
#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"
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);
}
}
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);
}
}
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;
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);
}
*/
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;
}
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);
}
}
pipe->screen->transfer_unmap(pipe->screen, dst_trans);
- screen->tex_transfer_release(screen, &dst_trans);
+ screen->tex_transfer_destroy(dst_trans);
}
#include "u_simple_screen.h"
#include "pipe/p_screen.h"
+#include "pipe/p_state.h"
#include "pipe/internal/p_winsys_screen.h"
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 *
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 *
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 *
}
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);
}
* 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"
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__);
}
struct cell_buffer_node *node = CALLOC_STRUCT(cell_buffer_node);
/* create new list node which references the buffer, insert at head */
if (node) {
- pipe_buffer_reference(ps, &node->buffer, buffer);
+ pipe_buffer_reference(&node->buffer, buffer);
node->next = list->head;
list->head = node;
}
pipe_buffer_unmap(ps, node->buffer);
#if 0
printf("Unref buffer %p\n", node->buffer);
- if (node->buffer->refcount == 1)
+ if (node->buffer->reference.count == 1)
printf(" Delete!\n");
#endif
- pipe_buffer_reference(ps, &node->buffer, NULL);
+ pipe_buffer_reference(&node->buffer, NULL);
FREE(node);
node = next;
}
cell_texture_create(struct pipe_screen *screen,
const struct pipe_texture *templat)
{
- struct pipe_winsys *ws = screen->winsys;
struct cell_texture *ct = CALLOC_STRUCT(cell_texture);
if (!ct)
return NULL;
ct->base = *templat;
- ct->base.refcount = 1;
+ pipe_reference_init(&ct->base.reference, 1);
ct->base.screen = screen;
cell_texture_layout(ct);
- ct->buffer = ws->buffer_create(ws, 32, PIPE_BUFFER_USAGE_PIXEL,
+ ct->buffer = screen->buffer_create(screen, 32, PIPE_BUFFER_USAGE_PIXEL,
ct->buffer_size);
if (!ct->buffer) {
static void
-cell_texture_release(struct pipe_screen *screen,
- struct pipe_texture **pt)
+cell_texture_destroy(struct pipe_texture *pt)
{
- if (!*pt)
- return;
-
- if (--(*pt)->refcount <= 0) {
- /* Delete this texture now.
- * But note that the underlying pipe_buffer may linger...
- */
- struct cell_texture *ct = cell_texture(*pt);
+ struct cell_texture *ct = cell_texture(pt);
- if (ct->mapped) {
- pipe_buffer_unmap(screen, ct->buffer);
- ct->mapped = NULL;
- }
+ if (ct->mapped) {
+ pipe_buffer_unmap(screen, ct->buffer);
+ ct->mapped = NULL;
+ }
- pipe_buffer_reference(screen, &ct->buffer, NULL);
+ pipe_buffer_reference(&ct->buffer, NULL);
- FREE(ct);
- }
- *pt = NULL;
+ FREE(ct);
}
ps = CALLOC_STRUCT(pipe_surface);
if (ps) {
- ps->refcount = 1;
+ pipe_reference_init(&ps->reference, 1);
pipe_texture_reference(&ps->texture, pt);
ps->format = pt->format;
ps->width = pt->width[level];
static void
-cell_tex_surface_release(struct pipe_screen *screen,
- struct pipe_surface **s)
+cell_tex_surface_destroy(struct pipe_surface *s)
{
- struct pipe_surface *surf = *s;
-
- if (--surf->refcount == 0) {
- pipe_texture_reference(&surf->texture, NULL);
- FREE(surf);
- }
- *s = NULL;
+ pipe_texture_reference(&surf->texture, NULL);
+ FREE(surf);
}
ctrans = CALLOC_STRUCT(cell_transfer);
if (ctrans) {
struct pipe_transfer *pt = &ctrans->base;
- pt->refcount = 1;
+ pipe_reference_init(&pt->reference, 1);
pipe_texture_reference(&pt->texture, texture);
pt->format = texture->format;
pt->block = texture->block;
static void
-cell_tex_transfer_release(struct pipe_screen *screen,
- struct pipe_transfer **t)
+cell_tex_transfer_destroy(struct pipe_transfer *t)
{
- struct cell_transfer *transfer = cell_transfer(*t);
+ struct cell_transfer *transfer = cell_transfer(t);
/* Effectively do the texture_update work here - if texture images
* needed post-processing to put them into hardware layout, this is
* where it would happen. For cell, nothing to do.
*/
assert (transfer->base.texture);
- if (--transfer->base.refcount == 0) {
- pipe_texture_reference(&transfer->base.texture, NULL);
- FREE(transfer);
- }
- *t = NULL;
+ pipe_texture_reference(&transfer->base.texture, NULL);
+ FREE(transfer);
}
cell_init_screen_texture_funcs(struct pipe_screen *screen)
{
screen->texture_create = cell_texture_create;
- screen->texture_release = cell_texture_release;
+ screen->texture_destroy = cell_texture_destroy;
screen->get_tex_surface = cell_get_tex_surface;
- screen->tex_surface_release = cell_tex_surface_release;
+ screen->tex_surface_destroy = cell_tex_surface_destroy;
screen->get_tex_transfer = cell_get_tex_transfer;
- screen->tex_transfer_release = cell_tex_transfer_release;
+ screen->tex_transfer_destroy = cell_tex_transfer_destroy;
screen->transfer_map = cell_transfer_map;
screen->transfer_unmap = cell_transfer_unmap;
#if 0
failover->pipe.texture_create = hw->texture_create;
- failover->pipe.texture_release = hw->texture_release;
+ failover->pipe.texture_destroy = hw->texture_destroy;
failover->pipe.get_tex_surface = hw->get_tex_surface;
failover->pipe.texture_update = hw->texture_update;
#endif
} else {
i915->vbo_flushed = 0;
if (i915_render->vbo)
- pipe_buffer_reference(screen, &i915_render->vbo, NULL);
+ pipe_buffer_reference(&i915_render->vbo, NULL);
}
if (!i915_render->vbo) {
trans = CALLOC_STRUCT(i915_transfer);
if (trans) {
- trans->base.refcount = 1;
pipe_texture_reference(&trans->base.texture, texture);
trans->base.format = trans->base.format;
trans->base.width = w;
}
static void
-i915_tex_transfer_release(struct pipe_screen *screen,
- struct pipe_transfer **transfer)
+i915_tex_transfer_destroy(struct pipe_transfer *trans)
{
- struct pipe_transfer *trans = *transfer;
-
- if (--trans->refcount == 0) {
- pipe_texture_reference(&trans->texture, NULL);
- FREE(trans);
- }
-
- *transfer = NULL;
+ pipe_texture_reference(&trans->texture, NULL);
+ FREE(trans);
}
static void *
i915screen->screen.get_paramf = i915_get_paramf;
i915screen->screen.is_format_supported = i915_is_format_supported;
i915screen->screen.get_tex_transfer = i915_get_tex_transfer;
- i915screen->screen.tex_transfer_release = i915_tex_transfer_release;
+ i915screen->screen.tex_transfer_destroy = i915_tex_transfer_destroy;
i915screen->screen.transfer_map = i915_transfer_map;
i915screen->screen.transfer_unmap = i915_transfer_unmap;
const struct pipe_texture *templat)
{
struct i915_screen *i915screen = i915_screen(screen);
- struct pipe_winsys *ws = screen->winsys;
struct i915_texture *tex = CALLOC_STRUCT(i915_texture);
size_t tex_size;
return NULL;
tex->base = *templat;
- tex->base.refcount = 1;
+ pipe_reference_init(&tex->base.reference, 1);
tex->base.screen = screen;
tex->base.nblocksx[0] = pf_get_nblocksx(&tex->base.block, tex->base.width[0]);
tex_size = tex->stride * tex->total_nblocksy;
- tex->buffer = ws->buffer_create(ws, 64,
+ tex->buffer = screen->buffer_create(screen, 64,
PIPE_BUFFER_USAGE_PIXEL,
tex_size);
static void
-i915_texture_release(struct pipe_screen *screen,
- struct pipe_texture **pt)
+i915_texture_destroy(struct pipe_texture *pt)
{
- if (!*pt)
- return;
+ struct i915_texture *tex = (struct i915_texture *)pt;
+ uint i;
/*
- DBG("%s %p refcount will be %d\n",
- __FUNCTION__, (void *) *pt, (*pt)->refcount - 1);
+ DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
*/
- if (--(*pt)->refcount <= 0) {
- struct i915_texture *tex = (struct i915_texture *)*pt;
- uint i;
-
- /*
- DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
- */
- pipe_buffer_reference(screen, &tex->buffer, NULL);
+ pipe_buffer_reference(&tex->buffer, NULL);
- for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
- if (tex->image_offset[i])
- FREE(tex->image_offset[i]);
+ for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
+ if (tex->image_offset[i])
+ FREE(tex->image_offset[i]);
- FREE(tex);
- }
- *pt = NULL;
+ FREE(tex);
}
static struct pipe_surface *
ps = CALLOC_STRUCT(pipe_surface);
if (ps) {
- ps->refcount = 1;
+ pipe_reference_init(&ps->reference, 1);
pipe_texture_reference(&ps->texture, pt);
ps->format = pt->format;
ps->width = pt->width[level];
return NULL;
tex->base = *base;
- tex->base.refcount = 1;
+ pipe_reference_init(&tex->base.reference, 1);
tex->base.screen = screen;
tex->stride = stride[0];
i915_miptree_set_level_info(tex, 0, 1, base->width[0], base->height[0], 1);
i915_miptree_set_image_offset(tex, 0, 0, 0, 0);
- pipe_buffer_reference(screen, &tex->buffer, buffer);
+ pipe_buffer_reference(&tex->buffer, buffer);
return &tex->base;
}
}
static void
-i915_tex_surface_release(struct pipe_screen *screen,
- struct pipe_surface **surface)
+i915_tex_surface_destroy(struct pipe_surface *surf)
{
- struct pipe_surface *surf = *surface;
-
- if (--surf->refcount == 0) {
-
- /* This really should not be possible, but it's actually
- * happening quite a bit... Will fix.
- */
- if (surf->status == PIPE_SURFACE_STATUS_CLEAR) {
- debug_printf("XXX destroying a surface with pending clears...\n");
- assert(0);
- }
-
- pipe_texture_reference(&surf->texture, NULL);
- FREE(surf);
+ /* This really should not be possible, but it's actually
+ * happening quite a bit... Will fix.
+ */
+ if (surf->status == PIPE_SURFACE_STATUS_CLEAR) {
+ debug_printf("XXX destroying a surface with pending clears...\n");
+ assert(0);
}
- *surface = NULL;
+ pipe_texture_reference(&surf->texture, NULL);
+ FREE(surf);
}
void
i915_init_screen_texture_functions(struct pipe_screen *screen)
{
screen->texture_create = i915_texture_create;
- screen->texture_release = i915_texture_release;
+ screen->texture_destroy = i915_texture_destroy;
screen->get_tex_surface = i915_get_tex_surface;
screen->texture_blanket = i915_texture_blanket;
- screen->tex_surface_release = i915_tex_surface_release;
+ screen->tex_surface_destroy = i915_tex_surface_destroy;
}
boolean i915_get_texture_buffer( struct pipe_texture *texture,
if (!tex)
return FALSE;
- pipe_buffer_reference(texture->screen, buf, tex->buffer);
+ pipe_buffer_reference(buf, tex->buffer);
if (stride)
*stride = tex->stride;
brw_texture_create_screen(struct pipe_screen *screen,
const struct pipe_texture *templat)
{
- struct pipe_winsys *ws = screen->winsys;
struct brw_texture *tex = CALLOC_STRUCT(brw_texture);
if (tex) {
tex->base = *templat;
- tex->base.refcount = 1;
+ pipe_reference_init(&tex->base.reference, 1);
tex->base.nblocksx[0] = pf_get_nblocksx(&tex->base.block, tex->base.width[0]);
tex->base.nblocksy[0] = pf_get_nblocksy(&tex->base.block, tex->base.height[0]);
if (brw_miptree_layout(tex))
- tex->buffer = ws->buffer_create(ws, 64,
+ tex->buffer = screen->buffer_create(screen, 64,
PIPE_BUFFER_USAGE_PIXEL,
tex->stride *
tex->total_nblocksy);
static void
-brw_texture_release_screen(struct pipe_screen *screen,
- struct pipe_texture **pt)
+brw_texture_destroy_screen(struct pipe_texture *pt)
{
- if (!*pt)
- return;
+ struct brw_texture *tex = (struct brw_texture *)pt;
+ uint i;
/*
- DBG("%s %p refcount will be %d\n",
- __FUNCTION__, (void *) *pt, (*pt)->refcount - 1);
+ DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
*/
- if (--(*pt)->refcount <= 0) {
- struct brw_texture *tex = (struct brw_texture *)*pt;
- uint i;
-
- /*
- DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
- */
- pipe_buffer_reference(screen, &tex->buffer, NULL);
+ pipe_buffer_reference(&tex->buffer, NULL);
- for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
- if (tex->image_offset[i])
- free(tex->image_offset[i]);
+ for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
+ if (tex->image_offset[i])
+ free(tex->image_offset[i]);
- free(tex);
- }
- *pt = NULL;
+ free(tex);
}
ps = CALLOC_STRUCT(pipe_surface);
if (ps) {
- ps->refcount = 1;
+ pipe_reference_init(&ps->reference, 1);
pipe_texture_reference(&ps->texture, pt);
ps->format = pt->format;
ps->width = pt->width[level];
brw_init_screen_texture_funcs(struct pipe_screen *screen)
{
screen->texture_create = brw_texture_create_screen;
- screen->texture_release = brw_texture_release_screen;
+ screen->texture_destroy = brw_texture_destroy_screen;
screen->get_tex_surface = brw_get_tex_surface_screen;
}
const struct brw_texture *texUnit = brw->attribs.Texture[i];
if (texUnit &&
- texUnit->base.refcount/*(texUnit->refcount > 0) == really used */) {
+ texUnit->base.reference.count/*(texUnit->reference.count > 0) == really used */) {
brw_update_texture_surface(brw, i);
};
struct nouveau_stateobj {
- int refcount;
+ struct pipe_reference reference;
unsigned *push;
struct nouveau_stateobj_reloc *reloc;
struct nouveau_stateobj *so;
so = MALLOC(sizeof(struct nouveau_stateobj));
- so->refcount = 0;
+ pipe_reference_init(&so->reference, 0);
so->push = MALLOC(sizeof(unsigned) * push);
so->reloc = MALLOC(sizeof(struct nouveau_stateobj_reloc) * reloc);
{
struct nouveau_stateobj *so = *pso;
- if (ref) {
- ref->refcount++;
- }
-
- if (so && --so->refcount <= 0) {
+ if (pipe_reference((struct pipe_reference**)pso, &ref->reference)) {
free(so->push);
free(so->reloc);
free(so);
}
-
- *pso = ref;
}
static INLINE void
static struct pipe_texture *
nv04_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
{
- struct pipe_winsys *ws = pscreen->winsys;
struct nv04_miptree *mt;
mt = MALLOC(sizeof(struct nv04_miptree));
if (!mt)
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
//mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
nv04_miptree_layout(mt);
- mt->buffer = ws->buffer_create(ws, 256, PIPE_BUFFER_USAGE_PIXEL |
+ mt->buffer = pscreen->buffer_create(pscreen, 256, PIPE_BUFFER_USAGE_PIXEL |
NOUVEAU_BUFFER_USAGE_TEXTURE,
mt->total_size);
if (!mt->buffer) {
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
mt->level[0].pitch = stride[0];
mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
- pipe_buffer_reference(pscreen, &mt->buffer, pb);
+ pipe_buffer_reference(&mt->buffer, pb);
return &mt->base;
}
static void
-nv04_miptree_release(struct pipe_screen *pscreen, struct pipe_texture **ppt)
+nv04_miptree_destroy(struct pipe_texture *pt)
{
- struct pipe_texture *pt = *ppt;
struct nv04_miptree *mt = (struct nv04_miptree *)pt;
int l;
- *ppt = NULL;
- if (--pt->refcount)
- return;
-
- pipe_buffer_reference(pscreen, &mt->buffer, NULL);
+ pipe_buffer_reference(&mt->buffer, NULL);
for (l = 0; l <= pt->last_level; l++) {
if (mt->level[l].image_offset)
FREE(mt->level[l].image_offset);
ns->base.height = pt->height[level];
ns->base.usage = flags;
ns->base.status = PIPE_SURFACE_STATUS_DEFINED;
- ns->base.refcount = 1;
+ pipe_reference_init(&ns->base.reference, 1);
ns->base.face = face;
ns->base.level = level;
ns->base.zslice = zslice;
}
static void
-nv04_miptree_surface_del(struct pipe_screen *pscreen,
- struct pipe_surface **psurface)
+nv04_miptree_surface_del(struct pipe_surface *ps)
{
- struct pipe_surface *ps = *psurface;
-
- *psurface = NULL;
- if (--ps->refcount > 0)
- return;
-
pipe_texture_reference(&ps->texture, NULL);
FREE(ps);
}
{
pscreen->texture_create = nv04_miptree_create;
pscreen->texture_blanket = nv04_miptree_blanket;
- pscreen->texture_release = nv04_miptree_release;
+ pscreen->texture_destroy = nv04_miptree_destroy;
pscreen->get_tex_surface = nv04_miptree_surface_new;
- pscreen->tex_surface_release = nv04_miptree_surface_del;
+ pscreen->tex_surface_destroy = nv04_miptree_surface_del;
}
if (!tx)
return NULL;
- tx->base.refcount = 1;
pipe_texture_reference(&tx->base.texture, pt);
tx->base.format = pt->format;
tx->base.x = x;
}
static void
-nv04_transfer_del(struct pipe_screen *pscreen, struct pipe_transfer **pptx)
+nv04_transfer_del(struct pipe_transfer *ptx)
{
- struct pipe_transfer *ptx = *pptx;
struct nv04_transfer *tx = (struct nv04_transfer *)ptx;
if (!tx->direct && ptx->usage != PIPE_TRANSFER_READ) {
+ struct pipe_screen *pscreen = ptx->texture->screen;
struct nv04_screen *nvscreen = nv04_screen(pscreen);
struct pipe_surface *dst;
pipe_surface_reference(&dst, NULL);
}
- *pptx = NULL;
- if (--ptx->refcount)
- return;
-
pipe_surface_reference(&tx->surface, NULL);
pipe_texture_reference(&ptx->texture, NULL);
FREE(ptx);
nv04_screen_init_transfer_functions(struct pipe_screen *pscreen)
{
pscreen->get_tex_transfer = nv04_transfer_new;
- pscreen->tex_transfer_release = nv04_transfer_del;
+ pscreen->tex_transfer_destroy = nv04_transfer_del;
pscreen->transfer_map = nv04_transfer_map;
pscreen->transfer_unmap = nv04_transfer_unmap;
}
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
mt->level[0].pitch = stride[0];
mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
- pipe_buffer_reference(pscreen, &mt->buffer, pb);
+ pipe_buffer_reference(&mt->buffer, pb);
return &mt->base;
}
static struct pipe_texture *
nv10_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt)
{
- struct pipe_winsys *ws = screen->winsys;
struct nv10_miptree *mt;
mt = MALLOC(sizeof(struct nv10_miptree));
if (!mt)
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = screen;
nv10_miptree_layout(mt);
- mt->buffer = ws->buffer_create(ws, 256, PIPE_BUFFER_USAGE_PIXEL,
+ mt->buffer = screen->buffer_create(screen, 256, PIPE_BUFFER_USAGE_PIXEL,
mt->total_size);
if (!mt->buffer) {
FREE(mt);
}
static void
-nv10_miptree_release(struct pipe_screen *screen, struct pipe_texture **pt)
+nv10_miptree_destroy(struct pipe_texture *pt)
{
- struct pipe_texture *mt = *pt;
-
- *pt = NULL;
- if (--mt->refcount <= 0) {
- struct nv10_miptree *nv10mt = (struct nv10_miptree *)mt;
- int l;
-
- pipe_buffer_reference(screen, &nv10mt->buffer, NULL);
- for (l = 0; l <= mt->last_level; l++) {
- if (nv10mt->level[l].image_offset)
- FREE(nv10mt->level[l].image_offset);
- }
- FREE(nv10mt);
- }
+ struct nv10_miptree *nv10mt = (struct nv10_miptree *)pt;
+ int l;
+
+ pipe_buffer_reference(&nv10mt->buffer, NULL);
+ for (l = 0; l <= pt->last_level; l++) {
+ if (nv10mt->level[l].image_offset)
+ FREE(nv10mt->level[l].image_offset);
+ }
+ FREE(nv10mt);
}
static void
ns->base.height = pt->height[level];
ns->base.usage = flags;
ns->base.status = PIPE_SURFACE_STATUS_DEFINED;
- ns->base.refcount = 1;
+ pipe_reference_init(&ns->base.reference, 1);
ns->base.face = face;
ns->base.level = level;
ns->base.zslice = zslice;
}
static void
-nv10_miptree_surface_release(struct pipe_screen *screen,
- struct pipe_surface **surface)
+nv10_miptree_surface_destroy(struct pipe_surface *surface)
{
}
{
pscreen->texture_create = nv10_miptree_create;
pscreen->texture_blanket = nv10_miptree_blanket;
- pscreen->texture_release = nv10_miptree_release;
+ pscreen->texture_destroy = nv10_miptree_destroy;
pscreen->get_tex_surface = nv10_miptree_surface_get;
- pscreen->tex_surface_release = nv10_miptree_surface_release;
+ pscreen->tex_surface_destroy = nv10_miptree_surface_destroy;
}
{
struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render);
struct nv10_context *nv10 = nv10_render->nv10;
- struct pipe_winsys *winsys = nv10->pipe.winsys;
+ struct pipe_screen *screen = nv10->pipe.screen;
size_t size = (size_t)vertex_size * (size_t)nr_vertices;
assert(!nv10_render->buffer);
- nv10_render->buffer = winsys->buffer_create(winsys, 64, PIPE_BUFFER_USAGE_VERTEX, size);
+ nv10_render->buffer = screen->buffer_create(screen, 64, PIPE_BUFFER_USAGE_VERTEX, size);
nv10->dirty |= NV10_NEW_VTXARRAYS;
struct pipe_screen *pscreen = &nv10->screen->pipe;
assert(nv10_render->buffer);
- pipe_buffer_reference(pscreen, &nv10_render->buffer, NULL);
+ pipe_buffer_reference(&nv10_render->buffer, NULL);
}
if (!tx)
return NULL;
- tx->base.refcount = 1;
pipe_texture_reference(&tx->base.texture, pt);
tx->base.format = pt->format;
tx->base.x = x;
}
static void
-nv10_transfer_del(struct pipe_screen *pscreen, struct pipe_transfer **pptx)
+nv10_transfer_del(struct pipe_transfer *ptx)
{
- struct pipe_transfer *ptx = *pptx;
struct nv10_transfer *tx = (struct nv10_transfer *)ptx;
if (!tx->direct && ptx->usage != PIPE_TRANSFER_READ) {
+ struct pipe_screen *pscreen = ptx->texture->screen;
struct nv10_screen *nvscreen = nv10_screen(pscreen);
struct pipe_surface *dst;
pipe_surface_reference(&dst, NULL);
}
- *pptx = NULL;
- if (--ptx->refcount)
- return;
-
pipe_surface_reference(&tx->surface, NULL);
pipe_texture_reference(&ptx->texture, NULL);
FREE(ptx);
nv10_screen_init_transfer_functions(struct pipe_screen *pscreen)
{
pscreen->get_tex_transfer = nv10_transfer_new;
- pscreen->tex_transfer_release = nv10_transfer_del;
+ pscreen->tex_transfer_destroy = nv10_transfer_del;
pscreen->transfer_map = nv10_transfer_map;
pscreen->transfer_unmap = nv10_transfer_unmap;
}
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
mt->level[0].pitch = stride[0];
mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
- pipe_buffer_reference(pscreen, &mt->buffer, pb);
+ pipe_buffer_reference(&mt->buffer, pb);
return &mt->base;
}
static struct pipe_texture *
nv20_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt)
{
- struct pipe_winsys *ws = screen->winsys;
struct nv20_miptree *mt;
unsigned buf_usage = PIPE_BUFFER_USAGE_PIXEL |
NOUVEAU_BUFFER_USAGE_TEXTURE;
if (!mt)
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = screen;
/* Swizzled textures must be POT */
nv20_miptree_layout(mt);
- mt->buffer = ws->buffer_create(ws, 256, buf_usage, mt->total_size);
+ mt->buffer = screen->buffer_create(screen, 256, buf_usage, mt->total_size);
if (!mt->buffer) {
FREE(mt);
return NULL;
}
static void
-nv20_miptree_release(struct pipe_screen *screen, struct pipe_texture **pt)
+nv20_miptree_destroy(struct pipe_texture *pt)
{
- struct pipe_texture *mt = *pt;
-
- *pt = NULL;
- if (--mt->refcount <= 0) {
- struct nv20_miptree *nv20mt = (struct nv20_miptree *)mt;
- int l;
+ struct nv20_miptree *nv20mt = (struct nv20_miptree *)pt;
+ int l;
- pipe_buffer_reference(screen, &nv20mt->buffer, NULL);
- for (l = 0; l <= mt->last_level; l++) {
- if (nv20mt->level[l].image_offset)
- FREE(nv20mt->level[l].image_offset);
- }
- FREE(nv20mt);
- }
+ pipe_buffer_reference(&nv20mt->buffer, NULL);
+ for (l = 0; l <= pt->last_level; l++) {
+ if (nv20mt->level[l].image_offset)
+ FREE(nv20mt->level[l].image_offset);
+ }
}
static struct pipe_surface *
ns->base.height = pt->height[level];
ns->base.usage = flags;
ns->base.status = PIPE_SURFACE_STATUS_DEFINED;
- ns->base.refcount = 1;
+ pipe_reference_init(&ns->base.reference, 1);
ns->base.face = face;
ns->base.level = level;
ns->base.zslice = zslice;
}
static void
-nv20_miptree_surface_release(struct pipe_screen *pscreen,
- struct pipe_surface **psurface)
+nv20_miptree_surface_destroy(struct pipe_surface *ps)
{
- struct pipe_surface *ps = *psurface;
-
- *psurface = NULL;
- if (--ps->refcount > 0)
- return;
-
pipe_texture_reference(&ps->texture, NULL);
FREE(ps);
}
{
pscreen->texture_create = nv20_miptree_create;
pscreen->texture_blanket = nv20_miptree_blanket;
- pscreen->texture_release = nv20_miptree_release;
+ pscreen->texture_destroy = nv20_miptree_destroy;
pscreen->get_tex_surface = nv20_miptree_surface_get;
- pscreen->tex_surface_release = nv20_miptree_surface_release;
+ pscreen->tex_surface_destroy = nv20_miptree_surface_destroy;
}
static void
nv20__allocate_pbuffer(struct nv20_vbuf_render *nv20_render, size_t size)
{
- struct pipe_winsys *winsys = nv20_render->nv20->pipe.winsys;
- nv20_render->pbuffer = winsys->buffer_create(winsys, 64,
+ struct pipe_screen *screen = nv20_render->nv20->pipe.screen;
+ nv20_render->pbuffer = screen->buffer_create(screen, 64,
PIPE_BUFFER_USAGE_VERTEX, size);
}
struct pipe_screen *pscreen = &nv20->screen->pipe;
if (nv20_render->pbuffer) {
- pipe_buffer_reference(pscreen, &nv20_render->pbuffer, NULL);
+ pipe_buffer_reference(&nv20_render->pbuffer, NULL);
} else if (nv20_render->mbuffer) {
FREE(nv20_render->mbuffer);
nv20_render->mbuffer = NULL;
if (!tx)
return NULL;
- tx->base.refcount = 1;
pipe_texture_reference(&tx->base.texture, pt);
tx->base.format = pt->format;
tx->base.x = x;
}
static void
-nv20_transfer_del(struct pipe_screen *pscreen, struct pipe_transfer **pptx)
+nv20_transfer_del(struct pipe_transfer *ptx)
{
- struct pipe_transfer *ptx = *pptx;
struct nv20_transfer *tx = (struct nv20_transfer *)ptx;
if (!tx->direct && ptx->usage != PIPE_TRANSFER_READ) {
+ struct pipe_screen *pscreen = ptx->texture->screen;
struct nv20_screen *nvscreen = nv20_screen(pscreen);
struct pipe_surface *dst;
pipe_surface_reference(&dst, NULL);
}
- *pptx = NULL;
- if (--ptx->refcount)
- return;
-
pipe_surface_reference(&tx->surface, NULL);
pipe_texture_reference(&ptx->texture, NULL);
FREE(ptx);
nv20_screen_init_transfer_functions(struct pipe_screen *pscreen)
{
pscreen->get_tex_transfer = nv20_transfer_new;
- pscreen->tex_transfer_release = nv20_transfer_del;
+ pscreen->tex_transfer_destroy = nv20_transfer_del;
pscreen->transfer_map = nv20_transfer_map;
pscreen->transfer_unmap = nv20_transfer_unmap;
}
struct nv30_fragment_program *fp = nv30->fragprog;
struct pipe_buffer *constbuf =
nv30->constbuf[PIPE_SHADER_FRAGMENT];
+ struct pipe_screen *screen = nv30->pipe.screen;
struct pipe_winsys *ws = nv30->pipe.winsys;
struct nouveau_stateobj *so;
boolean new_consts = FALSE;
return FALSE;
}
- fp->buffer = ws->buffer_create(ws, 0x100, 0, fp->insn_len * 4);
+ fp->buffer = screen->buffer_create(screen, 0x100, 0, fp->insn_len * 4);
nv30_fragprog_upload(nv30, fp);
so = so_new(8, 1);
static struct pipe_texture *
nv30_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
{
- struct pipe_winsys *ws = pscreen->winsys;
struct nv30_miptree *mt;
unsigned buf_usage = PIPE_BUFFER_USAGE_PIXEL |
NOUVEAU_BUFFER_USAGE_TEXTURE;
if (!mt)
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
/* Swizzled textures must be POT */
nv30_miptree_layout(mt);
- mt->buffer = ws->buffer_create(ws, 256, buf_usage,
+ mt->buffer = pscreen->buffer_create(pscreen, 256, buf_usage,
mt->total_size);
if (!mt->buffer) {
FREE(mt);
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
mt->level[0].pitch = stride[0];
mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
- pipe_buffer_reference(pscreen, &mt->buffer, pb);
+ pipe_buffer_reference(&mt->buffer, pb);
return &mt->base;
}
static void
-nv30_miptree_release(struct pipe_screen *pscreen, struct pipe_texture **ppt)
+nv30_miptree_destroy(struct pipe_texture *pt)
{
- struct pipe_texture *pt = *ppt;
struct nv30_miptree *mt = (struct nv30_miptree *)pt;
int l;
- *ppt = NULL;
- if (--pt->refcount)
- return;
-
- pipe_buffer_reference(pscreen, &mt->buffer, NULL);
+ pipe_buffer_reference(&mt->buffer, NULL);
for (l = 0; l <= pt->last_level; l++) {
if (mt->level[l].image_offset)
FREE(mt->level[l].image_offset);
ns->base.height = pt->height[level];
ns->base.usage = flags;
ns->base.status = PIPE_SURFACE_STATUS_DEFINED;
- ns->base.refcount = 1;
+ pipe_reference_init(&ns->base.reference, 1);
ns->base.face = face;
ns->base.level = level;
ns->base.zslice = zslice;
}
static void
-nv30_miptree_surface_del(struct pipe_screen *pscreen,
- struct pipe_surface **psurface)
+nv30_miptree_surface_del(struct pipe_surface *ps)
{
- struct pipe_surface *ps = *psurface;
-
- *psurface = NULL;
- if (--ps->refcount > 0)
- return;
-
pipe_texture_reference(&ps->texture, NULL);
FREE(ps);
}
{
pscreen->texture_create = nv30_miptree_create;
pscreen->texture_blanket = nv30_miptree_blanket;
- pscreen->texture_release = nv30_miptree_release;
+ pscreen->texture_destroy = nv30_miptree_destroy;
pscreen->get_tex_surface = nv30_miptree_surface_new;
- pscreen->tex_surface_release = nv30_miptree_surface_del;
+ pscreen->tex_surface_destroy = nv30_miptree_surface_del;
}
if (!tx)
return NULL;
- tx->base.refcount = 1;
pipe_texture_reference(&tx->base.texture, pt);
tx->base.format = pt->format;
tx->base.x = x;
}
static void
-nv30_transfer_del(struct pipe_screen *pscreen, struct pipe_transfer **pptx)
+nv30_transfer_del(struct pipe_transfer *ptx)
{
- struct pipe_transfer *ptx = *pptx;
struct nv30_transfer *tx = (struct nv30_transfer *)ptx;
if (!tx->direct && ptx->usage != PIPE_TRANSFER_READ) {
+ struct pipe_screen *pscreen = ptx->texture->screen;
struct nv30_screen *nvscreen = nv30_screen(pscreen);
struct pipe_surface *dst;
pipe_surface_reference(&dst, NULL);
}
- *pptx = NULL;
- if (--ptx->refcount)
- return;
-
pipe_surface_reference(&tx->surface, NULL);
pipe_texture_reference(&ptx->texture, NULL);
FREE(ptx);
nv30_screen_init_transfer_functions(struct pipe_screen *pscreen)
{
pscreen->get_tex_transfer = nv30_transfer_new;
- pscreen->tex_transfer_release = nv30_transfer_del;
+ pscreen->tex_transfer_destroy = nv30_transfer_del;
pscreen->transfer_map = nv30_transfer_map;
pscreen->transfer_unmap = nv30_transfer_unmap;
}
struct nv40_fragment_program *fp = nv40->fragprog;
struct pipe_buffer *constbuf =
nv40->constbuf[PIPE_SHADER_FRAGMENT];
+ struct pipe_screen *screen = nv40->pipe.screen;
struct pipe_winsys *ws = nv40->pipe.winsys;
struct nouveau_stateobj *so;
boolean new_consts = FALSE;
return FALSE;
}
- fp->buffer = ws->buffer_create(ws, 0x100, 0, fp->insn_len * 4);
+ fp->buffer = screen->buffer_create(screen, 0x100, 0, fp->insn_len * 4);
nv40_fragprog_upload(nv40, fp);
so = so_new(4, 1);
static struct pipe_texture *
nv40_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
{
- struct pipe_winsys *ws = pscreen->winsys;
struct nv40_miptree *mt;
unsigned buf_usage = PIPE_BUFFER_USAGE_PIXEL |
NOUVEAU_BUFFER_USAGE_TEXTURE;
if (!mt)
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
/* Swizzled textures must be POT */
nv40_miptree_layout(mt);
- mt->buffer = ws->buffer_create(ws, 256, buf_usage, mt->total_size);
+ mt->buffer = pscreen->buffer_create(pscreen, 256, buf_usage, mt->total_size);
if (!mt->buffer) {
FREE(mt);
return NULL;
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
mt->level[0].pitch = stride[0];
mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
- pipe_buffer_reference(pscreen, &mt->buffer, pb);
+ pipe_buffer_reference(&mt->buffer, pb);
return &mt->base;
}
static void
-nv40_miptree_release(struct pipe_screen *pscreen, struct pipe_texture **ppt)
+nv40_miptree_destroy(struct pipe_texture *pt)
{
- struct pipe_texture *pt = *ppt;
struct nv40_miptree *mt = (struct nv40_miptree *)pt;
int l;
- *ppt = NULL;
- if (--pt->refcount)
- return;
-
- pipe_buffer_reference(pscreen, &mt->buffer, NULL);
+ pipe_buffer_reference(&mt->buffer, NULL);
for (l = 0; l <= pt->last_level; l++) {
if (mt->level[l].image_offset)
FREE(mt->level[l].image_offset);
ns->base.height = pt->height[level];
ns->base.usage = flags;
ns->base.status = PIPE_SURFACE_STATUS_DEFINED;
- ns->base.refcount = 1;
+ pipe_reference_init(&ns->base.reference, 1);
ns->base.face = face;
ns->base.level = level;
ns->base.zslice = zslice;
}
static void
-nv40_miptree_surface_del(struct pipe_screen *pscreen,
- struct pipe_surface **psurface)
+nv40_miptree_surface_del(struct pipe_surface *ps)
{
- struct pipe_surface *ps = *psurface;
-
- *psurface = NULL;
- if (--ps->refcount > 0)
- return;
-
pipe_texture_reference(&ps->texture, NULL);
FREE(ps);
}
{
pscreen->texture_create = nv40_miptree_create;
pscreen->texture_blanket = nv40_miptree_blanket;
- pscreen->texture_release = nv40_miptree_release;
+ pscreen->texture_destroy = nv40_miptree_destroy;
pscreen->get_tex_surface = nv40_miptree_surface_new;
- pscreen->tex_surface_release = nv40_miptree_surface_del;
+ pscreen->tex_surface_destroy = nv40_miptree_surface_del;
}
if (!tx)
return NULL;
- tx->base.refcount = 1;
pipe_texture_reference(&tx->base.texture, pt);
tx->base.format = pt->format;
tx->base.x = x;
}
static void
-nv40_transfer_del(struct pipe_screen *pscreen, struct pipe_transfer **pptx)
+nv40_transfer_del(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
{
- struct pipe_transfer *ptx = *pptx;
struct nv40_transfer *tx = (struct nv40_transfer *)ptx;
if (!tx->direct && ptx->usage != PIPE_TRANSFER_READ) {
+ struct pipe_screen *pscreen = ptx->texture->screen;
struct nv40_screen *nvscreen = nv40_screen(pscreen);
struct pipe_surface *dst;
pipe_surface_reference(&dst, NULL);
}
- *pptx = NULL;
- if (--ptx->refcount)
- return;
-
pipe_surface_reference(&tx->surface, NULL);
pipe_texture_reference(&ptx->texture, NULL);
FREE(ptx);
nv40_screen_init_transfer_functions(struct pipe_screen *pscreen)
{
pscreen->get_tex_transfer = nv40_transfer_new;
- pscreen->tex_transfer_release = nv40_transfer_del;
+ pscreen->tex_transfer_destroy = nv40_transfer_del;
pscreen->transfer_map = nv40_transfer_map;
pscreen->transfer_unmap = nv40_transfer_unmap;
}
static struct pipe_texture *
nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp)
{
- struct pipe_winsys *ws = pscreen->winsys;
struct nv50_miptree *mt = CALLOC_STRUCT(nv50_miptree);
struct pipe_texture *pt = &mt->base;
unsigned usage, width = tmp->width[0], height = tmp->height[0];
int i, l;
mt->base = *tmp;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
usage = PIPE_BUFFER_USAGE_PIXEL;
}
}
- mt->buffer = ws->buffer_create(ws, 256, usage, mt->total_size);
+ mt->buffer = pscreen->buffer_create(pscreen, 256, usage, mt->total_size);
if (!mt->buffer) {
FREE(mt);
return NULL;
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
mt->image_nr = 1;
mt->level[0].pitch = *stride;
mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
- pipe_buffer_reference(pscreen, &mt->buffer, pb);
+ pipe_buffer_reference(&mt->buffer, pb);
return &mt->base;
}
static void
-nv50_miptree_release(struct pipe_screen *pscreen, struct pipe_texture **ppt)
+nv50_miptree_destroy(struct pipe_texture *pt)
{
- struct pipe_texture *pt = *ppt;
-
- *ppt = NULL;
-
- if (--pt->refcount <= 0) {
- struct nv50_miptree *mt = nv50_miptree(pt);
+ struct nv50_miptree *mt = nv50_miptree(pt);
- pipe_buffer_reference(pscreen, &mt->buffer, NULL);
- FREE(mt);
- }
+ pipe_buffer_reference(&mt->buffer, NULL);
+ FREE(mt);
}
static struct pipe_surface *
ps->height = pt->height[level];
ps->usage = flags;
ps->status = PIPE_SURFACE_STATUS_DEFINED;
- ps->refcount = 1;
+ pipe_reference_init(&ps->reference, 1);
ps->face = face;
ps->level = level;
ps->zslice = zslice;
}
static void
-nv50_miptree_surface_del(struct pipe_screen *pscreen,
- struct pipe_surface **psurface)
+nv50_miptree_surface_del(struct pipe_surface *ps)
{
- struct pipe_surface *ps = *psurface;
struct nv50_surface *s = nv50_surface(ps);
- *psurface = NULL;
-
- if (--ps->refcount <= 0) {
- pipe_texture_reference(&ps->texture, NULL);
- FREE(s);
- }
+ pipe_texture_reference(&ps->texture, NULL);
+ FREE(s);
}
void
{
pscreen->texture_create = nv50_miptree_create;
pscreen->texture_blanket = nv50_miptree_blanket;
- pscreen->texture_release = nv50_miptree_release;
+ pscreen->texture_destroy = nv50_miptree_destroy;
pscreen->get_tex_surface = nv50_miptree_surface_new;
- pscreen->tex_surface_release = nv50_miptree_surface_del;
+ pscreen->tex_surface_destroy = nv50_miptree_surface_del;
}
{
struct nouveau_channel *chan = nv50->screen->nvws->channel;
struct nouveau_grobj *tesla = nv50->screen->tesla;
- struct pipe_winsys *ws = nv50->pipe.winsys;
+ struct pipe_screen *screen = nv50->pipe.screen;
struct nv50_program_exec *e;
struct nouveau_stateobj *so;
const unsigned flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_WR;
boolean upload = FALSE;
if (!p->buffer) {
- p->buffer = ws->buffer_create(ws, 0x100, 0, p->exec_size * 4);
+ p->buffer = screen->buffer_create(screen, 0x100, 0, p->exec_size * 4);
upload = TRUE;
}
p->exec_size = 0;
if (p->buffer)
- pipe_buffer_reference(pscreen, &p->buffer, NULL);
+ pipe_buffer_reference(&p->buffer, NULL);
nv50->screen->nvws->res_free(&p->data);
static struct pipe_query *
nv50_query_create(struct pipe_context *pipe, unsigned type)
{
- struct pipe_winsys *ws = pipe->winsys;
+ struct pipe_screen *screen = pipe->winsys;
struct nv50_query *q = CALLOC_STRUCT(nv50_query);
assert (q->type == PIPE_QUERY_OCCLUSION_COUNTER);
q->type = type;
- q->buffer = ws->buffer_create(ws, 256, 0, 16);
+ q->buffer = screen->buffer_create(screen, 256, 0, 16);
if (!q->buffer) {
FREE(q);
return NULL;
struct nv50_query *q = nv50_query(pq);
if (q) {
- pipe_buffer_reference(pipe->screen, &q->buffer, NULL);
+ pipe_buffer_reference(&q->buffer, NULL);
FREE(q);
}
}
so_data (so, 8);
/* Shared constant buffer */
- screen->constbuf = ws->buffer_create(ws, 0, 0, 128 * 4 * 4);
+ screen->constbuf = screen->pipe.buffer_create(&screen->pipe, 0, 0, 128 * 4 * 4);
if (nvws->res_init(&screen->vp_data_heap, 0, 128)) {
NOUVEAU_ERR("Error initialising constant buffer\n");
nv50_screen_destroy(&screen->pipe);
* blocks. At some point we *may* want to go the NVIDIA way of doing
* things?
*/
- screen->tic = ws->buffer_create(ws, 0, 0, 32 * 8 * 4);
+ screen->tic = screen->pipe.buffer_create(&screen->pipe, 0, 0, 32 * 8 * 4);
so_method(so, screen->tesla, 0x1280, 3);
so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM |
NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
so_data (so, 0x00000800);
- screen->tsc = ws->buffer_create(ws, 0, 0, 32 * 8 * 4);
+ screen->tsc = screen->pipe.buffer_create(&screen->pipe, 0, 0, 32 * 8 * 4);
so_method(so, screen->tesla, 0x1280, 3);
so_reloc (so, screen->tsc, 0, NOUVEAU_BO_VRAM |
NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
if (!tx)
return NULL;
- tx->base.refcount = 1;
pipe_texture_reference(&tx->base.texture, pt);
tx->base.format = pt->format;
tx->base.width = w;
}
static void
-nv50_transfer_del(struct pipe_screen *pscreen, struct pipe_transfer **pptx)
+nv50_transfer_del(struct pipe_transfer *ptx)
{
- struct pipe_transfer *ptx = *pptx;
struct nv50_transfer *tx = (struct nv50_transfer *)ptx;
struct nv50_miptree *mt = nv50_miptree(ptx->texture);
- *pptx = NULL;
- if (--ptx->refcount)
- return;
-
if (ptx->usage != PIPE_TRANSFER_READ) {
+ struct pipe_screen *pscreen = ptx->texture->screen;
nv50_transfer_rect_m2mf(pscreen, tx->buffer, tx->base.stride,
0, 0, tx->base.width, tx->base.height,
mt->buffer, tx->level_pitch,
NOUVEAU_BO_VRAM | NOUVEAU_BO_GART);
}
- pipe_buffer_reference(pscreen, &tx->buffer, NULL);
+ pipe_buffer_reference(&tx->buffer, NULL);
pipe_texture_reference(&ptx->texture, NULL);
FREE(ptx);
}
nv50_transfer_init_screen_functions(struct pipe_screen *pscreen)
{
pscreen->get_tex_transfer = nv50_transfer_new;
- pscreen->tex_transfer_release = nv50_transfer_del;
+ pscreen->tex_transfer_destroy = nv50_transfer_del;
pscreen->transfer_map = nv50_transfer_map;
pscreen->transfer_unmap = nv50_transfer_unmap;
}
trans = CALLOC_STRUCT(r300_transfer);
if (trans) {
- trans->transfer.refcount = 1;
pipe_texture_reference(&trans->transfer.texture, texture);
trans->transfer.format = trans->transfer.format;
trans->transfer.width = w;
}
static void
-r300_tex_transfer_release(struct pipe_screen *screen,
- struct pipe_transfer **transfer)
+r300_tex_transfer_destroy(struct pipe_transfer *trans)
{
- struct pipe_transfer *trans = *transfer;
-
- if (--trans->refcount == 0) {
- pipe_texture_reference(&trans->texture, NULL);
- FREE(trans);
- }
-
- *transfer = NULL;
+ pipe_texture_reference(&trans->texture, NULL);
+ FREE(trans);
}
static void* r300_transfer_map(struct pipe_screen* screen,
r300screen->screen.get_paramf = r300_get_paramf;
r300screen->screen.is_format_supported = r300_is_format_supported;
r300screen->screen.get_tex_transfer = r300_get_tex_transfer;
- r300screen->screen.tex_transfer_release = r300_tex_transfer_release;
+ r300screen->screen.tex_transfer_destroy = r300_tex_transfer_destroy;
r300screen->screen.transfer_map = r300_transfer_map;
r300screen->screen.transfer_unmap = r300_transfer_unmap;
size_t size = (size_t)vertex_size * (size_t)count;
if (r300render->vbo) {
- pipe_buffer_reference(screen, &r300render->vbo, NULL);
+ pipe_buffer_reference(&r300render->vbo, NULL);
}
r300render->vbo_size = MAX2(size, r300render->vbo_alloc_size);
static void r300_swtcl_render_release_vertices(struct vbuf_render* render)
{
struct r300_swtcl_render* r300render = r300_swtcl_render(render);
- struct pipe_screen* screen = r300render->r300->context.screen;
- pipe_buffer_reference(screen, &r300render->vbo, NULL);
+ pipe_buffer_reference(&r300render->vbo, NULL);
}
static boolean r300_swtcl_render_set_primitive(struct vbuf_render* render,
}
tex->tex = *template;
- tex->tex.refcount = 1;
+ pipe_reference_init(&tex->tex.reference, 1);
tex->tex.screen = screen;
r300_setup_miptree(tex);
return (struct pipe_texture*)tex;
}
-static void r300_texture_release(struct pipe_screen* screen,
- struct pipe_texture** texture)
+static void r300_texture_destroy(struct pipe_texture* texture)
{
- if (!*texture) {
- return;
- }
-
- (*texture)->refcount--;
-
- if ((*texture)->refcount <= 0) {
- struct r300_texture* tex = (struct r300_texture*)*texture;
+ struct r300_texture* tex = (struct r300_texture*)texture;
- pipe_buffer_reference(screen, &tex->buffer, NULL);
+ pipe_buffer_reference(&tex->buffer, NULL);
- FREE(tex);
- }
-
- *texture = NULL;
+ FREE(tex);
}
static struct pipe_surface* r300_get_tex_surface(struct pipe_screen* screen,
offset = tex->offset[level];
if (surface) {
- surface->refcount = 1;
+ pipe_reference_init(&surface->reference, 1);
pipe_texture_reference(&surface->texture, texture);
surface->format = texture->format;
surface->width = texture->width[level];
return surface;
}
-static void r300_tex_surface_release(struct pipe_screen* screen,
- struct pipe_surface** surface)
+static void r300_tex_surface_destroy(struct pipe_surface* s)
{
- struct pipe_surface* s = *surface;
-
- s->refcount--;
-
- if (s->refcount <= 0) {
- pipe_texture_reference(&s->texture, NULL);
- FREE(s);
- }
-
- *surface = NULL;
+ pipe_texture_reference(&s->texture, NULL);
+ FREE(s);
}
static struct pipe_texture*
}
tex->tex = *base;
- tex->tex.refcount = 1;
+ pipe_reference_init(&tex->tex.reference, 1);
tex->tex.screen = screen;
tex->stride = *stride;
- pipe_buffer_reference(screen, &tex->buffer, buffer);
+ pipe_buffer_reference(&tex->buffer, buffer);
return (struct pipe_texture*)tex;
}
void r300_init_screen_texture_functions(struct pipe_screen* screen)
{
screen->texture_create = r300_texture_create;
- screen->texture_release = r300_texture_release;
+ screen->texture_destroy = r300_texture_destroy;
screen->get_tex_surface = r300_get_tex_surface;
- screen->tex_surface_release = r300_tex_surface_release;
+ screen->tex_surface_destroy = r300_tex_surface_destroy;
screen->texture_blanket = r300_texture_blanket;
}
return FALSE;
}
- pipe_buffer_reference(texture->screen, buffer, tex->buffer);
+ pipe_buffer_reference(buffer, tex->buffer);
if (stride) {
*stride = tex->stride;
static void softpipe_destroy( struct pipe_context *pipe )
{
struct softpipe_context *softpipe = softpipe_context( pipe );
- struct pipe_screen *screen = pipe->screen;
uint i;
if (softpipe->draw)
for (i = 0; i < Elements(softpipe->constants); i++) {
if (softpipe->constants[i].buffer) {
- pipe_buffer_reference(screen, &softpipe->constants[i].buffer, NULL);
+ pipe_buffer_reference(&softpipe->constants[i].buffer, NULL);
}
}
const struct pipe_constant_buffer *buf)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
- struct pipe_screen *screen = pipe->screen;
assert(shader < PIPE_SHADER_TYPES);
assert(index == 0);
/* note: reference counting */
- pipe_buffer_reference(screen,
- &softpipe->constants[shader].buffer,
+ pipe_buffer_reference(&softpipe->constants[shader].buffer,
buf ? buf->buffer : NULL);
softpipe->dirty |= SP_NEW_CONSTANTS;
softpipe_texture_layout(struct pipe_screen *screen,
struct softpipe_texture * spt)
{
- struct pipe_winsys *ws = screen->winsys;
struct pipe_texture *pt = &spt->base;
unsigned level;
unsigned width = pt->width[0];
depth = minify(depth);
}
- spt->buffer = ws->buffer_create(ws, 32,
- PIPE_BUFFER_USAGE_PIXEL,
- buffer_size);
+ spt->buffer = screen->buffer_create(screen, 32,
+ PIPE_BUFFER_USAGE_PIXEL,
+ buffer_size);
return spt->buffer != NULL;
}
softpipe_displaytarget_layout(struct pipe_screen *screen,
struct softpipe_texture * spt)
{
- struct pipe_winsys *ws = screen->winsys;
unsigned usage = (PIPE_BUFFER_USAGE_CPU_READ_WRITE |
PIPE_BUFFER_USAGE_GPU_READ_WRITE);
spt->base.nblocksx[0] = pf_get_nblocksx(&spt->base.block, spt->base.width[0]);
spt->base.nblocksy[0] = pf_get_nblocksy(&spt->base.block, spt->base.height[0]);
- spt->buffer = ws->surface_buffer_create( ws,
- spt->base.width[0],
- spt->base.height[0],
- spt->base.format,
- usage,
- &spt->stride[0]);
+ spt->buffer = screen->surface_buffer_create( screen,
+ spt->base.width[0],
+ spt->base.height[0],
+ spt->base.format,
+ usage,
+ &spt->stride[0]);
return spt->buffer != NULL;
}
return NULL;
spt->base = *templat;
- spt->base.refcount = 1;
+ pipe_reference_init(&spt->base.reference, 1);
spt->base.screen = screen;
if (spt->base.tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) {
goto fail;
}
- assert(spt->base.refcount == 1);
+ assert(spt->base.reference.count == 1);
return &spt->base;
fail:
return NULL;
spt->base = *base;
- spt->base.refcount = 1;
+ pipe_reference_init(&spt->base.reference, 1);
spt->base.screen = screen;
spt->base.nblocksx[0] = pf_get_nblocksx(&spt->base.block, spt->base.width[0]);
spt->base.nblocksy[0] = pf_get_nblocksy(&spt->base.block, spt->base.height[0]);
spt->stride[0] = stride[0];
- pipe_buffer_reference(screen, &spt->buffer, buffer);
+ pipe_buffer_reference(&spt->buffer, buffer);
return &spt->base;
}
static void
-softpipe_texture_release(struct pipe_screen *screen,
- struct pipe_texture **pt)
+softpipe_texture_destroy(struct pipe_texture *pt)
{
- if (!*pt)
- return;
-
- if (--(*pt)->refcount <= 0) {
- struct softpipe_texture *spt = softpipe_texture(*pt);
+ struct softpipe_texture *spt = softpipe_texture(pt);
- pipe_buffer_reference(screen, &spt->buffer, NULL);
- FREE(spt);
- }
- *pt = NULL;
+ pipe_buffer_reference(&spt->buffer, NULL);
+ FREE(spt);
}
ps = CALLOC_STRUCT(pipe_surface);
if (ps) {
- ps->refcount = 1;
+ pipe_reference_init(&ps->reference, 1);
pipe_texture_reference(&ps->texture, pt);
ps->format = pt->format;
ps->width = pt->width[level];
static void
-softpipe_tex_surface_release(struct pipe_screen *screen,
- struct pipe_surface **s)
+softpipe_tex_surface_destroy(struct pipe_surface *surf)
{
- struct pipe_surface *surf = *s;
/* Effectively do the texture_update work here - if texture images
* needed post-processing to put them into hardware layout, this is
* where it would happen. For softpipe, nothing to do.
*/
assert(surf->texture);
- if (--surf->refcount == 0) {
- pipe_texture_reference(&surf->texture, NULL);
- FREE(surf);
- }
- *s = NULL;
+ pipe_texture_reference(&surf->texture, NULL);
+ FREE(surf);
}
spt = CALLOC_STRUCT(softpipe_transfer);
if (spt) {
struct pipe_transfer *pt = &spt->base;
- pt->refcount = 1;
pipe_texture_reference(&pt->texture, texture);
pt->format = texture->format;
pt->block = texture->block;
static void
-softpipe_tex_transfer_release(struct pipe_screen *screen,
- struct pipe_transfer **t)
+softpipe_tex_transfer_destroy(struct pipe_transfer *transfer)
{
- struct softpipe_transfer *transfer = softpipe_transfer(*t);
/* Effectively do the texture_update work here - if texture images
* needed post-processing to put them into hardware layout, this is
* where it would happen. For softpipe, nothing to do.
*/
- assert (transfer->base.texture);
- if (--transfer->base.refcount == 0) {
- pipe_texture_reference(&transfer->base.texture, NULL);
- FREE(transfer);
- }
- *t = NULL;
+ assert (transfer->texture);
+ pipe_texture_reference(&transfer->texture, NULL);
+ FREE(transfer);
}
{
screen->texture_create = softpipe_texture_create;
screen->texture_blanket = softpipe_texture_blanket;
- screen->texture_release = softpipe_texture_release;
+ screen->texture_destroy = softpipe_texture_destroy;
screen->get_tex_surface = softpipe_get_tex_surface;
- screen->tex_surface_release = softpipe_tex_surface_release;
+ screen->tex_surface_destroy = softpipe_tex_surface_destroy;
screen->get_tex_transfer = softpipe_get_tex_transfer;
- screen->tex_transfer_release = softpipe_tex_transfer_release;
+ screen->tex_transfer_destroy = softpipe_tex_transfer_destroy;
screen->transfer_map = softpipe_transfer_map;
screen->transfer_unmap = softpipe_transfer_unmap;
}
}
if (tc->transfer) {
screen = tc->transfer->texture->screen;
- screen->tex_transfer_release(screen, &tc->transfer);
+ screen->tex_transfer_destroy(tc->transfer);
}
if (tc->tex_trans) {
screen = tc->tex_trans->texture->screen;
- screen->tex_transfer_release(screen, &tc->tex_trans);
+ screen->tex_transfer_destroy(tc->tex_trans);
}
FREE( tc );
return;
if (tc->transfer_map) {
- tc->screen->transfer_unmap(tc->screen, tc->transfer);
+ screen->transfer_unmap(screen, tc->transfer);
tc->transfer_map = NULL;
}
- screen->tex_transfer_release(screen, &tc->transfer);
+ screen->tex_transfer_destroy(tc->transfer);
}
tc->surface = ps;
struct pipe_screen *screen = tc->transfer->texture->screen;
if (tc->tex_trans_map) {
- tc->screen->transfer_unmap(tc->screen, tc->tex_trans);
+ screen->transfer_unmap(screen, tc->tex_trans);
tc->tex_trans_map = NULL;
}
- screen->tex_transfer_release(screen, &tc->tex_trans);
+ screen->tex_transfer_destroy(tc->tex_trans);
}
/* mark as entries as invalid/empty */
if (tc->tex_trans_map)
tc->screen->transfer_unmap(tc->screen, tc->tex_trans);
- screen->tex_transfer_release(screen, &tc->tex_trans);
+ screen->tex_transfer_destroy(tc->tex_trans);
}
tc->tex_trans = screen->get_tex_transfer(screen, tc->texture, face, level, z,
static void
-trace_screen_texture_release(struct pipe_screen *_screen,
- struct pipe_texture **ptexture)
+trace_screen_texture_destroy(struct pipe_texture *texture)
{
- struct trace_screen *tr_scr = trace_screen(_screen);
- struct pipe_screen *screen = tr_scr->screen;
- struct trace_texture *tr_tex;
- struct pipe_texture *texture;
-
- assert(ptexture);
- if(*ptexture) {
- tr_tex = trace_texture(tr_scr, *ptexture);
- texture = tr_tex->texture;
- assert(texture->screen == screen);
- }
- else
- texture = NULL;
-
- if (*ptexture) {
- if (!--(*ptexture)->refcount) {
- trace_dump_call_begin("pipe_screen", "texture_destroy");
-
- trace_dump_arg(ptr, screen);
- trace_dump_arg(ptr, texture);
-
- trace_texture_destroy(tr_scr, *ptexture);
-
- trace_dump_call_end();
- }
+ struct pipe_screen *screen = texture->screen;
- *ptexture = NULL;
- }
+ trace_dump_call_begin("pipe_screen", "texture_destroy");
+
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(ptr, texture);
+
+ trace_texture_destroy(trace_screen(screen), texture);
+
+ trace_dump_call_end();
}
static void
-trace_screen_tex_surface_release(struct pipe_screen *_screen,
- struct pipe_surface **psurface)
+trace_screen_tex_surface_destroy(struct pipe_surface *surface)
{
- struct trace_screen *tr_scr = trace_screen(_screen);
- struct pipe_screen *screen = tr_scr->screen;
- struct trace_texture *tr_tex;
- struct trace_surface *tr_surf;
- struct pipe_surface *surface;
-
- assert(psurface);
- if(*psurface) {
- tr_tex = trace_texture(tr_scr, (*psurface)->texture);
- tr_surf = trace_surface(tr_tex, *psurface);
- surface = tr_surf->surface;
- }
- else
- surface = NULL;
+ struct pipe_screen *screen = surface->texture->screen;
- if (*psurface) {
- if (!--(*psurface)->refcount) {
- trace_dump_call_begin("pipe_screen", "tex_surface_destroy");
-
- trace_dump_arg(ptr, screen);
- trace_dump_arg(ptr, surface);
+ trace_dump_call_begin("pipe_screen", "tex_surface_destroy");
- trace_surface_destroy(tr_tex, *psurface);
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(ptr, surface);
- trace_dump_call_end();
- }
-
- *psurface = NULL;
- }
+ trace_surface_destroy(trace_texture(trace_screen(screen), surface->texture),
+ surface);
+
+ trace_dump_call_end();
}
static void
-trace_screen_tex_transfer_release(struct pipe_screen *_screen,
- struct pipe_transfer **ptransfer)
+trace_screen_tex_transfer_destroy(struct pipe_transfer *transfer)
{
- struct trace_screen *tr_scr = trace_screen(_screen);
- struct pipe_screen *screen = tr_scr->screen;
- struct trace_texture *tr_tex;
- struct trace_transfer *tr_trans;
- struct pipe_transfer *transfer;
-
- assert(ptransfer);
- if(*ptransfer) {
- tr_tex = trace_texture(tr_scr, (*ptransfer)->texture);
- tr_trans = trace_transfer(tr_tex, *ptransfer);
- transfer = tr_trans->transfer;
- }
- else
- transfer = NULL;
-
- if (*ptransfer) {
- if (!--(*ptransfer)->refcount) {
- trace_dump_call_begin("pipe_screen", "tex_transfer_destroy");
-
- trace_dump_arg(ptr, screen);
- trace_dump_arg(ptr, transfer);
+ struct pipe_texture *texture = transfer->texture;
+ struct pipe_screen *screen = texture->screen;
- trace_transfer_destroy(tr_tex, *ptransfer);
+ trace_dump_call_begin("pipe_screen", "tex_transfer_destroy");
- trace_dump_call_end();
- }
-
- *ptransfer = NULL;
- }
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(ptr, transfer);
+
+ trace_transfer_destroy(trace_texture(trace_screen(screen), texture),
+ transfer);
+
+ trace_dump_call_end();
}
tr_scr->base.is_format_supported = trace_screen_is_format_supported;
tr_scr->base.texture_create = trace_screen_texture_create;
tr_scr->base.texture_blanket = trace_screen_texture_blanket;
- tr_scr->base.texture_release = trace_screen_texture_release;
+ tr_scr->base.texture_destroy = trace_screen_texture_destroy;
tr_scr->base.get_tex_surface = trace_screen_get_tex_surface;
- tr_scr->base.tex_surface_release = trace_screen_tex_surface_release;
+ tr_scr->base.tex_surface_destroy = trace_screen_tex_surface_destroy;
tr_scr->base.get_tex_transfer = trace_screen_get_tex_transfer;
- tr_scr->base.tex_transfer_release = trace_screen_tex_transfer_release;
+ tr_scr->base.tex_transfer_destroy = trace_screen_tex_transfer_destroy;
tr_scr->base.transfer_map = trace_screen_transfer_map;
tr_scr->base.transfer_unmap = trace_screen_transfer_unmap;
}
+static void trace_dump_reference(const struct pipe_reference *reference)
+{
+ trace_dump_struct_begin("pipe_reference");
+ trace_dump_member(uint, reference, count);
+ trace_dump_struct_end();
+}
+
+
void trace_dump_template(const struct pipe_texture *templat)
{
if(!templat) {
trace_dump_struct_begin("pipe_surface");
+ trace_dump_reference(&state->reference);
+
trace_dump_member(format, state, format);
trace_dump_member(uint, state, status);
trace_dump_member(uint, state, clear_value);
trace_dump_member(uint, state, layout);
trace_dump_member(uint, state, offset);
- trace_dump_member(uint, state, refcount);
trace_dump_member(uint, state, usage);
trace_dump_member(ptr, state, texture);
trace_dump_member(uint, state, nblocksx);
trace_dump_member(uint, state, nblocksy);
trace_dump_member(uint, state, stride);
- trace_dump_member(uint, state, refcount);
trace_dump_member(uint, state, usage);
trace_dump_member(ptr, state, texture);
return &tr_trans->base;
error:
- pipe_transfer_reference(&transfer, NULL);
+ transfer->texture->screen->tex_transfer_destroy(transfer);
return NULL;
}
{
struct trace_transfer *tr_trans = trace_transfer(tr_tex, transfer);
pipe_texture_reference(&tr_trans->base.texture, NULL);
- pipe_transfer_reference(&tr_trans->transfer, NULL);
+ transfer->texture->screen->tex_transfer_destroy(tr_trans->transfer);
FREE(tr_trans);
}
static void
-trace_winsys_buffer_destroy(struct pipe_winsys *_winsys,
- struct pipe_buffer *buffer)
+trace_winsys_buffer_destroy(struct pipe_buffer *buffer)
{
- struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct pipe_winsys *winsys = tr_ws->winsys;
+ struct pipe_winsys *winsys = buffer->screen->winsys;
trace_dump_call_begin("pipe_winsys", "buffer_destroy");
trace_dump_arg(ptr, winsys);
trace_dump_arg(ptr, buffer);
- winsys->buffer_destroy(winsys, buffer);
+ winsys->buffer_destroy(buffer);
trace_dump_call_end();
}
void (*buffer_unmap)( struct pipe_winsys *ws,
struct pipe_buffer *buf );
- void (*buffer_destroy)( struct pipe_winsys *ws,
- struct pipe_buffer *buf );
+ void (*buffer_destroy)( struct pipe_buffer *buf );
/** Set ptr = fence, with reference counting */
#endif
-/**
- * Set 'ptr' to point to 'surf' and update reference counting.
- * The old thing pointed to, if any, will be unreferenced first.
- * 'surf' may be NULL.
- */
-static INLINE void
-pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
-{
- /* bump the refcount first */
- if (surf) {
- assert(surf->refcount);
- surf->refcount++;
- }
-
- if (*ptr) {
- struct pipe_screen *screen;
- assert((*ptr)->refcount);
- assert((*ptr)->texture);
- screen = (*ptr)->texture->screen;
- screen->tex_surface_release( screen, ptr );
- assert(!*ptr);
- }
-
- *ptr = surf;
-}
-
-
-/**
- * \sa pipe_surface_reference
- */
-static INLINE void
-pipe_transfer_reference(struct pipe_transfer **ptr, struct pipe_transfer *trans)
-{
- /* bump the refcount first */
- if (trans) {
- assert(trans->refcount);
- trans->refcount++;
- }
-
- if (*ptr) {
- struct pipe_screen *screen;
- assert((*ptr)->refcount);
- assert((*ptr)->texture);
- screen = (*ptr)->texture->screen;
- screen->tex_transfer_release( screen, ptr );
- assert(!*ptr);
- }
-
- *ptr = trans;
-}
-
-
-/**
- * \sa pipe_surface_reference
- */
-static INLINE void
-pipe_texture_reference(struct pipe_texture **ptr,
- struct pipe_texture *pt)
-{
- assert(ptr);
-
- if (pt) {
- assert(pt->refcount);
- pt->refcount++;
- }
-
- if (*ptr) {
- struct pipe_screen *screen = (*ptr)->screen;
- assert(screen);
- assert((*ptr)->refcount);
- screen->texture_release(screen, ptr);
-
- assert(!*ptr);
- }
-
- *ptr = pt;
-}
-
-
-static INLINE void
-pipe_texture_release(struct pipe_texture **ptr)
-{
- struct pipe_screen *screen;
- assert(ptr);
- screen = (*ptr)->screen;
- assert((*ptr)->refcount);
- screen->texture_release(screen, ptr);
- *ptr = NULL;
-}
-
-
/**
* Convenience wrappers for screen buffer functions.
*/
}
}
-/* XXX: thread safety issues!
- */
-static INLINE void
-pipe_buffer_reference(struct pipe_screen *screen,
- struct pipe_buffer **ptr,
- struct pipe_buffer *buf)
-{
- if (buf) {
- assert(buf->refcount);
- buf->refcount++;
- }
-
- if (*ptr) {
- assert((*ptr)->refcount);
- if(--(*ptr)->refcount == 0) {
- screen->buffer_destroy( screen, *ptr );
- }
- }
-
- *ptr = buf;
-}
-
#ifdef __cplusplus
}
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef P_REFCNT_H
+#define P_REFCNT_H
+
+
+#include "p_defines.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+struct pipe_reference
+{
+ unsigned count;
+};
+
+
+static INLINE void
+pipe_reference_init(struct pipe_reference *reference, unsigned count)
+{
+ reference->count = count;
+}
+
+
+/**
+ * Set 'ptr' to point to 'reference' and update reference counting.
+ * The old thing pointed to, if any, will be unreferenced first.
+ * 'reference' may be NULL.
+ *
+ * XXX: thread safety issues!
+ */
+static INLINE bool
+pipe_reference(struct pipe_reference **ptr, struct pipe_reference *reference)
+{
+ bool destroy = FALSE;
+
+ /* bump the reference.count first */
+ if (reference) {
+ assert(reference->count);
+ reference->count++;
+ }
+
+ if (*ptr) {
+ assert((*ptr)->count);
+ if (--(*ptr)->count == 0) {
+ destroy = TRUE;
+ }
+ }
+
+ *ptr = reference;
+
+ return destroy;
+}
+
+
+#endif /* P_REFCNT_H */
const unsigned *stride,
struct pipe_buffer *buffer);
- void (*texture_release)(struct pipe_screen *,
- struct pipe_texture **pt);
+ void (*texture_destroy)(struct pipe_texture *pt);
/** Get a surface which is a "view" into a texture */
struct pipe_surface *(*get_tex_surface)(struct pipe_screen *,
unsigned zslice,
unsigned usage );
- /* Surfaces allocated by the above must be released here:
- */
- void (*tex_surface_release)( struct pipe_screen *,
- struct pipe_surface ** );
+ void (*tex_surface_destroy)(struct pipe_surface *);
/** Get a transfer object for transferring data to/from a texture */
unsigned x, unsigned y,
unsigned w, unsigned h);
- /* Transfer objects allocated by the above must be released here:
- */
- void (*tex_transfer_release)( struct pipe_screen *,
- struct pipe_transfer ** );
+ void (*tex_transfer_destroy)(struct pipe_transfer *);
void *(*transfer_map)( struct pipe_screen *,
struct pipe_transfer *transfer );
void (*buffer_unmap)( struct pipe_screen *screen,
struct pipe_buffer *buf );
- void (*buffer_destroy)( struct pipe_screen *screen,
- struct pipe_buffer *buf );
+ void (*buffer_destroy)( struct pipe_buffer *buf );
/**
#include "p_compiler.h"
#include "p_defines.h"
#include "p_format.h"
+#include "p_refcnt.h"
+#include "p_screen.h"
#ifdef __cplusplus
/* fwd decls */
-struct pipe_screen;
struct pipe_surface;
-
/**
* The driver will certainly subclass this to include actual memory
* management information.
*/
struct pipe_buffer
{
+ struct pipe_reference reference;
+ struct pipe_screen *screen;
unsigned alignment;
unsigned usage;
unsigned size;
-
- /** Reference count */
- unsigned refcount;
};
*/
struct pipe_surface
{
+ struct pipe_reference reference;
enum pipe_format format; /**< PIPE_FORMAT_x */
unsigned status; /**< PIPE_SURFACE_STATUS_x */
unsigned clear_value; /**< XXX may be temporary */
unsigned height; /**< logical height in pixels */
unsigned layout; /**< PIPE_SURFACE_LAYOUT_x */
unsigned offset; /**< offset from start of buffer, in bytes */
- unsigned refcount;
unsigned usage; /**< PIPE_BUFFER_USAGE_* */
struct pipe_texture *texture; /**< texture into which this is a view */
unsigned nblocksx; /**< allocated width in blocks */
unsigned nblocksy; /**< allocated height in blocks */
unsigned stride; /**< stride in bytes between rows of blocks */
- unsigned refcount;
unsigned usage; /**< PIPE_TRANSFER_* */
struct pipe_texture *texture; /**< texture to transfer to/from */
*/
struct pipe_texture
{
+ struct pipe_reference reference;
+
enum pipe_texture_target target; /**< PIPE_TEXTURE_x */
enum pipe_format format; /**< PIPE_FORMAT_x */
unsigned tex_usage; /* PIPE_TEXTURE_USAGE_* */
- /* These are also refcounted:
- */
- unsigned refcount;
-
struct pipe_screen *screen; /**< screen that this texture belongs to */
};
};
+/* Reference counting helper functions */
+static INLINE void
+pipe_buffer_reference(struct pipe_buffer **ptr, struct pipe_buffer *buf)
+{
+ struct pipe_buffer *old_buf = *ptr;
+
+ if (pipe_reference((struct pipe_reference **)ptr, &buf->reference))
+ old_buf->screen->buffer_destroy(old_buf);
+}
+
+static INLINE void
+pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
+{
+ struct pipe_surface *old_surf = *ptr;
+
+ if (pipe_reference((struct pipe_reference **)ptr, &surf->reference))
+ old_surf->texture->screen->tex_surface_destroy(old_surf);
+}
+
+static INLINE void
+pipe_texture_reference(struct pipe_texture **ptr, struct pipe_texture *tex)
+{
+ struct pipe_texture *old_tex = *ptr;
+
+ if (pipe_reference((struct pipe_reference **)ptr, &tex->reference))
+ old_tex->screen->texture_destroy(old_tex);
+}
+
+
#ifdef __cplusplus
}
#endif
buf);
/* we don't need the buffer from this point on */
- pipe_buffer_reference(screen, &buf, NULL);
+ pipe_buffer_reference(&buf, NULL);
if (!texture)
return NULL;
err_surf:
pipe_texture_reference(&texture, NULL);
err_tex:
- pipe_buffer_reference(screen, &buf, NULL);
+ pipe_buffer_reference(&buf, NULL);
err_buf:
return;
}
pipe_surface_reference(&screen->surface, NULL);
pipe_texture_reference(&screen->tex, NULL);
- pipe_buffer_reference(dev->screen, &screen->buffer, NULL);
+ pipe_buffer_reference(&screen->buffer, NULL);
screen->shown = 0;
}
err_bo:
pipe_surface_reference(&scrn->surface, NULL);
pipe_texture_reference(&scrn->tex, NULL);
- pipe_buffer_reference(dev->screen, &scrn->buffer, NULL);
+ pipe_buffer_reference(&scrn->buffer, NULL);
return EGL_FALSE;
}
pipe->delete_fs_state(pipe, basic_csc->fragment_shader);
for (i = 0; i < 2; ++i)
- pipe_buffer_reference(pipe->screen, &basic_csc->vertex_bufs[i].buffer, NULL);
+ pipe_buffer_reference(&basic_csc->vertex_bufs[i].buffer, NULL);
- pipe_buffer_reference(pipe->screen, &basic_csc->vs_const_buf.buffer, NULL);
- pipe_buffer_reference(pipe->screen, &basic_csc->fs_const_buf.buffer, NULL);
+ pipe_buffer_reference(&basic_csc->vs_const_buf.buffer, NULL);
+ pipe_buffer_reference(&basic_csc->fs_const_buf.buffer, NULL);
FREE(basic_csc);
for (i = 0; i < 3; ++i)
{
pipe->screen->transfer_unmap(pipe->screen, mc->tex_transfer[i]);
- pipe->screen->tex_transfer_release(pipe->screen, &mc->tex_transfer[i]);
+ pipe->screen->tex_transfer_destroy(mc->tex_transfer[i]);
}
mc->render_target.cbufs[0] = pipe->screen->get_tex_surface
pipe->delete_sampler_state(pipe, mc->samplers.all[i]);
for (i = 0; i < 3; ++i)
- pipe_buffer_reference(pipe->screen, &mc->vertex_bufs.all[i].buffer, NULL);
+ pipe_buffer_reference(&mc->vertex_bufs.all[i].buffer, NULL);
/* Textures 3 & 4 are not created directly, no need to release them here */
for (i = 0; i < 3; ++i)
pipe->delete_fs_state(pipe, mc->b_fs[i]);
}
- pipe_buffer_reference(pipe->screen, &mc->vs_const_buf.buffer, NULL);
- pipe_buffer_reference(pipe->screen, &mc->fs_const_buf.buffer, NULL);
+ pipe_buffer_reference(&mc->vs_const_buf.buffer, NULL);
+ pipe_buffer_reference(&mc->fs_const_buf.buffer, NULL);
FREE(mc->macroblocks);
FREE(mc);
}
+static void
+st_device_reference(struct st_device **ptr, struct st_device *st_dev)
+{
+ struct st_device *old_dev = *ptr;
+
+ if (pipe_reference((struct pipe_reference **)ptr, &st_dev->reference))
+ st_device_really_destroy(old_dev);
+}
+
+
void
st_device_destroy(struct st_device *st_dev)
{
- if(!--st_dev->refcount)
- st_device_really_destroy(st_dev);
+ st_device_reference(&st_dev, NULL);
}
if(!st_dev)
return NULL;
- st_dev->refcount = 1;
+ pipe_reference_init(&st_dev->reference, 1);
st_dev->st_ws = st_ws;
st_dev->real_screen = st_ws->screen_create();
FREE(st_ctx);
- if(!--st_dev->refcount)
- st_device_really_destroy(st_dev);
+ st_device_reference(&st_dev, NULL);
}
}
if(!st_ctx)
return NULL;
- st_ctx->st_dev = st_dev;
- ++st_dev->refcount;
+ st_device_reference(&st_ctx->st_dev, st_dev);
st_ctx->real_pipe = st_dev->st_ws->context_create(st_dev->real_screen);
if(!st_ctx->real_pipe) {
st_buffer_destroy(struct st_buffer *st_buf)
{
if(st_buf) {
- struct pipe_screen *screen = st_buf->st_dev->screen;
- pipe_buffer_reference(screen, &st_buf->buffer, NULL);
+ pipe_buffer_reference(&st_buf->buffer, NULL);
FREE(st_buf);
}
}
struct st_device {
+ /* FIXME: we also need to refcount for textures and surfaces... */
+ struct pipe_reference reference;
+
const struct st_winsys *st_ws;
struct pipe_screen *real_screen;
struct pipe_screen *screen;
-
- /* FIXME: we also need to refcount for textures and surfaces... */
- unsigned refcount;
};
{
struct st_softpipe_buffer *buffer = CALLOC_STRUCT(st_softpipe_buffer);
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.alignment = alignment;
buffer->base.usage = usage;
buffer->base.size = size;
if(!buffer)
return NULL;
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.size = bytes;
buffer->userBuffer = TRUE;
buffer->data = ptr;
struct crtc_private *crtcp = crtc->driver_private;
if (crtcp->cursor_buf)
- pipe_buffer_reference(ms->screen, &crtcp->cursor_buf, NULL);
+ pipe_buffer_reference(&crtcp->cursor_buf, NULL);
drmModeFreeCrtc(crtcp->drm_crtc);
xfree(crtcp);
struct crtc_private *crtcp = crtc->driver_private;
if (crtcp->cursor_buf) {
- pipe_buffer_reference(ms->screen, &crtcp->cursor_buf, NULL);
+ pipe_buffer_reference(&crtcp->cursor_buf, NULL);
}
}
(*pScreen->DestroyPixmap)(private->pPixmap);
pipe_texture_reference(&private->tex, NULL);
- pipe_buffer_reference(ms->screen, &private->buf, NULL);
+ pipe_buffer_reference(&private->buf, NULL);
}
if (buffers) {
return;
exa->scrn->transfer_unmap(exa->scrn, priv->map_transfer);
- pipe_transfer_reference(&priv->map_transfer, NULL);
+ exa->scrn->tex_transfer_destroy(priv->map_transfer);
}
return;
if (priv->src_surf)
- exa->scrn->tex_surface_release(exa->scrn, &priv->src_surf);
+ exa->scrn->tex_surface_destroy(priv->src_surf);
priv->src_surf = NULL;
}
exa->ctx->surface_fill(exa->ctx, surf, x0, y0, x1 - x0, y1 - y0,
priv->color);
- exa->scrn->tex_surface_release(exa->scrn, &surf);
+ exa->scrn->tex_surface_destroy(surf);
}
static Bool
exa->ctx->surface_copy(exa->ctx, 0, surf, dstX, dstY, priv->src_surf,
srcX, srcY, width, height);
- exa->scrn->tex_surface_release(exa->scrn, &surf);
+ exa->scrn->tex_surface_destroy(surf);
}
static Bool
return;
if (priv->tex)
- ms->screen->texture_release(exa->scrn, &priv->tex);
+ ms->screen->texture_destroy(priv->tex);
xfree(priv);
}
drm_api_hooks.buffer_from_texture(priv->tex, &buffer, &stride);
drm_api_hooks.handle_from_buffer(ms->screen, buffer, &handle);
- pipe_buffer_reference(ms->screen, &buffer, NULL);
+ pipe_buffer_reference(&buffer, NULL);
return handle;
}
if (fence) {
if (*fence)
- intel_be_fence_unreference(*fence);
+ intel_be_fence_reference(fence, NULL);
(*fence) = CALLOC_STRUCT(intel_be_fence);
- (*fence)->refcount = 1;
+ pipe_reference_init(&(*fence)->reference, 1);
(*fence)->bo = NULL;
}
}
}
static void
-intel_be_buffer_destroy(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
+intel_be_buffer_destroy(struct pipe_buffer *buf)
{
drm_intel_bo_unreference(intel_bo(buf));
free(buf);
if (!buffer)
return NULL;
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.alignment = alignment;
buffer->base.usage = usage;
buffer->base.size = size;
if (!buffer)
return NULL;
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.alignment = 0;
buffer->base.usage = 0;
buffer->base.size = bytes;
if (!buffer->bo)
goto err;
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.alignment = buffer->bo->align;
buffer->base.usage = PIPE_BUFFER_USAGE_GPU_READ |
PIPE_BUFFER_USAGE_GPU_WRITE |
struct intel_be_fence **p = (struct intel_be_fence **)ptr;
struct intel_be_fence *f = (struct intel_be_fence *)fence;
- assert(p);
-
- if (f)
- intel_be_fence_reference(f);
-
- if (*p)
- intel_be_fence_unreference(*p);
-
- *p = f;
+ intel_be_fence_reference(p, f);
}
static int
*/
struct intel_be_fence
{
- uint32_t refcount;
+ struct pipe_reference reference;
drm_intel_bo *bo;
};
static INLINE void
-intel_be_fence_reference(struct intel_be_fence *f)
+intel_be_fence_reference(struct intel_be_fence **ptr, struct intel_be_fence *f)
{
- f->refcount++;
-}
+ struct intel_be_fence *old_fence = *ptr;
-static INLINE void
-intel_be_fence_unreference(struct intel_be_fence *f)
-{
- if (!--f->refcount) {
- if (f->bo)
- drm_intel_bo_unreference(f->bo);
- free(f);
+ if (pipe_reference((struct pipe_reference**)ptr, &f->reference)) {
+ if (old_fence->bo)
+ drm_intel_bo_unreference(old_fence->bo);
+ free(old_fence);
}
}
nv_screen->nvc = nvc;
}
- nvc->refcount++;
- nv->nvc = nvc;
+ pipe_reference((struct pipe_reference**)&nv->nvc, &nvc->reference);
/* Find a free slot for a pipe context, allocate a new one if needed */
nv->pctx_id = -1;
enum pipe_format format;
fb_buf = calloc(1, sizeof(struct nouveau_pipe_buffer));
- fb_buf->base.refcount = 1;
+ pipe_reference_init(&fb_buf->base.reference, 1);
fb_buf->base.usage = PIPE_BUFFER_USAGE_PIXEL;
nouveau_bo_fake(dev, nv_screen->front_offset, NOUVEAU_BO_VRAM,
if (nv->pctx_id >= 0) {
nvc->pctx[nv->pctx_id] = NULL;
- if (--nvc->refcount <= 0) {
+ if (pipe_reference((struct pipe_reference**)&nv->nvc, NULL)) {
nouveau_channel_context_destroy(nvc);
nv->nv_screen->nvc = NULL;
}
#include "nouveau_local.h"
struct nouveau_channel_context {
+ struct pipe_reference reference;
struct pipe_screen *pscreen;
- int refcount;
unsigned cur_pctx;
unsigned nr_pctx;
nvbuf = CALLOC_STRUCT(nouveau_pipe_buffer);
if (!nvbuf)
return NULL;
- nvbuf->base.refcount = 1;
+ pipe_reference_init(&nvbuf->base.reference, 1);
nvbuf->base.alignment = alignment;
nvbuf->base.usage = usage;
nvbuf->base.size = size;
nvbuf = CALLOC_STRUCT(nouveau_pipe_buffer);
if (!nvbuf)
return NULL;
- nvbuf->base.refcount = 1;
+ pipe_reference_init(&nvbuf->base.reference, 1);
nvbuf->base.size = bytes;
if (nouveau_bo_user(dev, ptr, bytes, &nvbuf->bo)) {
}
static void
-nouveau_pipe_bo_del(struct pipe_winsys *ws, struct pipe_buffer *buf)
+nouveau_pipe_bo_del(struct pipe_buffer *buf)
{
struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf);
return NULL;
}
- radeon_buffer->base.refcount = 1;
+ pipe_reference_init(&radeon_buffer->base.reference, 1);
radeon_buffer->base.alignment = alignment;
radeon_buffer->base.usage = usage;
radeon_buffer->base.size = size;
return &radeon_buffer->base;
}
-static void radeon_buffer_del(struct pipe_winsys *ws, struct pipe_buffer *buffer)
+static void radeon_buffer_del(struct pipe_buffer *buffer)
{
struct radeon_pipe_buffer *radeon_buffer = (struct radeon_pipe_buffer*)buffer;
radeon_bo_unref(bo);
return NULL;
}
- radeon_buffer->base.refcount = 1;
+ pipe_reference_init(&radeon_buffer->base.reference, 1);
radeon_buffer->base.usage = PIPE_BUFFER_USAGE_PIXEL;
radeon_buffer->bo = bo;
return &radeon_buffer->base;
pt = pipe_screen->texture_blanket(pipe_screen, &tmpl, &pitch, pb);
if (pt == NULL) {
- pipe_buffer_reference(pipe_screen, &pb, NULL);
+ pipe_buffer_reference(&pb, NULL);
}
ps = pipe_screen->get_tex_surface(pipe_screen, pt, 0, 0, 0,
PIPE_BUFFER_USAGE_GPU_WRITE);
return ps;
}
-#endif
\ No newline at end of file
+#endif
return NULL;
}
- radeon_buffer->base.refcount = 1;
+ pipe_reference_init(&radeon_buffer->base.reference, 1);
+ radeon_buffer->base.screen = screen;
radeon_buffer->base.usage = PIPE_BUFFER_USAGE_PIXEL;
radeon_buffer->bo = bo;
return &radeon_buffer->base;
if (!buffer)
return NULL;
- buffer->Base.refcount = 1;
+ pipe_reference_init(&buffer->Base.reference, 1);
buffer->Base.alignment = alignment;
buffer->Base.usage = usage;
buffer->Base.size = size;
if (!buffer)
return NULL;
- buffer->Base.refcount = 1;
+ pipe_reference_init(&buffer->Base.reference, 1);
buffer->Base.size = bytes;
buffer->UserBuffer = TRUE;
buffer->Data = ptr;
static void
-buffer_destroy(struct pipe_winsys *pws, struct pipe_buffer *buf)
+buffer_destroy(struct pipe_buffer *buf)
{
struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf);
assert(pws);
buffer = calloc(1, sizeof(struct xsp_buffer));
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.alignment = alignment;
buffer->base.usage = usage;
buffer->base.size = size;
assert(pws);
buffer = calloc(1, sizeof(struct xsp_buffer));
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.size = size;
buffer->is_user_buffer = TRUE;
buffer->data = data;
static void
-gdi_softpipe_buffer_destroy(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
+gdi_softpipe_buffer_destroy(struct pipe_buffer *buf)
{
struct gdi_softpipe_buffer *oldBuf = gdi_softpipe_buffer(buf);
{
struct gdi_softpipe_buffer *buffer = CALLOC_STRUCT(gdi_softpipe_buffer);
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.alignment = alignment;
buffer->base.usage = usage;
buffer->base.size = size;
if(!buffer)
return NULL;
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.size = bytes;
buffer->userBuffer = TRUE;
buffer->data = ptr;
}
struct aub_buffer {
+ struct pipe_reference reference;
char *data;
unsigned offset;
unsigned size;
- unsigned refcount;
unsigned map_count;
boolean dump_on_unmap;
};
static void
-aub_buffer_destroy(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
+aub_buffer_destroy(struct pipe_buffer *buf)
{
free(buf);
}
struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys);
struct aub_buffer *sbo = CALLOC_STRUCT(aub_buffer);
- sbo->refcount = 1;
+ pipe_reference_init(&sbo->reference, 1);
/* Could reuse buffers that are not referenced in current
* batchbuffer. Can't do that atm, so always reallocate:
{
struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.alignment = alignment;
buffer->base.usage = usage;
buffer->base.size = size;
xm_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes)
{
struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.size = bytes;
buffer->userBuffer = TRUE;
buffer->data = ptr;
}
static void
-xm_buffer_destroy(struct pipe_winsys *pws,
- struct pipe_buffer *buf)
+xm_buffer_destroy(struct pipe_buffer *buf)
{
struct xm_buffer *oldBuf = xm_buffer(buf);
}
#endif
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.alignment = alignment;
buffer->base.usage = usage;
buffer->base.size = size;
xm_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes)
{
struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.size = bytes;
buffer->userBuffer = TRUE;
buffer->data = ptr;
/* We always need to get a new buffer, to keep the drivers simple and
* avoid gratuitous rendering synchronization.
*/
- pipe_buffer_reference(pipe->screen, &cbuf->buffer, NULL );
+ pipe_buffer_reference(&cbuf->buffer, NULL );
cbuf->buffer = pipe_buffer_create(pipe->screen, 16, PIPE_BUFFER_USAGE_CONSTANT,
paramBytes );
}
screen->transfer_unmap(screen, transfer);
- screen->tex_transfer_release(screen, &transfer);
+ screen->tex_transfer_destroy(transfer);
}
}
screen->transfer_unmap(screen, acc_pt);
- screen->tex_transfer_release(screen, &acc_pt);
+ screen->tex_transfer_destroy(acc_pt);
}
}
screen->transfer_unmap(screen, acc_pt);
- screen->tex_transfer_release(screen, &acc_pt);
+ screen->tex_transfer_destroy(acc_pt);
}
accBuf[i] = accBuf[i] + colorBuf[i] * value;
}
- screen->tex_transfer_release(screen, &acc_trans);
+ screen->tex_transfer_destroy(acc_trans);
acc_trans = screen->get_tex_transfer(screen, acc_strb->texture, 0, 0, 0,
PIPE_TRANSFER_WRITE, xpos, ypos,
width, height);
_mesa_free(colorBuf);
_mesa_free(accBuf);
- screen->tex_transfer_release(screen, &acc_trans);
- screen->tex_transfer_release(screen, &color_trans);
+ screen->tex_transfer_destroy(acc_trans);
+ screen->tex_transfer_destroy(color_trans);
}
acc_put_tile_rgba(pipe, acc_trans, 0, 0, width, height, buf);
_mesa_free(buf);
- screen->tex_transfer_release(screen, &acc_trans);
- screen->tex_transfer_release(screen, &color_trans);
+ screen->tex_transfer_destroy(acc_trans);
+ screen->tex_transfer_destroy(color_trans);
}
_mesa_free(abuf);
if (cbuf)
_mesa_free(cbuf);
- screen->tex_transfer_release(screen, &acc_trans);
- screen->tex_transfer_release(screen, &color_trans);
+ screen->tex_transfer_destroy(acc_trans);
+ screen->tex_transfer_destroy(color_trans);
}
/* Release transfer */
screen->transfer_unmap(screen, transfer);
- screen->tex_transfer_release(screen, &transfer);
+ screen->tex_transfer_destroy(transfer);
return pt;
}
GLuint i;
if (st->bitmap.vbuf_slot >= max_slots) {
- pipe_buffer_reference(pipe->screen, &st->bitmap.vbuf, NULL);
+ pipe_buffer_reference(&st->bitmap.vbuf, NULL);
st->bitmap.vbuf_slot = 0;
}
cache->ymax = -1000000;
if (cache->trans)
- screen->tex_transfer_release(screen, &cache->trans);
+ screen->tex_transfer_destroy(cache->trans);
assert(!cache->texture);
screen->transfer_unmap(screen, cache->trans);
cache->buffer = NULL;
- screen->tex_transfer_release(screen, &cache->trans);
+ screen->tex_transfer_destroy(cache->trans);
draw_bitmap_quad(st->ctx,
cache->xpos,
/* Release vertex buffer to avoid synchronous rendering if we were
* to map it in the next frame.
*/
- pipe_buffer_reference(st->pipe->screen, &st->bitmap.vbuf, NULL);
+ pipe_buffer_reference(&st->bitmap.vbuf, NULL);
st->bitmap.vbuf_slot = 0;
}
struct bitmap_cache *cache = st->bitmap.cache;
screen->transfer_unmap(screen, cache->trans);
- screen->tex_transfer_release(screen, &cache->trans);
+ screen->tex_transfer_destroy(cache->trans);
if (st->bitmap.vs) {
cso_delete_vertex_shader(st->cso_context, st->bitmap.vs);
util_free_shader(&st->bitmap.vert_shader);
if (st->bitmap.vbuf) {
- pipe_buffer_reference(pipe->screen, &st->bitmap.vbuf, NULL);
+ pipe_buffer_reference(&st->bitmap.vbuf, NULL);
st->bitmap.vbuf = NULL;
}
if (st->bitmap.cache) {
- pipe_texture_release(&st->bitmap.cache->texture);
+ pipe_texture_reference(&st->bitmap.cache->texture, NULL);
_mesa_free(st->bitmap.cache);
st->bitmap.cache = NULL;
}
static void
st_bufferobj_free(GLcontext *ctx, struct gl_buffer_object *obj)
{
- struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_buffer_object *st_obj = st_buffer_object(obj);
if (st_obj->buffer)
- pipe_buffer_reference(pipe->screen, &st_obj->buffer, NULL);
+ pipe_buffer_reference(&st_obj->buffer, NULL);
_mesa_free(st_obj);
}
buffer_usage = 0;
}
- pipe_buffer_reference( pipe->screen, &st_obj->buffer, NULL );
+ pipe_buffer_reference( &st_obj->buffer, NULL );
st_obj->buffer = pipe_buffer_create( pipe->screen, 32, buffer_usage, size );
void
st_destroy_clear(struct st_context *st)
{
- struct pipe_context *pipe = st->pipe;
-
if (st->clear.vert_shader.tokens) {
util_free_shader(&st->clear.vert_shader);
st->clear.vert_shader.tokens = NULL;
st->clear.vs = NULL;
}
if (st->clear.vbuf) {
- pipe_buffer_reference(pipe->screen, &st->clear.vbuf, NULL);
+ pipe_buffer_reference(&st->clear.vbuf, NULL);
st->clear.vbuf = NULL;
}
}
GLuint i;
if (st->clear.vbuf_slot >= max_slots) {
- pipe_buffer_reference(pipe->screen, &st->clear.vbuf, NULL);
+ pipe_buffer_reference(&st->clear.vbuf, NULL);
st->clear.vbuf_slot = 0;
}
/* Release vertex buffer to avoid synchronous rendering if we were
* to map it in the next frame.
*/
- pipe_buffer_reference(st->pipe->screen, &st->clear.vbuf, NULL);
+ pipe_buffer_reference(&st->clear.vbuf, NULL);
st->clear.vbuf_slot = 0;
}
/* unmap */
screen->transfer_unmap(screen, transfer);
- screen->tex_transfer_release(screen, &transfer);
+ screen->tex_transfer_destroy(transfer);
assert(success);
PIPE_PRIM_QUADS,
4, /* verts */
3); /* attribs/vert */
- pipe_buffer_reference(pipe->screen, &buf, NULL);
+ pipe_buffer_reference(&buf, NULL);
}
}
/* unmap the stencil buffer */
screen->transfer_unmap(screen, pt);
- screen->tex_transfer_release(screen, &pt);
+ screen->tex_transfer_destroy(pt);
}
/* unmap the stencil buffer */
screen->transfer_unmap(screen, ptDraw);
- screen->tex_transfer_release(screen, &ptDraw);
+ screen->tex_transfer_destroy(ptDraw);
}
_mesa_free(buf);
}
- screen->tex_transfer_release(screen, &ptRead);
- screen->tex_transfer_release(screen, &ptTex);
+ screen->tex_transfer_destroy(ptRead);
+ screen->tex_transfer_destroy(ptTex);
}
/* draw textured quad */
st_finish_render_texture(GLcontext *ctx,
struct gl_renderbuffer_attachment *att)
{
- struct pipe_screen *screen = ctx->st->pipe->screen;
struct st_renderbuffer *strb = st_renderbuffer(att->Renderbuffer);
if (!strb)
st_flush( ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL );
if (strb->surface)
- screen->tex_surface_release( screen, &strb->surface );
+ pipe_surface_reference( &strb->surface, NULL );
strb->rtt = NULL;
/* unmap the stencil buffer */
screen->transfer_unmap(screen, pt);
- screen->tex_transfer_release(screen, &pt);
+ screen->tex_transfer_destroy(pt);
}
map = screen->transfer_map(screen, trans);
if (!map) {
- screen->tex_transfer_release(screen, &trans);
+ screen->tex_transfer_destroy(trans);
return GL_FALSE;
}
}
screen->transfer_unmap(screen, trans);
- screen->tex_transfer_release(screen, &trans);
+ screen->tex_transfer_destroy(trans);
}
return GL_TRUE;
}
}
- screen->tex_transfer_release(screen, &trans);
+ screen->tex_transfer_destroy(trans);
_mesa_unmap_readpix_pbo(ctx, &clippedPacking);
}
srcY = strb->Base.Height - srcY - height;
}
- src_trans = pipe->screen->get_tex_transfer( pipe->screen,
- strb->texture,
- 0, 0, 0,
- PIPE_TRANSFER_READ,
- srcX, srcY,
- width, height);
+ src_trans = screen->get_tex_transfer( screen,
+ strb->texture,
+ 0, 0, 0,
+ PIPE_TRANSFER_READ,
+ srcX, srcY,
+ width, height);
texDest = st_texture_image_map(ctx->st, stImage, 0, PIPE_TRANSFER_WRITE,
destX, destY, width, height);
}
st_texture_image_unmap(ctx->st, stImage);
- screen->tex_transfer_release(screen, &src_trans);
+ screen->tex_transfer_destroy(src_trans);
}
stObj->pt->depth[0] != firstImage->base.Depth2 ||
stObj->pt->block.size/stObj->pt->block.width != cpp || /* Nominal bytes per pixel */
stObj->pt->compressed != firstImage->base.IsCompressed) {
- pipe_texture_release(&stObj->pt);
+ pipe_texture_reference(&stObj->pt, NULL);
ctx->st->dirty.st |= ST_NEW_FRAMEBUFFER;
}
}
for (i = 0; i < Elements(st->state.constants); i++) {
if (st->state.constants[i].buffer) {
- pipe_buffer_reference(st->pipe->screen, &st->state.constants[i].buffer, NULL);
+ pipe_buffer_reference(&st->state.constants[i].buffer, NULL);
}
}
}
else {
vbuffer->buffer = NULL;
- pipe_buffer_reference(pipe->screen, &vbuffer->buffer, stobj->buffer);
+ pipe_buffer_reference(&vbuffer->buffer, stobj->buffer);
vbuffer->buffer_offset = (unsigned) low;
}
vbuffer->stride = stride; /* in bytes */
/*printf("stobj %u = %p\n", attr, (void*) stobj);*/
vbuffer[attr].buffer = NULL;
- pipe_buffer_reference(pipe->screen, &vbuffer[attr].buffer, stobj->buffer);
+ pipe_buffer_reference(&vbuffer[attr].buffer, stobj->buffer);
vbuffer[attr].buffer_offset = (unsigned) arrays[mesaAttr]->Ptr;
velements[attr].src_offset = 0;
}
if (bufobj && bufobj->Name) {
/* elements/indexes are in a real VBO */
struct st_buffer_object *stobj = st_buffer_object(bufobj);
- pipe_buffer_reference(pipe->screen, &indexBuf, stobj->buffer);
+ pipe_buffer_reference(&indexBuf, stobj->buffer);
indexOffset = (unsigned) ib->ptr / indexSize;
}
else {
}
}
- pipe_buffer_reference(pipe->screen, &indexBuf, NULL);
+ pipe_buffer_reference(&indexBuf, NULL);
}
else {
/* non-indexed */
/* unreference buffers (frees wrapped user-space buffer objects) */
for (attr = 0; attr < num_vbuffers; attr++) {
- pipe_buffer_reference(pipe->screen, &vbuffer[attr].buffer, NULL);
+ pipe_buffer_reference(&vbuffer[attr].buffer, NULL);
assert(!vbuffer[attr].buffer);
}
assert(stobj->buffer);
vbuffers[attr].buffer = NULL;
- pipe_buffer_reference(pipe->screen, &vbuffers[attr].buffer, stobj->buffer);
+ pipe_buffer_reference(&vbuffers[attr].buffer, stobj->buffer);
vbuffers[attr].buffer_offset = (unsigned) arrays[0]->Ptr;/* in bytes */
velements[attr].src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr;
}
for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
if (draw->pt.vertex_buffer[i].buffer) {
pipe_buffer_unmap(pipe->screen, draw->pt.vertex_buffer[i].buffer);
- pipe_buffer_reference(pipe->screen, &draw->pt.vertex_buffer[i].buffer, NULL);
+ pipe_buffer_reference(&draw->pt.vertex_buffer[i].buffer, NULL);
draw_set_mapped_vertex_buffer(draw, i, NULL);
}
}
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);
}
}
newtex = screen->texture_create(screen, &pt);
- assert(!newtex || newtex->refcount == 1);
+ assert(!newtex || newtex->reference.count == 1);
return newtex;
}
screen->transfer_unmap(screen, stImage->transfer);
- screen->tex_transfer_release(screen, &stImage->transfer);
+ screen->tex_transfer_destroy(stImage->transfer);
}
0, 0, /* source x, y */
dst->width[level], dst->height[level]); /* width, height */
- screen->tex_transfer_release(screen, &dst_transfer);
+ screen->tex_transfer_destroy(dst_transfer);
srcUB += src_image_stride;
}
0, 0, /* srcX, Y */
width, height);
- screen->tex_surface_release(screen, &src_surface);
- screen->tex_surface_release(screen, &dst_surface);
+ pipe_surface_reference(&src_surface, NULL);
+ pipe_surface_reference(&dst_surface, NULL);
}
}