diff options
author | Marek Olšák <[email protected]> | 2017-06-10 01:46:34 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-06-22 01:51:02 +0200 |
commit | 581d77315bdb2338e97133a05fa8c354352f5fd8 (patch) | |
tree | 4b92a067c861b25dad5174bf68b9a8185ca21f79 /src | |
parent | b677e96078889140ad1549cb7b94b0a33c10f7ba (diff) |
mesa: don't flag _NEW_COLOR for st/mesa if possible
Reviewed-by: Nicolai Hähnle <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/blend.c | 29 | ||||
-rw-r--r-- | src/mesa/main/blend.h | 20 | ||||
-rw-r--r-- | src/mesa/main/enable.c | 17 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 12 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_context.c | 7 |
5 files changed, 65 insertions, 20 deletions
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index e042b5e8e6a..881e9c8a79f 100644 --- a/src/mesa/main/blend.c +++ b/src/mesa/main/blend.c @@ -259,7 +259,8 @@ _mesa_BlendFuncSeparate( GLenum sfactorRGB, GLenum dfactorRGB, return; } - FLUSH_VERTICES(ctx, _NEW_COLOR); + FLUSH_VERTICES(ctx, ctx->DriverFlags.NewBlend ? 0 : _NEW_COLOR); + ctx->NewDriverState |= ctx->DriverFlags.NewBlend; for (buf = 0; buf < numBuffers; buf++) { ctx->Color.Blend[buf].SrcRGB = sfactorRGB; @@ -331,7 +332,8 @@ blend_func_separatei(GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB, return; } - FLUSH_VERTICES(ctx, _NEW_COLOR); + FLUSH_VERTICES(ctx, ctx->DriverFlags.NewBlend ? 0 : _NEW_COLOR); + ctx->NewDriverState |= ctx->DriverFlags.NewBlend; ctx->Color.Blend[buf].SrcRGB = sfactorRGB; ctx->Color.Blend[buf].DstRGB = dfactorRGB; @@ -477,7 +479,7 @@ _mesa_BlendEquation( GLenum mode ) return; } - FLUSH_VERTICES(ctx, _NEW_COLOR); + _mesa_flush_vertices_for_blend_state(ctx); for (buf = 0; buf < numBuffers; buf++) { ctx->Color.Blend[buf].EquationRGB = mode; @@ -519,7 +521,7 @@ _mesa_BlendEquationiARB(GLuint buf, GLenum mode) ctx->Color.Blend[buf].EquationA == mode) return; /* no change */ - FLUSH_VERTICES(ctx, _NEW_COLOR); + _mesa_flush_vertices_for_blend_state(ctx); ctx->Color.Blend[buf].EquationRGB = mode; ctx->Color.Blend[buf].EquationA = mode; ctx->Color._BlendEquationPerBuffer = GL_TRUE; @@ -585,7 +587,7 @@ _mesa_BlendEquationSeparate( GLenum modeRGB, GLenum modeA ) return; } - FLUSH_VERTICES(ctx, _NEW_COLOR); + _mesa_flush_vertices_for_blend_state(ctx); for (buf = 0; buf < numBuffers; buf++) { ctx->Color.Blend[buf].EquationRGB = modeRGB; @@ -607,7 +609,7 @@ blend_equation_separatei(struct gl_context *ctx, GLuint buf, GLenum modeRGB, ctx->Color.Blend[buf].EquationA == modeA) return; /* no change */ - FLUSH_VERTICES(ctx, _NEW_COLOR); + _mesa_flush_vertices_for_blend_state(ctx); ctx->Color.Blend[buf].EquationRGB = modeRGB; ctx->Color.Blend[buf].EquationA = modeA; ctx->Color._BlendEquationPerBuffer = GL_TRUE; @@ -691,7 +693,8 @@ _mesa_BlendColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) if (TEST_EQ_4V(tmp, ctx->Color.BlendColorUnclamped)) return; - FLUSH_VERTICES(ctx, _NEW_COLOR); + FLUSH_VERTICES(ctx, ctx->DriverFlags.NewBlendColor ? 0 : _NEW_COLOR); + ctx->NewDriverState |= ctx->DriverFlags.NewBlendColor; COPY_4FV( ctx->Color.BlendColorUnclamped, tmp ); ctx->Color.BlendColor[0] = CLAMP(tmp[0], 0.0F, 1.0F); @@ -796,7 +799,8 @@ _mesa_LogicOp( GLenum opcode ) if (ctx->Color.LogicOp == opcode) return; - FLUSH_VERTICES(ctx, _NEW_COLOR); + FLUSH_VERTICES(ctx, ctx->DriverFlags.NewLogicOp ? 0 : _NEW_COLOR); + ctx->NewDriverState |= ctx->DriverFlags.NewLogicOp; ctx->Color.LogicOp = opcode; if (ctx->Driver.LogicOpcode) @@ -812,7 +816,8 @@ _mesa_IndexMask( GLuint mask ) if (ctx->Color.IndexMask == mask) return; - FLUSH_VERTICES(ctx, _NEW_COLOR); + FLUSH_VERTICES(ctx, ctx->DriverFlags.NewColorMask ? 0 : _NEW_COLOR); + ctx->NewDriverState |= ctx->DriverFlags.NewColorMask; ctx->Color.IndexMask = mask; } @@ -856,7 +861,8 @@ _mesa_ColorMask( GLboolean red, GLboolean green, for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { if (!TEST_EQ_4V(tmp, ctx->Color.ColorMask[i])) { if (!flushed) { - FLUSH_VERTICES(ctx, _NEW_COLOR); + FLUSH_VERTICES(ctx, ctx->DriverFlags.NewColorMask ? 0 : _NEW_COLOR); + ctx->NewDriverState |= ctx->DriverFlags.NewColorMask; } flushed = GL_TRUE; COPY_4UBV(ctx->Color.ColorMask[i], tmp); @@ -898,7 +904,8 @@ _mesa_ColorMaski( GLuint buf, GLboolean red, GLboolean green, if (TEST_EQ_4V(tmp, ctx->Color.ColorMask[buf])) return; - FLUSH_VERTICES(ctx, _NEW_COLOR); + FLUSH_VERTICES(ctx, ctx->DriverFlags.NewColorMask ? 0 : _NEW_COLOR); + ctx->NewDriverState |= ctx->DriverFlags.NewColorMask; COPY_4UBV(ctx->Color.ColorMask[buf], tmp); } diff --git a/src/mesa/main/blend.h b/src/mesa/main/blend.h index 54b9ce6e1b1..675e50d3886 100644 --- a/src/mesa/main/blend.h +++ b/src/mesa/main/blend.h @@ -34,7 +34,9 @@ #include "glheader.h" +#include "context.h" #include "formats.h" +#include "extensions.h" struct gl_context; struct gl_framebuffer; @@ -136,4 +138,22 @@ _mesa_get_render_format(const struct gl_context *ctx, mesa_format format); extern void _mesa_init_color( struct gl_context * ctx ); + +static inline void +_mesa_flush_vertices_for_blend_state(struct gl_context *ctx) +{ + /* The advanced blend mode needs _NEW_COLOR to update the state constant, + * so we have to set it. This is inefficient. + * This should only be done for states that affect the state constant. + * It shouldn't be done for other blend states. + */ + if (_mesa_has_KHR_blend_equation_advanced(ctx) || + !ctx->DriverFlags.NewBlend) { + FLUSH_VERTICES(ctx, _NEW_COLOR); + } else { + FLUSH_VERTICES(ctx, 0); + } + ctx->NewDriverState |= ctx->DriverFlags.NewBlend; +} + #endif diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 9dccf759ca1..d33fc8b3dda 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -29,6 +29,7 @@ #include "glheader.h" +#include "blend.h" #include "clip.h" #include "context.h" #include "debug_output.h" @@ -311,7 +312,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) GLbitfield newEnabled = state * ((1 << ctx->Const.MaxDrawBuffers) - 1); if (newEnabled != ctx->Color.BlendEnabled) { - FLUSH_VERTICES(ctx, _NEW_COLOR); + _mesa_flush_vertices_for_blend_state(ctx); ctx->Color.BlendEnabled = newEnabled; } } @@ -378,7 +379,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) case GL_DITHER: if (ctx->Color.DitherFlag == state) return; - FLUSH_VERTICES(ctx, _NEW_COLOR); + FLUSH_VERTICES(ctx, ctx->DriverFlags.NewBlend ? 0 : _NEW_COLOR); + ctx->NewDriverState |= ctx->DriverFlags.NewBlend; ctx->Color.DitherFlag = state; break; case GL_FOG: @@ -440,7 +442,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) goto invalid_enum_error; if (ctx->Color.IndexLogicOpEnabled == state) return; - FLUSH_VERTICES(ctx, _NEW_COLOR); + FLUSH_VERTICES(ctx, ctx->DriverFlags.NewLogicOp ? 0 : _NEW_COLOR); + ctx->NewDriverState |= ctx->DriverFlags.NewLogicOp; ctx->Color.IndexLogicOpEnabled = state; break; case GL_CONSERVATIVE_RASTERIZATION_INTEL: @@ -458,7 +461,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) goto invalid_enum_error; if (ctx->Color.ColorLogicOpEnabled == state) return; - FLUSH_VERTICES(ctx, _NEW_COLOR); + FLUSH_VERTICES(ctx, ctx->DriverFlags.NewLogicOp ? 0 : _NEW_COLOR); + ctx->NewDriverState |= ctx->DriverFlags.NewLogicOp; ctx->Color.ColorLogicOpEnabled = state; break; case GL_MAP1_COLOR_4: @@ -1040,7 +1044,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) CHECK_EXTENSION(KHR_blend_equation_advanced_coherent, cap); if (ctx->Color.BlendCoherent == state) return; - FLUSH_VERTICES(ctx, _NEW_COLOR); + FLUSH_VERTICES(ctx, ctx->DriverFlags.NewBlend ? 0 : _NEW_COLOR); + ctx->NewDriverState |= ctx->DriverFlags.NewBlend; ctx->Color.BlendCoherent = state; break; @@ -1106,7 +1111,7 @@ _mesa_set_enablei(struct gl_context *ctx, GLenum cap, return; } if (((ctx->Color.BlendEnabled >> index) & 1) != state) { - FLUSH_VERTICES(ctx, _NEW_COLOR); + _mesa_flush_vertices_for_blend_state(ctx); if (state) ctx->Color.BlendEnabled |= (1 << index); else diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 4e870359dc8..640202cbe7c 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -4478,9 +4478,21 @@ struct gl_driver_flags /** gl_context::Color::Alpha* */ uint64_t NewAlphaTest; + /** gl_context::Color::Blend/Dither */ + uint64_t NewBlend; + + /** gl_context::Color::BlendColor */ + uint64_t NewBlendColor; + + /** gl_context::Color::Color/Index */ + uint64_t NewColorMask; + /** gl_context::Depth */ uint64_t NewDepth; + /** gl_context::Color::LogicOp/ColorLogicOp/IndexLogicOp */ + uint64_t NewLogicOp; + /** gl_context::Stencil */ uint64_t NewStencil; }; diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index cdcc4ddaf48..2bd91530312 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -236,9 +236,6 @@ st_invalidate_state(struct gl_context * ctx) st_user_clip_planes_enabled(ctx)) st->dirty |= ST_NEW_CLIP_STATE; - if (new_state & _NEW_COLOR) - st->dirty |= ST_NEW_BLEND; - if (new_state & _NEW_PIXEL) st->dirty |= ST_NEW_PIXEL_TRANSFER; @@ -519,7 +516,11 @@ static void st_init_driver_flags(struct st_context *st) f->NewScissorRect = ST_NEW_SCISSOR; f->NewScissorTest = ST_NEW_SCISSOR | ST_NEW_RASTERIZER; f->NewAlphaTest = ST_NEW_DSA; + f->NewBlend = ST_NEW_BLEND; + f->NewBlendColor = ST_NEW_BLEND; /* TODO: add an atom for blend color */ + f->NewColorMask = ST_NEW_BLEND; f->NewDepth = ST_NEW_DSA; + f->NewLogicOp = ST_NEW_BLEND; f->NewStencil = ST_NEW_DSA; } |