From: Marek Olšák <marek.ol...@amd.com> Now AlphaFunc avoids the blend state update in st/mesa and avoids _mesa_update_state_locked.
The GL_ALPHA_TEST enable won't trigger blend state updates in st/mesa after st/mesa stops relying on _NEW_COLOR. --- src/mesa/main/blend.c | 3 ++- src/mesa/main/enable.c | 2 ++ src/mesa/main/mtypes.h | 3 +++ src/mesa/state_tracker/st_context.c | 4 ++-- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index 8c763ed..e042b5e 100644 --- a/src/mesa/main/blend.c +++ b/src/mesa/main/blend.c @@ -728,21 +728,22 @@ _mesa_AlphaFunc( GLenum func, GLclampf ref ) switch (func) { case GL_NEVER: case GL_LESS: case GL_EQUAL: case GL_LEQUAL: case GL_GREATER: case GL_NOTEQUAL: case GL_GEQUAL: case GL_ALWAYS: - FLUSH_VERTICES(ctx, _NEW_COLOR); + FLUSH_VERTICES(ctx, ctx->DriverFlags.NewAlphaTest ? 0 : _NEW_COLOR); + ctx->NewDriverState |= ctx->DriverFlags.NewAlphaTest; ctx->Color.AlphaFunc = func; ctx->Color.AlphaRefUnclamped = ref; ctx->Color.AlphaRef = CLAMP(ref, 0.0F, 1.0F); if (ctx->Driver.AlphaFunc) ctx->Driver.AlphaFunc(ctx, func, ctx->Color.AlphaRef); return; default: _mesa_error( ctx, GL_INVALID_ENUM, "glAlphaFunc(func)" ); diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 58c6d94..e1eb95f 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -286,21 +286,23 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) state ? "glEnable" : "glDisable", _mesa_enum_to_string(cap), ctx->NewState); switch (cap) { case GL_ALPHA_TEST: if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; if (ctx->Color.AlphaEnabled == state) return; + /* AlphaEnabled is used by the fixed-func fragment program */ FLUSH_VERTICES(ctx, _NEW_COLOR); + ctx->NewDriverState |= ctx->DriverFlags.NewAlphaTest; ctx->Color.AlphaEnabled = state; break; case GL_AUTO_NORMAL: if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Eval.AutoNormal == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.AutoNormal = state; break; diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 3e2b825..d3afc65 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -4396,20 +4396,23 @@ struct gl_driver_flags /** gl_context::Color::sRGBEnabled */ uint64_t NewFramebufferSRGB; /** gl_context::Scissor::EnableFlags */ uint64_t NewScissorTest; /** gl_context::Scissor::ScissorArray */ uint64_t NewScissorRect; + /** gl_context::Color::Alpha* */ + uint64_t NewAlphaTest; + /** gl_context::Depth */ uint64_t NewDepth; /** gl_context::Stencil */ uint64_t NewStencil; }; struct gl_uniform_buffer_binding { struct gl_buffer_object *BufferObject; diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index fd7295b..d3d06fe 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -230,22 +230,21 @@ st_invalidate_state(struct gl_context * ctx) _NEW_TRANSFORM)) st->dirty |= ST_NEW_RASTERIZER; } if (new_state & (_NEW_PROJECTION | _NEW_TRANSFORM) && st_user_clip_planes_enabled(ctx)) st->dirty |= ST_NEW_CLIP_STATE; if (new_state & _NEW_COLOR) - st->dirty |= ST_NEW_BLEND | - ST_NEW_DSA; + st->dirty |= ST_NEW_BLEND; if (new_state & _NEW_PIXEL) st->dirty |= ST_NEW_PIXEL_TRANSFER; if (new_state & _NEW_CURRENT_ATTRIB) st->dirty |= ST_NEW_VERTEX_ARRAYS; /* Update the vertex shader if ctx->Light._ClampVertexColor was changed. */ if (st->clamp_vert_color_in_shader && (new_state & _NEW_LIGHT)) st->dirty |= ST_NEW_VS_STATE; @@ -510,20 +509,21 @@ static void st_init_driver_flags(struct st_context *st) f->NewUniformBuffer = ST_NEW_UNIFORM_BUFFER; f->NewDefaultTessLevels = ST_NEW_TESS_STATE; f->NewTextureBuffer = ST_NEW_SAMPLER_VIEWS; f->NewAtomicBuffer = ST_NEW_ATOMIC_BUFFER; f->NewShaderStorageBuffer = ST_NEW_STORAGE_BUFFER; f->NewImageUnits = ST_NEW_IMAGE_UNITS; f->NewWindowRectangles = ST_NEW_WINDOW_RECTANGLES; f->NewFramebufferSRGB = ST_NEW_FRAMEBUFFER; f->NewScissorRect = ST_NEW_SCISSOR; f->NewScissorTest = ST_NEW_SCISSOR | ST_NEW_RASTERIZER; + f->NewAlphaTest = ST_NEW_DSA; f->NewDepth = ST_NEW_DSA; f->NewStencil = ST_NEW_DSA; } struct st_context *st_create_context(gl_api api, struct pipe_context *pipe, const struct gl_config *visual, struct st_context *share, const struct st_config_options *options) { struct gl_context *ctx; -- 2.7.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev