summaryrefslogtreecommitdiff
path: root/src/gallium/include
diff options
context:
space:
mode:
authorRoland Scheidegger <sroland@vmware.com>2009-12-08 19:26:20 +0100
committerRoland Scheidegger <sroland@vmware.com>2009-12-08 19:26:20 +0100
commit4ebc54795dc93f7eee200312abfa2da1b49506e3 (patch)
tree3303b9bd235763ddfe55603f3e16d54fc41d83c5 /src/gallium/include
parentbc7567d9665924650c43c661d07ae9a922554bee (diff)
parentee1720b99dfb5964962f2346406a4e3e88374a68 (diff)
Merge branch 'gallium-strict-aliasing'
Diffstat (limited to 'src/gallium/include')
-rw-r--r--src/gallium/include/pipe/p_refcnt.h18
-rw-r--r--src/gallium/include/pipe/p_state.h9
-rw-r--r--src/gallium/include/pipe/p_video_state.h3
3 files changed, 16 insertions, 14 deletions
diff --git a/src/gallium/include/pipe/p_refcnt.h b/src/gallium/include/pipe/p_refcnt.h
index 1f9088b3e9..f1875b6b82 100644
--- a/src/gallium/include/pipe/p_refcnt.h
+++ b/src/gallium/include/pipe/p_refcnt.h
@@ -59,30 +59,28 @@ pipe_is_referenced(struct pipe_reference *reference)
/**
- * 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.
+ * Update reference counting.
+ * The old thing pointed to, if any, will be unreferenced.
+ * Both 'ptr' and 'reference' may be NULL.
*/
static INLINE bool
-pipe_reference(struct pipe_reference **ptr, struct pipe_reference *reference)
+pipe_reference(struct pipe_reference *ptr, struct pipe_reference *reference)
{
bool destroy = FALSE;
- if(*ptr != reference) {
+ if(ptr != reference) {
/* bump the reference.count first */
if (reference) {
assert(pipe_is_referenced(reference));
p_atomic_inc(&reference->count);
}
- if (*ptr) {
- assert(pipe_is_referenced(*ptr));
- if (p_atomic_dec_zero(&(*ptr)->count)) {
+ if (ptr) {
+ assert(pipe_is_referenced(ptr));
+ if (p_atomic_dec_zero(&ptr->count)) {
destroy = TRUE;
}
}
-
- *ptr = reference;
}
return destroy;
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index cbd5bfa469..60e96b98de 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -392,8 +392,9 @@ 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))
+ if (pipe_reference(&(*ptr)->reference, &buf->reference))
old_buf->screen->buffer_destroy(old_buf);
+ *ptr = buf;
}
static INLINE void
@@ -401,8 +402,9 @@ 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))
+ if (pipe_reference(&(*ptr)->reference, &surf->reference))
old_surf->texture->screen->tex_surface_destroy(old_surf);
+ *ptr = surf;
}
static INLINE void
@@ -410,8 +412,9 @@ 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))
+ if (pipe_reference(&(*ptr)->reference, &tex->reference))
old_tex->screen->texture_destroy(old_tex);
+ *ptr = tex;
}
diff --git a/src/gallium/include/pipe/p_video_state.h b/src/gallium/include/pipe/p_video_state.h
index 4da26d608c..b85f01c2b0 100644
--- a/src/gallium/include/pipe/p_video_state.h
+++ b/src/gallium/include/pipe/p_video_state.h
@@ -56,8 +56,9 @@ pipe_video_surface_reference(struct pipe_video_surface **ptr, struct pipe_video_
{
struct pipe_video_surface *old_surf = *ptr;
- if (pipe_reference((struct pipe_reference **)ptr, &surf->reference))
+ if (pipe_reference(&(*ptr)->reference, &surf->reference))
old_surf->screen->video_surface_destroy(old_surf);
+ *ptr = surf;
}
struct pipe_video_rect