#include "pipe/p_defines.h"
#include "cso_cache/cso_context.h"
+#include "framebuffer.h"
#include "main/macros.h"
/**
blend_per_rt(const struct gl_context *ctx)
{
if (ctx->Color.BlendEnabled &&
- (ctx->Color.BlendEnabled != ((1 << ctx->Const.MaxDrawBuffers) - 1))) {
+ (ctx->Color.BlendEnabled != ((1U << ctx->Const.MaxDrawBuffers) - 1))) {
/* This can only happen if GL_EXT_draw_buffers2 is enabled */
return GL_TRUE;
}
return GL_FALSE;
}
-static void
-update_blend( struct st_context *st )
+void
+st_update_blend( struct st_context *st )
{
struct pipe_blend_state *blend = &st->state.blend;
const struct gl_context *ctx = st->ctx;
blend->logicop_enable = 1;
blend->logicop_func = translate_logicop(ctx->Color.LogicOp);
}
- else if (ctx->Color.BlendEnabled) {
+ else if (ctx->Color.BlendEnabled && !ctx->Color._AdvancedBlendMode) {
/* blending enabled */
for (i = 0, j = 0; i < num_state; i++) {
blend->rt[i].colormask |= PIPE_MASK_A;
}
- if (ctx->Color.DitherFlag)
- blend->dither = 1;
+ blend->dither = ctx->Color.DitherFlag;
- if (ctx->Multisample.Enabled) {
- /* unlike in gallium/d3d10 these operations are only performed
- if msaa is enabled */
- if (ctx->Multisample.SampleAlphaToCoverage)
- blend->alpha_to_coverage = 1;
- if (ctx->Multisample.SampleAlphaToOne)
- blend->alpha_to_one = 1;
+ if (_mesa_is_multisample_enabled(ctx) &&
+ !(ctx->DrawBuffer->_IntegerBuffers & 0x1)) {
+ /* Unlike in gallium/d3d10 these operations are only performed
+ * if both msaa is enabled and we have a multisample buffer.
+ */
+ blend->alpha_to_coverage = ctx->Multisample.SampleAlphaToCoverage;
+ blend->alpha_to_one = ctx->Multisample.SampleAlphaToOne;
}
cso_set_blend(st->cso_context, blend);
-
- {
- struct pipe_blend_color bc;
- COPY_4FV(bc.color, ctx->Color.BlendColorUnclamped);
- cso_set_blend_color(st->cso_context, &bc);
- }
}
+void
+st_update_blend_color(struct st_context *st)
+{
+ struct pipe_blend_color bc;
-const struct st_tracked_state st_update_blend = {
- "st_update_blend", /* name */
- { /* dirty */
- (_NEW_COLOR | _NEW_MULTISAMPLE), /* XXX _NEW_BLEND someday? */ /* mesa */
- 0, /* st */
- },
- update_blend, /* update */
-};
+ COPY_4FV(bc.color, st->ctx->Color.BlendColorUnclamped);
+ cso_set_blend_color(st->cso_context, &bc);
+}