Mesa (staging/19.2): i965: Unify CC_STATE and BLEND_STATE atoms on Haswell as a workaround

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Nov 20 16:41:14 UTC 2019


Module: Mesa
Branch: staging/19.2
Commit: 3199172eaa703ac4c1fc3830c8e49c367725c3b8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3199172eaa703ac4c1fc3830c8e49c367725c3b8

Author: Danylo Piliaiev <danylo.piliaiev at globallogic.com>
Date:   Thu Nov 14 15:36:27 2019 +0200

i965: Unify CC_STATE and BLEND_STATE atoms on Haswell as a workaround

Re-emitting 3DSTATE_CC_STATE_POINTERS after emitting
3DSTATE_BLEND_STATE_POINTERS fixes the shadow flickering in
SuperTuxCart and Tropico 6 which was seen only on Haswell.
The reason for this is unknown and fix was found empirically.

The closest mention in PRM is that it should improve performance.
>From the HSW PRM, volume 2b, page 823 (3DSTATE_BLEND_STATE_POINTERS):
 "When the BLEND_STATE pointer changes but not the CC_STATE pointer,
  driver needs to force a CC_STATE pointer change to improve
  blend performance in pixel backend."

Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/1834
Fixes: eca4a654 ("i965: Disable dual source blending when shader doesn't support it on gen8+")
Cc: <mesa-stable at lists.freedesktop.org>
Signed-off-by: Danylo Piliaiev <danylo.piliaiev at globallogic.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
(cherry picked from commit 6f17fe0606a144f977d8b70a7ee9f8371abc144b)

---

 src/mesa/drivers/dri/i965/genX_state_upload.c | 37 +++++++++++++++++++++++++--
 1 file changed, 35 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c b/src/mesa/drivers/dri/i965/genX_state_upload.c
index 629849def74..01f9d198104 100644
--- a/src/mesa/drivers/dri/i965/genX_state_upload.c
+++ b/src/mesa/drivers/dri/i965/genX_state_upload.c
@@ -3051,7 +3051,7 @@ genX(upload_blend_state)(struct brw_context *brw)
 #endif
 }
 
-static const struct brw_tracked_state genX(blend_state) = {
+UNUSED static const struct brw_tracked_state genX(blend_state) = {
    .dirty = {
       .mesa = _NEW_BUFFERS |
               _NEW_COLOR |
@@ -3412,7 +3412,7 @@ genX(upload_color_calc_state)(struct brw_context *brw)
 #endif
 }
 
-static const struct brw_tracked_state genX(color_calc_state) = {
+UNUSED static const struct brw_tracked_state genX(color_calc_state) = {
    .dirty = {
       .mesa = _NEW_COLOR |
               _NEW_STENCIL |
@@ -3432,6 +3432,35 @@ static const struct brw_tracked_state genX(color_calc_state) = {
 
 /* ---------------------------------------------------------------------- */
 
+#if GEN_IS_HASWELL
+static void
+genX(upload_color_calc_and_blend_state)(struct brw_context *brw)
+{
+   genX(upload_blend_state)(brw);
+   genX(upload_color_calc_state)(brw);
+}
+
+/* On Haswell when BLEND_STATE is emitted CC_STATE should also be re-emitted,
+ * this workarounds the flickering shadows in several games.
+ */
+static const struct brw_tracked_state genX(cc_and_blend_state) = {
+   .dirty = {
+      .mesa = _NEW_BUFFERS |
+              _NEW_COLOR |
+              _NEW_STENCIL |
+              _NEW_MULTISAMPLE,
+      .brw = BRW_NEW_BATCH |
+             BRW_NEW_BLORP |
+             BRW_NEW_CC_STATE |
+             BRW_NEW_FS_PROG_DATA |
+             BRW_NEW_STATE_BASE_ADDRESS,
+   },
+   .emit = genX(upload_color_calc_and_blend_state),
+};
+#endif
+
+/* ---------------------------------------------------------------------- */
+
 #if GEN_GEN >= 7
 static void
 genX(upload_sbe)(struct brw_context *brw)
@@ -5697,8 +5726,12 @@ genX(init_atoms)(struct brw_context *brw)
       &gen7_l3_state,
       &gen7_push_constant_space,
       &gen7_urb,
+#if GEN_IS_HASWELL
+      &genX(cc_and_blend_state),
+#else
       &genX(blend_state),		/* must do before cc unit */
       &genX(color_calc_state),	/* must do before cc unit */
+#endif
       &genX(depth_stencil_state),	/* must do before cc unit */
 
       &brw_vs_image_surfaces, /* Before vs push/pull constants and binding table */




More information about the mesa-commit mailing list