Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 1 | /* |
Luc Charbonneau | e48b02d | 2022-01-11 17:17:44 -0500 | [diff] [blame] | 2 | * Copyright (c) 2015-2022 The Khronos Group Inc. |
| 3 | * Copyright (c) 2015-2022 Valve Corporation |
| 4 | * Copyright (c) 2015-2022 LunarG, Inc. |
| 5 | * Copyright (c) 2015-2022 Google, Inc. |
| 6 | * Modifications Copyright (C) 2020-2022 Advanced Micro Devices, Inc. All rights reserved. |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 7 | * |
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | * you may not use this file except in compliance with the License. |
| 10 | * You may obtain a copy of the License at |
| 11 | * |
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | * |
| 14 | * Author: Chia-I Wu <olvaffe@gmail.com> |
| 15 | * Author: Chris Forbes <chrisf@ijw.co.nz> |
| 16 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 17 | * Author: Mark Lobodzinski <mark@lunarg.com> |
| 18 | * Author: Mike Stroyan <mike@LunarG.com> |
| 19 | * Author: Tobin Ehlis <tobine@google.com> |
| 20 | * Author: Tony Barbour <tony@LunarG.com> |
| 21 | * Author: Cody Northrop <cnorthrop@google.com> |
| 22 | * Author: Dave Houlton <daveh@lunarg.com> |
| 23 | * Author: Jeremy Kniager <jeremyk@lunarg.com> |
| 24 | * Author: Shannon McPherson <shannon@lunarg.com> |
| 25 | * Author: John Zulauf <jzulauf@lunarg.com> |
| 26 | * Author: Tobias Hector <tobias.hector@amd.com> |
| 27 | */ |
| 28 | |
| 29 | #include "cast_utils.h" |
| 30 | #include "layer_validation_tests.h" |
| 31 | |
| 32 | TEST_F(VkLayerTest, ImagelessFramebufferRenderPassBeginImageViewMismatchTests) { |
| 33 | TEST_DESCRIPTION( |
| 34 | "Begin a renderPass where the image views specified do not match the parameters used to create the framebuffer and render " |
| 35 | "pass."); |
| 36 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 37 | AddRequiredExtensions(VK_KHR_IMAGELESS_FRAMEBUFFER_EXTENSION_NAME); |
| 38 | AddOptionalExtensions(VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME); |
Mark Lobodzinski | 09ce9c4 | 2020-03-06 10:02:44 -0700 | [diff] [blame] | 39 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 40 | if (!AreRequiredExtensionsEnabled()) { |
| 41 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported."; |
| 42 | } |
| 43 | bool rp2Supported = IsExtensionsEnabled(VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 44 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 45 | auto imageless_features = LvlInitStruct<VkPhysicalDeviceImagelessFramebufferFeaturesKHR>(); |
| 46 | auto features2 = GetPhysicalDeviceFeatures2(imageless_features); |
| 47 | if (!imageless_features.imagelessFramebuffer) { |
| 48 | GTEST_SKIP() << "imagelessFramebuffer not supported."; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 49 | } |
| 50 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 51 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 52 | |
| 53 | uint32_t attachmentWidth = 512; |
| 54 | uint32_t attachmentHeight = 512; |
| 55 | VkFormat attachmentFormats[2] = {VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8A8_UNORM}; |
| 56 | VkFormat framebufferAttachmentFormats[3] = {VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_B8G8R8A8_UNORM}; |
| 57 | |
| 58 | // Create a renderPass with a single attachment |
| 59 | VkAttachmentDescription attachmentDescription = {}; |
| 60 | attachmentDescription.format = attachmentFormats[0]; |
| 61 | attachmentDescription.samples = VK_SAMPLE_COUNT_1_BIT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 62 | attachmentDescription.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 63 | attachmentDescription.finalLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 64 | VkAttachmentReference attachmentReference = {}; |
| 65 | attachmentReference.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 66 | VkSubpassDescription subpassDescription = {}; |
| 67 | subpassDescription.colorAttachmentCount = 1; |
| 68 | subpassDescription.pColorAttachments = &attachmentReference; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 69 | auto rpci = LvlInitStruct<VkRenderPassCreateInfo>(); |
| 70 | rpci.subpassCount = 1; |
| 71 | rpci.pSubpasses = &subpassDescription; |
| 72 | rpci.attachmentCount = 1; |
| 73 | rpci.pAttachments = &attachmentDescription; |
| 74 | vk_testing::RenderPass rp(*m_device, rpci); |
| 75 | ASSERT_TRUE(rp.initialized()); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 76 | |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 77 | VkFramebufferAttachmentImageInfoKHR framebufferAttachmentImageInfo = LvlInitStruct<VkFramebufferAttachmentImageInfoKHR>(); |
Mark Lobodzinski | 5088599 | 2019-12-03 14:44:22 -0700 | [diff] [blame] | 78 | framebufferAttachmentImageInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
sfricke-samsung | ab73ad6 | 2021-01-17 09:05:54 -0800 | [diff] [blame] | 79 | framebufferAttachmentImageInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 80 | framebufferAttachmentImageInfo.width = attachmentWidth; |
| 81 | framebufferAttachmentImageInfo.height = attachmentHeight; |
| 82 | framebufferAttachmentImageInfo.layerCount = 1; |
| 83 | framebufferAttachmentImageInfo.viewFormatCount = 2; |
| 84 | framebufferAttachmentImageInfo.pViewFormats = framebufferAttachmentFormats; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 85 | VkFramebufferAttachmentsCreateInfoKHR framebufferAttachmentsCreateInfo = LvlInitStruct<VkFramebufferAttachmentsCreateInfoKHR>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 86 | framebufferAttachmentsCreateInfo.attachmentImageInfoCount = 1; |
| 87 | framebufferAttachmentsCreateInfo.pAttachmentImageInfos = &framebufferAttachmentImageInfo; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 88 | VkFramebufferCreateInfo framebufferCreateInfo = LvlInitStruct<VkFramebufferCreateInfo>(&framebufferAttachmentsCreateInfo); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 89 | framebufferCreateInfo.flags = VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR; |
| 90 | framebufferCreateInfo.width = attachmentWidth; |
| 91 | framebufferCreateInfo.height = attachmentHeight; |
| 92 | framebufferCreateInfo.layers = 1; |
| 93 | framebufferCreateInfo.attachmentCount = 1; |
| 94 | framebufferCreateInfo.pAttachments = nullptr; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 95 | framebufferCreateInfo.renderPass = rp.handle(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 96 | |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 97 | VkImageFormatListCreateInfoKHR imageFormatListCreateInfo = LvlInitStruct<VkImageFormatListCreateInfo>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 98 | imageFormatListCreateInfo.viewFormatCount = 2; |
| 99 | imageFormatListCreateInfo.pViewFormats = attachmentFormats; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 100 | VkImageCreateInfo imageCreateInfo = LvlInitStruct<VkImageCreateInfo>(&imageFormatListCreateInfo); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 101 | imageCreateInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
sfricke-samsung | ab73ad6 | 2021-01-17 09:05:54 -0800 | [diff] [blame] | 102 | imageCreateInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 103 | imageCreateInfo.extent.width = attachmentWidth; |
| 104 | imageCreateInfo.extent.height = attachmentHeight; |
| 105 | imageCreateInfo.extent.depth = 1; |
| 106 | imageCreateInfo.arrayLayers = 1; |
| 107 | imageCreateInfo.mipLevels = 10; |
| 108 | imageCreateInfo.imageType = VK_IMAGE_TYPE_2D; |
| 109 | imageCreateInfo.samples = VK_SAMPLE_COUNT_1_BIT; |
| 110 | imageCreateInfo.format = attachmentFormats[0]; |
| 111 | |
| 112 | VkImageObj imageObject(m_device); |
| 113 | imageObject.init(&imageCreateInfo); |
| 114 | VkImage image = imageObject.image(); |
| 115 | |
sfricke-samsung | ab73ad6 | 2021-01-17 09:05:54 -0800 | [diff] [blame] | 116 | // Only use the subset without the TRANSFER bit |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 117 | VkImageViewUsageCreateInfo image_view_usage_create_info = LvlInitStruct<VkImageViewUsageCreateInfo>(); |
sfricke-samsung | ab73ad6 | 2021-01-17 09:05:54 -0800 | [diff] [blame] | 118 | image_view_usage_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 119 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 120 | VkImageViewCreateInfo imageViewCreateInfo = LvlInitStruct<VkImageViewCreateInfo>(&image_view_usage_create_info); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 121 | imageViewCreateInfo.image = image; |
| 122 | imageViewCreateInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 123 | imageViewCreateInfo.format = attachmentFormats[0]; |
| 124 | imageViewCreateInfo.subresourceRange.layerCount = 1; |
| 125 | imageViewCreateInfo.subresourceRange.levelCount = 1; |
| 126 | imageViewCreateInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
sfricke-samsung | ab73ad6 | 2021-01-17 09:05:54 -0800 | [diff] [blame] | 127 | |
| 128 | // Has subset of usage flags |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 129 | vk_testing::ImageView imageViewSubset(*m_device, imageViewCreateInfo); |
| 130 | ASSERT_TRUE(imageViewSubset.initialized()); |
sfricke-samsung | ab73ad6 | 2021-01-17 09:05:54 -0800 | [diff] [blame] | 131 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 132 | imageViewCreateInfo.pNext = nullptr; |
| 133 | vk_testing::ImageView imageView(*m_device, imageViewCreateInfo); |
| 134 | ASSERT_TRUE(imageView.initialized()); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 135 | |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 136 | VkRenderPassAttachmentBeginInfoKHR renderPassAttachmentBeginInfo = LvlInitStruct<VkRenderPassAttachmentBeginInfo>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 137 | renderPassAttachmentBeginInfo.attachmentCount = 1; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 138 | renderPassAttachmentBeginInfo.pAttachments = &imageView.handle(); |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 139 | VkRenderPassBeginInfo renderPassBeginInfo = LvlInitStruct<VkRenderPassBeginInfo>(&renderPassAttachmentBeginInfo); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 140 | renderPassBeginInfo.renderPass = rp.handle(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 141 | renderPassBeginInfo.renderArea.extent.width = attachmentWidth; |
| 142 | renderPassBeginInfo.renderArea.extent.height = attachmentHeight; |
| 143 | |
Mark Lobodzinski | 5088599 | 2019-12-03 14:44:22 -0700 | [diff] [blame] | 144 | VkCommandBufferBeginInfo cmd_begin_info = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr, |
| 145 | VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, nullptr}; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 146 | |
| 147 | // Positive test first |
| 148 | { |
| 149 | framebufferCreateInfo.pAttachments = nullptr; |
| 150 | framebufferCreateInfo.flags = VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR; |
| 151 | vk_testing::Framebuffer framebuffer(*m_device, framebufferCreateInfo); |
| 152 | ASSERT_TRUE(framebuffer.initialized()); |
| 153 | renderPassBeginInfo.framebuffer = framebuffer.handle(); |
| 154 | m_commandBuffer->begin(&cmd_begin_info); |
| 155 | m_commandBuffer->BeginRenderPass(renderPassBeginInfo); |
| 156 | m_commandBuffer->reset(); |
| 157 | } |
Mark Lobodzinski | 5088599 | 2019-12-03 14:44:22 -0700 | [diff] [blame] | 158 | |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 159 | // Imageless framebuffer creation bit not present |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 160 | { |
| 161 | framebufferCreateInfo.pAttachments = &imageView.handle(); |
| 162 | framebufferCreateInfo.flags = 0; |
| 163 | vk_testing::Framebuffer framebuffer(*m_device, framebufferCreateInfo); |
| 164 | ASSERT_TRUE(framebuffer.initialized()); |
| 165 | renderPassBeginInfo.framebuffer = framebuffer.handle(); |
| 166 | TestRenderPassBegin(m_errorMonitor, m_device->device(), m_commandBuffer->handle(), &renderPassBeginInfo, rp2Supported, |
| 167 | "VUID-VkRenderPassBeginInfo-framebuffer-03207", "VUID-VkRenderPassBeginInfo-framebuffer-03207"); |
| 168 | } |
| 169 | { |
| 170 | framebufferCreateInfo.pAttachments = nullptr; |
| 171 | framebufferCreateInfo.flags = VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR; |
| 172 | vk_testing::Framebuffer framebuffer(*m_device, framebufferCreateInfo); |
| 173 | ASSERT_TRUE(framebuffer.initialized()); |
| 174 | renderPassAttachmentBeginInfo.attachmentCount = 2; |
| 175 | renderPassBeginInfo.framebuffer = framebuffer.handle(); |
| 176 | TestRenderPassBegin(m_errorMonitor, m_device->device(), m_commandBuffer->handle(), &renderPassBeginInfo, rp2Supported, |
| 177 | "VUID-VkRenderPassBeginInfo-framebuffer-03208", "VUID-VkRenderPassBeginInfo-framebuffer-03208"); |
| 178 | renderPassAttachmentBeginInfo.attachmentCount = 1; |
| 179 | } |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 180 | |
| 181 | // Mismatched number of attachments |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 182 | { |
| 183 | vk_testing::Framebuffer framebuffer(*m_device, framebufferCreateInfo); |
| 184 | ASSERT_TRUE(framebuffer.initialized()); |
| 185 | renderPassAttachmentBeginInfo.attachmentCount = 2; |
| 186 | renderPassBeginInfo.framebuffer = framebuffer.handle(); |
| 187 | TestRenderPassBegin(m_errorMonitor, m_device->device(), m_commandBuffer->handle(), &renderPassBeginInfo, rp2Supported, |
| 188 | "VUID-VkRenderPassBeginInfo-framebuffer-03208", "VUID-VkRenderPassBeginInfo-framebuffer-03208"); |
| 189 | renderPassAttachmentBeginInfo.attachmentCount = 1; |
| 190 | } |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 191 | |
| 192 | // Mismatched flags |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 193 | { |
| 194 | framebufferAttachmentImageInfo.flags = 0; |
| 195 | vk_testing::Framebuffer framebuffer(*m_device, framebufferCreateInfo); |
| 196 | ASSERT_TRUE(framebuffer.initialized()); |
| 197 | renderPassBeginInfo.framebuffer = framebuffer.handle(); |
| 198 | TestRenderPassBegin(m_errorMonitor, m_device->device(), m_commandBuffer->handle(), &renderPassBeginInfo, rp2Supported, |
| 199 | "VUID-VkRenderPassBeginInfo-framebuffer-03209", "VUID-VkRenderPassBeginInfo-framebuffer-03209"); |
| 200 | framebufferAttachmentImageInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
| 201 | } |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 202 | |
| 203 | // Mismatched usage |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 204 | { |
| 205 | framebufferAttachmentImageInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT; |
| 206 | vk_testing::Framebuffer framebuffer(*m_device, framebufferCreateInfo); |
| 207 | ASSERT_TRUE(framebuffer.initialized()); |
| 208 | renderPassBeginInfo.framebuffer = framebuffer.handle(); |
| 209 | TestRenderPassBegin(m_errorMonitor, m_device->device(), m_commandBuffer->handle(), &renderPassBeginInfo, rp2Supported, |
| 210 | "VUID-VkRenderPassBeginInfo-framebuffer-04627", "VUID-VkRenderPassBeginInfo-framebuffer-04627"); |
| 211 | framebufferAttachmentImageInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 212 | } |
sfricke-samsung | ab73ad6 | 2021-01-17 09:05:54 -0800 | [diff] [blame] | 213 | |
| 214 | // Mismatched usage because VkImageViewUsageCreateInfo restricted to TRANSFER |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 215 | { |
| 216 | renderPassAttachmentBeginInfo.pAttachments = &imageViewSubset.handle(); |
| 217 | vk_testing::Framebuffer framebuffer(*m_device, framebufferCreateInfo); |
| 218 | ASSERT_TRUE(framebuffer.initialized()); |
| 219 | renderPassBeginInfo.framebuffer = framebuffer.handle(); |
| 220 | TestRenderPassBegin(m_errorMonitor, m_device->device(), m_commandBuffer->handle(), &renderPassBeginInfo, rp2Supported, |
| 221 | "VUID-VkRenderPassBeginInfo-framebuffer-04627", "VUID-VkRenderPassBeginInfo-framebuffer-04627"); |
| 222 | renderPassAttachmentBeginInfo.pAttachments = &imageView.handle(); |
| 223 | } |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 224 | |
| 225 | // Mismatched width |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 226 | { |
| 227 | framebufferAttachmentImageInfo.width += 1; |
| 228 | vk_testing::Framebuffer framebuffer(*m_device, framebufferCreateInfo); |
| 229 | ASSERT_TRUE(framebuffer.initialized()); |
| 230 | renderPassBeginInfo.framebuffer = framebuffer.handle(); |
| 231 | TestRenderPassBegin(m_errorMonitor, m_device->device(), m_commandBuffer->handle(), &renderPassBeginInfo, rp2Supported, |
| 232 | "VUID-VkRenderPassBeginInfo-framebuffer-03211", "VUID-VkRenderPassBeginInfo-framebuffer-03211"); |
| 233 | framebufferAttachmentImageInfo.width -= 1; |
| 234 | } |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 235 | |
| 236 | // Mismatched height |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 237 | { |
| 238 | framebufferAttachmentImageInfo.height += 1; |
| 239 | vk_testing::Framebuffer framebuffer(*m_device, framebufferCreateInfo); |
| 240 | ASSERT_TRUE(framebuffer.initialized()); |
| 241 | renderPassBeginInfo.framebuffer = framebuffer.handle(); |
| 242 | TestRenderPassBegin(m_errorMonitor, m_device->device(), m_commandBuffer->handle(), &renderPassBeginInfo, rp2Supported, |
| 243 | "VUID-VkRenderPassBeginInfo-framebuffer-03212", "VUID-VkRenderPassBeginInfo-framebuffer-03212"); |
| 244 | framebufferAttachmentImageInfo.height -= 1; |
| 245 | } |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 246 | |
| 247 | // Mismatched layer count |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 248 | { |
| 249 | framebufferAttachmentImageInfo.layerCount += 1; |
| 250 | vk_testing::Framebuffer framebuffer(*m_device, framebufferCreateInfo); |
| 251 | ASSERT_TRUE(framebuffer.initialized()); |
| 252 | renderPassBeginInfo.framebuffer = framebuffer.handle(); |
| 253 | TestRenderPassBegin(m_errorMonitor, m_device->device(), m_commandBuffer->handle(), &renderPassBeginInfo, rp2Supported, |
| 254 | "VUID-VkRenderPassBeginInfo-framebuffer-03213", "VUID-VkRenderPassBeginInfo-framebuffer-03213"); |
| 255 | framebufferAttachmentImageInfo.layerCount -= 1; |
| 256 | } |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 257 | |
| 258 | // Mismatched view format count |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 259 | { |
| 260 | framebufferAttachmentImageInfo.viewFormatCount = 3; |
| 261 | vk_testing::Framebuffer framebuffer(*m_device, framebufferCreateInfo); |
| 262 | ASSERT_TRUE(framebuffer.initialized()); |
| 263 | renderPassBeginInfo.framebuffer = framebuffer.handle(); |
| 264 | TestRenderPassBegin(m_errorMonitor, m_device->device(), m_commandBuffer->handle(), &renderPassBeginInfo, rp2Supported, |
| 265 | "VUID-VkRenderPassBeginInfo-framebuffer-03214", "VUID-VkRenderPassBeginInfo-framebuffer-03214"); |
| 266 | framebufferAttachmentImageInfo.viewFormatCount = 2; |
| 267 | } |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 268 | |
| 269 | // Mismatched format lists |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 270 | { |
| 271 | framebufferAttachmentFormats[1] = VK_FORMAT_B8G8R8A8_SRGB; |
| 272 | vk_testing::Framebuffer framebuffer(*m_device, framebufferCreateInfo); |
| 273 | ASSERT_TRUE(framebuffer.initialized()); |
| 274 | renderPassBeginInfo.framebuffer = framebuffer.handle(); |
| 275 | TestRenderPassBegin(m_errorMonitor, m_device->device(), m_commandBuffer->handle(), &renderPassBeginInfo, rp2Supported, |
| 276 | "VUID-VkRenderPassBeginInfo-framebuffer-03215", "VUID-VkRenderPassBeginInfo-framebuffer-03215"); |
| 277 | framebufferAttachmentFormats[1] = VK_FORMAT_B8G8R8A8_UNORM; |
| 278 | } |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 279 | |
| 280 | // Mismatched formats |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 281 | { |
| 282 | imageViewCreateInfo.format = attachmentFormats[1]; |
| 283 | vk_testing::ImageView imageView2(*m_device, imageViewCreateInfo); |
| 284 | ASSERT_TRUE(imageView2.initialized()); |
| 285 | renderPassAttachmentBeginInfo.pAttachments = &imageView2.handle(); |
| 286 | vk_testing::Framebuffer framebuffer(*m_device, framebufferCreateInfo); |
| 287 | ASSERT_TRUE(framebuffer.initialized()); |
| 288 | renderPassBeginInfo.framebuffer = framebuffer.handle(); |
| 289 | TestRenderPassBegin(m_errorMonitor, m_device->device(), m_commandBuffer->handle(), &renderPassBeginInfo, rp2Supported, |
| 290 | "VUID-VkRenderPassBeginInfo-framebuffer-03216", "VUID-VkRenderPassBeginInfo-framebuffer-03216"); |
| 291 | renderPassAttachmentBeginInfo.pAttachments = &imageView.handle(); |
| 292 | imageViewCreateInfo.format = attachmentFormats[0]; |
| 293 | } |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 294 | |
| 295 | // Mismatched sample counts |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 296 | { |
| 297 | imageCreateInfo.samples = VK_SAMPLE_COUNT_4_BIT; |
| 298 | imageCreateInfo.mipLevels = 1; |
| 299 | VkImageObj imageObject2(m_device); |
| 300 | imageObject2.init(&imageCreateInfo); |
| 301 | imageViewCreateInfo.image = imageObject2.image(); |
| 302 | vk_testing::ImageView imageView2(*m_device, imageViewCreateInfo); |
| 303 | ASSERT_TRUE(imageView2.initialized()); |
| 304 | renderPassAttachmentBeginInfo.pAttachments = &imageView2.handle(); |
| 305 | vk_testing::Framebuffer framebuffer(*m_device, framebufferCreateInfo); |
| 306 | ASSERT_TRUE(framebuffer.initialized()); |
| 307 | renderPassBeginInfo.framebuffer = framebuffer.handle(); |
| 308 | TestRenderPassBegin(m_errorMonitor, m_device->device(), m_commandBuffer->handle(), &renderPassBeginInfo, rp2Supported, |
| 309 | "VUID-VkRenderPassBeginInfo-framebuffer-03217", "VUID-VkRenderPassBeginInfo-framebuffer-03217"); |
| 310 | renderPassAttachmentBeginInfo.pAttachments = &imageView.handle(); |
| 311 | imageViewCreateInfo.image = imageObject.image(); |
| 312 | imageCreateInfo.samples = VK_SAMPLE_COUNT_1_BIT; |
| 313 | imageCreateInfo.mipLevels = 10; |
| 314 | } |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 315 | |
| 316 | // Mismatched level counts |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 317 | { |
| 318 | imageViewCreateInfo.subresourceRange.levelCount = 2; |
| 319 | vk_testing::ImageView imageView2(*m_device, imageViewCreateInfo); |
| 320 | ASSERT_TRUE(imageView2.initialized()); |
| 321 | renderPassAttachmentBeginInfo.pAttachments = &imageView2.handle(); |
| 322 | vk_testing::Framebuffer framebuffer(*m_device, framebufferCreateInfo); |
| 323 | ASSERT_TRUE(framebuffer.initialized()); |
| 324 | renderPassBeginInfo.framebuffer = framebuffer.handle(); |
| 325 | TestRenderPassBegin(m_errorMonitor, m_device->device(), m_commandBuffer->handle(), &renderPassBeginInfo, rp2Supported, |
| 326 | "VUID-VkRenderPassAttachmentBeginInfo-pAttachments-03218", |
| 327 | "VUID-VkRenderPassAttachmentBeginInfo-pAttachments-03218"); |
| 328 | renderPassAttachmentBeginInfo.pAttachments = &imageView.handle(); |
| 329 | imageViewCreateInfo.subresourceRange.levelCount = 1; |
| 330 | } |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 331 | |
| 332 | // Non-identity component swizzle |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 333 | { |
| 334 | imageViewCreateInfo.components.r = VK_COMPONENT_SWIZZLE_A; |
| 335 | vk_testing::ImageView imageView2(*m_device, imageViewCreateInfo); |
| 336 | ASSERT_TRUE(imageView2.initialized()); |
| 337 | renderPassAttachmentBeginInfo.pAttachments = &imageView2.handle(); |
| 338 | vk_testing::Framebuffer framebuffer(*m_device, framebufferCreateInfo); |
| 339 | ASSERT_TRUE(framebuffer.initialized()); |
| 340 | renderPassBeginInfo.framebuffer = framebuffer.handle(); |
| 341 | TestRenderPassBegin(m_errorMonitor, m_device->device(), m_commandBuffer->handle(), &renderPassBeginInfo, rp2Supported, |
| 342 | "VUID-VkRenderPassAttachmentBeginInfo-pAttachments-03219", |
| 343 | "VUID-VkRenderPassAttachmentBeginInfo-pAttachments-03219"); |
| 344 | renderPassAttachmentBeginInfo.pAttachments = &imageView.handle(); |
| 345 | imageViewCreateInfo.components.r = VK_COMPONENT_SWIZZLE_IDENTITY; |
| 346 | } |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 347 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 348 | { |
| 349 | imageViewCreateInfo.subresourceRange.baseMipLevel = 1; |
| 350 | vk_testing::ImageView imageView2(*m_device, imageViewCreateInfo); |
| 351 | ASSERT_TRUE(imageView2.initialized()); |
| 352 | renderPassAttachmentBeginInfo.pAttachments = &imageView2.handle(); |
| 353 | framebufferAttachmentImageInfo.height = framebufferAttachmentImageInfo.height / 2; |
| 354 | framebufferAttachmentImageInfo.width = framebufferAttachmentImageInfo.width / 2; |
| 355 | framebufferCreateInfo.height = framebufferCreateInfo.height / 2; |
| 356 | framebufferCreateInfo.width = framebufferCreateInfo.width / 2; |
| 357 | vk_testing::Framebuffer framebuffer(*m_device, framebufferCreateInfo); |
| 358 | ASSERT_TRUE(framebuffer.initialized()); |
| 359 | renderPassBeginInfo.framebuffer = framebuffer.handle(); |
| 360 | renderPassBeginInfo.renderArea.extent.height = renderPassBeginInfo.renderArea.extent.height / 2; |
| 361 | renderPassBeginInfo.renderArea.extent.width = renderPassBeginInfo.renderArea.extent.width / 2; |
| 362 | m_commandBuffer->begin(&cmd_begin_info); |
| 363 | m_commandBuffer->BeginRenderPass(renderPassBeginInfo); |
| 364 | m_commandBuffer->reset(); |
| 365 | renderPassAttachmentBeginInfo.pAttachments = &imageView.handle(); |
| 366 | imageViewCreateInfo.subresourceRange.baseMipLevel = 0; |
| 367 | framebufferAttachmentImageInfo.height = framebufferAttachmentImageInfo.height * 2; |
| 368 | framebufferAttachmentImageInfo.width = framebufferAttachmentImageInfo.width * 2; |
| 369 | } |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | TEST_F(VkLayerTest, ImagelessFramebufferFeatureEnableTest) { |
| 373 | TEST_DESCRIPTION("Use imageless framebuffer functionality without enabling the feature"); |
| 374 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 375 | AddRequiredExtensions(VK_KHR_IMAGELESS_FRAMEBUFFER_EXTENSION_NAME); |
Mark Lobodzinski | 09ce9c4 | 2020-03-06 10:02:44 -0700 | [diff] [blame] | 376 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 377 | if (!AreRequiredExtensionsEnabled()) { |
| 378 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported."; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, nullptr, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
| 382 | |
| 383 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 384 | |
| 385 | uint32_t attachmentWidth = 512; |
| 386 | uint32_t attachmentHeight = 512; |
| 387 | VkFormat attachmentFormat = VK_FORMAT_R8G8B8A8_UNORM; |
| 388 | |
| 389 | // Create a renderPass with a single attachment |
| 390 | VkAttachmentDescription attachmentDescription = {}; |
| 391 | attachmentDescription.format = attachmentFormat; |
| 392 | attachmentDescription.samples = VK_SAMPLE_COUNT_1_BIT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 393 | attachmentDescription.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 394 | attachmentDescription.finalLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 395 | VkAttachmentReference attachmentReference = {}; |
| 396 | attachmentReference.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 397 | VkSubpassDescription subpassDescription = {}; |
| 398 | subpassDescription.colorAttachmentCount = 1; |
| 399 | subpassDescription.pColorAttachments = &attachmentReference; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 400 | VkRenderPassCreateInfo renderPassCreateInfo = LvlInitStruct<VkRenderPassCreateInfo>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 401 | renderPassCreateInfo.subpassCount = 1; |
| 402 | renderPassCreateInfo.pSubpasses = &subpassDescription; |
| 403 | renderPassCreateInfo.attachmentCount = 1; |
| 404 | renderPassCreateInfo.pAttachments = &attachmentDescription; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 405 | VkRenderPass renderPass; |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 406 | vk::CreateRenderPass(m_device->device(), &renderPassCreateInfo, NULL, &renderPass); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 407 | |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 408 | VkFramebufferAttachmentImageInfoKHR framebufferAttachmentImageInfo = LvlInitStruct<VkFramebufferAttachmentImageInfoKHR>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 409 | framebufferAttachmentImageInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 410 | framebufferAttachmentImageInfo.width = attachmentWidth; |
| 411 | framebufferAttachmentImageInfo.height = attachmentHeight; |
| 412 | framebufferAttachmentImageInfo.layerCount = 1; |
| 413 | framebufferAttachmentImageInfo.viewFormatCount = 1; |
| 414 | framebufferAttachmentImageInfo.pViewFormats = &attachmentFormat; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 415 | VkFramebufferAttachmentsCreateInfoKHR framebufferAttachmentsCreateInfo = LvlInitStruct<VkFramebufferAttachmentsCreateInfoKHR>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 416 | framebufferAttachmentsCreateInfo.attachmentImageInfoCount = 1; |
| 417 | framebufferAttachmentsCreateInfo.pAttachmentImageInfos = &framebufferAttachmentImageInfo; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 418 | VkFramebufferCreateInfo framebufferCreateInfo = LvlInitStruct<VkFramebufferCreateInfo>(&framebufferAttachmentsCreateInfo); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 419 | framebufferCreateInfo.flags = VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR; |
| 420 | framebufferCreateInfo.width = attachmentWidth; |
| 421 | framebufferCreateInfo.height = attachmentHeight; |
| 422 | framebufferCreateInfo.layers = 1; |
| 423 | framebufferCreateInfo.renderPass = renderPass; |
| 424 | framebufferCreateInfo.attachmentCount = 1; |
| 425 | VkFramebuffer framebuffer = VK_NULL_HANDLE; |
| 426 | |
| 427 | // Imageless framebuffer creation bit not present |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 428 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-flags-03189"); |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 429 | vk::CreateFramebuffer(m_device->device(), &framebufferCreateInfo, nullptr, &framebuffer); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 430 | m_errorMonitor->VerifyFound(); |
| 431 | |
| 432 | if (framebuffer != VK_NULL_HANDLE) { |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 433 | vk::DestroyFramebuffer(m_device->device(), framebuffer, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 434 | } |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 435 | vk::DestroyRenderPass(m_device->device(), renderPass, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 436 | } |
| 437 | |
| 438 | TEST_F(VkLayerTest, ImagelessFramebufferCreationTests) { |
| 439 | TEST_DESCRIPTION("Create an imageless framebuffer in various invalid ways"); |
| 440 | |
| 441 | if (InstanceExtensionSupported(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME)) { |
| 442 | m_instance_extension_names.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 443 | } else { |
| 444 | printf("%s Did not find required instance extension %s; skipped.\n", kSkipPrefix, |
| 445 | VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 446 | return; |
| 447 | } |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 448 | AddRequiredExtensions(VK_KHR_IMAGELESS_FRAMEBUFFER_EXTENSION_NAME); |
| 449 | AddOptionalExtensions(VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME); |
| 450 | AddOptionalExtensions(VK_KHR_MULTIVIEW_EXTENSION_NAME); |
| 451 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 452 | if (!AreRequiredExtensionsEnabled()) { |
| 453 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported."; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 454 | } |
| 455 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 456 | bool multiviewSupported = IsExtensionsEnabled(VK_KHR_MULTIVIEW_EXTENSION_NAME); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 457 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 458 | auto mv_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeaturesKHR>(); |
| 459 | auto imageless_features = LvlInitStruct<VkPhysicalDeviceImagelessFramebufferFeaturesKHR>(); |
| 460 | if (multiviewSupported) { |
| 461 | imageless_features.pNext = &mv_features; |
| 462 | } |
| 463 | VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(imageless_features); |
| 464 | if (!imageless_features.imagelessFramebuffer) { |
| 465 | GTEST_SKIP() << "imagelessFramebuffer not supported."; |
| 466 | } |
| 467 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 468 | |
| 469 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 470 | |
| 471 | uint32_t attachmentWidth = 512; |
| 472 | uint32_t attachmentHeight = 512; |
| 473 | VkFormat attachmentFormat = VK_FORMAT_R8G8B8A8_UNORM; |
| 474 | |
| 475 | // Create a renderPass with a single attachment |
| 476 | VkAttachmentDescription attachmentDescription = {}; |
| 477 | attachmentDescription.format = attachmentFormat; |
| 478 | attachmentDescription.samples = VK_SAMPLE_COUNT_1_BIT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 479 | attachmentDescription.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 480 | attachmentDescription.finalLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 481 | VkAttachmentReference attachmentReference = {}; |
| 482 | attachmentReference.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 483 | VkSubpassDescription subpassDescription = {}; |
| 484 | subpassDescription.colorAttachmentCount = 1; |
| 485 | subpassDescription.pColorAttachments = &attachmentReference; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 486 | VkRenderPassCreateInfo renderPassCreateInfo = LvlInitStruct<VkRenderPassCreateInfo>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 487 | renderPassCreateInfo.subpassCount = 1; |
| 488 | renderPassCreateInfo.pSubpasses = &subpassDescription; |
| 489 | renderPassCreateInfo.attachmentCount = 1; |
| 490 | renderPassCreateInfo.pAttachments = &attachmentDescription; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 491 | VkRenderPass renderPass; |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 492 | vk::CreateRenderPass(m_device->device(), &renderPassCreateInfo, NULL, &renderPass); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 493 | |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 494 | VkFramebufferAttachmentImageInfoKHR framebufferAttachmentImageInfo = LvlInitStruct<VkFramebufferAttachmentImageInfoKHR>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 495 | framebufferAttachmentImageInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 496 | framebufferAttachmentImageInfo.width = attachmentWidth; |
| 497 | framebufferAttachmentImageInfo.height = attachmentHeight; |
| 498 | framebufferAttachmentImageInfo.layerCount = 1; |
| 499 | framebufferAttachmentImageInfo.viewFormatCount = 1; |
| 500 | framebufferAttachmentImageInfo.pViewFormats = &attachmentFormat; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 501 | VkFramebufferAttachmentsCreateInfoKHR framebufferAttachmentsCreateInfo = LvlInitStruct<VkFramebufferAttachmentsCreateInfoKHR>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 502 | framebufferAttachmentsCreateInfo.attachmentImageInfoCount = 1; |
| 503 | framebufferAttachmentsCreateInfo.pAttachmentImageInfos = &framebufferAttachmentImageInfo; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 504 | VkFramebufferCreateInfo framebufferCreateInfo = LvlInitStruct<VkFramebufferCreateInfo>(&framebufferAttachmentsCreateInfo); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 505 | framebufferCreateInfo.flags = VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR; |
| 506 | framebufferCreateInfo.width = attachmentWidth; |
| 507 | framebufferCreateInfo.height = attachmentHeight; |
| 508 | framebufferCreateInfo.layers = 1; |
| 509 | framebufferCreateInfo.renderPass = renderPass; |
| 510 | framebufferCreateInfo.attachmentCount = 1; |
| 511 | VkFramebuffer framebuffer = VK_NULL_HANDLE; |
| 512 | |
| 513 | // Attachments info not present |
| 514 | framebufferCreateInfo.pNext = nullptr; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 515 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-flags-03190"); |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 516 | vk::CreateFramebuffer(m_device->device(), &framebufferCreateInfo, nullptr, &framebuffer); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 517 | m_errorMonitor->VerifyFound(); |
| 518 | if (framebuffer != VK_NULL_HANDLE) { |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 519 | vk::DestroyFramebuffer(m_device->device(), framebuffer, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 520 | } |
| 521 | framebufferCreateInfo.pNext = &framebufferAttachmentsCreateInfo; |
| 522 | |
| 523 | // Mismatched attachment counts |
| 524 | framebufferAttachmentsCreateInfo.attachmentImageInfoCount = 2; |
| 525 | VkFramebufferAttachmentImageInfoKHR framebufferAttachmentImageInfos[2] = {framebufferAttachmentImageInfo, |
| 526 | framebufferAttachmentImageInfo}; |
| 527 | framebufferAttachmentsCreateInfo.pAttachmentImageInfos = framebufferAttachmentImageInfos; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 528 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-flags-03191"); |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 529 | vk::CreateFramebuffer(m_device->device(), &framebufferCreateInfo, nullptr, &framebuffer); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 530 | m_errorMonitor->VerifyFound(); |
| 531 | if (framebuffer != VK_NULL_HANDLE) { |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 532 | vk::DestroyFramebuffer(m_device->device(), framebuffer, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 533 | } |
| 534 | framebufferAttachmentsCreateInfo.pAttachmentImageInfos = &framebufferAttachmentImageInfo; |
| 535 | framebufferAttachmentsCreateInfo.attachmentImageInfoCount = 1; |
| 536 | |
| 537 | // Mismatched format list |
| 538 | attachmentFormat = VK_FORMAT_B8G8R8A8_UNORM; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 539 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-flags-03205"); |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 540 | vk::CreateFramebuffer(m_device->device(), &framebufferCreateInfo, nullptr, &framebuffer); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 541 | m_errorMonitor->VerifyFound(); |
| 542 | if (framebuffer != VK_NULL_HANDLE) { |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 543 | vk::DestroyFramebuffer(m_device->device(), framebuffer, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 544 | } |
| 545 | attachmentFormat = VK_FORMAT_R8G8B8A8_UNORM; |
| 546 | |
| 547 | // Mismatched format list |
| 548 | attachmentFormat = VK_FORMAT_B8G8R8A8_UNORM; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 549 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-flags-03205"); |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 550 | vk::CreateFramebuffer(m_device->device(), &framebufferCreateInfo, nullptr, &framebuffer); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 551 | m_errorMonitor->VerifyFound(); |
| 552 | if (framebuffer != VK_NULL_HANDLE) { |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 553 | vk::DestroyFramebuffer(m_device->device(), framebuffer, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 554 | } |
| 555 | attachmentFormat = VK_FORMAT_R8G8B8A8_UNORM; |
| 556 | |
| 557 | // Mismatched layer count, multiview disabled |
| 558 | framebufferCreateInfo.layers = 2; |
| 559 | const char* mismatchedLayersNoMultiviewVuid = |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 560 | multiviewSupported ? "VUID-VkFramebufferCreateInfo-renderPass-04546" : "VUID-VkFramebufferCreateInfo-flags-04547"; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 561 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, mismatchedLayersNoMultiviewVuid); |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 562 | vk::CreateFramebuffer(m_device->device(), &framebufferCreateInfo, nullptr, &framebuffer); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 563 | m_errorMonitor->VerifyFound(); |
| 564 | if (framebuffer != VK_NULL_HANDLE) { |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 565 | vk::DestroyFramebuffer(m_device->device(), framebuffer, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 566 | } |
| 567 | framebufferCreateInfo.layers = 1; |
| 568 | |
| 569 | // Mismatched width |
| 570 | framebufferCreateInfo.width += 1; |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 571 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-flags-04541"); |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 572 | vk::CreateFramebuffer(m_device->device(), &framebufferCreateInfo, nullptr, &framebuffer); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 573 | m_errorMonitor->VerifyFound(); |
| 574 | if (framebuffer != VK_NULL_HANDLE) { |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 575 | vk::DestroyFramebuffer(m_device->device(), framebuffer, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 576 | } |
| 577 | framebufferCreateInfo.width -= 1; |
| 578 | |
| 579 | // Mismatched height |
| 580 | framebufferCreateInfo.height += 1; |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 581 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-flags-04542"); |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 582 | vk::CreateFramebuffer(m_device->device(), &framebufferCreateInfo, nullptr, &framebuffer); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 583 | m_errorMonitor->VerifyFound(); |
| 584 | if (framebuffer != VK_NULL_HANDLE) { |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 585 | vk::DestroyFramebuffer(m_device->device(), framebuffer, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 586 | } |
| 587 | framebufferCreateInfo.height -= 1; |
| 588 | |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 589 | vk::DestroyRenderPass(m_device->device(), renderPass, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 590 | } |
| 591 | |
| 592 | TEST_F(VkLayerTest, ImagelessFramebufferAttachmentImageUsageMismatchTests) { |
| 593 | TEST_DESCRIPTION("Create an imageless framebuffer with mismatched attachment image usage"); |
| 594 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 595 | AddRequiredExtensions(VK_KHR_IMAGELESS_FRAMEBUFFER_EXTENSION_NAME); |
| 596 | AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 597 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 598 | if (!AreRequiredExtensionsEnabled()) { |
| 599 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported."; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 600 | } |
| 601 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 602 | auto imageless_features = LvlInitStruct<VkPhysicalDeviceImagelessFramebufferFeaturesKHR>(); |
| 603 | auto features2 = GetPhysicalDeviceFeatures2(imageless_features); |
| 604 | if (!imageless_features.imagelessFramebuffer) { |
| 605 | GTEST_SKIP() << "imagelessFramebuffer feature not supported."; |
| 606 | } |
| 607 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 608 | |
| 609 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 610 | |
| 611 | uint32_t attachmentWidth = 512; |
| 612 | uint32_t attachmentHeight = 512; |
| 613 | VkFormat colorAndInputAttachmentFormat = VK_FORMAT_R8G8B8A8_UNORM; |
| 614 | VkFormat depthStencilAttachmentFormat = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 615 | |
| 616 | VkAttachmentDescription attachmentDescriptions[4] = {}; |
| 617 | // Color attachment |
| 618 | attachmentDescriptions[0].format = colorAndInputAttachmentFormat; |
| 619 | attachmentDescriptions[0].samples = VK_SAMPLE_COUNT_4_BIT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 620 | attachmentDescriptions[0].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 621 | attachmentDescriptions[0].finalLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 622 | // Color resolve attachment |
| 623 | attachmentDescriptions[1].format = colorAndInputAttachmentFormat; |
| 624 | attachmentDescriptions[1].samples = VK_SAMPLE_COUNT_1_BIT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 625 | attachmentDescriptions[1].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 626 | attachmentDescriptions[1].finalLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 627 | // Depth stencil attachment |
| 628 | attachmentDescriptions[2].format = depthStencilAttachmentFormat; |
| 629 | attachmentDescriptions[2].samples = VK_SAMPLE_COUNT_4_BIT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 630 | attachmentDescriptions[2].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 631 | attachmentDescriptions[2].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 632 | attachmentDescriptions[2].finalLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 633 | // Input attachment |
| 634 | attachmentDescriptions[3].format = colorAndInputAttachmentFormat; |
| 635 | attachmentDescriptions[3].samples = VK_SAMPLE_COUNT_1_BIT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 636 | attachmentDescriptions[3].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 637 | attachmentDescriptions[3].finalLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 638 | |
| 639 | VkAttachmentReference colorAttachmentReference = {}; |
| 640 | colorAttachmentReference.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 641 | colorAttachmentReference.attachment = 0; |
| 642 | VkAttachmentReference colorResolveAttachmentReference = {}; |
| 643 | colorResolveAttachmentReference.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 644 | colorResolveAttachmentReference.attachment = 1; |
| 645 | VkAttachmentReference depthStencilAttachmentReference = {}; |
| 646 | depthStencilAttachmentReference.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 647 | depthStencilAttachmentReference.attachment = 2; |
| 648 | VkAttachmentReference inputAttachmentReference = {}; |
| 649 | inputAttachmentReference.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 650 | inputAttachmentReference.attachment = 3; |
| 651 | VkSubpassDescription subpassDescription = {}; |
| 652 | subpassDescription.colorAttachmentCount = 1; |
| 653 | subpassDescription.pColorAttachments = &colorAttachmentReference; |
| 654 | subpassDescription.pResolveAttachments = &colorResolveAttachmentReference; |
| 655 | subpassDescription.pDepthStencilAttachment = &depthStencilAttachmentReference; |
| 656 | subpassDescription.inputAttachmentCount = 1; |
| 657 | subpassDescription.pInputAttachments = &inputAttachmentReference; |
| 658 | |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 659 | VkRenderPassCreateInfo renderPassCreateInfo = LvlInitStruct<VkRenderPassCreateInfo>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 660 | renderPassCreateInfo.attachmentCount = 4; |
| 661 | renderPassCreateInfo.subpassCount = 1; |
| 662 | renderPassCreateInfo.pSubpasses = &subpassDescription; |
| 663 | renderPassCreateInfo.pAttachments = attachmentDescriptions; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 664 | VkRenderPass renderPass; |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 665 | vk::CreateRenderPass(m_device->device(), &renderPassCreateInfo, nullptr, &renderPass); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 666 | |
| 667 | VkFramebufferAttachmentImageInfoKHR framebufferAttachmentImageInfos[4] = {}; |
| 668 | // Color attachment |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 669 | framebufferAttachmentImageInfos[0] = LvlInitStruct<VkFramebufferAttachmentImageInfoKHR>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 670 | framebufferAttachmentImageInfos[0].width = attachmentWidth; |
| 671 | framebufferAttachmentImageInfos[0].height = attachmentHeight; |
| 672 | framebufferAttachmentImageInfos[0].usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 673 | framebufferAttachmentImageInfos[0].layerCount = 1; |
| 674 | framebufferAttachmentImageInfos[0].viewFormatCount = 1; |
| 675 | framebufferAttachmentImageInfos[0].pViewFormats = &colorAndInputAttachmentFormat; |
| 676 | // Color resolve attachment |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 677 | framebufferAttachmentImageInfos[1] = LvlInitStruct<VkFramebufferAttachmentImageInfoKHR>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 678 | framebufferAttachmentImageInfos[1].width = attachmentWidth; |
| 679 | framebufferAttachmentImageInfos[1].height = attachmentHeight; |
| 680 | framebufferAttachmentImageInfos[1].usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 681 | framebufferAttachmentImageInfos[1].layerCount = 1; |
| 682 | framebufferAttachmentImageInfos[1].viewFormatCount = 1; |
| 683 | framebufferAttachmentImageInfos[1].pViewFormats = &colorAndInputAttachmentFormat; |
| 684 | // Depth stencil attachment |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 685 | framebufferAttachmentImageInfos[2] = LvlInitStruct<VkFramebufferAttachmentImageInfoKHR>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 686 | framebufferAttachmentImageInfos[2].width = attachmentWidth; |
| 687 | framebufferAttachmentImageInfos[2].height = attachmentHeight; |
| 688 | framebufferAttachmentImageInfos[2].usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 689 | framebufferAttachmentImageInfos[2].layerCount = 1; |
| 690 | framebufferAttachmentImageInfos[2].viewFormatCount = 1; |
| 691 | framebufferAttachmentImageInfos[2].pViewFormats = &depthStencilAttachmentFormat; |
| 692 | // Input attachment |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 693 | framebufferAttachmentImageInfos[3] = LvlInitStruct<VkFramebufferAttachmentImageInfoKHR>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 694 | framebufferAttachmentImageInfos[3].width = attachmentWidth; |
| 695 | framebufferAttachmentImageInfos[3].height = attachmentHeight; |
| 696 | framebufferAttachmentImageInfos[3].usage = VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT; |
| 697 | framebufferAttachmentImageInfos[3].layerCount = 1; |
| 698 | framebufferAttachmentImageInfos[3].viewFormatCount = 1; |
| 699 | framebufferAttachmentImageInfos[3].pViewFormats = &colorAndInputAttachmentFormat; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 700 | VkFramebufferAttachmentsCreateInfoKHR framebufferAttachmentsCreateInfo = LvlInitStruct<VkFramebufferAttachmentsCreateInfoKHR>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 701 | framebufferAttachmentsCreateInfo.attachmentImageInfoCount = 4; |
| 702 | framebufferAttachmentsCreateInfo.pAttachmentImageInfos = framebufferAttachmentImageInfos; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 703 | VkFramebufferCreateInfo framebufferCreateInfo = LvlInitStruct<VkFramebufferCreateInfo>(&framebufferAttachmentsCreateInfo); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 704 | framebufferCreateInfo.flags = VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR; |
| 705 | framebufferCreateInfo.width = attachmentWidth; |
| 706 | framebufferCreateInfo.height = attachmentHeight; |
| 707 | framebufferCreateInfo.layers = 1; |
| 708 | framebufferCreateInfo.renderPass = renderPass; |
| 709 | framebufferCreateInfo.attachmentCount = 4; |
| 710 | VkFramebuffer framebuffer = VK_NULL_HANDLE; |
| 711 | |
| 712 | // Color attachment, mismatched usage |
| 713 | framebufferAttachmentImageInfos[0].usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 714 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-flags-03201"); |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 715 | vk::CreateFramebuffer(m_device->device(), &framebufferCreateInfo, nullptr, &framebuffer); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 716 | m_errorMonitor->VerifyFound(); |
| 717 | if (framebuffer != VK_NULL_HANDLE) { |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 718 | vk::DestroyFramebuffer(m_device->device(), framebuffer, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 719 | } |
| 720 | framebufferAttachmentImageInfos[0].usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 721 | |
| 722 | // Color resolve attachment, mismatched usage |
| 723 | framebufferAttachmentImageInfos[1].usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 724 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-flags-03201"); |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 725 | vk::CreateFramebuffer(m_device->device(), &framebufferCreateInfo, nullptr, &framebuffer); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 726 | m_errorMonitor->VerifyFound(); |
| 727 | if (framebuffer != VK_NULL_HANDLE) { |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 728 | vk::DestroyFramebuffer(m_device->device(), framebuffer, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 729 | } |
| 730 | framebufferAttachmentImageInfos[1].usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 731 | |
| 732 | // Depth stencil attachment, mismatched usage |
| 733 | framebufferAttachmentImageInfos[2].usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 734 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-flags-03202"); |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 735 | vk::CreateFramebuffer(m_device->device(), &framebufferCreateInfo, nullptr, &framebuffer); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 736 | m_errorMonitor->VerifyFound(); |
| 737 | if (framebuffer != VK_NULL_HANDLE) { |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 738 | vk::DestroyFramebuffer(m_device->device(), framebuffer, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 739 | } |
| 740 | framebufferAttachmentImageInfos[2].usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 741 | |
| 742 | // Color attachment, mismatched usage |
| 743 | framebufferAttachmentImageInfos[3].usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 744 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-flags-03204"); |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 745 | vk::CreateFramebuffer(m_device->device(), &framebufferCreateInfo, nullptr, &framebuffer); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 746 | m_errorMonitor->VerifyFound(); |
| 747 | if (framebuffer != VK_NULL_HANDLE) { |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 748 | vk::DestroyFramebuffer(m_device->device(), framebuffer, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 749 | } |
| 750 | framebufferAttachmentImageInfos[3].usage = VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT; |
| 751 | |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 752 | vk::DestroyRenderPass(m_device->device(), renderPass, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 753 | } |
| 754 | |
| 755 | TEST_F(VkLayerTest, ImagelessFramebufferAttachmentMultiviewImageLayerCountMismatchTests) { |
| 756 | TEST_DESCRIPTION("Create an imageless framebuffer against a multiview-enabled render pass with mismatched layer counts"); |
| 757 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 758 | AddRequiredExtensions(VK_KHR_IMAGELESS_FRAMEBUFFER_EXTENSION_NAME); |
| 759 | AddRequiredExtensions(VK_KHR_MULTIVIEW_EXTENSION_NAME); |
Mark Lobodzinski | 09ce9c4 | 2020-03-06 10:02:44 -0700 | [diff] [blame] | 760 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 761 | if (!AreRequiredExtensionsEnabled()) { |
| 762 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported."; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 763 | } |
| 764 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 765 | auto mv_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeaturesKHR>(); |
| 766 | auto imageless_features = LvlInitStruct<VkPhysicalDeviceImagelessFramebufferFeaturesKHR>(&mv_features); |
| 767 | auto features2 = GetPhysicalDeviceFeatures2(imageless_features); |
| 768 | if (!imageless_features.imagelessFramebuffer) { |
| 769 | GTEST_SKIP() << "imagelessFramebuffer feature not supported."; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 770 | } |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 771 | if (!mv_features.multiview) { |
| 772 | GTEST_SKIP() << "multivew feature not supported."; |
| 773 | } |
| 774 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 775 | |
| 776 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 777 | |
| 778 | uint32_t attachmentWidth = 512; |
| 779 | uint32_t attachmentHeight = 512; |
| 780 | VkFormat colorAndInputAttachmentFormat = VK_FORMAT_R8G8B8A8_UNORM; |
| 781 | VkFormat depthStencilAttachmentFormat = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 782 | |
| 783 | VkAttachmentDescription attachmentDescriptions[4] = {}; |
| 784 | // Color attachment |
| 785 | attachmentDescriptions[0].format = colorAndInputAttachmentFormat; |
| 786 | attachmentDescriptions[0].samples = VK_SAMPLE_COUNT_4_BIT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 787 | attachmentDescriptions[0].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 788 | attachmentDescriptions[0].finalLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 789 | // Color resolve attachment |
| 790 | attachmentDescriptions[1].format = colorAndInputAttachmentFormat; |
| 791 | attachmentDescriptions[1].samples = VK_SAMPLE_COUNT_1_BIT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 792 | attachmentDescriptions[1].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 793 | attachmentDescriptions[1].finalLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 794 | // Depth stencil attachment |
| 795 | attachmentDescriptions[2].format = depthStencilAttachmentFormat; |
| 796 | attachmentDescriptions[2].samples = VK_SAMPLE_COUNT_4_BIT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 797 | attachmentDescriptions[2].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 798 | attachmentDescriptions[2].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 799 | attachmentDescriptions[2].finalLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 800 | // Input attachment |
| 801 | attachmentDescriptions[3].format = colorAndInputAttachmentFormat; |
| 802 | attachmentDescriptions[3].samples = VK_SAMPLE_COUNT_1_BIT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 803 | attachmentDescriptions[3].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 804 | attachmentDescriptions[3].finalLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 805 | |
| 806 | VkAttachmentReference colorAttachmentReference = {}; |
| 807 | colorAttachmentReference.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 808 | colorAttachmentReference.attachment = 0; |
| 809 | VkAttachmentReference colorResolveAttachmentReference = {}; |
| 810 | colorResolveAttachmentReference.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 811 | colorResolveAttachmentReference.attachment = 1; |
| 812 | VkAttachmentReference depthStencilAttachmentReference = {}; |
| 813 | depthStencilAttachmentReference.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 814 | depthStencilAttachmentReference.attachment = 2; |
| 815 | VkAttachmentReference inputAttachmentReference = {}; |
| 816 | inputAttachmentReference.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 817 | inputAttachmentReference.attachment = 3; |
| 818 | VkSubpassDescription subpassDescription = {}; |
| 819 | subpassDescription.colorAttachmentCount = 1; |
| 820 | subpassDescription.pColorAttachments = &colorAttachmentReference; |
| 821 | subpassDescription.pResolveAttachments = &colorResolveAttachmentReference; |
| 822 | subpassDescription.pDepthStencilAttachment = &depthStencilAttachmentReference; |
| 823 | subpassDescription.inputAttachmentCount = 1; |
| 824 | subpassDescription.pInputAttachments = &inputAttachmentReference; |
| 825 | |
| 826 | uint32_t viewMask = 0x3u; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 827 | VkRenderPassMultiviewCreateInfo renderPassMultiviewCreateInfo = LvlInitStruct<VkRenderPassMultiviewCreateInfo>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 828 | renderPassMultiviewCreateInfo.subpassCount = 1; |
| 829 | renderPassMultiviewCreateInfo.pViewMasks = &viewMask; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 830 | VkRenderPassCreateInfo renderPassCreateInfo = LvlInitStruct<VkRenderPassCreateInfo>(&renderPassMultiviewCreateInfo); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 831 | renderPassCreateInfo.attachmentCount = 4; |
| 832 | renderPassCreateInfo.subpassCount = 1; |
| 833 | renderPassCreateInfo.pSubpasses = &subpassDescription; |
| 834 | renderPassCreateInfo.pAttachments = attachmentDescriptions; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 835 | VkRenderPass renderPass; |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 836 | vk::CreateRenderPass(m_device->device(), &renderPassCreateInfo, nullptr, &renderPass); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 837 | |
| 838 | VkFramebufferAttachmentImageInfoKHR framebufferAttachmentImageInfos[4] = {}; |
| 839 | // Color attachment |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 840 | framebufferAttachmentImageInfos[0] = LvlInitStruct<VkFramebufferAttachmentImageInfoKHR>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 841 | framebufferAttachmentImageInfos[0].width = attachmentWidth; |
| 842 | framebufferAttachmentImageInfos[0].height = attachmentHeight; |
| 843 | framebufferAttachmentImageInfos[0].usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 844 | framebufferAttachmentImageInfos[0].layerCount = 2; |
| 845 | framebufferAttachmentImageInfos[0].viewFormatCount = 1; |
| 846 | framebufferAttachmentImageInfos[0].pViewFormats = &colorAndInputAttachmentFormat; |
| 847 | // Color resolve attachment |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 848 | framebufferAttachmentImageInfos[1] = LvlInitStruct<VkFramebufferAttachmentImageInfoKHR>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 849 | framebufferAttachmentImageInfos[1].width = attachmentWidth; |
| 850 | framebufferAttachmentImageInfos[1].height = attachmentHeight; |
| 851 | framebufferAttachmentImageInfos[1].usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 852 | framebufferAttachmentImageInfos[1].layerCount = 2; |
| 853 | framebufferAttachmentImageInfos[1].viewFormatCount = 1; |
| 854 | framebufferAttachmentImageInfos[1].pViewFormats = &colorAndInputAttachmentFormat; |
| 855 | // Depth stencil attachment |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 856 | framebufferAttachmentImageInfos[2] = LvlInitStruct<VkFramebufferAttachmentImageInfoKHR>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 857 | framebufferAttachmentImageInfos[2].width = attachmentWidth; |
| 858 | framebufferAttachmentImageInfos[2].height = attachmentHeight; |
| 859 | framebufferAttachmentImageInfos[2].usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 860 | framebufferAttachmentImageInfos[2].layerCount = 2; |
| 861 | framebufferAttachmentImageInfos[2].viewFormatCount = 1; |
| 862 | framebufferAttachmentImageInfos[2].pViewFormats = &depthStencilAttachmentFormat; |
| 863 | // Input attachment |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 864 | framebufferAttachmentImageInfos[3] = LvlInitStruct<VkFramebufferAttachmentImageInfoKHR>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 865 | framebufferAttachmentImageInfos[3].width = attachmentWidth; |
| 866 | framebufferAttachmentImageInfos[3].height = attachmentHeight; |
| 867 | framebufferAttachmentImageInfos[3].usage = VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT; |
| 868 | framebufferAttachmentImageInfos[3].layerCount = 2; |
| 869 | framebufferAttachmentImageInfos[3].viewFormatCount = 1; |
| 870 | framebufferAttachmentImageInfos[3].pViewFormats = &colorAndInputAttachmentFormat; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 871 | VkFramebufferAttachmentsCreateInfoKHR framebufferAttachmentsCreateInfo = LvlInitStruct<VkFramebufferAttachmentsCreateInfoKHR>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 872 | framebufferAttachmentsCreateInfo.attachmentImageInfoCount = 4; |
| 873 | framebufferAttachmentsCreateInfo.pAttachmentImageInfos = framebufferAttachmentImageInfos; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 874 | VkFramebufferCreateInfo framebufferCreateInfo = LvlInitStruct<VkFramebufferCreateInfo>(&framebufferAttachmentsCreateInfo); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 875 | framebufferCreateInfo.flags = VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR; |
| 876 | framebufferCreateInfo.width = attachmentWidth; |
| 877 | framebufferCreateInfo.height = attachmentHeight; |
| 878 | framebufferCreateInfo.layers = 1; |
| 879 | framebufferCreateInfo.renderPass = renderPass; |
| 880 | framebufferCreateInfo.attachmentCount = 4; |
| 881 | VkFramebuffer framebuffer = VK_NULL_HANDLE; |
| 882 | |
| 883 | // Color attachment, mismatched layer count |
| 884 | framebufferAttachmentImageInfos[0].layerCount = 1; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 885 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-renderPass-03198"); |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 886 | vk::CreateFramebuffer(m_device->device(), &framebufferCreateInfo, nullptr, &framebuffer); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 887 | m_errorMonitor->VerifyFound(); |
| 888 | if (framebuffer != VK_NULL_HANDLE) { |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 889 | vk::DestroyFramebuffer(m_device->device(), framebuffer, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 890 | } |
| 891 | framebufferAttachmentImageInfos[0].layerCount = 2; |
| 892 | |
| 893 | // Color resolve attachment, mismatched layer count |
| 894 | framebufferAttachmentImageInfos[1].layerCount = 1; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 895 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-renderPass-03198"); |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 896 | vk::CreateFramebuffer(m_device->device(), &framebufferCreateInfo, nullptr, &framebuffer); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 897 | m_errorMonitor->VerifyFound(); |
| 898 | if (framebuffer != VK_NULL_HANDLE) { |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 899 | vk::DestroyFramebuffer(m_device->device(), framebuffer, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 900 | } |
| 901 | framebufferAttachmentImageInfos[1].layerCount = 2; |
| 902 | |
| 903 | // Depth stencil attachment, mismatched layer count |
| 904 | framebufferAttachmentImageInfos[2].layerCount = 1; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 905 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-renderPass-03198"); |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 906 | vk::CreateFramebuffer(m_device->device(), &framebufferCreateInfo, nullptr, &framebuffer); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 907 | m_errorMonitor->VerifyFound(); |
| 908 | if (framebuffer != VK_NULL_HANDLE) { |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 909 | vk::DestroyFramebuffer(m_device->device(), framebuffer, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 910 | } |
| 911 | framebufferAttachmentImageInfos[2].layerCount = 2; |
| 912 | |
| 913 | // Input attachment, mismatched layer count |
| 914 | framebufferAttachmentImageInfos[3].layerCount = 1; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 915 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-renderPass-03198"); |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 916 | vk::CreateFramebuffer(m_device->device(), &framebufferCreateInfo, nullptr, &framebuffer); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 917 | m_errorMonitor->VerifyFound(); |
| 918 | if (framebuffer != VK_NULL_HANDLE) { |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 919 | vk::DestroyFramebuffer(m_device->device(), framebuffer, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 920 | } |
| 921 | framebufferAttachmentImageInfos[3].layerCount = 2; |
| 922 | |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 923 | vk::DestroyRenderPass(m_device->device(), renderPass, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 924 | } |
| 925 | |
| 926 | TEST_F(VkLayerTest, ImagelessFramebufferDepthStencilResolveAttachmentTests) { |
| 927 | TEST_DESCRIPTION( |
| 928 | "Create an imageless framebuffer against a render pass using depth stencil resolve, with mismatched information"); |
| 929 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 930 | AddRequiredExtensions(VK_KHR_IMAGELESS_FRAMEBUFFER_EXTENSION_NAME); |
| 931 | AddRequiredExtensions(VK_KHR_DEPTH_STENCIL_RESOLVE_EXTENSION_NAME); |
| 932 | AddRequiredExtensions(VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME); |
| 933 | AddRequiredExtensions(VK_KHR_MULTIVIEW_EXTENSION_NAME); |
| 934 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 935 | if (!AreRequiredExtensionsEnabled()) { |
| 936 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported."; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 937 | } |
| 938 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 939 | auto mv_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeaturesKHR>(); |
| 940 | auto imageless_features = LvlInitStruct<VkPhysicalDeviceImagelessFramebufferFeaturesKHR>(&mv_features); |
| 941 | auto features2 = GetPhysicalDeviceFeatures2(imageless_features); |
| 942 | if (!imageless_features.imagelessFramebuffer) { |
| 943 | GTEST_SKIP() << "imagelessFramebuffer feature not supported."; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 944 | } |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 945 | if (!mv_features.multiview) { |
| 946 | GTEST_SKIP() << "multiview feature not supported."; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 947 | } |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 948 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 949 | |
| 950 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 951 | |
| 952 | uint32_t attachmentWidth = 512; |
| 953 | uint32_t attachmentHeight = 512; |
sfricke-samsung | 31bdb2d | 2020-05-24 00:19:06 -0700 | [diff] [blame] | 954 | VkFormat attachmentFormat = FindSupportedDepthStencilFormat(gpu()); |
| 955 | if (attachmentFormat == VK_FORMAT_UNDEFINED) { |
| 956 | printf("%s Did not find a supported depth stencil format; skipped.\n", kSkipPrefix); |
| 957 | return; |
| 958 | } |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 959 | |
| 960 | VkAttachmentDescription2KHR attachmentDescriptions[2] = {}; |
| 961 | // Depth/stencil attachment |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 962 | attachmentDescriptions[0] = LvlInitStruct<VkAttachmentDescription2>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 963 | attachmentDescriptions[0].format = attachmentFormat; |
| 964 | attachmentDescriptions[0].samples = VK_SAMPLE_COUNT_4_BIT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 965 | attachmentDescriptions[0].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 966 | attachmentDescriptions[0].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 967 | attachmentDescriptions[0].finalLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 968 | // Depth/stencil resolve attachment |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 969 | attachmentDescriptions[1] = LvlInitStruct<VkAttachmentDescription2>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 970 | attachmentDescriptions[1].format = attachmentFormat; |
| 971 | attachmentDescriptions[1].samples = VK_SAMPLE_COUNT_1_BIT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 972 | attachmentDescriptions[1].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 973 | attachmentDescriptions[1].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 974 | attachmentDescriptions[1].finalLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 975 | |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 976 | VkAttachmentReference2KHR depthStencilAttachmentReference = LvlInitStruct<VkAttachmentReference2>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 977 | depthStencilAttachmentReference.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 978 | depthStencilAttachmentReference.attachment = 0; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 979 | VkAttachmentReference2KHR depthStencilResolveAttachmentReference = LvlInitStruct<VkAttachmentReference2>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 980 | depthStencilResolveAttachmentReference.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 981 | depthStencilResolveAttachmentReference.attachment = 1; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 982 | VkSubpassDescriptionDepthStencilResolveKHR subpassDescriptionDepthStencilResolve = |
| 983 | LvlInitStruct<VkSubpassDescriptionDepthStencilResolveKHR>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 984 | subpassDescriptionDepthStencilResolve.pDepthStencilResolveAttachment = &depthStencilResolveAttachmentReference; |
| 985 | subpassDescriptionDepthStencilResolve.depthResolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT_KHR; |
| 986 | subpassDescriptionDepthStencilResolve.stencilResolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT_KHR; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 987 | VkSubpassDescription2KHR subpassDescription = LvlInitStruct<VkSubpassDescription2>(&subpassDescriptionDepthStencilResolve); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 988 | subpassDescription.pDepthStencilAttachment = &depthStencilAttachmentReference; |
| 989 | subpassDescription.viewMask = 0x3u; |
| 990 | |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 991 | VkRenderPassCreateInfo2KHR renderPassCreateInfo = LvlInitStruct<VkRenderPassCreateInfo2>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 992 | renderPassCreateInfo.attachmentCount = 2; |
| 993 | renderPassCreateInfo.subpassCount = 1; |
| 994 | renderPassCreateInfo.pSubpasses = &subpassDescription; |
| 995 | renderPassCreateInfo.pAttachments = attachmentDescriptions; |
| 996 | VkRenderPass renderPass; |
| 997 | PFN_vkCreateRenderPass2KHR vkCreateRenderPass2KHR = |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 998 | (PFN_vkCreateRenderPass2KHR)vk::GetDeviceProcAddr(m_device->device(), "vkCreateRenderPass2KHR"); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 999 | vkCreateRenderPass2KHR(m_device->device(), &renderPassCreateInfo, nullptr, &renderPass); |
| 1000 | |
| 1001 | VkFramebufferAttachmentImageInfoKHR framebufferAttachmentImageInfos[2] = {}; |
| 1002 | // Depth/stencil attachment |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1003 | framebufferAttachmentImageInfos[0] = LvlInitStruct<VkFramebufferAttachmentImageInfoKHR>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 1004 | framebufferAttachmentImageInfos[0].width = attachmentWidth; |
| 1005 | framebufferAttachmentImageInfos[0].height = attachmentHeight; |
| 1006 | framebufferAttachmentImageInfos[0].usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 1007 | framebufferAttachmentImageInfos[0].layerCount = 2; |
| 1008 | framebufferAttachmentImageInfos[0].viewFormatCount = 1; |
| 1009 | framebufferAttachmentImageInfos[0].pViewFormats = &attachmentFormat; |
| 1010 | // Depth/stencil resolve attachment |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1011 | framebufferAttachmentImageInfos[1] = LvlInitStruct<VkFramebufferAttachmentImageInfoKHR>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 1012 | framebufferAttachmentImageInfos[1].width = attachmentWidth; |
| 1013 | framebufferAttachmentImageInfos[1].height = attachmentHeight; |
| 1014 | framebufferAttachmentImageInfos[1].usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 1015 | framebufferAttachmentImageInfos[1].layerCount = 2; |
| 1016 | framebufferAttachmentImageInfos[1].viewFormatCount = 1; |
| 1017 | framebufferAttachmentImageInfos[1].pViewFormats = &attachmentFormat; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1018 | VkFramebufferAttachmentsCreateInfoKHR framebufferAttachmentsCreateInfo = LvlInitStruct<VkFramebufferAttachmentsCreateInfoKHR>(); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 1019 | framebufferAttachmentsCreateInfo.attachmentImageInfoCount = 2; |
| 1020 | framebufferAttachmentsCreateInfo.pAttachmentImageInfos = framebufferAttachmentImageInfos; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1021 | VkFramebufferCreateInfo framebufferCreateInfo = LvlInitStruct<VkFramebufferCreateInfo>(&framebufferAttachmentsCreateInfo); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 1022 | framebufferCreateInfo.flags = VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR; |
| 1023 | framebufferCreateInfo.width = attachmentWidth; |
| 1024 | framebufferCreateInfo.height = attachmentHeight; |
| 1025 | framebufferCreateInfo.layers = 1; |
| 1026 | framebufferCreateInfo.renderPass = renderPass; |
| 1027 | framebufferCreateInfo.attachmentCount = 2; |
sfricke-samsung | 7aecc35 | 2020-04-23 22:49:47 -0700 | [diff] [blame] | 1028 | framebufferCreateInfo.pAttachments = nullptr; |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 1029 | VkFramebuffer framebuffer = VK_NULL_HANDLE; |
| 1030 | |
| 1031 | // Color attachment, mismatched layer count |
| 1032 | framebufferAttachmentImageInfos[0].layerCount = 1; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1033 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-renderPass-03198"); |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 1034 | vk::CreateFramebuffer(m_device->device(), &framebufferCreateInfo, nullptr, &framebuffer); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 1035 | m_errorMonitor->VerifyFound(); |
| 1036 | if (framebuffer != VK_NULL_HANDLE) { |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 1037 | vk::DestroyFramebuffer(m_device->device(), framebuffer, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 1038 | } |
| 1039 | framebufferAttachmentImageInfos[0].layerCount = 2; |
| 1040 | |
| 1041 | // Depth resolve attachment, mismatched image usage |
| 1042 | framebufferAttachmentImageInfos[1].usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1043 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-flags-03203"); |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 1044 | vk::CreateFramebuffer(m_device->device(), &framebufferCreateInfo, nullptr, &framebuffer); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 1045 | m_errorMonitor->VerifyFound(); |
| 1046 | if (framebuffer != VK_NULL_HANDLE) { |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 1047 | vk::DestroyFramebuffer(m_device->device(), framebuffer, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 1048 | } |
| 1049 | framebufferAttachmentImageInfos[1].usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 1050 | |
| 1051 | // Depth resolve attachment, mismatched layer count |
| 1052 | framebufferAttachmentImageInfos[1].layerCount = 1; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1053 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-renderPass-03198"); |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 1054 | vk::CreateFramebuffer(m_device->device(), &framebufferCreateInfo, nullptr, &framebuffer); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 1055 | m_errorMonitor->VerifyFound(); |
| 1056 | if (framebuffer != VK_NULL_HANDLE) { |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 1057 | vk::DestroyFramebuffer(m_device->device(), framebuffer, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 1058 | } |
| 1059 | framebufferAttachmentImageInfos[1].layerCount = 2; |
| 1060 | |
Mark Lobodzinski | 993b43e | 2019-09-27 14:54:40 -0600 | [diff] [blame] | 1061 | vk::DestroyRenderPass(m_device->device(), renderPass, nullptr); |
Tobias Hector | cf26efe | 2019-07-23 12:18:52 +0100 | [diff] [blame] | 1062 | } |
sfricke-samsung | c65e62b | 2020-11-01 08:48:24 -0800 | [diff] [blame] | 1063 | |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1064 | TEST_F(VkLayerTest, InvalidFragmentShadingRateImagelessFramebufferUsage) { |
| 1065 | TEST_DESCRIPTION("Specify a fragment shading rate attachment without the correct usage"); |
| 1066 | |
| 1067 | // Enable KHR_fragment_shading_rate and all of its required extensions |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1068 | AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
| 1069 | AddRequiredExtensions(VK_KHR_IMAGELESS_FRAMEBUFFER_EXTENSION_NAME); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1070 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1071 | if (!AreRequiredExtensionsEnabled()) { |
| 1072 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported."; |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1073 | } |
| 1074 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1075 | auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>(); |
| 1076 | GetPhysicalDeviceProperties2(fsr_properties); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1077 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1078 | auto if_features = LvlInitStruct<VkPhysicalDeviceImagelessFramebufferFeatures>(); |
| 1079 | auto fsr_features = LvlInitStruct<VkPhysicalDeviceFragmentShadingRateFeaturesKHR>(&if_features); |
| 1080 | auto features2 = GetPhysicalDeviceFeatures2(fsr_features); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1081 | |
| 1082 | if (fsr_features.attachmentFragmentShadingRate != VK_TRUE) { |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1083 | GTEST_SKIP() << "requires attachmentFragmentShadingRate feature"; |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1084 | } |
| 1085 | |
| 1086 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 1087 | |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1088 | VkAttachmentReference2 attach = LvlInitStruct<VkAttachmentReference2>(); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1089 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 1090 | attach.attachment = 0; |
| 1091 | |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1092 | VkFragmentShadingRateAttachmentInfoKHR fsr_attachment = LvlInitStruct<VkFragmentShadingRateAttachmentInfoKHR>(); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1093 | fsr_attachment.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize; |
| 1094 | fsr_attachment.pFragmentShadingRateAttachment = &attach; |
| 1095 | |
| 1096 | // Create a renderPass with a single fsr attachment |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1097 | VkSubpassDescription2 subpass = LvlInitStruct<VkSubpassDescription2>(&fsr_attachment); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1098 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1099 | auto attach_desc = LvlInitStruct<VkAttachmentDescription2>(); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1100 | attach_desc.format = VK_FORMAT_R8_UINT; |
| 1101 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1102 | attach_desc.initialLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 1103 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 1104 | |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1105 | VkRenderPassCreateInfo2 rpci = LvlInitStruct<VkRenderPassCreateInfo2>(); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1106 | rpci.subpassCount = 1; |
| 1107 | rpci.pSubpasses = &subpass; |
| 1108 | rpci.attachmentCount = 1; |
| 1109 | rpci.pAttachments = &attach_desc; |
| 1110 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1111 | vk_testing::RenderPass rp(*m_device, rpci, true); |
| 1112 | ASSERT_TRUE(rp.initialized()); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1113 | |
| 1114 | VkFormat viewFormat = VK_FORMAT_R8_UINT; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1115 | VkFramebufferAttachmentImageInfo fbai_info = LvlInitStruct<VkFramebufferAttachmentImageInfo>(); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1116 | fbai_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 1117 | fbai_info.width = 1; |
| 1118 | fbai_info.height = 1; |
| 1119 | fbai_info.layerCount = 1; |
| 1120 | fbai_info.viewFormatCount = 1; |
| 1121 | fbai_info.pViewFormats = &viewFormat; |
| 1122 | |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1123 | VkFramebufferAttachmentsCreateInfo fba_info = LvlInitStruct<VkFramebufferAttachmentsCreateInfo>(); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1124 | fba_info.attachmentImageInfoCount = 1; |
| 1125 | fba_info.pAttachmentImageInfos = &fbai_info; |
| 1126 | |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1127 | VkFramebufferCreateInfo fb_info = LvlInitStruct<VkFramebufferCreateInfo>(&fba_info); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1128 | fb_info.flags = VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1129 | fb_info.renderPass = rp.handle(); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1130 | fb_info.attachmentCount = 1; |
| 1131 | fb_info.pAttachments = NULL; |
| 1132 | fb_info.width = fsr_properties.minFragmentShadingRateAttachmentTexelSize.width; |
| 1133 | fb_info.height = fsr_properties.minFragmentShadingRateAttachmentTexelSize.height; |
| 1134 | fb_info.layers = 1; |
| 1135 | |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1136 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-flags-04549"); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1137 | vk_testing::Framebuffer fb(*m_device, fb_info); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1138 | m_errorMonitor->VerifyFound(); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1139 | } |
| 1140 | |
| 1141 | TEST_F(VkLayerTest, InvalidFragmentShadingRateImagelessFramebufferDimensions) { |
| 1142 | TEST_DESCRIPTION("Specify a fragment shading rate attachment without the correct usage"); |
| 1143 | |
| 1144 | // Enable KHR_fragment_shading_rate and all of its required extensions |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1145 | AddRequiredExtensions(VK_KHR_IMAGELESS_FRAMEBUFFER_EXTENSION_NAME); |
| 1146 | AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
| 1147 | AddOptionalExtensions(VK_KHR_MULTIVIEW_EXTENSION_NAME); |
| 1148 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 1149 | if (!AreRequiredExtensionsEnabled()) { |
| 1150 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported."; |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1151 | } |
| 1152 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1153 | auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>(); |
| 1154 | GetPhysicalDeviceProperties2(fsr_properties); |
| 1155 | |
| 1156 | auto mv_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeaturesKHR>(); |
| 1157 | auto if_features = LvlInitStruct<VkPhysicalDeviceImagelessFramebufferFeatures>(); |
| 1158 | if (IsExtensionsEnabled(VK_KHR_MULTIVIEW_EXTENSION_NAME)) { |
| 1159 | if_features.pNext = &mv_features; |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1160 | } |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1161 | auto fsr_features = LvlInitStruct<VkPhysicalDeviceFragmentShadingRateFeaturesKHR>(&if_features); |
| 1162 | auto features2 = GetPhysicalDeviceFeatures2(fsr_features); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1163 | |
| 1164 | if (fsr_features.attachmentFragmentShadingRate != VK_TRUE) { |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1165 | GTEST_SKIP() << "attachmentFragmentShadingRate feature not supported"; |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1166 | } |
| 1167 | |
| 1168 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 1169 | |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1170 | VkAttachmentReference2 attach = LvlInitStruct<VkAttachmentReference2>(); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1171 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 1172 | attach.attachment = 0; |
| 1173 | |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1174 | VkFragmentShadingRateAttachmentInfoKHR fsr_attachment = LvlInitStruct<VkFragmentShadingRateAttachmentInfoKHR>(); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1175 | fsr_attachment.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize; |
| 1176 | fsr_attachment.pFragmentShadingRateAttachment = &attach; |
| 1177 | |
| 1178 | // Create a renderPass with a single fsr attachment |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1179 | VkSubpassDescription2 subpass = LvlInitStruct<VkSubpassDescription2>(&fsr_attachment); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1180 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1181 | auto attach_desc = LvlInitStruct<VkAttachmentDescription2>(); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1182 | attach_desc.format = VK_FORMAT_R8_UINT; |
| 1183 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1184 | attach_desc.initialLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 1185 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 1186 | |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1187 | VkRenderPassCreateInfo2 rpci = LvlInitStruct<VkRenderPassCreateInfo2>(); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1188 | rpci.subpassCount = 1; |
| 1189 | rpci.pSubpasses = &subpass; |
| 1190 | rpci.attachmentCount = 1; |
| 1191 | rpci.pAttachments = &attach_desc; |
| 1192 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1193 | vk_testing::RenderPass rp(*m_device, rpci, true); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1194 | |
| 1195 | VkFormat viewFormat = VK_FORMAT_R8_UINT; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1196 | VkFramebufferAttachmentImageInfo fbai_info = LvlInitStruct<VkFramebufferAttachmentImageInfo>(); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1197 | fbai_info.usage = VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR; |
| 1198 | fbai_info.width = 1; |
| 1199 | fbai_info.height = 1; |
| 1200 | fbai_info.layerCount = 1; |
| 1201 | fbai_info.viewFormatCount = 1; |
| 1202 | fbai_info.pViewFormats = &viewFormat; |
| 1203 | |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1204 | VkFramebufferAttachmentsCreateInfo fba_info = LvlInitStruct<VkFramebufferAttachmentsCreateInfo>(); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1205 | fba_info.attachmentImageInfoCount = 1; |
| 1206 | fba_info.pAttachmentImageInfos = &fbai_info; |
| 1207 | |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1208 | VkFramebufferCreateInfo fb_info = LvlInitStruct<VkFramebufferCreateInfo>(&fba_info); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1209 | fb_info.flags = VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1210 | fb_info.renderPass = rp.handle(); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1211 | fb_info.attachmentCount = 1; |
| 1212 | fb_info.pAttachments = NULL; |
| 1213 | fb_info.width = fsr_properties.minFragmentShadingRateAttachmentTexelSize.width; |
| 1214 | fb_info.height = fsr_properties.minFragmentShadingRateAttachmentTexelSize.height; |
| 1215 | fb_info.layers = 1; |
| 1216 | |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1217 | fb_info.width = fsr_properties.minFragmentShadingRateAttachmentTexelSize.width * 2; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1218 | { |
| 1219 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-flags-04543"); |
| 1220 | vk_testing::Framebuffer fb(*m_device, fb_info); |
| 1221 | m_errorMonitor->VerifyFound(); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1222 | } |
| 1223 | fb_info.width = fsr_properties.minFragmentShadingRateAttachmentTexelSize.width; |
| 1224 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1225 | { |
| 1226 | fb_info.height = fsr_properties.minFragmentShadingRateAttachmentTexelSize.height * 2; |
| 1227 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-flags-04544"); |
| 1228 | vk_testing::Framebuffer fb(*m_device, fb_info); |
| 1229 | m_errorMonitor->VerifyFound(); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1230 | } |
| 1231 | fb_info.height = fsr_properties.minFragmentShadingRateAttachmentTexelSize.height; |
| 1232 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1233 | { |
| 1234 | fbai_info.layerCount = 2; |
| 1235 | fb_info.layers = 3; |
| 1236 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-flags-04545"); |
| 1237 | vk_testing::Framebuffer fb(*m_device, fb_info); |
| 1238 | m_errorMonitor->VerifyFound(); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1239 | } |
| 1240 | fb_info.layers = 1; |
| 1241 | fbai_info.layerCount = 1; |
| 1242 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1243 | if (fsr_properties.layeredShadingRateAttachments && mv_features.multiview) { |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1244 | subpass.viewMask = 0x4; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1245 | vk_testing::RenderPass rp2(*m_device, rpci, true); |
| 1246 | ASSERT_TRUE(rp2.initialized()); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1247 | subpass.viewMask = 0; |
| 1248 | |
| 1249 | fbai_info.layerCount = 2; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1250 | fb_info.renderPass = rp2.handle(); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1251 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, kVUIDUndefined); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1252 | vk_testing::Framebuffer fb(*m_device, fb_info); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1253 | m_errorMonitor->VerifyFound(); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 1254 | } |
| 1255 | } |
| 1256 | |
sfricke-samsung | c65e62b | 2020-11-01 08:48:24 -0800 | [diff] [blame] | 1257 | TEST_F(VkLayerTest, ImagelessFramebufferRenderPassBeginImageView3D) { |
| 1258 | TEST_DESCRIPTION("Misuse of VK_IMAGE_VIEW_TYPE_3D."); |
| 1259 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1260 | AddRequiredExtensions(VK_KHR_IMAGELESS_FRAMEBUFFER_EXTENSION_NAME); |
| 1261 | AddOptionalExtensions(VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME); |
| 1262 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 1263 | if (!AreRequiredExtensionsEnabled()) { |
| 1264 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported."; |
| 1265 | } |
| 1266 | bool rp2Supported = IsExtensionsEnabled(VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME); |
| 1267 | |
| 1268 | auto imageless_features = LvlInitStruct<VkPhysicalDeviceImagelessFramebufferFeaturesKHR>(); |
| 1269 | auto features2 = GetPhysicalDeviceFeatures2(imageless_features); |
| 1270 | if (!imageless_features.imagelessFramebuffer) { |
| 1271 | GTEST_SKIP() << "imagelessFramebuffer feature not supported."; |
sfricke-samsung | c65e62b | 2020-11-01 08:48:24 -0800 | [diff] [blame] | 1272 | } |
| 1273 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1274 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
sfricke-samsung | c65e62b | 2020-11-01 08:48:24 -0800 | [diff] [blame] | 1275 | uint32_t attachmentWidth = 512; |
| 1276 | uint32_t attachmentHeight = 512; |
| 1277 | VkFormat attachmentFormats[1] = {VK_FORMAT_R8G8B8A8_UNORM}; |
| 1278 | VkFormat framebufferAttachmentFormats[1] = {VK_FORMAT_R8G8B8A8_UNORM}; |
| 1279 | |
| 1280 | // Create a renderPass with a single attachment |
| 1281 | VkAttachmentDescription attachmentDescription = {}; |
| 1282 | attachmentDescription.format = attachmentFormats[0]; |
| 1283 | attachmentDescription.samples = VK_SAMPLE_COUNT_1_BIT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1284 | attachmentDescription.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
sfricke-samsung | c65e62b | 2020-11-01 08:48:24 -0800 | [diff] [blame] | 1285 | attachmentDescription.finalLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 1286 | VkAttachmentReference attachmentReference = {}; |
| 1287 | attachmentReference.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 1288 | VkSubpassDescription subpassDescription = {}; |
| 1289 | subpassDescription.colorAttachmentCount = 1; |
| 1290 | subpassDescription.pColorAttachments = &attachmentReference; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1291 | VkRenderPassCreateInfo renderPassCreateInfo = LvlInitStruct<VkRenderPassCreateInfo>(); |
sfricke-samsung | c65e62b | 2020-11-01 08:48:24 -0800 | [diff] [blame] | 1292 | renderPassCreateInfo.subpassCount = 1; |
| 1293 | renderPassCreateInfo.pSubpasses = &subpassDescription; |
| 1294 | renderPassCreateInfo.attachmentCount = 1; |
| 1295 | renderPassCreateInfo.pAttachments = &attachmentDescription; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1296 | vk_testing::RenderPass renderPass(*m_device, renderPassCreateInfo); |
| 1297 | ASSERT_TRUE(renderPass.initialized()); |
sfricke-samsung | c65e62b | 2020-11-01 08:48:24 -0800 | [diff] [blame] | 1298 | |
| 1299 | // Create Attachments |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1300 | VkImageCreateInfo imageCreateInfo = LvlInitStruct<VkImageCreateInfo>(); |
sfricke-samsung | c65e62b | 2020-11-01 08:48:24 -0800 | [diff] [blame] | 1301 | imageCreateInfo.flags = 0; |
| 1302 | imageCreateInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 1303 | imageCreateInfo.extent.width = attachmentWidth; |
| 1304 | imageCreateInfo.extent.height = attachmentHeight; |
| 1305 | imageCreateInfo.extent.depth = 1; |
| 1306 | imageCreateInfo.arrayLayers = 1; |
| 1307 | imageCreateInfo.mipLevels = 1; |
| 1308 | imageCreateInfo.imageType = VK_IMAGE_TYPE_3D; |
| 1309 | imageCreateInfo.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1310 | imageCreateInfo.format = attachmentFormats[0]; |
| 1311 | |
| 1312 | VkImageObj image3D(m_device); |
| 1313 | image3D.init(&imageCreateInfo); |
| 1314 | |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1315 | VkImageViewCreateInfo imageViewCreateInfo = LvlInitStruct<VkImageViewCreateInfo>(); |
sfricke-samsung | c65e62b | 2020-11-01 08:48:24 -0800 | [diff] [blame] | 1316 | imageViewCreateInfo.viewType = VK_IMAGE_VIEW_TYPE_3D; |
| 1317 | imageViewCreateInfo.format = attachmentFormats[0]; |
| 1318 | imageViewCreateInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 1319 | imageViewCreateInfo.subresourceRange.baseMipLevel = 0; |
| 1320 | imageViewCreateInfo.subresourceRange.levelCount = 1; |
| 1321 | imageViewCreateInfo.subresourceRange.baseArrayLayer = 0; |
| 1322 | imageViewCreateInfo.subresourceRange.layerCount = 1; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1323 | VkImageView imageView3D = image3D.targetView(imageViewCreateInfo); |
sfricke-samsung | c65e62b | 2020-11-01 08:48:24 -0800 | [diff] [blame] | 1324 | |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1325 | VkFramebufferAttachmentImageInfoKHR framebufferAttachmentImageInfo = LvlInitStruct<VkFramebufferAttachmentImageInfoKHR>(); |
sfricke-samsung | c65e62b | 2020-11-01 08:48:24 -0800 | [diff] [blame] | 1326 | framebufferAttachmentImageInfo.flags = 0; |
| 1327 | framebufferAttachmentImageInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 1328 | framebufferAttachmentImageInfo.width = attachmentWidth; |
| 1329 | framebufferAttachmentImageInfo.height = attachmentHeight; |
| 1330 | framebufferAttachmentImageInfo.layerCount = 1; |
| 1331 | framebufferAttachmentImageInfo.viewFormatCount = 1; |
| 1332 | framebufferAttachmentImageInfo.pViewFormats = framebufferAttachmentFormats; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1333 | VkFramebufferAttachmentsCreateInfoKHR framebufferAttachmentsCreateInfo = LvlInitStruct<VkFramebufferAttachmentsCreateInfoKHR>(); |
sfricke-samsung | c65e62b | 2020-11-01 08:48:24 -0800 | [diff] [blame] | 1334 | framebufferAttachmentsCreateInfo.attachmentImageInfoCount = 1; |
| 1335 | framebufferAttachmentsCreateInfo.pAttachmentImageInfos = &framebufferAttachmentImageInfo; |
| 1336 | |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1337 | VkFramebufferCreateInfo framebufferCreateInfo = LvlInitStruct<VkFramebufferCreateInfo>(); |
sfricke-samsung | c65e62b | 2020-11-01 08:48:24 -0800 | [diff] [blame] | 1338 | framebufferCreateInfo.width = attachmentWidth; |
| 1339 | framebufferCreateInfo.height = attachmentHeight; |
| 1340 | framebufferCreateInfo.layers = 1; |
| 1341 | framebufferCreateInfo.attachmentCount = 1; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1342 | framebufferCreateInfo.renderPass = renderPass.handle(); |
sfricke-samsung | c65e62b | 2020-11-01 08:48:24 -0800 | [diff] [blame] | 1343 | |
| 1344 | // Try to use 3D Image View without imageless flag |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1345 | { |
| 1346 | framebufferCreateInfo.pNext = nullptr; |
| 1347 | framebufferCreateInfo.flags = 0; |
| 1348 | framebufferCreateInfo.pAttachments = &imageView3D; |
| 1349 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-flags-04113"); |
| 1350 | vk_testing::Framebuffer framebuffer(*m_device, framebufferCreateInfo); |
| 1351 | m_errorMonitor->VerifyFound(); |
| 1352 | } |
sfricke-samsung | c65e62b | 2020-11-01 08:48:24 -0800 | [diff] [blame] | 1353 | |
| 1354 | framebufferCreateInfo.pNext = &framebufferAttachmentsCreateInfo; |
| 1355 | framebufferCreateInfo.flags = VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR; |
| 1356 | framebufferCreateInfo.pAttachments = nullptr; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1357 | vk_testing::Framebuffer framebuffer(*m_device, framebufferCreateInfo); |
| 1358 | ASSERT_TRUE(framebuffer.initialized()); |
sfricke-samsung | c65e62b | 2020-11-01 08:48:24 -0800 | [diff] [blame] | 1359 | |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1360 | VkRenderPassAttachmentBeginInfoKHR renderPassAttachmentBeginInfo = LvlInitStruct<VkRenderPassAttachmentBeginInfo>(); |
sfricke-samsung | c65e62b | 2020-11-01 08:48:24 -0800 | [diff] [blame] | 1361 | renderPassAttachmentBeginInfo.attachmentCount = 1; |
| 1362 | renderPassAttachmentBeginInfo.pAttachments = &imageView3D; |
sfricke-samsung | 4385fd0 | 2021-12-31 01:55:03 -0600 | [diff] [blame] | 1363 | VkRenderPassBeginInfo renderPassBeginInfo = LvlInitStruct<VkRenderPassBeginInfo>(&renderPassAttachmentBeginInfo); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1364 | renderPassBeginInfo.renderPass = renderPass.handle(); |
sfricke-samsung | c65e62b | 2020-11-01 08:48:24 -0800 | [diff] [blame] | 1365 | renderPassBeginInfo.renderArea.extent.width = attachmentWidth; |
| 1366 | renderPassBeginInfo.renderArea.extent.height = attachmentHeight; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1367 | renderPassBeginInfo.framebuffer = framebuffer.handle(); |
sfricke-samsung | c65e62b | 2020-11-01 08:48:24 -0800 | [diff] [blame] | 1368 | |
| 1369 | // Try to use 3D Image View with imageless flag |
| 1370 | TestRenderPassBegin(m_errorMonitor, m_device->device(), m_commandBuffer->handle(), &renderPassBeginInfo, rp2Supported, |
| 1371 | "VUID-VkRenderPassAttachmentBeginInfo-pAttachments-04114", |
| 1372 | "VUID-VkRenderPassAttachmentBeginInfo-pAttachments-04114"); |
sfricke-samsung | c65e62b | 2020-11-01 08:48:24 -0800 | [diff] [blame] | 1373 | } |
ziga-lunarg | 91a9064 | 2021-07-29 13:25:07 +0200 | [diff] [blame] | 1374 | |
| 1375 | TEST_F(VkLayerTest, FramebufferAttachmentImageInfoPNext) { |
| 1376 | TEST_DESCRIPTION("Begin render pass with missing framebuffer attachment"); |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 1377 | AddRequiredExtensions(VK_KHR_IMAGELESS_FRAMEBUFFER_EXTENSION_NAME); |
ziga-lunarg | 91a9064 | 2021-07-29 13:25:07 +0200 | [diff] [blame] | 1378 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1379 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 1380 | if (!AreRequiredExtensionsEnabled()) { |
| 1381 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 91a9064 | 2021-07-29 13:25:07 +0200 | [diff] [blame] | 1382 | } |
ziga-lunarg | 91a9064 | 2021-07-29 13:25:07 +0200 | [diff] [blame] | 1383 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1384 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1385 | |
| 1386 | VkFormat attachment_format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1387 | VkFramebufferAttachmentImageInfo fb_fdm = LvlInitStruct<VkFramebufferAttachmentImageInfo>(); |
| 1388 | fb_fdm.pNext = &fb_fdm; |
| 1389 | fb_fdm.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1390 | fb_fdm.width = 64; |
| 1391 | fb_fdm.height = 64; |
| 1392 | fb_fdm.layerCount = 1; |
| 1393 | fb_fdm.viewFormatCount = 1; |
| 1394 | fb_fdm.pViewFormats = &attachment_format; |
| 1395 | |
| 1396 | VkFramebufferAttachmentsCreateInfo fb_aci_fdm = LvlInitStruct<VkFramebufferAttachmentsCreateInfo>(); |
| 1397 | fb_aci_fdm.attachmentImageInfoCount = 1; |
| 1398 | fb_aci_fdm.pAttachmentImageInfos = &fb_fdm; |
| 1399 | |
| 1400 | VkFramebufferCreateInfo framebufferCreateInfo = LvlInitStruct<VkFramebufferCreateInfo>(&fb_aci_fdm); |
| 1401 | framebufferCreateInfo.width = 64; |
| 1402 | framebufferCreateInfo.height = 64; |
| 1403 | framebufferCreateInfo.layers = 1; |
| 1404 | framebufferCreateInfo.renderPass = m_renderPass; |
| 1405 | framebufferCreateInfo.attachmentCount = static_cast<uint32_t>(m_framebuffer_attachments.size()); |
| 1406 | framebufferCreateInfo.pAttachments = m_framebuffer_attachments.data(); |
| 1407 | |
ziga-lunarg | 91a9064 | 2021-07-29 13:25:07 +0200 | [diff] [blame] | 1408 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferAttachmentImageInfo-pNext-pNext"); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1409 | vk_testing::Framebuffer framebuffer(*m_device, framebufferCreateInfo); |
ziga-lunarg | 91a9064 | 2021-07-29 13:25:07 +0200 | [diff] [blame] | 1410 | m_errorMonitor->VerifyFound(); |
| 1411 | } |
ziga-lunarg | 69bbdef | 2021-08-01 17:52:16 +0200 | [diff] [blame] | 1412 | |
| 1413 | TEST_F(VkLayerTest, DescriptorUpdateTemplateEntryWithInlineUniformBlock) { |
| 1414 | TEST_DESCRIPTION("Test VkDescriptorUpdateTemplateEntry with descriptor type VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT"); |
| 1415 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1416 | AddRequiredExtensions(VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_EXTENSION_NAME); |
| 1417 | AddRequiredExtensions(VK_EXT_INLINE_UNIFORM_BLOCK_EXTENSION_NAME); |
| 1418 | AddRequiredExtensions(VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); |
Nathaniel Cesario | b3f17dc | 2021-08-17 12:52:22 -0600 | [diff] [blame] | 1419 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1420 | if (!AreRequiredExtensionsEnabled()) { |
| 1421 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported."; |
ziga-lunarg | 69bbdef | 2021-08-01 17:52:16 +0200 | [diff] [blame] | 1422 | } |
ziga-lunarg | 69bbdef | 2021-08-01 17:52:16 +0200 | [diff] [blame] | 1423 | |
| 1424 | // Note: Includes workaround for some implementations which incorrectly return 0 maxPushDescriptors |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1425 | auto push_descriptor_prop = LvlInitStruct<VkPhysicalDevicePushDescriptorPropertiesKHR>(); |
| 1426 | GetPhysicalDeviceProperties2(push_descriptor_prop); |
| 1427 | if (push_descriptor_prop.maxPushDescriptors < 1) { |
| 1428 | GTEST_SKIP() << "maxPushDescriptors < 1, push descriptor cases skipped."; |
ziga-lunarg | 69bbdef | 2021-08-01 17:52:16 +0200 | [diff] [blame] | 1429 | } |
| 1430 | |
| 1431 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, nullptr, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
| 1432 | |
| 1433 | std::vector<VkDescriptorSetLayoutBinding> ds_bindings = { |
| 1434 | {0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_ALL, nullptr}}; |
| 1435 | OneOffDescriptorSet descriptor_set(m_device, ds_bindings); |
| 1436 | |
| 1437 | // Create a buffer to be used for invalid updates |
| 1438 | VkBufferCreateInfo buff_ci = LvlInitStruct<VkBufferCreateInfo>(); |
| 1439 | buff_ci.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1440 | buff_ci.size = m_device->props.limits.minUniformBufferOffsetAlignment; |
| 1441 | buff_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1442 | VkBufferObj buffer; |
| 1443 | buffer.init(*m_device, buff_ci); |
| 1444 | |
| 1445 | // Relying on the "return nullptr for non-enabled extensions |
| 1446 | auto vkCreateDescriptorUpdateTemplateKHR = |
| 1447 | (PFN_vkCreateDescriptorUpdateTemplateKHR)vk::GetDeviceProcAddr(m_device->device(), "vkCreateDescriptorUpdateTemplateKHR"); |
| 1448 | auto vkDestroyDescriptorUpdateTemplateKHR = |
| 1449 | (PFN_vkDestroyDescriptorUpdateTemplateKHR)vk::GetDeviceProcAddr(m_device->device(), "vkDestroyDescriptorUpdateTemplateKHR"); |
| 1450 | auto vkUpdateDescriptorSetWithTemplateKHR = |
| 1451 | (PFN_vkUpdateDescriptorSetWithTemplateKHR)vk::GetDeviceProcAddr(m_device->device(), "vkUpdateDescriptorSetWithTemplateKHR"); |
| 1452 | |
| 1453 | ASSERT_NE(vkCreateDescriptorUpdateTemplateKHR, nullptr); |
| 1454 | ASSERT_NE(vkDestroyDescriptorUpdateTemplateKHR, nullptr); |
| 1455 | ASSERT_NE(vkUpdateDescriptorSetWithTemplateKHR, nullptr); |
| 1456 | |
| 1457 | struct SimpleTemplateData { |
| 1458 | VkDescriptorBufferInfo buff_info; |
| 1459 | }; |
| 1460 | |
| 1461 | VkDescriptorUpdateTemplateEntry update_template_entry = {}; |
| 1462 | update_template_entry.dstBinding = 0; |
| 1463 | update_template_entry.dstArrayElement = 2; |
| 1464 | update_template_entry.descriptorCount = 1; |
| 1465 | update_template_entry.descriptorType = VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT; |
| 1466 | update_template_entry.offset = offsetof(SimpleTemplateData, buff_info); |
| 1467 | update_template_entry.stride = sizeof(SimpleTemplateData); |
| 1468 | |
| 1469 | auto update_template_ci = LvlInitStruct<VkDescriptorUpdateTemplateCreateInfoKHR>(); |
| 1470 | update_template_ci.descriptorUpdateEntryCount = 1; |
| 1471 | update_template_ci.pDescriptorUpdateEntries = &update_template_entry; |
| 1472 | update_template_ci.templateType = VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET; |
| 1473 | update_template_ci.descriptorSetLayout = descriptor_set.layout_.handle(); |
| 1474 | |
| 1475 | VkDescriptorUpdateTemplate update_template = VK_NULL_HANDLE; |
| 1476 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkDescriptorUpdateTemplateEntry-descriptor-02226"); |
| 1477 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkDescriptorUpdateTemplateEntry-descriptor-02227"); |
| 1478 | vkCreateDescriptorUpdateTemplateKHR(m_device->device(), &update_template_ci, nullptr, &update_template); |
| 1479 | m_errorMonitor->VerifyFound(); |
| 1480 | } |
ziga-lunarg | f1ea8fb | 2021-08-05 22:54:52 +0200 | [diff] [blame] | 1481 | |
| 1482 | TEST_F(VkLayerTest, RenderPassCreateFragmentDensityMapReferenceToInvalidAttachment) { |
| 1483 | TEST_DESCRIPTION( |
| 1484 | "Test creating a framebuffer with fragment density map reference to an attachment with layer count different from 1"); |
| 1485 | |
Luc Charbonneau | e48b02d | 2022-01-11 17:17:44 -0500 | [diff] [blame] | 1486 | SetTargetApiVersion(VK_API_VERSION_1_0); |
| 1487 | |
ziga-lunarg | f1ea8fb | 2021-08-05 22:54:52 +0200 | [diff] [blame] | 1488 | if (!InstanceExtensionSupported(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME)) { |
| 1489 | return; |
| 1490 | } |
| 1491 | m_instance_extension_names.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 1492 | |
| 1493 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 1494 | if (!DeviceExtensionSupported(gpu(), nullptr, VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME)) { |
| 1495 | printf("%s %s extension not supported skipped.\n", kSkipPrefix, VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 1496 | return; |
| 1497 | } |
Luc Charbonneau | e48b02d | 2022-01-11 17:17:44 -0500 | [diff] [blame] | 1498 | |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 1499 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 1500 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
Luc Charbonneau | e48b02d | 2022-01-11 17:17:44 -0500 | [diff] [blame] | 1501 | } |
| 1502 | |
ziga-lunarg | f1ea8fb | 2021-08-05 22:54:52 +0200 | [diff] [blame] | 1503 | m_device_extension_names.push_back(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME); |
| 1504 | VkPhysicalDeviceFragmentDensityMapFeaturesEXT fdm_features = LvlInitStruct<VkPhysicalDeviceFragmentDensityMapFeaturesEXT>(); |
| 1505 | VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&fdm_features); |
| 1506 | fdm_features.fragmentDensityMap = true; |
| 1507 | |
| 1508 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, 0)); |
| 1509 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1510 | |
| 1511 | VkAttachmentReference ref; |
| 1512 | ref.attachment = 0; |
| 1513 | ref.layout = VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT; |
| 1514 | VkRenderPassFragmentDensityMapCreateInfoEXT rpfdmi = LvlInitStruct<VkRenderPassFragmentDensityMapCreateInfoEXT>(); |
| 1515 | rpfdmi.fragmentDensityMapAttachment = ref; |
| 1516 | |
| 1517 | VkAttachmentDescription attach = {}; |
| 1518 | attach.format = VK_FORMAT_R8G8_UNORM; |
| 1519 | attach.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1520 | attach.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; |
| 1521 | attach.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 1522 | attach.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 1523 | attach.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 1524 | attach.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 1525 | attach.finalLayout = VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT; |
| 1526 | |
| 1527 | VkSubpassDescription subpass = {}; |
| 1528 | subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; |
| 1529 | subpass.inputAttachmentCount = 1; |
| 1530 | subpass.pInputAttachments = &ref; |
| 1531 | |
| 1532 | VkRenderPassCreateInfo rpci = LvlInitStruct<VkRenderPassCreateInfo>(&rpfdmi); |
| 1533 | rpci.attachmentCount = 1; |
| 1534 | rpci.pAttachments = &attach; |
| 1535 | rpci.subpassCount = 1; |
| 1536 | rpci.pSubpasses = &subpass; |
| 1537 | |
| 1538 | VkRenderPass renderPass; |
| 1539 | vk::CreateRenderPass(device(), &rpci, nullptr, &renderPass); |
| 1540 | |
| 1541 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 1542 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1543 | image_create_info.format = VK_FORMAT_R8G8_UNORM; |
| 1544 | image_create_info.extent.width = 32; |
| 1545 | image_create_info.extent.height = 32; |
| 1546 | image_create_info.extent.depth = 1; |
| 1547 | image_create_info.mipLevels = 1; |
| 1548 | image_create_info.arrayLayers = 4; |
| 1549 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1550 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 1551 | image_create_info.usage = VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT; |
| 1552 | image_create_info.flags = 0; |
| 1553 | |
| 1554 | VkImageObj image(m_device); |
| 1555 | image.Init(image_create_info); |
| 1556 | VkImageView imageView = image.targetView(VK_FORMAT_R8G8_UNORM, VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 4); |
| 1557 | |
| 1558 | VkFramebufferCreateInfo fb_info = LvlInitStruct<VkFramebufferCreateInfo>(); |
| 1559 | fb_info.renderPass = renderPass; |
| 1560 | fb_info.attachmentCount = 1; |
| 1561 | fb_info.pAttachments = &imageView; |
| 1562 | fb_info.width = 32; |
| 1563 | fb_info.height = 32; |
| 1564 | fb_info.layers = 1; |
| 1565 | |
| 1566 | VkFramebuffer framebuffer; |
| 1567 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkFramebufferCreateInfo-pAttachments-02744"); |
| 1568 | vk::CreateFramebuffer(device(), &fb_info, nullptr, &framebuffer); |
| 1569 | m_errorMonitor->VerifyFound(); |
| 1570 | } |