[Mesa-dev] [PATCH 2/3] mesa: Skip clearing color buffers when color writes are disabled.
Kenneth Graunke
kenneth at whitecape.org
Mon Mar 24 14:52:04 PDT 2014
On 03/24/2014 08:07 AM, Brian Paul wrote:
> On 03/24/2014 02:52 AM, 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.
>>
>> v3: Use _mesa_format_has_color_component to determine whether components
>> actually exist, fixing alpha format handling.
>>
>> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
>> ---
>> src/mesa/main/clear.c | 20 +++++++++++++++++++-
>> 1 file changed, 19 insertions(+), 1 deletion(-)
>>
>> Thanks for the review! You're absolutely right about ALPHA formats.
>>
>> I think this version should actually work :)
>>
>> diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
>> index 077c5fc..e2566c0 100644
>> --- a/src/mesa/main/clear.c
>> +++ b/src/mesa/main/clear.c
>> @@ -106,6 +106,24 @@ _mesa_ClearColorIuiEXT(GLuint r, GLuint g, GLuint
>> b, GLuint a)
>> }
>>
>>
>> +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 < 4; c++) {
>> + if (_mesa_format_has_color_component(rb->Format, c))
>> + colorMask |= ctx->Color.ColorMask[idx][c];
>> + }
>> + }
>> +
>> + return colorMask != 0;
>> +}
>> +
>> +
>> /**
>> * Clear buffers.
>> *
>> @@ -181,7 +199,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;
>> }
>> }
>>
>
> I still think a comment on the new function would be nice. Looks good
> though.
>
> Reviewed-by: Brian Paul <brianp at vmware.com>
Oops, sorry...I missed your request for a comment. Added in v4 (with no
actual code changes), and pushed. Thanks!
--Ken
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140324/8a574006/attachment.sig>
More information about the mesa-dev
mailing list