Re: [Mesa-dev] [PATCH] mesa: optimize color_buffer_writes_enabled()

2017-04-28 Thread Marek Olšák
Reviewed-by: Marek Olšák 

Marek

On Fri, Apr 28, 2017 at 5:09 AM, Brian Paul  wrote:
> 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.
> ---
>  src/mesa/main/clear.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> 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;
>  }
>
>
> --
> 1.9.1
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] mesa: optimize color_buffer_writes_enabled()

2017-04-27 Thread Brian Paul
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.
---
 src/mesa/main/clear.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

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;
 }
 
 
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev