iris: Restore flagging of dirty bindings in binder_realloc
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 10 Mar 2022 03:21:23 +0000 (19:21 -0800)
committerMarge Bot <emma+marge@anholt.net>
Fri, 11 Mar 2022 07:59:18 +0000 (07:59 +0000)
When I switched iris over to use 3DSTATE_BINDING_TABLE_POOL_ALLOC, I
stopped flagging things dirty when allocating a new binder, because
the contents of the binding table were still valid, thanks to us not
having to subtract Surface State Base Address anymore.

This unfortunately missed the point that the old binding table is in the
old buffer, which is no longer what the binder pool base address points
to.  So we'd either need to copy it over, or just flag it dirty and
re-emit it on the next draw.

Fixes misrendering in Ryujinx.

Fixes: 8b9045e7a45 ("intel: Use 3DSTATE_BINDING_TABLE_POOL_ALLOC exclusively on Gfx11+")
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15314>

src/gallium/drivers/iris/iris_binder.c

index 66a1ecf..d2ae1f9 100644 (file)
@@ -63,7 +63,6 @@ static void
 binder_realloc(struct iris_context *ice)
 {
    struct iris_screen *screen = (void *) ice->ctx.screen;
-   const struct intel_device_info *devinfo = &screen->devinfo;
    struct iris_bufmgr *bufmgr = screen->bufmgr;
    struct iris_binder *binder = &ice->state.binder;
 
@@ -77,21 +76,20 @@ binder_realloc(struct iris_context *ice)
    /* Avoid using offset 0 - tools consider it NULL. */
    binder->insert_point = binder->alignment;
 
-   if (devinfo->ver < 11) {
-      /* Allocating a new binder requires changing Surface State Base Address,
-       * which also invalidates all our previous binding tables - each entry
-       * in those tables is an offset from the old base.
-       *
-       * We do this here so that iris_binder_reserve_3d correctly gets a new
-       * larger total_size when making the updated reservation.
-       *
-       * On Icelake and later, we just update the binding table pool address
-       * rather than moving surface state base address, so we no longer need
-       * to do any of this.
-       */
-      ice->state.dirty |= IRIS_DIRTY_RENDER_BUFFER;
-      ice->state.stage_dirty |= IRIS_ALL_STAGE_DIRTY_BINDINGS;
-   }
+   /* Allocating a new binder requires changing Surface State Base Address,
+    * which also invalidates all our previous binding tables - each entry
+    * in those tables is an offset from the old base.
+    *
+    * We do this here so that iris_binder_reserve_3d correctly gets a new
+    * larger total_size when making the updated reservation.
+    *
+    * Gfx11+ simply updates the binding table pool address instead, which
+    * means the old binding table's contents are still valid.  Nevertheless,
+    * it still lives in the old BO, so we'd at least need to copy it to the
+    * new one.  Instead, we just flag it dirty and re-emit it anyway.
+    */
+   ice->state.dirty |= IRIS_DIRTY_RENDER_BUFFER;
+   ice->state.stage_dirty |= IRIS_ALL_STAGE_DIRTY_BINDINGS;
 }
 
 static uint32_t