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