diff options
author | Marek Olšák <[email protected]> | 2010-06-29 01:52:09 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2010-06-29 01:54:26 +0200 |
commit | 0b50fcbd556ead8d35c2b543f13de433996a5822 (patch) | |
tree | 152a0c1b786a413833413bd43e18f28aa33a26a9 /src/gallium/auxiliary/util/u_blitter.h | |
parent | 7e1ce791c7ac6bf01c3136393bc3300a8a0c6145 (diff) |
util: reference surfaces and sampler views in blitter when saving them
Ooops. This should possibly fix some bugs...
Diffstat (limited to 'src/gallium/auxiliary/util/u_blitter.h')
-rw-r--r-- | src/gallium/auxiliary/util/u_blitter.h | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h index 22849280ab9..f421ad5b938 100644 --- a/src/gallium/auxiliary/util/u_blitter.h +++ b/src/gallium/auxiliary/util/u_blitter.h @@ -208,11 +208,45 @@ void util_blitter_save_vertex_shader(struct blitter_context *blitter, blitter->saved_vs = vs; } +/* XXX This should probably be moved elsewhere. */ +static INLINE +void util_assign_framebuffer_state(struct pipe_framebuffer_state *dst, + const struct pipe_framebuffer_state *src) +{ + unsigned i; + + if (src) { + /* Reference all surfaces. */ + for (i = 0; i < src->nr_cbufs; i++) { + pipe_surface_reference(&dst->cbufs[i], src->cbufs[i]); + } + for (; i < dst->nr_cbufs; i++) { + pipe_surface_reference(&dst->cbufs[i], NULL); + } + + pipe_surface_reference(&dst->zsbuf, src->zsbuf); + + dst->nr_cbufs = src->nr_cbufs; + dst->width = src->width; + dst->height = src->height; + } else { + /* Set all surfaces to NULL. */ + for (i = 0; i < dst->nr_cbufs; i++) { + pipe_surface_reference(&dst->cbufs[i], NULL); + } + + pipe_surface_reference(&dst->zsbuf, NULL); + + dst->nr_cbufs = 0; + } +} + static INLINE void util_blitter_save_framebuffer(struct blitter_context *blitter, - struct pipe_framebuffer_state *state) + const struct pipe_framebuffer_state *state) { - blitter->saved_fb_state = *state; + blitter->saved_fb_state.nr_cbufs = 0; /* It's ~0 now, meaning it's unsaved. */ + util_assign_framebuffer_state(&blitter->saved_fb_state, state); } static INLINE @@ -247,12 +281,13 @@ util_blitter_save_fragment_sampler_views(struct blitter_context *blitter, int num_views, struct pipe_sampler_view **views) { + unsigned i; assert(num_views <= Elements(blitter->saved_sampler_views)); blitter->saved_num_sampler_views = num_views; - memcpy(blitter->saved_sampler_views, - views, - num_views * sizeof(struct pipe_sampler_view *)); + for (i = 0; i < num_views; i++) + pipe_sampler_view_reference(&blitter->saved_sampler_views[i], + views[i]); } static INLINE void |