diff options
author | Rob Clark <robclark@freedesktop.org> | 2016-06-11 09:21:10 -0400 |
---|---|---|
committer | Rob Clark <robdclark@gmail.com> | 2016-07-06 10:17:30 -0400 |
commit | def044376a6d15d992fd8e0d9a63c40a9f509c78 (patch) | |
tree | d7ae1339995c8e288e60f42213a6337895fcb5b7 | |
parent | 660cd3de4acf5ae8ccef2bc5d367de98d9ac0e27 (diff) |
gallium/util: make util_copy_framebuffer_state(src=NULL) work
Be more consistent with the other u_inlines util_copy_xyz_state()
helpers and support NULL src.
Signed-off-by: Rob Clark <robclark@freedesktop.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
-rw-r--r-- | src/gallium/auxiliary/util/u_framebuffer.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/src/gallium/auxiliary/util/u_framebuffer.c b/src/gallium/auxiliary/util/u_framebuffer.c index f2108a15fa1..c2948a5cfb3 100644 --- a/src/gallium/auxiliary/util/u_framebuffer.c +++ b/src/gallium/auxiliary/util/u_framebuffer.c @@ -86,22 +86,37 @@ util_copy_framebuffer_state(struct pipe_framebuffer_state *dst, { unsigned i; - dst->width = src->width; - dst->height = src->height; + if (src) { + dst->width = src->width; + dst->height = src->height; - dst->samples = src->samples; - dst->layers = src->layers; + dst->samples = src->samples; + dst->layers = src->layers; - for (i = 0; i < src->nr_cbufs; i++) - pipe_surface_reference(&dst->cbufs[i], src->cbufs[i]); + for (i = 0; i < src->nr_cbufs; i++) + pipe_surface_reference(&dst->cbufs[i], src->cbufs[i]); - /* Set remaining dest cbuf pointers to NULL */ - for ( ; i < ARRAY_SIZE(dst->cbufs); i++) - pipe_surface_reference(&dst->cbufs[i], NULL); + /* Set remaining dest cbuf pointers to NULL */ + for ( ; i < ARRAY_SIZE(dst->cbufs); i++) + pipe_surface_reference(&dst->cbufs[i], NULL); - dst->nr_cbufs = src->nr_cbufs; + dst->nr_cbufs = src->nr_cbufs; - pipe_surface_reference(&dst->zsbuf, src->zsbuf); + pipe_surface_reference(&dst->zsbuf, src->zsbuf); + } else { + dst->width = 0; + dst->height = 0; + + dst->samples = 0; + dst->layers = 0; + + for (i = 0 ; i < ARRAY_SIZE(dst->cbufs); i++) + pipe_surface_reference(&dst->cbufs[i], NULL); + + dst->nr_cbufs = 0; + + pipe_surface_reference(&dst->zsbuf, NULL); + } } |