From 4453339dec02bc08a8d4104ebeb3c6737fdeffcf Mon Sep 17 00:00:00 2001 From: Cort Date: Tue, 17 Jan 2017 17:32:33 -0800 Subject: [PATCH] layers: Add VU 792,804 (bind mem to sparse image/buffer) --- layers/core_validation.cpp | 20 ++++++++++++++++---- layers/vk_validation_error_database.txt | 4 ++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 738fac1..fcf7773 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -739,10 +739,22 @@ static bool SetMemBinding(layer_data *dev_data, VkDeviceMemory mem, uint64_t han if (mem != VK_NULL_HANDLE) { BINDABLE *mem_binding = GetObjectMemBinding(dev_data, handle, type); assert(mem_binding); - // TODO : Add check here to make sure object isn't sparse - // VALIDATION_ERROR_00792 for buffers - // VALIDATION_ERROR_00804 for images - assert(!mem_binding->sparse); + if (mem_binding->sparse) { + UNIQUE_VALIDATION_ERROR_CODE error_code = VALIDATION_ERROR_00804; + const char *handle_type = "IMAGE"; + if (strcmp(apiName, "vkBindBufferMemory") == 0) { + error_code = VALIDATION_ERROR_00792; + handle_type = "BUFFER"; + } else { + assert(strcmp(apiName, "vkBindImageMemory") == 0); + } + skip_call |= + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, + reinterpret_cast(mem), __LINE__, error_code, "MEM", + "In %s, attempting to bind memory (0x%" PRIxLEAST64 ") to object (0x%" PRIxLEAST64 + ") which was created with sparse memory flags (VK_%s_CREATE_SPARSE_*_BIT). %s", + apiName, reinterpret_cast(mem), handle, handle_type, validation_error_map[error_code]); + } DEVICE_MEM_INFO *mem_info = GetMemObjInfo(dev_data, mem); if (mem_info) { DEVICE_MEM_INFO *prev_binding = GetMemObjInfo(dev_data, mem_binding->binding.mem); diff --git a/layers/vk_validation_error_database.txt b/layers/vk_validation_error_database.txt index b6db7bf..e0be081 100644 --- a/layers/vk_validation_error_database.txt +++ b/layers/vk_validation_error_database.txt @@ -780,7 +780,7 @@ VALIDATION_ERROR_00788~^~Y~^~CreateUnknownObject~^~vkGetImageMemoryRequirements~ VALIDATION_ERROR_00789~^~N~^~Unknown~^~vkGetImageMemoryRequirements~^~For more information refer to Vulkan Spec Section '11.6. Resource Memory Association' which states 'pMemoryRequirements must be a pointer to a VkMemoryRequirements structure' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkGetImageMemoryRequirements)~^~implicit VALIDATION_ERROR_00790~^~N~^~Unknown~^~vkGetImageMemoryRequirements~^~For more information refer to Vulkan Spec Section '11.6. Resource Memory Association' which states 'image must have been created, allocated, or retrieved from device' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkGetImageMemoryRequirements)~^~implicit VALIDATION_ERROR_00791~^~N~^~Unknown~^~vkBindBufferMemory~^~For more information refer to Vulkan Spec Section '11.6. Resource Memory Association' which states 'buffer must not already be backed by a memory object' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkBindBufferMemory)~^~ -VALIDATION_ERROR_00792~^~N~^~Unknown~^~vkBindBufferMemory~^~For more information refer to Vulkan Spec Section '11.6. Resource Memory Association' which states 'buffer must not have been created with any sparse memory binding flags' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkBindBufferMemory)~^~ +VALIDATION_ERROR_00792~^~Y~^~Unknown~^~vkBindBufferMemory~^~For more information refer to Vulkan Spec Section '11.6. Resource Memory Association' which states 'buffer must not have been created with any sparse memory binding flags' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkBindBufferMemory)~^~ VALIDATION_ERROR_00793~^~N~^~Unknown~^~vkBindBufferMemory~^~For more information refer to Vulkan Spec Section '11.6. Resource Memory Association' which states 'memoryOffset must be less than the size of memory' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkBindBufferMemory)~^~ VALIDATION_ERROR_00794~^~Y~^~Unknown~^~vkBindBufferMemory~^~For more information refer to Vulkan Spec Section '11.6. Resource Memory Association' which states 'If buffer was created with the VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT or VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT, memoryOffset must be a multiple of VkPhysicalDeviceLimits::minTexelBufferOffsetAlignment' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkBindBufferMemory)~^~ VALIDATION_ERROR_00795~^~Y~^~Unknown~^~vkBindBufferMemory~^~For more information refer to Vulkan Spec Section '11.6. Resource Memory Association' which states 'If buffer was created with the VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, memoryOffset must be a multiple of VkPhysicalDeviceLimits::minUniformBufferOffsetAlignment' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkBindBufferMemory)~^~ @@ -792,7 +792,7 @@ VALIDATION_ERROR_00800~^~Y~^~Unknown~^~vkBindBufferMemory~^~For more information VALIDATION_ERROR_00801~^~N~^~Unknown~^~vkBindBufferMemory~^~For more information refer to Vulkan Spec Section '11.6. Resource Memory Association' which states 'buffer must have been created, allocated, or retrieved from device' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkBindBufferMemory)~^~implicit VALIDATION_ERROR_00802~^~N~^~Unknown~^~vkBindBufferMemory~^~For more information refer to Vulkan Spec Section '11.6. Resource Memory Association' which states 'memory must have been created, allocated, or retrieved from device' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkBindBufferMemory)~^~implicit VALIDATION_ERROR_00803~^~N~^~Unknown~^~vkBindImageMemory~^~For more information refer to Vulkan Spec Section '11.6. Resource Memory Association' which states 'image must not already be backed by a memory object' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkBindImageMemory)~^~ -VALIDATION_ERROR_00804~^~N~^~Unknown~^~vkBindImageMemory~^~For more information refer to Vulkan Spec Section '11.6. Resource Memory Association' which states 'image must not have been created with any sparse memory binding flags' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkBindImageMemory)~^~ +VALIDATION_ERROR_00804~^~Y~^~Unknown~^~vkBindImageMemory~^~For more information refer to Vulkan Spec Section '11.6. Resource Memory Association' which states 'image must not have been created with any sparse memory binding flags' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkBindImageMemory)~^~ VALIDATION_ERROR_00805~^~N~^~Unknown~^~vkBindImageMemory~^~For more information refer to Vulkan Spec Section '11.6. Resource Memory Association' which states 'memoryOffset must be less than the size of memory' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkBindImageMemory)~^~ VALIDATION_ERROR_00806~^~Y~^~Unknown~^~vkBindImageMemory~^~For more information refer to Vulkan Spec Section '11.6. Resource Memory Association' which states 'memory must have been allocated using one of the memory types allowed in the memoryTypeBits member of the VkMemoryRequirements structure returned from a call to vkGetImageMemoryRequirements with image' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkBindImageMemory)~^~ VALIDATION_ERROR_00807~^~Y~^~None~^~vkBindImageMemory~^~For more information refer to Vulkan Spec Section '11.6. Resource Memory Association' which states 'device must be a valid VkDevice handle' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkBindImageMemory)~^~implicit -- 2.7.4