anv: debug messaging for sparse texture usage
authorFelix DeGrood <felix.j.degrood@intel.com>
Fri, 7 Jul 2023 17:15:01 +0000 (17:15 +0000)
committerMarge Bot <emma+marge@anholt.net>
Thu, 3 Aug 2023 19:57:19 +0000 (19:57 +0000)
Enable sparse debug messages with INTEL_DEBUG=sparse

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24046>

docs/envvars.rst
src/intel/dev/intel_debug.c
src/intel/dev/intel_debug.h
src/intel/vulkan/anv_batch_chain.c
src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_formats.c
src/intel/vulkan/anv_image.c

index c4f61ff..31d7e43 100644 (file)
@@ -571,6 +571,8 @@ Intel driver environment variables
       the SF program)
    ``soft64``
       enable implementation of software 64bit floating point support
+   ``sparse``
+      dump usage of sparse resources
    ``spill_fs``
       force spilling of all registers in the scalar backend (useful to
       debug spilling code)
index b488fdd..6277f36 100644 (file)
@@ -103,6 +103,7 @@ static const struct debug_control debug_control[] = {
    { "swsb-stall",  DEBUG_SWSB_STALL },
    { "heaps",       DEBUG_HEAPS },
    { "isl",         DEBUG_ISL },
+   { "sparse",      DEBUG_SPARSE },
    { NULL,    0 }
 };
 
index 99e28da..8a2cca4 100644 (file)
@@ -93,6 +93,7 @@ extern uint64_t intel_debug;
 #define DEBUG_SWSB_STALL          (1ull << 45)
 #define DEBUG_HEAPS               (1ull << 46)
 #define DEBUG_ISL                 (1ull << 47)
+#define DEBUG_SPARSE              (1ull << 48)
 
 #define DEBUG_ANY                 (~0ull)
 
