mesa: use DriverFlags.NewAlphaTest to communicate alphatest changes to st/mesa
authorMarek Olšák <marek.olsak@amd.com>
Fri, 9 Jun 2017 23:07:59 +0000 (01:07 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 21 Jun 2017 23:51:02 +0000 (01:51 +0200)
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.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/mesa/main/blend.c
src/mesa/main/enable.c
src/mesa/main/mtypes.h
src/mesa/state_tracker/st_context.c

index 8c763ed34e564dfbf13eda6332607b81077bfa3b..e042b5e8e6ac7d08ac96a4879609ce2a2a9b4db6 100644 (file)
@@ -735,7 +735,8 @@ _mesa_AlphaFunc( GLenum func, GLclampf ref )
    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);
index 5a37770d0099473b36225f656865df94a5a1a8e1..9dccf759ca1b26e71fff238dc96227e1f6934908 100644 (file)
@@ -293,7 +293,9 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             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:
index e78554bd0b04f8fe34869a190f2c2233bc72def3..4e870359dc8ee3818812307cfb206caa32e435bc 100644 (file)
@@ -4475,6 +4475,9 @@ struct gl_driver_flags
    /** gl_context::Scissor::ScissorArray */
    uint64_t NewScissorRect;
 
+   /** gl_context::Color::Alpha* */
+   uint64_t NewAlphaTest;
+
    /** gl_context::Depth */
    uint64_t NewDepth;
 
index dff40c676048cfc8e7bd21b42153d8e080249955..cdcc4ddaf48e38e6ab1dc0e169ff186ddb807c8c 100644 (file)
@@ -237,8 +237,7 @@ st_invalidate_state(struct gl_context * 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;
@@ -519,6 +518,7 @@ static void st_init_driver_flags(struct st_context *st)
    f->NewFramebufferSRGB = ST_NEW_FB_STATE;
    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;
 }