diff options
author | Marek Olšák <maraeo@gmail.com> | 2010-12-26 18:43:39 +0100 |
---|---|---|
committer | Marek Olšák <maraeo@gmail.com> | 2011-01-06 16:16:29 +0100 |
commit | 3c9aa3a7b12cfe178c14fea93cfb64a32db0b8ad (patch) | |
tree | 5bc57604dfc2f71d6ce696689750a0bec2147bf8 /src/gallium/auxiliary/util | |
parent | 58c5e782e351621bde2693fa945d0c90d140b855 (diff) |
gallium: drivers should reference vertex buffers
So that a state tracker can unreference them after set_vertex_buffers.
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r-- | src/gallium/auxiliary/util/u_blitter.h | 18 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_inlines.h | 18 |
2 files changed, 23 insertions, 13 deletions
diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h index c5660cf2d0..922a8580ac 100644 --- a/src/gallium/auxiliary/util/u_blitter.h +++ b/src/gallium/auxiliary/util/u_blitter.h @@ -318,21 +318,13 @@ util_blitter_save_vertex_buffers(struct blitter_context *blitter, int num_vertex_buffers, struct pipe_vertex_buffer *vertex_buffers) { - unsigned i; assert(num_vertex_buffers <= Elements(blitter->saved_vertex_buffers)); - blitter->saved_num_vertex_buffers = num_vertex_buffers; - - for (i = 0; i < num_vertex_buffers; i++) { - if (vertex_buffers[i].buffer) { - pipe_resource_reference(&blitter->saved_vertex_buffers[i].buffer, - vertex_buffers[i].buffer); - } - } - - memcpy(blitter->saved_vertex_buffers, - vertex_buffers, - num_vertex_buffers * sizeof(struct pipe_vertex_buffer)); + blitter->saved_num_vertex_buffers = 0; + util_copy_vertex_buffers(blitter->saved_vertex_buffers, + (unsigned*)&blitter->saved_num_vertex_buffers, + vertex_buffers, + num_vertex_buffers); } #ifdef __cplusplus diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h index 9184b6aa4d..8aaf7a7416 100644 --- a/src/gallium/auxiliary/util/u_inlines.h +++ b/src/gallium/auxiliary/util/u_inlines.h @@ -400,6 +400,24 @@ static INLINE boolean util_get_offset( } } +static INLINE void util_copy_vertex_buffers(struct pipe_vertex_buffer *dst, + unsigned *dst_count, + const struct pipe_vertex_buffer *src, + unsigned src_count) +{ + unsigned i; + + for (i = 0; i < src_count; i++) { + pipe_resource_reference(&dst[i].buffer, src[i].buffer); + } + for (; i < *dst_count; i++) { + pipe_resource_reference(&dst[i].buffer, NULL); + } + + *dst_count = src_count; + memcpy(dst, src, src_count * sizeof(struct pipe_vertex_buffer)); +} + #ifdef __cplusplus } #endif |