* 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;
}
{
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;
}
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)
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)