radeonsi/gfx9: properly handle imported textures with unexpected swizzle mode
authorMarek Olšák <marek.olsak@amd.com>
Thu, 17 Aug 2017 21:24:00 +0000 (23:24 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 22 Aug 2017 11:29:47 +0000 (13:29 +0200)
Cc: 17.2 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/amd/common/ac_surface.c
src/gallium/drivers/radeon/r600_texture.c

index 823a65d038ff2134c59037815386e7452092baae..610071a956ff741dc313b268943244bfb301f8f5 100644 (file)
@@ -1044,6 +1044,11 @@ static int gfx9_compute_surface(ADDR_HANDLE addrlib,
 
        case RADEON_SURF_MODE_1D:
        case RADEON_SURF_MODE_2D:
+               if (surf->flags & RADEON_SURF_IMPORTED) {
+                       AddrSurfInfoIn.swizzleMode = surf->u.gfx9.surf.swizzle_mode;
+                       break;
+               }
+
                r = gfx9_get_preferred_swizzle_mode(addrlib, &AddrSurfInfoIn, false,
                                                    &AddrSurfInfoIn.swizzleMode);
                if (r)
index 22850e0c87d43e3b6667052cbd926af54960cc4d..47fd56fa6bf326714f312e62befb221495914e47 100644 (file)
@@ -356,7 +356,9 @@ static void r600_surface_import_metadata(struct r600_common_screen *rscreen,
                        *array_mode = RADEON_SURF_MODE_LINEAR_ALIGNED;
 
                *is_scanout = metadata->u.gfx9.swizzle_mode == 0 ||
-                       metadata->u.gfx9.swizzle_mode % 4 == 2;
+                             metadata->u.gfx9.swizzle_mode % 4 == 2;
+
+               surf->u.gfx9.surf.swizzle_mode = metadata->u.gfx9.swizzle_mode;
        } else {
                surf->u.legacy.pipe_config = metadata->u.legacy.pipe_config;
                surf->u.legacy.bankw = metadata->u.legacy.bankw;
@@ -1521,11 +1523,6 @@ static struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen
        if (rscreen->apply_opaque_metadata)
                rscreen->apply_opaque_metadata(rscreen, rtex, &metadata);
 
-       /* Validate that addrlib arrived at the same surface parameters. */
-       if (rscreen->chip_class >= GFX9) {
-               assert(metadata.u.gfx9.swizzle_mode == surface.u.gfx9.surf.swizzle_mode);
-       }
-
        assert(rtex->surface.tile_swizzle == 0);
        return &rtex->resource.b.b;
 }