index 0dacca9..4a6ab74 100644 (file)
@@ -1258,6 +1258,17 @@ anv_queue_submit_locked(struct anv_queue *queue,
 {
    VkResult result;
 
+   if (unlikely((submit->buffer_bind_count ||
+                 submit->image_opaque_bind_count ||
+                 submit->image_bind_count))) {
+      if (INTEL_DEBUG(DEBUG_SPARSE))
+         fprintf(stderr, "=== application submitting sparse operations: "
+               "buffer_bind:%d image_opaque_bind:%d image_bind:%d\n",
+               submit->buffer_bind_count, submit->image_opaque_bind_count,
+               submit->image_bind_count);
+      fprintf(stderr, "Error: Using sparse operation. Sparse binding not supported.\n");
+   }
+
    if (submit->command_buffer_count == 0) {
       result = anv_queue_exec_locked(queue, submit->wait_count, submit->waits,
                                      0 /* cmd_buffer_count */,
index eeb2d52..a5152a1 100644 (file)
@@ -4243,6 +4243,9 @@ VkResult anv_QueueBindSparse(
    if (vk_device_is_lost(&queue->device->vk))
       return VK_ERROR_DEVICE_LOST;
 
+   if (INTEL_DEBUG(DEBUG_SPARSE))
+      fprintf(stderr, "=== [%s:%d] [%s]\n", __FILE__, __LINE__, __func__);
+
    return vk_error(queue, VK_ERROR_FEATURE_NOT_PRESENT);
 }
 
@@ -4385,6 +4388,13 @@ void anv_GetDeviceBufferMemoryRequirementsKHR(
 {
    ANV_FROM_HANDLE(anv_device, device, _device);
 
+   if (INTEL_DEBUG(DEBUG_SPARSE) && pInfo->pCreateInfo->flags &
+           (VK_BUFFER_CREATE_SPARSE_BINDING_BIT |
+            VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT |
+            VK_BUFFER_CREATE_SPARSE_ALIASED_BIT))
+      fprintf(stderr, "=== %s %s:%d flags:0x%08x\n", __func__, __FILE__,
+              __LINE__, pInfo->pCreateInfo->flags);
+
    anv_get_buffer_memory_requirements(device,
                                       pInfo->pCreateInfo->size,
                                       pInfo->pCreateInfo->usage,
@@ -4400,6 +4410,13 @@ VkResult anv_CreateBuffer(
    ANV_FROM_HANDLE(anv_device, device, _device);
    struct anv_buffer *buffer;
 
+   if (INTEL_DEBUG(DEBUG_SPARSE) && (pCreateInfo->flags &
+           (VK_BUFFER_CREATE_SPARSE_BINDING_BIT |
+            VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT |
+            VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)))
+      fprintf(stderr, "=== %s %s:%d flags:0x%08x\n", __func__, __FILE__,
+              __LINE__, pCreateInfo->flags);
+
    /* Don't allow creating buffers bigger than our address space.  The real
     * issue here is that we may align up the buffer size and we don't want
     * doing so to cause roll-over.  However, no one has any business
index a2e6212..85c29d3 100644 (file)
@@ -1785,6 +1785,8 @@ void anv_GetPhysicalDeviceSparseImageFormatProperties(
     uint32_t*                                   pNumProperties,
     VkSparseImageFormatProperties*              pProperties)
 {
+   if (INTEL_DEBUG(DEBUG_SPARSE))
+      fprintf(stderr, "=== [%s:%d] [%s]\n", __FILE__, __LINE__, __func__);
    /* Sparse images are not yet supported. */
    *pNumProperties = 0;
 }
@@ -1795,6 +1797,9 @@ void anv_GetPhysicalDeviceSparseImageFormatProperties2(
     uint32_t*                                   pPropertyCount,
     VkSparseImageFormatProperties2*             pProperties)
 {
+   if (INTEL_DEBUG(DEBUG_SPARSE))
+      fprintf(stderr, "=== [%s:%d] [%s]\n", __FILE__, __LINE__, __func__);
+
    /* Sparse images are not yet supported. */
    *pPropertyCount = 0;
 }
index d0cf6ae..c7ba03c 100644 (file)
@@ -1540,6 +1540,13 @@ VkResult anv_CreateImage(
 {
    ANV_FROM_HANDLE(anv_device, device, _device);
 
+   if (INTEL_DEBUG(DEBUG_SPARSE) && (pCreateInfo->flags &
+         (VK_IMAGE_CREATE_SPARSE_BINDING_BIT |
+          VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT |
+          VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)))
+      fprintf(stderr, "=== %s %s:%d flags:0x%08x\n", __func__, __FILE__,
+              __LINE__, pCreateInfo->flags);
+
 #ifndef VK_USE_PLATFORM_ANDROID_KHR
    /* Ignore swapchain creation info on Android. Since we don't have an
     * implementation in Mesa, we're guaranteed to access an Android object
@@ -1754,6 +1761,13 @@ void anv_GetDeviceImageMemoryRequirementsKHR(
    ANV_FROM_HANDLE(anv_device, device, _device);
    struct anv_image image = { 0 };
 
+   if (INTEL_DEBUG(DEBUG_SPARSE) && (pInfo->pCreateInfo->flags &
+         (VK_IMAGE_CREATE_SPARSE_BINDING_BIT |
+          VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT |
+          VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)))
+      fprintf(stderr, "=== %s %s:%d flags:0x%08x\n", __func__, __FILE__,
+              __LINE__, pInfo->pCreateInfo->flags);
+
    ASSERTED VkResult result =
       anv_image_init_from_create_info(device, &image, pInfo->pCreateInfo, true);
    assert(result == VK_SUCCESS);
@@ -1771,6 +1785,8 @@ void anv_GetImageSparseMemoryRequirements(
     uint32_t*                                   pSparseMemoryRequirementCount,
     VkSparseImageMemoryRequirements*            pSparseMemoryRequirements)
 {
+   if (INTEL_DEBUG(DEBUG_SPARSE))
+      fprintf(stderr, "=== [%s:%d] [%s]\n", __FILE__, __LINE__, __func__);
    *pSparseMemoryRequirementCount = 0;
 }
 
@@ -1780,6 +1796,8 @@ void anv_GetImageSparseMemoryRequirements2(
     uint32_t*                                   pSparseMemoryRequirementCount,
     VkSparseImageMemoryRequirements2*           pSparseMemoryRequirements)
 {
+   if (INTEL_DEBUG(DEBUG_SPARSE))
+      fprintf(stderr, "=== [%s:%d] [%s]\n", __FILE__, __LINE__, __func__);
    *pSparseMemoryRequirementCount = 0;
 }
 
@@ -1789,6 +1807,8 @@ void anv_GetDeviceImageSparseMemoryRequirementsKHR(
     uint32_t*                                   pSparseMemoryRequirementCount,
     VkSparseImageMemoryRequirements2*           pSparseMemoryRequirements)
 {
+   if (INTEL_DEBUG(DEBUG_SPARSE))
+      fprintf(stderr, "=== [%s:%d] [%s]\n", __FILE__, __LINE__, __func__);
    *pSparseMemoryRequirementCount = 0;
 }