From 21a9545f151c15d6f413d98eaf5411f2fd8074b0 Mon Sep 17 00:00:00 2001 From: Mark Lobodzinski Date: Mon, 6 Feb 2017 15:44:49 -0700 Subject: [PATCH] layers: Move GetImageSubresourceLayout to CV Moved the validation routine from the image layer into the core validation layer. Change-Id: Ic2402de60934356d6582c3c938bba8695336ba83 --- layers/core_validation.cpp | 39 +++++++++++++++++++++++++++++++++++++++ layers/image.cpp | 39 --------------------------------------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 7ffff87..5e98b81 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -8425,6 +8425,44 @@ VKAPI_ATTR void VKAPI_CALL CmdResolveImage(VkCommandBuffer commandBuffer, VkImag } } +VKAPI_ATTR void VKAPI_CALL GetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubresource *pSubresource, + VkSubresourceLayout *pLayout) { + bool skipCall = false; + layer_data *device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); + VkFormat format; + + auto imageEntry = getImageState(device_data, image); + + // Validate that image aspects match formats + if (imageEntry) { + format = imageEntry->createInfo.format; + if (vk_format_is_color(format)) { + if (pSubresource->aspectMask != VK_IMAGE_ASPECT_COLOR_BIT) { + std::stringstream ss; + ss << "vkGetImageSubresourceLayout: For color formats, the aspectMask field of VkImageSubresource must be " + "VK_IMAGE_ASPECT_COLOR."; + skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, + (uint64_t)image, __LINE__, VALIDATION_ERROR_00741, "IMAGE", "%s. %s", ss.str().c_str(), + validation_error_map[VALIDATION_ERROR_00741]); + } + } else if (vk_format_is_depth_or_stencil(format)) { + if ((pSubresource->aspectMask != VK_IMAGE_ASPECT_DEPTH_BIT) && + (pSubresource->aspectMask != VK_IMAGE_ASPECT_STENCIL_BIT)) { + std::stringstream ss; + ss << "vkGetImageSubresourceLayout: For depth/stencil formats, the aspectMask selects either the depth or stencil " + "image aspectMask."; + skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, + (uint64_t)image, __LINE__, VALIDATION_ERROR_00741, "IMAGE", "%s. %s", ss.str().c_str(), + validation_error_map[VALIDATION_ERROR_00741]); + } + } + } + + if (!skipCall) { + device_data->dispatch_table.GetImageSubresourceLayout(device, image, pSubresource, pLayout); + } +} + bool setEventStageMask(VkQueue queue, VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask) { layer_data *dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); GLOBAL_CB_NODE *pCB = getCBNode(dev_data, commandBuffer); @@ -12325,6 +12363,7 @@ static PFN_vkVoidFunction intercept_core_device_command(const char *name) { {"vkCmdClearDepthStencilImage", reinterpret_cast(CmdClearDepthStencilImage)}, {"vkCmdClearAttachments", reinterpret_cast(CmdClearAttachments)}, {"vkCmdResolveImage", reinterpret_cast(CmdResolveImage)}, + {"vkGetImageSubresourceLayout", reinterpret_cast(GetImageSubresourceLayout) }, {"vkCmdSetEvent", reinterpret_cast(CmdSetEvent)}, {"vkCmdResetEvent", reinterpret_cast(CmdResetEvent)}, {"vkCmdWaitEvents", reinterpret_cast(CmdWaitEvents)}, diff --git a/layers/image.cpp b/layers/image.cpp index 4fe04d2..31a28e2 100644 --- a/layers/image.cpp +++ b/layers/image.cpp @@ -344,44 +344,6 @@ VKAPI_ATTR void VKAPI_CALL CmdCopyBufferToImage(VkCommandBuffer commandBuffer, V } } -VKAPI_ATTR void VKAPI_CALL GetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubresource *pSubresource, - VkSubresourceLayout *pLayout) { - bool skipCall = false; - layer_data *device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); - VkFormat format; - - auto imageEntry = getImageState(device_data, image); - - // Validate that image aspects match formats - if (imageEntry) { - format = imageEntry->format; - if (vk_format_is_color(format)) { - if (pSubresource->aspectMask != VK_IMAGE_ASPECT_COLOR_BIT) { - std::stringstream ss; - ss << "vkGetImageSubresourceLayout: For color formats, the aspectMask field of VkImageSubresource must be " - "VK_IMAGE_ASPECT_COLOR."; - skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, - (uint64_t)image, __LINE__, VALIDATION_ERROR_00741, "IMAGE", "%s. %s", ss.str().c_str(), - validation_error_map[VALIDATION_ERROR_00741]); - } - } else if (vk_format_is_depth_or_stencil(format)) { - if ((pSubresource->aspectMask != VK_IMAGE_ASPECT_DEPTH_BIT) && - (pSubresource->aspectMask != VK_IMAGE_ASPECT_STENCIL_BIT)) { - std::stringstream ss; - ss << "vkGetImageSubresourceLayout: For depth/stencil formats, the aspectMask selects either the depth or stencil " - "image aspectMask."; - skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, - (uint64_t)image, __LINE__, VALIDATION_ERROR_00741, "IMAGE", "%s. %s", ss.str().c_str(), - validation_error_map[VALIDATION_ERROR_00741]); - } - } - } - - if (!skipCall) { - device_data->device_dispatch_table->GetImageSubresourceLayout(device, image, pSubresource, pLayout); - } -} - VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties *pProperties) { layer_data *phy_dev_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); phy_dev_data->instance_dispatch_table->GetPhysicalDeviceProperties(physicalDevice, pProperties); @@ -496,7 +458,6 @@ static PFN_vkVoidFunction intercept_core_device_command(const char *name) { {"vkDestroyImage", reinterpret_cast(DestroyImage)}, {"vkCmdCopyImageToBuffer", reinterpret_cast(CmdCopyImageToBuffer)}, {"vkCmdCopyBufferToImage", reinterpret_cast(CmdCopyBufferToImage)}, - {"vkGetImageSubresourceLayout", reinterpret_cast(GetImageSubresourceLayout)}, }; for (size_t i = 0; i < ARRAY_SIZE(core_device_commands); i++) { -- 2.7.4