diff options
author | Marek Olšák <[email protected]> | 2018-01-31 03:03:25 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2018-02-04 01:50:10 +0100 |
commit | af3685d14936844f79e6f372b4b258e29375f21b (patch) | |
tree | 84c3ab4b661bceaf4364be3e7c9501cb6b50537e /src/mesa/state_tracker | |
parent | 83e60ce927142752c57163fcb8b30eca2370d014 (diff) |
mesa: change ctx->Color.ColorMask into a 32-bit bitmask
4 bits per draw buffer, 8 draw buffers in total --> 32 bits.
This is easier to work with.
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_atom_blend.c | 27 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_clear.c | 39 |
2 files changed, 11 insertions, 55 deletions
diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c index 8bc5a5fd12c..f7327d6838c 100644 --- a/src/mesa/state_tracker/st_atom_blend.c +++ b/src/mesa/state_tracker/st_atom_blend.c @@ -40,6 +40,7 @@ #include "cso_cache/cso_context.h" #include "framebuffer.h" +#include "main/blend.h" #include "main/macros.h" /** @@ -113,14 +114,11 @@ translate_blend(GLenum blend) static GLboolean colormask_per_rt(const struct gl_context *ctx) { - /* a bit suboptimal have to compare lots of values */ - unsigned i; - for (i = 1; i < ctx->Const.MaxDrawBuffers; i++) { - if (memcmp(ctx->Color.ColorMask[0], ctx->Color.ColorMask[i], 4)) { - return GL_TRUE; - } - } - return GL_FALSE; + GLbitfield repl_mask0 = + _mesa_replicate_colormask(GET_COLORMASK(ctx->Color.ColorMask, 0), + ctx->Const.MaxDrawBuffers); + + return ctx->Color.ColorMask != repl_mask0; } /** @@ -206,17 +204,8 @@ st_update_blend( struct st_context *st ) /* no blending / logicop */ } - /* Colormask - maybe reverse these bits? */ - for (i = 0; i < num_state; i++) { - if (ctx->Color.ColorMask[i][0]) - blend->rt[i].colormask |= PIPE_MASK_R; - if (ctx->Color.ColorMask[i][1]) - blend->rt[i].colormask |= PIPE_MASK_G; - if (ctx->Color.ColorMask[i][2]) - blend->rt[i].colormask |= PIPE_MASK_B; - if (ctx->Color.ColorMask[i][3]) - blend->rt[i].colormask |= PIPE_MASK_A; - } + for (i = 0; i < num_state; i++) + blend->rt[i].colormask = GET_COLORMASK(ctx->Color.ColorMask, i); blend->dither = ctx->Color.DitherFlag; diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index f50f8442d55..68677182abf 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -226,14 +226,7 @@ clear_with_quad(struct gl_context *ctx, unsigned clear_buffers) if (!(clear_buffers & (PIPE_CLEAR_COLOR0 << i))) continue; - if (ctx->Color.ColorMask[i][0]) - blend.rt[i].colormask |= PIPE_MASK_R; - if (ctx->Color.ColorMask[i][1]) - blend.rt[i].colormask |= PIPE_MASK_G; - if (ctx->Color.ColorMask[i][2]) - blend.rt[i].colormask |= PIPE_MASK_B; - if (ctx->Color.ColorMask[i][3]) - blend.rt[i].colormask |= PIPE_MASK_A; + blend.rt[i].colormask = GET_COLORMASK(ctx->Color.ColorMask, i); } if (ctx->Color.DitherFlag) @@ -338,32 +331,6 @@ is_window_rectangle_enabled(struct gl_context *ctx) /** - * Return if all of the color channels are masked. - */ -static inline GLboolean -is_color_disabled(struct gl_context *ctx, int i) -{ - return !ctx->Color.ColorMask[i][0] && - !ctx->Color.ColorMask[i][1] && - !ctx->Color.ColorMask[i][2] && - !ctx->Color.ColorMask[i][3]; -} - - -/** - * Return if any of the color channels are masked. - */ -static inline GLboolean -is_color_masked(struct gl_context *ctx, int i) -{ - return !ctx->Color.ColorMask[i][0] || - !ctx->Color.ColorMask[i][1] || - !ctx->Color.ColorMask[i][2] || - !ctx->Color.ColorMask[i][3]; -} - - -/** * Return if all of the stencil bits are masked. */ static inline GLboolean @@ -423,12 +390,12 @@ st_Clear(struct gl_context *ctx, GLbitfield mask) if (!strb || !strb->surface) continue; - if (is_color_disabled(ctx, colormask_index)) + if (!GET_COLORMASK(ctx->Color.ColorMask, colormask_index)) continue; if (is_scissor_enabled(ctx, rb) || is_window_rectangle_enabled(ctx) || - is_color_masked(ctx, colormask_index)) + GET_COLORMASK(ctx->Color.ColorMask, colormask_index) != 0xf) quad_buffers |= PIPE_CLEAR_COLOR0 << i; else clear_buffers |= PIPE_CLEAR_COLOR0 << i; |