mesa: don't flag _NEW_MULTISAMPLE for st/mesa
authorMarek Olšák <marek.olsak@amd.com>
Sat, 10 Jun 2017 00:14:15 +0000 (02:14 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 21 Jun 2017 23:51:02 +0000 (01:51 +0200)
There are several new driver flags here so that it maps nicely to gallium.

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/enable.c
src/mesa/main/mtypes.h
src/mesa/main/multisample.c
src/mesa/state_tracker/st_context.c

index d33fc8b3dda8d192a9054887ccd1a9e2e2a7b6c8..9ff3c5af530fc7687e7c76f14105c53778f433be 100644 (file)
@@ -239,7 +239,18 @@ _mesa_set_multisample(struct gl_context *ctx, GLboolean state)
 {
    if (ctx->Multisample.Enabled == state)
       return;
-   FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+
+   /* GL compatibility needs Multisample.Enable to determine program state
+    * constants.
+    */
+   if (ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGLES ||
+       !ctx->DriverFlags.NewMultisampleEnable) {
+      FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+   } else {
+      FLUSH_VERTICES(ctx, 0);
+   }
+
+   ctx->NewDriverState |= ctx->DriverFlags.NewMultisampleEnable;
    ctx->Multisample.Enabled = state;
 
    if (ctx->Driver.Enable) {
@@ -808,7 +819,9 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
       case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
          if (ctx->Multisample.SampleAlphaToCoverage == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+         FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleAlphaToXEnable ? 0 :
+                                                         _NEW_MULTISAMPLE);
+         ctx->NewDriverState |= ctx->DriverFlags.NewSampleAlphaToXEnable;
          ctx->Multisample.SampleAlphaToCoverage = state;
          break;
       case GL_SAMPLE_ALPHA_TO_ONE_ARB:
@@ -816,13 +829,17 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             goto invalid_enum_error;
          if (ctx->Multisample.SampleAlphaToOne == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+         FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleAlphaToXEnable ? 0 :
+                                                         _NEW_MULTISAMPLE);
+         ctx->NewDriverState |= ctx->DriverFlags.NewSampleAlphaToXEnable;
          ctx->Multisample.SampleAlphaToOne = state;
          break;
       case GL_SAMPLE_COVERAGE_ARB:
          if (ctx->Multisample.SampleCoverage == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+         FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleMask ? 0 :
+                                                         _NEW_MULTISAMPLE);
+         ctx->NewDriverState |= ctx->DriverFlags.NewSampleMask;
          ctx->Multisample.SampleCoverage = state;
          break;
       case GL_SAMPLE_COVERAGE_INVERT_ARB:
@@ -830,7 +847,9 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             goto invalid_enum_error;
          if (ctx->Multisample.SampleCoverageInvert == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+         FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleMask ? 0 :
+                                                         _NEW_MULTISAMPLE);
+         ctx->NewDriverState |= ctx->DriverFlags.NewSampleMask;
          ctx->Multisample.SampleCoverageInvert = state;
          break;
 
@@ -841,7 +860,9 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
          CHECK_EXTENSION(ARB_sample_shading, cap);
          if (ctx->Multisample.SampleShading == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+         FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleShading ? 0 :
+                                                         _NEW_MULTISAMPLE);
+         ctx->NewDriverState |= ctx->DriverFlags.NewSampleShading;
          ctx->Multisample.SampleShading = state;
          break;
 
@@ -1036,7 +1057,9 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
          CHECK_EXTENSION(ARB_texture_multisample, cap);
          if (ctx->Multisample.SampleMask == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+         FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleMask ? 0 :
+                                                         _NEW_MULTISAMPLE);
+         ctx->NewDriverState |= ctx->DriverFlags.NewSampleMask;
          ctx->Multisample.SampleMask = state;
          break;
 
index 640202cbe7cb40cd9935d5d7a3490037d423addb..c4e67353e9f4431450d954395fdbe756b526c6a4 100644 (file)
@@ -4493,6 +4493,18 @@ struct gl_driver_flags
    /** gl_context::Color::LogicOp/ColorLogicOp/IndexLogicOp */
    uint64_t NewLogicOp;
 
+   /** gl_context::Multisample::Enabled */
+   uint64_t NewMultisampleEnable;
+
+   /** gl_context::Multisample::SampleAlphaTo* */
+   uint64_t NewSampleAlphaToXEnable;
+
+   /** gl_context::Multisample::SampleCoverage/SampleMaskValue */
+   uint64_t NewSampleMask;
+
+   /** gl_context::Multisample::(Min)SampleShading */
+   uint64_t NewSampleShading;
+
    /** gl_context::Stencil */
    uint64_t NewStencil;
 };
index 07786130d51bba42380d322f863d429f3033488d..38d91f7204e2d27527006c5b45bcd9a5a5626c2a 100644 (file)
@@ -47,7 +47,8 @@ _mesa_SampleCoverage(GLclampf value, GLboolean invert)
        ctx->Multisample.SampleCoverageValue == value)
       return;
 
-   FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+   FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleMask ? 0 : _NEW_MULTISAMPLE);
+   ctx->NewDriverState |= ctx->DriverFlags.NewSampleMask;
    ctx->Multisample.SampleCoverageValue = value;
    ctx->Multisample.SampleCoverageInvert = invert;
 }
@@ -122,7 +123,8 @@ _mesa_SampleMaski(GLuint index, GLbitfield mask)
    if (ctx->Multisample.SampleMaskValue == mask)
       return;
 
-   FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+   FLUSH_VERTICES(ctx, ctx->DriverFlags.NewSampleMask ? 0 : _NEW_MULTISAMPLE);
+   ctx->NewDriverState |= ctx->DriverFlags.NewSampleMask;
    ctx->Multisample.SampleMaskValue = mask;
 }
 
@@ -145,7 +147,9 @@ _mesa_MinSampleShading(GLclampf value)
    if (ctx->Multisample.MinSampleShadingValue == value)
       return;
 
-   FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+   FLUSH_VERTICES(ctx,
+                  ctx->DriverFlags.NewSampleShading ? 0 : _NEW_MULTISAMPLE);
+   ctx->NewDriverState |= ctx->DriverFlags.NewSampleShading;
    ctx->Multisample.MinSampleShadingValue = value;
 }
 
index 2bd91530312cedd8d159a70e8116d2d063f14f4f..23e3768373fb33dfb3036a02e38b48d51698a93c 100644 (file)
@@ -213,23 +213,12 @@ st_invalidate_state(struct gl_context * ctx)
       }
    }
 
-   if (new_state & _NEW_MULTISAMPLE) {
-      st->dirty |= ST_NEW_BLEND |
-                   ST_NEW_SAMPLE_MASK |
-                   ST_NEW_SAMPLE_SHADING |
-                   ST_NEW_RASTERIZER |
-                   ST_NEW_FS_STATE;
-   } else {
-      /* These set a subset of flags set by _NEW_MULTISAMPLE, so we only
-       * have to check them when _NEW_MULTISAMPLE isn't set.
-       */
-      if (new_state & (_NEW_LIGHT |
-                       _NEW_LINE |
-                       _NEW_POINT |
-                       _NEW_POLYGON |
-                       _NEW_TRANSFORM))
-         st->dirty |= ST_NEW_RASTERIZER;
-   }
+   if (new_state & (_NEW_LIGHT |
+                    _NEW_LINE |
+                    _NEW_POINT |
+                    _NEW_POLYGON |
+                    _NEW_TRANSFORM))
+      st->dirty |= ST_NEW_RASTERIZER;
 
    if (new_state & (_NEW_PROJECTION |
                     _NEW_TRANSFORM) &&
@@ -522,6 +511,19 @@ static void st_init_driver_flags(struct st_context *st)
    f->NewDepth = ST_NEW_DSA;
    f->NewLogicOp = ST_NEW_BLEND;
    f->NewStencil = ST_NEW_DSA;
+   f->NewMultisampleEnable = ST_NEW_BLEND | ST_NEW_RASTERIZER |
+                             ST_NEW_SAMPLE_MASK | ST_NEW_SAMPLE_SHADING;
+   f->NewSampleAlphaToXEnable = ST_NEW_BLEND;
+   f->NewSampleMask = ST_NEW_SAMPLE_MASK;
+   f->NewSampleShading = ST_NEW_SAMPLE_SHADING;
+
+   /* This depends on what the gallium driver wants. */
+   if (st->force_persample_in_shader) {
+      f->NewMultisampleEnable |= ST_NEW_FS_STATE;
+      f->NewSampleShading |= ST_NEW_FS_STATE;
+   } else {
+      f->NewSampleShading |= ST_NEW_RASTERIZER;
+   }
 }
 
 struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,