diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-03-29 15:40:21 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-03-29 15:43:56 +0100 |
commit | 7bae1c3d85344b7229e0124d1f54376392682430 (patch) | |
tree | 000bf997644518fb1c8aa92a8e42d87f45a401d6 /src | |
parent | 252eaa765e69a70036ec33a7e1e0ffeac1aab2ff (diff) |
intel: Protect intel_clear_with_blit from failed buffer allocations
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=34419
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_blit.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c index e1ab7f16371..d6a648c49ad 100644 --- a/src/mesa/drivers/dri/intel/intel_blit.c +++ b/src/mesa/drivers/dri/intel/intel_blit.c @@ -239,12 +239,12 @@ intelClearWithBlit(struct gl_context *ctx, GLbitfield mask) if (cw == 0 || ch == 0) return 0; - GLuint buf; all = (cw == fb->Width && ch == fb->Height); /* Loop over all renderbuffers */ - for (buf = 0; buf < BUFFER_COUNT && mask; buf++) { - const GLbitfield bufBit = 1 << buf; + mask &= (1 << BUFFER_COUNT) - 1; + while (mask) { + GLuint buf = _mesa_ffs(mask) - 1; struct intel_renderbuffer *irb; drm_intel_bo *write_buffer; int x1, y1, x2, y2; @@ -253,11 +253,15 @@ intelClearWithBlit(struct gl_context *ctx, GLbitfield mask) int pitch, cpp; drm_intel_bo *aper_array[2]; - if (!(mask & bufBit)) - continue; + mask &= ~(1 << buf); - /* OK, clear this renderbuffer */ irb = intel_get_renderbuffer(fb, buf); + if (irb == NULL || irb->region == NULL || irb->region->buffer == NULL) { + fail_mask |= 1 << buf; + continue; + } + + /* OK, clear this renderbuffer */ write_buffer = intel_region_buffer(intel, irb->region, all ? INTEL_WRITE_FULL : INTEL_WRITE_PART); @@ -333,8 +337,7 @@ intelClearWithBlit(struct gl_context *ctx, GLbitfield mask) clear[3], clear[3]); break; default: - fail_mask |= bufBit; - mask &= ~bufBit; + fail_mask |= 1 << buf; continue; } } @@ -367,8 +370,6 @@ intelClearWithBlit(struct gl_context *ctx, GLbitfield mask) if (buf == BUFFER_DEPTH || buf == BUFFER_STENCIL) mask &= ~(BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL); - else - mask &= ~bufBit; /* turn off bit, for faster loop exit */ } return fail_mask; |