From: Brian Paul Date: Thu, 27 Apr 2017 14:52:30 +0000 (-0600) Subject: mesa: optimize color_buffer_writes_enabled() X-Git-Tag: upstream/18.1.0~10407 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6b60153f042c1191ae8fde3fbfc7d861650287aa;p=platform%2Fupstream%2Fmesa.git mesa: optimize color_buffer_writes_enabled() Return as soon as we find an existing color channel that's enabled for writing. Typically, this allows us to return true on the first loop iteration intead of doing four iterations. No piglit regressions. Reviewed-by: Marek Olšák --- diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c index a1bb36e..884cf98 100644 --- a/src/mesa/main/clear.c +++ b/src/mesa/main/clear.c @@ -115,16 +115,17 @@ 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]; + if (ctx->Color.ColorMask[idx][c] && + _mesa_format_has_color_component(rb->Format, c)) { + return true; + } } } - return colorMask != 0; + return false; }