From 6e7718dcea4159b358be46d709db05f0fb1b02b1 Mon Sep 17 00:00:00 2001 From: Felix DeGrood Date: Fri, 7 Jul 2023 17:15:01 +0000 Subject: [PATCH] anv: debug messaging for sparse texture usage Enable sparse debug messages with INTEL_DEBUG=sparse Reviewed-by: Lionel Landwerlin Part-of: --- docs/envvars.rst | 2 ++ src/intel/dev/intel_debug.c | 1 + src/intel/dev/intel_debug.h | 1 + src/intel/vulkan/anv_batch_chain.c | 11 +++++++++++ src/intel/vulkan/anv_device.c | 17 +++++++++++++++++ src/intel/vulkan/anv_formats.c | 5 +++++ src/intel/vulkan/anv_image.c | 20 ++++++++++++++++++++ 7 files changed, 57 insertions(+) diff --git a/docs/envvars.rst b/docs/envvars.rst index c4f61ff..31d7e43 100644 --- a/docs/envvars.rst +++ b/docs/envvars.rst @@ -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) diff --git a/src/intel/dev/intel_debug.c b/src/intel/dev/intel_debug.c index b488fdd..6277f36 100644 --- a/src/intel/dev/intel_debug.c +++ b/src/intel/dev/intel_debug.c @@ -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 } }; diff --git a/src/intel/dev/intel_debug.h b/src/intel/dev/intel_debug.h index 99e28da..8a2cca4 100644 --- a/src/intel/dev/intel_debug.h +++ b/src/intel/dev/intel_debug.h @@ -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) diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c index 0dacca9..4a6ab74 100644 --- a/src/intel/vulkan/anv_batch_chain.c +++ b/src/intel/vulkan/anv_batch_chain.c @@ -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 */, diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index eeb2d52..a5152a1 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -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 diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c index a2e6212..85c29d3 100644 --- a/src/intel/vulkan/anv_formats.c +++ b/src/intel/vulkan/anv_formats.c @@ -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; } diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index d0cf6ae..c7ba03c 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -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; } -- 2.7.4