ac/surface: limit RADEON_SURF_NO_TEXTURE to color surfaces
authorChia-I Wu <olvaffe@gmail.com>
Fri, 18 Aug 2023 04:36:23 +0000 (21:36 -0700)
committerMarge Bot <emma+marge@anholt.net>
Tue, 22 Aug 2023 02:36:20 +0000 (02:36 +0000)
For z surfaces, flags.texture should be based on
RADEON_SURF_TC_COMPATIBLE_HTILE alone.  Otherwise, addrlib could pick a
_X/_T swizzle mode for a MSAA depth texture, which is said to be broken:

  When _X/_T swizzle mode was used for MSAA depth texture, TC will get zplane
  equation from wrong address within memory range a tile covered and use the
  garbage data for compressed Z reading which finally leads to corruption.

Fixes: de0885cdb89 ("amd/surface: add RADEON_SURF_NO_TEXTURE flag")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24767>

src/amd/common/ac_surface.c
src/amd/common/ac_surface.h

index fcccd80cd3771407988c187adbb377095efff9ab..cc47d6e15ce73cbcb9a0879a0473f007e9dfad40 100644 (file)
@@ -2208,9 +2208,8 @@ static int gfx9_compute_surface(struct ac_addrlib *addrlib, const struct radeon_
    AddrSurfInfoIn.flags.depth = (surf->flags & RADEON_SURF_ZBUFFER) != 0;
    AddrSurfInfoIn.flags.display = get_display_flag(config, surf);
    /* flags.texture currently refers to TC-compatible HTILE */
-   AddrSurfInfoIn.flags.texture = !(surf->flags & RADEON_SURF_NO_TEXTURE) &&
-                                  (is_color_surface ||
-                                   surf->flags & RADEON_SURF_TC_COMPATIBLE_HTILE);
+   AddrSurfInfoIn.flags.texture = (is_color_surface && !(surf->flags & RADEON_SURF_NO_TEXTURE)) ||
+                                  (surf->flags & RADEON_SURF_TC_COMPATIBLE_HTILE);
    AddrSurfInfoIn.flags.opt4space = 1;
    AddrSurfInfoIn.flags.prt = (surf->flags & RADEON_SURF_PRT) != 0;
 
index 6aa5cdda63d63c5a8c7c1608f1a2041277bdea5d..382eb5d79f0fa77dff32138722bcd3eeed2e1d70 100644 (file)
@@ -71,8 +71,8 @@ enum radeon_micro_mode
 #define RADEON_SURF_PRT                   (1ull << 32)
 #define RADEON_SURF_VRS_RATE              (1ull << 33)
 /* Block compressed + linear format is not supported in addrlib. These surface can be
- * used as transfer resource. This flag indicates not to set flags.texture flag in
- * gfx9_compute_surface(). */
+ * used as transfer resource. This flag indicates not to set flags.texture flag for
+ * color surface in gfx9_compute_surface(). */
 #define RADEON_SURF_NO_TEXTURE            (1ull << 34)
 #define RADEON_SURF_NO_STENCIL_ADJUST     (1ull << 35)