gallium/util: easy fixes for NULL colorbuffers
authorMarek Olšák <marek.olsak@amd.com>
Wed, 8 Jan 2014 00:07:20 +0000 (01:07 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 13 Jan 2014 14:48:08 +0000 (15:48 +0100)
Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/auxiliary/util/u_clear.h
src/gallium/auxiliary/util/u_framebuffer.c

index 75047c16b93f30cb2ba993688830aa2b579d6862..bd8efdb4ad2cd4b04c342f1609f75312fd802ccf 100644 (file)
@@ -47,7 +47,10 @@ util_clear(struct pipe_context *pipe,
    for (i = 0; i < framebuffer->nr_cbufs; i++) {
       if (buffers & (PIPE_CLEAR_COLOR0 << i)) {
          struct pipe_surface *ps = framebuffer->cbufs[i];
-         pipe->clear_render_target(pipe, ps, color, 0, 0, ps->width, ps->height);
+
+         if (ps) {
+            pipe->clear_render_target(pipe, ps, color, 0, 0, ps->width, ps->height);
+         }
       }
    }
 
index 377b802b62a74d5d0af184d79e294cdd5b6c839b..2e0ef749e820603fc5635707076ddc4b9afe9760 100644 (file)
@@ -127,6 +127,9 @@ util_framebuffer_min_size(const struct pipe_framebuffer_state *fb,
    unsigned i;
 
    for (i = 0; i < fb->nr_cbufs; i++) {
+      if (!fb->cbufs[i])
+         continue;
+
       w = MIN2(w, fb->cbufs[i]->width);
       h = MIN2(h, fb->cbufs[i]->height);
    }