diff options
Diffstat (limited to 'src/gallium/include/pipe/p_state.h')
-rw-r--r-- | src/gallium/include/pipe/p_state.h | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index a2e839da5c6..57a7672d6c3 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -43,6 +43,8 @@ #include "p_compiler.h" #include "p_defines.h" #include "p_format.h" +#include "p_refcnt.h" +#include "p_screen.h" #ifdef __cplusplus @@ -64,23 +66,20 @@ extern "C" { /* 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; }; @@ -275,6 +274,7 @@ struct pipe_sampler_state */ 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 */ @@ -282,7 +282,6 @@ struct pipe_surface 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 */ @@ -306,7 +305,6 @@ struct pipe_transfer 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 */ @@ -321,6 +319,8 @@ struct pipe_transfer */ struct pipe_texture { + struct pipe_reference reference; + enum pipe_texture_target target; /**< PIPE_TEXTURE_x */ enum pipe_format format; /**< PIPE_FORMAT_x */ @@ -339,10 +339,6 @@ struct pipe_texture unsigned tex_usage; /* PIPE_TEXTURE_USAGE_* */ - /* These are also refcounted: - */ - unsigned refcount; - struct pipe_screen *screen; /**< screen that this texture belongs to */ }; @@ -379,6 +375,35 @@ struct pipe_vertex_element }; +/* 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 |