From e66e915087e859ff55210ab5460b363b51bf0580 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 1 Mar 2016 15:02:52 +1000 Subject: [PATCH] renderer: fix separate buffer clears this fixes clearbuffer-mixed-format --- src/vrend_renderer.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 6c711d2..5bf788b 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -2335,13 +2335,38 @@ void vrend_clear(struct vrend_context *ctx, if (buffers & PIPE_CLEAR_STENCIL) glClearStencil(stencil); - if (buffers & PIPE_CLEAR_COLOR) - bits |= GL_COLOR_BUFFER_BIT; + if (buffers & PIPE_CLEAR_COLOR) { + uint32_t mask = 0; + int i; + for (i = 0; i < ctx->sub->nr_cbufs; i++) { + if (ctx->sub->surf[i]) + mask |= (1 << i); + } + if (mask != (buffers >> 2)) { + mask = buffers >> 2; + while (mask) { + i = u_bit_scan(&mask); + if (util_format_is_pure_uint(ctx->sub->surf[i]->format)) + glClearBufferuiv(GL_COLOR, + i, (GLuint *)color); + else if (util_format_is_pure_sint(ctx->sub->surf[i]->format)) + glClearBufferiv(GL_COLOR, + i, (GLint *)color); + else + glClearBufferfv(GL_COLOR, + i, (GLfloat *)color); + } + } + else + bits |= GL_COLOR_BUFFER_BIT; + } if (buffers & PIPE_CLEAR_DEPTH) bits |= GL_DEPTH_BUFFER_BIT; if (buffers & PIPE_CLEAR_STENCIL) bits |= GL_STENCIL_BUFFER_BIT; - glClear(bits); + + if (bits) + glClear(bits); if (buffers & PIPE_CLEAR_DEPTH) if (!ctx->sub->dsa_state.depth.writemask)