unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1 | /* |
Aaron Hagan | d1a6121 | 2021-12-22 11:53:49 -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) 2022 Advanced Micro Devices, Inc. All rights reserved. |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [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> |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 26 | * Author: Tobias Hector <tobias.hector@amd.com> |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 27 | */ |
| 28 | |
| 29 | #include "cast_utils.h" |
| 30 | #include "layer_validation_tests.h" |
| 31 | |
| 32 | TEST_F(VkLayerTest, InvalidCommandPoolConsistency) { |
| 33 | TEST_DESCRIPTION("Allocate command buffers from one command pool and attempt to delete them from another."); |
| 34 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 35 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkFreeCommandBuffers-pCommandBuffers-parent"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 36 | |
| 37 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 38 | VkCommandPool command_pool_one; |
| 39 | VkCommandPool command_pool_two; |
| 40 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 41 | VkCommandPoolCreateInfo pool_create_info = LvlInitStruct<VkCommandPoolCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 42 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 43 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 44 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 45 | vk::CreateCommandPool(m_device->device(), &pool_create_info, nullptr, &command_pool_one); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 46 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 47 | vk::CreateCommandPool(m_device->device(), &pool_create_info, nullptr, &command_pool_two); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 48 | |
| 49 | VkCommandBuffer cb; |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 50 | VkCommandBufferAllocateInfo command_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 51 | command_buffer_allocate_info.commandPool = command_pool_one; |
| 52 | command_buffer_allocate_info.commandBufferCount = 1; |
| 53 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 54 | vk::AllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, &cb); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 55 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 56 | vk::FreeCommandBuffers(m_device->device(), command_pool_two, 1, &cb); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 57 | |
| 58 | m_errorMonitor->VerifyFound(); |
| 59 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 60 | vk::DestroyCommandPool(m_device->device(), command_pool_one, NULL); |
| 61 | vk::DestroyCommandPool(m_device->device(), command_pool_two, NULL); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | TEST_F(VkLayerTest, InvalidSecondaryCommandBufferBarrier) { |
| 65 | TEST_DESCRIPTION("Add an invalid image barrier in a secondary command buffer"); |
| 66 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 67 | |
| 68 | // A renderpass with a single subpass that declared a self-dependency |
| 69 | VkAttachmentDescription attach[] = { |
| 70 | {0, VK_FORMAT_R8G8B8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 71 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_IMAGE_LAYOUT_UNDEFINED, |
| 72 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}, |
| 73 | }; |
| 74 | VkAttachmentReference ref = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}; |
| 75 | VkSubpassDescription subpasses[] = { |
| 76 | {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &ref, nullptr, nullptr, 0, nullptr}, |
| 77 | }; |
| 78 | VkSubpassDependency dep = {0, |
| 79 | 0, |
| 80 | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, |
| 81 | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, |
| 82 | VK_ACCESS_SHADER_WRITE_BIT, |
| 83 | VK_ACCESS_SHADER_WRITE_BIT, |
| 84 | VK_DEPENDENCY_BY_REGION_BIT}; |
| 85 | VkRenderPassCreateInfo rpci = {VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, 0, 1, attach, 1, subpasses, 1, &dep}; |
| 86 | VkRenderPass rp; |
| 87 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 88 | VkResult err = vk::CreateRenderPass(m_device->device(), &rpci, nullptr, &rp); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 89 | ASSERT_VK_SUCCESS(err); |
| 90 | |
| 91 | VkImageObj image(m_device); |
| 92 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 93 | VkImageView imageView = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 94 | // Second image that img_barrier will incorrectly use |
| 95 | VkImageObj image2(m_device); |
| 96 | image2.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 97 | |
| 98 | VkFramebufferCreateInfo fbci = {VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, nullptr, 0, rp, 1, &imageView, 32, 32, 1}; |
| 99 | VkFramebuffer fb; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 100 | err = vk::CreateFramebuffer(m_device->device(), &fbci, nullptr, &fb); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 101 | ASSERT_VK_SUCCESS(err); |
| 102 | |
| 103 | m_commandBuffer->begin(); |
| 104 | |
| 105 | VkRenderPassBeginInfo rpbi = {VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, |
| 106 | nullptr, |
| 107 | rp, |
| 108 | fb, |
| 109 | {{ |
| 110 | 0, |
| 111 | 0, |
| 112 | }, |
| 113 | {32, 32}}, |
| 114 | 0, |
| 115 | nullptr}; |
| 116 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 117 | vk::CmdBeginRenderPass(m_commandBuffer->handle(), &rpbi, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 118 | |
| 119 | VkCommandPoolObj pool(m_device, m_device->graphics_queue_node_index_, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT); |
| 120 | VkCommandBufferObj secondary(m_device, &pool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 121 | |
| 122 | VkCommandBufferInheritanceInfo cbii = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, |
| 123 | nullptr, |
| 124 | rp, |
| 125 | 0, |
| 126 | VK_NULL_HANDLE, // Set to NULL FB handle intentionally to flesh out any errors |
| 127 | VK_FALSE, |
| 128 | 0, |
| 129 | 0}; |
| 130 | VkCommandBufferBeginInfo cbbi = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr, |
| 131 | VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, |
| 132 | &cbii}; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 133 | vk::BeginCommandBuffer(secondary.handle(), &cbbi); |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 134 | VkImageMemoryBarrier img_barrier = LvlInitStruct<VkImageMemoryBarrier>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 135 | img_barrier.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT; |
| 136 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT; |
| 137 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 138 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 139 | img_barrier.image = image2.handle(); // Image mis-matches with FB image |
| 140 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 141 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 142 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 143 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 144 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 145 | img_barrier.subresourceRange.layerCount = 1; |
| 146 | img_barrier.subresourceRange.levelCount = 1; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 147 | vk::CmdPipelineBarrier(secondary.handle(), VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, |
| 148 | VK_DEPENDENCY_BY_REGION_BIT, 0, nullptr, 0, nullptr, 1, &img_barrier); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 149 | secondary.end(); |
| 150 | |
Shannon McPherson | 93970b1 | 2020-06-12 14:34:35 -0600 | [diff] [blame] | 151 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPipelineBarrier-image-04073"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 152 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 153 | m_errorMonitor->VerifyFound(); |
| 154 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 155 | vk::DestroyFramebuffer(m_device->device(), fb, nullptr); |
| 156 | vk::DestroyRenderPass(m_device->device(), rp, nullptr); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | TEST_F(VkLayerTest, DynamicDepthBiasNotBound) { |
| 160 | TEST_DESCRIPTION( |
| 161 | "Run a simple draw calls to validate failure when Depth Bias dynamic state is required but not correctly bound."); |
| 162 | |
| 163 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 164 | // Dynamic depth bias |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 165 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "Dynamic depth bias state not set for this command buffer"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 166 | VKTriangleTest(BsoFailDepthBias); |
| 167 | m_errorMonitor->VerifyFound(); |
| 168 | } |
| 169 | |
| 170 | TEST_F(VkLayerTest, DynamicLineWidthNotBound) { |
| 171 | TEST_DESCRIPTION( |
| 172 | "Run a simple draw calls to validate failure when Line Width dynamic state is required but not correctly bound."); |
| 173 | |
| 174 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 175 | // Dynamic line width |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 176 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "Dynamic line width state not set for this command buffer"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 177 | VKTriangleTest(BsoFailLineWidth); |
| 178 | m_errorMonitor->VerifyFound(); |
| 179 | } |
| 180 | |
Jeff Bolz | f390c6c | 2019-08-16 16:29:53 -0500 | [diff] [blame] | 181 | TEST_F(VkLayerTest, DynamicLineStippleNotBound) { |
| 182 | TEST_DESCRIPTION( |
| 183 | "Run a simple draw calls to validate failure when Line Stipple dynamic state is required but not correctly bound."); |
| 184 | |
sjfricke | d8e01c5 | 2022-07-06 14:09:04 +0900 | [diff] [blame] | 185 | AddRequiredExtensions(VK_EXT_LINE_RASTERIZATION_EXTENSION_NAME); |
Mark Lobodzinski | 09ce9c4 | 2020-03-06 10:02:44 -0700 | [diff] [blame] | 186 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
sjfricke | d8e01c5 | 2022-07-06 14:09:04 +0900 | [diff] [blame] | 187 | if (!AreRequiredExtensionsEnabled()) { |
| 188 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
Jeff Bolz | f390c6c | 2019-08-16 16:29:53 -0500 | [diff] [blame] | 189 | } |
| 190 | |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 191 | auto line_rasterization_features = LvlInitStruct<VkPhysicalDeviceLineRasterizationFeaturesEXT>(); |
sjfricke | 11db0c7 | 2022-08-18 13:23:11 +0900 | [diff] [blame^] | 192 | auto features2 = GetPhysicalDeviceFeatures2(line_rasterization_features); |
Jeff Bolz | f390c6c | 2019-08-16 16:29:53 -0500 | [diff] [blame] | 193 | if (!line_rasterization_features.stippledBresenhamLines || !line_rasterization_features.bresenhamLines) { |
| 194 | printf("%sStipple Bresenham lines not supported; skipped.\n", kSkipPrefix); |
| 195 | return; |
| 196 | } |
| 197 | |
| 198 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
| 199 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 200 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "Dynamic line stipple state not set for this command buffer"); |
Jeff Bolz | f390c6c | 2019-08-16 16:29:53 -0500 | [diff] [blame] | 201 | VKTriangleTest(BsoFailLineStipple); |
| 202 | m_errorMonitor->VerifyFound(); |
| 203 | } |
| 204 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 205 | TEST_F(VkLayerTest, DynamicViewportNotBound) { |
| 206 | TEST_DESCRIPTION( |
| 207 | "Run a simple draw calls to validate failure when Viewport dynamic state is required but not correctly bound."); |
| 208 | |
| 209 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 210 | // Dynamic viewport state |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 211 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 212 | "Dynamic viewport(s) 0 are used by pipeline state object, but were not provided"); |
| 213 | VKTriangleTest(BsoFailViewport); |
| 214 | m_errorMonitor->VerifyFound(); |
| 215 | } |
| 216 | |
| 217 | TEST_F(VkLayerTest, DynamicScissorNotBound) { |
| 218 | TEST_DESCRIPTION("Run a simple draw calls to validate failure when Scissor dynamic state is required but not correctly bound."); |
| 219 | |
| 220 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 221 | // Dynamic scissor state |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 222 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 223 | "Dynamic scissor(s) 0 are used by pipeline state object, but were not provided"); |
| 224 | VKTriangleTest(BsoFailScissor); |
| 225 | m_errorMonitor->VerifyFound(); |
| 226 | } |
| 227 | |
| 228 | TEST_F(VkLayerTest, DynamicBlendConstantsNotBound) { |
| 229 | TEST_DESCRIPTION( |
| 230 | "Run a simple draw calls to validate failure when Blend Constants dynamic state is required but not correctly bound."); |
| 231 | |
| 232 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 233 | // Dynamic blend constant state |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 234 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "Dynamic blend constants state not set for this command buffer"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 235 | VKTriangleTest(BsoFailBlend); |
| 236 | m_errorMonitor->VerifyFound(); |
| 237 | } |
| 238 | |
| 239 | TEST_F(VkLayerTest, DynamicDepthBoundsNotBound) { |
| 240 | TEST_DESCRIPTION( |
| 241 | "Run a simple draw calls to validate failure when Depth Bounds dynamic state is required but not correctly bound."); |
| 242 | |
| 243 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 244 | if (!m_device->phy().features().depthBounds) { |
| 245 | printf("%s Device does not support depthBounds test; skipped.\n", kSkipPrefix); |
| 246 | return; |
| 247 | } |
| 248 | // Dynamic depth bounds |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 249 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "Dynamic depth bounds state not set for this command buffer"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 250 | VKTriangleTest(BsoFailDepthBounds); |
| 251 | m_errorMonitor->VerifyFound(); |
| 252 | } |
| 253 | |
| 254 | TEST_F(VkLayerTest, DynamicStencilReadNotBound) { |
| 255 | TEST_DESCRIPTION( |
| 256 | "Run a simple draw calls to validate failure when Stencil Read dynamic state is required but not correctly bound."); |
| 257 | |
| 258 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 259 | // Dynamic stencil read mask |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 260 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "Dynamic stencil read mask state not set for this command buffer"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 261 | VKTriangleTest(BsoFailStencilReadMask); |
| 262 | m_errorMonitor->VerifyFound(); |
| 263 | } |
| 264 | |
| 265 | TEST_F(VkLayerTest, DynamicStencilWriteNotBound) { |
| 266 | TEST_DESCRIPTION( |
| 267 | "Run a simple draw calls to validate failure when Stencil Write dynamic state is required but not correctly bound."); |
| 268 | |
| 269 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 270 | // Dynamic stencil write mask |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 271 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "Dynamic stencil write mask state not set for this command buffer"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 272 | VKTriangleTest(BsoFailStencilWriteMask); |
| 273 | m_errorMonitor->VerifyFound(); |
| 274 | } |
| 275 | |
| 276 | TEST_F(VkLayerTest, DynamicStencilRefNotBound) { |
| 277 | TEST_DESCRIPTION( |
| 278 | "Run a simple draw calls to validate failure when Stencil Ref dynamic state is required but not correctly bound."); |
| 279 | |
| 280 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 281 | // Dynamic stencil reference |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 282 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "Dynamic stencil reference state not set for this command buffer"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 283 | VKTriangleTest(BsoFailStencilReference); |
| 284 | m_errorMonitor->VerifyFound(); |
| 285 | } |
| 286 | |
| 287 | TEST_F(VkLayerTest, IndexBufferNotBound) { |
| 288 | TEST_DESCRIPTION("Run an indexed draw call without an index buffer bound."); |
| 289 | |
| 290 | ASSERT_NO_FATAL_FAILURE(Init()); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 291 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "Index buffer object not bound to this command buffer when Indexed "); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 292 | VKTriangleTest(BsoFailIndexBuffer); |
| 293 | m_errorMonitor->VerifyFound(); |
| 294 | } |
| 295 | |
| 296 | TEST_F(VkLayerTest, IndexBufferBadSize) { |
| 297 | TEST_DESCRIPTION("Run indexed draw call with bad index buffer size."); |
| 298 | |
| 299 | ASSERT_NO_FATAL_FAILURE(Init(nullptr, nullptr, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
Tony-LunarG | 4490de4 | 2021-06-21 15:49:19 -0600 | [diff] [blame] | 300 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "vkCmdDrawIndexed(): index size "); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 301 | VKTriangleTest(BsoFailIndexBufferBadSize); |
| 302 | m_errorMonitor->VerifyFound(); |
| 303 | } |
| 304 | |
| 305 | TEST_F(VkLayerTest, IndexBufferBadOffset) { |
| 306 | TEST_DESCRIPTION("Run indexed draw call with bad index buffer offset."); |
| 307 | |
| 308 | ASSERT_NO_FATAL_FAILURE(Init(nullptr, nullptr, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
Tony-LunarG | 4490de4 | 2021-06-21 15:49:19 -0600 | [diff] [blame] | 309 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "vkCmdDrawIndexed(): index size "); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 310 | VKTriangleTest(BsoFailIndexBufferBadOffset); |
| 311 | m_errorMonitor->VerifyFound(); |
| 312 | } |
| 313 | |
| 314 | TEST_F(VkLayerTest, IndexBufferBadBindSize) { |
| 315 | TEST_DESCRIPTION("Run bind index buffer with a size greater than the index buffer."); |
| 316 | |
| 317 | ASSERT_NO_FATAL_FAILURE(Init(nullptr, nullptr, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
Tony-LunarG | 4490de4 | 2021-06-21 15:49:19 -0600 | [diff] [blame] | 318 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "vkCmdDrawIndexed(): index size "); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 319 | VKTriangleTest(BsoFailIndexBufferBadMapSize); |
| 320 | m_errorMonitor->VerifyFound(); |
| 321 | } |
| 322 | |
| 323 | TEST_F(VkLayerTest, IndexBufferBadBindOffset) { |
| 324 | TEST_DESCRIPTION("Run bind index buffer with an offset greater than the size of the index buffer."); |
| 325 | |
| 326 | ASSERT_NO_FATAL_FAILURE(Init(nullptr, nullptr, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
Tony-LunarG | 4490de4 | 2021-06-21 15:49:19 -0600 | [diff] [blame] | 327 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "vkCmdDrawIndexed(): index size "); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 328 | VKTriangleTest(BsoFailIndexBufferBadMapOffset); |
| 329 | m_errorMonitor->VerifyFound(); |
| 330 | } |
| 331 | |
| 332 | TEST_F(VkLayerTest, MissingClearAttachment) { |
| 333 | TEST_DESCRIPTION("Points to a wrong colorAttachment index in a VkClearAttachment structure passed to vkCmdClearAttachments"); |
| 334 | ASSERT_NO_FATAL_FAILURE(Init()); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 335 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdClearAttachments-aspectMask-02501"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 336 | |
| 337 | VKTriangleTest(BsoFailCmdClearAttachments); |
| 338 | m_errorMonitor->VerifyFound(); |
| 339 | } |
| 340 | |
Mark Lobodzinski | cd0204c | 2019-11-11 16:59:18 -0700 | [diff] [blame] | 341 | TEST_F(VkLayerTest, SecondaryCommandbufferAsPrimary) { |
| 342 | TEST_DESCRIPTION("Create a secondary command buffer and pass it to QueueSubmit."); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 343 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo-pCommandBuffers-00075"); |
Mark Lobodzinski | cd0204c | 2019-11-11 16:59:18 -0700 | [diff] [blame] | 344 | |
| 345 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 346 | |
| 347 | VkCommandBufferObj secondary(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 348 | secondary.begin(); |
| 349 | secondary.ClearAllBuffers(m_renderTargets, m_clear_color, nullptr, m_depth_clear_color, m_stencil_clear_color); |
| 350 | secondary.end(); |
| 351 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 352 | VkSubmitInfo submit_info = LvlInitStruct<VkSubmitInfo>(); |
Mark Lobodzinski | cd0204c | 2019-11-11 16:59:18 -0700 | [diff] [blame] | 353 | submit_info.waitSemaphoreCount = 0; |
| 354 | submit_info.pWaitSemaphores = NULL; |
| 355 | submit_info.pWaitDstStageMask = NULL; |
| 356 | submit_info.commandBufferCount = 1; |
| 357 | submit_info.pCommandBuffers = &secondary.handle(); |
| 358 | submit_info.signalSemaphoreCount = 0; |
| 359 | submit_info.pSignalSemaphores = NULL; |
| 360 | |
| 361 | vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 362 | m_errorMonitor->VerifyFound(); |
| 363 | } |
| 364 | |
Jeremy Gebben | 1db6edc | 2021-02-17 15:28:40 -0700 | [diff] [blame] | 365 | TEST_F(VkLayerTest, Sync2SecondaryCommandbufferAsPrimary) { |
| 366 | TEST_DESCRIPTION("Create a secondary command buffer and pass it to QueueSubmit2KHR."); |
| 367 | SetTargetApiVersion(VK_API_VERSION_1_2); |
| 368 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 369 | if (DeviceExtensionSupported(gpu(), nullptr, VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME)) { |
| 370 | m_device_extension_names.push_back(VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME); |
| 371 | } else { |
sjfricke | 20f4a87 | 2022-08-12 08:28:05 +0900 | [diff] [blame] | 372 | GTEST_SKIP() << "Synchronization2 not supported"; |
Jeremy Gebben | 1db6edc | 2021-02-17 15:28:40 -0700 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | if (!CheckSynchronization2SupportAndInitState(this)) { |
sjfricke | 20f4a87 | 2022-08-12 08:28:05 +0900 | [diff] [blame] | 376 | GTEST_SKIP() << "Synchronization2 not supported"; |
Jeremy Gebben | 1db6edc | 2021-02-17 15:28:40 -0700 | [diff] [blame] | 377 | } |
| 378 | auto fpQueueSubmit2KHR = (PFN_vkQueueSubmit2KHR)vk::GetDeviceProcAddr(m_device->device(), "vkQueueSubmit2KHR"); |
Tony-LunarG | 279601c | 2021-11-16 10:50:51 -0700 | [diff] [blame] | 379 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferSubmitInfo-commandBuffer-03890"); |
Jeremy Gebben | 1db6edc | 2021-02-17 15:28:40 -0700 | [diff] [blame] | 380 | |
| 381 | VkCommandBufferObj secondary(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 382 | secondary.begin(); |
| 383 | secondary.ClearAllBuffers(m_renderTargets, m_clear_color, nullptr, m_depth_clear_color, m_stencil_clear_color); |
| 384 | secondary.end(); |
| 385 | |
| 386 | auto cb_info = lvl_init_struct<VkCommandBufferSubmitInfoKHR>(); |
| 387 | cb_info.commandBuffer = secondary.handle(); |
| 388 | |
| 389 | auto submit_info = lvl_init_struct<VkSubmitInfo2KHR>(); |
| 390 | submit_info.commandBufferInfoCount = 1; |
| 391 | submit_info.pCommandBufferInfos = &cb_info; |
| 392 | |
| 393 | fpQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 394 | m_errorMonitor->VerifyFound(); |
| 395 | } |
| 396 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 397 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 398 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 399 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has been submitted"); |
| 400 | |
| 401 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 402 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 403 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 404 | |
| 405 | // We luck out b/c by default the framework creates CB w/ the |
| 406 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
| 407 | m_commandBuffer->begin(); |
| 408 | m_commandBuffer->ClearAllBuffers(m_renderTargets, m_clear_color, nullptr, m_depth_clear_color, m_stencil_clear_color); |
| 409 | m_commandBuffer->end(); |
| 410 | |
| 411 | // Bypass framework since it does the waits automatically |
| 412 | VkResult err = VK_SUCCESS; |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 413 | VkSubmitInfo submit_info = LvlInitStruct<VkSubmitInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 414 | submit_info.waitSemaphoreCount = 0; |
| 415 | submit_info.pWaitSemaphores = NULL; |
| 416 | submit_info.pWaitDstStageMask = NULL; |
| 417 | submit_info.commandBufferCount = 1; |
| 418 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
| 419 | submit_info.signalSemaphoreCount = 0; |
| 420 | submit_info.pSignalSemaphores = NULL; |
| 421 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 422 | err = vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 423 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 424 | vk::QueueWaitIdle(m_device->m_queue); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 425 | |
| 426 | // Cause validation error by re-submitting cmd buffer that should only be |
| 427 | // submitted once |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 428 | err = vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 429 | vk::QueueWaitIdle(m_device->m_queue); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 430 | |
| 431 | m_errorMonitor->VerifyFound(); |
| 432 | } |
| 433 | |
Jeremy Gebben | 1db6edc | 2021-02-17 15:28:40 -0700 | [diff] [blame] | 434 | TEST_F(VkLayerTest, Sync2CommandBufferTwoSubmits) { |
| 435 | SetTargetApiVersion(VK_API_VERSION_1_2); |
| 436 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 437 | if (DeviceExtensionSupported(gpu(), nullptr, VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME)) { |
| 438 | m_device_extension_names.push_back(VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME); |
| 439 | } else { |
sjfricke | 20f4a87 | 2022-08-12 08:28:05 +0900 | [diff] [blame] | 440 | GTEST_SKIP() << "Synchronization2 not supported"; |
Jeremy Gebben | 1db6edc | 2021-02-17 15:28:40 -0700 | [diff] [blame] | 441 | } |
| 442 | |
| 443 | if (!CheckSynchronization2SupportAndInitState(this)) { |
sjfricke | 20f4a87 | 2022-08-12 08:28:05 +0900 | [diff] [blame] | 444 | GTEST_SKIP() << "Synchronization2 not supported"; |
Jeremy Gebben | 1db6edc | 2021-02-17 15:28:40 -0700 | [diff] [blame] | 445 | } |
| 446 | auto fpQueueSubmit2KHR = (PFN_vkQueueSubmit2KHR)vk::GetDeviceProcAddr(m_device->device(), "vkQueueSubmit2KHR"); |
| 447 | |
| 448 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
| 449 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has been submitted"); |
| 450 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 451 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 452 | |
| 453 | // We luck out b/c by default the framework creates CB w/ the |
| 454 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
| 455 | m_commandBuffer->begin(); |
| 456 | m_commandBuffer->ClearAllBuffers(m_renderTargets, m_clear_color, nullptr, m_depth_clear_color, m_stencil_clear_color); |
| 457 | m_commandBuffer->end(); |
| 458 | |
| 459 | // Bypass framework since it does the waits automatically |
| 460 | VkResult err = VK_SUCCESS; |
| 461 | auto cb_info = lvl_init_struct<VkCommandBufferSubmitInfoKHR>(); |
| 462 | cb_info.commandBuffer = m_commandBuffer->handle(); |
| 463 | |
| 464 | auto submit_info = lvl_init_struct<VkSubmitInfo2KHR>(); |
| 465 | submit_info.commandBufferInfoCount = 1; |
| 466 | submit_info.pCommandBufferInfos = &cb_info; |
| 467 | |
| 468 | err = fpQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 469 | ASSERT_VK_SUCCESS(err); |
| 470 | vk::QueueWaitIdle(m_device->m_queue); |
| 471 | |
| 472 | // Cause validation error by re-submitting cmd buffer that should only be |
| 473 | // submitted once |
| 474 | err = fpQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 475 | vk::QueueWaitIdle(m_device->m_queue); |
| 476 | |
| 477 | m_errorMonitor->VerifyFound(); |
| 478 | } |
| 479 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 480 | TEST_F(VkLayerTest, InvalidPushConstants) { |
| 481 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 482 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 483 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 484 | |
| 485 | VkPipelineLayout pipeline_layout; |
| 486 | VkPushConstantRange pc_range = {}; |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 487 | VkPipelineLayoutCreateInfo pipeline_layout_ci = LvlInitStruct<VkPipelineLayoutCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 488 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 489 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 490 | |
| 491 | // |
| 492 | // Check for invalid push constant ranges in pipeline layouts. |
| 493 | // |
| 494 | struct PipelineLayoutTestCase { |
| 495 | VkPushConstantRange const range; |
| 496 | char const *msg; |
| 497 | }; |
| 498 | |
| 499 | const uint32_t too_big = m_device->props.limits.maxPushConstantsSize + 0x4; |
| 500 | const std::array<PipelineLayoutTestCase, 10> range_tests = {{ |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 501 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, "VUID-VkPushConstantRange-size-00296"}, |
| 502 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, "VUID-VkPushConstantRange-size-00297"}, |
| 503 | {{VK_SHADER_STAGE_VERTEX_BIT, 4, 1}, "VUID-VkPushConstantRange-size-00297"}, |
| 504 | {{VK_SHADER_STAGE_VERTEX_BIT, 4, 0}, "VUID-VkPushConstantRange-size-00296"}, |
| 505 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, "VUID-VkPushConstantRange-offset-00295"}, |
| 506 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, "VUID-VkPushConstantRange-size-00298"}, |
| 507 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, "VUID-VkPushConstantRange-offset-00294"}, |
| 508 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 4}, "VUID-VkPushConstantRange-offset-00294"}, |
| 509 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, "VUID-VkPushConstantRange-offset-00294"}, |
| 510 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, "VUID-VkPushConstantRange-size-00298"}, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 511 | }}; |
| 512 | |
| 513 | // Check for invalid offset and size |
| 514 | for (const auto &iter : range_tests) { |
| 515 | pc_range = iter.range; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 516 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, iter.msg); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 517 | vk::CreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 518 | m_errorMonitor->VerifyFound(); |
| 519 | } |
| 520 | |
| 521 | // Check for invalid stage flag |
| 522 | pc_range.offset = 0; |
| 523 | pc_range.size = 16; |
| 524 | pc_range.stageFlags = 0; |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 525 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkPushConstantRange-stageFlags-requiredbitmask"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 526 | vk::CreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 527 | m_errorMonitor->VerifyFound(); |
| 528 | |
| 529 | // Check for duplicate stage flags in a list of push constant ranges. |
| 530 | // A shader can only have one push constant block and that block is mapped |
| 531 | // to the push constant range that has that shader's stage flag set. |
| 532 | // The shader's stage flag can only appear once in all the ranges, so the |
| 533 | // implementation can find the one and only range to map it to. |
| 534 | const uint32_t ranges_per_test = 5; |
| 535 | struct DuplicateStageFlagsTestCase { |
| 536 | VkPushConstantRange const ranges[ranges_per_test]; |
| 537 | std::vector<char const *> const msg; |
| 538 | }; |
| 539 | // Overlapping ranges are OK, but a stage flag can appear only once. |
| 540 | const std::array<DuplicateStageFlagsTestCase, 3> duplicate_stageFlags_tests = { |
| 541 | { |
| 542 | {{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 543 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 544 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 545 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 546 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 547 | { |
| 548 | "vkCreatePipelineLayout() Duplicate stage flags found in ranges 0 and 1.", |
| 549 | "vkCreatePipelineLayout() Duplicate stage flags found in ranges 0 and 2.", |
| 550 | "vkCreatePipelineLayout() Duplicate stage flags found in ranges 0 and 3.", |
| 551 | "vkCreatePipelineLayout() Duplicate stage flags found in ranges 0 and 4.", |
| 552 | "vkCreatePipelineLayout() Duplicate stage flags found in ranges 1 and 2.", |
| 553 | "vkCreatePipelineLayout() Duplicate stage flags found in ranges 1 and 3.", |
| 554 | "vkCreatePipelineLayout() Duplicate stage flags found in ranges 1 and 4.", |
| 555 | "vkCreatePipelineLayout() Duplicate stage flags found in ranges 2 and 3.", |
| 556 | "vkCreatePipelineLayout() Duplicate stage flags found in ranges 2 and 4.", |
| 557 | "vkCreatePipelineLayout() Duplicate stage flags found in ranges 3 and 4.", |
| 558 | }}, |
| 559 | {{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 560 | {VK_SHADER_STAGE_GEOMETRY_BIT, 0, 4}, |
| 561 | {VK_SHADER_STAGE_FRAGMENT_BIT, 0, 4}, |
| 562 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 563 | {VK_SHADER_STAGE_GEOMETRY_BIT, 0, 4}}, |
| 564 | { |
| 565 | "vkCreatePipelineLayout() Duplicate stage flags found in ranges 0 and 3.", |
| 566 | "vkCreatePipelineLayout() Duplicate stage flags found in ranges 1 and 4.", |
| 567 | }}, |
| 568 | {{{VK_SHADER_STAGE_FRAGMENT_BIT, 0, 4}, |
| 569 | {VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, 0, 4}, |
| 570 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 571 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 572 | {VK_SHADER_STAGE_GEOMETRY_BIT, 0, 4}}, |
| 573 | { |
| 574 | "vkCreatePipelineLayout() Duplicate stage flags found in ranges 2 and 3.", |
| 575 | }}, |
| 576 | }, |
| 577 | }; |
| 578 | |
| 579 | for (const auto &iter : duplicate_stageFlags_tests) { |
| 580 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
| 581 | pipeline_layout_ci.pushConstantRangeCount = ranges_per_test; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 582 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, iter.msg.begin(), iter.msg.end()); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 583 | vk::CreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 584 | m_errorMonitor->VerifyFound(); |
| 585 | } |
| 586 | |
| 587 | // |
| 588 | // CmdPushConstants tests |
| 589 | // |
| 590 | |
| 591 | // Setup a pipeline layout with ranges: [0,32) [16,80) |
| 592 | const std::vector<VkPushConstantRange> pc_range2 = {{VK_SHADER_STAGE_VERTEX_BIT, 16, 64}, |
| 593 | {VK_SHADER_STAGE_FRAGMENT_BIT, 0, 32}}; |
| 594 | const VkPipelineLayoutObj pipeline_layout_obj(m_device, {}, pc_range2); |
| 595 | |
| 596 | const uint8_t dummy_values[100] = {}; |
| 597 | |
| 598 | m_commandBuffer->begin(); |
| 599 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 600 | |
| 601 | // Check for invalid stage flag |
| 602 | // Note that VU 00996 isn't reached due to parameter validation |
sfricke-samsung | 51303fb | 2021-05-09 19:09:13 -0700 | [diff] [blame] | 603 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPushConstants-stageFlags-requiredbitmask"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 604 | vk::CmdPushConstants(m_commandBuffer->handle(), pipeline_layout_obj.handle(), 0, 0, 16, dummy_values); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 605 | m_errorMonitor->VerifyFound(); |
| 606 | |
| 607 | // Positive tests for the overlapping ranges |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 608 | vk::CmdPushConstants(m_commandBuffer->handle(), pipeline_layout_obj.handle(), VK_SHADER_STAGE_FRAGMENT_BIT, 0, 16, |
| 609 | dummy_values); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 610 | vk::CmdPushConstants(m_commandBuffer->handle(), pipeline_layout_obj.handle(), VK_SHADER_STAGE_VERTEX_BIT, 32, 48, dummy_values); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 611 | vk::CmdPushConstants(m_commandBuffer->handle(), pipeline_layout_obj.handle(), |
| 612 | VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 16, 16, dummy_values); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 613 | |
| 614 | // Wrong cmd stages for extant range |
| 615 | // No range for all cmd stages -- "VUID-vkCmdPushConstants-offset-01795" VUID-vkCmdPushConstants-offset-01795 |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 616 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPushConstants-offset-01795"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 617 | // Missing cmd stages for found overlapping range -- "VUID-vkCmdPushConstants-offset-01796" VUID-vkCmdPushConstants-offset-01796 |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 618 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPushConstants-offset-01796"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 619 | vk::CmdPushConstants(m_commandBuffer->handle(), pipeline_layout_obj.handle(), VK_SHADER_STAGE_GEOMETRY_BIT, 0, 16, |
| 620 | dummy_values); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 621 | m_errorMonitor->VerifyFound(); |
| 622 | |
| 623 | // Wrong no extant range |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 624 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPushConstants-offset-01795"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 625 | vk::CmdPushConstants(m_commandBuffer->handle(), pipeline_layout_obj.handle(), VK_SHADER_STAGE_FRAGMENT_BIT, 80, 4, |
| 626 | dummy_values); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 627 | m_errorMonitor->VerifyFound(); |
| 628 | |
| 629 | // Wrong overlapping extent |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 630 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPushConstants-offset-01795"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 631 | vk::CmdPushConstants(m_commandBuffer->handle(), pipeline_layout_obj.handle(), |
| 632 | VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, 20, dummy_values); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 633 | m_errorMonitor->VerifyFound(); |
| 634 | |
| 635 | // Wrong stage flags for valid overlapping range |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 636 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPushConstants-offset-01796"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 637 | vk::CmdPushConstants(m_commandBuffer->handle(), pipeline_layout_obj.handle(), VK_SHADER_STAGE_VERTEX_BIT, 16, 16, dummy_values); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 638 | m_errorMonitor->VerifyFound(); |
| 639 | |
| 640 | m_commandBuffer->EndRenderPass(); |
| 641 | m_commandBuffer->end(); |
| 642 | } |
| 643 | |
| 644 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
sfricke-samsung | 946027b | 2021-04-20 22:44:36 -0700 | [diff] [blame] | 645 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkEndCommandBuffer-commandBuffer-00059"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 646 | |
| 647 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 648 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 649 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 650 | vk::EndCommandBuffer(commandBuffer.handle()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 651 | |
| 652 | m_errorMonitor->VerifyFound(); |
| 653 | } |
| 654 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 655 | TEST_F(VkLayerTest, SecondaryCommandBufferRerecordedExplicitReset) { |
| 656 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 657 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 658 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "was destroyed or rerecorded"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 659 | |
| 660 | // A pool we can reset in. |
| 661 | VkCommandPoolObj pool(m_device, m_device->graphics_queue_node_index_, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT); |
| 662 | VkCommandBufferObj secondary(m_device, &pool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 663 | |
| 664 | secondary.begin(); |
| 665 | secondary.end(); |
| 666 | |
| 667 | m_commandBuffer->begin(); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 668 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 669 | |
| 670 | // rerecording of secondary |
| 671 | secondary.reset(); // explicit reset here. |
| 672 | secondary.begin(); |
| 673 | secondary.end(); |
| 674 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 675 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 676 | m_errorMonitor->VerifyFound(); |
| 677 | } |
| 678 | |
| 679 | TEST_F(VkLayerTest, SecondaryCommandBufferRerecordedNoReset) { |
| 680 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 681 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 682 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "was destroyed or rerecorded"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 683 | |
| 684 | // A pool we can reset in. |
| 685 | VkCommandPoolObj pool(m_device, m_device->graphics_queue_node_index_, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT); |
| 686 | VkCommandBufferObj secondary(m_device, &pool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 687 | |
| 688 | secondary.begin(); |
| 689 | secondary.end(); |
| 690 | |
| 691 | m_commandBuffer->begin(); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 692 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 693 | |
| 694 | // rerecording of secondary |
| 695 | secondary.begin(); // implicit reset in begin |
| 696 | secondary.end(); |
| 697 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 698 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 699 | m_errorMonitor->VerifyFound(); |
| 700 | } |
| 701 | |
| 702 | TEST_F(VkLayerTest, CascadedInvalidation) { |
| 703 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 704 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 705 | VkEventCreateInfo eci = LvlInitStruct<VkEventCreateInfo>(); |
| 706 | eci.flags = 0; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 707 | VkEvent event; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 708 | vk::CreateEvent(m_device->device(), &eci, nullptr, &event); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 709 | |
| 710 | VkCommandBufferObj secondary(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 711 | secondary.begin(); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 712 | vk::CmdSetEvent(secondary.handle(), event, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 713 | secondary.end(); |
| 714 | |
| 715 | m_commandBuffer->begin(); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 716 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 717 | m_commandBuffer->end(); |
| 718 | |
| 719 | // destroying the event should invalidate both primary and secondary CB |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 720 | vk::DestroyEvent(m_device->device(), event, nullptr); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 721 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 722 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "UNASSIGNED-CoreValidation-DrawState-InvalidCommandBuffer-VkEvent"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 723 | m_commandBuffer->QueueCommandBuffer(false); |
| 724 | m_errorMonitor->VerifyFound(); |
| 725 | } |
| 726 | |
| 727 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
| 728 | // Cause error due to Begin while recording CB |
| 729 | // Then cause 2 errors for attempting to reset CB w/o having |
| 730 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 731 | // which CBs were allocated. Note that this bit is off by default. |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 732 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkBeginCommandBuffer-commandBuffer-00049"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 733 | |
| 734 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 735 | |
| 736 | // Calls AllocateCommandBuffers |
| 737 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 738 | |
| 739 | // Force the failure by setting the Renderpass and Framebuffer fields with (fake) data |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 740 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = LvlInitStruct<VkCommandBufferInheritanceInfo>(); |
| 741 | VkCommandBufferBeginInfo cmd_buf_info = LvlInitStruct<VkCommandBufferBeginInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 742 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 743 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
| 744 | |
| 745 | // Begin CB to transition to recording state |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 746 | vk::BeginCommandBuffer(commandBuffer.handle(), &cmd_buf_info); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 747 | // Can't re-begin. This should trigger error |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 748 | vk::BeginCommandBuffer(commandBuffer.handle(), &cmd_buf_info); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 749 | m_errorMonitor->VerifyFound(); |
| 750 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 751 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkResetCommandBuffer-commandBuffer-00046"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 752 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 753 | // Reset attempt will trigger error due to incorrect CommandPool state |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 754 | vk::ResetCommandBuffer(commandBuffer.handle(), flags); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 755 | m_errorMonitor->VerifyFound(); |
| 756 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 757 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkBeginCommandBuffer-commandBuffer-00050"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 758 | // Transition CB to RECORDED state |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 759 | vk::EndCommandBuffer(commandBuffer.handle()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 760 | // Now attempting to Begin will implicitly reset, which triggers error |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 761 | vk::BeginCommandBuffer(commandBuffer.handle(), &cmd_buf_info); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 762 | m_errorMonitor->VerifyFound(); |
| 763 | } |
| 764 | |
sfricke-samsung | ae9f00a | 2020-05-28 20:48:49 -0700 | [diff] [blame] | 765 | TEST_F(VkLayerTest, CommandBufferPrimaryFlags) { |
| 766 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 767 | |
| 768 | // Calls AllocateCommandBuffers |
| 769 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 770 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 771 | VkCommandBufferBeginInfo cmd_buf_info = LvlInitStruct<VkCommandBufferBeginInfo>(); |
sfricke-samsung | ae9f00a | 2020-05-28 20:48:49 -0700 | [diff] [blame] | 772 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT; |
| 773 | |
| 774 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkBeginCommandBuffer-commandBuffer-02840"); |
| 775 | vk::BeginCommandBuffer(commandBuffer.handle(), &cmd_buf_info); |
| 776 | m_errorMonitor->VerifyFound(); |
| 777 | } |
| 778 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 779 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
| 780 | // Call CmdClearAttachmentss outside of an active RenderPass |
| 781 | |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 782 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "vkCmdClearAttachments: This call must be issued inside an active render pass"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 783 | |
| 784 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 785 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 786 | |
| 787 | // Start no RenderPass |
| 788 | m_commandBuffer->begin(); |
| 789 | |
| 790 | VkClearAttachment color_attachment; |
| 791 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 792 | color_attachment.clearValue.color.float32[0] = 0; |
| 793 | color_attachment.clearValue.color.float32[1] = 0; |
| 794 | color_attachment.clearValue.color.float32[2] = 0; |
| 795 | color_attachment.clearValue.color.float32[3] = 0; |
| 796 | color_attachment.colorAttachment = 0; |
Mark Lobodzinski | d544751 | 2019-06-28 09:56:36 -0600 | [diff] [blame] | 797 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}, 0, 1}; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 798 | vk::CmdClearAttachments(m_commandBuffer->handle(), 1, &color_attachment, 1, &clear_rect); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 799 | |
| 800 | m_errorMonitor->VerifyFound(); |
| 801 | } |
| 802 | |
Mark Lobodzinski | 7d7da06 | 2019-06-27 16:01:39 -0600 | [diff] [blame] | 803 | TEST_F(VkLayerTest, ClearColorAttachmentsZeroLayercount) { |
| 804 | TEST_DESCRIPTION("Call CmdClearAttachments with a pRect having a layerCount of zero."); |
| 805 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 806 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdClearAttachments-layerCount-01934"); |
Mark Lobodzinski | 7d7da06 | 2019-06-27 16:01:39 -0600 | [diff] [blame] | 807 | |
| 808 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 809 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 810 | |
| 811 | m_commandBuffer->begin(); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 812 | vk::CmdBeginRenderPass(m_commandBuffer->handle(), &renderPassBeginInfo(), VK_SUBPASS_CONTENTS_INLINE); |
Mark Lobodzinski | 7d7da06 | 2019-06-27 16:01:39 -0600 | [diff] [blame] | 813 | |
| 814 | VkClearAttachment color_attachment; |
| 815 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 816 | color_attachment.clearValue.color.float32[0] = 0; |
| 817 | color_attachment.clearValue.color.float32[1] = 0; |
| 818 | color_attachment.clearValue.color.float32[2] = 0; |
| 819 | color_attachment.clearValue.color.float32[3] = 0; |
| 820 | color_attachment.colorAttachment = 0; |
| 821 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 822 | vk::CmdClearAttachments(m_commandBuffer->handle(), 1, &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 7d7da06 | 2019-06-27 16:01:39 -0600 | [diff] [blame] | 823 | |
| 824 | m_errorMonitor->VerifyFound(); |
| 825 | } |
| 826 | |
sfricke-samsung | f0f3d8b | 2020-04-25 02:20:47 -0700 | [diff] [blame] | 827 | TEST_F(VkLayerTest, ClearColorAttachmentsZeroExtent) { |
| 828 | TEST_DESCRIPTION("Call CmdClearAttachments with a pRect having a rect2D extent of zero."); |
| 829 | |
| 830 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 831 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 832 | |
| 833 | m_commandBuffer->begin(); |
| 834 | vk::CmdBeginRenderPass(m_commandBuffer->handle(), &renderPassBeginInfo(), VK_SUBPASS_CONTENTS_INLINE); |
| 835 | |
| 836 | VkClearAttachment color_attachment; |
| 837 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 838 | color_attachment.clearValue.color.float32[0] = 0; |
| 839 | color_attachment.clearValue.color.float32[1] = 0; |
| 840 | color_attachment.clearValue.color.float32[2] = 0; |
| 841 | color_attachment.clearValue.color.float32[3] = 0; |
| 842 | color_attachment.colorAttachment = 0; |
| 843 | VkClearRect clear_rect = {}; |
| 844 | clear_rect.rect.offset = {0, 0}; |
| 845 | clear_rect.baseArrayLayer = 0; |
| 846 | clear_rect.layerCount = 1; |
| 847 | |
| 848 | clear_rect.rect.extent = {0, 1}; |
| 849 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdClearAttachments-rect-02682"); |
| 850 | vk::CmdClearAttachments(m_commandBuffer->handle(), 1, &color_attachment, 1, &clear_rect); |
| 851 | m_errorMonitor->VerifyFound(); |
| 852 | |
| 853 | clear_rect.rect.extent = {1, 0}; |
| 854 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdClearAttachments-rect-02683"); |
| 855 | vk::CmdClearAttachments(m_commandBuffer->handle(), 1, &color_attachment, 1, &clear_rect); |
| 856 | m_errorMonitor->VerifyFound(); |
| 857 | } |
| 858 | |
sfricke-samsung | 6141db3 | 2020-10-26 03:31:38 -0700 | [diff] [blame] | 859 | TEST_F(VkLayerTest, ClearAttachmentsInvalidAspectMasks) { |
| 860 | TEST_DESCRIPTION("Check VkClearAttachment invalid aspect masks."); |
| 861 | |
| 862 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 863 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 864 | |
| 865 | m_commandBuffer->begin(); |
| 866 | vk::CmdBeginRenderPass(m_commandBuffer->handle(), &renderPassBeginInfo(), VK_SUBPASS_CONTENTS_INLINE); |
| 867 | |
| 868 | VkClearAttachment attachment; |
| 869 | attachment.clearValue.color.float32[0] = 0; |
| 870 | attachment.clearValue.color.float32[1] = 0; |
| 871 | attachment.clearValue.color.float32[2] = 0; |
| 872 | attachment.clearValue.color.float32[3] = 0; |
| 873 | attachment.colorAttachment = 0; |
| 874 | VkClearRect clear_rect = {}; |
| 875 | clear_rect.rect.offset = {0, 0}; |
| 876 | clear_rect.rect.extent = {1, 1}; |
| 877 | clear_rect.baseArrayLayer = 0; |
| 878 | clear_rect.layerCount = 1; |
| 879 | |
| 880 | attachment.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 881 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkClearAttachment-aspectMask-00020"); |
| 882 | vk::CmdClearAttachments(m_commandBuffer->handle(), 1, &attachment, 1, &clear_rect); |
| 883 | m_errorMonitor->VerifyFound(); |
| 884 | |
| 885 | attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_METADATA_BIT; |
| 886 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkClearAttachment-aspectMask-00020"); |
| 887 | vk::CmdClearAttachments(m_commandBuffer->handle(), 1, &attachment, 1, &clear_rect); |
| 888 | m_errorMonitor->VerifyFound(); |
| 889 | |
| 890 | attachment.aspectMask = VK_IMAGE_ASPECT_MEMORY_PLANE_1_BIT_EXT; |
| 891 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkClearAttachment-aspectMask-02246"); |
| 892 | vk::CmdClearAttachments(m_commandBuffer->handle(), 1, &attachment, 1, &clear_rect); |
| 893 | m_errorMonitor->VerifyFound(); |
| 894 | |
| 895 | attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_MEMORY_PLANE_2_BIT_EXT; |
| 896 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkClearAttachment-aspectMask-02246"); |
| 897 | vk::CmdClearAttachments(m_commandBuffer->handle(), 1, &attachment, 1, &clear_rect); |
| 898 | m_errorMonitor->VerifyFound(); |
| 899 | } |
| 900 | |
sfricke-samsung | 91f4a54 | 2020-10-21 00:29:17 -0700 | [diff] [blame] | 901 | TEST_F(VkLayerTest, ClearAttachmentsImplicitCheck) { |
| 902 | TEST_DESCRIPTION("Check VkClearAttachment implicit VUs."); |
| 903 | |
| 904 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 905 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 906 | |
| 907 | m_commandBuffer->begin(); |
| 908 | vk::CmdBeginRenderPass(m_commandBuffer->handle(), &renderPassBeginInfo(), VK_SUBPASS_CONTENTS_INLINE); |
| 909 | |
| 910 | VkClearAttachment color_attachment; |
| 911 | color_attachment.clearValue.color.float32[0] = 0; |
| 912 | color_attachment.clearValue.color.float32[1] = 0; |
| 913 | color_attachment.clearValue.color.float32[2] = 0; |
| 914 | color_attachment.clearValue.color.float32[3] = 0; |
| 915 | color_attachment.colorAttachment = 0; |
| 916 | VkClearRect clear_rect = {}; |
| 917 | clear_rect.rect.offset = {0, 0}; |
| 918 | clear_rect.rect.extent = {1, 1}; |
| 919 | clear_rect.baseArrayLayer = 0; |
| 920 | clear_rect.layerCount = 1; |
| 921 | |
| 922 | color_attachment.aspectMask = 0; |
| 923 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkClearAttachment-aspectMask-requiredbitmask"); |
| 924 | vk::CmdClearAttachments(m_commandBuffer->handle(), 1, &color_attachment, 1, &clear_rect); |
| 925 | m_errorMonitor->VerifyFound(); |
| 926 | |
| 927 | color_attachment.aspectMask = 0xffffffff; |
| 928 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkClearAttachment-aspectMask-parameter"); |
| 929 | vk::CmdClearAttachments(m_commandBuffer->handle(), 1, &color_attachment, 1, &clear_rect); |
| 930 | m_errorMonitor->VerifyFound(); |
| 931 | } |
| 932 | |
sfricke-samsung | 87b0951 | 2020-10-26 03:35:42 -0700 | [diff] [blame] | 933 | TEST_F(VkLayerTest, ClearColorAttachmentsDepthStencil) { |
| 934 | TEST_DESCRIPTION("Call CmdClearAttachments with invalid depth/stencil aspect masks."); |
| 935 | |
| 936 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 937 | // Creates a color attachment |
| 938 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 939 | |
| 940 | m_commandBuffer->begin(); |
| 941 | vk::CmdBeginRenderPass(m_commandBuffer->handle(), &renderPassBeginInfo(), VK_SUBPASS_CONTENTS_INLINE); |
| 942 | |
| 943 | VkClearAttachment attachment; |
| 944 | attachment.clearValue.color.float32[0] = 0; |
| 945 | attachment.clearValue.color.float32[1] = 0; |
| 946 | attachment.clearValue.color.float32[2] = 0; |
| 947 | attachment.clearValue.color.float32[3] = 0; |
| 948 | attachment.colorAttachment = 0; |
| 949 | VkClearRect clear_rect = {}; |
| 950 | clear_rect.rect.offset = {0, 0}; |
| 951 | clear_rect.rect.extent = {1, 1}; |
| 952 | clear_rect.baseArrayLayer = 0; |
| 953 | clear_rect.layerCount = 1; |
| 954 | |
sfricke-samsung | 87b0951 | 2020-10-26 03:35:42 -0700 | [diff] [blame] | 955 | attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 956 | vk::CmdClearAttachments(m_commandBuffer->handle(), 1, &attachment, 1, &clear_rect); |
sfricke-samsung | 87b0951 | 2020-10-26 03:35:42 -0700 | [diff] [blame] | 957 | |
| 958 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdClearAttachments-aspectMask-02502"); |
| 959 | attachment.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; |
| 960 | vk::CmdClearAttachments(m_commandBuffer->handle(), 1, &attachment, 1, &clear_rect); |
| 961 | m_errorMonitor->VerifyFound(); |
| 962 | |
| 963 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdClearAttachments-aspectMask-02503"); |
| 964 | attachment.aspectMask = VK_IMAGE_ASPECT_STENCIL_BIT; |
| 965 | vk::CmdClearAttachments(m_commandBuffer->handle(), 1, &attachment, 1, &clear_rect); |
| 966 | m_errorMonitor->VerifyFound(); |
| 967 | } |
| 968 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 969 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 970 | TEST_DESCRIPTION("Attempt vkCmdExecuteCommands with a primary command buffer (should only be secondary)"); |
| 971 | |
| 972 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 973 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 974 | |
| 975 | // An empty primary command buffer |
| 976 | VkCommandBufferObj cb(m_device, m_commandPool); |
| 977 | cb.begin(); |
| 978 | cb.end(); |
| 979 | |
| 980 | m_commandBuffer->begin(); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 981 | vk::CmdBeginRenderPass(m_commandBuffer->handle(), &renderPassBeginInfo(), VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 982 | VkCommandBuffer handle = cb.handle(); |
| 983 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 984 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pCommandBuffers-00088"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 985 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &handle); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 986 | m_errorMonitor->VerifyFound(); |
| 987 | |
| 988 | m_errorMonitor->SetUnexpectedError("All elements of pCommandBuffers must not be in the pending state"); |
| 989 | |
| 990 | m_commandBuffer->EndRenderPass(); |
| 991 | m_commandBuffer->end(); |
| 992 | } |
| 993 | |
Petr Kraus | 8e53cf0 | 2020-01-03 05:30:04 +0100 | [diff] [blame] | 994 | TEST_F(VkLayerTest, ExecuteCommandsToSecondaryCB) { |
| 995 | TEST_DESCRIPTION("Attempt vkCmdExecuteCommands to a Secondary command buffer"); |
| 996 | |
| 997 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 998 | |
| 999 | VkCommandBufferObj main_cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 1000 | VkCommandBufferObj secondary_cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 1001 | secondary_cb.begin(); |
| 1002 | secondary_cb.end(); |
| 1003 | |
| 1004 | main_cb.begin(); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1005 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-bufferlevel"); |
Petr Kraus | 8e53cf0 | 2020-01-03 05:30:04 +0100 | [diff] [blame] | 1006 | vk::CmdExecuteCommands(main_cb.handle(), 1, &secondary_cb.handle()); |
| 1007 | m_errorMonitor->VerifyFound(); |
| 1008 | } |
| 1009 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1010 | TEST_F(VkLayerTest, InvalidVertexAttributeAlignment) { |
| 1011 | TEST_DESCRIPTION("Check for proper aligment of attribAddress which depends on a bound pipeline and on a bound vertex buffer"); |
| 1012 | |
| 1013 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 1014 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1015 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1016 | |
| 1017 | const VkPipelineLayoutObj pipeline_layout(m_device); |
| 1018 | |
| 1019 | struct VboEntry { |
| 1020 | uint16_t input0[2]; |
| 1021 | uint32_t input1; |
| 1022 | float input2[4]; |
| 1023 | }; |
| 1024 | |
| 1025 | const unsigned vbo_entry_count = 3; |
| 1026 | const VboEntry vbo_data[vbo_entry_count] = {}; |
| 1027 | |
| 1028 | VkConstantBufferObj vbo(m_device, static_cast<int>(sizeof(VboEntry) * vbo_entry_count), |
| 1029 | reinterpret_cast<const void *>(vbo_data), VK_BUFFER_USAGE_VERTEX_BUFFER_BIT); |
| 1030 | |
| 1031 | VkVertexInputBindingDescription input_binding; |
| 1032 | input_binding.binding = 0; |
| 1033 | input_binding.stride = sizeof(VboEntry); |
| 1034 | input_binding.inputRate = VK_VERTEX_INPUT_RATE_VERTEX; |
| 1035 | |
| 1036 | VkVertexInputAttributeDescription input_attribs[3]; |
| 1037 | |
| 1038 | input_attribs[0].binding = 0; |
| 1039 | // Location switch between attrib[0] and attrib[1] is intentional |
| 1040 | input_attribs[0].location = 1; |
| 1041 | input_attribs[0].format = VK_FORMAT_A8B8G8R8_UNORM_PACK32; |
| 1042 | input_attribs[0].offset = offsetof(VboEntry, input1); |
| 1043 | |
| 1044 | input_attribs[1].binding = 0; |
| 1045 | input_attribs[1].location = 0; |
| 1046 | input_attribs[1].format = VK_FORMAT_R16G16_UNORM; |
| 1047 | input_attribs[1].offset = offsetof(VboEntry, input0); |
| 1048 | |
| 1049 | input_attribs[2].binding = 0; |
| 1050 | input_attribs[2].location = 2; |
| 1051 | input_attribs[2].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 1052 | input_attribs[2].offset = offsetof(VboEntry, input2); |
| 1053 | |
sfricke-samsung | 1c0b96a | 2021-07-08 22:24:09 -0700 | [diff] [blame] | 1054 | char const *vsSource = R"glsl( |
| 1055 | #version 450 |
| 1056 | layout(location = 0) in vec2 input0; |
| 1057 | layout(location = 1) in vec4 input1; |
| 1058 | layout(location = 2) in vec4 input2; |
| 1059 | void main(){ |
| 1060 | gl_Position = input1 + input2; |
| 1061 | gl_Position.xy += input0; |
| 1062 | } |
| 1063 | )glsl"; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1064 | |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 1065 | VkShaderObj vs(this, vsSource, VK_SHADER_STAGE_VERTEX_BIT); |
| 1066 | VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1067 | |
| 1068 | VkPipelineObj pipe1(m_device); |
| 1069 | pipe1.AddDefaultColorAttachment(); |
| 1070 | pipe1.AddShader(&vs); |
| 1071 | pipe1.AddShader(&fs); |
| 1072 | pipe1.AddVertexInputBindings(&input_binding, 1); |
| 1073 | pipe1.AddVertexInputAttribs(&input_attribs[0], 3); |
| 1074 | pipe1.SetViewport(m_viewports); |
| 1075 | pipe1.SetScissor(m_scissors); |
| 1076 | pipe1.CreateVKPipeline(pipeline_layout.handle(), renderPass()); |
| 1077 | |
| 1078 | input_binding.stride = 6; |
| 1079 | |
| 1080 | VkPipelineObj pipe2(m_device); |
| 1081 | pipe2.AddDefaultColorAttachment(); |
| 1082 | pipe2.AddShader(&vs); |
| 1083 | pipe2.AddShader(&fs); |
| 1084 | pipe2.AddVertexInputBindings(&input_binding, 1); |
| 1085 | pipe2.AddVertexInputAttribs(&input_attribs[0], 3); |
| 1086 | pipe2.SetViewport(m_viewports); |
| 1087 | pipe2.SetScissor(m_scissors); |
| 1088 | pipe2.CreateVKPipeline(pipeline_layout.handle(), renderPass()); |
| 1089 | |
| 1090 | m_commandBuffer->begin(); |
| 1091 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 1092 | |
| 1093 | // Test with invalid buffer offset |
| 1094 | VkDeviceSize offset = 1; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1095 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle()); |
| 1096 | vk::CmdBindVertexBuffers(m_commandBuffer->handle(), 0, 1, &vbo.handle(), &offset); |
sfricke-samsung | 0cb6c4e | 2022-02-08 14:49:23 -0800 | [diff] [blame] | 1097 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-None-02721"); // attribute 0 |
| 1098 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-None-02721"); // attribute 1 |
| 1099 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-None-02721"); // attribute 2 |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1100 | m_commandBuffer->Draw(1, 0, 0, 0); |
| 1101 | m_errorMonitor->VerifyFound(); |
| 1102 | |
| 1103 | // Test with invalid buffer stride |
| 1104 | offset = 0; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1105 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.handle()); |
| 1106 | vk::CmdBindVertexBuffers(m_commandBuffer->handle(), 0, 1, &vbo.handle(), &offset); |
sfricke-samsung | 0cb6c4e | 2022-02-08 14:49:23 -0800 | [diff] [blame] | 1107 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-None-02721"); // attribute 0 |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1108 | // Attribute[1] is aligned properly even with a wrong stride |
sfricke-samsung | 0cb6c4e | 2022-02-08 14:49:23 -0800 | [diff] [blame] | 1109 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-None-02721"); // attribute 2 |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1110 | m_commandBuffer->Draw(1, 0, 0, 0); |
| 1111 | m_errorMonitor->VerifyFound(); |
| 1112 | |
| 1113 | m_commandBuffer->EndRenderPass(); |
| 1114 | m_commandBuffer->end(); |
| 1115 | } |
| 1116 | |
| 1117 | TEST_F(VkLayerTest, NonSimultaneousSecondaryMarksPrimary) { |
| 1118 | ASSERT_NO_FATAL_FAILURE(Init()); |
locke-lunarg | 77b9f7c | 2019-06-18 00:06:03 -0600 | [diff] [blame] | 1119 | const char *simultaneous_use_message = "UNASSIGNED-CoreValidation-DrawState-InvalidCommandBufferSimultaneousUse"; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1120 | |
| 1121 | VkCommandBufferObj secondary(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 1122 | |
| 1123 | secondary.begin(); |
| 1124 | secondary.end(); |
| 1125 | |
| 1126 | VkCommandBufferBeginInfo cbbi = { |
| 1127 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, |
| 1128 | nullptr, |
| 1129 | VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT, |
| 1130 | nullptr, |
| 1131 | }; |
| 1132 | |
| 1133 | m_commandBuffer->begin(&cbbi); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1134 | m_errorMonitor->SetDesiredFailureMsg(kWarningBit, simultaneous_use_message); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1135 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1136 | m_errorMonitor->VerifyFound(); |
| 1137 | m_commandBuffer->end(); |
| 1138 | } |
| 1139 | |
| 1140 | TEST_F(VkLayerTest, SimultaneousUseSecondaryTwoExecutes) { |
| 1141 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 1142 | |
John Zulauf | f1640d1 | 2019-08-13 15:39:58 -0600 | [diff] [blame] | 1143 | const char *simultaneous_use_message = "VUID-vkCmdExecuteCommands-pCommandBuffers-00092"; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1144 | |
| 1145 | VkCommandBufferObj secondary(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 1146 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 1147 | VkCommandBufferInheritanceInfo inh = LvlInitStruct<VkCommandBufferInheritanceInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1148 | VkCommandBufferBeginInfo cbbi = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr, 0, &inh}; |
| 1149 | |
| 1150 | secondary.begin(&cbbi); |
| 1151 | secondary.end(); |
| 1152 | |
| 1153 | m_commandBuffer->begin(); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1154 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1155 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, simultaneous_use_message); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1156 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1157 | m_errorMonitor->VerifyFound(); |
| 1158 | m_commandBuffer->end(); |
| 1159 | } |
| 1160 | |
| 1161 | TEST_F(VkLayerTest, SimultaneousUseSecondarySingleExecute) { |
| 1162 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 1163 | |
| 1164 | // variation on previous test executing the same CB twice in the same |
| 1165 | // CmdExecuteCommands call |
| 1166 | |
John Zulauf | f1640d1 | 2019-08-13 15:39:58 -0600 | [diff] [blame] | 1167 | const char *simultaneous_use_message = "VUID-vkCmdExecuteCommands-pCommandBuffers-00093"; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1168 | |
| 1169 | VkCommandBufferObj secondary(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 1170 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 1171 | VkCommandBufferInheritanceInfo inh = LvlInitStruct<VkCommandBufferInheritanceInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1172 | VkCommandBufferBeginInfo cbbi = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr, 0, &inh}; |
| 1173 | |
| 1174 | secondary.begin(&cbbi); |
| 1175 | secondary.end(); |
| 1176 | |
| 1177 | m_commandBuffer->begin(); |
| 1178 | VkCommandBuffer cbs[] = {secondary.handle(), secondary.handle()}; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1179 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, simultaneous_use_message); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1180 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 2, cbs); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1181 | m_errorMonitor->VerifyFound(); |
| 1182 | m_commandBuffer->end(); |
| 1183 | } |
| 1184 | |
| 1185 | TEST_F(VkLayerTest, SimultaneousUseOneShot) { |
| 1186 | TEST_DESCRIPTION("Submit the same command buffer twice in one submit looking for simultaneous use and one time submit errors"); |
| 1187 | const char *simultaneous_use_message = "is already in use and is not marked for simultaneous use"; |
| 1188 | const char *one_shot_message = "VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has been submitted"; |
| 1189 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 1190 | |
| 1191 | VkCommandBuffer cmd_bufs[2]; |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 1192 | VkCommandBufferAllocateInfo alloc_info = LvlInitStruct<VkCommandBufferAllocateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1193 | alloc_info.commandBufferCount = 2; |
| 1194 | alloc_info.commandPool = m_commandPool->handle(); |
| 1195 | alloc_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1196 | vk::AllocateCommandBuffers(m_device->device(), &alloc_info, cmd_bufs); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1197 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 1198 | VkCommandBufferBeginInfo cb_binfo = LvlInitStruct<VkCommandBufferBeginInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1199 | cb_binfo.pInheritanceInfo = VK_NULL_HANDLE; |
| 1200 | cb_binfo.flags = 0; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1201 | vk::BeginCommandBuffer(cmd_bufs[0], &cb_binfo); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1202 | VkViewport viewport = {0, 0, 16, 16, 0, 1}; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1203 | vk::CmdSetViewport(cmd_bufs[0], 0, 1, &viewport); |
| 1204 | vk::EndCommandBuffer(cmd_bufs[0]); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1205 | VkCommandBuffer duplicates[2] = {cmd_bufs[0], cmd_bufs[0]}; |
| 1206 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 1207 | VkSubmitInfo submit_info = LvlInitStruct<VkSubmitInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1208 | submit_info.commandBufferCount = 2; |
| 1209 | submit_info.pCommandBuffers = duplicates; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1210 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, simultaneous_use_message); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1211 | vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1212 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1213 | vk::QueueWaitIdle(m_device->m_queue); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1214 | |
| 1215 | // Set one time use and now look for one time submit |
| 1216 | duplicates[0] = duplicates[1] = cmd_bufs[1]; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1217 | cb_binfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1218 | vk::BeginCommandBuffer(cmd_bufs[1], &cb_binfo); |
| 1219 | vk::CmdSetViewport(cmd_bufs[1], 0, 1, &viewport); |
| 1220 | vk::EndCommandBuffer(cmd_bufs[1]); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 1221 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkQueueSubmit-pCommandBuffers-00071"); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1222 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, one_shot_message); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1223 | vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1224 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1225 | vk::QueueWaitIdle(m_device->m_queue); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1226 | } |
| 1227 | |
| 1228 | TEST_F(VkLayerTest, DrawTimeImageViewTypeMismatchWithPipeline) { |
| 1229 | TEST_DESCRIPTION( |
| 1230 | "Test that an error is produced when an image view type does not match the dimensionality declared in the shader"); |
| 1231 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1232 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "requires an image view of type VK_IMAGE_VIEW_TYPE_3D"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1233 | |
| 1234 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 1235 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1236 | |
sfricke-samsung | 1c0b96a | 2021-07-08 22:24:09 -0700 | [diff] [blame] | 1237 | char const *fsSource = R"glsl( |
| 1238 | #version 450 |
| 1239 | layout(set=0, binding=0) uniform sampler3D s; |
| 1240 | layout(location=0) out vec4 color; |
| 1241 | void main() { |
| 1242 | color = texture(s, vec3(0)); |
| 1243 | } |
| 1244 | )glsl"; |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 1245 | VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT); |
| 1246 | VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1247 | |
| 1248 | VkPipelineObj pipe(m_device); |
| 1249 | pipe.AddShader(&vs); |
| 1250 | pipe.AddShader(&fs); |
| 1251 | pipe.AddDefaultColorAttachment(); |
| 1252 | |
| 1253 | VkTextureObj texture(m_device, nullptr); |
| 1254 | VkSamplerObj sampler(m_device); |
| 1255 | |
| 1256 | VkDescriptorSetObj descriptorSet(m_device); |
| 1257 | descriptorSet.AppendSamplerTexture(&sampler, &texture); |
| 1258 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 1259 | |
| 1260 | VkResult err = pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 1261 | ASSERT_VK_SUCCESS(err); |
| 1262 | |
| 1263 | m_commandBuffer->begin(); |
| 1264 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 1265 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1266 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1267 | m_commandBuffer->BindDescriptorSet(descriptorSet); |
| 1268 | |
| 1269 | VkViewport viewport = {0, 0, 16, 16, 0, 1}; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1270 | vk::CmdSetViewport(m_commandBuffer->handle(), 0, 1, &viewport); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1271 | VkRect2D scissor = {{0, 0}, {16, 16}}; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1272 | vk::CmdSetScissor(m_commandBuffer->handle(), 0, 1, &scissor); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1273 | |
| 1274 | // error produced here. |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1275 | vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1276 | |
| 1277 | m_errorMonitor->VerifyFound(); |
| 1278 | |
| 1279 | m_commandBuffer->EndRenderPass(); |
| 1280 | m_commandBuffer->end(); |
| 1281 | } |
| 1282 | |
| 1283 | TEST_F(VkLayerTest, DrawTimeImageMultisampleMismatchWithPipeline) { |
| 1284 | TEST_DESCRIPTION( |
| 1285 | "Test that an error is produced when a multisampled images are consumed via singlesample images types in the shader, or " |
| 1286 | "vice versa."); |
| 1287 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1288 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "requires bound image to have multiple samples"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1289 | |
| 1290 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 1291 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1292 | |
sfricke-samsung | 1c0b96a | 2021-07-08 22:24:09 -0700 | [diff] [blame] | 1293 | char const *fsSource = R"glsl( |
| 1294 | #version 450 |
| 1295 | layout(set=0, binding=0) uniform sampler2DMS s; |
| 1296 | layout(location=0) out vec4 color; |
| 1297 | void main() { |
| 1298 | color = texelFetch(s, ivec2(0), 0); |
| 1299 | } |
| 1300 | )glsl"; |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 1301 | VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT); |
| 1302 | VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1303 | |
| 1304 | VkPipelineObj pipe(m_device); |
| 1305 | pipe.AddShader(&vs); |
| 1306 | pipe.AddShader(&fs); |
| 1307 | pipe.AddDefaultColorAttachment(); |
| 1308 | |
| 1309 | VkTextureObj texture(m_device, nullptr); // THIS LINE CAUSES CRASH ON MALI |
| 1310 | VkSamplerObj sampler(m_device); |
| 1311 | |
| 1312 | VkDescriptorSetObj descriptorSet(m_device); |
| 1313 | descriptorSet.AppendSamplerTexture(&sampler, &texture); |
| 1314 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 1315 | |
| 1316 | VkResult err = pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 1317 | ASSERT_VK_SUCCESS(err); |
| 1318 | |
| 1319 | m_commandBuffer->begin(); |
| 1320 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 1321 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1322 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1323 | m_commandBuffer->BindDescriptorSet(descriptorSet); |
| 1324 | |
| 1325 | VkViewport viewport = {0, 0, 16, 16, 0, 1}; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1326 | vk::CmdSetViewport(m_commandBuffer->handle(), 0, 1, &viewport); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1327 | VkRect2D scissor = {{0, 0}, {16, 16}}; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1328 | vk::CmdSetScissor(m_commandBuffer->handle(), 0, 1, &scissor); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1329 | |
| 1330 | // error produced here. |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1331 | vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1332 | |
| 1333 | m_errorMonitor->VerifyFound(); |
| 1334 | |
| 1335 | m_commandBuffer->EndRenderPass(); |
| 1336 | m_commandBuffer->end(); |
| 1337 | } |
| 1338 | |
| 1339 | TEST_F(VkLayerTest, DrawTimeImageComponentTypeMismatchWithPipeline) { |
| 1340 | TEST_DESCRIPTION( |
| 1341 | "Test that an error is produced when the component type of an imageview disagrees with the type in the shader."); |
| 1342 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1343 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "SINT component type, but bound descriptor"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1344 | |
| 1345 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 1346 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1347 | |
sfricke-samsung | 1c0b96a | 2021-07-08 22:24:09 -0700 | [diff] [blame] | 1348 | char const *fsSource = R"glsl( |
| 1349 | #version 450 |
| 1350 | layout(set=0, binding=0) uniform isampler2D s; |
| 1351 | layout(location=0) out vec4 color; |
| 1352 | void main() { |
| 1353 | color = texelFetch(s, ivec2(0), 0); |
| 1354 | } |
| 1355 | )glsl"; |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 1356 | VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT); |
| 1357 | VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1358 | |
| 1359 | VkPipelineObj pipe(m_device); |
| 1360 | pipe.AddShader(&vs); |
| 1361 | pipe.AddShader(&fs); |
| 1362 | pipe.AddDefaultColorAttachment(); |
| 1363 | |
| 1364 | VkTextureObj texture(m_device, nullptr); // UNORM texture by default, incompatible with isampler2D |
| 1365 | VkSamplerObj sampler(m_device); |
| 1366 | |
| 1367 | VkDescriptorSetObj descriptorSet(m_device); |
| 1368 | descriptorSet.AppendSamplerTexture(&sampler, &texture); |
| 1369 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 1370 | |
| 1371 | VkResult err = pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 1372 | ASSERT_VK_SUCCESS(err); |
| 1373 | |
| 1374 | m_commandBuffer->begin(); |
| 1375 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 1376 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1377 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1378 | m_commandBuffer->BindDescriptorSet(descriptorSet); |
| 1379 | |
| 1380 | VkViewport viewport = {0, 0, 16, 16, 0, 1}; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1381 | vk::CmdSetViewport(m_commandBuffer->handle(), 0, 1, &viewport); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1382 | VkRect2D scissor = {{0, 0}, {16, 16}}; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1383 | vk::CmdSetScissor(m_commandBuffer->handle(), 0, 1, &scissor); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1384 | |
| 1385 | // error produced here. |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1386 | vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1387 | |
| 1388 | m_errorMonitor->VerifyFound(); |
| 1389 | |
| 1390 | m_commandBuffer->EndRenderPass(); |
| 1391 | m_commandBuffer->end(); |
| 1392 | } |
| 1393 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1394 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
| 1395 | TEST_DESCRIPTION( |
| 1396 | "Try to copy between images with the source subresource having a different layerCount than the destination subresource"); |
sfricke-samsung | 30b094c | 2020-05-30 11:42:11 -0700 | [diff] [blame] | 1397 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
| 1398 | bool maintenance1 = false; |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 1399 | if (DeviceExtensionSupported(gpu(), nullptr, VK_KHR_MAINTENANCE_1_EXTENSION_NAME)) { |
| 1400 | m_device_extension_names.push_back(VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
sfricke-samsung | 30b094c | 2020-05-30 11:42:11 -0700 | [diff] [blame] | 1401 | maintenance1 = true; |
| 1402 | } |
| 1403 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1404 | |
| 1405 | VkFormat image_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1406 | VkFormatProperties format_props; |
| 1407 | vk::GetPhysicalDeviceFormatProperties(m_device->phy().handle(), image_format, &format_props); |
| 1408 | if ((format_props.optimalTilingFeatures & (VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT)) == 0) { |
| 1409 | printf("%s Transfer for format is not supported.\n", kSkipPrefix); |
| 1410 | return; |
| 1411 | } |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1412 | |
| 1413 | // Create two images to copy between |
| 1414 | VkImageObj src_image_obj(m_device); |
| 1415 | VkImageObj dst_image_obj(m_device); |
| 1416 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 1417 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1418 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
sfricke-samsung | 30b094c | 2020-05-30 11:42:11 -0700 | [diff] [blame] | 1419 | image_create_info.format = image_format; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1420 | image_create_info.extent.width = 32; |
| 1421 | image_create_info.extent.height = 32; |
| 1422 | image_create_info.extent.depth = 1; |
| 1423 | image_create_info.mipLevels = 1; |
| 1424 | image_create_info.arrayLayers = 4; |
| 1425 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1426 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 1427 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 1428 | image_create_info.flags = 0; |
| 1429 | |
| 1430 | src_image_obj.init(&image_create_info); |
| 1431 | ASSERT_TRUE(src_image_obj.initialized()); |
| 1432 | |
| 1433 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 1434 | dst_image_obj.init(&image_create_info); |
| 1435 | ASSERT_TRUE(dst_image_obj.initialized()); |
| 1436 | |
| 1437 | m_commandBuffer->begin(); |
| 1438 | VkImageCopy copyRegion; |
| 1439 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 1440 | copyRegion.srcSubresource.mipLevel = 0; |
| 1441 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 1442 | copyRegion.srcSubresource.layerCount = 1; |
| 1443 | copyRegion.srcOffset.x = 0; |
| 1444 | copyRegion.srcOffset.y = 0; |
| 1445 | copyRegion.srcOffset.z = 0; |
| 1446 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 1447 | copyRegion.dstSubresource.mipLevel = 0; |
| 1448 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 1449 | // Introduce failure by forcing the dst layerCount to differ from src |
| 1450 | copyRegion.dstSubresource.layerCount = 3; |
| 1451 | copyRegion.dstOffset.x = 0; |
| 1452 | copyRegion.dstOffset.y = 0; |
| 1453 | copyRegion.dstOffset.z = 0; |
| 1454 | copyRegion.extent.width = 1; |
| 1455 | copyRegion.extent.height = 1; |
| 1456 | copyRegion.extent.depth = 1; |
| 1457 | |
sfricke-samsung | 30b094c | 2020-05-30 11:42:11 -0700 | [diff] [blame] | 1458 | const char *vuid = (maintenance1 == true) ? "VUID-VkImageCopy-extent-00140" : "VUID-VkImageCopy-layerCount-00138"; |
| 1459 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1460 | m_commandBuffer->CopyImage(src_image_obj.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image_obj.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 1461 | ©Region); |
| 1462 | m_errorMonitor->VerifyFound(); |
| 1463 | } |
| 1464 | |
| 1465 | TEST_F(VkLayerTest, CompressedImageMipCopyTests) { |
| 1466 | TEST_DESCRIPTION("Image/Buffer copies for higher mip levels"); |
| 1467 | |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 1468 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
| 1469 | |
| 1470 | bool copy_commands2 = false; |
| 1471 | if (DeviceExtensionSupported(gpu(), nullptr, VK_KHR_COPY_COMMANDS_2_EXTENSION_NAME)) { |
| 1472 | m_device_extension_names.push_back(VK_KHR_COPY_COMMANDS_2_EXTENSION_NAME); |
| 1473 | copy_commands2 = true; |
| 1474 | } |
| 1475 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1476 | |
| 1477 | PFN_vkCmdCopyBufferToImage2KHR vkCmdCopyBufferToImage2Function = nullptr; |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 1478 | if (copy_commands2) { |
| 1479 | vkCmdCopyBufferToImage2Function = |
| 1480 | (PFN_vkCmdCopyBufferToImage2KHR)vk::GetDeviceProcAddr(m_device->handle(), "vkCmdCopyBufferToImage2KHR"); |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 1481 | } |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1482 | |
| 1483 | VkPhysicalDeviceFeatures device_features = {}; |
| 1484 | ASSERT_NO_FATAL_FAILURE(GetPhysicalDeviceFeatures(&device_features)); |
| 1485 | VkFormat compressed_format = VK_FORMAT_UNDEFINED; |
| 1486 | if (device_features.textureCompressionBC) { |
| 1487 | compressed_format = VK_FORMAT_BC3_SRGB_BLOCK; |
| 1488 | } else if (device_features.textureCompressionETC2) { |
| 1489 | compressed_format = VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK; |
| 1490 | } else if (device_features.textureCompressionASTC_LDR) { |
| 1491 | compressed_format = VK_FORMAT_ASTC_4x4_UNORM_BLOCK; |
| 1492 | } else { |
| 1493 | printf("%s No compressed formats supported - CompressedImageMipCopyTests skipped.\n", kSkipPrefix); |
| 1494 | return; |
| 1495 | } |
| 1496 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 1497 | VkImageCreateInfo ci = LvlInitStruct<VkImageCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1498 | ci.flags = 0; |
| 1499 | ci.imageType = VK_IMAGE_TYPE_2D; |
| 1500 | ci.format = compressed_format; |
| 1501 | ci.extent = {32, 32, 1}; |
| 1502 | ci.mipLevels = 6; |
| 1503 | ci.arrayLayers = 1; |
| 1504 | ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1505 | ci.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 1506 | ci.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 1507 | ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1508 | ci.queueFamilyIndexCount = 0; |
| 1509 | ci.pQueueFamilyIndices = NULL; |
| 1510 | ci.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 1511 | |
| 1512 | VkImageObj image(m_device); |
| 1513 | image.init(&ci); |
| 1514 | ASSERT_TRUE(image.initialized()); |
| 1515 | |
| 1516 | VkImageObj odd_image(m_device); |
| 1517 | ci.extent = {31, 32, 1}; // Mips are [31,32] [15,16] [7,8] [3,4], [1,2] [1,1] |
| 1518 | odd_image.init(&ci); |
| 1519 | ASSERT_TRUE(odd_image.initialized()); |
| 1520 | |
| 1521 | // Allocate buffers |
| 1522 | VkMemoryPropertyFlags reqs = 0; |
| 1523 | VkBufferObj buffer_1024, buffer_64, buffer_16, buffer_8; |
| 1524 | buffer_1024.init_as_src_and_dst(*m_device, 1024, reqs); |
| 1525 | buffer_64.init_as_src_and_dst(*m_device, 64, reqs); |
| 1526 | buffer_16.init_as_src_and_dst(*m_device, 16, reqs); |
| 1527 | buffer_8.init_as_src_and_dst(*m_device, 8, reqs); |
| 1528 | |
| 1529 | VkBufferImageCopy region = {}; |
| 1530 | region.bufferRowLength = 0; |
| 1531 | region.bufferImageHeight = 0; |
| 1532 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 1533 | region.imageSubresource.layerCount = 1; |
| 1534 | region.imageOffset = {0, 0, 0}; |
| 1535 | region.bufferOffset = 0; |
| 1536 | |
| 1537 | // start recording |
| 1538 | m_commandBuffer->begin(); |
| 1539 | |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 1540 | VkMemoryBarrier mem_barriers[3]; |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 1541 | mem_barriers[0] = LvlInitStruct<VkMemoryBarrier>(); |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 1542 | mem_barriers[0].srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; |
| 1543 | mem_barriers[0].dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 1544 | mem_barriers[1] = LvlInitStruct<VkMemoryBarrier>(); |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 1545 | mem_barriers[1].srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT; |
| 1546 | mem_barriers[1].dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 1547 | mem_barriers[2] = LvlInitStruct<VkMemoryBarrier>(); |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 1548 | mem_barriers[2].srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; |
| 1549 | mem_barriers[2].dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; |
| 1550 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1551 | // Mip level copies that work - 5 levels |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1552 | |
| 1553 | // Mip 0 should fit in 1k buffer - 1k texels @ 1b each |
| 1554 | region.imageExtent = {32, 32, 1}; |
| 1555 | region.imageSubresource.mipLevel = 0; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1556 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_1024.handle(), 1, ®ion); |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 1557 | |
| 1558 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, |
| 1559 | &mem_barriers[2], 0, nullptr, 0, nullptr); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1560 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_1024.handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1561 | |
| 1562 | // Mip 2 should fit in 64b buffer - 64 texels @ 1b each |
| 1563 | region.imageExtent = {8, 8, 1}; |
| 1564 | region.imageSubresource.mipLevel = 2; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1565 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_64.handle(), 1, ®ion); |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 1566 | |
| 1567 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 2, |
| 1568 | &mem_barriers[1], 0, nullptr, 0, nullptr); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1569 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_64.handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1570 | |
| 1571 | // Mip 3 should fit in 16b buffer - 16 texels @ 1b each |
| 1572 | region.imageExtent = {4, 4, 1}; |
| 1573 | region.imageSubresource.mipLevel = 3; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1574 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_16.handle(), 1, ®ion); |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 1575 | |
| 1576 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 2, |
| 1577 | &mem_barriers[1], 0, nullptr, 0, nullptr); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1578 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_16.handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1579 | |
| 1580 | // Mip 4&5 should fit in 16b buffer with no complaint - 4 & 1 texels @ 1b each |
| 1581 | region.imageExtent = {2, 2, 1}; |
| 1582 | region.imageSubresource.mipLevel = 4; |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 1583 | |
| 1584 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, |
| 1585 | &mem_barriers[0], 0, nullptr, 0, nullptr); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1586 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_16.handle(), 1, ®ion); |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 1587 | |
| 1588 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 2, |
| 1589 | &mem_barriers[1], 0, nullptr, 0, nullptr); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1590 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_16.handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1591 | |
| 1592 | region.imageExtent = {1, 1, 1}; |
| 1593 | region.imageSubresource.mipLevel = 5; |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 1594 | |
| 1595 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, |
| 1596 | &mem_barriers[0], 0, nullptr, 0, nullptr); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1597 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_16.handle(), 1, ®ion); |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 1598 | |
| 1599 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 2, |
| 1600 | &mem_barriers[1], 0, nullptr, 0, nullptr); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1601 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_16.handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1602 | |
| 1603 | // Buffer must accommodate a full compressed block, regardless of texel count |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1604 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImageToBuffer-pRegions-00183"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1605 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_8.handle(), 1, ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1606 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1607 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyBufferToImage-pRegions-00171"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1608 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_8.handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1609 | m_errorMonitor->VerifyFound(); |
| 1610 | |
| 1611 | // Copy width < compressed block size, but not the full mip width |
| 1612 | region.imageExtent = {1, 2, 1}; |
| 1613 | region.imageSubresource.mipLevel = 4; |
sfricke-samsung | 88ac6fe | 2020-10-24 10:00:13 -0700 | [diff] [blame] | 1614 | // width not a multiple of compressed block width |
| 1615 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImageToBuffer-imageExtent-00207"); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1616 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1617 | "VUID-vkCmdCopyImageToBuffer-imageOffset-01794"); // image transfer granularity |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1618 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_16.handle(), 1, ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1619 | m_errorMonitor->VerifyFound(); |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 1620 | |
sfricke-samsung | 88ac6fe | 2020-10-24 10:00:13 -0700 | [diff] [blame] | 1621 | m_errorMonitor->SetDesiredFailureMsg( |
| 1622 | kErrorBit, "VUID-vkCmdCopyBufferToImage-imageExtent-00207"); // width not a multiple of compressed block width |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1623 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1624 | "VUID-vkCmdCopyBufferToImage-imageOffset-01793"); // image transfer granularity |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1625 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_16.handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1626 | m_errorMonitor->VerifyFound(); |
| 1627 | |
| 1628 | // Copy height < compressed block size but not the full mip height |
| 1629 | region.imageExtent = {2, 1, 1}; |
sfricke-samsung | 88ac6fe | 2020-10-24 10:00:13 -0700 | [diff] [blame] | 1630 | m_errorMonitor->SetDesiredFailureMsg( |
| 1631 | kErrorBit, "VUID-vkCmdCopyImageToBuffer-imageExtent-00208"); // height not a multiple of compressed block width |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1632 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1633 | "VUID-vkCmdCopyImageToBuffer-imageOffset-01794"); // image transfer granularity |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1634 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_16.handle(), 1, ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1635 | m_errorMonitor->VerifyFound(); |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 1636 | |
sfricke-samsung | 88ac6fe | 2020-10-24 10:00:13 -0700 | [diff] [blame] | 1637 | m_errorMonitor->SetDesiredFailureMsg( |
| 1638 | kErrorBit, "VUID-vkCmdCopyBufferToImage-imageExtent-00208"); // height not a multiple of compressed block width |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1639 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1640 | "VUID-vkCmdCopyBufferToImage-imageOffset-01793"); // image transfer granularity |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1641 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_16.handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1642 | m_errorMonitor->VerifyFound(); |
| 1643 | |
| 1644 | // Offsets must be multiple of compressed block size |
| 1645 | region.imageOffset = {1, 1, 0}; |
| 1646 | region.imageExtent = {1, 1, 1}; |
sfricke-samsung | 88ac6fe | 2020-10-24 10:00:13 -0700 | [diff] [blame] | 1647 | // imageOffset not a multiple of block size |
| 1648 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImageToBuffer-imageOffset-00205"); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1649 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1650 | "VUID-vkCmdCopyImageToBuffer-imageOffset-01794"); // image transfer granularity |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1651 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_16.handle(), 1, ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1652 | m_errorMonitor->VerifyFound(); |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 1653 | |
sfricke-samsung | 88ac6fe | 2020-10-24 10:00:13 -0700 | [diff] [blame] | 1654 | m_errorMonitor->SetDesiredFailureMsg( |
| 1655 | kErrorBit, "VUID-vkCmdCopyBufferToImage-imageOffset-00205"); // imageOffset not a multiple of block size |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1656 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1657 | "VUID-vkCmdCopyBufferToImage-imageOffset-01793"); // image transfer granularity |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1658 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_16.handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1659 | m_errorMonitor->VerifyFound(); |
| 1660 | |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 1661 | // Equivalent test using KHR_copy_commands2 |
| 1662 | if (copy_commands2 && vkCmdCopyBufferToImage2Function) { |
| 1663 | const VkBufferImageCopy2KHR region2 = {VK_STRUCTURE_TYPE_BUFFER_IMAGE_COPY_2_KHR, |
| 1664 | NULL, |
| 1665 | region.bufferOffset, |
| 1666 | region.bufferRowLength, |
| 1667 | region.bufferImageHeight, |
| 1668 | region.imageSubresource, |
| 1669 | region.imageOffset, |
| 1670 | region.imageExtent}; |
| 1671 | const VkCopyBufferToImageInfo2KHR copy_buffer_to_image_info2 = {VK_STRUCTURE_TYPE_COPY_BUFFER_TO_IMAGE_INFO_2_KHR, |
| 1672 | NULL, |
| 1673 | buffer_16.handle(), |
| 1674 | image.handle(), |
| 1675 | VK_IMAGE_LAYOUT_GENERAL, |
| 1676 | 1, |
| 1677 | ®ion2}; |
sfricke-samsung | 88ac6fe | 2020-10-24 10:00:13 -0700 | [diff] [blame] | 1678 | m_errorMonitor->SetDesiredFailureMsg( |
Tony-LunarG | 953d55a | 2021-11-11 14:20:25 -0700 | [diff] [blame] | 1679 | kErrorBit, "VUID-VkCopyBufferToImageInfo2-imageOffset-00205"); // imageOffset not a multiple of block size |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 1680 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
Tony-LunarG | 953d55a | 2021-11-11 14:20:25 -0700 | [diff] [blame] | 1681 | "VUID-VkCopyBufferToImageInfo2-imageOffset-01793"); // image transfer granularity |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 1682 | vkCmdCopyBufferToImage2Function(m_commandBuffer->handle(), ©_buffer_to_image_info2); |
| 1683 | m_errorMonitor->VerifyFound(); |
| 1684 | } |
| 1685 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1686 | // Offset + extent width = mip width - should succeed |
| 1687 | region.imageOffset = {4, 4, 0}; |
| 1688 | region.imageExtent = {3, 4, 1}; |
| 1689 | region.imageSubresource.mipLevel = 2; |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 1690 | |
| 1691 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, |
| 1692 | &mem_barriers[0], 0, nullptr, 0, nullptr); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1693 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), odd_image.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_16.handle(), 1, |
| 1694 | ®ion); |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 1695 | |
| 1696 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 2, |
| 1697 | &mem_barriers[1], 0, nullptr, 0, nullptr); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1698 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_16.handle(), odd_image.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 1699 | ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1700 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1701 | // Offset + extent width < mip width and not a multiple of block width - should fail |
| 1702 | region.imageExtent = {3, 3, 1}; |
sfricke-samsung | 88ac6fe | 2020-10-24 10:00:13 -0700 | [diff] [blame] | 1703 | m_errorMonitor->SetDesiredFailureMsg( |
| 1704 | kErrorBit, "VUID-vkCmdCopyImageToBuffer-imageExtent-00208"); // offset+extent not a multiple of block width |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1705 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1706 | "VUID-vkCmdCopyImageToBuffer-imageOffset-01794"); // image transfer granularity |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1707 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), odd_image.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_16.handle(), 1, |
| 1708 | ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1709 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 88ac6fe | 2020-10-24 10:00:13 -0700 | [diff] [blame] | 1710 | m_errorMonitor->SetDesiredFailureMsg( |
| 1711 | kErrorBit, "VUID-vkCmdCopyBufferToImage-imageExtent-00208"); // offset+extent not a multiple of block width |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1712 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1713 | "VUID-vkCmdCopyBufferToImage-imageOffset-01793"); // image transfer granularity |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1714 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_16.handle(), odd_image.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 1715 | ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1716 | m_errorMonitor->VerifyFound(); |
| 1717 | } |
| 1718 | |
| 1719 | TEST_F(VkLayerTest, ImageBufferCopyTests) { |
| 1720 | TEST_DESCRIPTION("Image to buffer and buffer to image tests"); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1721 | |
| 1722 | // Enable KHR multiplane req'd extensions for multi-planar copy tests |
| 1723 | bool mp_extensions = InstanceExtensionSupported(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, |
| 1724 | VK_KHR_GET_MEMORY_REQUIREMENTS_2_SPEC_VERSION); |
| 1725 | if (mp_extensions) { |
| 1726 | m_instance_extension_names.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 1727 | } |
Mark Lobodzinski | 09ce9c4 | 2020-03-06 10:02:44 -0700 | [diff] [blame] | 1728 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor, nullptr)); |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 1729 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1730 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME); |
| 1731 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_BIND_MEMORY_2_EXTENSION_NAME); |
| 1732 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME); |
| 1733 | if (mp_extensions) { |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 1734 | m_device_extension_names.push_back(VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1735 | m_device_extension_names.push_back(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME); |
| 1736 | m_device_extension_names.push_back(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME); |
| 1737 | m_device_extension_names.push_back(VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME); |
| 1738 | } |
| 1739 | ASSERT_NO_FATAL_FAILURE(InitState()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1740 | |
| 1741 | // Bail if any dimension of transfer granularity is 0. |
| 1742 | auto index = m_device->graphics_queue_node_index_; |
| 1743 | auto queue_family_properties = m_device->phy().queue_properties(); |
| 1744 | if ((queue_family_properties[index].minImageTransferGranularity.depth == 0) || |
| 1745 | (queue_family_properties[index].minImageTransferGranularity.width == 0) || |
| 1746 | (queue_family_properties[index].minImageTransferGranularity.height == 0)) { |
| 1747 | printf("%s Subresource copies are disallowed when xfer granularity (x|y|z) is 0. Skipped.\n", kSkipPrefix); |
| 1748 | return; |
| 1749 | } |
| 1750 | |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1751 | // All VkImageObj must be defined here as if defined inside below scopes will cause image memory to be deleted when out of scope |
| 1752 | // and invalidates the entire command buffer. This prevents from having to reset the commmand buffer every scope rgba |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1753 | VkImageObj image_64k(m_device); // 128^2 texels, 64k |
| 1754 | VkImageObj image_16k(m_device); // 64^2 texels, 16k |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1755 | // depth stencil |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1756 | VkImageObj image_16k_depth(m_device); // 64^2 texels, depth, 16k |
| 1757 | VkImageObj ds_image_4D_1S(m_device); // 256^2 texels, 512kb (256k depth, 64k stencil, 192k pack) |
| 1758 | VkImageObj ds_image_3D_1S(m_device); // 256^2 texels, 256kb (192k depth, 64k stencil) |
| 1759 | VkImageObj ds_image_2D(m_device); // 256^2 texels, 128k (128k depth) |
| 1760 | VkImageObj ds_image_1S(m_device); // 256^2 texels, 64k (64k stencil) |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1761 | // compression |
| 1762 | VkImageObj image_16k_4x4comp(m_device); // 128^2 texels as 32^2 compressed (4x4) blocks, 16k |
| 1763 | VkImageObj image_NPOT_4x4comp(m_device); // 130^2 texels as 33^2 compressed (4x4) blocks |
| 1764 | // multi-planar |
| 1765 | VkImageObj image_multi_planar(m_device); // 128^2 texels in plane_0 and 64^2 texels in plane_1 |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1766 | |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1767 | // Verify R8G8B8A8_UINT format is supported for transfer |
| 1768 | bool missing_rgba_support = false; |
| 1769 | VkFormatProperties props = {0, 0, 0}; |
| 1770 | vk::GetPhysicalDeviceFormatProperties(m_device->phy().handle(), VK_FORMAT_R8G8B8A8_UINT, &props); |
| 1771 | missing_rgba_support |= (props.bufferFeatures == 0 && props.linearTilingFeatures == 0 && props.optimalTilingFeatures == 0); |
| 1772 | missing_rgba_support |= (props.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT) == 0; |
| 1773 | missing_rgba_support |= (props.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_DST_BIT) == 0; |
| 1774 | |
| 1775 | if (!missing_rgba_support) { |
| 1776 | image_64k.Init(128, 128, 1, VK_FORMAT_R8G8B8A8_UINT, |
| 1777 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 1778 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 1779 | ASSERT_TRUE(image_64k.initialized()); |
| 1780 | |
| 1781 | image_16k.Init(64, 64, 1, VK_FORMAT_R8G8B8A8_UINT, |
| 1782 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 1783 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 1784 | ASSERT_TRUE(image_16k.initialized()); |
| 1785 | } |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1786 | |
| 1787 | // Verify all needed Depth/Stencil formats are supported |
| 1788 | bool missing_ds_support = false; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1789 | vk::GetPhysicalDeviceFormatProperties(m_device->phy().handle(), VK_FORMAT_D32_SFLOAT_S8_UINT, &props); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1790 | missing_ds_support |= (props.bufferFeatures == 0 && props.linearTilingFeatures == 0 && props.optimalTilingFeatures == 0); |
| 1791 | missing_ds_support |= (props.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT) == 0; |
| 1792 | missing_ds_support |= (props.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_DST_BIT) == 0; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1793 | vk::GetPhysicalDeviceFormatProperties(m_device->phy().handle(), VK_FORMAT_D24_UNORM_S8_UINT, &props); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1794 | missing_ds_support |= (props.bufferFeatures == 0 && props.linearTilingFeatures == 0 && props.optimalTilingFeatures == 0); |
| 1795 | missing_ds_support |= (props.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT) == 0; |
| 1796 | missing_ds_support |= (props.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_DST_BIT) == 0; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1797 | vk::GetPhysicalDeviceFormatProperties(m_device->phy().handle(), VK_FORMAT_D16_UNORM, &props); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1798 | missing_ds_support |= (props.bufferFeatures == 0 && props.linearTilingFeatures == 0 && props.optimalTilingFeatures == 0); |
| 1799 | missing_ds_support |= (props.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT) == 0; |
| 1800 | missing_ds_support |= (props.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_DST_BIT) == 0; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 1801 | vk::GetPhysicalDeviceFormatProperties(m_device->phy().handle(), VK_FORMAT_S8_UINT, &props); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1802 | missing_ds_support |= (props.bufferFeatures == 0 && props.linearTilingFeatures == 0 && props.optimalTilingFeatures == 0); |
| 1803 | missing_ds_support |= (props.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT) == 0; |
| 1804 | missing_ds_support |= (props.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_DST_BIT) == 0; |
| 1805 | |
| 1806 | if (!missing_ds_support) { |
| 1807 | image_16k_depth.Init(64, 64, 1, VK_FORMAT_D24_UNORM_S8_UINT, |
| 1808 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 1809 | ASSERT_TRUE(image_16k_depth.initialized()); |
| 1810 | |
| 1811 | ds_image_4D_1S.Init( |
| 1812 | 256, 256, 1, VK_FORMAT_D32_SFLOAT_S8_UINT, |
| 1813 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, |
| 1814 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 1815 | ASSERT_TRUE(ds_image_4D_1S.initialized()); |
| 1816 | |
| 1817 | ds_image_3D_1S.Init( |
| 1818 | 256, 256, 1, VK_FORMAT_D24_UNORM_S8_UINT, |
| 1819 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, |
| 1820 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 1821 | ASSERT_TRUE(ds_image_3D_1S.initialized()); |
| 1822 | |
| 1823 | ds_image_2D.Init( |
| 1824 | 256, 256, 1, VK_FORMAT_D16_UNORM, |
| 1825 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, |
| 1826 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 1827 | ASSERT_TRUE(ds_image_2D.initialized()); |
| 1828 | |
| 1829 | ds_image_1S.Init( |
| 1830 | 256, 256, 1, VK_FORMAT_S8_UINT, |
| 1831 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, |
| 1832 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 1833 | ASSERT_TRUE(ds_image_1S.initialized()); |
| 1834 | } |
| 1835 | |
| 1836 | // Allocate buffers |
| 1837 | VkBufferObj buffer_256k, buffer_128k, buffer_64k, buffer_16k; |
| 1838 | VkMemoryPropertyFlags reqs = 0; |
| 1839 | buffer_256k.init_as_src_and_dst(*m_device, 262144, reqs); // 256k |
| 1840 | buffer_128k.init_as_src_and_dst(*m_device, 131072, reqs); // 128k |
| 1841 | buffer_64k.init_as_src_and_dst(*m_device, 65536, reqs); // 64k |
| 1842 | buffer_16k.init_as_src_and_dst(*m_device, 16384, reqs); // 16k |
| 1843 | |
| 1844 | VkBufferImageCopy region = {}; |
| 1845 | region.bufferRowLength = 0; |
| 1846 | region.bufferImageHeight = 0; |
| 1847 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 1848 | region.imageSubresource.layerCount = 1; |
| 1849 | region.imageOffset = {0, 0, 0}; |
| 1850 | region.imageExtent = {64, 64, 1}; |
| 1851 | region.bufferOffset = 0; |
| 1852 | |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 1853 | VkMemoryBarrier mem_barriers[3]; |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 1854 | mem_barriers[0] = LvlInitStruct<VkMemoryBarrier>(); |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 1855 | mem_barriers[0].srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; |
| 1856 | mem_barriers[0].dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 1857 | mem_barriers[1] = LvlInitStruct<VkMemoryBarrier>(); |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 1858 | mem_barriers[1].srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT; |
| 1859 | mem_barriers[1].dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 1860 | mem_barriers[2] = LvlInitStruct<VkMemoryBarrier>(); |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 1861 | mem_barriers[2].srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; |
| 1862 | mem_barriers[2].dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; |
| 1863 | |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1864 | if (missing_rgba_support) { |
| 1865 | printf("%s R8G8B8A8_UINT transfer unsupported - skipping RGBA tests.\n", kSkipPrefix); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1866 | |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1867 | // start recording for future tests |
| 1868 | m_commandBuffer->begin(); |
| 1869 | } else { |
| 1870 | // attempt copies before putting command buffer in recording state |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1871 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyBufferToImage-commandBuffer-recording"); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1872 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_64k.handle(), image_64k.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 1873 | ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 1874 | m_errorMonitor->VerifyFound(); |
| 1875 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1876 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImageToBuffer-commandBuffer-recording"); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1877 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_64k.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_64k.handle(), 1, |
| 1878 | ®ion); |
| 1879 | m_errorMonitor->VerifyFound(); |
| 1880 | |
| 1881 | // start recording |
| 1882 | m_commandBuffer->begin(); |
| 1883 | |
| 1884 | // successful copies |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1885 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_16k.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_16k.handle(), 1, |
| 1886 | ®ion); |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 1887 | |
| 1888 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, |
| 1889 | &mem_barriers[2], 0, nullptr, 0, nullptr); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1890 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_16k.handle(), image_16k.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 1891 | ®ion); |
| 1892 | region.imageOffset.x = 16; // 16k copy, offset requires larger image |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 1893 | |
| 1894 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, |
| 1895 | &mem_barriers[0], 0, nullptr, 0, nullptr); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1896 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_64k.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_16k.handle(), 1, |
| 1897 | ®ion); |
| 1898 | region.imageExtent.height = 78; // > 16k copy requires larger buffer & image |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 1899 | |
| 1900 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, |
| 1901 | &mem_barriers[1], 0, nullptr, 0, nullptr); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1902 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_64k.handle(), image_64k.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 1903 | ®ion); |
| 1904 | region.imageOffset.x = 0; |
| 1905 | region.imageExtent.height = 64; |
| 1906 | region.bufferOffset = 256; // 16k copy with buffer offset, requires larger buffer |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 1907 | |
| 1908 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 2, |
| 1909 | &mem_barriers[1], 0, nullptr, 0, nullptr); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1910 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_16k.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_64k.handle(), 1, |
| 1911 | ®ion); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1912 | |
| 1913 | // image/buffer too small (extent too large) on copy to image |
| 1914 | region.imageExtent = {65, 64, 1}; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1915 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1916 | "VUID-vkCmdCopyBufferToImage-pRegions-00171"); // buffer too small |
| 1917 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_16k.handle(), image_64k.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 1918 | ®ion); |
| 1919 | m_errorMonitor->VerifyFound(); |
| 1920 | |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 1921 | m_errorMonitor->SetUnexpectedError("VUID-vkCmdCopyBufferToImage-pRegions-06218"); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1922 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 1923 | "VUID-vkCmdCopyBufferToImage-pRegions-06217"); // image too small |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1924 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_64k.handle(), image_16k.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 1925 | ®ion); |
| 1926 | m_errorMonitor->VerifyFound(); |
| 1927 | |
| 1928 | // image/buffer too small (offset) on copy to image |
| 1929 | region.imageExtent = {64, 64, 1}; |
| 1930 | region.imageOffset = {0, 4, 0}; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1931 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1932 | "VUID-vkCmdCopyBufferToImage-pRegions-00171"); // buffer too small |
| 1933 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_16k.handle(), image_64k.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 1934 | ®ion); |
| 1935 | m_errorMonitor->VerifyFound(); |
| 1936 | |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 1937 | m_errorMonitor->SetUnexpectedError("VUID-vkCmdCopyBufferToImage-pRegions-06218"); |
| 1938 | m_errorMonitor->SetUnexpectedError("VUID-vkCmdCopyBufferToImage-pRegions-06219"); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1939 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 1940 | "VUID-vkCmdCopyBufferToImage-pRegions-06217"); // image too small |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1941 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_64k.handle(), image_16k.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 1942 | ®ion); |
| 1943 | m_errorMonitor->VerifyFound(); |
| 1944 | |
| 1945 | // image/buffer too small on copy to buffer |
| 1946 | region.imageExtent = {64, 64, 1}; |
| 1947 | region.imageOffset = {0, 0, 0}; |
| 1948 | region.bufferOffset = 4; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1949 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1950 | "VUID-vkCmdCopyImageToBuffer-pRegions-00183"); // buffer too small |
| 1951 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_64k.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_16k.handle(), 1, |
| 1952 | ®ion); |
| 1953 | m_errorMonitor->VerifyFound(); |
| 1954 | |
| 1955 | region.imageExtent = {64, 65, 1}; |
| 1956 | region.bufferOffset = 0; |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 1957 | m_errorMonitor->SetUnexpectedError("VUID-vkCmdCopyImageToBuffer-pRegions-06222"); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1958 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 1959 | "VUID-vkCmdCopyImageToBuffer-pRegions-06220"); // image too small |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1960 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_16k.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_64k.handle(), 1, |
| 1961 | ®ion); |
| 1962 | m_errorMonitor->VerifyFound(); |
| 1963 | |
| 1964 | // buffer size OK but rowlength causes loose packing |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1965 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImageToBuffer-pRegions-00183"); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1966 | region.imageExtent = {64, 64, 1}; |
| 1967 | region.bufferRowLength = 68; |
| 1968 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_16k.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_16k.handle(), 1, |
| 1969 | ®ion); |
| 1970 | m_errorMonitor->VerifyFound(); |
| 1971 | |
sfricke-samsung | 5f11b0e | 2022-03-22 14:12:15 -0500 | [diff] [blame] | 1972 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkBufferImageCopy-imageExtent-06659"); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1973 | region.imageExtent.width = 0; |
sfricke-samsung | 5f11b0e | 2022-03-22 14:12:15 -0500 | [diff] [blame] | 1974 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_16k.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_64k.handle(), 1, |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1975 | ®ion); |
| 1976 | m_errorMonitor->VerifyFound(); |
| 1977 | |
| 1978 | // aspect bits |
| 1979 | region.imageExtent = {64, 64, 1}; |
| 1980 | region.bufferRowLength = 0; |
| 1981 | region.bufferImageHeight = 0; |
| 1982 | if (!missing_ds_support) { |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1983 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1984 | "VUID-VkBufferImageCopy-aspectMask-00212"); // more than 1 aspect bit set |
| 1985 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
| 1986 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_16k_depth.handle(), VK_IMAGE_LAYOUT_GENERAL, |
| 1987 | buffer_16k.handle(), 1, ®ion); |
| 1988 | m_errorMonitor->VerifyFound(); |
| 1989 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1990 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
sfricke-samsung | 88ac6fe | 2020-10-24 10:00:13 -0700 | [diff] [blame] | 1991 | "VUID-vkCmdCopyImageToBuffer-aspectMask-00211"); // different mis-matched aspect |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 1992 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 1993 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_16k_depth.handle(), VK_IMAGE_LAYOUT_GENERAL, |
| 1994 | buffer_16k.handle(), 1, ®ion); |
| 1995 | m_errorMonitor->VerifyFound(); |
| 1996 | } |
| 1997 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 1998 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
sfricke-samsung | 88ac6fe | 2020-10-24 10:00:13 -0700 | [diff] [blame] | 1999 | "VUID-vkCmdCopyImageToBuffer-aspectMask-00211"); // mis-matched aspect |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2000 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; |
| 2001 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_16k.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_16k.handle(), 1, |
| 2002 | ®ion); |
| 2003 | m_errorMonitor->VerifyFound(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2004 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2005 | |
| 2006 | // Out-of-range mip levels should fail |
| 2007 | region.imageSubresource.mipLevel = image_16k.create_info().mipLevels + 1; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2008 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImageToBuffer-imageSubresource-01703"); |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 2009 | m_errorMonitor->SetUnexpectedError("VUID-vkCmdCopyImageToBuffer-pRegions-06221"); |
| 2010 | m_errorMonitor->SetUnexpectedError("VUID-vkCmdCopyImageToBuffer-pRegions-06222"); |
sfricke-samsung | 88ac6fe | 2020-10-24 10:00:13 -0700 | [diff] [blame] | 2011 | m_errorMonitor->SetUnexpectedError("VUID-vkCmdCopyImageToBuffer-imageOffset-00200"); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2012 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2013 | kErrorBit, |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 2014 | "VUID-vkCmdCopyImageToBuffer-pRegions-06220"); // unavoidable "region exceeds image bounds" for non-existent mip |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2015 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_16k.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_16k.handle(), 1, |
| 2016 | ®ion); |
| 2017 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2018 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyBufferToImage-imageSubresource-01701"); |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 2019 | m_errorMonitor->SetUnexpectedError("VUID-vkCmdCopyBufferToImage-pRegions-06218"); |
| 2020 | m_errorMonitor->SetUnexpectedError("VUID-vkCmdCopyBufferToImage-pRegions-06219"); |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2021 | m_errorMonitor->SetUnexpectedError("VUID-vkCmdCopyBufferToImage-imageOffset-00200"); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2022 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2023 | kErrorBit, |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 2024 | "VUID-vkCmdCopyBufferToImage-pRegions-06217"); // unavoidable "region exceeds image bounds" for non-existent mip |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2025 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_16k.handle(), image_16k.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 2026 | ®ion); |
| 2027 | m_errorMonitor->VerifyFound(); |
| 2028 | region.imageSubresource.mipLevel = 0; |
| 2029 | |
| 2030 | // Out-of-range array layers should fail |
| 2031 | region.imageSubresource.baseArrayLayer = image_16k.create_info().arrayLayers; |
| 2032 | region.imageSubresource.layerCount = 1; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2033 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImageToBuffer-imageSubresource-01704"); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2034 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_16k.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_16k.handle(), 1, |
| 2035 | ®ion); |
| 2036 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2037 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyBufferToImage-imageSubresource-01702"); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2038 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_16k.handle(), image_16k.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 2039 | ®ion); |
| 2040 | m_errorMonitor->VerifyFound(); |
| 2041 | region.imageSubresource.baseArrayLayer = 0; |
| 2042 | |
| 2043 | // Layout mismatch should fail |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2044 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImageToBuffer-srcImageLayout-00189"); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2045 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_16k.handle(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
| 2046 | buffer_16k.handle(), 1, ®ion); |
| 2047 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2048 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyBufferToImage-dstImageLayout-00180"); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2049 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_16k.handle(), image_16k.handle(), |
| 2050 | VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2051 | m_errorMonitor->VerifyFound(); |
| 2052 | } |
| 2053 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2054 | // Test Depth/Stencil copies |
| 2055 | if (missing_ds_support) { |
| 2056 | printf("%s Depth / Stencil formats unsupported - skipping D/S tests.\n", kSkipPrefix); |
| 2057 | } else { |
| 2058 | VkBufferImageCopy ds_region = {}; |
| 2059 | ds_region.bufferOffset = 0; |
| 2060 | ds_region.bufferRowLength = 0; |
| 2061 | ds_region.bufferImageHeight = 0; |
| 2062 | ds_region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; |
| 2063 | ds_region.imageSubresource.mipLevel = 0; |
| 2064 | ds_region.imageSubresource.baseArrayLayer = 0; |
| 2065 | ds_region.imageSubresource.layerCount = 1; |
| 2066 | ds_region.imageOffset = {0, 0, 0}; |
| 2067 | ds_region.imageExtent = {256, 256, 1}; |
| 2068 | |
| 2069 | // Depth copies that should succeed |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 2070 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), ds_image_4D_1S.handle(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
| 2071 | buffer_256k.handle(), 1, &ds_region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2072 | |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 2073 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, |
| 2074 | &mem_barriers[0], 0, nullptr, 0, nullptr); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 2075 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), ds_image_3D_1S.handle(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
| 2076 | buffer_256k.handle(), 1, &ds_region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2077 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 2078 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), ds_image_2D.handle(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
| 2079 | buffer_128k.handle(), 1, &ds_region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2080 | |
| 2081 | // Depth copies that should fail |
| 2082 | ds_region.bufferOffset = 4; |
| 2083 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2084 | kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2085 | "VUID-vkCmdCopyImageToBuffer-pRegions-00183"); // Extract 4b depth per texel, pack into 256k buffer |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 2086 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), ds_image_4D_1S.handle(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
| 2087 | buffer_256k.handle(), 1, &ds_region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2088 | m_errorMonitor->VerifyFound(); |
| 2089 | |
| 2090 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2091 | kErrorBit, |
locke-lunarg | 0071051 | 2020-06-01 13:56:49 -0600 | [diff] [blame] | 2092 | "VUID-vkCmdCopyImageToBuffer-pRegions-00183"); // Extract 3b depth per texel, pack (loose) into 128k buffer |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 2093 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), ds_image_3D_1S.handle(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
locke-lunarg | 0071051 | 2020-06-01 13:56:49 -0600 | [diff] [blame] | 2094 | buffer_128k.handle(), 1, &ds_region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2095 | m_errorMonitor->VerifyFound(); |
| 2096 | |
| 2097 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2098 | kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2099 | "VUID-vkCmdCopyImageToBuffer-pRegions-00183"); // Copy 2b depth per texel, into 128k buffer |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 2100 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), ds_image_2D.handle(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
| 2101 | buffer_128k.handle(), 1, &ds_region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2102 | m_errorMonitor->VerifyFound(); |
| 2103 | |
sfricke-samsung | 5a01949 | 2021-01-25 10:32:08 -0800 | [diff] [blame] | 2104 | ds_region.bufferOffset = 5; |
| 2105 | ds_region.imageExtent = {64, 64, 1}; // need smaller so offset works |
| 2106 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImageToBuffer-srcImage-04053"); |
| 2107 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), ds_image_2D.handle(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
| 2108 | buffer_128k.handle(), 1, &ds_region); |
| 2109 | m_errorMonitor->VerifyFound(); |
| 2110 | ds_region.imageExtent = {256, 256, 1}; |
| 2111 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2112 | // Stencil copies that should succeed |
| 2113 | ds_region.bufferOffset = 0; |
| 2114 | ds_region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_STENCIL_BIT; |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 2115 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, |
| 2116 | &mem_barriers[0], 0, nullptr, 0, nullptr); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 2117 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), ds_image_4D_1S.handle(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
| 2118 | buffer_64k.handle(), 1, &ds_region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2119 | |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 2120 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, |
| 2121 | &mem_barriers[0], 0, nullptr, 0, nullptr); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 2122 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), ds_image_3D_1S.handle(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
| 2123 | buffer_64k.handle(), 1, &ds_region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2124 | |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 2125 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, |
| 2126 | &mem_barriers[0], 0, nullptr, 0, nullptr); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 2127 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), ds_image_1S.handle(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
| 2128 | buffer_64k.handle(), 1, &ds_region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2129 | |
| 2130 | // Stencil copies that should fail |
| 2131 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2132 | kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2133 | "VUID-vkCmdCopyImageToBuffer-pRegions-00183"); // Extract 1b stencil per texel, pack into 64k buffer |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 2134 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), ds_image_4D_1S.handle(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
| 2135 | buffer_16k.handle(), 1, &ds_region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2136 | m_errorMonitor->VerifyFound(); |
| 2137 | |
| 2138 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2139 | kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2140 | "VUID-vkCmdCopyImageToBuffer-pRegions-00183"); // Extract 1b stencil per texel, pack into 64k buffer |
| 2141 | ds_region.bufferRowLength = 260; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 2142 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), ds_image_3D_1S.handle(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
| 2143 | buffer_64k.handle(), 1, &ds_region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2144 | m_errorMonitor->VerifyFound(); |
| 2145 | |
| 2146 | ds_region.bufferRowLength = 0; |
| 2147 | ds_region.bufferOffset = 4; |
| 2148 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2149 | kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2150 | "VUID-vkCmdCopyImageToBuffer-pRegions-00183"); // Copy 1b depth per texel, into 64k buffer |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 2151 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), ds_image_1S.handle(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
| 2152 | buffer_64k.handle(), 1, &ds_region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2153 | m_errorMonitor->VerifyFound(); |
| 2154 | } |
| 2155 | |
| 2156 | // Test compressed formats, if supported |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2157 | // Support here requires both feature bit for compression and picked format supports transfer feature bits |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2158 | VkPhysicalDeviceFeatures device_features = {}; |
| 2159 | ASSERT_NO_FATAL_FAILURE(GetPhysicalDeviceFeatures(&device_features)); |
| 2160 | if (!(device_features.textureCompressionBC || device_features.textureCompressionETC2 || |
| 2161 | device_features.textureCompressionASTC_LDR)) { |
| 2162 | printf("%s No compressed formats supported - block compression tests skipped.\n", kSkipPrefix); |
| 2163 | } else { |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2164 | // Verify transfer support for each compression format used blow |
| 2165 | bool missing_bc_support = false; |
| 2166 | bool missing_etc_support = false; |
| 2167 | bool missing_astc_support = false; |
| 2168 | bool missing_compression_support = false; |
| 2169 | |
| 2170 | vk::GetPhysicalDeviceFormatProperties(m_device->phy().handle(), VK_FORMAT_BC3_SRGB_BLOCK, &props); |
| 2171 | missing_bc_support |= (props.bufferFeatures == 0 && props.linearTilingFeatures == 0 && props.optimalTilingFeatures == 0); |
| 2172 | missing_bc_support |= (props.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT) == 0; |
| 2173 | missing_bc_support |= (props.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_DST_BIT) == 0; |
| 2174 | |
| 2175 | vk::GetPhysicalDeviceFormatProperties(m_device->phy().handle(), VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK, &props); |
| 2176 | missing_etc_support |= (props.bufferFeatures == 0 && props.linearTilingFeatures == 0 && props.optimalTilingFeatures == 0); |
| 2177 | missing_etc_support |= (props.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT) == 0; |
| 2178 | missing_etc_support |= (props.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_DST_BIT) == 0; |
| 2179 | |
| 2180 | vk::GetPhysicalDeviceFormatProperties(m_device->phy().handle(), VK_FORMAT_ASTC_4x4_UNORM_BLOCK, &props); |
| 2181 | missing_astc_support |= (props.bufferFeatures == 0 && props.linearTilingFeatures == 0 && props.optimalTilingFeatures == 0); |
| 2182 | missing_astc_support |= (props.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT) == 0; |
| 2183 | missing_astc_support |= (props.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_DST_BIT) == 0; |
| 2184 | |
| 2185 | if (device_features.textureCompressionBC && (!missing_bc_support)) { |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2186 | image_16k_4x4comp.Init(128, 128, 1, VK_FORMAT_BC3_SRGB_BLOCK, VK_IMAGE_USAGE_TRANSFER_SRC_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 2187 | 0); |
| 2188 | image_NPOT_4x4comp.Init(130, 130, 1, VK_FORMAT_BC3_SRGB_BLOCK, VK_IMAGE_USAGE_TRANSFER_SRC_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 2189 | 0); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2190 | } else if (device_features.textureCompressionETC2 && (!missing_etc_support)) { |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2191 | image_16k_4x4comp.Init(128, 128, 1, VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK, VK_IMAGE_USAGE_TRANSFER_SRC_BIT, |
| 2192 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 2193 | image_NPOT_4x4comp.Init(130, 130, 1, VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK, VK_IMAGE_USAGE_TRANSFER_SRC_BIT, |
| 2194 | VK_IMAGE_TILING_OPTIMAL, 0); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2195 | } else if (device_features.textureCompressionASTC_LDR && (!missing_astc_support)) { |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2196 | image_16k_4x4comp.Init(128, 128, 1, VK_FORMAT_ASTC_4x4_UNORM_BLOCK, VK_IMAGE_USAGE_TRANSFER_SRC_BIT, |
| 2197 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 2198 | image_NPOT_4x4comp.Init(130, 130, 1, VK_FORMAT_ASTC_4x4_UNORM_BLOCK, VK_IMAGE_USAGE_TRANSFER_SRC_BIT, |
| 2199 | VK_IMAGE_TILING_OPTIMAL, 0); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2200 | } else { |
| 2201 | missing_compression_support = true; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2202 | } |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2203 | |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2204 | if (missing_compression_support) { |
| 2205 | printf("%s No compressed formats transfers bits are supported - block compression tests skipped.\n", kSkipPrefix); |
| 2206 | } else { |
| 2207 | ASSERT_TRUE(image_16k_4x4comp.initialized()); |
sfricke-samsung | 3a10b92 | 2020-05-13 23:23:16 -0700 | [diff] [blame] | 2208 | std::string vuid; |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2209 | // Just fits |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 2210 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, |
| 2211 | &mem_barriers[0], 0, nullptr, 0, nullptr); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2212 | region.imageExtent = {128, 128, 1}; |
| 2213 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_16k_4x4comp.handle(), VK_IMAGE_LAYOUT_GENERAL, |
| 2214 | buffer_16k.handle(), 1, ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2215 | |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2216 | // with offset, too big for buffer |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2217 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImageToBuffer-pRegions-00183"); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2218 | region.bufferOffset = 16; |
| 2219 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_16k_4x4comp.handle(), VK_IMAGE_LAYOUT_GENERAL, |
| 2220 | buffer_16k.handle(), 1, ®ion); |
| 2221 | m_errorMonitor->VerifyFound(); |
| 2222 | region.bufferOffset = 0; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2223 | |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2224 | // extents that are not a multiple of compressed block size |
sfricke-samsung | 88ac6fe | 2020-10-24 10:00:13 -0700 | [diff] [blame] | 2225 | m_errorMonitor->SetDesiredFailureMsg( |
| 2226 | kErrorBit, "VUID-vkCmdCopyImageToBuffer-imageExtent-00207"); // extent width not a multiple of block size |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2227 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2228 | "VUID-vkCmdCopyImageToBuffer-imageOffset-01794"); // image transfer granularity |
| 2229 | region.imageExtent.width = 66; |
| 2230 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_NPOT_4x4comp.handle(), VK_IMAGE_LAYOUT_GENERAL, |
| 2231 | buffer_16k.handle(), 1, ®ion); |
| 2232 | m_errorMonitor->VerifyFound(); |
| 2233 | region.imageExtent.width = 128; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2234 | |
sfricke-samsung | 88ac6fe | 2020-10-24 10:00:13 -0700 | [diff] [blame] | 2235 | m_errorMonitor->SetDesiredFailureMsg( |
| 2236 | kErrorBit, "VUID-vkCmdCopyImageToBuffer-imageExtent-00208"); // extent height not a multiple of block size |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2237 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2238 | "VUID-vkCmdCopyImageToBuffer-imageOffset-01794"); // image transfer granularity |
| 2239 | region.imageExtent.height = 2; |
| 2240 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_NPOT_4x4comp.handle(), VK_IMAGE_LAYOUT_GENERAL, |
| 2241 | buffer_16k.handle(), 1, ®ion); |
| 2242 | m_errorMonitor->VerifyFound(); |
| 2243 | region.imageExtent.height = 128; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2244 | |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2245 | // TODO: All available compressed formats are 2D, with block depth of 1. Unable to provoke VU_01277. |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2246 | |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2247 | // non-multiple extents are allowed if at the far edge of a non-block-multiple image - these should pass |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2248 | region.imageExtent.width = 66; |
| 2249 | region.imageOffset.x = 64; |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 2250 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, |
| 2251 | &mem_barriers[0], 0, nullptr, 0, nullptr); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2252 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_NPOT_4x4comp.handle(), VK_IMAGE_LAYOUT_GENERAL, |
| 2253 | buffer_16k.handle(), 1, ®ion); |
| 2254 | region.imageExtent.width = 16; |
| 2255 | region.imageOffset.x = 0; |
| 2256 | region.imageExtent.height = 2; |
| 2257 | region.imageOffset.y = 128; |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 2258 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, |
| 2259 | &mem_barriers[0], 0, nullptr, 0, nullptr); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2260 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_NPOT_4x4comp.handle(), VK_IMAGE_LAYOUT_GENERAL, |
| 2261 | buffer_16k.handle(), 1, ®ion); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2262 | region.imageOffset = {0, 0, 0}; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2263 | |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2264 | // buffer offset must be a multiple of texel block size (16) |
sfricke-samsung | 88ac6fe | 2020-10-24 10:00:13 -0700 | [diff] [blame] | 2265 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImageToBuffer-bufferOffset-00206"); |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2266 | vuid = |
sfricke-samsung | 88ac6fe | 2020-10-24 10:00:13 -0700 | [diff] [blame] | 2267 | mp_extensions ? "VUID-vkCmdCopyImageToBuffer-bufferOffset-01558" : "VUID-vkCmdCopyImageToBuffer-bufferOffset-00193"; |
sfricke-samsung | 125d2b4 | 2020-05-28 06:32:43 -0700 | [diff] [blame] | 2268 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2269 | region.imageExtent = {64, 64, 1}; |
| 2270 | region.bufferOffset = 24; |
| 2271 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_16k_4x4comp.handle(), VK_IMAGE_LAYOUT_GENERAL, |
| 2272 | buffer_16k.handle(), 1, ®ion); |
| 2273 | m_errorMonitor->VerifyFound(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2274 | |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2275 | // rowlength not a multiple of block width (4) |
sfricke-samsung | 88ac6fe | 2020-10-24 10:00:13 -0700 | [diff] [blame] | 2276 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImageToBuffer-bufferRowLength-00203"); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2277 | region.bufferOffset = 0; |
| 2278 | region.bufferRowLength = 130; |
| 2279 | region.bufferImageHeight = 0; |
| 2280 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_16k_4x4comp.handle(), VK_IMAGE_LAYOUT_GENERAL, |
| 2281 | buffer_64k.handle(), 1, ®ion); |
| 2282 | m_errorMonitor->VerifyFound(); |
| 2283 | |
| 2284 | // imageheight not a multiple of block height (4) |
sfricke-samsung | 88ac6fe | 2020-10-24 10:00:13 -0700 | [diff] [blame] | 2285 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImageToBuffer-bufferImageHeight-00204"); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2286 | region.bufferRowLength = 0; |
| 2287 | region.bufferImageHeight = 130; |
| 2288 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_16k_4x4comp.handle(), VK_IMAGE_LAYOUT_GENERAL, |
| 2289 | buffer_64k.handle(), 1, ®ion); |
| 2290 | m_errorMonitor->VerifyFound(); |
| 2291 | } |
| 2292 | } |
| 2293 | |
| 2294 | // Test multi-planar formats, if supported |
| 2295 | if (!mp_extensions) { |
| 2296 | printf("%s multi-planar extensions not supported; skipped.\n", kSkipPrefix); |
| 2297 | } else { |
| 2298 | // Try to use G8_B8R8_2PLANE_420_UNORM because need 2-plane format for some tests and likely supported due to copy support |
| 2299 | // being required with samplerYcbcrConversion feature |
| 2300 | bool missing_mp_support = false; |
| 2301 | vk::GetPhysicalDeviceFormatProperties(m_device->phy().handle(), VK_FORMAT_G8_B8R8_2PLANE_420_UNORM, &props); |
| 2302 | missing_mp_support |= (props.bufferFeatures == 0 && props.linearTilingFeatures == 0 && props.optimalTilingFeatures == 0); |
| 2303 | missing_mp_support |= (props.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT) == 0; |
| 2304 | missing_mp_support |= (props.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_DST_BIT) == 0; |
| 2305 | |
| 2306 | if (missing_mp_support) { |
| 2307 | printf("%s VK_FORMAT_G8_B8R8_2PLANE_420_UNORM transfer not supported; skipped.\n", kSkipPrefix); |
| 2308 | } else { |
| 2309 | VkBufferImageCopy mp_region = {}; |
| 2310 | mp_region.bufferOffset = 0; |
| 2311 | mp_region.bufferRowLength = 0; |
| 2312 | mp_region.bufferImageHeight = 0; |
| 2313 | mp_region.imageSubresource.mipLevel = 0; |
| 2314 | mp_region.imageSubresource.baseArrayLayer = 0; |
| 2315 | mp_region.imageSubresource.layerCount = 1; |
| 2316 | mp_region.imageOffset = {0, 0, 0}; |
| 2317 | mp_region.imageExtent = {128, 128, 1}; |
| 2318 | |
| 2319 | // YUV420 means 1/2 width and height so plane_0 is 128x128 and plane_1 is 64x64 here |
| 2320 | image_multi_planar.Init(128, 128, 1, VK_FORMAT_G8_B8R8_2PLANE_420_UNORM, VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 2321 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 2322 | ASSERT_TRUE(image_multi_planar.initialized()); |
| 2323 | |
| 2324 | // Copies into a mutli-planar image aspect properly |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2325 | mp_region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_0_BIT; |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 2326 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, |
| 2327 | &mem_barriers[2], 0, nullptr, 0, nullptr); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2328 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_16k.handle(), image_multi_planar.handle(), |
| 2329 | VK_IMAGE_LAYOUT_GENERAL, 1, &mp_region); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2330 | |
| 2331 | // uses plane_2 without being 3 planar format |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2332 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyBufferToImage-aspectMask-01560"); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2333 | mp_region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_2_BIT; |
| 2334 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_16k.handle(), image_multi_planar.handle(), |
| 2335 | VK_IMAGE_LAYOUT_GENERAL, 1, &mp_region); |
| 2336 | m_errorMonitor->VerifyFound(); |
| 2337 | |
| 2338 | // uses single-plane aspect mask |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2339 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyBufferToImage-aspectMask-01560"); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2340 | mp_region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2341 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_16k.handle(), image_multi_planar.handle(), |
| 2342 | VK_IMAGE_LAYOUT_GENERAL, 1, &mp_region); |
| 2343 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | b616d3f | 2020-06-03 22:00:34 -0700 | [diff] [blame] | 2344 | |
| 2345 | // buffer offset must be a multiple of texel block size for VK_FORMAT_R8G8_UNORM (2) |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2346 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyBufferToImage-bufferOffset-01559"); |
sfricke-samsung | b616d3f | 2020-06-03 22:00:34 -0700 | [diff] [blame] | 2347 | mp_region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_1_BIT; |
| 2348 | mp_region.bufferOffset = 5; |
| 2349 | mp_region.imageExtent = {8, 8, 1}; |
| 2350 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_16k.handle(), image_multi_planar.handle(), |
| 2351 | VK_IMAGE_LAYOUT_GENERAL, 1, &mp_region); |
| 2352 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 6d97e56 | 2020-01-07 22:01:00 -0800 | [diff] [blame] | 2353 | } |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2354 | } |
| 2355 | } |
| 2356 | |
| 2357 | TEST_F(VkLayerTest, MiscImageLayerTests) { |
| 2358 | TEST_DESCRIPTION("Image-related tests that don't belong elsewhere"); |
| 2359 | |
| 2360 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 2361 | |
| 2362 | // TODO: Ideally we should check if a format is supported, before using it. |
| 2363 | VkImageObj image(m_device); |
| 2364 | image.Init(128, 128, 1, VK_FORMAT_R16G16B16A16_UINT, VK_IMAGE_USAGE_TRANSFER_DST_BIT, VK_IMAGE_TILING_OPTIMAL, 0); // 64bpp |
| 2365 | ASSERT_TRUE(image.initialized()); |
| 2366 | VkBufferObj buffer; |
| 2367 | VkMemoryPropertyFlags reqs = 0; |
| 2368 | buffer.init_as_src(*m_device, 128 * 128 * 8, reqs); |
| 2369 | VkBufferImageCopy region = {}; |
| 2370 | region.bufferRowLength = 128; |
| 2371 | region.bufferImageHeight = 128; |
| 2372 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2373 | // layerCount can't be 0 - Expect MISMATCHED_IMAGE_ASPECT |
| 2374 | region.imageSubresource.layerCount = 1; |
| 2375 | region.imageExtent.height = 4; |
| 2376 | region.imageExtent.width = 4; |
| 2377 | region.imageExtent.depth = 1; |
| 2378 | |
| 2379 | VkImageObj image2(m_device); |
| 2380 | image2.Init(128, 128, 1, VK_FORMAT_R8G8_UNORM, VK_IMAGE_USAGE_TRANSFER_DST_BIT, VK_IMAGE_TILING_OPTIMAL, 0); // 16bpp |
| 2381 | ASSERT_TRUE(image2.initialized()); |
| 2382 | VkBufferObj buffer2; |
| 2383 | VkMemoryPropertyFlags reqs2 = 0; |
| 2384 | buffer2.init_as_src(*m_device, 128 * 128 * 2, reqs2); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2385 | m_commandBuffer->begin(); |
| 2386 | |
| 2387 | // Image must have offset.z of 0 and extent.depth of 1 |
| 2388 | // Introduce failure by setting imageExtent.depth to 0 |
| 2389 | region.imageExtent.depth = 0; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2390 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyBufferToImage-srcImage-00201"); |
sfricke-samsung | 5f11b0e | 2022-03-22 14:12:15 -0500 | [diff] [blame] | 2391 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkBufferImageCopy-imageExtent-06661"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 2392 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer.handle(), image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, |
| 2393 | ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2394 | m_errorMonitor->VerifyFound(); |
| 2395 | |
| 2396 | region.imageExtent.depth = 1; |
| 2397 | |
| 2398 | // Image must have offset.z of 0 and extent.depth of 1 |
| 2399 | // Introduce failure by setting imageOffset.z to 4 |
| 2400 | // Note: Also (unavoidably) triggers 'region exceeds image' #1228 |
| 2401 | region.imageOffset.z = 4; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2402 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyBufferToImage-srcImage-00201"); |
| 2403 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyBufferToImage-imageOffset-00200"); |
Mike Schuchardt | 7b152fa | 2021-08-03 16:30:27 -0700 | [diff] [blame] | 2404 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyBufferToImage-pRegions-06217"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 2405 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer.handle(), image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, |
| 2406 | ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2407 | m_errorMonitor->VerifyFound(); |
| 2408 | |
| 2409 | region.imageOffset.z = 0; |
| 2410 | // BufferOffset must be a multiple of the calling command's VkImage parameter's texel size |
| 2411 | // Introduce failure by setting bufferOffset to 1 and 1/2 texels |
| 2412 | region.bufferOffset = 4; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2413 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyBufferToImage-bufferOffset-00193"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 2414 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer.handle(), image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, |
| 2415 | ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2416 | m_errorMonitor->VerifyFound(); |
| 2417 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2418 | // BufferRowLength must be 0, or greater than or equal to the width member of imageExtent |
| 2419 | region.bufferOffset = 0; |
| 2420 | region.imageExtent.height = 128; |
| 2421 | region.imageExtent.width = 128; |
| 2422 | // Introduce failure by setting bufferRowLength > 0 but less than width |
| 2423 | region.bufferRowLength = 64; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2424 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkBufferImageCopy-bufferRowLength-00195"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 2425 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer.handle(), image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, |
| 2426 | ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2427 | m_errorMonitor->VerifyFound(); |
| 2428 | |
| 2429 | // BufferImageHeight must be 0, or greater than or equal to the height member of imageExtent |
| 2430 | region.bufferRowLength = 128; |
| 2431 | // Introduce failure by setting bufferRowHeight > 0 but less than height |
| 2432 | region.bufferImageHeight = 64; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2433 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkBufferImageCopy-bufferImageHeight-00196"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 2434 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer.handle(), image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, |
| 2435 | ®ion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2436 | m_errorMonitor->VerifyFound(); |
| 2437 | |
| 2438 | region.bufferImageHeight = 128; |
| 2439 | VkImageObj intImage1(m_device); |
| 2440 | intImage1.Init(128, 128, 1, VK_FORMAT_R8_UNORM, VK_IMAGE_USAGE_TRANSFER_SRC_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 2441 | intImage1.SetLayout(VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL); |
| 2442 | VkImageObj intImage2(m_device); |
| 2443 | intImage2.Init(128, 128, 1, VK_FORMAT_R8_UNORM, VK_IMAGE_USAGE_TRANSFER_DST_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 2444 | intImage2.SetLayout(VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL); |
| 2445 | VkImageBlit blitRegion = {}; |
| 2446 | blitRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2447 | blitRegion.srcSubresource.baseArrayLayer = 0; |
| 2448 | blitRegion.srcSubresource.layerCount = 1; |
| 2449 | blitRegion.srcSubresource.mipLevel = 0; |
| 2450 | blitRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2451 | blitRegion.dstSubresource.baseArrayLayer = 0; |
| 2452 | blitRegion.dstSubresource.layerCount = 1; |
| 2453 | blitRegion.dstSubresource.mipLevel = 0; |
| 2454 | blitRegion.srcOffsets[0] = {128, 0, 0}; |
| 2455 | blitRegion.srcOffsets[1] = {128, 128, 1}; |
| 2456 | blitRegion.dstOffsets[0] = {0, 128, 0}; |
| 2457 | blitRegion.dstOffsets[1] = {128, 128, 1}; |
| 2458 | |
| 2459 | // Look for NULL-blit warning |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 2460 | m_errorMonitor->SetDesiredFailureMsg(kWarningBit, "vkCmdBlitImage: pRegions[0].srcOffsets specify a zero-volume area."); |
| 2461 | m_errorMonitor->SetDesiredFailureMsg(kWarningBit, "vkCmdBlitImage: pRegions[0].dstOffsets specify a zero-volume area."); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 2462 | vk::CmdBlitImage(m_commandBuffer->handle(), intImage1.handle(), intImage1.Layout(), intImage2.handle(), intImage2.Layout(), 1, |
| 2463 | &blitRegion, VK_FILTER_LINEAR); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2464 | m_errorMonitor->VerifyFound(); |
| 2465 | } |
| 2466 | |
| 2467 | TEST_F(VkLayerTest, CopyImageTypeExtentMismatch) { |
| 2468 | // Image copy tests where format type and extents don't match |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 2469 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
| 2470 | |
| 2471 | bool copy_commands2 = false; |
| 2472 | if (DeviceExtensionSupported(gpu(), nullptr, VK_KHR_COPY_COMMANDS_2_EXTENSION_NAME)) { |
| 2473 | m_device_extension_names.push_back(VK_KHR_COPY_COMMANDS_2_EXTENSION_NAME); |
| 2474 | copy_commands2 = true; |
| 2475 | } |
| 2476 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2477 | |
| 2478 | PFN_vkCmdCopyImage2KHR vkCmdCopyImage2Function = nullptr; |
| 2479 | if (copy_commands2) { |
| 2480 | vkCmdCopyImage2Function = (PFN_vkCmdCopyImage2KHR)vk::GetDeviceProcAddr(m_device->handle(), "vkCmdCopyImage2KHR"); |
| 2481 | } |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2482 | |
sfricke-samsung | 30b094c | 2020-05-30 11:42:11 -0700 | [diff] [blame] | 2483 | // Tests are designed to run without Maintenance1 which was promoted in 1.1 |
| 2484 | if (DeviceValidationVersion() >= VK_API_VERSION_1_1) { |
sjfricke | 50955f3 | 2022-06-05 10:12:52 +0900 | [diff] [blame] | 2485 | GTEST_SKIP() << "Tests for 1.0 only"; |
sfricke-samsung | 30b094c | 2020-05-30 11:42:11 -0700 | [diff] [blame] | 2486 | } |
| 2487 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 2488 | VkImageCreateInfo ci = LvlInitStruct<VkImageCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2489 | ci.flags = 0; |
| 2490 | ci.imageType = VK_IMAGE_TYPE_1D; |
| 2491 | ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 2492 | ci.extent = {32, 1, 1}; |
| 2493 | ci.mipLevels = 1; |
| 2494 | ci.arrayLayers = 1; |
| 2495 | ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2496 | ci.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 2497 | ci.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 2498 | ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 2499 | ci.queueFamilyIndexCount = 0; |
| 2500 | ci.pQueueFamilyIndices = NULL; |
| 2501 | ci.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 2502 | |
| 2503 | // Create 1D image |
| 2504 | VkImageObj image_1D(m_device); |
| 2505 | image_1D.init(&ci); |
| 2506 | ASSERT_TRUE(image_1D.initialized()); |
| 2507 | |
| 2508 | // 2D image |
| 2509 | ci.imageType = VK_IMAGE_TYPE_2D; |
| 2510 | ci.extent = {32, 32, 1}; |
| 2511 | VkImageObj image_2D(m_device); |
| 2512 | image_2D.init(&ci); |
| 2513 | ASSERT_TRUE(image_2D.initialized()); |
| 2514 | |
| 2515 | // 3D image |
| 2516 | ci.imageType = VK_IMAGE_TYPE_3D; |
| 2517 | ci.extent = {32, 32, 8}; |
| 2518 | VkImageObj image_3D(m_device); |
| 2519 | image_3D.init(&ci); |
| 2520 | ASSERT_TRUE(image_3D.initialized()); |
| 2521 | |
| 2522 | // 2D image array |
| 2523 | ci.imageType = VK_IMAGE_TYPE_2D; |
| 2524 | ci.extent = {32, 32, 1}; |
| 2525 | ci.arrayLayers = 8; |
| 2526 | VkImageObj image_2D_array(m_device); |
| 2527 | image_2D_array.init(&ci); |
| 2528 | ASSERT_TRUE(image_2D_array.initialized()); |
| 2529 | |
| 2530 | m_commandBuffer->begin(); |
| 2531 | |
| 2532 | VkImageCopy copy_region; |
| 2533 | copy_region.extent = {32, 1, 1}; |
| 2534 | copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2535 | copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2536 | copy_region.srcSubresource.mipLevel = 0; |
| 2537 | copy_region.dstSubresource.mipLevel = 0; |
| 2538 | copy_region.srcSubresource.baseArrayLayer = 0; |
| 2539 | copy_region.dstSubresource.baseArrayLayer = 0; |
| 2540 | copy_region.srcSubresource.layerCount = 1; |
| 2541 | copy_region.dstSubresource.layerCount = 1; |
| 2542 | copy_region.srcOffset = {0, 0, 0}; |
| 2543 | copy_region.dstOffset = {0, 0, 0}; |
| 2544 | |
| 2545 | // Sanity check |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2546 | m_commandBuffer->CopyImage(image_1D.image(), VK_IMAGE_LAYOUT_GENERAL, image_2D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 2547 | ©_region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2548 | |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 2549 | // Equivalent sanity check using KHR_copy_commands2 |
| 2550 | if (copy_commands2 && vkCmdCopyImage2Function) { |
| 2551 | const VkImageCopy2KHR region2 = {VK_STRUCTURE_TYPE_IMAGE_COPY_2_KHR, |
| 2552 | NULL, |
| 2553 | copy_region.srcSubresource, |
| 2554 | copy_region.srcOffset, |
| 2555 | copy_region.dstSubresource, |
| 2556 | copy_region.dstOffset, |
| 2557 | copy_region.extent}; |
| 2558 | const VkCopyImageInfo2KHR copy_image_info2 = {VK_STRUCTURE_TYPE_COPY_IMAGE_INFO_2_KHR, |
| 2559 | NULL, |
| 2560 | image_1D.image(), |
| 2561 | VK_IMAGE_LAYOUT_GENERAL, |
| 2562 | image_2D.image(), |
| 2563 | VK_IMAGE_LAYOUT_GENERAL, |
| 2564 | 1, |
| 2565 | ®ion2}; |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 2566 | vkCmdCopyImage2Function(m_commandBuffer->handle(), ©_image_info2); |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 2567 | } |
| 2568 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2569 | // 1D texture w/ offset.y > 0. Source = VU 09c00124, dest = 09c00130 |
| 2570 | copy_region.srcOffset.y = 1; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2571 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcImage-00146"); |
| 2572 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcOffset-00145"); // also y-dim overrun |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2573 | m_commandBuffer->CopyImage(image_1D.image(), VK_IMAGE_LAYOUT_GENERAL, image_2D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 2574 | ©_region); |
| 2575 | m_errorMonitor->VerifyFound(); |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 2576 | |
| 2577 | // Equivalent test using KHR_copy_commands2 |
| 2578 | if (copy_commands2 && vkCmdCopyImage2Function) { |
| 2579 | const VkImageCopy2KHR region2 = {VK_STRUCTURE_TYPE_IMAGE_COPY_2_KHR, |
| 2580 | NULL, |
| 2581 | copy_region.srcSubresource, |
| 2582 | copy_region.srcOffset, |
| 2583 | copy_region.dstSubresource, |
| 2584 | copy_region.dstOffset, |
| 2585 | copy_region.extent}; |
| 2586 | const VkCopyImageInfo2KHR copy_image_info2 = {VK_STRUCTURE_TYPE_COPY_IMAGE_INFO_2_KHR, |
| 2587 | NULL, |
| 2588 | image_1D.image(), |
| 2589 | VK_IMAGE_LAYOUT_GENERAL, |
| 2590 | image_2D.image(), |
| 2591 | VK_IMAGE_LAYOUT_GENERAL, |
| 2592 | 1, |
| 2593 | ®ion2}; |
Tony-LunarG | 953d55a | 2021-11-11 14:20:25 -0700 | [diff] [blame] | 2594 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCopyImageInfo2-srcImage-00146"); |
| 2595 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCopyImageInfo2-srcOffset-00145"); // also y-dim overrun |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 2596 | vkCmdCopyImage2Function(m_commandBuffer->handle(), ©_image_info2); |
| 2597 | m_errorMonitor->VerifyFound(); |
| 2598 | } |
| 2599 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2600 | copy_region.srcOffset.y = 0; |
| 2601 | copy_region.dstOffset.y = 1; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2602 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-dstImage-00152"); |
| 2603 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-dstOffset-00151"); // also y-dim overrun |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2604 | m_commandBuffer->CopyImage(image_2D.image(), VK_IMAGE_LAYOUT_GENERAL, image_1D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 2605 | ©_region); |
| 2606 | m_errorMonitor->VerifyFound(); |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 2607 | |
| 2608 | // Equivalent test using KHR_copy_commands2 |
| 2609 | if (copy_commands2 && vkCmdCopyImage2Function) { |
| 2610 | const VkImageCopy2KHR region2 = {VK_STRUCTURE_TYPE_IMAGE_COPY_2_KHR, |
| 2611 | NULL, |
| 2612 | copy_region.srcSubresource, |
| 2613 | copy_region.srcOffset, |
| 2614 | copy_region.dstSubresource, |
| 2615 | copy_region.dstOffset, |
| 2616 | copy_region.extent}; |
| 2617 | const VkCopyImageInfo2KHR copy_image_info2 = {VK_STRUCTURE_TYPE_COPY_IMAGE_INFO_2_KHR, |
| 2618 | NULL, |
| 2619 | image_2D.image(), |
| 2620 | VK_IMAGE_LAYOUT_GENERAL, |
| 2621 | image_1D.image(), |
| 2622 | VK_IMAGE_LAYOUT_GENERAL, |
| 2623 | 1, |
| 2624 | ®ion2}; |
Tony-LunarG | 953d55a | 2021-11-11 14:20:25 -0700 | [diff] [blame] | 2625 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCopyImageInfo2-dstImage-00152"); |
| 2626 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCopyImageInfo2-dstOffset-00151"); // also y-dim overrun |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 2627 | vkCmdCopyImage2Function(m_commandBuffer->handle(), ©_image_info2); |
| 2628 | m_errorMonitor->VerifyFound(); |
| 2629 | } |
| 2630 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2631 | copy_region.dstOffset.y = 0; |
| 2632 | |
| 2633 | // 1D texture w/ extent.height > 1. Source = VU 09c00124, dest = 09c00130 |
| 2634 | copy_region.extent.height = 2; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2635 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcImage-00146"); |
| 2636 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcOffset-00145"); // also y-dim overrun |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2637 | m_commandBuffer->CopyImage(image_1D.image(), VK_IMAGE_LAYOUT_GENERAL, image_2D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 2638 | ©_region); |
| 2639 | m_errorMonitor->VerifyFound(); |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 2640 | |
| 2641 | // Equivalent test using KHR_copy_commands2 |
| 2642 | if (copy_commands2 && vkCmdCopyImage2Function) { |
| 2643 | const VkImageCopy2KHR region2 = {VK_STRUCTURE_TYPE_IMAGE_COPY_2_KHR, |
| 2644 | NULL, |
| 2645 | copy_region.srcSubresource, |
| 2646 | copy_region.srcOffset, |
| 2647 | copy_region.dstSubresource, |
| 2648 | copy_region.dstOffset, |
| 2649 | copy_region.extent}; |
| 2650 | const VkCopyImageInfo2KHR copy_image_info2 = {VK_STRUCTURE_TYPE_COPY_IMAGE_INFO_2_KHR, |
| 2651 | NULL, |
| 2652 | image_1D.image(), |
| 2653 | VK_IMAGE_LAYOUT_GENERAL, |
| 2654 | image_2D.image(), |
| 2655 | VK_IMAGE_LAYOUT_GENERAL, |
| 2656 | 1, |
| 2657 | ®ion2}; |
Tony-LunarG | 953d55a | 2021-11-11 14:20:25 -0700 | [diff] [blame] | 2658 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCopyImageInfo2-srcImage-00146"); |
| 2659 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCopyImageInfo2-srcOffset-00145"); // also y-dim overrun |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 2660 | vkCmdCopyImage2Function(m_commandBuffer->handle(), ©_image_info2); |
| 2661 | m_errorMonitor->VerifyFound(); |
| 2662 | } |
| 2663 | |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2664 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-dstImage-00152"); |
| 2665 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-dstOffset-00151"); // also y-dim overrun |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2666 | m_commandBuffer->CopyImage(image_2D.image(), VK_IMAGE_LAYOUT_GENERAL, image_1D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 2667 | ©_region); |
| 2668 | m_errorMonitor->VerifyFound(); |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 2669 | |
| 2670 | // Equivalent test using KHR_copy_commands2 |
| 2671 | if (copy_commands2 && vkCmdCopyImage2Function) { |
| 2672 | const VkImageCopy2KHR region2 = {VK_STRUCTURE_TYPE_IMAGE_COPY_2_KHR, |
| 2673 | NULL, |
| 2674 | copy_region.srcSubresource, |
| 2675 | copy_region.srcOffset, |
| 2676 | copy_region.dstSubresource, |
| 2677 | copy_region.dstOffset, |
| 2678 | copy_region.extent}; |
| 2679 | const VkCopyImageInfo2KHR copy_image_info2 = {VK_STRUCTURE_TYPE_COPY_IMAGE_INFO_2_KHR, |
| 2680 | NULL, |
| 2681 | image_2D.image(), |
| 2682 | VK_IMAGE_LAYOUT_GENERAL, |
| 2683 | image_1D.image(), |
| 2684 | VK_IMAGE_LAYOUT_GENERAL, |
| 2685 | 1, |
| 2686 | ®ion2}; |
Tony-LunarG | 953d55a | 2021-11-11 14:20:25 -0700 | [diff] [blame] | 2687 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCopyImageInfo2-dstImage-00152"); |
| 2688 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCopyImageInfo2-dstOffset-00151"); // also y-dim overrun |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 2689 | vkCmdCopyImage2Function(m_commandBuffer->handle(), ©_image_info2); |
| 2690 | m_errorMonitor->VerifyFound(); |
| 2691 | } |
| 2692 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2693 | copy_region.extent.height = 1; |
| 2694 | |
| 2695 | // 1D texture w/ offset.z > 0. Source = VU 09c00df2, dest = 09c00df4 |
| 2696 | copy_region.srcOffset.z = 1; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2697 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcImage-01785"); |
| 2698 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcOffset-00147"); // also z-dim overrun |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2699 | m_commandBuffer->CopyImage(image_1D.image(), VK_IMAGE_LAYOUT_GENERAL, image_2D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 2700 | ©_region); |
| 2701 | m_errorMonitor->VerifyFound(); |
| 2702 | copy_region.srcOffset.z = 0; |
| 2703 | copy_region.dstOffset.z = 1; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2704 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-dstImage-01786"); |
| 2705 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-dstOffset-00153"); // also z-dim overrun |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2706 | m_commandBuffer->CopyImage(image_2D.image(), VK_IMAGE_LAYOUT_GENERAL, image_1D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 2707 | ©_region); |
| 2708 | m_errorMonitor->VerifyFound(); |
| 2709 | copy_region.dstOffset.z = 0; |
| 2710 | |
| 2711 | // 1D texture w/ extent.depth > 1. Source = VU 09c00df2, dest = 09c00df4 |
| 2712 | copy_region.extent.depth = 2; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2713 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcImage-01785"); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2714 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2715 | "VUID-vkCmdCopyImage-srcOffset-00147"); // also z-dim overrun (src) |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2716 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2717 | "VUID-vkCmdCopyImage-dstOffset-00153"); // also z-dim overrun (dst) |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2718 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2719 | "VUID-vkCmdCopyImage-srcImage-01789"); // 2D needs to be 1 pre-Vulkan 1.1 |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2720 | m_commandBuffer->CopyImage(image_1D.image(), VK_IMAGE_LAYOUT_GENERAL, image_2D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 2721 | ©_region); |
| 2722 | m_errorMonitor->VerifyFound(); |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2723 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-dstImage-01786"); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2724 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2725 | "VUID-vkCmdCopyImage-srcOffset-00147"); // also z-dim overrun (src) |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2726 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2727 | "VUID-vkCmdCopyImage-dstOffset-00153"); // also z-dim overrun (dst) |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2728 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2729 | "VUID-vkCmdCopyImage-srcImage-01789"); // 2D needs to be 1 pre-Vulkan 1.1 |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2730 | m_commandBuffer->CopyImage(image_2D.image(), VK_IMAGE_LAYOUT_GENERAL, image_1D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 2731 | ©_region); |
| 2732 | m_errorMonitor->VerifyFound(); |
| 2733 | copy_region.extent.depth = 1; |
| 2734 | |
| 2735 | // 2D texture w/ offset.z > 0. Source = VU 09c00df6, dest = 09c00df8 |
| 2736 | copy_region.extent = {16, 16, 1}; |
| 2737 | copy_region.srcOffset.z = 4; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2738 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcImage-01787"); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2739 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2740 | "VUID-vkCmdCopyImage-srcOffset-00147"); // also z-dim overrun (src) |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2741 | m_commandBuffer->CopyImage(image_2D.image(), VK_IMAGE_LAYOUT_GENERAL, image_3D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 2742 | ©_region); |
| 2743 | m_errorMonitor->VerifyFound(); |
| 2744 | copy_region.srcOffset.z = 0; |
| 2745 | copy_region.dstOffset.z = 1; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2746 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-dstImage-01788"); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2747 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2748 | "VUID-vkCmdCopyImage-dstOffset-00153"); // also z-dim overrun (dst) |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2749 | m_commandBuffer->CopyImage(image_3D.image(), VK_IMAGE_LAYOUT_GENERAL, image_2D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 2750 | ©_region); |
| 2751 | m_errorMonitor->VerifyFound(); |
| 2752 | copy_region.dstOffset.z = 0; |
| 2753 | |
| 2754 | // 3D texture accessing an array layer other than 0. VU 09c0011a |
| 2755 | copy_region.extent = {4, 4, 1}; |
| 2756 | copy_region.srcSubresource.baseArrayLayer = 1; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2757 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcImage-00139"); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2758 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2759 | "VUID-vkCmdCopyImage-srcSubresource-01698"); // also 'too many layers' |
| 2760 | m_commandBuffer->CopyImage(image_3D.image(), VK_IMAGE_LAYOUT_GENERAL, image_2D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 2761 | ©_region); |
| 2762 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 211ee9c | 2020-02-13 23:38:39 -0800 | [diff] [blame] | 2763 | copy_region.srcSubresource.baseArrayLayer = 0; |
| 2764 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2765 | m_commandBuffer->end(); |
| 2766 | } |
| 2767 | |
| 2768 | TEST_F(VkLayerTest, CopyImageTypeExtentMismatchMaintenance1) { |
| 2769 | // Image copy tests where format type and extents don't match and the Maintenance1 extension is enabled |
Mark Lobodzinski | 09ce9c4 | 2020-03-06 10:02:44 -0700 | [diff] [blame] | 2770 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 2771 | if (DeviceExtensionSupported(gpu(), nullptr, VK_KHR_MAINTENANCE_1_EXTENSION_NAME)) { |
| 2772 | m_device_extension_names.push_back(VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2773 | } else { |
| 2774 | printf("%s Maintenance1 extension cannot be enabled, test skipped.\n", kSkipPrefix); |
| 2775 | return; |
| 2776 | } |
| 2777 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2778 | |
| 2779 | VkFormat image_format = VK_FORMAT_R8G8B8A8_UNORM; |
| 2780 | VkFormatProperties format_props; |
| 2781 | // TODO: Remove this check if or when devsim handles extensions. |
| 2782 | // The chosen format has mandatory support the transfer src and dst format features when Maitenance1 is enabled. However, our |
| 2783 | // use of devsim and the mock ICD violate this guarantee. |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 2784 | vk::GetPhysicalDeviceFormatProperties(m_device->phy().handle(), image_format, &format_props); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2785 | if (!(format_props.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT)) { |
| 2786 | printf("%s Maintenance1 extension is not supported.\n", kSkipPrefix); |
| 2787 | return; |
| 2788 | } |
| 2789 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 2790 | VkImageCreateInfo ci = LvlInitStruct<VkImageCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2791 | ci.flags = 0; |
| 2792 | ci.imageType = VK_IMAGE_TYPE_1D; |
| 2793 | ci.format = image_format; |
| 2794 | ci.extent = {32, 1, 1}; |
| 2795 | ci.mipLevels = 1; |
| 2796 | ci.arrayLayers = 1; |
| 2797 | ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2798 | ci.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 2799 | ci.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 2800 | ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 2801 | ci.queueFamilyIndexCount = 0; |
| 2802 | ci.pQueueFamilyIndices = NULL; |
| 2803 | ci.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 2804 | |
| 2805 | // Create 1D image |
| 2806 | VkImageObj image_1D(m_device); |
| 2807 | image_1D.init(&ci); |
| 2808 | ASSERT_TRUE(image_1D.initialized()); |
| 2809 | |
| 2810 | // 2D image |
| 2811 | ci.imageType = VK_IMAGE_TYPE_2D; |
| 2812 | ci.extent = {32, 32, 1}; |
| 2813 | VkImageObj image_2D(m_device); |
| 2814 | image_2D.init(&ci); |
| 2815 | ASSERT_TRUE(image_2D.initialized()); |
| 2816 | |
| 2817 | // 3D image |
| 2818 | ci.imageType = VK_IMAGE_TYPE_3D; |
| 2819 | ci.extent = {32, 32, 8}; |
| 2820 | VkImageObj image_3D(m_device); |
| 2821 | image_3D.init(&ci); |
| 2822 | ASSERT_TRUE(image_3D.initialized()); |
| 2823 | |
| 2824 | // 2D image array |
| 2825 | ci.imageType = VK_IMAGE_TYPE_2D; |
| 2826 | ci.extent = {32, 32, 1}; |
| 2827 | ci.arrayLayers = 8; |
| 2828 | VkImageObj image_2D_array(m_device); |
| 2829 | image_2D_array.init(&ci); |
| 2830 | ASSERT_TRUE(image_2D_array.initialized()); |
| 2831 | |
sfricke-samsung | 211ee9c | 2020-02-13 23:38:39 -0800 | [diff] [blame] | 2832 | // second 2D image array |
| 2833 | ci.imageType = VK_IMAGE_TYPE_2D; |
| 2834 | ci.extent = {32, 32, 1}; |
| 2835 | ci.arrayLayers = 8; |
| 2836 | VkImageObj image_2D_array_2(m_device); |
| 2837 | image_2D_array_2.init(&ci); |
| 2838 | ASSERT_TRUE(image_2D_array_2.initialized()); |
| 2839 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2840 | m_commandBuffer->begin(); |
| 2841 | |
| 2842 | VkImageCopy copy_region; |
| 2843 | copy_region.extent = {32, 1, 1}; |
| 2844 | copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2845 | copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2846 | copy_region.srcSubresource.mipLevel = 0; |
| 2847 | copy_region.dstSubresource.mipLevel = 0; |
| 2848 | copy_region.srcSubresource.baseArrayLayer = 0; |
| 2849 | copy_region.dstSubresource.baseArrayLayer = 0; |
| 2850 | copy_region.srcSubresource.layerCount = 1; |
| 2851 | copy_region.dstSubresource.layerCount = 1; |
| 2852 | copy_region.srcOffset = {0, 0, 0}; |
| 2853 | copy_region.dstOffset = {0, 0, 0}; |
| 2854 | |
| 2855 | // Copy from layer not present |
| 2856 | copy_region.srcSubresource.baseArrayLayer = 4; |
| 2857 | copy_region.srcSubresource.layerCount = 6; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2858 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcSubresource-01698"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2859 | m_commandBuffer->CopyImage(image_2D_array.image(), VK_IMAGE_LAYOUT_GENERAL, image_3D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 2860 | ©_region); |
| 2861 | m_errorMonitor->VerifyFound(); |
| 2862 | copy_region.srcSubresource.baseArrayLayer = 0; |
| 2863 | copy_region.srcSubresource.layerCount = 1; |
| 2864 | |
| 2865 | // Copy to layer not present |
| 2866 | copy_region.dstSubresource.baseArrayLayer = 1; |
| 2867 | copy_region.dstSubresource.layerCount = 8; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2868 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-dstSubresource-01699"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2869 | m_commandBuffer->CopyImage(image_3D.image(), VK_IMAGE_LAYOUT_GENERAL, image_2D_array.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 2870 | ©_region); |
| 2871 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 211ee9c | 2020-02-13 23:38:39 -0800 | [diff] [blame] | 2872 | copy_region.dstSubresource.baseArrayLayer = 0; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2873 | copy_region.dstSubresource.layerCount = 1; |
| 2874 | |
sfricke-samsung | 211ee9c | 2020-02-13 23:38:39 -0800 | [diff] [blame] | 2875 | // both 2D and extent.depth not 1 |
| 2876 | // Need two 2D array images to prevent other errors |
| 2877 | copy_region.extent = {4, 1, 2}; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2878 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcImage-01790"); |
sfricke-samsung | 211ee9c | 2020-02-13 23:38:39 -0800 | [diff] [blame] | 2879 | m_commandBuffer->CopyImage(image_2D_array.image(), VK_IMAGE_LAYOUT_GENERAL, image_2D_array_2.image(), VK_IMAGE_LAYOUT_GENERAL, |
| 2880 | 1, ©_region); |
| 2881 | m_errorMonitor->VerifyFound(); |
| 2882 | copy_region.extent = {32, 1, 1}; |
| 2883 | |
| 2884 | // 2D src / 3D dst and depth not equal to src layerCount |
| 2885 | copy_region.extent = {4, 1, 2}; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2886 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcImage-01791"); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2887 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkImageCopy-extent-00140"); |
sfricke-samsung | 211ee9c | 2020-02-13 23:38:39 -0800 | [diff] [blame] | 2888 | m_commandBuffer->CopyImage(image_2D_array.image(), VK_IMAGE_LAYOUT_GENERAL, image_3D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 2889 | ©_region); |
| 2890 | m_errorMonitor->VerifyFound(); |
| 2891 | copy_region.extent = {32, 1, 1}; |
| 2892 | |
| 2893 | // 3D src / 2D dst and depth not equal to dst layerCount |
| 2894 | copy_region.extent = {4, 1, 2}; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2895 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-dstImage-01792"); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2896 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkImageCopy-extent-00140"); |
sfricke-samsung | 211ee9c | 2020-02-13 23:38:39 -0800 | [diff] [blame] | 2897 | m_commandBuffer->CopyImage(image_3D.image(), VK_IMAGE_LAYOUT_GENERAL, image_2D_array.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 2898 | ©_region); |
| 2899 | m_errorMonitor->VerifyFound(); |
| 2900 | copy_region.extent = {32, 1, 1}; |
| 2901 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2902 | m_commandBuffer->end(); |
| 2903 | } |
| 2904 | |
| 2905 | TEST_F(VkLayerTest, CopyImageCompressedBlockAlignment) { |
| 2906 | // Image copy tests on compressed images with block alignment errors |
| 2907 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 2908 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 2909 | |
| 2910 | // Select a compressed format and verify support |
| 2911 | VkPhysicalDeviceFeatures device_features = {}; |
| 2912 | ASSERT_NO_FATAL_FAILURE(GetPhysicalDeviceFeatures(&device_features)); |
| 2913 | VkFormat compressed_format = VK_FORMAT_UNDEFINED; |
| 2914 | if (device_features.textureCompressionBC) { |
| 2915 | compressed_format = VK_FORMAT_BC3_SRGB_BLOCK; |
| 2916 | } else if (device_features.textureCompressionETC2) { |
| 2917 | compressed_format = VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK; |
| 2918 | } else if (device_features.textureCompressionASTC_LDR) { |
| 2919 | compressed_format = VK_FORMAT_ASTC_4x4_UNORM_BLOCK; |
| 2920 | } |
| 2921 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 2922 | VkImageCreateInfo ci = LvlInitStruct<VkImageCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2923 | ci.flags = 0; |
| 2924 | ci.imageType = VK_IMAGE_TYPE_2D; |
| 2925 | ci.format = compressed_format; |
| 2926 | ci.extent = {64, 64, 1}; |
| 2927 | ci.mipLevels = 1; |
| 2928 | ci.arrayLayers = 1; |
| 2929 | ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2930 | ci.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 2931 | ci.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 2932 | ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 2933 | ci.queueFamilyIndexCount = 0; |
| 2934 | ci.pQueueFamilyIndices = NULL; |
| 2935 | ci.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 2936 | |
| 2937 | VkImageFormatProperties img_prop = {}; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 2938 | if (VK_SUCCESS != vk::GetPhysicalDeviceImageFormatProperties(m_device->phy().handle(), ci.format, ci.imageType, ci.tiling, |
| 2939 | ci.usage, ci.flags, &img_prop)) { |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2940 | printf("%s No compressed formats supported - CopyImageCompressedBlockAlignment skipped.\n", kSkipPrefix); |
| 2941 | return; |
| 2942 | } |
| 2943 | |
| 2944 | // Create images |
| 2945 | VkImageObj image_1(m_device); |
| 2946 | image_1.init(&ci); |
| 2947 | ASSERT_TRUE(image_1.initialized()); |
| 2948 | |
| 2949 | ci.extent = {62, 62, 1}; // slightly smaller and not divisible by block size |
| 2950 | VkImageObj image_2(m_device); |
| 2951 | image_2.init(&ci); |
| 2952 | ASSERT_TRUE(image_2.initialized()); |
| 2953 | |
| 2954 | m_commandBuffer->begin(); |
| 2955 | |
| 2956 | VkImageCopy copy_region; |
| 2957 | copy_region.extent = {48, 48, 1}; |
| 2958 | copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2959 | copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2960 | copy_region.srcSubresource.mipLevel = 0; |
| 2961 | copy_region.dstSubresource.mipLevel = 0; |
| 2962 | copy_region.srcSubresource.baseArrayLayer = 0; |
| 2963 | copy_region.dstSubresource.baseArrayLayer = 0; |
| 2964 | copy_region.srcSubresource.layerCount = 1; |
| 2965 | copy_region.dstSubresource.layerCount = 1; |
| 2966 | copy_region.srcOffset = {0, 0, 0}; |
| 2967 | copy_region.dstOffset = {0, 0, 0}; |
| 2968 | |
| 2969 | // Sanity check |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2970 | m_commandBuffer->CopyImage(image_1.image(), VK_IMAGE_LAYOUT_GENERAL, image_2.image(), VK_IMAGE_LAYOUT_GENERAL, 1, ©_region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2971 | |
| 2972 | std::string vuid; |
| 2973 | bool ycbcr = (DeviceExtensionEnabled(VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME) || |
| 2974 | (DeviceValidationVersion() >= VK_API_VERSION_1_1)); |
| 2975 | |
| 2976 | // Src, Dest offsets must be multiples of compressed block sizes {4, 4, 1} |
| 2977 | // Image transfer granularity gets set to compressed block size, so an ITG error is also (unavoidably) triggered. |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2978 | vuid = ycbcr ? "VUID-vkCmdCopyImage-srcImage-01727" : "VUID-vkCmdCopyImage-srcImage-01727"; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2979 | copy_region.srcOffset = {2, 4, 0}; // source width |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2980 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid); |
| 2981 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2982 | "VUID-vkCmdCopyImage-srcOffset-01783"); // srcOffset image transfer granularity |
| 2983 | m_commandBuffer->CopyImage(image_1.image(), VK_IMAGE_LAYOUT_GENERAL, image_2.image(), VK_IMAGE_LAYOUT_GENERAL, 1, ©_region); |
| 2984 | m_errorMonitor->VerifyFound(); |
| 2985 | copy_region.srcOffset = {12, 1, 0}; // source height |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2986 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid); |
| 2987 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2988 | "VUID-vkCmdCopyImage-srcOffset-01783"); // srcOffset image transfer granularity |
| 2989 | m_commandBuffer->CopyImage(image_1.image(), VK_IMAGE_LAYOUT_GENERAL, image_2.image(), VK_IMAGE_LAYOUT_GENERAL, 1, ©_region); |
| 2990 | m_errorMonitor->VerifyFound(); |
| 2991 | copy_region.srcOffset = {0, 0, 0}; |
| 2992 | |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 2993 | vuid = ycbcr ? "VUID-vkCmdCopyImage-dstImage-01731" : "VUID-vkCmdCopyImage-dstImage-01731"; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2994 | copy_region.dstOffset = {1, 0, 0}; // dest width |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 2995 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid); |
| 2996 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 2997 | "VUID-vkCmdCopyImage-dstOffset-01784"); // dstOffset image transfer granularity |
| 2998 | m_commandBuffer->CopyImage(image_1.image(), VK_IMAGE_LAYOUT_GENERAL, image_2.image(), VK_IMAGE_LAYOUT_GENERAL, 1, ©_region); |
| 2999 | m_errorMonitor->VerifyFound(); |
| 3000 | copy_region.dstOffset = {4, 1, 0}; // dest height |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 3001 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid); |
| 3002 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3003 | "VUID-vkCmdCopyImage-dstOffset-01784"); // dstOffset image transfer granularity |
| 3004 | m_commandBuffer->CopyImage(image_1.image(), VK_IMAGE_LAYOUT_GENERAL, image_2.image(), VK_IMAGE_LAYOUT_GENERAL, 1, ©_region); |
| 3005 | m_errorMonitor->VerifyFound(); |
| 3006 | copy_region.dstOffset = {0, 0, 0}; |
| 3007 | |
| 3008 | // Copy extent must be multiples of compressed block sizes {4, 4, 1} if not full width/height |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3009 | vuid = ycbcr ? "VUID-vkCmdCopyImage-srcImage-01728" : "VUID-vkCmdCopyImage-srcImage-01728"; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3010 | copy_region.extent = {62, 60, 1}; // source width |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 3011 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid); |
| 3012 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3013 | "VUID-vkCmdCopyImage-srcOffset-01783"); // src extent image transfer granularity |
| 3014 | m_commandBuffer->CopyImage(image_1.image(), VK_IMAGE_LAYOUT_GENERAL, image_2.image(), VK_IMAGE_LAYOUT_GENERAL, 1, ©_region); |
| 3015 | m_errorMonitor->VerifyFound(); |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3016 | vuid = ycbcr ? "VUID-vkCmdCopyImage-srcImage-01729" : "VUID-vkCmdCopyImage-srcImage-01729"; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3017 | copy_region.extent = {60, 62, 1}; // source height |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 3018 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid); |
| 3019 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3020 | "VUID-vkCmdCopyImage-srcOffset-01783"); // src extent image transfer granularity |
| 3021 | m_commandBuffer->CopyImage(image_1.image(), VK_IMAGE_LAYOUT_GENERAL, image_2.image(), VK_IMAGE_LAYOUT_GENERAL, 1, ©_region); |
| 3022 | m_errorMonitor->VerifyFound(); |
| 3023 | |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3024 | vuid = ycbcr ? "VUID-vkCmdCopyImage-dstImage-01732" : "VUID-vkCmdCopyImage-dstImage-01732"; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3025 | copy_region.extent = {62, 60, 1}; // dest width |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 3026 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid); |
| 3027 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3028 | "VUID-vkCmdCopyImage-dstOffset-01784"); // dst extent image transfer granularity |
| 3029 | m_commandBuffer->CopyImage(image_2.image(), VK_IMAGE_LAYOUT_GENERAL, image_1.image(), VK_IMAGE_LAYOUT_GENERAL, 1, ©_region); |
| 3030 | m_errorMonitor->VerifyFound(); |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3031 | vuid = ycbcr ? "VUID-vkCmdCopyImage-dstImage-01733" : "VUID-vkCmdCopyImage-dstImage-01733"; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3032 | copy_region.extent = {60, 62, 1}; // dest height |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 3033 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid); |
| 3034 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3035 | "VUID-vkCmdCopyImage-dstOffset-01784"); // dst extent image transfer granularity |
| 3036 | m_commandBuffer->CopyImage(image_2.image(), VK_IMAGE_LAYOUT_GENERAL, image_1.image(), VK_IMAGE_LAYOUT_GENERAL, 1, ©_region); |
| 3037 | m_errorMonitor->VerifyFound(); |
| 3038 | |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3039 | // Note: "VUID-vkCmdCopyImage-srcImage-01730", "VUID-vkCmdCopyImage-dstImage-01734", "VUID-vkCmdCopyImage-srcImage-01730", |
| 3040 | // "VUID-vkCmdCopyImage-dstImage-01734" |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3041 | // There are currently no supported compressed formats with a block depth other than 1, |
| 3042 | // so impossible to create a 'not a multiple' condition for depth. |
| 3043 | m_commandBuffer->end(); |
| 3044 | } |
| 3045 | |
| 3046 | TEST_F(VkLayerTest, CopyImageSinglePlane422Alignment) { |
| 3047 | // Image copy tests on single-plane _422 formats with block alignment errors |
| 3048 | |
| 3049 | // Enable KHR multiplane req'd extensions |
| 3050 | bool mp_extensions = InstanceExtensionSupported(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, |
| 3051 | VK_KHR_GET_MEMORY_REQUIREMENTS_2_SPEC_VERSION); |
| 3052 | if (mp_extensions) { |
| 3053 | m_instance_extension_names.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 3054 | } |
Mark Lobodzinski | 09ce9c4 | 2020-03-06 10:02:44 -0700 | [diff] [blame] | 3055 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 3056 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3057 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME); |
| 3058 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_BIND_MEMORY_2_EXTENSION_NAME); |
| 3059 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME); |
| 3060 | if (mp_extensions) { |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 3061 | m_device_extension_names.push_back(VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3062 | m_device_extension_names.push_back(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME); |
| 3063 | m_device_extension_names.push_back(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME); |
| 3064 | m_device_extension_names.push_back(VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME); |
| 3065 | } else { |
| 3066 | printf("%s test requires KHR multiplane extensions, not available. Skipping.\n", kSkipPrefix); |
| 3067 | return; |
| 3068 | } |
| 3069 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3070 | |
| 3071 | // Select a _422 format and verify support |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 3072 | VkImageCreateInfo ci = LvlInitStruct<VkImageCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3073 | ci.flags = 0; |
| 3074 | ci.imageType = VK_IMAGE_TYPE_2D; |
| 3075 | ci.format = VK_FORMAT_G8B8G8R8_422_UNORM_KHR; |
| 3076 | ci.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3077 | ci.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 3078 | ci.mipLevels = 1; |
| 3079 | ci.arrayLayers = 1; |
| 3080 | ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3081 | ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 3082 | ci.queueFamilyIndexCount = 0; |
| 3083 | ci.pQueueFamilyIndices = NULL; |
| 3084 | ci.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 3085 | |
| 3086 | // Verify formats |
| 3087 | VkFormatFeatureFlags features = VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT; |
| 3088 | bool supported = ImageFormatAndFeaturesSupported(instance(), gpu(), ci, features); |
| 3089 | if (!supported) { |
| 3090 | printf("%s Single-plane _422 image format not supported. Skipping test.\n", kSkipPrefix); |
| 3091 | return; // Assume there's low ROI on searching for different mp formats |
| 3092 | } |
| 3093 | |
| 3094 | // Create images |
| 3095 | ci.extent = {64, 64, 1}; |
| 3096 | VkImageObj image_422(m_device); |
| 3097 | image_422.init(&ci); |
| 3098 | ASSERT_TRUE(image_422.initialized()); |
| 3099 | |
| 3100 | ci.extent = {64, 64, 1}; |
| 3101 | ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 3102 | VkImageObj image_ucmp(m_device); |
| 3103 | image_ucmp.init(&ci); |
| 3104 | ASSERT_TRUE(image_ucmp.initialized()); |
| 3105 | |
| 3106 | m_commandBuffer->begin(); |
| 3107 | |
| 3108 | VkImageCopy copy_region; |
| 3109 | copy_region.extent = {48, 48, 1}; |
| 3110 | copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3111 | copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3112 | copy_region.srcSubresource.mipLevel = 0; |
| 3113 | copy_region.dstSubresource.mipLevel = 0; |
| 3114 | copy_region.srcSubresource.baseArrayLayer = 0; |
| 3115 | copy_region.dstSubresource.baseArrayLayer = 0; |
| 3116 | copy_region.srcSubresource.layerCount = 1; |
| 3117 | copy_region.dstSubresource.layerCount = 1; |
| 3118 | copy_region.srcOffset = {0, 0, 0}; |
| 3119 | copy_region.dstOffset = {0, 0, 0}; |
| 3120 | |
| 3121 | // Src offsets must be multiples of compressed block sizes |
| 3122 | copy_region.srcOffset = {3, 4, 0}; // source offset x |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3123 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcImage-01727"); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 3124 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcOffset-01783"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3125 | m_commandBuffer->CopyImage(image_422.image(), VK_IMAGE_LAYOUT_GENERAL, image_ucmp.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3126 | ©_region); |
| 3127 | m_errorMonitor->VerifyFound(); |
| 3128 | copy_region.srcOffset = {0, 0, 0}; |
| 3129 | |
| 3130 | // Dst offsets must be multiples of compressed block sizes |
| 3131 | copy_region.dstOffset = {1, 0, 0}; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3132 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-dstImage-01731"); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 3133 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-dstOffset-01784"); |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3134 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-dstOffset-00150"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3135 | m_commandBuffer->CopyImage(image_ucmp.image(), VK_IMAGE_LAYOUT_GENERAL, image_422.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3136 | ©_region); |
| 3137 | m_errorMonitor->VerifyFound(); |
| 3138 | copy_region.dstOffset = {0, 0, 0}; |
| 3139 | |
| 3140 | // Copy extent must be multiples of compressed block sizes if not full width/height |
| 3141 | copy_region.extent = {31, 60, 1}; // 422 source, extent.x |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3142 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcImage-01728"); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 3143 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcOffset-01783"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3144 | m_commandBuffer->CopyImage(image_422.image(), VK_IMAGE_LAYOUT_GENERAL, image_ucmp.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3145 | ©_region); |
| 3146 | m_errorMonitor->VerifyFound(); |
| 3147 | |
unknown | 357e178 | 2019-09-25 17:57:40 -0600 | [diff] [blame] | 3148 | // 422 dest |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3149 | m_commandBuffer->CopyImage(image_ucmp.image(), VK_IMAGE_LAYOUT_GENERAL, image_422.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3150 | ©_region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3151 | copy_region.dstOffset = {0, 0, 0}; |
| 3152 | |
| 3153 | m_commandBuffer->end(); |
| 3154 | } |
| 3155 | |
| 3156 | TEST_F(VkLayerTest, CopyImageMultiplaneAspectBits) { |
| 3157 | // Image copy tests on multiplane images with aspect errors |
| 3158 | |
| 3159 | // Enable KHR multiplane req'd extensions |
| 3160 | bool mp_extensions = InstanceExtensionSupported(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, |
| 3161 | VK_KHR_GET_MEMORY_REQUIREMENTS_2_SPEC_VERSION); |
| 3162 | if (mp_extensions) { |
| 3163 | m_instance_extension_names.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 3164 | } |
Mark Lobodzinski | 09ce9c4 | 2020-03-06 10:02:44 -0700 | [diff] [blame] | 3165 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 3166 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3167 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME); |
| 3168 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_BIND_MEMORY_2_EXTENSION_NAME); |
| 3169 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME); |
| 3170 | if (mp_extensions) { |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 3171 | m_device_extension_names.push_back(VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3172 | m_device_extension_names.push_back(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME); |
| 3173 | m_device_extension_names.push_back(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME); |
| 3174 | m_device_extension_names.push_back(VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME); |
| 3175 | } else { |
| 3176 | printf("%s test requires KHR multiplane extensions, not available. Skipping.\n", kSkipPrefix); |
| 3177 | return; |
| 3178 | } |
| 3179 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3180 | |
| 3181 | // Select multi-plane formats and verify support |
| 3182 | VkFormat mp3_format = VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM_KHR; |
| 3183 | VkFormat mp2_format = VK_FORMAT_G8_B8R8_2PLANE_422_UNORM_KHR; |
| 3184 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 3185 | VkImageCreateInfo ci = LvlInitStruct<VkImageCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3186 | ci.flags = 0; |
| 3187 | ci.imageType = VK_IMAGE_TYPE_2D; |
| 3188 | ci.format = mp2_format; |
| 3189 | ci.extent = {256, 256, 1}; |
| 3190 | ci.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3191 | ci.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 3192 | ci.mipLevels = 1; |
| 3193 | ci.arrayLayers = 1; |
| 3194 | ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3195 | ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 3196 | ci.queueFamilyIndexCount = 0; |
| 3197 | ci.pQueueFamilyIndices = NULL; |
| 3198 | ci.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 3199 | |
| 3200 | // Verify formats |
| 3201 | VkFormatFeatureFlags features = VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT; |
| 3202 | bool supported = ImageFormatAndFeaturesSupported(instance(), gpu(), ci, features); |
| 3203 | ci.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 3204 | supported = supported && ImageFormatAndFeaturesSupported(instance(), gpu(), ci, features); |
| 3205 | ci.format = mp3_format; |
| 3206 | supported = supported && ImageFormatAndFeaturesSupported(instance(), gpu(), ci, features); |
| 3207 | if (!supported) { |
| 3208 | printf("%s Multiplane image formats or optimally tiled depth-stencil buffers not supported. Skipping test.\n", |
| 3209 | kSkipPrefix); |
| 3210 | return; // Assume there's low ROI on searching for different mp formats |
| 3211 | } |
| 3212 | |
| 3213 | // Create images |
| 3214 | VkImageObj mp3_image(m_device); |
| 3215 | mp3_image.init(&ci); |
| 3216 | ASSERT_TRUE(mp3_image.initialized()); |
| 3217 | |
| 3218 | ci.format = mp2_format; |
| 3219 | VkImageObj mp2_image(m_device); |
| 3220 | mp2_image.init(&ci); |
| 3221 | ASSERT_TRUE(mp2_image.initialized()); |
| 3222 | |
| 3223 | ci.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 3224 | VkImageObj sp_image(m_device); |
| 3225 | sp_image.init(&ci); |
| 3226 | ASSERT_TRUE(sp_image.initialized()); |
| 3227 | |
| 3228 | m_commandBuffer->begin(); |
| 3229 | |
| 3230 | VkImageCopy copy_region; |
| 3231 | copy_region.extent = {128, 128, 1}; |
| 3232 | copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_2_BIT_KHR; |
| 3233 | copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_2_BIT_KHR; |
| 3234 | copy_region.srcSubresource.mipLevel = 0; |
| 3235 | copy_region.dstSubresource.mipLevel = 0; |
| 3236 | copy_region.srcSubresource.baseArrayLayer = 0; |
| 3237 | copy_region.dstSubresource.baseArrayLayer = 0; |
| 3238 | copy_region.srcSubresource.layerCount = 1; |
| 3239 | copy_region.dstSubresource.layerCount = 1; |
| 3240 | copy_region.srcOffset = {0, 0, 0}; |
| 3241 | copy_region.dstOffset = {0, 0, 0}; |
| 3242 | |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3243 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcImage-01552"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3244 | m_commandBuffer->CopyImage(mp2_image.image(), VK_IMAGE_LAYOUT_GENERAL, mp3_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3245 | ©_region); |
| 3246 | m_errorMonitor->VerifyFound(); |
| 3247 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3248 | copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3249 | copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_0_BIT_KHR; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3250 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcImage-01553"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3251 | m_commandBuffer->CopyImage(mp3_image.image(), VK_IMAGE_LAYOUT_GENERAL, mp2_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3252 | ©_region); |
| 3253 | m_errorMonitor->VerifyFound(); |
| 3254 | |
| 3255 | copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_1_BIT_KHR; |
| 3256 | copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_2_BIT_KHR; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3257 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-dstImage-01554"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3258 | m_commandBuffer->CopyImage(mp3_image.image(), VK_IMAGE_LAYOUT_GENERAL, mp2_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3259 | ©_region); |
| 3260 | m_errorMonitor->VerifyFound(); |
| 3261 | |
| 3262 | copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3263 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-dstImage-01555"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3264 | m_commandBuffer->CopyImage(mp2_image.image(), VK_IMAGE_LAYOUT_GENERAL, mp3_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3265 | ©_region); |
| 3266 | m_errorMonitor->VerifyFound(); |
| 3267 | |
| 3268 | copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3269 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcImage-01556"); |
sfricke-samsung | 99dc12c | 2020-04-23 01:52:01 -0700 | [diff] [blame] | 3270 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-None-01549"); // since also non-compatiable |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3271 | m_commandBuffer->CopyImage(mp2_image.image(), VK_IMAGE_LAYOUT_GENERAL, sp_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3272 | ©_region); |
| 3273 | m_errorMonitor->VerifyFound(); |
| 3274 | |
| 3275 | copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; |
| 3276 | copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_2_BIT_KHR; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3277 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-dstImage-01557"); |
sfricke-samsung | 99dc12c | 2020-04-23 01:52:01 -0700 | [diff] [blame] | 3278 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-None-01549"); // since also non-compatiable |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3279 | m_commandBuffer->CopyImage(sp_image.image(), VK_IMAGE_LAYOUT_GENERAL, mp3_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3280 | ©_region); |
| 3281 | m_errorMonitor->VerifyFound(); |
| 3282 | |
| 3283 | m_commandBuffer->end(); |
| 3284 | } |
| 3285 | |
| 3286 | TEST_F(VkLayerTest, CopyImageSrcSizeExceeded) { |
| 3287 | // Image copy with source region specified greater than src image size |
| 3288 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 3289 | |
| 3290 | // Create images with full mip chain |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 3291 | VkImageCreateInfo ci = LvlInitStruct<VkImageCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3292 | ci.flags = 0; |
| 3293 | ci.imageType = VK_IMAGE_TYPE_3D; |
| 3294 | ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 3295 | ci.extent = {32, 32, 8}; |
| 3296 | ci.mipLevels = 6; |
| 3297 | ci.arrayLayers = 1; |
| 3298 | ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3299 | ci.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3300 | ci.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 3301 | ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 3302 | ci.queueFamilyIndexCount = 0; |
| 3303 | ci.pQueueFamilyIndices = NULL; |
| 3304 | ci.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 3305 | |
| 3306 | VkImageObj src_image(m_device); |
| 3307 | src_image.init(&ci); |
| 3308 | ASSERT_TRUE(src_image.initialized()); |
| 3309 | |
| 3310 | // Dest image with one more mip level |
| 3311 | ci.extent = {64, 64, 16}; |
| 3312 | ci.mipLevels = 7; |
| 3313 | ci.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 3314 | VkImageObj dst_image(m_device); |
| 3315 | dst_image.init(&ci); |
| 3316 | ASSERT_TRUE(dst_image.initialized()); |
| 3317 | |
| 3318 | m_commandBuffer->begin(); |
| 3319 | |
| 3320 | VkImageCopy copy_region; |
| 3321 | copy_region.extent = {32, 32, 8}; |
| 3322 | copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3323 | copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3324 | copy_region.srcSubresource.mipLevel = 0; |
| 3325 | copy_region.dstSubresource.mipLevel = 0; |
| 3326 | copy_region.srcSubresource.baseArrayLayer = 0; |
| 3327 | copy_region.dstSubresource.baseArrayLayer = 0; |
| 3328 | copy_region.srcSubresource.layerCount = 1; |
| 3329 | copy_region.dstSubresource.layerCount = 1; |
| 3330 | copy_region.srcOffset = {0, 0, 0}; |
| 3331 | copy_region.dstOffset = {0, 0, 0}; |
| 3332 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3333 | m_commandBuffer->CopyImage(src_image.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3334 | ©_region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3335 | |
sfricke-samsung | 066e0c7 | 2022-03-15 23:35:23 -0500 | [diff] [blame] | 3336 | // Source exceeded in x-dim |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3337 | copy_region.srcOffset.x = 4; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3338 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcOffset-00144"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3339 | m_commandBuffer->CopyImage(src_image.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3340 | ©_region); |
| 3341 | m_errorMonitor->VerifyFound(); |
| 3342 | |
sfricke-samsung | 066e0c7 | 2022-03-15 23:35:23 -0500 | [diff] [blame] | 3343 | // Dest exceeded in x-dim in negative direction (since offset is a signed in) |
| 3344 | copy_region.extent.width = 4; |
| 3345 | copy_region.srcOffset.x = -8; |
| 3346 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcOffset-00144"); |
| 3347 | m_commandBuffer->CopyImage(src_image.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3348 | ©_region); |
| 3349 | m_errorMonitor->VerifyFound(); |
| 3350 | copy_region.extent.width = 32; |
| 3351 | |
| 3352 | // Source exceeded in y-dim |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3353 | copy_region.srcOffset.x = 0; |
| 3354 | copy_region.extent.height = 48; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3355 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcOffset-00145"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3356 | m_commandBuffer->CopyImage(src_image.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3357 | ©_region); |
| 3358 | m_errorMonitor->VerifyFound(); |
| 3359 | |
sfricke-samsung | 066e0c7 | 2022-03-15 23:35:23 -0500 | [diff] [blame] | 3360 | // Source exceeded in z-dim |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3361 | copy_region.extent = {4, 4, 4}; |
| 3362 | copy_region.srcSubresource.mipLevel = 2; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3363 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcOffset-00147"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3364 | m_commandBuffer->CopyImage(src_image.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3365 | ©_region); |
| 3366 | m_errorMonitor->VerifyFound(); |
| 3367 | |
| 3368 | m_commandBuffer->end(); |
| 3369 | } |
| 3370 | |
| 3371 | TEST_F(VkLayerTest, CopyImageDstSizeExceeded) { |
| 3372 | // Image copy with dest region specified greater than dest image size |
| 3373 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 3374 | |
| 3375 | // Create images with full mip chain |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 3376 | VkImageCreateInfo ci = LvlInitStruct<VkImageCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3377 | ci.flags = 0; |
| 3378 | ci.imageType = VK_IMAGE_TYPE_3D; |
| 3379 | ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 3380 | ci.extent = {32, 32, 8}; |
| 3381 | ci.mipLevels = 6; |
| 3382 | ci.arrayLayers = 1; |
| 3383 | ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3384 | ci.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3385 | ci.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 3386 | ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 3387 | ci.queueFamilyIndexCount = 0; |
| 3388 | ci.pQueueFamilyIndices = NULL; |
| 3389 | ci.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 3390 | |
| 3391 | VkImageObj dst_image(m_device); |
| 3392 | dst_image.init(&ci); |
| 3393 | ASSERT_TRUE(dst_image.initialized()); |
| 3394 | |
| 3395 | // Src image with one more mip level |
| 3396 | ci.extent = {64, 64, 16}; |
| 3397 | ci.mipLevels = 7; |
| 3398 | ci.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 3399 | VkImageObj src_image(m_device); |
| 3400 | src_image.init(&ci); |
| 3401 | ASSERT_TRUE(src_image.initialized()); |
| 3402 | |
| 3403 | m_commandBuffer->begin(); |
| 3404 | |
| 3405 | VkImageCopy copy_region; |
| 3406 | copy_region.extent = {32, 32, 8}; |
| 3407 | copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3408 | copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3409 | copy_region.srcSubresource.mipLevel = 0; |
| 3410 | copy_region.dstSubresource.mipLevel = 0; |
| 3411 | copy_region.srcSubresource.baseArrayLayer = 0; |
| 3412 | copy_region.dstSubresource.baseArrayLayer = 0; |
| 3413 | copy_region.srcSubresource.layerCount = 1; |
| 3414 | copy_region.dstSubresource.layerCount = 1; |
| 3415 | copy_region.srcOffset = {0, 0, 0}; |
| 3416 | copy_region.dstOffset = {0, 0, 0}; |
| 3417 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3418 | m_commandBuffer->CopyImage(src_image.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3419 | ©_region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3420 | |
sfricke-samsung | 066e0c7 | 2022-03-15 23:35:23 -0500 | [diff] [blame] | 3421 | // Dest exceeded in x-dim |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3422 | copy_region.dstOffset.x = 4; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3423 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-dstOffset-00150"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3424 | m_commandBuffer->CopyImage(src_image.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3425 | ©_region); |
| 3426 | m_errorMonitor->VerifyFound(); |
| 3427 | |
sfricke-samsung | 066e0c7 | 2022-03-15 23:35:23 -0500 | [diff] [blame] | 3428 | // Dest exceeded in x-dim in negative direction (since offset is a signed in) |
| 3429 | copy_region.extent.width = 4; |
| 3430 | copy_region.dstOffset.x = -8; |
| 3431 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-dstOffset-00150"); |
| 3432 | m_commandBuffer->CopyImage(src_image.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3433 | ©_region); |
| 3434 | m_errorMonitor->VerifyFound(); |
| 3435 | copy_region.extent.width = 32; |
| 3436 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3437 | copy_region.dstOffset.x = 0; |
| 3438 | copy_region.extent.height = 48; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3439 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-dstOffset-00151"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3440 | m_commandBuffer->CopyImage(src_image.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3441 | ©_region); |
| 3442 | m_errorMonitor->VerifyFound(); |
| 3443 | |
sfricke-samsung | 066e0c7 | 2022-03-15 23:35:23 -0500 | [diff] [blame] | 3444 | // Dest exceeded in z-dim |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3445 | copy_region.extent = {4, 4, 4}; |
| 3446 | copy_region.dstSubresource.mipLevel = 2; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3447 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-dstOffset-00153"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3448 | m_commandBuffer->CopyImage(src_image.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3449 | ©_region); |
| 3450 | m_errorMonitor->VerifyFound(); |
| 3451 | |
| 3452 | m_commandBuffer->end(); |
| 3453 | } |
| 3454 | |
sfricke-samsung | ea1154b | 2022-03-31 22:29:34 -0500 | [diff] [blame] | 3455 | TEST_F(VkLayerTest, CopyImageZeroSize) { |
| 3456 | TEST_DESCRIPTION("Image Copy with empty regions"); |
| 3457 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 3458 | |
| 3459 | // Create images with full mip chain |
| 3460 | VkImageCreateInfo ci = LvlInitStruct<VkImageCreateInfo>(); |
| 3461 | ci.flags = 0; |
| 3462 | ci.imageType = VK_IMAGE_TYPE_3D; |
| 3463 | ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 3464 | ci.extent = {32, 32, 8}; |
| 3465 | ci.mipLevels = 6; |
| 3466 | ci.arrayLayers = 1; |
| 3467 | ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3468 | ci.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3469 | ci.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 3470 | ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 3471 | ci.queueFamilyIndexCount = 0; |
| 3472 | ci.pQueueFamilyIndices = NULL; |
| 3473 | ci.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 3474 | |
| 3475 | VkImageObj src_image(m_device); |
| 3476 | src_image.init(&ci); |
| 3477 | ASSERT_TRUE(src_image.initialized()); |
| 3478 | |
| 3479 | ci.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 3480 | VkImageObj dst_image(m_device); |
| 3481 | dst_image.init(&ci); |
| 3482 | ASSERT_TRUE(dst_image.initialized()); |
| 3483 | |
| 3484 | VkBufferObj buffer; |
| 3485 | VkMemoryPropertyFlags reqs = 0; |
| 3486 | buffer.init_as_src_and_dst(*m_device, 16384, reqs); // large enough for image |
| 3487 | |
| 3488 | m_commandBuffer->begin(); |
| 3489 | |
| 3490 | VkImageCopy copy_region; |
| 3491 | copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3492 | copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3493 | copy_region.srcSubresource.mipLevel = 0; |
| 3494 | copy_region.dstSubresource.mipLevel = 0; |
| 3495 | copy_region.srcSubresource.baseArrayLayer = 0; |
| 3496 | copy_region.dstSubresource.baseArrayLayer = 0; |
| 3497 | copy_region.srcSubresource.layerCount = 1; |
| 3498 | copy_region.dstSubresource.layerCount = 1; |
| 3499 | copy_region.srcOffset = {0, 0, 0}; |
| 3500 | copy_region.dstOffset = {0, 0, 0}; |
| 3501 | |
| 3502 | copy_region.extent = {4, 4, 0}; |
| 3503 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkImageCopy-extent-06670"); |
| 3504 | m_commandBuffer->CopyImage(src_image.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3505 | ©_region); |
| 3506 | m_errorMonitor->VerifyFound(); |
| 3507 | |
| 3508 | copy_region.extent = {0, 0, 4}; |
| 3509 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkImageCopy-extent-06668"); // width |
| 3510 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkImageCopy-extent-06669"); // height |
| 3511 | m_commandBuffer->CopyImage(src_image.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3512 | ©_region); |
| 3513 | m_errorMonitor->VerifyFound(); |
| 3514 | |
| 3515 | VkImageSubresourceLayers image_subresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}; |
| 3516 | VkBufferImageCopy buffer_image_copy; |
| 3517 | buffer_image_copy.bufferRowLength = 0; |
| 3518 | buffer_image_copy.bufferImageHeight = 0; |
| 3519 | buffer_image_copy.imageSubresource = image_subresource; |
| 3520 | buffer_image_copy.imageOffset = {0, 0, 0}; |
| 3521 | buffer_image_copy.bufferOffset = 0; |
| 3522 | |
| 3523 | buffer_image_copy.imageExtent = {4, 0, 1}; |
| 3524 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkBufferImageCopy-imageExtent-06660"); |
| 3525 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), src_image.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer.handle(), 1, |
| 3526 | &buffer_image_copy); |
| 3527 | m_errorMonitor->VerifyFound(); |
| 3528 | |
| 3529 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkBufferImageCopy-imageExtent-06660"); |
| 3530 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer.handle(), dst_image.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3531 | &buffer_image_copy); |
| 3532 | m_errorMonitor->VerifyFound(); |
| 3533 | |
| 3534 | // depth is now zero |
| 3535 | buffer_image_copy.imageExtent = {4, 1, 0}; |
| 3536 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkBufferImageCopy-imageExtent-06661"); |
| 3537 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), src_image.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer.handle(), 1, |
| 3538 | &buffer_image_copy); |
| 3539 | m_errorMonitor->VerifyFound(); |
| 3540 | |
| 3541 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkBufferImageCopy-imageExtent-06661"); |
| 3542 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer.handle(), dst_image.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3543 | &buffer_image_copy); |
| 3544 | m_errorMonitor->VerifyFound(); |
| 3545 | |
| 3546 | m_commandBuffer->end(); |
| 3547 | } |
| 3548 | |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3549 | TEST_F(VkLayerTest, CopyImageMultiPlaneSizeExceeded) { |
| 3550 | TEST_DESCRIPTION("Image Copy for multi-planar format that exceed size of plane for both src and dst"); |
| 3551 | |
| 3552 | // Enable KHR multiplane req'd extensions |
| 3553 | bool mp_extensions = InstanceExtensionSupported(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, |
| 3554 | VK_KHR_GET_MEMORY_REQUIREMENTS_2_SPEC_VERSION); |
| 3555 | if (mp_extensions == true) { |
| 3556 | m_instance_extension_names.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 3557 | } |
| 3558 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 3559 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3560 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME); |
| 3561 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_BIND_MEMORY_2_EXTENSION_NAME); |
| 3562 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME); |
| 3563 | if (mp_extensions == true) { |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 3564 | m_device_extension_names.push_back(VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3565 | m_device_extension_names.push_back(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME); |
| 3566 | m_device_extension_names.push_back(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME); |
| 3567 | m_device_extension_names.push_back(VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME); |
| 3568 | } else { |
| 3569 | printf("%s test requires KHR multiplane extensions, not available. Skipping.\n", kSkipPrefix); |
| 3570 | return; |
| 3571 | } |
| 3572 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3573 | |
sfricke-samsung | 99dc12c | 2020-04-23 01:52:01 -0700 | [diff] [blame] | 3574 | // Try to use VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM because need multi-plane format for some tests and likely supported due to |
| 3575 | // copy support being required with samplerYcbcrConversion feature |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3576 | VkFormatProperties props = {0, 0, 0}; |
| 3577 | bool missing_format_support = false; |
sfricke-samsung | 99dc12c | 2020-04-23 01:52:01 -0700 | [diff] [blame] | 3578 | vk::GetPhysicalDeviceFormatProperties(m_device->phy().handle(), VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM, &props); |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3579 | missing_format_support |= (props.bufferFeatures == 0 && props.linearTilingFeatures == 0 && props.optimalTilingFeatures == 0); |
| 3580 | missing_format_support |= (props.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT) == 0; |
| 3581 | missing_format_support |= (props.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_DST_BIT) == 0; |
| 3582 | |
| 3583 | if (missing_format_support == true) { |
sfricke-samsung | 99dc12c | 2020-04-23 01:52:01 -0700 | [diff] [blame] | 3584 | printf("%s VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM transfer not supported; skipped.\n", kSkipPrefix); |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3585 | return; |
| 3586 | } |
| 3587 | |
| 3588 | // 128^2 texels in plane_0 and 64^2 texels in plane_1 |
| 3589 | VkImageObj src_image(m_device); |
| 3590 | VkImageObj dst_image(m_device); |
sfricke-samsung | 99dc12c | 2020-04-23 01:52:01 -0700 | [diff] [blame] | 3591 | src_image.Init(128, 128, 1, VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM, VK_IMAGE_USAGE_TRANSFER_SRC_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3592 | ASSERT_TRUE(src_image.initialized()); |
sfricke-samsung | 99dc12c | 2020-04-23 01:52:01 -0700 | [diff] [blame] | 3593 | dst_image.Init(128, 128, 1, VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM, VK_IMAGE_USAGE_TRANSFER_DST_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3594 | ASSERT_TRUE(dst_image.initialized()); |
| 3595 | |
| 3596 | VkImageCopy copy_region = {}; |
| 3597 | copy_region.extent = {64, 64, 1}; // Size of plane 1 |
| 3598 | copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_1_BIT; |
| 3599 | copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_1_BIT; |
| 3600 | copy_region.srcSubresource.mipLevel = 0; |
| 3601 | copy_region.dstSubresource.mipLevel = 0; |
| 3602 | copy_region.srcSubresource.baseArrayLayer = 0; |
| 3603 | copy_region.dstSubresource.baseArrayLayer = 0; |
| 3604 | copy_region.srcSubresource.layerCount = 1; |
| 3605 | copy_region.dstSubresource.layerCount = 1; |
| 3606 | copy_region.srcOffset = {0, 0, 0}; |
| 3607 | copy_region.dstOffset = {0, 0, 0}; |
| 3608 | VkImageCopy original_region = copy_region; |
| 3609 | |
| 3610 | m_commandBuffer->begin(); |
| 3611 | |
| 3612 | // Should be able to do a 64x64 copy from plane 1 -> Plane 1 |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3613 | m_commandBuffer->CopyImage(src_image.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3614 | ©_region); |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3615 | |
| 3616 | // Should be able to do a 64x64 copy from plane 0 -> Plane 0 |
| 3617 | copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_0_BIT; |
| 3618 | copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_0_BIT; |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3619 | m_commandBuffer->CopyImage(src_image.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3620 | ©_region); |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3621 | |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 3622 | VkMemoryBarrier mem_barrier = LvlInitStruct<VkMemoryBarrier>(); |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 3623 | mem_barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; |
| 3624 | mem_barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; |
| 3625 | |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3626 | // Should be able to do a 64x64 copy from plane 0 -> Plane 1 |
| 3627 | copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_0_BIT; |
| 3628 | copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_1_BIT; |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 3629 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, |
| 3630 | &mem_barrier, 0, nullptr, 0, nullptr); |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3631 | m_commandBuffer->CopyImage(src_image.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3632 | ©_region); |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3633 | |
| 3634 | // Should be able to do a 64x64 copy from plane 0 -> Plane 1 |
| 3635 | copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_1_BIT; |
| 3636 | copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_0_BIT; |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 3637 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, |
| 3638 | &mem_barrier, 0, nullptr, 0, nullptr); |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3639 | m_commandBuffer->CopyImage(src_image.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3640 | ©_region); |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3641 | |
| 3642 | // Should be able to do a 128x64 copy from plane 0 -> Plane 0 |
| 3643 | copy_region.extent = {128, 64, 1}; |
| 3644 | copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_0_BIT; |
| 3645 | copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_0_BIT; |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 3646 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, |
| 3647 | &mem_barrier, 0, nullptr, 0, nullptr); |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3648 | m_commandBuffer->CopyImage(src_image.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3649 | ©_region); |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3650 | |
| 3651 | // 128x64 copy from plane 0 -> Plane 1 |
| 3652 | copy_region.extent = {128, 64, 1}; |
| 3653 | copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_0_BIT; |
| 3654 | copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_1_BIT; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3655 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-dstOffset-00150"); |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3656 | m_commandBuffer->CopyImage(src_image.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3657 | ©_region); |
| 3658 | m_errorMonitor->VerifyFound(); |
| 3659 | |
| 3660 | // 128x64 copy from plane 1 -> Plane 0 |
| 3661 | copy_region.extent = {128, 64, 1}; |
| 3662 | copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_1_BIT; |
| 3663 | copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_0_BIT; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3664 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcOffset-00144"); |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3665 | m_commandBuffer->CopyImage(src_image.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3666 | ©_region); |
| 3667 | m_errorMonitor->VerifyFound(); |
| 3668 | |
| 3669 | // src exceeded in y-dim from offset |
| 3670 | copy_region = original_region; |
| 3671 | copy_region.srcOffset.y = 4; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3672 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcOffset-00145"); |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3673 | m_commandBuffer->CopyImage(src_image.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3674 | ©_region); |
| 3675 | m_errorMonitor->VerifyFound(); |
| 3676 | |
| 3677 | // dst exceeded in y-dim from offset |
| 3678 | copy_region = original_region; |
| 3679 | copy_region.dstOffset.y = 4; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 3680 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-dstOffset-00151"); |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3681 | m_commandBuffer->CopyImage(src_image.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3682 | ©_region); |
| 3683 | m_errorMonitor->VerifyFound(); |
| 3684 | |
| 3685 | m_commandBuffer->end(); |
| 3686 | } |
| 3687 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3688 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
sjfricke | 3a10ae8 | 2022-08-02 18:48:57 +0900 | [diff] [blame] | 3689 | if (!OverrideDevsimForDeviceProfileLayer()) { |
| 3690 | GTEST_SKIP() << "Failed to override devsim for device profile layer."; |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3691 | } |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3692 | |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3693 | // Enable KHR multiplane req'd extensions |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 3694 | AddRequiredExtensions(VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME); |
| 3695 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 3696 | if (!AreRequiredExtensionsEnabled()) { |
| 3697 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
sfricke-samsung | 8ceaaea | 2020-03-07 14:08:08 -0800 | [diff] [blame] | 3698 | } |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 3699 | auto mp_features = LvlInitStruct<VkPhysicalDeviceSamplerYcbcrConversionFeaturesKHR>(); |
| 3700 | auto features2 = GetPhysicalDeviceFeatures2(mp_features); |
| 3701 | |
| 3702 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3703 | |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3704 | PFN_vkSetPhysicalDeviceFormatPropertiesEXT fpvkSetPhysicalDeviceFormatPropertiesEXT = nullptr; |
| 3705 | PFN_vkGetOriginalPhysicalDeviceFormatPropertiesEXT fpvkGetOriginalPhysicalDeviceFormatPropertiesEXT = nullptr; |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3706 | if (!LoadDeviceProfileLayer(fpvkSetPhysicalDeviceFormatPropertiesEXT, fpvkGetOriginalPhysicalDeviceFormatPropertiesEXT)) { |
sjfricke | 3a10ae8 | 2022-08-02 18:48:57 +0900 | [diff] [blame] | 3707 | GTEST_SKIP() << "Failed to load device profile layer."; |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3708 | } |
| 3709 | |
| 3710 | // Set transfer for all potential used formats |
| 3711 | VkFormatProperties format_props; |
| 3712 | fpvkGetOriginalPhysicalDeviceFormatPropertiesEXT(gpu(), VK_FORMAT_R8_UNORM, &format_props); |
| 3713 | format_props.optimalTilingFeatures |= (VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT); |
| 3714 | fpvkSetPhysicalDeviceFormatPropertiesEXT(gpu(), VK_FORMAT_R8_UNORM, format_props); |
| 3715 | |
| 3716 | fpvkGetOriginalPhysicalDeviceFormatPropertiesEXT(gpu(), VK_FORMAT_R8_UINT, &format_props); |
| 3717 | format_props.optimalTilingFeatures |= (VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT); |
| 3718 | fpvkSetPhysicalDeviceFormatPropertiesEXT(gpu(), VK_FORMAT_R8_UINT, format_props); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3719 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 3720 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3721 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3722 | image_create_info.extent.width = 32; |
| 3723 | image_create_info.extent.height = 32; |
| 3724 | image_create_info.extent.depth = 1; |
| 3725 | image_create_info.mipLevels = 1; |
| 3726 | image_create_info.arrayLayers = 1; |
| 3727 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3728 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3729 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3730 | image_create_info.flags = 0; |
| 3731 | |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3732 | image_create_info.format = VK_FORMAT_R8_UNORM; |
| 3733 | VkImageObj image_8b_unorm(m_device); |
| 3734 | image_8b_unorm.init(&image_create_info); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3735 | |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3736 | image_create_info.format = VK_FORMAT_R8_UINT; |
| 3737 | VkImageObj image_8b_uint(m_device); |
| 3738 | image_8b_uint.init(&image_create_info); |
| 3739 | |
| 3740 | // First try to test two single plane mismatch |
| 3741 | { |
| 3742 | fpvkGetOriginalPhysicalDeviceFormatPropertiesEXT(gpu(), VK_FORMAT_R8G8B8A8_UNORM, &format_props); |
| 3743 | format_props.optimalTilingFeatures |= (VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT); |
| 3744 | fpvkSetPhysicalDeviceFormatPropertiesEXT(gpu(), VK_FORMAT_R8G8B8A8_UNORM, format_props); |
| 3745 | |
| 3746 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 3747 | VkImageObj image_32b_unorm(m_device); |
| 3748 | image_32b_unorm.init(&image_create_info); |
| 3749 | |
| 3750 | m_commandBuffer->begin(); |
| 3751 | VkImageCopy copyRegion; |
| 3752 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3753 | copyRegion.srcSubresource.mipLevel = 0; |
| 3754 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 3755 | copyRegion.srcSubresource.layerCount = 1; |
| 3756 | copyRegion.srcOffset.x = 0; |
| 3757 | copyRegion.srcOffset.y = 0; |
| 3758 | copyRegion.srcOffset.z = 0; |
| 3759 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3760 | copyRegion.dstSubresource.mipLevel = 0; |
| 3761 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 3762 | copyRegion.dstSubresource.layerCount = 1; |
| 3763 | copyRegion.dstOffset.x = 0; |
| 3764 | copyRegion.dstOffset.y = 0; |
| 3765 | copyRegion.dstOffset.z = 0; |
| 3766 | copyRegion.extent.width = 1; |
| 3767 | copyRegion.extent.height = 1; |
| 3768 | copyRegion.extent.depth = 1; |
| 3769 | |
| 3770 | // Sanity check between two 8bit formats |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3771 | m_commandBuffer->CopyImage(image_8b_unorm.handle(), VK_IMAGE_LAYOUT_GENERAL, image_8b_uint.handle(), |
| 3772 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3773 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 3774 | const char *vuid = (IsExtensionsEnabled(VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME)) |
| 3775 | ? "VUID-vkCmdCopyImage-srcImage-01548" |
| 3776 | : "VUID-vkCmdCopyImage-srcImage-00135"; |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3777 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid); |
| 3778 | m_commandBuffer->CopyImage(image_8b_unorm.handle(), VK_IMAGE_LAYOUT_GENERAL, image_32b_unorm.handle(), |
| 3779 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 3780 | m_errorMonitor->VerifyFound(); |
| 3781 | |
| 3782 | // Swap src and dst |
| 3783 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid); |
| 3784 | m_commandBuffer->CopyImage(image_32b_unorm.handle(), VK_IMAGE_LAYOUT_GENERAL, image_8b_unorm.handle(), |
| 3785 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 3786 | m_errorMonitor->VerifyFound(); |
| 3787 | |
| 3788 | m_commandBuffer->end(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3789 | } |
| 3790 | |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3791 | // DstImage is a mismatched plane of a multi-planar format |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 3792 | if (!mp_features.samplerYcbcrConversion) { |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3793 | printf("%s No multi-planar support; section of tests skipped.\n", kSkipPrefix); |
| 3794 | } else { |
| 3795 | fpvkGetOriginalPhysicalDeviceFormatPropertiesEXT(gpu(), VK_FORMAT_G8_B8R8_2PLANE_420_UNORM, &format_props); |
| 3796 | format_props.optimalTilingFeatures |= (VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT); |
| 3797 | fpvkSetPhysicalDeviceFormatPropertiesEXT(gpu(), VK_FORMAT_G8_B8R8_2PLANE_420_UNORM, format_props); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3798 | |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3799 | image_create_info.format = VK_FORMAT_G8_B8R8_2PLANE_420_UNORM; |
| 3800 | VkImageObj image_8b_16b_420_unorm(m_device); |
| 3801 | image_8b_16b_420_unorm.init(&image_create_info); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3802 | |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3803 | m_commandBuffer->begin(); |
| 3804 | VkImageCopy copyRegion; |
| 3805 | copyRegion.srcSubresource.mipLevel = 0; |
| 3806 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 3807 | copyRegion.srcSubresource.layerCount = 1; |
| 3808 | copyRegion.srcOffset.x = 0; |
| 3809 | copyRegion.srcOffset.y = 0; |
| 3810 | copyRegion.srcOffset.z = 0; |
| 3811 | copyRegion.dstSubresource.mipLevel = 0; |
| 3812 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 3813 | copyRegion.dstSubresource.layerCount = 1; |
| 3814 | copyRegion.dstOffset.x = 0; |
| 3815 | copyRegion.dstOffset.y = 0; |
| 3816 | copyRegion.dstOffset.z = 0; |
| 3817 | copyRegion.extent.width = 1; |
| 3818 | copyRegion.extent.height = 1; |
| 3819 | copyRegion.extent.depth = 1; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3820 | |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3821 | // First test single-plane -> multi-plan |
| 3822 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3823 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_0_BIT; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3824 | |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3825 | // Plane 0 is VK_FORMAT_R8_UNORM so this should succeed |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3826 | m_commandBuffer->CopyImage(image_8b_unorm.handle(), VK_IMAGE_LAYOUT_GENERAL, image_8b_16b_420_unorm.handle(), |
| 3827 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3828 | |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 3829 | image_8b_16b_420_unorm.ImageMemoryBarrier(m_commandBuffer, VK_IMAGE_ASPECT_PLANE_0_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, |
| 3830 | VK_ACCESS_TRANSFER_WRITE_BIT, VK_IMAGE_LAYOUT_GENERAL); |
| 3831 | |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3832 | // Make sure no false postiives if Compatible format |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3833 | m_commandBuffer->CopyImage(image_8b_uint.handle(), VK_IMAGE_LAYOUT_GENERAL, image_8b_16b_420_unorm.handle(), |
| 3834 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3835 | |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3836 | // Plane 1 is VK_FORMAT_R8G8_UNORM so this should fail |
| 3837 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_1_BIT; |
| 3838 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-None-01549"); |
| 3839 | m_commandBuffer->CopyImage(image_8b_unorm.handle(), VK_IMAGE_LAYOUT_GENERAL, image_8b_16b_420_unorm.handle(), |
| 3840 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 3841 | m_errorMonitor->VerifyFound(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3842 | |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3843 | // Same tests but swap src and dst |
| 3844 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_0_BIT; |
| 3845 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
sfricke-samsung | dce5f69 | 2020-03-07 13:59:31 -0800 | [diff] [blame] | 3846 | |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 3847 | image_8b_unorm.ImageMemoryBarrier(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_ACCESS_TRANSFER_READ_BIT, |
| 3848 | VK_ACCESS_TRANSFER_WRITE_BIT, VK_IMAGE_LAYOUT_GENERAL); |
| 3849 | image_8b_16b_420_unorm.ImageMemoryBarrier(m_commandBuffer, VK_IMAGE_ASPECT_PLANE_0_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, |
| 3850 | VK_ACCESS_TRANSFER_READ_BIT, VK_IMAGE_LAYOUT_GENERAL); |
| 3851 | |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3852 | m_commandBuffer->CopyImage(image_8b_16b_420_unorm.handle(), VK_IMAGE_LAYOUT_GENERAL, image_8b_unorm.handle(), |
| 3853 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3854 | |
locke-lunarg | df00db0 | 2020-03-04 19:00:57 -0700 | [diff] [blame] | 3855 | image_8b_16b_420_unorm.ImageMemoryBarrier(m_commandBuffer, VK_IMAGE_ASPECT_PLANE_0_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, |
| 3856 | VK_ACCESS_TRANSFER_READ_BIT, VK_IMAGE_LAYOUT_GENERAL); |
| 3857 | |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3858 | m_commandBuffer->CopyImage(image_8b_16b_420_unorm.handle(), VK_IMAGE_LAYOUT_GENERAL, image_8b_uint.handle(), |
| 3859 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
sfricke-samsung | 51067b2 | 2020-04-30 21:41:17 -0700 | [diff] [blame] | 3860 | |
| 3861 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_1_BIT; |
| 3862 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-None-01549"); |
| 3863 | m_commandBuffer->CopyImage(image_8b_16b_420_unorm.handle(), VK_IMAGE_LAYOUT_GENERAL, image_8b_unorm.handle(), |
| 3864 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 3865 | m_errorMonitor->VerifyFound(); |
| 3866 | |
| 3867 | m_commandBuffer->end(); |
| 3868 | } |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3869 | } |
| 3870 | |
| 3871 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 3872 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 3873 | auto depth_format = FindSupportedDepthStencilFormat(gpu()); |
| 3874 | if (!depth_format) { |
| 3875 | printf("%s Couldn't depth stencil image format.\n", kSkipPrefix); |
| 3876 | return; |
| 3877 | } |
| 3878 | |
| 3879 | VkFormatProperties properties; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 3880 | vk::GetPhysicalDeviceFormatProperties(m_device->phy().handle(), VK_FORMAT_D32_SFLOAT, &properties); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3881 | if (properties.optimalTilingFeatures == 0) { |
| 3882 | printf("%s Image format not supported; skipped.\n", kSkipPrefix); |
| 3883 | return; |
| 3884 | } |
| 3885 | |
| 3886 | VkImageObj srcImage(m_device); |
| 3887 | srcImage.Init(32, 32, 1, VK_FORMAT_D32_SFLOAT, VK_IMAGE_USAGE_TRANSFER_SRC_BIT, VK_IMAGE_TILING_OPTIMAL); |
| 3888 | ASSERT_TRUE(srcImage.initialized()); |
| 3889 | VkImageObj dstImage(m_device); |
| 3890 | dstImage.Init(32, 32, 1, depth_format, VK_IMAGE_USAGE_TRANSFER_DST_BIT, VK_IMAGE_TILING_OPTIMAL); |
| 3891 | ASSERT_TRUE(dstImage.initialized()); |
| 3892 | |
| 3893 | // Create two images of different types and try to copy between them |
| 3894 | |
| 3895 | m_commandBuffer->begin(); |
| 3896 | VkImageCopy copyRegion; |
| 3897 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; |
| 3898 | copyRegion.srcSubresource.mipLevel = 0; |
| 3899 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 3900 | copyRegion.srcSubresource.layerCount = 1; |
| 3901 | copyRegion.srcOffset.x = 0; |
| 3902 | copyRegion.srcOffset.y = 0; |
| 3903 | copyRegion.srcOffset.z = 0; |
| 3904 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; |
| 3905 | copyRegion.dstSubresource.mipLevel = 0; |
| 3906 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 3907 | copyRegion.dstSubresource.layerCount = 1; |
| 3908 | copyRegion.dstOffset.x = 0; |
| 3909 | copyRegion.dstOffset.y = 0; |
| 3910 | copyRegion.dstOffset.z = 0; |
| 3911 | copyRegion.extent.width = 1; |
| 3912 | copyRegion.extent.height = 1; |
| 3913 | copyRegion.extent.depth = 1; |
| 3914 | |
sfricke-samsung | 99dc12c | 2020-04-23 01:52:01 -0700 | [diff] [blame] | 3915 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcImage-00135"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3916 | m_commandBuffer->CopyImage(srcImage.handle(), VK_IMAGE_LAYOUT_GENERAL, dstImage.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 3917 | ©Region); |
| 3918 | m_commandBuffer->end(); |
| 3919 | |
| 3920 | m_errorMonitor->VerifyFound(); |
| 3921 | } |
| 3922 | |
| 3923 | TEST_F(VkLayerTest, CopyImageSampleCountMismatch) { |
| 3924 | TEST_DESCRIPTION("Image copies with sample count mis-matches"); |
| 3925 | |
| 3926 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 3927 | |
| 3928 | VkImageFormatProperties image_format_properties; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 3929 | vk::GetPhysicalDeviceImageFormatProperties(gpu(), VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_OPTIMAL, |
| 3930 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, 0, |
| 3931 | &image_format_properties); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3932 | |
| 3933 | if ((0 == (VK_SAMPLE_COUNT_2_BIT & image_format_properties.sampleCounts)) || |
| 3934 | (0 == (VK_SAMPLE_COUNT_4_BIT & image_format_properties.sampleCounts))) { |
| 3935 | printf("%s Image multi-sample support not found; skipped.\n", kSkipPrefix); |
| 3936 | return; |
| 3937 | } |
| 3938 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 3939 | VkImageCreateInfo ci = LvlInitStruct<VkImageCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3940 | ci.flags = 0; |
| 3941 | ci.imageType = VK_IMAGE_TYPE_2D; |
| 3942 | ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 3943 | ci.extent = {128, 128, 1}; |
| 3944 | ci.mipLevels = 1; |
| 3945 | ci.arrayLayers = 1; |
| 3946 | ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3947 | ci.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3948 | ci.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 3949 | ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 3950 | ci.queueFamilyIndexCount = 0; |
| 3951 | ci.pQueueFamilyIndices = NULL; |
| 3952 | ci.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 3953 | |
| 3954 | VkImageObj image1(m_device); |
| 3955 | image1.init(&ci); |
| 3956 | ASSERT_TRUE(image1.initialized()); |
| 3957 | |
| 3958 | ci.samples = VK_SAMPLE_COUNT_2_BIT; |
| 3959 | VkImageObj image2(m_device); |
| 3960 | image2.init(&ci); |
| 3961 | ASSERT_TRUE(image2.initialized()); |
| 3962 | |
| 3963 | ci.samples = VK_SAMPLE_COUNT_4_BIT; |
| 3964 | VkImageObj image4(m_device); |
| 3965 | image4.init(&ci); |
| 3966 | ASSERT_TRUE(image4.initialized()); |
| 3967 | |
| 3968 | m_commandBuffer->begin(); |
| 3969 | |
| 3970 | VkImageCopy copyRegion; |
| 3971 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3972 | copyRegion.srcSubresource.mipLevel = 0; |
| 3973 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 3974 | copyRegion.srcSubresource.layerCount = 1; |
| 3975 | copyRegion.srcOffset = {0, 0, 0}; |
| 3976 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3977 | copyRegion.dstSubresource.mipLevel = 0; |
| 3978 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 3979 | copyRegion.dstSubresource.layerCount = 1; |
| 3980 | copyRegion.dstOffset = {0, 0, 0}; |
| 3981 | copyRegion.extent = {128, 128, 1}; |
| 3982 | |
| 3983 | // Copy a single sample image to/from a multi-sample image |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 3984 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcImage-00136"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 3985 | vk::CmdCopyImage(m_commandBuffer->handle(), image1.handle(), VK_IMAGE_LAYOUT_GENERAL, image4.handle(), VK_IMAGE_LAYOUT_GENERAL, |
| 3986 | 1, ©Region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3987 | m_errorMonitor->VerifyFound(); |
| 3988 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 3989 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcImage-00136"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 3990 | vk::CmdCopyImage(m_commandBuffer->handle(), image2.handle(), VK_IMAGE_LAYOUT_GENERAL, image1.handle(), VK_IMAGE_LAYOUT_GENERAL, |
| 3991 | 1, ©Region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3992 | m_errorMonitor->VerifyFound(); |
| 3993 | |
| 3994 | // Copy between multi-sample images with different sample counts |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 3995 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcImage-00136"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 3996 | vk::CmdCopyImage(m_commandBuffer->handle(), image2.handle(), VK_IMAGE_LAYOUT_GENERAL, image4.handle(), VK_IMAGE_LAYOUT_GENERAL, |
| 3997 | 1, ©Region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 3998 | m_errorMonitor->VerifyFound(); |
| 3999 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 4000 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-srcImage-00136"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 4001 | vk::CmdCopyImage(m_commandBuffer->handle(), image4.handle(), VK_IMAGE_LAYOUT_GENERAL, image2.handle(), VK_IMAGE_LAYOUT_GENERAL, |
| 4002 | 1, ©Region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4003 | m_errorMonitor->VerifyFound(); |
| 4004 | |
| 4005 | m_commandBuffer->end(); |
| 4006 | } |
| 4007 | |
| 4008 | TEST_F(VkLayerTest, CopyImageAspectMismatch) { |
| 4009 | TEST_DESCRIPTION("Image copies with aspect mask errors"); |
sfricke-samsung | 99dc12c | 2020-04-23 01:52:01 -0700 | [diff] [blame] | 4010 | |
sjfricke | 3a10ae8 | 2022-08-02 18:48:57 +0900 | [diff] [blame] | 4011 | if (!OverrideDevsimForDeviceProfileLayer()) { |
| 4012 | GTEST_SKIP() << "Failed to override devsim for device profile layer."; |
sfricke-samsung | 99dc12c | 2020-04-23 01:52:01 -0700 | [diff] [blame] | 4013 | } |
| 4014 | |
| 4015 | bool mp_extensions = InstanceExtensionSupported(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, 1); |
| 4016 | if (mp_extensions) { |
| 4017 | m_instance_extension_names.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 4018 | } |
| 4019 | |
| 4020 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 4021 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
sfricke-samsung | 99dc12c | 2020-04-23 01:52:01 -0700 | [diff] [blame] | 4022 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME); |
| 4023 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_BIND_MEMORY_2_EXTENSION_NAME); |
| 4024 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME); |
| 4025 | if (mp_extensions) { |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 4026 | m_device_extension_names.push_back(VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
sfricke-samsung | 99dc12c | 2020-04-23 01:52:01 -0700 | [diff] [blame] | 4027 | m_device_extension_names.push_back(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME); |
| 4028 | m_device_extension_names.push_back(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME); |
| 4029 | m_device_extension_names.push_back(VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME); |
| 4030 | } |
| 4031 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4032 | |
| 4033 | PFN_vkSetPhysicalDeviceFormatPropertiesEXT fpvkSetPhysicalDeviceFormatPropertiesEXT = nullptr; |
| 4034 | PFN_vkGetOriginalPhysicalDeviceFormatPropertiesEXT fpvkGetOriginalPhysicalDeviceFormatPropertiesEXT = nullptr; |
sfricke-samsung | 99dc12c | 2020-04-23 01:52:01 -0700 | [diff] [blame] | 4035 | if (!LoadDeviceProfileLayer(fpvkSetPhysicalDeviceFormatPropertiesEXT, fpvkGetOriginalPhysicalDeviceFormatPropertiesEXT)) { |
sjfricke | 3a10ae8 | 2022-08-02 18:48:57 +0900 | [diff] [blame] | 4036 | GTEST_SKIP() << "Failed to load device profile layer."; |
sfricke-samsung | 99dc12c | 2020-04-23 01:52:01 -0700 | [diff] [blame] | 4037 | } |
| 4038 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4039 | auto ds_format = FindSupportedDepthStencilFormat(gpu()); |
| 4040 | if (!ds_format) { |
| 4041 | printf("%s Couldn't find depth stencil format.\n", kSkipPrefix); |
| 4042 | return; |
| 4043 | } |
| 4044 | |
sfricke-samsung | 99dc12c | 2020-04-23 01:52:01 -0700 | [diff] [blame] | 4045 | // Add Transfer support for all used formats |
| 4046 | VkFormatProperties formatProps; |
| 4047 | fpvkGetOriginalPhysicalDeviceFormatPropertiesEXT(gpu(), VK_FORMAT_R32_SFLOAT, &formatProps); |
| 4048 | formatProps.optimalTilingFeatures |= (VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT); |
| 4049 | fpvkSetPhysicalDeviceFormatPropertiesEXT(gpu(), VK_FORMAT_R32_SFLOAT, formatProps); |
| 4050 | fpvkGetOriginalPhysicalDeviceFormatPropertiesEXT(gpu(), VK_FORMAT_D32_SFLOAT, &formatProps); |
| 4051 | formatProps.optimalTilingFeatures |= (VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT); |
| 4052 | fpvkSetPhysicalDeviceFormatPropertiesEXT(gpu(), VK_FORMAT_R32_SFLOAT, formatProps); |
| 4053 | fpvkGetOriginalPhysicalDeviceFormatPropertiesEXT(gpu(), ds_format, &formatProps); |
| 4054 | formatProps.optimalTilingFeatures |= (VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT); |
| 4055 | fpvkSetPhysicalDeviceFormatPropertiesEXT(gpu(), ds_format, formatProps); |
| 4056 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4057 | VkImageObj color_image(m_device), ds_image(m_device), depth_image(m_device); |
| 4058 | color_image.Init(128, 128, 1, VK_FORMAT_R32_SFLOAT, VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT); |
| 4059 | depth_image.Init(128, 128, 1, VK_FORMAT_D32_SFLOAT, VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 4060 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 4061 | ds_image.Init(128, 128, 1, ds_format, VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 4062 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 4063 | ASSERT_TRUE(color_image.initialized()); |
| 4064 | ASSERT_TRUE(depth_image.initialized()); |
| 4065 | ASSERT_TRUE(ds_image.initialized()); |
| 4066 | |
| 4067 | VkImageCopy copyRegion; |
| 4068 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; |
| 4069 | copyRegion.srcSubresource.mipLevel = 0; |
| 4070 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 4071 | copyRegion.srcSubresource.layerCount = 1; |
| 4072 | copyRegion.srcOffset = {0, 0, 0}; |
| 4073 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; |
| 4074 | copyRegion.dstSubresource.mipLevel = 0; |
| 4075 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 4076 | copyRegion.dstSubresource.layerCount = 1; |
| 4077 | copyRegion.dstOffset = {64, 0, 0}; |
| 4078 | copyRegion.extent = {64, 128, 1}; |
| 4079 | |
| 4080 | // Submitting command before command buffer is in recording state |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 4081 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4082 | "You must call vkBeginCommandBuffer"); // "VUID-vkCmdCopyImage-commandBuffer-recording"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 4083 | vk::CmdCopyImage(m_commandBuffer->handle(), depth_image.handle(), VK_IMAGE_LAYOUT_GENERAL, depth_image.handle(), |
| 4084 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4085 | m_errorMonitor->VerifyFound(); |
| 4086 | |
| 4087 | m_commandBuffer->begin(); |
| 4088 | |
| 4089 | // Src and dest aspect masks don't match |
| 4090 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_STENCIL_BIT; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 4091 | const char *vuid = mp_extensions ? "VUID-vkCmdCopyImage-srcImage-01551" : "VUID-VkImageCopy-aspectMask-00137"; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 4092 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 4093 | vk::CmdCopyImage(m_commandBuffer->handle(), ds_image.handle(), VK_IMAGE_LAYOUT_GENERAL, ds_image.handle(), |
| 4094 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4095 | m_errorMonitor->VerifyFound(); |
| 4096 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; |
| 4097 | |
| 4098 | // Illegal combinations of aspect bits |
| 4099 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT; // color must be alone |
| 4100 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 4101 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkImageSubresourceLayers-aspectMask-00167"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4102 | // These aspect/format mismatches are redundant but unavoidable here |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 4103 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-aspectMask-00142"); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 4104 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 4105 | vk::CmdCopyImage(m_commandBuffer->handle(), color_image.handle(), VK_IMAGE_LAYOUT_GENERAL, color_image.handle(), |
| 4106 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4107 | m_errorMonitor->VerifyFound(); |
| 4108 | // same test for dstSubresource |
| 4109 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4110 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT; // color must be alone |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 4111 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkImageSubresourceLayers-aspectMask-00167"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4112 | // These aspect/format mismatches are redundant but unavoidable here |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 4113 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-aspectMask-00143"); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 4114 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 4115 | vk::CmdCopyImage(m_commandBuffer->handle(), color_image.handle(), VK_IMAGE_LAYOUT_GENERAL, color_image.handle(), |
| 4116 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4117 | m_errorMonitor->VerifyFound(); |
| 4118 | |
| 4119 | // Metadata aspect is illegal |
| 4120 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 4121 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 4122 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkImageSubresourceLayers-aspectMask-00168"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4123 | // These aspect/format mismatches are redundant but unavoidable here |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 4124 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 4125 | vk::CmdCopyImage(m_commandBuffer->handle(), color_image.handle(), VK_IMAGE_LAYOUT_GENERAL, color_image.handle(), |
| 4126 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4127 | m_errorMonitor->VerifyFound(); |
| 4128 | // same test for dstSubresource |
| 4129 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4130 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 4131 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkImageSubresourceLayers-aspectMask-00168"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4132 | // These aspect/format mismatches are redundant but unavoidable here |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 4133 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 4134 | vk::CmdCopyImage(m_commandBuffer->handle(), color_image.handle(), VK_IMAGE_LAYOUT_GENERAL, color_image.handle(), |
| 4135 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4136 | m_errorMonitor->VerifyFound(); |
| 4137 | |
sfricke-samsung | 6141db3 | 2020-10-26 03:31:38 -0700 | [diff] [blame] | 4138 | // Aspect Memory Plane mask is illegal |
| 4139 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_MEMORY_PLANE_2_BIT_EXT; |
| 4140 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4141 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkImageSubresourceLayers-aspectMask-02247"); |
| 4142 | // These aspect/format mismatches are redundant but unavoidable here |
| 4143 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid); |
| 4144 | vk::CmdCopyImage(m_commandBuffer->handle(), color_image.handle(), VK_IMAGE_LAYOUT_GENERAL, color_image.handle(), |
| 4145 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 4146 | m_errorMonitor->VerifyFound(); |
| 4147 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4148 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; |
| 4149 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; |
sfricke-samsung | 99dc12c | 2020-04-23 01:52:01 -0700 | [diff] [blame] | 4150 | const char *compatible_vuid = mp_extensions ? "VUID-vkCmdCopyImage-srcImage-01548" : "VUID-vkCmdCopyImage-srcImage-00135"; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4151 | |
| 4152 | // Aspect mask doesn't match source image format |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 4153 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-aspectMask-00142"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4154 | // Again redundant but unavoidable |
sfricke-samsung | 99dc12c | 2020-04-23 01:52:01 -0700 | [diff] [blame] | 4155 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, compatible_vuid); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 4156 | vk::CmdCopyImage(m_commandBuffer->handle(), color_image.handle(), VK_IMAGE_LAYOUT_GENERAL, depth_image.handle(), |
| 4157 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4158 | m_errorMonitor->VerifyFound(); |
| 4159 | |
| 4160 | // Aspect mask doesn't match dest image format |
| 4161 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4162 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 4163 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-aspectMask-00143"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4164 | // Again redundant but unavoidable |
sfricke-samsung | 99dc12c | 2020-04-23 01:52:01 -0700 | [diff] [blame] | 4165 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, compatible_vuid); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 4166 | vk::CmdCopyImage(m_commandBuffer->handle(), color_image.handle(), VK_IMAGE_LAYOUT_GENERAL, depth_image.handle(), |
| 4167 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4168 | m_errorMonitor->VerifyFound(); |
| 4169 | |
aitor-lunarg | 54c295b | 2022-01-28 17:02:32 +0100 | [diff] [blame] | 4170 | // Check no performance warnings regarding layout are thrown when copying from and to the same image |
| 4171 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; |
| 4172 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; |
aitor-lunarg | 54c295b | 2022-01-28 17:02:32 +0100 | [diff] [blame] | 4173 | vk::CmdCopyImage(m_commandBuffer->handle(), depth_image.handle(), VK_IMAGE_LAYOUT_GENERAL, depth_image.handle(), |
| 4174 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
aitor-lunarg | 54c295b | 2022-01-28 17:02:32 +0100 | [diff] [blame] | 4175 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4176 | m_commandBuffer->end(); |
| 4177 | } |
| 4178 | |
| 4179 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
sfricke-samsung | c26350e | 2020-05-30 12:31:31 -0700 | [diff] [blame] | 4180 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-srcImage-00257"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4181 | |
| 4182 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 4183 | |
| 4184 | // Create two images of sample count 1 and try to Resolve between them |
| 4185 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 4186 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4187 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4188 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4189 | image_create_info.extent.width = 32; |
| 4190 | image_create_info.extent.height = 1; |
| 4191 | image_create_info.extent.depth = 1; |
| 4192 | image_create_info.mipLevels = 1; |
| 4193 | image_create_info.arrayLayers = 1; |
| 4194 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 4195 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4196 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 4197 | image_create_info.flags = 0; |
| 4198 | |
| 4199 | VkImageObj srcImage(m_device); |
| 4200 | srcImage.init(&image_create_info); |
| 4201 | ASSERT_TRUE(srcImage.initialized()); |
| 4202 | |
| 4203 | VkImageObj dstImage(m_device); |
| 4204 | dstImage.init(&image_create_info); |
| 4205 | ASSERT_TRUE(dstImage.initialized()); |
| 4206 | |
| 4207 | m_commandBuffer->begin(); |
| 4208 | VkImageResolve resolveRegion; |
| 4209 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4210 | resolveRegion.srcSubresource.mipLevel = 0; |
| 4211 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
| 4212 | resolveRegion.srcSubresource.layerCount = 1; |
| 4213 | resolveRegion.srcOffset.x = 0; |
| 4214 | resolveRegion.srcOffset.y = 0; |
| 4215 | resolveRegion.srcOffset.z = 0; |
| 4216 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4217 | resolveRegion.dstSubresource.mipLevel = 0; |
| 4218 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 4219 | resolveRegion.dstSubresource.layerCount = 1; |
| 4220 | resolveRegion.dstOffset.x = 0; |
| 4221 | resolveRegion.dstOffset.y = 0; |
| 4222 | resolveRegion.dstOffset.z = 0; |
| 4223 | resolveRegion.extent.width = 1; |
| 4224 | resolveRegion.extent.height = 1; |
| 4225 | resolveRegion.extent.depth = 1; |
| 4226 | m_commandBuffer->ResolveImage(srcImage.handle(), VK_IMAGE_LAYOUT_GENERAL, dstImage.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 4227 | &resolveRegion); |
| 4228 | m_commandBuffer->end(); |
| 4229 | |
| 4230 | m_errorMonitor->VerifyFound(); |
| 4231 | } |
| 4232 | |
| 4233 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
sfricke-samsung | c26350e | 2020-05-30 12:31:31 -0700 | [diff] [blame] | 4234 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-dstImage-00259"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4235 | |
| 4236 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 4237 | |
| 4238 | // Create two images of sample count 4 and try to Resolve between them |
| 4239 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 4240 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4241 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4242 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4243 | image_create_info.extent.width = 32; |
| 4244 | image_create_info.extent.height = 1; |
| 4245 | image_create_info.extent.depth = 1; |
| 4246 | image_create_info.mipLevels = 1; |
| 4247 | image_create_info.arrayLayers = 1; |
| 4248 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
| 4249 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4250 | // Note: Some implementations expect color attachment usage for any |
| 4251 | // multisample surface |
| 4252 | image_create_info.usage = |
| 4253 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 4254 | image_create_info.flags = 0; |
| 4255 | |
| 4256 | VkImageObj srcImage(m_device); |
| 4257 | srcImage.init(&image_create_info); |
| 4258 | ASSERT_TRUE(srcImage.initialized()); |
| 4259 | |
| 4260 | VkImageObj dstImage(m_device); |
| 4261 | dstImage.init(&image_create_info); |
| 4262 | ASSERT_TRUE(dstImage.initialized()); |
| 4263 | |
| 4264 | m_commandBuffer->begin(); |
| 4265 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 4266 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 4267 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
| 4268 | VkImageResolve resolveRegion; |
| 4269 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4270 | resolveRegion.srcSubresource.mipLevel = 0; |
| 4271 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
| 4272 | resolveRegion.srcSubresource.layerCount = 1; |
| 4273 | resolveRegion.srcOffset.x = 0; |
| 4274 | resolveRegion.srcOffset.y = 0; |
| 4275 | resolveRegion.srcOffset.z = 0; |
| 4276 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4277 | resolveRegion.dstSubresource.mipLevel = 0; |
| 4278 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 4279 | resolveRegion.dstSubresource.layerCount = 1; |
| 4280 | resolveRegion.dstOffset.x = 0; |
| 4281 | resolveRegion.dstOffset.y = 0; |
| 4282 | resolveRegion.dstOffset.z = 0; |
| 4283 | resolveRegion.extent.width = 1; |
| 4284 | resolveRegion.extent.height = 1; |
| 4285 | resolveRegion.extent.depth = 1; |
| 4286 | m_commandBuffer->ResolveImage(srcImage.handle(), VK_IMAGE_LAYOUT_GENERAL, dstImage.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 4287 | &resolveRegion); |
| 4288 | m_commandBuffer->end(); |
| 4289 | |
| 4290 | m_errorMonitor->VerifyFound(); |
| 4291 | } |
| 4292 | |
| 4293 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
sfricke-samsung | c26350e | 2020-05-30 12:31:31 -0700 | [diff] [blame] | 4294 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-srcImage-01386"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4295 | |
| 4296 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 4297 | |
| 4298 | // Create two images of different types and try to copy between them |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 4299 | VkImageObj srcImage(m_device); |
| 4300 | VkImageObj dstImage(m_device); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4301 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 4302 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4303 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4304 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4305 | image_create_info.extent.width = 32; |
| 4306 | image_create_info.extent.height = 1; |
| 4307 | image_create_info.extent.depth = 1; |
| 4308 | image_create_info.mipLevels = 1; |
| 4309 | image_create_info.arrayLayers = 1; |
sfricke-samsung | f46582f | 2021-03-31 02:02:37 -0700 | [diff] [blame] | 4310 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; // guarantee support from sampledImageColorSampleCounts |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4311 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4312 | // Note: Some implementations expect color attachment usage for any |
| 4313 | // multisample surface |
| 4314 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 4315 | image_create_info.flags = 0; |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 4316 | srcImage.init(&image_create_info); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4317 | |
| 4318 | // Set format to something other than source image |
| 4319 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 4320 | // Note: Some implementations expect color attachment usage for any |
| 4321 | // multisample surface |
| 4322 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 4323 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 4324 | dstImage.init(&image_create_info); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4325 | |
| 4326 | m_commandBuffer->begin(); |
| 4327 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 4328 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 4329 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
| 4330 | VkImageResolve resolveRegion; |
| 4331 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4332 | resolveRegion.srcSubresource.mipLevel = 0; |
| 4333 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
| 4334 | resolveRegion.srcSubresource.layerCount = 1; |
| 4335 | resolveRegion.srcOffset.x = 0; |
| 4336 | resolveRegion.srcOffset.y = 0; |
| 4337 | resolveRegion.srcOffset.z = 0; |
| 4338 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4339 | resolveRegion.dstSubresource.mipLevel = 0; |
| 4340 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 4341 | resolveRegion.dstSubresource.layerCount = 1; |
| 4342 | resolveRegion.dstOffset.x = 0; |
| 4343 | resolveRegion.dstOffset.y = 0; |
| 4344 | resolveRegion.dstOffset.z = 0; |
| 4345 | resolveRegion.extent.width = 1; |
| 4346 | resolveRegion.extent.height = 1; |
| 4347 | resolveRegion.extent.depth = 1; |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 4348 | m_commandBuffer->ResolveImage(srcImage.handle(), VK_IMAGE_LAYOUT_GENERAL, dstImage.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 4349 | &resolveRegion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4350 | m_commandBuffer->end(); |
| 4351 | |
| 4352 | m_errorMonitor->VerifyFound(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4353 | } |
| 4354 | |
| 4355 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
sfricke-samsung | c26350e | 2020-05-30 12:31:31 -0700 | [diff] [blame] | 4356 | m_errorMonitor->SetDesiredFailureMsg(kWarningBit, "UNASSIGNED-CoreValidation-DrawState-MismatchedImageType"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4357 | |
| 4358 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 4359 | |
| 4360 | // Create two images of different types and try to copy between them |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 4361 | VkImageObj srcImage(m_device); |
| 4362 | VkImageObj dstImage(m_device); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4363 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 4364 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4365 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4366 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4367 | image_create_info.extent.width = 32; |
| 4368 | image_create_info.extent.height = 1; |
| 4369 | image_create_info.extent.depth = 1; |
| 4370 | image_create_info.mipLevels = 1; |
| 4371 | image_create_info.arrayLayers = 1; |
sfricke-samsung | f46582f | 2021-03-31 02:02:37 -0700 | [diff] [blame] | 4372 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; // guarantee support from sampledImageColorSampleCounts |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4373 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4374 | // Note: Some implementations expect color attachment usage for any |
| 4375 | // multisample surface |
| 4376 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 4377 | image_create_info.flags = 0; |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 4378 | srcImage.init(&image_create_info); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4379 | |
| 4380 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 4381 | // Note: Some implementations expect color attachment usage for any |
| 4382 | // multisample surface |
| 4383 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 4384 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 4385 | dstImage.init(&image_create_info); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4386 | |
| 4387 | m_commandBuffer->begin(); |
| 4388 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 4389 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 4390 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
| 4391 | VkImageResolve resolveRegion; |
| 4392 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4393 | resolveRegion.srcSubresource.mipLevel = 0; |
| 4394 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
| 4395 | resolveRegion.srcSubresource.layerCount = 1; |
| 4396 | resolveRegion.srcOffset.x = 0; |
| 4397 | resolveRegion.srcOffset.y = 0; |
| 4398 | resolveRegion.srcOffset.z = 0; |
| 4399 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4400 | resolveRegion.dstSubresource.mipLevel = 0; |
| 4401 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 4402 | resolveRegion.dstSubresource.layerCount = 1; |
| 4403 | resolveRegion.dstOffset.x = 0; |
| 4404 | resolveRegion.dstOffset.y = 0; |
| 4405 | resolveRegion.dstOffset.z = 0; |
| 4406 | resolveRegion.extent.width = 1; |
| 4407 | resolveRegion.extent.height = 1; |
| 4408 | resolveRegion.extent.depth = 1; |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 4409 | m_commandBuffer->ResolveImage(srcImage.handle(), VK_IMAGE_LAYOUT_GENERAL, dstImage.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 4410 | &resolveRegion); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4411 | m_commandBuffer->end(); |
| 4412 | |
| 4413 | m_errorMonitor->VerifyFound(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4414 | } |
| 4415 | |
| 4416 | TEST_F(VkLayerTest, ResolveImageLayoutMismatch) { |
| 4417 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 4418 | |
| 4419 | // Create two images of different types and try to copy between them |
| 4420 | VkImageObj srcImage(m_device); |
| 4421 | VkImageObj dstImage(m_device); |
| 4422 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 4423 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4424 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4425 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4426 | image_create_info.extent.width = 32; |
| 4427 | image_create_info.extent.height = 32; |
| 4428 | image_create_info.extent.depth = 1; |
| 4429 | image_create_info.mipLevels = 1; |
| 4430 | image_create_info.arrayLayers = 1; |
sfricke-samsung | f46582f | 2021-03-31 02:02:37 -0700 | [diff] [blame] | 4431 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; // guarantee support from sampledImageColorSampleCounts |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4432 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4433 | image_create_info.usage = |
| 4434 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 4435 | // Note: Some implementations expect color attachment usage for any |
| 4436 | // multisample surface |
| 4437 | image_create_info.flags = 0; |
| 4438 | srcImage.init(&image_create_info); |
| 4439 | ASSERT_TRUE(srcImage.initialized()); |
| 4440 | |
| 4441 | // Note: Some implementations expect color attachment usage for any |
| 4442 | // multisample surface |
| 4443 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 4444 | dstImage.init(&image_create_info); |
| 4445 | ASSERT_TRUE(dstImage.initialized()); |
| 4446 | |
| 4447 | m_commandBuffer->begin(); |
| 4448 | // source image must have valid contents before resolve |
| 4449 | VkClearColorValue clear_color = {{0, 0, 0, 0}}; |
| 4450 | VkImageSubresourceRange subresource = {}; |
| 4451 | subresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4452 | subresource.layerCount = 1; |
| 4453 | subresource.levelCount = 1; |
| 4454 | srcImage.SetLayout(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); |
| 4455 | m_commandBuffer->ClearColorImage(srcImage.image(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clear_color, 1, &subresource); |
| 4456 | srcImage.SetLayout(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL); |
| 4457 | dstImage.SetLayout(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); |
| 4458 | |
| 4459 | VkImageResolve resolveRegion; |
| 4460 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4461 | resolveRegion.srcSubresource.mipLevel = 0; |
| 4462 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
| 4463 | resolveRegion.srcSubresource.layerCount = 1; |
| 4464 | resolveRegion.srcOffset.x = 0; |
| 4465 | resolveRegion.srcOffset.y = 0; |
| 4466 | resolveRegion.srcOffset.z = 0; |
| 4467 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4468 | resolveRegion.dstSubresource.mipLevel = 0; |
| 4469 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 4470 | resolveRegion.dstSubresource.layerCount = 1; |
| 4471 | resolveRegion.dstOffset.x = 0; |
| 4472 | resolveRegion.dstOffset.y = 0; |
| 4473 | resolveRegion.dstOffset.z = 0; |
| 4474 | resolveRegion.extent.width = 1; |
| 4475 | resolveRegion.extent.height = 1; |
| 4476 | resolveRegion.extent.depth = 1; |
| 4477 | // source image layout mismatch |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 4478 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-srcImageLayout-00260"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4479 | m_commandBuffer->ResolveImage(srcImage.image(), VK_IMAGE_LAYOUT_GENERAL, dstImage.image(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 4480 | 1, &resolveRegion); |
| 4481 | m_errorMonitor->VerifyFound(); |
| 4482 | // dst image layout mismatch |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 4483 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-dstImageLayout-00262"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4484 | m_commandBuffer->ResolveImage(srcImage.image(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, dstImage.image(), VK_IMAGE_LAYOUT_GENERAL, |
| 4485 | 1, &resolveRegion); |
| 4486 | m_errorMonitor->VerifyFound(); |
| 4487 | m_commandBuffer->end(); |
| 4488 | } |
| 4489 | |
| 4490 | TEST_F(VkLayerTest, ResolveInvalidSubresource) { |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 4491 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
| 4492 | |
| 4493 | bool copy_commands2 = false; |
| 4494 | if (DeviceExtensionSupported(gpu(), nullptr, VK_KHR_COPY_COMMANDS_2_EXTENSION_NAME)) { |
| 4495 | m_device_extension_names.push_back(VK_KHR_COPY_COMMANDS_2_EXTENSION_NAME); |
| 4496 | copy_commands2 = true; |
| 4497 | } |
| 4498 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4499 | |
| 4500 | PFN_vkCmdResolveImage2KHR vkCmdResolveImage2Function = nullptr; |
| 4501 | if (copy_commands2) { |
| 4502 | vkCmdResolveImage2Function = (PFN_vkCmdResolveImage2KHR)vk::GetDeviceProcAddr(m_device->handle(), "vkCmdResolveImage2KHR"); |
| 4503 | } |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4504 | |
| 4505 | // Create two images of different types and try to copy between them |
| 4506 | VkImageObj srcImage(m_device); |
| 4507 | VkImageObj dstImage(m_device); |
| 4508 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 4509 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4510 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4511 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4512 | image_create_info.extent.width = 32; |
| 4513 | image_create_info.extent.height = 32; |
| 4514 | image_create_info.extent.depth = 1; |
| 4515 | image_create_info.mipLevels = 1; |
| 4516 | image_create_info.arrayLayers = 1; |
sfricke-samsung | f46582f | 2021-03-31 02:02:37 -0700 | [diff] [blame] | 4517 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; // guarantee support from sampledImageColorSampleCounts |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4518 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4519 | image_create_info.usage = |
| 4520 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 4521 | // Note: Some implementations expect color attachment usage for any |
| 4522 | // multisample surface |
| 4523 | image_create_info.flags = 0; |
| 4524 | srcImage.init(&image_create_info); |
| 4525 | ASSERT_TRUE(srcImage.initialized()); |
| 4526 | |
| 4527 | // Note: Some implementations expect color attachment usage for any |
| 4528 | // multisample surface |
| 4529 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 4530 | dstImage.init(&image_create_info); |
| 4531 | ASSERT_TRUE(dstImage.initialized()); |
| 4532 | |
| 4533 | m_commandBuffer->begin(); |
| 4534 | // source image must have valid contents before resolve |
| 4535 | VkClearColorValue clear_color = {{0, 0, 0, 0}}; |
| 4536 | VkImageSubresourceRange subresource = {}; |
| 4537 | subresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4538 | subresource.layerCount = 1; |
| 4539 | subresource.levelCount = 1; |
| 4540 | srcImage.SetLayout(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); |
| 4541 | m_commandBuffer->ClearColorImage(srcImage.image(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clear_color, 1, &subresource); |
| 4542 | srcImage.SetLayout(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL); |
| 4543 | dstImage.SetLayout(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); |
| 4544 | |
| 4545 | VkImageResolve resolveRegion; |
| 4546 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4547 | resolveRegion.srcSubresource.mipLevel = 0; |
| 4548 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
| 4549 | resolveRegion.srcSubresource.layerCount = 1; |
| 4550 | resolveRegion.srcOffset.x = 0; |
| 4551 | resolveRegion.srcOffset.y = 0; |
| 4552 | resolveRegion.srcOffset.z = 0; |
| 4553 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4554 | resolveRegion.dstSubresource.mipLevel = 0; |
| 4555 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 4556 | resolveRegion.dstSubresource.layerCount = 1; |
| 4557 | resolveRegion.dstOffset.x = 0; |
| 4558 | resolveRegion.dstOffset.y = 0; |
| 4559 | resolveRegion.dstOffset.z = 0; |
| 4560 | resolveRegion.extent.width = 1; |
| 4561 | resolveRegion.extent.height = 1; |
| 4562 | resolveRegion.extent.depth = 1; |
| 4563 | // invalid source mip level |
| 4564 | resolveRegion.srcSubresource.mipLevel = image_create_info.mipLevels; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 4565 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-srcSubresource-01709"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4566 | m_commandBuffer->ResolveImage(srcImage.image(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, dstImage.image(), |
| 4567 | VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &resolveRegion); |
| 4568 | m_errorMonitor->VerifyFound(); |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 4569 | |
| 4570 | // Equivalent test using KHR_copy_commands2 |
| 4571 | if (copy_commands2 && vkCmdResolveImage2Function) { |
| 4572 | const VkImageResolve2KHR resolveRegion2 = {VK_STRUCTURE_TYPE_IMAGE_RESOLVE_2_KHR, |
| 4573 | NULL, |
| 4574 | resolveRegion.srcSubresource, |
| 4575 | resolveRegion.srcOffset, |
| 4576 | resolveRegion.dstSubresource, |
| 4577 | resolveRegion.dstOffset, |
| 4578 | resolveRegion.extent}; |
| 4579 | const VkResolveImageInfo2KHR resolve_image_info2 = {VK_STRUCTURE_TYPE_RESOLVE_IMAGE_INFO_2_KHR, |
| 4580 | NULL, |
| 4581 | srcImage.image(), |
| 4582 | VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
| 4583 | dstImage.image(), |
| 4584 | VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 4585 | 1, |
| 4586 | &resolveRegion2}; |
Tony-LunarG | 953d55a | 2021-11-11 14:20:25 -0700 | [diff] [blame] | 4587 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkResolveImageInfo2-srcSubresource-01709"); |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 4588 | vkCmdResolveImage2Function(m_commandBuffer->handle(), &resolve_image_info2); |
| 4589 | m_errorMonitor->VerifyFound(); |
| 4590 | } |
| 4591 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4592 | resolveRegion.srcSubresource.mipLevel = 0; |
| 4593 | // invalid dest mip level |
| 4594 | resolveRegion.dstSubresource.mipLevel = image_create_info.mipLevels; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 4595 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-dstSubresource-01710"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4596 | m_commandBuffer->ResolveImage(srcImage.image(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, dstImage.image(), |
| 4597 | VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &resolveRegion); |
| 4598 | m_errorMonitor->VerifyFound(); |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 4599 | |
| 4600 | // Equivalent test using KHR_copy_commands2 |
| 4601 | if (copy_commands2 && vkCmdResolveImage2Function) { |
| 4602 | const VkImageResolve2KHR resolveRegion2 = {VK_STRUCTURE_TYPE_IMAGE_RESOLVE_2_KHR, |
| 4603 | NULL, |
| 4604 | resolveRegion.srcSubresource, |
| 4605 | resolveRegion.srcOffset, |
| 4606 | resolveRegion.dstSubresource, |
| 4607 | resolveRegion.dstOffset, |
| 4608 | resolveRegion.extent}; |
| 4609 | const VkResolveImageInfo2KHR resolve_image_info2 = {VK_STRUCTURE_TYPE_RESOLVE_IMAGE_INFO_2_KHR, |
| 4610 | NULL, |
| 4611 | srcImage.image(), |
| 4612 | VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
| 4613 | dstImage.image(), |
| 4614 | VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 4615 | 1, |
| 4616 | &resolveRegion2}; |
Tony-LunarG | 953d55a | 2021-11-11 14:20:25 -0700 | [diff] [blame] | 4617 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkResolveImageInfo2-dstSubresource-01710"); |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 4618 | vkCmdResolveImage2Function(m_commandBuffer->handle(), &resolve_image_info2); |
| 4619 | m_errorMonitor->VerifyFound(); |
| 4620 | } |
| 4621 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4622 | resolveRegion.dstSubresource.mipLevel = 0; |
| 4623 | // invalid source array layer range |
| 4624 | resolveRegion.srcSubresource.baseArrayLayer = image_create_info.arrayLayers; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 4625 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-srcSubresource-01711"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4626 | m_commandBuffer->ResolveImage(srcImage.image(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, dstImage.image(), |
| 4627 | VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &resolveRegion); |
| 4628 | m_errorMonitor->VerifyFound(); |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 4629 | |
| 4630 | // Equivalent test using KHR_copy_commands2 |
| 4631 | if (copy_commands2 && vkCmdResolveImage2Function) { |
| 4632 | const VkImageResolve2KHR resolveRegion2 = {VK_STRUCTURE_TYPE_IMAGE_RESOLVE_2_KHR, |
| 4633 | NULL, |
| 4634 | resolveRegion.srcSubresource, |
| 4635 | resolveRegion.srcOffset, |
| 4636 | resolveRegion.dstSubresource, |
| 4637 | resolveRegion.dstOffset, |
| 4638 | resolveRegion.extent}; |
| 4639 | const VkResolveImageInfo2KHR resolve_image_info2 = {VK_STRUCTURE_TYPE_RESOLVE_IMAGE_INFO_2_KHR, |
| 4640 | NULL, |
| 4641 | srcImage.image(), |
| 4642 | VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
| 4643 | dstImage.image(), |
| 4644 | VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 4645 | 1, |
| 4646 | &resolveRegion2}; |
Tony-LunarG | 953d55a | 2021-11-11 14:20:25 -0700 | [diff] [blame] | 4647 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkResolveImageInfo2-srcSubresource-01711"); |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 4648 | vkCmdResolveImage2Function(m_commandBuffer->handle(), &resolve_image_info2); |
| 4649 | m_errorMonitor->VerifyFound(); |
| 4650 | } |
| 4651 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4652 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
| 4653 | // invalid dest array layer range |
| 4654 | resolveRegion.dstSubresource.baseArrayLayer = image_create_info.arrayLayers; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 4655 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-dstSubresource-01712"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4656 | m_commandBuffer->ResolveImage(srcImage.image(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, dstImage.image(), |
| 4657 | VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &resolveRegion); |
| 4658 | m_errorMonitor->VerifyFound(); |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 4659 | |
| 4660 | // Equivalent test using KHR_copy_commands2 |
| 4661 | if (copy_commands2 && vkCmdResolveImage2Function) { |
| 4662 | const VkImageResolve2KHR resolveRegion2 = {VK_STRUCTURE_TYPE_IMAGE_RESOLVE_2_KHR, |
| 4663 | NULL, |
| 4664 | resolveRegion.srcSubresource, |
| 4665 | resolveRegion.srcOffset, |
| 4666 | resolveRegion.dstSubresource, |
| 4667 | resolveRegion.dstOffset, |
| 4668 | resolveRegion.extent}; |
| 4669 | const VkResolveImageInfo2KHR resolve_image_info2 = {VK_STRUCTURE_TYPE_RESOLVE_IMAGE_INFO_2_KHR, |
| 4670 | NULL, |
| 4671 | srcImage.image(), |
| 4672 | VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
| 4673 | dstImage.image(), |
| 4674 | VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 4675 | 1, |
| 4676 | &resolveRegion2}; |
Tony-LunarG | 953d55a | 2021-11-11 14:20:25 -0700 | [diff] [blame] | 4677 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkResolveImageInfo2-dstSubresource-01712"); |
Jeff Leger | 465acf5 | 2020-10-12 18:07:16 -0400 | [diff] [blame] | 4678 | vkCmdResolveImage2Function(m_commandBuffer->handle(), &resolve_image_info2); |
| 4679 | m_errorMonitor->VerifyFound(); |
| 4680 | } |
| 4681 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4682 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 4683 | |
| 4684 | m_commandBuffer->end(); |
| 4685 | } |
| 4686 | |
sfricke-samsung | f78d059 | 2020-06-11 21:34:44 -0700 | [diff] [blame] | 4687 | TEST_F(VkLayerTest, ResolveImageImageType) { |
| 4688 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 4689 | // Create images of different types and try to resolve between them |
| 4690 | VkImageObj srcImage2D(m_device); |
| 4691 | VkImageObj dstImage1D(m_device); |
| 4692 | VkImageObj dstImage3D(m_device); |
| 4693 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 4694 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
sfricke-samsung | f78d059 | 2020-06-11 21:34:44 -0700 | [diff] [blame] | 4695 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 4696 | image_create_info.extent.width = 32; |
| 4697 | image_create_info.extent.height = 1; |
| 4698 | image_create_info.extent.depth = 1; |
| 4699 | image_create_info.mipLevels = 1; |
| 4700 | image_create_info.arrayLayers = 4; // more than 1 to not trip other validation |
sfricke-samsung | f46582f | 2021-03-31 02:02:37 -0700 | [diff] [blame] | 4701 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; // guarantee support from sampledImageColorSampleCounts |
sfricke-samsung | f78d059 | 2020-06-11 21:34:44 -0700 | [diff] [blame] | 4702 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4703 | image_create_info.usage = |
| 4704 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 4705 | // Note: Some implementations expect color attachment usage for any |
| 4706 | // multisample surface |
| 4707 | image_create_info.flags = 0; |
| 4708 | |
| 4709 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4710 | srcImage2D.init(&image_create_info); |
| 4711 | ASSERT_TRUE(srcImage2D.initialized()); |
| 4712 | |
| 4713 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 4714 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 4715 | dstImage1D.init(&image_create_info); |
| 4716 | ASSERT_TRUE(dstImage1D.initialized()); |
| 4717 | |
| 4718 | image_create_info.imageType = VK_IMAGE_TYPE_3D; |
| 4719 | image_create_info.extent.height = 16; |
| 4720 | image_create_info.extent.depth = 16; |
| 4721 | image_create_info.arrayLayers = 1; |
| 4722 | dstImage3D.init(&image_create_info); |
| 4723 | ASSERT_TRUE(dstImage3D.initialized()); |
| 4724 | |
| 4725 | m_commandBuffer->begin(); |
| 4726 | |
| 4727 | VkImageResolve resolveRegion; |
| 4728 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4729 | resolveRegion.srcSubresource.mipLevel = 0; |
| 4730 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
| 4731 | resolveRegion.srcSubresource.layerCount = 1; |
| 4732 | resolveRegion.srcOffset.x = 0; |
| 4733 | resolveRegion.srcOffset.y = 0; |
| 4734 | resolveRegion.srcOffset.z = 0; |
| 4735 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4736 | resolveRegion.dstSubresource.mipLevel = 0; |
| 4737 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 4738 | resolveRegion.dstSubresource.layerCount = 1; |
| 4739 | resolveRegion.dstOffset.x = 0; |
| 4740 | resolveRegion.dstOffset.y = 0; |
| 4741 | resolveRegion.dstOffset.z = 0; |
| 4742 | resolveRegion.extent.width = 1; |
| 4743 | resolveRegion.extent.height = 1; |
| 4744 | resolveRegion.extent.depth = 1; |
| 4745 | |
| 4746 | // non-zero value baseArrayLayer |
| 4747 | resolveRegion.srcSubresource.baseArrayLayer = 2; |
Shannon McPherson | 74b341c | 2020-09-08 15:43:05 -0600 | [diff] [blame] | 4748 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-srcImage-04446"); |
sfricke-samsung | f78d059 | 2020-06-11 21:34:44 -0700 | [diff] [blame] | 4749 | m_commandBuffer->ResolveImage(srcImage2D.image(), VK_IMAGE_LAYOUT_GENERAL, dstImage3D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 4750 | &resolveRegion); |
| 4751 | m_errorMonitor->VerifyFound(); |
| 4752 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
| 4753 | |
| 4754 | // Set height with 1D dstImage |
| 4755 | resolveRegion.extent.height = 2; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 4756 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-dstImage-00276"); |
sfricke-samsung | dfeb317 | 2020-07-25 21:17:07 -0700 | [diff] [blame] | 4757 | // Also exceed height of both images |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 4758 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-srcOffset-00270"); |
| 4759 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-dstOffset-00275"); |
sfricke-samsung | f78d059 | 2020-06-11 21:34:44 -0700 | [diff] [blame] | 4760 | m_commandBuffer->ResolveImage(srcImage2D.image(), VK_IMAGE_LAYOUT_GENERAL, dstImage1D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 4761 | &resolveRegion); |
| 4762 | m_errorMonitor->VerifyFound(); |
| 4763 | resolveRegion.extent.height = 1; |
| 4764 | |
| 4765 | // Set depth with 1D dstImage and 2D srcImage |
| 4766 | resolveRegion.extent.depth = 2; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 4767 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-dstImage-00278"); |
| 4768 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-srcImage-00273"); |
sfricke-samsung | f78d059 | 2020-06-11 21:34:44 -0700 | [diff] [blame] | 4769 | m_commandBuffer->ResolveImage(srcImage2D.image(), VK_IMAGE_LAYOUT_GENERAL, dstImage1D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 4770 | &resolveRegion); |
| 4771 | m_errorMonitor->VerifyFound(); |
| 4772 | resolveRegion.extent.depth = 1; |
| 4773 | |
| 4774 | m_commandBuffer->end(); |
| 4775 | } |
| 4776 | |
sfricke-samsung | c967a2d | 2020-07-25 21:17:16 -0700 | [diff] [blame] | 4777 | TEST_F(VkLayerTest, ResolveImageSizeExceeded) { |
| 4778 | TEST_DESCRIPTION("Resolve Image with subresource region greater than size of src/dst image"); |
| 4779 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 4780 | |
| 4781 | VkImageObj srcImage2D(m_device); |
| 4782 | VkImageObj dstImage2D(m_device); |
| 4783 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 4784 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
sfricke-samsung | c967a2d | 2020-07-25 21:17:16 -0700 | [diff] [blame] | 4785 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 4786 | image_create_info.extent.width = 32; |
| 4787 | image_create_info.extent.height = 32; |
| 4788 | image_create_info.extent.depth = 1; |
Tony-LunarG | 0f8f94b | 2021-06-01 13:23:09 -0600 | [diff] [blame] | 4789 | image_create_info.mipLevels = 1; |
sfricke-samsung | c967a2d | 2020-07-25 21:17:16 -0700 | [diff] [blame] | 4790 | image_create_info.arrayLayers = 1; |
| 4791 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
| 4792 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4793 | image_create_info.usage = |
| 4794 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 4795 | // Note: Some implementations expect color attachment usage for any |
| 4796 | // multisample surface |
| 4797 | image_create_info.flags = 0; |
| 4798 | |
| 4799 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4800 | srcImage2D.init(&image_create_info); |
| 4801 | ASSERT_TRUE(srcImage2D.initialized()); |
| 4802 | |
| 4803 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 4804 | dstImage2D.init(&image_create_info); |
| 4805 | ASSERT_TRUE(dstImage2D.initialized()); |
| 4806 | |
| 4807 | m_commandBuffer->begin(); |
| 4808 | |
| 4809 | VkImageResolve resolveRegion = {}; |
| 4810 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4811 | resolveRegion.srcSubresource.mipLevel = 0; |
| 4812 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
| 4813 | resolveRegion.srcSubresource.layerCount = 1; |
| 4814 | resolveRegion.srcOffset.x = 0; |
| 4815 | resolveRegion.srcOffset.y = 0; |
| 4816 | resolveRegion.srcOffset.z = 0; |
| 4817 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4818 | resolveRegion.dstSubresource.mipLevel = 0; |
| 4819 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 4820 | resolveRegion.dstSubresource.layerCount = 1; |
| 4821 | resolveRegion.dstOffset.x = 0; |
| 4822 | resolveRegion.dstOffset.y = 0; |
| 4823 | resolveRegion.dstOffset.z = 0; |
| 4824 | resolveRegion.extent.width = 32; |
| 4825 | resolveRegion.extent.height = 32; |
| 4826 | resolveRegion.extent.depth = 1; |
| 4827 | |
sfricke-samsung | c967a2d | 2020-07-25 21:17:16 -0700 | [diff] [blame] | 4828 | m_commandBuffer->ResolveImage(srcImage2D.image(), VK_IMAGE_LAYOUT_GENERAL, dstImage2D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 4829 | &resolveRegion); |
sfricke-samsung | c967a2d | 2020-07-25 21:17:16 -0700 | [diff] [blame] | 4830 | |
| 4831 | // srcImage exceeded in x-dim |
| 4832 | resolveRegion.srcOffset.x = 4; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 4833 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-srcOffset-00269"); |
sfricke-samsung | c967a2d | 2020-07-25 21:17:16 -0700 | [diff] [blame] | 4834 | m_commandBuffer->ResolveImage(srcImage2D.image(), VK_IMAGE_LAYOUT_GENERAL, dstImage2D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 4835 | &resolveRegion); |
| 4836 | m_errorMonitor->VerifyFound(); |
| 4837 | resolveRegion.srcOffset.x = 0; |
| 4838 | |
| 4839 | // dstImage exceeded in x-dim |
| 4840 | resolveRegion.dstOffset.x = 4; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 4841 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-dstOffset-00274"); |
sfricke-samsung | c967a2d | 2020-07-25 21:17:16 -0700 | [diff] [blame] | 4842 | m_commandBuffer->ResolveImage(srcImage2D.image(), VK_IMAGE_LAYOUT_GENERAL, dstImage2D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 4843 | &resolveRegion); |
| 4844 | m_errorMonitor->VerifyFound(); |
| 4845 | resolveRegion.dstOffset.x = 0; |
| 4846 | |
Tony-LunarG | 0f8f94b | 2021-06-01 13:23:09 -0600 | [diff] [blame] | 4847 | // both image exceeded in y-dim |
| 4848 | resolveRegion.srcOffset.y = 32; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 4849 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-srcOffset-00270"); |
sfricke-samsung | c967a2d | 2020-07-25 21:17:16 -0700 | [diff] [blame] | 4850 | m_commandBuffer->ResolveImage(srcImage2D.image(), VK_IMAGE_LAYOUT_GENERAL, dstImage2D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 4851 | &resolveRegion); |
| 4852 | m_errorMonitor->VerifyFound(); |
Tony-LunarG | 0f8f94b | 2021-06-01 13:23:09 -0600 | [diff] [blame] | 4853 | resolveRegion.srcOffset.y = 0; |
sfricke-samsung | c967a2d | 2020-07-25 21:17:16 -0700 | [diff] [blame] | 4854 | |
Tony-LunarG | 0f8f94b | 2021-06-01 13:23:09 -0600 | [diff] [blame] | 4855 | resolveRegion.dstOffset.y = 32; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 4856 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-dstOffset-00275"); |
sfricke-samsung | c967a2d | 2020-07-25 21:17:16 -0700 | [diff] [blame] | 4857 | m_commandBuffer->ResolveImage(srcImage2D.image(), VK_IMAGE_LAYOUT_GENERAL, dstImage2D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 4858 | &resolveRegion); |
| 4859 | m_errorMonitor->VerifyFound(); |
Tony-LunarG | 0f8f94b | 2021-06-01 13:23:09 -0600 | [diff] [blame] | 4860 | resolveRegion.dstOffset.y = 0; |
sfricke-samsung | c967a2d | 2020-07-25 21:17:16 -0700 | [diff] [blame] | 4861 | |
| 4862 | // srcImage exceeded in z-dim |
| 4863 | resolveRegion.srcOffset.z = 1; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 4864 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-srcOffset-00272"); |
| 4865 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-srcImage-00273"); // because it's a 2d image |
sfricke-samsung | c967a2d | 2020-07-25 21:17:16 -0700 | [diff] [blame] | 4866 | m_commandBuffer->ResolveImage(srcImage2D.image(), VK_IMAGE_LAYOUT_GENERAL, dstImage2D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 4867 | &resolveRegion); |
| 4868 | m_errorMonitor->VerifyFound(); |
| 4869 | resolveRegion.srcOffset.z = 0; |
| 4870 | |
| 4871 | // dstImage exceeded in z-dim |
| 4872 | resolveRegion.dstOffset.z = 1; |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 4873 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-dstOffset-00277"); |
| 4874 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-dstImage-00278"); // because it's a 2d image |
sfricke-samsung | c967a2d | 2020-07-25 21:17:16 -0700 | [diff] [blame] | 4875 | m_commandBuffer->ResolveImage(srcImage2D.image(), VK_IMAGE_LAYOUT_GENERAL, dstImage2D.image(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 4876 | &resolveRegion); |
| 4877 | m_errorMonitor->VerifyFound(); |
| 4878 | resolveRegion.dstOffset.z = 0; |
| 4879 | |
| 4880 | m_commandBuffer->end(); |
| 4881 | } |
| 4882 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4883 | TEST_F(VkLayerTest, ClearImageErrors) { |
| 4884 | TEST_DESCRIPTION("Call ClearColorImage w/ a depth|stencil image and ClearDepthStencilImage with a color image."); |
| 4885 | |
| 4886 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 4887 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4888 | |
| 4889 | m_commandBuffer->begin(); |
| 4890 | |
| 4891 | // Color image |
| 4892 | VkClearColorValue clear_color; |
| 4893 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
| 4894 | const VkFormat color_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4895 | const int32_t img_width = 32; |
| 4896 | const int32_t img_height = 32; |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 4897 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4898 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4899 | image_create_info.format = color_format; |
| 4900 | image_create_info.extent.width = img_width; |
| 4901 | image_create_info.extent.height = img_height; |
| 4902 | image_create_info.extent.depth = 1; |
| 4903 | image_create_info.mipLevels = 1; |
| 4904 | image_create_info.arrayLayers = 1; |
| 4905 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 4906 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4907 | |
| 4908 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4909 | vk_testing::Image color_image_no_transfer; |
| 4910 | color_image_no_transfer.init(*m_device, image_create_info); |
| 4911 | |
| 4912 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 4913 | vk_testing::Image color_image; |
| 4914 | color_image.init(*m_device, image_create_info); |
| 4915 | |
| 4916 | const VkImageSubresourceRange color_range = vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
| 4917 | |
| 4918 | // Depth/Stencil image |
| 4919 | VkClearDepthStencilValue clear_value = {0}; |
| 4920 | VkImageCreateInfo ds_image_create_info = vk_testing::Image::create_info(); |
| 4921 | ds_image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4922 | ds_image_create_info.format = VK_FORMAT_D16_UNORM; |
| 4923 | ds_image_create_info.extent.width = 64; |
| 4924 | ds_image_create_info.extent.height = 64; |
| 4925 | ds_image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4926 | ds_image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 4927 | |
| 4928 | vk_testing::Image ds_image; |
| 4929 | ds_image.init(*m_device, ds_image_create_info); |
| 4930 | |
| 4931 | const VkImageSubresourceRange ds_range = vk_testing::Image::subresource_range(ds_image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 4932 | |
sfricke-samsung | cd924d9 | 2020-05-20 23:51:17 -0700 | [diff] [blame] | 4933 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdClearColorImage-image-00007"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4934 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 4935 | vk::CmdClearColorImage(m_commandBuffer->handle(), ds_image.handle(), VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &color_range); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4936 | |
| 4937 | m_errorMonitor->VerifyFound(); |
| 4938 | |
sfricke-samsung | cd924d9 | 2020-05-20 23:51:17 -0700 | [diff] [blame] | 4939 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdClearColorImage-image-00002"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4940 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 4941 | vk::CmdClearColorImage(m_commandBuffer->handle(), color_image_no_transfer.handle(), VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, |
| 4942 | &color_range); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4943 | |
| 4944 | m_errorMonitor->VerifyFound(); |
| 4945 | |
| 4946 | // Call CmdClearDepthStencilImage with color image |
sfricke-samsung | cd924d9 | 2020-05-20 23:51:17 -0700 | [diff] [blame] | 4947 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdClearDepthStencilImage-image-00014"); |
sfricke-samsung | 30e325a | 2020-07-25 12:56:13 -0700 | [diff] [blame] | 4948 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdClearDepthStencilImage-image-02826"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4949 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 4950 | vk::CmdClearDepthStencilImage(m_commandBuffer->handle(), color_image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 4951 | &clear_value, 1, &ds_range); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4952 | |
| 4953 | m_errorMonitor->VerifyFound(); |
| 4954 | } |
| 4955 | |
| 4956 | TEST_F(VkLayerTest, CommandQueueFlags) { |
| 4957 | TEST_DESCRIPTION( |
| 4958 | "Allocate a command buffer on a queue that does not support graphics and try to issue a graphics-only command"); |
| 4959 | |
| 4960 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 4961 | |
| 4962 | uint32_t queueFamilyIndex = m_device->QueueFamilyWithoutCapabilities(VK_QUEUE_GRAPHICS_BIT); |
| 4963 | if (queueFamilyIndex == UINT32_MAX) { |
| 4964 | printf("%s Non-graphics queue family not found; skipped.\n", kSkipPrefix); |
| 4965 | return; |
| 4966 | } else { |
| 4967 | // Create command pool on a non-graphics queue |
| 4968 | VkCommandPoolObj command_pool(m_device, queueFamilyIndex); |
| 4969 | |
| 4970 | // Setup command buffer on pool |
| 4971 | VkCommandBufferObj command_buffer(m_device, &command_pool); |
| 4972 | command_buffer.begin(); |
| 4973 | |
| 4974 | // Issue a graphics only command |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 4975 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetViewport-commandBuffer-cmdpool"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 4976 | VkViewport viewport = {0, 0, 16, 16, 0, 1}; |
| 4977 | command_buffer.SetViewport(0, 1, &viewport); |
| 4978 | m_errorMonitor->VerifyFound(); |
| 4979 | } |
| 4980 | } |
| 4981 | |
sfricke-samsung | 674ba10 | 2020-08-18 22:38:49 -0700 | [diff] [blame] | 4982 | TEST_F(VkLayerTest, DepthStencilImageCopyNoGraphicsQueueFlags) { |
| 4983 | TEST_DESCRIPTION( |
| 4984 | "Allocate a command buffer on a queue that does not support graphics and try to issue a depth/stencil image copy to " |
| 4985 | "buffer"); |
| 4986 | |
| 4987 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 4988 | |
| 4989 | uint32_t queueFamilyIndex = m_device->QueueFamilyWithoutCapabilities(VK_QUEUE_GRAPHICS_BIT); |
| 4990 | if (queueFamilyIndex == UINT32_MAX) { |
| 4991 | printf("%s Non-graphics queue family not found; skipped.\n", kSkipPrefix); |
| 4992 | return; |
| 4993 | } else { |
| 4994 | // Create Depth image |
| 4995 | const VkFormat ds_format = FindSupportedDepthOnlyFormat(gpu()); |
| 4996 | if (ds_format == VK_FORMAT_UNDEFINED) { |
| 4997 | printf("%s No only Depth format found. Skipped.\n", kSkipPrefix); |
| 4998 | return; |
| 4999 | } |
| 5000 | |
| 5001 | VkImageObj ds_image(m_device); |
| 5002 | ds_image.Init(64, 64, 1, ds_format, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, |
| 5003 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 5004 | ASSERT_TRUE(ds_image.initialized()); |
| 5005 | |
| 5006 | // Allocate buffers |
| 5007 | VkBufferObj buffer; |
| 5008 | VkMemoryPropertyFlags reqs = 0; |
| 5009 | buffer.init_as_src_and_dst(*m_device, 262144, reqs); // 256k to have more then enough to copy |
| 5010 | |
| 5011 | VkBufferImageCopy region = {}; |
| 5012 | region.bufferRowLength = 0; |
| 5013 | region.bufferImageHeight = 0; |
| 5014 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; |
| 5015 | region.imageSubresource.layerCount = 1; |
| 5016 | region.imageOffset = {0, 0, 0}; |
| 5017 | region.imageExtent = {64, 64, 1}; |
| 5018 | region.bufferOffset = 0; |
| 5019 | |
| 5020 | // Create command pool on a non-graphics queue |
| 5021 | VkCommandPoolObj command_pool(m_device, queueFamilyIndex); |
| 5022 | |
| 5023 | // Setup command buffer on pool |
| 5024 | VkCommandBufferObj command_buffer(m_device, &command_pool); |
| 5025 | command_buffer.begin(); |
| 5026 | |
sfricke-samsung | ea4fd14 | 2020-10-17 23:51:59 -0700 | [diff] [blame] | 5027 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyBufferToImage-commandBuffer-04477"); |
sfricke-samsung | 674ba10 | 2020-08-18 22:38:49 -0700 | [diff] [blame] | 5028 | vk::CmdCopyBufferToImage(command_buffer.handle(), buffer.handle(), ds_image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 5029 | 1, ®ion); |
| 5030 | m_errorMonitor->VerifyFound(); |
| 5031 | } |
| 5032 | } |
| 5033 | |
sfricke-samsung | 5a01949 | 2021-01-25 10:32:08 -0800 | [diff] [blame] | 5034 | TEST_F(VkLayerTest, ImageCopyTransferQueueFlags) { |
| 5035 | TEST_DESCRIPTION( |
| 5036 | "Allocate a command buffer on a queue that does not support graphics/compute and try to issue an invalid image copy to " |
| 5037 | "buffer"); |
| 5038 | |
| 5039 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 5040 | |
| 5041 | // Should be left with a tranfser queue |
| 5042 | uint32_t queueFamilyIndex = m_device->QueueFamilyWithoutCapabilities(VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT); |
| 5043 | if (queueFamilyIndex == UINT32_MAX) { |
| 5044 | printf("%s Non-graphics/compute queue family not found; skipped.\n", kSkipPrefix); |
| 5045 | return; |
| 5046 | } |
| 5047 | |
| 5048 | VkImageObj image(m_device); |
| 5049 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, |
| 5050 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 5051 | ASSERT_TRUE(image.initialized()); |
| 5052 | |
| 5053 | // Allocate buffers |
| 5054 | VkBufferObj buffer; |
| 5055 | VkMemoryPropertyFlags reqs = 0; |
| 5056 | buffer.init_as_src_and_dst(*m_device, 262144, reqs); // 256k to have more then enough to copy |
| 5057 | |
| 5058 | VkBufferImageCopy region = {}; |
| 5059 | region.bufferRowLength = 0; |
| 5060 | region.bufferImageHeight = 0; |
| 5061 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5062 | region.imageSubresource.layerCount = 1; |
| 5063 | region.imageOffset = {0, 0, 0}; |
| 5064 | region.imageExtent = {16, 16, 1}; |
| 5065 | region.bufferOffset = 5; |
| 5066 | |
| 5067 | // Create command pool on a non-graphics queue |
| 5068 | VkCommandPoolObj command_pool(m_device, queueFamilyIndex); |
| 5069 | |
| 5070 | // Setup command buffer on pool |
| 5071 | VkCommandBufferObj command_buffer(m_device, &command_pool); |
| 5072 | command_buffer.begin(); |
| 5073 | |
| 5074 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyBufferToImage-bufferOffset-00193"); |
| 5075 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyBufferToImage-commandBuffer-04052"); |
| 5076 | vk::CmdCopyBufferToImage(command_buffer.handle(), buffer.handle(), image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, |
| 5077 | ®ion); |
| 5078 | m_errorMonitor->VerifyFound(); |
| 5079 | } |
| 5080 | |
sfricke-samsung | cb46767 | 2020-11-25 00:09:28 -0800 | [diff] [blame] | 5081 | TEST_F(VkLayerTest, ExecuteDiffertQueueFlagsSecondaryCB) { |
| 5082 | TEST_DESCRIPTION("Allocate a command buffer from two different queues and try to use a secondary command buffer"); |
| 5083 | |
| 5084 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 5085 | |
| 5086 | if (m_device->queue_props.size() < 2) { |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 5087 | GTEST_SKIP() << "Need 2 different queues for testing skipping."; |
sfricke-samsung | cb46767 | 2020-11-25 00:09:28 -0800 | [diff] [blame] | 5088 | } |
| 5089 | |
| 5090 | // First two queue families |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 5091 | uint32_t queue_index_a = 0; |
| 5092 | uint32_t queue_index_b = 1; |
sfricke-samsung | cb46767 | 2020-11-25 00:09:28 -0800 | [diff] [blame] | 5093 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 5094 | VkCommandPoolCreateInfo pool_create_info = LvlInitStruct<VkCommandPoolCreateInfo>(); |
sfricke-samsung | cb46767 | 2020-11-25 00:09:28 -0800 | [diff] [blame] | 5095 | pool_create_info.flags = 0; |
| 5096 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 5097 | pool_create_info.queueFamilyIndex = queue_index_a; |
| 5098 | vk_testing::CommandPool command_pool_a(*m_device, pool_create_info); |
| 5099 | ASSERT_TRUE(command_pool_a.initialized()); |
sfricke-samsung | cb46767 | 2020-11-25 00:09:28 -0800 | [diff] [blame] | 5100 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 5101 | pool_create_info.queueFamilyIndex = queue_index_b; |
| 5102 | vk_testing::CommandPool command_pool_b(*m_device, pool_create_info); |
| 5103 | ASSERT_TRUE(command_pool_b.initialized()); |
sfricke-samsung | cb46767 | 2020-11-25 00:09:28 -0800 | [diff] [blame] | 5104 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 5105 | auto command_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>(); |
sfricke-samsung | cb46767 | 2020-11-25 00:09:28 -0800 | [diff] [blame] | 5106 | command_buffer_allocate_info.commandBufferCount = 1; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 5107 | command_buffer_allocate_info.commandPool = command_pool_a.handle(); |
sfricke-samsung | cb46767 | 2020-11-25 00:09:28 -0800 | [diff] [blame] | 5108 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 5109 | vk_testing::CommandBuffer command_buffer_primary(*m_device, command_buffer_allocate_info); |
| 5110 | ASSERT_TRUE(command_buffer_primary.initialized()); |
sfricke-samsung | cb46767 | 2020-11-25 00:09:28 -0800 | [diff] [blame] | 5111 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 5112 | command_buffer_allocate_info.commandPool = command_pool_b.handle(); |
sfricke-samsung | cb46767 | 2020-11-25 00:09:28 -0800 | [diff] [blame] | 5113 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 5114 | vk_testing::CommandBuffer command_buffer_secondary(*m_device, command_buffer_allocate_info); |
sfricke-samsung | cb46767 | 2020-11-25 00:09:28 -0800 | [diff] [blame] | 5115 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 5116 | auto cmdbuff_ii = LvlInitStruct<VkCommandBufferInheritanceInfo>(); |
| 5117 | cmdbuff_ii.renderPass = m_renderPass; |
| 5118 | cmdbuff_ii.subpass = 0; |
| 5119 | cmdbuff_ii.framebuffer = m_framebuffer; |
| 5120 | |
| 5121 | auto begin_info = LvlInitStruct<VkCommandBufferBeginInfo>(); |
| 5122 | begin_info.pInheritanceInfo = &cmdbuff_ii; |
sfricke-samsung | cb46767 | 2020-11-25 00:09:28 -0800 | [diff] [blame] | 5123 | |
| 5124 | // secondary |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 5125 | command_buffer_secondary.begin(&begin_info); |
| 5126 | command_buffer_secondary.end(); |
sfricke-samsung | cb46767 | 2020-11-25 00:09:28 -0800 | [diff] [blame] | 5127 | |
| 5128 | // Try using different pool's command buffer as secondary |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 5129 | command_buffer_primary.begin(&begin_info); |
sfricke-samsung | cb46767 | 2020-11-25 00:09:28 -0800 | [diff] [blame] | 5130 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pCommandBuffers-00094"); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 5131 | vk::CmdExecuteCommands(command_buffer_primary.handle(), 1, &command_buffer_secondary.handle()); |
sfricke-samsung | cb46767 | 2020-11-25 00:09:28 -0800 | [diff] [blame] | 5132 | m_errorMonitor->VerifyFound(); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 5133 | command_buffer_primary.end(); |
sfricke-samsung | cb46767 | 2020-11-25 00:09:28 -0800 | [diff] [blame] | 5134 | } |
| 5135 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5136 | TEST_F(VkLayerTest, ExecuteUnrecordedSecondaryCB) { |
| 5137 | TEST_DESCRIPTION("Attempt vkCmdExecuteCommands with a CB in the initial state"); |
| 5138 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 5139 | VkCommandBufferObj secondary(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 5140 | // never record secondary |
| 5141 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5142 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pCommandBuffers-00089"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5143 | m_commandBuffer->begin(); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5144 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5145 | m_errorMonitor->VerifyFound(); |
| 5146 | m_commandBuffer->end(); |
| 5147 | } |
| 5148 | |
| 5149 | TEST_F(VkLayerTest, ExecuteSecondaryCBWithLayoutMismatch) { |
| 5150 | TEST_DESCRIPTION("Attempt vkCmdExecuteCommands with a CB with incorrect initial layout."); |
| 5151 | |
Mark Lobodzinski | 09ce9c4 | 2020-03-06 10:02:44 -0700 | [diff] [blame] | 5152 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5153 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, nullptr, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
| 5154 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 5155 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5156 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5157 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5158 | image_create_info.extent.width = 32; |
| 5159 | image_create_info.extent.height = 1; |
| 5160 | image_create_info.extent.depth = 1; |
| 5161 | image_create_info.mipLevels = 1; |
| 5162 | image_create_info.arrayLayers = 1; |
| 5163 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 5164 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 5165 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 5166 | image_create_info.flags = 0; |
| 5167 | |
| 5168 | VkImageSubresource image_sub = VkImageObj::subresource(VK_IMAGE_ASPECT_COLOR_BIT, 0, 0); |
| 5169 | VkImageSubresourceRange image_sub_range = VkImageObj::subresource_range(image_sub); |
| 5170 | |
| 5171 | VkImageObj image(m_device); |
| 5172 | image.init(&image_create_info); |
| 5173 | ASSERT_TRUE(image.initialized()); |
| 5174 | VkImageMemoryBarrier image_barrier = |
| 5175 | image.image_memory_barrier(0, 0, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL, image_sub_range); |
| 5176 | |
| 5177 | auto pipeline = [&image_barrier](const VkCommandBufferObj &cb, VkImageLayout old_layout, VkImageLayout new_layout) { |
| 5178 | image_barrier.oldLayout = old_layout; |
| 5179 | image_barrier.newLayout = new_layout; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5180 | vk::CmdPipelineBarrier(cb.handle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 5181 | 0, nullptr, 1, &image_barrier); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5182 | }; |
| 5183 | |
| 5184 | // Validate that mismatched use of image layout in secondary command buffer is caught at record time |
| 5185 | VkCommandBufferObj secondary(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 5186 | secondary.begin(); |
| 5187 | pipeline(secondary, VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); |
| 5188 | secondary.end(); |
| 5189 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5190 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "UNASSIGNED-vkCmdExecuteCommands-commandBuffer-00001"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5191 | m_commandBuffer->begin(); |
| 5192 | pipeline(*m_commandBuffer, VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5193 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5194 | m_errorMonitor->VerifyFound(); |
| 5195 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5196 | m_commandBuffer->reset(); |
| 5197 | secondary.reset(); |
| 5198 | |
| 5199 | // Validate that UNDEFINED doesn't false positive on us |
| 5200 | secondary.begin(); |
| 5201 | pipeline(secondary, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); |
| 5202 | secondary.end(); |
| 5203 | m_commandBuffer->begin(); |
| 5204 | pipeline(*m_commandBuffer, VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5205 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5206 | m_commandBuffer->end(); |
| 5207 | } |
| 5208 | |
| 5209 | TEST_F(VkLayerTest, SetDynViewportParamTests) { |
| 5210 | TEST_DESCRIPTION("Test parameters of vkCmdSetViewport without multiViewport feature"); |
| 5211 | |
| 5212 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 5213 | VkPhysicalDeviceFeatures features{}; |
| 5214 | ASSERT_NO_FATAL_FAILURE(Init(&features)); |
| 5215 | |
| 5216 | const VkViewport vp = {0.0, 0.0, 64.0, 64.0, 0.0, 1.0}; |
| 5217 | const VkViewport viewports[] = {vp, vp}; |
| 5218 | |
| 5219 | m_commandBuffer->begin(); |
| 5220 | |
| 5221 | // array tests |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5222 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetViewport-firstViewport-01224"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5223 | vk::CmdSetViewport(m_commandBuffer->handle(), 1, 1, viewports); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5224 | m_errorMonitor->VerifyFound(); |
| 5225 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5226 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetViewport-viewportCount-arraylength"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5227 | vk::CmdSetViewport(m_commandBuffer->handle(), 0, 0, nullptr); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5228 | m_errorMonitor->VerifyFound(); |
| 5229 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5230 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetViewport-viewportCount-01225"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5231 | vk::CmdSetViewport(m_commandBuffer->handle(), 0, 2, viewports); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5232 | m_errorMonitor->VerifyFound(); |
| 5233 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5234 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetViewport-firstViewport-01224"); |
| 5235 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetViewport-viewportCount-01225"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5236 | vk::CmdSetViewport(m_commandBuffer->handle(), 1, 2, viewports); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5237 | m_errorMonitor->VerifyFound(); |
| 5238 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5239 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetViewport-pViewports-parameter"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5240 | vk::CmdSetViewport(m_commandBuffer->handle(), 0, 1, nullptr); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5241 | m_errorMonitor->VerifyFound(); |
| 5242 | |
| 5243 | // core viewport tests |
| 5244 | using std::vector; |
| 5245 | struct TestCase { |
| 5246 | VkViewport vp; |
| 5247 | std::string veid; |
| 5248 | }; |
| 5249 | |
| 5250 | // not necessarily boundary values (unspecified cast rounding), but guaranteed to be over limit |
| 5251 | const auto one_past_max_w = NearestGreater(static_cast<float>(m_device->props.limits.maxViewportDimensions[0])); |
| 5252 | const auto one_past_max_h = NearestGreater(static_cast<float>(m_device->props.limits.maxViewportDimensions[1])); |
| 5253 | |
| 5254 | const auto min_bound = m_device->props.limits.viewportBoundsRange[0]; |
| 5255 | const auto max_bound = m_device->props.limits.viewportBoundsRange[1]; |
| 5256 | const auto one_before_min_bounds = NearestSmaller(min_bound); |
| 5257 | const auto one_past_max_bounds = NearestGreater(max_bound); |
| 5258 | |
| 5259 | const auto below_zero = NearestSmaller(0.0f); |
| 5260 | const auto past_one = NearestGreater(1.0f); |
| 5261 | |
| 5262 | vector<TestCase> test_cases = { |
| 5263 | {{0.0, 0.0, 0.0, 64.0, 0.0, 1.0}, "VUID-VkViewport-width-01770"}, |
| 5264 | {{0.0, 0.0, one_past_max_w, 64.0, 0.0, 1.0}, "VUID-VkViewport-width-01771"}, |
| 5265 | {{0.0, 0.0, NAN, 64.0, 0.0, 1.0}, "VUID-VkViewport-width-01770"}, |
| 5266 | {{0.0, 0.0, 64.0, one_past_max_h, 0.0, 1.0}, "VUID-VkViewport-height-01773"}, |
| 5267 | {{one_before_min_bounds, 0.0, 64.0, 64.0, 0.0, 1.0}, "VUID-VkViewport-x-01774"}, |
| 5268 | {{one_past_max_bounds, 0.0, 64.0, 64.0, 0.0, 1.0}, "VUID-VkViewport-x-01232"}, |
| 5269 | {{NAN, 0.0, 64.0, 64.0, 0.0, 1.0}, "VUID-VkViewport-x-01774"}, |
| 5270 | {{0.0, one_before_min_bounds, 64.0, 64.0, 0.0, 1.0}, "VUID-VkViewport-y-01775"}, |
| 5271 | {{0.0, NAN, 64.0, 64.0, 0.0, 1.0}, "VUID-VkViewport-y-01775"}, |
| 5272 | {{max_bound, 0.0, 1.0, 64.0, 0.0, 1.0}, "VUID-VkViewport-x-01232"}, |
| 5273 | {{0.0, max_bound, 64.0, 1.0, 0.0, 1.0}, "VUID-VkViewport-y-01233"}, |
| 5274 | {{0.0, 0.0, 64.0, 64.0, below_zero, 1.0}, "VUID-VkViewport-minDepth-01234"}, |
| 5275 | {{0.0, 0.0, 64.0, 64.0, past_one, 1.0}, "VUID-VkViewport-minDepth-01234"}, |
| 5276 | {{0.0, 0.0, 64.0, 64.0, NAN, 1.0}, "VUID-VkViewport-minDepth-01234"}, |
| 5277 | {{0.0, 0.0, 64.0, 64.0, 0.0, below_zero}, "VUID-VkViewport-maxDepth-01235"}, |
| 5278 | {{0.0, 0.0, 64.0, 64.0, 0.0, past_one}, "VUID-VkViewport-maxDepth-01235"}, |
| 5279 | {{0.0, 0.0, 64.0, 64.0, 0.0, NAN}, "VUID-VkViewport-maxDepth-01235"}, |
| 5280 | }; |
| 5281 | |
| 5282 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 5283 | test_cases.push_back({{0.0, 0.0, 64.0, 0.0, 0.0, 1.0}, "VUID-VkViewport-height-01772"}); |
| 5284 | test_cases.push_back({{0.0, 0.0, 64.0, NAN, 0.0, 1.0}, "VUID-VkViewport-height-01772"}); |
| 5285 | } else { |
| 5286 | test_cases.push_back({{0.0, 0.0, 64.0, NAN, 0.0, 1.0}, "VUID-VkViewport-height-01773"}); |
| 5287 | } |
| 5288 | |
| 5289 | for (const auto &test_case : test_cases) { |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5290 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, test_case.veid); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5291 | vk::CmdSetViewport(m_commandBuffer->handle(), 0, 1, &test_case.vp); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5292 | m_errorMonitor->VerifyFound(); |
| 5293 | } |
| 5294 | } |
| 5295 | |
| 5296 | TEST_F(VkLayerTest, SetDynViewportParamMaintenance1Tests) { |
| 5297 | TEST_DESCRIPTION("Verify errors are detected on misuse of SetViewport with a negative viewport extension enabled."); |
| 5298 | |
Mark Lobodzinski | 09ce9c4 | 2020-03-06 10:02:44 -0700 | [diff] [blame] | 5299 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5300 | |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 5301 | if (DeviceExtensionSupported(gpu(), nullptr, VK_KHR_MAINTENANCE_1_EXTENSION_NAME)) { |
| 5302 | m_device_extension_names.push_back(VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5303 | } else { |
| 5304 | printf("%s VK_KHR_maintenance1 extension not supported -- skipping test\n", kSkipPrefix); |
| 5305 | return; |
| 5306 | } |
| 5307 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5308 | |
| 5309 | NegHeightViewportTests(m_device, m_commandBuffer, m_errorMonitor); |
| 5310 | } |
| 5311 | |
| 5312 | TEST_F(VkLayerTest, SetDynViewportParamMultiviewportTests) { |
| 5313 | TEST_DESCRIPTION("Test parameters of vkCmdSetViewport with multiViewport feature enabled"); |
| 5314 | |
| 5315 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 5316 | |
| 5317 | if (!m_device->phy().features().multiViewport) { |
| 5318 | printf("%s VkPhysicalDeviceFeatures::multiViewport is not supported -- skipping test.\n", kSkipPrefix); |
| 5319 | return; |
| 5320 | } |
| 5321 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5322 | m_commandBuffer->begin(); |
| 5323 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5324 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetViewport-viewportCount-arraylength"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5325 | vk::CmdSetViewport(m_commandBuffer->handle(), 0, 0, nullptr); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5326 | m_errorMonitor->VerifyFound(); |
| 5327 | |
Petr Kraus | 14e4949 | 2019-09-09 20:13:29 +0200 | [diff] [blame] | 5328 | const auto max_viewports = m_device->props.limits.maxViewports; |
| 5329 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5330 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetViewport-pViewports-parameter"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5331 | vk::CmdSetViewport(m_commandBuffer->handle(), 0, max_viewports, nullptr); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5332 | m_errorMonitor->VerifyFound(); |
| 5333 | |
Petr Kraus | 14e4949 | 2019-09-09 20:13:29 +0200 | [diff] [blame] | 5334 | const uint32_t too_big_max_viewports = 65536 + 1; // let's say this is too much to allocate |
| 5335 | if (max_viewports >= too_big_max_viewports) { |
| 5336 | printf("%s VkPhysicalDeviceLimits::maxViewports is too large to practically test against -- skipping part of test.\n", |
| 5337 | kSkipPrefix); |
| 5338 | } else { |
| 5339 | const VkViewport vp = {0.0, 0.0, 64.0, 64.0, 0.0, 1.0}; |
| 5340 | const std::vector<VkViewport> viewports(max_viewports + 1, vp); |
| 5341 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5342 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetViewport-firstViewport-01223"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5343 | vk::CmdSetViewport(m_commandBuffer->handle(), 0, max_viewports + 1, viewports.data()); |
Petr Kraus | 14e4949 | 2019-09-09 20:13:29 +0200 | [diff] [blame] | 5344 | m_errorMonitor->VerifyFound(); |
| 5345 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5346 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetViewport-firstViewport-01223"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5347 | vk::CmdSetViewport(m_commandBuffer->handle(), max_viewports, 1, viewports.data()); |
Petr Kraus | 14e4949 | 2019-09-09 20:13:29 +0200 | [diff] [blame] | 5348 | m_errorMonitor->VerifyFound(); |
| 5349 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5350 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetViewport-firstViewport-01223"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5351 | vk::CmdSetViewport(m_commandBuffer->handle(), 1, max_viewports, viewports.data()); |
Petr Kraus | 14e4949 | 2019-09-09 20:13:29 +0200 | [diff] [blame] | 5352 | m_errorMonitor->VerifyFound(); |
| 5353 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5354 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetViewport-viewportCount-arraylength"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5355 | vk::CmdSetViewport(m_commandBuffer->handle(), 1, 0, viewports.data()); |
Petr Kraus | 14e4949 | 2019-09-09 20:13:29 +0200 | [diff] [blame] | 5356 | m_errorMonitor->VerifyFound(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5357 | } |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5358 | } |
| 5359 | |
| 5360 | TEST_F(VkLayerTest, BadRenderPassScopeSecondaryCmdBuffer) { |
| 5361 | TEST_DESCRIPTION( |
| 5362 | "Test secondary buffers executed in wrong render pass scope wrt VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT"); |
| 5363 | |
| 5364 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 5365 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5366 | |
| 5367 | VkCommandBufferObj sec_cmdbuff_inside_rp(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 5368 | VkCommandBufferObj sec_cmdbuff_outside_rp(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 5369 | |
| 5370 | const VkCommandBufferInheritanceInfo cmdbuff_ii = { |
| 5371 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, |
| 5372 | nullptr, // pNext |
| 5373 | m_renderPass, |
| 5374 | 0, // subpass |
| 5375 | m_framebuffer, |
| 5376 | }; |
| 5377 | const VkCommandBufferBeginInfo cmdbuff_bi_tmpl = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, |
| 5378 | nullptr, // pNext |
| 5379 | VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, &cmdbuff_ii}; |
| 5380 | |
| 5381 | VkCommandBufferBeginInfo cmdbuff_inside_rp_bi = cmdbuff_bi_tmpl; |
| 5382 | cmdbuff_inside_rp_bi.flags |= VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 5383 | sec_cmdbuff_inside_rp.begin(&cmdbuff_inside_rp_bi); |
| 5384 | sec_cmdbuff_inside_rp.end(); |
| 5385 | |
| 5386 | VkCommandBufferBeginInfo cmdbuff_outside_rp_bi = cmdbuff_bi_tmpl; |
| 5387 | cmdbuff_outside_rp_bi.flags &= ~VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 5388 | sec_cmdbuff_outside_rp.begin(&cmdbuff_outside_rp_bi); |
| 5389 | sec_cmdbuff_outside_rp.end(); |
| 5390 | |
| 5391 | m_commandBuffer->begin(); |
| 5392 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5393 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pCommandBuffers-00100"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5394 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &sec_cmdbuff_inside_rp.handle()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5395 | m_errorMonitor->VerifyFound(); |
| 5396 | |
| 5397 | const VkRenderPassBeginInfo rp_bi{VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, |
| 5398 | nullptr, // pNext |
| 5399 | m_renderPass, |
| 5400 | m_framebuffer, |
| 5401 | {{0, 0}, {32, 32}}, |
| 5402 | static_cast<uint32_t>(m_renderPassClearValues.size()), |
| 5403 | m_renderPassClearValues.data()}; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5404 | vk::CmdBeginRenderPass(m_commandBuffer->handle(), &rp_bi, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5405 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5406 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pCommandBuffers-00096"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5407 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &sec_cmdbuff_outside_rp.handle()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5408 | m_errorMonitor->VerifyFound(); |
| 5409 | } |
| 5410 | |
| 5411 | TEST_F(VkLayerTest, SecondaryCommandBufferClearColorAttachmentsRenderArea) { |
| 5412 | TEST_DESCRIPTION( |
| 5413 | "Create a secondary command buffer with CmdClearAttachments call that has a rect outside of renderPass renderArea"); |
| 5414 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 5415 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5416 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 5417 | VkCommandBufferAllocateInfo command_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5418 | command_buffer_allocate_info.commandPool = m_commandPool->handle(); |
| 5419 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
| 5420 | command_buffer_allocate_info.commandBufferCount = 1; |
| 5421 | |
| 5422 | VkCommandBuffer secondary_command_buffer; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5423 | ASSERT_VK_SUCCESS(vk::AllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, &secondary_command_buffer)); |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 5424 | VkCommandBufferBeginInfo command_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>(); |
| 5425 | VkCommandBufferInheritanceInfo command_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5426 | command_buffer_inheritance_info.renderPass = m_renderPass; |
| 5427 | command_buffer_inheritance_info.framebuffer = m_framebuffer; |
| 5428 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5429 | command_buffer_begin_info.flags = |
| 5430 | VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 5431 | command_buffer_begin_info.pInheritanceInfo = &command_buffer_inheritance_info; |
| 5432 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5433 | vk::BeginCommandBuffer(secondary_command_buffer, &command_buffer_begin_info); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5434 | VkClearAttachment color_attachment; |
| 5435 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5436 | color_attachment.clearValue.color.float32[0] = 0; |
| 5437 | color_attachment.clearValue.color.float32[1] = 0; |
| 5438 | color_attachment.clearValue.color.float32[2] = 0; |
| 5439 | color_attachment.clearValue.color.float32[3] = 0; |
| 5440 | color_attachment.colorAttachment = 0; |
| 5441 | // x extent of 257 exceeds render area of 256 |
Mark Lobodzinski | 6249089 | 2019-06-28 09:58:27 -0600 | [diff] [blame] | 5442 | VkClearRect clear_rect = {{{0, 0}, {257, 32}}, 0, 1}; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5443 | vk::CmdClearAttachments(secondary_command_buffer, 1, &color_attachment, 1, &clear_rect); |
| 5444 | vk::EndCommandBuffer(secondary_command_buffer); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5445 | m_commandBuffer->begin(); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5446 | vk::CmdBeginRenderPass(m_commandBuffer->handle(), &m_renderPassBeginInfo, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5447 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5448 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdClearAttachments-pRects-00016"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5449 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_command_buffer); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5450 | m_errorMonitor->VerifyFound(); |
| 5451 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5452 | vk::CmdEndRenderPass(m_commandBuffer->handle()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5453 | m_commandBuffer->end(); |
| 5454 | } |
| 5455 | |
| 5456 | TEST_F(VkLayerTest, PushDescriptorSetCmdPushBadArgs) { |
| 5457 | TEST_DESCRIPTION("Attempt to push a push descriptor set with incorrect arguments."); |
sjfricke | d8e01c5 | 2022-07-06 14:09:04 +0900 | [diff] [blame] | 5458 | AddRequiredExtensions(VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5459 | |
Mark Lobodzinski | 09ce9c4 | 2020-03-06 10:02:44 -0700 | [diff] [blame] | 5460 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
sjfricke | d8e01c5 | 2022-07-06 14:09:04 +0900 | [diff] [blame] | 5461 | if (!AreRequiredExtensionsEnabled()) { |
| 5462 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5463 | } |
| 5464 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5465 | |
sjfricke | 74a1aad | 2022-08-17 14:41:33 +0900 | [diff] [blame] | 5466 | VkPhysicalDevicePushDescriptorPropertiesKHR push_descriptor_prop = LvlInitStruct<VkPhysicalDevicePushDescriptorPropertiesKHR>(); |
| 5467 | GetPhysicalDeviceProperties2(push_descriptor_prop); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5468 | if (push_descriptor_prop.maxPushDescriptors < 1) { |
| 5469 | // Some implementations report an invalid maxPushDescriptors of 0 |
| 5470 | printf("%s maxPushDescriptors is zero, skipping tests\n", kSkipPrefix); |
| 5471 | return; |
| 5472 | } |
| 5473 | |
| 5474 | // Create ordinary and push descriptor set layout |
| 5475 | VkDescriptorSetLayoutBinding binding = {0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr}; |
| 5476 | const VkDescriptorSetLayoutObj ds_layout(m_device, {binding}); |
| 5477 | ASSERT_TRUE(ds_layout.initialized()); |
| 5478 | const VkDescriptorSetLayoutObj push_ds_layout(m_device, {binding}, VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR); |
| 5479 | ASSERT_TRUE(push_ds_layout.initialized()); |
| 5480 | |
| 5481 | // Now use the descriptor set layouts to create a pipeline layout |
| 5482 | const VkPipelineLayoutObj pipeline_layout(m_device, {&push_ds_layout, &ds_layout}); |
| 5483 | ASSERT_TRUE(pipeline_layout.initialized()); |
| 5484 | |
| 5485 | // Create a descriptor to push |
| 5486 | const uint32_t buffer_data[4] = {4, 5, 6, 7}; |
| 5487 | VkConstantBufferObj buffer_obj(m_device, sizeof(buffer_data), &buffer_data); |
| 5488 | ASSERT_TRUE(buffer_obj.initialized()); |
| 5489 | |
| 5490 | // Create a "write" struct, noting that the buffer_info cannot be a temporary arg (the return from write_descriptor_set |
| 5491 | // references its data), and the DescriptorSet() can be temporary, because the value is ignored |
| 5492 | VkDescriptorBufferInfo buffer_info = {buffer_obj.handle(), 0, VK_WHOLE_SIZE}; |
| 5493 | |
| 5494 | VkWriteDescriptorSet descriptor_write = vk_testing::Device::write_descriptor_set( |
| 5495 | vk_testing::DescriptorSet(), 0, 0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, &buffer_info); |
| 5496 | |
| 5497 | // Find address of extension call and make the call |
| 5498 | PFN_vkCmdPushDescriptorSetKHR vkCmdPushDescriptorSetKHR = |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5499 | (PFN_vkCmdPushDescriptorSetKHR)vk::GetDeviceProcAddr(m_device->device(), "vkCmdPushDescriptorSetKHR"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5500 | ASSERT_TRUE(vkCmdPushDescriptorSetKHR != nullptr); |
| 5501 | |
| 5502 | // Section 1: Queue family matching/capabilities. |
| 5503 | // Create command pool on a non-graphics queue |
| 5504 | const uint32_t no_gfx_qfi = m_device->QueueFamilyMatching(VK_QUEUE_COMPUTE_BIT, VK_QUEUE_GRAPHICS_BIT); |
| 5505 | const uint32_t transfer_only_qfi = |
| 5506 | m_device->QueueFamilyMatching(VK_QUEUE_TRANSFER_BIT, (VK_QUEUE_COMPUTE_BIT | VK_QUEUE_GRAPHICS_BIT)); |
| 5507 | if ((UINT32_MAX == transfer_only_qfi) && (UINT32_MAX == no_gfx_qfi)) { |
unknown | c3033e5 | 2019-06-21 16:56:20 -0600 | [diff] [blame] | 5508 | printf("%s No compute or transfer only queue family, skipping bindpoint and queue tests.\n", kSkipPrefix); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5509 | } else { |
| 5510 | const uint32_t err_qfi = (UINT32_MAX == no_gfx_qfi) ? transfer_only_qfi : no_gfx_qfi; |
| 5511 | |
| 5512 | VkCommandPoolObj command_pool(m_device, err_qfi); |
| 5513 | ASSERT_TRUE(command_pool.initialized()); |
| 5514 | VkCommandBufferObj command_buffer(m_device, &command_pool); |
| 5515 | ASSERT_TRUE(command_buffer.initialized()); |
| 5516 | command_buffer.begin(); |
| 5517 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5518 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPushDescriptorSetKHR-pipelineBindPoint-00363"); |
| 5519 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkWriteDescriptorSet-descriptorType-00330"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5520 | if (err_qfi == transfer_only_qfi) { |
| 5521 | // This as this queue neither supports the gfx or compute bindpoints, we'll get two errors |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5522 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPushDescriptorSetKHR-commandBuffer-cmdpool"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5523 | } |
| 5524 | vkCmdPushDescriptorSetKHR(command_buffer.handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout.handle(), 0, 1, |
| 5525 | &descriptor_write); |
| 5526 | m_errorMonitor->VerifyFound(); |
| 5527 | command_buffer.end(); |
| 5528 | |
| 5529 | // If we succeed in testing only one condition above, we need to test the other below. |
| 5530 | if ((UINT32_MAX != transfer_only_qfi) && (err_qfi != transfer_only_qfi)) { |
| 5531 | // Need to test the neither compute/gfx supported case separately. |
| 5532 | VkCommandPoolObj tran_command_pool(m_device, transfer_only_qfi); |
| 5533 | ASSERT_TRUE(tran_command_pool.initialized()); |
| 5534 | VkCommandBufferObj tran_command_buffer(m_device, &tran_command_pool); |
| 5535 | ASSERT_TRUE(tran_command_buffer.initialized()); |
| 5536 | tran_command_buffer.begin(); |
| 5537 | |
| 5538 | // We can't avoid getting *both* errors in this case |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5539 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPushDescriptorSetKHR-pipelineBindPoint-00363"); |
| 5540 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkWriteDescriptorSet-descriptorType-00330"); |
| 5541 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPushDescriptorSetKHR-commandBuffer-cmdpool"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5542 | vkCmdPushDescriptorSetKHR(tran_command_buffer.handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout.handle(), 0, 1, |
| 5543 | &descriptor_write); |
| 5544 | m_errorMonitor->VerifyFound(); |
| 5545 | tran_command_buffer.end(); |
| 5546 | } |
| 5547 | } |
| 5548 | |
| 5549 | // Push to the non-push binding |
| 5550 | m_commandBuffer->begin(); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5551 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPushDescriptorSetKHR-set-00365"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5552 | vkCmdPushDescriptorSetKHR(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout.handle(), 1, 1, |
| 5553 | &descriptor_write); |
| 5554 | m_errorMonitor->VerifyFound(); |
| 5555 | |
| 5556 | // Specify set out of bounds |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5557 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPushDescriptorSetKHR-set-00364"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5558 | vkCmdPushDescriptorSetKHR(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout.handle(), 2, 1, |
| 5559 | &descriptor_write); |
| 5560 | m_errorMonitor->VerifyFound(); |
| 5561 | m_commandBuffer->end(); |
| 5562 | |
| 5563 | // This is a test for VUID-vkCmdPushDescriptorSetKHR-commandBuffer-recording |
| 5564 | // TODO: Add VALIDATION_ERROR_ code support to core_validation::ValidateCmd |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5565 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 5566 | "You must call vkBeginCommandBuffer() before this call to vkCmdPushDescriptorSetKHR"); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5567 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkWriteDescriptorSet-descriptorType-00330"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5568 | vkCmdPushDescriptorSetKHR(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout.handle(), 0, 1, |
| 5569 | &descriptor_write); |
| 5570 | m_errorMonitor->VerifyFound(); |
| 5571 | } |
| 5572 | |
Jeremy Hayes | f96a516 | 2020-02-10 13:49:31 -0700 | [diff] [blame] | 5573 | TEST_F(VkLayerTest, PushDescriptorSetCmdBufferOffsetUnaligned) { |
| 5574 | TEST_DESCRIPTION("Attempt to push a push descriptor set buffer with unaligned offset."); |
sjfricke | d8e01c5 | 2022-07-06 14:09:04 +0900 | [diff] [blame] | 5575 | AddRequiredExtensions(VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); |
Jeremy Hayes | f96a516 | 2020-02-10 13:49:31 -0700 | [diff] [blame] | 5576 | |
Mark Lobodzinski | 09ce9c4 | 2020-03-06 10:02:44 -0700 | [diff] [blame] | 5577 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
sjfricke | d8e01c5 | 2022-07-06 14:09:04 +0900 | [diff] [blame] | 5578 | if (!AreRequiredExtensionsEnabled()) { |
| 5579 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
Jeremy Hayes | f96a516 | 2020-02-10 13:49:31 -0700 | [diff] [blame] | 5580 | } |
| 5581 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5582 | |
sjfricke | 74a1aad | 2022-08-17 14:41:33 +0900 | [diff] [blame] | 5583 | VkPhysicalDevicePushDescriptorPropertiesKHR push_descriptor_prop = LvlInitStruct<VkPhysicalDevicePushDescriptorPropertiesKHR>(); |
| 5584 | GetPhysicalDeviceProperties2(push_descriptor_prop); |
Jeremy Hayes | f96a516 | 2020-02-10 13:49:31 -0700 | [diff] [blame] | 5585 | if (push_descriptor_prop.maxPushDescriptors < 1) { |
| 5586 | // Some implementations report an invalid maxPushDescriptors of 0. |
| 5587 | printf("%s maxPushDescriptors is zero, skipping test\n", kSkipPrefix); |
| 5588 | return; |
| 5589 | } |
| 5590 | |
| 5591 | auto const min_alignment = m_device->props.limits.minUniformBufferOffsetAlignment; |
| 5592 | if (min_alignment == 0) { |
| 5593 | printf("%s minUniformBufferOffsetAlignment is zero, skipping test\n", kSkipPrefix); |
| 5594 | return; |
| 5595 | } |
| 5596 | |
| 5597 | VkDescriptorSetLayoutBinding binding = {0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr}; |
| 5598 | const VkDescriptorSetLayoutObj push_ds_layout(m_device, {binding}, VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR); |
| 5599 | ASSERT_TRUE(push_ds_layout.initialized()); |
| 5600 | |
| 5601 | const VkPipelineLayoutObj pipeline_layout(m_device, {&push_ds_layout}); |
| 5602 | ASSERT_TRUE(pipeline_layout.initialized()); |
| 5603 | |
| 5604 | const uint32_t buffer_data[4] = {4, 5, 6, 7}; |
| 5605 | VkConstantBufferObj buffer_obj(m_device, sizeof(buffer_data), &buffer_data, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT); |
| 5606 | ASSERT_TRUE(buffer_obj.initialized()); |
| 5607 | |
| 5608 | // Use an invalid alignment. |
| 5609 | VkDescriptorBufferInfo buffer_info = {buffer_obj.handle(), min_alignment - 1, VK_WHOLE_SIZE}; |
| 5610 | VkWriteDescriptorSet descriptor_write = vk_testing::Device::write_descriptor_set( |
| 5611 | vk_testing::DescriptorSet(), 0, 0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, &buffer_info); |
| 5612 | |
| 5613 | PFN_vkCmdPushDescriptorSetKHR vkCmdPushDescriptorSetKHR = |
| 5614 | (PFN_vkCmdPushDescriptorSetKHR)vk::GetDeviceProcAddr(m_device->device(), "vkCmdPushDescriptorSetKHR"); |
| 5615 | ASSERT_TRUE(vkCmdPushDescriptorSetKHR != nullptr); |
| 5616 | |
| 5617 | m_commandBuffer->begin(); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5618 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkWriteDescriptorSet-descriptorType-00327"); |
Jeremy Hayes | f96a516 | 2020-02-10 13:49:31 -0700 | [diff] [blame] | 5619 | vkCmdPushDescriptorSetKHR(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout.handle(), 0, 1, |
| 5620 | &descriptor_write); |
| 5621 | m_errorMonitor->VerifyFound(); |
| 5622 | |
| 5623 | m_commandBuffer->end(); |
| 5624 | } |
| 5625 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5626 | TEST_F(VkLayerTest, SetDynScissorParamTests) { |
| 5627 | TEST_DESCRIPTION("Test parameters of vkCmdSetScissor without multiViewport feature"); |
| 5628 | |
| 5629 | VkPhysicalDeviceFeatures features{}; |
| 5630 | ASSERT_NO_FATAL_FAILURE(Init(&features)); |
| 5631 | |
| 5632 | const VkRect2D scissor = {{0, 0}, {16, 16}}; |
| 5633 | const VkRect2D scissors[] = {scissor, scissor}; |
| 5634 | |
| 5635 | m_commandBuffer->begin(); |
| 5636 | |
| 5637 | // array tests |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5638 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetScissor-firstScissor-00593"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5639 | vk::CmdSetScissor(m_commandBuffer->handle(), 1, 1, scissors); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5640 | m_errorMonitor->VerifyFound(); |
| 5641 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5642 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetScissor-scissorCount-arraylength"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5643 | vk::CmdSetScissor(m_commandBuffer->handle(), 0, 0, nullptr); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5644 | m_errorMonitor->VerifyFound(); |
| 5645 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5646 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetScissor-scissorCount-00594"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5647 | vk::CmdSetScissor(m_commandBuffer->handle(), 0, 2, scissors); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5648 | m_errorMonitor->VerifyFound(); |
| 5649 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5650 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetScissor-firstScissor-00593"); |
| 5651 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetScissor-scissorCount-00594"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5652 | vk::CmdSetScissor(m_commandBuffer->handle(), 1, 2, scissors); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5653 | m_errorMonitor->VerifyFound(); |
| 5654 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5655 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetScissor-pScissors-parameter"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5656 | vk::CmdSetScissor(m_commandBuffer->handle(), 0, 1, nullptr); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5657 | m_errorMonitor->VerifyFound(); |
| 5658 | |
| 5659 | struct TestCase { |
| 5660 | VkRect2D scissor; |
| 5661 | std::string vuid; |
| 5662 | }; |
| 5663 | |
| 5664 | std::vector<TestCase> test_cases = {{{{-1, 0}, {16, 16}}, "VUID-vkCmdSetScissor-x-00595"}, |
| 5665 | {{{0, -1}, {16, 16}}, "VUID-vkCmdSetScissor-x-00595"}, |
| 5666 | {{{1, 0}, {INT32_MAX, 16}}, "VUID-vkCmdSetScissor-offset-00596"}, |
| 5667 | {{{INT32_MAX, 0}, {1, 16}}, "VUID-vkCmdSetScissor-offset-00596"}, |
| 5668 | {{{0, 0}, {uint32_t{INT32_MAX} + 1, 16}}, "VUID-vkCmdSetScissor-offset-00596"}, |
| 5669 | {{{0, 1}, {16, INT32_MAX}}, "VUID-vkCmdSetScissor-offset-00597"}, |
| 5670 | {{{0, INT32_MAX}, {16, 1}}, "VUID-vkCmdSetScissor-offset-00597"}, |
| 5671 | {{{0, 0}, {16, uint32_t{INT32_MAX} + 1}}, "VUID-vkCmdSetScissor-offset-00597"}}; |
| 5672 | |
| 5673 | for (const auto &test_case : test_cases) { |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5674 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, test_case.vuid); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5675 | vk::CmdSetScissor(m_commandBuffer->handle(), 0, 1, &test_case.scissor); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5676 | m_errorMonitor->VerifyFound(); |
| 5677 | } |
| 5678 | |
| 5679 | m_commandBuffer->end(); |
| 5680 | } |
| 5681 | |
| 5682 | TEST_F(VkLayerTest, SetDynScissorParamMultiviewportTests) { |
| 5683 | TEST_DESCRIPTION("Test parameters of vkCmdSetScissor with multiViewport feature enabled"); |
| 5684 | |
| 5685 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 5686 | |
| 5687 | if (!m_device->phy().features().multiViewport) { |
| 5688 | printf("%s VkPhysicalDeviceFeatures::multiViewport is not supported -- skipping test.\n", kSkipPrefix); |
| 5689 | return; |
| 5690 | } |
| 5691 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5692 | m_commandBuffer->begin(); |
| 5693 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5694 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetScissor-scissorCount-arraylength"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5695 | vk::CmdSetScissor(m_commandBuffer->handle(), 0, 0, nullptr); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5696 | m_errorMonitor->VerifyFound(); |
| 5697 | |
Petr Kraus | 14e4949 | 2019-09-09 20:13:29 +0200 | [diff] [blame] | 5698 | const auto max_scissors = m_device->props.limits.maxViewports; |
| 5699 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5700 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetScissor-pScissors-parameter"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5701 | vk::CmdSetScissor(m_commandBuffer->handle(), 0, max_scissors, nullptr); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5702 | m_errorMonitor->VerifyFound(); |
| 5703 | |
Petr Kraus | 14e4949 | 2019-09-09 20:13:29 +0200 | [diff] [blame] | 5704 | const uint32_t too_big_max_scissors = 65536 + 1; // let's say this is too much to allocate |
| 5705 | if (max_scissors >= too_big_max_scissors) { |
| 5706 | printf("%s VkPhysicalDeviceLimits::maxViewports is too large to practically test against -- skipping part of test.\n", |
| 5707 | kSkipPrefix); |
| 5708 | } else { |
| 5709 | const VkRect2D scissor = {{0, 0}, {16, 16}}; |
| 5710 | const std::vector<VkRect2D> scissors(max_scissors + 1, scissor); |
| 5711 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5712 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetScissor-firstScissor-00592"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5713 | vk::CmdSetScissor(m_commandBuffer->handle(), 0, max_scissors + 1, scissors.data()); |
Petr Kraus | 14e4949 | 2019-09-09 20:13:29 +0200 | [diff] [blame] | 5714 | m_errorMonitor->VerifyFound(); |
| 5715 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5716 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetScissor-firstScissor-00592"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5717 | vk::CmdSetScissor(m_commandBuffer->handle(), max_scissors, 1, scissors.data()); |
Petr Kraus | 14e4949 | 2019-09-09 20:13:29 +0200 | [diff] [blame] | 5718 | m_errorMonitor->VerifyFound(); |
| 5719 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5720 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetScissor-firstScissor-00592"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5721 | vk::CmdSetScissor(m_commandBuffer->handle(), 1, max_scissors, scissors.data()); |
Petr Kraus | 14e4949 | 2019-09-09 20:13:29 +0200 | [diff] [blame] | 5722 | m_errorMonitor->VerifyFound(); |
| 5723 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5724 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetScissor-scissorCount-arraylength"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5725 | vk::CmdSetScissor(m_commandBuffer->handle(), 1, 0, scissors.data()); |
Petr Kraus | 14e4949 | 2019-09-09 20:13:29 +0200 | [diff] [blame] | 5726 | m_errorMonitor->VerifyFound(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5727 | } |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5728 | } |
| 5729 | |
Tony-LunarG | 667cc02 | 2021-06-25 10:11:17 -0600 | [diff] [blame] | 5730 | TEST_F(VkLayerTest, MultiDrawTests) { |
| 5731 | TEST_DESCRIPTION("Test validation of multi_draw extension"); |
| 5732 | SetTargetApiVersion(VK_API_VERSION_1_2); |
| 5733 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
| 5734 | if (DeviceValidationVersion() < VK_API_VERSION_1_2) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 5735 | GTEST_SKIP() << "At least Vulkan version 1.2 is required"; |
Tony-LunarG | 667cc02 | 2021-06-25 10:11:17 -0600 | [diff] [blame] | 5736 | } |
| 5737 | |
| 5738 | auto multi_draw_features = LvlInitStruct<VkPhysicalDeviceMultiDrawFeaturesEXT>(); |
sjfricke | 11db0c7 | 2022-08-18 13:23:11 +0900 | [diff] [blame^] | 5739 | auto features2 = GetPhysicalDeviceFeatures2(multi_draw_features); |
Tony-LunarG | 667cc02 | 2021-06-25 10:11:17 -0600 | [diff] [blame] | 5740 | if (!multi_draw_features.multiDraw) { |
| 5741 | printf("%s Test requires (unsupported) multiDraw, skipping\n", kSkipPrefix); |
| 5742 | return; |
| 5743 | } |
| 5744 | if (DeviceExtensionSupported(gpu(), nullptr, VK_EXT_MULTI_DRAW_EXTENSION_NAME)) { |
| 5745 | m_device_extension_names.push_back(VK_EXT_MULTI_DRAW_EXTENSION_NAME); |
| 5746 | } else { |
| 5747 | printf("%s VK_EXT_multi_draw extension not supported, skipping test\n", kSkipPrefix); |
| 5748 | return; |
| 5749 | } |
| 5750 | auto multi_draw_properties = LvlInitStruct<VkPhysicalDeviceMultiDrawPropertiesEXT>(); |
| 5751 | auto properties2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&multi_draw_properties); |
sjfricke | 74a1aad | 2022-08-17 14:41:33 +0900 | [diff] [blame] | 5752 | GetPhysicalDeviceProperties2(properties2); |
Tony-LunarG | 667cc02 | 2021-06-25 10:11:17 -0600 | [diff] [blame] | 5753 | |
| 5754 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 5755 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5756 | |
| 5757 | auto vkCmdDrawMultiEXT = (PFN_vkCmdDrawMultiEXT)vk::GetDeviceProcAddr(m_device->device(), "vkCmdDrawMultiEXT"); |
| 5758 | auto vkCmdDrawMultiIndexedEXT = |
| 5759 | (PFN_vkCmdDrawMultiIndexedEXT)vk::GetDeviceProcAddr(m_device->device(), "vkCmdDrawMultiIndexedEXT"); |
| 5760 | assert(vkCmdDrawMultiEXT != nullptr && vkCmdDrawMultiIndexedEXT != nullptr); |
| 5761 | |
| 5762 | VkMultiDrawInfoEXT multi_draws[3] = {}; |
| 5763 | multi_draws[0].vertexCount = multi_draws[1].vertexCount = multi_draws[2].vertexCount = 3; |
| 5764 | |
| 5765 | VkMultiDrawIndexedInfoEXT multi_draw_indices[3] = {}; |
| 5766 | multi_draw_indices[0].indexCount = multi_draw_indices[1].indexCount = multi_draw_indices[2].indexCount = 1; |
| 5767 | |
| 5768 | CreatePipelineHelper pipe(*this); |
| 5769 | pipe.InitInfo(); |
| 5770 | pipe.InitState(); |
| 5771 | pipe.CreateGraphicsPipeline(); |
| 5772 | |
| 5773 | // Try existing VUID checks |
| 5774 | m_commandBuffer->begin(); |
| 5775 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 5776 | |
| 5777 | vk::CmdBindDescriptorSets(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_layout_.handle(), 0, 1, |
| 5778 | &pipe.descriptor_set_->set_, 0, NULL); |
| 5779 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawMultiEXT-None-02700"); |
| 5780 | vkCmdDrawMultiEXT(m_commandBuffer->handle(), 3, multi_draws, 1, 0, sizeof(VkMultiDrawInfoEXT)); |
| 5781 | m_errorMonitor->VerifyFound(); |
| 5782 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawMultiIndexedEXT-None-02700"); |
| 5783 | vkCmdDrawMultiIndexedEXT(m_commandBuffer->handle(), 3, multi_draw_indices, 1, 0, sizeof(VkMultiDrawIndexedInfoEXT), 0); |
| 5784 | m_errorMonitor->VerifyFound(); |
| 5785 | |
| 5786 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_); |
| 5787 | |
| 5788 | // New VUIDs added with multi_draw (also see GPU-AV) |
| 5789 | VkBufferObj buffer; |
| 5790 | buffer.init(*m_device, 1024, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, VK_BUFFER_USAGE_INDEX_BUFFER_BIT); |
| 5791 | multi_draw_indices[2].indexCount = 513; |
| 5792 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawMultiIndexedEXT-firstIndex-04938"); |
| 5793 | m_commandBuffer->BindIndexBuffer(&buffer, 0, VK_INDEX_TYPE_UINT16); |
| 5794 | vkCmdDrawMultiIndexedEXT(m_commandBuffer->handle(), 3, multi_draw_indices, 1, 0, sizeof(VkMultiDrawIndexedInfoEXT), 0); |
| 5795 | m_errorMonitor->VerifyFound(); |
| 5796 | multi_draw_indices[2].indexCount = 1; |
| 5797 | |
| 5798 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawMultiEXT-stride-04936"); |
| 5799 | vkCmdDrawMultiEXT(m_commandBuffer->handle(), 3, multi_draws, 1, 0, sizeof(VkMultiDrawInfoEXT) + 1); |
| 5800 | m_errorMonitor->VerifyFound(); |
| 5801 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941"); |
| 5802 | vkCmdDrawMultiIndexedEXT(m_commandBuffer->handle(), 3, multi_draw_indices, 1, 0, sizeof(VkMultiDrawIndexedInfoEXT) + 1, 0); |
| 5803 | m_errorMonitor->VerifyFound(); |
| 5804 | |
| 5805 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawMultiEXT-drawCount-04935"); |
| 5806 | vkCmdDrawMultiEXT(m_commandBuffer->handle(), 3, nullptr, 1, 0, sizeof(VkMultiDrawInfoEXT)); |
| 5807 | m_errorMonitor->VerifyFound(); |
| 5808 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940"); |
| 5809 | vkCmdDrawMultiIndexedEXT(m_commandBuffer->handle(), 3, nullptr, 1, 0, sizeof(VkMultiDrawIndexedInfoEXT), 0); |
| 5810 | m_errorMonitor->VerifyFound(); |
| 5811 | |
| 5812 | if (multi_draw_properties.maxMultiDrawCount < UINT32_MAX) { |
| 5813 | uint32_t draw_count = multi_draw_properties.maxMultiDrawCount + 1; |
| 5814 | std::vector<VkMultiDrawInfoEXT> max_multi_draws(draw_count); |
| 5815 | std::vector<VkMultiDrawIndexedInfoEXT> max_multi_indexed_draws(draw_count); |
| 5816 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawMultiEXT-drawCount-04934"); |
| 5817 | vkCmdDrawMultiEXT(m_commandBuffer->handle(), draw_count, max_multi_draws.data(), 1, 0, sizeof(VkMultiDrawInfoEXT)); |
| 5818 | m_errorMonitor->VerifyFound(); |
| 5819 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04939"); |
| 5820 | vkCmdDrawMultiIndexedEXT(m_commandBuffer->handle(), draw_count, max_multi_indexed_draws.data(), 1, 0, |
| 5821 | sizeof(VkMultiDrawIndexedInfoEXT), 0); |
| 5822 | m_errorMonitor->VerifyFound(); |
| 5823 | } |
| 5824 | } |
| 5825 | |
| 5826 | TEST_F(VkLayerTest, MultiDrawFeatures) { |
| 5827 | TEST_DESCRIPTION("Test validation of multi draw feature enabled"); |
| 5828 | SetTargetApiVersion(VK_API_VERSION_1_2); |
| 5829 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
| 5830 | if (DeviceValidationVersion() < VK_API_VERSION_1_2) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 5831 | GTEST_SKIP() << "At least Vulkan version 1.2 is required"; |
Tony-LunarG | 667cc02 | 2021-06-25 10:11:17 -0600 | [diff] [blame] | 5832 | } |
| 5833 | if (DeviceExtensionSupported(gpu(), nullptr, VK_EXT_MULTI_DRAW_EXTENSION_NAME)) { |
| 5834 | m_device_extension_names.push_back(VK_EXT_MULTI_DRAW_EXTENSION_NAME); |
| 5835 | } else { |
| 5836 | printf("%s VK_EXT_multi_draw extension not supported, skipping test\n", kSkipPrefix); |
| 5837 | return; |
| 5838 | } |
| 5839 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5840 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5841 | |
sfricke-samsung | ca16208 | 2022-02-10 08:53:41 -0800 | [diff] [blame] | 5842 | auto multi_draw_props = LvlInitStruct<VkPhysicalDeviceMultiDrawPropertiesEXT>(); |
| 5843 | auto pd_props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&multi_draw_props); |
sjfricke | 74a1aad | 2022-08-17 14:41:33 +0900 | [diff] [blame] | 5844 | GetPhysicalDeviceProperties2(pd_props2); |
sfricke-samsung | ca16208 | 2022-02-10 08:53:41 -0800 | [diff] [blame] | 5845 | if (multi_draw_props.maxMultiDrawCount == 0) { |
| 5846 | // If using MockICD and devsim the value might be zero'ed and cause false errors |
| 5847 | return; |
| 5848 | } |
| 5849 | |
Tony-LunarG | 667cc02 | 2021-06-25 10:11:17 -0600 | [diff] [blame] | 5850 | auto vkCmdDrawMultiEXT = (PFN_vkCmdDrawMultiEXT)vk::GetDeviceProcAddr(m_device->device(), "vkCmdDrawMultiEXT"); |
| 5851 | auto vkCmdDrawMultiIndexedEXT = |
| 5852 | (PFN_vkCmdDrawMultiIndexedEXT)vk::GetDeviceProcAddr(m_device->device(), "vkCmdDrawMultiIndexedEXT"); |
| 5853 | assert(vkCmdDrawMultiEXT != nullptr && vkCmdDrawMultiIndexedEXT != nullptr); |
| 5854 | |
| 5855 | VkMultiDrawInfoEXT multi_draws[3] = {}; |
| 5856 | multi_draws[0].vertexCount = multi_draws[1].vertexCount = multi_draws[2].vertexCount = 3; |
| 5857 | |
| 5858 | VkMultiDrawIndexedInfoEXT multi_draw_indices[3] = {}; |
| 5859 | multi_draw_indices[0].indexCount = multi_draw_indices[1].indexCount = multi_draw_indices[2].indexCount = 1; |
| 5860 | |
| 5861 | CreatePipelineHelper pipe(*this); |
| 5862 | pipe.InitInfo(); |
| 5863 | pipe.InitState(); |
| 5864 | pipe.CreateGraphicsPipeline(); |
| 5865 | |
| 5866 | m_commandBuffer->begin(); |
| 5867 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_); |
| 5868 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 5869 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawMultiEXT-None-04933"); |
| 5870 | vkCmdDrawMultiEXT(m_commandBuffer->handle(), 3, multi_draws, 1, 0, sizeof(VkMultiDrawInfoEXT)); |
| 5871 | m_errorMonitor->VerifyFound(); |
| 5872 | VkBufferObj buffer; |
| 5873 | buffer.init(*m_device, 1024, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, VK_BUFFER_USAGE_INDEX_BUFFER_BIT); |
| 5874 | m_commandBuffer->BindIndexBuffer(&buffer, 0, VK_INDEX_TYPE_UINT16); |
| 5875 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawMultiIndexedEXT-None-04937"); |
| 5876 | vkCmdDrawMultiIndexedEXT(m_commandBuffer->handle(), 3, multi_draw_indices, 1, 0, sizeof(VkMultiDrawIndexedInfoEXT), 0); |
| 5877 | m_errorMonitor->VerifyFound(); |
| 5878 | } |
| 5879 | |
Mark Lobodzinski | 128608f | 2020-11-02 13:46:57 -0700 | [diff] [blame] | 5880 | TEST_F(VkLayerTest, IndirectDrawTests) { |
| 5881 | TEST_DESCRIPTION("Test covered valid usage for vkCmdDrawIndirect and vkCmdDrawIndexedIndirect"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5882 | |
sjfricke | d8e01c5 | 2022-07-06 14:09:04 +0900 | [diff] [blame] | 5883 | AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
Mark Lobodzinski | 128608f | 2020-11-02 13:46:57 -0700 | [diff] [blame] | 5884 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
| 5885 | |
| 5886 | if (IsPlatform(kMockICD) || DeviceSimulation()) { |
sjfricke | 11b2469 | 2022-06-21 20:49:53 +0900 | [diff] [blame] | 5887 | GTEST_SKIP() << "Test not supported by MockICD"; |
Mark Lobodzinski | 128608f | 2020-11-02 13:46:57 -0700 | [diff] [blame] | 5888 | } |
sjfricke | d8e01c5 | 2022-07-06 14:09:04 +0900 | [diff] [blame] | 5889 | if (!AreRequiredExtensionsEnabled()) { |
| 5890 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
| 5891 | } |
Aaron Hagan | d1a6121 | 2021-12-22 11:53:49 -0500 | [diff] [blame] | 5892 | ASSERT_NO_FATAL_FAILURE(InitState()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5893 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5894 | |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 5895 | CreatePipelineHelper pipe(*this); |
| 5896 | pipe.InitInfo(); |
| 5897 | const VkDynamicState dyn_states[] = {VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR}; |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 5898 | VkPipelineDynamicStateCreateInfo dyn_state_ci = LvlInitStruct<VkPipelineDynamicStateCreateInfo>(); |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 5899 | dyn_state_ci.dynamicStateCount = size(dyn_states); |
| 5900 | dyn_state_ci.pDynamicStates = dyn_states; |
| 5901 | pipe.dyn_state_ci_ = dyn_state_ci; |
| 5902 | pipe.InitState(); |
| 5903 | pipe.CreateGraphicsPipeline(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5904 | |
| 5905 | m_commandBuffer->begin(); |
| 5906 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 5907 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5908 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_); |
| 5909 | vk::CmdBindDescriptorSets(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_layout_.handle(), 0, 1, |
| 5910 | &pipe.descriptor_set_->set_, 0, NULL); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5911 | |
| 5912 | VkViewport viewport = {0, 0, 16, 16, 0, 1}; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5913 | vk::CmdSetViewport(m_commandBuffer->handle(), 0, 1, &viewport); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5914 | VkRect2D scissor = {{0, 0}, {16, 16}}; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5915 | vk::CmdSetScissor(m_commandBuffer->handle(), 0, 1, &scissor); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5916 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 5917 | VkBufferCreateInfo buffer_create_info = LvlInitStruct<VkBufferCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5918 | buffer_create_info.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT; |
| 5919 | buffer_create_info.size = sizeof(VkDrawIndirectCommand); |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 5920 | VkBufferObj draw_buffer; |
| 5921 | draw_buffer.init(*m_device, buffer_create_info); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5922 | |
Aaron Hagan | d1a6121 | 2021-12-22 11:53:49 -0500 | [diff] [blame] | 5923 | VkBufferObj draw_buffer_correct; |
| 5924 | buffer_create_info.usage = VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT; |
| 5925 | draw_buffer_correct.init(*m_device, buffer_create_info); |
| 5926 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5927 | // VUID-vkCmdDrawIndirect-buffer-02709 |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5928 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndirect-buffer-02709"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 5929 | vk::CmdDrawIndirect(m_commandBuffer->handle(), draw_buffer.handle(), 0, 1, sizeof(VkDrawIndirectCommand)); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5930 | m_errorMonitor->VerifyFound(); |
| 5931 | |
Mark Lobodzinski | 128608f | 2020-11-02 13:46:57 -0700 | [diff] [blame] | 5932 | // VUID-vkCmdDrawIndirect-drawCount-02718 |
Aaron Hagan | d1a6121 | 2021-12-22 11:53:49 -0500 | [diff] [blame] | 5933 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndirect-drawCount-00488"); |
| 5934 | vk::CmdDrawIndirect(m_commandBuffer->handle(), draw_buffer_correct.handle(), 0, 2, sizeof(VkDrawIndirectCommand)); |
Mark Lobodzinski | 128608f | 2020-11-02 13:46:57 -0700 | [diff] [blame] | 5935 | m_errorMonitor->VerifyFound(); |
| 5936 | |
Aaron Hagan | d1a6121 | 2021-12-22 11:53:49 -0500 | [diff] [blame] | 5937 | // VUID-vkCmdDrawIndexedIndirect-commandBuffer-02701 |
| 5938 | // VUID-vkCmdDrawIndexedIndirect-drawCount-00540 |
| 5939 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndexedIndirect-commandBuffer-02701"); |
| 5940 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndexedIndirect-drawCount-00540"); |
| 5941 | vk::CmdDrawIndexedIndirect(m_commandBuffer->handle(), draw_buffer_correct.handle(), 0, 2, sizeof(VkDrawIndexedIndirectCommand)); |
Mark Lobodzinski | 128608f | 2020-11-02 13:46:57 -0700 | [diff] [blame] | 5942 | m_errorMonitor->VerifyFound(); |
| 5943 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5944 | m_commandBuffer->EndRenderPass(); |
| 5945 | m_commandBuffer->end(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 5946 | } |
| 5947 | |
Mark Lobodzinski | 977f034 | 2019-12-19 14:24:09 -0700 | [diff] [blame] | 5948 | TEST_F(VkLayerTest, DrawIndirectByteCountEXT) { |
| 5949 | TEST_DESCRIPTION("Test covered valid usage for vkCmdDrawIndirectByteCountEXT"); |
| 5950 | |
sjfricke | d8e01c5 | 2022-07-06 14:09:04 +0900 | [diff] [blame] | 5951 | AddRequiredExtensions(VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME); |
| 5952 | |
Mark Lobodzinski | 09ce9c4 | 2020-03-06 10:02:44 -0700 | [diff] [blame] | 5953 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
Mark Lobodzinski | 977f034 | 2019-12-19 14:24:09 -0700 | [diff] [blame] | 5954 | |
sjfricke | d8e01c5 | 2022-07-06 14:09:04 +0900 | [diff] [blame] | 5955 | if (!AreRequiredExtensionsEnabled()) { |
| 5956 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
Mark Lobodzinski | 977f034 | 2019-12-19 14:24:09 -0700 | [diff] [blame] | 5957 | } |
| 5958 | |
| 5959 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5960 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5961 | |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 5962 | auto tf_properties = LvlInitStruct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>(); |
| 5963 | auto pd_properties = LvlInitStruct<VkPhysicalDeviceProperties2>(&tf_properties); |
sjfricke | 74a1aad | 2022-08-17 14:41:33 +0900 | [diff] [blame] | 5964 | GetPhysicalDeviceProperties2(pd_properties); |
sfricke-samsung | d5e9adb | 2020-10-26 03:59:29 -0700 | [diff] [blame] | 5965 | |
Mark Lobodzinski | 977f034 | 2019-12-19 14:24:09 -0700 | [diff] [blame] | 5966 | PFN_vkCmdDrawIndirectByteCountEXT fpvkCmdDrawIndirectByteCountEXT = |
| 5967 | (PFN_vkCmdDrawIndirectByteCountEXT)vk::GetDeviceProcAddr(device(), "vkCmdDrawIndirectByteCountEXT"); |
| 5968 | |
| 5969 | m_commandBuffer->begin(); |
| 5970 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 5971 | VkBufferCreateInfo buffer_create_info = LvlInitStruct<VkBufferCreateInfo>(); |
Mark Lobodzinski | 977f034 | 2019-12-19 14:24:09 -0700 | [diff] [blame] | 5972 | buffer_create_info.usage = VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT; |
| 5973 | buffer_create_info.size = 1024; |
| 5974 | VkBufferObj counter_buffer; |
| 5975 | counter_buffer.init(*m_device, buffer_create_info); |
| 5976 | |
sfricke-samsung | d5e9adb | 2020-10-26 03:59:29 -0700 | [diff] [blame] | 5977 | // Greater stride than maxTransformFeedbackBufferDataStride |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 5978 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289"); |
sfricke-samsung | d5e9adb | 2020-10-26 03:59:29 -0700 | [diff] [blame] | 5979 | fpvkCmdDrawIndirectByteCountEXT(m_commandBuffer->handle(), 1, 0, counter_buffer.handle(), 0, 0, 0xCADECADE); |
Mark Lobodzinski | 977f034 | 2019-12-19 14:24:09 -0700 | [diff] [blame] | 5980 | m_errorMonitor->VerifyFound(); |
| 5981 | |
sfricke-samsung | d5e9adb | 2020-10-26 03:59:29 -0700 | [diff] [blame] | 5982 | // some mock ICD json files are missing a valid stride value |
| 5983 | if (tf_properties.maxTransformFeedbackBufferDataStride > 0) { |
| 5984 | // non-4 multiple stride |
sfricke-samsung | 6886c4b | 2021-01-16 08:37:35 -0800 | [diff] [blame] | 5985 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568"); |
sfricke-samsung | d5e9adb | 2020-10-26 03:59:29 -0700 | [diff] [blame] | 5986 | fpvkCmdDrawIndirectByteCountEXT(m_commandBuffer->handle(), 1, 0, counter_buffer.handle(), 0, 1, 4); |
| 5987 | m_errorMonitor->VerifyFound(); |
| 5988 | } |
| 5989 | |
Mark Lobodzinski | 977f034 | 2019-12-19 14:24:09 -0700 | [diff] [blame] | 5990 | m_commandBuffer->EndRenderPass(); |
| 5991 | m_commandBuffer->end(); |
Tony-LunarG | 983bbc5 | 2020-11-06 11:04:59 -0700 | [diff] [blame] | 5992 | |
| 5993 | if (!tf_properties.maxTransformFeedbackBufferDataStride) { |
Nathaniel Cesario | 13da77b | 2022-07-15 14:51:12 -0600 | [diff] [blame] | 5994 | GTEST_SKIP() << "maxTransformFeedbackBufferDataStride is zero, skipping subtests"; |
Tony-LunarG | 983bbc5 | 2020-11-06 11:04:59 -0700 | [diff] [blame] | 5995 | } |
| 5996 | |
| 5997 | std::vector<const char *> device_extension_names; |
| 5998 | device_extension_names.push_back(VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME); |
| 5999 | VkDeviceObj test_device(0, gpu(), device_extension_names); |
| 6000 | VkCommandPoolObj commandPool(&test_device, 0); |
| 6001 | VkCommandBufferObj commandBuffer(&test_device, &commandPool); |
| 6002 | VkBufferObj counter_buffer2; |
| 6003 | counter_buffer2.init(test_device, buffer_create_info); |
Nathaniel Cesario | 13da77b | 2022-07-15 14:51:12 -0600 | [diff] [blame] | 6004 | |
Tony-LunarG | 983bbc5 | 2020-11-06 11:04:59 -0700 | [diff] [blame] | 6005 | VkPipelineLayoutObj pipelineLayout(&test_device); |
Nathaniel Cesario | 13da77b | 2022-07-15 14:51:12 -0600 | [diff] [blame] | 6006 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 6007 | VkRenderPassCreateInfo rp_info = LvlInitStruct<VkRenderPassCreateInfo>(); |
Tony-LunarG | 983bbc5 | 2020-11-06 11:04:59 -0700 | [diff] [blame] | 6008 | VkSubpassDescription subpass = {}; |
Tony-LunarG | 983bbc5 | 2020-11-06 11:04:59 -0700 | [diff] [blame] | 6009 | rp_info.pSubpasses = &subpass; |
| 6010 | rp_info.subpassCount = 1; |
Nathaniel Cesario | 13da77b | 2022-07-15 14:51:12 -0600 | [diff] [blame] | 6011 | vk_testing::RenderPass renderpass(test_device, rp_info); |
| 6012 | ASSERT_TRUE(renderpass.handle()); |
| 6013 | |
Tony-LunarG | 983bbc5 | 2020-11-06 11:04:59 -0700 | [diff] [blame] | 6014 | VkPipelineObj pipeline(&test_device); |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 6015 | VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, SPV_ENV_VULKAN_1_0, SPV_SOURCE_GLSL_TRY); |
Nathaniel Cesario | 13da77b | 2022-07-15 14:51:12 -0600 | [diff] [blame] | 6016 | VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, SPV_ENV_VULKAN_1_0, SPV_SOURCE_GLSL_TRY); |
sjfricke | 394227a | 2022-06-20 16:47:38 +0900 | [diff] [blame] | 6017 | vs.InitFromGLSLTry(false, &test_device); |
Nathaniel Cesario | 13da77b | 2022-07-15 14:51:12 -0600 | [diff] [blame] | 6018 | fs.InitFromGLSLTry(false, &test_device); |
Tony-LunarG | 983bbc5 | 2020-11-06 11:04:59 -0700 | [diff] [blame] | 6019 | pipeline.AddShader(&vs); |
Nathaniel Cesario | 13da77b | 2022-07-15 14:51:12 -0600 | [diff] [blame] | 6020 | pipeline.AddShader(&fs); |
| 6021 | pipeline.CreateVKPipeline(pipelineLayout.handle(), renderpass.handle()); |
| 6022 | m_renderPassBeginInfo.renderPass = renderpass.handle(); |
| 6023 | VkFramebufferCreateInfo fbci = { |
| 6024 | VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, nullptr, 0, renderpass.handle(), 0, nullptr, 256, 256, 1}; |
| 6025 | vk_testing::Framebuffer fb(test_device, fbci); |
| 6026 | ASSERT_TRUE(fb.initialized()); |
| 6027 | m_renderPassBeginInfo.framebuffer = fb.handle(); |
| 6028 | m_renderPassBeginInfo.renderPass = renderpass.handle(); |
Tony-LunarG | 983bbc5 | 2020-11-06 11:04:59 -0700 | [diff] [blame] | 6029 | commandBuffer.begin(); |
| 6030 | VkViewport viewport = {0, 0, 16, 16, 0, 1}; |
| 6031 | vk::CmdSetViewport(commandBuffer.handle(), 0, 1, &viewport); |
| 6032 | VkRect2D scissor = {{0, 0}, {16, 16}}; |
| 6033 | vk::CmdSetScissor(commandBuffer.handle(), 0, 1, &scissor); |
| 6034 | vk::CmdBindPipeline(commandBuffer.handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline.handle()); |
| 6035 | commandBuffer.BeginRenderPass(m_renderPassBeginInfo); |
| 6036 | if (!tf_properties.transformFeedbackDraw) { |
sfricke-samsung | ba459bd | 2020-12-06 23:20:04 -0800 | [diff] [blame] | 6037 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndirectByteCountEXT-transformFeedbackDraw-02288"); |
Tony-LunarG | 983bbc5 | 2020-11-06 11:04:59 -0700 | [diff] [blame] | 6038 | } |
| 6039 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndirectByteCountEXT-transformFeedback-02287"); |
| 6040 | fpvkCmdDrawIndirectByteCountEXT(commandBuffer.handle(), 1, 0, counter_buffer2.handle(), 0, 0, 1); |
| 6041 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 977f034 | 2019-12-19 14:24:09 -0700 | [diff] [blame] | 6042 | } |
| 6043 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6044 | TEST_F(VkLayerTest, DrawIndirectCountKHR) { |
| 6045 | TEST_DESCRIPTION("Test covered valid usage for vkCmdDrawIndirectCountKHR"); |
| 6046 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6047 | AddRequiredExtensions(VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME); |
| 6048 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 6049 | if (!AreRequiredExtensionsEnabled()) { |
| 6050 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported."; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6051 | } |
| 6052 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6053 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6054 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6055 | auto vkCmdDrawIndirectCountKHR = |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6056 | (PFN_vkCmdDrawIndirectCountKHR)vk::GetDeviceProcAddr(m_device->device(), "vkCmdDrawIndirectCountKHR"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6057 | |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 6058 | CreatePipelineHelper pipe(*this); |
| 6059 | pipe.InitInfo(); |
| 6060 | const VkDynamicState dyn_states[] = {VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR}; |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 6061 | VkPipelineDynamicStateCreateInfo dyn_state_ci = LvlInitStruct<VkPipelineDynamicStateCreateInfo>(); |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 6062 | dyn_state_ci.dynamicStateCount = size(dyn_states); |
| 6063 | dyn_state_ci.pDynamicStates = dyn_states; |
| 6064 | pipe.dyn_state_ci_ = dyn_state_ci; |
| 6065 | pipe.InitState(); |
| 6066 | pipe.CreateGraphicsPipeline(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6067 | |
| 6068 | m_commandBuffer->begin(); |
| 6069 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 6070 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6071 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_); |
| 6072 | vk::CmdBindDescriptorSets(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_layout_.handle(), 0, 1, |
| 6073 | &pipe.descriptor_set_->set_, 0, NULL); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6074 | |
| 6075 | VkViewport viewport = {0, 0, 16, 16, 0, 1}; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6076 | vk::CmdSetViewport(m_commandBuffer->handle(), 0, 1, &viewport); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6077 | VkRect2D scissor = {{0, 0}, {16, 16}}; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6078 | vk::CmdSetScissor(m_commandBuffer->handle(), 0, 1, &scissor); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6079 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 6080 | VkBufferCreateInfo buffer_create_info = LvlInitStruct<VkBufferCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6081 | buffer_create_info.size = sizeof(VkDrawIndirectCommand); |
| 6082 | buffer_create_info.usage = VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6083 | vk_testing::Buffer draw_buffer; |
| 6084 | draw_buffer.init_no_mem(*m_device, buffer_create_info); |
| 6085 | ASSERT_TRUE(draw_buffer.initialized()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6086 | |
sjfricke | edd669c | 2022-06-02 17:37:19 +0900 | [diff] [blame] | 6087 | VkDeviceSize count_buffer_size = 128; |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 6088 | VkBufferCreateInfo count_buffer_create_info = LvlInitStruct<VkBufferCreateInfo>(); |
sjfricke | edd669c | 2022-06-02 17:37:19 +0900 | [diff] [blame] | 6089 | count_buffer_create_info.size = count_buffer_size; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6090 | count_buffer_create_info.usage = VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT; |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 6091 | VkBufferObj count_buffer; |
| 6092 | count_buffer.init(*m_device, count_buffer_create_info); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6093 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6094 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndirectCount-buffer-02708"); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6095 | vkCmdDrawIndirectCountKHR(m_commandBuffer->handle(), draw_buffer.handle(), 0, count_buffer.handle(), 0, 1, |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 6096 | sizeof(VkDrawIndirectCommand)); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6097 | m_errorMonitor->VerifyFound(); |
| 6098 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6099 | draw_buffer.bind_memory(*m_device, 0, 0); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6100 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6101 | vk_testing::Buffer count_buffer_unbound; |
| 6102 | count_buffer_unbound.init_no_mem(*m_device, count_buffer_create_info); |
| 6103 | ASSERT_TRUE(count_buffer_unbound.initialized()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6104 | |
sjfricke | edd669c | 2022-06-02 17:37:19 +0900 | [diff] [blame] | 6105 | VkBufferObj count_buffer_wrong; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6106 | count_buffer_create_info.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
sjfricke | edd669c | 2022-06-02 17:37:19 +0900 | [diff] [blame] | 6107 | count_buffer_wrong.init(*m_device, count_buffer_create_info); |
| 6108 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6109 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndirectCount-countBuffer-02714"); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6110 | vkCmdDrawIndirectCountKHR(m_commandBuffer->handle(), draw_buffer.handle(), 0, count_buffer_unbound.handle(), 0, 1, |
| 6111 | sizeof(VkDrawIndirectCommand)); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6112 | m_errorMonitor->VerifyFound(); |
| 6113 | |
sjfricke | edd669c | 2022-06-02 17:37:19 +0900 | [diff] [blame] | 6114 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, " VUID-vkCmdDrawIndirectCount-countBuffer-02715"); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6115 | vkCmdDrawIndirectCountKHR(m_commandBuffer->handle(), draw_buffer.handle(), 0, count_buffer_wrong.handle(), 0, 1, |
sjfricke | edd669c | 2022-06-02 17:37:19 +0900 | [diff] [blame] | 6116 | sizeof(VkDrawIndirectCommand)); |
| 6117 | m_errorMonitor->VerifyFound(); |
| 6118 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6119 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndirectCount-offset-02710"); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6120 | vkCmdDrawIndirectCountKHR(m_commandBuffer->handle(), draw_buffer.handle(), 1, count_buffer.handle(), 0, 1, |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 6121 | sizeof(VkDrawIndirectCommand)); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6122 | m_errorMonitor->VerifyFound(); |
| 6123 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6124 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716"); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6125 | vkCmdDrawIndirectCountKHR(m_commandBuffer->handle(), draw_buffer.handle(), 0, count_buffer.handle(), 1, 1, |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 6126 | sizeof(VkDrawIndirectCommand)); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6127 | m_errorMonitor->VerifyFound(); |
| 6128 | |
sjfricke | edd669c | 2022-06-02 17:37:19 +0900 | [diff] [blame] | 6129 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndirectCount-countBufferOffset-04129"); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6130 | vkCmdDrawIndirectCountKHR(m_commandBuffer->handle(), draw_buffer.handle(), 0, count_buffer.handle(), count_buffer_size, 1, |
sjfricke | edd669c | 2022-06-02 17:37:19 +0900 | [diff] [blame] | 6131 | sizeof(VkDrawIndirectCommand)); |
| 6132 | m_errorMonitor->VerifyFound(); |
| 6133 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6134 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndirectCount-stride-03110"); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6135 | vkCmdDrawIndirectCountKHR(m_commandBuffer->handle(), draw_buffer.handle(), 0, count_buffer.handle(), 0, 1, 1); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6136 | m_errorMonitor->VerifyFound(); |
| 6137 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6138 | m_commandBuffer->EndRenderPass(); |
| 6139 | m_commandBuffer->end(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6140 | } |
| 6141 | |
| 6142 | TEST_F(VkLayerTest, DrawIndexedIndirectCountKHR) { |
| 6143 | TEST_DESCRIPTION("Test covered valid usage for vkCmdDrawIndexedIndirectCountKHR"); |
| 6144 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6145 | AddRequiredExtensions(VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME); |
Mark Lobodzinski | 09ce9c4 | 2020-03-06 10:02:44 -0700 | [diff] [blame] | 6146 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6147 | if (!AreRequiredExtensionsEnabled()) { |
| 6148 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported."; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6149 | } |
| 6150 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6151 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6152 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6153 | auto vkCmdDrawIndexedIndirectCountKHR = |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6154 | (PFN_vkCmdDrawIndexedIndirectCountKHR)vk::GetDeviceProcAddr(m_device->device(), "vkCmdDrawIndexedIndirectCountKHR"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6155 | |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 6156 | CreatePipelineHelper pipe(*this); |
| 6157 | pipe.InitInfo(); |
| 6158 | const VkDynamicState dyn_states[] = {VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR}; |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 6159 | VkPipelineDynamicStateCreateInfo dyn_state_ci = LvlInitStruct<VkPipelineDynamicStateCreateInfo>(); |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 6160 | dyn_state_ci.dynamicStateCount = size(dyn_states); |
| 6161 | dyn_state_ci.pDynamicStates = dyn_states; |
| 6162 | pipe.dyn_state_ci_ = dyn_state_ci; |
| 6163 | pipe.InitState(); |
| 6164 | pipe.CreateGraphicsPipeline(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6165 | |
| 6166 | m_commandBuffer->begin(); |
| 6167 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 6168 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6169 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_); |
| 6170 | vk::CmdBindDescriptorSets(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_layout_.handle(), 0, 1, |
| 6171 | &pipe.descriptor_set_->set_, 0, NULL); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6172 | |
| 6173 | VkViewport viewport = {0, 0, 16, 16, 0, 1}; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6174 | vk::CmdSetViewport(m_commandBuffer->handle(), 0, 1, &viewport); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6175 | VkRect2D scissor = {{0, 0}, {16, 16}}; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6176 | vk::CmdSetScissor(m_commandBuffer->handle(), 0, 1, &scissor); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6177 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 6178 | VkBufferCreateInfo buffer_create_info = LvlInitStruct<VkBufferCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6179 | buffer_create_info.size = sizeof(VkDrawIndexedIndirectCommand); |
| 6180 | buffer_create_info.usage = VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT; |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 6181 | VkBufferObj draw_buffer; |
| 6182 | draw_buffer.init(*m_device, buffer_create_info); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6183 | |
sjfricke | edd669c | 2022-06-02 17:37:19 +0900 | [diff] [blame] | 6184 | VkDeviceSize count_buffer_size = 128; |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 6185 | VkBufferCreateInfo count_buffer_create_info = LvlInitStruct<VkBufferCreateInfo>(); |
sjfricke | edd669c | 2022-06-02 17:37:19 +0900 | [diff] [blame] | 6186 | count_buffer_create_info.size = count_buffer_size; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6187 | count_buffer_create_info.usage = VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT; |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 6188 | VkBufferObj count_buffer; |
| 6189 | count_buffer.init(*m_device, count_buffer_create_info); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6190 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 6191 | VkBufferCreateInfo index_buffer_create_info = LvlInitStruct<VkBufferCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6192 | index_buffer_create_info.size = sizeof(uint32_t); |
| 6193 | index_buffer_create_info.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 6194 | VkBufferObj index_buffer; |
| 6195 | index_buffer.init(*m_device, index_buffer_create_info); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6196 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6197 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndexedIndirectCount-commandBuffer-02701"); |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 6198 | vkCmdDrawIndexedIndirectCountKHR(m_commandBuffer->handle(), draw_buffer.handle(), 0, count_buffer.handle(), 0, 1, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6199 | sizeof(VkDrawIndexedIndirectCommand)); |
| 6200 | m_errorMonitor->VerifyFound(); |
| 6201 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6202 | vk::CmdBindIndexBuffer(m_commandBuffer->handle(), index_buffer.handle(), 0, VK_INDEX_TYPE_UINT32); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6203 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6204 | vk_testing::Buffer draw_buffer_unbound; |
| 6205 | draw_buffer_unbound.init_no_mem(*m_device, count_buffer_create_info); |
| 6206 | ASSERT_TRUE(draw_buffer_unbound.initialized()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6207 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6208 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndexedIndirectCount-buffer-02708"); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6209 | vkCmdDrawIndexedIndirectCountKHR(m_commandBuffer->handle(), draw_buffer_unbound.handle(), 0, count_buffer.handle(), 0, 1, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6210 | sizeof(VkDrawIndexedIndirectCommand)); |
| 6211 | m_errorMonitor->VerifyFound(); |
| 6212 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6213 | vk_testing::Buffer count_buffer_unbound; |
| 6214 | count_buffer_unbound.init_no_mem(*m_device, count_buffer_create_info); |
| 6215 | ASSERT_TRUE(count_buffer_unbound.initialized()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6216 | |
sjfricke | edd669c | 2022-06-02 17:37:19 +0900 | [diff] [blame] | 6217 | VkBufferObj count_buffer_wrong; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6218 | count_buffer_create_info.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
sjfricke | edd669c | 2022-06-02 17:37:19 +0900 | [diff] [blame] | 6219 | count_buffer_wrong.init(*m_device, count_buffer_create_info); |
| 6220 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6221 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndexedIndirectCount-countBuffer-02714"); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6222 | vkCmdDrawIndexedIndirectCountKHR(m_commandBuffer->handle(), draw_buffer.handle(), 0, count_buffer_unbound.handle(), 0, 1, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6223 | sizeof(VkDrawIndexedIndirectCommand)); |
| 6224 | m_errorMonitor->VerifyFound(); |
| 6225 | |
sjfricke | edd669c | 2022-06-02 17:37:19 +0900 | [diff] [blame] | 6226 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndexedIndirectCount-countBuffer-02715"); |
| 6227 | vkCmdDrawIndexedIndirectCountKHR(m_commandBuffer->handle(), draw_buffer.handle(), 0, count_buffer_wrong.handle(), 0, 1, |
| 6228 | sizeof(VkDrawIndexedIndirectCommand)); |
| 6229 | m_errorMonitor->VerifyFound(); |
| 6230 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6231 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710"); |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 6232 | vkCmdDrawIndexedIndirectCountKHR(m_commandBuffer->handle(), draw_buffer.handle(), 1, count_buffer.handle(), 0, 1, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6233 | sizeof(VkDrawIndexedIndirectCommand)); |
| 6234 | m_errorMonitor->VerifyFound(); |
| 6235 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6236 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716"); |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 6237 | vkCmdDrawIndexedIndirectCountKHR(m_commandBuffer->handle(), draw_buffer.handle(), 0, count_buffer.handle(), 1, 1, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6238 | sizeof(VkDrawIndexedIndirectCommand)); |
| 6239 | m_errorMonitor->VerifyFound(); |
| 6240 | |
sjfricke | edd669c | 2022-06-02 17:37:19 +0900 | [diff] [blame] | 6241 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-04129"); |
| 6242 | vkCmdDrawIndexedIndirectCountKHR(m_commandBuffer->handle(), draw_buffer.handle(), 0, count_buffer.handle(), count_buffer_size, |
| 6243 | 1, sizeof(VkDrawIndexedIndirectCommand)); |
| 6244 | m_errorMonitor->VerifyFound(); |
| 6245 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6246 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndexedIndirectCount-stride-03142"); |
locke-lunarg | 8e2c91b | 2019-06-11 17:53:26 -0600 | [diff] [blame] | 6247 | vkCmdDrawIndexedIndirectCountKHR(m_commandBuffer->handle(), draw_buffer.handle(), 0, count_buffer.handle(), 0, 1, 1); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6248 | m_errorMonitor->VerifyFound(); |
| 6249 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6250 | m_commandBuffer->EndRenderPass(); |
| 6251 | m_commandBuffer->end(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6252 | } |
| 6253 | |
sfricke-samsung | 860d3b2 | 2020-05-04 21:08:29 -0700 | [diff] [blame] | 6254 | TEST_F(VkLayerTest, DrawIndirectCountFeature) { |
| 6255 | TEST_DESCRIPTION("Test covered valid usage for the 1.2 drawIndirectCount feature"); |
| 6256 | |
| 6257 | SetTargetApiVersion(VK_API_VERSION_1_2); |
| 6258 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 6259 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6260 | if (DeviceValidationVersion() < VK_API_VERSION_1_2) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 6261 | GTEST_SKIP() << "At least Vulkan version 1.2 is required"; |
sfricke-samsung | 860d3b2 | 2020-05-04 21:08:29 -0700 | [diff] [blame] | 6262 | } |
| 6263 | |
| 6264 | VkBufferObj indirect_buffer; |
| 6265 | indirect_buffer.init(*m_device, sizeof(VkDrawIndirectCommand), VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, |
| 6266 | VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT); |
| 6267 | |
| 6268 | VkBufferObj indexed_indirect_buffer; |
| 6269 | indexed_indirect_buffer.init(*m_device, sizeof(VkDrawIndexedIndirectCommand), VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, |
| 6270 | VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT); |
| 6271 | |
| 6272 | VkBufferObj count_buffer; |
| 6273 | count_buffer.init(*m_device, sizeof(uint32_t), VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT); |
| 6274 | |
| 6275 | VkBufferObj index_buffer; |
| 6276 | index_buffer.init(*m_device, sizeof(uint32_t), VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, VK_BUFFER_USAGE_INDEX_BUFFER_BIT); |
| 6277 | |
| 6278 | CreatePipelineHelper pipe(*this); |
| 6279 | pipe.InitInfo(); |
| 6280 | pipe.InitState(); |
| 6281 | pipe.CreateGraphicsPipeline(); |
| 6282 | |
| 6283 | // Make calls to valid commands but without the drawIndirectCount feature set |
| 6284 | m_commandBuffer->begin(); |
| 6285 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 6286 | |
| 6287 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_); |
| 6288 | |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 6289 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndirectCount-None-04445"); |
sfricke-samsung | 860d3b2 | 2020-05-04 21:08:29 -0700 | [diff] [blame] | 6290 | vk::CmdDrawIndirectCount(m_commandBuffer->handle(), indirect_buffer.handle(), 0, count_buffer.handle(), 0, 1, |
| 6291 | sizeof(VkDrawIndirectCommand)); |
| 6292 | m_errorMonitor->VerifyFound(); |
| 6293 | |
| 6294 | vk::CmdBindIndexBuffer(m_commandBuffer->handle(), index_buffer.handle(), 0, VK_INDEX_TYPE_UINT32); |
| 6295 | |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 6296 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndexedIndirectCount-None-04445"); |
sfricke-samsung | 860d3b2 | 2020-05-04 21:08:29 -0700 | [diff] [blame] | 6297 | vk::CmdDrawIndexedIndirectCount(m_commandBuffer->handle(), indexed_indirect_buffer.handle(), 0, count_buffer.handle(), 0, 1, |
| 6298 | sizeof(VkDrawIndexedIndirectCommand)); |
| 6299 | m_errorMonitor->VerifyFound(); |
| 6300 | |
| 6301 | m_commandBuffer->EndRenderPass(); |
| 6302 | m_commandBuffer->end(); |
| 6303 | } |
| 6304 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6305 | TEST_F(VkLayerTest, ExclusiveScissorNV) { |
| 6306 | TEST_DESCRIPTION("Test VK_NV_scissor_exclusive with multiViewport disabled."); |
| 6307 | |
| 6308 | if (InstanceExtensionSupported(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME)) { |
| 6309 | m_instance_extension_names.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 6310 | } else { |
| 6311 | printf("%s Did not find required instance extension %s; skipped.\n", kSkipPrefix, |
| 6312 | VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 6313 | return; |
| 6314 | } |
Mark Lobodzinski | 09ce9c4 | 2020-03-06 10:02:44 -0700 | [diff] [blame] | 6315 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6316 | std::array<const char *, 1> required_device_extensions = {{VK_NV_SCISSOR_EXCLUSIVE_EXTENSION_NAME}}; |
| 6317 | for (auto device_extension : required_device_extensions) { |
| 6318 | if (DeviceExtensionSupported(gpu(), nullptr, device_extension)) { |
| 6319 | m_device_extension_names.push_back(device_extension); |
| 6320 | } else { |
| 6321 | printf("%s %s Extension not supported, skipping tests\n", kSkipPrefix, device_extension); |
| 6322 | return; |
| 6323 | } |
| 6324 | } |
| 6325 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6326 | // Create a device that enables exclusive scissor but disables multiViewport |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 6327 | auto exclusive_scissor_features = LvlInitStruct<VkPhysicalDeviceExclusiveScissorFeaturesNV>(); |
sjfricke | 11db0c7 | 2022-08-18 13:23:11 +0900 | [diff] [blame^] | 6328 | auto features2 = GetPhysicalDeviceFeatures2(exclusive_scissor_features); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6329 | features2.features.multiViewport = VK_FALSE; |
| 6330 | |
| 6331 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 6332 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6333 | |
| 6334 | if (m_device->phy().properties().limits.maxViewports) { |
| 6335 | printf("%s Device doesn't support the necessary number of viewports, skipping test.\n", kSkipPrefix); |
| 6336 | return; |
| 6337 | } |
| 6338 | |
| 6339 | // Based on PSOViewportStateTests |
| 6340 | { |
| 6341 | VkViewport viewport = {0.0f, 0.0f, 64.0f, 64.0f, 0.0f, 1.0f}; |
| 6342 | VkViewport viewports[] = {viewport, viewport}; |
| 6343 | VkRect2D scissor = {{0, 0}, {64, 64}}; |
| 6344 | VkRect2D scissors[100] = {scissor, scissor}; |
| 6345 | |
| 6346 | using std::vector; |
| 6347 | struct TestCase { |
| 6348 | uint32_t viewport_count; |
| 6349 | VkViewport *viewports; |
| 6350 | uint32_t scissor_count; |
| 6351 | VkRect2D *scissors; |
| 6352 | uint32_t exclusive_scissor_count; |
| 6353 | VkRect2D *exclusive_scissors; |
| 6354 | |
| 6355 | vector<std::string> vuids; |
| 6356 | }; |
| 6357 | |
| 6358 | vector<TestCase> test_cases = { |
| 6359 | {1, |
| 6360 | viewports, |
| 6361 | 1, |
| 6362 | scissors, |
| 6363 | 2, |
| 6364 | scissors, |
| 6365 | {"VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027", |
| 6366 | "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029"}}, |
| 6367 | {1, |
| 6368 | viewports, |
| 6369 | 1, |
| 6370 | scissors, |
| 6371 | 100, |
| 6372 | scissors, |
| 6373 | {"VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027", |
| 6374 | "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028", |
| 6375 | "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029"}}, |
Shannon McPherson | 24c13d1 | 2020-06-18 15:51:41 -0600 | [diff] [blame] | 6376 | {1, viewports, 1, scissors, 1, nullptr, {"VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056"}}, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6377 | }; |
| 6378 | |
| 6379 | for (const auto &test_case : test_cases) { |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 6380 | VkPipelineViewportExclusiveScissorStateCreateInfoNV exc = |
| 6381 | LvlInitStruct<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6382 | |
| 6383 | const auto break_vp = [&test_case, &exc](CreatePipelineHelper &helper) { |
| 6384 | helper.vp_state_ci_.viewportCount = test_case.viewport_count; |
| 6385 | helper.vp_state_ci_.pViewports = test_case.viewports; |
| 6386 | helper.vp_state_ci_.scissorCount = test_case.scissor_count; |
| 6387 | helper.vp_state_ci_.pScissors = test_case.scissors; |
| 6388 | helper.vp_state_ci_.pNext = &exc; |
| 6389 | |
| 6390 | exc.exclusiveScissorCount = test_case.exclusive_scissor_count; |
| 6391 | exc.pExclusiveScissors = test_case.exclusive_scissors; |
| 6392 | }; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6393 | CreatePipelineHelper::OneshotTest(*this, break_vp, kErrorBit, test_case.vuids); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6394 | } |
| 6395 | } |
| 6396 | |
| 6397 | // Based on SetDynScissorParamTests |
| 6398 | { |
| 6399 | auto vkCmdSetExclusiveScissorNV = |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6400 | (PFN_vkCmdSetExclusiveScissorNV)vk::GetDeviceProcAddr(m_device->device(), "vkCmdSetExclusiveScissorNV"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6401 | |
| 6402 | const VkRect2D scissor = {{0, 0}, {16, 16}}; |
| 6403 | const VkRect2D scissors[] = {scissor, scissor}; |
| 6404 | |
| 6405 | m_commandBuffer->begin(); |
| 6406 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6407 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6408 | vkCmdSetExclusiveScissorNV(m_commandBuffer->handle(), 1, 1, scissors); |
| 6409 | m_errorMonitor->VerifyFound(); |
| 6410 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6411 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6412 | "vkCmdSetExclusiveScissorNV: parameter exclusiveScissorCount must be greater than 0"); |
| 6413 | vkCmdSetExclusiveScissorNV(m_commandBuffer->handle(), 0, 0, nullptr); |
| 6414 | m_errorMonitor->VerifyFound(); |
| 6415 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6416 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6417 | vkCmdSetExclusiveScissorNV(m_commandBuffer->handle(), 0, 2, scissors); |
| 6418 | m_errorMonitor->VerifyFound(); |
| 6419 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6420 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6421 | "vkCmdSetExclusiveScissorNV: parameter exclusiveScissorCount must be greater than 0"); |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6422 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6423 | vkCmdSetExclusiveScissorNV(m_commandBuffer->handle(), 1, 0, scissors); |
| 6424 | m_errorMonitor->VerifyFound(); |
| 6425 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6426 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035"); |
| 6427 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6428 | vkCmdSetExclusiveScissorNV(m_commandBuffer->handle(), 1, 2, scissors); |
| 6429 | m_errorMonitor->VerifyFound(); |
| 6430 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6431 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6432 | "vkCmdSetExclusiveScissorNV: required parameter pExclusiveScissors specified as NULL"); |
| 6433 | vkCmdSetExclusiveScissorNV(m_commandBuffer->handle(), 0, 1, nullptr); |
| 6434 | m_errorMonitor->VerifyFound(); |
| 6435 | |
| 6436 | struct TestCase { |
| 6437 | VkRect2D scissor; |
| 6438 | std::string vuid; |
| 6439 | }; |
| 6440 | |
| 6441 | std::vector<TestCase> test_cases = { |
| 6442 | {{{-1, 0}, {16, 16}}, "VUID-vkCmdSetExclusiveScissorNV-x-02037"}, |
| 6443 | {{{0, -1}, {16, 16}}, "VUID-vkCmdSetExclusiveScissorNV-x-02037"}, |
| 6444 | {{{1, 0}, {INT32_MAX, 16}}, "VUID-vkCmdSetExclusiveScissorNV-offset-02038"}, |
| 6445 | {{{INT32_MAX, 0}, {1, 16}}, "VUID-vkCmdSetExclusiveScissorNV-offset-02038"}, |
| 6446 | {{{0, 0}, {uint32_t{INT32_MAX} + 1, 16}}, "VUID-vkCmdSetExclusiveScissorNV-offset-02038"}, |
| 6447 | {{{0, 1}, {16, INT32_MAX}}, "VUID-vkCmdSetExclusiveScissorNV-offset-02039"}, |
| 6448 | {{{0, INT32_MAX}, {16, 1}}, "VUID-vkCmdSetExclusiveScissorNV-offset-02039"}, |
| 6449 | {{{0, 0}, {16, uint32_t{INT32_MAX} + 1}}, "VUID-vkCmdSetExclusiveScissorNV-offset-02039"}}; |
| 6450 | |
| 6451 | for (const auto &test_case : test_cases) { |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6452 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, test_case.vuid); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6453 | vkCmdSetExclusiveScissorNV(m_commandBuffer->handle(), 0, 1, &test_case.scissor); |
| 6454 | m_errorMonitor->VerifyFound(); |
| 6455 | } |
| 6456 | |
| 6457 | m_commandBuffer->end(); |
| 6458 | } |
| 6459 | } |
| 6460 | |
| 6461 | TEST_F(VkLayerTest, MeshShaderNV) { |
| 6462 | TEST_DESCRIPTION("Test VK_NV_mesh_shader."); |
| 6463 | |
sjfricke | d8e01c5 | 2022-07-06 14:09:04 +0900 | [diff] [blame] | 6464 | AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 6465 | AddRequiredExtensions(VK_NV_MESH_SHADER_EXTENSION_NAME); |
Mark Lobodzinski | 09ce9c4 | 2020-03-06 10:02:44 -0700 | [diff] [blame] | 6466 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
sjfricke | d8e01c5 | 2022-07-06 14:09:04 +0900 | [diff] [blame] | 6467 | if (!AreRequiredExtensionsEnabled()) { |
| 6468 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6469 | } |
| 6470 | |
Tony-LunarG | 048f501 | 2020-04-29 16:55:11 -0600 | [diff] [blame] | 6471 | if (IsPlatform(kMockICD) || DeviceSimulation()) { |
sjfricke | 11b2469 | 2022-06-21 20:49:53 +0900 | [diff] [blame] | 6472 | GTEST_SKIP() << "Test not supported by MockICD"; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6473 | } |
| 6474 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6475 | // Create a device that enables mesh_shader |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 6476 | auto mesh_shader_features = LvlInitStruct<VkPhysicalDeviceMeshShaderFeaturesNV>(); |
sjfricke | 11db0c7 | 2022-08-18 13:23:11 +0900 | [diff] [blame^] | 6477 | auto features2 = GetPhysicalDeviceFeatures2(mesh_shader_features); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6478 | features2.features.multiDrawIndirect = VK_FALSE; |
| 6479 | |
| 6480 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 6481 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6482 | |
sfricke-samsung | 1c0b96a | 2021-07-08 22:24:09 -0700 | [diff] [blame] | 6483 | static const char vertShaderText[] = R"glsl( |
| 6484 | #version 450 |
| 6485 | vec2 vertices[3]; |
| 6486 | void main() { |
| 6487 | vertices[0] = vec2(-1.0, -1.0); |
| 6488 | vertices[1] = vec2( 1.0, -1.0); |
| 6489 | vertices[2] = vec2( 0.0, 1.0); |
| 6490 | gl_Position = vec4(vertices[gl_VertexIndex % 3], 0.0, 1.0); |
| 6491 | gl_PointSize = 1.0f; |
| 6492 | } |
| 6493 | )glsl"; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6494 | |
sfricke-samsung | 1c0b96a | 2021-07-08 22:24:09 -0700 | [diff] [blame] | 6495 | static const char meshShaderText[] = R"glsl( |
| 6496 | #version 450 |
| 6497 | #extension GL_NV_mesh_shader : require |
| 6498 | layout(local_size_x = 1) in; |
| 6499 | layout(max_vertices = 3) out; |
| 6500 | layout(max_primitives = 1) out; |
| 6501 | layout(triangles) out; |
| 6502 | void main() { |
| 6503 | gl_MeshVerticesNV[0].gl_Position = vec4(-1.0, -1.0, 0, 1); |
| 6504 | gl_MeshVerticesNV[1].gl_Position = vec4( 1.0, -1.0, 0, 1); |
| 6505 | gl_MeshVerticesNV[2].gl_Position = vec4( 0.0, 1.0, 0, 1); |
| 6506 | gl_PrimitiveIndicesNV[0] = 0; |
| 6507 | gl_PrimitiveIndicesNV[1] = 1; |
| 6508 | gl_PrimitiveIndicesNV[2] = 2; |
| 6509 | gl_PrimitiveCountNV = 1; |
| 6510 | } |
| 6511 | )glsl"; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6512 | |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 6513 | VkShaderObj vs(this, vertShaderText, VK_SHADER_STAGE_VERTEX_BIT); |
| 6514 | VkShaderObj ms(this, meshShaderText, VK_SHADER_STAGE_MESH_BIT_NV); |
| 6515 | VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6516 | |
| 6517 | // Test pipeline creation |
| 6518 | { |
| 6519 | // can't mix mesh with vertex |
| 6520 | const auto break_vp = [&](CreatePipelineHelper &helper) { |
| 6521 | helper.shader_stages_ = {vs.GetStageCreateInfo(), fs.GetStageCreateInfo(), ms.GetStageCreateInfo()}; |
| 6522 | }; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6523 | CreatePipelineHelper::OneshotTest(*this, break_vp, kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6524 | vector<std::string>({"VUID-VkGraphicsPipelineCreateInfo-pStages-02095"})); |
| 6525 | |
| 6526 | // vertex or mesh must be present |
Nathaniel Cesario | 13da77b | 2022-07-15 14:51:12 -0600 | [diff] [blame] | 6527 | // 02096 overlaps with 06896 |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6528 | const auto break_vp2 = [&](CreatePipelineHelper &helper) { helper.shader_stages_ = {fs.GetStageCreateInfo()}; }; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6529 | CreatePipelineHelper::OneshotTest(*this, break_vp2, kErrorBit, |
Nathaniel Cesario | 13da77b | 2022-07-15 14:51:12 -0600 | [diff] [blame] | 6530 | vector<std::string>({"VUID-VkGraphicsPipelineCreateInfo-stage-02096", |
| 6531 | "VUID-VkGraphicsPipelineCreateInfo-pStages-06896"})); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6532 | |
| 6533 | // vertexinput and inputassembly must be valid when vertex stage is present |
| 6534 | const auto break_vp3 = [&](CreatePipelineHelper &helper) { |
| 6535 | helper.shader_stages_ = {vs.GetStageCreateInfo(), fs.GetStageCreateInfo()}; |
| 6536 | helper.gp_ci_.pVertexInputState = nullptr; |
| 6537 | helper.gp_ci_.pInputAssemblyState = nullptr; |
| 6538 | }; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6539 | CreatePipelineHelper::OneshotTest(*this, break_vp3, kErrorBit, |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6540 | vector<std::string>({"VUID-VkGraphicsPipelineCreateInfo-pStages-02097", |
| 6541 | "VUID-VkGraphicsPipelineCreateInfo-pStages-02098"})); |
| 6542 | } |
| 6543 | |
| 6544 | PFN_vkCmdDrawMeshTasksIndirectNV vkCmdDrawMeshTasksIndirectNV = |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6545 | (PFN_vkCmdDrawMeshTasksIndirectNV)vk::GetInstanceProcAddr(instance(), "vkCmdDrawMeshTasksIndirectNV"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6546 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 6547 | VkBufferCreateInfo buffer_create_info = LvlInitStruct<VkBufferCreateInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6548 | buffer_create_info.size = sizeof(uint32_t); |
| 6549 | buffer_create_info.usage = VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT; |
| 6550 | VkBuffer buffer; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6551 | VkResult result = vk::CreateBuffer(m_device->device(), &buffer_create_info, nullptr, &buffer); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6552 | ASSERT_VK_SUCCESS(result); |
| 6553 | |
| 6554 | m_commandBuffer->begin(); |
| 6555 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6556 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146"); |
| 6557 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718"); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6558 | vkCmdDrawMeshTasksIndirectNV(m_commandBuffer->handle(), buffer, 0, 2, 0); |
| 6559 | m_errorMonitor->VerifyFound(); |
| 6560 | |
| 6561 | m_commandBuffer->end(); |
| 6562 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6563 | vk::DestroyBuffer(m_device->device(), buffer, 0); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6564 | } |
| 6565 | |
| 6566 | TEST_F(VkLayerTest, MeshShaderDisabledNV) { |
| 6567 | TEST_DESCRIPTION("Test VK_NV_mesh_shader VUs with NV_mesh_shader disabled."); |
Nathaniel Cesario | fe8d786 | 2022-02-16 17:27:29 -0700 | [diff] [blame] | 6568 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 6569 | AddRequiredExtensions(VK_NV_MESH_SHADER_EXTENSION_NAME); |
Nathaniel Cesario | fe8d786 | 2022-02-16 17:27:29 -0700 | [diff] [blame] | 6570 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 6571 | if (!AreRequiredExtensionsEnabled()) { |
| 6572 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
Nathaniel Cesario | fe8d786 | 2022-02-16 17:27:29 -0700 | [diff] [blame] | 6573 | } |
Nathaniel Cesario | fe8d786 | 2022-02-16 17:27:29 -0700 | [diff] [blame] | 6574 | |
| 6575 | auto mesh_shader_features = LvlInitStruct<VkPhysicalDeviceMeshShaderFeaturesNV>(); |
Nathaniel Cesario | 13da77b | 2022-07-15 14:51:12 -0600 | [diff] [blame] | 6576 | GetPhysicalDeviceFeatures2(mesh_shader_features); |
Nathaniel Cesario | fe8d786 | 2022-02-16 17:27:29 -0700 | [diff] [blame] | 6577 | if (mesh_shader_features.meshShader != VK_TRUE) { |
Nathaniel Cesario | 13da77b | 2022-07-15 14:51:12 -0600 | [diff] [blame] | 6578 | GTEST_SKIP() << "Mesh shader feature not supported"; |
Nathaniel Cesario | fe8d786 | 2022-02-16 17:27:29 -0700 | [diff] [blame] | 6579 | } |
| 6580 | |
| 6581 | mesh_shader_features.meshShader = VK_FALSE; |
| 6582 | mesh_shader_features.taskShader = VK_FALSE; |
Nathaniel Cesario | 13da77b | 2022-07-15 14:51:12 -0600 | [diff] [blame] | 6583 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &mesh_shader_features)); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6584 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6585 | |
Nathaniel Cesario | 13da77b | 2022-07-15 14:51:12 -0600 | [diff] [blame] | 6586 | vk_testing::Event event_obj(*m_device); |
| 6587 | const auto event = event_obj.handle(); |
| 6588 | ASSERT_TRUE(event_obj.initialized()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6589 | |
| 6590 | m_commandBuffer->begin(); |
| 6591 | |
Shannon McPherson | 93970b1 | 2020-06-12 14:34:35 -0600 | [diff] [blame] | 6592 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetEvent-stageMask-04095"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6593 | vk::CmdSetEvent(m_commandBuffer->handle(), event, VK_PIPELINE_STAGE_MESH_SHADER_BIT_NV); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6594 | m_errorMonitor->VerifyFound(); |
| 6595 | |
Shannon McPherson | 93970b1 | 2020-06-12 14:34:35 -0600 | [diff] [blame] | 6596 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetEvent-stageMask-04096"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6597 | vk::CmdSetEvent(m_commandBuffer->handle(), event, VK_PIPELINE_STAGE_TASK_SHADER_BIT_NV); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6598 | m_errorMonitor->VerifyFound(); |
| 6599 | |
Shannon McPherson | 93970b1 | 2020-06-12 14:34:35 -0600 | [diff] [blame] | 6600 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResetEvent-stageMask-04095"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6601 | vk::CmdResetEvent(m_commandBuffer->handle(), event, VK_PIPELINE_STAGE_MESH_SHADER_BIT_NV); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6602 | m_errorMonitor->VerifyFound(); |
| 6603 | |
Shannon McPherson | 93970b1 | 2020-06-12 14:34:35 -0600 | [diff] [blame] | 6604 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResetEvent-stageMask-04096"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6605 | vk::CmdResetEvent(m_commandBuffer->handle(), event, VK_PIPELINE_STAGE_TASK_SHADER_BIT_NV); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6606 | m_errorMonitor->VerifyFound(); |
| 6607 | |
Shannon McPherson | 93970b1 | 2020-06-12 14:34:35 -0600 | [diff] [blame] | 6608 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdWaitEvents-srcStageMask-04095"); |
| 6609 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdWaitEvents-dstStageMask-04095"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6610 | vk::CmdWaitEvents(m_commandBuffer->handle(), 1, &event, VK_PIPELINE_STAGE_MESH_SHADER_BIT_NV, |
| 6611 | VK_PIPELINE_STAGE_MESH_SHADER_BIT_NV, 0, nullptr, 0, nullptr, 0, nullptr); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6612 | m_errorMonitor->VerifyFound(); |
| 6613 | |
Shannon McPherson | 93970b1 | 2020-06-12 14:34:35 -0600 | [diff] [blame] | 6614 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdWaitEvents-srcStageMask-04096"); |
| 6615 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdWaitEvents-dstStageMask-04096"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6616 | vk::CmdWaitEvents(m_commandBuffer->handle(), 1, &event, VK_PIPELINE_STAGE_TASK_SHADER_BIT_NV, |
| 6617 | VK_PIPELINE_STAGE_TASK_SHADER_BIT_NV, 0, nullptr, 0, nullptr, 0, nullptr); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6618 | m_errorMonitor->VerifyFound(); |
| 6619 | |
Shannon McPherson | 93970b1 | 2020-06-12 14:34:35 -0600 | [diff] [blame] | 6620 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPipelineBarrier-srcStageMask-04095"); |
| 6621 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPipelineBarrier-dstStageMask-04095"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6622 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_MESH_SHADER_BIT_NV, VK_PIPELINE_STAGE_MESH_SHADER_BIT_NV, 0, |
| 6623 | 0, nullptr, 0, nullptr, 0, nullptr); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6624 | m_errorMonitor->VerifyFound(); |
| 6625 | |
Shannon McPherson | 93970b1 | 2020-06-12 14:34:35 -0600 | [diff] [blame] | 6626 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPipelineBarrier-srcStageMask-04096"); |
| 6627 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPipelineBarrier-dstStageMask-04096"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6628 | vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TASK_SHADER_BIT_NV, VK_PIPELINE_STAGE_TASK_SHADER_BIT_NV, 0, |
| 6629 | 0, nullptr, 0, nullptr, 0, nullptr); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6630 | m_errorMonitor->VerifyFound(); |
| 6631 | |
| 6632 | m_commandBuffer->end(); |
| 6633 | |
Nathaniel Cesario | 13da77b | 2022-07-15 14:51:12 -0600 | [diff] [blame] | 6634 | vk_testing::Semaphore semaphore_obj(*m_device); |
| 6635 | const auto semaphore = semaphore_obj.handle(); |
| 6636 | ASSERT_TRUE(semaphore_obj.initialized()); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6637 | |
| 6638 | VkPipelineStageFlags stage_flags = VK_PIPELINE_STAGE_MESH_SHADER_BIT_NV | VK_PIPELINE_STAGE_TASK_SHADER_BIT_NV; |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 6639 | VkSubmitInfo submit_info = LvlInitStruct<VkSubmitInfo>(); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6640 | |
| 6641 | // Signal the semaphore so the next test can wait on it. |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6642 | submit_info.signalSemaphoreCount = 1; |
| 6643 | submit_info.pSignalSemaphores = &semaphore; |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6644 | vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6645 | |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6646 | submit_info.signalSemaphoreCount = 0; |
| 6647 | submit_info.pSignalSemaphores = nullptr; |
| 6648 | submit_info.waitSemaphoreCount = 1; |
| 6649 | submit_info.pWaitSemaphores = &semaphore; |
| 6650 | submit_info.pWaitDstStageMask = &stage_flags; |
| 6651 | |
sfricke-samsung | 1ac6484 | 2021-09-23 14:11:17 -0700 | [diff] [blame] | 6652 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo-pWaitDstStageMask-04095"); |
| 6653 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo-pWaitDstStageMask-04096"); |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6654 | vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6655 | m_errorMonitor->VerifyFound(); |
| 6656 | |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6657 | vk::QueueWaitIdle(m_device->m_queue); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6658 | |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 6659 | VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT); |
Nathaniel Cesario | fe8d786 | 2022-02-16 17:27:29 -0700 | [diff] [blame] | 6660 | |
| 6661 | static const char task_src[] = R"glsl( |
| 6662 | #version 450 |
| 6663 | |
| 6664 | #extension GL_NV_mesh_shader : require |
| 6665 | |
| 6666 | layout(local_size_x = 32) in; |
| 6667 | |
| 6668 | taskNV out Task { |
| 6669 | uint baseID; |
| 6670 | } OUT; |
| 6671 | |
| 6672 | void main() { |
| 6673 | OUT.baseID = 1; |
| 6674 | } |
| 6675 | )glsl"; |
| 6676 | |
| 6677 | static const char mesh_src[] = R"glsl( |
| 6678 | #version 450 |
| 6679 | |
| 6680 | #extension GL_NV_mesh_shader : require |
| 6681 | |
| 6682 | layout(local_size_x = 1) in; |
| 6683 | layout(max_vertices = 3) out; |
| 6684 | layout(max_primitives = 1) out; |
| 6685 | layout(triangles) out; |
| 6686 | |
| 6687 | taskNV in Task { |
| 6688 | uint baseID; |
| 6689 | } IN; |
| 6690 | |
| 6691 | void main() { |
| 6692 | } |
| 6693 | )glsl"; |
| 6694 | |
| 6695 | VkShaderObj task_shader(this, task_src, VK_SHADER_STAGE_TASK_BIT_NV); |
| 6696 | VkShaderObj mesh_shader(this, mesh_src, VK_SHADER_STAGE_MESH_BIT_NV); |
Nathaniel Cesario | 13da77b | 2022-07-15 14:51:12 -0600 | [diff] [blame] | 6697 | VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6698 | |
| 6699 | // mesh and task shaders not supported |
| 6700 | const auto break_vp = [&](CreatePipelineHelper &helper) { |
Nathaniel Cesario | 13da77b | 2022-07-15 14:51:12 -0600 | [diff] [blame] | 6701 | helper.shader_stages_ = {task_shader.GetStageCreateInfo(), mesh_shader.GetStageCreateInfo(), fs.GetStageCreateInfo()}; |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6702 | }; |
Nathaniel Cesario | fe8d786 | 2022-02-16 17:27:29 -0700 | [diff] [blame] | 6703 | CreatePipelineHelper::OneshotTest(*this, break_vp, kErrorBit, |
| 6704 | vector<std::string>({"VUID-VkPipelineShaderStageCreateInfo-stage-02091", |
| 6705 | "VUID-VkPipelineShaderStageCreateInfo-stage-02092"})); |
unknown | 088160a | 2019-05-23 17:43:13 -0600 | [diff] [blame] | 6706 | } |
Chris Mayer | c93536f | 2019-09-19 16:34:49 +0200 | [diff] [blame] | 6707 | |
| 6708 | TEST_F(VkLayerTest, ViewportWScalingNV) { |
| 6709 | TEST_DESCRIPTION("Verify VK_NV_clip_space_w_scaling"); |
| 6710 | |
Mark Lobodzinski | 09ce9c4 | 2020-03-06 10:02:44 -0700 | [diff] [blame] | 6711 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
Chris Mayer | c93536f | 2019-09-19 16:34:49 +0200 | [diff] [blame] | 6712 | |
| 6713 | VkPhysicalDeviceFeatures device_features = {}; |
| 6714 | ASSERT_NO_FATAL_FAILURE(GetPhysicalDeviceFeatures(&device_features)); |
| 6715 | |
| 6716 | if (!device_features.multiViewport) { |
| 6717 | printf("%s VkPhysicalDeviceFeatures::multiViewport is not supported, skipping tests\n", kSkipPrefix); |
| 6718 | return; |
| 6719 | } |
| 6720 | |
| 6721 | if (DeviceExtensionSupported(gpu(), nullptr, VK_NV_CLIP_SPACE_W_SCALING_EXTENSION_NAME)) { |
| 6722 | m_device_extension_names.push_back(VK_NV_CLIP_SPACE_W_SCALING_EXTENSION_NAME); |
| 6723 | } else { |
| 6724 | printf("%s %s Extension not supported, skipping tests\n", kSkipPrefix, VK_NV_CLIP_SPACE_W_SCALING_EXTENSION_NAME); |
| 6725 | return; |
| 6726 | } |
| 6727 | |
| 6728 | ASSERT_NO_FATAL_FAILURE(InitState(&device_features)); |
| 6729 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6730 | |
| 6731 | auto vkCmdSetViewportWScalingNV = |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6732 | reinterpret_cast<PFN_vkCmdSetViewportWScalingNV>(vk::GetDeviceProcAddr(m_device->device(), "vkCmdSetViewportWScalingNV")); |
Chris Mayer | c93536f | 2019-09-19 16:34:49 +0200 | [diff] [blame] | 6733 | |
sfricke-samsung | 1c0b96a | 2021-07-08 22:24:09 -0700 | [diff] [blame] | 6734 | const char vs_src[] = R"glsl( |
Chris Mayer | c93536f | 2019-09-19 16:34:49 +0200 | [diff] [blame] | 6735 | #version 450 |
| 6736 | const vec2 positions[] = { vec2(-1.0f, 1.0f), |
| 6737 | vec2( 1.0f, 1.0f), |
| 6738 | vec2(-1.0f, -1.0f), |
| 6739 | vec2( 1.0f, -1.0f) }; |
| 6740 | out gl_PerVertex { |
| 6741 | vec4 gl_Position; |
| 6742 | }; |
| 6743 | |
| 6744 | void main() { |
| 6745 | gl_Position = vec4(positions[gl_VertexIndex % 4], 0.0f, 1.0f); |
sfricke-samsung | 1c0b96a | 2021-07-08 22:24:09 -0700 | [diff] [blame] | 6746 | } |
| 6747 | )glsl"; |
Chris Mayer | c93536f | 2019-09-19 16:34:49 +0200 | [diff] [blame] | 6748 | |
sfricke-samsung | 1c0b96a | 2021-07-08 22:24:09 -0700 | [diff] [blame] | 6749 | const char fs_src[] = R"glsl( |
Chris Mayer | c93536f | 2019-09-19 16:34:49 +0200 | [diff] [blame] | 6750 | #version 450 |
| 6751 | layout(location = 0) out vec4 outColor; |
| 6752 | |
| 6753 | void main() { |
| 6754 | outColor = vec4(0.0f, 1.0f, 0.0f, 1.0f); |
sfricke-samsung | 1c0b96a | 2021-07-08 22:24:09 -0700 | [diff] [blame] | 6755 | } |
| 6756 | )glsl"; |
Chris Mayer | c93536f | 2019-09-19 16:34:49 +0200 | [diff] [blame] | 6757 | |
| 6758 | const std::vector<VkViewport> vp = { |
| 6759 | {0.0f, 0.0f, 64.0f, 64.0f}, {0.0f, 0.0f, 64.0f, 64.0f}, {0.0f, 0.0f, 64.0f, 64.0f}, {0.0f, 0.0f, 64.0f, 64.0f}}; |
| 6760 | const std::vector<VkRect2D> sc = {{{0, 0}, {32, 32}}, {{32, 0}, {32, 32}}, {{0, 32}, {32, 32}}, {{32, 32}, {32, 32}}}; |
| 6761 | const std::vector<VkViewportWScalingNV> scale = {{-0.2f, -0.2f}, {0.2f, -0.2f}, {-0.2f, 0.2f}, {0.2f, 0.2f}}; |
| 6762 | |
| 6763 | const uint32_t vp_count = static_cast<uint32_t>(vp.size()); |
| 6764 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 6765 | VkPipelineViewportWScalingStateCreateInfoNV vpsi = LvlInitStruct<VkPipelineViewportWScalingStateCreateInfoNV>(); |
Chris Mayer | c93536f | 2019-09-19 16:34:49 +0200 | [diff] [blame] | 6766 | vpsi.viewportWScalingEnable = VK_TRUE; |
| 6767 | vpsi.viewportCount = vp_count; |
| 6768 | vpsi.pViewportWScalings = scale.data(); |
| 6769 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 6770 | VkPipelineViewportStateCreateInfo vpci = LvlInitStruct<VkPipelineViewportStateCreateInfo>(&vpsi); |
Chris Mayer | c93536f | 2019-09-19 16:34:49 +0200 | [diff] [blame] | 6771 | vpci.viewportCount = vp_count; |
| 6772 | vpci.pViewports = vp.data(); |
| 6773 | vpci.scissorCount = vp_count; |
| 6774 | vpci.pScissors = sc.data(); |
Chris Mayer | c93536f | 2019-09-19 16:34:49 +0200 | [diff] [blame] | 6775 | |
| 6776 | const auto set_vpci = [&vpci](CreatePipelineHelper &helper) { helper.vp_state_ci_ = vpci; }; |
| 6777 | |
| 6778 | // Make sure no errors show up when creating the pipeline with w-scaling enabled |
Nathaniel Cesario | cabaf44 | 2022-07-21 14:57:41 -0600 | [diff] [blame] | 6779 | CreatePipelineHelper::OneshotTest(*this, set_vpci, kErrorBit); |
Chris Mayer | c93536f | 2019-09-19 16:34:49 +0200 | [diff] [blame] | 6780 | |
| 6781 | // Create pipeline with w-scaling enabled but without a valid scaling array |
| 6782 | vpsi.pViewportWScalings = nullptr; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6783 | CreatePipelineHelper::OneshotTest(*this, set_vpci, kErrorBit, |
Chris Mayer | c93536f | 2019-09-19 16:34:49 +0200 | [diff] [blame] | 6784 | vector<std::string>({"VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715"})); |
| 6785 | |
| 6786 | vpsi.pViewportWScalings = scale.data(); |
| 6787 | |
| 6788 | // Create pipeline with w-scaling enabled but without matching viewport counts |
| 6789 | vpsi.viewportCount = 1; |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6790 | CreatePipelineHelper::OneshotTest(*this, set_vpci, kErrorBit, |
Chris Mayer | c93536f | 2019-09-19 16:34:49 +0200 | [diff] [blame] | 6791 | vector<std::string>({"VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726"})); |
| 6792 | |
| 6793 | const VkPipelineLayoutObj pl(m_device); |
| 6794 | |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 6795 | VkShaderObj vs(this, vs_src, VK_SHADER_STAGE_VERTEX_BIT); |
| 6796 | VkShaderObj fs(this, fs_src, VK_SHADER_STAGE_FRAGMENT_BIT); |
Chris Mayer | c93536f | 2019-09-19 16:34:49 +0200 | [diff] [blame] | 6797 | |
| 6798 | VkPipelineObj pipe(m_device); |
| 6799 | pipe.AddDefaultColorAttachment(); |
| 6800 | pipe.AddShader(&vs); |
| 6801 | pipe.AddShader(&fs); |
| 6802 | pipe.SetViewport(vp); |
| 6803 | pipe.SetScissor(sc); |
| 6804 | pipe.CreateVKPipeline(pl.handle(), renderPass()); |
| 6805 | |
| 6806 | VkPipelineObj pipeDynWScale(m_device); |
| 6807 | pipeDynWScale.AddDefaultColorAttachment(); |
| 6808 | pipeDynWScale.AddShader(&vs); |
| 6809 | pipeDynWScale.AddShader(&fs); |
| 6810 | pipeDynWScale.SetViewport(vp); |
| 6811 | pipeDynWScale.SetScissor(sc); |
| 6812 | pipeDynWScale.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV); |
| 6813 | pipeDynWScale.CreateVKPipeline(pl.handle(), renderPass()); |
| 6814 | |
| 6815 | m_commandBuffer->begin(); |
| 6816 | |
| 6817 | // Bind pipeline without dynamic w scaling enabled |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6818 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Chris Mayer | c93536f | 2019-09-19 16:34:49 +0200 | [diff] [blame] | 6819 | |
Chris Mayer | c93536f | 2019-09-19 16:34:49 +0200 | [diff] [blame] | 6820 | // Bind pipeline that has dynamic w-scaling enabled |
Mark Lobodzinski | 902cb0f | 2019-09-27 14:45:36 -0600 | [diff] [blame] | 6821 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeDynWScale.handle()); |
Chris Mayer | c93536f | 2019-09-19 16:34:49 +0200 | [diff] [blame] | 6822 | |
| 6823 | const auto max_vps = m_device->props.limits.maxViewports; |
| 6824 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6825 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324"); |
Chris Mayer | c93536f | 2019-09-19 16:34:49 +0200 | [diff] [blame] | 6826 | vkCmdSetViewportWScalingNV(m_commandBuffer->handle(), 1, max_vps, scale.data()); |
| 6827 | m_errorMonitor->VerifyFound(); |
| 6828 | |
Chris Mayer | c93536f | 2019-09-19 16:34:49 +0200 | [diff] [blame] | 6829 | vkCmdSetViewportWScalingNV(m_commandBuffer->handle(), 0, vp_count, scale.data()); |
Chris Mayer | c93536f | 2019-09-19 16:34:49 +0200 | [diff] [blame] | 6830 | |
| 6831 | m_commandBuffer->end(); |
| 6832 | } |
sfricke-samsung | 914e800 | 2020-01-07 22:26:18 -0800 | [diff] [blame] | 6833 | |
| 6834 | TEST_F(VkLayerTest, CreateSamplerYcbcrConversionEnable) { |
| 6835 | TEST_DESCRIPTION("Checks samplerYcbcrConversion is enabled before calling vkCreateSamplerYcbcrConversion"); |
| 6836 | |
| 6837 | // Enable Sampler YCbCr Conversion req'd extensions |
| 6838 | // Only need revision 1 of vkGetPhysicalDeviceProperties2 and this allows more device capable for testing |
| 6839 | bool mp_extensions = InstanceExtensionSupported(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, 1); |
| 6840 | if (mp_extensions) { |
| 6841 | m_instance_extension_names.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 6842 | } |
| 6843 | SetTargetApiVersion(VK_API_VERSION_1_1); |
Mark Lobodzinski | 09ce9c4 | 2020-03-06 10:02:44 -0700 | [diff] [blame] | 6844 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 6845 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
sfricke-samsung | 914e800 | 2020-01-07 22:26:18 -0800 | [diff] [blame] | 6846 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME); |
| 6847 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_BIND_MEMORY_2_EXTENSION_NAME); |
| 6848 | mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME); |
| 6849 | if (mp_extensions) { |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 6850 | m_device_extension_names.push_back(VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
sfricke-samsung | 914e800 | 2020-01-07 22:26:18 -0800 | [diff] [blame] | 6851 | m_device_extension_names.push_back(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME); |
| 6852 | m_device_extension_names.push_back(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME); |
| 6853 | m_device_extension_names.push_back(VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME); |
| 6854 | } else { |
| 6855 | printf("%s test requires Sampler YCbCr Conversion extensions, not available. Skipping.\n", kSkipPrefix); |
| 6856 | return; |
| 6857 | } |
| 6858 | |
| 6859 | // Explictly not enable Ycbcr Conversion Features |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 6860 | VkPhysicalDeviceSamplerYcbcrConversionFeatures ycbcr_features = LvlInitStruct<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(); |
sfricke-samsung | 914e800 | 2020-01-07 22:26:18 -0800 | [diff] [blame] | 6861 | ycbcr_features.samplerYcbcrConversion = VK_FALSE; |
| 6862 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &ycbcr_features)); |
| 6863 | |
| 6864 | PFN_vkCreateSamplerYcbcrConversionKHR vkCreateSamplerYcbcrConversionFunction = |
| 6865 | (PFN_vkCreateSamplerYcbcrConversionKHR)vk::GetDeviceProcAddr(m_device->handle(), "vkCreateSamplerYcbcrConversionKHR"); |
| 6866 | if (vkCreateSamplerYcbcrConversionFunction == nullptr) { |
| 6867 | printf("%s did not find vkCreateSamplerYcbcrConversionKHR function pointer; Skipping.\n", kSkipPrefix); |
| 6868 | return; |
| 6869 | } |
| 6870 | |
| 6871 | // Create Ycbcr conversion |
| 6872 | VkSamplerYcbcrConversion conversions; |
| 6873 | VkSamplerYcbcrConversionCreateInfo ycbcr_create_info = {VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO, |
| 6874 | NULL, |
| 6875 | VK_FORMAT_G8_B8R8_2PLANE_420_UNORM_KHR, |
| 6876 | VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY, |
| 6877 | VK_SAMPLER_YCBCR_RANGE_ITU_FULL, |
| 6878 | {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, |
| 6879 | VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY}, |
| 6880 | VK_CHROMA_LOCATION_COSITED_EVEN, |
| 6881 | VK_CHROMA_LOCATION_COSITED_EVEN, |
| 6882 | VK_FILTER_NEAREST, |
| 6883 | false}; |
| 6884 | |
Mark Lobodzinski | 2031078 | 2020-02-28 14:25:17 -0700 | [diff] [blame] | 6885 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCreateSamplerYcbcrConversion-None-01648"); |
sfricke-samsung | 914e800 | 2020-01-07 22:26:18 -0800 | [diff] [blame] | 6886 | vkCreateSamplerYcbcrConversionFunction(m_device->handle(), &ycbcr_create_info, nullptr, &conversions); |
| 6887 | m_errorMonitor->VerifyFound(); |
Shannon McPherson | 5042160 | 2020-01-28 15:18:46 -0700 | [diff] [blame] | 6888 | } |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 6889 | |
| 6890 | TEST_F(VkLayerTest, TransformFeedbackFeatureEnabled) { |
| 6891 | TEST_DESCRIPTION("VkPhysicalDeviceTransformFeedbackFeaturesEXT::transformFeedback must be enabled"); |
| 6892 | |
sjfricke | d8e01c5 | 2022-07-06 14:09:04 +0900 | [diff] [blame] | 6893 | AddRequiredExtensions(VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 6894 | |
| 6895 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
| 6896 | |
sjfricke | d8e01c5 | 2022-07-06 14:09:04 +0900 | [diff] [blame] | 6897 | if (!AreRequiredExtensionsEnabled()) { |
| 6898 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 6899 | } |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 6900 | |
| 6901 | { |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 6902 | auto tf_features = LvlInitStruct<VkPhysicalDeviceTransformFeedbackFeaturesEXT>(); |
sjfricke | 11db0c7 | 2022-08-18 13:23:11 +0900 | [diff] [blame^] | 6903 | GetPhysicalDeviceFeatures2(tf_features); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 6904 | if (!tf_features.transformFeedback) { |
| 6905 | printf("%s transformFeedback not supported; skipped.\n", kSkipPrefix); |
| 6906 | return; |
| 6907 | } |
| 6908 | } |
| 6909 | |
| 6910 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6911 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6912 | |
| 6913 | { |
| 6914 | auto vkCmdBindTransformFeedbackBuffersEXT = (PFN_vkCmdBindTransformFeedbackBuffersEXT)vk::GetDeviceProcAddr( |
| 6915 | m_device->device(), "vkCmdBindTransformFeedbackBuffersEXT"); |
| 6916 | ASSERT_TRUE(vkCmdBindTransformFeedbackBuffersEXT != nullptr); |
| 6917 | |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 6918 | auto info = LvlInitStruct<VkBufferCreateInfo>(); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 6919 | info.usage = VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT; |
| 6920 | info.size = 4; |
| 6921 | VkBufferObj buffer; |
| 6922 | buffer.init(*m_device, info); |
| 6923 | VkDeviceSize offsets[1]{}; |
| 6924 | |
| 6925 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindTransformFeedbackBuffersEXT-transformFeedback-02355"); |
| 6926 | vkCmdBindTransformFeedbackBuffersEXT(m_commandBuffer->handle(), 0, 1, &buffer.handle(), offsets, nullptr); |
| 6927 | m_errorMonitor->VerifyFound(); |
| 6928 | } |
| 6929 | |
| 6930 | { |
| 6931 | auto vkCmdBeginTransformFeedbackEXT = |
| 6932 | (PFN_vkCmdBeginTransformFeedbackEXT)vk::GetDeviceProcAddr(m_device->device(), "vkCmdBeginTransformFeedbackEXT"); |
| 6933 | ASSERT_TRUE(vkCmdBeginTransformFeedbackEXT != nullptr); |
| 6934 | |
| 6935 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBeginTransformFeedbackEXT-transformFeedback-02366"); |
| 6936 | vkCmdBeginTransformFeedbackEXT(m_commandBuffer->handle(), 0, 1, nullptr, nullptr); |
| 6937 | m_errorMonitor->VerifyFound(); |
| 6938 | } |
| 6939 | |
| 6940 | { |
| 6941 | auto vkCmdEndTransformFeedbackEXT = |
| 6942 | (PFN_vkCmdEndTransformFeedbackEXT)vk::GetDeviceProcAddr(m_device->device(), "vkCmdEndTransformFeedbackEXT"); |
| 6943 | ASSERT_TRUE(vkCmdEndTransformFeedbackEXT != nullptr); |
| 6944 | |
| 6945 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdEndTransformFeedbackEXT-transformFeedback-02374"); |
| 6946 | m_errorMonitor->SetUnexpectedError("VUID-vkCmdEndTransformFeedbackEXT-None-02375"); |
| 6947 | vkCmdEndTransformFeedbackEXT(m_commandBuffer->handle(), 0, 1, nullptr, nullptr); |
| 6948 | m_errorMonitor->VerifyFound(); |
| 6949 | } |
| 6950 | } |
| 6951 | |
| 6952 | TEST_F(VkLayerTest, TransformFeedbackCmdBindTransformFeedbackBuffersEXT) { |
| 6953 | TEST_DESCRIPTION("Submit invalid arguments to vkCmdBindTransformFeedbackBuffersEXT"); |
| 6954 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6955 | AddRequiredExtensions(VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME); |
| 6956 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 6957 | if (!AreRequiredExtensionsEnabled()) { |
| 6958 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported."; |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 6959 | } |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 6960 | |
Nathaniel Cesario | 27d85f5 | 2021-07-22 12:42:07 -0600 | [diff] [blame] | 6961 | if (IsPlatform(kGalaxyS10)) { |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6962 | GTEST_SKIP() << "Test temporarily disabled on S10 device"; |
Nathaniel Cesario | 27d85f5 | 2021-07-22 12:42:07 -0600 | [diff] [blame] | 6963 | } |
| 6964 | |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 6965 | { |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 6966 | auto tf_features = LvlInitStruct<VkPhysicalDeviceTransformFeedbackFeaturesEXT>(); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6967 | auto pd_features = GetPhysicalDeviceFeatures2(tf_features); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 6968 | |
| 6969 | if (!tf_features.transformFeedback) { |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6970 | GTEST_SKIP() << "transformFeedback not supported; skipped."; |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 6971 | } |
| 6972 | |
| 6973 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &pd_features)); |
| 6974 | } |
| 6975 | |
| 6976 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6977 | |
| 6978 | auto vkCmdBindTransformFeedbackBuffersEXT = |
| 6979 | (PFN_vkCmdBindTransformFeedbackBuffersEXT)vk::GetDeviceProcAddr(m_device->device(), "vkCmdBindTransformFeedbackBuffersEXT"); |
| 6980 | ASSERT_TRUE(vkCmdBindTransformFeedbackBuffersEXT != nullptr); |
| 6981 | |
| 6982 | { |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 6983 | auto tf_properties = LvlInitStruct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>(); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 6984 | GetPhysicalDeviceProperties2(tf_properties); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 6985 | |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 6986 | auto info = LvlInitStruct<VkBufferCreateInfo>(); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 6987 | info.usage = VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT; |
| 6988 | info.size = 8; |
| 6989 | VkBufferObj const buffer_obj(*m_device, info); |
| 6990 | |
| 6991 | // Request a firstBinding that is too large. |
| 6992 | { |
| 6993 | auto const firstBinding = tf_properties.maxTransformFeedbackBuffers; |
| 6994 | VkDeviceSize const offsets[1]{}; |
| 6995 | |
| 6996 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356"); |
| 6997 | m_errorMonitor->SetUnexpectedError("VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357"); |
| 6998 | vkCmdBindTransformFeedbackBuffersEXT(m_commandBuffer->handle(), firstBinding, 1, &buffer_obj.handle(), offsets, |
| 6999 | nullptr); |
| 7000 | m_errorMonitor->VerifyFound(); |
| 7001 | } |
| 7002 | |
| 7003 | // Request too many bindings. |
| 7004 | if (tf_properties.maxTransformFeedbackBuffers < std::numeric_limits<uint32_t>::max()) { |
| 7005 | auto const bindingCount = tf_properties.maxTransformFeedbackBuffers + 1; |
| 7006 | std::vector<VkBuffer> buffers(bindingCount, buffer_obj.handle()); |
| 7007 | |
| 7008 | std::vector<VkDeviceSize> offsets(bindingCount); |
| 7009 | |
| 7010 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357"); |
| 7011 | vkCmdBindTransformFeedbackBuffersEXT(m_commandBuffer->handle(), 0, bindingCount, buffers.data(), offsets.data(), |
| 7012 | nullptr); |
| 7013 | m_errorMonitor->VerifyFound(); |
| 7014 | } |
| 7015 | |
| 7016 | // Request a size that is larger than the maximum size. |
| 7017 | if (tf_properties.maxTransformFeedbackBufferSize < std::numeric_limits<VkDeviceSize>::max()) { |
| 7018 | VkDeviceSize const offsets[1]{}; |
| 7019 | VkDeviceSize const sizes[1]{tf_properties.maxTransformFeedbackBufferSize + 1}; |
| 7020 | |
| 7021 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361"); |
| 7022 | vkCmdBindTransformFeedbackBuffersEXT(m_commandBuffer->handle(), 0, 1, &buffer_obj.handle(), offsets, sizes); |
| 7023 | m_errorMonitor->VerifyFound(); |
| 7024 | } |
| 7025 | } |
| 7026 | |
| 7027 | { |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 7028 | auto info = LvlInitStruct<VkBufferCreateInfo>(); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7029 | info.usage = VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT; |
| 7030 | info.size = 8; |
| 7031 | VkBufferObj const buffer_obj(*m_device, info); |
| 7032 | |
| 7033 | // Request an offset that is too large. |
| 7034 | { |
| 7035 | VkDeviceSize const offsets[1]{info.size + 4}; |
| 7036 | |
| 7037 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02358"); |
| 7038 | vkCmdBindTransformFeedbackBuffersEXT(m_commandBuffer->handle(), 0, 1, &buffer_obj.handle(), offsets, nullptr); |
| 7039 | m_errorMonitor->VerifyFound(); |
| 7040 | } |
| 7041 | |
| 7042 | // Request an offset that is not a multiple of 4. |
| 7043 | { |
| 7044 | VkDeviceSize const offsets[1]{1}; |
| 7045 | |
| 7046 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359"); |
| 7047 | vkCmdBindTransformFeedbackBuffersEXT(m_commandBuffer->handle(), 0, 1, &buffer_obj.handle(), offsets, nullptr); |
| 7048 | m_errorMonitor->VerifyFound(); |
| 7049 | } |
| 7050 | |
| 7051 | // Request a size that is larger than the buffer's size. |
| 7052 | { |
| 7053 | VkDeviceSize const offsets[1]{}; |
| 7054 | VkDeviceSize const sizes[1]{info.size + 1}; |
| 7055 | |
| 7056 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSizes-02362"); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7057 | vkCmdBindTransformFeedbackBuffersEXT(m_commandBuffer->handle(), 0, 1, &buffer_obj.handle(), offsets, sizes); |
| 7058 | m_errorMonitor->VerifyFound(); |
| 7059 | } |
| 7060 | |
| 7061 | // Request an offset and size whose sum is larger than the buffer's size. |
| 7062 | { |
| 7063 | VkDeviceSize const offsets[1]{4}; |
| 7064 | VkDeviceSize const sizes[1]{info.size - 3}; |
| 7065 | |
| 7066 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02363"); |
| 7067 | vkCmdBindTransformFeedbackBuffersEXT(m_commandBuffer->handle(), 0, 1, &buffer_obj.handle(), offsets, sizes); |
| 7068 | m_errorMonitor->VerifyFound(); |
| 7069 | } |
| 7070 | |
| 7071 | // Bind while transform feedback is active. |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 7072 | if (!IsDriver(VK_DRIVER_ID_MESA_RADV)) { |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7073 | auto vkCmdBeginTransformFeedbackEXT = |
| 7074 | (PFN_vkCmdBeginTransformFeedbackEXT)vk::GetDeviceProcAddr(m_device->device(), "vkCmdBeginTransformFeedbackEXT"); |
| 7075 | ASSERT_TRUE(vkCmdBeginTransformFeedbackEXT != nullptr); |
| 7076 | vkCmdBeginTransformFeedbackEXT(m_commandBuffer->handle(), 0, 1, nullptr, nullptr); |
| 7077 | |
| 7078 | VkDeviceSize const offsets[1]{}; |
| 7079 | |
| 7080 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindTransformFeedbackBuffersEXT-None-02365"); |
| 7081 | vkCmdBindTransformFeedbackBuffersEXT(m_commandBuffer->handle(), 0, 1, &buffer_obj.handle(), offsets, nullptr); |
| 7082 | m_errorMonitor->VerifyFound(); |
| 7083 | |
| 7084 | auto vkCmdEndTransformFeedbackEXT = |
| 7085 | (PFN_vkCmdEndTransformFeedbackEXT)vk::GetDeviceProcAddr(m_device->device(), "vkCmdEndTransformFeedbackEXT"); |
| 7086 | ASSERT_TRUE(vkCmdEndTransformFeedbackEXT != nullptr); |
| 7087 | vkCmdEndTransformFeedbackEXT(m_commandBuffer->handle(), 0, 1, nullptr, nullptr); |
| 7088 | } |
| 7089 | } |
| 7090 | |
| 7091 | // Don't set VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT. |
| 7092 | { |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 7093 | auto info = LvlInitStruct<VkBufferCreateInfo>(); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7094 | // info.usage = VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT; |
| 7095 | info.size = 4; |
paul-lunarg | abe3b30 | 2022-07-08 15:23:08 -0600 | [diff] [blame] | 7096 | m_errorMonitor->SetUnexpectedError("VUID-VkBufferCreateInfo-usage-requiredbitmask"); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7097 | VkBufferObj const buffer_obj(*m_device, info); |
| 7098 | |
| 7099 | VkDeviceSize const offsets[1]{}; |
| 7100 | |
| 7101 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pBuffers-02360"); |
| 7102 | vkCmdBindTransformFeedbackBuffersEXT(m_commandBuffer->handle(), 0, 1, &buffer_obj.handle(), offsets, nullptr); |
| 7103 | m_errorMonitor->VerifyFound(); |
| 7104 | } |
| 7105 | |
| 7106 | // Don't bind memory. |
| 7107 | { |
Nathaniel Cesario | 079b1b9 | 2022-07-06 15:56:26 -0600 | [diff] [blame] | 7108 | vk_testing::Buffer buffer; |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7109 | { |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 7110 | auto info = LvlInitStruct<VkBufferCreateInfo>(); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7111 | info.usage = VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT; |
| 7112 | info.size = 4; |
Nathaniel Cesario | 079b1b9 | 2022-07-06 15:56:26 -0600 | [diff] [blame] | 7113 | buffer.init_no_mem(*m_device, info); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7114 | } |
| 7115 | |
| 7116 | VkDeviceSize const offsets[1]{}; |
| 7117 | |
| 7118 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pBuffers-02364"); |
Nathaniel Cesario | 079b1b9 | 2022-07-06 15:56:26 -0600 | [diff] [blame] | 7119 | vkCmdBindTransformFeedbackBuffersEXT(m_commandBuffer->handle(), 0, 1, &buffer.handle(), offsets, nullptr); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7120 | m_errorMonitor->VerifyFound(); |
| 7121 | } |
| 7122 | } |
| 7123 | |
| 7124 | TEST_F(VkLayerTest, TransformFeedbackCmdBeginTransformFeedbackEXT) { |
| 7125 | TEST_DESCRIPTION("Submit invalid arguments to vkCmdBeginTransformFeedbackEXT"); |
| 7126 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 7127 | AddRequiredExtensions(VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME); |
| 7128 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 7129 | if (!AreRequiredExtensionsEnabled()) { |
| 7130 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported."; |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7131 | } |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7132 | |
Nathaniel Cesario | 27d85f5 | 2021-07-22 12:42:07 -0600 | [diff] [blame] | 7133 | if (IsPlatform(kGalaxyS10)) { |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 7134 | GTEST_SKIP() << "Test temporarily disabled on S10 device"; |
Nathaniel Cesario | 27d85f5 | 2021-07-22 12:42:07 -0600 | [diff] [blame] | 7135 | } |
| 7136 | |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7137 | { |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 7138 | auto tf_features = LvlInitStruct<VkPhysicalDeviceTransformFeedbackFeaturesEXT>(); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 7139 | auto pd_features = GetPhysicalDeviceFeatures2(tf_features); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7140 | |
| 7141 | if (!tf_features.transformFeedback) { |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 7142 | GTEST_SKIP() << "transformFeedback not supported; skipped."; |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7143 | } |
| 7144 | |
| 7145 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &pd_features)); |
| 7146 | } |
| 7147 | |
| 7148 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7149 | |
| 7150 | auto vkCmdBeginTransformFeedbackEXT = |
| 7151 | (PFN_vkCmdBeginTransformFeedbackEXT)vk::GetDeviceProcAddr(m_device->device(), "vkCmdBeginTransformFeedbackEXT"); |
| 7152 | ASSERT_TRUE(vkCmdBeginTransformFeedbackEXT != nullptr); |
| 7153 | |
| 7154 | { |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 7155 | auto tf_properties = LvlInitStruct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>(); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 7156 | GetPhysicalDeviceProperties2(tf_properties); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7157 | |
| 7158 | // Request a firstCounterBuffer that is too large. |
| 7159 | { |
| 7160 | auto const firstCounterBuffer = tf_properties.maxTransformFeedbackBuffers; |
| 7161 | |
| 7162 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368"); |
| 7163 | m_errorMonitor->SetUnexpectedError("VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369"); |
| 7164 | vkCmdBeginTransformFeedbackEXT(m_commandBuffer->handle(), firstCounterBuffer, 1, nullptr, nullptr); |
| 7165 | m_errorMonitor->VerifyFound(); |
| 7166 | } |
| 7167 | |
| 7168 | // Request too many buffers. |
| 7169 | if (tf_properties.maxTransformFeedbackBuffers < std::numeric_limits<uint32_t>::max()) { |
| 7170 | auto const counterBufferCount = tf_properties.maxTransformFeedbackBuffers + 1; |
| 7171 | |
| 7172 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369"); |
| 7173 | vkCmdBeginTransformFeedbackEXT(m_commandBuffer->handle(), 0, counterBufferCount, nullptr, nullptr); |
| 7174 | m_errorMonitor->VerifyFound(); |
| 7175 | } |
| 7176 | } |
| 7177 | |
| 7178 | // Request an out-of-bounds location. |
| 7179 | { |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 7180 | auto info = LvlInitStruct<VkBufferCreateInfo>(); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7181 | info.usage = VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT; |
| 7182 | info.size = 4; |
| 7183 | VkBufferObj const buffer_obj(*m_device, info); |
| 7184 | |
| 7185 | VkDeviceSize const offsets[1]{1}; |
| 7186 | |
| 7187 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBeginTransformFeedbackEXT-pCounterBufferOffsets-02370"); |
| 7188 | vkCmdBeginTransformFeedbackEXT(m_commandBuffer->handle(), 0, 1, &buffer_obj.handle(), offsets); |
| 7189 | m_errorMonitor->VerifyFound(); |
| 7190 | } |
| 7191 | |
| 7192 | // Request specific offsets without specifying buffers. |
| 7193 | { |
| 7194 | VkDeviceSize const offsets[1]{}; |
| 7195 | |
| 7196 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBeginTransformFeedbackEXT-pCounterBuffer-02371"); |
| 7197 | vkCmdBeginTransformFeedbackEXT(m_commandBuffer->handle(), 0, 1, nullptr, offsets); |
| 7198 | m_errorMonitor->VerifyFound(); |
| 7199 | } |
| 7200 | |
| 7201 | // Don't set VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT. |
| 7202 | { |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 7203 | auto info = LvlInitStruct<VkBufferCreateInfo>(); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7204 | // info.usage = VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT; |
| 7205 | info.size = 4; |
paul-lunarg | abe3b30 | 2022-07-08 15:23:08 -0600 | [diff] [blame] | 7206 | m_errorMonitor->SetUnexpectedError("VUID-VkBufferCreateInfo-usage-requiredbitmask"); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7207 | VkBufferObj const buffer_obj(*m_device, info); |
| 7208 | |
| 7209 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBeginTransformFeedbackEXT-pCounterBuffers-02372"); |
| 7210 | vkCmdBeginTransformFeedbackEXT(m_commandBuffer->handle(), 0, 1, &buffer_obj.handle(), nullptr); |
| 7211 | m_errorMonitor->VerifyFound(); |
| 7212 | } |
| 7213 | |
| 7214 | // Begin while transform feedback is active. |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 7215 | if (!IsDriver(VK_DRIVER_ID_MESA_RADV)) { |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7216 | vkCmdBeginTransformFeedbackEXT(m_commandBuffer->handle(), 0, 1, nullptr, nullptr); |
| 7217 | |
| 7218 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBeginTransformFeedbackEXT-None-02367"); |
| 7219 | vkCmdBeginTransformFeedbackEXT(m_commandBuffer->handle(), 0, 1, nullptr, nullptr); |
| 7220 | m_errorMonitor->VerifyFound(); |
| 7221 | |
| 7222 | auto vkCmdEndTransformFeedbackEXT = |
| 7223 | (PFN_vkCmdEndTransformFeedbackEXT)vk::GetDeviceProcAddr(m_device->device(), "vkCmdEndTransformFeedbackEXT"); |
| 7224 | ASSERT_TRUE(vkCmdEndTransformFeedbackEXT != nullptr); |
| 7225 | |
| 7226 | vkCmdEndTransformFeedbackEXT(m_commandBuffer->handle(), 0, 1, nullptr, nullptr); |
| 7227 | } |
| 7228 | } |
| 7229 | |
| 7230 | TEST_F(VkLayerTest, TransformFeedbackCmdEndTransformFeedbackEXT) { |
| 7231 | TEST_DESCRIPTION("Submit invalid arguments to vkCmdEndTransformFeedbackEXT"); |
| 7232 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 7233 | AddRequiredExtensions(VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7234 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 7235 | if (!AreRequiredExtensionsEnabled()) { |
| 7236 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported."; |
| 7237 | } |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7238 | |
Nathaniel Cesario | 27d85f5 | 2021-07-22 12:42:07 -0600 | [diff] [blame] | 7239 | if (IsPlatform(kGalaxyS10)) { |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 7240 | GTEST_SKIP() << "Test temporarily disabled on S10 device"; |
Nathaniel Cesario | 27d85f5 | 2021-07-22 12:42:07 -0600 | [diff] [blame] | 7241 | } |
| 7242 | |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7243 | { |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 7244 | auto tf_features = LvlInitStruct<VkPhysicalDeviceTransformFeedbackFeaturesEXT>(); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 7245 | auto pd_features = GetPhysicalDeviceFeatures2(tf_features); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7246 | |
| 7247 | if (!tf_features.transformFeedback) { |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 7248 | GTEST_SKIP() << "transformFeedback not supported; skipped."; |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7249 | } |
| 7250 | |
| 7251 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &pd_features)); |
| 7252 | } |
| 7253 | |
| 7254 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7255 | |
| 7256 | auto vkCmdEndTransformFeedbackEXT = |
| 7257 | (PFN_vkCmdEndTransformFeedbackEXT)vk::GetDeviceProcAddr(m_device->device(), "vkCmdEndTransformFeedbackEXT"); |
| 7258 | ASSERT_TRUE(vkCmdEndTransformFeedbackEXT != nullptr); |
| 7259 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 7260 | if (!IsDriver(VK_DRIVER_ID_MESA_RADV)) { |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7261 | { |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 7262 | // Activate transform feedback. |
| 7263 | auto vkCmdBeginTransformFeedbackEXT = |
| 7264 | (PFN_vkCmdBeginTransformFeedbackEXT)vk::GetDeviceProcAddr(m_device->device(), "vkCmdBeginTransformFeedbackEXT"); |
| 7265 | ASSERT_TRUE(vkCmdBeginTransformFeedbackEXT != nullptr); |
| 7266 | vkCmdBeginTransformFeedbackEXT(m_commandBuffer->handle(), 0, 1, nullptr, nullptr); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7267 | |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7268 | { |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 7269 | auto tf_properties = LvlInitStruct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>(); |
| 7270 | GetPhysicalDeviceProperties2(tf_properties); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7271 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 7272 | // Request a firstCounterBuffer that is too large. |
| 7273 | { |
| 7274 | auto const firstCounterBuffer = tf_properties.maxTransformFeedbackBuffers; |
| 7275 | |
| 7276 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376"); |
| 7277 | m_errorMonitor->SetUnexpectedError("VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377"); |
| 7278 | vkCmdEndTransformFeedbackEXT(m_commandBuffer->handle(), firstCounterBuffer, 1, nullptr, nullptr); |
| 7279 | m_errorMonitor->VerifyFound(); |
| 7280 | } |
| 7281 | |
| 7282 | // Request too many buffers. |
| 7283 | if (tf_properties.maxTransformFeedbackBuffers < std::numeric_limits<uint32_t>::max()) { |
| 7284 | auto const counterBufferCount = tf_properties.maxTransformFeedbackBuffers + 1; |
| 7285 | |
| 7286 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377"); |
| 7287 | vkCmdEndTransformFeedbackEXT(m_commandBuffer->handle(), 0, counterBufferCount, nullptr, nullptr); |
| 7288 | m_errorMonitor->VerifyFound(); |
| 7289 | } |
| 7290 | } |
| 7291 | |
| 7292 | // Request an out-of-bounds location. |
| 7293 | { |
| 7294 | auto info = LvlInitStruct<VkBufferCreateInfo>(); |
| 7295 | info.usage = VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT; |
| 7296 | info.size = 4; |
| 7297 | VkBufferObj const buffer_obj(*m_device, info); |
| 7298 | |
| 7299 | VkDeviceSize const offsets[1]{1}; |
| 7300 | |
| 7301 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdEndTransformFeedbackEXT-pCounterBufferOffsets-02378"); |
| 7302 | vkCmdEndTransformFeedbackEXT(m_commandBuffer->handle(), 0, 1, &buffer_obj.handle(), offsets); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7303 | m_errorMonitor->VerifyFound(); |
| 7304 | } |
| 7305 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 7306 | // Request specific offsets without specifying buffers. |
| 7307 | { |
| 7308 | VkDeviceSize const offsets[1]{}; |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7309 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 7310 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdEndTransformFeedbackEXT-pCounterBuffer-02379"); |
| 7311 | vkCmdEndTransformFeedbackEXT(m_commandBuffer->handle(), 0, 1, nullptr, offsets); |
| 7312 | m_errorMonitor->VerifyFound(); |
| 7313 | } |
| 7314 | |
| 7315 | // Don't set VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT. |
| 7316 | { |
| 7317 | auto info = LvlInitStruct<VkBufferCreateInfo>(); |
| 7318 | // info.usage = VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT; |
| 7319 | info.size = 4; |
paul-lunarg | abe3b30 | 2022-07-08 15:23:08 -0600 | [diff] [blame] | 7320 | m_errorMonitor->SetUnexpectedError("VUID-VkBufferCreateInfo-usage-requiredbitmask"); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 7321 | VkBufferObj const buffer_obj(*m_device, info); |
| 7322 | |
| 7323 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdEndTransformFeedbackEXT-pCounterBuffers-02380"); |
| 7324 | vkCmdEndTransformFeedbackEXT(m_commandBuffer->handle(), 0, 1, &buffer_obj.handle(), nullptr); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7325 | m_errorMonitor->VerifyFound(); |
| 7326 | } |
| 7327 | } |
| 7328 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 7329 | // End while transform feedback is inactive. |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7330 | { |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 7331 | vkCmdEndTransformFeedbackEXT(m_commandBuffer->handle(), 0, 1, nullptr, nullptr); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7332 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 7333 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdEndTransformFeedbackEXT-None-02375"); |
| 7334 | vkCmdEndTransformFeedbackEXT(m_commandBuffer->handle(), 0, 1, nullptr, nullptr); |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7335 | m_errorMonitor->VerifyFound(); |
| 7336 | } |
Jeremy Hayes | cd7df2c | 2020-05-21 16:36:47 -0600 | [diff] [blame] | 7337 | } |
| 7338 | } |
sfricke-samsung | 071af2d | 2020-07-02 10:37:22 -0700 | [diff] [blame] | 7339 | |
sfricke-samsung | 39ee244 | 2020-07-22 21:21:15 -0700 | [diff] [blame] | 7340 | TEST_F(VkLayerTest, InvalidUnprotectedCommands) { |
| 7341 | TEST_DESCRIPTION("Test making commands in unprotected command buffers that can't be used"); |
sfricke-samsung | 071af2d | 2020-07-02 10:37:22 -0700 | [diff] [blame] | 7342 | |
| 7343 | // protect memory added in VK 1.1 |
| 7344 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 7345 | |
sjfricke | d8e01c5 | 2022-07-06 14:09:04 +0900 | [diff] [blame] | 7346 | AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 7347 | |
sfricke-samsung | 071af2d | 2020-07-02 10:37:22 -0700 | [diff] [blame] | 7348 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
| 7349 | |
sjfricke | d8e01c5 | 2022-07-06 14:09:04 +0900 | [diff] [blame] | 7350 | if (!AreRequiredExtensionsEnabled()) { |
| 7351 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
| 7352 | } |
| 7353 | |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 7354 | auto protected_memory_features = LvlInitStruct<VkPhysicalDeviceProtectedMemoryFeatures>(); |
sjfricke | 11db0c7 | 2022-08-18 13:23:11 +0900 | [diff] [blame^] | 7355 | auto features2 = GetPhysicalDeviceFeatures2(protected_memory_features); |
sfricke-samsung | 071af2d | 2020-07-02 10:37:22 -0700 | [diff] [blame] | 7356 | |
| 7357 | if (protected_memory_features.protectedMemory == VK_FALSE) { |
| 7358 | printf("%s protectedMemory feature not supported, skipped.\n", kSkipPrefix); |
| 7359 | return; |
| 7360 | }; |
| 7361 | |
| 7362 | // Turns m_commandBuffer into a protected command buffer |
| 7363 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_PROTECTED_BIT)); |
| 7364 | |
| 7365 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7366 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 7367 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
sfricke-samsung | 071af2d | 2020-07-02 10:37:22 -0700 | [diff] [blame] | 7368 | } |
| 7369 | |
| 7370 | VkBufferObj indirect_buffer; |
| 7371 | indirect_buffer.init(*m_device, sizeof(VkDrawIndirectCommand), VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, |
| 7372 | VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT); |
| 7373 | |
| 7374 | VkBufferObj indexed_indirect_buffer; |
| 7375 | indexed_indirect_buffer.init(*m_device, sizeof(VkDrawIndexedIndirectCommand), VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, |
| 7376 | VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT); |
| 7377 | |
| 7378 | VkBufferObj index_buffer; |
| 7379 | index_buffer.init(*m_device, sizeof(uint32_t), VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, VK_BUFFER_USAGE_INDEX_BUFFER_BIT); |
| 7380 | |
| 7381 | CreatePipelineHelper pipe(*this); |
| 7382 | pipe.InitInfo(); |
| 7383 | pipe.InitState(); |
| 7384 | pipe.CreateGraphicsPipeline(); |
| 7385 | |
sfricke-samsung | 39ee244 | 2020-07-22 21:21:15 -0700 | [diff] [blame] | 7386 | VkQueryPool query_pool; |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 7387 | VkQueryPoolCreateInfo query_pool_create_info = LvlInitStruct<VkQueryPoolCreateInfo>(); |
sfricke-samsung | 39ee244 | 2020-07-22 21:21:15 -0700 | [diff] [blame] | 7388 | query_pool_create_info.queryType = VK_QUERY_TYPE_OCCLUSION; |
| 7389 | query_pool_create_info.queryCount = 1; |
| 7390 | vk::CreateQueryPool(m_device->device(), &query_pool_create_info, nullptr, &query_pool); |
| 7391 | |
sfricke-samsung | 071af2d | 2020-07-02 10:37:22 -0700 | [diff] [blame] | 7392 | m_commandBuffer->begin(); |
| 7393 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 7394 | |
| 7395 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_); |
| 7396 | |
| 7397 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndirect-commandBuffer-02711"); |
| 7398 | vk::CmdDrawIndirect(m_commandBuffer->handle(), indirect_buffer.handle(), 0, 1, sizeof(VkDrawIndirectCommand)); |
| 7399 | m_errorMonitor->VerifyFound(); |
| 7400 | |
| 7401 | vk::CmdBindIndexBuffer(m_commandBuffer->handle(), index_buffer.handle(), 0, VK_INDEX_TYPE_UINT32); |
| 7402 | |
| 7403 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndexedIndirect-commandBuffer-02711"); |
| 7404 | vk::CmdDrawIndexedIndirect(m_commandBuffer->handle(), indexed_indirect_buffer.handle(), 0, 1, |
| 7405 | sizeof(VkDrawIndexedIndirectCommand)); |
| 7406 | m_errorMonitor->VerifyFound(); |
| 7407 | |
| 7408 | m_commandBuffer->EndRenderPass(); |
sfricke-samsung | 39ee244 | 2020-07-22 21:21:15 -0700 | [diff] [blame] | 7409 | |
| 7410 | // Query should be outside renderpass |
| 7411 | vk::CmdResetQueryPool(m_commandBuffer->handle(), query_pool, 0, 1); |
| 7412 | |
| 7413 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBeginQuery-commandBuffer-01885"); |
| 7414 | vk::CmdBeginQuery(m_commandBuffer->handle(), query_pool, 0, 0); |
| 7415 | m_errorMonitor->VerifyFound(); |
| 7416 | |
| 7417 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdEndQuery-commandBuffer-01886"); |
| 7418 | m_errorMonitor->SetUnexpectedError("VUID-vkCmdEndQuery-None-01923"); |
| 7419 | vk::CmdEndQuery(m_commandBuffer->handle(), query_pool, 0); |
| 7420 | m_errorMonitor->VerifyFound(); |
| 7421 | |
sfricke-samsung | 071af2d | 2020-07-02 10:37:22 -0700 | [diff] [blame] | 7422 | m_commandBuffer->end(); |
sfricke-samsung | 39ee244 | 2020-07-22 21:21:15 -0700 | [diff] [blame] | 7423 | |
| 7424 | vk::DestroyQueryPool(m_device->device(), query_pool, nullptr); |
sfricke-samsung | 071af2d | 2020-07-02 10:37:22 -0700 | [diff] [blame] | 7425 | } |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7426 | |
| 7427 | TEST_F(VkLayerTest, InvalidMixingProtectedResources) { |
| 7428 | TEST_DESCRIPTION("Test where there is mixing of protectedMemory backed resource in command buffers"); |
| 7429 | |
| 7430 | SetTargetApiVersion(VK_API_VERSION_1_1); |
sjfricke | d8e01c5 | 2022-07-06 14:09:04 +0900 | [diff] [blame] | 7431 | AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7432 | |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7433 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
| 7434 | |
Mark Lobodzinski | c231274 | 2020-08-05 13:57:11 -0600 | [diff] [blame] | 7435 | if (IsPlatform(kShieldTV) || IsPlatform(kShieldTVb)) { |
| 7436 | printf("%s CreateImageView calls crash ShieldTV, skipped for this platform.\n", kSkipPrefix); |
| 7437 | return; |
| 7438 | } |
sjfricke | d8e01c5 | 2022-07-06 14:09:04 +0900 | [diff] [blame] | 7439 | if (!AreRequiredExtensionsEnabled()) { |
| 7440 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
| 7441 | } |
Mark Lobodzinski | c231274 | 2020-08-05 13:57:11 -0600 | [diff] [blame] | 7442 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7443 | PFN_vkGetPhysicalDeviceProperties2KHR vkGetPhysicalDeviceProperties2KHR = |
| 7444 | (PFN_vkGetPhysicalDeviceProperties2KHR)vk::GetInstanceProcAddr(instance(), "vkGetPhysicalDeviceProperties2KHR"); |
| 7445 | ASSERT_TRUE(vkGetPhysicalDeviceProperties2KHR != nullptr); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7446 | |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 7447 | auto protected_memory_features = LvlInitStruct<VkPhysicalDeviceProtectedMemoryFeatures>(); |
sjfricke | 11db0c7 | 2022-08-18 13:23:11 +0900 | [diff] [blame^] | 7448 | auto features2 = GetPhysicalDeviceFeatures2(protected_memory_features); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7449 | |
| 7450 | if (protected_memory_features.protectedMemory == VK_FALSE) { |
| 7451 | printf("%s protectedMemory feature not supported, skipped.\n", kSkipPrefix); |
| 7452 | return; |
| 7453 | }; |
| 7454 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7455 | VkPhysicalDeviceProtectedMemoryProperties protected_memory_properties = |
| 7456 | LvlInitStruct<VkPhysicalDeviceProtectedMemoryProperties>(); |
| 7457 | VkPhysicalDeviceProperties2KHR properties2 = LvlInitStruct<VkPhysicalDeviceProperties2KHR>(&protected_memory_properties); |
| 7458 | vkGetPhysicalDeviceProperties2KHR(gpu(), &properties2); |
| 7459 | |
| 7460 | // Turns m_commandBuffer into a unprotected command buffer without passing in a VkCommandPoolCreateFlags |
sjfricke | 8ab00c1 | 2022-07-08 17:33:48 +0900 | [diff] [blame] | 7461 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7462 | |
| 7463 | VkCommandPoolObj protectedCommandPool(m_device, m_device->graphics_queue_node_index_, VK_COMMAND_POOL_CREATE_PROTECTED_BIT); |
| 7464 | VkCommandBufferObj protectedCommandBuffer(m_device, &protectedCommandPool); |
| 7465 | |
| 7466 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 7467 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7468 | } |
| 7469 | |
| 7470 | // Create actual protected and unprotected buffers |
| 7471 | VkBuffer buffer_protected = VK_NULL_HANDLE; |
| 7472 | VkBuffer buffer_unprotected = VK_NULL_HANDLE; |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 7473 | VkBufferCreateInfo buffer_create_info = LvlInitStruct<VkBufferCreateInfo>(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7474 | buffer_create_info.size = 1 << 20; // 1 MB |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 7475 | buffer_create_info.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | |
| 7476 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT | |
| 7477 | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT; |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7478 | buffer_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 7479 | |
| 7480 | buffer_create_info.flags = VK_BUFFER_CREATE_PROTECTED_BIT; |
| 7481 | vk::CreateBuffer(device(), &buffer_create_info, nullptr, &buffer_protected); |
| 7482 | buffer_create_info.flags = 0; |
| 7483 | vk::CreateBuffer(device(), &buffer_create_info, nullptr, &buffer_unprotected); |
| 7484 | |
| 7485 | // Create actual protected and unprotected images |
sfricke-samsung | 27d3c1e | 2021-07-16 22:36:48 -0700 | [diff] [blame] | 7486 | const VkFormat image_format = VK_FORMAT_R8G8B8A8_UNORM; |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7487 | VkImageObj image_protected(m_device); |
| 7488 | VkImageObj image_unprotected(m_device); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 7489 | VkImageObj image_protected_descriptor(m_device); |
| 7490 | VkImageObj image_unprotected_descriptor(m_device); |
sfricke-samsung | c1c43b0 | 2020-08-04 00:21:48 -0700 | [diff] [blame] | 7491 | VkImageView image_views[2]; |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 7492 | VkImageView image_views_descriptor[2]; |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 7493 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7494 | image_create_info.extent = {64, 64, 1}; |
sfricke-samsung | 27d3c1e | 2021-07-16 22:36:48 -0700 | [diff] [blame] | 7495 | image_create_info.format = image_format; |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7496 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7497 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 7498 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | |
| 7499 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT; |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7500 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7501 | image_create_info.arrayLayers = 1; |
| 7502 | image_create_info.mipLevels = 1; |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7503 | image_create_info.flags = VK_IMAGE_CREATE_PROTECTED_BIT; |
| 7504 | image_protected.init_no_mem(*m_device, image_create_info); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 7505 | image_protected_descriptor.init_no_mem(*m_device, image_create_info); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 7506 | |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7507 | image_create_info.flags = 0; |
| 7508 | image_unprotected.init_no_mem(*m_device, image_create_info); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 7509 | image_unprotected_descriptor.init_no_mem(*m_device, image_create_info); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 7510 | |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7511 | // Create protected and unproteced memory |
| 7512 | VkDeviceMemory memory_protected = VK_NULL_HANDLE; |
| 7513 | VkDeviceMemory memory_unprotected = VK_NULL_HANDLE; |
| 7514 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 7515 | VkMemoryAllocateInfo alloc_info = LvlInitStruct<VkMemoryAllocateInfo>(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7516 | alloc_info.allocationSize = 0; |
| 7517 | |
| 7518 | // set allocationSize to buffer as it will be larger than the image, but query image to avoid BP warning |
| 7519 | VkMemoryRequirements mem_reqs_protected; |
| 7520 | vk::GetImageMemoryRequirements(device(), image_protected.handle(), &mem_reqs_protected); |
| 7521 | vk::GetBufferMemoryRequirements(device(), buffer_protected, &mem_reqs_protected); |
| 7522 | VkMemoryRequirements mem_reqs_unprotected; |
| 7523 | vk::GetImageMemoryRequirements(device(), image_unprotected.handle(), &mem_reqs_unprotected); |
| 7524 | vk::GetBufferMemoryRequirements(device(), buffer_unprotected, &mem_reqs_unprotected); |
| 7525 | |
| 7526 | // Get memory index for a protected and unprotected memory |
| 7527 | VkPhysicalDeviceMemoryProperties phys_mem_props; |
| 7528 | vk::GetPhysicalDeviceMemoryProperties(gpu(), &phys_mem_props); |
| 7529 | uint32_t memory_type_protected = phys_mem_props.memoryTypeCount + 1; |
| 7530 | uint32_t memory_type_unprotected = phys_mem_props.memoryTypeCount + 1; |
| 7531 | for (uint32_t i = 0; i < phys_mem_props.memoryTypeCount; i++) { |
| 7532 | if ((mem_reqs_unprotected.memoryTypeBits & (1 << i)) && |
| 7533 | ((phys_mem_props.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) == |
| 7534 | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) { |
| 7535 | memory_type_unprotected = i; |
| 7536 | } |
| 7537 | // Check just protected bit is in type at all |
| 7538 | if ((mem_reqs_protected.memoryTypeBits & (1 << i)) && |
| 7539 | ((phys_mem_props.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_PROTECTED_BIT) != 0)) { |
| 7540 | memory_type_protected = i; |
| 7541 | } |
| 7542 | } |
| 7543 | if ((memory_type_protected >= phys_mem_props.memoryTypeCount) || (memory_type_unprotected >= phys_mem_props.memoryTypeCount)) { |
| 7544 | printf("%s No valid memory type index could be found; skipped.\n", kSkipPrefix); |
| 7545 | vk::DestroyBuffer(device(), buffer_protected, nullptr); |
| 7546 | vk::DestroyBuffer(device(), buffer_unprotected, nullptr); |
| 7547 | return; |
| 7548 | } |
| 7549 | |
| 7550 | alloc_info.memoryTypeIndex = memory_type_protected; |
| 7551 | alloc_info.allocationSize = mem_reqs_protected.size; |
| 7552 | vk::AllocateMemory(device(), &alloc_info, NULL, &memory_protected); |
| 7553 | |
| 7554 | alloc_info.allocationSize = mem_reqs_unprotected.size; |
| 7555 | alloc_info.memoryTypeIndex = memory_type_unprotected; |
| 7556 | vk::AllocateMemory(device(), &alloc_info, NULL, &memory_unprotected); |
| 7557 | |
| 7558 | vk::BindBufferMemory(device(), buffer_protected, memory_protected, 0); |
| 7559 | vk::BindBufferMemory(device(), buffer_unprotected, memory_unprotected, 0); |
| 7560 | vk::BindImageMemory(device(), image_protected.handle(), memory_protected, 0); |
| 7561 | vk::BindImageMemory(device(), image_unprotected.handle(), memory_unprotected, 0); |
sfricke-samsung | 27d3c1e | 2021-07-16 22:36:48 -0700 | [diff] [blame] | 7562 | vk::BindImageMemory(device(), image_protected_descriptor.handle(), memory_protected, 0); |
| 7563 | vk::BindImageMemory(device(), image_unprotected_descriptor.handle(), memory_unprotected, 0); |
| 7564 | |
Aitor Camacho | 6ba32ff | 2022-06-16 19:11:12 +0200 | [diff] [blame] | 7565 | // Change layout once memory is bound |
| 7566 | image_protected.SetLayout(VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL); |
| 7567 | image_protected_descriptor.SetLayout(VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL); |
| 7568 | image_unprotected.SetLayout(VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL); |
| 7569 | image_unprotected_descriptor.SetLayout(VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL); |
| 7570 | |
sfricke-samsung | 27d3c1e | 2021-07-16 22:36:48 -0700 | [diff] [blame] | 7571 | // need memory bound at image view creation time |
| 7572 | image_views[0] = image_protected.targetView(image_format); |
| 7573 | image_views[1] = image_unprotected.targetView(image_format); |
| 7574 | image_views_descriptor[0] = image_protected_descriptor.targetView(image_format); |
| 7575 | image_views_descriptor[1] = image_unprotected_descriptor.targetView(image_format); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7576 | |
sfricke-samsung | c1c43b0 | 2020-08-04 00:21:48 -0700 | [diff] [blame] | 7577 | // A renderpass and framebuffer that contains a protected and unprotected image view |
| 7578 | VkAttachmentDescription attachments[2] = { |
sfricke-samsung | 27d3c1e | 2021-07-16 22:36:48 -0700 | [diff] [blame] | 7579 | {0, image_format, VK_SAMPLE_COUNT_1_BIT, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
sfricke-samsung | c1c43b0 | 2020-08-04 00:21:48 -0700 | [diff] [blame] | 7580 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_IMAGE_LAYOUT_UNDEFINED, |
| 7581 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}, |
sfricke-samsung | 27d3c1e | 2021-07-16 22:36:48 -0700 | [diff] [blame] | 7582 | {0, image_format, VK_SAMPLE_COUNT_1_BIT, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
sfricke-samsung | c1c43b0 | 2020-08-04 00:21:48 -0700 | [diff] [blame] | 7583 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_IMAGE_LAYOUT_UNDEFINED, |
| 7584 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}, |
| 7585 | }; |
| 7586 | VkAttachmentReference references[2] = {{0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}, |
| 7587 | {1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}}; |
| 7588 | VkSubpassDescription subpass = {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 2, references, nullptr, nullptr, 0, nullptr}; |
| 7589 | VkSubpassDependency dependency = {0, |
| 7590 | 0, |
| 7591 | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, |
| 7592 | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, |
| 7593 | VK_ACCESS_SHADER_WRITE_BIT, |
| 7594 | VK_ACCESS_SHADER_WRITE_BIT, |
| 7595 | VK_DEPENDENCY_BY_REGION_BIT}; |
| 7596 | VkRenderPassCreateInfo render_pass_create_info = { |
| 7597 | VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, 0, 2, attachments, 1, &subpass, 1, &dependency}; |
| 7598 | VkRenderPass render_pass; |
| 7599 | ASSERT_VK_SUCCESS(vk::CreateRenderPass(device(), &render_pass_create_info, nullptr, &render_pass)); |
| 7600 | VkFramebufferCreateInfo framebuffer_create_info = { |
| 7601 | VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, nullptr, 0, render_pass, 2, image_views, 8, 8, 1}; |
| 7602 | VkFramebuffer framebuffer; |
| 7603 | ASSERT_VK_SUCCESS(vk::CreateFramebuffer(device(), &framebuffer_create_info, nullptr, &framebuffer)); |
| 7604 | |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7605 | // Various structs used for commands |
| 7606 | VkImageSubresourceLayers image_subresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}; |
| 7607 | VkImageBlit blit_region = {}; |
| 7608 | blit_region.srcSubresource = image_subresource; |
| 7609 | blit_region.dstSubresource = image_subresource; |
| 7610 | blit_region.srcOffsets[0] = {0, 0, 0}; |
| 7611 | blit_region.srcOffsets[1] = {8, 8, 1}; |
| 7612 | blit_region.dstOffsets[0] = {0, 8, 0}; |
| 7613 | blit_region.dstOffsets[1] = {8, 8, 1}; |
| 7614 | VkClearColorValue clear_color = {{0, 0, 0, 0}}; |
| 7615 | VkImageSubresourceRange subresource_range = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; |
| 7616 | VkBufferCopy buffer_copy = {0, 0, 64}; |
| 7617 | VkBufferImageCopy buffer_image_copy = {}; |
| 7618 | buffer_image_copy.bufferRowLength = 0; |
| 7619 | buffer_image_copy.bufferImageHeight = 0; |
| 7620 | buffer_image_copy.imageSubresource = image_subresource; |
| 7621 | buffer_image_copy.imageOffset = {0, 0, 0}; |
| 7622 | buffer_image_copy.imageExtent = {1, 1, 1}; |
| 7623 | buffer_image_copy.bufferOffset = 0; |
| 7624 | VkImageCopy image_copy = {}; |
| 7625 | image_copy.srcSubresource = image_subresource; |
| 7626 | image_copy.srcOffset = {0, 0, 0}; |
| 7627 | image_copy.dstSubresource = image_subresource; |
| 7628 | image_copy.dstOffset = {0, 0, 0}; |
| 7629 | image_copy.extent = {1, 1, 1}; |
| 7630 | uint32_t update_data[4] = {0, 0, 0, 0}; |
sfricke-samsung | c1c43b0 | 2020-08-04 00:21:48 -0700 | [diff] [blame] | 7631 | VkRect2D render_area = {{0, 0}, {8, 8}}; |
| 7632 | VkRenderPassBeginInfo render_pass_begin = { |
| 7633 | VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, nullptr, render_pass, framebuffer, render_area, 0, nullptr}; |
| 7634 | VkClearAttachment clear_attachments[2] = {{VK_IMAGE_ASPECT_COLOR_BIT, 0, {m_clear_color}}, |
| 7635 | {VK_IMAGE_ASPECT_COLOR_BIT, 1, {m_clear_color}}}; |
| 7636 | VkClearRect clear_rect[2] = {{render_area, 0, 1}, {render_area, 0, 1}}; |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7637 | |
sfricke-samsung | 1c0b96a | 2021-07-08 22:24:09 -0700 | [diff] [blame] | 7638 | const char fsSource[] = R"glsl( |
| 7639 | #version 450 |
| 7640 | layout(set=0, binding=0) uniform foo { int x; int y; } bar; |
| 7641 | layout(set=0, binding=1, rgba8) uniform image2D si1; |
| 7642 | layout(location=0) out vec4 x; |
| 7643 | void main(){ |
| 7644 | x = vec4(bar.y); |
| 7645 | imageStore(si1, ivec2(0), vec4(0)); |
| 7646 | } |
| 7647 | )glsl"; |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 7648 | VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 7649 | |
aitor-lunarg | f15acd5 | 2022-03-09 22:13:25 +0100 | [diff] [blame] | 7650 | CreatePipelineHelper g_pipe(*this, 2u); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 7651 | g_pipe.InitInfo(); |
| 7652 | g_pipe.gp_ci_.renderPass = render_pass; |
| 7653 | g_pipe.shader_stages_ = {g_pipe.vs_->GetStageCreateInfo(), fs.GetStageCreateInfo()}; |
| 7654 | g_pipe.dsl_bindings_ = {{0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr}, |
| 7655 | {1, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr}}; |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 7656 | g_pipe.InitState(); |
| 7657 | ASSERT_VK_SUCCESS(g_pipe.CreateGraphicsPipeline()); |
| 7658 | |
| 7659 | VkSampler sampler; |
| 7660 | VkSamplerCreateInfo sampler_ci = SafeSaneSamplerCreateInfo(); |
| 7661 | VkResult err = vk::CreateSampler(m_device->device(), &sampler_ci, nullptr, &sampler); |
| 7662 | ASSERT_VK_SUCCESS(err); |
| 7663 | |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7664 | // Use protected resources in unprotected command buffer |
sfricke-samsung | 3642846 | 2021-02-10 01:23:34 -0800 | [diff] [blame] | 7665 | g_pipe.descriptor_set_->WriteDescriptorBufferInfo(0, buffer_protected, 0, 1024); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 7666 | g_pipe.descriptor_set_->WriteDescriptorImageInfo(1, image_views_descriptor[0], sampler, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, |
| 7667 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); |
| 7668 | g_pipe.descriptor_set_->UpdateDescriptorSets(); |
| 7669 | |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7670 | m_commandBuffer->begin(); |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7671 | // will get undefined values, but not invalid if protectedNoFault is supported |
| 7672 | // Will still create an empty command buffer to test submit VUs if protectedNoFault is supported |
| 7673 | if (!protected_memory_properties.protectedNoFault) { |
| 7674 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBlitImage-commandBuffer-01834"); |
| 7675 | vk::CmdBlitImage(m_commandBuffer->handle(), image_protected.handle(), VK_IMAGE_LAYOUT_GENERAL, image_unprotected.handle(), |
| 7676 | VK_IMAGE_LAYOUT_GENERAL, 1, &blit_region, VK_FILTER_NEAREST); |
| 7677 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7678 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7679 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBlitImage-commandBuffer-01835"); |
| 7680 | vk::CmdBlitImage(m_commandBuffer->handle(), image_unprotected.handle(), VK_IMAGE_LAYOUT_GENERAL, image_protected.handle(), |
| 7681 | VK_IMAGE_LAYOUT_GENERAL, 1, &blit_region, VK_FILTER_NEAREST); |
| 7682 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7683 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7684 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdClearColorImage-commandBuffer-01805"); |
| 7685 | vk::CmdClearColorImage(m_commandBuffer->handle(), image_protected.handle(), VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, |
| 7686 | &subresource_range); |
| 7687 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7688 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7689 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyBuffer-commandBuffer-01822"); |
| 7690 | vk::CmdCopyBuffer(m_commandBuffer->handle(), buffer_protected, buffer_unprotected, 1, &buffer_copy); |
| 7691 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7692 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7693 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyBuffer-commandBuffer-01823"); |
| 7694 | vk::CmdCopyBuffer(m_commandBuffer->handle(), buffer_unprotected, buffer_protected, 1, &buffer_copy); |
| 7695 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7696 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7697 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyBufferToImage-commandBuffer-01828"); |
| 7698 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_protected, image_unprotected.handle(), VK_IMAGE_LAYOUT_GENERAL, |
| 7699 | 1, &buffer_image_copy); |
| 7700 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7701 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7702 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyBufferToImage-commandBuffer-01829"); |
| 7703 | vk::CmdCopyBufferToImage(m_commandBuffer->handle(), buffer_unprotected, image_protected.handle(), VK_IMAGE_LAYOUT_GENERAL, |
| 7704 | 1, &buffer_image_copy); |
| 7705 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7706 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7707 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-commandBuffer-01825"); |
| 7708 | vk::CmdCopyImage(m_commandBuffer->handle(), image_protected.handle(), VK_IMAGE_LAYOUT_GENERAL, image_unprotected.handle(), |
| 7709 | VK_IMAGE_LAYOUT_GENERAL, 1, &image_copy); |
| 7710 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7711 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7712 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-commandBuffer-01826"); |
| 7713 | vk::CmdCopyImage(m_commandBuffer->handle(), image_unprotected.handle(), VK_IMAGE_LAYOUT_GENERAL, image_protected.handle(), |
| 7714 | VK_IMAGE_LAYOUT_GENERAL, 1, &image_copy); |
| 7715 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7716 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7717 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImageToBuffer-commandBuffer-01831"); |
| 7718 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_protected.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_unprotected, |
| 7719 | 1, &buffer_image_copy); |
| 7720 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7721 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7722 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImageToBuffer-commandBuffer-01832"); |
| 7723 | vk::CmdCopyImageToBuffer(m_commandBuffer->handle(), image_unprotected.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_protected, |
| 7724 | 1, &buffer_image_copy); |
| 7725 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7726 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7727 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdFillBuffer-commandBuffer-01811"); |
| 7728 | vk::CmdFillBuffer(m_commandBuffer->handle(), buffer_protected, 0, 4, 0); |
| 7729 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7730 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7731 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdUpdateBuffer-commandBuffer-01813"); |
| 7732 | vk::CmdUpdateBuffer(m_commandBuffer->handle(), buffer_protected, 0, 4, (void *)update_data); |
| 7733 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7734 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7735 | vk::CmdBeginRenderPass(m_commandBuffer->handle(), &render_pass_begin, VK_SUBPASS_CONTENTS_INLINE); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7736 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7737 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdClearAttachments-commandBuffer-02504"); |
| 7738 | vk::CmdClearAttachments(m_commandBuffer->handle(), 2, clear_attachments, 2, clear_rect); |
| 7739 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | c1c43b0 | 2020-08-04 00:21:48 -0700 | [diff] [blame] | 7740 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7741 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, g_pipe.pipeline_); |
| 7742 | vk::CmdBindDescriptorSets(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, g_pipe.pipeline_layout_.handle(), 0, |
| 7743 | 1, &g_pipe.descriptor_set_->set_, 0, nullptr); |
| 7744 | VkDeviceSize offset = 0; |
| 7745 | vk::CmdBindVertexBuffers(m_commandBuffer->handle(), 0, 1, &buffer_protected, &offset); |
| 7746 | vk::CmdBindIndexBuffer(m_commandBuffer->handle(), buffer_protected, 0, VK_INDEX_TYPE_UINT16); |
sfricke-samsung | c1c43b0 | 2020-08-04 00:21:48 -0700 | [diff] [blame] | 7747 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7748 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndexed-commandBuffer-02707"); // color attachment |
| 7749 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndexed-commandBuffer-02707"); // buffer descriptorSet |
| 7750 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndexed-commandBuffer-02707"); // image descriptorSet |
| 7751 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndexed-commandBuffer-02707"); // vertex |
| 7752 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndexed-commandBuffer-02707"); // index |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 7753 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7754 | vk::CmdDrawIndexed(m_commandBuffer->handle(), 1, 0, 0, 0, 0); |
| 7755 | m_errorMonitor->VerifyFound(); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 7756 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7757 | vk::CmdEndRenderPass(m_commandBuffer->handle()); |
| 7758 | } |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7759 | m_commandBuffer->end(); |
| 7760 | |
| 7761 | // Use unprotected resources in protected command buffer |
sfricke-samsung | 3642846 | 2021-02-10 01:23:34 -0800 | [diff] [blame] | 7762 | g_pipe.descriptor_set_->WriteDescriptorBufferInfo(0, buffer_unprotected, 0, 1024); |
locke-lunarg | 5ec8ddf | 2020-11-25 01:05:55 -0700 | [diff] [blame] | 7763 | g_pipe.descriptor_set_->WriteDescriptorImageInfo(1, image_views_descriptor[1], sampler, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, |
| 7764 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 7765 | g_pipe.descriptor_set_->UpdateDescriptorSets(); |
| 7766 | |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7767 | protectedCommandBuffer.begin(); |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7768 | if (!protected_memory_properties.protectedNoFault) { |
| 7769 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBlitImage-commandBuffer-01836"); |
| 7770 | vk::CmdBlitImage(protectedCommandBuffer.handle(), image_protected.handle(), VK_IMAGE_LAYOUT_GENERAL, |
| 7771 | image_unprotected.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &blit_region, VK_FILTER_NEAREST); |
| 7772 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7773 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7774 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdClearColorImage-commandBuffer-01806"); |
| 7775 | vk::CmdClearColorImage(protectedCommandBuffer.handle(), image_unprotected.handle(), VK_IMAGE_LAYOUT_GENERAL, &clear_color, |
| 7776 | 1, &subresource_range); |
| 7777 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7778 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7779 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyBuffer-commandBuffer-01824"); |
| 7780 | vk::CmdCopyBuffer(protectedCommandBuffer.handle(), buffer_protected, buffer_unprotected, 1, &buffer_copy); |
| 7781 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7782 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7783 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyBufferToImage-commandBuffer-01830"); |
| 7784 | vk::CmdCopyBufferToImage(protectedCommandBuffer.handle(), buffer_protected, image_unprotected.handle(), |
| 7785 | VK_IMAGE_LAYOUT_GENERAL, 1, &buffer_image_copy); |
| 7786 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7787 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7788 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImage-commandBuffer-01827"); |
| 7789 | vk::CmdCopyImage(protectedCommandBuffer.handle(), image_protected.handle(), VK_IMAGE_LAYOUT_GENERAL, |
| 7790 | image_unprotected.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &image_copy); |
| 7791 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7792 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7793 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdCopyImageToBuffer-commandBuffer-01833"); |
| 7794 | vk::CmdCopyImageToBuffer(protectedCommandBuffer.handle(), image_protected.handle(), VK_IMAGE_LAYOUT_GENERAL, |
| 7795 | buffer_unprotected, 1, &buffer_image_copy); |
| 7796 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7797 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7798 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdFillBuffer-commandBuffer-01812"); |
| 7799 | vk::CmdFillBuffer(protectedCommandBuffer.handle(), buffer_unprotected, 0, 4, 0); |
| 7800 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7801 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7802 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdUpdateBuffer-commandBuffer-01814"); |
| 7803 | vk::CmdUpdateBuffer(protectedCommandBuffer.handle(), buffer_unprotected, 0, 4, (void *)update_data); |
| 7804 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7805 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7806 | vk::CmdBeginRenderPass(protectedCommandBuffer.handle(), &render_pass_begin, VK_SUBPASS_CONTENTS_INLINE); |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7807 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7808 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdClearAttachments-commandBuffer-02505"); |
| 7809 | vk::CmdClearAttachments(protectedCommandBuffer.handle(), 2, clear_attachments, 2, clear_rect); |
| 7810 | m_errorMonitor->VerifyFound(); |
sfricke-samsung | c1c43b0 | 2020-08-04 00:21:48 -0700 | [diff] [blame] | 7811 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7812 | vk::CmdBindPipeline(protectedCommandBuffer.handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, g_pipe.pipeline_); |
| 7813 | vk::CmdBindDescriptorSets(protectedCommandBuffer.handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 7814 | g_pipe.pipeline_layout_.handle(), 0, 1, &g_pipe.descriptor_set_->set_, 0, nullptr); |
| 7815 | VkDeviceSize offset = 0; |
| 7816 | vk::CmdBindVertexBuffers(protectedCommandBuffer.handle(), 0, 1, &buffer_unprotected, &offset); |
| 7817 | vk::CmdBindIndexBuffer(protectedCommandBuffer.handle(), buffer_unprotected, 0, VK_INDEX_TYPE_UINT16); |
sfricke-samsung | c1c43b0 | 2020-08-04 00:21:48 -0700 | [diff] [blame] | 7818 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7819 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndexed-commandBuffer-02712"); // color attachment |
| 7820 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndexed-commandBuffer-02712"); // descriptorSet |
| 7821 | vk::CmdDrawIndexed(protectedCommandBuffer.handle(), 1, 0, 0, 0, 0); |
| 7822 | m_errorMonitor->VerifyFound(); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 7823 | |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7824 | vk::CmdEndRenderPass(protectedCommandBuffer.handle()); |
| 7825 | } |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7826 | protectedCommandBuffer.end(); |
| 7827 | |
sfricke-samsung | 96cd993 | 2020-08-23 20:57:11 -0700 | [diff] [blame] | 7828 | // Try submitting together to test only 1 error occurs for the corresponding command buffer |
| 7829 | VkCommandBuffer comman_buffers[2] = {m_commandBuffer->handle(), protectedCommandBuffer.handle()}; |
| 7830 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 7831 | VkProtectedSubmitInfo protected_submit_info = LvlInitStruct<VkProtectedSubmitInfo>(); |
| 7832 | VkSubmitInfo submit_info = LvlInitStruct<VkSubmitInfo>(&protected_submit_info); |
sfricke-samsung | 96cd993 | 2020-08-23 20:57:11 -0700 | [diff] [blame] | 7833 | submit_info.commandBufferCount = 2; |
| 7834 | submit_info.pCommandBuffers = comman_buffers; |
| 7835 | |
| 7836 | protected_submit_info.protectedSubmit = VK_TRUE; |
sfricke-samsung | 21286f8 | 2021-11-16 08:21:46 -0800 | [diff] [blame] | 7837 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkQueueSubmit-queue-06448"); |
Shannon McPherson | 2c793ba | 2020-08-28 12:13:24 -0600 | [diff] [blame] | 7838 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo-pNext-04148"); |
sfricke-samsung | 96cd993 | 2020-08-23 20:57:11 -0700 | [diff] [blame] | 7839 | vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 7840 | m_errorMonitor->VerifyFound(); |
| 7841 | |
| 7842 | protected_submit_info.protectedSubmit = VK_FALSE; |
| 7843 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo-pNext-04120"); |
| 7844 | vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 7845 | m_errorMonitor->VerifyFound(); |
| 7846 | |
sfricke-samsung | 2aaf66f | 2020-07-24 03:26:22 -0700 | [diff] [blame] | 7847 | vk::DestroyBuffer(device(), buffer_protected, nullptr); |
| 7848 | vk::DestroyBuffer(device(), buffer_unprotected, nullptr); |
| 7849 | vk::FreeMemory(device(), memory_protected, nullptr); |
| 7850 | vk::FreeMemory(device(), memory_unprotected, nullptr); |
sfricke-samsung | c1c43b0 | 2020-08-04 00:21:48 -0700 | [diff] [blame] | 7851 | vk::DestroyFramebuffer(device(), framebuffer, nullptr); |
| 7852 | vk::DestroyRenderPass(device(), render_pass, nullptr); |
Mark Lobodzinski | c231274 | 2020-08-05 13:57:11 -0600 | [diff] [blame] | 7853 | } |
locke-lunarg | 6b0de70 | 2020-08-07 17:42:13 -0600 | [diff] [blame] | 7854 | |
Tony-LunarG | 1ed322e | 2021-06-04 12:59:27 -0600 | [diff] [blame] | 7855 | TEST_F(VkLayerTest, InvalidStorageAtomicOperation) { |
locke-lunarg | 6b0de70 | 2020-08-07 17:42:13 -0600 | [diff] [blame] | 7856 | TEST_DESCRIPTION( |
| 7857 | "If storage view use atomic operation, the view's format MUST support VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT or " |
| 7858 | "VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT "); |
| 7859 | |
sjfricke | d8e01c5 | 2022-07-06 14:09:04 +0900 | [diff] [blame] | 7860 | AddRequiredExtensions(VK_EXT_SHADER_ATOMIC_FLOAT_EXTENSION_NAME); |
sfricke-samsung | bbd74ca | 2021-08-05 01:09:56 -0700 | [diff] [blame] | 7861 | |
sjfricke | d8e01c5 | 2022-07-06 14:09:04 +0900 | [diff] [blame] | 7862 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
| 7863 | if (!AreRequiredExtensionsEnabled()) { |
| 7864 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
| 7865 | } |
sfricke-samsung | bbd74ca | 2021-08-05 01:09:56 -0700 | [diff] [blame] | 7866 | |
| 7867 | auto atomic_float_features = lvl_init_struct<VkPhysicalDeviceShaderAtomicFloatFeaturesEXT>(); |
sjfricke | 11db0c7 | 2022-08-18 13:23:11 +0900 | [diff] [blame^] | 7868 | auto features2 = GetPhysicalDeviceFeatures2(atomic_float_features); |
sfricke-samsung | bbd74ca | 2021-08-05 01:09:56 -0700 | [diff] [blame] | 7869 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 7870 | |
| 7871 | if (atomic_float_features.shaderImageFloat32Atomics == VK_FALSE) { |
| 7872 | printf("%s shaderImageFloat32Atomics not supported. Skipping test.\n", kSkipPrefix); |
| 7873 | return; |
| 7874 | } |
locke-lunarg | 6b0de70 | 2020-08-07 17:42:13 -0600 | [diff] [blame] | 7875 | |
| 7876 | VkImageUsageFlags usage = VK_IMAGE_USAGE_STORAGE_BIT; |
| 7877 | VkFormat image_format = VK_FORMAT_R8G8B8A8_UNORM; // The format doesn't support VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT to |
| 7878 | // cause DesiredFailure. VK_FORMAT_R32_UINT is right format. |
| 7879 | auto image_ci = VkImageObj::ImageCreateInfo2D(64, 64, 1, 1, image_format, usage, VK_IMAGE_TILING_OPTIMAL); |
| 7880 | |
| 7881 | if (ImageFormatAndFeaturesSupported(instance(), gpu(), image_ci, VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT)) { |
| 7882 | printf("%s Cannot make VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT not supported. Skipping test.\n", kSkipPrefix); |
| 7883 | return; |
| 7884 | } |
| 7885 | |
| 7886 | VkFormat buffer_view_format = |
| 7887 | VK_FORMAT_R8_UNORM; // The format doesn't support VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT to |
| 7888 | // cause DesiredFailure. VK_FORMAT_R32_UINT is right format. |
| 7889 | if (BufferFormatAndFeaturesSupported(gpu(), buffer_view_format, VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT)) { |
| 7890 | printf("%s Cannot make VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT not supported. Skipping test.\n", kSkipPrefix); |
| 7891 | return; |
| 7892 | } |
Nathaniel Cesario | b3f17dc | 2021-08-17 12:52:22 -0600 | [diff] [blame] | 7893 | m_errorMonitor->SetUnexpectedError("VUID-VkBufferViewCreateInfo-buffer-00934"); |
locke-lunarg | 6b0de70 | 2020-08-07 17:42:13 -0600 | [diff] [blame] | 7894 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7895 | |
| 7896 | VkPhysicalDeviceFeatures device_features = {}; |
| 7897 | ASSERT_NO_FATAL_FAILURE(GetPhysicalDeviceFeatures(&device_features)); |
| 7898 | if (!device_features.vertexPipelineStoresAndAtomics || !device_features.fragmentStoresAndAtomics) { |
| 7899 | printf("%s vertexPipelineStoresAndAtomics & fragmentStoresAndAtomics NOT supported. skipped.\n", kSkipPrefix); |
| 7900 | return; |
| 7901 | } |
| 7902 | |
| 7903 | VkImageObj image(m_device); |
| 7904 | image.Init(image_ci); |
| 7905 | VkImageView image_view = image.targetView(image_format); |
| 7906 | |
| 7907 | VkSampler sampler = VK_NULL_HANDLE; |
| 7908 | VkSamplerCreateInfo sampler_info = SafeSaneSamplerCreateInfo(); |
| 7909 | vk::CreateSampler(m_device->device(), &sampler_info, NULL, &sampler); |
| 7910 | |
| 7911 | VkBufferObj buffer; |
| 7912 | buffer.init(*m_device, 64, 0, VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT); |
| 7913 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 7914 | VkBufferViewCreateInfo bvci = LvlInitStruct<VkBufferViewCreateInfo>(); |
locke-lunarg | 6b0de70 | 2020-08-07 17:42:13 -0600 | [diff] [blame] | 7915 | bvci.buffer = buffer.handle(); |
| 7916 | bvci.format = buffer_view_format; |
| 7917 | bvci.range = VK_WHOLE_SIZE; |
| 7918 | VkBufferView buffer_view; |
| 7919 | vk::CreateBufferView(m_device->device(), &bvci, NULL, &buffer_view); |
| 7920 | |
sfricke-samsung | 1c0b96a | 2021-07-08 22:24:09 -0700 | [diff] [blame] | 7921 | char const *fsSource = R"glsl( |
| 7922 | #version 450 |
| 7923 | layout(set=0, binding=3, r32f) uniform image2D si0; |
| 7924 | layout(set=0, binding=2, r32f) uniform image2D si1[2]; |
| 7925 | layout(set = 0, binding = 1, r32f) uniform imageBuffer stb2; |
| 7926 | layout(set = 0, binding = 0, r32f) uniform imageBuffer stb3[2]; |
| 7927 | void main() { |
| 7928 | imageAtomicExchange(si0, ivec2(0), 1); |
| 7929 | imageAtomicExchange(si1[0], ivec2(0), 1); |
| 7930 | imageAtomicExchange(si1[1], ivec2(0), 1); |
| 7931 | imageAtomicExchange(stb2, 0, 1); |
| 7932 | imageAtomicExchange(stb3[0], 0, 1); |
| 7933 | imageAtomicExchange(stb3[1], 0, 1); |
| 7934 | } |
| 7935 | )glsl"; |
locke-lunarg | 6b0de70 | 2020-08-07 17:42:13 -0600 | [diff] [blame] | 7936 | |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 7937 | VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT); |
| 7938 | VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT); |
locke-lunarg | 6b0de70 | 2020-08-07 17:42:13 -0600 | [diff] [blame] | 7939 | |
| 7940 | CreatePipelineHelper g_pipe(*this); |
| 7941 | g_pipe.InitInfo(); |
| 7942 | g_pipe.shader_stages_ = {vs.GetStageCreateInfo(), fs.GetStageCreateInfo()}; |
locke-lunarg | 76e8dee | 2020-08-21 13:20:02 -0600 | [diff] [blame] | 7943 | g_pipe.dsl_bindings_ = {{3, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr}, |
| 7944 | {2, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 2, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr}, |
| 7945 | {1, VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr}, |
| 7946 | {0, VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, 2, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr}}; |
locke-lunarg | 6b0de70 | 2020-08-07 17:42:13 -0600 | [diff] [blame] | 7947 | g_pipe.InitState(); |
| 7948 | ASSERT_VK_SUCCESS(g_pipe.CreateGraphicsPipeline()); |
| 7949 | |
locke-lunarg | 76e8dee | 2020-08-21 13:20:02 -0600 | [diff] [blame] | 7950 | g_pipe.descriptor_set_->WriteDescriptorImageInfo(3, image_view, sampler, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, |
locke-lunarg | 6b0de70 | 2020-08-07 17:42:13 -0600 | [diff] [blame] | 7951 | VK_IMAGE_LAYOUT_GENERAL); |
locke-lunarg | 76e8dee | 2020-08-21 13:20:02 -0600 | [diff] [blame] | 7952 | g_pipe.descriptor_set_->WriteDescriptorImageInfo(2, image_view, sampler, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, |
sfricke-samsung | 392ba9f | 2021-03-05 02:23:21 -0800 | [diff] [blame] | 7953 | VK_IMAGE_LAYOUT_GENERAL, 0, 2); |
locke-lunarg | 76e8dee | 2020-08-21 13:20:02 -0600 | [diff] [blame] | 7954 | g_pipe.descriptor_set_->WriteDescriptorBufferView(1, buffer_view); |
sfricke-samsung | 392ba9f | 2021-03-05 02:23:21 -0800 | [diff] [blame] | 7955 | g_pipe.descriptor_set_->WriteDescriptorBufferView(0, buffer_view, VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, 0, 2); |
locke-lunarg | 6b0de70 | 2020-08-07 17:42:13 -0600 | [diff] [blame] | 7956 | g_pipe.descriptor_set_->UpdateDescriptorSets(); |
| 7957 | |
| 7958 | m_commandBuffer->begin(); |
| 7959 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 7960 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, g_pipe.pipeline_); |
| 7961 | vk::CmdBindDescriptorSets(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, g_pipe.pipeline_layout_.handle(), 0, 1, |
| 7962 | &g_pipe.descriptor_set_->set_, 0, nullptr); |
| 7963 | |
| 7964 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-vkCmdDraw-None-02691"); |
| 7965 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-vkCmdDraw-None-02691"); |
| 7966 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "UNASSIGNED-None-MismatchAtomicBufferFeature"); |
| 7967 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "UNASSIGNED-None-MismatchAtomicBufferFeature"); |
| 7968 | vk::CmdDraw(m_commandBuffer->handle(), 1, 0, 0, 0); |
| 7969 | m_errorMonitor->VerifyFound(); |
| 7970 | |
| 7971 | m_commandBuffer->EndRenderPass(); |
| 7972 | m_commandBuffer->end(); |
Tony-LunarG | 1ed322e | 2021-06-04 12:59:27 -0600 | [diff] [blame] | 7973 | vk::DestroyBufferView(m_device->handle(), buffer_view, nullptr); |
| 7974 | vk::DestroySampler(m_device->handle(), sampler, nullptr); |
locke-lunarg | 6b0de70 | 2020-08-07 17:42:13 -0600 | [diff] [blame] | 7975 | } |
locke-lunarg | ae1bbab | 2020-09-10 11:55:56 -0600 | [diff] [blame] | 7976 | |
| 7977 | TEST_F(VkLayerTest, DrawWithoutUpdatePushConstants) { |
| 7978 | TEST_DESCRIPTION("Not every bytes in used push constant ranges has been set before Draw "); |
| 7979 | |
| 7980 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 7981 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7982 | |
| 7983 | // push constant range: 0-99 |
sfricke-samsung | 1c0b96a | 2021-07-08 22:24:09 -0700 | [diff] [blame] | 7984 | char const *const vsSource = R"glsl( |
| 7985 | #version 450 |
| 7986 | layout(push_constant, std430) uniform foo { |
| 7987 | bool b; |
| 7988 | float f2[3]; |
| 7989 | vec3 v; |
| 7990 | vec4 v2[2]; |
| 7991 | mat3 m; |
| 7992 | } constants; |
| 7993 | void func1( float f ){ |
| 7994 | // use the whole v2[1]. byte: 48-63. |
| 7995 | vec2 v2 = constants.v2[1].yz; |
| 7996 | } |
| 7997 | void main(){ |
| 7998 | // use only v2[0].z. byte: 40-43. |
| 7999 | func1( constants.v2[0].z); |
| 8000 | // index of m is variable. The all m is used. byte: 64-99. |
| 8001 | for(int i=1;i<2;++i) { |
| 8002 | vec3 v3 = constants.m[i]; |
| 8003 | } |
| 8004 | } |
| 8005 | )glsl"; |
locke-lunarg | ae1bbab | 2020-09-10 11:55:56 -0600 | [diff] [blame] | 8006 | |
| 8007 | // push constant range: 0 - 95 |
sfricke-samsung | 1c0b96a | 2021-07-08 22:24:09 -0700 | [diff] [blame] | 8008 | char const *const fsSource = R"glsl( |
| 8009 | #version 450 |
| 8010 | struct foo1{ |
| 8011 | int i[4]; |
| 8012 | }f; |
| 8013 | layout(push_constant, std430) uniform foo { |
| 8014 | float x[2][2][2]; |
| 8015 | foo1 s; |
| 8016 | foo1 ss[3]; |
| 8017 | } constants; |
| 8018 | void main(){ |
| 8019 | // use s. byte: 32-47. |
| 8020 | f = constants.s; |
| 8021 | // use every i[3] in ss. byte: 60-63, 76-79, 92-95. |
| 8022 | for(int i=1;i<2;++i) { |
| 8023 | int ii = constants.ss[i].i[3]; |
| 8024 | } |
| 8025 | } |
| 8026 | )glsl"; |
locke-lunarg | ae1bbab | 2020-09-10 11:55:56 -0600 | [diff] [blame] | 8027 | |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 8028 | VkShaderObj const vs(this, vsSource, VK_SHADER_STAGE_VERTEX_BIT); |
| 8029 | VkShaderObj const fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT); |
locke-lunarg | ae1bbab | 2020-09-10 11:55:56 -0600 | [diff] [blame] | 8030 | |
| 8031 | VkPushConstantRange push_constant_range = {VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, 128}; |
| 8032 | VkPushConstantRange push_constant_range_small = {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}; |
| 8033 | |
Aitor Camacho | 2933a0a | 2022-06-13 20:46:34 +0200 | [diff] [blame] | 8034 | auto pipeline_layout_info = LvlInitStruct<VkPipelineLayoutCreateInfo>(); |
| 8035 | pipeline_layout_info.pushConstantRangeCount = 1; |
| 8036 | pipeline_layout_info.pPushConstantRanges = &push_constant_range; |
locke-lunarg | ae1bbab | 2020-09-10 11:55:56 -0600 | [diff] [blame] | 8037 | |
| 8038 | VkPipelineLayout pipeline_layout; |
| 8039 | vk::CreatePipelineLayout(m_device->device(), &pipeline_layout_info, NULL, &pipeline_layout); |
| 8040 | |
| 8041 | CreatePipelineHelper g_pipe(*this); |
| 8042 | g_pipe.InitInfo(); |
| 8043 | g_pipe.shader_stages_ = {vs.GetStageCreateInfo(), fs.GetStageCreateInfo()}; |
| 8044 | g_pipe.pipeline_layout_ci_ = pipeline_layout_info; |
| 8045 | g_pipe.InitState(); |
| 8046 | ASSERT_VK_SUCCESS(g_pipe.CreateGraphicsPipeline()); |
| 8047 | |
| 8048 | pipeline_layout_info.pPushConstantRanges = &push_constant_range_small; |
| 8049 | VkPipelineLayout pipeline_layout_small; |
| 8050 | vk::CreatePipelineLayout(m_device->device(), &pipeline_layout_info, NULL, &pipeline_layout_small); |
| 8051 | |
| 8052 | CreatePipelineHelper g_pipe_small_range(*this); |
| 8053 | g_pipe_small_range.InitInfo(); |
| 8054 | g_pipe_small_range.shader_stages_ = {vs.GetStageCreateInfo(), fs.GetStageCreateInfo()}; |
| 8055 | g_pipe_small_range.pipeline_layout_ci_ = pipeline_layout_info; |
| 8056 | g_pipe_small_range.InitState(); |
| 8057 | |
sfricke-samsung | 7699b91 | 2021-04-12 23:01:51 -0700 | [diff] [blame] | 8058 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-VkGraphicsPipelineCreateInfo-layout-00756"); |
| 8059 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-VkGraphicsPipelineCreateInfo-layout-00756"); |
locke-lunarg | ae1bbab | 2020-09-10 11:55:56 -0600 | [diff] [blame] | 8060 | g_pipe_small_range.CreateGraphicsPipeline(); |
| 8061 | m_errorMonitor->VerifyFound(); |
| 8062 | |
| 8063 | m_commandBuffer->begin(); |
| 8064 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 8065 | |
Piers Daniell | a7f93b6 | 2021-11-20 12:32:04 -0700 | [diff] [blame] | 8066 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-vkCmdDraw-maintenance4-06425"); |
locke-lunarg | ae1bbab | 2020-09-10 11:55:56 -0600 | [diff] [blame] | 8067 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, g_pipe.pipeline_); |
| 8068 | vk::CmdBindDescriptorSets(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, g_pipe.pipeline_layout_.handle(), 0, 1, |
| 8069 | &g_pipe.descriptor_set_->set_, 0, nullptr); |
| 8070 | vk::CmdDraw(m_commandBuffer->handle(), 1, 0, 0, 0); |
| 8071 | m_errorMonitor->VerifyFound(); |
| 8072 | |
locke-lunarg | ae1bbab | 2020-09-10 11:55:56 -0600 | [diff] [blame] | 8073 | const float dummy_values[128] = {}; |
locke-lunarg | ae1bbab | 2020-09-10 11:55:56 -0600 | [diff] [blame] | 8074 | |
Nathaniel Cesario | ee42bab | 2021-04-14 20:02:16 -0600 | [diff] [blame] | 8075 | // NOTE: these are commented out due to ambiguity around VUID 02698 and push constant lifetimes |
| 8076 | // See https://gitlab.khronos.org/vulkan/vulkan/-/issues/2602 and |
| 8077 | // https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/2689 |
| 8078 | // for more details. |
Piers Daniell | a7f93b6 | 2021-11-20 12:32:04 -0700 | [diff] [blame] | 8079 | // m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-vkCmdDraw-maintenance4-06425"); |
Nathaniel Cesario | ee42bab | 2021-04-14 20:02:16 -0600 | [diff] [blame] | 8080 | // vk::CmdPushConstants(m_commandBuffer->handle(), g_pipe.pipeline_layout_.handle(), |
| 8081 | // VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, 96, dummy_values); |
| 8082 | // vk::CmdDraw(m_commandBuffer->handle(), 1, 0, 0, 0); |
| 8083 | // m_errorMonitor->VerifyFound(); |
| 8084 | |
Piers Daniell | a7f93b6 | 2021-11-20 12:32:04 -0700 | [diff] [blame] | 8085 | // m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-vkCmdDraw-maintenance4-06425"); |
Nathaniel Cesario | ee42bab | 2021-04-14 20:02:16 -0600 | [diff] [blame] | 8086 | // vk::CmdPushConstants(m_commandBuffer->handle(), pipeline_layout_small, VK_SHADER_STAGE_VERTEX_BIT, 4, 4, dummy_values); |
| 8087 | // vk::CmdDraw(m_commandBuffer->handle(), 1, 0, 0, 0); |
| 8088 | // m_errorMonitor->VerifyFound(); |
locke-lunarg | ae1bbab | 2020-09-10 11:55:56 -0600 | [diff] [blame] | 8089 | |
locke-lunarg | ae1bbab | 2020-09-10 11:55:56 -0600 | [diff] [blame] | 8090 | vk::CmdPushConstants(m_commandBuffer->handle(), pipeline_layout, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 32, |
| 8091 | 68, dummy_values); |
| 8092 | vk::CmdDraw(m_commandBuffer->handle(), 1, 0, 0, 0); |
paul-lunarg | 6b0b1f6 | 2022-07-11 14:00:48 -0600 | [diff] [blame] | 8093 | |
| 8094 | m_commandBuffer->EndRenderPass(); |
| 8095 | m_commandBuffer->end(); |
| 8096 | |
| 8097 | vk::DestroyPipelineLayout(m_device->handle(), pipeline_layout, nullptr); |
| 8098 | vk::DestroyPipelineLayout(m_device->handle(), pipeline_layout_small, nullptr); |
locke-lunarg | 41b8c36 | 2020-10-16 23:30:12 -0600 | [diff] [blame] | 8099 | } |
| 8100 | |
| 8101 | TEST_F(VkLayerTest, VerifyVertextBinding) { |
| 8102 | TEST_DESCRIPTION("Verify if VkPipelineVertexInputStateCreateInfo matches vkCmdBindVertexBuffers"); |
| 8103 | |
| 8104 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 8105 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8106 | |
| 8107 | VkBufferObj vtx_buf; |
| 8108 | auto info = vtx_buf.create_info(32, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT); |
| 8109 | vtx_buf.init(*m_device, info); |
| 8110 | |
| 8111 | CreatePipelineHelper pipe(*this); |
| 8112 | pipe.InitInfo(); |
| 8113 | // CmdBindVertexBuffers only has binding:1. It causes 04007 & 04008 desired fail. |
| 8114 | VkVertexInputBindingDescription vtx_binding_des[3] = { |
| 8115 | {0, 64, VK_VERTEX_INPUT_RATE_VERTEX}, {1, 64, VK_VERTEX_INPUT_RATE_VERTEX}, {2, 64, VK_VERTEX_INPUT_RATE_VERTEX}}; |
| 8116 | |
| 8117 | // CmdBindVertexBuffers only has binding:1. It causes twice 02721 desired fail. |
| 8118 | // Plus, binding:1's offset is wrong. It causes 02721 desired fail, again. |
| 8119 | VkVertexInputAttributeDescription vtx_attri_des[3] = {{0, 0, VK_FORMAT_R32G32B32A32_SFLOAT, 10}, |
| 8120 | {1, 1, VK_FORMAT_R32G32B32A32_SFLOAT, 10}, |
| 8121 | {2, 2, VK_FORMAT_R32G32B32A32_SFLOAT, 10}}; |
| 8122 | pipe.vi_ci_.vertexBindingDescriptionCount = 3; |
| 8123 | pipe.vi_ci_.pVertexBindingDescriptions = vtx_binding_des; |
| 8124 | pipe.vi_ci_.vertexAttributeDescriptionCount = 3; |
| 8125 | pipe.vi_ci_.pVertexAttributeDescriptions = vtx_attri_des; |
| 8126 | pipe.InitState(); |
| 8127 | pipe.CreateGraphicsPipeline(); |
| 8128 | |
| 8129 | m_commandBuffer->begin(); |
| 8130 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 8131 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_); |
| 8132 | VkDeviceSize offset = 0; |
| 8133 | vk::CmdBindVertexBuffers(m_commandBuffer->handle(), 1, 1, &vtx_buf.handle(), &offset); |
| 8134 | |
| 8135 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-vkCmdDraw-None-04008"); |
| 8136 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-vkCmdDraw-None-04007"); |
| 8137 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-vkCmdDraw-None-02721"); |
| 8138 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-vkCmdDraw-None-02721"); |
| 8139 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-vkCmdDraw-None-02721"); |
| 8140 | vk::CmdDraw(m_commandBuffer->handle(), 1, 0, 0, 0); |
| 8141 | m_errorMonitor->VerifyFound(); |
locke-lunarg | ae1bbab | 2020-09-10 11:55:56 -0600 | [diff] [blame] | 8142 | |
| 8143 | m_commandBuffer->EndRenderPass(); |
| 8144 | m_commandBuffer->end(); |
| 8145 | } |
locke-lunarg | d7a08e9 | 2020-10-21 00:24:00 -0600 | [diff] [blame] | 8146 | |
| 8147 | TEST_F(VkLayerTest, VerifyDynamicStateSettingCommands) { |
| 8148 | TEST_DESCRIPTION("Verify if pipeline doesn't setup dynamic state, but set dynamic commands"); |
| 8149 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 8150 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8151 | |
| 8152 | CreatePipelineHelper pipe(*this); |
| 8153 | pipe.InitInfo(); |
| 8154 | |
| 8155 | std::vector<VkDynamicState> dyn_states = {VK_DYNAMIC_STATE_VIEWPORT}; |
| 8156 | |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 8157 | auto dyn_state_ci = LvlInitStruct<VkPipelineDynamicStateCreateInfo>(); |
locke-lunarg | d7a08e9 | 2020-10-21 00:24:00 -0600 | [diff] [blame] | 8158 | dyn_state_ci.dynamicStateCount = static_cast<uint32_t>(dyn_states.size()); |
| 8159 | dyn_state_ci.pDynamicStates = dyn_states.data(); |
| 8160 | pipe.dyn_state_ci_ = dyn_state_ci; |
| 8161 | pipe.InitState(); |
| 8162 | pipe.CreateGraphicsPipeline(); |
| 8163 | |
| 8164 | m_commandBuffer->begin(); |
| 8165 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 8166 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_); |
| 8167 | |
| 8168 | VkViewport viewport = {0, 0, 16, 16, 0, 1}; |
| 8169 | vk::CmdSetViewport(m_commandBuffer->handle(), 0, 1, &viewport); |
| 8170 | VkRect2D scissor = {{0, 0}, {16, 16}}; |
| 8171 | vk::CmdSetScissor(m_commandBuffer->handle(), 0, 1, &scissor); |
| 8172 | vk::CmdSetLineWidth(m_commandBuffer->handle(), 1); |
| 8173 | |
| 8174 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-vkCmdDraw-None-02859"); |
| 8175 | vk::CmdDraw(m_commandBuffer->handle(), 1, 0, 0, 0); |
| 8176 | m_errorMonitor->VerifyFound(); |
| 8177 | |
| 8178 | m_commandBuffer->EndRenderPass(); |
| 8179 | m_commandBuffer->end(); |
| 8180 | } |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 8181 | |
| 8182 | TEST_F(VkLayerTest, VerifyFilterCubicSamplerInCmdDraw) { |
| 8183 | TEST_DESCRIPTION("Verify if sampler is filter cubic, image view needs to support it."); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 8184 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 8185 | AddRequiredExtensions(VK_EXT_FILTER_CUBIC_EXTENSION_NAME); |
| 8186 | AddRequiredExtensions(VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME); |
| 8187 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 8188 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 8189 | GTEST_SKIP() << "Test requires at least Vulkan 1.1"; |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 8190 | } |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 8191 | if (!AreRequiredExtensionsEnabled()) { |
| 8192 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported."; |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 8193 | } |
| 8194 | |
| 8195 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, nullptr, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
| 8196 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8197 | |
| 8198 | VkImageUsageFlags usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8199 | VkFormat format = VK_FORMAT_R8G8B8A8_UNORM; |
sfricke-samsung | 715e3d1 | 2020-12-01 22:45:49 -0800 | [diff] [blame] | 8200 | |
| 8201 | VkFormatProperties format_props; |
| 8202 | vk::GetPhysicalDeviceFormatProperties(m_device->phy().handle(), format, &format_props); |
| 8203 | if ((format_props.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT) == 0) { |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 8204 | GTEST_SKIP() << "SAMPLED_IMAGE_FILTER_CUBIC_BIT for format is not supported."; |
sfricke-samsung | 715e3d1 | 2020-12-01 22:45:49 -0800 | [diff] [blame] | 8205 | } |
| 8206 | |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 8207 | auto image_ci = VkImageObj::ImageCreateInfo2D(128, 128, 1, 1, format, usage, VK_IMAGE_TILING_OPTIMAL); |
| 8208 | VkImageViewType imageViewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8209 | |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 8210 | auto imageview_format_info = LvlInitStruct<VkPhysicalDeviceImageViewImageFormatInfoEXT>(); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 8211 | imageview_format_info.imageViewType = imageViewType; |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 8212 | auto image_format_info = LvlInitStruct<VkPhysicalDeviceImageFormatInfo2>(&imageview_format_info); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 8213 | image_format_info.type = image_ci.imageType; |
| 8214 | image_format_info.format = image_ci.format; |
| 8215 | image_format_info.tiling = image_ci.tiling; |
| 8216 | image_format_info.usage = image_ci.usage; |
| 8217 | image_format_info.flags = image_ci.flags; |
| 8218 | |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 8219 | auto filter_cubic_props = LvlInitStruct<VkFilterCubicImageViewImageFormatPropertiesEXT>(); |
| 8220 | auto image_format_properties = LvlInitStruct<VkImageFormatProperties2>(&filter_cubic_props); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 8221 | |
| 8222 | vk::GetPhysicalDeviceImageFormatProperties2(gpu(), &image_format_info, &image_format_properties); |
| 8223 | |
| 8224 | if (filter_cubic_props.filterCubic || filter_cubic_props.filterCubicMinmax) { |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 8225 | GTEST_SKIP() << "Image and ImageView supports filter cubic ; skipped."; |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 8226 | } |
| 8227 | |
| 8228 | VkImageObj image(m_device); |
| 8229 | image.Init(image_ci); |
| 8230 | VkImageView imageView = image.targetView(format, imageViewType); |
| 8231 | |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 8232 | auto sampler_ci = LvlInitStruct<VkSamplerCreateInfo>(); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 8233 | sampler_ci.minFilter = VK_FILTER_CUBIC_EXT; |
| 8234 | sampler_ci.magFilter = VK_FILTER_CUBIC_EXT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 8235 | vk_testing::Sampler sampler(*m_device, sampler_ci); |
| 8236 | ASSERT_TRUE(sampler.initialized()); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 8237 | |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 8238 | auto reduction_mode_ci = LvlInitStruct<VkSamplerReductionModeCreateInfo>(); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 8239 | reduction_mode_ci.reductionMode = VK_SAMPLER_REDUCTION_MODE_MIN; |
| 8240 | sampler_ci.pNext = &reduction_mode_ci; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 8241 | vk_testing::Sampler sampler_reduction(*m_device, sampler_ci); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 8242 | |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 8243 | VkShaderObj fs(this, bindStateFragSamplerShaderText, VK_SHADER_STAGE_FRAGMENT_BIT); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 8244 | |
| 8245 | CreatePipelineHelper g_pipe(*this); |
| 8246 | g_pipe.InitInfo(); |
| 8247 | g_pipe.shader_stages_ = {g_pipe.vs_->GetStageCreateInfo(), fs.GetStageCreateInfo()}; |
| 8248 | g_pipe.dsl_bindings_ = {{0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr}}; |
| 8249 | g_pipe.InitState(); |
| 8250 | ASSERT_VK_SUCCESS(g_pipe.CreateGraphicsPipeline()); |
| 8251 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 8252 | g_pipe.descriptor_set_->WriteDescriptorImageInfo(0, imageView, sampler_reduction.handle()); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 8253 | g_pipe.descriptor_set_->UpdateDescriptorSets(); |
| 8254 | |
| 8255 | m_commandBuffer->begin(); |
| 8256 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 8257 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, g_pipe.pipeline_); |
| 8258 | vk::CmdBindDescriptorSets(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, g_pipe.pipeline_layout_.handle(), 0, 1, |
| 8259 | &g_pipe.descriptor_set_->set_, 0, nullptr); |
| 8260 | |
| 8261 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-vkCmdDraw-filterCubicMinmax-02695"); |
| 8262 | m_commandBuffer->Draw(1, 0, 0, 0); |
| 8263 | m_errorMonitor->VerifyFound(); |
| 8264 | |
| 8265 | m_commandBuffer->EndRenderPass(); |
| 8266 | m_commandBuffer->end(); |
| 8267 | m_commandBuffer->reset(); |
| 8268 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 8269 | g_pipe.descriptor_set_->WriteDescriptorImageInfo(0, imageView, sampler.handle()); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 8270 | g_pipe.descriptor_set_->UpdateDescriptorSets(); |
| 8271 | |
| 8272 | m_commandBuffer->begin(); |
| 8273 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 8274 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, g_pipe.pipeline_); |
| 8275 | vk::CmdBindDescriptorSets(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, g_pipe.pipeline_layout_.handle(), 0, 1, |
| 8276 | &g_pipe.descriptor_set_->set_, 0, nullptr); |
| 8277 | |
| 8278 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-vkCmdDraw-filterCubic-02694"); |
| 8279 | m_commandBuffer->Draw(1, 0, 0, 0); |
| 8280 | m_errorMonitor->VerifyFound(); |
| 8281 | |
| 8282 | m_commandBuffer->EndRenderPass(); |
| 8283 | m_commandBuffer->end(); |
| 8284 | } |
| 8285 | |
Mark Lobodzinski | 28168c5 | 2020-12-01 14:25:05 -0700 | [diff] [blame] | 8286 | TEST_F(VkLayerTest, VerifyImgFilterCubicSamplerInCmdDraw) { |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 8287 | TEST_DESCRIPTION("Verify if sampler is filter cubic with the VK_IMG_filter cubic extension that it's a valid ImageViewType."); |
Mark Lobodzinski | 28168c5 | 2020-12-01 14:25:05 -0700 | [diff] [blame] | 8288 | |
Clemens Kern | 5a42ea6 | 2021-09-29 16:30:23 +0200 | [diff] [blame] | 8289 | AddRequiredExtensions(VK_IMG_FILTER_CUBIC_EXTENSION_NAME); |
| 8290 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 8291 | if (!AreRequiredExtensionsEnabled()) { |
| 8292 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
Mark Lobodzinski | 28168c5 | 2020-12-01 14:25:05 -0700 | [diff] [blame] | 8293 | } |
| 8294 | |
| 8295 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, nullptr, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
| 8296 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8297 | |
| 8298 | VkImageUsageFlags usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8299 | VkFormat format = VK_FORMAT_R8G8B8A8_UNORM; |
Clemens Kern | 5a42ea6 | 2021-09-29 16:30:23 +0200 | [diff] [blame] | 8300 | auto image_ci = vk_testing::Image::create_info(); |
| 8301 | image_ci.imageType = VK_IMAGE_TYPE_3D; |
| 8302 | image_ci.format = format; |
| 8303 | image_ci.extent.width = 128; |
| 8304 | image_ci.extent.height = 128; |
| 8305 | image_ci.mipLevels = 1; |
| 8306 | image_ci.arrayLayers = 1; |
| 8307 | image_ci.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8308 | image_ci.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 8309 | image_ci.usage = usage; |
| 8310 | VkImageViewType imageViewType = VK_IMAGE_VIEW_TYPE_3D; |
Mark Lobodzinski | 28168c5 | 2020-12-01 14:25:05 -0700 | [diff] [blame] | 8311 | |
| 8312 | VkImageObj image(m_device); |
| 8313 | image.Init(image_ci); |
| 8314 | VkImageView imageView = image.targetView(format, VK_IMAGE_ASPECT_COLOR_BIT, 0, VK_REMAINING_MIP_LEVELS, 0, |
| 8315 | VK_REMAINING_ARRAY_LAYERS, imageViewType); |
| 8316 | |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 8317 | auto sampler_ci = LvlInitStruct<VkSamplerCreateInfo>(); |
Mark Lobodzinski | 28168c5 | 2020-12-01 14:25:05 -0700 | [diff] [blame] | 8318 | sampler_ci.minFilter = VK_FILTER_CUBIC_EXT; |
| 8319 | sampler_ci.magFilter = VK_FILTER_CUBIC_EXT; |
Nathaniel Cesario | 079b1b9 | 2022-07-06 15:56:26 -0600 | [diff] [blame] | 8320 | vk_testing::Sampler sampler(*m_device, sampler_ci); |
| 8321 | ASSERT_TRUE(sampler.initialized()); |
Mark Lobodzinski | 28168c5 | 2020-12-01 14:25:05 -0700 | [diff] [blame] | 8322 | |
Clemens Kern | 5a42ea6 | 2021-09-29 16:30:23 +0200 | [diff] [blame] | 8323 | static const char fs_src[] = R"glsl( |
| 8324 | #version 450 |
| 8325 | layout(set=0, binding=0) uniform sampler3D s; |
| 8326 | layout(location=0) out vec4 x; |
| 8327 | void main(){ |
| 8328 | x = texture(s, vec3(1)); |
| 8329 | } |
| 8330 | )glsl"; |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 8331 | VkShaderObj fs(this, fs_src, VK_SHADER_STAGE_FRAGMENT_BIT); |
Mark Lobodzinski | 28168c5 | 2020-12-01 14:25:05 -0700 | [diff] [blame] | 8332 | |
| 8333 | CreatePipelineHelper g_pipe(*this); |
| 8334 | g_pipe.InitInfo(); |
| 8335 | g_pipe.shader_stages_ = {g_pipe.vs_->GetStageCreateInfo(), fs.GetStageCreateInfo()}; |
| 8336 | g_pipe.dsl_bindings_ = {{0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr}}; |
| 8337 | g_pipe.InitState(); |
| 8338 | ASSERT_VK_SUCCESS(g_pipe.CreateGraphicsPipeline()); |
| 8339 | |
Nathaniel Cesario | 079b1b9 | 2022-07-06 15:56:26 -0600 | [diff] [blame] | 8340 | g_pipe.descriptor_set_->WriteDescriptorImageInfo(0, imageView, sampler.handle()); |
Mark Lobodzinski | 28168c5 | 2020-12-01 14:25:05 -0700 | [diff] [blame] | 8341 | g_pipe.descriptor_set_->UpdateDescriptorSets(); |
| 8342 | |
| 8343 | m_commandBuffer->begin(); |
| 8344 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 8345 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, g_pipe.pipeline_); |
| 8346 | vk::CmdBindDescriptorSets(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, g_pipe.pipeline_layout_.handle(), 0, 1, |
| 8347 | &g_pipe.descriptor_set_->set_, 0, nullptr); |
| 8348 | |
| 8349 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-vkCmdDraw-None-02693"); |
| 8350 | m_commandBuffer->Draw(1, 0, 0, 0); |
| 8351 | m_errorMonitor->VerifyFound(); |
| 8352 | |
| 8353 | m_commandBuffer->EndRenderPass(); |
| 8354 | m_commandBuffer->end(); |
| 8355 | } |
| 8356 | |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 8357 | TEST_F(VkLayerTest, VerifyMaxMultiviewInstanceIndex) { |
| 8358 | TEST_DESCRIPTION("Verify if instance index in CmdDraw is greater than maxMultiviewInstanceIndex."); |
sjfricke | d8e01c5 | 2022-07-06 14:09:04 +0900 | [diff] [blame] | 8359 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 8360 | AddRequiredExtensions(VK_KHR_MULTIVIEW_EXTENSION_NAME); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 8361 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
| 8362 | |
sjfricke | d8e01c5 | 2022-07-06 14:09:04 +0900 | [diff] [blame] | 8363 | if (!AreRequiredExtensionsEnabled()) { |
| 8364 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
| 8365 | } |
| 8366 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 8367 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 8368 | } |
| 8369 | |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 8370 | auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>(); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 8371 | multiview_features.multiview = VK_TRUE; |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 8372 | VkPhysicalDeviceFeatures2 pd_features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&multiview_features); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 8373 | |
| 8374 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &pd_features2)); |
| 8375 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8376 | |
| 8377 | PFN_vkGetPhysicalDeviceProperties2KHR vkGetPhysicalDeviceProperties2KHR = |
| 8378 | (PFN_vkGetPhysicalDeviceProperties2KHR)vk::GetInstanceProcAddr(instance(), "vkGetPhysicalDeviceProperties2KHR"); |
| 8379 | ASSERT_TRUE(vkGetPhysicalDeviceProperties2KHR != nullptr); |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 8380 | auto multiview_props = LvlInitStruct<VkPhysicalDeviceMultiviewProperties>(); |
| 8381 | VkPhysicalDeviceProperties2KHR properties2 = LvlInitStruct<VkPhysicalDeviceProperties2KHR>(&multiview_props); |
locke-lunarg | 0de0252 | 2020-10-27 22:55:17 -0600 | [diff] [blame] | 8382 | vkGetPhysicalDeviceProperties2KHR(gpu(), &properties2); |
| 8383 | if (multiview_props.maxMultiviewInstanceIndex == std::numeric_limits<uint32_t>::max()) { |
| 8384 | printf("%s maxMultiviewInstanceIndex is uint32_t max, skipping tests\n", kSkipPrefix); |
| 8385 | return; |
| 8386 | } |
| 8387 | CreatePipelineHelper pipe(*this); |
| 8388 | pipe.InitInfo(); |
| 8389 | pipe.InitState(); |
| 8390 | pipe.CreateGraphicsPipeline(); |
| 8391 | |
| 8392 | m_commandBuffer->begin(); |
| 8393 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 8394 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_); |
| 8395 | |
| 8396 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-vkCmdDraw-maxMultiviewInstanceIndex-02688"); |
| 8397 | m_commandBuffer->Draw(1, multiview_props.maxMultiviewInstanceIndex + 1, 0, 0); |
| 8398 | m_errorMonitor->VerifyFound(); |
| 8399 | |
| 8400 | m_commandBuffer->EndRenderPass(); |
| 8401 | m_commandBuffer->end(); |
| 8402 | } |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8403 | |
| 8404 | TEST_F(VkLayerTest, InvalidSetFragmentShadingRateValues) { |
| 8405 | TEST_DESCRIPTION("Specify invalid fragment shading rate values"); |
| 8406 | |
| 8407 | // Enable KHR_fragment_shading_rate and all of its required extensions |
| 8408 | bool fsr_extensions = InstanceExtensionSupported(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 8409 | if (fsr_extensions) { |
| 8410 | m_instance_extension_names.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 8411 | } |
| 8412 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
| 8413 | |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 8414 | fsr_extensions = fsr_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
| 8415 | 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] | 8416 | fsr_extensions = fsr_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_MULTIVIEW_EXTENSION_NAME); |
| 8417 | fsr_extensions = fsr_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME); |
| 8418 | fsr_extensions = fsr_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
| 8419 | if (fsr_extensions) { |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 8420 | m_device_extension_names.push_back(VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
| 8421 | m_device_extension_names.push_back(VK_KHR_MAINTENANCE_2_EXTENSION_NAME); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8422 | m_device_extension_names.push_back(VK_KHR_MULTIVIEW_EXTENSION_NAME); |
| 8423 | m_device_extension_names.push_back(VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME); |
| 8424 | m_device_extension_names.push_back(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
| 8425 | } else { |
| 8426 | printf("%s requires VK_KHR_fragment_shading_rate.\n", kSkipPrefix); |
| 8427 | return; |
| 8428 | } |
| 8429 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 8430 | VkPhysicalDeviceFragmentShadingRateFeaturesKHR fsr_features = LvlInitStruct<VkPhysicalDeviceFragmentShadingRateFeaturesKHR>(); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8431 | fsr_features.pipelineFragmentShadingRate = true; |
| 8432 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 8433 | VkPhysicalDeviceFeatures2 device_features = LvlInitStruct<VkPhysicalDeviceFeatures2>(&fsr_features); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8434 | |
| 8435 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &device_features)); |
| 8436 | |
| 8437 | // Find address of extension call and make the call |
| 8438 | PFN_vkCmdSetFragmentShadingRateKHR vkCmdSetFragmentShadingRateKHR = |
| 8439 | (PFN_vkCmdSetFragmentShadingRateKHR)vk::GetDeviceProcAddr(m_device->device(), "vkCmdSetFragmentShadingRateKHR"); |
| 8440 | ASSERT_TRUE(vkCmdSetFragmentShadingRateKHR != nullptr); |
| 8441 | |
| 8442 | VkExtent2D fragmentSize = {1, 1}; |
| 8443 | VkFragmentShadingRateCombinerOpKHR combinerOps[2] = {VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR, |
| 8444 | VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR}; |
| 8445 | |
| 8446 | m_commandBuffer->begin(); |
| 8447 | fragmentSize.width = 0; |
| 8448 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-vkCmdSetFragmentShadingRateKHR-pFragmentSize-04513"); |
| 8449 | vkCmdSetFragmentShadingRateKHR(m_commandBuffer->handle(), &fragmentSize, combinerOps); |
| 8450 | m_errorMonitor->VerifyFound(); |
| 8451 | fragmentSize.width = 1; |
| 8452 | |
| 8453 | fragmentSize.height = 0; |
| 8454 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-vkCmdSetFragmentShadingRateKHR-pFragmentSize-04514"); |
| 8455 | vkCmdSetFragmentShadingRateKHR(m_commandBuffer->handle(), &fragmentSize, combinerOps); |
| 8456 | m_errorMonitor->VerifyFound(); |
| 8457 | fragmentSize.height = 1; |
| 8458 | |
| 8459 | fragmentSize.width = 3; |
| 8460 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-vkCmdSetFragmentShadingRateKHR-pFragmentSize-04515"); |
| 8461 | vkCmdSetFragmentShadingRateKHR(m_commandBuffer->handle(), &fragmentSize, combinerOps); |
| 8462 | m_errorMonitor->VerifyFound(); |
| 8463 | fragmentSize.width = 1; |
| 8464 | |
| 8465 | fragmentSize.height = 3; |
| 8466 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-vkCmdSetFragmentShadingRateKHR-pFragmentSize-04516"); |
| 8467 | vkCmdSetFragmentShadingRateKHR(m_commandBuffer->handle(), &fragmentSize, combinerOps); |
| 8468 | m_errorMonitor->VerifyFound(); |
| 8469 | fragmentSize.height = 1; |
| 8470 | |
| 8471 | fragmentSize.width = 8; |
| 8472 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-vkCmdSetFragmentShadingRateKHR-pFragmentSize-04517"); |
| 8473 | vkCmdSetFragmentShadingRateKHR(m_commandBuffer->handle(), &fragmentSize, combinerOps); |
| 8474 | m_errorMonitor->VerifyFound(); |
| 8475 | fragmentSize.width = 1; |
| 8476 | |
| 8477 | fragmentSize.height = 8; |
| 8478 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "VUID-vkCmdSetFragmentShadingRateKHR-pFragmentSize-04518"); |
| 8479 | vkCmdSetFragmentShadingRateKHR(m_commandBuffer->handle(), &fragmentSize, combinerOps); |
| 8480 | m_errorMonitor->VerifyFound(); |
| 8481 | fragmentSize.height = 1; |
| 8482 | m_commandBuffer->end(); |
| 8483 | } |
| 8484 | |
| 8485 | TEST_F(VkLayerTest, InvalidSetFragmentShadingRateValuesNoFeatures) { |
| 8486 | TEST_DESCRIPTION("Specify invalid fsr pipeline settings for the enabled features"); |
| 8487 | |
| 8488 | // Enable KHR_fragment_shading_rate and all of its required extensions |
| 8489 | bool fsr_extensions = InstanceExtensionSupported(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 8490 | if (fsr_extensions) { |
| 8491 | m_instance_extension_names.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 8492 | } |
| 8493 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
| 8494 | |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 8495 | fsr_extensions = fsr_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
| 8496 | 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] | 8497 | fsr_extensions = fsr_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_MULTIVIEW_EXTENSION_NAME); |
| 8498 | fsr_extensions = fsr_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME); |
| 8499 | fsr_extensions = fsr_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
| 8500 | if (fsr_extensions) { |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 8501 | m_device_extension_names.push_back(VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
| 8502 | m_device_extension_names.push_back(VK_KHR_MAINTENANCE_2_EXTENSION_NAME); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8503 | m_device_extension_names.push_back(VK_KHR_MULTIVIEW_EXTENSION_NAME); |
| 8504 | m_device_extension_names.push_back(VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME); |
| 8505 | m_device_extension_names.push_back(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
| 8506 | } else { |
| 8507 | printf("%s requires VK_KHR_fragment_shading_rate.\n", kSkipPrefix); |
| 8508 | return; |
| 8509 | } |
| 8510 | |
| 8511 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8512 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8513 | |
| 8514 | // Find address of extension call and make the call |
| 8515 | PFN_vkCmdSetFragmentShadingRateKHR vkCmdSetFragmentShadingRateKHR = |
| 8516 | (PFN_vkCmdSetFragmentShadingRateKHR)vk::GetDeviceProcAddr(m_device->device(), "vkCmdSetFragmentShadingRateKHR"); |
| 8517 | ASSERT_TRUE(vkCmdSetFragmentShadingRateKHR != nullptr); |
| 8518 | |
| 8519 | VkExtent2D fragmentSize = {1, 1}; |
| 8520 | VkFragmentShadingRateCombinerOpKHR combinerOps[2] = {VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR, |
| 8521 | VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR}; |
| 8522 | |
| 8523 | m_commandBuffer->begin(); |
| 8524 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8525 | "VUID-vkCmdSetFragmentShadingRateKHR-pipelineFragmentShadingRate-04509"); |
| 8526 | vkCmdSetFragmentShadingRateKHR(m_commandBuffer->handle(), &fragmentSize, combinerOps); |
| 8527 | m_errorMonitor->VerifyFound(); |
| 8528 | m_commandBuffer->end(); |
| 8529 | } |
| 8530 | |
| 8531 | TEST_F(VkLayerTest, InvalidSetFragmentShadingRateCombinerOpsNoFeatures) { |
| 8532 | TEST_DESCRIPTION("Specify combiner operations when only pipeline rate is supported"); |
| 8533 | |
| 8534 | // Enable KHR_fragment_shading_rate and all of its required extensions |
| 8535 | bool fsr_extensions = InstanceExtensionSupported(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 8536 | if (fsr_extensions) { |
| 8537 | m_instance_extension_names.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 8538 | } |
| 8539 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
| 8540 | |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 8541 | fsr_extensions = fsr_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
| 8542 | 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] | 8543 | fsr_extensions = fsr_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_MULTIVIEW_EXTENSION_NAME); |
| 8544 | fsr_extensions = fsr_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME); |
| 8545 | fsr_extensions = fsr_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
| 8546 | if (fsr_extensions) { |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 8547 | m_device_extension_names.push_back(VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
| 8548 | m_device_extension_names.push_back(VK_KHR_MAINTENANCE_2_EXTENSION_NAME); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8549 | m_device_extension_names.push_back(VK_KHR_MULTIVIEW_EXTENSION_NAME); |
| 8550 | m_device_extension_names.push_back(VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME); |
| 8551 | m_device_extension_names.push_back(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
| 8552 | } else { |
| 8553 | printf("%s requires VK_KHR_fragment_shading_rate.\n", kSkipPrefix); |
| 8554 | return; |
| 8555 | } |
| 8556 | |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 8557 | VkPhysicalDeviceFragmentShadingRateFeaturesKHR fsr_features = LvlInitStruct<VkPhysicalDeviceFragmentShadingRateFeaturesKHR>(); |
sjfricke | 11db0c7 | 2022-08-18 13:23:11 +0900 | [diff] [blame^] | 8558 | VkPhysicalDeviceFeatures2KHR features2 = GetPhysicalDeviceFeatures2(fsr_features); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8559 | |
| 8560 | fsr_features.pipelineFragmentShadingRate = VK_TRUE; |
| 8561 | fsr_features.primitiveFragmentShadingRate = VK_FALSE; |
| 8562 | fsr_features.attachmentFragmentShadingRate = VK_FALSE; |
| 8563 | |
| 8564 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 8565 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8566 | |
| 8567 | // Find address of extension call and make the call |
| 8568 | PFN_vkCmdSetFragmentShadingRateKHR vkCmdSetFragmentShadingRateKHR = |
| 8569 | (PFN_vkCmdSetFragmentShadingRateKHR)vk::GetDeviceProcAddr(m_device->device(), "vkCmdSetFragmentShadingRateKHR"); |
| 8570 | ASSERT_TRUE(vkCmdSetFragmentShadingRateKHR != nullptr); |
| 8571 | |
| 8572 | VkExtent2D fragmentSize = {1, 1}; |
| 8573 | VkFragmentShadingRateCombinerOpKHR combinerOps[2] = {VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR, |
| 8574 | VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR}; |
| 8575 | |
| 8576 | m_commandBuffer->begin(); |
| 8577 | |
| 8578 | combinerOps[0] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_KHR; |
| 8579 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8580 | "VUID-vkCmdSetFragmentShadingRateKHR-primitiveFragmentShadingRate-04510"); |
| 8581 | vkCmdSetFragmentShadingRateKHR(m_commandBuffer->handle(), &fragmentSize, combinerOps); |
| 8582 | m_errorMonitor->VerifyFound(); |
| 8583 | combinerOps[0] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR; |
| 8584 | |
| 8585 | combinerOps[1] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_KHR; |
| 8586 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8587 | "VUID-vkCmdSetFragmentShadingRateKHR-attachmentFragmentShadingRate-04511"); |
| 8588 | vkCmdSetFragmentShadingRateKHR(m_commandBuffer->handle(), &fragmentSize, combinerOps); |
| 8589 | m_errorMonitor->VerifyFound(); |
| 8590 | combinerOps[1] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR; |
| 8591 | |
| 8592 | m_commandBuffer->end(); |
| 8593 | } |
| 8594 | |
| 8595 | TEST_F(VkLayerTest, InvalidSetFragmentShadingRateCombinerOpsNoPipelineRate) { |
| 8596 | TEST_DESCRIPTION("Specify pipeline rate when only attachment or primitive rate are supported"); |
| 8597 | |
| 8598 | // Enable KHR_fragment_shading_rate and all of its required extensions |
| 8599 | bool fsr_extensions = InstanceExtensionSupported(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 8600 | if (fsr_extensions) { |
| 8601 | m_instance_extension_names.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 8602 | } |
| 8603 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
| 8604 | |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 8605 | fsr_extensions = fsr_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
| 8606 | 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] | 8607 | fsr_extensions = fsr_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_MULTIVIEW_EXTENSION_NAME); |
| 8608 | fsr_extensions = fsr_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME); |
| 8609 | fsr_extensions = fsr_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
| 8610 | if (fsr_extensions) { |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 8611 | m_device_extension_names.push_back(VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
| 8612 | m_device_extension_names.push_back(VK_KHR_MAINTENANCE_2_EXTENSION_NAME); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8613 | m_device_extension_names.push_back(VK_KHR_MULTIVIEW_EXTENSION_NAME); |
| 8614 | m_device_extension_names.push_back(VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME); |
| 8615 | m_device_extension_names.push_back(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
| 8616 | } else { |
| 8617 | printf("%s requires VK_KHR_fragment_shading_rate.\n", kSkipPrefix); |
| 8618 | return; |
| 8619 | } |
| 8620 | |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 8621 | VkPhysicalDeviceFragmentShadingRateFeaturesKHR fsr_features = LvlInitStruct<VkPhysicalDeviceFragmentShadingRateFeaturesKHR>(); |
sjfricke | 11db0c7 | 2022-08-18 13:23:11 +0900 | [diff] [blame^] | 8622 | VkPhysicalDeviceFeatures2KHR features2 = GetPhysicalDeviceFeatures2(fsr_features); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8623 | |
| 8624 | if (fsr_features.attachmentFragmentShadingRate == VK_FALSE && fsr_features.primitiveFragmentShadingRate == VK_FALSE) { |
| 8625 | printf("%s requires attachmentFragmentShadingRate or primitiveFragmentShadingRate.\n", kSkipPrefix); |
| 8626 | return; |
| 8627 | } |
| 8628 | |
| 8629 | fsr_features.pipelineFragmentShadingRate = VK_FALSE; |
| 8630 | |
| 8631 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 8632 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8633 | |
| 8634 | // Find address of extension call and make the call |
| 8635 | PFN_vkCmdSetFragmentShadingRateKHR vkCmdSetFragmentShadingRateKHR = |
| 8636 | (PFN_vkCmdSetFragmentShadingRateKHR)vk::GetDeviceProcAddr(m_device->device(), "vkCmdSetFragmentShadingRateKHR"); |
| 8637 | ASSERT_TRUE(vkCmdSetFragmentShadingRateKHR != nullptr); |
| 8638 | |
| 8639 | VkExtent2D fragmentSize = {1, 1}; |
| 8640 | VkFragmentShadingRateCombinerOpKHR combinerOps[2] = {VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR, |
| 8641 | VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR}; |
| 8642 | |
| 8643 | m_commandBuffer->begin(); |
| 8644 | fragmentSize.width = 2; |
| 8645 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8646 | "VUID-vkCmdSetFragmentShadingRateKHR-pipelineFragmentShadingRate-04507"); |
| 8647 | vkCmdSetFragmentShadingRateKHR(m_commandBuffer->handle(), &fragmentSize, combinerOps); |
| 8648 | m_errorMonitor->VerifyFound(); |
| 8649 | fragmentSize.width = 1; |
| 8650 | |
| 8651 | fragmentSize.height = 2; |
| 8652 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8653 | "VUID-vkCmdSetFragmentShadingRateKHR-pipelineFragmentShadingRate-04508"); |
| 8654 | vkCmdSetFragmentShadingRateKHR(m_commandBuffer->handle(), &fragmentSize, combinerOps); |
| 8655 | m_errorMonitor->VerifyFound(); |
| 8656 | fragmentSize.height = 1; |
| 8657 | } |
| 8658 | |
| 8659 | TEST_F(VkLayerTest, InvalidSetFragmentShadingRateCombinerOpsLimit) { |
| 8660 | TEST_DESCRIPTION("Specify invalid fsr pipeline settings for the enabled features"); |
| 8661 | |
| 8662 | // Enable KHR_fragment_shading_rate and all of its required extensions |
| 8663 | bool fsr_extensions = InstanceExtensionSupported(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 8664 | if (fsr_extensions) { |
| 8665 | m_instance_extension_names.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 8666 | } |
| 8667 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
| 8668 | |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 8669 | fsr_extensions = fsr_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
| 8670 | 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] | 8671 | fsr_extensions = fsr_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_MULTIVIEW_EXTENSION_NAME); |
| 8672 | fsr_extensions = fsr_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME); |
| 8673 | fsr_extensions = fsr_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
| 8674 | if (fsr_extensions) { |
Mike Schuchardt | 7cc5784 | 2021-09-15 10:49:59 -0700 | [diff] [blame] | 8675 | m_device_extension_names.push_back(VK_KHR_MAINTENANCE_1_EXTENSION_NAME); |
| 8676 | m_device_extension_names.push_back(VK_KHR_MAINTENANCE_2_EXTENSION_NAME); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8677 | m_device_extension_names.push_back(VK_KHR_MULTIVIEW_EXTENSION_NAME); |
| 8678 | m_device_extension_names.push_back(VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME); |
| 8679 | m_device_extension_names.push_back(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
| 8680 | } else { |
| 8681 | printf("%s requires VK_KHR_fragment_shading_rate.\n", kSkipPrefix); |
| 8682 | return; |
| 8683 | } |
| 8684 | |
| 8685 | PFN_vkGetPhysicalDeviceProperties2KHR vkGetPhysicalDeviceProperties2KHR = |
| 8686 | (PFN_vkGetPhysicalDeviceProperties2KHR)vk::GetInstanceProcAddr(instance(), "vkGetPhysicalDeviceProperties2KHR"); |
| 8687 | ASSERT_TRUE(vkGetPhysicalDeviceProperties2KHR != nullptr); |
| 8688 | VkPhysicalDeviceFragmentShadingRatePropertiesKHR fsr_properties = |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 8689 | LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>(); |
| 8690 | VkPhysicalDeviceProperties2KHR properties2 = LvlInitStruct<VkPhysicalDeviceProperties2KHR>(&fsr_properties); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8691 | vkGetPhysicalDeviceProperties2KHR(gpu(), &properties2); |
| 8692 | |
| 8693 | if (fsr_properties.fragmentShadingRateNonTrivialCombinerOps) { |
| 8694 | printf("%s requires fragmentShadingRateNonTrivialCombinerOps to be unsupported.\n", kSkipPrefix); |
| 8695 | return; |
| 8696 | } |
| 8697 | |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 8698 | VkPhysicalDeviceFragmentShadingRateFeaturesKHR fsr_features = LvlInitStruct<VkPhysicalDeviceFragmentShadingRateFeaturesKHR>(); |
sjfricke | 11db0c7 | 2022-08-18 13:23:11 +0900 | [diff] [blame^] | 8699 | VkPhysicalDeviceFeatures2KHR features2 = GetPhysicalDeviceFeatures2(fsr_features); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8700 | |
| 8701 | if (!fsr_features.primitiveFragmentShadingRate && !fsr_features.attachmentFragmentShadingRate) { |
| 8702 | printf("%s requires primitiveFragmentShadingRate or attachmentFragmentShadingRate to be supported.\n", kSkipPrefix); |
| 8703 | return; |
| 8704 | } |
| 8705 | |
| 8706 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 8707 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8708 | |
| 8709 | // Find address of extension call and make the call |
| 8710 | PFN_vkCmdSetFragmentShadingRateKHR vkCmdSetFragmentShadingRateKHR = |
| 8711 | (PFN_vkCmdSetFragmentShadingRateKHR)vk::GetDeviceProcAddr(m_device->device(), "vkCmdSetFragmentShadingRateKHR"); |
| 8712 | ASSERT_TRUE(vkCmdSetFragmentShadingRateKHR != nullptr); |
| 8713 | |
| 8714 | VkExtent2D fragmentSize = {1, 1}; |
| 8715 | VkFragmentShadingRateCombinerOpKHR combinerOps[2] = {VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR, |
| 8716 | VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR}; |
| 8717 | |
| 8718 | m_commandBuffer->begin(); |
| 8719 | if (fsr_features.primitiveFragmentShadingRate) { |
| 8720 | combinerOps[0] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_KHR; |
| 8721 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8722 | "VUID-vkCmdSetFragmentShadingRateKHR-fragmentSizeNonTrivialCombinerOps-04512"); |
| 8723 | vkCmdSetFragmentShadingRateKHR(m_commandBuffer->handle(), &fragmentSize, combinerOps); |
| 8724 | m_errorMonitor->VerifyFound(); |
| 8725 | combinerOps[0] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR; |
| 8726 | } |
| 8727 | |
| 8728 | if (fsr_features.attachmentFragmentShadingRate) { |
| 8729 | combinerOps[1] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_KHR; |
| 8730 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8731 | "VUID-vkCmdSetFragmentShadingRateKHR-fragmentSizeNonTrivialCombinerOps-04512"); |
| 8732 | vkCmdSetFragmentShadingRateKHR(m_commandBuffer->handle(), &fragmentSize, combinerOps); |
| 8733 | m_errorMonitor->VerifyFound(); |
| 8734 | combinerOps[1] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR; |
| 8735 | } |
| 8736 | m_commandBuffer->end(); |
| 8737 | } |
| 8738 | |
| 8739 | TEST_F(VkLayerTest, InvalidPrimitiveFragmentShadingRateWriteMultiViewportLimitDynamic) { |
| 8740 | TEST_DESCRIPTION("Test dynamic validation of the primitiveFragmentShadingRateWithMultipleViewports limit"); |
| 8741 | |
| 8742 | // Enable KHR_fragment_shading_rate and all of its required extensions |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 8743 | AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
| 8744 | AddRequiredExtensions(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME); |
| 8745 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 8746 | if (!AreRequiredExtensionsEnabled()) { |
| 8747 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported."; |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8748 | } |
| 8749 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 8750 | auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>(); |
| 8751 | GetPhysicalDeviceProperties2(fsr_properties); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8752 | |
| 8753 | if (fsr_properties.primitiveFragmentShadingRateWithMultipleViewports) { |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 8754 | GTEST_SKIP() << "Test requires primitiveFragmentShadingRateWithMultipleViewports to be unsupported."; |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8755 | } |
| 8756 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 8757 | auto eds_features = LvlInitStruct<VkPhysicalDeviceExtendedDynamicStateFeaturesEXT>(); |
| 8758 | auto fsr_features = LvlInitStruct<VkPhysicalDeviceFragmentShadingRateFeaturesKHR>(&eds_features); |
| 8759 | auto features2 = GetPhysicalDeviceFeatures2(fsr_features); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8760 | |
| 8761 | if (!fsr_features.primitiveFragmentShadingRate) { |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 8762 | GTEST_SKIP() << "Test requires primitiveFragmentShadingRate to be supported."; |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8763 | } |
| 8764 | |
| 8765 | if (!features2.features.multiViewport) { |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 8766 | GTEST_SKIP() << "%s requires multiViewport to be supported."; |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8767 | } |
| 8768 | |
| 8769 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 8770 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8771 | |
sfricke-samsung | 1c0b96a | 2021-07-08 22:24:09 -0700 | [diff] [blame] | 8772 | char const *vsSource = R"glsl( |
| 8773 | #version 450 |
| 8774 | #extension GL_EXT_fragment_shading_rate : enable |
| 8775 | void main() { |
| 8776 | gl_PrimitiveShadingRateEXT = gl_ShadingRateFlag4VerticalPixelsEXT | gl_ShadingRateFlag4HorizontalPixelsEXT; |
| 8777 | } |
| 8778 | )glsl"; |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8779 | |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 8780 | VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8781 | |
| 8782 | VkPipelineObj pipe(m_device); |
Tony-LunarG | 6ee1006 | 2021-02-03 13:56:52 -0700 | [diff] [blame] | 8783 | std::vector<VkRect2D> scissors = {{{0, 0}, {16, 16}}, {{1, 1}, {16, 16}}}; |
| 8784 | pipe.SetScissor(scissors); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8785 | pipe.AddShader(&fs); |
| 8786 | pipe.AddDefaultColorAttachment(); |
| 8787 | pipe.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8788 | const VkPipelineLayoutObj pl(m_device); |
Tony-LunarG | 6ee1006 | 2021-02-03 13:56:52 -0700 | [diff] [blame] | 8789 | { |
sfricke-samsung | ae54c1e | 2022-01-21 05:35:21 -0800 | [diff] [blame] | 8790 | VkShaderObj vs(this, vsSource, VK_SHADER_STAGE_VERTEX_BIT); |
Tony-LunarG | 6ee1006 | 2021-02-03 13:56:52 -0700 | [diff] [blame] | 8791 | pipe.AddShader(&vs); |
| 8792 | VkResult err = pipe.CreateVKPipeline(pl.handle(), renderPass()); |
| 8793 | ASSERT_VK_SUCCESS(err); |
| 8794 | } |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8795 | m_commandBuffer->begin(); |
| 8796 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 8797 | |
| 8798 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 8799 | |
| 8800 | VkViewport viewports[] = {{0, 0, 16, 16, 0, 1}, {1, 1, 16, 16, 0, 1}}; |
| 8801 | PFN_vkCmdSetViewportWithCountEXT vkCmdSetViewportWithCountEXT = |
| 8802 | (PFN_vkCmdSetViewportWithCountEXT)vk::GetDeviceProcAddr(device(), "vkCmdSetViewportWithCountEXT"); |
| 8803 | vkCmdSetViewportWithCountEXT(m_commandBuffer->handle(), 2, viewports); |
| 8804 | |
| 8805 | // error produced here. |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 8806 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-primitiveFragmentShadingRateWithMultipleViewports-04552"); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8807 | vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0); |
Tobias Hector | 04f2ab2 | 2020-12-01 10:59:33 +0000 | [diff] [blame] | 8808 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 07d0a61 | 2020-12-30 15:42:31 -0700 | [diff] [blame] | 8809 | } |
ziga-lunarg | dada63d | 2021-07-13 22:10:11 +0200 | [diff] [blame] | 8810 | |
| 8811 | TEST_F(VkLayerTest, InvalidCmdUpdateBufferSize) { |
| 8812 | TEST_DESCRIPTION("Update buffer with invalid dataSize"); |
| 8813 | |
| 8814 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 8815 | |
| 8816 | uint32_t update_data[4] = {0, 0, 0, 0}; |
| 8817 | VkDeviceSize dataSize = sizeof(uint32_t) * 4; |
| 8818 | VkMemoryPropertyFlags reqs = 0; |
| 8819 | VkBufferObj buffer; |
| 8820 | buffer.init_as_src_and_dst(*m_device, dataSize, reqs); |
| 8821 | |
| 8822 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdUpdateBuffer-dataSize-00033"); |
| 8823 | m_commandBuffer->begin(); |
| 8824 | vk::CmdUpdateBuffer(m_commandBuffer->handle(), buffer.handle(), sizeof(uint32_t), dataSize, (void *)update_data); |
| 8825 | m_commandBuffer->end(); |
| 8826 | m_errorMonitor->VerifyFound(); |
| 8827 | } |
ziga-lunarg | c08456d | 2021-07-16 21:40:13 +0200 | [diff] [blame] | 8828 | |
| 8829 | TEST_F(VkLayerTest, InvalidCmdUpdateBufferDstOffset) { |
| 8830 | TEST_DESCRIPTION("Update buffer with invalid dst offset"); |
| 8831 | |
| 8832 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 8833 | |
| 8834 | uint32_t update_data[4] = {0, 0, 0, 0}; |
| 8835 | VkDeviceSize dataSize = sizeof(uint32_t) * 4; |
| 8836 | VkMemoryPropertyFlags reqs = 0; |
| 8837 | VkBufferObj buffer; |
| 8838 | buffer.init_as_src_and_dst(*m_device, dataSize, reqs); |
| 8839 | |
| 8840 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdUpdateBuffer-dstOffset-00032"); |
| 8841 | m_commandBuffer->begin(); |
| 8842 | vk::CmdUpdateBuffer(m_commandBuffer->handle(), buffer.handle(), sizeof(uint32_t) * 8, dataSize, (void *)update_data); |
| 8843 | m_commandBuffer->end(); |
| 8844 | m_errorMonitor->VerifyFound(); |
| 8845 | } |
ziga-lunarg | 4e31a75 | 2021-07-22 14:35:03 +0200 | [diff] [blame] | 8846 | |
| 8847 | TEST_F(VkLayerTest, InvalidDescriptorSetPipelineBindPoint) { |
| 8848 | TEST_DESCRIPTION( |
| 8849 | "Attempt to bind descriptor set to a bind point not supported by command pool the command buffer was allocated from"); |
| 8850 | |
| 8851 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 8852 | |
| 8853 | const uint32_t no_gfx_qfi = m_device->QueueFamilyMatching(VK_QUEUE_COMPUTE_BIT, VK_QUEUE_GRAPHICS_BIT); |
| 8854 | const uint32_t INVALID_QUEUE = std::numeric_limits<uint32_t>::max(); |
| 8855 | if (INVALID_QUEUE == no_gfx_qfi) { |
| 8856 | printf("%s No compute and transfer only queue family, skipping bindpoint and queue tests.\n", kSkipPrefix); |
| 8857 | return; |
| 8858 | } |
| 8859 | |
| 8860 | VkCommandPoolObj command_pool(m_device, no_gfx_qfi); |
| 8861 | ASSERT_TRUE(command_pool.initialized()); |
| 8862 | VkCommandBufferObj command_buffer(m_device, &command_pool); |
| 8863 | |
| 8864 | VkDescriptorPoolSize ds_type_count = {}; |
| 8865 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8866 | ds_type_count.descriptorCount = 1; |
| 8867 | |
| 8868 | VkDescriptorPoolCreateInfo ds_pool_ci = LvlInitStruct<VkDescriptorPoolCreateInfo>(); |
| 8869 | ds_pool_ci.maxSets = 1; |
| 8870 | ds_pool_ci.poolSizeCount = 1; |
| 8871 | ds_pool_ci.flags = 0; |
| 8872 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 8873 | |
Nathaniel Cesario | 079b1b9 | 2022-07-06 15:56:26 -0600 | [diff] [blame] | 8874 | vk_testing::DescriptorPool ds_pool(*m_device, ds_pool_ci); |
| 8875 | ASSERT_TRUE(ds_pool.initialized()); |
ziga-lunarg | 4e31a75 | 2021-07-22 14:35:03 +0200 | [diff] [blame] | 8876 | |
| 8877 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 8878 | dsl_binding.binding = 0; |
| 8879 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8880 | dsl_binding.descriptorCount = 1; |
| 8881 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8882 | dsl_binding.pImmutableSamplers = nullptr; |
| 8883 | |
| 8884 | const VkDescriptorSetLayoutObj ds_layout(m_device, {dsl_binding}); |
| 8885 | |
| 8886 | VkDescriptorSet descriptorSet; |
| 8887 | VkDescriptorSetAllocateInfo alloc_info = LvlInitStruct<VkDescriptorSetAllocateInfo>(); |
| 8888 | alloc_info.descriptorSetCount = 1; |
Nathaniel Cesario | 079b1b9 | 2022-07-06 15:56:26 -0600 | [diff] [blame] | 8889 | alloc_info.descriptorPool = ds_pool.handle(); |
ziga-lunarg | 4e31a75 | 2021-07-22 14:35:03 +0200 | [diff] [blame] | 8890 | alloc_info.pSetLayouts = &ds_layout.handle(); |
| 8891 | vk::AllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 8892 | |
| 8893 | const VkDescriptorSetLayoutObj descriptor_set_layout(m_device, {dsl_binding}); |
| 8894 | const VkPipelineLayoutObj pipeline_layout(DeviceObj(), {&descriptor_set_layout}); |
| 8895 | |
| 8896 | command_buffer.begin(); |
| 8897 | // Set invalid set |
| 8898 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindDescriptorSets-pipelineBindPoint-00361"); |
| 8899 | vk::CmdBindDescriptorSets(command_buffer.handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout.handle(), 0, 1, |
| 8900 | &descriptorSet, 0, nullptr); |
| 8901 | m_errorMonitor->VerifyFound(); |
| 8902 | command_buffer.end(); |
| 8903 | } |
ziga-lunarg | 4d86a25 | 2021-07-23 00:31:07 +0200 | [diff] [blame] | 8904 | |
| 8905 | TEST_F(VkLayerTest, CommandBufferMissingOcclusionQueryEnabled) { |
| 8906 | TEST_DESCRIPTION( |
| 8907 | "Test executing secondary command buffer without VkCommandBufferInheritanceInfo::occlusionQueryEnable enabled while " |
| 8908 | "occlusion query is active."); |
| 8909 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 8910 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8911 | |
| 8912 | VkQueryPoolCreateInfo qpci = LvlInitStruct<VkQueryPoolCreateInfo>(); |
| 8913 | qpci.queryType = VK_QUERY_TYPE_OCCLUSION; |
| 8914 | qpci.queryCount = 1; |
| 8915 | |
| 8916 | VkQueryPool query_pool; |
| 8917 | vk::CreateQueryPool(device(), &qpci, nullptr, &query_pool); |
| 8918 | |
| 8919 | VkCommandBufferObj secondary(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 8920 | |
| 8921 | VkCommandBufferInheritanceInfo cbii = LvlInitStruct<VkCommandBufferInheritanceInfo>(); |
| 8922 | cbii.renderPass = m_renderPass; |
| 8923 | cbii.framebuffer = m_framebuffer; |
| 8924 | cbii.occlusionQueryEnable = VK_FALSE; // Invalid |
| 8925 | |
| 8926 | VkCommandBufferBeginInfo cbbi = LvlInitStruct<VkCommandBufferBeginInfo>(); |
| 8927 | cbbi.pInheritanceInfo = &cbii; |
| 8928 | |
| 8929 | VkCommandBuffer secondary_handle = secondary.handle(); |
| 8930 | vk::BeginCommandBuffer(secondary_handle, &cbbi); |
| 8931 | vk::EndCommandBuffer(secondary_handle); |
| 8932 | |
| 8933 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-commandBuffer-00102"); |
| 8934 | m_commandBuffer->begin(); |
| 8935 | vk::CmdBeginQuery(m_commandBuffer->handle(), query_pool, 0, 0); |
| 8936 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle); |
| 8937 | vk::CmdEndQuery(m_commandBuffer->handle(), query_pool, 0); |
| 8938 | m_commandBuffer->end(); |
| 8939 | m_errorMonitor->VerifyFound(); |
| 8940 | |
| 8941 | vk::DestroyQueryPool(device(), query_pool, nullptr); |
| 8942 | } |
Nathaniel Cesario | 46465d3 | 2021-08-03 13:52:01 -0600 | [diff] [blame] | 8943 | |
| 8944 | TEST_F(VkLayerTest, CmdClearColorImageNullColor) { |
| 8945 | TEST_DESCRIPTION("Test invalid null entries for clear color"); |
| 8946 | |
| 8947 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 8948 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8949 | |
| 8950 | VkImageObj image(m_device); |
| 8951 | image.Init(32, 32, 1, VK_FORMAT_B8G8R8A8_UNORM, VK_IMAGE_USAGE_TRANSFER_DST_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 8952 | |
| 8953 | VkImageSubresourceRange isr = {}; |
| 8954 | isr.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8955 | isr.baseArrayLayer = 0; |
| 8956 | isr.baseMipLevel = 0; |
| 8957 | isr.layerCount = 1; |
| 8958 | isr.levelCount = 1; |
| 8959 | |
| 8960 | m_commandBuffer->begin(); |
| 8961 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdClearColorImage-pColor-04961"); |
| 8962 | vk::CmdClearColorImage(m_commandBuffer->handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, nullptr, 1, &isr); |
| 8963 | m_errorMonitor->VerifyFound(); |
| 8964 | m_commandBuffer->end(); |
| 8965 | } |
ziga-lunarg | ad4f0fe | 2021-08-05 17:01:07 +0200 | [diff] [blame] | 8966 | |
| 8967 | TEST_F(VkLayerTest, InvalidClearColorAttachmentsWithMultiview) { |
| 8968 | TEST_DESCRIPTION("Test cmdClearAttachments with active render pass that uses multiview"); |
| 8969 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 8970 | AddRequiredExtensions(VK_KHR_MULTIVIEW_EXTENSION_NAME); |
ziga-lunarg | ad4f0fe | 2021-08-05 17:01:07 +0200 | [diff] [blame] | 8971 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 8972 | if (!AreRequiredExtensionsEnabled()) { |
| 8973 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported."; |
ziga-lunarg | ad4f0fe | 2021-08-05 17:01:07 +0200 | [diff] [blame] | 8974 | } |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 8975 | |
| 8976 | auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>(); |
| 8977 | auto features2 = GetPhysicalDeviceFeatures2(multiview_features); |
| 8978 | if (!multiview_features.multiview) { |
| 8979 | GTEST_SKIP() << "VkPhysicalDeviceMultiviewFeatures::multiview not supported"; |
| 8980 | } |
| 8981 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
ziga-lunarg | ad4f0fe | 2021-08-05 17:01:07 +0200 | [diff] [blame] | 8982 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8983 | |
| 8984 | VkAttachmentDescription attachmentDescription = {}; |
| 8985 | attachmentDescription.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 8986 | attachmentDescription.samples = VK_SAMPLE_COUNT_1_BIT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 8987 | attachmentDescription.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
ziga-lunarg | ad4f0fe | 2021-08-05 17:01:07 +0200 | [diff] [blame] | 8988 | attachmentDescription.finalLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 8989 | |
| 8990 | VkAttachmentReference colorAttachmentReference = {}; |
| 8991 | colorAttachmentReference.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 8992 | colorAttachmentReference.attachment = 0; |
| 8993 | |
| 8994 | VkSubpassDescription subpassDescription = {}; |
| 8995 | subpassDescription.colorAttachmentCount = 1; |
| 8996 | subpassDescription.pColorAttachments = &colorAttachmentReference; |
| 8997 | |
| 8998 | uint32_t viewMask = 0x1u; |
| 8999 | VkRenderPassMultiviewCreateInfo renderPassMultiviewCreateInfo = LvlInitStruct<VkRenderPassMultiviewCreateInfo>(); |
| 9000 | renderPassMultiviewCreateInfo.subpassCount = 1; |
| 9001 | renderPassMultiviewCreateInfo.pViewMasks = &viewMask; |
| 9002 | |
| 9003 | VkRenderPassCreateInfo renderPassCreateInfo = LvlInitStruct<VkRenderPassCreateInfo>(&renderPassMultiviewCreateInfo); |
| 9004 | renderPassCreateInfo.attachmentCount = 1; |
| 9005 | renderPassCreateInfo.pAttachments = &attachmentDescription; |
| 9006 | renderPassCreateInfo.subpassCount = 1; |
| 9007 | renderPassCreateInfo.pSubpasses = &subpassDescription; |
| 9008 | |
Nathaniel Cesario | 079b1b9 | 2022-07-06 15:56:26 -0600 | [diff] [blame] | 9009 | vk_testing::RenderPass renderPass(*m_device, renderPassCreateInfo); |
| 9010 | ASSERT_TRUE(renderPass.initialized()); |
ziga-lunarg | ad4f0fe | 2021-08-05 17:01:07 +0200 | [diff] [blame] | 9011 | |
| 9012 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 9013 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9014 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 9015 | image_create_info.extent.width = 32; |
| 9016 | image_create_info.extent.height = 32; |
| 9017 | image_create_info.extent.depth = 1; |
| 9018 | image_create_info.mipLevels = 1; |
| 9019 | image_create_info.arrayLayers = 4; |
| 9020 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9021 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9022 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9023 | image_create_info.flags = 0; |
| 9024 | |
| 9025 | VkImageObj image(m_device); |
| 9026 | image.Init(image_create_info); |
aitor-lunarg | 4c6d9b2 | 2022-01-25 20:24:57 +0100 | [diff] [blame] | 9027 | VkImageView imageView = image.targetView(VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_ASPECT_COLOR_BIT, 0, VK_REMAINING_MIP_LEVELS, 0, |
| 9028 | VK_REMAINING_ARRAY_LAYERS, VK_IMAGE_VIEW_TYPE_2D_ARRAY); |
ziga-lunarg | ad4f0fe | 2021-08-05 17:01:07 +0200 | [diff] [blame] | 9029 | |
| 9030 | VkFramebufferCreateInfo framebufferCreateInfo = LvlInitStruct<VkFramebufferCreateInfo>(); |
| 9031 | framebufferCreateInfo.width = 32; |
| 9032 | framebufferCreateInfo.height = 32; |
| 9033 | framebufferCreateInfo.layers = 1; |
Nathaniel Cesario | 079b1b9 | 2022-07-06 15:56:26 -0600 | [diff] [blame] | 9034 | framebufferCreateInfo.renderPass = renderPass.handle(); |
ziga-lunarg | ad4f0fe | 2021-08-05 17:01:07 +0200 | [diff] [blame] | 9035 | framebufferCreateInfo.attachmentCount = 1; |
| 9036 | framebufferCreateInfo.pAttachments = &imageView; |
| 9037 | |
Nathaniel Cesario | 079b1b9 | 2022-07-06 15:56:26 -0600 | [diff] [blame] | 9038 | vk_testing::Framebuffer framebuffer(*m_device, framebufferCreateInfo); |
| 9039 | ASSERT_TRUE(framebuffer.initialized()); |
ziga-lunarg | ad4f0fe | 2021-08-05 17:01:07 +0200 | [diff] [blame] | 9040 | |
| 9041 | // Start no RenderPass |
| 9042 | m_commandBuffer->begin(); |
| 9043 | |
| 9044 | VkClearAttachment color_attachment; |
| 9045 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9046 | color_attachment.clearValue.color.float32[0] = 0; |
| 9047 | color_attachment.clearValue.color.float32[1] = 0; |
| 9048 | color_attachment.clearValue.color.float32[2] = 0; |
| 9049 | color_attachment.clearValue.color.float32[3] = 0; |
| 9050 | color_attachment.colorAttachment = 0; |
| 9051 | |
| 9052 | VkClearRect clear_rect = {}; |
| 9053 | clear_rect.rect.extent.width = 32; |
| 9054 | clear_rect.rect.extent.height = 32; |
| 9055 | |
| 9056 | VkRenderPassBeginInfo render_pass_begin_info = LvlInitStruct<VkRenderPassBeginInfo>(); |
Nathaniel Cesario | 079b1b9 | 2022-07-06 15:56:26 -0600 | [diff] [blame] | 9057 | render_pass_begin_info.renderPass = renderPass.handle(); |
| 9058 | render_pass_begin_info.framebuffer = framebuffer.handle(); |
ziga-lunarg | ad4f0fe | 2021-08-05 17:01:07 +0200 | [diff] [blame] | 9059 | render_pass_begin_info.renderArea.extent.width = 32; |
| 9060 | render_pass_begin_info.renderArea.extent.height = 32; |
| 9061 | |
| 9062 | vk::CmdBeginRenderPass(m_commandBuffer->handle(), &render_pass_begin_info, VK_SUBPASS_CONTENTS_INLINE); |
| 9063 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdClearAttachments-baseArrayLayer-00018"); |
| 9064 | clear_rect.layerCount = 2; |
| 9065 | vk::CmdClearAttachments(m_commandBuffer->handle(), 1, &color_attachment, 1, &clear_rect); |
| 9066 | m_errorMonitor->VerifyFound(); |
| 9067 | |
| 9068 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdClearAttachments-baseArrayLayer-00018"); |
| 9069 | clear_rect.baseArrayLayer = 1; |
| 9070 | clear_rect.layerCount = 1; |
| 9071 | vk::CmdClearAttachments(m_commandBuffer->handle(), 1, &color_attachment, 1, &clear_rect); |
| 9072 | m_errorMonitor->VerifyFound(); |
| 9073 | } |
ziga-lunarg | daff74b | 2021-08-14 23:16:25 +0200 | [diff] [blame] | 9074 | |
| 9075 | TEST_F(VkLayerTest, TestEndCommandBufferWithConditionalRendering) { |
| 9076 | TEST_DESCRIPTION("Call EndCommandBuffer when conditional rendering is active"); |
| 9077 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9078 | AddRequiredExtensions(VK_EXT_CONDITIONAL_RENDERING_EXTENSION_NAME); |
ziga-lunarg | daff74b | 2021-08-14 23:16:25 +0200 | [diff] [blame] | 9079 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9080 | if (!AreRequiredExtensionsEnabled()) { |
| 9081 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | daff74b | 2021-08-14 23:16:25 +0200 | [diff] [blame] | 9082 | } |
| 9083 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9084 | |
| 9085 | PFN_vkCmdBeginConditionalRenderingEXT vkCmdBeginConditionalRenderingEXT = |
| 9086 | (PFN_vkCmdBeginConditionalRenderingEXT)vk::GetInstanceProcAddr(instance(), "vkCmdBeginConditionalRenderingEXT"); |
| 9087 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9088 | auto buffer_ci = |
| 9089 | vk_testing::Buffer::create_info(32, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_CONDITIONAL_RENDERING_BIT_EXT); |
| 9090 | vk_testing::Buffer buffer(*m_device, buffer_ci); |
ziga-lunarg | daff74b | 2021-08-14 23:16:25 +0200 | [diff] [blame] | 9091 | |
| 9092 | VkConditionalRenderingBeginInfoEXT conditional_rendering_begin = LvlInitStruct<VkConditionalRenderingBeginInfoEXT>(); |
| 9093 | conditional_rendering_begin.buffer = buffer.handle(); |
| 9094 | |
| 9095 | VkCommandBufferBeginInfo command_buffer_begin = LvlInitStruct<VkCommandBufferBeginInfo>(); |
| 9096 | |
| 9097 | vk::BeginCommandBuffer(m_commandBuffer->handle(), &command_buffer_begin); |
| 9098 | vkCmdBeginConditionalRenderingEXT(m_commandBuffer->handle(), &conditional_rendering_begin); |
| 9099 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkEndCommandBuffer-None-01978"); |
| 9100 | vk::EndCommandBuffer(m_commandBuffer->handle()); |
| 9101 | m_errorMonitor->VerifyFound(); |
| 9102 | } |
ziga-lunarg | 1b7bd57 | 2021-08-21 21:49:26 +0200 | [diff] [blame] | 9103 | |
| 9104 | TEST_F(VkLayerTest, BindPipelineDuringTransformFeedback) { |
| 9105 | TEST_DESCRIPTION("Call CmdBindPipeline when transform feedback is active"); |
| 9106 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9107 | AddRequiredExtensions(VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME); |
| 9108 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 9109 | if (!AreRequiredExtensionsEnabled()) { |
| 9110 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported."; |
ziga-lunarg | 1b7bd57 | 2021-08-21 21:49:26 +0200 | [diff] [blame] | 9111 | } |
| 9112 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9113 | auto xfb_features = LvlInitStruct<VkPhysicalDeviceTransformFeedbackFeaturesEXT>(); |
| 9114 | auto features2 = GetPhysicalDeviceFeatures2(xfb_features); |
| 9115 | if (!xfb_features.transformFeedback) { |
| 9116 | GTEST_SKIP() << "VkPhysicalDeviceTransformFeedbackFeaturesEXT::transformFeedback not supported."; |
| 9117 | } |
| 9118 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
ziga-lunarg | 1b7bd57 | 2021-08-21 21:49:26 +0200 | [diff] [blame] | 9119 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9120 | |
| 9121 | CreatePipelineHelper pipe_one(*this); |
| 9122 | pipe_one.InitInfo(); |
| 9123 | pipe_one.InitState(); |
| 9124 | pipe_one.CreateGraphicsPipeline(); |
| 9125 | |
| 9126 | CreatePipelineHelper pipe_two(*this); |
| 9127 | pipe_two.InitInfo(); |
| 9128 | pipe_two.InitState(); |
| 9129 | pipe_two.CreateGraphicsPipeline(); |
| 9130 | |
| 9131 | auto vkCmdBeginTransformFeedbackEXT = |
| 9132 | (PFN_vkCmdBeginTransformFeedbackEXT)vk::GetDeviceProcAddr(m_device->device(), "vkCmdBeginTransformFeedbackEXT"); |
| 9133 | ASSERT_TRUE(vkCmdBeginTransformFeedbackEXT != nullptr); |
| 9134 | auto vkCmdEndTransformFeedbackEXT = |
| 9135 | (PFN_vkCmdEndTransformFeedbackEXT)vk::GetDeviceProcAddr(m_device->device(), "vkCmdEndTransformFeedbackEXT"); |
| 9136 | ASSERT_TRUE(vkCmdEndTransformFeedbackEXT != nullptr); |
| 9137 | |
| 9138 | m_commandBuffer->begin(); |
| 9139 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe_one.pipeline_); |
| 9140 | vkCmdBeginTransformFeedbackEXT(m_commandBuffer->handle(), 0, 1, nullptr, nullptr); |
| 9141 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-None-02323"); |
| 9142 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe_two.pipeline_); |
| 9143 | m_errorMonitor->VerifyFound(); |
| 9144 | vkCmdEndTransformFeedbackEXT(m_commandBuffer->handle(), 0, 1, nullptr, nullptr); |
| 9145 | m_commandBuffer->end(); |
ziga-lunarg | deeb825 | 2021-08-30 16:48:46 +0200 | [diff] [blame] | 9146 | } |
| 9147 | |
| 9148 | TEST_F(VkLayerTest, DrawBlendEnabledFormatFeatures) { |
| 9149 | TEST_DESCRIPTION("Test pipeline blend enabled with missing image views format features"); |
| 9150 | |
| 9151 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 9152 | |
| 9153 | PFN_vkSetPhysicalDeviceFormatPropertiesEXT fpvkSetPhysicalDeviceFormatPropertiesEXT = nullptr; |
| 9154 | PFN_vkGetOriginalPhysicalDeviceFormatPropertiesEXT fpvkGetOriginalPhysicalDeviceFormatPropertiesEXT = nullptr; |
ziga-lunarg | deeb825 | 2021-08-30 16:48:46 +0200 | [diff] [blame] | 9155 | if (!LoadDeviceProfileLayer(fpvkSetPhysicalDeviceFormatPropertiesEXT, fpvkGetOriginalPhysicalDeviceFormatPropertiesEXT)) { |
sjfricke | 3a10ae8 | 2022-08-02 18:48:57 +0900 | [diff] [blame] | 9156 | GTEST_SKIP() << "Failed to load device profile layer."; |
ziga-lunarg | deeb825 | 2021-08-30 16:48:46 +0200 | [diff] [blame] | 9157 | } |
| 9158 | |
| 9159 | VkFormat render_format = VkTestFramework::GetFormat(instance_, m_device); |
| 9160 | |
| 9161 | // Set format features from being found |
| 9162 | VkFormatProperties formatProps; |
| 9163 | fpvkGetOriginalPhysicalDeviceFormatPropertiesEXT(gpu(), render_format, &formatProps); |
| 9164 | if ((formatProps.linearTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) == 0) { |
| 9165 | printf("%s Required linear tiling features not supported.\n", kSkipPrefix); |
| 9166 | return; |
| 9167 | } |
| 9168 | // Gets pass pipeline creation but not the actual tiling used |
| 9169 | formatProps.optimalTilingFeatures |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT; |
| 9170 | // will be caught at draw time that feature for optimal image is not set |
| 9171 | // InitRenderTarget() should be setting color attachment as VK_IMAGE_TILING_LINEAR |
| 9172 | formatProps.linearTilingFeatures &= ~VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT; |
| 9173 | fpvkSetPhysicalDeviceFormatPropertiesEXT(gpu(), render_format, formatProps); |
| 9174 | |
| 9175 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9176 | |
| 9177 | CreatePipelineHelper pipe(*this); |
| 9178 | pipe.InitInfo(); |
| 9179 | pipe.InitState(); |
aitor-lunarg | f15acd5 | 2022-03-09 22:13:25 +0100 | [diff] [blame] | 9180 | pipe.cb_attachments_[0].blendEnable = VK_TRUE; |
ziga-lunarg | deeb825 | 2021-08-30 16:48:46 +0200 | [diff] [blame] | 9181 | pipe.CreateGraphicsPipeline(); |
| 9182 | |
| 9183 | m_commandBuffer->begin(); |
| 9184 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_); |
| 9185 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 9186 | |
| 9187 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-blendEnable-04727"); |
| 9188 | vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0); |
| 9189 | m_errorMonitor->VerifyFound(); |
| 9190 | |
| 9191 | m_commandBuffer->EndRenderPass(); |
| 9192 | m_commandBuffer->end(); |
| 9193 | } |
ziga-lunarg | 88c0e39 | 2021-09-03 19:14:13 +0200 | [diff] [blame] | 9194 | |
| 9195 | TEST_F(VkLayerTest, InvalidEndConditionalRendering) { |
| 9196 | TEST_DESCRIPTION("Invalid calls to vkCmdEndConditionalRenderingEXT."); |
| 9197 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9198 | AddRequiredExtensions(VK_EXT_CONDITIONAL_RENDERING_EXTENSION_NAME); |
ziga-lunarg | 88c0e39 | 2021-09-03 19:14:13 +0200 | [diff] [blame] | 9199 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9200 | if (!AreRequiredExtensionsEnabled()) { |
| 9201 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported."; |
ziga-lunarg | 88c0e39 | 2021-09-03 19:14:13 +0200 | [diff] [blame] | 9202 | } |
ziga-lunarg | 88c0e39 | 2021-09-03 19:14:13 +0200 | [diff] [blame] | 9203 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9204 | |
| 9205 | VkAttachmentDescription attach[] = { |
| 9206 | {0, VK_FORMAT_R8G8B8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 9207 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_IMAGE_LAYOUT_UNDEFINED, |
| 9208 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}, |
| 9209 | }; |
| 9210 | VkAttachmentReference ref = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}; |
| 9211 | VkSubpassDescription subpasses[] = { |
| 9212 | {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &ref, nullptr, nullptr, 0, nullptr}, |
| 9213 | {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &ref, nullptr, nullptr, 0, nullptr}, |
| 9214 | }; |
| 9215 | |
| 9216 | VkSubpassDependency dep = {0, |
| 9217 | 1, |
| 9218 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, |
| 9219 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, |
| 9220 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, |
| 9221 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, |
| 9222 | VK_DEPENDENCY_BY_REGION_BIT}; |
| 9223 | |
| 9224 | VkRenderPassCreateInfo rpci = LvlInitStruct<VkRenderPassCreateInfo>(); |
| 9225 | rpci.attachmentCount = 1; |
| 9226 | rpci.pAttachments = attach; |
| 9227 | rpci.subpassCount = 2; |
| 9228 | rpci.pSubpasses = subpasses; |
| 9229 | rpci.dependencyCount = 1; |
| 9230 | rpci.pDependencies = &dep; |
| 9231 | |
| 9232 | vk_testing::RenderPass render_pass; |
| 9233 | render_pass.init(*m_device, rpci); |
Nathaniel Cesario | 079b1b9 | 2022-07-06 15:56:26 -0600 | [diff] [blame] | 9234 | ASSERT_TRUE(render_pass.initialized()); |
ziga-lunarg | 88c0e39 | 2021-09-03 19:14:13 +0200 | [diff] [blame] | 9235 | |
| 9236 | VkImageObj image(m_device); |
| 9237 | image.InitNoLayout(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 9238 | VkImageView imageView = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 9239 | |
| 9240 | VkFramebufferCreateInfo fbci = LvlInitStruct<VkFramebufferCreateInfo>(); |
| 9241 | fbci.renderPass = render_pass.handle(); |
| 9242 | fbci.attachmentCount = 1; |
| 9243 | fbci.pAttachments = &imageView; |
| 9244 | fbci.width = 32; |
| 9245 | fbci.height = 32; |
| 9246 | fbci.layers = 1; |
Nathaniel Cesario | 079b1b9 | 2022-07-06 15:56:26 -0600 | [diff] [blame] | 9247 | vk_testing::Framebuffer framebuffer(*m_device, fbci); |
| 9248 | ASSERT_TRUE(framebuffer.initialized()); |
ziga-lunarg | 88c0e39 | 2021-09-03 19:14:13 +0200 | [diff] [blame] | 9249 | |
| 9250 | PFN_vkCmdBeginConditionalRenderingEXT vkCmdBeginConditionalRenderingEXT = |
| 9251 | (PFN_vkCmdBeginConditionalRenderingEXT)vk::GetDeviceProcAddr(m_device->handle(), "vkCmdBeginConditionalRenderingEXT"); |
| 9252 | PFN_vkCmdEndConditionalRenderingEXT vkCmdEndConditionalRenderingEXT = |
| 9253 | (PFN_vkCmdEndConditionalRenderingEXT)vk::GetDeviceProcAddr(m_device->handle(), "vkCmdEndConditionalRenderingEXT"); |
| 9254 | |
| 9255 | VkBufferCreateInfo buffer_create_info = LvlInitStruct<VkBufferCreateInfo>(); |
| 9256 | buffer_create_info.size = 32; |
| 9257 | buffer_create_info.usage = VK_BUFFER_USAGE_CONDITIONAL_RENDERING_BIT_EXT; |
| 9258 | VkBufferObj buffer; |
| 9259 | buffer.init(*m_device, buffer_create_info); |
| 9260 | |
| 9261 | VkConditionalRenderingBeginInfoEXT conditional_rendering_begin = LvlInitStruct<VkConditionalRenderingBeginInfoEXT>(); |
| 9262 | conditional_rendering_begin.buffer = buffer.handle(); |
| 9263 | |
| 9264 | VkClearValue clear_value; |
| 9265 | clear_value.color = m_clear_color; |
| 9266 | |
| 9267 | VkRenderPassBeginInfo rpbi = LvlInitStruct<VkRenderPassBeginInfo>(); |
| 9268 | rpbi.renderPass = render_pass.handle(); |
Nathaniel Cesario | 079b1b9 | 2022-07-06 15:56:26 -0600 | [diff] [blame] | 9269 | rpbi.framebuffer = framebuffer.handle(); |
ziga-lunarg | 88c0e39 | 2021-09-03 19:14:13 +0200 | [diff] [blame] | 9270 | rpbi.renderArea = {{0, 0}, {32, 32}}; |
| 9271 | rpbi.clearValueCount = 1; |
| 9272 | rpbi.pClearValues = &clear_value; |
| 9273 | |
| 9274 | m_commandBuffer->begin(); |
| 9275 | |
| 9276 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdEndConditionalRenderingEXT-None-01985"); |
| 9277 | vkCmdEndConditionalRenderingEXT(m_commandBuffer->handle()); |
| 9278 | m_errorMonitor->VerifyFound(); |
| 9279 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9280 | vkCmdBeginConditionalRenderingEXT(m_commandBuffer->handle(), &conditional_rendering_begin); |
| 9281 | vk::CmdBeginRenderPass(m_commandBuffer->handle(), &rpbi, VK_SUBPASS_CONTENTS_INLINE); |
ziga-lunarg | 88c0e39 | 2021-09-03 19:14:13 +0200 | [diff] [blame] | 9282 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdEndConditionalRenderingEXT-None-01986"); |
ziga-lunarg | 88c0e39 | 2021-09-03 19:14:13 +0200 | [diff] [blame] | 9283 | vkCmdEndConditionalRenderingEXT(m_commandBuffer->handle()); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9284 | m_errorMonitor->VerifyFound(); |
ziga-lunarg | 88c0e39 | 2021-09-03 19:14:13 +0200 | [diff] [blame] | 9285 | vk::CmdNextSubpass(m_commandBuffer->handle(), VK_SUBPASS_CONTENTS_INLINE); |
| 9286 | vk::CmdEndRenderPass(m_commandBuffer->handle()); |
| 9287 | vkCmdEndConditionalRenderingEXT(m_commandBuffer->handle()); |
ziga-lunarg | 88c0e39 | 2021-09-03 19:14:13 +0200 | [diff] [blame] | 9288 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9289 | vk::CmdBeginRenderPass(m_commandBuffer->handle(), &rpbi, VK_SUBPASS_CONTENTS_INLINE); |
| 9290 | vkCmdBeginConditionalRenderingEXT(m_commandBuffer->handle(), &conditional_rendering_begin); |
| 9291 | vk::CmdNextSubpass(m_commandBuffer->handle(), VK_SUBPASS_CONTENTS_INLINE); |
ziga-lunarg | 88c0e39 | 2021-09-03 19:14:13 +0200 | [diff] [blame] | 9292 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdEndConditionalRenderingEXT-None-01987"); |
ziga-lunarg | 88c0e39 | 2021-09-03 19:14:13 +0200 | [diff] [blame] | 9293 | vkCmdEndConditionalRenderingEXT(m_commandBuffer->handle()); |
ziga-lunarg | 88c0e39 | 2021-09-03 19:14:13 +0200 | [diff] [blame] | 9294 | m_errorMonitor->VerifyFound(); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9295 | vk::CmdEndRenderPass(m_commandBuffer->handle()); |
ziga-lunarg | 88c0e39 | 2021-09-03 19:14:13 +0200 | [diff] [blame] | 9296 | } |
ziga-lunarg | 5825514 | 2021-09-12 13:25:17 +0200 | [diff] [blame] | 9297 | |
| 9298 | TEST_F(VkLayerTest, InvalidBeginTransformFeedbackInMultiviewRenderPass) { |
| 9299 | TEST_DESCRIPTION("Test beginning transform feedback in a render pass with multiview enabled"); |
| 9300 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9301 | AddRequiredExtensions(VK_KHR_MULTIVIEW_EXTENSION_NAME); |
| 9302 | AddRequiredExtensions(VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME); |
ziga-lunarg | 5825514 | 2021-09-12 13:25:17 +0200 | [diff] [blame] | 9303 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9304 | if (!AreRequiredExtensionsEnabled()) { |
| 9305 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported."; |
ziga-lunarg | 5825514 | 2021-09-12 13:25:17 +0200 | [diff] [blame] | 9306 | } |
ziga-lunarg | 5825514 | 2021-09-12 13:25:17 +0200 | [diff] [blame] | 9307 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9308 | auto mv_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeaturesKHR>(); |
| 9309 | auto tf_features = LvlInitStruct<VkPhysicalDeviceTransformFeedbackFeaturesEXT>(&mv_features); |
| 9310 | auto pd_features = GetPhysicalDeviceFeatures2(tf_features); |
ziga-lunarg | 5825514 | 2021-09-12 13:25:17 +0200 | [diff] [blame] | 9311 | |
| 9312 | if (!tf_features.transformFeedback) { |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9313 | GTEST_SKIP() << "transformFeedback not supported; skipped."; |
| 9314 | } |
| 9315 | if (!mv_features.multiview) { |
| 9316 | GTEST_SKIP() << "multiview not supported."; |
ziga-lunarg | 5825514 | 2021-09-12 13:25:17 +0200 | [diff] [blame] | 9317 | } |
| 9318 | |
| 9319 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &pd_features)); |
| 9320 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9321 | |
| 9322 | VkAttachmentDescription attachmentDescription = {}; |
| 9323 | attachmentDescription.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 9324 | attachmentDescription.samples = VK_SAMPLE_COUNT_1_BIT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9325 | attachmentDescription.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
ziga-lunarg | 5825514 | 2021-09-12 13:25:17 +0200 | [diff] [blame] | 9326 | attachmentDescription.finalLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 9327 | |
| 9328 | VkAttachmentReference colorAttachmentReference = {}; |
| 9329 | colorAttachmentReference.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 9330 | colorAttachmentReference.attachment = 0; |
| 9331 | |
| 9332 | VkSubpassDescription subpassDescription = {}; |
| 9333 | subpassDescription.colorAttachmentCount = 1; |
| 9334 | subpassDescription.pColorAttachments = &colorAttachmentReference; |
| 9335 | |
| 9336 | uint32_t viewMask = 0x1u; |
| 9337 | VkRenderPassMultiviewCreateInfo renderPassMultiviewCreateInfo = LvlInitStruct<VkRenderPassMultiviewCreateInfo>(); |
| 9338 | renderPassMultiviewCreateInfo.subpassCount = 1; |
| 9339 | renderPassMultiviewCreateInfo.pViewMasks = &viewMask; |
| 9340 | |
| 9341 | VkRenderPassCreateInfo renderPassCreateInfo = LvlInitStruct<VkRenderPassCreateInfo>(&renderPassMultiviewCreateInfo); |
| 9342 | renderPassCreateInfo.attachmentCount = 1; |
| 9343 | renderPassCreateInfo.pAttachments = &attachmentDescription; |
| 9344 | renderPassCreateInfo.subpassCount = 1; |
| 9345 | renderPassCreateInfo.pSubpasses = &subpassDescription; |
| 9346 | |
| 9347 | vk_testing::RenderPass render_pass; |
| 9348 | render_pass.init(*m_device, renderPassCreateInfo); |
| 9349 | |
| 9350 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 9351 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9352 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 9353 | image_create_info.extent.width = 32; |
| 9354 | image_create_info.extent.height = 32; |
| 9355 | image_create_info.extent.depth = 1; |
| 9356 | image_create_info.mipLevels = 1; |
| 9357 | image_create_info.arrayLayers = 4; |
| 9358 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9359 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9360 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9361 | image_create_info.flags = 0; |
| 9362 | |
| 9363 | VkImageObj image(m_device); |
| 9364 | image.Init(image_create_info); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9365 | auto image_view_ci = image.TargetViewCI(VK_FORMAT_R8G8B8A8_UNORM); |
| 9366 | image_view_ci.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY; |
| 9367 | VkImageView imageView = image.targetView(image_view_ci); |
ziga-lunarg | 5825514 | 2021-09-12 13:25:17 +0200 | [diff] [blame] | 9368 | |
| 9369 | VkFramebufferCreateInfo framebufferCreateInfo = LvlInitStruct<VkFramebufferCreateInfo>(); |
| 9370 | framebufferCreateInfo.width = 32; |
| 9371 | framebufferCreateInfo.height = 32; |
| 9372 | framebufferCreateInfo.layers = 1; |
| 9373 | framebufferCreateInfo.renderPass = render_pass.handle(); |
| 9374 | framebufferCreateInfo.attachmentCount = 1; |
| 9375 | framebufferCreateInfo.pAttachments = &imageView; |
| 9376 | |
| 9377 | vk_testing::Framebuffer framebuffer; |
| 9378 | framebuffer.init(*m_device, framebufferCreateInfo); |
| 9379 | |
| 9380 | VkRenderPassBeginInfo render_pass_begin_info = LvlInitStruct<VkRenderPassBeginInfo>(); |
| 9381 | render_pass_begin_info.renderPass = render_pass.handle(); |
| 9382 | render_pass_begin_info.framebuffer = framebuffer.handle(); |
| 9383 | render_pass_begin_info.renderArea.extent.width = 32; |
| 9384 | render_pass_begin_info.renderArea.extent.height = 32; |
| 9385 | |
| 9386 | auto vkCmdBeginTransformFeedbackEXT = |
| 9387 | (PFN_vkCmdBeginTransformFeedbackEXT)vk::GetDeviceProcAddr(m_device->device(), "vkCmdBeginTransformFeedbackEXT"); |
| 9388 | ASSERT_TRUE(vkCmdBeginTransformFeedbackEXT != nullptr); |
| 9389 | |
| 9390 | m_commandBuffer->begin(); |
| 9391 | m_commandBuffer->BeginRenderPass(render_pass_begin_info); |
| 9392 | |
| 9393 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBeginTransformFeedbackEXT-None-02373"); |
| 9394 | vkCmdBeginTransformFeedbackEXT(m_commandBuffer->handle(), 0, 1, nullptr, nullptr); |
| 9395 | m_errorMonitor->VerifyFound(); |
| 9396 | |
| 9397 | m_commandBuffer->EndRenderPass(); |
| 9398 | m_commandBuffer->end(); |
| 9399 | } |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9400 | |
| 9401 | TEST_F(VkLayerTest, BeginRenderingWithSecondaryContents) { |
| 9402 | TEST_DESCRIPTION("Test that an error is produced when a secondary command buffer calls BeginRendering with secondary contents"); |
| 9403 | |
| 9404 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 9405 | |
stusmith | ab8e2a2 | 2021-12-17 11:20:03 +0000 | [diff] [blame] | 9406 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 9407 | |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9408 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 9409 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 9410 | if (!AreRequiredExtensionsEnabled()) { |
| 9411 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
stusmith | ab8e2a2 | 2021-12-17 11:20:03 +0000 | [diff] [blame] | 9412 | } |
| 9413 | |
| 9414 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 9415 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9416 | } |
| 9417 | |
| 9418 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
sjfricke | 11db0c7 | 2022-08-18 13:23:11 +0900 | [diff] [blame^] | 9419 | auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9420 | if (!dynamic_rendering_features.dynamicRendering) { |
| 9421 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 9422 | return; |
| 9423 | } |
| 9424 | |
| 9425 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 9426 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 9427 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9428 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 9429 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 9430 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9431 | begin_rendering_info.flags = VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR; |
ziga-lunarg | aa97cbb | 2022-03-18 19:06:35 +0100 | [diff] [blame] | 9432 | begin_rendering_info.layerCount = 1; |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9433 | begin_rendering_info.colorAttachmentCount = 1; |
| 9434 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 9435 | |
| 9436 | VkCommandBufferObj secondary(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 9437 | |
| 9438 | secondary.begin(); |
| 9439 | |
Tony-LunarG | bbd2ab9 | 2021-12-02 08:31:24 -0700 | [diff] [blame] | 9440 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBeginRendering-commandBuffer-06068"); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9441 | secondary.BeginRendering(begin_rendering_info); |
| 9442 | m_errorMonitor->VerifyFound(); |
| 9443 | |
| 9444 | secondary.end(); |
| 9445 | } |
| 9446 | |
| 9447 | TEST_F(VkLayerTest, BadRenderPassContentsWhenCallingCmdExecuteCommandsWithBeginRenderPass) { |
| 9448 | TEST_DESCRIPTION( |
| 9449 | "Test CmdExecuteCommands inside a render pass begun with CmdBeginRenderPass that hasn't set " |
| 9450 | "VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS"); |
| 9451 | |
| 9452 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 9453 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9454 | |
| 9455 | VkCommandBufferObj secondary(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 9456 | |
| 9457 | const VkCommandBufferInheritanceInfo cmdbuff_ii = { |
| 9458 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, |
| 9459 | nullptr, // pNext |
| 9460 | m_renderPass, |
| 9461 | 0, // subpass |
| 9462 | m_framebuffer, |
| 9463 | }; |
| 9464 | |
| 9465 | VkCommandBufferBeginInfo cmdbuff__bi = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, |
| 9466 | nullptr, // pNext |
| 9467 | VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, &cmdbuff_ii}; |
| 9468 | cmdbuff__bi.flags |= VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 9469 | secondary.begin(&cmdbuff__bi); |
| 9470 | secondary.end(); |
| 9471 | |
| 9472 | m_commandBuffer->begin(); |
| 9473 | |
| 9474 | const VkRenderPassBeginInfo rp_bi{VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, |
| 9475 | nullptr, // pNext |
| 9476 | m_renderPass, |
| 9477 | m_framebuffer, |
| 9478 | {{0, 0}, {32, 32}}, |
| 9479 | static_cast<uint32_t>(m_renderPassClearValues.size()), |
| 9480 | m_renderPassClearValues.data()}; |
| 9481 | |
| 9482 | m_commandBuffer->BeginRenderPass(rp_bi); |
| 9483 | |
| 9484 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-contents-06018"); |
ziga-lunarg | a3cc848 | 2022-04-29 14:58:29 +0200 | [diff] [blame] | 9485 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-contents-00095"); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9486 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
| 9487 | m_errorMonitor->VerifyFound(); |
| 9488 | |
| 9489 | m_commandBuffer->EndRenderPass(); |
| 9490 | m_commandBuffer->end(); |
| 9491 | } |
| 9492 | |
| 9493 | TEST_F(VkLayerTest, BadRenderPassContentsWhenCallingCmdExecuteCommandsWithBeginRendering) { |
| 9494 | TEST_DESCRIPTION( |
| 9495 | "Test CmdExecuteCommands inside a render pass begun with CmdBeginRendering that hasn't set " |
| 9496 | "VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR"); |
| 9497 | |
| 9498 | SetTargetApiVersion(VK_API_VERSION_1_1); |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 9499 | |
stusmith | ab8e2a2 | 2021-12-17 11:20:03 +0000 | [diff] [blame] | 9500 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 9501 | |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9502 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
stusmith | ab8e2a2 | 2021-12-17 11:20:03 +0000 | [diff] [blame] | 9503 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 9504 | if (!AreRequiredExtensionsEnabled()) { |
| 9505 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9506 | } |
stusmith | ab8e2a2 | 2021-12-17 11:20:03 +0000 | [diff] [blame] | 9507 | |
| 9508 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 9509 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
stusmith | ab8e2a2 | 2021-12-17 11:20:03 +0000 | [diff] [blame] | 9510 | } |
| 9511 | |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9512 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
sjfricke | 11db0c7 | 2022-08-18 13:23:11 +0900 | [diff] [blame^] | 9513 | auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9514 | if (!dynamic_rendering_features.dynamicRendering) { |
| 9515 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 9516 | return; |
| 9517 | } |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 9518 | |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9519 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 9520 | |
| 9521 | VkFormat color_formats = {VK_FORMAT_R8G8B8A8_UNORM}; |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 9522 | |
| 9523 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9524 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 9525 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 9526 | VkCommandBufferInheritanceRenderingInfoKHR inheritance_rendering_info = |
| 9527 | LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9528 | inheritance_rendering_info.colorAttachmentCount = 1; |
| 9529 | inheritance_rendering_info.pColorAttachmentFormats = &color_formats; |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 9530 | inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9531 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 9532 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9533 | begin_rendering_info.colorAttachmentCount = 1; |
| 9534 | begin_rendering_info.pColorAttachments = &color_attachment; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9535 | begin_rendering_info.layerCount = 1; |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9536 | |
| 9537 | VkCommandBufferObj secondary(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 9538 | |
| 9539 | const VkCommandBufferInheritanceInfo cmdbuff_ii = { |
| 9540 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, |
| 9541 | &inheritance_rendering_info, // pNext |
| 9542 | VK_NULL_HANDLE, |
| 9543 | 0, // subpass |
| 9544 | VK_NULL_HANDLE, |
| 9545 | }; |
| 9546 | |
| 9547 | VkCommandBufferBeginInfo cmdbuff__bi = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, |
| 9548 | nullptr, // pNext |
| 9549 | VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, &cmdbuff_ii}; |
| 9550 | cmdbuff__bi.flags |= VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 9551 | secondary.begin(&cmdbuff__bi); |
| 9552 | secondary.end(); |
| 9553 | |
| 9554 | m_commandBuffer->begin(); |
| 9555 | |
| 9556 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 9557 | |
| 9558 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-flags-06024"); |
| 9559 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
| 9560 | m_errorMonitor->VerifyFound(); |
| 9561 | |
| 9562 | m_commandBuffer->EndRendering(); |
| 9563 | m_commandBuffer->end(); |
| 9564 | } |
| 9565 | |
| 9566 | TEST_F(VkLayerTest, BadExecuteCommandsSubpassIndices) { |
| 9567 | TEST_DESCRIPTION("Test invalid subpass when calling CmdExecuteCommands"); |
| 9568 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9569 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9570 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9571 | |
| 9572 | // A renderpass with two subpasses, both writing the same attachment. |
| 9573 | VkAttachmentDescription attach[] = { |
| 9574 | {0, VK_FORMAT_R8G8B8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 9575 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_IMAGE_LAYOUT_UNDEFINED, |
| 9576 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}, |
| 9577 | }; |
| 9578 | VkAttachmentReference ref = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}; |
| 9579 | VkSubpassDescription subpasses[] = { |
| 9580 | {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &ref, nullptr, nullptr, 0, nullptr}, |
| 9581 | {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &ref, nullptr, nullptr, 0, nullptr}, |
| 9582 | }; |
| 9583 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9584 | VkSubpassDependency dependencies = { |
| 9585 | 0, // srcSubpass |
| 9586 | 1, // dstSubpass |
| 9587 | VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, // srcStageMask |
| 9588 | VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, // dstStageMask |
| 9589 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // srcAccessMask |
| 9590 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // dstAccessMask |
| 9591 | 0, // dependencyFlags |
| 9592 | }; |
| 9593 | |
| 9594 | auto rpci = LvlInitStruct<VkRenderPassCreateInfo>(); |
| 9595 | rpci.attachmentCount = 1; |
| 9596 | rpci.pAttachments = attach; |
| 9597 | rpci.subpassCount = 2; |
| 9598 | rpci.pSubpasses = subpasses; |
| 9599 | rpci.dependencyCount = 1; |
| 9600 | rpci.pDependencies = &dependencies; |
| 9601 | vk_testing::RenderPass render_pass(*m_device, rpci); |
| 9602 | ASSERT_TRUE(render_pass.initialized()); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9603 | |
| 9604 | VkImageObj image(m_device); |
| 9605 | image.InitNoLayout(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 9606 | VkImageView imageView = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 9607 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9608 | VkFramebufferCreateInfo fbci = { |
| 9609 | VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, nullptr, 0, render_pass.handle(), 1, &imageView, 32, 32, 1}; |
| 9610 | vk_testing::Framebuffer framebuffer(*m_device, fbci); |
| 9611 | ASSERT_TRUE(framebuffer.initialized()); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9612 | |
| 9613 | VkCommandBufferObj secondary(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 9614 | |
| 9615 | const VkCommandBufferInheritanceInfo cmdbuff_ii = { |
| 9616 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, |
| 9617 | nullptr, // pNext |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9618 | render_pass.handle(), |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9619 | 1, // subpass |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9620 | framebuffer.handle(), |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9621 | }; |
| 9622 | |
| 9623 | VkCommandBufferBeginInfo cmdbuff__bi = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, |
| 9624 | nullptr, // pNext |
| 9625 | VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, &cmdbuff_ii}; |
| 9626 | cmdbuff__bi.flags |= VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 9627 | secondary.begin(&cmdbuff__bi); |
| 9628 | secondary.end(); |
| 9629 | |
| 9630 | const VkRenderPassBeginInfo rp_bi{VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, |
| 9631 | nullptr, // pNext |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9632 | render_pass.handle(), |
| 9633 | framebuffer.handle(), |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9634 | {{0, 0}, {32, 32}}, |
| 9635 | 0, |
| 9636 | nullptr}; |
| 9637 | |
| 9638 | m_commandBuffer->begin(); |
| 9639 | m_commandBuffer->BeginRenderPass(rp_bi, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS); |
| 9640 | |
| 9641 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pCommandBuffers-06019"); |
ziga-lunarg | a3cc848 | 2022-04-29 14:58:29 +0200 | [diff] [blame] | 9642 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pCommandBuffers-00097"); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9643 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
| 9644 | m_errorMonitor->VerifyFound(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9645 | } |
| 9646 | |
| 9647 | TEST_F(VkLayerTest, IncompatibleRenderPassesInExecuteCommands) { |
| 9648 | TEST_DESCRIPTION("Test invalid subpass when calling CmdExecuteCommands"); |
| 9649 | |
| 9650 | ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor)); |
| 9651 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9652 | |
| 9653 | // A renderpass with two subpasses, both writing the same attachment. |
| 9654 | VkAttachmentDescription attach[] = { |
| 9655 | {0, VK_FORMAT_R8G8B8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 9656 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_IMAGE_LAYOUT_UNDEFINED, |
| 9657 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}, |
| 9658 | }; |
| 9659 | VkAttachmentReference ref = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}; |
| 9660 | VkSubpassDescription subpasses[] = { |
| 9661 | {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &ref, nullptr, nullptr, 0, nullptr}, |
| 9662 | {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &ref, nullptr, nullptr, 0, nullptr}, |
| 9663 | }; |
| 9664 | |
| 9665 | VkRenderPassCreateInfo rpci = {VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, 0, 1, attach, 1, subpasses, 0, nullptr}; |
| 9666 | VkRenderPass render_pass_1; |
| 9667 | VkResult err = vk::CreateRenderPass(m_device->device(), &rpci, nullptr, &render_pass_1); |
| 9668 | ASSERT_VK_SUCCESS(err); |
| 9669 | |
| 9670 | VkRenderPassCreateInfo rpci_2 = {VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, 0, 1, attach, 2, subpasses, 0, nullptr}; |
| 9671 | VkRenderPass render_pass_2; |
| 9672 | vk::CreateRenderPass(m_device->device(), &rpci_2, nullptr, &render_pass_2); |
| 9673 | ASSERT_VK_SUCCESS(err); |
| 9674 | |
| 9675 | VkImageObj image(m_device); |
| 9676 | image.InitNoLayout(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 9677 | VkImageView imageView = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 9678 | |
| 9679 | VkFramebufferCreateInfo fbci = {VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, nullptr, 0, render_pass_1, 1, &imageView, 32, 32, 1}; |
| 9680 | VkFramebuffer framebuffer; |
| 9681 | err = vk::CreateFramebuffer(m_device->device(), &fbci, nullptr, &framebuffer); |
| 9682 | ASSERT_VK_SUCCESS(err); |
| 9683 | |
| 9684 | VkCommandBufferObj secondary(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 9685 | |
| 9686 | const VkCommandBufferInheritanceInfo cmdbuff_ii = { |
| 9687 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, |
| 9688 | nullptr, // pNext |
| 9689 | render_pass_2, |
| 9690 | 0, // subpass |
| 9691 | VK_NULL_HANDLE, |
| 9692 | }; |
| 9693 | |
| 9694 | VkCommandBufferBeginInfo cmdbuff__bi = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, |
| 9695 | nullptr, // pNext |
| 9696 | VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, &cmdbuff_ii}; |
| 9697 | cmdbuff__bi.flags |= VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 9698 | secondary.begin(&cmdbuff__bi); |
| 9699 | secondary.end(); |
| 9700 | |
| 9701 | const VkRenderPassBeginInfo rp_bi{VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, |
| 9702 | nullptr, // pNext |
| 9703 | render_pass_1, |
| 9704 | framebuffer, |
| 9705 | {{0, 0}, {32, 32}}, |
| 9706 | 0, |
| 9707 | nullptr}; |
| 9708 | |
| 9709 | m_commandBuffer->begin(); |
| 9710 | m_commandBuffer->BeginRenderPass(rp_bi, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS); |
| 9711 | |
| 9712 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pBeginInfo-06020"); |
ziga-lunarg | a3cc848 | 2022-04-29 14:58:29 +0200 | [diff] [blame] | 9713 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pInheritanceInfo-00098"); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9714 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
| 9715 | m_errorMonitor->VerifyFound(); |
| 9716 | |
| 9717 | m_commandBuffer->EndRenderPass(); |
| 9718 | m_commandBuffer->end(); |
| 9719 | |
| 9720 | vk::DestroyFramebuffer(m_device->device(), framebuffer, nullptr); |
| 9721 | vk::DestroyRenderPass(m_device->device(), render_pass_2, nullptr); |
| 9722 | vk::DestroyRenderPass(m_device->device(), render_pass_1, nullptr); |
| 9723 | } |
| 9724 | |
| 9725 | TEST_F(VkLayerTest, DynamicRenderingAndExecuteCommandsWithNonNullRenderPass) { |
| 9726 | TEST_DESCRIPTION( |
| 9727 | "Test CmdExecuteCommands inside a render pass begun with CmdBeginRendering that hasn't set " |
| 9728 | "renderPass to VK_NULL_HANDLE in pInheritanceInfo"); |
| 9729 | |
| 9730 | SetTargetApiVersion(VK_API_VERSION_1_1); |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 9731 | |
stusmith | ab8e2a2 | 2021-12-17 11:20:03 +0000 | [diff] [blame] | 9732 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 9733 | |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9734 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
stusmith | ab8e2a2 | 2021-12-17 11:20:03 +0000 | [diff] [blame] | 9735 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 9736 | if (!AreRequiredExtensionsEnabled()) { |
| 9737 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9738 | } |
stusmith | ab8e2a2 | 2021-12-17 11:20:03 +0000 | [diff] [blame] | 9739 | |
| 9740 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 9741 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
stusmith | ab8e2a2 | 2021-12-17 11:20:03 +0000 | [diff] [blame] | 9742 | } |
| 9743 | |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9744 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
sjfricke | 11db0c7 | 2022-08-18 13:23:11 +0900 | [diff] [blame^] | 9745 | auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9746 | if (!dynamic_rendering_features.dynamicRendering) { |
| 9747 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 9748 | return; |
| 9749 | } |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 9750 | |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9751 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 9752 | |
| 9753 | VkAttachmentDescription attach[] = { |
| 9754 | {0, VK_FORMAT_R8G8B8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, |
| 9755 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_IMAGE_LAYOUT_UNDEFINED, |
| 9756 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}, |
| 9757 | }; |
| 9758 | VkAttachmentReference ref = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}; |
| 9759 | VkSubpassDescription subpasses[] = { |
| 9760 | {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &ref, nullptr, nullptr, 0, nullptr}, |
| 9761 | {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &ref, nullptr, nullptr, 0, nullptr}, |
| 9762 | }; |
| 9763 | |
| 9764 | VkRenderPassCreateInfo rpci = {VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, 0, 1, attach, 2, subpasses, 0, nullptr}; |
| 9765 | VkRenderPass render_pass; |
| 9766 | VkResult err = vk::CreateRenderPass(m_device->device(), &rpci, nullptr, &render_pass); |
| 9767 | ASSERT_VK_SUCCESS(err); |
| 9768 | |
| 9769 | VkFormat color_formats = {VK_FORMAT_R8G8B8A8_UNORM}; |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 9770 | |
| 9771 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9772 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 9773 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 9774 | VkCommandBufferInheritanceRenderingInfoKHR inheritance_rendering_info = |
| 9775 | LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9776 | inheritance_rendering_info.colorAttachmentCount = 1; |
| 9777 | inheritance_rendering_info.pColorAttachmentFormats = &color_formats; |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 9778 | inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9779 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 9780 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9781 | begin_rendering_info.flags = VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR; |
| 9782 | begin_rendering_info.colorAttachmentCount = 1; |
| 9783 | begin_rendering_info.pColorAttachments = &color_attachment; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9784 | begin_rendering_info.layerCount = 1; |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9785 | |
| 9786 | VkCommandBufferObj secondary(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 9787 | |
| 9788 | const VkCommandBufferInheritanceInfo cmdbuff_ii = { |
| 9789 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, |
| 9790 | &inheritance_rendering_info, // pNext |
| 9791 | render_pass, |
| 9792 | 0, // subpass |
| 9793 | VK_NULL_HANDLE, |
| 9794 | }; |
| 9795 | |
| 9796 | VkCommandBufferBeginInfo cmdbuff__bi = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, |
| 9797 | nullptr, // pNext |
| 9798 | VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, &cmdbuff_ii}; |
| 9799 | cmdbuff__bi.flags |= VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 9800 | secondary.begin(&cmdbuff__bi); |
| 9801 | secondary.end(); |
| 9802 | |
| 9803 | m_commandBuffer->begin(); |
| 9804 | |
| 9805 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 9806 | |
| 9807 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pBeginInfo-06025"); |
| 9808 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
| 9809 | m_errorMonitor->VerifyFound(); |
| 9810 | |
| 9811 | m_commandBuffer->EndRendering(); |
| 9812 | m_commandBuffer->end(); |
| 9813 | |
| 9814 | vk::DestroyRenderPass(m_device->device(), render_pass, nullptr); |
| 9815 | } |
| 9816 | |
| 9817 | TEST_F(VkLayerTest, DynamicRenderingAndExecuteCommandsWithMismatchingFlags) { |
| 9818 | TEST_DESCRIPTION("Test CmdExecuteCommands inside a render pass begun with CmdBeginRendering that has mismatching flags"); |
| 9819 | |
| 9820 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 9821 | |
stusmith | ab8e2a2 | 2021-12-17 11:20:03 +0000 | [diff] [blame] | 9822 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 9823 | |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9824 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 9825 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 9826 | if (!AreRequiredExtensionsEnabled()) { |
| 9827 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
stusmith | ab8e2a2 | 2021-12-17 11:20:03 +0000 | [diff] [blame] | 9828 | } |
| 9829 | |
| 9830 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 9831 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9832 | } |
| 9833 | |
| 9834 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
sjfricke | 11db0c7 | 2022-08-18 13:23:11 +0900 | [diff] [blame^] | 9835 | auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9836 | if (!dynamic_rendering_features.dynamicRendering) { |
| 9837 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 9838 | return; |
| 9839 | } |
| 9840 | |
| 9841 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 9842 | |
| 9843 | VkFormat color_formats = {VK_FORMAT_R8G8B8A8_UNORM}; |
| 9844 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 9845 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9846 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 9847 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 9848 | VkCommandBufferInheritanceRenderingInfoKHR inheritance_rendering_info = |
| 9849 | LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9850 | inheritance_rendering_info.colorAttachmentCount = 1; |
| 9851 | inheritance_rendering_info.pColorAttachmentFormats = &color_formats; |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 9852 | inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9853 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 9854 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9855 | begin_rendering_info.flags = |
| 9856 | VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR | VK_RENDERING_SUSPENDING_BIT_KHR | VK_RENDERING_RESUMING_BIT_KHR; |
| 9857 | begin_rendering_info.colorAttachmentCount = 1; |
| 9858 | begin_rendering_info.pColorAttachments = &color_attachment; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9859 | begin_rendering_info.layerCount = 1; |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9860 | |
| 9861 | VkCommandBufferObj secondary(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 9862 | |
| 9863 | const VkCommandBufferInheritanceInfo cmdbuff_ii = { |
| 9864 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, |
| 9865 | &inheritance_rendering_info, // pNext |
| 9866 | VK_NULL_HANDLE, |
| 9867 | 0, // subpass |
| 9868 | VK_NULL_HANDLE, |
| 9869 | }; |
| 9870 | |
| 9871 | VkCommandBufferBeginInfo cmdbuff__bi = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, |
| 9872 | nullptr, // pNext |
| 9873 | VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, &cmdbuff_ii}; |
| 9874 | cmdbuff__bi.flags |= VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 9875 | secondary.begin(&cmdbuff__bi); |
| 9876 | secondary.end(); |
| 9877 | |
| 9878 | m_commandBuffer->begin(); |
| 9879 | |
| 9880 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 9881 | |
| 9882 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-flags-06026"); |
| 9883 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
| 9884 | m_errorMonitor->VerifyFound(); |
| 9885 | |
| 9886 | m_commandBuffer->EndRendering(); |
| 9887 | m_commandBuffer->end(); |
| 9888 | } |
| 9889 | |
| 9890 | TEST_F(VkLayerTest, DynamicRenderingAndExecuteCommandsWithMismatchingColorAttachmentCount) { |
| 9891 | TEST_DESCRIPTION( |
| 9892 | "Test CmdExecuteCommands inside a render pass begun with CmdBeginRendering that has mismatching colorAttachmentCount"); |
| 9893 | |
| 9894 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 9895 | |
stusmith | ab8e2a2 | 2021-12-17 11:20:03 +0000 | [diff] [blame] | 9896 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 9897 | |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9898 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 9899 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 9900 | if (!AreRequiredExtensionsEnabled()) { |
| 9901 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
stusmith | ab8e2a2 | 2021-12-17 11:20:03 +0000 | [diff] [blame] | 9902 | } |
| 9903 | |
| 9904 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 9905 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9906 | } |
| 9907 | |
| 9908 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
sjfricke | 11db0c7 | 2022-08-18 13:23:11 +0900 | [diff] [blame^] | 9909 | auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9910 | if (!dynamic_rendering_features.dynamicRendering) { |
| 9911 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 9912 | return; |
| 9913 | } |
| 9914 | |
| 9915 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 9916 | |
| 9917 | VkFormat color_formats = {VK_FORMAT_R8G8B8A8_UNORM}; |
| 9918 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 9919 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9920 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 9921 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 9922 | VkCommandBufferInheritanceRenderingInfoKHR inheritance_rendering_info = |
| 9923 | LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9924 | inheritance_rendering_info.colorAttachmentCount = 0; |
| 9925 | inheritance_rendering_info.pColorAttachmentFormats = &color_formats; |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 9926 | inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9927 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 9928 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9929 | begin_rendering_info.flags = VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR; |
| 9930 | begin_rendering_info.colorAttachmentCount = 1; |
| 9931 | begin_rendering_info.pColorAttachments = &color_attachment; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 9932 | begin_rendering_info.layerCount = 1; |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9933 | |
| 9934 | VkCommandBufferObj secondary(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 9935 | |
| 9936 | const VkCommandBufferInheritanceInfo cmdbuff_ii = { |
| 9937 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, |
| 9938 | &inheritance_rendering_info, // pNext |
| 9939 | VK_NULL_HANDLE, |
| 9940 | 0, // subpass |
| 9941 | VK_NULL_HANDLE, |
| 9942 | }; |
| 9943 | |
| 9944 | VkCommandBufferBeginInfo cmdbuff__bi = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, |
| 9945 | nullptr, // pNext |
| 9946 | VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, &cmdbuff_ii}; |
| 9947 | cmdbuff__bi.flags |= VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 9948 | secondary.begin(&cmdbuff__bi); |
| 9949 | secondary.end(); |
| 9950 | |
| 9951 | m_commandBuffer->begin(); |
| 9952 | |
| 9953 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 9954 | |
| 9955 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-colorAttachmentCount-06027"); |
| 9956 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
| 9957 | m_errorMonitor->VerifyFound(); |
| 9958 | |
| 9959 | m_commandBuffer->EndRendering(); |
| 9960 | m_commandBuffer->end(); |
| 9961 | } |
| 9962 | |
| 9963 | TEST_F(VkLayerTest, DynamicRenderingAndExecuteCommandsWithMismatchingColorImageViewFormat) { |
| 9964 | TEST_DESCRIPTION( |
| 9965 | "Test CmdExecuteCommands inside a render pass begun with CmdBeginRendering that has mismatching color image view format"); |
| 9966 | |
| 9967 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 9968 | |
stusmith | ab8e2a2 | 2021-12-17 11:20:03 +0000 | [diff] [blame] | 9969 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 9970 | |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9971 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 9972 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 9973 | if (!AreRequiredExtensionsEnabled()) { |
| 9974 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
stusmith | ab8e2a2 | 2021-12-17 11:20:03 +0000 | [diff] [blame] | 9975 | } |
| 9976 | |
| 9977 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 9978 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9979 | } |
| 9980 | |
| 9981 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
sjfricke | 11db0c7 | 2022-08-18 13:23:11 +0900 | [diff] [blame^] | 9982 | auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9983 | if (!dynamic_rendering_features.dynamicRendering) { |
| 9984 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 9985 | return; |
| 9986 | } |
| 9987 | |
| 9988 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 9989 | |
| 9990 | VkImageObj image(m_device); |
| 9991 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 9992 | VkImageView imageView = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 9993 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 9994 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 9995 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 9996 | color_attachment.imageView = imageView; |
| 9997 | |
| 9998 | VkFormat bad_color_formats = {VK_FORMAT_R8G8B8A8_UINT}; |
| 9999 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 10000 | VkCommandBufferInheritanceRenderingInfoKHR inheritance_rendering_info = |
| 10001 | LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 10002 | inheritance_rendering_info.colorAttachmentCount = 1; |
| 10003 | inheritance_rendering_info.pColorAttachmentFormats = &bad_color_formats; |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 10004 | inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 10005 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 10006 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 10007 | begin_rendering_info.flags = VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR; |
| 10008 | begin_rendering_info.colorAttachmentCount = 1; |
| 10009 | begin_rendering_info.pColorAttachments = &color_attachment; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 10010 | begin_rendering_info.layerCount = 1; |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 10011 | |
| 10012 | VkCommandBufferObj secondary(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 10013 | |
| 10014 | const VkCommandBufferInheritanceInfo cmdbuff_ii = { |
| 10015 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, |
| 10016 | &inheritance_rendering_info, // pNext |
| 10017 | VK_NULL_HANDLE, |
| 10018 | 0, // subpass |
| 10019 | VK_NULL_HANDLE, |
| 10020 | }; |
| 10021 | |
| 10022 | VkCommandBufferBeginInfo cmdbuff__bi = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, |
| 10023 | nullptr, // pNext |
| 10024 | VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, &cmdbuff_ii}; |
| 10025 | cmdbuff__bi.flags |= VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 10026 | secondary.begin(&cmdbuff__bi); |
| 10027 | secondary.end(); |
| 10028 | |
| 10029 | m_commandBuffer->begin(); |
| 10030 | |
| 10031 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 10032 | |
| 10033 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-imageView-06028"); |
| 10034 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
| 10035 | m_errorMonitor->VerifyFound(); |
| 10036 | |
| 10037 | m_commandBuffer->EndRendering(); |
| 10038 | m_commandBuffer->end(); |
| 10039 | } |
| 10040 | |
| 10041 | TEST_F(VkLayerTest, DynamicRenderingAndExecuteCommandsWithMismatchingDepthStencilImageViewFormat) { |
| 10042 | TEST_DESCRIPTION( |
| 10043 | "Test CmdExecuteCommands inside a render pass begun with CmdBeginRendering that has mismatching depth/stencil image view " |
| 10044 | "format"); |
| 10045 | |
| 10046 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 10047 | |
stusmith | ab8e2a2 | 2021-12-17 11:20:03 +0000 | [diff] [blame] | 10048 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 10049 | |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 10050 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 10051 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 10052 | if (!AreRequiredExtensionsEnabled()) { |
| 10053 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
stusmith | ab8e2a2 | 2021-12-17 11:20:03 +0000 | [diff] [blame] | 10054 | } |
| 10055 | |
| 10056 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 10057 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 10058 | } |
| 10059 | |
| 10060 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
sjfricke | 11db0c7 | 2022-08-18 13:23:11 +0900 | [diff] [blame^] | 10061 | auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 10062 | if (!dynamic_rendering_features.dynamicRendering) { |
| 10063 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 10064 | return; |
| 10065 | } |
| 10066 | |
| 10067 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 10068 | |
| 10069 | VkImageObj image(m_device); |
| 10070 | auto depth_stencil_format = FindSupportedDepthStencilFormat(gpu()); |
| 10071 | if (!depth_stencil_format) { |
| 10072 | printf("%s Couldn't depth stencil image format.\n", kSkipPrefix); |
| 10073 | return; |
| 10074 | } |
| 10075 | image.Init(32, 32, 1, depth_stencil_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 10076 | VkImageView imageView = image.targetView(depth_stencil_format, VK_IMAGE_ASPECT_DEPTH_BIT|VK_IMAGE_ASPECT_STENCIL_BIT); |
| 10077 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 10078 | VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 10079 | depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL; |
| 10080 | depth_stencil_attachment.imageView = imageView; |
| 10081 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 10082 | VkCommandBufferInheritanceRenderingInfoKHR inheritance_rendering_info = |
| 10083 | LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>(); |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 10084 | inheritance_rendering_info.depthAttachmentFormat = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 10085 | inheritance_rendering_info.stencilAttachmentFormat = VK_FORMAT_D32_SFLOAT_S8_UINT; |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 10086 | inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 10087 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 10088 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 10089 | begin_rendering_info.flags = VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR; |
| 10090 | begin_rendering_info.pDepthAttachment = &depth_stencil_attachment; |
| 10091 | begin_rendering_info.pStencilAttachment = &depth_stencil_attachment; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 10092 | begin_rendering_info.layerCount = 1; |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 10093 | |
| 10094 | VkCommandBufferObj secondary(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 10095 | |
| 10096 | const VkCommandBufferInheritanceInfo cmdbuff_ii = { |
| 10097 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, |
| 10098 | &inheritance_rendering_info, // pNext |
| 10099 | VK_NULL_HANDLE, |
| 10100 | 0, // subpass |
| 10101 | VK_NULL_HANDLE, |
| 10102 | }; |
| 10103 | |
| 10104 | VkCommandBufferBeginInfo cmdbuff__bi = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, |
| 10105 | nullptr, // pNext |
| 10106 | VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, &cmdbuff_ii}; |
| 10107 | cmdbuff__bi.flags |= VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 10108 | secondary.begin(&cmdbuff__bi); |
| 10109 | secondary.end(); |
| 10110 | |
| 10111 | m_commandBuffer->begin(); |
| 10112 | |
| 10113 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 10114 | |
| 10115 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pDepthAttachment-06029"); |
| 10116 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pStencilAttachment-06030"); |
| 10117 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
| 10118 | m_errorMonitor->VerifyFound(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 10119 | } |
| 10120 | |
| 10121 | TEST_F(VkLayerTest, DynamicRenderingAndExecuteCommandsWithMismatchingViewMask) { |
| 10122 | TEST_DESCRIPTION( |
| 10123 | "Test CmdExecuteCommands inside a render pass begun with CmdBeginRendering that has mismatching viewMask format"); |
| 10124 | |
| 10125 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 10126 | |
stusmith | ab8e2a2 | 2021-12-17 11:20:03 +0000 | [diff] [blame] | 10127 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 10128 | |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 10129 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 10130 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 10131 | if (!AreRequiredExtensionsEnabled()) { |
| 10132 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
stusmith | ab8e2a2 | 2021-12-17 11:20:03 +0000 | [diff] [blame] | 10133 | } |
| 10134 | |
| 10135 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 10136 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 10137 | } |
| 10138 | |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 10139 | auto mv_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeaturesKHR>(); |
| 10140 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(&mv_features); |
| 10141 | auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 10142 | if (!dynamic_rendering_features.dynamicRendering) { |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 10143 | GTEST_SKIP() << "Test requires (unsupported) dynamicRendering , skipping."; |
| 10144 | } |
| 10145 | if (!mv_features.multiview) { |
| 10146 | GTEST_SKIP() << "multiview feature not supported."; |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 10147 | } |
| 10148 | |
| 10149 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 10150 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 10151 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 10152 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10153 | |
| 10154 | VkFormat color_formats = {VK_FORMAT_R8G8B8A8_UNORM}; |
| 10155 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 10156 | VkCommandBufferInheritanceRenderingInfoKHR inheritance_rendering_info = |
| 10157 | LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 10158 | inheritance_rendering_info.viewMask = 0; |
| 10159 | inheritance_rendering_info.colorAttachmentCount = 1; |
| 10160 | inheritance_rendering_info.pColorAttachmentFormats = &color_formats; |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 10161 | inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 10162 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 10163 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 10164 | begin_rendering_info.flags = VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR; |
| 10165 | begin_rendering_info.viewMask = 1; |
| 10166 | begin_rendering_info.colorAttachmentCount = 1; |
| 10167 | begin_rendering_info.pColorAttachments = &color_attachment; |
| 10168 | |
| 10169 | VkCommandBufferObj secondary(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 10170 | |
| 10171 | const VkCommandBufferInheritanceInfo cmdbuff_ii = { |
| 10172 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, |
| 10173 | &inheritance_rendering_info, // pNext |
| 10174 | VK_NULL_HANDLE, |
| 10175 | 0, // subpass |
| 10176 | VK_NULL_HANDLE, |
| 10177 | }; |
| 10178 | |
| 10179 | VkCommandBufferBeginInfo cmdbuff__bi = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, |
| 10180 | nullptr, // pNext |
| 10181 | VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, &cmdbuff_ii}; |
| 10182 | cmdbuff__bi.flags |= VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 10183 | secondary.begin(&cmdbuff__bi); |
| 10184 | secondary.end(); |
| 10185 | |
| 10186 | m_commandBuffer->begin(); |
| 10187 | |
| 10188 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 10189 | |
| 10190 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-viewMask-06031"); |
| 10191 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
| 10192 | m_errorMonitor->VerifyFound(); |
stusmith | d2f3683 | 2021-11-26 11:44:11 +0000 | [diff] [blame] | 10193 | } |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 10194 | |
| 10195 | TEST_F(VkLayerTest, DynamicRenderingAndExecuteCommandsWithMismatchingImageViewRasterizationSamples) { |
| 10196 | TEST_DESCRIPTION( |
| 10197 | "Test CmdExecuteCommands inside a render pass begun with CmdBeginRendering that has mismatching rasterization samples"); |
| 10198 | |
| 10199 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 10200 | |
| 10201 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 10202 | |
| 10203 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 10204 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 10205 | if (!AreRequiredExtensionsEnabled()) { |
| 10206 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 10207 | } |
| 10208 | |
| 10209 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 10210 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 10211 | } |
| 10212 | |
| 10213 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
sjfricke | 11db0c7 | 2022-08-18 13:23:11 +0900 | [diff] [blame^] | 10214 | auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features); |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 10215 | if (!dynamic_rendering_features.dynamicRendering) { |
| 10216 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 10217 | return; |
| 10218 | } |
| 10219 | |
| 10220 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 10221 | |
| 10222 | VkImageObj image(m_device); |
| 10223 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 10224 | VkImageView imageView = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 10225 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 10226 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 10227 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10228 | color_attachment.imageView = imageView; |
| 10229 | |
| 10230 | VkFormat color_formats = {VK_FORMAT_R8G8B8A8_UNORM}; |
| 10231 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 10232 | VkCommandBufferInheritanceRenderingInfoKHR inheritance_rendering_info = |
| 10233 | LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>(); |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 10234 | inheritance_rendering_info.colorAttachmentCount = 1; |
| 10235 | inheritance_rendering_info.pColorAttachmentFormats = &color_formats; |
| 10236 | inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_2_BIT; |
| 10237 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 10238 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 10239 | begin_rendering_info.flags = VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR; |
| 10240 | begin_rendering_info.colorAttachmentCount = 1; |
| 10241 | begin_rendering_info.pColorAttachments = &color_attachment; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 10242 | begin_rendering_info.layerCount = 1; |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 10243 | |
| 10244 | // A pool we can reset in. |
| 10245 | VkCommandPoolObj pool(m_device, m_device->graphics_queue_node_index_, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT); |
| 10246 | VkCommandBufferObj secondary(m_device, &pool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 10247 | |
| 10248 | const VkCommandBufferInheritanceInfo cmdbuff_ii = { |
| 10249 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, |
| 10250 | &inheritance_rendering_info, // pNext |
| 10251 | VK_NULL_HANDLE, |
| 10252 | 0, // subpass |
| 10253 | VK_NULL_HANDLE, |
| 10254 | }; |
| 10255 | |
| 10256 | VkCommandBufferBeginInfo cmdbuff__bi = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, |
| 10257 | nullptr, // pNext |
| 10258 | VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, &cmdbuff_ii}; |
| 10259 | cmdbuff__bi.flags |= VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 10260 | secondary.begin(&cmdbuff__bi); |
| 10261 | secondary.end(); |
| 10262 | |
| 10263 | m_commandBuffer->begin(); |
| 10264 | |
| 10265 | // color samples mismatch |
| 10266 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 10267 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pNext-06035"); |
| 10268 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
| 10269 | m_errorMonitor->VerifyFound(); |
| 10270 | m_commandBuffer->EndRendering(); |
| 10271 | |
| 10272 | VkImageObj depthStencilImage(m_device); |
| 10273 | auto depth_stencil_format = FindSupportedDepthStencilFormat(gpu()); |
| 10274 | if (!depth_stencil_format) { |
| 10275 | printf("%s Couldn't depth stencil image format.\n", kSkipPrefix); |
| 10276 | return; |
| 10277 | } |
| 10278 | depthStencilImage.Init(32, 32, 1, depth_stencil_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 10279 | 0); |
| 10280 | VkImageView depthStencilImageView = |
| 10281 | depthStencilImage.targetView(depth_stencil_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT); |
| 10282 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 10283 | VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 10284 | depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 10285 | depth_stencil_attachment.imageView = depthStencilImageView; |
| 10286 | |
| 10287 | begin_rendering_info.colorAttachmentCount = 0; |
| 10288 | begin_rendering_info.pDepthAttachment = &depth_stencil_attachment; |
| 10289 | inheritance_rendering_info.colorAttachmentCount = 0; |
| 10290 | inheritance_rendering_info.depthAttachmentFormat = depth_stencil_format; |
| 10291 | |
| 10292 | secondary.begin(&cmdbuff__bi); |
| 10293 | secondary.end(); |
| 10294 | |
| 10295 | // depth samples mismatch |
| 10296 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 10297 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pNext-06036"); |
| 10298 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
| 10299 | m_errorMonitor->VerifyFound(); |
| 10300 | m_commandBuffer->EndRendering(); |
| 10301 | |
| 10302 | begin_rendering_info.pDepthAttachment = nullptr; |
| 10303 | begin_rendering_info.pStencilAttachment = &depth_stencil_attachment; |
| 10304 | inheritance_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED; |
| 10305 | inheritance_rendering_info.stencilAttachmentFormat = depth_stencil_format; |
| 10306 | |
| 10307 | secondary.begin(&cmdbuff__bi); |
| 10308 | secondary.end(); |
| 10309 | |
| 10310 | // stencil samples mismatch |
| 10311 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 10312 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pNext-06037"); |
| 10313 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
| 10314 | m_errorMonitor->VerifyFound(); |
| 10315 | m_commandBuffer->EndRendering(); |
| 10316 | |
| 10317 | m_commandBuffer->end(); |
| 10318 | } |
| 10319 | |
| 10320 | TEST_F(VkLayerTest, DynamicRenderingAndExecuteCommandsWithMismatchingImageViewAttachmentSamples) { |
| 10321 | TEST_DESCRIPTION( |
| 10322 | "Test CmdExecuteCommands inside a render pass begun with CmdBeginRendering that has mismatching that has mismatching " |
| 10323 | "attachment samples"); |
| 10324 | |
| 10325 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 10326 | |
| 10327 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 10328 | |
| 10329 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 10330 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 10331 | if (!AreRequiredExtensionsEnabled()) { |
| 10332 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 10333 | } |
| 10334 | |
| 10335 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 10336 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 10337 | } |
| 10338 | |
| 10339 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
sjfricke | 11db0c7 | 2022-08-18 13:23:11 +0900 | [diff] [blame^] | 10340 | auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features); |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 10341 | if (!dynamic_rendering_features.dynamicRendering) { |
| 10342 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 10343 | return; |
| 10344 | } |
| 10345 | |
| 10346 | bool amd_samples = false; |
| 10347 | if (DeviceExtensionSupported(gpu(), nullptr, VK_AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME)) { |
| 10348 | m_device_extension_names.push_back(VK_AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME); |
| 10349 | amd_samples = true; |
| 10350 | } |
| 10351 | |
| 10352 | bool nv_samples = false; |
| 10353 | if (DeviceExtensionSupported(gpu(), nullptr, VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME)) { |
| 10354 | m_device_extension_names.push_back(VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME); |
| 10355 | nv_samples = true; |
| 10356 | } |
| 10357 | |
| 10358 | if (!amd_samples && !nv_samples) { |
| 10359 | printf("%s Test requires either VK_AMD_mixed_attachment_samples or VK_NV_framebuffer_mixed_samples, skipping\n", |
| 10360 | kSkipPrefix); |
| 10361 | return; |
| 10362 | } |
| 10363 | |
| 10364 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 10365 | |
| 10366 | VkImageObj image(m_device); |
| 10367 | image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 10368 | VkImageView imageView = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 10369 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 10370 | VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 10371 | color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10372 | color_attachment.imageView = imageView; |
| 10373 | |
| 10374 | VkFormat color_formats = {VK_FORMAT_R8G8B8A8_UNORM}; |
| 10375 | |
| 10376 | VkSampleCountFlagBits counts = {VK_SAMPLE_COUNT_2_BIT}; |
| 10377 | auto samples_info = LvlInitStruct<VkAttachmentSampleCountInfoAMD>(); |
| 10378 | samples_info.colorAttachmentCount = 1; |
| 10379 | samples_info.pColorAttachmentSamples = &counts; |
| 10380 | |
| 10381 | auto inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>(&samples_info); |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 10382 | inheritance_rendering_info.colorAttachmentCount = 1; |
| 10383 | inheritance_rendering_info.pColorAttachmentFormats = &color_formats; |
| 10384 | inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 10385 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 10386 | VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(); |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 10387 | begin_rendering_info.flags = VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR; |
| 10388 | begin_rendering_info.colorAttachmentCount = 1; |
| 10389 | begin_rendering_info.pColorAttachments = &color_attachment; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 10390 | begin_rendering_info.layerCount = 1; |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 10391 | |
| 10392 | // A pool we can reset in. |
| 10393 | VkCommandPoolObj pool(m_device, m_device->graphics_queue_node_index_, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT); |
| 10394 | VkCommandBufferObj secondary(m_device, &pool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 10395 | |
| 10396 | const VkCommandBufferInheritanceInfo cmdbuff_ii = { |
| 10397 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, |
| 10398 | &inheritance_rendering_info, // pNext |
| 10399 | VK_NULL_HANDLE, |
| 10400 | 0, // subpass |
| 10401 | VK_NULL_HANDLE, |
| 10402 | }; |
| 10403 | |
| 10404 | VkCommandBufferBeginInfo cmdbuff__bi = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, |
| 10405 | nullptr, // pNext |
| 10406 | VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, &cmdbuff_ii}; |
| 10407 | cmdbuff__bi.flags |= VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 10408 | secondary.begin(&cmdbuff__bi); |
| 10409 | secondary.end(); |
| 10410 | |
| 10411 | m_commandBuffer->begin(); |
| 10412 | |
| 10413 | // color samples mismatch |
| 10414 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 10415 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pNext-06032"); |
| 10416 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
| 10417 | m_errorMonitor->VerifyFound(); |
| 10418 | m_commandBuffer->EndRendering(); |
| 10419 | |
| 10420 | VkImageObj depthStencilImage(m_device); |
| 10421 | auto depth_stencil_format = FindSupportedDepthStencilFormat(gpu()); |
| 10422 | if (!depth_stencil_format) { |
| 10423 | printf("%s Couldn't depth stencil image format.\n", kSkipPrefix); |
| 10424 | return; |
| 10425 | } |
| 10426 | depthStencilImage.Init(32, 32, 1, depth_stencil_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 10427 | 0); |
| 10428 | VkImageView depthStencilImageView = |
| 10429 | depthStencilImage.targetView(depth_stencil_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT); |
| 10430 | |
sfricke-samsung | 1c61f19 | 2021-12-31 01:53:03 -0600 | [diff] [blame] | 10431 | VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>(); |
stusmith | cba0c50 | 2021-12-21 17:16:28 +0000 | [diff] [blame] | 10432 | depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 10433 | depth_stencil_attachment.imageView = depthStencilImageView; |
| 10434 | |
| 10435 | samples_info.colorAttachmentCount = 0; |
| 10436 | samples_info.pColorAttachmentSamples = nullptr; |
| 10437 | begin_rendering_info.colorAttachmentCount = 0; |
| 10438 | begin_rendering_info.pDepthAttachment = &depth_stencil_attachment; |
| 10439 | inheritance_rendering_info.colorAttachmentCount = 0; |
| 10440 | inheritance_rendering_info.depthAttachmentFormat = depth_stencil_format; |
| 10441 | samples_info.depthStencilAttachmentSamples = VK_SAMPLE_COUNT_2_BIT; |
| 10442 | |
| 10443 | secondary.begin(&cmdbuff__bi); |
| 10444 | secondary.end(); |
| 10445 | |
| 10446 | // depth samples mismatch |
| 10447 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 10448 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pNext-06033"); |
| 10449 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
| 10450 | m_errorMonitor->VerifyFound(); |
| 10451 | m_commandBuffer->EndRendering(); |
| 10452 | |
| 10453 | begin_rendering_info.pDepthAttachment = nullptr; |
| 10454 | begin_rendering_info.pStencilAttachment = &depth_stencil_attachment; |
| 10455 | inheritance_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED; |
| 10456 | inheritance_rendering_info.stencilAttachmentFormat = depth_stencil_format; |
| 10457 | |
| 10458 | secondary.begin(&cmdbuff__bi); |
| 10459 | secondary.end(); |
| 10460 | |
| 10461 | // stencil samples mismatch |
| 10462 | m_commandBuffer->BeginRendering(begin_rendering_info); |
| 10463 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pNext-06034"); |
| 10464 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
| 10465 | m_errorMonitor->VerifyFound(); |
| 10466 | m_commandBuffer->EndRendering(); |
| 10467 | |
| 10468 | m_commandBuffer->end(); |
| 10469 | } |
Tony-LunarG | 7d584ce | 2022-01-17 13:52:40 -0700 | [diff] [blame] | 10470 | |
| 10471 | TEST_F(VkLayerTest, CopyCommands2V13) { |
| 10472 | TEST_DESCRIPTION("Ensure copy_commands2 promotions are validated"); |
| 10473 | |
| 10474 | SetTargetApiVersion(VK_API_VERSION_1_3); |
| 10475 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 10476 | if (DeviceValidationVersion() < VK_API_VERSION_1_3) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 10477 | GTEST_SKIP() << "At least Vulkan version 1.3 is required"; |
Tony-LunarG | 7d584ce | 2022-01-17 13:52:40 -0700 | [diff] [blame] | 10478 | } |
| 10479 | VkImageObj image(m_device); |
| 10480 | image.Init(128, 128, 1, VK_FORMAT_B8G8R8A8_UNORM, VK_IMAGE_USAGE_TRANSFER_SRC_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
ziga-lunarg | 0ce5188 | 2022-05-18 14:36:48 +0200 | [diff] [blame] | 10481 | VkImageObj image2(m_device); |
| 10482 | image2.Init(128, 128, 1, VK_FORMAT_B8G8R8A8_UNORM, VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10483 | VK_IMAGE_TILING_OPTIMAL, 0); |
Tony-LunarG | 7d584ce | 2022-01-17 13:52:40 -0700 | [diff] [blame] | 10484 | ASSERT_TRUE(image.initialized()); |
| 10485 | VkBufferObj dst_buffer; |
| 10486 | VkMemoryPropertyFlags reqs = 0; |
| 10487 | dst_buffer.init_as_dst(*m_device, 128 * 128, reqs); |
| 10488 | VkBufferObj src_buffer; |
| 10489 | src_buffer.init_as_src(*m_device, 128 * 128, reqs); |
| 10490 | auto copy_region = LvlInitStruct<VkImageCopy2>(); |
| 10491 | copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10492 | copy_region.srcSubresource.layerCount = 1; |
| 10493 | copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10494 | copy_region.dstSubresource.layerCount = 1; |
| 10495 | copy_region.dstOffset = {4, 4, 0}; |
| 10496 | copy_region.extent.width = 1; |
| 10497 | copy_region.extent.height = 1; |
| 10498 | copy_region.extent.depth = 1; |
| 10499 | auto copy_image_info = LvlInitStruct<VkCopyImageInfo2>(); |
| 10500 | copy_image_info.srcImage = image.handle(); |
| 10501 | copy_image_info.srcImageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 10502 | copy_image_info.dstImage = image.handle(); |
| 10503 | copy_image_info.dstImageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 10504 | copy_image_info.regionCount = 1; |
| 10505 | copy_image_info.pRegions = ©_region; |
| 10506 | m_commandBuffer->begin(); |
| 10507 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCopyImageInfo2-dstImage-00131"); |
| 10508 | vk::CmdCopyImage2(m_commandBuffer->handle(), ©_image_info); |
| 10509 | m_errorMonitor->VerifyFound(); |
| 10510 | auto copy_buffer = LvlInitStruct<VkBufferCopy2>(); |
ziga-lunarg | 852187f | 2022-03-16 21:21:33 +0100 | [diff] [blame] | 10511 | copy_buffer.dstOffset = 4; |
Tony-LunarG | 7d584ce | 2022-01-17 13:52:40 -0700 | [diff] [blame] | 10512 | copy_buffer.size = 4; |
| 10513 | auto copy_buffer_info = LvlInitStruct<VkCopyBufferInfo2>(); |
| 10514 | copy_buffer_info.srcBuffer = dst_buffer.handle(); |
| 10515 | copy_buffer_info.dstBuffer = dst_buffer.handle(); |
| 10516 | copy_buffer_info.regionCount = 1; |
| 10517 | copy_buffer_info.pRegions = ©_buffer; |
| 10518 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCopyBufferInfo2-srcBuffer-00118"); |
| 10519 | vk::CmdCopyBuffer2(m_commandBuffer->handle(), ©_buffer_info); |
| 10520 | m_errorMonitor->VerifyFound(); |
| 10521 | auto bic_region = LvlInitStruct<VkBufferImageCopy2>(); |
| 10522 | bic_region.bufferRowLength = 128; |
| 10523 | bic_region.bufferImageHeight = 128; |
| 10524 | bic_region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10525 | bic_region.imageSubresource.layerCount = 1; |
| 10526 | bic_region.imageExtent.height = 4; |
| 10527 | bic_region.imageExtent.width = 4; |
| 10528 | bic_region.imageExtent.depth = 1; |
| 10529 | VkCopyBufferToImageInfo2KHR buffer_image_info = LvlInitStruct<VkCopyBufferToImageInfo2>(); |
| 10530 | buffer_image_info.srcBuffer = src_buffer.handle(); |
| 10531 | buffer_image_info.dstImage = image.handle(); |
| 10532 | buffer_image_info.dstImageLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; |
| 10533 | buffer_image_info.regionCount = 1; |
| 10534 | buffer_image_info.pRegions = &bic_region; |
| 10535 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCopyBufferToImageInfo2-dstImage-00177"); |
| 10536 | vk::CmdCopyBufferToImage2(m_commandBuffer->handle(), &buffer_image_info); |
| 10537 | m_errorMonitor->VerifyFound(); |
| 10538 | auto image_buffer_info = LvlInitStruct<VkCopyImageToBufferInfo2>(); |
| 10539 | image_buffer_info.dstBuffer = src_buffer.handle(); |
| 10540 | image_buffer_info.srcImage = image.handle(); |
| 10541 | image_buffer_info.srcImageLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 10542 | image_buffer_info.regionCount = 1; |
| 10543 | image_buffer_info.pRegions = &bic_region; |
| 10544 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCopyImageToBufferInfo2-dstBuffer-00191"); |
| 10545 | vk::CmdCopyImageToBuffer2(m_commandBuffer->handle(), &image_buffer_info); |
| 10546 | m_errorMonitor->VerifyFound(); |
| 10547 | auto blit_region = LvlInitStruct<VkImageBlit2>(); |
| 10548 | blit_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10549 | blit_region.srcSubresource.baseArrayLayer = 0; |
| 10550 | blit_region.srcSubresource.layerCount = 1; |
| 10551 | blit_region.srcSubresource.mipLevel = 0; |
| 10552 | blit_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10553 | blit_region.dstSubresource.baseArrayLayer = 0; |
| 10554 | blit_region.dstSubresource.layerCount = 1; |
| 10555 | blit_region.dstSubresource.mipLevel = 0; |
| 10556 | blit_region.srcOffsets[0] = {0, 0, 0}; |
aitor-lunarg | 3ad811f | 2022-03-31 22:00:39 +0200 | [diff] [blame] | 10557 | blit_region.srcOffsets[1] = {31, 31, 1}; |
| 10558 | blit_region.dstOffsets[0] = {32, 32, 0}; |
| 10559 | blit_region.dstOffsets[1] = {64, 64, 1}; |
Tony-LunarG | 7d584ce | 2022-01-17 13:52:40 -0700 | [diff] [blame] | 10560 | auto blit_image_info = LvlInitStruct<VkBlitImageInfo2>(); |
| 10561 | blit_image_info.srcImage = image.handle(); |
| 10562 | blit_image_info.srcImageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 10563 | blit_image_info.dstImage = image.handle(); |
| 10564 | blit_image_info.dstImageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 10565 | blit_image_info.regionCount = 1; |
| 10566 | blit_image_info.pRegions = &blit_region; |
| 10567 | blit_image_info.filter = VK_FILTER_NEAREST; |
| 10568 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkBlitImageInfo2-dstImage-00224"); |
| 10569 | vk::CmdBlitImage2(m_commandBuffer->handle(), &blit_image_info); |
| 10570 | m_errorMonitor->VerifyFound(); |
| 10571 | auto resolve_region = LvlInitStruct<VkImageResolve2>(); |
| 10572 | resolve_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10573 | resolve_region.srcSubresource.mipLevel = 0; |
| 10574 | resolve_region.srcSubresource.baseArrayLayer = 0; |
| 10575 | resolve_region.srcSubresource.layerCount = 1; |
| 10576 | resolve_region.srcOffset.x = 0; |
| 10577 | resolve_region.srcOffset.y = 0; |
| 10578 | resolve_region.srcOffset.z = 0; |
| 10579 | resolve_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10580 | resolve_region.dstSubresource.mipLevel = 0; |
| 10581 | resolve_region.dstSubresource.baseArrayLayer = 0; |
| 10582 | resolve_region.dstSubresource.layerCount = 1; |
| 10583 | resolve_region.dstOffset.x = 0; |
| 10584 | resolve_region.dstOffset.y = 0; |
| 10585 | resolve_region.dstOffset.z = 0; |
| 10586 | resolve_region.extent.width = 1; |
| 10587 | resolve_region.extent.height = 1; |
| 10588 | resolve_region.extent.depth = 1; |
| 10589 | auto resolve_image_info = LvlInitStruct<VkResolveImageInfo2>(); |
| 10590 | resolve_image_info.srcImage = image.handle(); |
| 10591 | resolve_image_info.srcImageLayout = VK_IMAGE_LAYOUT_GENERAL; |
ziga-lunarg | 0ce5188 | 2022-05-18 14:36:48 +0200 | [diff] [blame] | 10592 | resolve_image_info.dstImage = image2.handle(); |
Tony-LunarG | 7d584ce | 2022-01-17 13:52:40 -0700 | [diff] [blame] | 10593 | resolve_image_info.dstImageLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 10594 | resolve_image_info.regionCount = 1; |
| 10595 | resolve_image_info.pRegions = &resolve_region; |
| 10596 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkResolveImageInfo2-srcImage-00257"); |
| 10597 | vk::CmdResolveImage2(m_commandBuffer->handle(), &resolve_image_info); |
| 10598 | m_errorMonitor->VerifyFound(); |
| 10599 | } |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame] | 10600 | |
| 10601 | TEST_F(VkLayerTest, ValidateMultiviewUnboundResourcesAfterBeginRenderPassAndNextSubpass) { |
| 10602 | TEST_DESCRIPTION( |
| 10603 | "Validate all required resources are bound if multiview is enabled after vkCmdBeginRenderPass and vkCmdNextSubpass"); |
| 10604 | |
Aitor Camacho | 768bbc9 | 2022-06-10 16:57:44 +0200 | [diff] [blame] | 10605 | constexpr unsigned multiview_count = 2u; |
| 10606 | constexpr unsigned extra_subpass_count = multiview_count - 1u; |
| 10607 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 10608 | AddRequiredExtensions(VK_KHR_MULTIVIEW_EXTENSION_NAME); |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame] | 10609 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 10610 | if (!AreRequiredExtensionsEnabled()) { |
| 10611 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame] | 10612 | } |
| 10613 | |
| 10614 | auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>(); |
sjfricke | 11db0c7 | 2022-08-18 13:23:11 +0900 | [diff] [blame^] | 10615 | auto features2 = GetPhysicalDeviceFeatures2(multiview_features); |
Aitor Camacho | 768bbc9 | 2022-06-10 16:57:44 +0200 | [diff] [blame] | 10616 | if (multiview_features.multiview == VK_FALSE) { |
| 10617 | GTEST_SKIP() << "Device does not support multiview."; |
| 10618 | } |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame] | 10619 | |
Aitor Camacho | 768bbc9 | 2022-06-10 16:57:44 +0200 | [diff] [blame] | 10620 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame] | 10621 | |
| 10622 | VkAttachmentDescription attachmentDescription = {}; |
| 10623 | attachmentDescription.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 10624 | attachmentDescription.samples = VK_SAMPLE_COUNT_1_BIT; |
Nathaniel Cesario | 0d50bcf | 2022-06-21 10:30:04 -0600 | [diff] [blame] | 10625 | attachmentDescription.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame] | 10626 | attachmentDescription.finalLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 10627 | |
| 10628 | VkAttachmentReference colorAttachmentReference = {}; |
| 10629 | colorAttachmentReference.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 10630 | colorAttachmentReference.attachment = 0; |
| 10631 | |
Aitor Camacho | 768bbc9 | 2022-06-10 16:57:44 +0200 | [diff] [blame] | 10632 | m_renderPass_subpasses.resize(multiview_count); |
| 10633 | for (unsigned i = 0; i < multiview_count; ++i) { |
| 10634 | m_renderPass_subpasses[i].colorAttachmentCount = 1; |
| 10635 | m_renderPass_subpasses[i].pColorAttachments = &colorAttachmentReference; |
| 10636 | } |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame] | 10637 | |
Aitor Camacho | 768bbc9 | 2022-06-10 16:57:44 +0200 | [diff] [blame] | 10638 | uint32_t viewMasks[multiview_count] = {}; |
| 10639 | for (unsigned i = 0; i < multiview_count; ++i) { |
| 10640 | viewMasks[i] = 1u << i; |
| 10641 | } |
| 10642 | auto renderPassMultiviewCreateInfo = LvlInitStruct<VkRenderPassMultiviewCreateInfo>(); |
| 10643 | renderPassMultiviewCreateInfo.subpassCount = multiview_count; |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame] | 10644 | renderPassMultiviewCreateInfo.pViewMasks = viewMasks; |
| 10645 | |
| 10646 | m_renderPass_info = LvlInitStruct<VkRenderPassCreateInfo>(&renderPassMultiviewCreateInfo); |
| 10647 | m_renderPass_info.attachmentCount = 1; |
| 10648 | m_renderPass_info.pAttachments = &attachmentDescription; |
| 10649 | m_renderPass_info.subpassCount = m_renderPass_subpasses.size(); |
| 10650 | m_renderPass_info.pSubpasses = m_renderPass_subpasses.data(); |
| 10651 | |
Aitor Camacho | 768bbc9 | 2022-06-10 16:57:44 +0200 | [diff] [blame] | 10652 | m_renderPass_dependencies.resize(extra_subpass_count); |
| 10653 | for (unsigned i = 0; i < m_renderPass_dependencies.size(); ++i) { |
| 10654 | auto &subpass_dep = m_renderPass_dependencies[i]; |
| 10655 | subpass_dep.srcSubpass = i; |
| 10656 | subpass_dep.dstSubpass = i + 1; |
| 10657 | |
| 10658 | subpass_dep.srcStageMask = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | |
| 10659 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; |
| 10660 | subpass_dep.dstStageMask = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | |
| 10661 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; |
| 10662 | |
| 10663 | subpass_dep.srcAccessMask = VK_ACCESS_UNIFORM_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT | VK_ACCESS_SHADER_READ_BIT | |
| 10664 | VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | |
| 10665 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | |
| 10666 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; |
| 10667 | subpass_dep.dstAccessMask = VK_ACCESS_UNIFORM_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT | VK_ACCESS_SHADER_READ_BIT | |
| 10668 | VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | |
| 10669 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | |
| 10670 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; |
| 10671 | |
| 10672 | subpass_dep.dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT; |
| 10673 | } |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame] | 10674 | |
| 10675 | m_renderPass_info.dependencyCount = static_cast<uint32_t>(m_renderPass_dependencies.size()); |
| 10676 | m_renderPass_info.pDependencies = m_renderPass_dependencies.data(); |
| 10677 | |
| 10678 | vk::CreateRenderPass(m_device->handle(), &m_renderPass_info, nullptr, &m_renderPass); |
| 10679 | |
Aitor Camacho | 768bbc9 | 2022-06-10 16:57:44 +0200 | [diff] [blame] | 10680 | auto image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame] | 10681 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10682 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 10683 | image_create_info.extent.width = static_cast<uint32_t>(m_width); |
| 10684 | image_create_info.extent.height = static_cast<uint32_t>(m_height); |
| 10685 | image_create_info.extent.depth = 1; |
| 10686 | image_create_info.mipLevels = 1; |
Aitor Camacho | 768bbc9 | 2022-06-10 16:57:44 +0200 | [diff] [blame] | 10687 | image_create_info.arrayLayers = multiview_count; |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame] | 10688 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10689 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10690 | image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10691 | image_create_info.flags = 0; |
| 10692 | |
| 10693 | VkImageObj image(m_device); |
| 10694 | image.Init(image_create_info); |
Aitor Camacho | 768bbc9 | 2022-06-10 16:57:44 +0200 | [diff] [blame] | 10695 | image.SetLayout(VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL); |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame] | 10696 | VkImageView imageView = image.targetView(VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_ASPECT_COLOR_BIT, 0, VK_REMAINING_MIP_LEVELS, 0, |
| 10697 | VK_REMAINING_ARRAY_LAYERS, VK_IMAGE_VIEW_TYPE_2D_ARRAY); |
| 10698 | |
Aitor Camacho | 768bbc9 | 2022-06-10 16:57:44 +0200 | [diff] [blame] | 10699 | auto framebufferCreateInfo = LvlInitStruct<VkFramebufferCreateInfo>(); |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame] | 10700 | framebufferCreateInfo.width = static_cast<uint32_t>(m_width); |
| 10701 | framebufferCreateInfo.height = static_cast<uint32_t>(m_height); |
| 10702 | framebufferCreateInfo.layers = 1; |
| 10703 | framebufferCreateInfo.renderPass = m_renderPass; |
| 10704 | framebufferCreateInfo.attachmentCount = 1; |
| 10705 | framebufferCreateInfo.pAttachments = &imageView; |
| 10706 | |
| 10707 | vk::CreateFramebuffer(m_device->device(), &framebufferCreateInfo, nullptr, &m_framebuffer); |
| 10708 | |
| 10709 | VkClearValue clear{}; |
| 10710 | clear.color = m_clear_color; |
| 10711 | m_renderPassClearValues.emplace_back(clear); |
| 10712 | m_renderPassBeginInfo.renderPass = m_renderPass; |
| 10713 | m_renderPassBeginInfo.framebuffer = m_framebuffer; |
| 10714 | m_renderPassBeginInfo.renderArea.extent.width = static_cast<uint32_t>(m_width); |
| 10715 | m_renderPassBeginInfo.renderArea.extent.height = static_cast<uint32_t>(m_height); |
| 10716 | m_renderPassBeginInfo.clearValueCount = m_renderPassClearValues.size(); |
| 10717 | m_renderPassBeginInfo.pClearValues = m_renderPassClearValues.data(); |
| 10718 | |
Aitor Camacho | 768bbc9 | 2022-06-10 16:57:44 +0200 | [diff] [blame] | 10719 | // Pipeline not bound test |
| 10720 | { |
| 10721 | // No need to create individual pipelines for each subpass since we are checking no bound pipeline |
| 10722 | CreatePipelineHelper pipe(*this); |
| 10723 | pipe.InitInfo(); |
| 10724 | pipe.InitState(); |
| 10725 | pipe.CreateGraphicsPipeline(); |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame] | 10726 | |
Aitor Camacho | 768bbc9 | 2022-06-10 16:57:44 +0200 | [diff] [blame] | 10727 | m_commandBuffer->begin(); |
| 10728 | // This bind should not be valid after we begin the renderpass |
| 10729 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_); |
| 10730 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame] | 10731 | |
Aitor Camacho | 768bbc9 | 2022-06-10 16:57:44 +0200 | [diff] [blame] | 10732 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-None-02700"); |
| 10733 | m_commandBuffer->Draw(1, 0, 0, 0); |
| 10734 | m_errorMonitor->VerifyFound(); |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame] | 10735 | |
Aitor Camacho | 768bbc9 | 2022-06-10 16:57:44 +0200 | [diff] [blame] | 10736 | for (unsigned i = 0; i < extra_subpass_count; ++i) { |
Aitor Camacho | 768bbc9 | 2022-06-10 16:57:44 +0200 | [diff] [blame] | 10737 | // This bind should not be valid for next subpass |
| 10738 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_); |
| 10739 | vk::CmdNextSubpass(m_commandBuffer->handle(), VK_SUBPASS_CONTENTS_INLINE); |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame] | 10740 | |
Aitor Camacho | 768bbc9 | 2022-06-10 16:57:44 +0200 | [diff] [blame] | 10741 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-None-02700"); |
| 10742 | m_commandBuffer->Draw(1, 0, 0, 0); |
| 10743 | m_errorMonitor->VerifyFound(); |
| 10744 | } |
| 10745 | |
Aitor Camacho | 768bbc9 | 2022-06-10 16:57:44 +0200 | [diff] [blame] | 10746 | m_commandBuffer->EndRenderPass(); |
| 10747 | m_commandBuffer->end(); |
| 10748 | } |
| 10749 | |
| 10750 | m_commandBuffer->reset(); |
| 10751 | |
Aitor Camacho | 131d219 | 2022-06-13 19:15:11 +0200 | [diff] [blame] | 10752 | // Dynamic state (checking with line width) |
| 10753 | { |
| 10754 | // Pipeline for subpass 0 |
| 10755 | CreatePipelineHelper pipe(*this); |
| 10756 | pipe.InitInfo(); |
| 10757 | |
| 10758 | VkDynamicState dyn_states = VK_DYNAMIC_STATE_LINE_WIDTH; |
| 10759 | pipe.ia_ci_.topology = VK_PRIMITIVE_TOPOLOGY_LINE_STRIP; |
| 10760 | pipe.dyn_state_ci_ = LvlInitStruct<VkPipelineDynamicStateCreateInfo>(); |
| 10761 | pipe.dyn_state_ci_.dynamicStateCount = 1; |
| 10762 | pipe.dyn_state_ci_.pDynamicStates = &dyn_states; |
| 10763 | pipe.InitState(); |
| 10764 | pipe.CreateGraphicsPipeline(); |
| 10765 | |
| 10766 | // Pipelines for all other subpasses |
| 10767 | vk_testing::Pipeline pipelines[extra_subpass_count]; |
| 10768 | for (unsigned i = 0; i < extra_subpass_count; ++i) { |
| 10769 | auto pipe_info = pipe.gp_ci_; |
| 10770 | pipe_info.subpass = i + 1; |
| 10771 | pipelines[i].init(*m_device, pipe_info); |
| 10772 | } |
| 10773 | |
| 10774 | m_commandBuffer->begin(); |
| 10775 | // This line width set should not be valid for next subpass |
| 10776 | vk::CmdSetLineWidth(m_commandBuffer->handle(), 1.0f); |
| 10777 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 10778 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_); |
Aitor Camacho | 131d219 | 2022-06-13 19:15:11 +0200 | [diff] [blame] | 10779 | |
| 10780 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-commandBuffer-02701"); |
| 10781 | vk::CmdDraw(m_commandBuffer->handle(), 1, 0, 0, 0); |
| 10782 | m_errorMonitor->VerifyFound(); |
| 10783 | |
| 10784 | for (unsigned i = 0; i < extra_subpass_count; ++i) { |
Aitor Camacho | 131d219 | 2022-06-13 19:15:11 +0200 | [diff] [blame] | 10785 | // This line width set should not be valid for next subpass |
| 10786 | vk::CmdSetLineWidth(m_commandBuffer->handle(), 1.0f); |
| 10787 | vk::CmdNextSubpass(m_commandBuffer->handle(), VK_SUBPASS_CONTENTS_INLINE); |
| 10788 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines[i].handle()); |
Aitor Camacho | 131d219 | 2022-06-13 19:15:11 +0200 | [diff] [blame] | 10789 | |
| 10790 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-commandBuffer-02701"); |
| 10791 | m_commandBuffer->Draw(1, 0, 0, 0); |
| 10792 | m_errorMonitor->VerifyFound(); |
| 10793 | } |
| 10794 | |
Aitor Camacho | 131d219 | 2022-06-13 19:15:11 +0200 | [diff] [blame] | 10795 | m_commandBuffer->EndRenderPass(); |
| 10796 | m_commandBuffer->end(); |
| 10797 | } |
| 10798 | |
| 10799 | m_commandBuffer->reset(); |
| 10800 | |
Aitor Camacho | 1f04dea | 2022-06-13 20:40:44 +0200 | [diff] [blame] | 10801 | // Push constants |
| 10802 | { |
| 10803 | char const *const vsSource = R"glsl( |
| 10804 | #version 450 |
| 10805 | layout(push_constant, std430) uniform foo { |
| 10806 | mat3 m; |
| 10807 | } constants; |
| 10808 | void main(){ |
| 10809 | vec3 v3 = constants.m[0]; |
| 10810 | } |
| 10811 | )glsl"; |
| 10812 | |
| 10813 | VkShaderObj const vs(this, vsSource, VK_SHADER_STAGE_VERTEX_BIT); |
| 10814 | VkShaderObj const fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT); |
| 10815 | |
| 10816 | VkPushConstantRange push_constant_range = {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}; |
| 10817 | auto pipeline_layout_info = LvlInitStruct<VkPipelineLayoutCreateInfo>(); |
| 10818 | pipeline_layout_info.pushConstantRangeCount = 1; |
| 10819 | pipeline_layout_info.pPushConstantRanges = &push_constant_range; |
| 10820 | |
| 10821 | vk_testing::PipelineLayout layout; |
| 10822 | layout.init(*m_device, pipeline_layout_info, std::vector<const vk_testing::DescriptorSetLayout *>{}); |
| 10823 | |
| 10824 | CreatePipelineHelper pipe(*this); |
| 10825 | pipe.InitInfo(); |
| 10826 | pipe.shader_stages_ = {vs.GetStageCreateInfo(), fs.GetStageCreateInfo()}; |
| 10827 | pipe.pipeline_layout_ci_ = pipeline_layout_info; |
| 10828 | pipe.InitState(); |
| 10829 | pipe.CreateGraphicsPipeline(); |
| 10830 | |
| 10831 | // Pipelines for all other subpasses |
| 10832 | vk_testing::Pipeline pipelines[extra_subpass_count]; |
| 10833 | for (unsigned i = 0; i < extra_subpass_count; ++i) { |
| 10834 | auto pipe_info = pipe.gp_ci_; |
| 10835 | pipe_info.subpass = i + 1; |
| 10836 | pipelines[i].init(*m_device, pipe_info); |
| 10837 | } |
| 10838 | // Set up complete |
| 10839 | |
| 10840 | const float dummy_values[16] = {}; |
| 10841 | m_commandBuffer->begin(); |
| 10842 | // This push constants should not be counted when render pass begins |
| 10843 | vk::CmdPushConstants(m_commandBuffer->handle(), layout.handle(), VK_SHADER_STAGE_VERTEX_BIT, push_constant_range.offset, |
| 10844 | push_constant_range.size, dummy_values); |
| 10845 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 10846 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_); |
Aitor Camacho | 1f04dea | 2022-06-13 20:40:44 +0200 | [diff] [blame] | 10847 | |
| 10848 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-maintenance4-06425"); |
| 10849 | m_commandBuffer->Draw(1, 0, 0, 0); |
| 10850 | m_errorMonitor->VerifyFound(); |
| 10851 | |
| 10852 | for (unsigned i = 0; i < extra_subpass_count; ++i) { |
Aitor Camacho | 1f04dea | 2022-06-13 20:40:44 +0200 | [diff] [blame] | 10853 | // This push constants should not be counted when we change subpass |
| 10854 | vk::CmdPushConstants(m_commandBuffer->handle(), layout.handle(), VK_SHADER_STAGE_VERTEX_BIT, push_constant_range.offset, |
| 10855 | push_constant_range.size, dummy_values); |
| 10856 | vk::CmdNextSubpass(m_commandBuffer->handle(), VK_SUBPASS_CONTENTS_INLINE); |
| 10857 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines[i].handle()); |
Aitor Camacho | 1f04dea | 2022-06-13 20:40:44 +0200 | [diff] [blame] | 10858 | |
| 10859 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-maintenance4-06425"); |
| 10860 | m_commandBuffer->Draw(1, 0, 0, 0); |
| 10861 | m_errorMonitor->VerifyFound(); |
| 10862 | } |
| 10863 | |
Aitor Camacho | 1f04dea | 2022-06-13 20:40:44 +0200 | [diff] [blame] | 10864 | m_commandBuffer->EndRenderPass(); |
| 10865 | m_commandBuffer->end(); |
| 10866 | } |
| 10867 | |
| 10868 | m_commandBuffer->reset(); |
| 10869 | |
Aitor Camacho | 097a232 | 2022-06-14 14:08:23 +0200 | [diff] [blame] | 10870 | // Descriptor sets |
| 10871 | { |
| 10872 | OneOffDescriptorSet descriptor_set{m_device, {{0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_ALL, nullptr}}}; |
| 10873 | |
| 10874 | auto bci = LvlInitStruct<VkBufferCreateInfo>(); |
| 10875 | bci.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 10876 | bci.size = 8; |
| 10877 | VkBufferObj buffer; |
| 10878 | buffer.init(*m_device, bci); |
| 10879 | VkDescriptorBufferInfo buffer_info; |
| 10880 | buffer_info.buffer = buffer.handle(); |
| 10881 | buffer_info.offset = 0; |
| 10882 | buffer_info.range = VK_WHOLE_SIZE; |
| 10883 | auto descriptor_write = LvlInitStruct<VkWriteDescriptorSet>(); |
| 10884 | descriptor_write.dstSet = descriptor_set.set_; |
| 10885 | descriptor_write.dstBinding = 0; |
| 10886 | descriptor_write.descriptorCount = 1; |
| 10887 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 10888 | descriptor_write.pBufferInfo = &buffer_info; |
| 10889 | vk::UpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 10890 | |
| 10891 | auto pipeline_layout_info = LvlInitStruct<VkPipelineLayoutCreateInfo>(); |
| 10892 | pipeline_layout_info.setLayoutCount = 1; |
| 10893 | pipeline_layout_info.pSetLayouts = &descriptor_set.layout_.handle(); |
| 10894 | |
| 10895 | vk_testing::PipelineLayout layout; |
| 10896 | layout.init(*m_device, pipeline_layout_info, std::vector<vk_testing::DescriptorSetLayout const *>{}); |
| 10897 | |
| 10898 | VkShaderObj const vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT); |
| 10899 | VkShaderObj const fs(this, bindStateFragUniformShaderText, VK_SHADER_STAGE_FRAGMENT_BIT); |
| 10900 | |
| 10901 | CreatePipelineHelper pipe(*this); |
| 10902 | pipe.InitInfo(); |
| 10903 | pipe.shader_stages_ = {vs.GetStageCreateInfo(), fs.GetStageCreateInfo()}; |
| 10904 | pipe.pipeline_layout_ci_ = pipeline_layout_info; |
| 10905 | pipe.InitState(); |
| 10906 | pipe.CreateGraphicsPipeline(); |
| 10907 | |
| 10908 | // Pipelines for all other subpasses |
| 10909 | vk_testing::Pipeline pipelines[extra_subpass_count]; |
| 10910 | for (unsigned i = 0; i < extra_subpass_count; ++i) { |
| 10911 | auto pipe_info = pipe.gp_ci_; |
| 10912 | pipe_info.subpass = i + 1; |
| 10913 | pipelines[i].init(*m_device, pipe_info); |
| 10914 | } |
| 10915 | // Set up complete |
| 10916 | |
| 10917 | m_commandBuffer->begin(); |
| 10918 | // This descriptor bind should not be counted when render pass begins |
| 10919 | vk::CmdBindDescriptorSets(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_layout_.handle(), 0, 1, |
| 10920 | &descriptor_set.set_, 0, nullptr); |
| 10921 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 10922 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_); |
Aitor Camacho | 097a232 | 2022-06-14 14:08:23 +0200 | [diff] [blame] | 10923 | |
| 10924 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-None-02697"); |
| 10925 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "UNASSIGNED-CoreValidation-DrawState-DescriptorSetNotBound"); |
| 10926 | m_commandBuffer->Draw(1, 0, 0, 0); |
| 10927 | m_errorMonitor->VerifyFound(); |
| 10928 | |
| 10929 | for (unsigned i = 0; i < extra_subpass_count; ++i) { |
Aitor Camacho | 097a232 | 2022-06-14 14:08:23 +0200 | [diff] [blame] | 10930 | // This descriptor bind should not be counted when next subpass begins |
| 10931 | vk::CmdBindDescriptorSets(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_layout_.handle(), 0, |
| 10932 | 1, &descriptor_set.set_, 0, nullptr); |
| 10933 | vk::CmdNextSubpass(m_commandBuffer->handle(), VK_SUBPASS_CONTENTS_INLINE); |
| 10934 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines[i].handle()); |
Aitor Camacho | 097a232 | 2022-06-14 14:08:23 +0200 | [diff] [blame] | 10935 | |
| 10936 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-None-02697"); |
| 10937 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "UNASSIGNED-CoreValidation-DrawState-DescriptorSetNotBound"); |
| 10938 | m_commandBuffer->Draw(1, 0, 0, 0); |
| 10939 | m_errorMonitor->VerifyFound(); |
| 10940 | } |
| 10941 | |
Aitor Camacho | 097a232 | 2022-06-14 14:08:23 +0200 | [diff] [blame] | 10942 | m_commandBuffer->EndRenderPass(); |
| 10943 | m_commandBuffer->end(); |
| 10944 | } |
| 10945 | |
| 10946 | m_commandBuffer->reset(); |
| 10947 | |
Aitor Camacho | b379c4b | 2022-06-14 14:43:40 +0200 | [diff] [blame] | 10948 | // Vertex buffer |
| 10949 | { |
| 10950 | float const vertex_data[] = {1.0f, 0.0f}; |
| 10951 | VkConstantBufferObj vbo(m_device, static_cast<int>(sizeof(vertex_data)), reinterpret_cast<const void *>(vertex_data), |
| 10952 | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT); |
| 10953 | |
| 10954 | VkVertexInputBindingDescription input_binding{}; |
| 10955 | input_binding.binding = 0; |
| 10956 | input_binding.stride = sizeof(vertex_data); |
| 10957 | input_binding.inputRate = VK_VERTEX_INPUT_RATE_VERTEX; |
| 10958 | |
| 10959 | VkVertexInputAttributeDescription input_attribs{}; |
| 10960 | input_attribs.binding = 0; |
| 10961 | input_attribs.location = 0; |
| 10962 | input_attribs.format = VK_FORMAT_R32G32_SFLOAT; |
| 10963 | input_attribs.offset = 0; |
| 10964 | |
| 10965 | char const *const vsSource = R"glsl( |
| 10966 | #version 450 |
| 10967 | layout(location = 0) in vec2 input0; |
| 10968 | void main(){ |
| 10969 | gl_Position = vec4(input0.x, input0.y, 0.0f, 1.0f); |
| 10970 | } |
| 10971 | )glsl"; |
| 10972 | |
| 10973 | VkShaderObj vs(this, vsSource, VK_SHADER_STAGE_VERTEX_BIT); |
| 10974 | VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT); |
| 10975 | |
| 10976 | CreatePipelineHelper pipe(*this); |
| 10977 | pipe.InitInfo(); |
| 10978 | pipe.shader_stages_ = {vs.GetStageCreateInfo(), fs.GetStageCreateInfo()}; |
| 10979 | pipe.vi_ci_.vertexBindingDescriptionCount = 1; |
| 10980 | pipe.vi_ci_.pVertexBindingDescriptions = &input_binding; |
| 10981 | pipe.vi_ci_.vertexAttributeDescriptionCount = 1; |
| 10982 | pipe.vi_ci_.pVertexAttributeDescriptions = &input_attribs; |
| 10983 | pipe.InitState(); |
| 10984 | pipe.CreateGraphicsPipeline(); |
| 10985 | |
| 10986 | // Pipelines for all other subpasses |
| 10987 | vk_testing::Pipeline pipelines[extra_subpass_count]; |
| 10988 | for (unsigned i = 0; i < extra_subpass_count; ++i) { |
| 10989 | auto pipe_info = pipe.gp_ci_; |
| 10990 | pipe_info.subpass = i + 1; |
| 10991 | pipelines[i].init(*m_device, pipe_info); |
| 10992 | } |
| 10993 | // Set up complete |
| 10994 | VkDeviceSize offset = 0; |
| 10995 | |
| 10996 | m_commandBuffer->begin(); |
| 10997 | // This vertex buffer bind should not be counted when render pass begins |
| 10998 | vk::CmdBindVertexBuffers(m_commandBuffer->handle(), 0, 1, &vbo.handle(), &offset); |
| 10999 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 11000 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_); |
Aitor Camacho | b379c4b | 2022-06-14 14:43:40 +0200 | [diff] [blame] | 11001 | |
| 11002 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-None-04007"); |
| 11003 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-None-02721"); |
| 11004 | m_commandBuffer->Draw(1, 0, 0, 0); |
| 11005 | m_errorMonitor->VerifyFound(); |
| 11006 | |
| 11007 | for (unsigned i = 0; i < extra_subpass_count; ++i) { |
Aitor Camacho | b379c4b | 2022-06-14 14:43:40 +0200 | [diff] [blame] | 11008 | // This vertex buffer bind should not be counted when next subpass begins |
| 11009 | vk::CmdBindVertexBuffers(m_commandBuffer->handle(), 0, 1, &vbo.handle(), &offset); |
| 11010 | vk::CmdNextSubpass(m_commandBuffer->handle(), VK_SUBPASS_CONTENTS_INLINE); |
| 11011 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines[i].handle()); |
Aitor Camacho | b379c4b | 2022-06-14 14:43:40 +0200 | [diff] [blame] | 11012 | |
| 11013 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-None-04007"); |
| 11014 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-None-02721"); |
| 11015 | m_commandBuffer->Draw(1, 0, 0, 0); |
| 11016 | m_errorMonitor->VerifyFound(); |
| 11017 | } |
| 11018 | |
Aitor Camacho | b379c4b | 2022-06-14 14:43:40 +0200 | [diff] [blame] | 11019 | m_commandBuffer->EndRenderPass(); |
| 11020 | m_commandBuffer->end(); |
| 11021 | } |
| 11022 | |
| 11023 | m_commandBuffer->reset(); |
| 11024 | |
Aitor Camacho | ea9030a | 2022-06-14 15:07:25 +0200 | [diff] [blame] | 11025 | // Index buffer |
| 11026 | { |
| 11027 | float const vertex_data[] = {1.0f, 0.0f}; |
| 11028 | VkConstantBufferObj vbo(m_device, static_cast<int>(sizeof(vertex_data)), reinterpret_cast<const void *>(vertex_data), |
| 11029 | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT); |
| 11030 | |
| 11031 | uint32_t const index_data[] = {0}; |
| 11032 | VkConstantBufferObj ibo(m_device, static_cast<int>(sizeof(index_data)), reinterpret_cast<const void *>(index_data), |
| 11033 | VK_BUFFER_USAGE_INDEX_BUFFER_BIT); |
| 11034 | |
| 11035 | VkVertexInputBindingDescription input_binding{}; |
| 11036 | input_binding.binding = 0; |
| 11037 | input_binding.stride = sizeof(vertex_data); |
| 11038 | input_binding.inputRate = VK_VERTEX_INPUT_RATE_VERTEX; |
| 11039 | |
| 11040 | VkVertexInputAttributeDescription input_attribs{}; |
| 11041 | input_attribs.binding = 0; |
| 11042 | input_attribs.location = 0; |
| 11043 | input_attribs.format = VK_FORMAT_R32G32_SFLOAT; |
| 11044 | input_attribs.offset = 0; |
| 11045 | |
| 11046 | char const *const vsSource = R"glsl( |
| 11047 | #version 450 |
| 11048 | layout(location = 0) in vec2 input0; |
| 11049 | void main(){ |
| 11050 | gl_Position = vec4(input0.x, input0.y, 0.0f, 1.0f); |
| 11051 | } |
| 11052 | )glsl"; |
| 11053 | |
| 11054 | VkShaderObj vs(this, vsSource, VK_SHADER_STAGE_VERTEX_BIT); |
| 11055 | VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT); |
| 11056 | |
| 11057 | CreatePipelineHelper pipe(*this); |
| 11058 | pipe.InitInfo(); |
| 11059 | pipe.shader_stages_ = {vs.GetStageCreateInfo(), fs.GetStageCreateInfo()}; |
| 11060 | pipe.vi_ci_.vertexBindingDescriptionCount = 1; |
| 11061 | pipe.vi_ci_.pVertexBindingDescriptions = &input_binding; |
| 11062 | pipe.vi_ci_.vertexAttributeDescriptionCount = 1; |
| 11063 | pipe.vi_ci_.pVertexAttributeDescriptions = &input_attribs; |
| 11064 | pipe.InitState(); |
| 11065 | pipe.CreateGraphicsPipeline(); |
| 11066 | |
| 11067 | // Pipelines for all other subpasses |
| 11068 | vk_testing::Pipeline pipelines[extra_subpass_count]; |
| 11069 | for (unsigned i = 0; i < extra_subpass_count; ++i) { |
| 11070 | auto pipe_info = pipe.gp_ci_; |
| 11071 | pipe_info.subpass = i + 1; |
| 11072 | pipelines[i].init(*m_device, pipe_info); |
| 11073 | } |
| 11074 | // Set up complete |
| 11075 | |
| 11076 | VkDeviceSize offset = 0; |
| 11077 | m_commandBuffer->begin(); |
| 11078 | // This index buffer bind should not be counted when render pass begins |
| 11079 | vk::CmdBindIndexBuffer(m_commandBuffer->handle(), ibo.handle(), 0, VK_INDEX_TYPE_UINT32); |
| 11080 | m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo); |
| 11081 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_); |
| 11082 | vk::CmdBindVertexBuffers(m_commandBuffer->handle(), 0, 1, &vbo.handle(), &offset); |
Aitor Camacho | ea9030a | 2022-06-14 15:07:25 +0200 | [diff] [blame] | 11083 | |
| 11084 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndexed-commandBuffer-02701"); |
| 11085 | m_commandBuffer->DrawIndexed(0, 1, 0, 0, 0); |
| 11086 | m_errorMonitor->VerifyFound(); |
| 11087 | |
| 11088 | for (unsigned i = 0; i < extra_subpass_count; ++i) { |
Aitor Camacho | ea9030a | 2022-06-14 15:07:25 +0200 | [diff] [blame] | 11089 | // This index buffer bind should not be counted when next subpass begins |
| 11090 | vk::CmdBindIndexBuffer(m_commandBuffer->handle(), ibo.handle(), 0, VK_INDEX_TYPE_UINT32); |
| 11091 | vk::CmdNextSubpass(m_commandBuffer->handle(), VK_SUBPASS_CONTENTS_INLINE); |
| 11092 | vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines[i].handle()); |
| 11093 | vk::CmdBindVertexBuffers(m_commandBuffer->handle(), 0, 1, &vbo.handle(), &offset); |
Aitor Camacho | ea9030a | 2022-06-14 15:07:25 +0200 | [diff] [blame] | 11094 | |
| 11095 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDrawIndexed-commandBuffer-02701"); |
| 11096 | m_commandBuffer->DrawIndexed(0, 1, 0, 0, 0); |
| 11097 | m_errorMonitor->VerifyFound(); |
| 11098 | } |
| 11099 | |
Aitor Camacho | ea9030a | 2022-06-14 15:07:25 +0200 | [diff] [blame] | 11100 | m_commandBuffer->EndRenderPass(); |
| 11101 | m_commandBuffer->end(); |
| 11102 | } |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame] | 11103 | } |
ziga-lunarg | 813fa01 | 2022-04-09 14:09:57 +0200 | [diff] [blame] | 11104 | |
| 11105 | TEST_F(VkLayerTest, TestCommandBufferInheritanceWithInvalidDepthFormat) { |
| 11106 | TEST_DESCRIPTION( |
| 11107 | "Test VkCommandBufferInheritanceRenderingInfoKHR with depthAttachmentFormat that does not include depth aspect"); |
| 11108 | |
| 11109 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 11110 | |
| 11111 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 11112 | |
| 11113 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 11114 | |
sjfricke | d700bc0 | 2022-05-30 16:35:06 +0900 | [diff] [blame] | 11115 | if (!AreRequiredExtensionsEnabled()) { |
| 11116 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
ziga-lunarg | 813fa01 | 2022-04-09 14:09:57 +0200 | [diff] [blame] | 11117 | } |
| 11118 | |
| 11119 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
sjfricke | bdd58dd | 2022-05-20 14:22:50 +0900 | [diff] [blame] | 11120 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
ziga-lunarg | 813fa01 | 2022-04-09 14:09:57 +0200 | [diff] [blame] | 11121 | } |
| 11122 | |
| 11123 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
sjfricke | 11db0c7 | 2022-08-18 13:23:11 +0900 | [diff] [blame^] | 11124 | auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features); |
ziga-lunarg | 813fa01 | 2022-04-09 14:09:57 +0200 | [diff] [blame] | 11125 | if (!dynamic_rendering_features.dynamicRendering) { |
| 11126 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 11127 | return; |
| 11128 | } |
| 11129 | |
| 11130 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 11131 | |
| 11132 | auto stencil_format = FindSupportedStencilOnlyFormat(gpu()); |
| 11133 | if (!stencil_format) { |
| 11134 | printf("%s Couldn't stencil image format.\n", kSkipPrefix); |
| 11135 | return; |
| 11136 | } |
| 11137 | |
| 11138 | auto inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>(); |
| 11139 | inheritance_rendering_info.depthAttachmentFormat = stencil_format; |
| 11140 | |
| 11141 | VkCommandBufferObj secondary(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 11142 | |
| 11143 | auto cmdbuf_ii = LvlInitStruct<VkCommandBufferInheritanceInfo>(&inheritance_rendering_info); |
| 11144 | auto cmdbuf_bi = LvlInitStruct<VkCommandBufferBeginInfo>(); |
| 11145 | cmdbuf_bi.pInheritanceInfo = &cmdbuf_ii; |
| 11146 | |
| 11147 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-depthAttachmentFormat-06540"); |
| 11148 | |
| 11149 | vk::BeginCommandBuffer(secondary.handle(), &cmdbuf_bi); |
| 11150 | |
| 11151 | m_errorMonitor->VerifyFound(); |
| 11152 | } |
ziga-lunarg | 0ce5188 | 2022-05-18 14:36:48 +0200 | [diff] [blame] | 11153 | |
| 11154 | TEST_F(VkLayerTest, ResolveInvalidUsage) { |
| 11155 | TEST_DESCRIPTION("Resolve image with missing usage flags."); |
| 11156 | |
sjfricke | 3a10ae8 | 2022-08-02 18:48:57 +0900 | [diff] [blame] | 11157 | if (!OverrideDevsimForDeviceProfileLayer()) { |
| 11158 | GTEST_SKIP() << "Failed to override devsim for device profile layer."; |
ziga-lunarg | 0ce5188 | 2022-05-18 14:36:48 +0200 | [diff] [blame] | 11159 | } |
| 11160 | |
| 11161 | ASSERT_NO_FATAL_FAILURE(Init()); |
| 11162 | |
| 11163 | PFN_vkSetPhysicalDeviceFormatPropertiesEXT fpvkSetPhysicalDeviceFormatPropertiesEXT = nullptr; |
| 11164 | PFN_vkGetOriginalPhysicalDeviceFormatPropertiesEXT fpvkGetOriginalPhysicalDeviceFormatPropertiesEXT = nullptr; |
ziga-lunarg | 0ce5188 | 2022-05-18 14:36:48 +0200 | [diff] [blame] | 11165 | if (!LoadDeviceProfileLayer(fpvkSetPhysicalDeviceFormatPropertiesEXT, fpvkGetOriginalPhysicalDeviceFormatPropertiesEXT)) { |
sjfricke | 3a10ae8 | 2022-08-02 18:48:57 +0900 | [diff] [blame] | 11166 | GTEST_SKIP() << "Failed to load device profile layer."; |
ziga-lunarg | 0ce5188 | 2022-05-18 14:36:48 +0200 | [diff] [blame] | 11167 | } |
| 11168 | |
| 11169 | VkFormat src_format = VK_FORMAT_R8_UNORM; |
| 11170 | VkFormat dst_format = VK_FORMAT_R8_SNORM; |
| 11171 | |
| 11172 | VkFormatProperties formatProps; |
| 11173 | fpvkGetOriginalPhysicalDeviceFormatPropertiesEXT(gpu(), src_format, &formatProps); |
| 11174 | formatProps.optimalTilingFeatures &= ~VK_FORMAT_FEATURE_TRANSFER_SRC_BIT; |
| 11175 | fpvkSetPhysicalDeviceFormatPropertiesEXT(gpu(), src_format, formatProps); |
| 11176 | fpvkGetOriginalPhysicalDeviceFormatPropertiesEXT(gpu(), dst_format, &formatProps); |
| 11177 | formatProps.optimalTilingFeatures &= ~VK_FORMAT_FEATURE_TRANSFER_DST_BIT; |
| 11178 | fpvkSetPhysicalDeviceFormatPropertiesEXT(gpu(), dst_format, formatProps); |
| 11179 | |
| 11180 | VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>(); |
| 11181 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11182 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11183 | image_create_info.extent.width = 32; |
| 11184 | image_create_info.extent.height = 1; |
| 11185 | image_create_info.extent.depth = 1; |
| 11186 | image_create_info.mipLevels = 1; |
| 11187 | image_create_info.arrayLayers = 1; |
| 11188 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 11189 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11190 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 11191 | image_create_info.flags = 0; |
| 11192 | |
| 11193 | VkImageObj srcImage(m_device); |
| 11194 | srcImage.init(&image_create_info); |
| 11195 | ASSERT_TRUE(srcImage.initialized()); |
| 11196 | |
| 11197 | image_create_info.format = dst_format; |
| 11198 | VkImageObj srcImage2(m_device); |
| 11199 | srcImage2.init(&image_create_info); |
| 11200 | ASSERT_TRUE(srcImage2.initialized()); |
| 11201 | |
| 11202 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11203 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 11204 | VkImageObj invalidSrcImage(m_device); |
| 11205 | invalidSrcImage.init(&image_create_info); |
| 11206 | ASSERT_TRUE(invalidSrcImage.initialized()); |
| 11207 | |
| 11208 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 11209 | image_create_info.format = src_format; |
| 11210 | VkImageObj invalidSrcImage2(m_device); |
| 11211 | invalidSrcImage2.init(&image_create_info); |
| 11212 | ASSERT_TRUE(invalidSrcImage2.initialized()); |
| 11213 | |
| 11214 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11215 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11216 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 11217 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11218 | VkImageObj dstImage(m_device); |
| 11219 | dstImage.init(&image_create_info); |
| 11220 | ASSERT_TRUE(dstImage.initialized()); |
| 11221 | |
| 11222 | image_create_info.format = src_format; |
| 11223 | VkImageObj dstImage2(m_device); |
| 11224 | dstImage2.init(&image_create_info); |
| 11225 | ASSERT_TRUE(dstImage2.initialized()); |
| 11226 | |
| 11227 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11228 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 11229 | VkImageObj invalidDstImage(m_device); |
| 11230 | invalidDstImage.init(&image_create_info); |
| 11231 | ASSERT_TRUE(invalidDstImage.initialized()); |
| 11232 | |
| 11233 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 11234 | image_create_info.format = dst_format; |
| 11235 | VkImageObj invalidDstImage2(m_device); |
| 11236 | invalidDstImage2.init(&image_create_info); |
| 11237 | ASSERT_TRUE(invalidDstImage2.initialized()); |
| 11238 | |
| 11239 | m_commandBuffer->begin(); |
| 11240 | VkImageResolve resolveRegion; |
| 11241 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11242 | resolveRegion.srcSubresource.mipLevel = 0; |
| 11243 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
| 11244 | resolveRegion.srcSubresource.layerCount = 1; |
| 11245 | resolveRegion.srcOffset.x = 0; |
| 11246 | resolveRegion.srcOffset.y = 0; |
| 11247 | resolveRegion.srcOffset.z = 0; |
| 11248 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 11249 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11250 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11251 | resolveRegion.dstSubresource.layerCount = 1; |
| 11252 | resolveRegion.dstOffset.x = 0; |
| 11253 | resolveRegion.dstOffset.y = 0; |
| 11254 | resolveRegion.dstOffset.z = 0; |
| 11255 | resolveRegion.extent.width = 1; |
| 11256 | resolveRegion.extent.height = 1; |
| 11257 | resolveRegion.extent.depth = 1; |
| 11258 | |
| 11259 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-srcImage-06762"); |
| 11260 | m_commandBuffer->ResolveImage(invalidSrcImage.handle(), VK_IMAGE_LAYOUT_GENERAL, dstImage.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 11261 | &resolveRegion); |
| 11262 | m_errorMonitor->VerifyFound(); |
| 11263 | |
| 11264 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-dstImage-06764"); |
| 11265 | m_commandBuffer->ResolveImage(srcImage.handle(), VK_IMAGE_LAYOUT_GENERAL, invalidDstImage.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, |
| 11266 | &resolveRegion); |
| 11267 | m_errorMonitor->VerifyFound(); |
| 11268 | |
| 11269 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-srcImage-06763"); |
| 11270 | m_commandBuffer->ResolveImage(invalidSrcImage2.handle(), VK_IMAGE_LAYOUT_GENERAL, dstImage2.handle(), VK_IMAGE_LAYOUT_GENERAL, |
| 11271 | 1, &resolveRegion); |
| 11272 | m_errorMonitor->VerifyFound(); |
| 11273 | |
| 11274 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdResolveImage-dstImage-06765"); |
| 11275 | m_commandBuffer->ResolveImage(srcImage2.handle(), VK_IMAGE_LAYOUT_GENERAL, invalidDstImage2.handle(), VK_IMAGE_LAYOUT_GENERAL, |
| 11276 | 1, &resolveRegion); |
| 11277 | m_errorMonitor->VerifyFound(); |
| 11278 | |
| 11279 | m_commandBuffer->end(); |
| 11280 | } |
ziga-lunarg | 9cd35db | 2022-08-05 16:46:30 +0200 | [diff] [blame] | 11281 | |
| 11282 | TEST_F(VkLayerTest, DynamicRenderingInSecondaryCommandBuffers) { |
| 11283 | TEST_DESCRIPTION("Test drawing in secondary command buffers with dynamic rendering"); |
| 11284 | |
| 11285 | SetTargetApiVersion(VK_API_VERSION_1_1); |
| 11286 | |
| 11287 | AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 11288 | |
| 11289 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 11290 | |
| 11291 | if (!AreRequiredExtensionsEnabled()) { |
| 11292 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; |
| 11293 | } |
| 11294 | |
| 11295 | if (DeviceValidationVersion() < VK_API_VERSION_1_1) { |
| 11296 | GTEST_SKIP() << "At least Vulkan version 1.1 is required"; |
| 11297 | } |
| 11298 | |
| 11299 | auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(); |
sjfricke | 11db0c7 | 2022-08-18 13:23:11 +0900 | [diff] [blame^] | 11300 | auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features); |
ziga-lunarg | 9cd35db | 2022-08-05 16:46:30 +0200 | [diff] [blame] | 11301 | if (!dynamic_rendering_features.dynamicRendering) { |
| 11302 | printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix); |
| 11303 | return; |
| 11304 | } |
| 11305 | |
| 11306 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2)); |
| 11307 | |
| 11308 | VkFormat format = VK_FORMAT_R32G32B32A32_UINT; |
| 11309 | |
| 11310 | auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(); |
| 11311 | pipeline_rendering_info.colorAttachmentCount = 1; |
| 11312 | pipeline_rendering_info.pColorAttachmentFormats = &format; |
| 11313 | |
| 11314 | CreatePipelineHelper pipe(*this); |
| 11315 | pipe.InitInfo(); |
| 11316 | pipe.gp_ci_.pNext = &pipeline_rendering_info; |
| 11317 | pipe.InitState(); |
| 11318 | pipe.CreateGraphicsPipeline(); |
| 11319 | |
| 11320 | VkCommandBufferInheritanceRenderingInfoKHR inheritanceRenderingInfo = |
| 11321 | LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>(); |
| 11322 | inheritanceRenderingInfo.colorAttachmentCount = 1; |
| 11323 | inheritanceRenderingInfo.pColorAttachmentFormats = &format; |
| 11324 | inheritanceRenderingInfo.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 11325 | |
| 11326 | VkCommandBufferInheritanceInfo cbii = LvlInitStruct<VkCommandBufferInheritanceInfo>(&inheritanceRenderingInfo); |
| 11327 | cbii.renderPass = m_renderPass; |
| 11328 | cbii.framebuffer = m_framebuffer; |
| 11329 | |
| 11330 | VkCommandBufferBeginInfo cbbi = LvlInitStruct<VkCommandBufferBeginInfo>(); |
| 11331 | cbbi.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 11332 | cbbi.pInheritanceInfo = &cbii; |
| 11333 | |
| 11334 | VkCommandBufferObj secondary(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 11335 | secondary.begin(&cbbi); |
| 11336 | vk::CmdBindPipeline(secondary.handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_); |
| 11337 | secondary.Draw(3, 1, 0, 0); |
| 11338 | secondary.end(); |
| 11339 | } |
janharaldfredriksen-arm | f6d6c68 | 2022-07-12 11:42:11 +0200 | [diff] [blame] | 11340 | |
| 11341 | TEST_F(VkLayerTest, IncompatibleFragmentRateShadingAttachmentInExecuteCommands) { |
| 11342 | TEST_DESCRIPTION( |
| 11343 | "Test incompatible fragment shading rate attachments " |
| 11344 | "calling CmdExecuteCommands"); |
| 11345 | |
| 11346 | // Enable KHR_fragment_shading_rate |
| 11347 | AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); |
| 11348 | ASSERT_NO_FATAL_FAILURE(InitFramework()); |
| 11349 | |
| 11350 | if (!AreRequiredExtensionsEnabled()) { |
| 11351 | GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported."; |
| 11352 | } |
| 11353 | |
| 11354 | ASSERT_NO_FATAL_FAILURE(InitState(nullptr, nullptr, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)); |
| 11355 | |
| 11356 | auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>(); |
| 11357 | auto pd_properties = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties); |
| 11358 | GetPhysicalDeviceProperties2(pd_properties); |
| 11359 | |
| 11360 | // Create a render pass without a Fragment Shading Rate attachment |
| 11361 | auto col_attach = LvlInitStruct<VkAttachmentDescription2>(); |
| 11362 | col_attach.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 11363 | col_attach.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11364 | col_attach.initialLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 11365 | col_attach.finalLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 11366 | |
| 11367 | VkSubpassDescription2 subpass_no_fsr = LvlInitStruct<VkSubpassDescription2>(); |
| 11368 | |
| 11369 | VkRenderPassCreateInfo2 rcpi_no_fsr = LvlInitStruct<VkRenderPassCreateInfo2KHR>(); |
| 11370 | rcpi_no_fsr.attachmentCount = 1; |
| 11371 | rcpi_no_fsr.pAttachments = &col_attach; |
| 11372 | rcpi_no_fsr.subpassCount = 1; |
| 11373 | rcpi_no_fsr.pSubpasses = &subpass_no_fsr; |
| 11374 | |
| 11375 | vk_testing::RenderPass rp_no_fsr(*m_device, rcpi_no_fsr, true); |
| 11376 | |
| 11377 | // Create 2 render passes with fragment shading rate attachments with |
| 11378 | // differing shadingRateAttachmentTexelSize values |
| 11379 | VkAttachmentReference2 fsr_attach_1 = LvlInitStruct<VkAttachmentReference2>(); |
| 11380 | fsr_attach_1.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 11381 | fsr_attach_1.attachment = 0; |
| 11382 | |
| 11383 | VkExtent2D texel_size_1 = {8, 8}; |
| 11384 | |
| 11385 | VkFragmentShadingRateAttachmentInfoKHR fsr_attachment_1 = LvlInitStruct<VkFragmentShadingRateAttachmentInfoKHR>(); |
| 11386 | fsr_attachment_1.shadingRateAttachmentTexelSize = texel_size_1; |
| 11387 | fsr_attachment_1.pFragmentShadingRateAttachment = &fsr_attach_1; |
| 11388 | VkSubpassDescription2 fsr_subpass_1 = LvlInitStruct<VkSubpassDescription2>(&fsr_attachment_1); |
| 11389 | |
| 11390 | VkAttachmentReference2 fsr_attach_2 = LvlInitStruct<VkAttachmentReference2>(); |
| 11391 | fsr_attach_2.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 11392 | fsr_attach_2.attachment = 0; |
| 11393 | |
| 11394 | VkExtent2D texel_size_2 = {32, 32}; |
| 11395 | |
| 11396 | VkFragmentShadingRateAttachmentInfoKHR fsr_attachment_2 = LvlInitStruct<VkFragmentShadingRateAttachmentInfoKHR>(); |
| 11397 | fsr_attachment_2.shadingRateAttachmentTexelSize = texel_size_2; |
| 11398 | fsr_attachment_2.pFragmentShadingRateAttachment = &fsr_attach_2; |
| 11399 | |
| 11400 | VkSubpassDescription2 fsr_subpass_2 = LvlInitStruct<VkSubpassDescription2>(&fsr_attachment_2); |
| 11401 | |
| 11402 | auto attach_desc = LvlInitStruct<VkAttachmentDescription2>(); |
| 11403 | attach_desc.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 11404 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11405 | attach_desc.initialLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 11406 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 11407 | |
| 11408 | VkRenderPassCreateInfo2KHR rpci_fsr_1 = LvlInitStruct<VkRenderPassCreateInfo2KHR>(); |
| 11409 | rpci_fsr_1.subpassCount = 1; |
| 11410 | rpci_fsr_1.pSubpasses = &fsr_subpass_1; |
| 11411 | rpci_fsr_1.attachmentCount = 1; |
| 11412 | rpci_fsr_1.pAttachments = &attach_desc; |
| 11413 | |
| 11414 | vk_testing::RenderPass rp_fsr_1(*m_device, rpci_fsr_1, true); |
| 11415 | ASSERT_TRUE(rp_fsr_1.initialized()); |
| 11416 | |
| 11417 | VkRenderPassCreateInfo2KHR rpci_fsr_2 = LvlInitStruct<VkRenderPassCreateInfo2KHR>(); |
| 11418 | rpci_fsr_2.subpassCount = 1; |
| 11419 | rpci_fsr_2.pSubpasses = &fsr_subpass_2; |
| 11420 | rpci_fsr_2.attachmentCount = 1; |
| 11421 | rpci_fsr_2.pAttachments = &attach_desc; |
| 11422 | |
| 11423 | vk_testing::RenderPass rp_fsr_2(*m_device, rpci_fsr_2, true); |
| 11424 | ASSERT_TRUE(rp_fsr_2.initialized()); |
| 11425 | |
| 11426 | VkImageObj image(m_device); |
| 11427 | image.InitNoLayout(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 11428 | VkImageView imageView = image.targetView(VK_FORMAT_R8G8B8A8_UNORM); |
| 11429 | |
| 11430 | // Create a frame buffer with a render pass with FSR attachment |
| 11431 | VkFramebufferCreateInfo fb_info = LvlInitStruct<VkFramebufferCreateInfo>(); |
| 11432 | fb_info.renderPass = rp_fsr_1.handle(); |
| 11433 | fb_info.attachmentCount = 1; |
| 11434 | fb_info.pAttachments = &imageView; |
| 11435 | fb_info.width = 32; |
| 11436 | fb_info.height = 32; |
| 11437 | fb_info.layers = 1; |
| 11438 | |
| 11439 | vk_testing::Framebuffer framebuffer_fsr; |
| 11440 | framebuffer_fsr.init(*m_device, fb_info); |
| 11441 | |
| 11442 | // Create a frame buffer with a render pass without FSR attachment |
| 11443 | VkFramebufferCreateInfo fb_info_0 = LvlInitStruct<VkFramebufferCreateInfo>(); |
| 11444 | fb_info_0.renderPass = rp_no_fsr.handle(); |
| 11445 | fb_info_0.attachmentCount = 1; |
| 11446 | fb_info_0.pAttachments = &imageView; |
| 11447 | fb_info_0.width = 32; |
| 11448 | fb_info_0.height = 32; |
| 11449 | fb_info_0.layers = 1; |
| 11450 | |
| 11451 | vk_testing::Framebuffer framebuffer_no_fsr; |
| 11452 | framebuffer_no_fsr.init(*m_device, fb_info_0); |
| 11453 | |
| 11454 | VkCommandPoolObj pool(m_device, m_device->graphics_queue_node_index_, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT); |
| 11455 | VkCommandBufferObj secondary(m_device, &pool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); |
| 11456 | |
| 11457 | // Inheritance info without FSR attachment |
| 11458 | const VkCommandBufferInheritanceInfo cmdbuff_ii_no_fsr = { |
| 11459 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, |
| 11460 | nullptr, // pNext |
| 11461 | rp_no_fsr.handle(), |
| 11462 | 0, // subpass |
| 11463 | VK_NULL_HANDLE, |
| 11464 | }; |
| 11465 | |
| 11466 | VkCommandBufferBeginInfo cmdbuff__bi_no_fsr = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, |
| 11467 | nullptr, // pNext |
| 11468 | VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, &cmdbuff_ii_no_fsr}; |
| 11469 | cmdbuff__bi_no_fsr.flags |= VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 11470 | |
| 11471 | // Render pass begin info for no FSR attachment |
| 11472 | const VkRenderPassBeginInfo rp_bi_no_fsr{VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, |
| 11473 | nullptr, // pNext |
| 11474 | rp_no_fsr.handle(), |
| 11475 | framebuffer_no_fsr.handle(), |
| 11476 | {{0, 0}, {32, 32}}, |
| 11477 | 0, |
| 11478 | nullptr}; |
| 11479 | |
| 11480 | // Inheritance info with FSR attachment |
| 11481 | const VkCommandBufferInheritanceInfo cmdbuff_ii_fsr = { |
| 11482 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, |
| 11483 | nullptr, // pNext |
| 11484 | rp_fsr_2.handle(), |
| 11485 | 0, // subpass |
| 11486 | VK_NULL_HANDLE, |
| 11487 | }; |
| 11488 | |
| 11489 | VkCommandBufferBeginInfo cmdbuff__bi_fsr = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, |
| 11490 | nullptr, // pNext |
| 11491 | VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, &cmdbuff_ii_fsr}; |
| 11492 | cmdbuff__bi_fsr.flags |= VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
| 11493 | |
| 11494 | // Render pass begin info with FSR attachment |
| 11495 | const VkRenderPassBeginInfo rp_bi_fsr{VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, |
| 11496 | nullptr, // pNext |
| 11497 | rp_fsr_1.handle(), |
| 11498 | framebuffer_fsr.handle(), |
| 11499 | {{0, 0}, {32, 32}}, |
| 11500 | 0, |
| 11501 | nullptr}; |
| 11502 | |
| 11503 | // Test case where primary command buffer does not have an FSR attachment but |
| 11504 | // secondary command buffer does. |
| 11505 | { |
| 11506 | secondary.begin(&cmdbuff__bi_fsr); |
| 11507 | secondary.end(); |
| 11508 | |
| 11509 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pBeginInfo-06020"); |
| 11510 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pInheritanceInfo-00098"); |
| 11511 | |
| 11512 | m_commandBuffer->begin(); |
| 11513 | m_commandBuffer->BeginRenderPass(rp_bi_no_fsr, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS); |
| 11514 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
| 11515 | m_errorMonitor->VerifyFound(); |
| 11516 | m_commandBuffer->EndRenderPass(); |
| 11517 | m_commandBuffer->end(); |
| 11518 | } |
| 11519 | |
| 11520 | m_commandBuffer->reset(); |
| 11521 | secondary.reset(); |
| 11522 | |
| 11523 | // Test case where primary command buffer has FSR attachment but secondary |
| 11524 | // command buffer does not. |
| 11525 | { |
| 11526 | secondary.begin(&cmdbuff__bi_no_fsr); |
| 11527 | secondary.end(); |
| 11528 | |
| 11529 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pBeginInfo-06020"); |
| 11530 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pInheritanceInfo-00098"); |
| 11531 | |
| 11532 | m_commandBuffer->begin(); |
| 11533 | m_commandBuffer->BeginRenderPass(rp_bi_fsr, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS); |
| 11534 | |
| 11535 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
| 11536 | m_errorMonitor->VerifyFound(); |
| 11537 | m_commandBuffer->EndRenderPass(); |
| 11538 | m_commandBuffer->end(); |
| 11539 | } |
| 11540 | |
| 11541 | m_commandBuffer->reset(); |
| 11542 | secondary.reset(); |
| 11543 | |
| 11544 | // Test case where both command buffers have FSR attachments but they are |
| 11545 | // incompatible. |
| 11546 | { |
| 11547 | secondary.begin(&cmdbuff__bi_fsr); |
| 11548 | secondary.end(); |
| 11549 | |
| 11550 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pBeginInfo-06020"); |
| 11551 | m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pInheritanceInfo-00098"); |
| 11552 | |
| 11553 | m_commandBuffer->begin(); |
| 11554 | m_commandBuffer->BeginRenderPass(rp_bi_fsr, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS); |
| 11555 | |
| 11556 | vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle()); |
| 11557 | m_errorMonitor->VerifyFound(); |
| 11558 | |
| 11559 | m_commandBuffer->EndRenderPass(); |
| 11560 | m_commandBuffer->end(); |
| 11561 | } |
| 11562 | |
| 11563 | m_commandBuffer->reset(); |
| 11564 | secondary.reset(); |
| 11565 | } |