radeonsi: add AMD_DEBUG=extra_md
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Tue, 21 Mar 2023 09:46:53 +0000 (10:46 +0100)
committerMarge Bot <emma+marge@anholt.net>
Tue, 28 Mar 2023 15:17:28 +0000 (15:17 +0000)
When this debug flag is set, the driver sets the umd metadata for
all color textures and enables the use of extended metadata.

Extended metadata allows umr to import textures and setting these
on all color texture allows to import non-exported textures
(eg: dGPU draw surface when DRI_PRIME=1 is used).

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21984>

docs/envvars.rst
src/gallium/drivers/radeonsi/si_pipe.c
src/gallium/drivers/radeonsi/si_pipe.h
src/gallium/drivers/radeonsi/si_texture.c

index 85d1930..de973e6 100644 (file)
@@ -1368,6 +1368,8 @@ RadeonSI driver environment variables
       Enable DPBB.
    ``dfsm``
       Enable DFSM.
+   ``extra_md``
+      add extra information in bo metadatas to help tools (umr)
 
 r600 driver environment variables
 ---------------------------------
index c83716d..55b9035 100644 (file)
@@ -119,6 +119,8 @@ static const struct debug_named_value radeonsi_debug_options[] = {
    {"nofmask", DBG(NO_FMASK), "Disable MSAA compression"},
    {"nodma", DBG(NO_DMA), "Disable SDMA-copy for DRI_PRIME"},
 
+   {"extra_md", DBG(EXTRA_METADATA), "Set UMD metadata for all textures and with additional fields for umr"},
+
    {"tmz", DBG(TMZ), "Force allocation of scanout/depth/stencil buffer as encrypted"},
    {"sqtt", DBG(SQTT), "Enable SQTT"},
 
index cfa3804..91efb8b 100644 (file)
@@ -256,6 +256,8 @@ enum
    DBG_NO_FMASK,
    DBG_NO_DMA,
 
+   DBG_EXTRA_METADATA,
+
    DBG_TMZ,
    DBG_SQTT,
 
index f7ef69d..8c5051e 100644 (file)
@@ -556,7 +556,7 @@ static void si_set_tex_bo_metadata(struct si_screen *sscreen, struct si_texture
    ac_surface_compute_umd_metadata(&sscreen->info, &tex->surface,
                                    tex->buffer.b.b.last_level + 1,
                                    desc, &md.size_metadata, md.metadata,
-                                   false);
+                                   sscreen->debug_flags & DBG(EXTRA_METADATA));
    sscreen->ws->buffer_set_metadata(sscreen->ws, tex->buffer.buf, &md, &tex->surface);
 }
 
@@ -1307,6 +1307,11 @@ si_texture_create_with_modifier(struct pipe_screen *screen,
        */
       if (num_planes > 1)
          plane_templ[i].bind |= PIPE_BIND_SHARED;
+      /* Setting metadata on suballocated buffers is impossible. So use PIPE_BIND_CUSTOM to
+       * request a non-suballocated buffer.
+       */
+      if (!is_zs && sscreen->debug_flags & DBG(EXTRA_METADATA))
+         plane_templ[i].bind |= PIPE_BIND_CUSTOM;
 
       if (si_init_surface(sscreen, &surface[i], &plane_templ[i], tile_mode, modifier,
                           false, plane_templ[i].bind & PIPE_BIND_SCANOUT,
@@ -1340,6 +1345,8 @@ si_texture_create_with_modifier(struct pipe_screen *screen,
          last_plane->buffer.b.b.next = &tex->buffer.b.b;
          last_plane = tex;
       }
+      if (i == 0 && !is_zs && sscreen->debug_flags & DBG(EXTRA_METADATA))
+         si_set_tex_bo_metadata(sscreen, tex);
    }
 
    return (struct pipe_resource *)plane0;