st/mesa: Move _NEW_FRAG_CLAMP to NewFragClamp driver flag.
authorMathias Fröhlich <mathias.froehlich@web.de>
Mon, 12 Aug 2019 10:16:16 +0000 (12:16 +0200)
committerMarge Bot <eric+marge@anholt.net>
Thu, 30 Apr 2020 22:01:55 +0000 (22:01 +0000)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4314>

src/mesa/main/blend.c
src/mesa/main/mtypes.h
src/mesa/state_tracker/st_atom_rasterizer.c
src/mesa/state_tracker/st_atom_shader.c
src/mesa/state_tracker/st_context.c

index 0dc2fa1..0bf27b1 100644 (file)
@@ -1121,6 +1121,8 @@ void
 _mesa_update_clamp_fragment_color(struct gl_context *ctx,
                                   const struct gl_framebuffer *drawFb)
 {
+   GLboolean clamp;
+
    /* Don't clamp if:
     * - there is no colorbuffer
     * - all colorbuffers are unsigned normalized, so clamping has no effect
@@ -1128,10 +1130,15 @@ _mesa_update_clamp_fragment_color(struct gl_context *ctx,
     */
    if (!drawFb || !drawFb->_HasSNormOrFloatColorBuffer ||
        drawFb->_IntegerBuffers)
-      ctx->Color._ClampFragmentColor = GL_FALSE;
+      clamp = GL_FALSE;
    else
-      ctx->Color._ClampFragmentColor =
-         _mesa_get_clamp_fragment_color(ctx, drawFb);
+      clamp = _mesa_get_clamp_fragment_color(ctx, drawFb);
+
+   if (ctx->Color._ClampFragmentColor == clamp)
+      return;
+
+   ctx->NewDriverState |= ctx->DriverFlags.NewFragClamp;
+   ctx->Color._ClampFragmentColor = clamp;
 }
 
 /**
index 5bb6ac5..8bfeeaf 100644 (file)
@@ -4707,6 +4707,9 @@ struct gl_driver_flags
    /** gl_context::Transform::ClipPlanesEnabled */
    uint64_t NewClipPlaneEnable;
 
+   /** gl_context::Color::ClampFragmentColor */
+   uint64_t NewFragClamp;
+
    /** gl_context::Transform::DepthClamp */
    uint64_t NewDepthClamp;
 
index bcbb3cd..4af7bdc 100644 (file)
@@ -239,7 +239,7 @@ st_update_rasterizer(struct st_context *st)
    /* _NEW_SCISSOR */
    raster->scissor = !!ctx->Scissor.EnableFlags;
 
-   /* _NEW_FRAG_CLAMP */
+   /* gl_driver_flags::NewFragClamp */
    raster->clamp_fragment_color = !st->clamp_frag_color_in_shader &&
                                   ctx->Color._ClampFragmentColor;
 
index 893dc59..b349c2a 100644 (file)
@@ -133,7 +133,7 @@ st_update_fp( struct st_context *st )
       key.lower_two_sided_color = st->lower_two_sided_color &&
          _mesa_vertex_program_two_side_enabled(st->ctx);
 
-      /* _NEW_FRAG_CLAMP */
+      /* gl_driver_flags::NewFragClamp */
       key.clamp_color = st->clamp_frag_color_in_shader &&
                         st->ctx->Color._ClampFragmentColor;
 
index 4f7fd24..2fc4ffe 100644 (file)
@@ -219,13 +219,6 @@ st_invalidate_state(struct gl_context *ctx)
 
       if (new_state & _NEW_FOG)
          st->dirty |= ST_NEW_FS_STATE;
-
-      if (new_state & _NEW_FRAG_CLAMP) {
-         if (st->clamp_frag_color_in_shader)
-            st->dirty |= ST_NEW_FS_STATE;
-         else
-            st->dirty |= ST_NEW_RASTERIZER;
-      }
    }
 
    if (new_state & (_NEW_LIGHT |
@@ -542,6 +535,12 @@ st_init_driver_flags(struct st_context *st)
    f->NewClipControl = ST_NEW_VIEWPORT | ST_NEW_RASTERIZER;
    f->NewClipPlane = ST_NEW_CLIP_STATE;
 
+   if (st->clamp_frag_color_in_shader) {
+      f->NewFragClamp = ST_NEW_FS_STATE;
+   } else {
+      f->NewFragClamp = ST_NEW_RASTERIZER;
+   }
+
    if (st->clamp_frag_depth_in_shader) {
       f->NewClipControl |= ST_NEW_VS_STATE | ST_NEW_GS_STATE |
                            ST_NEW_TES_STATE;