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

Author: Mike Blumenkrantz <[email protected]>
Date:   Wed May  5 09:26:57 2021 -0400

lavapipe: don't unnecessarily flag dsa states for updating

these force a new dsa state to be created and bound, which isn't necessary
if the same value is being reset

Reviewed-by: Dave Airlie <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10625>

---

 src/gallium/frontends/lavapipe/lvp_execute.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/gallium/frontends/lavapipe/lvp_execute.c 
b/src/gallium/frontends/lavapipe/lvp_execute.c
index 9a8f3401df1..bc9483424de 100644
--- a/src/gallium/frontends/lavapipe/lvp_execute.c
+++ b/src/gallium/frontends/lavapipe/lvp_execute.c
@@ -43,6 +43,8 @@
 
 #include "vk_util.h"
 
+#define DOUBLE_EQ(a, b) (fabs((a) - (b)) < DBL_EPSILON)
+
 struct rendering_state {
    struct pipe_context *pctx;
 
@@ -1654,9 +1656,10 @@ static void handle_set_blend_constants(struct 
lvp_cmd_buffer_entry *cmd,
 static void handle_set_depth_bounds(struct lvp_cmd_buffer_entry *cmd,
                                     struct rendering_state *state)
 {
+   state->dsa_dirty |= !DOUBLE_EQ(state->dsa_state.depth_bounds_min, 
cmd->u.set_depth_bounds.min_depth);
+   state->dsa_dirty |= !DOUBLE_EQ(state->dsa_state.depth_bounds_max, 
cmd->u.set_depth_bounds.max_depth);
    state->dsa_state.depth_bounds_min = cmd->u.set_depth_bounds.min_depth;
    state->dsa_state.depth_bounds_max = cmd->u.set_depth_bounds.max_depth;
-   state->dsa_dirty = true;
 }
 
 static void handle_set_stencil_compare_mask(struct lvp_cmd_buffer_entry *cmd,
@@ -2868,37 +2871,38 @@ static void handle_set_primitive_topology(struct 
lvp_cmd_buffer_entry *cmd,
 static void handle_set_depth_test_enable(struct lvp_cmd_buffer_entry *cmd,
                                          struct rendering_state *state)
 {
+   state->dsa_dirty |= state->dsa_state.depth_enabled != 
cmd->u.set_depth_test_enable.depth_test_enable;
    state->dsa_state.depth_enabled = 
cmd->u.set_depth_test_enable.depth_test_enable;
-   state->dsa_dirty = true;
 }
 
 static void handle_set_depth_write_enable(struct lvp_cmd_buffer_entry *cmd,
                                           struct rendering_state *state)
 {
+   state->dsa_dirty |= state->dsa_state.depth_writemask != 
cmd->u.set_depth_write_enable.depth_write_enable;
    state->dsa_state.depth_writemask = 
cmd->u.set_depth_write_enable.depth_write_enable;
-   state->dsa_dirty = true;
 }
 
 static void handle_set_depth_compare_op(struct lvp_cmd_buffer_entry *cmd,
                                         struct rendering_state *state)
 {
+   state->dsa_dirty |= state->dsa_state.depth_func != 
cmd->u.set_depth_compare_op.depth_op;
    state->dsa_state.depth_func = cmd->u.set_depth_compare_op.depth_op;
-   state->dsa_dirty = true;
 }
 
 static void handle_set_depth_bounds_test_enable(struct lvp_cmd_buffer_entry 
*cmd,
                                                 struct rendering_state *state)
 {
+   state->dsa_dirty |= state->dsa_state.depth_bounds_test != 
cmd->u.set_depth_bounds_test_enable.depth_bounds_test_enable;
    state->dsa_state.depth_bounds_test = 
cmd->u.set_depth_bounds_test_enable.depth_bounds_test_enable;
-   state->dsa_dirty = true;
 }
 
 static void handle_set_stencil_test_enable(struct lvp_cmd_buffer_entry *cmd,
                                            struct rendering_state *state)
 {
+   state->dsa_dirty |= state->dsa_state.stencil[0].enabled != 
cmd->u.set_stencil_test_enable.stencil_test_enable ||
+                       state->dsa_state.stencil[1].enabled != 
cmd->u.set_stencil_test_enable.stencil_test_enable;
    state->dsa_state.stencil[0].enabled = 
cmd->u.set_stencil_test_enable.stencil_test_enable;
    state->dsa_state.stencil[1].enabled = 
cmd->u.set_stencil_test_enable.stencil_test_enable;
-   state->dsa_dirty = true;
 }
 
 static void handle_set_stencil_op(struct lvp_cmd_buffer_entry *cmd,

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to