diff options
author | Marek Olšák <[email protected]> | 2018-01-31 04:37:00 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2018-02-09 15:52:22 +0100 |
commit | 76085f2048d426ae5fd35b26bae2141c6cfeba28 (patch) | |
tree | bc95eb06a201b71bc1ee86c0bd0ecfbcb88de7cd /src/mesa/state_tracker | |
parent | c446dd7927477e68e9a961acb1727ff53fb7ea4f (diff) |
st/mesa: generate blend state according to the number of enabled color buffers
Non-MRT cases always translate blend state for 1 color buffer only.
MRT cases only check and translate blend state for enabled color buffers.
This also avoids an assertion failure in translate_blend for:
dEQP-GLES31.functional.draw_buffers_indexed.overwrite_common.common_advanced_blend_eq_buffer_blend_eq
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_atom_blend.c | 21 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_framebuffer.c | 1 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_list.h | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_context.h | 1 |
4 files changed, 16 insertions, 9 deletions
diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c index 2a8da75f360..57400e2e791 100644 --- a/src/mesa/state_tracker/st_atom_blend.c +++ b/src/mesa/state_tracker/st_atom_blend.c @@ -112,23 +112,26 @@ translate_blend(GLenum blend) * Figure out if colormasks are different per rt. */ static GLboolean -colormask_per_rt(const struct gl_context *ctx) +colormask_per_rt(const struct gl_context *ctx, unsigned num_cb) { + GLbitfield full_mask = _mesa_replicate_colormask(0xf, num_cb); GLbitfield repl_mask0 = _mesa_replicate_colormask(GET_COLORMASK(ctx->Color.ColorMask, 0), - ctx->Const.MaxDrawBuffers); + num_cb); - return ctx->Color.ColorMask != repl_mask0; + return (ctx->Color.ColorMask & full_mask) != repl_mask0; } /** * Figure out if blend enables/state are different per rt. */ static GLboolean -blend_per_rt(const struct gl_context *ctx) +blend_per_rt(const struct gl_context *ctx, unsigned num_cb) { - if (ctx->Color.BlendEnabled && - (ctx->Color.BlendEnabled != ((1U << ctx->Const.MaxDrawBuffers) - 1))) { + GLbitfield cb_mask = u_bit_consecutive(0, num_cb); + GLbitfield blend_enabled = ctx->Color.BlendEnabled & cb_mask; + + if (blend_enabled && blend_enabled != cb_mask) { /* This can only happen if GL_EXT_draw_buffers2 is enabled */ return GL_TRUE; } @@ -144,13 +147,15 @@ st_update_blend( struct st_context *st ) { struct pipe_blend_state *blend = &st->state.blend; const struct gl_context *ctx = st->ctx; + unsigned num_cb = st->state.fb_num_cb; unsigned num_state = 1; unsigned i, j; memset(blend, 0, sizeof(*blend)); - if (blend_per_rt(ctx) || colormask_per_rt(ctx)) { - num_state = ctx->Const.MaxDrawBuffers; + if (num_cb > 1 && + (blend_per_rt(ctx, num_cb) || colormask_per_rt(ctx, num_cb))) { + num_state = num_cb; blend->independent_blend_enable = 1; } diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index acbe9809034..a29f5b35a85 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -216,4 +216,5 @@ st_update_framebuffer_state( struct st_context *st ) st->state.fb_height = framebuffer.height; st->state.fb_num_samples = util_framebuffer_get_num_samples(&framebuffer); st->state.fb_num_layers = util_framebuffer_get_num_layers(&framebuffer); + st->state.fb_num_cb = framebuffer.nr_cbufs; } diff --git a/src/mesa/state_tracker/st_atom_list.h b/src/mesa/state_tracker/st_atom_list.h index 8f50a72d00f..5391d4710c1 100644 --- a/src/mesa/state_tracker/st_atom_list.h +++ b/src/mesa/state_tracker/st_atom_list.h @@ -10,7 +10,6 @@ ST_STATE(ST_NEW_VS_STATE, st_update_vp) ST_STATE(ST_NEW_POLY_STIPPLE, st_update_polygon_stipple) ST_STATE(ST_NEW_WINDOW_RECTANGLES, st_update_window_rectangles) -ST_STATE(ST_NEW_BLEND, st_update_blend) ST_STATE(ST_NEW_BLEND_COLOR, st_update_blend_color) ST_STATE(ST_NEW_VS_SAMPLER_VIEWS, st_update_vertex_textures) @@ -33,6 +32,7 @@ ST_STATE(ST_NEW_GS_IMAGES, st_bind_gs_images) ST_STATE(ST_NEW_FS_IMAGES, st_bind_fs_images) ST_STATE(ST_NEW_FB_STATE, st_update_framebuffer_state) /* depends on update_*_texture and bind_*_images */ +ST_STATE(ST_NEW_BLEND, st_update_blend) /* depends on update_framebuffer_state */ ST_STATE(ST_NEW_RASTERIZER, st_update_rasterizer) /* depends on update_framebuffer_state */ ST_STATE(ST_NEW_SAMPLE_MASK, st_update_sample_mask) /* depends on update_framebuffer_state */ ST_STATE(ST_NEW_SAMPLE_SHADING, st_update_sample_shading) diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 660c993fe22..9f2480e5dac 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -164,6 +164,7 @@ struct st_context unsigned fb_height; unsigned fb_num_samples; unsigned fb_num_layers; + unsigned fb_num_cb; unsigned num_viewports; struct pipe_scissor_state scissor[PIPE_MAX_VIEWPORTS]; struct pipe_viewport_state viewport[PIPE_MAX_VIEWPORTS]; |