radv: add img debug flag
authorSimon Ser <contact@emersion.fr>
Fri, 3 Jul 2020 13:16:00 +0000 (15:16 +0200)
committerSimon Ser <contact@emersion.fr>
Fri, 13 Nov 2020 10:32:17 +0000 (11:32 +0100)
This is similar to AMD_DEBUG=tex, but for radv.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5734>

docs/envvars.rst
src/amd/vulkan/radv_debug.h
src/amd/vulkan/radv_device.c
src/amd/vulkan/radv_image.c

index ed9d640..363f0aa 100644 (file)
@@ -557,6 +557,8 @@ RADV driver environment variables
    ``hang``
       enable GPU hangs detection and dump a report to $HOME/radv_dumps_<pid>
       if a GPU hang is detected
+   ``img``
+      Print image info
    ``info``
       show GPU-related information
    ``metashaders``
index 0985be3..4f049f7 100644 (file)
@@ -58,6 +58,7 @@ enum {
        RADV_DEBUG_LLVM              = 1 << 27,
        RADV_DEBUG_FORCE_COMPRESS    = 1 << 28,
        RADV_DEBUG_HANG              = 1 << 29,
+       RADV_DEBUG_IMG               = 1 << 30,
 };
 
 enum {
index 4801cbb..8643367 100644 (file)
@@ -552,6 +552,7 @@ static const struct debug_control radv_debug_options[] = {
        {"llvm", RADV_DEBUG_LLVM},
        {"forcecompress", RADV_DEBUG_FORCE_COMPRESS},
        {"hang", RADV_DEBUG_HANG},
+       {"img", RADV_DEBUG_IMG},
        {NULL, 0}
 };
 
index ab70e1b..99ead12 100644 (file)
@@ -1409,6 +1409,31 @@ radv_destroy_image(struct radv_device *device,
        vk_free2(&device->vk.alloc, pAllocator, image);
 }
 
+static void
+radv_image_print_info(struct radv_device *device, struct radv_image *image)
+{
+       fprintf(stderr, "Image:\n");
+       fprintf(stderr, "  Info: size=%" PRIu64 ", alignment=%" PRIu32 ", "
+                       "width=%" PRIu32 ", height=%" PRIu32 ", "
+                       "offset=%" PRIu64 "\n",
+               image->size, image->alignment, image->info.width,
+               image->info.height, image->offset);
+       for (unsigned i = 0; i < image->plane_count; ++i) {
+               const struct radv_image_plane *plane = &image->planes[i];
+               const struct radeon_surf *surf = &plane->surface;
+               const struct vk_format_description *desc =
+                       vk_format_description(plane->format);
+
+               fprintf(stderr,
+                       "  Plane[%u]: vkformat=%s, offset=%" PRIu64 "\n",
+                       i, desc->name, plane->offset);
+
+               ac_surface_print_info(stderr,
+                                     &device->physical_device->rad_info,
+                                     surf);
+       }
+}
+
 VkResult
 radv_image_create(VkDevice _device,
                  const struct radv_image_create_info *create_info,
@@ -1505,6 +1530,10 @@ radv_image_create(VkDevice _device,
                }
        }
 
+       if (device->instance->debug_flags & RADV_DEBUG_IMG) {
+               radv_image_print_info(device, image);
+       }
+
        *pImage = radv_image_to_handle(image);
 
        return VK_SUCCESS;