The format can also be luminance or intensity. Marek
On Sat, Mar 22, 2014 at 5:18 PM, Brian Paul <bri...@vmware.com> wrote: > On 03/21/2014 05:22 PM, Kenneth Graunke wrote: >> >> WebGL Aquarium in Chrome 24 actually hits this. >> >> v2: Move to core Mesa (wisely suggested by Ian); only consider >> components which actually exist. >> >> Signed-off-by: Kenneth Graunke <kenn...@whitecape.org> >> Cc: Ian Romanick <i...@freedesktop.org> >> Cc: Paul Berry <stereotype...@gmail.com> >> Cc: Anuj Phogat <anuj.pho...@gmail.com> >> --- >> src/mesa/main/clear.c | 19 ++++++++++++++++++- >> 1 file changed, 18 insertions(+), 1 deletion(-) >> >> Good call, Ian! I was a bit sleepy last night when I wrote that code :) >> >> Here's an updated patch which moves it to core Mesa. It also only checks >> the writemask of enabled components. >> >> I didn't see any existing code to handle this. There's similar code which >> disables depth clears if Depth.Mask == 0, but I didn't see any for color. >> >> diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c >> index 077c5fc..c9ca681 100644 >> --- a/src/mesa/main/clear.c >> +++ b/src/mesa/main/clear.c >> @@ -106,6 +106,23 @@ _mesa_ClearColorIuiEXT(GLuint r, GLuint g, GLuint b, >> GLuint a) >> } >> >> > > Could you add a comment to the function to explain it? > > What if the buffer is a GL_ALPHA only buffer (I think that's possible)? > Then _mesa_format_num_components() would be one and we should check the > colormask's A component, right? > > > > >> +static bool >> +color_buffer_writes_enabled(const struct gl_context *ctx, unsigned idx) >> +{ >> + struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[idx]; >> + GLuint c; >> + GLubyte colorMask = 0; >> + >> + if (rb) { >> + for (c = 0; c < _mesa_format_num_components(rb->Format); c++) { >> + colorMask |= ctx->Color.ColorMask[idx][c]; >> + } >> + } >> + >> + return colorMask != 0; >> +} >> + >> + >> /** >> * Clear buffers. >> * >> @@ -181,7 +198,7 @@ _mesa_Clear( GLbitfield mask ) >> for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) { >> GLint buf = ctx->DrawBuffer->_ColorDrawBufferIndexes[i]; >> >> - if (buf >= 0) { >> + if (buf >= 0 && color_buffer_writes_enabled(ctx, i)) { >> bufferMask |= 1 << buf; >> } >> } >> > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev