Module: Mesa
Branch: main
Commit: 5e2bd30ea4c0f570c99d58490ace2ae3a3bd5e44
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5e2bd30ea4c0f570c99d58490ace2ae3a3bd5e44

Author: Rob Clark <[email protected]>
Date:   Thu Jan 20 18:11:46 2022 -0800

freedreno: Add FD_DIRTY_RASTERIZER_CLIP_PLANE_ENABLE

Add a dirty bit for clip_plane_enable changes.

Signed-off-by: Rob Clark <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14643>

---

 src/gallium/drivers/freedreno/freedreno_context.h |  5 +++--
 src/gallium/drivers/freedreno/freedreno_state.c   | 10 ++++++++--
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/freedreno/freedreno_context.h 
b/src/gallium/drivers/freedreno/freedreno_context.h
index 35135b4e65c..6cbd7e6a255 100644
--- a/src/gallium/drivers/freedreno/freedreno_context.h
+++ b/src/gallium/drivers/freedreno/freedreno_context.h
@@ -172,8 +172,9 @@ enum fd_dirty_3d_state {
     * from hw perspective:
     */
    FD_DIRTY_RASTERIZER_DISCARD = BIT(24),
-   FD_DIRTY_BLEND_DUAL = BIT(25),
-#define NUM_DIRTY_BITS 26
+   FD_DIRTY_RASTERIZER_CLIP_PLANE_ENABLE = BIT(25),
+   FD_DIRTY_BLEND_DUAL = BIT(26),
+#define NUM_DIRTY_BITS 27
 
    /* additional flag for state requires updated resource tracking: */
    FD_DIRTY_RESOURCE = BIT(31),
diff --git a/src/gallium/drivers/freedreno/freedreno_state.c 
b/src/gallium/drivers/freedreno/freedreno_state.c
index 90c29894e05..01454d0c076 100644
--- a/src/gallium/drivers/freedreno/freedreno_state.c
+++ b/src/gallium/drivers/freedreno/freedreno_state.c
@@ -38,6 +38,8 @@
 #include "freedreno_texture.h"
 #include "freedreno_util.h"
 
+#define get_safe(ptr, field) ((ptr) ? (ptr)->field : 0)
+
 /* All the generic state handling.. In case of CSO's that are specific
  * to the GPU version, when the bind and the delete are common they can
  * go in here.
@@ -434,7 +436,8 @@ fd_rasterizer_state_bind(struct pipe_context *pctx, void 
*hwcso) in_dt
 {
    struct fd_context *ctx = fd_context(pctx);
    struct pipe_scissor_state *old_scissor = fd_context_get_scissor(ctx);
-   bool discard = ctx->rasterizer && ctx->rasterizer->rasterizer_discard;
+   bool discard = get_safe(ctx->rasterizer, rasterizer_discard);
+   unsigned clip_plane_enable = get_safe(ctx->rasterizer, clip_plane_enable);
 
    ctx->rasterizer = hwcso;
    fd_context_dirty(ctx, FD_DIRTY_RASTERIZER);
@@ -453,8 +456,11 @@ fd_rasterizer_state_bind(struct pipe_context *pctx, void 
*hwcso) in_dt
    if (old_scissor != fd_context_get_scissor(ctx))
       fd_context_dirty(ctx, FD_DIRTY_SCISSOR);
 
-   if (ctx->rasterizer && (discard != ctx->rasterizer->rasterizer_discard))
+   if (discard != get_safe(ctx->rasterizer, rasterizer_discard))
       fd_context_dirty(ctx, FD_DIRTY_RASTERIZER_DISCARD);
+
+   if (clip_plane_enable != get_safe(ctx->rasterizer, clip_plane_enable))
+      fd_context_dirty(ctx, FD_DIRTY_RASTERIZER_CLIP_PLANE_ENABLE);
 }
 
 static void

Reply via email to