const VkMemoryAllocateInfo *pAllocateInfo) {
assert(object != NULL);
- dev_data->memObjMap[mem] = unique_ptr<DEVICE_MEM_INFO>(new DEVICE_MEM_INFO(object, mem, pAllocateInfo));
-
- if (pAllocateInfo->pNext) {
- auto struct_header = reinterpret_cast<const GENERIC_HEADER *>(pAllocateInfo->pNext);
- while (struct_header) {
- if (VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR == struct_header->sType ||
- VK_STRUCTURE_TYPE_IMPORT_MEMORY_WIN32_HANDLE_INFO_KHR == struct_header->sType) {
- dev_data->memObjMap[mem]->global_valid = true;
- break;
- }
- struct_header = reinterpret_cast<const GENERIC_HEADER *>(struct_header->pNext);
- }
+ auto *mem_info = new DEVICE_MEM_INFO(object, mem, pAllocateInfo);
+ dev_data->memObjMap[mem] = unique_ptr<DEVICE_MEM_INFO>(mem_info);
+
+ // TODO: If the number of things we search for goes much higher, need a map...
+ mem_info->global_valid = nullptr != lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
+#ifdef VK_USE_PLATFORM_WIN32_KHR
+ mem_info->global_valid |= nullptr != lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
+#endif
+
+ auto dedicated = lvl_find_in_chain<VkMemoryDedicatedAllocateInfoKHR>(pAllocateInfo->pNext);
+ if (dedicated) {
+ mem_info->is_dedicated = true;
+ mem_info->dedicated_buffer = dedicated->buffer;
+ mem_info->dedicated_image = dedicated->image;
}
}
}
// Validate bound memory range information
- auto mem_info = GetMemObjInfo(dev_data, mem);
+ const auto mem_info = GetMemObjInfo(dev_data, mem);
if (mem_info) {
skip |= ValidateInsertBufferMemoryRange(dev_data, buffer, mem_info, memoryOffset, buffer_state->requirements, api_name);
skip |= ValidateMemoryTypes(dev_data, mem_info, buffer_state->requirements.memoryTypeBits, api_name,
validation_error_map[VALIDATION_ERROR_17000818]);
}
- // Validate memory requirements size
if (mem_info) {
+ // Validate memory requirements size
if (buffer_state->requirements.size > (mem_info->alloc_info.allocationSize - memoryOffset)) {
skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT,
buffer_handle, __LINE__, VALIDATION_ERROR_1700081a, "DS",
api_name, mem_info->alloc_info.allocationSize - memoryOffset, buffer_state->requirements.size,
validation_error_map[VALIDATION_ERROR_1700081a]);
}
+
+ // Validate dedicated allocation
+ if (mem_info->is_dedicated && ((mem_info->dedicated_buffer != buffer) || (memoryOffset != 0))) {
+ // TODO: Add vkBindBufferMemory2KHR error message when added to spec.
+ auto validation_error = VALIDATION_ERROR_UNDEFINED;
+ const char *validation_error_msg = "";
+ if (strcmp(api_name, "vkBindBufferMemory()") == 0) {
+ validation_error = VALIDATION_ERROR_17000bc8;
+ validation_error_msg = validation_error_map[validation_error];
+ }
+ skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT,
+ buffer_handle, __LINE__, validation_error, "DS",
+ "%s: for dedicated memory allocation 0x%" PRIxLEAST64
+ ", VkMemoryDedicatedAllocateInfoKHR::buffer 0x%" PRIXLEAST64
+ " must be equal to buffer 0x%" PRIxLEAST64 " and memoryOffset 0x%" PRIxLEAST64 " must be zero. %s",
+ api_name, HandleToUint64(mem), HandleToUint64(mem_info->dedicated_buffer), buffer_handle,
+ memoryOffset, validation_error_msg);
+ }
}
// Validate device limits alignments
validation_error_map[VALIDATION_ERROR_17400830]);
}
- // Validate memory requirements size
if (mem_info) {
+ // Validate memory requirements size
if (image_state->requirements.size > mem_info->alloc_info.allocationSize - memoryOffset) {
skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT,
image_handle, __LINE__, VALIDATION_ERROR_17400832, "DS",
api_name, mem_info->alloc_info.allocationSize - memoryOffset, image_state->requirements.size,
validation_error_map[VALIDATION_ERROR_17400832]);
}
+
+ // Validate dedicated allocation
+ if (mem_info->is_dedicated && ((mem_info->dedicated_image != image) || (memoryOffset != 0))) {
+ // TODO: Add vkBindImageMemory2KHR error message when added to spec.
+ auto validation_error = VALIDATION_ERROR_UNDEFINED;
+ const char *validation_error_msg = "";
+ if (strcmp(api_name, "vkBindImageMemory()") == 0) {
+ validation_error = VALIDATION_ERROR_17400bca;
+ validation_error_msg = validation_error_map[validation_error];
+ }
+ skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT,
+ image_handle, __LINE__, validation_error, "DS",
+ "%s: for dedicated memory allocation 0x%" PRIxLEAST64
+ ", VkMemoryDedicatedAllocateInfoKHR::image 0x%" PRIXLEAST64
+ " must be equal to image 0x%" PRIxLEAST64 " and memoryOffset 0x%" PRIxLEAST64 " must be zero. %s",
+ api_name, HandleToUint64(mem), HandleToUint64(mem_info->dedicated_image), image_handle,
+ memoryOffset, validation_error_msg);
+ }
}
}
return skip;
VALIDATION_ERROR_1700081c~^~N~^~Unknown~^~vkBindBufferMemory~^~VUID-vkBindBufferMemory-buffer-01038~^~(VK_NV_dedicated_allocation)~^~The spec valid usage text states 'If buffer was created with VkDedicatedAllocationBufferCreateInfoNV::dedicatedAllocation equal to VK_TRUE, memory must have been created with VkDedicatedAllocationMemoryAllocateInfoNV::buffer equal to a buffer handle created with identical creation parameters to buffer and memoryOffset must be zero' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkBindBufferMemory-buffer-01038)~^~
VALIDATION_ERROR_1700081e~^~N~^~Unknown~^~vkBindBufferMemory~^~VUID-vkBindBufferMemory-buffer-01039~^~(VK_NV_dedicated_allocation)+!(VK_KHR_dedicated_allocation)~^~The spec valid usage text states 'If buffer was not created with VkDedicatedAllocationBufferCreateInfoNV::dedicatedAllocation equal to VK_TRUE, memory must not have been allocated dedicated for a specific buffer or image' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkBindBufferMemory-buffer-01039)~^~
VALIDATION_ERROR_17000b48~^~N~^~None~^~vkBindBufferMemory~^~VUID-vkBindBufferMemory-buffer-01444~^~(VK_KHR_dedicated_allocation)~^~The spec valid usage text states 'If buffer requires a dedicated allocation(as reported by vkGetBufferMemoryRequirements2KHR in VkMemoryDedicatedRequirementsKHR::requiresDedicatedAllocation for image), memory must have been created with VkMemoryDedicatedAllocateInfoKHR::buffer equal to buffer' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkBindBufferMemory-buffer-01444)~^~
-VALIDATION_ERROR_17000bc8~^~N~^~None~^~vkBindBufferMemory~^~VUID-vkBindBufferMemory-memory-01508~^~(VK_KHR_dedicated_allocation)~^~The spec valid usage text states 'If the VkmemoryAllocateInfo provided when memory was allocated included an instance of VkMemoryDedicatedAllocateInfoKHR in its pNext chain, and VkMemoryDedicatedAllocateInfoKHR::buffer was not VK_NULL_HANDLE, then buffer must equal VkMemoryDedicatedAllocateInfoKHR::buffer and memoryOffset must be zero.' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkBindBufferMemory-memory-01508)~^~
+VALIDATION_ERROR_17000bc8~^~Y~^~None~^~vkBindBufferMemory~^~VUID-vkBindBufferMemory-memory-01508~^~(VK_KHR_dedicated_allocation)~^~The spec valid usage text states 'If the VkmemoryAllocateInfo provided when memory was allocated included an instance of VkMemoryDedicatedAllocateInfoKHR in its pNext chain, and VkMemoryDedicatedAllocateInfoKHR::buffer was not VK_NULL_HANDLE, then buffer must equal VkMemoryDedicatedAllocateInfoKHR::buffer and memoryOffset must be zero.' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkBindBufferMemory-memory-01508)~^~
VALIDATION_ERROR_17001a01~^~Y~^~VertexBufferInvalid~^~vkBindBufferMemory~^~VUID-vkBindBufferMemory-buffer-parameter~^~core~^~The spec valid usage text states 'buffer must be a valid VkBuffer handle' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkBindBufferMemory-buffer-parameter)~^~implicit
VALIDATION_ERROR_17001a07~^~Y~^~Unknown~^~vkBindBufferMemory~^~VUID-vkBindBufferMemory-buffer-parent~^~core~^~The spec valid usage text states 'buffer must have been created, allocated, or retrieved from device' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkBindBufferMemory-buffer-parent)~^~implicit
VALIDATION_ERROR_17005601~^~Y~^~None~^~vkBindBufferMemory~^~VUID-vkBindBufferMemory-device-parameter~^~core~^~The spec valid usage text states 'device must be a valid VkDevice handle' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkBindBufferMemory-device-parameter)~^~implicit
VALIDATION_ERROR_17400834~^~N~^~Unknown~^~vkBindImageMemory~^~VUID-vkBindImageMemory-image-01050~^~(VK_NV_dedicated_allocation)~^~The spec valid usage text states 'If image was created with VkDedicatedAllocationImageCreateInfoNV::dedicatedAllocation equal to VK_TRUE, memory must have been created with VkDedicatedAllocationMemoryAllocateInfoNV::image equal to an image handle created with identical creation parameters to image and memoryOffset must be zero' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkBindImageMemory-image-01050)~^~
VALIDATION_ERROR_17400836~^~N~^~Unknown~^~vkBindImageMemory~^~VUID-vkBindImageMemory-image-01051~^~(VK_NV_dedicated_allocation)+!(VK_KHR_dedicated_allocation)~^~The spec valid usage text states 'If image was not created with VkDedicatedAllocationImageCreateInfoNV::dedicatedAllocation equal to VK_TRUE, memory must not have been allocated dedicated for a specific buffer or image' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkBindImageMemory-image-01051)~^~
VALIDATION_ERROR_17400b4a~^~N~^~None~^~vkBindImageMemory~^~VUID-vkBindImageMemory-image-01445~^~(VK_KHR_dedicated_allocation)~^~The spec valid usage text states 'If image requires a dedicated allocation (as reported by vkGetImageMemoryRequirements2KHR in VkMemoryDedicatedRequirementsKHR::requiresDedicatedAllocation for image), memory must have been created with VkMemoryDedicatedAllocateInfoKHR::image equal to image' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkBindImageMemory-image-01445)~^~
-VALIDATION_ERROR_17400bca~^~N~^~None~^~vkBindImageMemory~^~VUID-vkBindImageMemory-memory-01509~^~(VK_KHR_dedicated_allocation)~^~The spec valid usage text states 'If the VkmemoryAllocateInfo provided when memory was allocated included an instance of VkMemoryDedicatedAllocateInfoKHR in its pNext chain, and VkMemoryDedicatedAllocateInfoKHR::image was not VK_NULL_HANDLE, then image must equal VkMemoryDedicatedAllocateInfoKHR::image and memoryOffset must be zero.' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkBindImageMemory-memory-01509)~^~
+VALIDATION_ERROR_17400bca~^~Y~^~None~^~vkBindImageMemory~^~VUID-vkBindImageMemory-memory-01509~^~(VK_KHR_dedicated_allocation)~^~The spec valid usage text states 'If the VkmemoryAllocateInfo provided when memory was allocated included an instance of VkMemoryDedicatedAllocateInfoKHR in its pNext chain, and VkMemoryDedicatedAllocateInfoKHR::image was not VK_NULL_HANDLE, then image must equal VkMemoryDedicatedAllocateInfoKHR::image and memoryOffset must be zero.' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkBindImageMemory-memory-01509)~^~
VALIDATION_ERROR_17400c90~^~N~^~None~^~vkBindImageMemory~^~VUID-vkBindImageMemory-image-01608~^~(VK_KHR_sampler_ycbcr_conversion)~^~The spec valid usage text states 'image must not have been created with the VK_IMAGE_CREATE_DISJOINT_BIT_KHR set.' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkBindImageMemory-image-01608)~^~
VALIDATION_ERROR_17405601~^~Y~^~None~^~vkBindImageMemory~^~VUID-vkBindImageMemory-device-parameter~^~core~^~The spec valid usage text states 'device must be a valid VkDevice handle' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkBindImageMemory-device-parameter)~^~implicit
VALIDATION_ERROR_1740a001~^~Y~^~BindMemoryToDestroyedObject~^~vkBindImageMemory~^~VUID-vkBindImageMemory-image-parameter~^~core~^~The spec valid usage text states 'image must be a valid VkImage handle' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkBindImageMemory-image-parameter)~^~implicit