Mesa (master): st/mesa: Move _NEW_FRAG_CLAMP to NewFragClamp driver flag.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 30 22:24:57 UTC 2020


Module: Mesa
Branch: master
Commit: f1538002b81493b5e4754746745db565cf6fe810
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f1538002b81493b5e4754746745db565cf6fe810

Author: Mathias Fröhlich <mathias.froehlich at web.de>
Date:   Mon Aug 12 12:16:16 2019 +0200

st/mesa: Move _NEW_FRAG_CLAMP to NewFragClamp driver flag.

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4314>

---

 src/mesa/main/blend.c                       | 13 ++++++++++---
 src/mesa/main/mtypes.h                      |  3 +++
 src/mesa/state_tracker/st_atom_rasterizer.c |  2 +-
 src/mesa/state_tracker/st_atom_shader.c     |  2 +-
 src/mesa/state_tracker/st_context.c         | 13 ++++++-------
 5 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index 0dc2fa171c3..0bf27b1f46e 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -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;
 }
 
 /**
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 5bb6ac58be4..8bfeeaf7cd4 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -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;
 
diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c
index bcbb3cd6b79..4af7bdc97d2 100644
--- a/src/mesa/state_tracker/st_atom_rasterizer.c
+++ b/src/mesa/state_tracker/st_atom_rasterizer.c
@@ -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;
 
diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c
index 893dc59e58f..b349c2a1f17 100644
--- a/src/mesa/state_tracker/st_atom_shader.c
+++ b/src/mesa/state_tracker/st_atom_shader.c
@@ -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;
 
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 4f7fd242741..2fc4ffe6728 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -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;



More information about the mesa-commit mailing list