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 0dc2fa171c354cdf3be5fe9da4f2e63cdc12ce87..0bf27b1f46efa24e2ece9e75aeb7577a5c35c4dd 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 5bb6ac58be45a0ab8140fa3e18c19b75dea8a21b..8bfeeaf7cd4137a639f6095158cdf6063bb4c983 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 bcbb3cd6b79b864130904051405328c09a64d307..4af7bdc97d25e1d57720a9f764a9fb8541d3a8bf 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 893dc59e58fd0cfc56f401b4fca1add716ce90d8..b349c2a1f17eb637f300e254be86a9e44fcb14da 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 4f7fd24274122fee2f9945fff7538fb68cfb31b7..2fc4ffe672842d9ac779aaa22d8b2c9807341b16 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;