Mark Lobodzinski | d42e4d2 | 2017-01-17 14:14:22 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2015-2017 The Khronos Group Inc. |
| 2 | * Copyright (c) 2015-2017 Valve Corporation |
| 3 | * Copyright (c) 2015-2017 LunarG, Inc. |
| 4 | * Copyright (C) 2015-2017 Google Inc. |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | * |
| 18 | * Author: Mark Lobodzinski <mark@lunarg.com> |
Dave Houlton | 4eaaf3a | 2017-03-14 11:31:20 -0600 | [diff] [blame] | 19 | * Author: Dave Houlton <daveh@lunarg.com> |
Mark Lobodzinski | d42e4d2 | 2017-01-17 14:14:22 -0700 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | // Allow use of STL min and max functions in Windows |
| 23 | #define NOMINMAX |
| 24 | |
Mark Lobodzinski | 90224de | 2017-01-26 15:23:11 -0700 | [diff] [blame] | 25 | #include <sstream> |
Petr Kraus | 4d71868 | 2017-05-18 03:38:41 +0200 | [diff] [blame] | 26 | #include <string> |
Mark Lobodzinski | 90224de | 2017-01-26 15:23:11 -0700 | [diff] [blame] | 27 | |
| 28 | #include "vk_enum_string_helper.h" |
| 29 | #include "vk_layer_data.h" |
| 30 | #include "vk_layer_utils.h" |
| 31 | #include "vk_layer_logging.h" |
Dave Houlton | bd2e262 | 2018-04-10 16:41:14 -0600 | [diff] [blame] | 32 | #include "vk_typemap_helper.h" |
Mark Lobodzinski | 90224de | 2017-01-26 15:23:11 -0700 | [diff] [blame] | 33 | |
Mark Lobodzinski | d42e4d2 | 2017-01-17 14:14:22 -0700 | [diff] [blame] | 34 | #include "buffer_validation.h" |
Mark Lobodzinski | 42fe5f7 | 2017-01-11 11:36:16 -0700 | [diff] [blame] | 35 | |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 36 | void SetLayout(layer_data *device_data, GLOBAL_CB_NODE *pCB, ImageSubresourcePair imgpair, const VkImageLayout &layout) { |
Dave Houlton | b3f4b28 | 2018-02-22 16:25:16 -0700 | [diff] [blame] | 37 | auto it = pCB->imageLayoutMap.find(imgpair); |
| 38 | if (it != pCB->imageLayoutMap.end()) { |
| 39 | it->second.layout = layout; |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 40 | } else { |
| 41 | assert(imgpair.hasSubresource); |
| 42 | IMAGE_CMD_BUF_LAYOUT_NODE node; |
| 43 | if (!FindCmdBufLayout(device_data, pCB, imgpair.image, imgpair.subresource, node)) { |
| 44 | node.initialLayout = layout; |
| 45 | } |
| 46 | SetLayout(device_data, pCB, imgpair, {node.initialLayout, layout}); |
| 47 | } |
| 48 | } |
| 49 | template <class OBJECT, class LAYOUT> |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 50 | void SetLayout(layer_data *device_data, OBJECT *pObject, VkImage image, VkImageSubresource range, const LAYOUT &layout) { |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 51 | ImageSubresourcePair imgpair = {image, true, range}; |
| 52 | SetLayout(device_data, pObject, imgpair, layout, VK_IMAGE_ASPECT_COLOR_BIT); |
| 53 | SetLayout(device_data, pObject, imgpair, layout, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 54 | SetLayout(device_data, pObject, imgpair, layout, VK_IMAGE_ASPECT_STENCIL_BIT); |
| 55 | SetLayout(device_data, pObject, imgpair, layout, VK_IMAGE_ASPECT_METADATA_BIT); |
Dave Houlton | b3f4b28 | 2018-02-22 16:25:16 -0700 | [diff] [blame] | 56 | if (GetDeviceExtensions(device_data)->vk_khr_sampler_ycbcr_conversion) { |
| 57 | SetLayout(device_data, pObject, imgpair, layout, VK_IMAGE_ASPECT_PLANE_0_BIT_KHR); |
| 58 | SetLayout(device_data, pObject, imgpair, layout, VK_IMAGE_ASPECT_PLANE_1_BIT_KHR); |
| 59 | SetLayout(device_data, pObject, imgpair, layout, VK_IMAGE_ASPECT_PLANE_2_BIT_KHR); |
| 60 | } |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | template <class OBJECT, class LAYOUT> |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 64 | void SetLayout(layer_data *device_data, OBJECT *pObject, ImageSubresourcePair imgpair, const LAYOUT &layout, |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 65 | VkImageAspectFlags aspectMask) { |
| 66 | if (imgpair.subresource.aspectMask & aspectMask) { |
| 67 | imgpair.subresource.aspectMask = aspectMask; |
| 68 | SetLayout(device_data, pObject, imgpair, layout); |
| 69 | } |
| 70 | } |
| 71 | |
Tony Barbour | df013b9 | 2017-01-25 12:53:48 -0700 | [diff] [blame] | 72 | // Set the layout in supplied map |
Tony Barbour | e0c5cc9 | 2017-02-08 13:53:39 -0700 | [diff] [blame] | 73 | void SetLayout(std::unordered_map<ImageSubresourcePair, IMAGE_LAYOUT_NODE> &imageLayoutMap, ImageSubresourcePair imgpair, |
| 74 | VkImageLayout layout) { |
Dave Houlton | b3f4b28 | 2018-02-22 16:25:16 -0700 | [diff] [blame] | 75 | auto it = imageLayoutMap.find(imgpair); |
| 76 | if (it != imageLayoutMap.end()) { |
| 77 | it->second.layout = layout; // Update |
| 78 | } else { |
| 79 | imageLayoutMap[imgpair].layout = layout; // Insert |
| 80 | } |
Tony Barbour | df013b9 | 2017-01-25 12:53:48 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Tobin Ehlis | c826645 | 2017-04-07 12:20:30 -0600 | [diff] [blame] | 83 | bool FindLayoutVerifyNode(layer_data const *device_data, GLOBAL_CB_NODE const *pCB, ImageSubresourcePair imgpair, |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 84 | IMAGE_CMD_BUF_LAYOUT_NODE &node, const VkImageAspectFlags aspectMask) { |
| 85 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
| 86 | |
| 87 | if (!(imgpair.subresource.aspectMask & aspectMask)) { |
| 88 | return false; |
| 89 | } |
| 90 | VkImageAspectFlags oldAspectMask = imgpair.subresource.aspectMask; |
| 91 | imgpair.subresource.aspectMask = aspectMask; |
| 92 | auto imgsubIt = pCB->imageLayoutMap.find(imgpair); |
| 93 | if (imgsubIt == pCB->imageLayoutMap.end()) { |
| 94 | return false; |
| 95 | } |
| 96 | if (node.layout != VK_IMAGE_LAYOUT_MAX_ENUM && node.layout != imgsubIt->second.layout) { |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 97 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, HandleToUint64(imgpair.image), |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 98 | DRAWSTATE_INVALID_LAYOUT, |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 99 | "Cannot query for VkImage 0x%" PRIx64 " layout when combined aspect mask %d has multiple layout types: %s and %s", |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 100 | HandleToUint64(imgpair.image), oldAspectMask, string_VkImageLayout(node.layout), |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 101 | string_VkImageLayout(imgsubIt->second.layout)); |
| 102 | } |
| 103 | if (node.initialLayout != VK_IMAGE_LAYOUT_MAX_ENUM && node.initialLayout != imgsubIt->second.initialLayout) { |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 104 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, HandleToUint64(imgpair.image), |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 105 | DRAWSTATE_INVALID_LAYOUT, |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 106 | "Cannot query for VkImage 0x%" PRIx64 |
| 107 | " layout when combined aspect mask %d has multiple initial layout types: %s and %s", |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 108 | HandleToUint64(imgpair.image), oldAspectMask, string_VkImageLayout(node.initialLayout), |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 109 | string_VkImageLayout(imgsubIt->second.initialLayout)); |
| 110 | } |
| 111 | node = imgsubIt->second; |
| 112 | return true; |
| 113 | } |
| 114 | |
Tobin Ehlis | c826645 | 2017-04-07 12:20:30 -0600 | [diff] [blame] | 115 | bool FindLayoutVerifyLayout(layer_data const *device_data, ImageSubresourcePair imgpair, VkImageLayout &layout, |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 116 | const VkImageAspectFlags aspectMask) { |
| 117 | if (!(imgpair.subresource.aspectMask & aspectMask)) { |
| 118 | return false; |
| 119 | } |
| 120 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
| 121 | VkImageAspectFlags oldAspectMask = imgpair.subresource.aspectMask; |
| 122 | imgpair.subresource.aspectMask = aspectMask; |
| 123 | auto imgsubIt = (*core_validation::GetImageLayoutMap(device_data)).find(imgpair); |
| 124 | if (imgsubIt == (*core_validation::GetImageLayoutMap(device_data)).end()) { |
| 125 | return false; |
| 126 | } |
| 127 | if (layout != VK_IMAGE_LAYOUT_MAX_ENUM && layout != imgsubIt->second.layout) { |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 128 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, HandleToUint64(imgpair.image), |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 129 | DRAWSTATE_INVALID_LAYOUT, |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 130 | "Cannot query for VkImage 0x%" PRIx64 " layout when combined aspect mask %d has multiple layout types: %s and %s", |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 131 | HandleToUint64(imgpair.image), oldAspectMask, string_VkImageLayout(layout), |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 132 | string_VkImageLayout(imgsubIt->second.layout)); |
| 133 | } |
| 134 | layout = imgsubIt->second.layout; |
| 135 | return true; |
| 136 | } |
| 137 | |
| 138 | // Find layout(s) on the command buffer level |
Tobin Ehlis | c826645 | 2017-04-07 12:20:30 -0600 | [diff] [blame] | 139 | bool FindCmdBufLayout(layer_data const *device_data, GLOBAL_CB_NODE const *pCB, VkImage image, VkImageSubresource range, |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 140 | IMAGE_CMD_BUF_LAYOUT_NODE &node) { |
| 141 | ImageSubresourcePair imgpair = {image, true, range}; |
| 142 | node = IMAGE_CMD_BUF_LAYOUT_NODE(VK_IMAGE_LAYOUT_MAX_ENUM, VK_IMAGE_LAYOUT_MAX_ENUM); |
| 143 | FindLayoutVerifyNode(device_data, pCB, imgpair, node, VK_IMAGE_ASPECT_COLOR_BIT); |
| 144 | FindLayoutVerifyNode(device_data, pCB, imgpair, node, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 145 | FindLayoutVerifyNode(device_data, pCB, imgpair, node, VK_IMAGE_ASPECT_STENCIL_BIT); |
| 146 | FindLayoutVerifyNode(device_data, pCB, imgpair, node, VK_IMAGE_ASPECT_METADATA_BIT); |
Dave Houlton | b3f4b28 | 2018-02-22 16:25:16 -0700 | [diff] [blame] | 147 | if (GetDeviceExtensions(device_data)->vk_khr_sampler_ycbcr_conversion) { |
| 148 | FindLayoutVerifyNode(device_data, pCB, imgpair, node, VK_IMAGE_ASPECT_PLANE_0_BIT_KHR); |
| 149 | FindLayoutVerifyNode(device_data, pCB, imgpair, node, VK_IMAGE_ASPECT_PLANE_1_BIT_KHR); |
| 150 | FindLayoutVerifyNode(device_data, pCB, imgpair, node, VK_IMAGE_ASPECT_PLANE_2_BIT_KHR); |
| 151 | } |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 152 | if (node.layout == VK_IMAGE_LAYOUT_MAX_ENUM) { |
| 153 | imgpair = {image, false, VkImageSubresource()}; |
| 154 | auto imgsubIt = pCB->imageLayoutMap.find(imgpair); |
| 155 | if (imgsubIt == pCB->imageLayoutMap.end()) return false; |
| 156 | // TODO: This is ostensibly a find function but it changes state here |
| 157 | node = imgsubIt->second; |
| 158 | } |
| 159 | return true; |
| 160 | } |
| 161 | |
| 162 | // Find layout(s) on the global level |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 163 | bool FindGlobalLayout(layer_data *device_data, ImageSubresourcePair imgpair, VkImageLayout &layout) { |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 164 | layout = VK_IMAGE_LAYOUT_MAX_ENUM; |
| 165 | FindLayoutVerifyLayout(device_data, imgpair, layout, VK_IMAGE_ASPECT_COLOR_BIT); |
| 166 | FindLayoutVerifyLayout(device_data, imgpair, layout, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 167 | FindLayoutVerifyLayout(device_data, imgpair, layout, VK_IMAGE_ASPECT_STENCIL_BIT); |
| 168 | FindLayoutVerifyLayout(device_data, imgpair, layout, VK_IMAGE_ASPECT_METADATA_BIT); |
Dave Houlton | b3f4b28 | 2018-02-22 16:25:16 -0700 | [diff] [blame] | 169 | if (GetDeviceExtensions(device_data)->vk_khr_sampler_ycbcr_conversion) { |
| 170 | FindLayoutVerifyLayout(device_data, imgpair, layout, VK_IMAGE_ASPECT_PLANE_0_BIT_KHR); |
| 171 | FindLayoutVerifyLayout(device_data, imgpair, layout, VK_IMAGE_ASPECT_PLANE_1_BIT_KHR); |
| 172 | FindLayoutVerifyLayout(device_data, imgpair, layout, VK_IMAGE_ASPECT_PLANE_2_BIT_KHR); |
| 173 | } |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 174 | if (layout == VK_IMAGE_LAYOUT_MAX_ENUM) { |
| 175 | imgpair = {imgpair.image, false, VkImageSubresource()}; |
| 176 | auto imgsubIt = (*core_validation::GetImageLayoutMap(device_data)).find(imgpair); |
| 177 | if (imgsubIt == (*core_validation::GetImageLayoutMap(device_data)).end()) return false; |
| 178 | layout = imgsubIt->second.layout; |
| 179 | } |
| 180 | return true; |
| 181 | } |
| 182 | |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 183 | bool FindLayouts(layer_data *device_data, VkImage image, std::vector<VkImageLayout> &layouts) { |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 184 | auto sub_data = (*core_validation::GetImageSubresourceMap(device_data)).find(image); |
| 185 | if (sub_data == (*core_validation::GetImageSubresourceMap(device_data)).end()) return false; |
Tobin Ehlis | b2e1e2c | 2017-02-08 09:16:32 -0700 | [diff] [blame] | 186 | auto image_state = GetImageState(device_data, image); |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 187 | if (!image_state) return false; |
| 188 | bool ignoreGlobal = false; |
| 189 | // TODO: Make this robust for >1 aspect mask. Now it will just say ignore potential errors in this case. |
| 190 | if (sub_data->second.size() >= (image_state->createInfo.arrayLayers * image_state->createInfo.mipLevels + 1)) { |
| 191 | ignoreGlobal = true; |
| 192 | } |
| 193 | for (auto imgsubpair : sub_data->second) { |
| 194 | if (ignoreGlobal && !imgsubpair.hasSubresource) continue; |
| 195 | auto img_data = (*core_validation::GetImageLayoutMap(device_data)).find(imgsubpair); |
| 196 | if (img_data != (*core_validation::GetImageLayoutMap(device_data)).end()) { |
| 197 | layouts.push_back(img_data->second.layout); |
| 198 | } |
| 199 | } |
| 200 | return true; |
| 201 | } |
Tony Barbour | e0c5cc9 | 2017-02-08 13:53:39 -0700 | [diff] [blame] | 202 | bool FindLayout(const std::unordered_map<ImageSubresourcePair, IMAGE_LAYOUT_NODE> &imageLayoutMap, ImageSubresourcePair imgpair, |
| 203 | VkImageLayout &layout, const VkImageAspectFlags aspectMask) { |
Tony Barbour | df013b9 | 2017-01-25 12:53:48 -0700 | [diff] [blame] | 204 | if (!(imgpair.subresource.aspectMask & aspectMask)) { |
| 205 | return false; |
| 206 | } |
| 207 | imgpair.subresource.aspectMask = aspectMask; |
| 208 | auto imgsubIt = imageLayoutMap.find(imgpair); |
| 209 | if (imgsubIt == imageLayoutMap.end()) { |
| 210 | return false; |
| 211 | } |
| 212 | layout = imgsubIt->second.layout; |
| 213 | return true; |
Tony Barbour | e0c5cc9 | 2017-02-08 13:53:39 -0700 | [diff] [blame] | 214 | } |
Tony Barbour | df013b9 | 2017-01-25 12:53:48 -0700 | [diff] [blame] | 215 | |
| 216 | // find layout in supplied map |
Dave Houlton | b3f4b28 | 2018-02-22 16:25:16 -0700 | [diff] [blame] | 217 | bool FindLayout(layer_data *device_data, const std::unordered_map<ImageSubresourcePair, IMAGE_LAYOUT_NODE> &imageLayoutMap, |
| 218 | ImageSubresourcePair imgpair, VkImageLayout &layout) { |
Tony Barbour | df013b9 | 2017-01-25 12:53:48 -0700 | [diff] [blame] | 219 | layout = VK_IMAGE_LAYOUT_MAX_ENUM; |
| 220 | FindLayout(imageLayoutMap, imgpair, layout, VK_IMAGE_ASPECT_COLOR_BIT); |
| 221 | FindLayout(imageLayoutMap, imgpair, layout, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 222 | FindLayout(imageLayoutMap, imgpair, layout, VK_IMAGE_ASPECT_STENCIL_BIT); |
| 223 | FindLayout(imageLayoutMap, imgpair, layout, VK_IMAGE_ASPECT_METADATA_BIT); |
Dave Houlton | b3f4b28 | 2018-02-22 16:25:16 -0700 | [diff] [blame] | 224 | if (GetDeviceExtensions(device_data)->vk_khr_sampler_ycbcr_conversion) { |
| 225 | FindLayout(imageLayoutMap, imgpair, layout, VK_IMAGE_ASPECT_PLANE_0_BIT_KHR); |
| 226 | FindLayout(imageLayoutMap, imgpair, layout, VK_IMAGE_ASPECT_PLANE_1_BIT_KHR); |
| 227 | FindLayout(imageLayoutMap, imgpair, layout, VK_IMAGE_ASPECT_PLANE_2_BIT_KHR); |
| 228 | } |
| 229 | // Image+subresource not found, look for image handle w/o subresource |
Tony Barbour | df013b9 | 2017-01-25 12:53:48 -0700 | [diff] [blame] | 230 | if (layout == VK_IMAGE_LAYOUT_MAX_ENUM) { |
| 231 | imgpair = {imgpair.image, false, VkImageSubresource()}; |
| 232 | auto imgsubIt = imageLayoutMap.find(imgpair); |
| 233 | if (imgsubIt == imageLayoutMap.end()) return false; |
| 234 | layout = imgsubIt->second.layout; |
| 235 | } |
| 236 | return true; |
| 237 | } |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 238 | |
| 239 | // Set the layout on the global level |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 240 | void SetGlobalLayout(layer_data *device_data, ImageSubresourcePair imgpair, const VkImageLayout &layout) { |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 241 | VkImage &image = imgpair.image; |
Dave Houlton | b3f4b28 | 2018-02-22 16:25:16 -0700 | [diff] [blame] | 242 | auto &lmap = (*core_validation::GetImageLayoutMap(device_data)); |
| 243 | auto data = lmap.find(imgpair); |
| 244 | if (data != lmap.end()) { |
| 245 | data->second.layout = layout; // Update |
| 246 | } else { |
| 247 | lmap[imgpair].layout = layout; // Insert |
| 248 | } |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 249 | auto &image_subresources = (*core_validation::GetImageSubresourceMap(device_data))[image]; |
| 250 | auto subresource = std::find(image_subresources.begin(), image_subresources.end(), imgpair); |
| 251 | if (subresource == image_subresources.end()) { |
| 252 | image_subresources.push_back(imgpair); |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | // Set the layout on the cmdbuf level |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 257 | void SetLayout(layer_data *device_data, GLOBAL_CB_NODE *pCB, ImageSubresourcePair imgpair, const IMAGE_CMD_BUF_LAYOUT_NODE &node) { |
Dave Houlton | b3f4b28 | 2018-02-22 16:25:16 -0700 | [diff] [blame] | 258 | auto it = pCB->imageLayoutMap.find(imgpair); |
| 259 | if (it != pCB->imageLayoutMap.end()) { |
| 260 | it->second = node; // Update |
| 261 | } else { |
| 262 | pCB->imageLayoutMap[imgpair] = node; // Insert |
| 263 | } |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 264 | } |
Tobin Ehlis | e35b66a | 2017-03-15 12:18:31 -0600 | [diff] [blame] | 265 | // Set image layout for given VkImageSubresourceRange struct |
| 266 | void SetImageLayout(layer_data *device_data, GLOBAL_CB_NODE *cb_node, const IMAGE_STATE *image_state, |
| 267 | VkImageSubresourceRange image_subresource_range, const VkImageLayout &layout) { |
| 268 | assert(image_state); |
John Zulauf | 48a6a70 | 2017-12-22 17:14:54 -0700 | [diff] [blame] | 269 | cb_node->image_layout_change_count++; // Change the version of this data to force revalidation |
Tobin Ehlis | e35b66a | 2017-03-15 12:18:31 -0600 | [diff] [blame] | 270 | for (uint32_t level_index = 0; level_index < image_subresource_range.levelCount; ++level_index) { |
| 271 | uint32_t level = image_subresource_range.baseMipLevel + level_index; |
| 272 | for (uint32_t layer_index = 0; layer_index < image_subresource_range.layerCount; layer_index++) { |
| 273 | uint32_t layer = image_subresource_range.baseArrayLayer + layer_index; |
| 274 | VkImageSubresource sub = {image_subresource_range.aspectMask, level, layer}; |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 275 | // TODO: If ImageView was created with depth or stencil, transition both layouts as the aspectMask is ignored and both |
| 276 | // are used. Verify that the extra implicit layout is OK for descriptor set layout validation |
Tobin Ehlis | e35b66a | 2017-03-15 12:18:31 -0600 | [diff] [blame] | 277 | if (image_subresource_range.aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) { |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 278 | if (FormatIsDepthAndStencil(image_state->createInfo.format)) { |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 279 | sub.aspectMask |= (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT); |
| 280 | } |
| 281 | } |
Tobin Ehlis | e35b66a | 2017-03-15 12:18:31 -0600 | [diff] [blame] | 282 | SetLayout(device_data, cb_node, image_state->image, sub, layout); |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 283 | } |
| 284 | } |
| 285 | } |
Tobin Ehlis | e35b66a | 2017-03-15 12:18:31 -0600 | [diff] [blame] | 286 | // Set image layout for given VkImageSubresourceLayers struct |
| 287 | void SetImageLayout(layer_data *device_data, GLOBAL_CB_NODE *cb_node, const IMAGE_STATE *image_state, |
| 288 | VkImageSubresourceLayers image_subresource_layers, const VkImageLayout &layout) { |
| 289 | // Transfer VkImageSubresourceLayers into VkImageSubresourceRange struct |
| 290 | VkImageSubresourceRange image_subresource_range; |
| 291 | image_subresource_range.aspectMask = image_subresource_layers.aspectMask; |
| 292 | image_subresource_range.baseArrayLayer = image_subresource_layers.baseArrayLayer; |
| 293 | image_subresource_range.layerCount = image_subresource_layers.layerCount; |
| 294 | image_subresource_range.baseMipLevel = image_subresource_layers.mipLevel; |
| 295 | image_subresource_range.levelCount = 1; |
| 296 | SetImageLayout(device_data, cb_node, image_state, image_subresource_range, layout); |
| 297 | } |
| 298 | // Set image layout for all slices of an image view |
| 299 | void SetImageViewLayout(layer_data *device_data, GLOBAL_CB_NODE *cb_node, VkImageView imageView, const VkImageLayout &layout) { |
| 300 | auto view_state = GetImageViewState(device_data, imageView); |
| 301 | assert(view_state); |
| 302 | |
| 303 | SetImageLayout(device_data, cb_node, GetImageState(device_data, view_state->create_info.image), |
| 304 | view_state->create_info.subresourceRange, layout); |
| 305 | } |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 306 | |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 307 | bool VerifyFramebufferAndRenderPassLayouts(layer_data *device_data, GLOBAL_CB_NODE *pCB, |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 308 | const VkRenderPassBeginInfo *pRenderPassBegin, |
| 309 | const FRAMEBUFFER_STATE *framebuffer_state) { |
Mark Lobodzinski | bdc3b02 | 2017-04-24 09:11:35 -0600 | [diff] [blame] | 310 | bool skip = false; |
Tobin Ehlis | b2e1e2c | 2017-02-08 09:16:32 -0700 | [diff] [blame] | 311 | auto const pRenderPassInfo = GetRenderPassState(device_data, pRenderPassBegin->renderPass)->createInfo.ptr(); |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 312 | auto const &framebufferInfo = framebuffer_state->createInfo; |
| 313 | const auto report_data = core_validation::GetReportData(device_data); |
| 314 | if (pRenderPassInfo->attachmentCount != framebufferInfo.attachmentCount) { |
Mark Lobodzinski | bdc3b02 | 2017-04-24 09:11:35 -0600 | [diff] [blame] | 315 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 316 | HandleToUint64(pCB->commandBuffer), DRAWSTATE_INVALID_RENDERPASS, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 317 | "You cannot start a render pass using a framebuffer with a different number of attachments."); |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 318 | } |
| 319 | for (uint32_t i = 0; i < pRenderPassInfo->attachmentCount; ++i) { |
| 320 | const VkImageView &image_view = framebufferInfo.pAttachments[i]; |
Tobin Ehlis | b2e1e2c | 2017-02-08 09:16:32 -0700 | [diff] [blame] | 321 | auto view_state = GetImageViewState(device_data, image_view); |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 322 | assert(view_state); |
| 323 | const VkImage &image = view_state->create_info.image; |
| 324 | const VkImageSubresourceRange &subRange = view_state->create_info.subresourceRange; |
Tobin Ehlis | 0d4274b | 2017-02-17 15:17:04 -0700 | [diff] [blame] | 325 | auto initial_layout = pRenderPassInfo->pAttachments[i].initialLayout; |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 326 | // TODO: Do not iterate over every possibility - consolidate where possible |
| 327 | for (uint32_t j = 0; j < subRange.levelCount; j++) { |
| 328 | uint32_t level = subRange.baseMipLevel + j; |
| 329 | for (uint32_t k = 0; k < subRange.layerCount; k++) { |
| 330 | uint32_t layer = subRange.baseArrayLayer + k; |
| 331 | VkImageSubresource sub = {subRange.aspectMask, level, layer}; |
| 332 | IMAGE_CMD_BUF_LAYOUT_NODE node; |
| 333 | if (!FindCmdBufLayout(device_data, pCB, image, sub, node)) { |
Tobin Ehlis | 0d4274b | 2017-02-17 15:17:04 -0700 | [diff] [blame] | 334 | // Missing layouts will be added during state update |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 335 | continue; |
| 336 | } |
Tobin Ehlis | 0d4274b | 2017-02-17 15:17:04 -0700 | [diff] [blame] | 337 | if (initial_layout != VK_IMAGE_LAYOUT_UNDEFINED && initial_layout != node.layout) { |
Mark Lobodzinski | bdc3b02 | 2017-04-24 09:11:35 -0600 | [diff] [blame] | 338 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 339 | DRAWSTATE_INVALID_RENDERPASS, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 340 | "You cannot start a render pass using attachment %u where the render pass initial layout is %s " |
| 341 | "and the previous known layout of the attachment is %s. The layouts must match, or the render " |
| 342 | "pass initial layout for the attachment must be VK_IMAGE_LAYOUT_UNDEFINED", |
Mark Lobodzinski | bdc3b02 | 2017-04-24 09:11:35 -0600 | [diff] [blame] | 343 | i, string_VkImageLayout(initial_layout), string_VkImageLayout(node.layout)); |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 344 | } |
| 345 | } |
| 346 | } |
| 347 | } |
Mark Lobodzinski | bdc3b02 | 2017-04-24 09:11:35 -0600 | [diff] [blame] | 348 | return skip; |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 349 | } |
| 350 | |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 351 | void TransitionAttachmentRefLayout(layer_data *device_data, GLOBAL_CB_NODE *pCB, FRAMEBUFFER_STATE *pFramebuffer, |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 352 | VkAttachmentReference ref) { |
| 353 | if (ref.attachment != VK_ATTACHMENT_UNUSED) { |
| 354 | auto image_view = pFramebuffer->createInfo.pAttachments[ref.attachment]; |
| 355 | SetImageViewLayout(device_data, pCB, image_view, ref.layout); |
| 356 | } |
| 357 | } |
| 358 | |
Tobin Ehlis | 0d4274b | 2017-02-17 15:17:04 -0700 | [diff] [blame] | 359 | void TransitionSubpassLayouts(layer_data *device_data, GLOBAL_CB_NODE *pCB, const RENDER_PASS_STATE *render_pass_state, |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 360 | const int subpass_index, FRAMEBUFFER_STATE *framebuffer_state) { |
Tobin Ehlis | 0d4274b | 2017-02-17 15:17:04 -0700 | [diff] [blame] | 361 | assert(render_pass_state); |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 362 | |
| 363 | if (framebuffer_state) { |
Tobin Ehlis | 0d4274b | 2017-02-17 15:17:04 -0700 | [diff] [blame] | 364 | auto const &subpass = render_pass_state->createInfo.pSubpasses[subpass_index]; |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 365 | for (uint32_t j = 0; j < subpass.inputAttachmentCount; ++j) { |
| 366 | TransitionAttachmentRefLayout(device_data, pCB, framebuffer_state, subpass.pInputAttachments[j]); |
| 367 | } |
| 368 | for (uint32_t j = 0; j < subpass.colorAttachmentCount; ++j) { |
| 369 | TransitionAttachmentRefLayout(device_data, pCB, framebuffer_state, subpass.pColorAttachments[j]); |
| 370 | } |
| 371 | if (subpass.pDepthStencilAttachment) { |
| 372 | TransitionAttachmentRefLayout(device_data, pCB, framebuffer_state, *subpass.pDepthStencilAttachment); |
| 373 | } |
| 374 | } |
| 375 | } |
| 376 | |
Tobin Ehlis | 9c0df96 | 2017-07-17 10:14:27 -0600 | [diff] [blame] | 377 | bool ValidateImageAspectLayout(layer_data *device_data, GLOBAL_CB_NODE const *pCB, const VkImageMemoryBarrier *mem_barrier, |
Mark Lobodzinski | 6b6c50a | 2017-02-27 12:56:14 -0700 | [diff] [blame] | 378 | uint32_t level, uint32_t layer, VkImageAspectFlags aspect) { |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 379 | if (!(mem_barrier->subresourceRange.aspectMask & aspect)) { |
| 380 | return false; |
| 381 | } |
| 382 | VkImageSubresource sub = {aspect, level, layer}; |
| 383 | IMAGE_CMD_BUF_LAYOUT_NODE node; |
| 384 | if (!FindCmdBufLayout(device_data, pCB, mem_barrier->image, sub, node)) { |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 385 | return false; |
| 386 | } |
| 387 | bool skip = false; |
| 388 | if (mem_barrier->oldLayout == VK_IMAGE_LAYOUT_UNDEFINED) { |
| 389 | // TODO: Set memory invalid which is in mem_tracker currently |
| 390 | } else if (node.layout != mem_barrier->oldLayout) { |
Cort Stratton | d46dcb5 | 2018-04-10 14:52:49 -0700 | [diff] [blame] | 391 | skip = |
| 392 | log_msg(core_validation::GetReportData(device_data), VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 393 | VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, HandleToUint64(pCB->commandBuffer), VALIDATION_ERROR_0a00095a, |
| 394 | "For image 0x%" PRIx64 |
| 395 | " you cannot transition the layout of aspect=%d level=%d layer=%d from %s when current layout is %s.", |
| 396 | HandleToUint64(mem_barrier->image), aspect, level, layer, string_VkImageLayout(mem_barrier->oldLayout), |
| 397 | string_VkImageLayout(node.layout)); |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 398 | } |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 399 | return skip; |
| 400 | } |
| 401 | |
Tobin Ehlis | 0d4274b | 2017-02-17 15:17:04 -0700 | [diff] [blame] | 402 | // Transition the layout state for renderpass attachments based on the BeginRenderPass() call. This includes: |
| 403 | // 1. Transition into initialLayout state |
| 404 | // 2. Transition from initialLayout to layout used in subpass 0 |
| 405 | void TransitionBeginRenderPassLayouts(layer_data *device_data, GLOBAL_CB_NODE *cb_state, const RENDER_PASS_STATE *render_pass_state, |
| 406 | FRAMEBUFFER_STATE *framebuffer_state) { |
| 407 | // First transition into initialLayout |
| 408 | auto const rpci = render_pass_state->createInfo.ptr(); |
| 409 | for (uint32_t i = 0; i < rpci->attachmentCount; ++i) { |
| 410 | VkImageView image_view = framebuffer_state->createInfo.pAttachments[i]; |
| 411 | SetImageViewLayout(device_data, cb_state, image_view, rpci->pAttachments[i].initialLayout); |
| 412 | } |
| 413 | // Now transition for first subpass (index 0) |
| 414 | TransitionSubpassLayouts(device_data, cb_state, render_pass_state, 0, framebuffer_state); |
| 415 | } |
| 416 | |
Mark Lobodzinski | 6b6c50a | 2017-02-27 12:56:14 -0700 | [diff] [blame] | 417 | void TransitionImageAspectLayout(layer_data *device_data, GLOBAL_CB_NODE *pCB, const VkImageMemoryBarrier *mem_barrier, |
| 418 | uint32_t level, uint32_t layer, VkImageAspectFlags aspect) { |
| 419 | if (!(mem_barrier->subresourceRange.aspectMask & aspect)) { |
| 420 | return; |
| 421 | } |
| 422 | VkImageSubresource sub = {aspect, level, layer}; |
| 423 | IMAGE_CMD_BUF_LAYOUT_NODE node; |
| 424 | if (!FindCmdBufLayout(device_data, pCB, mem_barrier->image, sub, node)) { |
John Zulauf | 48a6a70 | 2017-12-22 17:14:54 -0700 | [diff] [blame] | 425 | pCB->image_layout_change_count++; // Change the version of this data to force revalidation |
Mark Lobodzinski | 6b6c50a | 2017-02-27 12:56:14 -0700 | [diff] [blame] | 426 | SetLayout(device_data, pCB, mem_barrier->image, sub, |
| 427 | IMAGE_CMD_BUF_LAYOUT_NODE(mem_barrier->oldLayout, mem_barrier->newLayout)); |
| 428 | return; |
| 429 | } |
| 430 | if (mem_barrier->oldLayout == VK_IMAGE_LAYOUT_UNDEFINED) { |
| 431 | // TODO: Set memory invalid |
| 432 | } |
| 433 | SetLayout(device_data, pCB, mem_barrier->image, sub, mem_barrier->newLayout); |
| 434 | } |
| 435 | |
Dave Houlton | 10b3948 | 2017-03-16 13:18:15 -0600 | [diff] [blame] | 436 | bool VerifyAspectsPresent(VkImageAspectFlags aspect_mask, VkFormat format) { |
Dave Houlton | 4eaaf3a | 2017-03-14 11:31:20 -0600 | [diff] [blame] | 437 | if ((aspect_mask & VK_IMAGE_ASPECT_COLOR_BIT) != 0) { |
Dave Houlton | e2fca55 | 2018-04-05 16:20:33 -0600 | [diff] [blame] | 438 | if (!(FormatIsColor(format) || FormatIsMultiplane(format))) return false; |
Dave Houlton | 4eaaf3a | 2017-03-14 11:31:20 -0600 | [diff] [blame] | 439 | } |
| 440 | if ((aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT) != 0) { |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 441 | if (!FormatHasDepth(format)) return false; |
Dave Houlton | 4eaaf3a | 2017-03-14 11:31:20 -0600 | [diff] [blame] | 442 | } |
| 443 | if ((aspect_mask & VK_IMAGE_ASPECT_STENCIL_BIT) != 0) { |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 444 | if (!FormatHasStencil(format)) return false; |
Dave Houlton | 4eaaf3a | 2017-03-14 11:31:20 -0600 | [diff] [blame] | 445 | } |
Dave Houlton | b3f4b28 | 2018-02-22 16:25:16 -0700 | [diff] [blame] | 446 | if (0 != |
| 447 | (aspect_mask & (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR))) { |
| 448 | if (FormatPlaneCount(format) == 1) return false; |
| 449 | } |
Dave Houlton | 4eaaf3a | 2017-03-14 11:31:20 -0600 | [diff] [blame] | 450 | return true; |
| 451 | } |
| 452 | |
Mike Weiblen | 62d08a3 | 2017-03-07 22:18:27 -0700 | [diff] [blame] | 453 | // Verify an ImageMemoryBarrier's old/new ImageLayouts are compatible with the Image's ImageUsageFlags. |
| 454 | bool ValidateBarrierLayoutToImageUsage(layer_data *device_data, const VkImageMemoryBarrier *img_barrier, bool new_not_old, |
| 455 | VkImageUsageFlags usage_flags, const char *func_name) { |
| 456 | const auto report_data = core_validation::GetReportData(device_data); |
| 457 | bool skip = false; |
| 458 | const VkImageLayout layout = (new_not_old) ? img_barrier->newLayout : img_barrier->oldLayout; |
| 459 | UNIQUE_VALIDATION_ERROR_CODE msg_code = VALIDATION_ERROR_UNDEFINED; // sentinel value meaning "no error" |
| 460 | |
| 461 | switch (layout) { |
| 462 | case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: |
| 463 | if ((usage_flags & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) == 0) { |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 464 | msg_code = VALIDATION_ERROR_0a000970; |
Mike Weiblen | 62d08a3 | 2017-03-07 22:18:27 -0700 | [diff] [blame] | 465 | } |
| 466 | break; |
| 467 | case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: |
| 468 | if ((usage_flags & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) { |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 469 | msg_code = VALIDATION_ERROR_0a000972; |
Mike Weiblen | 62d08a3 | 2017-03-07 22:18:27 -0700 | [diff] [blame] | 470 | } |
| 471 | break; |
| 472 | case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: |
| 473 | if ((usage_flags & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) { |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 474 | msg_code = VALIDATION_ERROR_0a000974; |
Mike Weiblen | 62d08a3 | 2017-03-07 22:18:27 -0700 | [diff] [blame] | 475 | } |
| 476 | break; |
| 477 | case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL: |
| 478 | if ((usage_flags & (VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT)) == 0) { |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 479 | msg_code = VALIDATION_ERROR_0a000976; |
Mike Weiblen | 62d08a3 | 2017-03-07 22:18:27 -0700 | [diff] [blame] | 480 | } |
| 481 | break; |
| 482 | case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL: |
| 483 | if ((usage_flags & VK_IMAGE_USAGE_TRANSFER_SRC_BIT) == 0) { |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 484 | msg_code = VALIDATION_ERROR_0a000978; |
Mike Weiblen | 62d08a3 | 2017-03-07 22:18:27 -0700 | [diff] [blame] | 485 | } |
| 486 | break; |
| 487 | case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL: |
| 488 | if ((usage_flags & VK_IMAGE_USAGE_TRANSFER_DST_BIT) == 0) { |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 489 | msg_code = VALIDATION_ERROR_0a00097a; |
Mike Weiblen | 62d08a3 | 2017-03-07 22:18:27 -0700 | [diff] [blame] | 490 | } |
| 491 | break; |
| 492 | default: |
| 493 | // Other VkImageLayout values do not have VUs defined in this context. |
| 494 | break; |
| 495 | } |
| 496 | |
| 497 | if (msg_code != VALIDATION_ERROR_UNDEFINED) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 498 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 499 | HandleToUint64(img_barrier->image), msg_code, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 500 | "%s: Image barrier 0x%p %sLayout=%s is not compatible with image 0x%" PRIx64 " usage flags 0x%" PRIx32 ".", |
| 501 | func_name, static_cast<const void *>(img_barrier), ((new_not_old) ? "new" : "old"), |
| 502 | string_VkImageLayout(layout), HandleToUint64(img_barrier->image), usage_flags); |
Mike Weiblen | 62d08a3 | 2017-03-07 22:18:27 -0700 | [diff] [blame] | 503 | } |
| 504 | return skip; |
| 505 | } |
| 506 | |
| 507 | // Verify image barriers are compatible with the images they reference. |
Tobin Ehlis | 9c0df96 | 2017-07-17 10:14:27 -0600 | [diff] [blame] | 508 | bool ValidateBarriersToImages(layer_data *device_data, GLOBAL_CB_NODE const *cb_state, uint32_t imageMemoryBarrierCount, |
Mike Weiblen | 62d08a3 | 2017-03-07 22:18:27 -0700 | [diff] [blame] | 509 | const VkImageMemoryBarrier *pImageMemoryBarriers, const char *func_name) { |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 510 | bool skip = false; |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 511 | |
Mike Weiblen | 62d08a3 | 2017-03-07 22:18:27 -0700 | [diff] [blame] | 512 | for (uint32_t i = 0; i < imageMemoryBarrierCount; ++i) { |
| 513 | auto img_barrier = &pImageMemoryBarriers[i]; |
| 514 | if (!img_barrier) continue; |
| 515 | |
Tobin Ehlis | bb03e5f | 2017-05-11 08:52:51 -0600 | [diff] [blame] | 516 | auto image_state = GetImageState(device_data, img_barrier->image); |
| 517 | if (image_state) { |
| 518 | VkImageUsageFlags usage_flags = image_state->createInfo.usage; |
| 519 | skip |= ValidateBarrierLayoutToImageUsage(device_data, img_barrier, false, usage_flags, func_name); |
| 520 | skip |= ValidateBarrierLayoutToImageUsage(device_data, img_barrier, true, usage_flags, func_name); |
| 521 | |
| 522 | // Make sure layout is able to be transitioned, currently only presented shared presentable images are locked |
| 523 | if (image_state->layout_locked) { |
| 524 | // TODO: Add unique id for error when available |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 525 | skip |= log_msg( |
| 526 | core_validation::GetReportData(device_data), VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 527 | VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, 0, |
Petr Kraus | 13c98a6 | 2017-12-09 00:22:39 +0100 | [diff] [blame] | 528 | "Attempting to transition shared presentable image 0x%" PRIx64 |
Tobin Ehlis | bb03e5f | 2017-05-11 08:52:51 -0600 | [diff] [blame] | 529 | " from layout %s to layout %s, but image has already been presented and cannot have its layout transitioned.", |
Petr Kraus | 13c98a6 | 2017-12-09 00:22:39 +0100 | [diff] [blame] | 530 | HandleToUint64(img_barrier->image), string_VkImageLayout(img_barrier->oldLayout), |
Tobin Ehlis | bb03e5f | 2017-05-11 08:52:51 -0600 | [diff] [blame] | 531 | string_VkImageLayout(img_barrier->newLayout)); |
| 532 | } |
| 533 | } |
| 534 | |
Mark Lobodzinski | 903e5ff | 2017-03-23 09:43:35 -0600 | [diff] [blame] | 535 | VkImageCreateInfo *image_create_info = &(GetImageState(device_data, img_barrier->image)->createInfo); |
Tobin Ehlis | 7ee9cbd | 2017-04-26 16:51:48 -0600 | [diff] [blame] | 536 | // For a Depth/Stencil image both aspects MUST be set |
| 537 | if (FormatIsDepthAndStencil(image_create_info->format)) { |
| 538 | auto const aspect_mask = img_barrier->subresourceRange.aspectMask; |
| 539 | auto const ds_mask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
| 540 | if ((aspect_mask & ds_mask) != (ds_mask)) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 541 | skip |= |
| 542 | log_msg(core_validation::GetReportData(device_data), VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 543 | VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, HandleToUint64(img_barrier->image), VALIDATION_ERROR_0a00096e, |
| 544 | "%s: Image barrier 0x%p references image 0x%" PRIx64 |
| 545 | " of format %s that must have the depth and stencil aspects set, but its aspectMask is 0x%" PRIx32 ".", |
| 546 | func_name, static_cast<const void *>(img_barrier), HandleToUint64(img_barrier->image), |
| 547 | string_VkFormat(image_create_info->format), aspect_mask); |
Tobin Ehlis | 7ee9cbd | 2017-04-26 16:51:48 -0600 | [diff] [blame] | 548 | } |
| 549 | } |
Mark Lobodzinski | 903e5ff | 2017-03-23 09:43:35 -0600 | [diff] [blame] | 550 | uint32_t level_count = ResolveRemainingLevels(&img_barrier->subresourceRange, image_create_info->mipLevels); |
| 551 | uint32_t layer_count = ResolveRemainingLayers(&img_barrier->subresourceRange, image_create_info->arrayLayers); |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 552 | |
Mike Weiblen | 62d08a3 | 2017-03-07 22:18:27 -0700 | [diff] [blame] | 553 | for (uint32_t j = 0; j < level_count; j++) { |
| 554 | uint32_t level = img_barrier->subresourceRange.baseMipLevel + j; |
| 555 | for (uint32_t k = 0; k < layer_count; k++) { |
| 556 | uint32_t layer = img_barrier->subresourceRange.baseArrayLayer + k; |
Tobin Ehlis | 9c0df96 | 2017-07-17 10:14:27 -0600 | [diff] [blame] | 557 | skip |= ValidateImageAspectLayout(device_data, cb_state, img_barrier, level, layer, VK_IMAGE_ASPECT_COLOR_BIT); |
| 558 | skip |= ValidateImageAspectLayout(device_data, cb_state, img_barrier, level, layer, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 559 | skip |= ValidateImageAspectLayout(device_data, cb_state, img_barrier, level, layer, VK_IMAGE_ASPECT_STENCIL_BIT); |
| 560 | skip |= ValidateImageAspectLayout(device_data, cb_state, img_barrier, level, layer, VK_IMAGE_ASPECT_METADATA_BIT); |
Dave Houlton | b3f4b28 | 2018-02-22 16:25:16 -0700 | [diff] [blame] | 561 | if (GetDeviceExtensions(device_data)->vk_khr_sampler_ycbcr_conversion) { |
| 562 | skip |= ValidateImageAspectLayout(device_data, cb_state, img_barrier, level, layer, |
| 563 | VK_IMAGE_ASPECT_PLANE_0_BIT_KHR); |
| 564 | skip |= ValidateImageAspectLayout(device_data, cb_state, img_barrier, level, layer, |
| 565 | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR); |
| 566 | skip |= ValidateImageAspectLayout(device_data, cb_state, img_barrier, level, layer, |
| 567 | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR); |
| 568 | } |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 569 | } |
| 570 | } |
| 571 | } |
| 572 | return skip; |
| 573 | } |
| 574 | |
Chris Forbes | 4de4b13 | 2017-08-21 11:27:08 -0700 | [diff] [blame] | 575 | static bool IsReleaseOp(layer_data *device_data, GLOBAL_CB_NODE *cb_state, VkImageMemoryBarrier const *barrier) { |
John Zulauf | 1b33d5a | 2018-03-24 19:52:19 -0600 | [diff] [blame] | 576 | if (!IsTransferOp(barrier)) return false; |
Chris Forbes | 4de4b13 | 2017-08-21 11:27:08 -0700 | [diff] [blame] | 577 | |
| 578 | auto pool = GetCommandPoolNode(device_data, cb_state->createInfo.commandPool); |
John Zulauf | 1b33d5a | 2018-03-24 19:52:19 -0600 | [diff] [blame] | 579 | return pool && IsReleaseOp<VkImageMemoryBarrier, true>(pool, barrier); |
Chris Forbes | 4de4b13 | 2017-08-21 11:27:08 -0700 | [diff] [blame] | 580 | } |
| 581 | |
Chris Forbes | 399a678 | 2017-08-18 15:00:48 -0700 | [diff] [blame] | 582 | void TransitionImageLayouts(layer_data *device_data, GLOBAL_CB_NODE *cb_state, uint32_t memBarrierCount, |
Mark Lobodzinski | 6b6c50a | 2017-02-27 12:56:14 -0700 | [diff] [blame] | 583 | const VkImageMemoryBarrier *pImgMemBarriers) { |
Mark Lobodzinski | 6b6c50a | 2017-02-27 12:56:14 -0700 | [diff] [blame] | 584 | for (uint32_t i = 0; i < memBarrierCount; ++i) { |
| 585 | auto mem_barrier = &pImgMemBarriers[i]; |
| 586 | if (!mem_barrier) continue; |
Mark Lobodzinski | 6b6c50a | 2017-02-27 12:56:14 -0700 | [diff] [blame] | 587 | |
Chris Forbes | 4de4b13 | 2017-08-21 11:27:08 -0700 | [diff] [blame] | 588 | // For ownership transfers, the barrier is specified twice; as a release |
| 589 | // operation on the yielding queue family, and as an acquire operation |
| 590 | // on the acquiring queue family. This barrier may also include a layout |
| 591 | // transition, which occurs 'between' the two operations. For validation |
| 592 | // purposes it doesn't seem important which side performs the layout |
| 593 | // transition, but it must not be performed twice. We'll arbitrarily |
| 594 | // choose to perform it as part of the acquire operation. |
| 595 | if (IsReleaseOp(device_data, cb_state, mem_barrier)) { |
| 596 | continue; |
| 597 | } |
| 598 | |
Mark Lobodzinski | 903e5ff | 2017-03-23 09:43:35 -0600 | [diff] [blame] | 599 | VkImageCreateInfo *image_create_info = &(GetImageState(device_data, mem_barrier->image)->createInfo); |
| 600 | uint32_t level_count = ResolveRemainingLevels(&mem_barrier->subresourceRange, image_create_info->mipLevels); |
| 601 | uint32_t layer_count = ResolveRemainingLayers(&mem_barrier->subresourceRange, image_create_info->arrayLayers); |
| 602 | |
Dave Houlton | b3f4b28 | 2018-02-22 16:25:16 -0700 | [diff] [blame] | 603 | // Special case for 3D images with VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT_KHR flag bit, where <extent.depth> and |
| 604 | // <arrayLayers> can potentially alias. When recording layout for the entire image, pre-emptively record layouts |
| 605 | // for all (potential) layer sub_resources. |
| 606 | if ((0 != (image_create_info->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT_KHR)) && |
| 607 | (mem_barrier->subresourceRange.baseArrayLayer == 0) && (layer_count == 1)) { |
| 608 | layer_count = image_create_info->extent.depth; // Treat each depth slice as a layer subresource |
| 609 | } |
| 610 | |
Mark Lobodzinski | 903e5ff | 2017-03-23 09:43:35 -0600 | [diff] [blame] | 611 | for (uint32_t j = 0; j < level_count; j++) { |
Mark Lobodzinski | 6b6c50a | 2017-02-27 12:56:14 -0700 | [diff] [blame] | 612 | uint32_t level = mem_barrier->subresourceRange.baseMipLevel + j; |
Mark Lobodzinski | 903e5ff | 2017-03-23 09:43:35 -0600 | [diff] [blame] | 613 | for (uint32_t k = 0; k < layer_count; k++) { |
Mark Lobodzinski | 6b6c50a | 2017-02-27 12:56:14 -0700 | [diff] [blame] | 614 | uint32_t layer = mem_barrier->subresourceRange.baseArrayLayer + k; |
Chris Forbes | 399a678 | 2017-08-18 15:00:48 -0700 | [diff] [blame] | 615 | TransitionImageAspectLayout(device_data, cb_state, mem_barrier, level, layer, VK_IMAGE_ASPECT_COLOR_BIT); |
| 616 | TransitionImageAspectLayout(device_data, cb_state, mem_barrier, level, layer, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 617 | TransitionImageAspectLayout(device_data, cb_state, mem_barrier, level, layer, VK_IMAGE_ASPECT_STENCIL_BIT); |
| 618 | TransitionImageAspectLayout(device_data, cb_state, mem_barrier, level, layer, VK_IMAGE_ASPECT_METADATA_BIT); |
Dave Houlton | b3f4b28 | 2018-02-22 16:25:16 -0700 | [diff] [blame] | 619 | if (GetDeviceExtensions(device_data)->vk_khr_sampler_ycbcr_conversion) { |
Chris Forbes | 399a678 | 2017-08-18 15:00:48 -0700 | [diff] [blame] | 620 | TransitionImageAspectLayout(device_data, cb_state, mem_barrier, level, layer, VK_IMAGE_ASPECT_PLANE_0_BIT_KHR); |
| 621 | TransitionImageAspectLayout(device_data, cb_state, mem_barrier, level, layer, VK_IMAGE_ASPECT_PLANE_1_BIT_KHR); |
| 622 | TransitionImageAspectLayout(device_data, cb_state, mem_barrier, level, layer, VK_IMAGE_ASPECT_PLANE_2_BIT_KHR); |
Dave Houlton | b3f4b28 | 2018-02-22 16:25:16 -0700 | [diff] [blame] | 623 | } |
Mark Lobodzinski | 6b6c50a | 2017-02-27 12:56:14 -0700 | [diff] [blame] | 624 | } |
| 625 | } |
| 626 | } |
| 627 | } |
| 628 | |
Tobin Ehlis | c826645 | 2017-04-07 12:20:30 -0600 | [diff] [blame] | 629 | bool VerifyImageLayout(layer_data const *device_data, GLOBAL_CB_NODE const *cb_node, IMAGE_STATE *image_state, |
Tobin Ehlis | 2d85ec6 | 2017-03-14 15:38:48 -0600 | [diff] [blame] | 630 | VkImageSubresourceLayers subLayers, VkImageLayout explicit_layout, VkImageLayout optimal_layout, |
Tobin Ehlis | c826645 | 2017-04-07 12:20:30 -0600 | [diff] [blame] | 631 | const char *caller, UNIQUE_VALIDATION_ERROR_CODE msg_code, bool *error) { |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 632 | const auto report_data = core_validation::GetReportData(device_data); |
Tobin Ehlis | 2d85ec6 | 2017-03-14 15:38:48 -0600 | [diff] [blame] | 633 | const auto image = image_state->image; |
Mark Lobodzinski | bdc3b02 | 2017-04-24 09:11:35 -0600 | [diff] [blame] | 634 | bool skip = false; |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 635 | |
| 636 | for (uint32_t i = 0; i < subLayers.layerCount; ++i) { |
| 637 | uint32_t layer = i + subLayers.baseArrayLayer; |
| 638 | VkImageSubresource sub = {subLayers.aspectMask, subLayers.mipLevel, layer}; |
| 639 | IMAGE_CMD_BUF_LAYOUT_NODE node; |
Tobin Ehlis | e35b66a | 2017-03-15 12:18:31 -0600 | [diff] [blame] | 640 | if (FindCmdBufLayout(device_data, cb_node, image, sub, node)) { |
| 641 | if (node.layout != explicit_layout) { |
Tobin Ehlis | c826645 | 2017-04-07 12:20:30 -0600 | [diff] [blame] | 642 | *error = true; |
Tobin Ehlis | e35b66a | 2017-03-15 12:18:31 -0600 | [diff] [blame] | 643 | // TODO: Improve log message in the next pass |
Petr Kraus | 13c98a6 | 2017-12-09 00:22:39 +0100 | [diff] [blame] | 644 | skip |= log_msg( |
| 645 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 646 | HandleToUint64(cb_node->commandBuffer), DRAWSTATE_INVALID_IMAGE_LAYOUT, |
Petr Kraus | 13c98a6 | 2017-12-09 00:22:39 +0100 | [diff] [blame] | 647 | "%s: Cannot use image 0x%" PRIx64 " with specific layout %s that doesn't match the actual current layout %s.", |
| 648 | caller, HandleToUint64(image), string_VkImageLayout(explicit_layout), string_VkImageLayout(node.layout)); |
Tobin Ehlis | e35b66a | 2017-03-15 12:18:31 -0600 | [diff] [blame] | 649 | } |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 650 | } |
| 651 | } |
Tobin Ehlis | 2d85ec6 | 2017-03-14 15:38:48 -0600 | [diff] [blame] | 652 | // If optimal_layout is not UNDEFINED, check that layout matches optimal for this case |
| 653 | if ((VK_IMAGE_LAYOUT_UNDEFINED != optimal_layout) && (explicit_layout != optimal_layout)) { |
| 654 | if (VK_IMAGE_LAYOUT_GENERAL == explicit_layout) { |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 655 | if (image_state->createInfo.tiling != VK_IMAGE_TILING_LINEAR) { |
| 656 | // LAYOUT_GENERAL is allowed, but may not be performance optimal, flag as perf warning. |
Mark Lobodzinski | bdc3b02 | 2017-04-24 09:11:35 -0600 | [diff] [blame] | 657 | skip |= log_msg(report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 658 | VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, HandleToUint64(cb_node->commandBuffer), |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 659 | DRAWSTATE_INVALID_IMAGE_LAYOUT, |
Petr Kraus | 13c98a6 | 2017-12-09 00:22:39 +0100 | [diff] [blame] | 660 | "%s: For optimal performance image 0x%" PRIx64 " layout should be %s instead of GENERAL.", caller, |
| 661 | HandleToUint64(image), string_VkImageLayout(optimal_layout)); |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 662 | } |
Mark Lobodzinski | 28426ae | 2017-06-01 07:56:38 -0600 | [diff] [blame] | 663 | } else if (GetDeviceExtensions(device_data)->vk_khr_shared_presentable_image) { |
Mark Lobodzinski | 087380c | 2017-05-16 14:42:25 -0600 | [diff] [blame] | 664 | if (image_state->shared_presentable) { |
| 665 | if (VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR != explicit_layout) { |
| 666 | // TODO: Add unique error id when available. |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 667 | skip |= |
| 668 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, msg_code, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 669 | "Layout for shared presentable image is %s but must be VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR.", |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 670 | string_VkImageLayout(optimal_layout)); |
Mark Lobodzinski | 087380c | 2017-05-16 14:42:25 -0600 | [diff] [blame] | 671 | } |
Tobin Ehlis | bb03e5f | 2017-05-11 08:52:51 -0600 | [diff] [blame] | 672 | } |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 673 | } else { |
Tobin Ehlis | c826645 | 2017-04-07 12:20:30 -0600 | [diff] [blame] | 674 | *error = true; |
Mark Lobodzinski | bdc3b02 | 2017-04-24 09:11:35 -0600 | [diff] [blame] | 675 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 676 | HandleToUint64(cb_node->commandBuffer), msg_code, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 677 | "%s: Layout for image 0x%" PRIx64 " is %s but can only be %s or VK_IMAGE_LAYOUT_GENERAL.", caller, |
| 678 | HandleToUint64(image), string_VkImageLayout(explicit_layout), string_VkImageLayout(optimal_layout)); |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 679 | } |
| 680 | } |
Mark Lobodzinski | bdc3b02 | 2017-04-24 09:11:35 -0600 | [diff] [blame] | 681 | return skip; |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 682 | } |
| 683 | |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 684 | void TransitionFinalSubpassLayouts(layer_data *device_data, GLOBAL_CB_NODE *pCB, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 685 | FRAMEBUFFER_STATE *framebuffer_state) { |
Tobin Ehlis | b2e1e2c | 2017-02-08 09:16:32 -0700 | [diff] [blame] | 686 | auto renderPass = GetRenderPassState(device_data, pRenderPassBegin->renderPass); |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 687 | if (!renderPass) return; |
| 688 | |
| 689 | const VkRenderPassCreateInfo *pRenderPassInfo = renderPass->createInfo.ptr(); |
| 690 | if (framebuffer_state) { |
| 691 | for (uint32_t i = 0; i < pRenderPassInfo->attachmentCount; ++i) { |
| 692 | auto image_view = framebuffer_state->createInfo.pAttachments[i]; |
| 693 | SetImageViewLayout(device_data, pCB, image_view, pRenderPassInfo->pAttachments[i].finalLayout); |
| 694 | } |
| 695 | } |
| 696 | } |
Dave Houlton | e19e20d | 2018-02-02 16:32:41 -0700 | [diff] [blame] | 697 | |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 698 | bool PreCallValidateCreateImage(layer_data *device_data, const VkImageCreateInfo *pCreateInfo, |
Mark Lobodzinski | 90224de | 2017-01-26 15:23:11 -0700 | [diff] [blame] | 699 | const VkAllocationCallbacks *pAllocator, VkImage *pImage) { |
Mark Lobodzinski | bdc3b02 | 2017-04-24 09:11:35 -0600 | [diff] [blame] | 700 | bool skip = false; |
Mark Lobodzinski | 90224de | 2017-01-26 15:23:11 -0700 | [diff] [blame] | 701 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
| 702 | |
Jeremy Hayes | 96dcd81 | 2017-03-14 14:04:19 -0600 | [diff] [blame] | 703 | if (pCreateInfo->format == VK_FORMAT_UNDEFINED) { |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 704 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 705 | VALIDATION_ERROR_09e0075e, "vkCreateImage: VkFormat for image must not be VK_FORMAT_UNDEFINED."); |
Jeremy Hayes | 96dcd81 | 2017-03-14 14:04:19 -0600 | [diff] [blame] | 706 | |
Mark Lobodzinski | bdc3b02 | 2017-04-24 09:11:35 -0600 | [diff] [blame] | 707 | return skip; |
Jeremy Hayes | 96dcd81 | 2017-03-14 14:04:19 -0600 | [diff] [blame] | 708 | } |
| 709 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 710 | const char *format_string = string_VkFormat(pCreateInfo->format); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 711 | |
| 712 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) && (VK_IMAGE_TYPE_2D != pCreateInfo->imageType)) { |
| 713 | std::stringstream ss; |
| 714 | ss << "vkCreateImage: Image type must be VK_IMAGE_TYPE_2D when VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT flag bit is set"; |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 715 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 716 | VALIDATION_ERROR_09e0076a, "%s.", ss.str().c_str()); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 717 | } |
| 718 | |
| 719 | const VkPhysicalDeviceLimits *device_limits = &(GetPhysicalDeviceProperties(device_data)->limits); |
| 720 | VkImageFormatProperties format_limits; // Format limits may exceed general device limits |
| 721 | VkResult err = GetImageFormatProperties(device_data, pCreateInfo, &format_limits); |
| 722 | if (VK_SUCCESS != err) { |
| 723 | std::stringstream ss; |
| 724 | ss << "vkCreateImage: The combination of format, type, tiling, usage and flags supplied in the VkImageCreateInfo struct is " |
| 725 | "reported by vkGetPhysicalDeviceImageFormatProperties() as unsupported"; |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 726 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 727 | VALIDATION_ERROR_09e00758, "%s.", ss.str().c_str()); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 728 | return skip; |
| 729 | } |
| 730 | |
| 731 | if ((VK_IMAGE_TYPE_1D == pCreateInfo->imageType) && |
| 732 | (pCreateInfo->extent.width > std::max(device_limits->maxImageDimension1D, format_limits.maxExtent.width))) { |
| 733 | std::stringstream ss; |
| 734 | ss << "vkCreateImage: 1D image width exceeds maximum supported width for format " << format_string; |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 735 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 736 | VALIDATION_ERROR_09e0076e, "%s.", ss.str().c_str()); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 737 | } |
| 738 | |
| 739 | if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) { |
| 740 | if (0 == (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT)) { |
| 741 | if (pCreateInfo->extent.width > std::max(device_limits->maxImageDimension2D, format_limits.maxExtent.width) || |
| 742 | pCreateInfo->extent.height > std::max(device_limits->maxImageDimension2D, format_limits.maxExtent.height)) { |
Lenny Komow | b79f04a | 2017-09-18 17:07:00 -0600 | [diff] [blame] | 743 | std::stringstream ss; |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 744 | ss << "vkCreateImage: 2D image extent exceeds maximum supported width or height for format " << format_string; |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 745 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 746 | VALIDATION_ERROR_09e00770, "%s.", ss.str().c_str()); |
Lenny Komow | b79f04a | 2017-09-18 17:07:00 -0600 | [diff] [blame] | 747 | } |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 748 | } else { |
| 749 | if (pCreateInfo->extent.width > std::max(device_limits->maxImageDimensionCube, format_limits.maxExtent.width) || |
| 750 | pCreateInfo->extent.height > std::max(device_limits->maxImageDimensionCube, format_limits.maxExtent.height)) { |
Lenny Komow | b79f04a | 2017-09-18 17:07:00 -0600 | [diff] [blame] | 751 | std::stringstream ss; |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 752 | ss << "vkCreateImage: 2D image extent exceeds maximum supported width or height for cube-compatible images with " |
| 753 | "format " |
| 754 | << format_string; |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 755 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 756 | VALIDATION_ERROR_09e00772, "%s.", ss.str().c_str()); |
Lenny Komow | b79f04a | 2017-09-18 17:07:00 -0600 | [diff] [blame] | 757 | } |
Jeremy Hayes | 96dcd81 | 2017-03-14 14:04:19 -0600 | [diff] [blame] | 758 | } |
Mark Lobodzinski | 90224de | 2017-01-26 15:23:11 -0700 | [diff] [blame] | 759 | } |
| 760 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 761 | if (VK_IMAGE_TYPE_3D == pCreateInfo->imageType) { |
| 762 | if ((pCreateInfo->extent.width > std::max(device_limits->maxImageDimension3D, format_limits.maxExtent.width)) || |
| 763 | (pCreateInfo->extent.height > std::max(device_limits->maxImageDimension3D, format_limits.maxExtent.height)) || |
| 764 | (pCreateInfo->extent.depth > std::max(device_limits->maxImageDimension3D, format_limits.maxExtent.depth))) { |
| 765 | std::stringstream ss; |
| 766 | ss << "vkCreateImage: 3D image extent exceeds maximum supported width, height, or depth for format " << format_string; |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 767 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 768 | VALIDATION_ERROR_09e00776, "%s.", ss.str().c_str()); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 769 | } |
Mark Lobodzinski | 90224de | 2017-01-26 15:23:11 -0700 | [diff] [blame] | 770 | } |
| 771 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 772 | // NOTE: As of 1/30/2018 the spec VU language is as in the commented code below. I believe this is an |
Dave Houlton | e19e20d | 2018-02-02 16:32:41 -0700 | [diff] [blame] | 773 | // error in the spec, and have submitted Gitlab Vulkan issue #1151 to have it changed to match the |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 774 | // implementation shown. DJH |
| 775 | // |
| 776 | // if ((pCreateInfo->mipLevels > format_limits.maxMipLevels) && |
| 777 | // (std::max({ pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth }) > |
| 778 | // device_limits->maxImageDimension3D)) { |
| 779 | if (pCreateInfo->mipLevels > format_limits.maxMipLevels) { |
| 780 | std::stringstream ss; |
| 781 | ss << "vkCreateImage: Image mip levels exceed image format maxMipLevels for format " << format_string; |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 782 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 783 | VALIDATION_ERROR_09e0077e, "%s.", ss.str().c_str()); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 784 | } |
Mark Lobodzinski | 90224de | 2017-01-26 15:23:11 -0700 | [diff] [blame] | 785 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 786 | VkImageUsageFlags attach_flags = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | |
| 787 | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT; |
| 788 | if ((pCreateInfo->usage & attach_flags) && (pCreateInfo->extent.width > device_limits->maxFramebufferWidth)) { |
| 789 | std::stringstream ss; |
| 790 | ss << "vkCreateImage: Image usage flags include a frame buffer attachment bit and image width exceeds device " |
| 791 | "maxFramebufferWidth"; |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 792 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 793 | VALIDATION_ERROR_09e00788, "%s.", ss.str().c_str()); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 794 | } |
| 795 | |
| 796 | if ((pCreateInfo->usage & attach_flags) && (pCreateInfo->extent.height > device_limits->maxFramebufferHeight)) { |
| 797 | std::stringstream ss; |
| 798 | ss << "vkCreateImage: Image usage flags include a frame buffer attachment bit and image height exceeds device " |
| 799 | "maxFramebufferHeight"; |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 800 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 801 | VALIDATION_ERROR_09e0078a, "%s.", ss.str().c_str()); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 802 | } |
| 803 | |
| 804 | uint64_t total_size = (uint64_t)pCreateInfo->extent.width * (uint64_t)pCreateInfo->extent.height * |
| 805 | (uint64_t)pCreateInfo->extent.depth * (uint64_t)pCreateInfo->arrayLayers * |
| 806 | (uint64_t)pCreateInfo->samples * (uint64_t)FormatSize(pCreateInfo->format); |
| 807 | |
| 808 | // Round up to imageGranularity boundary |
| 809 | VkDeviceSize imageGranularity = GetPhysicalDeviceProperties(device_data)->limits.bufferImageGranularity; |
| 810 | uint64_t ig_mask = imageGranularity - 1; |
| 811 | total_size = (total_size + ig_mask) & ~ig_mask; |
| 812 | |
| 813 | if (total_size > format_limits.maxResourceSize) { |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 814 | skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 815 | IMAGE_INVALID_FORMAT_LIMITS_VIOLATION, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 816 | "CreateImage resource size exceeds allowable maximum Image resource size = 0x%" PRIxLEAST64 |
| 817 | ", maximum resource size = 0x%" PRIxLEAST64 " ", |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 818 | total_size, format_limits.maxResourceSize); |
Mark Lobodzinski | 90224de | 2017-01-26 15:23:11 -0700 | [diff] [blame] | 819 | } |
| 820 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 821 | if (pCreateInfo->arrayLayers > format_limits.maxArrayLayers) { |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 822 | skip |= |
| 823 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, 0, VALIDATION_ERROR_09e00780, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 824 | "CreateImage arrayLayers=%d exceeds allowable maximum supported by format of %d.", pCreateInfo->arrayLayers, |
| 825 | format_limits.maxArrayLayers); |
Mark Lobodzinski | 90224de | 2017-01-26 15:23:11 -0700 | [diff] [blame] | 826 | } |
| 827 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 828 | if ((pCreateInfo->samples & format_limits.sampleCounts) == 0) { |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 829 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 830 | VALIDATION_ERROR_09e0078e, "CreateImage samples %s is not supported by format 0x%.8X.", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 831 | string_VkSampleCountFlagBits(pCreateInfo->samples), format_limits.sampleCounts); |
Mark Lobodzinski | 90224de | 2017-01-26 15:23:11 -0700 | [diff] [blame] | 832 | } |
| 833 | |
Mark Lobodzinski | 035a4cf | 2017-03-13 09:45:07 -0600 | [diff] [blame] | 834 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!GetEnabledFeatures(device_data)->sparseResidencyAliased)) { |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 835 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 836 | DRAWSTATE_INVALID_FEATURE, |
Mark Lobodzinski | bdc3b02 | 2017-04-24 09:11:35 -0600 | [diff] [blame] | 837 | "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the " |
| 838 | "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set."); |
Mark Lobodzinski | 035a4cf | 2017-03-13 09:45:07 -0600 | [diff] [blame] | 839 | } |
| 840 | |
Lenny Komow | b79f04a | 2017-09-18 17:07:00 -0600 | [diff] [blame] | 841 | if (GetDeviceExtensions(device_data)->vk_khr_maintenance2) { |
| 842 | if (pCreateInfo->flags & VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT_KHR) { |
| 843 | if (!(FormatIsCompressed_BC(pCreateInfo->format) || FormatIsCompressed_ASTC_LDR(pCreateInfo->format) || |
| 844 | FormatIsCompressed_ETC2_EAC(pCreateInfo->format))) { |
| 845 | // TODO: Add Maintenance2 VUID |
| 846 | skip |= |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 847 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 848 | VALIDATION_ERROR_UNDEFINED, |
Lenny Komow | b79f04a | 2017-09-18 17:07:00 -0600 | [diff] [blame] | 849 | "vkCreateImage(): If pCreateInfo->flags contains VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT_KHR, " |
| 850 | "format must be block, ETC or ASTC compressed, but is %s", |
| 851 | string_VkFormat(pCreateInfo->format)); |
| 852 | } |
| 853 | if (!(pCreateInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) { |
| 854 | // TODO: Add Maintenance2 VUID |
| 855 | skip |= |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 856 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 857 | VALIDATION_ERROR_UNDEFINED, |
Lenny Komow | b79f04a | 2017-09-18 17:07:00 -0600 | [diff] [blame] | 858 | "vkCreateImage(): If pCreateInfo->flags contains VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT_KHR, " |
| 859 | "flags must also contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT."); |
| 860 | } |
| 861 | } |
| 862 | } |
| 863 | |
Mark Lobodzinski | bdc3b02 | 2017-04-24 09:11:35 -0600 | [diff] [blame] | 864 | return skip; |
Mark Lobodzinski | 90224de | 2017-01-26 15:23:11 -0700 | [diff] [blame] | 865 | } |
| 866 | |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 867 | void PostCallRecordCreateImage(layer_data *device_data, const VkImageCreateInfo *pCreateInfo, VkImage *pImage) { |
Mark Lobodzinski | 42fe5f7 | 2017-01-11 11:36:16 -0700 | [diff] [blame] | 868 | IMAGE_LAYOUT_NODE image_state; |
| 869 | image_state.layout = pCreateInfo->initialLayout; |
| 870 | image_state.format = pCreateInfo->format; |
Mark Lobodzinski | 214144a | 2017-01-27 14:25:32 -0700 | [diff] [blame] | 871 | GetImageMap(device_data)->insert(std::make_pair(*pImage, std::unique_ptr<IMAGE_STATE>(new IMAGE_STATE(*pImage, pCreateInfo)))); |
Mark Lobodzinski | 42fe5f7 | 2017-01-11 11:36:16 -0700 | [diff] [blame] | 872 | ImageSubresourcePair subpair{*pImage, false, VkImageSubresource()}; |
Mark Lobodzinski | 214144a | 2017-01-27 14:25:32 -0700 | [diff] [blame] | 873 | (*core_validation::GetImageSubresourceMap(device_data))[*pImage].push_back(subpair); |
| 874 | (*core_validation::GetImageLayoutMap(device_data))[subpair] = image_state; |
Mark Lobodzinski | 42fe5f7 | 2017-01-11 11:36:16 -0700 | [diff] [blame] | 875 | } |
Mark Lobodzinski | 9ef5d56 | 2017-01-27 12:28:30 -0700 | [diff] [blame] | 876 | |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 877 | bool PreCallValidateDestroyImage(layer_data *device_data, VkImage image, IMAGE_STATE **image_state, VK_OBJECT *obj_struct) { |
Mark Lobodzinski | 9ef5d56 | 2017-01-27 12:28:30 -0700 | [diff] [blame] | 878 | const CHECK_DISABLED *disabled = core_validation::GetDisables(device_data); |
Tobin Ehlis | b2e1e2c | 2017-02-08 09:16:32 -0700 | [diff] [blame] | 879 | *image_state = core_validation::GetImageState(device_data, image); |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 880 | *obj_struct = {HandleToUint64(image), kVulkanObjectTypeImage}; |
Mark Lobodzinski | 9ef5d56 | 2017-01-27 12:28:30 -0700 | [diff] [blame] | 881 | if (disabled->destroy_image) return false; |
| 882 | bool skip = false; |
| 883 | if (*image_state) { |
Mike Schuchardt | a502565 | 2017-09-27 14:56:21 -0600 | [diff] [blame] | 884 | skip |= core_validation::ValidateObjectNotInUse(device_data, *image_state, *obj_struct, "vkDestroyImage", |
| 885 | VALIDATION_ERROR_252007d0); |
Mark Lobodzinski | 9ef5d56 | 2017-01-27 12:28:30 -0700 | [diff] [blame] | 886 | } |
| 887 | return skip; |
| 888 | } |
| 889 | |
John Zulauf | fca05c1 | 2018-04-26 16:30:39 -0600 | [diff] [blame] | 890 | void PreCallRecordDestroyImage(layer_data *device_data, VkImage image, IMAGE_STATE *image_state, VK_OBJECT obj_struct) { |
Mark Lobodzinski | 9ef5d56 | 2017-01-27 12:28:30 -0700 | [diff] [blame] | 891 | core_validation::invalidateCommandBuffers(device_data, image_state->cb_bindings, obj_struct); |
| 892 | // Clean up memory mapping, bindings and range references for image |
| 893 | for (auto mem_binding : image_state->GetBoundMemory()) { |
Tobin Ehlis | b2e1e2c | 2017-02-08 09:16:32 -0700 | [diff] [blame] | 894 | auto mem_info = core_validation::GetMemObjInfo(device_data, mem_binding); |
Mark Lobodzinski | 9ef5d56 | 2017-01-27 12:28:30 -0700 | [diff] [blame] | 895 | if (mem_info) { |
| 896 | core_validation::RemoveImageMemoryRange(obj_struct.handle, mem_info); |
| 897 | } |
| 898 | } |
Mark Lobodzinski | 3382637 | 2017-04-13 11:10:11 -0600 | [diff] [blame] | 899 | core_validation::ClearMemoryObjectBindings(device_data, obj_struct.handle, kVulkanObjectTypeImage); |
Mark Lobodzinski | 9ef5d56 | 2017-01-27 12:28:30 -0700 | [diff] [blame] | 900 | // Remove image from imageMap |
| 901 | core_validation::GetImageMap(device_data)->erase(image); |
| 902 | std::unordered_map<VkImage, std::vector<ImageSubresourcePair>> *imageSubresourceMap = |
| 903 | core_validation::GetImageSubresourceMap(device_data); |
| 904 | |
| 905 | const auto &sub_entry = imageSubresourceMap->find(image); |
| 906 | if (sub_entry != imageSubresourceMap->end()) { |
| 907 | for (const auto &pair : sub_entry->second) { |
| 908 | core_validation::GetImageLayoutMap(device_data)->erase(pair); |
| 909 | } |
| 910 | imageSubresourceMap->erase(sub_entry); |
| 911 | } |
| 912 | } |
Mark Lobodzinski | c409a58 | 2017-01-27 15:16:01 -0700 | [diff] [blame] | 913 | |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 914 | bool ValidateImageAttributes(layer_data *device_data, IMAGE_STATE *image_state, VkImageSubresourceRange range) { |
Mark Lobodzinski | c409a58 | 2017-01-27 15:16:01 -0700 | [diff] [blame] | 915 | bool skip = false; |
| 916 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
| 917 | |
| 918 | if (range.aspectMask != VK_IMAGE_ASPECT_COLOR_BIT) { |
| 919 | char const str[] = "vkCmdClearColorImage aspectMasks for all subresource ranges must be set to VK_IMAGE_ASPECT_COLOR_BIT"; |
| 920 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 921 | HandleToUint64(image_state->image), DRAWSTATE_INVALID_IMAGE_ASPECT, str); |
Mark Lobodzinski | c409a58 | 2017-01-27 15:16:01 -0700 | [diff] [blame] | 922 | } |
| 923 | |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 924 | if (FormatIsDepthOrStencil(image_state->createInfo.format)) { |
Mark Lobodzinski | c409a58 | 2017-01-27 15:16:01 -0700 | [diff] [blame] | 925 | char const str[] = "vkCmdClearColorImage called with depth/stencil image."; |
| 926 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 927 | HandleToUint64(image_state->image), VALIDATION_ERROR_1880000e, "%s.", str); |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 928 | } else if (FormatIsCompressed(image_state->createInfo.format)) { |
Mark Lobodzinski | c409a58 | 2017-01-27 15:16:01 -0700 | [diff] [blame] | 929 | char const str[] = "vkCmdClearColorImage called with compressed image."; |
| 930 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 931 | HandleToUint64(image_state->image), VALIDATION_ERROR_1880000e, "%s.", str); |
Mark Lobodzinski | c409a58 | 2017-01-27 15:16:01 -0700 | [diff] [blame] | 932 | } |
| 933 | |
| 934 | if (!(image_state->createInfo.usage & VK_IMAGE_USAGE_TRANSFER_DST_BIT)) { |
| 935 | char const str[] = "vkCmdClearColorImage called with image created without VK_IMAGE_USAGE_TRANSFER_DST_BIT."; |
| 936 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 937 | HandleToUint64(image_state->image), VALIDATION_ERROR_18800004, "%s.", str); |
Mark Lobodzinski | c409a58 | 2017-01-27 15:16:01 -0700 | [diff] [blame] | 938 | } |
| 939 | return skip; |
| 940 | } |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 941 | |
Mark Lobodzinski | 903e5ff | 2017-03-23 09:43:35 -0600 | [diff] [blame] | 942 | uint32_t ResolveRemainingLevels(const VkImageSubresourceRange *range, uint32_t mip_levels) { |
| 943 | // Return correct number of mip levels taking into account VK_REMAINING_MIP_LEVELS |
| 944 | uint32_t mip_level_count = range->levelCount; |
Mark Lobodzinski | 9c93dbd | 2017-02-02 08:31:18 -0700 | [diff] [blame] | 945 | if (range->levelCount == VK_REMAINING_MIP_LEVELS) { |
Mark Lobodzinski | 903e5ff | 2017-03-23 09:43:35 -0600 | [diff] [blame] | 946 | mip_level_count = mip_levels - range->baseMipLevel; |
Mark Lobodzinski | 9c93dbd | 2017-02-02 08:31:18 -0700 | [diff] [blame] | 947 | } |
Mark Lobodzinski | 903e5ff | 2017-03-23 09:43:35 -0600 | [diff] [blame] | 948 | return mip_level_count; |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 949 | } |
| 950 | |
Mark Lobodzinski | 903e5ff | 2017-03-23 09:43:35 -0600 | [diff] [blame] | 951 | uint32_t ResolveRemainingLayers(const VkImageSubresourceRange *range, uint32_t layers) { |
| 952 | // Return correct number of layers taking into account VK_REMAINING_ARRAY_LAYERS |
| 953 | uint32_t array_layer_count = range->layerCount; |
| 954 | if (range->layerCount == VK_REMAINING_ARRAY_LAYERS) { |
| 955 | array_layer_count = layers - range->baseArrayLayer; |
Mark Lobodzinski | 9c93dbd | 2017-02-02 08:31:18 -0700 | [diff] [blame] | 956 | } |
Mark Lobodzinski | 903e5ff | 2017-03-23 09:43:35 -0600 | [diff] [blame] | 957 | return array_layer_count; |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 958 | } |
| 959 | |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 960 | bool VerifyClearImageLayout(layer_data *device_data, GLOBAL_CB_NODE *cb_node, IMAGE_STATE *image_state, |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 961 | VkImageSubresourceRange range, VkImageLayout dest_image_layout, const char *func_name) { |
| 962 | bool skip = false; |
| 963 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
| 964 | |
Mark Lobodzinski | 903e5ff | 2017-03-23 09:43:35 -0600 | [diff] [blame] | 965 | uint32_t level_count = ResolveRemainingLevels(&range, image_state->createInfo.mipLevels); |
| 966 | uint32_t layer_count = ResolveRemainingLayers(&range, image_state->createInfo.arrayLayers); |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 967 | |
| 968 | if (dest_image_layout != VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL) { |
| 969 | if (dest_image_layout == VK_IMAGE_LAYOUT_GENERAL) { |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 970 | if (image_state->createInfo.tiling != VK_IMAGE_TILING_LINEAR) { |
| 971 | // LAYOUT_GENERAL is allowed, but may not be performance optimal, flag as perf warning. |
Mark Lobodzinski | 0827aec | 2017-03-21 16:41:45 -0600 | [diff] [blame] | 972 | skip |= log_msg(report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 973 | HandleToUint64(image_state->image), DRAWSTATE_INVALID_IMAGE_LAYOUT, |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 974 | "%s: Layout for cleared image should be TRANSFER_DST_OPTIMAL instead of GENERAL.", func_name); |
| 975 | } |
Mark Lobodzinski | 087380c | 2017-05-16 14:42:25 -0600 | [diff] [blame] | 976 | } else if (VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR == dest_image_layout) { |
Mark Lobodzinski | 28426ae | 2017-06-01 07:56:38 -0600 | [diff] [blame] | 977 | if (!GetDeviceExtensions(device_data)->vk_khr_shared_presentable_image) { |
Tobin Ehlis | fb0661c | 2017-05-11 08:52:51 -0600 | [diff] [blame] | 978 | // TODO: Add unique error id when available. |
Mark Lobodzinski | 087380c | 2017-05-16 14:42:25 -0600 | [diff] [blame] | 979 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 980 | HandleToUint64(image_state->image), 0, |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 981 | "Must enable VK_KHR_shared_presentable_image extension before creating images with a layout type " |
| 982 | "of VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR."); |
Mark Lobodzinski | 087380c | 2017-05-16 14:42:25 -0600 | [diff] [blame] | 983 | |
| 984 | } else { |
| 985 | if (image_state->shared_presentable) { |
| 986 | skip |= log_msg( |
| 987 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 988 | HandleToUint64(image_state->image), 0, |
Mark Lobodzinski | 087380c | 2017-05-16 14:42:25 -0600 | [diff] [blame] | 989 | "Layout for shared presentable cleared image is %s but can only be VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR.", |
| 990 | string_VkImageLayout(dest_image_layout)); |
| 991 | } |
Tobin Ehlis | bb03e5f | 2017-05-11 08:52:51 -0600 | [diff] [blame] | 992 | } |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 993 | } else { |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 994 | UNIQUE_VALIDATION_ERROR_CODE error_code = VALIDATION_ERROR_1880000a; |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 995 | if (strcmp(func_name, "vkCmdClearDepthStencilImage()") == 0) { |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 996 | error_code = VALIDATION_ERROR_18a00018; |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 997 | } else { |
| 998 | assert(strcmp(func_name, "vkCmdClearColorImage()") == 0); |
| 999 | } |
Mark Lobodzinski | 0827aec | 2017-03-21 16:41:45 -0600 | [diff] [blame] | 1000 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1001 | HandleToUint64(image_state->image), error_code, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1002 | "%s: Layout for cleared image is %s but can only be TRANSFER_DST_OPTIMAL or GENERAL.", func_name, |
| 1003 | string_VkImageLayout(dest_image_layout)); |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 1004 | } |
| 1005 | } |
| 1006 | |
Mark Lobodzinski | 903e5ff | 2017-03-23 09:43:35 -0600 | [diff] [blame] | 1007 | for (uint32_t level_index = 0; level_index < level_count; ++level_index) { |
| 1008 | uint32_t level = level_index + range.baseMipLevel; |
| 1009 | for (uint32_t layer_index = 0; layer_index < layer_count; ++layer_index) { |
| 1010 | uint32_t layer = layer_index + range.baseArrayLayer; |
| 1011 | VkImageSubresource sub = {range.aspectMask, level, layer}; |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 1012 | IMAGE_CMD_BUF_LAYOUT_NODE node; |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 1013 | if (FindCmdBufLayout(device_data, cb_node, image_state->image, sub, node)) { |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 1014 | if (node.layout != dest_image_layout) { |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 1015 | UNIQUE_VALIDATION_ERROR_CODE error_code = VALIDATION_ERROR_18800008; |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 1016 | if (strcmp(func_name, "vkCmdClearDepthStencilImage()") == 0) { |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 1017 | error_code = VALIDATION_ERROR_18a00016; |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 1018 | } else { |
| 1019 | assert(strcmp(func_name, "vkCmdClearColorImage()") == 0); |
| 1020 | } |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1021 | skip |= |
| 1022 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, 0, |
| 1023 | error_code, "%s: Cannot clear an image whose layout is %s and doesn't match the current layout %s.", |
| 1024 | func_name, string_VkImageLayout(dest_image_layout), string_VkImageLayout(node.layout)); |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 1025 | } |
| 1026 | } |
| 1027 | } |
| 1028 | } |
| 1029 | |
| 1030 | return skip; |
| 1031 | } |
| 1032 | |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 1033 | void RecordClearImageLayout(layer_data *device_data, GLOBAL_CB_NODE *cb_node, VkImage image, VkImageSubresourceRange range, |
| 1034 | VkImageLayout dest_image_layout) { |
Mark Lobodzinski | 903e5ff | 2017-03-23 09:43:35 -0600 | [diff] [blame] | 1035 | VkImageCreateInfo *image_create_info = &(GetImageState(device_data, image)->createInfo); |
| 1036 | uint32_t level_count = ResolveRemainingLevels(&range, image_create_info->mipLevels); |
| 1037 | uint32_t layer_count = ResolveRemainingLayers(&range, image_create_info->arrayLayers); |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 1038 | |
Mark Lobodzinski | 903e5ff | 2017-03-23 09:43:35 -0600 | [diff] [blame] | 1039 | for (uint32_t level_index = 0; level_index < level_count; ++level_index) { |
| 1040 | uint32_t level = level_index + range.baseMipLevel; |
| 1041 | for (uint32_t layer_index = 0; layer_index < layer_count; ++layer_index) { |
| 1042 | uint32_t layer = layer_index + range.baseArrayLayer; |
| 1043 | VkImageSubresource sub = {range.aspectMask, level, layer}; |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 1044 | IMAGE_CMD_BUF_LAYOUT_NODE node; |
Mark Lobodzinski | 3c0f636 | 2017-02-01 13:35:48 -0700 | [diff] [blame] | 1045 | if (!FindCmdBufLayout(device_data, cb_node, image, sub, node)) { |
| 1046 | SetLayout(device_data, cb_node, image, sub, IMAGE_CMD_BUF_LAYOUT_NODE(dest_image_layout, dest_image_layout)); |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 1047 | } |
| 1048 | } |
| 1049 | } |
| 1050 | } |
| 1051 | |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 1052 | bool PreCallValidateCmdClearColorImage(layer_data *dev_data, VkCommandBuffer commandBuffer, VkImage image, |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 1053 | VkImageLayout imageLayout, uint32_t rangeCount, const VkImageSubresourceRange *pRanges) { |
| 1054 | bool skip = false; |
| 1055 | // TODO : Verify memory is in VK_IMAGE_STATE_CLEAR state |
Tobin Ehlis | b2e1e2c | 2017-02-08 09:16:32 -0700 | [diff] [blame] | 1056 | auto cb_node = GetCBNode(dev_data, commandBuffer); |
| 1057 | auto image_state = GetImageState(dev_data, image); |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 1058 | if (cb_node && image_state) { |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 1059 | skip |= ValidateMemoryIsBoundToImage(dev_data, image_state, "vkCmdClearColorImage()", VALIDATION_ERROR_18800006); |
Mike Schuchardt | 9c58240 | 2017-02-23 15:57:37 -0700 | [diff] [blame] | 1060 | skip |= ValidateCmdQueueFlags(dev_data, cb_node, "vkCmdClearColorImage()", VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT, |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 1061 | VALIDATION_ERROR_18802415); |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 1062 | skip |= ValidateCmd(dev_data, cb_node, CMD_CLEARCOLORIMAGE, "vkCmdClearColorImage()"); |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 1063 | skip |= insideRenderPass(dev_data, cb_node, "vkCmdClearColorImage()", VALIDATION_ERROR_18800017); |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 1064 | for (uint32_t i = 0; i < rangeCount; ++i) { |
Petr Kraus | 4d71868 | 2017-05-18 03:38:41 +0200 | [diff] [blame] | 1065 | std::string param_name = "pRanges[" + std::to_string(i) + "]"; |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 1066 | skip |= ValidateCmdClearColorSubresourceRange(dev_data, image_state, pRanges[i], param_name.c_str()); |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 1067 | skip |= ValidateImageAttributes(dev_data, image_state, pRanges[i]); |
Mark Lobodzinski | 9c93dbd | 2017-02-02 08:31:18 -0700 | [diff] [blame] | 1068 | skip |= VerifyClearImageLayout(dev_data, cb_node, image_state, pRanges[i], imageLayout, "vkCmdClearColorImage()"); |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 1069 | } |
| 1070 | } |
| 1071 | return skip; |
| 1072 | } |
| 1073 | |
| 1074 | // This state recording routine is shared between ClearColorImage and ClearDepthStencilImage |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 1075 | void PreCallRecordCmdClearImage(layer_data *dev_data, VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, |
Chris Forbes | 38c2e79 | 2017-06-16 16:42:35 -0700 | [diff] [blame] | 1076 | uint32_t rangeCount, const VkImageSubresourceRange *pRanges) { |
Tobin Ehlis | b2e1e2c | 2017-02-08 09:16:32 -0700 | [diff] [blame] | 1077 | auto cb_node = GetCBNode(dev_data, commandBuffer); |
| 1078 | auto image_state = GetImageState(dev_data, image); |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 1079 | if (cb_node && image_state) { |
| 1080 | AddCommandBufferBindingImage(dev_data, cb_node, image_state); |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 1081 | for (uint32_t i = 0; i < rangeCount; ++i) { |
| 1082 | RecordClearImageLayout(dev_data, cb_node, image, pRanges[i], imageLayout); |
| 1083 | } |
| 1084 | } |
| 1085 | } |
| 1086 | |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 1087 | bool PreCallValidateCmdClearDepthStencilImage(layer_data *device_data, VkCommandBuffer commandBuffer, VkImage image, |
| 1088 | VkImageLayout imageLayout, uint32_t rangeCount, |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 1089 | const VkImageSubresourceRange *pRanges) { |
| 1090 | bool skip = false; |
Mark Lobodzinski | 1241a31 | 2017-02-01 10:57:21 -0700 | [diff] [blame] | 1091 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
| 1092 | |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 1093 | // TODO : Verify memory is in VK_IMAGE_STATE_CLEAR state |
Tobin Ehlis | b2e1e2c | 2017-02-08 09:16:32 -0700 | [diff] [blame] | 1094 | auto cb_node = GetCBNode(device_data, commandBuffer); |
| 1095 | auto image_state = GetImageState(device_data, image); |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 1096 | if (cb_node && image_state) { |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 1097 | skip |= ValidateMemoryIsBoundToImage(device_data, image_state, "vkCmdClearDepthStencilImage()", VALIDATION_ERROR_18a00014); |
Mike Schuchardt | 9c58240 | 2017-02-23 15:57:37 -0700 | [diff] [blame] | 1098 | skip |= ValidateCmdQueueFlags(device_data, cb_node, "vkCmdClearDepthStencilImage()", VK_QUEUE_GRAPHICS_BIT, |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 1099 | VALIDATION_ERROR_18a02415); |
Mark Lobodzinski | 1241a31 | 2017-02-01 10:57:21 -0700 | [diff] [blame] | 1100 | skip |= ValidateCmd(device_data, cb_node, CMD_CLEARDEPTHSTENCILIMAGE, "vkCmdClearDepthStencilImage()"); |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 1101 | skip |= insideRenderPass(device_data, cb_node, "vkCmdClearDepthStencilImage()", VALIDATION_ERROR_18a00017); |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 1102 | for (uint32_t i = 0; i < rangeCount; ++i) { |
Petr Kraus | 4d71868 | 2017-05-18 03:38:41 +0200 | [diff] [blame] | 1103 | std::string param_name = "pRanges[" + std::to_string(i) + "]"; |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 1104 | skip |= ValidateCmdClearDepthSubresourceRange(device_data, image_state, pRanges[i], param_name.c_str()); |
Mark Lobodzinski | 9c93dbd | 2017-02-02 08:31:18 -0700 | [diff] [blame] | 1105 | skip |= |
| 1106 | VerifyClearImageLayout(device_data, cb_node, image_state, pRanges[i], imageLayout, "vkCmdClearDepthStencilImage()"); |
Mark Lobodzinski | 1241a31 | 2017-02-01 10:57:21 -0700 | [diff] [blame] | 1107 | // Image aspect must be depth or stencil or both |
| 1108 | if (((pRanges[i].aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) != VK_IMAGE_ASPECT_DEPTH_BIT) && |
| 1109 | ((pRanges[i].aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) != VK_IMAGE_ASPECT_STENCIL_BIT)) { |
| 1110 | char const str[] = |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1111 | "vkCmdClearDepthStencilImage aspectMasks for all subresource ranges must be set to VK_IMAGE_ASPECT_DEPTH_BIT " |
| 1112 | "and/or VK_IMAGE_ASPECT_STENCIL_BIT"; |
Mark Lobodzinski | 1241a31 | 2017-02-01 10:57:21 -0700 | [diff] [blame] | 1113 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1114 | HandleToUint64(commandBuffer), DRAWSTATE_INVALID_IMAGE_ASPECT, str); |
Mark Lobodzinski | 1241a31 | 2017-02-01 10:57:21 -0700 | [diff] [blame] | 1115 | } |
| 1116 | } |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 1117 | if (image_state && !FormatIsDepthOrStencil(image_state->createInfo.format)) { |
Mark Lobodzinski | 1241a31 | 2017-02-01 10:57:21 -0700 | [diff] [blame] | 1118 | char const str[] = "vkCmdClearDepthStencilImage called without a depth/stencil image."; |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 1119 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1120 | HandleToUint64(image), VALIDATION_ERROR_18a0001c, "%s.", str); |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 1121 | } |
Tobin Ehlis | 4af8c24 | 2017-11-30 13:47:11 -0700 | [diff] [blame] | 1122 | if (VK_IMAGE_USAGE_TRANSFER_DST_BIT != (VK_IMAGE_USAGE_TRANSFER_DST_BIT & image_state->createInfo.usage)) { |
| 1123 | char const str[] = |
| 1124 | "vkCmdClearDepthStencilImage() called with an image that was not created with the VK_IMAGE_USAGE_TRANSFER_DST_BIT " |
| 1125 | "set."; |
| 1126 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1127 | HandleToUint64(image), VALIDATION_ERROR_18a00012, "%s.", str); |
Tobin Ehlis | 4af8c24 | 2017-11-30 13:47:11 -0700 | [diff] [blame] | 1128 | } |
| 1129 | VkFormatProperties props = GetFormatProperties(device_data, image_state->createInfo.format); |
| 1130 | VkImageTiling tiling = image_state->createInfo.tiling; |
| 1131 | VkFormatFeatureFlags flags = (tiling == VK_IMAGE_TILING_LINEAR ? props.linearTilingFeatures : props.optimalTilingFeatures); |
| 1132 | if ((GetDeviceExtensions(device_data)->vk_khr_maintenance1) && |
| 1133 | (VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR != (flags & VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR))) { |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 1134 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1135 | HandleToUint64(image), VALIDATION_ERROR_18a00010, |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 1136 | "vkCmdClearDepthStencilImage() called with an image of format %s and tiling %s that does not support " |
| 1137 | "VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR.", |
| 1138 | string_VkFormat(image_state->createInfo.format), string_VkImageTiling(image_state->createInfo.tiling)); |
Tobin Ehlis | 4af8c24 | 2017-11-30 13:47:11 -0700 | [diff] [blame] | 1139 | } |
Mark Lobodzinski | d81d101 | 2017-02-01 09:03:06 -0700 | [diff] [blame] | 1140 | } |
| 1141 | return skip; |
| 1142 | } |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 1143 | |
| 1144 | // Returns true if [x, xoffset] and [y, yoffset] overlap |
| 1145 | static bool RangesIntersect(int32_t start, uint32_t start_offset, int32_t end, uint32_t end_offset) { |
| 1146 | bool result = false; |
| 1147 | uint32_t intersection_min = std::max(static_cast<uint32_t>(start), static_cast<uint32_t>(end)); |
| 1148 | uint32_t intersection_max = std::min(static_cast<uint32_t>(start) + start_offset, static_cast<uint32_t>(end) + end_offset); |
| 1149 | |
| 1150 | if (intersection_max > intersection_min) { |
| 1151 | result = true; |
| 1152 | } |
| 1153 | return result; |
| 1154 | } |
| 1155 | |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1156 | // Returns true if source area of first copy region intersects dest area of second region |
| 1157 | // It is assumed that these are copy regions within a single image (otherwise no possibility of collision) |
| 1158 | static bool RegionIntersects(const VkImageCopy *rgn0, const VkImageCopy *rgn1, VkImageType type, bool is_multiplane) { |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 1159 | bool result = false; |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 1160 | |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1161 | // Separate planes within a multiplane image cannot intersect |
| 1162 | if (is_multiplane && (rgn0->srcSubresource.aspectMask != rgn1->dstSubresource.aspectMask)) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 1163 | return result; |
| 1164 | } |
| 1165 | |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1166 | if ((rgn0->srcSubresource.mipLevel == rgn1->dstSubresource.mipLevel) && |
| 1167 | (RangesIntersect(rgn0->srcSubresource.baseArrayLayer, rgn0->srcSubresource.layerCount, rgn1->dstSubresource.baseArrayLayer, |
| 1168 | rgn1->dstSubresource.layerCount))) { |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 1169 | result = true; |
| 1170 | switch (type) { |
| 1171 | case VK_IMAGE_TYPE_3D: |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1172 | result &= RangesIntersect(rgn0->srcOffset.z, rgn0->extent.depth, rgn1->dstOffset.z, rgn1->extent.depth); |
Tobin Ehlis | 648b1cf | 2018-04-13 15:24:13 -0600 | [diff] [blame] | 1173 | // fall through |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 1174 | case VK_IMAGE_TYPE_2D: |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1175 | result &= RangesIntersect(rgn0->srcOffset.y, rgn0->extent.height, rgn1->dstOffset.y, rgn1->extent.height); |
Tobin Ehlis | 648b1cf | 2018-04-13 15:24:13 -0600 | [diff] [blame] | 1176 | // fall through |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 1177 | case VK_IMAGE_TYPE_1D: |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1178 | result &= RangesIntersect(rgn0->srcOffset.x, rgn0->extent.width, rgn1->dstOffset.x, rgn1->extent.width); |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 1179 | break; |
| 1180 | default: |
| 1181 | // Unrecognized or new IMAGE_TYPE enums will be caught in parameter_validation |
| 1182 | assert(false); |
| 1183 | } |
| 1184 | } |
| 1185 | return result; |
| 1186 | } |
| 1187 | |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1188 | // Returns non-zero if offset and extent exceed image extents |
| 1189 | static const uint32_t x_bit = 1; |
| 1190 | static const uint32_t y_bit = 2; |
| 1191 | static const uint32_t z_bit = 4; |
Dave Houlton | 1150cf5 | 2017-04-27 14:38:11 -0600 | [diff] [blame] | 1192 | static uint32_t ExceedsBounds(const VkOffset3D *offset, const VkExtent3D *extent, const VkExtent3D *image_extent) { |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1193 | uint32_t result = 0; |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 1194 | // Extents/depths cannot be negative but checks left in for clarity |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 1195 | if ((offset->z + extent->depth > image_extent->depth) || (offset->z < 0) || |
| 1196 | ((offset->z + static_cast<int32_t>(extent->depth)) < 0)) { |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1197 | result |= z_bit; |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 1198 | } |
| 1199 | if ((offset->y + extent->height > image_extent->height) || (offset->y < 0) || |
| 1200 | ((offset->y + static_cast<int32_t>(extent->height)) < 0)) { |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1201 | result |= y_bit; |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 1202 | } |
| 1203 | if ((offset->x + extent->width > image_extent->width) || (offset->x < 0) || |
| 1204 | ((offset->x + static_cast<int32_t>(extent->width)) < 0)) { |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1205 | result |= x_bit; |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 1206 | } |
| 1207 | return result; |
| 1208 | } |
| 1209 | |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1210 | // Test if two VkExtent3D structs are equivalent |
| 1211 | static inline bool IsExtentEqual(const VkExtent3D *extent, const VkExtent3D *other_extent) { |
| 1212 | bool result = true; |
| 1213 | if ((extent->width != other_extent->width) || (extent->height != other_extent->height) || |
| 1214 | (extent->depth != other_extent->depth)) { |
| 1215 | result = false; |
| 1216 | } |
| 1217 | return result; |
| 1218 | } |
| 1219 | |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1220 | // For image copies between compressed/uncompressed formats, the extent is provided in source image texels |
| 1221 | // Destination image texel extents must be adjusted by block size for the dest validation checks |
| 1222 | VkExtent3D GetAdjustedDestImageExtent(VkFormat src_format, VkFormat dst_format, VkExtent3D extent) { |
| 1223 | VkExtent3D adjusted_extent = extent; |
| 1224 | if ((FormatIsCompressed(src_format) && (!FormatIsCompressed(dst_format)))) { |
| 1225 | VkExtent3D block_size = FormatCompressedTexelBlockExtent(src_format); |
| 1226 | adjusted_extent.width /= block_size.width; |
| 1227 | adjusted_extent.height /= block_size.height; |
| 1228 | adjusted_extent.depth /= block_size.depth; |
| 1229 | } else if ((!FormatIsCompressed(src_format) && (FormatIsCompressed(dst_format)))) { |
| 1230 | VkExtent3D block_size = FormatCompressedTexelBlockExtent(dst_format); |
| 1231 | adjusted_extent.width *= block_size.width; |
| 1232 | adjusted_extent.height *= block_size.height; |
| 1233 | adjusted_extent.depth *= block_size.depth; |
| 1234 | } |
| 1235 | return adjusted_extent; |
| 1236 | } |
| 1237 | |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1238 | // Returns the effective extent of an image subresource, adjusted for mip level and array depth. |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1239 | static inline VkExtent3D GetImageSubresourceExtent(const IMAGE_STATE *img, const VkImageSubresourceLayers *subresource) { |
| 1240 | const uint32_t mip = subresource->mipLevel; |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1241 | |
| 1242 | // Return zero extent if mip level doesn't exist |
Dave Houlton | 1150cf5 | 2017-04-27 14:38:11 -0600 | [diff] [blame] | 1243 | if (mip >= img->createInfo.mipLevels) { |
| 1244 | return VkExtent3D{0, 0, 0}; |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1245 | } |
Dave Houlton | 1150cf5 | 2017-04-27 14:38:11 -0600 | [diff] [blame] | 1246 | |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 1247 | // Don't allow mip adjustment to create 0 dim, but pass along a 0 if that's what subresource specified |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1248 | VkExtent3D extent = img->createInfo.extent; |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 1249 | extent.width = (0 == extent.width ? 0 : std::max(1U, extent.width >> mip)); |
| 1250 | extent.height = (0 == extent.height ? 0 : std::max(1U, extent.height >> mip)); |
| 1251 | extent.depth = (0 == extent.depth ? 0 : std::max(1U, extent.depth >> mip)); |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1252 | |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1253 | // Image arrays have an effective z extent that isn't diminished by mip level |
| 1254 | if (VK_IMAGE_TYPE_3D != img->createInfo.imageType) { |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1255 | extent.depth = img->createInfo.arrayLayers; |
| 1256 | } |
| 1257 | |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1258 | return extent; |
| 1259 | } |
| 1260 | |
| 1261 | // Test if the extent argument has all dimensions set to 0. |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 1262 | static inline bool IsExtentAllZeroes(const VkExtent3D *extent) { |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1263 | return ((extent->width == 0) && (extent->height == 0) && (extent->depth == 0)); |
| 1264 | } |
| 1265 | |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 1266 | // Test if the extent argument has any dimensions set to 0. |
| 1267 | static inline bool IsExtentSizeZero(const VkExtent3D *extent) { |
| 1268 | return ((extent->width == 0) || (extent->height == 0) || (extent->depth == 0)); |
| 1269 | } |
| 1270 | |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1271 | // Returns the image transfer granularity for a specific image scaled by compressed block size if necessary. |
| 1272 | static inline VkExtent3D GetScaledItg(layer_data *device_data, const GLOBAL_CB_NODE *cb_node, const IMAGE_STATE *img) { |
| 1273 | // Default to (0, 0, 0) granularity in case we can't find the real granularity for the physical device. |
| 1274 | VkExtent3D granularity = {0, 0, 0}; |
| 1275 | auto pPool = GetCommandPoolNode(device_data, cb_node->createInfo.commandPool); |
| 1276 | if (pPool) { |
| 1277 | granularity = |
| 1278 | GetPhysDevProperties(device_data)->queue_family_properties[pPool->queueFamilyIndex].minImageTransferGranularity; |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 1279 | if (FormatIsCompressed(img->createInfo.format)) { |
| 1280 | auto block_size = FormatCompressedTexelBlockExtent(img->createInfo.format); |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1281 | granularity.width *= block_size.width; |
| 1282 | granularity.height *= block_size.height; |
| 1283 | } |
| 1284 | } |
| 1285 | return granularity; |
| 1286 | } |
| 1287 | |
| 1288 | // Test elements of a VkExtent3D structure against alignment constraints contained in another VkExtent3D structure |
| 1289 | static inline bool IsExtentAligned(const VkExtent3D *extent, const VkExtent3D *granularity) { |
| 1290 | bool valid = true; |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 1291 | if ((SafeModulo(extent->depth, granularity->depth) != 0) || (SafeModulo(extent->width, granularity->width) != 0) || |
| 1292 | (SafeModulo(extent->height, granularity->height) != 0)) { |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1293 | valid = false; |
| 1294 | } |
| 1295 | return valid; |
| 1296 | } |
| 1297 | |
| 1298 | // Check elements of a VkOffset3D structure against a queue family's Image Transfer Granularity values |
| 1299 | static inline bool CheckItgOffset(layer_data *device_data, const GLOBAL_CB_NODE *cb_node, const VkOffset3D *offset, |
Cort Stratton | 420ebd4 | 2018-05-04 01:12:23 -0400 | [diff] [blame] | 1300 | const VkExtent3D *granularity, const uint32_t i, const char *function, const char *member, |
| 1301 | UNIQUE_VALIDATION_ERROR_CODE vuid) { |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1302 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
| 1303 | bool skip = false; |
| 1304 | VkExtent3D offset_extent = {}; |
| 1305 | offset_extent.width = static_cast<uint32_t>(abs(offset->x)); |
| 1306 | offset_extent.height = static_cast<uint32_t>(abs(offset->y)); |
| 1307 | offset_extent.depth = static_cast<uint32_t>(abs(offset->z)); |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 1308 | if (IsExtentAllZeroes(granularity)) { |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1309 | // If the queue family image transfer granularity is (0, 0, 0), then the offset must always be (0, 0, 0) |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 1310 | if (IsExtentAllZeroes(&offset_extent) == false) { |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 1311 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Cort Stratton | 420ebd4 | 2018-05-04 01:12:23 -0400 | [diff] [blame] | 1312 | HandleToUint64(cb_node->commandBuffer), vuid, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1313 | "%s: pRegion[%d].%s (x=%d, y=%d, z=%d) must be (x=0, y=0, z=0) when the command buffer's queue family " |
| 1314 | "image transfer granularity is (w=0, h=0, d=0).", |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 1315 | function, i, member, offset->x, offset->y, offset->z); |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1316 | } |
| 1317 | } else { |
| 1318 | // If the queue family image transfer granularity is not (0, 0, 0), then the offset dimensions must always be even |
| 1319 | // integer multiples of the image transfer granularity. |
| 1320 | if (IsExtentAligned(&offset_extent, granularity) == false) { |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 1321 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Cort Stratton | 420ebd4 | 2018-05-04 01:12:23 -0400 | [diff] [blame] | 1322 | HandleToUint64(cb_node->commandBuffer), vuid, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1323 | "%s: pRegion[%d].%s (x=%d, y=%d, z=%d) dimensions must be even integer multiples of this command " |
| 1324 | "buffer's queue family image transfer granularity (w=%d, h=%d, d=%d).", |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 1325 | function, i, member, offset->x, offset->y, offset->z, granularity->width, granularity->height, |
| 1326 | granularity->depth); |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1327 | } |
| 1328 | } |
| 1329 | return skip; |
| 1330 | } |
| 1331 | |
| 1332 | // Check elements of a VkExtent3D structure against a queue family's Image Transfer Granularity values |
| 1333 | static inline bool CheckItgExtent(layer_data *device_data, const GLOBAL_CB_NODE *cb_node, const VkExtent3D *extent, |
| 1334 | const VkOffset3D *offset, const VkExtent3D *granularity, const VkExtent3D *subresource_extent, |
Cort Stratton | 420ebd4 | 2018-05-04 01:12:23 -0400 | [diff] [blame] | 1335 | const VkImageType image_type, const uint32_t i, const char *function, const char *member, |
| 1336 | UNIQUE_VALIDATION_ERROR_CODE vuid) { |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1337 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
| 1338 | bool skip = false; |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 1339 | if (IsExtentAllZeroes(granularity)) { |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1340 | // If the queue family image transfer granularity is (0, 0, 0), then the extent must always match the image |
| 1341 | // subresource extent. |
| 1342 | if (IsExtentEqual(extent, subresource_extent) == false) { |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 1343 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Cort Stratton | 420ebd4 | 2018-05-04 01:12:23 -0400 | [diff] [blame] | 1344 | HandleToUint64(cb_node->commandBuffer), vuid, |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 1345 | "%s: pRegion[%d].%s (w=%d, h=%d, d=%d) must match the image subresource extents (w=%d, h=%d, d=%d) " |
| 1346 | "when the command buffer's queue family image transfer granularity is (w=0, h=0, d=0).", |
| 1347 | function, i, member, extent->width, extent->height, extent->depth, subresource_extent->width, |
| 1348 | subresource_extent->height, subresource_extent->depth); |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1349 | } |
| 1350 | } else { |
| 1351 | // If the queue family image transfer granularity is not (0, 0, 0), then the extent dimensions must always be even |
| 1352 | // integer multiples of the image transfer granularity or the offset + extent dimensions must always match the image |
| 1353 | // subresource extent dimensions. |
| 1354 | VkExtent3D offset_extent_sum = {}; |
| 1355 | offset_extent_sum.width = static_cast<uint32_t>(abs(offset->x)) + extent->width; |
| 1356 | offset_extent_sum.height = static_cast<uint32_t>(abs(offset->y)) + extent->height; |
| 1357 | offset_extent_sum.depth = static_cast<uint32_t>(abs(offset->z)) + extent->depth; |
Mark Lobodzinski | 283ade6 | 2017-10-09 16:36:49 -0600 | [diff] [blame] | 1358 | bool x_ok = true; |
| 1359 | bool y_ok = true; |
| 1360 | bool z_ok = true; |
| 1361 | switch (image_type) { |
| 1362 | case VK_IMAGE_TYPE_3D: |
| 1363 | z_ok = ((0 == SafeModulo(extent->depth, granularity->depth)) || |
| 1364 | (subresource_extent->depth == offset_extent_sum.depth)); |
Tobin Ehlis | 648b1cf | 2018-04-13 15:24:13 -0600 | [diff] [blame] | 1365 | // fall through |
Mark Lobodzinski | 283ade6 | 2017-10-09 16:36:49 -0600 | [diff] [blame] | 1366 | case VK_IMAGE_TYPE_2D: |
| 1367 | y_ok = ((0 == SafeModulo(extent->height, granularity->height)) || |
| 1368 | (subresource_extent->height == offset_extent_sum.height)); |
Tobin Ehlis | 648b1cf | 2018-04-13 15:24:13 -0600 | [diff] [blame] | 1369 | // fall through |
Mark Lobodzinski | 283ade6 | 2017-10-09 16:36:49 -0600 | [diff] [blame] | 1370 | case VK_IMAGE_TYPE_1D: |
| 1371 | x_ok = ((0 == SafeModulo(extent->width, granularity->width)) || |
| 1372 | (subresource_extent->width == offset_extent_sum.width)); |
| 1373 | break; |
| 1374 | default: |
| 1375 | // Unrecognized or new IMAGE_TYPE enums will be caught in parameter_validation |
| 1376 | assert(false); |
| 1377 | } |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1378 | if (!(x_ok && y_ok && z_ok)) { |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1379 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Cort Stratton | 420ebd4 | 2018-05-04 01:12:23 -0400 | [diff] [blame] | 1380 | HandleToUint64(cb_node->commandBuffer), vuid, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1381 | "%s: pRegion[%d].%s (w=%d, h=%d, d=%d) dimensions must be even integer multiples of this command " |
| 1382 | "buffer's queue family image transfer granularity (w=%d, h=%d, d=%d) or offset (x=%d, y=%d, z=%d) + " |
| 1383 | "extent (w=%d, h=%d, d=%d) must match the image subresource extents (w=%d, h=%d, d=%d).", |
| 1384 | function, i, member, extent->width, extent->height, extent->depth, granularity->width, |
| 1385 | granularity->height, granularity->depth, offset->x, offset->y, offset->z, extent->width, extent->height, |
| 1386 | extent->depth, subresource_extent->width, subresource_extent->height, subresource_extent->depth); |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1387 | } |
| 1388 | } |
| 1389 | return skip; |
| 1390 | } |
| 1391 | |
Mark Lobodzinski | bf0042d | 2018-02-26 16:01:22 -0700 | [diff] [blame] | 1392 | // Check valid usage Image Transfer Granularity requirements for elements of a VkBufferImageCopy structure |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1393 | bool ValidateCopyBufferImageTransferGranularityRequirements(layer_data *device_data, const GLOBAL_CB_NODE *cb_node, |
| 1394 | const IMAGE_STATE *img, const VkBufferImageCopy *region, |
Cort Stratton | 420ebd4 | 2018-05-04 01:12:23 -0400 | [diff] [blame] | 1395 | const uint32_t i, const char *function, |
| 1396 | UNIQUE_VALIDATION_ERROR_CODE vuid) { |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1397 | bool skip = false; |
Cort Stratton | 420ebd4 | 2018-05-04 01:12:23 -0400 | [diff] [blame] | 1398 | VkExtent3D granularity = GetScaledItg(device_data, cb_node, img); |
| 1399 | skip |= CheckItgOffset(device_data, cb_node, ®ion->imageOffset, &granularity, i, function, "imageOffset", vuid); |
| 1400 | VkExtent3D subresource_extent = GetImageSubresourceExtent(img, ®ion->imageSubresource); |
| 1401 | skip |= CheckItgExtent(device_data, cb_node, ®ion->imageExtent, ®ion->imageOffset, &granularity, &subresource_extent, |
| 1402 | img->createInfo.imageType, i, function, "imageExtent", vuid); |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1403 | return skip; |
| 1404 | } |
| 1405 | |
Mark Lobodzinski | bf0042d | 2018-02-26 16:01:22 -0700 | [diff] [blame] | 1406 | // Check valid usage Image Transfer Granularity requirements for elements of a VkImageCopy structure |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1407 | bool ValidateCopyImageTransferGranularityRequirements(layer_data *device_data, const GLOBAL_CB_NODE *cb_node, |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1408 | const IMAGE_STATE *src_img, const IMAGE_STATE *dst_img, |
| 1409 | const VkImageCopy *region, const uint32_t i, const char *function) { |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1410 | bool skip = false; |
Mark Lobodzinski | d078880 | 2017-10-19 15:38:59 -0600 | [diff] [blame] | 1411 | // Source image checks |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1412 | VkExtent3D granularity = GetScaledItg(device_data, cb_node, src_img); |
Cort Stratton | 420ebd4 | 2018-05-04 01:12:23 -0400 | [diff] [blame] | 1413 | skip |= |
| 1414 | CheckItgOffset(device_data, cb_node, ®ion->srcOffset, &granularity, i, function, "srcOffset", VALIDATION_ERROR_19000dee); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1415 | VkExtent3D subresource_extent = GetImageSubresourceExtent(src_img, ®ion->srcSubresource); |
Dave Houlton | 94a0037 | 2017-12-14 15:08:47 -0700 | [diff] [blame] | 1416 | const VkExtent3D extent = region->extent; |
Mark Lobodzinski | d078880 | 2017-10-19 15:38:59 -0600 | [diff] [blame] | 1417 | skip |= CheckItgExtent(device_data, cb_node, &extent, ®ion->srcOffset, &granularity, &subresource_extent, |
Cort Stratton | 420ebd4 | 2018-05-04 01:12:23 -0400 | [diff] [blame] | 1418 | src_img->createInfo.imageType, i, function, "extent", VALIDATION_ERROR_19000dee); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1419 | |
Mark Lobodzinski | d078880 | 2017-10-19 15:38:59 -0600 | [diff] [blame] | 1420 | // Destination image checks |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1421 | granularity = GetScaledItg(device_data, cb_node, dst_img); |
Cort Stratton | 420ebd4 | 2018-05-04 01:12:23 -0400 | [diff] [blame] | 1422 | skip |= |
| 1423 | CheckItgOffset(device_data, cb_node, ®ion->dstOffset, &granularity, i, function, "dstOffset", VALIDATION_ERROR_19000df0); |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1424 | // Adjust dest extent, if necessary |
Dave Houlton | 94a0037 | 2017-12-14 15:08:47 -0700 | [diff] [blame] | 1425 | const VkExtent3D dest_effective_extent = |
| 1426 | GetAdjustedDestImageExtent(src_img->createInfo.format, dst_img->createInfo.format, extent); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1427 | subresource_extent = GetImageSubresourceExtent(dst_img, ®ion->dstSubresource); |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1428 | skip |= CheckItgExtent(device_data, cb_node, &dest_effective_extent, ®ion->dstOffset, &granularity, &subresource_extent, |
Cort Stratton | 420ebd4 | 2018-05-04 01:12:23 -0400 | [diff] [blame] | 1429 | dst_img->createInfo.imageType, i, function, "extent", VALIDATION_ERROR_19000df0); |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1430 | return skip; |
| 1431 | } |
| 1432 | |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1433 | // Validate contents of a VkImageCopy struct |
| 1434 | bool ValidateImageCopyData(const layer_data *device_data, const debug_report_data *report_data, const uint32_t regionCount, |
| 1435 | const VkImageCopy *ic_regions, const IMAGE_STATE *src_state, const IMAGE_STATE *dst_state) { |
| 1436 | bool skip = false; |
| 1437 | |
| 1438 | for (uint32_t i = 0; i < regionCount; i++) { |
Dave Houlton | 94a0037 | 2017-12-14 15:08:47 -0700 | [diff] [blame] | 1439 | const VkImageCopy region = ic_regions[i]; |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1440 | |
| 1441 | // For comp<->uncomp copies, the copy extent for the dest image must be adjusted |
Dave Houlton | 94a0037 | 2017-12-14 15:08:47 -0700 | [diff] [blame] | 1442 | const VkExtent3D src_copy_extent = region.extent; |
| 1443 | const VkExtent3D dst_copy_extent = |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1444 | GetAdjustedDestImageExtent(src_state->createInfo.format, dst_state->createInfo.format, region.extent); |
| 1445 | |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1446 | bool slice_override = false; |
| 1447 | uint32_t depth_slices = 0; |
| 1448 | |
| 1449 | // Special case for copying between a 1D/2D array and a 3D image |
| 1450 | // TBD: This seems like the only way to reconcile 3 mutually-exclusive VU checks for 2D/3D copies. Heads up. |
| 1451 | if ((VK_IMAGE_TYPE_3D == src_state->createInfo.imageType) && (VK_IMAGE_TYPE_3D != dst_state->createInfo.imageType)) { |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1452 | depth_slices = region.dstSubresource.layerCount; // Slice count from 2D subresource |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1453 | slice_override = (depth_slices != 1); |
| 1454 | } else if ((VK_IMAGE_TYPE_3D == dst_state->createInfo.imageType) && (VK_IMAGE_TYPE_3D != src_state->createInfo.imageType)) { |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1455 | depth_slices = region.srcSubresource.layerCount; // Slice count from 2D subresource |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1456 | slice_override = (depth_slices != 1); |
| 1457 | } |
| 1458 | |
| 1459 | // Do all checks on source image |
| 1460 | // |
| 1461 | if (src_state->createInfo.imageType == VK_IMAGE_TYPE_1D) { |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1462 | if ((0 != region.srcOffset.y) || (1 != src_copy_extent.height)) { |
| 1463 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1464 | HandleToUint64(src_state->image), VALIDATION_ERROR_09c00124, |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1465 | "vkCmdCopyImage(): pRegion[%d] srcOffset.y is %d and extent.height is %d. For 1D images these must " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1466 | "be 0 and 1, respectively.", |
| 1467 | i, region.srcOffset.y, src_copy_extent.height); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1468 | } |
| 1469 | } |
| 1470 | |
Dave Houlton | 533be9f | 2018-03-26 17:08:30 -0600 | [diff] [blame] | 1471 | // VUID-VkImageCopy-srcImage-01785 |
| 1472 | if ((src_state->createInfo.imageType == VK_IMAGE_TYPE_1D) && ((0 != region.srcOffset.z) || (1 != src_copy_extent.depth))) { |
| 1473 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1474 | HandleToUint64(src_state->image), VALIDATION_ERROR_09c00df2, |
Dave Houlton | 533be9f | 2018-03-26 17:08:30 -0600 | [diff] [blame] | 1475 | "vkCmdCopyImage(): pRegion[%d] srcOffset.z is %d and extent.depth is %d. For 1D images " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1476 | "these must be 0 and 1, respectively.", |
| 1477 | i, region.srcOffset.z, src_copy_extent.depth); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1478 | } |
| 1479 | |
Dave Houlton | 533be9f | 2018-03-26 17:08:30 -0600 | [diff] [blame] | 1480 | // VUID-VkImageCopy-srcImage-01787 |
| 1481 | if ((src_state->createInfo.imageType == VK_IMAGE_TYPE_2D) && (0 != region.srcOffset.z)) { |
| 1482 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1483 | HandleToUint64(src_state->image), VALIDATION_ERROR_09c00df6, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1484 | "vkCmdCopyImage(): pRegion[%d] srcOffset.z is %d. For 2D images the z-offset must be 0.", i, |
| 1485 | region.srcOffset.z); |
Dave Houlton | 533be9f | 2018-03-26 17:08:30 -0600 | [diff] [blame] | 1486 | } |
| 1487 | |
Mark Lobodzinski | 28426ae | 2017-06-01 07:56:38 -0600 | [diff] [blame] | 1488 | if (GetDeviceExtensions(device_data)->vk_khr_maintenance1) { |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1489 | if (src_state->createInfo.imageType == VK_IMAGE_TYPE_3D) { |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1490 | if ((0 != region.srcSubresource.baseArrayLayer) || (1 != region.srcSubresource.layerCount)) { |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1491 | skip |= |
| 1492 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1493 | HandleToUint64(src_state->image), VALIDATION_ERROR_09c0011a, |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1494 | "vkCmdCopyImage(): pRegion[%d] srcSubresource.baseArrayLayer is %d and srcSubresource.layerCount " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1495 | "is %d. For VK_IMAGE_TYPE_3D images these must be 0 and 1, respectively.", |
| 1496 | i, region.srcSubresource.baseArrayLayer, region.srcSubresource.layerCount); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1497 | } |
| 1498 | } |
| 1499 | } else { // Pre maint 1 |
| 1500 | if (src_state->createInfo.imageType == VK_IMAGE_TYPE_3D || dst_state->createInfo.imageType == VK_IMAGE_TYPE_3D) { |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1501 | if ((0 != region.srcSubresource.baseArrayLayer) || (1 != region.srcSubresource.layerCount)) { |
Petr Kraus | 13c98a6 | 2017-12-09 00:22:39 +0100 | [diff] [blame] | 1502 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1503 | HandleToUint64(src_state->image), VALIDATION_ERROR_09c0011a, |
Petr Kraus | 13c98a6 | 2017-12-09 00:22:39 +0100 | [diff] [blame] | 1504 | "vkCmdCopyImage(): pRegion[%d] srcSubresource.baseArrayLayer is %d and " |
| 1505 | "srcSubresource.layerCount is %d. For copies with either source or dest of type " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1506 | "VK_IMAGE_TYPE_3D, these must be 0 and 1, respectively.", |
| 1507 | i, region.srcSubresource.baseArrayLayer, region.srcSubresource.layerCount); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1508 | } |
| 1509 | } |
| 1510 | } |
| 1511 | |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1512 | // Source checks that apply only to compressed images (or to _422 images if ycbcr enabled) |
| 1513 | bool ext_ycbcr = GetDeviceExtensions(device_data)->vk_khr_sampler_ycbcr_conversion; |
| 1514 | if (FormatIsCompressed(src_state->createInfo.format) || |
| 1515 | (ext_ycbcr && FormatIsSinglePlane_422(src_state->createInfo.format))) { |
Dave Houlton | 94a0037 | 2017-12-14 15:08:47 -0700 | [diff] [blame] | 1516 | const VkExtent3D block_size = FormatCompressedTexelBlockExtent(src_state->createInfo.format); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1517 | // image offsets must be multiples of block dimensions |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1518 | if ((SafeModulo(region.srcOffset.x, block_size.width) != 0) || |
| 1519 | (SafeModulo(region.srcOffset.y, block_size.height) != 0) || |
| 1520 | (SafeModulo(region.srcOffset.z, block_size.depth) != 0)) { |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1521 | UNIQUE_VALIDATION_ERROR_CODE vuid = ext_ycbcr ? VALIDATION_ERROR_09c00d7e : VALIDATION_ERROR_09c0013a; |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1522 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1523 | HandleToUint64(src_state->image), vuid, |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1524 | "vkCmdCopyImage(): pRegion[%d] srcOffset (%d, %d) must be multiples of the compressed image's " |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1525 | "texel width & height (%d, %d).", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1526 | i, region.srcOffset.x, region.srcOffset.y, block_size.width, block_size.height); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1527 | } |
| 1528 | |
Dave Houlton | 94a0037 | 2017-12-14 15:08:47 -0700 | [diff] [blame] | 1529 | const VkExtent3D mip_extent = GetImageSubresourceExtent(src_state, &(region.srcSubresource)); |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1530 | if ((SafeModulo(src_copy_extent.width, block_size.width) != 0) && |
| 1531 | (src_copy_extent.width + region.srcOffset.x != mip_extent.width)) { |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1532 | UNIQUE_VALIDATION_ERROR_CODE vuid = ext_ycbcr ? VALIDATION_ERROR_09c00d80 : VALIDATION_ERROR_09c0013c; |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1533 | skip |= |
| 1534 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1535 | HandleToUint64(src_state->image), vuid, |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1536 | "vkCmdCopyImage(): pRegion[%d] extent width (%d) must be a multiple of the compressed texture block " |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1537 | "width (%d), or when added to srcOffset.x (%d) must equal the image subresource width (%d).", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1538 | i, src_copy_extent.width, block_size.width, region.srcOffset.x, mip_extent.width); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1539 | } |
| 1540 | |
Mark Lobodzinski | d078880 | 2017-10-19 15:38:59 -0600 | [diff] [blame] | 1541 | // Extent height must be a multiple of block height, or extent+offset height must equal subresource height |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1542 | if ((SafeModulo(src_copy_extent.height, block_size.height) != 0) && |
| 1543 | (src_copy_extent.height + region.srcOffset.y != mip_extent.height)) { |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1544 | UNIQUE_VALIDATION_ERROR_CODE vuid = ext_ycbcr ? VALIDATION_ERROR_09c00d82 : VALIDATION_ERROR_09c0013e; |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1545 | skip |= |
| 1546 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1547 | HandleToUint64(src_state->image), vuid, |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1548 | "vkCmdCopyImage(): pRegion[%d] extent height (%d) must be a multiple of the compressed texture block " |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1549 | "height (%d), or when added to srcOffset.y (%d) must equal the image subresource height (%d).", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1550 | i, src_copy_extent.height, block_size.height, region.srcOffset.y, mip_extent.height); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1551 | } |
| 1552 | |
Mark Lobodzinski | d078880 | 2017-10-19 15:38:59 -0600 | [diff] [blame] | 1553 | // Extent depth must be a multiple of block depth, or extent+offset depth must equal subresource depth |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1554 | uint32_t copy_depth = (slice_override ? depth_slices : src_copy_extent.depth); |
| 1555 | if ((SafeModulo(copy_depth, block_size.depth) != 0) && (copy_depth + region.srcOffset.z != mip_extent.depth)) { |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1556 | UNIQUE_VALIDATION_ERROR_CODE vuid = ext_ycbcr ? VALIDATION_ERROR_09c00d84 : VALIDATION_ERROR_09c00140; |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1557 | skip |= |
| 1558 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1559 | HandleToUint64(src_state->image), vuid, |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1560 | "vkCmdCopyImage(): pRegion[%d] extent width (%d) must be a multiple of the compressed texture block " |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1561 | "depth (%d), or when added to srcOffset.z (%d) must equal the image subresource depth (%d).", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1562 | i, src_copy_extent.depth, block_size.depth, region.srcOffset.z, mip_extent.depth); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1563 | } |
| 1564 | } // Compressed |
| 1565 | |
| 1566 | // Do all checks on dest image |
| 1567 | // |
| 1568 | if (dst_state->createInfo.imageType == VK_IMAGE_TYPE_1D) { |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1569 | if ((0 != region.dstOffset.y) || (1 != dst_copy_extent.height)) { |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1570 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1571 | HandleToUint64(dst_state->image), VALIDATION_ERROR_09c00130, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1572 | "vkCmdCopyImage(): pRegion[%d] dstOffset.y is %d and dst_copy_extent.height is %d. For 1D images " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1573 | "these must be 0 and 1, respectively.", |
| 1574 | i, region.dstOffset.y, dst_copy_extent.height); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1575 | } |
| 1576 | } |
| 1577 | |
Dave Houlton | 533be9f | 2018-03-26 17:08:30 -0600 | [diff] [blame] | 1578 | // VUID-VkImageCopy-dstImage-01786 |
| 1579 | if ((dst_state->createInfo.imageType == VK_IMAGE_TYPE_1D) && ((0 != region.dstOffset.z) || (1 != dst_copy_extent.depth))) { |
| 1580 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1581 | HandleToUint64(dst_state->image), VALIDATION_ERROR_09c00df4, |
Dave Houlton | 533be9f | 2018-03-26 17:08:30 -0600 | [diff] [blame] | 1582 | "vkCmdCopyImage(): pRegion[%d] dstOffset.z is %d and extent.depth is %d. For 1D images these must be 0 " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1583 | "and 1, respectively.", |
| 1584 | i, region.dstOffset.z, dst_copy_extent.depth); |
Dave Houlton | 533be9f | 2018-03-26 17:08:30 -0600 | [diff] [blame] | 1585 | } |
| 1586 | |
| 1587 | // VUID-VkImageCopy-dstImage-01788 |
| 1588 | if ((dst_state->createInfo.imageType == VK_IMAGE_TYPE_2D) && (0 != region.dstOffset.z)) { |
| 1589 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1590 | HandleToUint64(dst_state->image), VALIDATION_ERROR_09c00df8, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1591 | "vkCmdCopyImage(): pRegion[%d] dstOffset.z is %d. For 2D images the z-offset must be 0.", i, |
| 1592 | region.dstOffset.z); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1593 | } |
| 1594 | |
| 1595 | if (dst_state->createInfo.imageType == VK_IMAGE_TYPE_3D) { |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1596 | if ((0 != region.dstSubresource.baseArrayLayer) || (1 != region.dstSubresource.layerCount)) { |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1597 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1598 | HandleToUint64(dst_state->image), VALIDATION_ERROR_09c0011a, |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1599 | "vkCmdCopyImage(): pRegion[%d] dstSubresource.baseArrayLayer is %d and dstSubresource.layerCount " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1600 | "is %d. For VK_IMAGE_TYPE_3D images these must be 0 and 1, respectively.", |
| 1601 | i, region.dstSubresource.baseArrayLayer, region.dstSubresource.layerCount); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1602 | } |
| 1603 | } |
| 1604 | // VU01199 changed with mnt1 |
Mark Lobodzinski | 28426ae | 2017-06-01 07:56:38 -0600 | [diff] [blame] | 1605 | if (GetDeviceExtensions(device_data)->vk_khr_maintenance1) { |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1606 | if (dst_state->createInfo.imageType == VK_IMAGE_TYPE_3D) { |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1607 | if ((0 != region.dstSubresource.baseArrayLayer) || (1 != region.dstSubresource.layerCount)) { |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1608 | skip |= |
| 1609 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1610 | HandleToUint64(dst_state->image), VALIDATION_ERROR_09c0011a, |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1611 | "vkCmdCopyImage(): pRegion[%d] dstSubresource.baseArrayLayer is %d and dstSubresource.layerCount " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1612 | "is %d. For VK_IMAGE_TYPE_3D images these must be 0 and 1, respectively.", |
| 1613 | i, region.dstSubresource.baseArrayLayer, region.dstSubresource.layerCount); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1614 | } |
| 1615 | } |
| 1616 | } else { // Pre maint 1 |
| 1617 | if (src_state->createInfo.imageType == VK_IMAGE_TYPE_3D || dst_state->createInfo.imageType == VK_IMAGE_TYPE_3D) { |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1618 | if ((0 != region.dstSubresource.baseArrayLayer) || (1 != region.dstSubresource.layerCount)) { |
Petr Kraus | 13c98a6 | 2017-12-09 00:22:39 +0100 | [diff] [blame] | 1619 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1620 | HandleToUint64(dst_state->image), VALIDATION_ERROR_09c0011a, |
Petr Kraus | 13c98a6 | 2017-12-09 00:22:39 +0100 | [diff] [blame] | 1621 | "vkCmdCopyImage(): pRegion[%d] dstSubresource.baseArrayLayer is %d and " |
| 1622 | "dstSubresource.layerCount is %d. For copies with either source or dest of type " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1623 | "VK_IMAGE_TYPE_3D, these must be 0 and 1, respectively.", |
| 1624 | i, region.dstSubresource.baseArrayLayer, region.dstSubresource.layerCount); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1625 | } |
| 1626 | } |
| 1627 | } |
| 1628 | |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1629 | // Dest checks that apply only to compressed images (or to _422 images if ycbcr enabled) |
| 1630 | if (FormatIsCompressed(dst_state->createInfo.format) || |
| 1631 | (ext_ycbcr && FormatIsSinglePlane_422(dst_state->createInfo.format))) { |
Dave Houlton | 94a0037 | 2017-12-14 15:08:47 -0700 | [diff] [blame] | 1632 | const VkExtent3D block_size = FormatCompressedTexelBlockExtent(dst_state->createInfo.format); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1633 | |
| 1634 | // image offsets must be multiples of block dimensions |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1635 | if ((SafeModulo(region.dstOffset.x, block_size.width) != 0) || |
| 1636 | (SafeModulo(region.dstOffset.y, block_size.height) != 0) || |
| 1637 | (SafeModulo(region.dstOffset.z, block_size.depth) != 0)) { |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1638 | UNIQUE_VALIDATION_ERROR_CODE vuid = ext_ycbcr ? VALIDATION_ERROR_09c00d86 : VALIDATION_ERROR_09c00144; |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1639 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1640 | HandleToUint64(dst_state->image), vuid, |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1641 | "vkCmdCopyImage(): pRegion[%d] dstOffset (%d, %d) must be multiples of the compressed image's " |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1642 | "texel width & height (%d, %d).", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1643 | i, region.dstOffset.x, region.dstOffset.y, block_size.width, block_size.height); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1644 | } |
| 1645 | |
Dave Houlton | 94a0037 | 2017-12-14 15:08:47 -0700 | [diff] [blame] | 1646 | const VkExtent3D mip_extent = GetImageSubresourceExtent(dst_state, &(region.dstSubresource)); |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1647 | if ((SafeModulo(dst_copy_extent.width, block_size.width) != 0) && |
| 1648 | (dst_copy_extent.width + region.dstOffset.x != mip_extent.width)) { |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1649 | UNIQUE_VALIDATION_ERROR_CODE vuid = ext_ycbcr ? VALIDATION_ERROR_09c00d88 : VALIDATION_ERROR_09c00146; |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1650 | skip |= |
| 1651 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1652 | HandleToUint64(dst_state->image), vuid, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1653 | "vkCmdCopyImage(): pRegion[%d] dst_copy_extent width (%d) must be a multiple of the compressed texture " |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1654 | "block width (%d), or when added to dstOffset.x (%d) must equal the image subresource width (%d).", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1655 | i, dst_copy_extent.width, block_size.width, region.dstOffset.x, mip_extent.width); |
Mark Lobodzinski | d078880 | 2017-10-19 15:38:59 -0600 | [diff] [blame] | 1656 | } |
| 1657 | |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1658 | // Extent height must be a multiple of block height, or dst_copy_extent+offset height must equal subresource height |
| 1659 | if ((SafeModulo(dst_copy_extent.height, block_size.height) != 0) && |
| 1660 | (dst_copy_extent.height + region.dstOffset.y != mip_extent.height)) { |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1661 | UNIQUE_VALIDATION_ERROR_CODE vuid = ext_ycbcr ? VALIDATION_ERROR_09c00d8a : VALIDATION_ERROR_09c00148; |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1662 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1663 | HandleToUint64(dst_state->image), vuid, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1664 | "vkCmdCopyImage(): pRegion[%d] dst_copy_extent height (%d) must be a multiple of the compressed " |
| 1665 | "texture block height (%d), or when added to dstOffset.y (%d) must equal the image subresource " |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1666 | "height (%d).", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1667 | i, dst_copy_extent.height, block_size.height, region.dstOffset.y, mip_extent.height); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1668 | } |
| 1669 | |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1670 | // Extent depth must be a multiple of block depth, or dst_copy_extent+offset depth must equal subresource depth |
| 1671 | uint32_t copy_depth = (slice_override ? depth_slices : dst_copy_extent.depth); |
| 1672 | if ((SafeModulo(copy_depth, block_size.depth) != 0) && (copy_depth + region.dstOffset.z != mip_extent.depth)) { |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1673 | UNIQUE_VALIDATION_ERROR_CODE vuid = ext_ycbcr ? VALIDATION_ERROR_09c00d8c : VALIDATION_ERROR_09c0014a; |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1674 | skip |= |
| 1675 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1676 | HandleToUint64(dst_state->image), vuid, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 1677 | "vkCmdCopyImage(): pRegion[%d] dst_copy_extent width (%d) must be a multiple of the compressed texture " |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1678 | "block depth (%d), or when added to dstOffset.z (%d) must equal the image subresource depth (%d).", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1679 | i, dst_copy_extent.depth, block_size.depth, region.dstOffset.z, mip_extent.depth); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1680 | } |
| 1681 | } // Compressed |
| 1682 | } |
| 1683 | return skip; |
| 1684 | } |
| 1685 | |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1686 | // vkCmdCopyImage checks that only apply if the multiplane extension is enabled |
| 1687 | bool CopyImageMultiplaneValidation(const layer_data *dev_data, VkCommandBuffer command_buffer, const IMAGE_STATE *src_image_state, |
| 1688 | const IMAGE_STATE *dst_image_state, const VkImageCopy region) { |
| 1689 | bool skip = false; |
| 1690 | const debug_report_data *report_data = core_validation::GetReportData(dev_data); |
| 1691 | |
| 1692 | // Neither image is multiplane |
| 1693 | if ((!FormatIsMultiplane(src_image_state->createInfo.format)) && (!FormatIsMultiplane(dst_image_state->createInfo.format))) { |
| 1694 | // If neither image is multi-plane the aspectMask member of src and dst must match |
| 1695 | if (region.srcSubresource.aspectMask != region.dstSubresource.aspectMask) { |
| 1696 | std::stringstream ss; |
| 1697 | ss << "vkCmdCopyImage: Copy between non-multiplane images with differing aspectMasks ( 0x" << std::hex |
| 1698 | << region.srcSubresource.aspectMask << " and 0x" << region.dstSubresource.aspectMask << " )"; |
| 1699 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 1700 | HandleToUint64(command_buffer), VALIDATION_ERROR_09c00c1e, "%s.", ss.str().c_str()); |
| 1701 | } |
| 1702 | } else { |
| 1703 | // Source image multiplane checks |
| 1704 | uint32_t planes = FormatPlaneCount(src_image_state->createInfo.format); |
| 1705 | VkImageAspectFlags aspect = region.srcSubresource.aspectMask; |
| 1706 | if ((2 == planes) && (aspect != VK_IMAGE_ASPECT_PLANE_0_BIT_KHR) && (aspect != VK_IMAGE_ASPECT_PLANE_1_BIT_KHR)) { |
| 1707 | std::stringstream ss; |
| 1708 | ss << "vkCmdCopyImage: Source image aspect mask (0x" << std::hex << aspect << ") is invalid for 2-plane format"; |
| 1709 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 1710 | HandleToUint64(command_buffer), VALIDATION_ERROR_09c00c20, "%s.", ss.str().c_str()); |
| 1711 | } |
| 1712 | if ((3 == planes) && (aspect != VK_IMAGE_ASPECT_PLANE_0_BIT_KHR) && (aspect != VK_IMAGE_ASPECT_PLANE_1_BIT_KHR) && |
| 1713 | (aspect != VK_IMAGE_ASPECT_PLANE_2_BIT_KHR)) { |
| 1714 | std::stringstream ss; |
| 1715 | ss << "vkCmdCopyImage: Source image aspect mask (0x" << std::hex << aspect << ") is invalid for 3-plane format"; |
| 1716 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 1717 | HandleToUint64(command_buffer), VALIDATION_ERROR_09c00c22, "%s.", ss.str().c_str()); |
| 1718 | } |
| 1719 | // Single-plane to multi-plane |
| 1720 | if ((!FormatIsMultiplane(src_image_state->createInfo.format)) && (FormatIsMultiplane(dst_image_state->createInfo.format)) && |
| 1721 | (VK_IMAGE_ASPECT_COLOR_BIT != aspect)) { |
| 1722 | std::stringstream ss; |
| 1723 | ss << "vkCmdCopyImage: Source image aspect mask (0x" << std::hex << aspect << ") is not VK_IMAGE_ASPECT_COLOR_BIT"; |
| 1724 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 1725 | HandleToUint64(command_buffer), VALIDATION_ERROR_09c00c2a, "%s.", ss.str().c_str()); |
| 1726 | } |
| 1727 | |
| 1728 | // Dest image multiplane checks |
| 1729 | planes = FormatPlaneCount(dst_image_state->createInfo.format); |
| 1730 | aspect = region.dstSubresource.aspectMask; |
| 1731 | if ((2 == planes) && (aspect != VK_IMAGE_ASPECT_PLANE_0_BIT_KHR) && (aspect != VK_IMAGE_ASPECT_PLANE_1_BIT_KHR)) { |
| 1732 | std::stringstream ss; |
| 1733 | ss << "vkCmdCopyImage: Dest image aspect mask (0x" << std::hex << aspect << ") is invalid for 2-plane format"; |
| 1734 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 1735 | HandleToUint64(command_buffer), VALIDATION_ERROR_09c00c24, "%s.", ss.str().c_str()); |
| 1736 | } |
| 1737 | if ((3 == planes) && (aspect != VK_IMAGE_ASPECT_PLANE_0_BIT_KHR) && (aspect != VK_IMAGE_ASPECT_PLANE_1_BIT_KHR) && |
| 1738 | (aspect != VK_IMAGE_ASPECT_PLANE_2_BIT_KHR)) { |
| 1739 | std::stringstream ss; |
| 1740 | ss << "vkCmdCopyImage: Dest image aspect mask (0x" << std::hex << aspect << ") is invalid for 3-plane format"; |
| 1741 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 1742 | HandleToUint64(command_buffer), VALIDATION_ERROR_09c00c26, "%s.", ss.str().c_str()); |
| 1743 | } |
| 1744 | // Multi-plane to single-plane |
| 1745 | if ((FormatIsMultiplane(src_image_state->createInfo.format)) && (!FormatIsMultiplane(dst_image_state->createInfo.format)) && |
| 1746 | (VK_IMAGE_ASPECT_COLOR_BIT != aspect)) { |
| 1747 | std::stringstream ss; |
| 1748 | ss << "vkCmdCopyImage: Dest image aspect mask (0x" << std::hex << aspect << ") is not VK_IMAGE_ASPECT_COLOR_BIT"; |
| 1749 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 1750 | HandleToUint64(command_buffer), VALIDATION_ERROR_09c00c28, "%s.", ss.str().c_str()); |
| 1751 | } |
| 1752 | } |
| 1753 | |
| 1754 | return skip; |
| 1755 | } |
| 1756 | |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 1757 | bool PreCallValidateCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_node, IMAGE_STATE *src_image_state, |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1758 | IMAGE_STATE *dst_image_state, uint32_t region_count, const VkImageCopy *regions, |
| 1759 | VkImageLayout src_image_layout, VkImageLayout dst_image_layout) { |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 1760 | bool skip = false; |
| 1761 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1762 | skip = ValidateImageCopyData(device_data, report_data, region_count, regions, src_image_state, dst_image_state); |
| 1763 | |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 1764 | VkCommandBuffer command_buffer = cb_node->commandBuffer; |
| 1765 | |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1766 | for (uint32_t i = 0; i < region_count; i++) { |
Dave Houlton | 94a0037 | 2017-12-14 15:08:47 -0700 | [diff] [blame] | 1767 | const VkImageCopy region = regions[i]; |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1768 | |
| 1769 | // For comp/uncomp copies, the copy extent for the dest image must be adjusted |
| 1770 | VkExtent3D src_copy_extent = region.extent; |
| 1771 | VkExtent3D dst_copy_extent = |
| 1772 | GetAdjustedDestImageExtent(src_image_state->createInfo.format, dst_image_state->createInfo.format, region.extent); |
| 1773 | |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1774 | bool slice_override = false; |
| 1775 | uint32_t depth_slices = 0; |
| 1776 | |
| 1777 | // Special case for copying between a 1D/2D array and a 3D image |
| 1778 | // TBD: This seems like the only way to reconcile 3 mutually-exclusive VU checks for 2D/3D copies. Heads up. |
| 1779 | if ((VK_IMAGE_TYPE_3D == src_image_state->createInfo.imageType) && |
| 1780 | (VK_IMAGE_TYPE_3D != dst_image_state->createInfo.imageType)) { |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1781 | depth_slices = region.dstSubresource.layerCount; // Slice count from 2D subresource |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1782 | slice_override = (depth_slices != 1); |
| 1783 | } else if ((VK_IMAGE_TYPE_3D == dst_image_state->createInfo.imageType) && |
| 1784 | (VK_IMAGE_TYPE_3D != src_image_state->createInfo.imageType)) { |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1785 | depth_slices = region.srcSubresource.layerCount; // Slice count from 2D subresource |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1786 | slice_override = (depth_slices != 1); |
| 1787 | } |
| 1788 | |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1789 | if (region.srcSubresource.layerCount == 0) { |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1790 | std::stringstream ss; |
| 1791 | ss << "vkCmdCopyImage: number of layers in pRegions[" << i << "] srcSubresource is zero"; |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 1792 | skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1793 | HandleToUint64(command_buffer), DRAWSTATE_INVALID_IMAGE_ASPECT, "%s", ss.str().c_str()); |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1794 | } |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 1795 | |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1796 | if (region.dstSubresource.layerCount == 0) { |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1797 | std::stringstream ss; |
| 1798 | ss << "vkCmdCopyImage: number of layers in pRegions[" << i << "] dstSubresource is zero"; |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 1799 | skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1800 | HandleToUint64(command_buffer), DRAWSTATE_INVALID_IMAGE_ASPECT, "%s", ss.str().c_str()); |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1801 | } |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 1802 | |
Mark Lobodzinski | 28426ae | 2017-06-01 07:56:38 -0600 | [diff] [blame] | 1803 | if (GetDeviceExtensions(device_data)->vk_khr_maintenance1) { |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1804 | // No chance of mismatch if we're overriding depth slice count |
| 1805 | if (!slice_override) { |
| 1806 | // The number of depth slices in srcSubresource and dstSubresource must match |
| 1807 | // Depth comes from layerCount for 1D,2D resources, from extent.depth for 3D |
| 1808 | uint32_t src_slices = |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1809 | (VK_IMAGE_TYPE_3D == src_image_state->createInfo.imageType ? src_copy_extent.depth |
| 1810 | : region.srcSubresource.layerCount); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1811 | uint32_t dst_slices = |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1812 | (VK_IMAGE_TYPE_3D == dst_image_state->createInfo.imageType ? dst_copy_extent.depth |
| 1813 | : region.dstSubresource.layerCount); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1814 | if (src_slices != dst_slices) { |
| 1815 | std::stringstream ss; |
| 1816 | ss << "vkCmdCopyImage: number of depth slices in source and destination subresources for pRegions[" << i |
| 1817 | << "] do not match"; |
| 1818 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1819 | HandleToUint64(command_buffer), VALIDATION_ERROR_09c00118, "%s.", ss.str().c_str()); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 1820 | } |
| 1821 | } |
| 1822 | } else { |
Mike Schuchardt | 64b5bb7 | 2017-03-21 16:33:26 -0600 | [diff] [blame] | 1823 | // For each region the layerCount member of srcSubresource and dstSubresource must match |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1824 | if (region.srcSubresource.layerCount != region.dstSubresource.layerCount) { |
Mike Schuchardt | 64b5bb7 | 2017-03-21 16:33:26 -0600 | [diff] [blame] | 1825 | std::stringstream ss; |
| 1826 | ss << "vkCmdCopyImage: number of layers in source and destination subresources for pRegions[" << i |
| 1827 | << "] do not match"; |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 1828 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1829 | HandleToUint64(command_buffer), VALIDATION_ERROR_09c00118, "%s.", ss.str().c_str()); |
Mike Schuchardt | 64b5bb7 | 2017-03-21 16:33:26 -0600 | [diff] [blame] | 1830 | } |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1831 | } |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 1832 | |
Dave Houlton | c991cc9 | 2018-03-06 11:08:51 -0700 | [diff] [blame] | 1833 | // Do multiplane-specific checks, if extension enabled |
| 1834 | if (GetDeviceExtensions(device_data)->vk_khr_sampler_ycbcr_conversion) { |
| 1835 | skip |= CopyImageMultiplaneValidation(device_data, command_buffer, src_image_state, dst_image_state, region); |
| 1836 | } |
| 1837 | |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 1838 | if (!GetDeviceExtensions(device_data)->vk_khr_sampler_ycbcr_conversion) { |
| 1839 | // not multi-plane, the aspectMask member of srcSubresource and dstSubresource must match |
| 1840 | if (region.srcSubresource.aspectMask != region.dstSubresource.aspectMask) { |
| 1841 | char const str[] = "vkCmdCopyImage: Src and dest aspectMasks for each region must match"; |
| 1842 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1843 | HandleToUint64(command_buffer), VALIDATION_ERROR_09c00112, "%s.", str); |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 1844 | } |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1845 | } |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 1846 | |
Dave Houlton | 4eaaf3a | 2017-03-14 11:31:20 -0600 | [diff] [blame] | 1847 | // For each region, the aspectMask member of srcSubresource must be present in the source image |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1848 | if (!VerifyAspectsPresent(region.srcSubresource.aspectMask, src_image_state->createInfo.format)) { |
Dave Houlton | 4eaaf3a | 2017-03-14 11:31:20 -0600 | [diff] [blame] | 1849 | std::stringstream ss; |
| 1850 | ss << "vkCmdCopyImage: pRegion[" << i |
| 1851 | << "] srcSubresource.aspectMask cannot specify aspects not present in source image"; |
| 1852 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1853 | HandleToUint64(command_buffer), VALIDATION_ERROR_09c0011c, "%s.", ss.str().c_str()); |
Dave Houlton | 4eaaf3a | 2017-03-14 11:31:20 -0600 | [diff] [blame] | 1854 | } |
| 1855 | |
| 1856 | // For each region, the aspectMask member of dstSubresource must be present in the destination image |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1857 | if (!VerifyAspectsPresent(region.dstSubresource.aspectMask, dst_image_state->createInfo.format)) { |
Dave Houlton | 4eaaf3a | 2017-03-14 11:31:20 -0600 | [diff] [blame] | 1858 | std::stringstream ss; |
| 1859 | ss << "vkCmdCopyImage: pRegion[" << i << "] dstSubresource.aspectMask cannot specify aspects not present in dest image"; |
| 1860 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1861 | HandleToUint64(command_buffer), VALIDATION_ERROR_09c0011e, "%s.", ss.str().c_str()); |
Dave Houlton | 4eaaf3a | 2017-03-14 11:31:20 -0600 | [diff] [blame] | 1862 | } |
| 1863 | |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1864 | // AspectMask must not contain VK_IMAGE_ASPECT_METADATA_BIT |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1865 | if ((region.srcSubresource.aspectMask & VK_IMAGE_ASPECT_METADATA_BIT) || |
| 1866 | (region.dstSubresource.aspectMask & VK_IMAGE_ASPECT_METADATA_BIT)) { |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1867 | std::stringstream ss; |
| 1868 | ss << "vkCmdCopyImage: pRegions[" << i << "] may not specify aspectMask containing VK_IMAGE_ASPECT_METADATA_BIT"; |
| 1869 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1870 | HandleToUint64(command_buffer), VALIDATION_ERROR_0a600150, "%s.", ss.str().c_str()); |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1871 | } |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 1872 | |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1873 | // For each region, if aspectMask contains VK_IMAGE_ASPECT_COLOR_BIT, it must not contain either of |
| 1874 | // VK_IMAGE_ASPECT_DEPTH_BIT or VK_IMAGE_ASPECT_STENCIL_BIT |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1875 | if ((region.srcSubresource.aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) && |
| 1876 | (region.srcSubresource.aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT))) { |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1877 | char const str[] = "vkCmdCopyImage aspectMask cannot specify both COLOR and DEPTH/STENCIL aspects"; |
| 1878 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1879 | HandleToUint64(command_buffer), VALIDATION_ERROR_0a60014e, "%s.", str); |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1880 | } |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 1881 | |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1882 | // MipLevel must be less than the mipLevels specified in VkImageCreateInfo when the image was created |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1883 | if (region.srcSubresource.mipLevel >= src_image_state->createInfo.mipLevels) { |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1884 | std::stringstream ss; |
| 1885 | ss << "vkCmdCopyImage: pRegions[" << i |
| 1886 | << "] specifies a src mipLevel greater than the number specified when the srcImage was created."; |
| 1887 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1888 | HandleToUint64(command_buffer), VALIDATION_ERROR_19000d40, "%s.", ss.str().c_str()); |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1889 | } |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1890 | if (region.dstSubresource.mipLevel >= dst_image_state->createInfo.mipLevels) { |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1891 | std::stringstream ss; |
| 1892 | ss << "vkCmdCopyImage: pRegions[" << i |
| 1893 | << "] specifies a dst mipLevel greater than the number specified when the dstImage was created."; |
| 1894 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1895 | HandleToUint64(command_buffer), VALIDATION_ERROR_19000d42, "%s.", ss.str().c_str()); |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1896 | } |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 1897 | |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1898 | // (baseArrayLayer + layerCount) must be less than or equal to the arrayLayers specified in VkImageCreateInfo when the |
| 1899 | // image was created |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1900 | if ((region.srcSubresource.baseArrayLayer + region.srcSubresource.layerCount) > src_image_state->createInfo.arrayLayers) { |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1901 | std::stringstream ss; |
| 1902 | ss << "vkCmdCopyImage: srcImage arrayLayers was " << src_image_state->createInfo.arrayLayers << " but subRegion[" << i |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1903 | << "] baseArrayLayer + layerCount is " << (region.srcSubresource.baseArrayLayer + region.srcSubresource.layerCount); |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1904 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1905 | HandleToUint64(command_buffer), VALIDATION_ERROR_19000d44, "%s.", ss.str().c_str()); |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1906 | } |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1907 | if ((region.dstSubresource.baseArrayLayer + region.dstSubresource.layerCount) > dst_image_state->createInfo.arrayLayers) { |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1908 | std::stringstream ss; |
| 1909 | ss << "vkCmdCopyImage: dstImage arrayLayers was " << dst_image_state->createInfo.arrayLayers << " but subRegion[" << i |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1910 | << "] baseArrayLayer + layerCount is " << (region.dstSubresource.baseArrayLayer + region.dstSubresource.layerCount); |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1911 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1912 | HandleToUint64(command_buffer), VALIDATION_ERROR_19000d46, "%s.", ss.str().c_str()); |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1913 | } |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 1914 | |
Mike Schuchardt | 64b5bb7 | 2017-03-21 16:33:26 -0600 | [diff] [blame] | 1915 | // Check region extents for 1D-1D, 2D-2D, and 3D-3D copies |
| 1916 | if (src_image_state->createInfo.imageType == dst_image_state->createInfo.imageType) { |
| 1917 | // The source region specified by a given element of regions must be a region that is contained within srcImage |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1918 | VkExtent3D img_extent = GetImageSubresourceExtent(src_image_state, &(region.srcSubresource)); |
| 1919 | if (0 != ExceedsBounds(®ion.srcOffset, &src_copy_extent, &img_extent)) { |
Mike Schuchardt | 64b5bb7 | 2017-03-21 16:33:26 -0600 | [diff] [blame] | 1920 | std::stringstream ss; |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1921 | ss << "vkCmdCopyImage: Source pRegion[" << i << "] with mipLevel [ " << region.srcSubresource.mipLevel |
| 1922 | << " ], offset [ " << region.srcOffset.x << ", " << region.srcOffset.y << ", " << region.srcOffset.z |
| 1923 | << " ], extent [ " << src_copy_extent.width << ", " << src_copy_extent.height << ", " << src_copy_extent.depth |
| 1924 | << " ] exceeds the source image dimensions"; |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 1925 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1926 | HandleToUint64(command_buffer), VALIDATION_ERROR_190000f4, "%s.", ss.str().c_str()); |
Mike Schuchardt | 64b5bb7 | 2017-03-21 16:33:26 -0600 | [diff] [blame] | 1927 | } |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 1928 | |
Mike Schuchardt | 64b5bb7 | 2017-03-21 16:33:26 -0600 | [diff] [blame] | 1929 | // The destination region specified by a given element of regions must be a region that is contained within dst_image |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1930 | img_extent = GetImageSubresourceExtent(dst_image_state, &(region.dstSubresource)); |
| 1931 | if (0 != ExceedsBounds(®ion.dstOffset, &dst_copy_extent, &img_extent)) { |
Mike Schuchardt | 64b5bb7 | 2017-03-21 16:33:26 -0600 | [diff] [blame] | 1932 | std::stringstream ss; |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1933 | ss << "vkCmdCopyImage: Dest pRegion[" << i << "] with mipLevel [ " << region.dstSubresource.mipLevel |
| 1934 | << " ], offset [ " << region.dstOffset.x << ", " << region.dstOffset.y << ", " << region.dstOffset.z |
| 1935 | << " ], extent [ " << dst_copy_extent.width << ", " << dst_copy_extent.height << ", " << dst_copy_extent.depth |
| 1936 | << " ] exceeds the destination image dimensions"; |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 1937 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1938 | HandleToUint64(command_buffer), VALIDATION_ERROR_190000f6, "%s.", ss.str().c_str()); |
Mike Schuchardt | 64b5bb7 | 2017-03-21 16:33:26 -0600 | [diff] [blame] | 1939 | } |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1940 | } |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 1941 | |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1942 | // Each dimension offset + extent limits must fall with image subresource extent |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1943 | VkExtent3D subresource_extent = GetImageSubresourceExtent(src_image_state, &(region.srcSubresource)); |
| 1944 | if (slice_override) src_copy_extent.depth = depth_slices; |
| 1945 | uint32_t extent_check = ExceedsBounds(&(region.srcOffset), &src_copy_extent, &subresource_extent); |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1946 | if (extent_check & x_bit) { |
| 1947 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1948 | HandleToUint64(command_buffer), VALIDATION_ERROR_09c00120, |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1949 | "vkCmdCopyImage: Source image pRegion %1d x-dimension offset [%1d] + extent [%1d] exceeds subResource " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1950 | "width [%1d].", |
| 1951 | i, region.srcOffset.x, src_copy_extent.width, subresource_extent.width); |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1952 | } |
| 1953 | |
| 1954 | if (extent_check & y_bit) { |
| 1955 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1956 | HandleToUint64(command_buffer), VALIDATION_ERROR_09c00122, |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1957 | "vkCmdCopyImage: Source image pRegion %1d y-dimension offset [%1d] + extent [%1d] exceeds subResource " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1958 | "height [%1d].", |
| 1959 | i, region.srcOffset.y, src_copy_extent.height, subresource_extent.height); |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1960 | } |
| 1961 | if (extent_check & z_bit) { |
| 1962 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1963 | HandleToUint64(command_buffer), VALIDATION_ERROR_09c00126, |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1964 | "vkCmdCopyImage: Source image pRegion %1d z-dimension offset [%1d] + extent [%1d] exceeds subResource " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1965 | "depth [%1d].", |
| 1966 | i, region.srcOffset.z, src_copy_extent.depth, subresource_extent.depth); |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1967 | } |
| 1968 | |
Dave Houlton | ee281a5 | 2017-12-08 13:51:02 -0700 | [diff] [blame] | 1969 | // Adjust dest extent if necessary |
| 1970 | subresource_extent = GetImageSubresourceExtent(dst_image_state, &(region.dstSubresource)); |
| 1971 | if (slice_override) dst_copy_extent.depth = depth_slices; |
| 1972 | |
| 1973 | extent_check = ExceedsBounds(&(region.dstOffset), &dst_copy_extent, &subresource_extent); |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1974 | if (extent_check & x_bit) { |
| 1975 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1976 | HandleToUint64(command_buffer), VALIDATION_ERROR_09c0012c, |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1977 | "vkCmdCopyImage: Dest image pRegion %1d x-dimension offset [%1d] + extent [%1d] exceeds subResource " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1978 | "width [%1d].", |
| 1979 | i, region.dstOffset.x, dst_copy_extent.width, subresource_extent.width); |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1980 | } |
| 1981 | if (extent_check & y_bit) { |
| 1982 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1983 | HandleToUint64(command_buffer), VALIDATION_ERROR_09c0012e, |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1984 | "vkCmdCopyImage: Dest image pRegion %1d y-dimension offset [%1d] + extent [%1d] exceeds subResource " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1985 | "height [%1d].", |
| 1986 | i, region.dstOffset.y, dst_copy_extent.height, subresource_extent.height); |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1987 | } |
| 1988 | if (extent_check & z_bit) { |
| 1989 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1990 | HandleToUint64(command_buffer), VALIDATION_ERROR_09c00132, |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1991 | "vkCmdCopyImage: Dest image pRegion %1d z-dimension offset [%1d] + extent [%1d] exceeds subResource " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 1992 | "depth [%1d].", |
| 1993 | i, region.dstOffset.z, dst_copy_extent.depth, subresource_extent.depth); |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 1994 | } |
| 1995 | |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 1996 | // The union of all source regions, and the union of all destination regions, specified by the elements of regions, |
| 1997 | // must not overlap in memory |
| 1998 | if (src_image_state->image == dst_image_state->image) { |
| 1999 | for (uint32_t j = 0; j < region_count; j++) { |
Dave Houlton | f521761 | 2018-02-02 16:18:52 -0700 | [diff] [blame] | 2000 | if (RegionIntersects(®ion, ®ions[j], src_image_state->createInfo.imageType, |
| 2001 | FormatIsMultiplane(src_image_state->createInfo.format))) { |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 2002 | std::stringstream ss; |
| 2003 | ss << "vkCmdCopyImage: pRegions[" << i << "] src overlaps with pRegions[" << j << "]."; |
| 2004 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2005 | HandleToUint64(command_buffer), VALIDATION_ERROR_190000f8, "%s.", ss.str().c_str()); |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 2006 | } |
| 2007 | } |
| 2008 | } |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 2009 | } |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 2010 | |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 2011 | // The formats of src_image and dst_image must be compatible. Formats are considered compatible if their texel size in bytes |
| 2012 | // is the same between both formats. For example, VK_FORMAT_R8G8B8A8_UNORM is compatible with VK_FORMAT_R32_UINT because |
| 2013 | // because both texels are 4 bytes in size. Depth/stencil formats must match exactly. |
Dave Houlton | 1150cf5 | 2017-04-27 14:38:11 -0600 | [diff] [blame] | 2014 | if (FormatIsDepthOrStencil(src_image_state->createInfo.format) || FormatIsDepthOrStencil(dst_image_state->createInfo.format)) { |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 2015 | if (src_image_state->createInfo.format != dst_image_state->createInfo.format) { |
| 2016 | char const str[] = "vkCmdCopyImage called with unmatched source and dest image depth/stencil formats."; |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 2017 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2018 | HandleToUint64(command_buffer), DRAWSTATE_MISMATCHED_IMAGE_FORMAT, str); |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 2019 | } |
| 2020 | } else { |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 2021 | size_t srcSize = FormatSize(src_image_state->createInfo.format); |
| 2022 | size_t destSize = FormatSize(dst_image_state->createInfo.format); |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 2023 | if (srcSize != destSize) { |
| 2024 | char const str[] = "vkCmdCopyImage called with unmatched source and dest image format sizes."; |
| 2025 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2026 | HandleToUint64(command_buffer), VALIDATION_ERROR_1900010e, "%s.", str); |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 2027 | } |
| 2028 | } |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 2029 | |
Dave Houlton | 33c22b7 | 2017-02-28 13:16:02 -0700 | [diff] [blame] | 2030 | // Source and dest image sample counts must match |
| 2031 | if (src_image_state->createInfo.samples != dst_image_state->createInfo.samples) { |
| 2032 | char const str[] = "vkCmdCopyImage() called on image pair with non-identical sample counts."; |
| 2033 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2034 | HandleToUint64(command_buffer), VALIDATION_ERROR_19000110, "%s", str); |
Dave Houlton | 33c22b7 | 2017-02-28 13:16:02 -0700 | [diff] [blame] | 2035 | } |
| 2036 | |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 2037 | skip |= ValidateMemoryIsBoundToImage(device_data, src_image_state, "vkCmdCopyImage()", VALIDATION_ERROR_190000fe); |
| 2038 | skip |= ValidateMemoryIsBoundToImage(device_data, dst_image_state, "vkCmdCopyImage()", VALIDATION_ERROR_19000108); |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 2039 | // Validate that SRC & DST images have correct usage flags set |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 2040 | skip |= ValidateImageUsageFlags(device_data, src_image_state, VK_IMAGE_USAGE_TRANSFER_SRC_BIT, true, VALIDATION_ERROR_190000fc, |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 2041 | "vkCmdCopyImage()", "VK_IMAGE_USAGE_TRANSFER_SRC_BIT"); |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 2042 | skip |= ValidateImageUsageFlags(device_data, dst_image_state, VK_IMAGE_USAGE_TRANSFER_DST_BIT, true, VALIDATION_ERROR_19000106, |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 2043 | "vkCmdCopyImage()", "VK_IMAGE_USAGE_TRANSFER_DST_BIT"); |
Mike Schuchardt | 9c58240 | 2017-02-23 15:57:37 -0700 | [diff] [blame] | 2044 | skip |= ValidateCmdQueueFlags(device_data, cb_node, "vkCmdCopyImage()", |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 2045 | VK_QUEUE_TRANSFER_BIT | VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT, VALIDATION_ERROR_19002415); |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 2046 | skip |= ValidateCmd(device_data, cb_node, CMD_COPYIMAGE, "vkCmdCopyImage()"); |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 2047 | skip |= insideRenderPass(device_data, cb_node, "vkCmdCopyImage()", VALIDATION_ERROR_19000017); |
Tobin Ehlis | c826645 | 2017-04-07 12:20:30 -0600 | [diff] [blame] | 2048 | bool hit_error = false; |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 2049 | for (uint32_t i = 0; i < region_count; ++i) { |
Tobin Ehlis | 2d85ec6 | 2017-03-14 15:38:48 -0600 | [diff] [blame] | 2050 | skip |= VerifyImageLayout(device_data, cb_node, src_image_state, regions[i].srcSubresource, src_image_layout, |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 2051 | VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, "vkCmdCopyImage()", VALIDATION_ERROR_19000102, &hit_error); |
Tobin Ehlis | 2d85ec6 | 2017-03-14 15:38:48 -0600 | [diff] [blame] | 2052 | skip |= VerifyImageLayout(device_data, cb_node, dst_image_state, regions[i].dstSubresource, dst_image_layout, |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 2053 | VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, "vkCmdCopyImage()", VALIDATION_ERROR_1900010c, &hit_error); |
Dave Houlton | 6f9059e | 2017-05-02 17:15:13 -0600 | [diff] [blame] | 2054 | skip |= ValidateCopyImageTransferGranularityRequirements(device_data, cb_node, src_image_state, dst_image_state, |
| 2055 | ®ions[i], i, "vkCmdCopyImage()"); |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 2056 | } |
| 2057 | |
Mark Lobodzinski | b39d2ec | 2017-02-02 14:38:47 -0700 | [diff] [blame] | 2058 | return skip; |
| 2059 | } |
Mark Lobodzinski | 2def2bf | 2017-02-02 15:22:50 -0700 | [diff] [blame] | 2060 | |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 2061 | void PreCallRecordCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_node, IMAGE_STATE *src_image_state, |
Tobin Ehlis | e35b66a | 2017-03-15 12:18:31 -0600 | [diff] [blame] | 2062 | IMAGE_STATE *dst_image_state, uint32_t region_count, const VkImageCopy *regions, |
| 2063 | VkImageLayout src_image_layout, VkImageLayout dst_image_layout) { |
| 2064 | // Make sure that all image slices are updated to correct layout |
| 2065 | for (uint32_t i = 0; i < region_count; ++i) { |
| 2066 | SetImageLayout(device_data, cb_node, src_image_state, regions[i].srcSubresource, src_image_layout); |
| 2067 | SetImageLayout(device_data, cb_node, dst_image_state, regions[i].dstSubresource, dst_image_layout); |
| 2068 | } |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 2069 | // Update bindings between images and cmd buffer |
| 2070 | AddCommandBufferBindingImage(device_data, cb_node, src_image_state); |
| 2071 | AddCommandBufferBindingImage(device_data, cb_node, dst_image_state); |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 2072 | } |
| 2073 | |
Mark Lobodzinski | 2def2bf | 2017-02-02 15:22:50 -0700 | [diff] [blame] | 2074 | // Returns true if sub_rect is entirely contained within rect |
| 2075 | static inline bool ContainsRect(VkRect2D rect, VkRect2D sub_rect) { |
| 2076 | if ((sub_rect.offset.x < rect.offset.x) || (sub_rect.offset.x + sub_rect.extent.width > rect.offset.x + rect.extent.width) || |
| 2077 | (sub_rect.offset.y < rect.offset.y) || (sub_rect.offset.y + sub_rect.extent.height > rect.offset.y + rect.extent.height)) |
| 2078 | return false; |
| 2079 | return true; |
| 2080 | } |
| 2081 | |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 2082 | bool PreCallValidateCmdClearAttachments(layer_data *device_data, VkCommandBuffer commandBuffer, uint32_t attachmentCount, |
| 2083 | const VkClearAttachment *pAttachments, uint32_t rectCount, const VkClearRect *pRects) { |
Tobin Ehlis | b2e1e2c | 2017-02-08 09:16:32 -0700 | [diff] [blame] | 2084 | GLOBAL_CB_NODE *cb_node = GetCBNode(device_data, commandBuffer); |
Mark Lobodzinski | 2def2bf | 2017-02-02 15:22:50 -0700 | [diff] [blame] | 2085 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
| 2086 | |
| 2087 | bool skip = false; |
| 2088 | if (cb_node) { |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 2089 | skip |= ValidateCmdQueueFlags(device_data, cb_node, "vkCmdClearAttachments()", VK_QUEUE_GRAPHICS_BIT, |
| 2090 | VALIDATION_ERROR_18602415); |
Mark Lobodzinski | 2def2bf | 2017-02-02 15:22:50 -0700 | [diff] [blame] | 2091 | skip |= ValidateCmd(device_data, cb_node, CMD_CLEARATTACHMENTS, "vkCmdClearAttachments()"); |
Mark Lobodzinski | 2def2bf | 2017-02-02 15:22:50 -0700 | [diff] [blame] | 2092 | // Warn if this is issued prior to Draw Cmd and clearing the entire attachment |
Chris Forbes | 05375e7 | 2017-04-21 13:15:15 -0700 | [diff] [blame] | 2093 | if (!cb_node->hasDrawCmd && (cb_node->activeRenderPassBeginInfo.renderArea.extent.width == pRects[0].rect.extent.width) && |
Mark Lobodzinski | 2def2bf | 2017-02-02 15:22:50 -0700 | [diff] [blame] | 2094 | (cb_node->activeRenderPassBeginInfo.renderArea.extent.height == pRects[0].rect.extent.height)) { |
| 2095 | // There are times where app needs to use ClearAttachments (generally when reusing a buffer inside of a render pass) |
Mark Lobodzinski | d833bb7 | 2017-02-22 10:55:30 -0700 | [diff] [blame] | 2096 | // This warning should be made more specific. It'd be best to avoid triggering this test if it's a use that must call |
| 2097 | // CmdClearAttachments. |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2098 | skip |= log_msg( |
| 2099 | report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2100 | HandleToUint64(commandBuffer), DRAWSTATE_CLEAR_CMD_BEFORE_DRAW, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2101 | "vkCmdClearAttachments() issued on command buffer object 0x%" PRIx64 |
| 2102 | " prior to any Draw Cmds. It is recommended you use RenderPass LOAD_OP_CLEAR on Attachments prior to any Draw.", |
| 2103 | HandleToUint64(commandBuffer)); |
Mark Lobodzinski | 2def2bf | 2017-02-02 15:22:50 -0700 | [diff] [blame] | 2104 | } |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 2105 | skip |= outsideRenderPass(device_data, cb_node, "vkCmdClearAttachments()", VALIDATION_ERROR_18600017); |
Mark Lobodzinski | 2def2bf | 2017-02-02 15:22:50 -0700 | [diff] [blame] | 2106 | } |
| 2107 | |
| 2108 | // Validate that attachment is in reference list of active subpass |
| 2109 | if (cb_node->activeRenderPass) { |
| 2110 | const VkRenderPassCreateInfo *renderpass_create_info = cb_node->activeRenderPass->createInfo.ptr(); |
| 2111 | const VkSubpassDescription *subpass_desc = &renderpass_create_info->pSubpasses[cb_node->activeSubpass]; |
Tobin Ehlis | b2e1e2c | 2017-02-08 09:16:32 -0700 | [diff] [blame] | 2112 | auto framebuffer = GetFramebufferState(device_data, cb_node->activeFramebuffer); |
Mark Lobodzinski | 2def2bf | 2017-02-02 15:22:50 -0700 | [diff] [blame] | 2113 | |
| 2114 | for (uint32_t i = 0; i < attachmentCount; i++) { |
| 2115 | auto clear_desc = &pAttachments[i]; |
| 2116 | VkImageView image_view = VK_NULL_HANDLE; |
| 2117 | |
Mark Lobodzinski | ac7e51e | 2017-02-02 15:50:27 -0700 | [diff] [blame] | 2118 | if (0 == clear_desc->aspectMask) { |
| 2119 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2120 | HandleToUint64(commandBuffer), VALIDATION_ERROR_01c00c03, " "); |
Mark Lobodzinski | ac7e51e | 2017-02-02 15:50:27 -0700 | [diff] [blame] | 2121 | } else if (clear_desc->aspectMask & VK_IMAGE_ASPECT_METADATA_BIT) { |
| 2122 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2123 | HandleToUint64(commandBuffer), VALIDATION_ERROR_01c00028, " "); |
Mark Lobodzinski | ac7e51e | 2017-02-02 15:50:27 -0700 | [diff] [blame] | 2124 | } else if (clear_desc->aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) { |
Mark Lobodzinski | 2def2bf | 2017-02-02 15:22:50 -0700 | [diff] [blame] | 2125 | if (clear_desc->colorAttachment >= subpass_desc->colorAttachmentCount) { |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 2126 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2127 | HandleToUint64(commandBuffer), VALIDATION_ERROR_1860001e, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2128 | "vkCmdClearAttachments() color attachment index %d out of range for active subpass %d.", |
| 2129 | clear_desc->colorAttachment, cb_node->activeSubpass); |
Mark Lobodzinski | 2def2bf | 2017-02-02 15:22:50 -0700 | [diff] [blame] | 2130 | } else if (subpass_desc->pColorAttachments[clear_desc->colorAttachment].attachment == VK_ATTACHMENT_UNUSED) { |
| 2131 | skip |= log_msg(report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 2132 | VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, HandleToUint64(commandBuffer), |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2133 | DRAWSTATE_MISSING_ATTACHMENT_REFERENCE, |
Mark Lobodzinski | ac7e51e | 2017-02-02 15:50:27 -0700 | [diff] [blame] | 2134 | "vkCmdClearAttachments() color attachment index %d is VK_ATTACHMENT_UNUSED; ignored.", |
| 2135 | clear_desc->colorAttachment); |
Mark Lobodzinski | 2def2bf | 2017-02-02 15:22:50 -0700 | [diff] [blame] | 2136 | } else { |
| 2137 | image_view = framebuffer->createInfo |
Mark Lobodzinski | ac7e51e | 2017-02-02 15:50:27 -0700 | [diff] [blame] | 2138 | .pAttachments[subpass_desc->pColorAttachments[clear_desc->colorAttachment].attachment]; |
Mark Lobodzinski | 2def2bf | 2017-02-02 15:22:50 -0700 | [diff] [blame] | 2139 | } |
Mark Lobodzinski | ac7e51e | 2017-02-02 15:50:27 -0700 | [diff] [blame] | 2140 | if ((clear_desc->aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) || |
| 2141 | (clear_desc->aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT)) { |
| 2142 | char const str[] = |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2143 | "vkCmdClearAttachments() aspectMask [%d] must set only VK_IMAGE_ASPECT_COLOR_BIT of a color attachment."; |
Mark Lobodzinski | ac7e51e | 2017-02-02 15:50:27 -0700 | [diff] [blame] | 2144 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2145 | HandleToUint64(commandBuffer), VALIDATION_ERROR_01c00026, str, i); |
Mark Lobodzinski | ac7e51e | 2017-02-02 15:50:27 -0700 | [diff] [blame] | 2146 | } |
| 2147 | } else { // Must be depth and/or stencil |
| 2148 | if (((clear_desc->aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) != VK_IMAGE_ASPECT_DEPTH_BIT) && |
| 2149 | ((clear_desc->aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) != VK_IMAGE_ASPECT_STENCIL_BIT)) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2150 | char const str[] = "vkCmdClearAttachments() aspectMask [%d] is not a valid combination of bits."; |
Mark Lobodzinski | ac7e51e | 2017-02-02 15:50:27 -0700 | [diff] [blame] | 2151 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2152 | HandleToUint64(commandBuffer), VALIDATION_ERROR_01c00c01, str, i); |
Mark Lobodzinski | ac7e51e | 2017-02-02 15:50:27 -0700 | [diff] [blame] | 2153 | } |
| 2154 | if (!subpass_desc->pDepthStencilAttachment || |
| 2155 | (subpass_desc->pDepthStencilAttachment->attachment == VK_ATTACHMENT_UNUSED)) { |
| 2156 | skip |= log_msg( |
| 2157 | report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2158 | HandleToUint64(commandBuffer), DRAWSTATE_MISSING_ATTACHMENT_REFERENCE, |
Mark Lobodzinski | ac7e51e | 2017-02-02 15:50:27 -0700 | [diff] [blame] | 2159 | "vkCmdClearAttachments() depth/stencil clear with no depth/stencil attachment in subpass; ignored"); |
Mark Lobodzinski | 2def2bf | 2017-02-02 15:22:50 -0700 | [diff] [blame] | 2160 | } else { |
| 2161 | image_view = framebuffer->createInfo.pAttachments[subpass_desc->pDepthStencilAttachment->attachment]; |
| 2162 | } |
| 2163 | } |
Mark Lobodzinski | 2def2bf | 2017-02-02 15:22:50 -0700 | [diff] [blame] | 2164 | if (image_view) { |
Tobin Ehlis | b2e1e2c | 2017-02-08 09:16:32 -0700 | [diff] [blame] | 2165 | auto image_view_state = GetImageViewState(device_data, image_view); |
Mark Lobodzinski | 2def2bf | 2017-02-02 15:22:50 -0700 | [diff] [blame] | 2166 | for (uint32_t j = 0; j < rectCount; j++) { |
Mark Lobodzinski | ac7e51e | 2017-02-02 15:50:27 -0700 | [diff] [blame] | 2167 | // The rectangular region specified by a given element of pRects must be contained within the render area of |
| 2168 | // the current render pass instance |
Tobin Ehlis | 37ec75a | 2018-03-12 11:26:39 -0600 | [diff] [blame] | 2169 | if (cb_node->createInfo.level == VK_COMMAND_BUFFER_LEVEL_PRIMARY) { |
| 2170 | if (false == ContainsRect(cb_node->activeRenderPassBeginInfo.renderArea, pRects[j].rect)) { |
| 2171 | skip |= |
| 2172 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2173 | HandleToUint64(commandBuffer), VALIDATION_ERROR_18600020, |
Mark Lobodzinski | ac7e51e | 2017-02-02 15:50:27 -0700 | [diff] [blame] | 2174 | "vkCmdClearAttachments(): The area defined by pRects[%d] is not contained in the area of " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2175 | "the current render pass instance.", |
| 2176 | j); |
Tobin Ehlis | 37ec75a | 2018-03-12 11:26:39 -0600 | [diff] [blame] | 2177 | } |
| 2178 | } else { |
Tobin Ehlis | 3faf8b3 | 2018-04-17 16:14:26 -0600 | [diff] [blame] | 2179 | const auto local_rect = |
| 2180 | pRects[j].rect; // local copy of rect captured by value below to preserve original contents |
Tobin Ehlis | 37ec75a | 2018-03-12 11:26:39 -0600 | [diff] [blame] | 2181 | cb_node->cmd_execute_commands_functions.emplace_back([=](GLOBAL_CB_NODE *prim_cb, VkFramebuffer fb) { |
Tobin Ehlis | 3faf8b3 | 2018-04-17 16:14:26 -0600 | [diff] [blame] | 2182 | if (false == ContainsRect(prim_cb->activeRenderPassBeginInfo.renderArea, local_rect)) { |
Tobin Ehlis | 37ec75a | 2018-03-12 11:26:39 -0600 | [diff] [blame] | 2183 | return log_msg( |
| 2184 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2185 | HandleToUint64(commandBuffer), VALIDATION_ERROR_18600020, |
Tobin Ehlis | 37ec75a | 2018-03-12 11:26:39 -0600 | [diff] [blame] | 2186 | "vkCmdClearAttachments(): The area defined by pRects[%d] is not contained in the area of " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2187 | "the current render pass instance.", |
| 2188 | j); |
Tobin Ehlis | 37ec75a | 2018-03-12 11:26:39 -0600 | [diff] [blame] | 2189 | } |
| 2190 | return false; |
| 2191 | }); |
Mark Lobodzinski | 2def2bf | 2017-02-02 15:22:50 -0700 | [diff] [blame] | 2192 | } |
| 2193 | // The layers specified by a given element of pRects must be contained within every attachment that |
| 2194 | // pAttachments refers to |
Mark Lobodzinski | 2def2bf | 2017-02-02 15:22:50 -0700 | [diff] [blame] | 2195 | auto attachment_layer_count = image_view_state->create_info.subresourceRange.layerCount; |
Dave Houlton | 8e15703 | 2017-05-22 16:16:27 -0600 | [diff] [blame] | 2196 | if ((pRects[j].baseArrayLayer >= attachment_layer_count) || |
| 2197 | (pRects[j].baseArrayLayer + pRects[j].layerCount > attachment_layer_count)) { |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2198 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2199 | HandleToUint64(commandBuffer), VALIDATION_ERROR_18600022, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2200 | "vkCmdClearAttachments(): The layers defined in pRects[%d] are not contained in the layers " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2201 | "of pAttachment[%d].", |
| 2202 | j, i); |
Mark Lobodzinski | 2def2bf | 2017-02-02 15:22:50 -0700 | [diff] [blame] | 2203 | } |
| 2204 | } |
| 2205 | } |
| 2206 | } |
| 2207 | } |
| 2208 | return skip; |
Mark Lobodzinski | 8e0c0bf | 2017-02-06 11:06:26 -0700 | [diff] [blame] | 2209 | } |
| 2210 | |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 2211 | bool PreCallValidateCmdResolveImage(layer_data *device_data, GLOBAL_CB_NODE *cb_node, IMAGE_STATE *src_image_state, |
Mark Lobodzinski | 50fbef1 | 2017-02-06 15:31:33 -0700 | [diff] [blame] | 2212 | IMAGE_STATE *dst_image_state, uint32_t regionCount, const VkImageResolve *pRegions) { |
Mark Lobodzinski | 2a3368e | 2017-02-06 15:29:37 -0700 | [diff] [blame] | 2213 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
Mark Lobodzinski | 8e0c0bf | 2017-02-06 11:06:26 -0700 | [diff] [blame] | 2214 | bool skip = false; |
| 2215 | if (cb_node && src_image_state && dst_image_state) { |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 2216 | skip |= ValidateMemoryIsBoundToImage(device_data, src_image_state, "vkCmdResolveImage()", VALIDATION_ERROR_1c800200); |
| 2217 | skip |= ValidateMemoryIsBoundToImage(device_data, dst_image_state, "vkCmdResolveImage()", VALIDATION_ERROR_1c800204); |
| 2218 | skip |= |
| 2219 | ValidateCmdQueueFlags(device_data, cb_node, "vkCmdResolveImage()", VK_QUEUE_GRAPHICS_BIT, VALIDATION_ERROR_1c802415); |
Mark Lobodzinski | 8e0c0bf | 2017-02-06 11:06:26 -0700 | [diff] [blame] | 2220 | skip |= ValidateCmd(device_data, cb_node, CMD_RESOLVEIMAGE, "vkCmdResolveImage()"); |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 2221 | skip |= insideRenderPass(device_data, cb_node, "vkCmdResolveImage()", VALIDATION_ERROR_1c800017); |
Mark Lobodzinski | 2a3368e | 2017-02-06 15:29:37 -0700 | [diff] [blame] | 2222 | |
| 2223 | // For each region, the number of layers in the image subresource should not be zero |
| 2224 | // For each region, src and dest image aspect must be color only |
| 2225 | for (uint32_t i = 0; i < regionCount; i++) { |
| 2226 | if (pRegions[i].srcSubresource.layerCount == 0) { |
| 2227 | char const str[] = "vkCmdResolveImage: number of layers in source subresource is zero"; |
Mark Lobodzinski | 50fbef1 | 2017-02-06 15:31:33 -0700 | [diff] [blame] | 2228 | skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2229 | HandleToUint64(cb_node->commandBuffer), DRAWSTATE_MISMATCHED_IMAGE_ASPECT, str); |
Mark Lobodzinski | 2a3368e | 2017-02-06 15:29:37 -0700 | [diff] [blame] | 2230 | } |
Mark Lobodzinski | 2a3368e | 2017-02-06 15:29:37 -0700 | [diff] [blame] | 2231 | if (pRegions[i].dstSubresource.layerCount == 0) { |
| 2232 | char const str[] = "vkCmdResolveImage: number of layers in destination subresource is zero"; |
Mark Lobodzinski | 50fbef1 | 2017-02-06 15:31:33 -0700 | [diff] [blame] | 2233 | skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2234 | HandleToUint64(cb_node->commandBuffer), DRAWSTATE_MISMATCHED_IMAGE_ASPECT, str); |
Mark Lobodzinski | 2a3368e | 2017-02-06 15:29:37 -0700 | [diff] [blame] | 2235 | } |
Mark Lobodzinski | 50fbef1 | 2017-02-06 15:31:33 -0700 | [diff] [blame] | 2236 | if (pRegions[i].srcSubresource.layerCount != pRegions[i].dstSubresource.layerCount) { |
| 2237 | skip |= log_msg( |
| 2238 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2239 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_0a200216, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2240 | "vkCmdResolveImage: layerCount in source and destination subresource of pRegions[%d] does not match.", i); |
Mark Lobodzinski | 50fbef1 | 2017-02-06 15:31:33 -0700 | [diff] [blame] | 2241 | } |
Mark Lobodzinski | 2a3368e | 2017-02-06 15:29:37 -0700 | [diff] [blame] | 2242 | if ((pRegions[i].srcSubresource.aspectMask != VK_IMAGE_ASPECT_COLOR_BIT) || |
| 2243 | (pRegions[i].dstSubresource.aspectMask != VK_IMAGE_ASPECT_COLOR_BIT)) { |
| 2244 | char const str[] = |
| 2245 | "vkCmdResolveImage: src and dest aspectMasks for each region must specify only VK_IMAGE_ASPECT_COLOR_BIT"; |
| 2246 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2247 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_0a200214, "%s.", str); |
Mark Lobodzinski | 2a3368e | 2017-02-06 15:29:37 -0700 | [diff] [blame] | 2248 | } |
| 2249 | } |
| 2250 | |
| 2251 | if (src_image_state->createInfo.format != dst_image_state->createInfo.format) { |
| 2252 | char const str[] = "vkCmdResolveImage called with unmatched source and dest formats."; |
Mark Lobodzinski | 50fbef1 | 2017-02-06 15:31:33 -0700 | [diff] [blame] | 2253 | skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2254 | HandleToUint64(cb_node->commandBuffer), DRAWSTATE_MISMATCHED_IMAGE_FORMAT, str); |
Mark Lobodzinski | 2a3368e | 2017-02-06 15:29:37 -0700 | [diff] [blame] | 2255 | } |
| 2256 | if (src_image_state->createInfo.imageType != dst_image_state->createInfo.imageType) { |
| 2257 | char const str[] = "vkCmdResolveImage called with unmatched source and dest image types."; |
Mark Lobodzinski | 50fbef1 | 2017-02-06 15:31:33 -0700 | [diff] [blame] | 2258 | skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2259 | HandleToUint64(cb_node->commandBuffer), DRAWSTATE_MISMATCHED_IMAGE_TYPE, str); |
Mark Lobodzinski | 2a3368e | 2017-02-06 15:29:37 -0700 | [diff] [blame] | 2260 | } |
| 2261 | if (src_image_state->createInfo.samples == VK_SAMPLE_COUNT_1_BIT) { |
| 2262 | char const str[] = "vkCmdResolveImage called with source sample count less than 2."; |
| 2263 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2264 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_1c800202, "%s.", str); |
Mark Lobodzinski | 2a3368e | 2017-02-06 15:29:37 -0700 | [diff] [blame] | 2265 | } |
| 2266 | if (dst_image_state->createInfo.samples != VK_SAMPLE_COUNT_1_BIT) { |
| 2267 | char const str[] = "vkCmdResolveImage called with dest sample count greater than 1."; |
| 2268 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2269 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_1c800206, "%s.", str); |
Mark Lobodzinski | 2a3368e | 2017-02-06 15:29:37 -0700 | [diff] [blame] | 2270 | } |
Tobin Ehlis | bb03e5f | 2017-05-11 08:52:51 -0600 | [diff] [blame] | 2271 | // TODO: Need to validate image layouts, which will include layout validation for shared presentable images |
Mark Lobodzinski | 8e0c0bf | 2017-02-06 11:06:26 -0700 | [diff] [blame] | 2272 | } else { |
| 2273 | assert(0); |
| 2274 | } |
| 2275 | return skip; |
| 2276 | } |
| 2277 | |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 2278 | void PreCallRecordCmdResolveImage(layer_data *device_data, GLOBAL_CB_NODE *cb_node, IMAGE_STATE *src_image_state, |
| 2279 | IMAGE_STATE *dst_image_state) { |
Mark Lobodzinski | 8e0c0bf | 2017-02-06 11:06:26 -0700 | [diff] [blame] | 2280 | // Update bindings between images and cmd buffer |
| 2281 | AddCommandBufferBindingImage(device_data, cb_node, src_image_state); |
| 2282 | AddCommandBufferBindingImage(device_data, cb_node, dst_image_state); |
Mark Lobodzinski | 8e0c0bf | 2017-02-06 11:06:26 -0700 | [diff] [blame] | 2283 | } |
| 2284 | |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 2285 | bool PreCallValidateCmdBlitImage(layer_data *device_data, GLOBAL_CB_NODE *cb_node, IMAGE_STATE *src_image_state, |
Norbert Garnys | 7bd4c2c | 2017-11-16 10:58:04 +0100 | [diff] [blame] | 2286 | IMAGE_STATE *dst_image_state, uint32_t region_count, const VkImageBlit *regions, |
| 2287 | VkImageLayout src_image_layout, VkImageLayout dst_image_layout, VkFilter filter) { |
Mark Lobodzinski | 9ad9658 | 2017-02-06 14:01:54 -0700 | [diff] [blame] | 2288 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
| 2289 | |
Mark Lobodzinski | 8e0c0bf | 2017-02-06 11:06:26 -0700 | [diff] [blame] | 2290 | bool skip = false; |
John Zulauf | 5c2750c | 2018-01-30 15:04:56 -0700 | [diff] [blame] | 2291 | if (cb_node) { |
| 2292 | skip |= ValidateCmd(device_data, cb_node, CMD_BLITIMAGE, "vkCmdBlitImage()"); |
| 2293 | } |
Mark Lobodzinski | 8e0c0bf | 2017-02-06 11:06:26 -0700 | [diff] [blame] | 2294 | if (cb_node && src_image_state && dst_image_state) { |
| 2295 | skip |= ValidateImageSampleCount(device_data, src_image_state, VK_SAMPLE_COUNT_1_BIT, "vkCmdBlitImage(): srcImage", |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 2296 | VALIDATION_ERROR_184001d2); |
Mark Lobodzinski | 8e0c0bf | 2017-02-06 11:06:26 -0700 | [diff] [blame] | 2297 | skip |= ValidateImageSampleCount(device_data, dst_image_state, VK_SAMPLE_COUNT_1_BIT, "vkCmdBlitImage(): dstImage", |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 2298 | VALIDATION_ERROR_184001d4); |
| 2299 | skip |= ValidateMemoryIsBoundToImage(device_data, src_image_state, "vkCmdBlitImage()", VALIDATION_ERROR_184001b8); |
| 2300 | skip |= ValidateMemoryIsBoundToImage(device_data, dst_image_state, "vkCmdBlitImage()", VALIDATION_ERROR_184001c2); |
| 2301 | skip |= ValidateImageUsageFlags(device_data, src_image_state, VK_IMAGE_USAGE_TRANSFER_SRC_BIT, true, |
| 2302 | VALIDATION_ERROR_184001b6, "vkCmdBlitImage()", "VK_IMAGE_USAGE_TRANSFER_SRC_BIT"); |
| 2303 | skip |= ValidateImageUsageFlags(device_data, dst_image_state, VK_IMAGE_USAGE_TRANSFER_DST_BIT, true, |
| 2304 | VALIDATION_ERROR_184001c0, "vkCmdBlitImage()", "VK_IMAGE_USAGE_TRANSFER_DST_BIT"); |
| 2305 | skip |= ValidateCmdQueueFlags(device_data, cb_node, "vkCmdBlitImage()", VK_QUEUE_GRAPHICS_BIT, VALIDATION_ERROR_18402415); |
Mark Lobodzinski | 8e0c0bf | 2017-02-06 11:06:26 -0700 | [diff] [blame] | 2306 | skip |= ValidateCmd(device_data, cb_node, CMD_BLITIMAGE, "vkCmdBlitImage()"); |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 2307 | skip |= insideRenderPass(device_data, cb_node, "vkCmdBlitImage()", VALIDATION_ERROR_18400017); |
Tobin Ehlis | bb03e5f | 2017-05-11 08:52:51 -0600 | [diff] [blame] | 2308 | // TODO: Need to validate image layouts, which will include layout validation for shared presentable images |
Mark Lobodzinski | 9ad9658 | 2017-02-06 14:01:54 -0700 | [diff] [blame] | 2309 | |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2310 | VkFormat src_format = src_image_state->createInfo.format; |
| 2311 | VkFormat dst_format = dst_image_state->createInfo.format; |
| 2312 | VkImageType src_type = src_image_state->createInfo.imageType; |
| 2313 | VkImageType dst_type = dst_image_state->createInfo.imageType; |
| 2314 | |
Jeremy Kniager | 7ec550f | 2017-08-16 14:57:42 -0600 | [diff] [blame] | 2315 | VkFormatProperties props = GetFormatProperties(device_data, src_format); |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2316 | VkImageTiling tiling = src_image_state->createInfo.tiling; |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2317 | VkFormatFeatureFlags flags = (tiling == VK_IMAGE_TILING_LINEAR ? props.linearTilingFeatures : props.optimalTilingFeatures); |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2318 | if (VK_FORMAT_FEATURE_BLIT_SRC_BIT != (flags & VK_FORMAT_FEATURE_BLIT_SRC_BIT)) { |
| 2319 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2320 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_184001b4, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2321 | "vkCmdBlitImage: source image format %s does not support VK_FORMAT_FEATURE_BLIT_SRC_BIT feature.", |
| 2322 | string_VkFormat(src_format)); |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2323 | } |
| 2324 | |
| 2325 | if ((VK_FILTER_LINEAR == filter) && |
| 2326 | (VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT != (flags & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT))) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2327 | skip |= |
| 2328 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2329 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_184001d6, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2330 | "vkCmdBlitImage: source image format %s does not support linear filtering.", string_VkFormat(src_format)); |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2331 | } |
| 2332 | |
| 2333 | if ((VK_FILTER_CUBIC_IMG == filter) && (VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG != |
| 2334 | (flags & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG))) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2335 | skip |= |
| 2336 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2337 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_184001d8, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2338 | "vkCmdBlitImage: source image format %s does not support cubic filtering.", string_VkFormat(src_format)); |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2339 | } |
| 2340 | |
| 2341 | if ((VK_FILTER_CUBIC_IMG == filter) && (VK_IMAGE_TYPE_3D != src_type)) { |
| 2342 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2343 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_184001da, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2344 | "vkCmdBlitImage: source image type must be VK_IMAGE_TYPE_3D when cubic filtering is specified."); |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2345 | } |
| 2346 | |
| 2347 | props = GetFormatProperties(device_data, dst_format); |
| 2348 | tiling = dst_image_state->createInfo.tiling; |
Jeremy Kniager | 7ec550f | 2017-08-16 14:57:42 -0600 | [diff] [blame] | 2349 | flags = (tiling == VK_IMAGE_TILING_LINEAR ? props.linearTilingFeatures : props.optimalTilingFeatures); |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2350 | if (VK_FORMAT_FEATURE_BLIT_DST_BIT != (flags & VK_FORMAT_FEATURE_BLIT_DST_BIT)) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2351 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2352 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_184001be, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2353 | "vkCmdBlitImage: destination image format %s does not support VK_FORMAT_FEATURE_BLIT_DST_BIT feature.", |
| 2354 | string_VkFormat(dst_format)); |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2355 | } |
| 2356 | |
| 2357 | if ((VK_SAMPLE_COUNT_1_BIT != src_image_state->createInfo.samples) || |
| 2358 | (VK_SAMPLE_COUNT_1_BIT != dst_image_state->createInfo.samples)) { |
| 2359 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2360 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_184001c8, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2361 | "vkCmdBlitImage: source or dest image has sample count other than VK_SAMPLE_COUNT_1_BIT."); |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2362 | } |
| 2363 | |
| 2364 | // Validate consistency for unsigned formats |
| 2365 | if (FormatIsUInt(src_format) != FormatIsUInt(dst_format)) { |
| 2366 | std::stringstream ss; |
| 2367 | ss << "vkCmdBlitImage: If one of srcImage and dstImage images has unsigned integer format, " |
| 2368 | << "the other one must also have unsigned integer format. " |
| 2369 | << "Source format is " << string_VkFormat(src_format) << " Destination format is " << string_VkFormat(dst_format); |
| 2370 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2371 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_184001cc, "%s.", ss.str().c_str()); |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2372 | } |
| 2373 | |
| 2374 | // Validate consistency for signed formats |
| 2375 | if (FormatIsSInt(src_format) != FormatIsSInt(dst_format)) { |
| 2376 | std::stringstream ss; |
| 2377 | ss << "vkCmdBlitImage: If one of srcImage and dstImage images has signed integer format, " |
| 2378 | << "the other one must also have signed integer format. " |
| 2379 | << "Source format is " << string_VkFormat(src_format) << " Destination format is " << string_VkFormat(dst_format); |
| 2380 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2381 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_184001ca, "%s.", ss.str().c_str()); |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2382 | } |
| 2383 | |
| 2384 | // Validate filter for Depth/Stencil formats |
| 2385 | if (FormatIsDepthOrStencil(src_format) && (filter != VK_FILTER_NEAREST)) { |
| 2386 | std::stringstream ss; |
| 2387 | ss << "vkCmdBlitImage: If the format of srcImage is a depth, stencil, or depth stencil " |
| 2388 | << "then filter must be VK_FILTER_NEAREST."; |
| 2389 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2390 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_184001d0, "%s.", ss.str().c_str()); |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2391 | } |
| 2392 | |
| 2393 | // Validate aspect bits and formats for depth/stencil images |
| 2394 | if (FormatIsDepthOrStencil(src_format) || FormatIsDepthOrStencil(dst_format)) { |
| 2395 | if (src_format != dst_format) { |
| 2396 | std::stringstream ss; |
| 2397 | ss << "vkCmdBlitImage: If one of srcImage and dstImage images has a format of depth, stencil or depth " |
| 2398 | << "stencil, the other one must have exactly the same format. " |
| 2399 | << "Source format is " << string_VkFormat(src_format) << " Destination format is " |
| 2400 | << string_VkFormat(dst_format); |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2401 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 2402 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_184001ce, "%s.", ss.str().c_str()); |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2403 | } |
| 2404 | |
| 2405 | #if 0 // TODO: Cannot find VU statements or spec language for these in CmdBlitImage. Verify or remove. |
| 2406 | for (uint32_t i = 0; i < regionCount; i++) { |
| 2407 | VkImageAspectFlags srcAspect = pRegions[i].srcSubresource.aspectMask; |
| 2408 | |
| 2409 | if (FormatIsDepthAndStencil(src_format)) { |
| 2410 | if ((srcAspect != VK_IMAGE_ASPECT_DEPTH_BIT) && (srcAspect != VK_IMAGE_ASPECT_STENCIL_BIT)) { |
| 2411 | std::stringstream ss; |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2412 | ss << "vkCmdBlitImage: Combination depth/stencil image formats must have only one of VK_IMAGE_ASPECT_DEPTH_BIT " |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2413 | << "and VK_IMAGE_ASPECT_STENCIL_BIT set in srcImage and dstImage"; |
| 2414 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2415 | HandleToUint64(cb_node->commandBuffer), DRAWSTATE_INVALID_IMAGE_ASPECT, |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2416 | "%s", ss.str().c_str()); |
| 2417 | } |
| 2418 | } |
| 2419 | else if (FormatIsStencilOnly(src_format)) { |
| 2420 | if (srcAspect != VK_IMAGE_ASPECT_STENCIL_BIT) { |
| 2421 | std::stringstream ss; |
| 2422 | ss << "vkCmdBlitImage: Stencil-only image formats must have only the VK_IMAGE_ASPECT_STENCIL_BIT " |
| 2423 | << "set in both the srcImage and dstImage"; |
| 2424 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2425 | HandleToUint64(cb_node->commandBuffer), DRAWSTATE_INVALID_IMAGE_ASPECT, |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2426 | "%s", ss.str().c_str()); |
| 2427 | } |
| 2428 | } |
| 2429 | else if (FormatIsDepthOnly(src_format)) { |
| 2430 | if (srcAspect != VK_IMAGE_ASPECT_DEPTH_BIT) { |
| 2431 | std::stringstream ss; |
| 2432 | ss << "vkCmdBlitImage: Depth-only image formats must have only the VK_IMAGE_ASPECT_DEPTH " |
| 2433 | << "set in both the srcImage and dstImage"; |
| 2434 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2435 | HandleToUint64(cb_node->commandBuffer), DRAWSTATE_INVALID_IMAGE_ASPECT, |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2436 | "%s", ss.str().c_str()); |
| 2437 | } |
| 2438 | } |
| 2439 | } |
| 2440 | #endif |
| 2441 | } // Depth or Stencil |
| 2442 | |
| 2443 | // Do per-region checks |
Norbert Garnys | 7bd4c2c | 2017-11-16 10:58:04 +0100 | [diff] [blame] | 2444 | for (uint32_t i = 0; i < region_count; i++) { |
| 2445 | const VkImageBlit rgn = regions[i]; |
| 2446 | bool hit_error = false; |
| 2447 | skip |= |
| 2448 | VerifyImageLayout(device_data, cb_node, src_image_state, rgn.srcSubresource, src_image_layout, |
| 2449 | VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, "vkCmdBlitImage()", VALIDATION_ERROR_184001bc, &hit_error); |
| 2450 | skip |= |
| 2451 | VerifyImageLayout(device_data, cb_node, dst_image_state, rgn.dstSubresource, dst_image_layout, |
| 2452 | VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, "vkCmdBlitImage()", VALIDATION_ERROR_184001c6, &hit_error); |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2453 | |
Mark Lobodzinski | 23c8114 | 2017-02-06 15:04:23 -0700 | [diff] [blame] | 2454 | // Warn for zero-sized regions |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2455 | if ((rgn.srcOffsets[0].x == rgn.srcOffsets[1].x) || (rgn.srcOffsets[0].y == rgn.srcOffsets[1].y) || |
| 2456 | (rgn.srcOffsets[0].z == rgn.srcOffsets[1].z)) { |
Mark Lobodzinski | 9ad9658 | 2017-02-06 14:01:54 -0700 | [diff] [blame] | 2457 | std::stringstream ss; |
| 2458 | ss << "vkCmdBlitImage: pRegions[" << i << "].srcOffsets specify a zero-volume area."; |
| 2459 | skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2460 | HandleToUint64(cb_node->commandBuffer), DRAWSTATE_INVALID_EXTENTS, "%s", ss.str().c_str()); |
Mark Lobodzinski | 9ad9658 | 2017-02-06 14:01:54 -0700 | [diff] [blame] | 2461 | } |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2462 | if ((rgn.dstOffsets[0].x == rgn.dstOffsets[1].x) || (rgn.dstOffsets[0].y == rgn.dstOffsets[1].y) || |
| 2463 | (rgn.dstOffsets[0].z == rgn.dstOffsets[1].z)) { |
Mark Lobodzinski | 9ad9658 | 2017-02-06 14:01:54 -0700 | [diff] [blame] | 2464 | std::stringstream ss; |
| 2465 | ss << "vkCmdBlitImage: pRegions[" << i << "].dstOffsets specify a zero-volume area."; |
| 2466 | skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2467 | HandleToUint64(cb_node->commandBuffer), DRAWSTATE_INVALID_EXTENTS, "%s", ss.str().c_str()); |
Mark Lobodzinski | 9ad9658 | 2017-02-06 14:01:54 -0700 | [diff] [blame] | 2468 | } |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2469 | if (rgn.srcSubresource.layerCount == 0) { |
Mark Lobodzinski | 23c8114 | 2017-02-06 15:04:23 -0700 | [diff] [blame] | 2470 | char const str[] = "vkCmdBlitImage: number of layers in source subresource is zero"; |
| 2471 | skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2472 | HandleToUint64(cb_node->commandBuffer), DRAWSTATE_MISMATCHED_IMAGE_ASPECT, str); |
Mark Lobodzinski | 23c8114 | 2017-02-06 15:04:23 -0700 | [diff] [blame] | 2473 | } |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2474 | if (rgn.dstSubresource.layerCount == 0) { |
Mark Lobodzinski | 23c8114 | 2017-02-06 15:04:23 -0700 | [diff] [blame] | 2475 | char const str[] = "vkCmdBlitImage: number of layers in destination subresource is zero"; |
| 2476 | skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2477 | HandleToUint64(cb_node->commandBuffer), DRAWSTATE_MISMATCHED_IMAGE_ASPECT, str); |
Mark Lobodzinski | 23c8114 | 2017-02-06 15:04:23 -0700 | [diff] [blame] | 2478 | } |
| 2479 | |
| 2480 | // Check that src/dst layercounts match |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2481 | if (rgn.srcSubresource.layerCount != rgn.dstSubresource.layerCount) { |
Mark Lobodzinski | 23c8114 | 2017-02-06 15:04:23 -0700 | [diff] [blame] | 2482 | skip |= |
| 2483 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2484 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_09a001de, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2485 | "vkCmdBlitImage: layerCount in source and destination subresource of pRegions[%d] does not match.", i); |
Mark Lobodzinski | 23c8114 | 2017-02-06 15:04:23 -0700 | [diff] [blame] | 2486 | } |
Mark Lobodzinski | e7e85fd | 2017-02-07 13:44:57 -0700 | [diff] [blame] | 2487 | |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2488 | if (rgn.srcSubresource.aspectMask != rgn.dstSubresource.aspectMask) { |
Mark Lobodzinski | e7e85fd | 2017-02-07 13:44:57 -0700 | [diff] [blame] | 2489 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2490 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_09a001dc, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2491 | "vkCmdBlitImage: aspectMask members for pRegion[%d] do not match.", i); |
Mark Lobodzinski | e7e85fd | 2017-02-07 13:44:57 -0700 | [diff] [blame] | 2492 | } |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2493 | |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2494 | if (!VerifyAspectsPresent(rgn.srcSubresource.aspectMask, src_format)) { |
| 2495 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2496 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_09a001e2, |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2497 | "vkCmdBlitImage: region [%d] source aspectMask (0x%x) specifies aspects not present in source " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2498 | "image format %s.", |
| 2499 | i, rgn.srcSubresource.aspectMask, string_VkFormat(src_format)); |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2500 | } |
| 2501 | |
| 2502 | if (!VerifyAspectsPresent(rgn.dstSubresource.aspectMask, dst_format)) { |
| 2503 | skip |= log_msg( |
| 2504 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2505 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_09a001e4, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2506 | "vkCmdBlitImage: region [%d] dest aspectMask (0x%x) specifies aspects not present in dest image format %s.", i, |
| 2507 | rgn.dstSubresource.aspectMask, string_VkFormat(dst_format)); |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2508 | } |
| 2509 | |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2510 | // Validate source image offsets |
| 2511 | VkExtent3D src_extent = GetImageSubresourceExtent(src_image_state, &(rgn.srcSubresource)); |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2512 | if (VK_IMAGE_TYPE_1D == src_type) { |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2513 | if ((0 != rgn.srcOffsets[0].y) || (1 != rgn.srcOffsets[1].y)) { |
| 2514 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2515 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_09a001ea, |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2516 | "vkCmdBlitImage: region [%d], source image of type VK_IMAGE_TYPE_1D with srcOffset[].y values " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2517 | "of (%1d, %1d). These must be (0, 1).", |
| 2518 | i, rgn.srcOffsets[0].y, rgn.srcOffsets[1].y); |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2519 | } |
| 2520 | } |
| 2521 | |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2522 | if ((VK_IMAGE_TYPE_1D == src_type) || (VK_IMAGE_TYPE_2D == src_type)) { |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2523 | if ((0 != rgn.srcOffsets[0].z) || (1 != rgn.srcOffsets[1].z)) { |
| 2524 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2525 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_09a001ee, |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2526 | "vkCmdBlitImage: region [%d], source image of type VK_IMAGE_TYPE_1D or VK_IMAGE_TYPE_2D with " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2527 | "srcOffset[].z values of (%1d, %1d). These must be (0, 1).", |
| 2528 | i, rgn.srcOffsets[0].z, rgn.srcOffsets[1].z); |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2529 | } |
| 2530 | } |
| 2531 | |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2532 | bool oob = false; |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2533 | if ((rgn.srcOffsets[0].x < 0) || (rgn.srcOffsets[0].x > static_cast<int32_t>(src_extent.width)) || |
| 2534 | (rgn.srcOffsets[1].x < 0) || (rgn.srcOffsets[1].x > static_cast<int32_t>(src_extent.width))) { |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2535 | oob = true; |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2536 | skip |= |
| 2537 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2538 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_09a001e6, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2539 | "vkCmdBlitImage: region [%d] srcOffset[].x values (%1d, %1d) exceed srcSubresource width extent (%1d).", |
| 2540 | i, rgn.srcOffsets[0].x, rgn.srcOffsets[1].x, src_extent.width); |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2541 | } |
| 2542 | if ((rgn.srcOffsets[0].y < 0) || (rgn.srcOffsets[0].y > static_cast<int32_t>(src_extent.height)) || |
| 2543 | (rgn.srcOffsets[1].y < 0) || (rgn.srcOffsets[1].y > static_cast<int32_t>(src_extent.height))) { |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2544 | oob = true; |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2545 | skip |= log_msg( |
| 2546 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2547 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_09a001e8, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2548 | "vkCmdBlitImage: region [%d] srcOffset[].y values (%1d, %1d) exceed srcSubresource height extent (%1d).", i, |
| 2549 | rgn.srcOffsets[0].y, rgn.srcOffsets[1].y, src_extent.height); |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2550 | } |
| 2551 | if ((rgn.srcOffsets[0].z < 0) || (rgn.srcOffsets[0].z > static_cast<int32_t>(src_extent.depth)) || |
| 2552 | (rgn.srcOffsets[1].z < 0) || (rgn.srcOffsets[1].z > static_cast<int32_t>(src_extent.depth))) { |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2553 | oob = true; |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2554 | skip |= |
| 2555 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2556 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_09a001ec, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2557 | "vkCmdBlitImage: region [%d] srcOffset[].z values (%1d, %1d) exceed srcSubresource depth extent (%1d).", |
| 2558 | i, rgn.srcOffsets[0].z, rgn.srcOffsets[1].z, src_extent.depth); |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2559 | } |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2560 | if (rgn.srcSubresource.mipLevel >= src_image_state->createInfo.mipLevels) { |
| 2561 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2562 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_184001ae, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2563 | "vkCmdBlitImage: region [%d] source image, attempt to access a non-existant mip level %1d.", i, |
| 2564 | rgn.srcSubresource.mipLevel); |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2565 | } else if (oob) { |
| 2566 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2567 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_184001ae, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2568 | "vkCmdBlitImage: region [%d] source image blit region exceeds image dimensions.", i); |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2569 | } |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2570 | |
| 2571 | // Validate dest image offsets |
| 2572 | VkExtent3D dst_extent = GetImageSubresourceExtent(dst_image_state, &(rgn.dstSubresource)); |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2573 | if (VK_IMAGE_TYPE_1D == dst_type) { |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2574 | if ((0 != rgn.dstOffsets[0].y) || (1 != rgn.dstOffsets[1].y)) { |
| 2575 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2576 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_09a001f4, |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2577 | "vkCmdBlitImage: region [%d], dest image of type VK_IMAGE_TYPE_1D with dstOffset[].y values of " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2578 | "(%1d, %1d). These must be (0, 1).", |
| 2579 | i, rgn.dstOffsets[0].y, rgn.dstOffsets[1].y); |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2580 | } |
| 2581 | } |
| 2582 | |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2583 | if ((VK_IMAGE_TYPE_1D == dst_type) || (VK_IMAGE_TYPE_2D == dst_type)) { |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2584 | if ((0 != rgn.dstOffsets[0].z) || (1 != rgn.dstOffsets[1].z)) { |
| 2585 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2586 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_09a001f8, |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2587 | "vkCmdBlitImage: region [%d], dest image of type VK_IMAGE_TYPE_1D or VK_IMAGE_TYPE_2D with " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2588 | "dstOffset[].z values of (%1d, %1d). These must be (0, 1).", |
| 2589 | i, rgn.dstOffsets[0].z, rgn.dstOffsets[1].z); |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2590 | } |
| 2591 | } |
| 2592 | |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2593 | oob = false; |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2594 | if ((rgn.dstOffsets[0].x < 0) || (rgn.dstOffsets[0].x > static_cast<int32_t>(dst_extent.width)) || |
| 2595 | (rgn.dstOffsets[1].x < 0) || (rgn.dstOffsets[1].x > static_cast<int32_t>(dst_extent.width))) { |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2596 | oob = true; |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2597 | skip |= |
| 2598 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2599 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_09a001f0, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2600 | "vkCmdBlitImage: region [%d] dstOffset[].x values (%1d, %1d) exceed dstSubresource width extent (%1d).", |
| 2601 | i, rgn.dstOffsets[0].x, rgn.dstOffsets[1].x, dst_extent.width); |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2602 | } |
| 2603 | if ((rgn.dstOffsets[0].y < 0) || (rgn.dstOffsets[0].y > static_cast<int32_t>(dst_extent.height)) || |
| 2604 | (rgn.dstOffsets[1].y < 0) || (rgn.dstOffsets[1].y > static_cast<int32_t>(dst_extent.height))) { |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2605 | oob = true; |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2606 | skip |= log_msg( |
| 2607 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2608 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_09a001f2, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2609 | "vkCmdBlitImage: region [%d] dstOffset[].y values (%1d, %1d) exceed dstSubresource height extent (%1d).", i, |
| 2610 | rgn.dstOffsets[0].y, rgn.dstOffsets[1].y, dst_extent.height); |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2611 | } |
| 2612 | if ((rgn.dstOffsets[0].z < 0) || (rgn.dstOffsets[0].z > static_cast<int32_t>(dst_extent.depth)) || |
| 2613 | (rgn.dstOffsets[1].z < 0) || (rgn.dstOffsets[1].z > static_cast<int32_t>(dst_extent.depth))) { |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2614 | oob = true; |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2615 | skip |= |
| 2616 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2617 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_09a001f6, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2618 | "vkCmdBlitImage: region [%d] dstOffset[].z values (%1d, %1d) exceed dstSubresource depth extent (%1d).", |
| 2619 | i, rgn.dstOffsets[0].z, rgn.dstOffsets[1].z, dst_extent.depth); |
Dave Houlton | 48989f3 | 2017-05-26 15:01:46 -0600 | [diff] [blame] | 2620 | } |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2621 | if (rgn.dstSubresource.mipLevel >= dst_image_state->createInfo.mipLevels) { |
Mark Lobodzinski | 9ad9658 | 2017-02-06 14:01:54 -0700 | [diff] [blame] | 2622 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2623 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_184001b0, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2624 | "vkCmdBlitImage: region [%d] destination image, attempt to access a non-existant mip level %1d.", i, |
| 2625 | rgn.dstSubresource.mipLevel); |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2626 | } else if (oob) { |
| 2627 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2628 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_184001b0, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2629 | "vkCmdBlitImage: region [%d] destination image blit region exceeds image dimensions.", i); |
Mark Lobodzinski | 9ad9658 | 2017-02-06 14:01:54 -0700 | [diff] [blame] | 2630 | } |
| 2631 | |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2632 | if ((VK_IMAGE_TYPE_3D == src_type) || (VK_IMAGE_TYPE_3D == dst_type)) { |
| 2633 | if ((0 != rgn.srcSubresource.baseArrayLayer) || (1 != rgn.srcSubresource.layerCount) || |
| 2634 | (0 != rgn.dstSubresource.baseArrayLayer) || (1 != rgn.dstSubresource.layerCount)) { |
| 2635 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2636 | HandleToUint64(cb_node->commandBuffer), VALIDATION_ERROR_09a001e0, |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2637 | "vkCmdBlitImage: region [%d] blit to/from a 3D image type with a non-zero baseArrayLayer, or a " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2638 | "layerCount other than 1.", |
| 2639 | i); |
Mark Lobodzinski | 9ad9658 | 2017-02-06 14:01:54 -0700 | [diff] [blame] | 2640 | } |
| 2641 | } |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2642 | } // per-region checks |
Mark Lobodzinski | 8e0c0bf | 2017-02-06 11:06:26 -0700 | [diff] [blame] | 2643 | } else { |
| 2644 | assert(0); |
| 2645 | } |
| 2646 | return skip; |
| 2647 | } |
| 2648 | |
Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 2649 | void PreCallRecordCmdBlitImage(layer_data *device_data, GLOBAL_CB_NODE *cb_node, IMAGE_STATE *src_image_state, |
Norbert Garnys | 7bd4c2c | 2017-11-16 10:58:04 +0100 | [diff] [blame] | 2650 | IMAGE_STATE *dst_image_state, uint32_t region_count, const VkImageBlit *regions, |
| 2651 | VkImageLayout src_image_layout, VkImageLayout dst_image_layout) { |
| 2652 | // Make sure that all image slices are updated to correct layout |
| 2653 | for (uint32_t i = 0; i < region_count; ++i) { |
| 2654 | SetImageLayout(device_data, cb_node, src_image_state, regions[i].srcSubresource, src_image_layout); |
| 2655 | SetImageLayout(device_data, cb_node, dst_image_state, regions[i].dstSubresource, dst_image_layout); |
| 2656 | } |
Mark Lobodzinski | 8e0c0bf | 2017-02-06 11:06:26 -0700 | [diff] [blame] | 2657 | // Update bindings between images and cmd buffer |
| 2658 | AddCommandBufferBindingImage(device_data, cb_node, src_image_state); |
| 2659 | AddCommandBufferBindingImage(device_data, cb_node, dst_image_state); |
Mark Lobodzinski | 8e0c0bf | 2017-02-06 11:06:26 -0700 | [diff] [blame] | 2660 | } |
| 2661 | |
Tony Barbour | df013b9 | 2017-01-25 12:53:48 -0700 | [diff] [blame] | 2662 | // This validates that the initial layout specified in the command buffer for |
| 2663 | // the IMAGE is the same |
| 2664 | // as the global IMAGE layout |
Tony Barbour | e0c5cc9 | 2017-02-08 13:53:39 -0700 | [diff] [blame] | 2665 | bool ValidateCmdBufImageLayouts(layer_data *device_data, GLOBAL_CB_NODE *pCB, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2666 | std::unordered_map<ImageSubresourcePair, IMAGE_LAYOUT_NODE> const &globalImageLayoutMap, |
| 2667 | std::unordered_map<ImageSubresourcePair, IMAGE_LAYOUT_NODE> &overlayLayoutMap) { |
Mark Lobodzinski | b0dd947 | 2017-02-07 16:38:17 -0700 | [diff] [blame] | 2668 | bool skip = false; |
Tony Barbour | df013b9 | 2017-01-25 12:53:48 -0700 | [diff] [blame] | 2669 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
Mark Lobodzinski | 4a3065e | 2017-02-07 16:36:03 -0700 | [diff] [blame] | 2670 | for (auto cb_image_data : pCB->imageLayoutMap) { |
| 2671 | VkImageLayout imageLayout; |
Tony Barbour | df013b9 | 2017-01-25 12:53:48 -0700 | [diff] [blame] | 2672 | |
Dave Houlton | b3f4b28 | 2018-02-22 16:25:16 -0700 | [diff] [blame] | 2673 | if (FindLayout(device_data, overlayLayoutMap, cb_image_data.first, imageLayout) || |
| 2674 | FindLayout(device_data, globalImageLayoutMap, cb_image_data.first, imageLayout)) { |
Mark Lobodzinski | 4a3065e | 2017-02-07 16:36:03 -0700 | [diff] [blame] | 2675 | if (cb_image_data.second.initialLayout == VK_IMAGE_LAYOUT_UNDEFINED) { |
| 2676 | // TODO: Set memory invalid which is in mem_tracker currently |
| 2677 | } else if (imageLayout != cb_image_data.second.initialLayout) { |
| 2678 | if (cb_image_data.first.hasSubresource) { |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2679 | skip |= log_msg( |
| 2680 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2681 | HandleToUint64(pCB->commandBuffer), DRAWSTATE_INVALID_IMAGE_LAYOUT, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2682 | "Cannot submit cmd buffer using image (0x%" PRIx64 |
| 2683 | ") [sub-resource: aspectMask 0x%X array layer %u, mip level %u], with layout %s when first use is %s.", |
| 2684 | HandleToUint64(cb_image_data.first.image), cb_image_data.first.subresource.aspectMask, |
| 2685 | cb_image_data.first.subresource.arrayLayer, cb_image_data.first.subresource.mipLevel, |
| 2686 | string_VkImageLayout(imageLayout), string_VkImageLayout(cb_image_data.second.initialLayout)); |
Mark Lobodzinski | 4a3065e | 2017-02-07 16:36:03 -0700 | [diff] [blame] | 2687 | } else { |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 2688 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2689 | HandleToUint64(pCB->commandBuffer), DRAWSTATE_INVALID_IMAGE_LAYOUT, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2690 | "Cannot submit cmd buffer using image (0x%" PRIx64 ") with layout %s when first use is %s.", |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 2691 | HandleToUint64(cb_image_data.first.image), string_VkImageLayout(imageLayout), |
| 2692 | string_VkImageLayout(cb_image_data.second.initialLayout)); |
Mark Lobodzinski | 4a3065e | 2017-02-07 16:36:03 -0700 | [diff] [blame] | 2693 | } |
| 2694 | } |
Chris Forbes | f9d7acd | 2017-06-26 17:57:39 -0700 | [diff] [blame] | 2695 | SetLayout(overlayLayoutMap, cb_image_data.first, cb_image_data.second.layout); |
Mark Lobodzinski | 4a3065e | 2017-02-07 16:36:03 -0700 | [diff] [blame] | 2696 | } |
| 2697 | } |
Mark Lobodzinski | b0dd947 | 2017-02-07 16:38:17 -0700 | [diff] [blame] | 2698 | return skip; |
Mark Lobodzinski | 4a3065e | 2017-02-07 16:36:03 -0700 | [diff] [blame] | 2699 | } |
Mark Lobodzinski | b3829a5 | 2017-02-07 16:55:53 -0700 | [diff] [blame] | 2700 | |
Tony Barbour | df013b9 | 2017-01-25 12:53:48 -0700 | [diff] [blame] | 2701 | void UpdateCmdBufImageLayouts(layer_data *device_data, GLOBAL_CB_NODE *pCB) { |
| 2702 | for (auto cb_image_data : pCB->imageLayoutMap) { |
| 2703 | VkImageLayout imageLayout; |
| 2704 | FindGlobalLayout(device_data, cb_image_data.first, imageLayout); |
| 2705 | SetGlobalLayout(device_data, cb_image_data.first, cb_image_data.second.layout); |
| 2706 | } |
| 2707 | } |
| 2708 | |
Mark Lobodzinski | b3829a5 | 2017-02-07 16:55:53 -0700 | [diff] [blame] | 2709 | // Print readable FlagBits in FlagMask |
| 2710 | static std::string string_VkAccessFlags(VkAccessFlags accessMask) { |
| 2711 | std::string result; |
| 2712 | std::string separator; |
| 2713 | |
| 2714 | if (accessMask == 0) { |
| 2715 | result = "[None]"; |
| 2716 | } else { |
| 2717 | result = "["; |
| 2718 | for (auto i = 0; i < 32; i++) { |
| 2719 | if (accessMask & (1 << i)) { |
| 2720 | result = result + separator + string_VkAccessFlagBits((VkAccessFlagBits)(1 << i)); |
| 2721 | separator = " | "; |
| 2722 | } |
| 2723 | } |
| 2724 | result = result + "]"; |
| 2725 | } |
| 2726 | return result; |
| 2727 | } |
| 2728 | |
Mark Lobodzinski | 9a8d40f | 2017-02-07 17:00:12 -0700 | [diff] [blame] | 2729 | // AccessFlags MUST have 'required_bit' set, and may have one or more of 'optional_bits' set. If required_bit is zero, accessMask |
| 2730 | // must have at least one of 'optional_bits' set |
Mark Lobodzinski | b3829a5 | 2017-02-07 16:55:53 -0700 | [diff] [blame] | 2731 | // TODO: Add tracking to ensure that at least one barrier has been set for these layout transitions |
Mark Lobodzinski | 9a8d40f | 2017-02-07 17:00:12 -0700 | [diff] [blame] | 2732 | static bool ValidateMaskBits(core_validation::layer_data *device_data, VkCommandBuffer cmdBuffer, const VkAccessFlags &accessMask, |
| 2733 | const VkImageLayout &layout, VkAccessFlags required_bit, VkAccessFlags optional_bits, |
| 2734 | const char *type) { |
| 2735 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
| 2736 | bool skip = false; |
Mark Lobodzinski | b3829a5 | 2017-02-07 16:55:53 -0700 | [diff] [blame] | 2737 | |
| 2738 | if ((accessMask & required_bit) || (!required_bit && (accessMask & optional_bits))) { |
| 2739 | if (accessMask & ~(required_bit | optional_bits)) { |
| 2740 | // TODO: Verify against Valid Use |
Mark Lobodzinski | 0827aec | 2017-03-21 16:41:45 -0600 | [diff] [blame] | 2741 | skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2742 | HandleToUint64(cmdBuffer), DRAWSTATE_INVALID_BARRIER, |
Mark Lobodzinski | 9a8d40f | 2017-02-07 17:00:12 -0700 | [diff] [blame] | 2743 | "Additional bits in %s accessMask 0x%X %s are specified when layout is %s.", type, accessMask, |
| 2744 | string_VkAccessFlags(accessMask).c_str(), string_VkImageLayout(layout)); |
Mark Lobodzinski | b3829a5 | 2017-02-07 16:55:53 -0700 | [diff] [blame] | 2745 | } |
| 2746 | } else { |
| 2747 | if (!required_bit) { |
Mark Lobodzinski | 0827aec | 2017-03-21 16:41:45 -0600 | [diff] [blame] | 2748 | skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2749 | HandleToUint64(cmdBuffer), DRAWSTATE_INVALID_BARRIER, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2750 | "%s AccessMask %d %s must contain at least one of access bits %d %s when layout is %s, unless the app " |
| 2751 | "has previously added a barrier for this transition.", |
Mark Lobodzinski | 9a8d40f | 2017-02-07 17:00:12 -0700 | [diff] [blame] | 2752 | type, accessMask, string_VkAccessFlags(accessMask).c_str(), optional_bits, |
| 2753 | string_VkAccessFlags(optional_bits).c_str(), string_VkImageLayout(layout)); |
Mark Lobodzinski | b3829a5 | 2017-02-07 16:55:53 -0700 | [diff] [blame] | 2754 | } else { |
| 2755 | std::string opt_bits; |
| 2756 | if (optional_bits != 0) { |
| 2757 | std::stringstream ss; |
| 2758 | ss << optional_bits; |
| 2759 | opt_bits = "and may have optional bits " + ss.str() + ' ' + string_VkAccessFlags(optional_bits); |
| 2760 | } |
Mark Lobodzinski | 0827aec | 2017-03-21 16:41:45 -0600 | [diff] [blame] | 2761 | skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2762 | HandleToUint64(cmdBuffer), DRAWSTATE_INVALID_BARRIER, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2763 | "%s AccessMask %d %s must have required access bit %d %s %s when layout is %s, unless the app has " |
| 2764 | "previously added a barrier for this transition.", |
Mark Lobodzinski | 9a8d40f | 2017-02-07 17:00:12 -0700 | [diff] [blame] | 2765 | type, accessMask, string_VkAccessFlags(accessMask).c_str(), required_bit, |
| 2766 | string_VkAccessFlags(required_bit).c_str(), opt_bits.c_str(), string_VkImageLayout(layout)); |
Mark Lobodzinski | b3829a5 | 2017-02-07 16:55:53 -0700 | [diff] [blame] | 2767 | } |
| 2768 | } |
Mark Lobodzinski | 9a8d40f | 2017-02-07 17:00:12 -0700 | [diff] [blame] | 2769 | return skip; |
Mark Lobodzinski | b3829a5 | 2017-02-07 16:55:53 -0700 | [diff] [blame] | 2770 | } |
| 2771 | |
Mark Lobodzinski | c679b03 | 2017-02-07 17:11:55 -0700 | [diff] [blame] | 2772 | // ValidateLayoutVsAttachmentDescription is a general function where we can validate various state associated with the |
Mark Lobodzinski | 552e440 | 2017-02-07 17:14:53 -0700 | [diff] [blame] | 2773 | // VkAttachmentDescription structs that are used by the sub-passes of a renderpass. Initial check is to make sure that READ_ONLY |
| 2774 | // layout attachments don't have CLEAR as their loadOp. |
Mark Lobodzinski | c679b03 | 2017-02-07 17:11:55 -0700 | [diff] [blame] | 2775 | bool ValidateLayoutVsAttachmentDescription(const debug_report_data *report_data, const VkImageLayout first_layout, |
Mark Lobodzinski | 552e440 | 2017-02-07 17:14:53 -0700 | [diff] [blame] | 2776 | const uint32_t attachment, const VkAttachmentDescription &attachment_description) { |
| 2777 | bool skip = false; |
Mark Lobodzinski | c679b03 | 2017-02-07 17:11:55 -0700 | [diff] [blame] | 2778 | // Verify that initial loadOp on READ_ONLY attachments is not CLEAR |
| 2779 | if (attachment_description.loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR) { |
| 2780 | if ((first_layout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL) || |
| 2781 | (first_layout == VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL)) { |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 2782 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2783 | VALIDATION_ERROR_12200688, "Cannot clear attachment %d with invalid first layout %s.", attachment, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2784 | string_VkImageLayout(first_layout)); |
Mark Lobodzinski | c679b03 | 2017-02-07 17:11:55 -0700 | [diff] [blame] | 2785 | } |
| 2786 | } |
Slawomir Cygan | adf2b55 | 2018-04-24 17:18:26 +0200 | [diff] [blame] | 2787 | if (attachment_description.loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR) { |
| 2788 | if (first_layout == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL) { |
| 2789 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2790 | VALIDATION_ERROR_12200c3c, "Cannot clear attachment %d with invalid first layout %s.", attachment, |
| 2791 | string_VkImageLayout(first_layout)); |
| 2792 | } |
| 2793 | } |
| 2794 | |
| 2795 | if (attachment_description.stencilLoadOp == VK_ATTACHMENT_LOAD_OP_CLEAR) { |
| 2796 | if (first_layout == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL) { |
| 2797 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 2798 | VALIDATION_ERROR_12200c3e, "Cannot clear attachment %d with invalid first layout %s.", attachment, |
| 2799 | string_VkImageLayout(first_layout)); |
| 2800 | } |
| 2801 | } |
Mark Lobodzinski | 552e440 | 2017-02-07 17:14:53 -0700 | [diff] [blame] | 2802 | return skip; |
Mark Lobodzinski | c679b03 | 2017-02-07 17:11:55 -0700 | [diff] [blame] | 2803 | } |
| 2804 | |
Mark Lobodzinski | 552e440 | 2017-02-07 17:14:53 -0700 | [diff] [blame] | 2805 | bool ValidateLayouts(core_validation::layer_data *device_data, VkDevice device, const VkRenderPassCreateInfo *pCreateInfo) { |
| 2806 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
Mark Lobodzinski | c679b03 | 2017-02-07 17:11:55 -0700 | [diff] [blame] | 2807 | bool skip = false; |
| 2808 | |
Jason Ekstrand | a190630 | 2017-12-03 20:16:32 -0800 | [diff] [blame] | 2809 | for (uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) { |
| 2810 | VkFormat format = pCreateInfo->pAttachments[i].format; |
| 2811 | if (pCreateInfo->pAttachments[i].initialLayout == VK_IMAGE_LAYOUT_UNDEFINED) { |
| 2812 | if ((FormatIsColor(format) || FormatHasDepth(format)) && |
| 2813 | pCreateInfo->pAttachments[i].loadOp == VK_ATTACHMENT_LOAD_OP_LOAD) { |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 2814 | skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2815 | DRAWSTATE_INVALID_RENDERPASS, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2816 | "Render pass has an attachment with loadOp == VK_ATTACHMENT_LOAD_OP_LOAD and initialLayout == " |
| 2817 | "VK_IMAGE_LAYOUT_UNDEFINED. This is probably not what you intended. Consider using " |
| 2818 | "VK_ATTACHMENT_LOAD_OP_DONT_CARE instead if the image truely is undefined at the start of the " |
| 2819 | "render pass."); |
Jason Ekstrand | a190630 | 2017-12-03 20:16:32 -0800 | [diff] [blame] | 2820 | } |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2821 | if (FormatHasStencil(format) && pCreateInfo->pAttachments[i].stencilLoadOp == VK_ATTACHMENT_LOAD_OP_LOAD) { |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 2822 | skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2823 | DRAWSTATE_INVALID_RENDERPASS, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2824 | "Render pass has an attachment with stencilLoadOp == VK_ATTACHMENT_LOAD_OP_LOAD and initialLayout " |
| 2825 | "== VK_IMAGE_LAYOUT_UNDEFINED. This is probably not what you intended. Consider using " |
| 2826 | "VK_ATTACHMENT_LOAD_OP_DONT_CARE instead if the image truely is undefined at the start of the " |
| 2827 | "render pass."); |
Jason Ekstrand | a190630 | 2017-12-03 20:16:32 -0800 | [diff] [blame] | 2828 | } |
| 2829 | } |
| 2830 | } |
| 2831 | |
Mark Lobodzinski | c679b03 | 2017-02-07 17:11:55 -0700 | [diff] [blame] | 2832 | // Track when we're observing the first use of an attachment |
| 2833 | std::vector<bool> attach_first_use(pCreateInfo->attachmentCount, true); |
| 2834 | for (uint32_t i = 0; i < pCreateInfo->subpassCount; ++i) { |
| 2835 | const VkSubpassDescription &subpass = pCreateInfo->pSubpasses[i]; |
Cort Stratton | 7547f77 | 2017-05-04 15:18:52 -0700 | [diff] [blame] | 2836 | |
| 2837 | // Check input attachments first, so we can detect first-use-as-input for VU #00349 |
| 2838 | for (uint32_t j = 0; j < subpass.inputAttachmentCount; ++j) { |
| 2839 | auto attach_index = subpass.pInputAttachments[j].attachment; |
| 2840 | if (attach_index == VK_ATTACHMENT_UNUSED) continue; |
| 2841 | |
| 2842 | switch (subpass.pInputAttachments[j].layout) { |
| 2843 | case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: |
| 2844 | case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL: |
| 2845 | // These are ideal. |
| 2846 | break; |
| 2847 | |
| 2848 | case VK_IMAGE_LAYOUT_GENERAL: |
| 2849 | // May not be optimal. TODO: reconsider this warning based on other constraints. |
| 2850 | skip |= log_msg(report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2851 | VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, DRAWSTATE_INVALID_IMAGE_LAYOUT, |
Cort Stratton | 7547f77 | 2017-05-04 15:18:52 -0700 | [diff] [blame] | 2852 | "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); |
| 2853 | break; |
| 2854 | |
| 2855 | default: |
| 2856 | // No other layouts are acceptable |
| 2857 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2858 | DRAWSTATE_INVALID_IMAGE_LAYOUT, |
Cort Stratton | 7547f77 | 2017-05-04 15:18:52 -0700 | [diff] [blame] | 2859 | "Layout for input attachment is %s but can only be READ_ONLY_OPTIMAL or GENERAL.", |
| 2860 | string_VkImageLayout(subpass.pInputAttachments[j].layout)); |
| 2861 | } |
| 2862 | |
| 2863 | VkImageLayout layout = subpass.pInputAttachments[j].layout; |
| 2864 | bool found_layout_mismatch = subpass.pDepthStencilAttachment && |
| 2865 | subpass.pDepthStencilAttachment->attachment == attach_index && |
| 2866 | subpass.pDepthStencilAttachment->layout != layout; |
| 2867 | for (uint32_t c = 0; !found_layout_mismatch && c < subpass.colorAttachmentCount; ++c) { |
| 2868 | found_layout_mismatch = |
| 2869 | (subpass.pColorAttachments[c].attachment == attach_index && subpass.pColorAttachments[c].layout != layout); |
| 2870 | } |
| 2871 | if (found_layout_mismatch) { |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 2872 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2873 | VALIDATION_ERROR_140006ae, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2874 | "CreateRenderPass: Subpass %u pInputAttachments[%u] (%u) has layout %u, but is also used as a " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2875 | "depth/color attachment with a different layout.", |
| 2876 | i, j, attach_index, layout); |
Cort Stratton | 7547f77 | 2017-05-04 15:18:52 -0700 | [diff] [blame] | 2877 | } |
| 2878 | |
| 2879 | if (attach_first_use[attach_index]) { |
| 2880 | skip |= ValidateLayoutVsAttachmentDescription(report_data, subpass.pInputAttachments[j].layout, attach_index, |
| 2881 | pCreateInfo->pAttachments[attach_index]); |
| 2882 | |
| 2883 | bool used_as_depth = |
| 2884 | (subpass.pDepthStencilAttachment != NULL && subpass.pDepthStencilAttachment->attachment == attach_index); |
| 2885 | bool used_as_color = false; |
| 2886 | for (uint32_t k = 0; !used_as_depth && !used_as_color && k < subpass.colorAttachmentCount; ++k) { |
| 2887 | used_as_color = (subpass.pColorAttachments[k].attachment == attach_index); |
| 2888 | } |
| 2889 | if (!used_as_depth && !used_as_color && |
| 2890 | pCreateInfo->pAttachments[attach_index].loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR) { |
| 2891 | skip |= log_msg( |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 2892 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2893 | VALIDATION_ERROR_1400069c, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2894 | "CreateRenderPass: attachment %u is first used as an input attachment in subpass %u with loadOp=CLEAR.", |
| 2895 | attach_index, attach_index); |
Cort Stratton | 7547f77 | 2017-05-04 15:18:52 -0700 | [diff] [blame] | 2896 | } |
| 2897 | } |
| 2898 | attach_first_use[attach_index] = false; |
| 2899 | } |
Mark Lobodzinski | c679b03 | 2017-02-07 17:11:55 -0700 | [diff] [blame] | 2900 | for (uint32_t j = 0; j < subpass.colorAttachmentCount; ++j) { |
| 2901 | auto attach_index = subpass.pColorAttachments[j].attachment; |
| 2902 | if (attach_index == VK_ATTACHMENT_UNUSED) continue; |
| 2903 | |
Tobin Ehlis | bb03e5f | 2017-05-11 08:52:51 -0600 | [diff] [blame] | 2904 | // TODO: Need a way to validate shared presentable images here, currently just allowing |
| 2905 | // VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR |
| 2906 | // as an acceptable layout, but need to make sure shared presentable images ONLY use that layout |
Mark Lobodzinski | c679b03 | 2017-02-07 17:11:55 -0700 | [diff] [blame] | 2907 | switch (subpass.pColorAttachments[j].layout) { |
Mark Lobodzinski | 552e440 | 2017-02-07 17:14:53 -0700 | [diff] [blame] | 2908 | case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 2909 | // This is ideal. |
Tobin Ehlis | bb03e5f | 2017-05-11 08:52:51 -0600 | [diff] [blame] | 2910 | case VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR: |
| 2911 | // TODO: See note above, just assuming that attachment is shared presentable and allowing this for now. |
Mark Lobodzinski | 552e440 | 2017-02-07 17:14:53 -0700 | [diff] [blame] | 2912 | break; |
Mark Lobodzinski | c679b03 | 2017-02-07 17:11:55 -0700 | [diff] [blame] | 2913 | |
Mark Lobodzinski | 552e440 | 2017-02-07 17:14:53 -0700 | [diff] [blame] | 2914 | case VK_IMAGE_LAYOUT_GENERAL: |
| 2915 | // May not be optimal; TODO: reconsider this warning based on other constraints? |
| 2916 | skip |= log_msg(report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2917 | VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, DRAWSTATE_INVALID_IMAGE_LAYOUT, |
Mark Lobodzinski | 552e440 | 2017-02-07 17:14:53 -0700 | [diff] [blame] | 2918 | "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); |
| 2919 | break; |
Mark Lobodzinski | c679b03 | 2017-02-07 17:11:55 -0700 | [diff] [blame] | 2920 | |
Mark Lobodzinski | 552e440 | 2017-02-07 17:14:53 -0700 | [diff] [blame] | 2921 | default: |
| 2922 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2923 | DRAWSTATE_INVALID_IMAGE_LAYOUT, |
Mark Lobodzinski | 552e440 | 2017-02-07 17:14:53 -0700 | [diff] [blame] | 2924 | "Layout for color attachment is %s but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL.", |
| 2925 | string_VkImageLayout(subpass.pColorAttachments[j].layout)); |
Mark Lobodzinski | c679b03 | 2017-02-07 17:11:55 -0700 | [diff] [blame] | 2926 | } |
| 2927 | |
| 2928 | if (attach_first_use[attach_index]) { |
Mark Lobodzinski | 552e440 | 2017-02-07 17:14:53 -0700 | [diff] [blame] | 2929 | skip |= ValidateLayoutVsAttachmentDescription(report_data, subpass.pColorAttachments[j].layout, attach_index, |
| 2930 | pCreateInfo->pAttachments[attach_index]); |
Mark Lobodzinski | c679b03 | 2017-02-07 17:11:55 -0700 | [diff] [blame] | 2931 | } |
| 2932 | attach_first_use[attach_index] = false; |
| 2933 | } |
Lenny Komow | b79f04a | 2017-09-18 17:07:00 -0600 | [diff] [blame] | 2934 | |
Mark Lobodzinski | c679b03 | 2017-02-07 17:11:55 -0700 | [diff] [blame] | 2935 | if (subpass.pDepthStencilAttachment && subpass.pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) { |
| 2936 | switch (subpass.pDepthStencilAttachment->layout) { |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2937 | case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: |
| 2938 | case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: |
| 2939 | // These are ideal. |
Lenny Komow | b79f04a | 2017-09-18 17:07:00 -0600 | [diff] [blame] | 2940 | break; |
Lenny Komow | b79f04a | 2017-09-18 17:07:00 -0600 | [diff] [blame] | 2941 | |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2942 | case VK_IMAGE_LAYOUT_GENERAL: |
| 2943 | // May not be optimal; TODO: reconsider this warning based on other constraints? GENERAL can be better than |
| 2944 | // doing a bunch of transitions. |
| 2945 | skip |= log_msg(report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2946 | VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, DRAWSTATE_INVALID_IMAGE_LAYOUT, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2947 | "GENERAL layout for depth attachment may not give optimal performance."); |
| 2948 | break; |
| 2949 | |
| 2950 | case VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR: |
| 2951 | case VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR: |
| 2952 | if (GetDeviceExtensions(device_data)->vk_khr_maintenance2) { |
| 2953 | break; |
| 2954 | } else { |
| 2955 | // Intentionally fall through to generic error message |
| 2956 | } |
Tobin Ehlis | 648b1cf | 2018-04-13 15:24:13 -0600 | [diff] [blame] | 2957 | // fall through |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2958 | default: |
| 2959 | // No other layouts are acceptable |
| 2960 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2961 | DRAWSTATE_INVALID_IMAGE_LAYOUT, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2962 | "Layout for depth attachment is %s but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL, " |
| 2963 | "DEPTH_STENCIL_READ_ONLY_OPTIMAL or GENERAL.", |
| 2964 | string_VkImageLayout(subpass.pDepthStencilAttachment->layout)); |
Mark Lobodzinski | c679b03 | 2017-02-07 17:11:55 -0700 | [diff] [blame] | 2965 | } |
| 2966 | |
| 2967 | auto attach_index = subpass.pDepthStencilAttachment->attachment; |
| 2968 | if (attach_first_use[attach_index]) { |
Mark Lobodzinski | 552e440 | 2017-02-07 17:14:53 -0700 | [diff] [blame] | 2969 | skip |= ValidateLayoutVsAttachmentDescription(report_data, subpass.pDepthStencilAttachment->layout, attach_index, |
| 2970 | pCreateInfo->pAttachments[attach_index]); |
Mark Lobodzinski | c679b03 | 2017-02-07 17:11:55 -0700 | [diff] [blame] | 2971 | } |
| 2972 | attach_first_use[attach_index] = false; |
| 2973 | } |
Mark Lobodzinski | c679b03 | 2017-02-07 17:11:55 -0700 | [diff] [blame] | 2974 | } |
| 2975 | return skip; |
| 2976 | } |
Mark Lobodzinski | 08f14fa | 2017-02-07 17:20:06 -0700 | [diff] [blame] | 2977 | |
| 2978 | // For any image objects that overlap mapped memory, verify that their layouts are PREINIT or GENERAL |
Mark Lobodzinski | ac23ec8 | 2017-02-07 17:21:55 -0700 | [diff] [blame] | 2979 | bool ValidateMapImageLayouts(core_validation::layer_data *device_data, VkDevice device, DEVICE_MEM_INFO const *mem_info, |
| 2980 | VkDeviceSize offset, VkDeviceSize end_offset) { |
| 2981 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
| 2982 | bool skip = false; |
| 2983 | // Iterate over all bound image ranges and verify that for any that overlap the map ranges, the layouts are |
| 2984 | // VK_IMAGE_LAYOUT_PREINITIALIZED or VK_IMAGE_LAYOUT_GENERAL |
Mark Lobodzinski | 08f14fa | 2017-02-07 17:20:06 -0700 | [diff] [blame] | 2985 | // TODO : This can be optimized if we store ranges based on starting address and early exit when we pass our range |
| 2986 | for (auto image_handle : mem_info->bound_images) { |
| 2987 | auto img_it = mem_info->bound_ranges.find(image_handle); |
| 2988 | if (img_it != mem_info->bound_ranges.end()) { |
Mark Lobodzinski | ac23ec8 | 2017-02-07 17:21:55 -0700 | [diff] [blame] | 2989 | if (rangesIntersect(device_data, &img_it->second, offset, end_offset)) { |
Mark Lobodzinski | 08f14fa | 2017-02-07 17:20:06 -0700 | [diff] [blame] | 2990 | std::vector<VkImageLayout> layouts; |
Mark Lobodzinski | ac23ec8 | 2017-02-07 17:21:55 -0700 | [diff] [blame] | 2991 | if (FindLayouts(device_data, VkImage(image_handle), layouts)) { |
Mark Lobodzinski | 08f14fa | 2017-02-07 17:20:06 -0700 | [diff] [blame] | 2992 | for (auto layout : layouts) { |
| 2993 | if (layout != VK_IMAGE_LAYOUT_PREINITIALIZED && layout != VK_IMAGE_LAYOUT_GENERAL) { |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 2994 | skip |= |
| 2995 | log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2996 | HandleToUint64(mem_info->mem), DRAWSTATE_INVALID_IMAGE_LAYOUT, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2997 | "Mapping an image with layout %s can result in undefined behavior if this memory is used " |
| 2998 | "by the device. Only GENERAL or PREINITIALIZED should be used.", |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 2999 | string_VkImageLayout(layout)); |
Mark Lobodzinski | 08f14fa | 2017-02-07 17:20:06 -0700 | [diff] [blame] | 3000 | } |
| 3001 | } |
| 3002 | } |
| 3003 | } |
| 3004 | } |
| 3005 | } |
Mark Lobodzinski | ac23ec8 | 2017-02-07 17:21:55 -0700 | [diff] [blame] | 3006 | return skip; |
Mark Lobodzinski | 08f14fa | 2017-02-07 17:20:06 -0700 | [diff] [blame] | 3007 | } |
Mark Lobodzinski | 9621074 | 2017-02-09 10:33:46 -0700 | [diff] [blame] | 3008 | |
| 3009 | // Helper function to validate correct usage bits set for buffers or images. Verify that (actual & desired) flags != 0 or, if strict |
| 3010 | // is true, verify that (actual & desired) flags == desired |
Mark Lobodzinski | 95dbbe5 | 2017-02-09 10:40:41 -0700 | [diff] [blame] | 3011 | static bool validate_usage_flags(layer_data *device_data, VkFlags actual, VkFlags desired, VkBool32 strict, uint64_t obj_handle, |
Mark Lobodzinski | 3382637 | 2017-04-13 11:10:11 -0600 | [diff] [blame] | 3012 | VulkanObjectType obj_type, int32_t const msgCode, char const *func_name, char const *usage_str) { |
Mark Lobodzinski | 95dbbe5 | 2017-02-09 10:40:41 -0700 | [diff] [blame] | 3013 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
Mark Lobodzinski | 9621074 | 2017-02-09 10:33:46 -0700 | [diff] [blame] | 3014 | |
| 3015 | bool correct_usage = false; |
Mark Lobodzinski | 95dbbe5 | 2017-02-09 10:40:41 -0700 | [diff] [blame] | 3016 | bool skip = false; |
Mark Lobodzinski | 3382637 | 2017-04-13 11:10:11 -0600 | [diff] [blame] | 3017 | const char *type_str = object_string[obj_type]; |
Mark Lobodzinski | 9621074 | 2017-02-09 10:33:46 -0700 | [diff] [blame] | 3018 | if (strict) { |
| 3019 | correct_usage = ((actual & desired) == desired); |
| 3020 | } else { |
| 3021 | correct_usage = ((actual & desired) != 0); |
| 3022 | } |
| 3023 | if (!correct_usage) { |
| 3024 | if (msgCode == -1) { |
| 3025 | // TODO: Fix callers with msgCode == -1 to use correct validation checks. |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 3026 | skip = |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 3027 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, get_debug_report_enum[obj_type], obj_handle, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3028 | MEMTRACK_INVALID_USAGE_FLAG, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 3029 | "Invalid usage flag for %s 0x%" PRIx64 " used by %s. In this case, %s should have %s set during creation.", |
| 3030 | type_str, obj_handle, func_name, type_str, usage_str); |
Mark Lobodzinski | 9621074 | 2017-02-09 10:33:46 -0700 | [diff] [blame] | 3031 | } else { |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 3032 | skip = |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3033 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, get_debug_report_enum[obj_type], obj_handle, msgCode, |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 3034 | "Invalid usage flag for %s 0x%" PRIx64 " used by %s. In this case, %s should have %s set during creation.", |
| 3035 | type_str, obj_handle, func_name, type_str, usage_str); |
Mark Lobodzinski | 9621074 | 2017-02-09 10:33:46 -0700 | [diff] [blame] | 3036 | } |
| 3037 | } |
Mark Lobodzinski | 95dbbe5 | 2017-02-09 10:40:41 -0700 | [diff] [blame] | 3038 | return skip; |
Mark Lobodzinski | 9621074 | 2017-02-09 10:33:46 -0700 | [diff] [blame] | 3039 | } |
| 3040 | |
| 3041 | // Helper function to validate usage flags for buffers. For given buffer_state send actual vs. desired usage off to helper above |
| 3042 | // where an error will be flagged if usage is not correct |
Chris Forbes | 8fdba30 | 2017-04-24 18:34:28 -0700 | [diff] [blame] | 3043 | bool ValidateImageUsageFlags(layer_data *device_data, IMAGE_STATE const *image_state, VkFlags desired, bool strict, |
Mark Lobodzinski | 9621074 | 2017-02-09 10:33:46 -0700 | [diff] [blame] | 3044 | int32_t const msgCode, char const *func_name, char const *usage_string) { |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 3045 | return validate_usage_flags(device_data, image_state->createInfo.usage, desired, strict, HandleToUint64(image_state->image), |
| 3046 | kVulkanObjectTypeImage, msgCode, func_name, usage_string); |
Mark Lobodzinski | 9621074 | 2017-02-09 10:33:46 -0700 | [diff] [blame] | 3047 | } |
| 3048 | |
| 3049 | // Helper function to validate usage flags for buffers. For given buffer_state send actual vs. desired usage off to helper above |
| 3050 | // where an error will be flagged if usage is not correct |
Chris Forbes | 8fdba30 | 2017-04-24 18:34:28 -0700 | [diff] [blame] | 3051 | bool ValidateBufferUsageFlags(layer_data *device_data, BUFFER_STATE const *buffer_state, VkFlags desired, bool strict, |
Mark Lobodzinski | 9621074 | 2017-02-09 10:33:46 -0700 | [diff] [blame] | 3052 | int32_t const msgCode, char const *func_name, char const *usage_string) { |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 3053 | return validate_usage_flags(device_data, buffer_state->createInfo.usage, desired, strict, HandleToUint64(buffer_state->buffer), |
| 3054 | kVulkanObjectTypeBuffer, msgCode, func_name, usage_string); |
Mark Lobodzinski | 9621074 | 2017-02-09 10:33:46 -0700 | [diff] [blame] | 3055 | } |
| 3056 | |
Mark Lobodzinski | 95dbbe5 | 2017-02-09 10:40:41 -0700 | [diff] [blame] | 3057 | bool PreCallValidateCreateBuffer(layer_data *device_data, const VkBufferCreateInfo *pCreateInfo) { |
Mark Lobodzinski | 9621074 | 2017-02-09 10:33:46 -0700 | [diff] [blame] | 3058 | bool skip = false; |
Mark Lobodzinski | 847b60c | 2017-03-13 09:32:45 -0600 | [diff] [blame] | 3059 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
| 3060 | |
Chris Forbes | e0f511c | 2017-06-14 12:38:01 -0700 | [diff] [blame] | 3061 | // TODO: Add check for VALIDATION_ERROR_1ec0071e (sparse address space accounting) |
Mark Lobodzinski | 847b60c | 2017-03-13 09:32:45 -0600 | [diff] [blame] | 3062 | |
| 3063 | if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!GetEnabledFeatures(device_data)->sparseBinding)) { |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 3064 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3065 | VALIDATION_ERROR_01400726, |
Mark Lobodzinski | 847b60c | 2017-03-13 09:32:45 -0600 | [diff] [blame] | 3066 | "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3067 | "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set."); |
Mark Lobodzinski | 847b60c | 2017-03-13 09:32:45 -0600 | [diff] [blame] | 3068 | } |
Mark Lobodzinski | af35506 | 2017-03-13 09:35:01 -0600 | [diff] [blame] | 3069 | |
| 3070 | if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!GetEnabledFeatures(device_data)->sparseResidencyBuffer)) { |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 3071 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3072 | VALIDATION_ERROR_01400728, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 3073 | "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3074 | "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set."); |
Mark Lobodzinski | af35506 | 2017-03-13 09:35:01 -0600 | [diff] [blame] | 3075 | } |
Mark Lobodzinski | 035a4cf | 2017-03-13 09:45:07 -0600 | [diff] [blame] | 3076 | |
| 3077 | if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!GetEnabledFeatures(device_data)->sparseResidencyAliased)) { |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 3078 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3079 | VALIDATION_ERROR_0140072a, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 3080 | "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3081 | "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set."); |
Mark Lobodzinski | 035a4cf | 2017-03-13 09:45:07 -0600 | [diff] [blame] | 3082 | } |
Mark Lobodzinski | 9621074 | 2017-02-09 10:33:46 -0700 | [diff] [blame] | 3083 | return skip; |
| 3084 | } |
| 3085 | |
| 3086 | void PostCallRecordCreateBuffer(layer_data *device_data, const VkBufferCreateInfo *pCreateInfo, VkBuffer *pBuffer) { |
| 3087 | // TODO : This doesn't create deep copy of pQueueFamilyIndices so need to fix that if/when we want that data to be valid |
| 3088 | GetBufferMap(device_data) |
| 3089 | ->insert(std::make_pair(*pBuffer, std::unique_ptr<BUFFER_STATE>(new BUFFER_STATE(*pBuffer, pCreateInfo)))); |
| 3090 | } |
| 3091 | |
Mark Lobodzinski | 95dbbe5 | 2017-02-09 10:40:41 -0700 | [diff] [blame] | 3092 | bool PreCallValidateCreateBufferView(layer_data *device_data, const VkBufferViewCreateInfo *pCreateInfo) { |
| 3093 | bool skip = false; |
| 3094 | BUFFER_STATE *buffer_state = GetBufferState(device_data, pCreateInfo->buffer); |
Mark Lobodzinski | 9621074 | 2017-02-09 10:33:46 -0700 | [diff] [blame] | 3095 | // If this isn't a sparse buffer, it needs to have memory backing it at CreateBufferView time |
| 3096 | if (buffer_state) { |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 3097 | skip |= ValidateMemoryIsBoundToBuffer(device_data, buffer_state, "vkCreateBufferView()", VALIDATION_ERROR_01a0074e); |
Mark Lobodzinski | 9621074 | 2017-02-09 10:33:46 -0700 | [diff] [blame] | 3098 | // In order to create a valid buffer view, the buffer must have been created with at least one of the following flags: |
| 3099 | // UNIFORM_TEXEL_BUFFER_BIT or STORAGE_TEXEL_BUFFER_BIT |
Mark Lobodzinski | 95dbbe5 | 2017-02-09 10:40:41 -0700 | [diff] [blame] | 3100 | skip |= ValidateBufferUsageFlags( |
| 3101 | device_data, buffer_state, VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT, false, |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 3102 | VALIDATION_ERROR_01a00748, "vkCreateBufferView()", "VK_BUFFER_USAGE_[STORAGE|UNIFORM]_TEXEL_BUFFER_BIT"); |
Mark Lobodzinski | 9621074 | 2017-02-09 10:33:46 -0700 | [diff] [blame] | 3103 | } |
Mark Lobodzinski | 95dbbe5 | 2017-02-09 10:40:41 -0700 | [diff] [blame] | 3104 | return skip; |
Mark Lobodzinski | 9621074 | 2017-02-09 10:33:46 -0700 | [diff] [blame] | 3105 | } |
| 3106 | |
| 3107 | void PostCallRecordCreateBufferView(layer_data *device_data, const VkBufferViewCreateInfo *pCreateInfo, VkBufferView *pView) { |
| 3108 | (*GetBufferViewMap(device_data))[*pView] = std::unique_ptr<BUFFER_VIEW_STATE>(new BUFFER_VIEW_STATE(*pView, pCreateInfo)); |
| 3109 | } |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3110 | |
| 3111 | // For the given format verify that the aspect masks make sense |
| 3112 | bool ValidateImageAspectMask(layer_data *device_data, VkImage image, VkFormat format, VkImageAspectFlags aspect_mask, |
| 3113 | const char *func_name) { |
| 3114 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
| 3115 | bool skip = false; |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 3116 | if (FormatIsColor(format)) { |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3117 | if ((aspect_mask & VK_IMAGE_ASPECT_COLOR_BIT) != VK_IMAGE_ASPECT_COLOR_BIT) { |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 3118 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3119 | HandleToUint64(image), VALIDATION_ERROR_0a400c01, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3120 | "%s: Color image formats must have the VK_IMAGE_ASPECT_COLOR_BIT set.", func_name); |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3121 | } else if ((aspect_mask & VK_IMAGE_ASPECT_COLOR_BIT) != aspect_mask) { |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 3122 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3123 | HandleToUint64(image), VALIDATION_ERROR_0a400c01, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3124 | "%s: Color image formats must have ONLY the VK_IMAGE_ASPECT_COLOR_BIT set.", func_name); |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3125 | } |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 3126 | } else if (FormatIsDepthAndStencil(format)) { |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3127 | if ((aspect_mask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) == 0) { |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 3128 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3129 | HandleToUint64(image), VALIDATION_ERROR_0a400c01, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 3130 | "%s: Depth/stencil image formats must have at least one of VK_IMAGE_ASPECT_DEPTH_BIT and " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3131 | "VK_IMAGE_ASPECT_STENCIL_BIT set.", |
| 3132 | func_name); |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3133 | } else if ((aspect_mask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) != aspect_mask) { |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 3134 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3135 | HandleToUint64(image), VALIDATION_ERROR_0a400c01, |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3136 | "%s: Combination depth/stencil image formats can have only the VK_IMAGE_ASPECT_DEPTH_BIT and " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3137 | "VK_IMAGE_ASPECT_STENCIL_BIT set.", |
| 3138 | func_name); |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3139 | } |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 3140 | } else if (FormatIsDepthOnly(format)) { |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3141 | if ((aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT) != VK_IMAGE_ASPECT_DEPTH_BIT) { |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 3142 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3143 | HandleToUint64(image), VALIDATION_ERROR_0a400c01, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3144 | "%s: Depth-only image formats must have the VK_IMAGE_ASPECT_DEPTH_BIT set.", func_name); |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3145 | } else if ((aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT) != aspect_mask) { |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 3146 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3147 | HandleToUint64(image), VALIDATION_ERROR_0a400c01, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3148 | "%s: Depth-only image formats can have only the VK_IMAGE_ASPECT_DEPTH_BIT set.", func_name); |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3149 | } |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 3150 | } else if (FormatIsStencilOnly(format)) { |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3151 | if ((aspect_mask & VK_IMAGE_ASPECT_STENCIL_BIT) != VK_IMAGE_ASPECT_STENCIL_BIT) { |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 3152 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3153 | HandleToUint64(image), VALIDATION_ERROR_0a400c01, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3154 | "%s: Stencil-only image formats must have the VK_IMAGE_ASPECT_STENCIL_BIT set.", func_name); |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3155 | } else if ((aspect_mask & VK_IMAGE_ASPECT_STENCIL_BIT) != aspect_mask) { |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 3156 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3157 | HandleToUint64(image), VALIDATION_ERROR_0a400c01, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3158 | "%s: Stencil-only image formats can have only the VK_IMAGE_ASPECT_STENCIL_BIT set.", func_name); |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3159 | } |
Dave Houlton | 501b15b | 2018-03-30 15:07:41 -0600 | [diff] [blame] | 3160 | } else if (FormatIsMultiplane(format)) { |
| 3161 | VkImageAspectFlags valid_flags = VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_PLANE_0_BIT | VK_IMAGE_ASPECT_PLANE_1_BIT; |
| 3162 | if (3 == FormatPlaneCount(format)) { |
| 3163 | valid_flags = valid_flags | VK_IMAGE_ASPECT_PLANE_2_BIT; |
| 3164 | } |
| 3165 | if ((aspect_mask & valid_flags) != aspect_mask) { |
| 3166 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
| 3167 | HandleToUint64(image), VALIDATION_ERROR_0a400c01, |
| 3168 | "%s: Multi-plane image formats may have only VK_IMAGE_ASPECT_COLOR_BIT or VK_IMAGE_ASPECT_PLANE_n_BITs " |
| 3169 | "set, where n = [0, 1, 2].", |
| 3170 | func_name); |
| 3171 | } |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3172 | } |
| 3173 | return skip; |
| 3174 | } |
| 3175 | |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3176 | struct SubresourceRangeErrorCodes { |
| 3177 | UNIQUE_VALIDATION_ERROR_CODE base_mip_err, mip_count_err, base_layer_err, layer_count_err; |
| 3178 | }; |
| 3179 | |
| 3180 | bool ValidateImageSubresourceRange(const layer_data *device_data, const uint32_t image_mip_count, const uint32_t image_layer_count, |
| 3181 | const VkImageSubresourceRange &subresourceRange, const char *cmd_name, const char *param_name, |
| 3182 | const char *image_layer_count_var_name, const uint64_t image_handle, |
| 3183 | SubresourceRangeErrorCodes errorCodes) { |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3184 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
| 3185 | bool skip = false; |
Petr Kraus | 4d71868 | 2017-05-18 03:38:41 +0200 | [diff] [blame] | 3186 | |
| 3187 | // Validate mip levels |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3188 | if (subresourceRange.baseMipLevel >= image_mip_count) { |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 3189 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, image_handle, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3190 | errorCodes.base_mip_err, |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3191 | "%s: %s.baseMipLevel (= %" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3192 | ") is greater or equal to the mip level count of the image (i.e. greater or equal to %" PRIu32 ").", |
| 3193 | cmd_name, param_name, subresourceRange.baseMipLevel, image_mip_count); |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3194 | } |
Petr Kraus | 4d71868 | 2017-05-18 03:38:41 +0200 | [diff] [blame] | 3195 | |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3196 | if (subresourceRange.levelCount != VK_REMAINING_MIP_LEVELS) { |
| 3197 | if (subresourceRange.levelCount == 0) { |
| 3198 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, image_handle, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3199 | errorCodes.mip_count_err, "%s: %s.levelCount is 0.", cmd_name, param_name); |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3200 | } else { |
| 3201 | const uint64_t necessary_mip_count = uint64_t{subresourceRange.baseMipLevel} + uint64_t{subresourceRange.levelCount}; |
Petr Kraus | 4d71868 | 2017-05-18 03:38:41 +0200 | [diff] [blame] | 3202 | |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3203 | if (necessary_mip_count > image_mip_count) { |
| 3204 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, image_handle, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3205 | errorCodes.mip_count_err, |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3206 | "%s: %s.baseMipLevel + .levelCount (= %" PRIu32 " + %" PRIu32 " = %" PRIu64 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3207 | ") is greater than the mip level count of the image (i.e. greater than %" PRIu32 ").", |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3208 | cmd_name, param_name, subresourceRange.baseMipLevel, subresourceRange.levelCount, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3209 | necessary_mip_count, image_mip_count); |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3210 | } |
Petr Kraus | 4d71868 | 2017-05-18 03:38:41 +0200 | [diff] [blame] | 3211 | } |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3212 | } |
Petr Kraus | 4d71868 | 2017-05-18 03:38:41 +0200 | [diff] [blame] | 3213 | |
| 3214 | // Validate array layers |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3215 | if (subresourceRange.baseArrayLayer >= image_layer_count) { |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 3216 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, image_handle, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3217 | errorCodes.base_layer_err, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3218 | "%s: %s.baseArrayLayer (= %" PRIu32 |
| 3219 | ") is greater or equal to the %s of the image when it was created (i.e. greater or equal to %" PRIu32 ").", |
| 3220 | cmd_name, param_name, subresourceRange.baseArrayLayer, image_layer_count_var_name, image_layer_count); |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3221 | } |
Petr Kraus | 4d71868 | 2017-05-18 03:38:41 +0200 | [diff] [blame] | 3222 | |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3223 | if (subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) { |
| 3224 | if (subresourceRange.layerCount == 0) { |
| 3225 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, image_handle, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3226 | errorCodes.layer_count_err, "%s: %s.layerCount is 0.", cmd_name, param_name); |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3227 | } else { |
| 3228 | const uint64_t necessary_layer_count = |
| 3229 | uint64_t{subresourceRange.baseArrayLayer} + uint64_t{subresourceRange.layerCount}; |
Petr Kraus | 8423f15 | 2017-05-26 01:20:04 +0200 | [diff] [blame] | 3230 | |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3231 | if (necessary_layer_count > image_layer_count) { |
| 3232 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, image_handle, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3233 | errorCodes.layer_count_err, |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3234 | "%s: %s.baseArrayLayer + .layerCount (= %" PRIu32 " + %" PRIu32 " = %" PRIu64 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3235 | ") is greater than the %s of the image when it was created (i.e. greater than %" PRIu32 ").", |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3236 | cmd_name, param_name, subresourceRange.baseArrayLayer, subresourceRange.layerCount, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3237 | necessary_layer_count, image_layer_count_var_name, image_layer_count); |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3238 | } |
Petr Kraus | 4d71868 | 2017-05-18 03:38:41 +0200 | [diff] [blame] | 3239 | } |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3240 | } |
Petr Kraus | 4d71868 | 2017-05-18 03:38:41 +0200 | [diff] [blame] | 3241 | |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3242 | return skip; |
| 3243 | } |
| 3244 | |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3245 | bool ValidateCreateImageViewSubresourceRange(const layer_data *device_data, const IMAGE_STATE *image_state, |
| 3246 | bool is_imageview_2d_type, const VkImageSubresourceRange &subresourceRange) { |
| 3247 | bool is_khr_maintenance1 = GetDeviceExtensions(device_data)->vk_khr_maintenance1; |
| 3248 | bool is_image_slicable = image_state->createInfo.imageType == VK_IMAGE_TYPE_3D && |
| 3249 | (image_state->createInfo.flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT_KHR); |
| 3250 | bool is_3D_to_2D_map = is_khr_maintenance1 && is_image_slicable && is_imageview_2d_type; |
| 3251 | |
| 3252 | const auto image_layer_count = is_3D_to_2D_map ? image_state->createInfo.extent.depth : image_state->createInfo.arrayLayers; |
| 3253 | const auto image_layer_count_var_name = is_3D_to_2D_map ? "extent.depth" : "arrayLayers"; |
| 3254 | |
| 3255 | SubresourceRangeErrorCodes subresourceRangeErrorCodes = {}; |
| 3256 | subresourceRangeErrorCodes.base_mip_err = VALIDATION_ERROR_0ac00b8c; |
Mike Schuchardt | 8da1bb5 | 2018-02-22 10:46:31 -0700 | [diff] [blame] | 3257 | subresourceRangeErrorCodes.mip_count_err = VALIDATION_ERROR_0ac00d6c; |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3258 | subresourceRangeErrorCodes.base_layer_err = |
| 3259 | is_khr_maintenance1 ? (is_3D_to_2D_map ? VALIDATION_ERROR_0ac00b98 : VALIDATION_ERROR_0ac00b94) : VALIDATION_ERROR_0ac00b90; |
| 3260 | subresourceRangeErrorCodes.layer_count_err = |
Mike Schuchardt | 8da1bb5 | 2018-02-22 10:46:31 -0700 | [diff] [blame] | 3261 | is_khr_maintenance1 ? (is_3D_to_2D_map ? VALIDATION_ERROR_0ac00b9a : VALIDATION_ERROR_0ac00b96) : VALIDATION_ERROR_0ac00d6e; |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3262 | |
| 3263 | return ValidateImageSubresourceRange(device_data, image_state->createInfo.mipLevels, image_layer_count, subresourceRange, |
| 3264 | "vkCreateImageView", "pCreateInfo->subresourceRange", image_layer_count_var_name, |
| 3265 | HandleToUint64(image_state->image), subresourceRangeErrorCodes); |
| 3266 | } |
| 3267 | |
| 3268 | bool ValidateCmdClearColorSubresourceRange(const layer_data *device_data, const IMAGE_STATE *image_state, |
| 3269 | const VkImageSubresourceRange &subresourceRange, const char *param_name) { |
| 3270 | SubresourceRangeErrorCodes subresourceRangeErrorCodes = {}; |
| 3271 | subresourceRangeErrorCodes.base_mip_err = VALIDATION_ERROR_18800b7c; |
Mike Schuchardt | 8da1bb5 | 2018-02-22 10:46:31 -0700 | [diff] [blame] | 3272 | subresourceRangeErrorCodes.mip_count_err = VALIDATION_ERROR_18800d38; |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3273 | subresourceRangeErrorCodes.base_layer_err = VALIDATION_ERROR_18800b80; |
Mike Schuchardt | 8da1bb5 | 2018-02-22 10:46:31 -0700 | [diff] [blame] | 3274 | subresourceRangeErrorCodes.layer_count_err = VALIDATION_ERROR_18800d3a; |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3275 | |
| 3276 | return ValidateImageSubresourceRange(device_data, image_state->createInfo.mipLevels, image_state->createInfo.arrayLayers, |
| 3277 | subresourceRange, "vkCmdClearColorImage", param_name, "arrayLayers", |
| 3278 | HandleToUint64(image_state->image), subresourceRangeErrorCodes); |
| 3279 | } |
| 3280 | |
| 3281 | bool ValidateCmdClearDepthSubresourceRange(const layer_data *device_data, const IMAGE_STATE *image_state, |
| 3282 | const VkImageSubresourceRange &subresourceRange, const char *param_name) { |
| 3283 | SubresourceRangeErrorCodes subresourceRangeErrorCodes = {}; |
| 3284 | subresourceRangeErrorCodes.base_mip_err = VALIDATION_ERROR_18a00b84; |
Mike Schuchardt | 8da1bb5 | 2018-02-22 10:46:31 -0700 | [diff] [blame] | 3285 | subresourceRangeErrorCodes.mip_count_err = VALIDATION_ERROR_18a00d3c; |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3286 | subresourceRangeErrorCodes.base_layer_err = VALIDATION_ERROR_18a00b88; |
Mike Schuchardt | 8da1bb5 | 2018-02-22 10:46:31 -0700 | [diff] [blame] | 3287 | subresourceRangeErrorCodes.layer_count_err = VALIDATION_ERROR_18a00d3e; |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3288 | |
| 3289 | return ValidateImageSubresourceRange(device_data, image_state->createInfo.mipLevels, image_state->createInfo.arrayLayers, |
| 3290 | subresourceRange, "vkCmdClearDepthStencilImage", param_name, "arrayLayers", |
| 3291 | HandleToUint64(image_state->image), subresourceRangeErrorCodes); |
| 3292 | } |
| 3293 | |
| 3294 | bool ValidateImageBarrierSubresourceRange(const layer_data *device_data, const IMAGE_STATE *image_state, |
| 3295 | const VkImageSubresourceRange &subresourceRange, const char *cmd_name, |
| 3296 | const char *param_name) { |
| 3297 | SubresourceRangeErrorCodes subresourceRangeErrorCodes = {}; |
| 3298 | subresourceRangeErrorCodes.base_mip_err = VALIDATION_ERROR_0a000b9c; |
Mike Schuchardt | 8da1bb5 | 2018-02-22 10:46:31 -0700 | [diff] [blame] | 3299 | subresourceRangeErrorCodes.mip_count_err = VALIDATION_ERROR_0a000d78; |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3300 | subresourceRangeErrorCodes.base_layer_err = VALIDATION_ERROR_0a000ba0; |
Mike Schuchardt | 8da1bb5 | 2018-02-22 10:46:31 -0700 | [diff] [blame] | 3301 | subresourceRangeErrorCodes.layer_count_err = VALIDATION_ERROR_0a000d7a; |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3302 | |
| 3303 | return ValidateImageSubresourceRange(device_data, image_state->createInfo.mipLevels, image_state->createInfo.arrayLayers, |
| 3304 | subresourceRange, cmd_name, param_name, "arrayLayers", HandleToUint64(image_state->image), |
| 3305 | subresourceRangeErrorCodes); |
| 3306 | } |
| 3307 | |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3308 | bool PreCallValidateCreateImageView(layer_data *device_data, const VkImageViewCreateInfo *create_info) { |
| 3309 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
| 3310 | bool skip = false; |
| 3311 | IMAGE_STATE *image_state = GetImageState(device_data, create_info->image); |
| 3312 | if (image_state) { |
| 3313 | skip |= ValidateImageUsageFlags( |
| 3314 | device_data, image_state, |
| 3315 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT | |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 3316 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3317 | false, -1, "vkCreateImageView()", |
| 3318 | "VK_IMAGE_USAGE_[SAMPLED|STORAGE|COLOR_ATTACHMENT|DEPTH_STENCIL_ATTACHMENT|INPUT_ATTACHMENT]_BIT"); |
| 3319 | // If this isn't a sparse image, it needs to have memory backing it at CreateImageView time |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 3320 | skip |= ValidateMemoryIsBoundToImage(device_data, image_state, "vkCreateImageView()", VALIDATION_ERROR_0ac007f8); |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3321 | // Checks imported from image layer |
Petr Kraus | ffa94af | 2017-08-08 21:46:02 +0200 | [diff] [blame] | 3322 | skip |= ValidateCreateImageViewSubresourceRange( |
| 3323 | device_data, image_state, |
| 3324 | create_info->viewType == VK_IMAGE_VIEW_TYPE_2D || create_info->viewType == VK_IMAGE_VIEW_TYPE_2D_ARRAY, |
| 3325 | create_info->subresourceRange); |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3326 | |
| 3327 | VkImageCreateFlags image_flags = image_state->createInfo.flags; |
| 3328 | VkFormat image_format = image_state->createInfo.format; |
Jeremy Kniager | cef491c | 2017-07-18 11:10:28 -0600 | [diff] [blame] | 3329 | VkImageUsageFlags image_usage = image_state->createInfo.usage; |
| 3330 | VkImageTiling image_tiling = image_state->createInfo.tiling; |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3331 | VkFormat view_format = create_info->format; |
| 3332 | VkImageAspectFlags aspect_mask = create_info->subresourceRange.aspectMask; |
Jeremy Kniager | 846ab73 | 2017-07-10 13:12:04 -0600 | [diff] [blame] | 3333 | VkImageType image_type = image_state->createInfo.imageType; |
| 3334 | VkImageViewType view_type = create_info->viewType; |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3335 | |
Dave Houlton | bd2e262 | 2018-04-10 16:41:14 -0600 | [diff] [blame] | 3336 | // If there's a chained VkImageViewUsageCreateInfo struct, modify image_usage to match |
| 3337 | auto chained_ivuci_struct = lvl_find_in_chain<VkImageViewUsageCreateInfoKHR>(create_info->pNext); |
| 3338 | if (chained_ivuci_struct) { |
| 3339 | if (chained_ivuci_struct->usage & ~image_usage) { |
| 3340 | std::stringstream ss; |
| 3341 | ss << "vkCreateImageView(): Chained VkImageViewUsageCreateInfo usage field (0x" << std::hex |
Dave Houlton | 0f3795b | 2018-04-13 15:04:35 -0600 | [diff] [blame] | 3342 | << chained_ivuci_struct->usage << ") must not include flags not present in underlying image's usage (0x" |
Dave Houlton | bd2e262 | 2018-04-10 16:41:14 -0600 | [diff] [blame] | 3343 | << image_usage << ")."; |
| 3344 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 3345 | VALIDATION_ERROR_3f200c66, "%s", ss.str().c_str()); |
| 3346 | } |
| 3347 | |
| 3348 | image_usage = chained_ivuci_struct->usage; |
| 3349 | } |
| 3350 | |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3351 | // Validate VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT state |
| 3352 | if (image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) { |
Dave Houlton | c798807 | 2018-04-16 11:46:56 -0600 | [diff] [blame] | 3353 | if (FormatIsMultiplane(image_format)) { |
| 3354 | // View format must match the multiplane compatible format |
| 3355 | uint32_t plane = 3; // invalid |
| 3356 | switch (aspect_mask) { |
| 3357 | case VK_IMAGE_ASPECT_PLANE_0_BIT: |
| 3358 | plane = 0; |
| 3359 | break; |
| 3360 | case VK_IMAGE_ASPECT_PLANE_1_BIT: |
| 3361 | plane = 1; |
| 3362 | break; |
| 3363 | case VK_IMAGE_ASPECT_PLANE_2_BIT: |
| 3364 | plane = 2; |
| 3365 | break; |
| 3366 | default: |
| 3367 | break; |
| 3368 | } |
| 3369 | |
| 3370 | VkFormat compat_format = FindMultiplaneCompatibleFormat(image_format, plane); |
| 3371 | if (view_format != compat_format) { |
Lenny Komow | b79f04a | 2017-09-18 17:07:00 -0600 | [diff] [blame] | 3372 | std::stringstream ss; |
| 3373 | ss << "vkCreateImageView(): ImageView format " << string_VkFormat(view_format) |
Dave Houlton | c798807 | 2018-04-16 11:46:56 -0600 | [diff] [blame] | 3374 | << " is not compatible with plane " << plane << " of underlying image format " |
| 3375 | << string_VkFormat(image_format) << ", must be " << string_VkFormat(compat_format) << "."; |
Lenny Komow | b79f04a | 2017-09-18 17:07:00 -0600 | [diff] [blame] | 3376 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Dave Houlton | c798807 | 2018-04-16 11:46:56 -0600 | [diff] [blame] | 3377 | VALIDATION_ERROR_0ac00c64, "%s", ss.str().c_str()); |
| 3378 | } |
| 3379 | } else { |
| 3380 | if ((!GetDeviceExtensions(device_data)->vk_khr_maintenance2 || |
| 3381 | !(image_flags & VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT_KHR))) { |
| 3382 | // Format MUST be compatible (in the same format compatibility class) as the format the image was created with |
| 3383 | if (FormatCompatibilityClass(image_format) != FormatCompatibilityClass(view_format)) { |
| 3384 | std::stringstream ss; |
| 3385 | ss << "vkCreateImageView(): ImageView format " << string_VkFormat(view_format) |
| 3386 | << " is not in the same format compatibility class as image (" << HandleToUint64(create_info->image) |
| 3387 | << ") format " << string_VkFormat(image_format) |
| 3388 | << ". Images created with the VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " |
| 3389 | << "can support ImageViews with differing formats but they must be in the same compatibility class."; |
| 3390 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
| 3391 | VALIDATION_ERROR_0ac007f4, "%s", ss.str().c_str()); |
| 3392 | } |
Lenny Komow | b79f04a | 2017-09-18 17:07:00 -0600 | [diff] [blame] | 3393 | } |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3394 | } |
| 3395 | } else { |
| 3396 | // Format MUST be IDENTICAL to the format the image was created with |
| 3397 | if (image_format != view_format) { |
| 3398 | std::stringstream ss; |
| 3399 | ss << "vkCreateImageView() format " << string_VkFormat(view_format) << " differs from image " |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 3400 | << HandleToUint64(create_info->image) << " format " << string_VkFormat(image_format) |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3401 | << ". Formats MUST be IDENTICAL unless VK_IMAGE_CREATE_MUTABLE_FORMAT BIT was set on image creation."; |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 3402 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3403 | VALIDATION_ERROR_0ac007f6, "%s", ss.str().c_str()); |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3404 | } |
| 3405 | } |
| 3406 | |
| 3407 | // Validate correct image aspect bits for desired formats and format consistency |
| 3408 | skip |= ValidateImageAspectMask(device_data, image_state->image, image_format, aspect_mask, "vkCreateImageView()"); |
Jeremy Kniager | 846ab73 | 2017-07-10 13:12:04 -0600 | [diff] [blame] | 3409 | |
| 3410 | switch (image_type) { |
| 3411 | case VK_IMAGE_TYPE_1D: |
| 3412 | if (view_type != VK_IMAGE_VIEW_TYPE_1D && view_type != VK_IMAGE_VIEW_TYPE_1D_ARRAY) { |
| 3413 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3414 | VALIDATION_ERROR_0ac007fa, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3415 | "vkCreateImageView(): pCreateInfo->viewType %s is not compatible with image type %s.", |
| 3416 | string_VkImageViewType(view_type), string_VkImageType(image_type)); |
Jeremy Kniager | 846ab73 | 2017-07-10 13:12:04 -0600 | [diff] [blame] | 3417 | } |
| 3418 | break; |
| 3419 | case VK_IMAGE_TYPE_2D: |
| 3420 | if (view_type != VK_IMAGE_VIEW_TYPE_2D && view_type != VK_IMAGE_VIEW_TYPE_2D_ARRAY) { |
| 3421 | if ((view_type == VK_IMAGE_VIEW_TYPE_CUBE || view_type == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && |
| 3422 | !(image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT)) { |
| 3423 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3424 | VALIDATION_ERROR_0ac007d6, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3425 | "vkCreateImageView(): pCreateInfo->viewType %s is not compatible with image type %s.", |
| 3426 | string_VkImageViewType(view_type), string_VkImageType(image_type)); |
Jeremy Kniager | 846ab73 | 2017-07-10 13:12:04 -0600 | [diff] [blame] | 3427 | } else if (view_type != VK_IMAGE_VIEW_TYPE_CUBE && view_type != VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) { |
| 3428 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3429 | VALIDATION_ERROR_0ac007fa, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3430 | "vkCreateImageView(): pCreateInfo->viewType %s is not compatible with image type %s.", |
| 3431 | string_VkImageViewType(view_type), string_VkImageType(image_type)); |
Jeremy Kniager | 846ab73 | 2017-07-10 13:12:04 -0600 | [diff] [blame] | 3432 | } |
| 3433 | } |
| 3434 | break; |
| 3435 | case VK_IMAGE_TYPE_3D: |
| 3436 | if (GetDeviceExtensions(device_data)->vk_khr_maintenance1) { |
| 3437 | if (view_type != VK_IMAGE_VIEW_TYPE_3D) { |
| 3438 | if ((view_type == VK_IMAGE_VIEW_TYPE_2D || view_type == VK_IMAGE_VIEW_TYPE_2D_ARRAY)) { |
| 3439 | if (!(image_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT_KHR)) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3440 | skip |= |
| 3441 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3442 | VALIDATION_ERROR_0ac007da, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3443 | "vkCreateImageView(): pCreateInfo->viewType %s is not compatible with image type %s.", |
| 3444 | string_VkImageViewType(view_type), string_VkImageType(image_type)); |
Jeremy Kniager | 846ab73 | 2017-07-10 13:12:04 -0600 | [diff] [blame] | 3445 | } else if ((image_flags & (VK_IMAGE_CREATE_SPARSE_BINDING_BIT | VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | |
| 3446 | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT))) { |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 3447 | skip |= |
| 3448 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3449 | VALIDATION_ERROR_0ac007fa, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 3450 | "vkCreateImageView(): pCreateInfo->viewType %s is not compatible with image type %s " |
| 3451 | "when the VK_IMAGE_CREATE_SPARSE_BINDING_BIT, VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT, or " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3452 | "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT flags are enabled.", |
| 3453 | string_VkImageViewType(view_type), string_VkImageType(image_type)); |
Jeremy Kniager | 846ab73 | 2017-07-10 13:12:04 -0600 | [diff] [blame] | 3454 | } |
| 3455 | } else { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3456 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3457 | VALIDATION_ERROR_0ac007fa, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3458 | "vkCreateImageView(): pCreateInfo->viewType %s is not compatible with image type %s.", |
| 3459 | string_VkImageViewType(view_type), string_VkImageType(image_type)); |
Jeremy Kniager | 846ab73 | 2017-07-10 13:12:04 -0600 | [diff] [blame] | 3460 | } |
| 3461 | } |
| 3462 | } else { |
| 3463 | if (view_type != VK_IMAGE_VIEW_TYPE_3D) { |
| 3464 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3465 | VALIDATION_ERROR_0ac007fa, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3466 | "vkCreateImageView(): pCreateInfo->viewType %s is not compatible with image type %s.", |
| 3467 | string_VkImageViewType(view_type), string_VkImageType(image_type)); |
Jeremy Kniager | 846ab73 | 2017-07-10 13:12:04 -0600 | [diff] [blame] | 3468 | } |
| 3469 | } |
| 3470 | break; |
| 3471 | default: |
| 3472 | break; |
| 3473 | } |
Jeremy Kniager | cef491c | 2017-07-18 11:10:28 -0600 | [diff] [blame] | 3474 | |
Jeremy Kniager | 7ec550f | 2017-08-16 14:57:42 -0600 | [diff] [blame] | 3475 | VkFormatProperties format_properties = GetFormatProperties(device_data, view_format); |
Jeremy Kniager | cef491c | 2017-07-18 11:10:28 -0600 | [diff] [blame] | 3476 | bool check_tiling_features = false; |
| 3477 | VkFormatFeatureFlags tiling_features = 0; |
| 3478 | UNIQUE_VALIDATION_ERROR_CODE linear_error_codes[] = { |
| 3479 | VALIDATION_ERROR_0ac007dc, VALIDATION_ERROR_0ac007e0, VALIDATION_ERROR_0ac007e2, |
| 3480 | VALIDATION_ERROR_0ac007e4, VALIDATION_ERROR_0ac007e6, |
| 3481 | }; |
| 3482 | UNIQUE_VALIDATION_ERROR_CODE optimal_error_codes[] = { |
| 3483 | VALIDATION_ERROR_0ac007e8, VALIDATION_ERROR_0ac007ea, VALIDATION_ERROR_0ac007ec, |
| 3484 | VALIDATION_ERROR_0ac007ee, VALIDATION_ERROR_0ac007f0, |
| 3485 | }; |
| 3486 | UNIQUE_VALIDATION_ERROR_CODE *error_codes = nullptr; |
| 3487 | if (image_tiling == VK_IMAGE_TILING_LINEAR) { |
Jeremy Kniager | 7ec550f | 2017-08-16 14:57:42 -0600 | [diff] [blame] | 3488 | tiling_features = format_properties.linearTilingFeatures; |
Jeremy Kniager | cef491c | 2017-07-18 11:10:28 -0600 | [diff] [blame] | 3489 | error_codes = linear_error_codes; |
| 3490 | check_tiling_features = true; |
| 3491 | } else if (image_tiling == VK_IMAGE_TILING_OPTIMAL) { |
Jeremy Kniager | 7ec550f | 2017-08-16 14:57:42 -0600 | [diff] [blame] | 3492 | tiling_features = format_properties.optimalTilingFeatures; |
Jeremy Kniager | cef491c | 2017-07-18 11:10:28 -0600 | [diff] [blame] | 3493 | error_codes = optimal_error_codes; |
| 3494 | check_tiling_features = true; |
| 3495 | } |
| 3496 | |
| 3497 | if (check_tiling_features) { |
| 3498 | if (tiling_features == 0) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3499 | skip |= |
| 3500 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, error_codes[0], |
| 3501 | "vkCreateImageView() pCreateInfo->format %s cannot be used with an image having the %s flag set.", |
| 3502 | string_VkFormat(view_format), string_VkImageTiling(image_tiling)); |
Jeremy Kniager | cef491c | 2017-07-18 11:10:28 -0600 | [diff] [blame] | 3503 | } else if ((image_usage & VK_IMAGE_USAGE_SAMPLED_BIT) && !(tiling_features & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3504 | skip |= |
| 3505 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, error_codes[1], |
| 3506 | "vkCreateImageView() pCreateInfo->format %s cannot be used with an image having the %s and " |
| 3507 | "VK_IMAGE_USAGE_SAMPLED_BIT flags set.", |
| 3508 | string_VkFormat(view_format), string_VkImageTiling(image_tiling)); |
Jeremy Kniager | cef491c | 2017-07-18 11:10:28 -0600 | [diff] [blame] | 3509 | } else if ((image_usage & VK_IMAGE_USAGE_STORAGE_BIT) && !(tiling_features & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT)) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3510 | skip |= |
| 3511 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, error_codes[2], |
| 3512 | "vkCreateImageView() pCreateInfo->format %s cannot be used with an image having the %s and " |
| 3513 | "VK_IMAGE_USAGE_STORAGE_BIT flags set.", |
| 3514 | string_VkFormat(view_format), string_VkImageTiling(image_tiling)); |
Jeremy Kniager | cef491c | 2017-07-18 11:10:28 -0600 | [diff] [blame] | 3515 | } else if ((image_usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) && |
| 3516 | !(tiling_features & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT)) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3517 | skip |= |
| 3518 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, error_codes[3], |
| 3519 | "vkCreateImageView() pCreateInfo->format %s cannot be used with an image having the %s and " |
| 3520 | "VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT flags set.", |
| 3521 | string_VkFormat(view_format), string_VkImageTiling(image_tiling)); |
Jeremy Kniager | cef491c | 2017-07-18 11:10:28 -0600 | [diff] [blame] | 3522 | } else if ((image_usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) && |
| 3523 | !(tiling_features & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3524 | skip |= |
| 3525 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, error_codes[4], |
| 3526 | "vkCreateImageView() pCreateInfo->format %s cannot be used with an image having the %s and " |
| 3527 | "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT flags set.", |
| 3528 | string_VkFormat(view_format), string_VkImageTiling(image_tiling)); |
Jeremy Kniager | cef491c | 2017-07-18 11:10:28 -0600 | [diff] [blame] | 3529 | } |
| 3530 | } |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3531 | } |
| 3532 | return skip; |
| 3533 | } |
| 3534 | |
Mark Lobodzinski | efd933b | 2017-02-10 12:09:23 -0700 | [diff] [blame] | 3535 | void PostCallRecordCreateImageView(layer_data *device_data, const VkImageViewCreateInfo *create_info, VkImageView view) { |
| 3536 | auto image_view_map = GetImageViewMap(device_data); |
| 3537 | (*image_view_map)[view] = std::unique_ptr<IMAGE_VIEW_STATE>(new IMAGE_VIEW_STATE(view, create_info)); |
| 3538 | |
| 3539 | auto image_state = GetImageState(device_data, create_info->image); |
Dave Houlton | 4eaaf3a | 2017-03-14 11:31:20 -0600 | [diff] [blame] | 3540 | auto &sub_res_range = (*image_view_map)[view].get()->create_info.subresourceRange; |
Mark Lobodzinski | 903e5ff | 2017-03-23 09:43:35 -0600 | [diff] [blame] | 3541 | sub_res_range.levelCount = ResolveRemainingLevels(&sub_res_range, image_state->createInfo.mipLevels); |
| 3542 | sub_res_range.layerCount = ResolveRemainingLayers(&sub_res_range, image_state->createInfo.arrayLayers); |
Mark Lobodzinski | 602de98 | 2017-02-09 11:01:33 -0700 | [diff] [blame] | 3543 | } |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 3544 | |
Mark Lobodzinski | 680421d | 2017-02-09 13:06:56 -0700 | [diff] [blame] | 3545 | bool PreCallValidateCmdCopyBuffer(layer_data *device_data, GLOBAL_CB_NODE *cb_node, BUFFER_STATE *src_buffer_state, |
| 3546 | BUFFER_STATE *dst_buffer_state) { |
| 3547 | bool skip = false; |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 3548 | skip |= ValidateMemoryIsBoundToBuffer(device_data, src_buffer_state, "vkCmdCopyBuffer()", VALIDATION_ERROR_18c000ee); |
| 3549 | skip |= ValidateMemoryIsBoundToBuffer(device_data, dst_buffer_state, "vkCmdCopyBuffer()", VALIDATION_ERROR_18c000f2); |
Mark Lobodzinski | 680421d | 2017-02-09 13:06:56 -0700 | [diff] [blame] | 3550 | // Validate that SRC & DST buffers have correct usage flags set |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 3551 | skip |= ValidateBufferUsageFlags(device_data, src_buffer_state, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, true, |
| 3552 | VALIDATION_ERROR_18c000ec, "vkCmdCopyBuffer()", "VK_BUFFER_USAGE_TRANSFER_SRC_BIT"); |
| 3553 | skip |= ValidateBufferUsageFlags(device_data, dst_buffer_state, VK_BUFFER_USAGE_TRANSFER_DST_BIT, true, |
| 3554 | VALIDATION_ERROR_18c000f0, "vkCmdCopyBuffer()", "VK_BUFFER_USAGE_TRANSFER_DST_BIT"); |
Mike Schuchardt | 9c58240 | 2017-02-23 15:57:37 -0700 | [diff] [blame] | 3555 | skip |= ValidateCmdQueueFlags(device_data, cb_node, "vkCmdCopyBuffer()", |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 3556 | VK_QUEUE_TRANSFER_BIT | VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT, VALIDATION_ERROR_18c02415); |
Mark Lobodzinski | 680421d | 2017-02-09 13:06:56 -0700 | [diff] [blame] | 3557 | skip |= ValidateCmd(device_data, cb_node, CMD_COPYBUFFER, "vkCmdCopyBuffer()"); |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 3558 | skip |= insideRenderPass(device_data, cb_node, "vkCmdCopyBuffer()", VALIDATION_ERROR_18c00017); |
Mark Lobodzinski | 680421d | 2017-02-09 13:06:56 -0700 | [diff] [blame] | 3559 | return skip; |
| 3560 | } |
Mark Lobodzinski | ab9be28 | 2017-02-09 12:01:27 -0700 | [diff] [blame] | 3561 | |
Mark Lobodzinski | 680421d | 2017-02-09 13:06:56 -0700 | [diff] [blame] | 3562 | void PreCallRecordCmdCopyBuffer(layer_data *device_data, GLOBAL_CB_NODE *cb_node, BUFFER_STATE *src_buffer_state, |
| 3563 | BUFFER_STATE *dst_buffer_state) { |
| 3564 | // Update bindings between buffers and cmd buffer |
| 3565 | AddCommandBufferBindingBuffer(device_data, cb_node, src_buffer_state); |
| 3566 | AddCommandBufferBindingBuffer(device_data, cb_node, dst_buffer_state); |
Mark Lobodzinski | 680421d | 2017-02-09 13:06:56 -0700 | [diff] [blame] | 3567 | } |
Mark Lobodzinski | 306441e | 2017-02-10 13:48:38 -0700 | [diff] [blame] | 3568 | |
| 3569 | static bool validateIdleBuffer(layer_data *device_data, VkBuffer buffer) { |
| 3570 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
| 3571 | bool skip = false; |
| 3572 | auto buffer_state = GetBufferState(device_data, buffer); |
| 3573 | if (!buffer_state) { |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 3574 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, HandleToUint64(buffer), |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3575 | DRAWSTATE_DOUBLE_DESTROY, "Cannot free buffer 0x%" PRIx64 " that has not been allocated.", |
Petr Kraus | 13c98a6 | 2017-12-09 00:22:39 +0100 | [diff] [blame] | 3576 | HandleToUint64(buffer)); |
Mark Lobodzinski | 306441e | 2017-02-10 13:48:38 -0700 | [diff] [blame] | 3577 | } else { |
| 3578 | if (buffer_state->in_use.load()) { |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 3579 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3580 | HandleToUint64(buffer), VALIDATION_ERROR_23c00734, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3581 | "Cannot free buffer 0x%" PRIx64 " that is in use by a command buffer.", HandleToUint64(buffer)); |
Mark Lobodzinski | 306441e | 2017-02-10 13:48:38 -0700 | [diff] [blame] | 3582 | } |
| 3583 | } |
| 3584 | return skip; |
| 3585 | } |
| 3586 | |
| 3587 | bool PreCallValidateDestroyImageView(layer_data *device_data, VkImageView image_view, IMAGE_VIEW_STATE **image_view_state, |
| 3588 | VK_OBJECT *obj_struct) { |
| 3589 | *image_view_state = GetImageViewState(device_data, image_view); |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 3590 | *obj_struct = {HandleToUint64(image_view), kVulkanObjectTypeImageView}; |
Mark Lobodzinski | 306441e | 2017-02-10 13:48:38 -0700 | [diff] [blame] | 3591 | if (GetDisables(device_data)->destroy_image_view) return false; |
| 3592 | bool skip = false; |
| 3593 | if (*image_view_state) { |
Mike Schuchardt | a502565 | 2017-09-27 14:56:21 -0600 | [diff] [blame] | 3594 | skip |= |
| 3595 | ValidateObjectNotInUse(device_data, *image_view_state, *obj_struct, "vkDestroyImageView", VALIDATION_ERROR_25400804); |
Mark Lobodzinski | 306441e | 2017-02-10 13:48:38 -0700 | [diff] [blame] | 3596 | } |
| 3597 | return skip; |
| 3598 | } |
| 3599 | |
John Zulauf | fca05c1 | 2018-04-26 16:30:39 -0600 | [diff] [blame] | 3600 | void PreCallRecordDestroyImageView(layer_data *device_data, VkImageView image_view, IMAGE_VIEW_STATE *image_view_state, |
| 3601 | VK_OBJECT obj_struct) { |
Mark Lobodzinski | 306441e | 2017-02-10 13:48:38 -0700 | [diff] [blame] | 3602 | // Any bound cmd buffers are now invalid |
| 3603 | invalidateCommandBuffers(device_data, image_view_state->cb_bindings, obj_struct); |
| 3604 | (*GetImageViewMap(device_data)).erase(image_view); |
| 3605 | } |
| 3606 | |
| 3607 | bool PreCallValidateDestroyBuffer(layer_data *device_data, VkBuffer buffer, BUFFER_STATE **buffer_state, VK_OBJECT *obj_struct) { |
| 3608 | *buffer_state = GetBufferState(device_data, buffer); |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 3609 | *obj_struct = {HandleToUint64(buffer), kVulkanObjectTypeBuffer}; |
Mark Lobodzinski | 306441e | 2017-02-10 13:48:38 -0700 | [diff] [blame] | 3610 | if (GetDisables(device_data)->destroy_buffer) return false; |
| 3611 | bool skip = false; |
| 3612 | if (*buffer_state) { |
| 3613 | skip |= validateIdleBuffer(device_data, buffer); |
| 3614 | } |
| 3615 | return skip; |
| 3616 | } |
| 3617 | |
John Zulauf | fca05c1 | 2018-04-26 16:30:39 -0600 | [diff] [blame] | 3618 | void PreCallRecordDestroyBuffer(layer_data *device_data, VkBuffer buffer, BUFFER_STATE *buffer_state, VK_OBJECT obj_struct) { |
Mark Lobodzinski | 306441e | 2017-02-10 13:48:38 -0700 | [diff] [blame] | 3619 | invalidateCommandBuffers(device_data, buffer_state->cb_bindings, obj_struct); |
| 3620 | for (auto mem_binding : buffer_state->GetBoundMemory()) { |
| 3621 | auto mem_info = GetMemObjInfo(device_data, mem_binding); |
| 3622 | if (mem_info) { |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 3623 | core_validation::RemoveBufferMemoryRange(HandleToUint64(buffer), mem_info); |
Mark Lobodzinski | 306441e | 2017-02-10 13:48:38 -0700 | [diff] [blame] | 3624 | } |
| 3625 | } |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 3626 | ClearMemoryObjectBindings(device_data, HandleToUint64(buffer), kVulkanObjectTypeBuffer); |
Mark Lobodzinski | 306441e | 2017-02-10 13:48:38 -0700 | [diff] [blame] | 3627 | GetBufferMap(device_data)->erase(buffer_state->buffer); |
| 3628 | } |
| 3629 | |
| 3630 | bool PreCallValidateDestroyBufferView(layer_data *device_data, VkBufferView buffer_view, BUFFER_VIEW_STATE **buffer_view_state, |
| 3631 | VK_OBJECT *obj_struct) { |
| 3632 | *buffer_view_state = GetBufferViewState(device_data, buffer_view); |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 3633 | *obj_struct = {HandleToUint64(buffer_view), kVulkanObjectTypeBufferView}; |
Mark Lobodzinski | 306441e | 2017-02-10 13:48:38 -0700 | [diff] [blame] | 3634 | if (GetDisables(device_data)->destroy_buffer_view) return false; |
| 3635 | bool skip = false; |
| 3636 | if (*buffer_view_state) { |
Mike Schuchardt | a502565 | 2017-09-27 14:56:21 -0600 | [diff] [blame] | 3637 | skip |= |
| 3638 | ValidateObjectNotInUse(device_data, *buffer_view_state, *obj_struct, "vkDestroyBufferView", VALIDATION_ERROR_23e00750); |
Mark Lobodzinski | 306441e | 2017-02-10 13:48:38 -0700 | [diff] [blame] | 3639 | } |
| 3640 | return skip; |
| 3641 | } |
| 3642 | |
John Zulauf | fca05c1 | 2018-04-26 16:30:39 -0600 | [diff] [blame] | 3643 | void PreCallRecordDestroyBufferView(layer_data *device_data, VkBufferView buffer_view, BUFFER_VIEW_STATE *buffer_view_state, |
| 3644 | VK_OBJECT obj_struct) { |
Mark Lobodzinski | 306441e | 2017-02-10 13:48:38 -0700 | [diff] [blame] | 3645 | // Any bound cmd buffers are now invalid |
| 3646 | invalidateCommandBuffers(device_data, buffer_view_state->cb_bindings, obj_struct); |
| 3647 | GetBufferViewMap(device_data)->erase(buffer_view); |
| 3648 | } |
Mark Lobodzinski | df0acbf | 2017-02-10 14:01:27 -0700 | [diff] [blame] | 3649 | |
| 3650 | bool PreCallValidateCmdFillBuffer(layer_data *device_data, GLOBAL_CB_NODE *cb_node, BUFFER_STATE *buffer_state) { |
| 3651 | bool skip = false; |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 3652 | skip |= ValidateMemoryIsBoundToBuffer(device_data, buffer_state, "vkCmdFillBuffer()", VALIDATION_ERROR_1b40003e); |
Mike Schuchardt | 9c58240 | 2017-02-23 15:57:37 -0700 | [diff] [blame] | 3653 | skip |= ValidateCmdQueueFlags(device_data, cb_node, "vkCmdFillBuffer()", |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 3654 | VK_QUEUE_TRANSFER_BIT | VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT, VALIDATION_ERROR_1b402415); |
Mark Lobodzinski | df0acbf | 2017-02-10 14:01:27 -0700 | [diff] [blame] | 3655 | skip |= ValidateCmd(device_data, cb_node, CMD_FILLBUFFER, "vkCmdFillBuffer()"); |
| 3656 | // Validate that DST buffer has correct usage flags set |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 3657 | skip |= ValidateBufferUsageFlags(device_data, buffer_state, VK_BUFFER_USAGE_TRANSFER_DST_BIT, true, VALIDATION_ERROR_1b40003a, |
Mark Lobodzinski | df0acbf | 2017-02-10 14:01:27 -0700 | [diff] [blame] | 3658 | "vkCmdFillBuffer()", "VK_BUFFER_USAGE_TRANSFER_DST_BIT"); |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 3659 | skip |= insideRenderPass(device_data, cb_node, "vkCmdFillBuffer()", VALIDATION_ERROR_1b400017); |
Mark Lobodzinski | df0acbf | 2017-02-10 14:01:27 -0700 | [diff] [blame] | 3660 | return skip; |
| 3661 | } |
| 3662 | |
| 3663 | void PreCallRecordCmdFillBuffer(layer_data *device_data, GLOBAL_CB_NODE *cb_node, BUFFER_STATE *buffer_state) { |
Mark Lobodzinski | df0acbf | 2017-02-10 14:01:27 -0700 | [diff] [blame] | 3664 | // Update bindings between buffer and cmd buffer |
| 3665 | AddCommandBufferBindingBuffer(device_data, cb_node, buffer_state); |
Mark Lobodzinski | df0acbf | 2017-02-10 14:01:27 -0700 | [diff] [blame] | 3666 | } |
Mark Lobodzinski | ab9ea3e | 2017-02-15 12:59:00 -0700 | [diff] [blame] | 3667 | |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 3668 | bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t regionCount, const VkBufferImageCopy *pRegions, |
| 3669 | IMAGE_STATE *image_state, const char *function) { |
Mark Lobodzinski | ab9ea3e | 2017-02-15 12:59:00 -0700 | [diff] [blame] | 3670 | bool skip = false; |
| 3671 | |
| 3672 | for (uint32_t i = 0; i < regionCount; i++) { |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3673 | if (image_state->createInfo.imageType == VK_IMAGE_TYPE_1D) { |
| 3674 | if ((pRegions[i].imageOffset.y != 0) || (pRegions[i].imageExtent.height != 1)) { |
Mark Lobodzinski | ab9ea3e | 2017-02-15 12:59:00 -0700 | [diff] [blame] | 3675 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3676 | HandleToUint64(image_state->image), VALIDATION_ERROR_0160018e, |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 3677 | "%s(): pRegion[%d] imageOffset.y is %d and imageExtent.height is %d. For 1D images these must be 0 " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3678 | "and 1, respectively.", |
| 3679 | function, i, pRegions[i].imageOffset.y, pRegions[i].imageExtent.height); |
Mark Lobodzinski | ab9ea3e | 2017-02-15 12:59:00 -0700 | [diff] [blame] | 3680 | } |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3681 | } |
Mark Lobodzinski | ab9ea3e | 2017-02-15 12:59:00 -0700 | [diff] [blame] | 3682 | |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3683 | if ((image_state->createInfo.imageType == VK_IMAGE_TYPE_1D) || (image_state->createInfo.imageType == VK_IMAGE_TYPE_2D)) { |
| 3684 | if ((pRegions[i].imageOffset.z != 0) || (pRegions[i].imageExtent.depth != 1)) { |
Mark Lobodzinski | ab9ea3e | 2017-02-15 12:59:00 -0700 | [diff] [blame] | 3685 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3686 | HandleToUint64(image_state->image), VALIDATION_ERROR_01600192, |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3687 | "%s(): pRegion[%d] imageOffset.z is %d and imageExtent.depth is %d. For 1D and 2D images these " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3688 | "must be 0 and 1, respectively.", |
| 3689 | function, i, pRegions[i].imageOffset.z, pRegions[i].imageExtent.depth); |
Mark Lobodzinski | ab9ea3e | 2017-02-15 12:59:00 -0700 | [diff] [blame] | 3690 | } |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3691 | } |
Mark Lobodzinski | ab9ea3e | 2017-02-15 12:59:00 -0700 | [diff] [blame] | 3692 | |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3693 | if (image_state->createInfo.imageType == VK_IMAGE_TYPE_3D) { |
| 3694 | if ((0 != pRegions[i].imageSubresource.baseArrayLayer) || (1 != pRegions[i].imageSubresource.layerCount)) { |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 3695 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3696 | HandleToUint64(image_state->image), VALIDATION_ERROR_016001aa, |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 3697 | "%s(): pRegion[%d] imageSubresource.baseArrayLayer is %d and imageSubresource.layerCount is %d. " |
| 3698 | "For 3D images these must be 0 and 1, respectively.", |
| 3699 | function, i, pRegions[i].imageSubresource.baseArrayLayer, pRegions[i].imageSubresource.layerCount); |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3700 | } |
| 3701 | } |
| 3702 | |
| 3703 | // If the the calling command's VkImage parameter's format is not a depth/stencil format, |
| 3704 | // then bufferOffset must be a multiple of the calling command's VkImage parameter's texel size |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 3705 | auto texel_size = FormatSize(image_state->createInfo.format); |
Dave Houlton | 1150cf5 | 2017-04-27 14:38:11 -0600 | [diff] [blame] | 3706 | if (!FormatIsDepthAndStencil(image_state->createInfo.format) && SafeModulo(pRegions[i].bufferOffset, texel_size) != 0) { |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3707 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3708 | HandleToUint64(image_state->image), VALIDATION_ERROR_01600182, |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3709 | "%s(): pRegion[%d] bufferOffset 0x%" PRIxLEAST64 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3710 | " must be a multiple of this format's texel size (" PRINTF_SIZE_T_SPECIFIER ").", |
| 3711 | function, i, pRegions[i].bufferOffset, texel_size); |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3712 | } |
| 3713 | |
| 3714 | // BufferOffset must be a multiple of 4 |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 3715 | if (SafeModulo(pRegions[i].bufferOffset, 4) != 0) { |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3716 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3717 | HandleToUint64(image_state->image), VALIDATION_ERROR_01600184, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3718 | "%s(): pRegion[%d] bufferOffset 0x%" PRIxLEAST64 " must be a multiple of 4.", function, i, |
| 3719 | pRegions[i].bufferOffset); |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3720 | } |
| 3721 | |
| 3722 | // BufferRowLength must be 0, or greater than or equal to the width member of imageExtent |
| 3723 | if ((pRegions[i].bufferRowLength != 0) && (pRegions[i].bufferRowLength < pRegions[i].imageExtent.width)) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3724 | skip |= |
| 3725 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3726 | HandleToUint64(image_state->image), VALIDATION_ERROR_01600186, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3727 | "%s(): pRegion[%d] bufferRowLength (%d) must be zero or greater-than-or-equal-to imageExtent.width (%d).", |
| 3728 | function, i, pRegions[i].bufferRowLength, pRegions[i].imageExtent.width); |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3729 | } |
| 3730 | |
| 3731 | // BufferImageHeight must be 0, or greater than or equal to the height member of imageExtent |
| 3732 | if ((pRegions[i].bufferImageHeight != 0) && (pRegions[i].bufferImageHeight < pRegions[i].imageExtent.height)) { |
| 3733 | skip |= log_msg( |
| 3734 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3735 | HandleToUint64(image_state->image), VALIDATION_ERROR_01600188, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3736 | "%s(): pRegion[%d] bufferImageHeight (%d) must be zero or greater-than-or-equal-to imageExtent.height (%d).", |
| 3737 | function, i, pRegions[i].bufferImageHeight, pRegions[i].imageExtent.height); |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3738 | } |
| 3739 | |
| 3740 | // subresource aspectMask must have exactly 1 bit set |
| 3741 | const int num_bits = sizeof(VkFlags) * CHAR_BIT; |
| 3742 | std::bitset<num_bits> aspect_mask_bits(pRegions[i].imageSubresource.aspectMask); |
| 3743 | if (aspect_mask_bits.count() != 1) { |
| 3744 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3745 | HandleToUint64(image_state->image), VALIDATION_ERROR_016001a8, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3746 | "%s: aspectMasks for imageSubresource in each region must have only a single bit set.", function); |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3747 | } |
| 3748 | |
| 3749 | // image subresource aspect bit must match format |
Dave Houlton | 4eaaf3a | 2017-03-14 11:31:20 -0600 | [diff] [blame] | 3750 | if (!VerifyAspectsPresent(pRegions[i].imageSubresource.aspectMask, image_state->createInfo.format)) { |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3751 | skip |= log_msg( |
| 3752 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3753 | HandleToUint64(image_state->image), VALIDATION_ERROR_016001a6, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3754 | "%s(): pRegion[%d] subresource aspectMask 0x%x specifies aspects that are not present in image format 0x%x.", |
| 3755 | function, i, pRegions[i].imageSubresource.aspectMask, image_state->createInfo.format); |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3756 | } |
| 3757 | |
| 3758 | // Checks that apply only to compressed images |
Cort Stratton | 420ebd4 | 2018-05-04 01:12:23 -0400 | [diff] [blame] | 3759 | if (FormatIsCompressed(image_state->createInfo.format) || FormatIsSinglePlane_422(image_state->createInfo.format)) { |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 3760 | auto block_size = FormatCompressedTexelBlockExtent(image_state->createInfo.format); |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3761 | |
| 3762 | // BufferRowLength must be a multiple of block width |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 3763 | if (SafeModulo(pRegions[i].bufferRowLength, block_size.width) != 0) { |
Mark Lobodzinski | ab9ea3e | 2017-02-15 12:59:00 -0700 | [diff] [blame] | 3764 | skip |= log_msg( |
| 3765 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3766 | HandleToUint64(image_state->image), VALIDATION_ERROR_01600196, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3767 | "%s(): pRegion[%d] bufferRowLength (%d) must be a multiple of the compressed image's texel width (%d)..", |
| 3768 | function, i, pRegions[i].bufferRowLength, block_size.width); |
Mark Lobodzinski | ab9ea3e | 2017-02-15 12:59:00 -0700 | [diff] [blame] | 3769 | } |
| 3770 | |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3771 | // BufferRowHeight must be a multiple of block height |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 3772 | if (SafeModulo(pRegions[i].bufferImageHeight, block_size.height) != 0) { |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 3773 | skip |= log_msg( |
| 3774 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3775 | HandleToUint64(image_state->image), VALIDATION_ERROR_01600198, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3776 | "%s(): pRegion[%d] bufferImageHeight (%d) must be a multiple of the compressed image's texel height (%d)..", |
| 3777 | function, i, pRegions[i].bufferImageHeight, block_size.height); |
Mark Lobodzinski | ab9ea3e | 2017-02-15 12:59:00 -0700 | [diff] [blame] | 3778 | } |
| 3779 | |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3780 | // image offsets must be multiples of block dimensions |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 3781 | if ((SafeModulo(pRegions[i].imageOffset.x, block_size.width) != 0) || |
| 3782 | (SafeModulo(pRegions[i].imageOffset.y, block_size.height) != 0) || |
| 3783 | (SafeModulo(pRegions[i].imageOffset.z, block_size.depth) != 0)) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3784 | skip |= |
| 3785 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3786 | HandleToUint64(image_state->image), VALIDATION_ERROR_0160019a, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3787 | "%s(): pRegion[%d] imageOffset(x,y) (%d, %d) must be multiples of the compressed image's texel " |
| 3788 | "width & height (%d, %d)..", |
| 3789 | function, i, pRegions[i].imageOffset.x, pRegions[i].imageOffset.y, block_size.width, block_size.height); |
Mark Lobodzinski | ab9ea3e | 2017-02-15 12:59:00 -0700 | [diff] [blame] | 3790 | } |
| 3791 | |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3792 | // bufferOffset must be a multiple of block size (linear bytes) |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 3793 | size_t block_size_in_bytes = FormatSize(image_state->createInfo.format); |
| 3794 | if (SafeModulo(pRegions[i].bufferOffset, block_size_in_bytes) != 0) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3795 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3796 | HandleToUint64(image_state->image), VALIDATION_ERROR_0160019c, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3797 | "%s(): pRegion[%d] bufferOffset (0x%" PRIxLEAST64 |
| 3798 | ") must be a multiple of the compressed image's texel block size (" PRINTF_SIZE_T_SPECIFIER ")..", |
| 3799 | function, i, pRegions[i].bufferOffset, block_size_in_bytes); |
Mark Lobodzinski | ab9ea3e | 2017-02-15 12:59:00 -0700 | [diff] [blame] | 3800 | } |
Dave Houlton | 67e9b53 | 2017-03-02 17:00:10 -0700 | [diff] [blame] | 3801 | |
| 3802 | // imageExtent width must be a multiple of block width, or extent+offset width must equal subresource width |
Dave Houlton | 75967fc | 2017-03-06 17:21:16 -0700 | [diff] [blame] | 3803 | VkExtent3D mip_extent = GetImageSubresourceExtent(image_state, &(pRegions[i].imageSubresource)); |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 3804 | if ((SafeModulo(pRegions[i].imageExtent.width, block_size.width) != 0) && |
Dave Houlton | 75967fc | 2017-03-06 17:21:16 -0700 | [diff] [blame] | 3805 | (pRegions[i].imageExtent.width + pRegions[i].imageOffset.x != mip_extent.width)) { |
| 3806 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3807 | HandleToUint64(image_state->image), VALIDATION_ERROR_0160019e, |
Dave Houlton | 75967fc | 2017-03-06 17:21:16 -0700 | [diff] [blame] | 3808 | "%s(): pRegion[%d] extent width (%d) must be a multiple of the compressed texture block width " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3809 | "(%d), or when added to offset.x (%d) must equal the image subresource width (%d)..", |
Dave Houlton | 75967fc | 2017-03-06 17:21:16 -0700 | [diff] [blame] | 3810 | function, i, pRegions[i].imageExtent.width, block_size.width, pRegions[i].imageOffset.x, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3811 | mip_extent.width); |
Dave Houlton | 67e9b53 | 2017-03-02 17:00:10 -0700 | [diff] [blame] | 3812 | } |
| 3813 | |
| 3814 | // imageExtent height must be a multiple of block height, or extent+offset height must equal subresource height |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 3815 | if ((SafeModulo(pRegions[i].imageExtent.height, block_size.height) != 0) && |
Dave Houlton | 75967fc | 2017-03-06 17:21:16 -0700 | [diff] [blame] | 3816 | (pRegions[i].imageExtent.height + pRegions[i].imageOffset.y != mip_extent.height)) { |
| 3817 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3818 | HandleToUint64(image_state->image), VALIDATION_ERROR_016001a0, |
Dave Houlton | 75967fc | 2017-03-06 17:21:16 -0700 | [diff] [blame] | 3819 | "%s(): pRegion[%d] extent height (%d) must be a multiple of the compressed texture block height " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3820 | "(%d), or when added to offset.y (%d) must equal the image subresource height (%d)..", |
Dave Houlton | 75967fc | 2017-03-06 17:21:16 -0700 | [diff] [blame] | 3821 | function, i, pRegions[i].imageExtent.height, block_size.height, pRegions[i].imageOffset.y, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3822 | mip_extent.height); |
Dave Houlton | 67e9b53 | 2017-03-02 17:00:10 -0700 | [diff] [blame] | 3823 | } |
| 3824 | |
| 3825 | // imageExtent depth must be a multiple of block depth, or extent+offset depth must equal subresource depth |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 3826 | if ((SafeModulo(pRegions[i].imageExtent.depth, block_size.depth) != 0) && |
Dave Houlton | 75967fc | 2017-03-06 17:21:16 -0700 | [diff] [blame] | 3827 | (pRegions[i].imageExtent.depth + pRegions[i].imageOffset.z != mip_extent.depth)) { |
| 3828 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3829 | HandleToUint64(image_state->image), VALIDATION_ERROR_016001a2, |
Dave Houlton | 75967fc | 2017-03-06 17:21:16 -0700 | [diff] [blame] | 3830 | "%s(): pRegion[%d] extent width (%d) must be a multiple of the compressed texture block depth " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3831 | "(%d), or when added to offset.z (%d) must equal the image subresource depth (%d)..", |
Dave Houlton | 75967fc | 2017-03-06 17:21:16 -0700 | [diff] [blame] | 3832 | function, i, pRegions[i].imageExtent.depth, block_size.depth, pRegions[i].imageOffset.z, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3833 | mip_extent.depth); |
Dave Houlton | 67e9b53 | 2017-03-02 17:00:10 -0700 | [diff] [blame] | 3834 | } |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3835 | } |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 3836 | } |
| 3837 | |
| 3838 | return skip; |
| 3839 | } |
| 3840 | |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3841 | static bool ValidateImageBounds(const debug_report_data *report_data, const IMAGE_STATE *image_state, const uint32_t regionCount, |
| 3842 | const VkBufferImageCopy *pRegions, const char *func_name, UNIQUE_VALIDATION_ERROR_CODE msg_code) { |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 3843 | bool skip = false; |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3844 | const VkImageCreateInfo *image_info = &(image_state->createInfo); |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 3845 | |
| 3846 | for (uint32_t i = 0; i < regionCount; i++) { |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 3847 | VkExtent3D extent = pRegions[i].imageExtent; |
| 3848 | VkOffset3D offset = pRegions[i].imageOffset; |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 3849 | |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3850 | if (IsExtentSizeZero(&extent)) // Warn on zero area subresource |
| 3851 | { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3852 | skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 3853 | (uint64_t)0, IMAGE_ZERO_AREA_SUBREGION, "%s: pRegion[%d] imageExtent of {%1d, %1d, %1d} has zero area", |
| 3854 | func_name, i, extent.width, extent.height, extent.depth); |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3855 | } |
| 3856 | |
| 3857 | VkExtent3D image_extent = GetImageSubresourceExtent(image_state, &(pRegions[i].imageSubresource)); |
| 3858 | |
| 3859 | // If we're using a compressed format, valid extent is rounded up to multiple of block size (per 18.1) |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 3860 | if (FormatIsCompressed(image_info->format)) { |
| 3861 | auto block_extent = FormatCompressedTexelBlockExtent(image_info->format); |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3862 | if (image_extent.width % block_extent.width) { |
| 3863 | image_extent.width += (block_extent.width - (image_extent.width % block_extent.width)); |
| 3864 | } |
| 3865 | if (image_extent.height % block_extent.height) { |
| 3866 | image_extent.height += (block_extent.height - (image_extent.height % block_extent.height)); |
| 3867 | } |
| 3868 | if (image_extent.depth % block_extent.depth) { |
| 3869 | image_extent.depth += (block_extent.depth - (image_extent.depth % block_extent.depth)); |
| 3870 | } |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 3871 | } |
| 3872 | |
Dave Houlton | fc1a405 | 2017-04-27 14:32:45 -0600 | [diff] [blame] | 3873 | if (0 != ExceedsBounds(&offset, &extent, &image_extent)) { |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 3874 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, (uint64_t)0, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3875 | msg_code, "%s: pRegion[%d] exceeds image bounds..", func_name, i); |
Mark Lobodzinski | ab9ea3e | 2017-02-15 12:59:00 -0700 | [diff] [blame] | 3876 | } |
| 3877 | } |
| 3878 | |
| 3879 | return skip; |
| 3880 | } |
| 3881 | |
Chris Forbes | e8ba09a | 2017-06-01 17:39:02 -0700 | [diff] [blame] | 3882 | static inline bool ValidateBufferBounds(const debug_report_data *report_data, IMAGE_STATE *image_state, BUFFER_STATE *buff_state, |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 3883 | uint32_t regionCount, const VkBufferImageCopy *pRegions, const char *func_name, |
| 3884 | UNIQUE_VALIDATION_ERROR_CODE msg_code) { |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 3885 | bool skip = false; |
| 3886 | |
| 3887 | VkDeviceSize buffer_size = buff_state->createInfo.size; |
| 3888 | |
| 3889 | for (uint32_t i = 0; i < regionCount; i++) { |
| 3890 | VkExtent3D copy_extent = pRegions[i].imageExtent; |
| 3891 | |
| 3892 | VkDeviceSize buffer_width = (0 == pRegions[i].bufferRowLength ? copy_extent.width : pRegions[i].bufferRowLength); |
| 3893 | VkDeviceSize buffer_height = (0 == pRegions[i].bufferImageHeight ? copy_extent.height : pRegions[i].bufferImageHeight); |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 3894 | VkDeviceSize unit_size = FormatSize(image_state->createInfo.format); // size (bytes) of texel or block |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 3895 | |
Dave Houlton | f3229d5 | 2017-02-21 15:59:08 -0700 | [diff] [blame] | 3896 | // Handle special buffer packing rules for specific depth/stencil formats |
| 3897 | if (pRegions[i].imageSubresource.aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) { |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 3898 | unit_size = FormatSize(VK_FORMAT_S8_UINT); |
Dave Houlton | f3229d5 | 2017-02-21 15:59:08 -0700 | [diff] [blame] | 3899 | } else if (pRegions[i].imageSubresource.aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) { |
| 3900 | switch (image_state->createInfo.format) { |
| 3901 | case VK_FORMAT_D16_UNORM_S8_UINT: |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 3902 | unit_size = FormatSize(VK_FORMAT_D16_UNORM); |
Dave Houlton | f3229d5 | 2017-02-21 15:59:08 -0700 | [diff] [blame] | 3903 | break; |
| 3904 | case VK_FORMAT_D32_SFLOAT_S8_UINT: |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 3905 | unit_size = FormatSize(VK_FORMAT_D32_SFLOAT); |
Dave Houlton | f3229d5 | 2017-02-21 15:59:08 -0700 | [diff] [blame] | 3906 | break; |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3907 | case VK_FORMAT_X8_D24_UNORM_PACK32: // Fall through |
Dave Houlton | f3229d5 | 2017-02-21 15:59:08 -0700 | [diff] [blame] | 3908 | case VK_FORMAT_D24_UNORM_S8_UINT: |
| 3909 | unit_size = 4; |
| 3910 | break; |
| 3911 | default: |
| 3912 | break; |
| 3913 | } |
| 3914 | } |
| 3915 | |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 3916 | if (FormatIsCompressed(image_state->createInfo.format)) { |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3917 | // Switch to texel block units, rounding up for any partially-used blocks |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 3918 | auto block_dim = FormatCompressedTexelBlockExtent(image_state->createInfo.format); |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3919 | buffer_width = (buffer_width + block_dim.width - 1) / block_dim.width; |
| 3920 | buffer_height = (buffer_height + block_dim.height - 1) / block_dim.height; |
| 3921 | |
| 3922 | copy_extent.width = (copy_extent.width + block_dim.width - 1) / block_dim.width; |
| 3923 | copy_extent.height = (copy_extent.height + block_dim.height - 1) / block_dim.height; |
| 3924 | copy_extent.depth = (copy_extent.depth + block_dim.depth - 1) / block_dim.depth; |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 3925 | } |
| 3926 | |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3927 | // Either depth or layerCount may be greater than 1 (not both). This is the number of 'slices' to copy |
| 3928 | uint32_t z_copies = std::max(copy_extent.depth, pRegions[i].imageSubresource.layerCount); |
| 3929 | if (IsExtentSizeZero(©_extent) || (0 == z_copies)) { |
Chris Forbes | e8ba09a | 2017-06-01 17:39:02 -0700 | [diff] [blame] | 3930 | // TODO: Issue warning here? Already warned in ValidateImageBounds()... |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3931 | } else { |
| 3932 | // Calculate buffer offset of final copied byte, + 1. |
| 3933 | VkDeviceSize max_buffer_offset = (z_copies - 1) * buffer_height * buffer_width; // offset to slice |
| 3934 | max_buffer_offset += ((copy_extent.height - 1) * buffer_width) + copy_extent.width; // add row,col |
| 3935 | max_buffer_offset *= unit_size; // convert to bytes |
| 3936 | max_buffer_offset += pRegions[i].bufferOffset; // add initial offset (bytes) |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 3937 | |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3938 | if (buffer_size < max_buffer_offset) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3939 | skip |= |
| 3940 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, (uint64_t)0, |
| 3941 | msg_code, "%s: pRegion[%d] exceeds buffer size of %" PRIu64 " bytes..", func_name, i, buffer_size); |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 3942 | } |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 3943 | } |
| 3944 | } |
| 3945 | |
Mark Lobodzinski | ab9ea3e | 2017-02-15 12:59:00 -0700 | [diff] [blame] | 3946 | return skip; |
| 3947 | } |
| 3948 | |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 3949 | bool PreCallValidateCmdCopyImageToBuffer(layer_data *device_data, VkImageLayout srcImageLayout, GLOBAL_CB_NODE *cb_node, |
Mark Lobodzinski | 1fe9b00 | 2017-02-15 14:11:12 -0700 | [diff] [blame] | 3950 | IMAGE_STATE *src_image_state, BUFFER_STATE *dst_buffer_state, uint32_t regionCount, |
Mark Lobodzinski | ab9ea3e | 2017-02-15 12:59:00 -0700 | [diff] [blame] | 3951 | const VkBufferImageCopy *pRegions, const char *func_name) { |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 3952 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
| 3953 | bool skip = ValidateBufferImageCopyData(report_data, regionCount, pRegions, src_image_state, "vkCmdCopyImageToBuffer"); |
| 3954 | |
| 3955 | // Validate command buffer state |
John Zulauf | 5c2750c | 2018-01-30 15:04:56 -0700 | [diff] [blame] | 3956 | skip |= ValidateCmd(device_data, cb_node, CMD_COPYIMAGETOBUFFER, "vkCmdCopyImageToBuffer()"); |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 3957 | |
| 3958 | // Command pool must support graphics, compute, or transfer operations |
| 3959 | auto pPool = GetCommandPoolNode(device_data, cb_node->createInfo.commandPool); |
| 3960 | |
| 3961 | VkQueueFlags queue_flags = GetPhysDevProperties(device_data)->queue_family_properties[pPool->queueFamilyIndex].queueFlags; |
| 3962 | if (0 == (queue_flags & (VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_TRANSFER_BIT))) { |
| 3963 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3964 | HandleToUint64(cb_node->createInfo.commandPool), VALIDATION_ERROR_19202415, |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 3965 | "Cannot call vkCmdCopyImageToBuffer() on a command buffer allocated from a pool without graphics, compute, " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3966 | "or transfer capabilities.."); |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 3967 | } |
Dave Houlton | 0ef2749 | 2018-04-04 11:41:48 -0600 | [diff] [blame] | 3968 | skip |= ValidateImageBounds(report_data, src_image_state, regionCount, pRegions, "vkCmdCopyImageToBuffer()", |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 3969 | VALIDATION_ERROR_1920016c); |
Chris Forbes | e8ba09a | 2017-06-01 17:39:02 -0700 | [diff] [blame] | 3970 | skip |= ValidateBufferBounds(report_data, src_image_state, dst_buffer_state, regionCount, pRegions, "vkCmdCopyImageToBuffer()", |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 3971 | VALIDATION_ERROR_1920016e); |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 3972 | |
| 3973 | skip |= ValidateImageSampleCount(device_data, src_image_state, VK_SAMPLE_COUNT_1_BIT, "vkCmdCopyImageToBuffer(): srcImage", |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 3974 | VALIDATION_ERROR_19200178); |
| 3975 | skip |= ValidateMemoryIsBoundToImage(device_data, src_image_state, "vkCmdCopyImageToBuffer()", VALIDATION_ERROR_19200176); |
| 3976 | skip |= ValidateMemoryIsBoundToBuffer(device_data, dst_buffer_state, "vkCmdCopyImageToBuffer()", VALIDATION_ERROR_19200180); |
Mark Lobodzinski | 033c90b | 2017-02-15 13:58:23 -0700 | [diff] [blame] | 3977 | |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 3978 | // Validate that SRC image & DST buffer have correct usage flags set |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 3979 | skip |= ValidateImageUsageFlags(device_data, src_image_state, VK_IMAGE_USAGE_TRANSFER_SRC_BIT, true, VALIDATION_ERROR_19200174, |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 3980 | "vkCmdCopyImageToBuffer()", "VK_IMAGE_USAGE_TRANSFER_SRC_BIT"); |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 3981 | skip |= ValidateBufferUsageFlags(device_data, dst_buffer_state, VK_BUFFER_USAGE_TRANSFER_DST_BIT, true, |
| 3982 | VALIDATION_ERROR_1920017e, "vkCmdCopyImageToBuffer()", "VK_BUFFER_USAGE_TRANSFER_DST_BIT"); |
| 3983 | skip |= insideRenderPass(device_data, cb_node, "vkCmdCopyImageToBuffer()", VALIDATION_ERROR_19200017); |
Tobin Ehlis | c826645 | 2017-04-07 12:20:30 -0600 | [diff] [blame] | 3984 | bool hit_error = false; |
Mark Lobodzinski | 033c90b | 2017-02-15 13:58:23 -0700 | [diff] [blame] | 3985 | for (uint32_t i = 0; i < regionCount; ++i) { |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 3986 | skip |= VerifyImageLayout(device_data, cb_node, src_image_state, pRegions[i].imageSubresource, srcImageLayout, |
| 3987 | VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, "vkCmdCopyImageToBuffer()", VALIDATION_ERROR_1920017c, |
| 3988 | &hit_error); |
Mark Lobodzinski | 033c90b | 2017-02-15 13:58:23 -0700 | [diff] [blame] | 3989 | skip |= ValidateCopyBufferImageTransferGranularityRequirements(device_data, cb_node, src_image_state, &pRegions[i], i, |
Cort Stratton | 420ebd4 | 2018-05-04 01:12:23 -0400 | [diff] [blame] | 3990 | "vkCmdCopyImageToBuffer()", VALIDATION_ERROR_19200e04); |
Mark Lobodzinski | 033c90b | 2017-02-15 13:58:23 -0700 | [diff] [blame] | 3991 | } |
| 3992 | return skip; |
| 3993 | } |
| 3994 | |
| 3995 | void PreCallRecordCmdCopyImageToBuffer(layer_data *device_data, GLOBAL_CB_NODE *cb_node, IMAGE_STATE *src_image_state, |
Tobin Ehlis | e35b66a | 2017-03-15 12:18:31 -0600 | [diff] [blame] | 3996 | BUFFER_STATE *dst_buffer_state, uint32_t region_count, const VkBufferImageCopy *regions, |
| 3997 | VkImageLayout src_image_layout) { |
| 3998 | // Make sure that all image slices are updated to correct layout |
| 3999 | for (uint32_t i = 0; i < region_count; ++i) { |
| 4000 | SetImageLayout(device_data, cb_node, src_image_state, regions[i].imageSubresource, src_image_layout); |
| 4001 | } |
Mark Lobodzinski | 033c90b | 2017-02-15 13:58:23 -0700 | [diff] [blame] | 4002 | // Update bindings between buffer/image and cmd buffer |
| 4003 | AddCommandBufferBindingImage(device_data, cb_node, src_image_state); |
Mark Lobodzinski | 1fe9b00 | 2017-02-15 14:11:12 -0700 | [diff] [blame] | 4004 | AddCommandBufferBindingBuffer(device_data, cb_node, dst_buffer_state); |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 4005 | } |
| 4006 | |
| 4007 | bool PreCallValidateCmdCopyBufferToImage(layer_data *device_data, VkImageLayout dstImageLayout, GLOBAL_CB_NODE *cb_node, |
Mark Lobodzinski | 1fe9b00 | 2017-02-15 14:11:12 -0700 | [diff] [blame] | 4008 | BUFFER_STATE *src_buffer_state, IMAGE_STATE *dst_image_state, uint32_t regionCount, |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 4009 | const VkBufferImageCopy *pRegions, const char *func_name) { |
| 4010 | const debug_report_data *report_data = core_validation::GetReportData(device_data); |
| 4011 | bool skip = ValidateBufferImageCopyData(report_data, regionCount, pRegions, dst_image_state, "vkCmdCopyBufferToImage"); |
| 4012 | |
| 4013 | // Validate command buffer state |
John Zulauf | 5c2750c | 2018-01-30 15:04:56 -0700 | [diff] [blame] | 4014 | skip |= ValidateCmd(device_data, cb_node, CMD_COPYBUFFERTOIMAGE, "vkCmdCopyBufferToImage()"); |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 4015 | |
| 4016 | // Command pool must support graphics, compute, or transfer operations |
| 4017 | auto pPool = GetCommandPoolNode(device_data, cb_node->createInfo.commandPool); |
| 4018 | VkQueueFlags queue_flags = GetPhysDevProperties(device_data)->queue_family_properties[pPool->queueFamilyIndex].queueFlags; |
| 4019 | if (0 == (queue_flags & (VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_TRANSFER_BIT))) { |
| 4020 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 4021 | HandleToUint64(cb_node->createInfo.commandPool), VALIDATION_ERROR_18e02415, |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 4022 | "Cannot call vkCmdCopyBufferToImage() on a command buffer allocated from a pool without graphics, compute, " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 4023 | "or transfer capabilities.."); |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 4024 | } |
Dave Houlton | 9dae7ec | 2017-03-01 16:23:25 -0700 | [diff] [blame] | 4025 | skip |= ValidateImageBounds(report_data, dst_image_state, regionCount, pRegions, "vkCmdCopyBufferToImage()", |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 4026 | VALIDATION_ERROR_18e00158); |
Chris Forbes | e8ba09a | 2017-06-01 17:39:02 -0700 | [diff] [blame] | 4027 | skip |= ValidateBufferBounds(report_data, dst_image_state, src_buffer_state, regionCount, pRegions, "vkCmdCopyBufferToImage()", |
Dave Houlton | 33c2d25 | 2017-06-09 17:08:32 -0600 | [diff] [blame] | 4028 | VALIDATION_ERROR_18e00156); |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 4029 | skip |= ValidateImageSampleCount(device_data, dst_image_state, VK_SAMPLE_COUNT_1_BIT, "vkCmdCopyBufferToImage(): dstImage", |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 4030 | VALIDATION_ERROR_18e00166); |
| 4031 | skip |= ValidateMemoryIsBoundToBuffer(device_data, src_buffer_state, "vkCmdCopyBufferToImage()", VALIDATION_ERROR_18e00160); |
| 4032 | skip |= ValidateMemoryIsBoundToImage(device_data, dst_image_state, "vkCmdCopyBufferToImage()", VALIDATION_ERROR_18e00164); |
| 4033 | skip |= ValidateBufferUsageFlags(device_data, src_buffer_state, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, true, |
| 4034 | VALIDATION_ERROR_18e0015c, "vkCmdCopyBufferToImage()", "VK_BUFFER_USAGE_TRANSFER_SRC_BIT"); |
| 4035 | skip |= ValidateImageUsageFlags(device_data, dst_image_state, VK_IMAGE_USAGE_TRANSFER_DST_BIT, true, VALIDATION_ERROR_18e00162, |
Mark Lobodzinski | d2b2f61 | 2017-02-15 13:45:18 -0700 | [diff] [blame] | 4036 | "vkCmdCopyBufferToImage()", "VK_IMAGE_USAGE_TRANSFER_DST_BIT"); |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 4037 | skip |= insideRenderPass(device_data, cb_node, "vkCmdCopyBufferToImage()", VALIDATION_ERROR_18e00017); |
Tobin Ehlis | c826645 | 2017-04-07 12:20:30 -0600 | [diff] [blame] | 4038 | bool hit_error = false; |
Mark Lobodzinski | 033c90b | 2017-02-15 13:58:23 -0700 | [diff] [blame] | 4039 | for (uint32_t i = 0; i < regionCount; ++i) { |
Tobin Ehlis | 3c37fb3 | 2017-05-24 09:31:13 -0600 | [diff] [blame] | 4040 | skip |= VerifyImageLayout(device_data, cb_node, dst_image_state, pRegions[i].imageSubresource, dstImageLayout, |
| 4041 | VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, "vkCmdCopyBufferToImage()", VALIDATION_ERROR_18e0016a, |
| 4042 | &hit_error); |
Mark Lobodzinski | 033c90b | 2017-02-15 13:58:23 -0700 | [diff] [blame] | 4043 | skip |= ValidateCopyBufferImageTransferGranularityRequirements(device_data, cb_node, dst_image_state, &pRegions[i], i, |
Cort Stratton | 420ebd4 | 2018-05-04 01:12:23 -0400 | [diff] [blame] | 4044 | "vkCmdCopyBufferToImage()", VALIDATION_ERROR_18e00e02); |
Mark Lobodzinski | 033c90b | 2017-02-15 13:58:23 -0700 | [diff] [blame] | 4045 | } |
| 4046 | return skip; |
| 4047 | } |
| 4048 | |
Mark Lobodzinski | 1fe9b00 | 2017-02-15 14:11:12 -0700 | [diff] [blame] | 4049 | void PreCallRecordCmdCopyBufferToImage(layer_data *device_data, GLOBAL_CB_NODE *cb_node, BUFFER_STATE *src_buffer_state, |
Tobin Ehlis | e35b66a | 2017-03-15 12:18:31 -0600 | [diff] [blame] | 4050 | IMAGE_STATE *dst_image_state, uint32_t region_count, const VkBufferImageCopy *regions, |
| 4051 | VkImageLayout dst_image_layout) { |
| 4052 | // Make sure that all image slices are updated to correct layout |
| 4053 | for (uint32_t i = 0; i < region_count; ++i) { |
| 4054 | SetImageLayout(device_data, cb_node, dst_image_state, regions[i].imageSubresource, dst_image_layout); |
| 4055 | } |
Mark Lobodzinski | 1fe9b00 | 2017-02-15 14:11:12 -0700 | [diff] [blame] | 4056 | AddCommandBufferBindingBuffer(device_data, cb_node, src_buffer_state); |
Mark Lobodzinski | 033c90b | 2017-02-15 13:58:23 -0700 | [diff] [blame] | 4057 | AddCommandBufferBindingImage(device_data, cb_node, dst_image_state); |
Mark Lobodzinski | ab9ea3e | 2017-02-15 12:59:00 -0700 | [diff] [blame] | 4058 | } |
Mike Weiblen | 672b58b | 2017-02-21 14:32:53 -0700 | [diff] [blame] | 4059 | |
| 4060 | bool PreCallValidateGetImageSubresourceLayout(layer_data *device_data, VkImage image, const VkImageSubresource *pSubresource) { |
| 4061 | const auto report_data = core_validation::GetReportData(device_data); |
| 4062 | bool skip = false; |
| 4063 | const VkImageAspectFlags sub_aspect = pSubresource->aspectMask; |
| 4064 | |
Dave Houlton | 1d960ff | 2018-01-19 12:17:05 -0700 | [diff] [blame] | 4065 | // The aspectMask member of pSubresource must only have a single bit set |
Mike Weiblen | 672b58b | 2017-02-21 14:32:53 -0700 | [diff] [blame] | 4066 | const int num_bits = sizeof(sub_aspect) * CHAR_BIT; |
| 4067 | std::bitset<num_bits> aspect_mask_bits(sub_aspect); |
| 4068 | if (aspect_mask_bits.count() != 1) { |
Petr Kraus | bc7f544 | 2017-05-14 23:43:38 +0200 | [diff] [blame] | 4069 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, HandleToUint64(image), |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 4070 | VALIDATION_ERROR_2a6007ca, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 4071 | "vkGetImageSubresourceLayout(): VkImageSubresource.aspectMask must have exactly 1 bit set."); |
Mike Weiblen | 672b58b | 2017-02-21 14:32:53 -0700 | [diff] [blame] | 4072 | } |
| 4073 | |
| 4074 | IMAGE_STATE *image_entry = GetImageState(device_data, image); |
| 4075 | if (!image_entry) { |
| 4076 | return skip; |
| 4077 | } |
| 4078 | |
Dave Houlton | 1d960ff | 2018-01-19 12:17:05 -0700 | [diff] [blame] | 4079 | // image must have been created with tiling equal to VK_IMAGE_TILING_LINEAR |
Mike Weiblen | 672b58b | 2017-02-21 14:32:53 -0700 | [diff] [blame] | 4080 | if (image_entry->createInfo.tiling != VK_IMAGE_TILING_LINEAR) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 4081 | skip |= |
| 4082 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, HandleToUint64(image), |
| 4083 | VALIDATION_ERROR_2a6007c8, "vkGetImageSubresourceLayout(): Image must have tiling of VK_IMAGE_TILING_LINEAR."); |
Mike Weiblen | 672b58b | 2017-02-21 14:32:53 -0700 | [diff] [blame] | 4084 | } |
| 4085 | |
Dave Houlton | 1d960ff | 2018-01-19 12:17:05 -0700 | [diff] [blame] | 4086 | // mipLevel must be less than the mipLevels specified in VkImageCreateInfo when the image was created |
Mike Weiblen | 672b58b | 2017-02-21 14:32:53 -0700 | [diff] [blame] | 4087 | if (pSubresource->mipLevel >= image_entry->createInfo.mipLevels) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 4088 | skip |= |
| 4089 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, HandleToUint64(image), |
| 4090 | VALIDATION_ERROR_2a600d68, "vkGetImageSubresourceLayout(): pSubresource.mipLevel (%d) must be less than %d.", |
| 4091 | pSubresource->mipLevel, image_entry->createInfo.mipLevels); |
Mike Weiblen | 672b58b | 2017-02-21 14:32:53 -0700 | [diff] [blame] | 4092 | } |
| 4093 | |
Dave Houlton | 1d960ff | 2018-01-19 12:17:05 -0700 | [diff] [blame] | 4094 | // arrayLayer must be less than the arrayLayers specified in VkImageCreateInfo when the image was created |
Mike Weiblen | 672b58b | 2017-02-21 14:32:53 -0700 | [diff] [blame] | 4095 | if (pSubresource->arrayLayer >= image_entry->createInfo.arrayLayers) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 4096 | skip |= |
| 4097 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, HandleToUint64(image), |
| 4098 | VALIDATION_ERROR_2a600d6a, "vkGetImageSubresourceLayout(): pSubresource.arrayLayer (%d) must be less than %d.", |
| 4099 | pSubresource->arrayLayer, image_entry->createInfo.arrayLayers); |
Mike Weiblen | 672b58b | 2017-02-21 14:32:53 -0700 | [diff] [blame] | 4100 | } |
| 4101 | |
Dave Houlton | 1d960ff | 2018-01-19 12:17:05 -0700 | [diff] [blame] | 4102 | // subresource's aspect must be compatible with image's format. |
Mike Weiblen | 672b58b | 2017-02-21 14:32:53 -0700 | [diff] [blame] | 4103 | const VkFormat img_format = image_entry->createInfo.format; |
Dave Houlton | 1d960ff | 2018-01-19 12:17:05 -0700 | [diff] [blame] | 4104 | if (FormatIsMultiplane(img_format)) { |
| 4105 | VkImageAspectFlags allowed_flags = (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR); |
| 4106 | UNIQUE_VALIDATION_ERROR_CODE vuid = VALIDATION_ERROR_2a600c5a; // 2-plane version |
| 4107 | if (FormatPlaneCount(img_format) > 2u) { |
| 4108 | allowed_flags |= VK_IMAGE_ASPECT_PLANE_2_BIT_KHR; |
| 4109 | vuid = VALIDATION_ERROR_2a600c5c; // 3-plane version |
| 4110 | } |
| 4111 | if (sub_aspect != (sub_aspect & allowed_flags)) { |
| 4112 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 4113 | HandleToUint64(image), vuid, |
Dave Houlton | 1d960ff | 2018-01-19 12:17:05 -0700 | [diff] [blame] | 4114 | "vkGetImageSubresourceLayout(): For multi-planar images, VkImageSubresource.aspectMask (0x%" PRIx32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 4115 | ") must be a single-plane specifier flag.", |
| 4116 | sub_aspect); |
Dave Houlton | 1d960ff | 2018-01-19 12:17:05 -0700 | [diff] [blame] | 4117 | } |
| 4118 | } else if (FormatIsColor(img_format)) { |
Mike Weiblen | 672b58b | 2017-02-21 14:32:53 -0700 | [diff] [blame] | 4119 | if (sub_aspect != VK_IMAGE_ASPECT_COLOR_BIT) { |
Dave Houlton | 852287e | 2018-01-19 15:11:51 -0700 | [diff] [blame] | 4120 | skip |= log_msg( |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 4121 | report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, HandleToUint64(image), |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 4122 | VALIDATION_ERROR_0a400c01, |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 4123 | "vkGetImageSubresourceLayout(): For color formats, VkImageSubresource.aspectMask must be VK_IMAGE_ASPECT_COLOR."); |
Mike Weiblen | 672b58b | 2017-02-21 14:32:53 -0700 | [diff] [blame] | 4124 | } |
Dave Houlton | 1d2022c | 2017-03-29 11:43:58 -0600 | [diff] [blame] | 4125 | } else if (FormatIsDepthOrStencil(img_format)) { |
Mike Weiblen | 672b58b | 2017-02-21 14:32:53 -0700 | [diff] [blame] | 4126 | if ((sub_aspect != VK_IMAGE_ASPECT_DEPTH_BIT) && (sub_aspect != VK_IMAGE_ASPECT_STENCIL_BIT)) { |
Mark Lobodzinski | 0827aec | 2017-03-21 16:41:45 -0600 | [diff] [blame] | 4127 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 4128 | HandleToUint64(image), VALIDATION_ERROR_0a400c01, |
Mike Weiblen | 672b58b | 2017-02-21 14:32:53 -0700 | [diff] [blame] | 4129 | "vkGetImageSubresourceLayout(): For depth/stencil formats, VkImageSubresource.aspectMask must be " |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 4130 | "either VK_IMAGE_ASPECT_DEPTH_BIT or VK_IMAGE_ASPECT_STENCIL_BIT."); |
Mike Weiblen | 672b58b | 2017-02-21 14:32:53 -0700 | [diff] [blame] | 4131 | } |
| 4132 | } |
| 4133 | return skip; |
| 4134 | } |