blob: 7cd59f14e636393bfcc27141e055f21ad9871821 [file] [log] [blame]
Aaron Haganaca50442021-12-07 22:26:29 -05001/*
stusmith15f24a82021-12-24 15:21:19 +00002 * Copyright (c) 2015-2022 The Khronos Group Inc.
3 * Copyright (c) 2015-2022 Valve Corporation
4 * Copyright (c) 2015-2022 LunarG, Inc.
5 * Copyright (c) 2015-2022 Google, Inc.
6 * Modifications Copyright (C) 2020-2022 Advanced Micro Devices, Inc. All rights reserved.
Tony-LunarG4c253372022-01-18 13:51:07 -07007 * Modifications Copyright (C) 2021-2022 ARM, Inc. All rights reserved.
Aaron Haganaca50442021-12-07 22:26:29 -05008 *
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 */
16
17#include "cast_utils.h"
18#include "layer_validation_tests.h"
19
Aaron Haganb54466d2022-02-18 15:02:54 -050020TEST_F(VkLayerTest, DynamicRenderingCommandBufferInheritanceRenderingInfo) {
Aaron Haganaca50442021-12-07 22:26:29 -050021 TEST_DESCRIPTION("VkCommandBufferInheritanceRenderingInfoKHR Dynamic Rendering Tests.");
22
arno1689b372022-08-25 19:34:15 +020023 SetTargetApiVersion(VK_API_VERSION_1_2);
sfricke-samsungae54c1e2022-01-21 05:35:21 -080024
Aaron Haganaca50442021-12-07 22:26:29 -050025 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
Nathaniel Cesarioa06135e2022-03-02 21:22:30 -070026 ASSERT_NO_FATAL_FAILURE(InitFramework());
Aaron Haganaca50442021-12-07 22:26:29 -050027
sjfricked700bc02022-05-30 16:35:06 +090028 if (!AreRequiredExtensionsEnabled()) {
29 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
Aaron Haganb54466d2022-02-18 15:02:54 -050030 }
31
Aaron Haganaca50442021-12-07 22:26:29 -050032 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
sjfrickebdd58dd2022-05-20 14:22:50 +090033 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
Aaron Haganaca50442021-12-07 22:26:29 -050034 }
sfricke-samsungae54c1e2022-01-21 05:35:21 -080035
Nathaniel Cesarioa06135e2022-03-02 21:22:30 -070036 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +090037 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
Nathaniel Cesarioa06135e2022-03-02 21:22:30 -070038 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +090039 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
Aaron Haganaca50442021-12-07 22:26:29 -050040 }
41
ziga-lunargf54cb2a2022-03-11 02:54:27 +010042 features2.features.variableMultisampleRate = VK_FALSE;
43
Nathaniel Cesarioa06135e2022-03-02 21:22:30 -070044 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
45
Aaron Haganaca50442021-12-07 22:26:29 -050046 VkPhysicalDeviceMultiviewProperties multiview_props = LvlInitStruct<VkPhysicalDeviceMultiviewProperties>();
47 VkPhysicalDeviceProperties2 pd_props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&multiview_props);
sjfricke74a1aad2022-08-17 14:41:33 +090048 GetPhysicalDeviceProperties2(pd_props2);
Aaron Haganaca50442021-12-07 22:26:29 -050049
50 if (multiview_props.maxMultiviewViewCount == 32) {
51 printf("%s VUID is not testable as maxMultiviewViewCount is 32, skipping test\n", kSkipPrefix);
52 return;
53 }
54
55 VkFormat color_format = VK_FORMAT_D32_SFLOAT;
56
57 auto cmd_buffer_inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>();
58 cmd_buffer_inheritance_rendering_info.colorAttachmentCount = 1;
59 cmd_buffer_inheritance_rendering_info.pColorAttachmentFormats = &color_format;
60 cmd_buffer_inheritance_rendering_info.depthAttachmentFormat = VK_FORMAT_R8G8B8_UNORM;
61 cmd_buffer_inheritance_rendering_info.stencilAttachmentFormat = VK_FORMAT_R8G8B8_SNORM;
62 cmd_buffer_inheritance_rendering_info.viewMask = 1 << multiview_props.maxMultiviewViewCount;
63
64 auto sample_count_info_amd = LvlInitStruct<VkAttachmentSampleCountInfoAMD>();
65 sample_count_info_amd.pNext = &cmd_buffer_inheritance_rendering_info;
66 sample_count_info_amd.colorAttachmentCount = 2;
sfricke-samsungae54c1e2022-01-21 05:35:21 -080067
Aaron Haganaca50442021-12-07 22:26:29 -050068 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
69 cmd_buffer_inheritance_info.pNext = &sample_count_info_amd;
70
71 auto cmd_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>();
72 cmd_buffer_allocate_info.commandPool = m_commandPool->handle();
73 cmd_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY;
74 cmd_buffer_allocate_info.commandBufferCount = 0x1;
75
76 VkCommandBuffer secondary_cmd_buffer;
77 VkResult err = vk::AllocateCommandBuffers(m_device->device(), &cmd_buffer_allocate_info, &secondary_cmd_buffer);
78 ASSERT_VK_SUCCESS(err);
79 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06003");
Tony-LunarGbbd2ab92021-12-02 08:31:24 -070080 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-colorAttachmentCount-06004");
81 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-variableMultisampleRate-06005");
82 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-depthAttachmentFormat-06007");
83 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-multiview-06008");
84 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-viewMask-06009");
ziga-lunarg813fa012022-04-09 14:09:57 +020085 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-stencilAttachmentFormat-06199");
86 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-depthAttachmentFormat-06200");
87 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-pColorAttachmentFormats-06006");
88 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-depthAttachmentFormat-06540");
ziga-lunarga3cc8482022-04-29 14:58:29 +020089 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-stencilAttachmentFormat-06541");
Aaron Haganaca50442021-12-07 22:26:29 -050090
91 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
92 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
93 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
94 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
95 m_errorMonitor->VerifyFound();
96}
97
Aaron Haganb54466d2022-02-18 15:02:54 -050098TEST_F(VkLayerTest, DynamicRenderingCommandDraw) {
Aaron Haganaca50442021-12-07 22:26:29 -050099 TEST_DESCRIPTION("vkCmdDraw* Dynamic Rendering Tests.");
100
arno1689b372022-08-25 19:34:15 +0200101 SetTargetApiVersion(VK_API_VERSION_1_2);
Aaron Haganaca50442021-12-07 22:26:29 -0500102
103 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
104
105 ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor));
106
107 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900108 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
Aaron Haganaca50442021-12-07 22:26:29 -0500109 }
110
sjfricked700bc02022-05-30 16:35:06 +0900111 if (!AreRequiredExtensionsEnabled()) {
112 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
Aaron Haganaca50442021-12-07 22:26:29 -0500113 }
114
115 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +0900116 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
Aaron Haganaca50442021-12-07 22:26:29 -0500117 if (!dynamic_rendering_features.dynamicRendering) {
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600118 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering , skipping.";
Aaron Haganaca50442021-12-07 22:26:29 -0500119 }
120
121 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
122
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800123 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
124 VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT);
Aaron Haganaca50442021-12-07 22:26:29 -0500125
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600126 auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
127
Aaron Haganaca50442021-12-07 22:26:29 -0500128 VkPipelineObj pipe(m_device);
129 pipe.AddShader(&vs);
130 pipe.AddShader(&fs);
131 pipe.AddDefaultColorAttachment();
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600132 pipe.SetDepthStencil(&ds_state);
Aaron Haganaca50442021-12-07 22:26:29 -0500133
134 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
135 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
136 const VkPipelineLayoutObj pl(m_device, {&dsl});
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800137
Aaron Haganaca50442021-12-07 22:26:29 -0500138 VkFormat depth_format = VK_FORMAT_D32_SFLOAT_S8_UINT;
139 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
Aaron Hagan80034ea2021-12-23 11:24:09 -0500140 pipeline_rendering_info.depthAttachmentFormat = depth_format;
141 pipeline_rendering_info.stencilAttachmentFormat = depth_format;
Aaron Haganaca50442021-12-07 22:26:29 -0500142
143 auto multisample_state_create_info = LvlInitStruct<VkPipelineMultisampleStateCreateInfo>();
144 multisample_state_create_info.rasterizationSamples = VK_SAMPLE_COUNT_2_BIT;
145
146 auto create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
147 pipe.InitGraphicsPipelineCreateInfo(&create_info);
148 create_info.pMultisampleState = &multisample_state_create_info;
149 create_info.renderPass = VkRenderPass(0x1);
150 create_info.pNext = &pipeline_rendering_info;
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800151
Aaron Haganaca50442021-12-07 22:26:29 -0500152 VkResult err = pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
153 ASSERT_VK_SUCCESS(err);
154
155 VkViewport viewport = {0, 0, 16, 16, 0, 1};
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800156 VkRect2D scissor = {{0, 0}, {16, 16}};
Aaron Haganaca50442021-12-07 22:26:29 -0500157
158 VkImageObj image(m_device);
159 image.Init(32, 32, 1, depth_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
160 ASSERT_TRUE(image.initialized());
161
162 VkImageViewCreateInfo ivci = {VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
163 nullptr,
164 0,
165 image.handle(),
166 VK_IMAGE_VIEW_TYPE_2D,
167 depth_format,
168 {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
169 VK_COMPONENT_SWIZZLE_IDENTITY},
170 {VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, 0, 1, 0, 1}};
171
paul-lunarg18e16342022-07-12 14:02:23 -0600172 vk_testing::ImageView depth_image_view(*m_device, ivci);
Aaron Haganaca50442021-12-07 22:26:29 -0500173
174 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
175 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
paul-lunarg18e16342022-07-12 14:02:23 -0600176 depth_attachment.imageView = depth_image_view.handle();
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800177
Aaron Haganaca50442021-12-07 22:26:29 -0500178 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
179 begin_rendering_info.pDepthAttachment = &depth_attachment;
180 begin_rendering_info.pStencilAttachment = &depth_attachment;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600181 begin_rendering_info.layerCount = 1;
Aaron Haganaca50442021-12-07 22:26:29 -0500182
183 m_commandBuffer->begin();
184 m_commandBuffer->BeginRendering(begin_rendering_info);
185 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle());
186 vk::CmdSetViewport(m_commandBuffer->handle(), 0, 1, &viewport);
187 vk::CmdSetScissor(m_commandBuffer->handle(), 0, 1, &scissor);
188 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06189");
189 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06190");
190 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
191 m_errorMonitor->VerifyFound();
192 m_commandBuffer->EndRendering();
193 m_commandBuffer->end();
194}
195
196TEST_F(VkLayerTest, DynamicRenderingGraphicsPipelineCreateInfo) {
197 TEST_DESCRIPTION("Test graphics pipeline creation with dynamic rendering.");
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800198
arno1689b372022-08-25 19:34:15 +0200199 SetTargetApiVersion(VK_API_VERSION_1_2);
Aaron Haganaca50442021-12-07 22:26:29 -0500200
201 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
202
203 ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor));
204
205 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900206 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
Aaron Haganaca50442021-12-07 22:26:29 -0500207 }
208
sjfricked700bc02022-05-30 16:35:06 +0900209 if (!AreRequiredExtensionsEnabled()) {
210 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
Aaron Haganaca50442021-12-07 22:26:29 -0500211 }
212
213 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +0900214 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
Aaron Haganaca50442021-12-07 22:26:29 -0500215 if (!dynamic_rendering_features.dynamicRendering) {
216 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
217 return;
218 }
219
220 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
221
222 const VkPipelineLayoutObj pl(m_device);
223 VkPipelineObj pipe(m_device);
224
225 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
226
227 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
228 color_blend_state_create_info.attachmentCount = 1;
229 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
230
231 VkFormat color_format[2] = {VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_D32_SFLOAT_S8_UINT};
232
233 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
234 pipeline_rendering_info.colorAttachmentCount = 2;
235 pipeline_rendering_info.pColorAttachmentFormats = &color_format[0];
236 pipeline_rendering_info.viewMask = 0x2;
Aaron Hagan80034ea2021-12-23 11:24:09 -0500237 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
Aaron Haganaca50442021-12-07 22:26:29 -0500238
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800239 auto pipeline_tessellation_state_info = LvlInitStruct<VkPipelineTessellationStateCreateInfo>();
Aaron Haganaca50442021-12-07 22:26:29 -0500240 pipeline_tessellation_state_info.patchControlPoints = 1;
241
242 auto pipeline_input_assembly_state_info = LvlInitStruct<VkPipelineInputAssemblyStateCreateInfo>();
243 pipeline_input_assembly_state_info.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST;
244
245 auto create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
Aaron Hagan80034ea2021-12-23 11:24:09 -0500246
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800247 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
248 VkShaderObj gs(this, bindStateGeomShaderText, VK_SHADER_STAGE_GEOMETRY_BIT);
249 VkShaderObj te(this, bindStateTeshaderText, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT);
250 VkShaderObj tc(this, bindStateTscShaderText, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT);
Aaron Hagan80034ea2021-12-23 11:24:09 -0500251 VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT);
252
Aaron Haganaca50442021-12-07 22:26:29 -0500253 pipe.AddShader(&vs);
254 pipe.AddShader(&gs);
255 pipe.AddShader(&te);
256 pipe.AddShader(&tc);
Aaron Hagan80034ea2021-12-23 11:24:09 -0500257 pipe.AddShader(&fs);
Aaron Haganaca50442021-12-07 22:26:29 -0500258 pipe.InitGraphicsPipelineCreateInfo(&create_info);
Nathaniel Cesario72f29552022-03-24 05:11:11 -0600259
Aaron Haganaca50442021-12-07 22:26:29 -0500260 create_info.pColorBlendState = &color_blend_state_create_info;
261 create_info.pNext = &pipeline_rendering_info;
262 create_info.pTessellationState = &pipeline_tessellation_state_info;
263 create_info.pInputAssemblyState = &pipeline_input_assembly_state_info;
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800264
Aaron Hagan80034ea2021-12-23 11:24:09 -0500265 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06053");
Nathaniel Cesario72f29552022-03-24 05:11:11 -0600266 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06581");
Aaron Haganaca50442021-12-07 22:26:29 -0500267 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06055");
268 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06057");
269 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06058");
Nathaniel Cesarioa6118572022-03-24 04:48:33 -0600270 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-multiview-06577");
Aaron Haganaca50442021-12-07 22:26:29 -0500271 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
272 m_errorMonitor->VerifyFound();
273
Aaron Hagan80034ea2021-12-23 11:24:09 -0500274 create_info.pColorBlendState = nullptr;
275 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
276 pipeline_rendering_info.viewMask = 0x0;
277 pipeline_rendering_info.colorAttachmentCount = 1;
278 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06054");
279 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
280 m_errorMonitor->VerifyFound();
Aaron Haganb54466d2022-02-18 15:02:54 -0500281
ziga-lunarg5e671602022-03-17 19:06:55 +0100282 color_format[0] = VK_FORMAT_D32_SFLOAT_S8_UINT;
283 color_blend_attachment_state.blendEnable = VK_TRUE;
284 create_info.pColorBlendState = &color_blend_state_create_info;
Nathaniel Cesario72f29552022-03-24 05:11:11 -0600285 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06581");
ziga-lunarg5e671602022-03-17 19:06:55 +0100286 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06062");
ziga-lunarg5e671602022-03-17 19:06:55 +0100287 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
288 m_errorMonitor->VerifyFound();
289 color_format[0] = VK_FORMAT_R8G8B8A8_UNORM;
290
Aaron Haganb54466d2022-02-18 15:02:54 -0500291 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
292 ds_ci.flags = VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM;
293 color_blend_state_create_info.flags = VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM;
294 create_info.pColorBlendState = &color_blend_state_create_info;
295 create_info.pDepthStencilState = &ds_ci;
296 create_info.renderPass = VK_NULL_HANDLE;
297 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
298 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06482");
299 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06483");
300 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
301 m_errorMonitor->VerifyFound();
stusmith15f24a82021-12-24 15:21:19 +0000302}
303
304TEST_F(VkLayerTest, DynamicRenderingWithMismatchingViewMask) {
305 TEST_DESCRIPTION("Draw with Dynamic Rendering and a mismatching viewMask");
306
307 SetTargetApiVersion(VK_API_VERSION_1_1);
308
309 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
310
311 ASSERT_NO_FATAL_FAILURE(InitFramework());
312
sjfricked700bc02022-05-30 16:35:06 +0900313 if (!AreRequiredExtensionsEnabled()) {
314 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
stusmith15f24a82021-12-24 15:21:19 +0000315 }
316
317 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900318 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
stusmith15f24a82021-12-24 15:21:19 +0000319 }
320
321 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
322 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(&multiview_features);
sjfricke11db0c72022-08-18 13:23:11 +0900323 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
stusmith15f24a82021-12-24 15:21:19 +0000324 if (!dynamic_rendering_features.dynamicRendering) {
325 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
326 return;
327 }
328 if (!multiview_features.multiview) {
329 printf("%s Test requires (unsupported) multiview , skipping\n", kSkipPrefix);
330 return;
331 }
332
333 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
334
335 char const *fsSource = R"glsl(
336 #version 450
337 layout(location=0) out vec4 color;
338 void main() {
339 color = vec4(1.0f);
340 }
341 )glsl";
342
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800343 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
344 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000345
346 VkPipelineObj pipe(m_device);
347 pipe.AddShader(&vs);
348 pipe.AddShader(&fs);
349 pipe.AddDefaultColorAttachment();
350
351 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
352 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
353 const VkPipelineLayoutObj pl(m_device, {&dsl});
354
355 VkFormat color_formats = {VK_FORMAT_R8G8B8A8_UNORM};
356 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
357 pipeline_rendering_info.colorAttachmentCount = 1;
358 pipeline_rendering_info.pColorAttachmentFormats = &color_formats;
359 pipeline_rendering_info.viewMask = 1;
360
361 VkViewport viewport = {0, 0, 16, 16, 0, 1};
362 VkRect2D scissor = {{0, 0}, {16, 16}};
363 m_viewports.push_back(viewport);
364 m_scissors.push_back(scissor);
365 pipe.SetViewport(m_viewports);
366 pipe.SetScissor(m_scissors);
367
368 auto create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
369 pipe.InitGraphicsPipelineCreateInfo(&create_info);
370 create_info.pNext = &pipeline_rendering_info;
371
372 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
373
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800374 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000375 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
376
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800377 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000378 begin_rendering_info.colorAttachmentCount = 1;
379 begin_rendering_info.pColorAttachments = &color_attachment;
380 begin_rendering_info.viewMask = 2;
381 begin_rendering_info.layerCount = 1;
382
383 m_commandBuffer->begin();
384 m_commandBuffer->BeginRendering(begin_rendering_info);
385 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle());
386 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-viewMask-06178");
387 m_commandBuffer->Draw(1, 1, 0, 0);
388 m_errorMonitor->VerifyFound();
389 m_commandBuffer->EndRendering();
390 m_commandBuffer->end();
391}
392
393TEST_F(VkLayerTest, DynamicRenderingWithMistmatchingAttachments) {
394 TEST_DESCRIPTION("Draw with Dynamic Rendering with mismatching color attachment counts and depth/stencil formats");
395
396 SetTargetApiVersion(VK_API_VERSION_1_1);
397
398 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
399
400 ASSERT_NO_FATAL_FAILURE(InitFramework());
401
sjfricked700bc02022-05-30 16:35:06 +0900402 if (!AreRequiredExtensionsEnabled()) {
403 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
stusmith15f24a82021-12-24 15:21:19 +0000404 }
405
406 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900407 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
stusmith15f24a82021-12-24 15:21:19 +0000408 }
409
410 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +0900411 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
stusmith15f24a82021-12-24 15:21:19 +0000412 if (!dynamic_rendering_features.dynamicRendering) {
413 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
414 return;
415 }
416
417 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
418
419 char const *fsSource = R"glsl(
420 #version 450
421 layout(location=0) out vec4 color;
422 void main() {
423 color = vec4(1.0f);
424 }
425 )glsl";
426
427 VkViewport viewport = {0, 0, 16, 16, 0, 1};
428 VkRect2D scissor = {{0, 0}, {16, 16}};
429 m_viewports.push_back(viewport);
430 m_scissors.push_back(scissor);
431
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800432 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
433 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000434
435 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
436 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
437 const VkPipelineLayoutObj pl(m_device, {&dsl});
438
439 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
440
441 VkPipelineObj pipe1(m_device);
442 pipe1.AddShader(&vs);
443 pipe1.AddShader(&fs);
444 pipe1.AddDefaultColorAttachment();
445 pipe1.SetViewport(m_viewports);
446 pipe1.SetScissor(m_scissors);
447
448 VkFormat color_formats[] = {VK_FORMAT_R8G8B8A8_UNORM};
449 pipeline_rendering_info.colorAttachmentCount = 1;
450 pipeline_rendering_info.pColorAttachmentFormats = color_formats;
451
452 auto create_info1 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
453 pipe1.InitGraphicsPipelineCreateInfo(&create_info1);
454 create_info1.pNext = &pipeline_rendering_info;
455
456 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
457
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600458 auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
459
stusmith15f24a82021-12-24 15:21:19 +0000460 VkPipelineObj pipe2(m_device);
461 pipe2.AddShader(&vs);
462 pipe2.AddShader(&fs);
463 pipe2.AddDefaultColorAttachment();
464 pipe2.SetViewport(m_viewports);
465 pipe2.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600466 pipe2.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000467
468 pipeline_rendering_info.colorAttachmentCount = 0;
469 pipeline_rendering_info.pColorAttachmentFormats = nullptr;
470 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_D16_UNORM;
471
472 auto create_info2 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
473 pipe2.InitGraphicsPipelineCreateInfo(&create_info2);
474 create_info2.pNext = &pipeline_rendering_info;
475
476 pipe2.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info2);
477
478 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
479 ASSERT_TRUE(depthStencilFormat != 0);
480
481 bool testStencil = false;
482 VkFormat stencilFormat = VK_FORMAT_UNDEFINED;
483
484 if (ImageFormatIsSupported(gpu(), VK_FORMAT_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
485 stencilFormat = VK_FORMAT_S8_UINT;
486 testStencil = true;
487 } else if ((depthStencilFormat != VK_FORMAT_D16_UNORM_S8_UINT) &&
488 ImageFormatIsSupported(gpu(), VK_FORMAT_D16_UNORM_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
489 stencilFormat = VK_FORMAT_D16_UNORM_S8_UINT;
490 testStencil = true;
491 } else if ((depthStencilFormat != VK_FORMAT_D24_UNORM_S8_UINT) &&
492 ImageFormatIsSupported(gpu(), VK_FORMAT_D24_UNORM_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
493 stencilFormat = VK_FORMAT_D24_UNORM_S8_UINT;
494 testStencil = true;
495 } else if ((depthStencilFormat != VK_FORMAT_D32_SFLOAT_S8_UINT) &&
496 ImageFormatIsSupported(gpu(), VK_FORMAT_D32_SFLOAT_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
497 stencilFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
498 testStencil = true;
499 }
500
501 VkPipelineObj pipe3(m_device);
502
503 if (testStencil) {
504 pipe3.AddShader(&vs);
505 pipe3.AddShader(&fs);
506 pipe3.AddDefaultColorAttachment();
507 pipe3.SetViewport(m_viewports);
508 pipe3.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600509 pipe3.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000510
511 pipeline_rendering_info.colorAttachmentCount = 0;
512 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
513 pipeline_rendering_info.stencilAttachmentFormat = stencilFormat;
514
515 auto create_info3 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
516 pipe3.InitGraphicsPipelineCreateInfo(&create_info3);
517 create_info3.pNext = &pipeline_rendering_info;
518
519 pipe3.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info3);
520 }
521
522 VkImageObj colorImage(m_device);
523 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
524 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
525
526 VkImageObj depthStencilImage(m_device);
527 depthStencilImage.Init(32, 32, 1, depthStencilFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
528 VkImageView depthStencilImageView =
529 depthStencilImage.targetView(depthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
530
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800531 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000532 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
533 color_attachment.imageView = colorImageView;
534
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800535 VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000536 depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
537 depth_stencil_attachment.imageView = depthStencilImageView;
538
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800539 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600540 begin_rendering_info.layerCount = 1;
stusmith15f24a82021-12-24 15:21:19 +0000541 m_commandBuffer->begin();
542
543 // Mismatching color attachment count
544 m_commandBuffer->BeginRendering(begin_rendering_info);
545 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
546 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06179");
547 m_commandBuffer->Draw(1, 1, 0, 0);
548 m_errorMonitor->VerifyFound();
549 m_commandBuffer->EndRendering();
550
551 // Mismatching color formats
552 begin_rendering_info.colorAttachmentCount = 1;
553 begin_rendering_info.pColorAttachments = &color_attachment;
554 m_commandBuffer->BeginRendering(begin_rendering_info);
555 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
556 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06180");
557 m_commandBuffer->Draw(1, 1, 0, 0);
558 m_errorMonitor->VerifyFound();
559 m_commandBuffer->EndRendering();
560
561 // Mismatching depth format
562 begin_rendering_info.colorAttachmentCount = 0;
563 begin_rendering_info.pColorAttachments = nullptr;
564 begin_rendering_info.pDepthAttachment = &depth_stencil_attachment;
565 m_commandBuffer->BeginRendering(begin_rendering_info);
566 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.handle());
567 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06181");
568 m_commandBuffer->Draw(1, 1, 0, 0);
569 m_errorMonitor->VerifyFound();
570 m_commandBuffer->EndRendering();
571
572 // Mismatching stencil format
573 if (testStencil) {
574 begin_rendering_info.pDepthAttachment = nullptr;
575 begin_rendering_info.pStencilAttachment = &depth_stencil_attachment;
576 m_commandBuffer->BeginRendering(begin_rendering_info);
577 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe3.handle());
578 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06182");
579 m_commandBuffer->Draw(1, 1, 0, 0);
580 m_errorMonitor->VerifyFound();
581 m_commandBuffer->EndRendering();
582 }
583
584 m_commandBuffer->end();
585}
586
587TEST_F(VkLayerTest, DynamicRenderingWithMistmatchingAttachmentSamples) {
588 TEST_DESCRIPTION("Draw with Dynamic Rendering with mismatching color/depth/stencil sample counts");
589
590 SetTargetApiVersion(VK_API_VERSION_1_1);
591
592 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
593
594 ASSERT_NO_FATAL_FAILURE(InitFramework());
595
sjfricked700bc02022-05-30 16:35:06 +0900596 if (!AreRequiredExtensionsEnabled()) {
597 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
stusmith15f24a82021-12-24 15:21:19 +0000598 }
599
600 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900601 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
stusmith15f24a82021-12-24 15:21:19 +0000602 }
603
604 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +0900605 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
stusmith15f24a82021-12-24 15:21:19 +0000606 if (!dynamic_rendering_features.dynamicRendering) {
607 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
608 return;
609 }
610
611 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
612
613 char const *fsSource = R"glsl(
614 #version 450
615 layout(location=0) out vec4 color;
616 void main() {
617 color = vec4(1.0f);
618 }
619 )glsl";
620
621 VkViewport viewport = {0, 0, 16, 16, 0, 1};
622 VkRect2D scissor = {{0, 0}, {16, 16}};
623 m_viewports.push_back(viewport);
624 m_scissors.push_back(scissor);
625
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800626 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
627 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000628
629 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
630 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
631 const VkPipelineLayoutObj pl(m_device, {&dsl});
632
633 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
634
stusmith15f24a82021-12-24 15:21:19 +0000635 VkPipelineObj pipe1(m_device);
636 pipe1.AddShader(&vs);
637 pipe1.AddShader(&fs);
638 pipe1.AddDefaultColorAttachment();
639 pipe1.SetViewport(m_viewports);
640 pipe1.SetScissor(m_scissors);
641
642 VkFormat color_formats[] = {VK_FORMAT_R8G8B8A8_UNORM};
643 pipeline_rendering_info.colorAttachmentCount = 1;
644 pipeline_rendering_info.pColorAttachmentFormats = color_formats;
645
646 auto create_info1 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
647 pipe1.InitGraphicsPipelineCreateInfo(&create_info1);
648 create_info1.pNext = &pipeline_rendering_info;
649
650 auto multisample_state_create_info = LvlInitStruct<VkPipelineMultisampleStateCreateInfo>();
651 multisample_state_create_info.rasterizationSamples = VK_SAMPLE_COUNT_2_BIT;
652 create_info1.pMultisampleState = &multisample_state_create_info;
653
654 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
655
stusmith15f24a82021-12-24 15:21:19 +0000656 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
657 ASSERT_TRUE(depthStencilFormat != 0);
658
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600659 auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
660
stusmith15f24a82021-12-24 15:21:19 +0000661 VkPipelineObj pipe2(m_device);
662 pipe2.AddShader(&vs);
663 pipe2.AddShader(&fs);
664 pipe2.AddDefaultColorAttachment();
665 pipe2.SetViewport(m_viewports);
666 pipe2.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600667 pipe2.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000668
669 pipeline_rendering_info.colorAttachmentCount = 0;
670 pipeline_rendering_info.pColorAttachmentFormats = nullptr;
671 pipeline_rendering_info.depthAttachmentFormat = depthStencilFormat;
672
673 auto create_info2 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
674 pipe2.InitGraphicsPipelineCreateInfo(&create_info2);
675 create_info2.pNext = &pipeline_rendering_info;
676
677 create_info2.pMultisampleState = &multisample_state_create_info;
678
679 pipe2.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info2);
680
stusmith15f24a82021-12-24 15:21:19 +0000681 VkPipelineObj pipe3(m_device);
682
683 pipe3.AddShader(&vs);
684 pipe3.AddShader(&fs);
685 pipe3.AddDefaultColorAttachment();
686 pipe3.SetViewport(m_viewports);
687 pipe3.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600688 pipe3.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000689
690 pipeline_rendering_info.colorAttachmentCount = 0;
691 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
692 pipeline_rendering_info.stencilAttachmentFormat = depthStencilFormat;
693
694 auto create_info3 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
695 pipe3.InitGraphicsPipelineCreateInfo(&create_info3);
696 create_info3.pNext = &pipeline_rendering_info;
697
698 create_info3.pMultisampleState = &multisample_state_create_info;
699
700 pipe3.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info3);
701
stusmith15f24a82021-12-24 15:21:19 +0000702 VkImageObj colorImage(m_device);
703 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
704 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UNORM);
705
706 VkImageObj depthStencilImage(m_device);
707 depthStencilImage.Init(32, 32, 1, depthStencilFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
708 VkImageView depthStencilImageView =
709 depthStencilImage.targetView(depthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
710
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800711 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000712 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
713 color_attachment.imageView = colorImageView;
714
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800715 VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000716 depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
717 depth_stencil_attachment.imageView = depthStencilImageView;
718
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800719 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600720 begin_rendering_info.layerCount = 1;
stusmith15f24a82021-12-24 15:21:19 +0000721 m_commandBuffer->begin();
722
723 // Mismatching color samples
724 begin_rendering_info.colorAttachmentCount = 1;
725 begin_rendering_info.pColorAttachments = &color_attachment;
726 m_commandBuffer->BeginRendering(begin_rendering_info);
727 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
728 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06188");
729 m_commandBuffer->Draw(1, 1, 0, 0);
730 m_errorMonitor->VerifyFound();
731 m_commandBuffer->EndRendering();
732
733 // Mismatching depth samples
734 begin_rendering_info.colorAttachmentCount = 0;
735 begin_rendering_info.pColorAttachments = nullptr;
736 begin_rendering_info.pDepthAttachment = &depth_stencil_attachment;
737 m_commandBuffer->BeginRendering(begin_rendering_info);
738 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.handle());
739 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06189");
740 m_commandBuffer->Draw(1, 1, 0, 0);
741 m_errorMonitor->VerifyFound();
742 m_commandBuffer->EndRendering();
743
744 // Mismatching stencil samples
745 begin_rendering_info.pDepthAttachment = nullptr;
746 begin_rendering_info.pStencilAttachment = &depth_stencil_attachment;
747 m_commandBuffer->BeginRendering(begin_rendering_info);
748 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe3.handle());
749 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06190");
750 m_commandBuffer->Draw(1, 1, 0, 0);
751 m_errorMonitor->VerifyFound();
752 m_commandBuffer->EndRendering();
753
754 m_commandBuffer->end();
755}
756
ziga-lunarga3cc8482022-04-29 14:58:29 +0200757TEST_F(VkLayerTest, DynamicRenderingWithMismatchingMixedAttachmentSamples) {
stusmith15f24a82021-12-24 15:21:19 +0000758 TEST_DESCRIPTION("Draw with Dynamic Rendering with mismatching mixed color/depth/stencil sample counts");
759
760 SetTargetApiVersion(VK_API_VERSION_1_1);
761
762 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
763
764 ASSERT_NO_FATAL_FAILURE(InitFramework());
765
sjfricked700bc02022-05-30 16:35:06 +0900766 if (!AreRequiredExtensionsEnabled()) {
767 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
stusmith15f24a82021-12-24 15:21:19 +0000768 }
769
770 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900771 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
stusmith15f24a82021-12-24 15:21:19 +0000772 }
773
774 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +0900775 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
stusmith15f24a82021-12-24 15:21:19 +0000776 if (!dynamic_rendering_features.dynamicRendering) {
777 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
778 return;
779 }
780
781 bool amd_samples = false;
782 if (DeviceExtensionSupported(gpu(), nullptr, VK_AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME)) {
783 m_device_extension_names.push_back(VK_AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME);
784 amd_samples = true;
785 }
786
787 bool nv_samples = false;
788 if (DeviceExtensionSupported(gpu(), nullptr, VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME)) {
789 m_device_extension_names.push_back(VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME);
790 nv_samples = true;
791 }
792
793 if (!amd_samples && !nv_samples) {
794 printf("%s Test requires either VK_AMD_mixed_attachment_samples or VK_NV_framebuffer_mixed_samples, skipping\n",
795 kSkipPrefix);
796 return;
797 }
798
799 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
800
801 char const *fsSource = R"glsl(
802 #version 450
803 layout(location=0) out vec4 color;
804 void main() {
805 color = vec4(1.0f);
806 }
807 )glsl";
808
809 VkViewport viewport = {0, 0, 16, 16, 0, 1};
810 VkRect2D scissor = {{0, 0}, {16, 16}};
811 m_viewports.push_back(viewport);
812 m_scissors.push_back(scissor);
813
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800814 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
815 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000816
817 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
818 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
819 const VkPipelineLayoutObj pl(m_device, {&dsl});
820
ziga-lunarga3cc8482022-04-29 14:58:29 +0200821 VkSampleCountFlagBits counts[2] = {VK_SAMPLE_COUNT_2_BIT, VK_SAMPLE_COUNT_2_BIT};
stusmith15f24a82021-12-24 15:21:19 +0000822 auto samples_info = LvlInitStruct<VkAttachmentSampleCountInfoAMD>();
823
824 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(&samples_info);
825
826 VkPipelineObj pipe1(m_device);
827 pipe1.AddShader(&vs);
828 pipe1.AddShader(&fs);
829 pipe1.AddDefaultColorAttachment();
830 pipe1.SetViewport(m_viewports);
831 pipe1.SetScissor(m_scissors);
832
833 VkFormat color_formats[] = {VK_FORMAT_R8G8B8A8_UNORM};
834 pipeline_rendering_info.colorAttachmentCount = 1;
835 pipeline_rendering_info.pColorAttachmentFormats = color_formats;
836
837 samples_info.colorAttachmentCount = 1;
ziga-lunarga3cc8482022-04-29 14:58:29 +0200838 samples_info.pColorAttachmentSamples = counts;
stusmith15f24a82021-12-24 15:21:19 +0000839
840 auto create_info1 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
841 pipe1.InitGraphicsPipelineCreateInfo(&create_info1);
842 create_info1.pNext = &pipeline_rendering_info;
843
Aaron Haganb54466d2022-02-18 15:02:54 -0500844 samples_info.colorAttachmentCount = 2;
845 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06063");
846 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
847 m_errorMonitor->VerifyFound();
848
849 samples_info.colorAttachmentCount = 1;
stusmith15f24a82021-12-24 15:21:19 +0000850 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
851
852 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
853 ASSERT_TRUE(depthStencilFormat != 0);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600854 auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
stusmith15f24a82021-12-24 15:21:19 +0000855
856 VkPipelineObj pipe2(m_device);
857 pipe2.AddShader(&vs);
858 pipe2.AddShader(&fs);
859 pipe2.AddDefaultColorAttachment();
860 pipe2.SetViewport(m_viewports);
861 pipe2.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600862 pipe2.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000863
864 pipeline_rendering_info.colorAttachmentCount = 0;
865 pipeline_rendering_info.pColorAttachmentFormats = nullptr;
866 pipeline_rendering_info.depthAttachmentFormat = depthStencilFormat;
867
868 samples_info.colorAttachmentCount = 0;
869 samples_info.pColorAttachmentSamples = nullptr;
ziga-lunarga3cc8482022-04-29 14:58:29 +0200870 samples_info.depthStencilAttachmentSamples = counts[0];
stusmith15f24a82021-12-24 15:21:19 +0000871
872 auto create_info2 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
873 pipe2.InitGraphicsPipelineCreateInfo(&create_info2);
874 create_info2.pNext = &pipeline_rendering_info;
875
876 pipe2.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info2);
877
878 VkPipelineObj pipe3(m_device);
879
880 pipe3.AddShader(&vs);
881 pipe3.AddShader(&fs);
882 pipe3.AddDefaultColorAttachment();
883 pipe3.SetViewport(m_viewports);
884 pipe3.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600885 pipe3.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000886
887 pipeline_rendering_info.colorAttachmentCount = 0;
888 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
889 pipeline_rendering_info.stencilAttachmentFormat = depthStencilFormat;
890
891 auto create_info3 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
892 pipe3.InitGraphicsPipelineCreateInfo(&create_info3);
893 create_info3.pNext = &pipeline_rendering_info;
894
895 pipe3.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info3);
896
897 VkImageObj colorImage(m_device);
898 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
899 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UNORM);
900
901 VkImageObj depthStencilImage(m_device);
902 depthStencilImage.Init(32, 32, 1, depthStencilFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
903 VkImageView depthStencilImageView =
904 depthStencilImage.targetView(depthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
905
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800906 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000907 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
908 color_attachment.imageView = colorImageView;
909
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800910 VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000911 depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
912 depth_stencil_attachment.imageView = depthStencilImageView;
913
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800914 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000915 m_commandBuffer->begin();
916
917 // Mismatching color samples
918 begin_rendering_info.colorAttachmentCount = 1;
919 begin_rendering_info.pColorAttachments = &color_attachment;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600920 begin_rendering_info.layerCount = 1;
stusmith15f24a82021-12-24 15:21:19 +0000921 m_commandBuffer->BeginRendering(begin_rendering_info);
922 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
923 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06185");
924 m_commandBuffer->Draw(1, 1, 0, 0);
925 m_errorMonitor->VerifyFound();
926 m_commandBuffer->EndRendering();
927
928 // Mismatching depth samples
929 begin_rendering_info.colorAttachmentCount = 0;
930 begin_rendering_info.pColorAttachments = nullptr;
931 begin_rendering_info.pDepthAttachment = &depth_stencil_attachment;
932 m_commandBuffer->BeginRendering(begin_rendering_info);
933 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.handle());
934 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06186");
935 m_commandBuffer->Draw(1, 1, 0, 0);
936 m_errorMonitor->VerifyFound();
937 m_commandBuffer->EndRendering();
938
939 // Mismatching stencil samples
940 begin_rendering_info.pDepthAttachment = nullptr;
941 begin_rendering_info.pStencilAttachment = &depth_stencil_attachment;
942 m_commandBuffer->BeginRendering(begin_rendering_info);
943 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe3.handle());
944 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06187");
945 m_commandBuffer->Draw(1, 1, 0, 0);
946 m_errorMonitor->VerifyFound();
947 m_commandBuffer->EndRendering();
948
949 m_commandBuffer->end();
950}
Aaron Hagan80034ea2021-12-23 11:24:09 -0500951
952TEST_F(VkLayerTest, DynamicRenderingAttachmentInfo) {
953 TEST_DESCRIPTION("AttachmentInfo Dynamic Rendering Tests.");
954
arno1689b372022-08-25 19:34:15 +0200955 SetTargetApiVersion(VK_API_VERSION_1_2);
Aaron Hagan80034ea2021-12-23 11:24:09 -0500956
957 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
958
959 ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor));
960
961 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900962 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
Aaron Hagan80034ea2021-12-23 11:24:09 -0500963 }
964
sjfricked700bc02022-05-30 16:35:06 +0900965 if (!AreRequiredExtensionsEnabled()) {
966 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
Aaron Hagan80034ea2021-12-23 11:24:09 -0500967 }
968
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600969 auto fdm_features = LvlInitStruct<VkPhysicalDeviceFragmentDensityMapFeaturesEXT>();
970 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(&fdm_features);
971 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
Aaron Hagan80034ea2021-12-23 11:24:09 -0500972 if (!dynamic_rendering_features.dynamicRendering) {
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600973 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering , skipping";
974 }
975 if (!fdm_features.fragmentDensityMapNonSubsampledImages) {
976 GTEST_SKIP() << "fragmentDensityMapNonSubsampledImages not supported.";
Aaron Hagan80034ea2021-12-23 11:24:09 -0500977 }
978
979 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
980
981 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
982 VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT);
983
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600984 auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
985
Aaron Hagan80034ea2021-12-23 11:24:09 -0500986 VkPipelineObj pipe(m_device);
987 pipe.AddShader(&vs);
988 pipe.AddShader(&fs);
989 pipe.AddDefaultColorAttachment();
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600990 pipe.SetDepthStencil(&ds_state);
Aaron Hagan80034ea2021-12-23 11:24:09 -0500991
992 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
993 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
994 const VkPipelineLayoutObj pl(m_device, {&dsl});
995
996 VkFormat depth_format = VK_FORMAT_D32_SFLOAT_S8_UINT;
997 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
998 pipeline_rendering_info.depthAttachmentFormat = depth_format;
999
1000 auto pipeline_create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
1001 pipe.InitGraphicsPipelineCreateInfo(&pipeline_create_info);
1002 pipeline_create_info.pNext = &pipeline_rendering_info;
1003
1004 VkResult err = pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &pipeline_create_info);
1005 ASSERT_VK_SUCCESS(err);
1006
1007 VkImageObj image(m_device);
1008 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
1009 image_create_info.imageType = VK_IMAGE_TYPE_2D;
1010 image_create_info.format = depth_format;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001011 image_create_info.extent = {64, 64, 1};
Aaron Hagan80034ea2021-12-23 11:24:09 -05001012 image_create_info.mipLevels = 1;
1013 image_create_info.arrayLayers = 1;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001014 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
Aaron Hagan80034ea2021-12-23 11:24:09 -05001015 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
ziga-lunarga3cc8482022-04-29 14:58:29 +02001016 image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT;
Aaron Hagan80034ea2021-12-23 11:24:09 -05001017 image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
1018
1019 image.Init(image_create_info);
1020 ASSERT_TRUE(image.initialized());
1021
1022 VkImageViewCreateInfo ivci = {VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
1023 nullptr,
1024 0,
1025 image.handle(),
1026 VK_IMAGE_VIEW_TYPE_2D,
1027 depth_format,
1028 {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
1029 VK_COMPONENT_SWIZZLE_IDENTITY},
1030 {VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, 0, 1, 0, 1}};
1031
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001032 VkImageView depth_image_view = image.targetView(ivci);
1033 ASSERT_NE(depth_image_view, VK_NULL_HANDLE);
Aaron Hagan80034ea2021-12-23 11:24:09 -05001034
1035 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1036 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
1037 depth_attachment.imageView = depth_image_view;
1038 depth_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
1039 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
1040
1041 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
1042 begin_rendering_info.pDepthAttachment = &depth_attachment;
1043 begin_rendering_info.viewMask = 0x4;
1044
1045 VkRenderingFragmentDensityMapAttachmentInfoEXT fragment_density_map =
1046 LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
1047 fragment_density_map.imageView = depth_image_view;
ziga-lunarga3cc8482022-04-29 14:58:29 +02001048 fragment_density_map.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
Aaron Hagan80034ea2021-12-23 11:24:09 -05001049 begin_rendering_info.pNext = &fragment_density_map;
1050
1051 m_commandBuffer->begin();
1052 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-multiview-06127");
Jeremy Gebben09c1a072022-02-08 09:42:47 -07001053 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06107");
1054 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06108");
1055 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06116");
Jeremy Gebben09c1a072022-02-08 09:42:47 -07001056 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06145");
1057 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06146");
Aaron Hagan80034ea2021-12-23 11:24:09 -05001058 m_commandBuffer->BeginRendering(begin_rendering_info);
1059 m_errorMonitor->VerifyFound();
1060}
Aaron Haganb54466d2022-02-18 15:02:54 -05001061
1062TEST_F(VkLayerTest, DynamicRenderingBufferBeginInfoLegacy) {
1063 TEST_DESCRIPTION("VkCommandBufferBeginInfo Dynamic Rendering Tests.");
1064
arno1689b372022-08-25 19:34:15 +02001065 SetTargetApiVersion(VK_API_VERSION_1_2);
Aaron Haganb54466d2022-02-18 15:02:54 -05001066
1067 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1068
1069 ASSERT_NO_FATAL_FAILURE(Init(nullptr, nullptr, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1070
1071 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001072 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
Aaron Haganb54466d2022-02-18 15:02:54 -05001073 }
1074
sjfricked700bc02022-05-30 16:35:06 +09001075 if (!AreRequiredExtensionsEnabled()) {
1076 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
Aaron Haganb54466d2022-02-18 15:02:54 -05001077 }
1078
1079 auto cmd_buffer_inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>();
1080 cmd_buffer_inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
1081
1082 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
1083 cmd_buffer_inheritance_info.pNext = &cmd_buffer_inheritance_rendering_info;
1084 cmd_buffer_inheritance_info.renderPass = VK_NULL_HANDLE;
1085
1086 auto cmd_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>();
1087 cmd_buffer_allocate_info.commandPool = m_commandPool->handle();
1088 cmd_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY;
1089 cmd_buffer_allocate_info.commandBufferCount = 0x1;
1090
1091 VkCommandBuffer secondary_cmd_buffer;
1092 VkResult err = vk::AllocateCommandBuffers(m_device->device(), &cmd_buffer_allocate_info, &secondary_cmd_buffer);
1093 ASSERT_VK_SUCCESS(err);
1094
1095 // Invalid RenderPass
1096 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-00053");
1097 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
1098 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
1099 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
1100 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
1101 m_errorMonitor->VerifyFound();
1102
1103 // Valid RenderPass
1104 VkAttachmentDescription attach[] = {
1105 {0, VK_FORMAT_B8G8R8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE,
1106 VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_IMAGE_LAYOUT_UNDEFINED,
1107 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL},
1108 };
1109 VkAttachmentReference att_ref = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL};
1110
1111 VkSubpassDescription subpass = {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &att_ref, nullptr, nullptr, 0, nullptr};
1112 VkRenderPassCreateInfo rpci = {VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, 0, 1, attach, 1, &subpass, 0, nullptr};
1113
1114 vk_testing::RenderPass rp1;
1115 rp1.init(*m_device, rpci);
1116
1117 cmd_buffer_inheritance_info.renderPass = rp1.handle();
1118 cmd_buffer_inheritance_info.subpass = 0x5;
1119 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-00054");
1120 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
1121 m_errorMonitor->VerifyFound();
1122}
1123
1124TEST_F(VkLayerTest, DynamicRenderingSecondaryCommandBuffer) {
1125 TEST_DESCRIPTION("VkCommandBufferBeginInfo Dynamic Rendering Tests.");
1126
arno1689b372022-08-25 19:34:15 +02001127 SetTargetApiVersion(VK_API_VERSION_1_3);
Aaron Haganb54466d2022-02-18 15:02:54 -05001128
1129 ASSERT_NO_FATAL_FAILURE(Init());
1130
1131 if (DeviceValidationVersion() < VK_API_VERSION_1_3) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001132 GTEST_SKIP() << "At least Vulkan version 1.3 is required";
Aaron Haganb54466d2022-02-18 15:02:54 -05001133 }
1134
1135 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
1136
1137 // Force the failure by not setting the Renderpass and Framebuffer fields
1138 VkCommandBufferInheritanceInfo cmd_buf_hinfo = LvlInitStruct<VkCommandBufferInheritanceInfo>();
1139 cmd_buf_hinfo.renderPass = VkRenderPass(0x1);
1140 VkCommandBufferBeginInfo cmd_buf_info = LvlInitStruct<VkCommandBufferBeginInfo>();
1141 cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
1142 cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo;
1143
1144 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06000");
1145 vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info);
1146 m_errorMonitor->VerifyFound();
1147
1148 // Valid RenderPass
1149 VkAttachmentDescription attach[] = {
1150 {0, VK_FORMAT_B8G8R8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE,
1151 VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_IMAGE_LAYOUT_UNDEFINED,
1152 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL},
1153 };
1154 VkAttachmentReference att_ref = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL};
1155
1156 VkSubpassDescription subpass = {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &att_ref, nullptr, nullptr, 0, nullptr};
1157 VkRenderPassCreateInfo rpci = {VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, 0, 1, attach, 1, &subpass, 0, nullptr};
1158
1159 vk_testing::RenderPass rp1;
1160 rp1.init(*m_device, rpci);
1161
1162 cmd_buf_hinfo.renderPass = rp1.handle();
1163 cmd_buf_hinfo.subpass = 0x5;
1164 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06001");
1165 vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info);
1166 m_errorMonitor->VerifyFound();
1167
1168 cmd_buf_hinfo.renderPass = VK_NULL_HANDLE;
1169 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06002");
1170 vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info);
1171 m_errorMonitor->VerifyFound();
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001172}
1173
1174TEST_F(VkLayerTest, TestDynamicRenderingPipelineMissingFlags) {
1175 TEST_DESCRIPTION("Test dynamic rendering with pipeline missing flags.");
1176
1177 SetTargetApiVersion(VK_API_VERSION_1_1);
1178 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001179 AddOptionalExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1180 AddOptionalExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001181
1182 ASSERT_NO_FATAL_FAILURE(InitFramework());
1183
1184 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001185 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001186 }
1187
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001188 if (!IsExtensionsEnabled(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
sjfricked700bc02022-05-30 16:35:06 +09001189 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001190 }
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001191 bool fragment_density = IsExtensionsEnabled(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1192 bool shading_rate = IsExtensionsEnabled(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001193
1194 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09001195 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001196 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001197 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001198 }
1199
1200 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
1201
1202 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
sjfricke74a1aad2022-08-17 14:41:33 +09001203 GetPhysicalDeviceProperties2(phys_dev_props_2);
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001204
1205 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1206 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
1207
1208 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
1209 ASSERT_TRUE(depthStencilFormat != 0);
1210
1211 VkImageObj image(m_device);
1212 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
1213 image_create_info.imageType = VK_IMAGE_TYPE_2D;
1214 image_create_info.format = depthStencilFormat;
1215 image_create_info.extent = {64, 64, 1};
1216 image_create_info.mipLevels = 1;
1217 image_create_info.arrayLayers = 1;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001218 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001219 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
Tony-LunarGbc7a5372022-08-16 08:53:14 -06001220 image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001221 image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
1222
Tony-LunarGbc7a5372022-08-16 08:53:14 -06001223 if (shading_rate) image_create_info.usage |= VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR;
1224
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001225 image.Init(image_create_info);
1226 ASSERT_TRUE(image.initialized());
1227
1228 VkImageViewCreateInfo ivci = {VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
1229 nullptr,
1230 0,
1231 image.handle(),
1232 VK_IMAGE_VIEW_TYPE_2D,
1233 depthStencilFormat,
1234 {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
1235 VK_COMPONENT_SWIZZLE_IDENTITY},
1236 {VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, 0, 1, 0, 1}};
1237
1238 vk_testing::ImageView depth_image_view;
1239 depth_image_view.init(*m_device, ivci);
1240
1241 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1242 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1243
1244 if (shading_rate) {
1245 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-imageView-06183");
1246 VkRenderingFragmentShadingRateAttachmentInfoKHR fragment_shading_rate =
1247 LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
1248 fragment_shading_rate.imageView = depth_image_view.handle();
1249 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1250 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
1251
1252 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
ziga-lunargaa97cbb2022-03-18 19:06:35 +01001253 begin_rendering_info.layerCount = 1;
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001254 begin_rendering_info.colorAttachmentCount = 1;
1255 begin_rendering_info.pColorAttachments = &color_attachment;
1256
1257 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
1258
1259 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
1260 pipeline_rendering_info.colorAttachmentCount = 1;
1261 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
1262
1263 CreatePipelineHelper pipe(*this);
1264 pipe.InitInfo();
1265 pipe.gp_ci_.pNext = &pipeline_rendering_info;
1266 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
1267 pipe.InitState();
1268 pipe.CreateGraphicsPipeline();
1269
1270 m_commandBuffer->begin();
1271 m_commandBuffer->BeginRendering(begin_rendering_info);
1272 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_);
1273 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
1274 m_commandBuffer->EndRendering();
1275 m_commandBuffer->end();
1276
1277 m_errorMonitor->VerifyFound();
1278 }
1279
1280 if (fragment_density) {
1281 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-imageView-06184");
1282 VkRenderingFragmentDensityMapAttachmentInfoEXT fragment_density_map =
1283 LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
1284 fragment_density_map.imageView = depth_image_view.handle();
1285
1286 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_density_map);
ziga-lunargaa97cbb2022-03-18 19:06:35 +01001287 begin_rendering_info.layerCount = 1;
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001288 begin_rendering_info.colorAttachmentCount = 1;
1289 begin_rendering_info.pColorAttachments = &color_attachment;
1290
1291 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
1292
1293 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
1294 pipeline_rendering_info.colorAttachmentCount = 1;
1295 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
1296
1297 CreatePipelineHelper pipe(*this);
1298 pipe.InitInfo();
1299 pipe.gp_ci_.pNext = &pipeline_rendering_info;
1300 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
1301 pipe.InitState();
1302 pipe.CreateGraphicsPipeline();
1303
1304 m_commandBuffer->begin();
1305 m_commandBuffer->BeginRendering(begin_rendering_info);
1306 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_);
1307 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
1308 m_commandBuffer->EndRendering();
1309 m_commandBuffer->end();
1310
1311 m_errorMonitor->VerifyFound();
1312 }
1313}
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001314
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001315TEST_F(VkLayerTest, DynamicRenderingLayerCount) {
1316 TEST_DESCRIPTION("Test dynamic rendering with viewMask 0 and invalid layer count.");
1317
1318 SetTargetApiVersion(VK_API_VERSION_1_1);
1319 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1320
1321 ASSERT_NO_FATAL_FAILURE(InitFramework());
1322
1323 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001324 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001325 }
1326
1327 if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
sjfricked700bc02022-05-30 16:35:06 +09001328 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001329 }
1330
1331 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09001332 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001333 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001334 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001335 }
1336
1337 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1338
1339 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
1340
1341 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-viewMask-06069");
1342 m_commandBuffer->begin();
1343 m_commandBuffer->BeginRendering(begin_rendering_info);
1344 m_commandBuffer->end();
1345 m_errorMonitor->VerifyFound();
1346}
1347
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001348TEST_F(VkLayerTest, TestRenderingInfoMismatchedSamples) {
1349 TEST_DESCRIPTION("Test beginning rendering with mismatched sample counts.");
1350
1351 SetTargetApiVersion(VK_API_VERSION_1_1);
1352 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1353
1354 ASSERT_NO_FATAL_FAILURE(InitFramework());
1355
1356 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001357 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001358 }
1359
1360 if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
sjfricked700bc02022-05-30 16:35:06 +09001361 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001362 }
1363
1364 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09001365 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001366 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001367 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001368 }
1369
1370 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1371
1372 VkImageCreateInfo image_ci = LvlInitStruct<VkImageCreateInfo>();
1373 image_ci.imageType = VK_IMAGE_TYPE_2D;
1374 image_ci.format = VK_FORMAT_R8G8B8A8_UNORM;
1375 image_ci.extent.width = 64;
1376 image_ci.extent.height = 64;
1377 image_ci.extent.depth = 1;
1378 image_ci.mipLevels = 1;
1379 image_ci.arrayLayers = 1;
1380 image_ci.samples = VK_SAMPLE_COUNT_2_BIT;
1381 image_ci.tiling = VK_IMAGE_TILING_OPTIMAL;
1382 image_ci.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
1383
1384 VkImageObj color_image(m_device);
1385 color_image.init(&image_ci);
1386
1387 VkImageViewCreateInfo civ_ci = LvlInitStruct<VkImageViewCreateInfo>();
1388 civ_ci.image = color_image.handle();
1389 civ_ci.viewType = VK_IMAGE_VIEW_TYPE_2D;
1390 civ_ci.format = VK_FORMAT_R8G8B8A8_UNORM;
1391 civ_ci.subresourceRange.layerCount = 1;
1392 civ_ci.subresourceRange.baseMipLevel = 0;
1393 civ_ci.subresourceRange.levelCount = 1;
1394 civ_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
1395
1396 vk_testing::ImageView color_image_view;
1397 color_image_view.init(*m_device, civ_ci);
1398
1399 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1400 color_attachment.imageView = color_image_view.handle();
1401 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1402 color_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
1403
1404 const VkFormat depth_format = FindSupportedDepthOnlyFormat(gpu());
1405 if (depth_format == VK_FORMAT_UNDEFINED) {
1406 printf("%s requires a depth only format, skipping.\n", kSkipPrefix);
1407 return;
1408 }
1409
1410 VkImageObj depth_image(m_device);
1411 depth_image.Init(64, 64, 1, depth_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL);
1412
1413 VkImageViewCreateInfo div_ci = LvlInitStruct<VkImageViewCreateInfo>();
1414 div_ci.image = depth_image.handle();
1415 div_ci.viewType = VK_IMAGE_VIEW_TYPE_2D;
1416 div_ci.format = depth_format;
1417 div_ci.subresourceRange.layerCount = 1;
1418 div_ci.subresourceRange.baseMipLevel = 0;
1419 div_ci.subresourceRange.levelCount = 1;
1420 div_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
1421
1422 vk_testing::ImageView depth_image_view;
1423 depth_image_view.init(*m_device, div_ci);
1424
1425 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1426 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1427 depth_attachment.imageView = depth_image_view.handle();
1428 depth_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
1429
1430 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
ziga-lunargaa97cbb2022-03-18 19:06:35 +01001431 begin_rendering_info.layerCount = 1;
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001432 begin_rendering_info.colorAttachmentCount = 1;
1433 begin_rendering_info.pColorAttachments = &color_attachment;
1434 begin_rendering_info.pDepthAttachment = &depth_attachment;
1435
Tony-LunarG7384f7e2022-07-05 14:20:42 -06001436 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-multisampledRenderToSingleSampled-06857");
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001437 m_commandBuffer->BeginRendering(begin_rendering_info);
1438 m_errorMonitor->VerifyFound();
1439}
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001440
ziga-lunargb7fec142022-03-18 22:08:17 +01001441TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRate) {
1442 TEST_DESCRIPTION("Test BeginRenderingInfo with FragmentShadingRateAttachment.");
1443
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001444 SetTargetApiVersion(VK_API_VERSION_1_2);
ziga-lunargb7fec142022-03-18 22:08:17 +01001445 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1446 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
1447
1448 ASSERT_NO_FATAL_FAILURE(InitFramework());
1449
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001450 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
1451 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
ziga-lunargb7fec142022-03-18 22:08:17 +01001452 }
1453
sjfricked700bc02022-05-30 16:35:06 +09001454 if (!AreRequiredExtensionsEnabled()) {
1455 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargb7fec142022-03-18 22:08:17 +01001456 }
1457
1458 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1459 auto features11 = LvlInitStruct<VkPhysicalDeviceVulkan11Features>(&dynamic_rendering_features);
sjfricke11db0c72022-08-18 13:23:11 +09001460 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(features11);
ziga-lunargb7fec142022-03-18 22:08:17 +01001461
1462 if (features11.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001463 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunargb7fec142022-03-18 22:08:17 +01001464 }
1465 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001466 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargb7fec142022-03-18 22:08:17 +01001467 }
1468
1469 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
1470
1471 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
sjfricke74a1aad2022-08-17 14:41:33 +09001472 GetPhysicalDeviceProperties2(phys_dev_props_2);
ziga-lunargb7fec142022-03-18 22:08:17 +01001473
1474 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1475 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
1476
1477 auto image_ci = LvlInitStruct<VkImageCreateInfo>(nullptr);
1478 image_ci.imageType = VK_IMAGE_TYPE_2D;
1479 image_ci.format = VK_FORMAT_R8G8B8A8_UNORM;
1480 image_ci.extent.width = 32;
1481 image_ci.extent.height = 32;
1482 image_ci.extent.depth = 1;
1483 image_ci.mipLevels = 1;
1484 image_ci.arrayLayers = 2;
1485 image_ci.samples = VK_SAMPLE_COUNT_1_BIT;
1486 image_ci.tiling = VK_IMAGE_TILING_OPTIMAL;
ziga-lunargade1d9e2022-04-25 10:59:15 +02001487 image_ci.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR;
ziga-lunargb7fec142022-03-18 22:08:17 +01001488
1489 VkImageObj image(m_device);
1490 image.init(&image_ci);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001491 VkImageView image_view =
1492 image.targetView(VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 2, VK_IMAGE_VIEW_TYPE_2D_ARRAY);
ziga-lunargb7fec142022-03-18 22:08:17 +01001493
ziga-lunargade1d9e2022-04-25 10:59:15 +02001494 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
ziga-lunargb7fec142022-03-18 22:08:17 +01001495 fragment_shading_rate.imageView = image_view;
1496 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1497 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
1498
1499 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
1500 begin_rendering_info.layerCount = 4;
1501
1502 m_commandBuffer->begin();
1503
1504 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06123");
1505 m_commandBuffer->BeginRendering(begin_rendering_info);
1506 m_errorMonitor->VerifyFound();
1507
1508 begin_rendering_info.viewMask = 0xF;
1509 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06124");
1510 m_commandBuffer->BeginRendering(begin_rendering_info);
1511 m_errorMonitor->VerifyFound();
1512
ziga-lunargade1d9e2022-04-25 10:59:15 +02001513 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1514 color_attachment.imageView = image_view;
1515 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1516
1517 begin_rendering_info.layerCount = 2;
1518 begin_rendering_info.colorAttachmentCount = 1;
1519 begin_rendering_info.pColorAttachments = &color_attachment;
1520 begin_rendering_info.viewMask = 0;
1521 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06125");
1522 m_commandBuffer->BeginRendering(begin_rendering_info);
1523 m_errorMonitor->VerifyFound();
1524
ziga-lunargb7fec142022-03-18 22:08:17 +01001525 m_commandBuffer->end();
ziga-lunargb7fec142022-03-18 22:08:17 +01001526}
1527
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001528TEST_F(VkLayerTest, TestDeviceGroupRenderPassBeginInfo) {
1529 TEST_DESCRIPTION("Test render area of DeviceGroupRenderPassBeginInfo.");
1530
1531 SetTargetApiVersion(VK_API_VERSION_1_1);
1532 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1533
1534 ASSERT_NO_FATAL_FAILURE(InitFramework());
1535
1536 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001537 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001538 }
1539
1540 if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
sjfricked700bc02022-05-30 16:35:06 +09001541 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001542 }
1543
1544 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09001545 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001546 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001547 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001548 }
1549
1550 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1551
1552 VkRect2D render_area = {};
1553 render_area.offset.x = 0;
1554 render_area.offset.y = 0;
1555 render_area.extent.width = 32;
1556 render_area.extent.height = 32;
1557
1558 auto device_group_render_pass_begin_info = LvlInitStruct<VkDeviceGroupRenderPassBeginInfo>();
1559 device_group_render_pass_begin_info.deviceRenderAreaCount = 1;
1560 device_group_render_pass_begin_info.pDeviceRenderAreas = &render_area;
1561
1562 VkImageObj colorImage(m_device);
1563 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
1564 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
1565
1566 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1567 color_attachment.imageView = colorImageView;
1568 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1569
1570 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&device_group_render_pass_begin_info);
ziga-lunarg1fec6332022-03-20 14:39:54 +01001571 begin_rendering_info.layerCount = 1;
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001572 begin_rendering_info.colorAttachmentCount = 1;
1573 begin_rendering_info.pColorAttachments = &color_attachment;
1574
1575 m_commandBuffer->begin();
1576
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001577 m_commandBuffer->BeginRendering(begin_rendering_info);
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001578
1579 render_area.offset.x = 1;
1580 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06083");
1581 m_commandBuffer->BeginRendering(begin_rendering_info);
1582 m_errorMonitor->VerifyFound();
1583
1584 render_area.offset.x = 0;
1585 render_area.offset.y = 16;
1586 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06084");
1587 m_commandBuffer->BeginRendering(begin_rendering_info);
1588 m_errorMonitor->VerifyFound();
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001589}
1590
ziga-lunarg184a20b2022-03-18 20:54:48 +01001591TEST_F(VkLayerTest, TestBeginRenderingInvalidFragmentShadingRateImage) {
1592 TEST_DESCRIPTION("Test BeginRendering with FragmentShadingRateAttachmentInfo with missing image usage bit.");
1593
1594 SetTargetApiVersion(VK_API_VERSION_1_1);
1595 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1596 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
1597
1598 ASSERT_NO_FATAL_FAILURE(InitFramework());
1599
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001600 if (IsDriver(VK_DRIVER_ID_AMD_PROPRIETARY)) {
1601 GTEST_SKIP() << "Skipping on AMD proprietary driver pending further investigation.";
1602 }
1603
ziga-lunarg184a20b2022-03-18 20:54:48 +01001604 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001605 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg184a20b2022-03-18 20:54:48 +01001606 }
1607
sjfricked700bc02022-05-30 16:35:06 +09001608 if (!AreRequiredExtensionsEnabled()) {
1609 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg184a20b2022-03-18 20:54:48 +01001610 }
1611
1612 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09001613 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg184a20b2022-03-18 20:54:48 +01001614 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001615 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg184a20b2022-03-18 20:54:48 +01001616 }
1617 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1618
1619 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
1620 auto properties2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
sjfricke74a1aad2022-08-17 14:41:33 +09001621 GetPhysicalDeviceProperties2(properties2);
ziga-lunarg184a20b2022-03-18 20:54:48 +01001622
1623 VkImageObj image(m_device);
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001624 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT,
1625 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR);
ziga-lunarg184a20b2022-03-18 20:54:48 +01001626 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
1627
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001628 VkImageObj invalid_image(m_device);
1629 invalid_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
1630 VkImageView invalid_image_view = invalid_image.targetView(VK_FORMAT_R8G8B8A8_UINT);
1631
ziga-lunarg184a20b2022-03-18 20:54:48 +01001632 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001633 fragment_shading_rate.imageView = invalid_image_view;
ziga-lunarg184a20b2022-03-18 20:54:48 +01001634 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1635 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
1636
1637 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001638 begin_rendering_info.layerCount = 1;
1639
1640 m_commandBuffer->begin();
ziga-lunarg184a20b2022-03-18 20:54:48 +01001641
1642 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06148");
ziga-lunarg184a20b2022-03-18 20:54:48 +01001643 m_commandBuffer->BeginRendering(begin_rendering_info);
ziga-lunarg184a20b2022-03-18 20:54:48 +01001644 m_errorMonitor->VerifyFound();
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001645 fragment_shading_rate.imageView = image_view;
1646
1647 fragment_shading_rate.shadingRateAttachmentTexelSize.width = fsr_properties.minFragmentShadingRateAttachmentTexelSize.width + 1;
1648 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06149");
1649 if (fragment_shading_rate.shadingRateAttachmentTexelSize.width >
1650 fsr_properties.minFragmentShadingRateAttachmentTexelSize.width) {
1651 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06150");
1652 }
1653 m_commandBuffer->BeginRendering(begin_rendering_info);
1654 m_errorMonitor->VerifyFound();
1655
1656 if (fsr_properties.minFragmentShadingRateAttachmentTexelSize.width > 1) {
1657 fragment_shading_rate.shadingRateAttachmentTexelSize.width =
1658 fsr_properties.minFragmentShadingRateAttachmentTexelSize.width / 2;
1659 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06151");
1660 if (fragment_shading_rate.shadingRateAttachmentTexelSize.height /
1661 fragment_shading_rate.shadingRateAttachmentTexelSize.width >=
1662 fsr_properties.maxFragmentShadingRateAttachmentTexelSizeAspectRatio) {
1663 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06156");
1664 }
1665 m_commandBuffer->BeginRendering(begin_rendering_info);
1666 m_errorMonitor->VerifyFound();
1667 }
1668
1669 fragment_shading_rate.shadingRateAttachmentTexelSize.width = fsr_properties.minFragmentShadingRateAttachmentTexelSize.width;
1670
1671 fragment_shading_rate.shadingRateAttachmentTexelSize.height =
1672 fsr_properties.minFragmentShadingRateAttachmentTexelSize.height + 1;
1673 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06152");
1674 if (fragment_shading_rate.shadingRateAttachmentTexelSize.height >
1675 fsr_properties.minFragmentShadingRateAttachmentTexelSize.height) {
1676 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06153");
1677 }
1678 m_commandBuffer->BeginRendering(begin_rendering_info);
1679 m_errorMonitor->VerifyFound();
1680
1681 if (fsr_properties.minFragmentShadingRateAttachmentTexelSize.height > 1) {
1682 fragment_shading_rate.shadingRateAttachmentTexelSize.height =
1683 fsr_properties.minFragmentShadingRateAttachmentTexelSize.height / 2;
1684 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06154");
1685 if (fragment_shading_rate.shadingRateAttachmentTexelSize.width /
1686 fragment_shading_rate.shadingRateAttachmentTexelSize.height >
1687 fsr_properties.maxFragmentShadingRateAttachmentTexelSizeAspectRatio) {
1688 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06155");
1689 }
1690 m_commandBuffer->BeginRendering(begin_rendering_info);
1691 m_errorMonitor->VerifyFound();
1692 }
1693
1694 m_commandBuffer->end();
ziga-lunarg184a20b2022-03-18 20:54:48 +01001695}
1696
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001697TEST_F(VkLayerTest, BeginRenderingInvalidDepthAttachmentFormat) {
1698 TEST_DESCRIPTION("Test begin rendering with a depth attachment that has an invalid format");
1699
1700 SetTargetApiVersion(VK_API_VERSION_1_3);
1701 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1702
1703 ASSERT_NO_FATAL_FAILURE(InitFramework());
1704
1705 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001706 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001707 }
1708
sjfricked700bc02022-05-30 16:35:06 +09001709 if (!AreRequiredExtensionsEnabled()) {
1710 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001711 }
1712
1713 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09001714 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001715 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001716 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001717 }
1718
1719 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1720
1721 VkFormat stencil_format = FindSupportedStencilOnlyFormat(gpu());
1722 if (stencil_format == VK_FORMAT_UNDEFINED) {
1723 printf("%s requires a stencil only format format.\n", kSkipPrefix);
1724 return;
1725 }
1726
1727 VkImageObj image(m_device);
1728 image.Init(32, 32, 1, stencil_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
1729 VkImageView image_view = image.targetView(stencil_format, VK_IMAGE_ASPECT_STENCIL_BIT);
1730
1731 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1732 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
1733 depth_attachment.imageView = image_view;
1734
1735 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
ziga-lunarg1fec6332022-03-20 14:39:54 +01001736 begin_rendering_info.layerCount = 1;
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001737 begin_rendering_info.pDepthAttachment = &depth_attachment;
1738
1739 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06547");
1740 m_commandBuffer->BeginRendering(begin_rendering_info);
1741 m_errorMonitor->VerifyFound();
1742}
ziga-lunarg4b5bb5b2022-03-20 00:49:04 +01001743
ziga-lunarg14a69782022-03-20 00:39:31 +01001744TEST_F(VkLayerTest, TestFragmentDensityMapRenderArea) {
1745 TEST_DESCRIPTION("Validate VkRenderingFragmentDensityMapAttachmentInfo attachment image view extent.");
1746
1747 SetTargetApiVersion(VK_API_VERSION_1_1);
1748 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1749 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1750
1751 ASSERT_NO_FATAL_FAILURE(InitFramework());
1752
1753 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001754 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg14a69782022-03-20 00:39:31 +01001755 }
1756
sjfricked700bc02022-05-30 16:35:06 +09001757 if (!AreRequiredExtensionsEnabled()) {
1758 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg14a69782022-03-20 00:39:31 +01001759 }
1760
1761 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09001762 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg14a69782022-03-20 00:39:31 +01001763 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001764 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg14a69782022-03-20 00:39:31 +01001765 }
1766
1767 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1768
1769 auto fdm_props = LvlInitStruct<VkPhysicalDeviceFragmentDensityMapPropertiesEXT>();
1770 auto props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fdm_props);
sjfricke74a1aad2022-08-17 14:41:33 +09001771 GetPhysicalDeviceProperties2(props2);
ziga-lunarg14a69782022-03-20 00:39:31 +01001772
1773 VkImageObj image(m_device);
ziga-lunarg2aa8d592022-04-25 14:29:13 +02001774 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT,
1775 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT);
ziga-lunarg14a69782022-03-20 00:39:31 +01001776 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1);
1777
1778 auto fragment_density_map = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
1779 fragment_density_map.imageView = image_view;
ziga-lunarg2aa8d592022-04-25 14:29:13 +02001780 fragment_density_map.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1781
ziga-lunarg14a69782022-03-20 00:39:31 +01001782 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_density_map);
1783 begin_rendering_info.layerCount = 1;
1784 begin_rendering_info.renderArea.extent.width = 64 * fdm_props.maxFragmentDensityTexelSize.width;
1785 begin_rendering_info.renderArea.extent.height = 32 * fdm_props.maxFragmentDensityTexelSize.height;
1786
1787 m_commandBuffer->begin();
1788
1789 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06112");
1790 m_commandBuffer->BeginRendering(begin_rendering_info);
1791 m_errorMonitor->VerifyFound();
1792
1793 begin_rendering_info.renderArea.extent.width = 32 * fdm_props.maxFragmentDensityTexelSize.width;
1794 begin_rendering_info.renderArea.extent.height = 64 * fdm_props.maxFragmentDensityTexelSize.height;
1795
1796 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06114");
1797 m_commandBuffer->BeginRendering(begin_rendering_info);
1798 m_errorMonitor->VerifyFound();
1799
1800 VkRect2D device_render_area = {};
1801 device_render_area.extent.width = 64 * fdm_props.maxFragmentDensityTexelSize.width;
1802 device_render_area.extent.height = 32 * fdm_props.maxFragmentDensityTexelSize.height;
1803 auto device_group_render_pass_begin_info = LvlInitStruct<VkDeviceGroupRenderPassBeginInfo>();
1804 device_group_render_pass_begin_info.deviceRenderAreaCount = 1;
1805 device_group_render_pass_begin_info.pDeviceRenderAreas = &device_render_area;
1806 fragment_density_map.pNext = &device_group_render_pass_begin_info;
1807
1808 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06113");
1809 m_commandBuffer->BeginRendering(begin_rendering_info);
1810 m_errorMonitor->VerifyFound();
1811
1812 device_render_area.extent.width = 32 * fdm_props.maxFragmentDensityTexelSize.width;
1813 device_render_area.extent.height = 64 * fdm_props.maxFragmentDensityTexelSize.height;
1814
1815 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06115");
1816 m_commandBuffer->BeginRendering(begin_rendering_info);
1817 m_errorMonitor->VerifyFound();
1818
1819 m_commandBuffer->end();
1820}
1821
ziga-lunarg50253b92022-04-25 14:36:13 +02001822TEST_F(VkLayerTest, TestFragmentDensityMapRenderAreaWithoutDeviceGroupExt) {
1823 TEST_DESCRIPTION("Validate VkRenderingFragmentDensityMapAttachmentInfo attachment image view extent.");
1824
1825 SetTargetApiVersion(VK_API_VERSION_1_0);
1826 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1827 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1828
1829 ASSERT_NO_FATAL_FAILURE(InitFramework());
1830
1831 if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
sjfricke50955f32022-06-05 10:12:52 +09001832 GTEST_SKIP() << "Tests for 1.0 only";
ziga-lunarg50253b92022-04-25 14:36:13 +02001833 }
1834
sjfricked700bc02022-05-30 16:35:06 +09001835 if (!AreRequiredExtensionsEnabled()) {
1836 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg50253b92022-04-25 14:36:13 +02001837 }
1838
ziga-lunarg50253b92022-04-25 14:36:13 +02001839 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09001840 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg50253b92022-04-25 14:36:13 +02001841 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001842 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg50253b92022-04-25 14:36:13 +02001843 }
1844
1845 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1846
1847 auto fdm_props = LvlInitStruct<VkPhysicalDeviceFragmentDensityMapPropertiesEXT>();
1848 auto props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fdm_props);
sjfricke74a1aad2022-08-17 14:41:33 +09001849 GetPhysicalDeviceProperties2(props2);
ziga-lunarg50253b92022-04-25 14:36:13 +02001850
1851 VkImageObj image(m_device);
1852 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT,
1853 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT);
1854 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1);
1855
1856 auto fragment_density_map = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
1857 fragment_density_map.imageView = image_view;
1858 fragment_density_map.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1859
1860 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_density_map);
1861 begin_rendering_info.layerCount = 1;
1862 begin_rendering_info.renderArea.extent.width = 64 * fdm_props.maxFragmentDensityTexelSize.width;
1863 begin_rendering_info.renderArea.extent.height = 32 * fdm_props.maxFragmentDensityTexelSize.height;
1864
1865 m_commandBuffer->begin();
1866
1867 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06110");
1868 m_commandBuffer->BeginRendering(begin_rendering_info);
1869 m_errorMonitor->VerifyFound();
1870
1871 begin_rendering_info.renderArea.extent.width = 32 * fdm_props.maxFragmentDensityTexelSize.width;
1872 begin_rendering_info.renderArea.extent.height = 64 * fdm_props.maxFragmentDensityTexelSize.height;
1873
1874 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06111");
1875 m_commandBuffer->BeginRendering(begin_rendering_info);
1876 m_errorMonitor->VerifyFound();
1877
1878 m_commandBuffer->end();
1879}
1880
ziga-lunarge7279ba2022-03-31 20:55:27 +02001881TEST_F(VkLayerTest, TestBarrierWithDynamicRendering) {
1882 TEST_DESCRIPTION("Test setting buffer memory barrier when dynamic rendering is active.");
1883
1884 SetTargetApiVersion(VK_API_VERSION_1_3);
1885
1886 ASSERT_NO_FATAL_FAILURE(InitFramework());
1887
1888 if (DeviceValidationVersion() < VK_API_VERSION_1_3) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001889 GTEST_SKIP() << "At least Vulkan version 1.3 is required";
ziga-lunarge7279ba2022-03-31 20:55:27 +02001890 }
1891
1892 auto vk13features = LvlInitStruct<VkPhysicalDeviceVulkan13Features>();
sjfricke11db0c72022-08-18 13:23:11 +09001893 auto features2 = GetPhysicalDeviceFeatures2(vk13features);
ziga-lunarge7279ba2022-03-31 20:55:27 +02001894 if (!vk13features.dynamicRendering) {
1895 printf("%s Test requires (unsupported) dynamicRendering, skipping\n", kSkipPrefix);
1896 return;
1897 }
1898 if (!vk13features.synchronization2) {
1899 printf("%s Test requires (unsupported) synchronization2, skipping\n", kSkipPrefix);
1900 return;
1901 }
1902
1903 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1904 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
1905
1906 PFN_vkCmdBeginRendering vkCmdBeginRendering =
1907 reinterpret_cast<PFN_vkCmdBeginRendering>(vk::GetDeviceProcAddr(m_device->device(), "vkCmdBeginRendering"));
1908 assert(vkCmdBeginRendering != nullptr);
1909 PFN_vkCmdEndRendering vkCmdEndRendering =
1910 reinterpret_cast<PFN_vkCmdEndRendering>(vk::GetDeviceProcAddr(m_device->device(), "vkCmdEndRendering"));
1911 assert(vkCmdEndRendering != nullptr);
1912
1913 m_commandBuffer->begin();
1914
1915 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
1916 VkClearRect clear_rect = {{{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}, 0, 1};
1917 begin_rendering_info.renderArea = clear_rect.rect;
1918 begin_rendering_info.layerCount = 1;
1919
1920 vkCmdBeginRendering(m_commandBuffer->handle(), &begin_rendering_info);
1921
1922 VkBufferObj buffer;
1923 VkMemoryPropertyFlags mem_reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
1924 buffer.init_as_src_and_dst(*m_device, 256, mem_reqs);
1925
1926 auto buf_barrier = lvl_init_struct<VkBufferMemoryBarrier2KHR>();
1927 buf_barrier.buffer = buffer.handle();
1928 buf_barrier.offset = 0;
1929 buf_barrier.size = VK_WHOLE_SIZE;
1930 buf_barrier.srcStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
1931 buf_barrier.dstStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
1932
1933 auto dependency_info = lvl_init_struct<VkDependencyInfoKHR>();
1934 dependency_info.bufferMemoryBarrierCount = 1;
1935 dependency_info.pBufferMemoryBarriers = &buf_barrier;
1936 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPipelineBarrier2-None-06191");
1937 vk::CmdPipelineBarrier2(m_commandBuffer->handle(), &dependency_info);
1938 m_errorMonitor->VerifyFound();
1939
1940 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPipelineBarrier-None-06191");
1941 vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, 0,
1942 nullptr, 0, nullptr, 0, nullptr);
1943 m_errorMonitor->VerifyFound();
1944
1945 vkCmdEndRendering(m_commandBuffer->handle());
1946 m_commandBuffer->end();
1947}
1948
ziga-lunarg5e0a2452022-04-20 19:29:37 +02001949TEST_F(VkLayerTest, BeginRenderingInvalidStencilAttachmentFormat) {
1950 TEST_DESCRIPTION("Test begin rendering with a stencil attachment that has an invalid format");
1951
1952 SetTargetApiVersion(VK_API_VERSION_1_3);
1953 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1954
1955 ASSERT_NO_FATAL_FAILURE(InitFramework());
1956
1957 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
1958 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
1959 }
1960
sjfricked700bc02022-05-30 16:35:06 +09001961 if (!AreRequiredExtensionsEnabled()) {
1962 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg5e0a2452022-04-20 19:29:37 +02001963 }
1964
1965 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09001966 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg5e0a2452022-04-20 19:29:37 +02001967 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001968 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg5e0a2452022-04-20 19:29:37 +02001969 }
1970
1971 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1972
1973 VkFormat depth_format = FindSupportedDepthOnlyFormat(gpu());
1974 if (depth_format == VK_FORMAT_UNDEFINED) {
1975 printf("%s requires a stencil only format format.\n", kSkipPrefix);
1976 return;
1977 }
1978
1979 VkImageObj image(m_device);
1980 image.Init(32, 32, 1, depth_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
1981 VkImageView image_view = image.targetView(depth_format, VK_IMAGE_ASPECT_DEPTH_BIT);
1982
1983 VkRenderingAttachmentInfoKHR stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1984 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL;
1985 stencil_attachment.imageView = image_view;
1986
1987 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
1988 begin_rendering_info.layerCount = 1;
1989 begin_rendering_info.pStencilAttachment = &stencil_attachment;
1990
1991 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06548");
1992 m_commandBuffer->BeginRendering(begin_rendering_info);
1993 m_errorMonitor->VerifyFound();
1994}
1995
1996TEST_F(VkLayerTest, TestInheritanceRenderingInfoStencilAttachmentFormat) {
1997 TEST_DESCRIPTION("Test begin rendering with a stencil attachment that has an invalid format");
1998
1999 SetTargetApiVersion(VK_API_VERSION_1_3);
2000 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2001
2002 ASSERT_NO_FATAL_FAILURE(InitFramework());
2003
2004 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
2005 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
2006 }
2007
sjfricked700bc02022-05-30 16:35:06 +09002008 if (!AreRequiredExtensionsEnabled()) {
2009 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002010 }
2011
2012 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09002013 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002014 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002015 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002016 }
2017
2018 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2019
2020 VkFormat depth_format = FindSupportedDepthOnlyFormat(gpu());
2021 if (depth_format == VK_FORMAT_UNDEFINED) {
2022 printf("%s requires a stencil only format format.\n", kSkipPrefix);
2023 return;
2024 }
2025
2026 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2027
2028 auto cmd_buffer_inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>();
2029 cmd_buffer_inheritance_rendering_info.colorAttachmentCount = 1;
2030 cmd_buffer_inheritance_rendering_info.pColorAttachmentFormats = &color_format;
2031 cmd_buffer_inheritance_rendering_info.depthAttachmentFormat = depth_format;
2032 cmd_buffer_inheritance_rendering_info.stencilAttachmentFormat = depth_format;
2033 cmd_buffer_inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
2034
2035 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2036 cmd_buffer_inheritance_info.pNext = &cmd_buffer_inheritance_rendering_info;
2037 cmd_buffer_inheritance_info.renderPass = VK_NULL_HANDLE;
2038
2039 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2040 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2041 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2042
2043 auto cmd_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>();
2044 cmd_buffer_allocate_info.commandPool = m_commandPool->handle();
2045 cmd_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY;
2046 cmd_buffer_allocate_info.commandBufferCount = 1;
2047
2048 VkCommandBuffer secondary_cmd_buffer;
ziga-lunarga3cc8482022-04-29 14:58:29 +02002049 vk::AllocateCommandBuffers(m_device->device(), &cmd_buffer_allocate_info, &secondary_cmd_buffer);
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002050
2051 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-stencilAttachmentFormat-06541");
2052 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
2053 m_errorMonitor->VerifyFound();
2054}
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002055
2056TEST_F(VkLayerTest, CreateGraphicsPipelineWithInvalidAttachmentSampleCount) {
2057 TEST_DESCRIPTION("Create pipeline with fragment shader that uses samples, but multisample state not begin set");
2058
ziga-lunarg7f25dff2022-05-06 17:49:34 +02002059 SetTargetApiVersion(VK_API_VERSION_1_1);
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002060 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2061 AddRequiredExtensions(VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME);
2062
2063 ASSERT_NO_FATAL_FAILURE(InitFramework());
2064
2065 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002066 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002067 }
2068
sjfricked700bc02022-05-30 16:35:06 +09002069 if (!AreRequiredExtensionsEnabled()) {
2070 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002071 }
2072
2073 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09002074 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002075 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002076 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002077 }
2078
2079 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2080 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2081
2082 auto sample_count_info_amd = LvlInitStruct<VkAttachmentSampleCountInfoNV>();
2083 sample_count_info_amd.colorAttachmentCount = 1;
ziga-lunarg7f25dff2022-05-06 17:49:34 +02002084 sample_count_info_amd.depthStencilAttachmentSamples = static_cast<VkSampleCountFlagBits>(0x3);
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002085
2086 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(&sample_count_info_amd);
2087 pipeline_rendering_info.colorAttachmentCount = 1;
2088 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2089
2090 CreatePipelineHelper pipe(*this);
2091 pipe.InitInfo();
2092 pipe.gp_ci_.pNext = &pipeline_rendering_info;
2093 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2094 pipe.InitState();
2095
2096 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-depthStencilAttachmentSamples-06593");
2097 pipe.CreateGraphicsPipeline();
2098 m_errorMonitor->VerifyFound();
2099}
ziga-lunargd680bf22022-04-20 22:01:00 +02002100
2101TEST_F(VkLayerTest, CreatePipelineUsingDynamicRenderingWithoutFeature) {
2102 TEST_DESCRIPTION("Create graphcis pipeline that uses dynamic rendering, but feature is not enabled");
2103
2104 SetTargetApiVersion(VK_API_VERSION_1_3);
2105 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2106 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
2107
2108 ASSERT_NO_FATAL_FAILURE(InitFramework());
2109
2110 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002111 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargd680bf22022-04-20 22:01:00 +02002112 }
2113
sjfricked700bc02022-05-30 16:35:06 +09002114 if (!AreRequiredExtensionsEnabled()) {
2115 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargd680bf22022-04-20 22:01:00 +02002116 }
2117
2118 ASSERT_NO_FATAL_FAILURE(InitState());
2119
2120 CreatePipelineHelper pipe(*this);
2121 pipe.InitInfo();
2122 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2123 pipe.InitState();
2124
2125 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-dynamicRendering-06576");
2126 pipe.CreateGraphicsPipeline();
2127 m_errorMonitor->VerifyFound();
2128}
ziga-lunargf20d7952022-04-20 22:11:40 +02002129
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002130TEST_F(VkLayerTest, DynamicRenderingAreaGreaterThanAttachmentExtent) {
2131 TEST_DESCRIPTION("Begin dynamic rendering with render area greater than extent of attachments");
2132
2133 SetTargetApiVersion(VK_API_VERSION_1_0);
2134 AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
2135 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2136 ASSERT_NO_FATAL_FAILURE(InitFramework());
2137
2138 if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
sjfricke50955f32022-06-05 10:12:52 +09002139 GTEST_SKIP() << "Tests for 1.0 only";
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002140 }
sjfricked700bc02022-05-30 16:35:06 +09002141 if (!AreRequiredExtensionsEnabled()) {
2142 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002143 }
2144
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002145 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09002146 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002147 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002148 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002149 }
2150
2151 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2152
2153 VkImageObj colorImage(m_device);
2154 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
2155 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
2156
ziga-lunarga51287c2022-04-20 23:24:37 +02002157 auto color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002158 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2159 color_attachment.imageView = colorImageView;
2160
ziga-lunarga51287c2022-04-20 23:24:37 +02002161 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002162 begin_rendering_info.layerCount = 1;
2163 begin_rendering_info.colorAttachmentCount = 1;
2164 begin_rendering_info.pColorAttachments = &color_attachment;
2165 begin_rendering_info.renderArea.extent.width = 64;
2166 begin_rendering_info.renderArea.extent.height = 32;
2167
2168 m_commandBuffer->begin();
2169
2170 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06075");
2171 m_commandBuffer->BeginRendering(begin_rendering_info);
2172 m_errorMonitor->VerifyFound();
2173
2174 begin_rendering_info.renderArea.extent.width = 32;
2175 begin_rendering_info.renderArea.extent.height = 64;
2176
2177 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06076");
2178 m_commandBuffer->BeginRendering(begin_rendering_info);
2179 m_errorMonitor->VerifyFound();
2180
2181 const VkFormat ds_format = FindSupportedDepthStencilFormat(gpu());
2182 if (ds_format != VK_FORMAT_UNDEFINED) {
2183 VkImageObj depthImage(m_device);
2184 depthImage.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
2185 VkImageView depthImageView = depthImage.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT);
2186
2187 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2188 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
2189 depth_attachment.imageView = depthImageView;
2190
2191 begin_rendering_info.colorAttachmentCount = 0;
2192 begin_rendering_info.pDepthAttachment = &depth_attachment;
2193
2194 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06076");
2195 m_commandBuffer->BeginRendering(begin_rendering_info);
2196 m_errorMonitor->VerifyFound();
2197 }
2198
2199 m_commandBuffer->end();
2200}
ziga-lunarga51287c2022-04-20 23:24:37 +02002201
2202TEST_F(VkLayerTest, DynamicRenderingDeviceGroupAreaGreaterThanAttachmentExtent) {
2203 TEST_DESCRIPTION("Begin dynamic rendering with device group with render area greater than extent of attachments");
2204
2205 SetTargetApiVersion(VK_API_VERSION_1_1);
2206 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2207 ASSERT_NO_FATAL_FAILURE(InitFramework());
2208
2209 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002210 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarga51287c2022-04-20 23:24:37 +02002211 }
sjfricked700bc02022-05-30 16:35:06 +09002212 if (!AreRequiredExtensionsEnabled()) {
2213 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarga51287c2022-04-20 23:24:37 +02002214 }
2215
2216 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09002217 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarga51287c2022-04-20 23:24:37 +02002218 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002219 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarga51287c2022-04-20 23:24:37 +02002220 }
2221
2222 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2223
2224 VkImageObj colorImage(m_device);
2225 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
2226 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
2227
2228 auto color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2229 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2230 color_attachment.imageView = colorImageView;
2231
2232 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2233 begin_rendering_info.layerCount = 1;
2234 begin_rendering_info.colorAttachmentCount = 1;
2235 begin_rendering_info.pColorAttachments = &color_attachment;
2236 begin_rendering_info.renderArea.extent.width = 64;
2237 begin_rendering_info.renderArea.extent.height = 32;
2238
2239 m_commandBuffer->begin();
2240
2241 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06079");
2242 m_commandBuffer->BeginRendering(begin_rendering_info);
2243 m_errorMonitor->VerifyFound();
2244
2245 begin_rendering_info.renderArea.extent.width = 32;
2246 begin_rendering_info.renderArea.extent.height = 64;
2247
2248 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06080");
2249 m_commandBuffer->BeginRendering(begin_rendering_info);
2250 m_errorMonitor->VerifyFound();
2251
2252 const VkFormat ds_format = FindSupportedDepthStencilFormat(gpu());
2253 if (ds_format != VK_FORMAT_UNDEFINED) {
2254 VkImageObj depthImage(m_device);
2255 depthImage.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
2256 VkImageView depthImageView = depthImage.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT);
2257
2258 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2259 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
2260 depth_attachment.imageView = depthImageView;
2261
2262 begin_rendering_info.colorAttachmentCount = 0;
2263 begin_rendering_info.pDepthAttachment = &depth_attachment;
2264
2265 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06080");
2266 m_commandBuffer->BeginRendering(begin_rendering_info);
2267 m_errorMonitor->VerifyFound();
2268 }
2269
2270 m_commandBuffer->end();
2271}
ziga-lunargd4105c12022-04-21 13:54:20 +02002272
2273TEST_F(VkLayerTest, SecondaryCommandBufferIncompatibleRenderPass) {
2274 TEST_DESCRIPTION("Execute secondary command buffers within render pass instance with incompatible render pass");
2275
2276 SetTargetApiVersion(VK_API_VERSION_1_1);
2277 ASSERT_NO_FATAL_FAILURE(InitFramework());
2278
2279 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002280 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargd4105c12022-04-21 13:54:20 +02002281 }
2282
2283 ASSERT_NO_FATAL_FAILURE(InitState());
2284 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2285
ziga-lunarga3cc8482022-04-29 14:58:29 +02002286 VkSubpassDescription subpass = {};
ziga-lunargd4105c12022-04-21 13:54:20 +02002287 auto render_pass_ci = LvlInitStruct<VkRenderPassCreateInfo>();
ziga-lunarga3cc8482022-04-29 14:58:29 +02002288 render_pass_ci.subpassCount = 1;
2289 render_pass_ci.pSubpasses = &subpass;
ziga-lunargd4105c12022-04-21 13:54:20 +02002290
2291 vk_testing::RenderPass render_pass;
2292 render_pass.init(*m_device, render_pass_ci);
2293
2294 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2295 VkCommandBuffer secondary_handle = cb.handle();
2296
2297 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2298 cmd_buffer_inheritance_info.renderPass = render_pass.handle();
2299 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2300 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2301 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2302
2303 cb.begin(&cmd_buffer_begin_info);
2304 cb.end();
2305
2306 m_commandBuffer->begin();
2307 m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
2308
2309 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pBeginInfo-06020");
2310 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pInheritanceInfo-00098");
2311 vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle);
2312 m_errorMonitor->VerifyFound();
2313
2314 m_commandBuffer->EndRenderPass();
2315 m_commandBuffer->end();
2316}
ziga-lunarg590e0292022-04-21 14:07:22 +02002317
2318TEST_F(VkLayerTest, SecondaryCommandBufferIncompatibleSubpass) {
2319 TEST_DESCRIPTION("Execute secondary command buffers with different subpass");
2320
2321 SetTargetApiVersion(VK_API_VERSION_1_1);
2322 ASSERT_NO_FATAL_FAILURE(InitFramework());
2323
2324 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002325 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg590e0292022-04-21 14:07:22 +02002326 }
2327
2328 ASSERT_NO_FATAL_FAILURE(InitState());
2329
2330 VkSubpassDescription subpasses[2] = {};
2331
2332 auto render_pass_ci = LvlInitStruct<VkRenderPassCreateInfo>();
2333 render_pass_ci.subpassCount = 2;
2334 render_pass_ci.pSubpasses = subpasses;
2335
2336 vk_testing::RenderPass render_pass;
2337 render_pass.init(*m_device, render_pass_ci);
2338
2339 auto framebuffer_ci = LvlInitStruct<VkFramebufferCreateInfo>();
2340 framebuffer_ci.renderPass = render_pass.handle();
2341 framebuffer_ci.width = 32;
2342 framebuffer_ci.height = 32;
ziga-lunarg143bdbf2022-05-04 19:04:58 +02002343 framebuffer_ci.layers = 1;
ziga-lunarg590e0292022-04-21 14:07:22 +02002344
2345 vk_testing::Framebuffer framebuffer;
2346 framebuffer.init(*m_device, framebuffer_ci);
2347
2348 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2349 VkCommandBuffer secondary_handle = cb.handle();
2350
2351 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2352 cmd_buffer_inheritance_info.renderPass = render_pass.handle();
2353 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2354 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2355 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2356
2357 cb.begin(&cmd_buffer_begin_info);
2358 cb.end();
2359
2360 auto render_pass_begin_info = LvlInitStruct<VkRenderPassBeginInfo>();
2361 render_pass_begin_info.renderPass = render_pass.handle();
2362 render_pass_begin_info.renderArea.extent = {32, 32};
2363 render_pass_begin_info.framebuffer = framebuffer.handle();
2364
2365 m_commandBuffer->begin();
2366 m_commandBuffer->BeginRenderPass(render_pass_begin_info, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
2367 vk::CmdNextSubpass(m_commandBuffer->handle(), VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
2368
2369 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pCommandBuffers-00097");
2370 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pCommandBuffers-06019");
2371 vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle);
2372 m_errorMonitor->VerifyFound();
2373
2374 m_commandBuffer->EndRenderPass();
2375 m_commandBuffer->end();
2376}
ziga-lunarg343193b2022-04-21 14:15:17 +02002377
2378TEST_F(VkLayerTest, SecondaryCommandBufferInvalidContents) {
2379 TEST_DESCRIPTION("Execute secondary command buffers within active render pass that was not begun with VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS");
2380
2381 SetTargetApiVersion(VK_API_VERSION_1_1);
2382 ASSERT_NO_FATAL_FAILURE(InitFramework());
2383
2384 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002385 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg343193b2022-04-21 14:15:17 +02002386 }
2387
2388 ASSERT_NO_FATAL_FAILURE(InitState());
2389 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2390
ziga-lunarg343193b2022-04-21 14:15:17 +02002391 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2392 VkCommandBuffer secondary_handle = cb.handle();
2393
2394 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2395 cmd_buffer_inheritance_info.renderPass = m_renderPass;
2396 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2397 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2398 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2399
2400 cb.begin(&cmd_buffer_begin_info);
2401 cb.end();
2402
2403 m_commandBuffer->begin();
2404 m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo);
2405
2406 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-contents-00095");
2407 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-contents-06018");
2408 vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle);
2409 m_errorMonitor->VerifyFound();
2410
2411 m_commandBuffer->EndRenderPass();
2412 m_commandBuffer->end();
2413}
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002414
2415TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoDepthFormat) {
2416 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo DepthFormat incompatible with previously used pipeline");
2417
2418 SetTargetApiVersion(VK_API_VERSION_1_1);
2419 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2420 ASSERT_NO_FATAL_FAILURE(InitFramework());
2421
2422 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002423 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002424 }
sjfricked700bc02022-05-30 16:35:06 +09002425 if (!AreRequiredExtensionsEnabled()) {
2426 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002427 }
2428
2429 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09002430 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002431 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002432 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002433 }
2434
2435 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2436 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2437
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002438 std::vector<VkFormat> depth_formats;
2439 const VkFormat ds_formats[] = {VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT};
2440 for (uint32_t i = 0; i < size(ds_formats); ++i) {
2441 VkFormatProperties format_props;
2442 vk::GetPhysicalDeviceFormatProperties(gpu(), ds_formats[i], &format_props);
2443
2444 if (format_props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) {
2445 depth_formats.push_back(ds_formats[i]);
2446 }
2447 }
2448
2449 if (depth_formats.size() < 2) {
2450 printf("%s Test requires 2 depth formats, skipping test.\n", kSkipPrefix);
2451 return;
2452 }
2453
2454 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2455 pipeline_rendering_info.depthAttachmentFormat = depth_formats[0];
2456
2457 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
2458
2459 CreatePipelineHelper pipe1(*this);
2460 pipe1.InitInfo();
2461 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2462 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2463 pipe1.InitState();
2464 pipe1.ds_ci_ = ds_ci;
2465 pipe1.CreateGraphicsPipeline();
2466
2467 pipeline_rendering_info.depthAttachmentFormat = depth_formats[1];
2468
2469 CreatePipelineHelper pipe2(*this);
2470 pipe2.InitInfo();
2471 pipe2.gp_ci_.pNext = &pipeline_rendering_info;
2472 pipe2.gp_ci_.renderPass = VK_NULL_HANDLE;
2473 pipe2.InitState();
2474 pipe2.ds_ci_ = ds_ci;
2475 pipe2.CreateGraphicsPipeline();
2476
2477 VkImageObj image(m_device);
2478 image.Init(32, 32, 1, depth_formats[0], VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2479 VkImageView depth_image_view = image.targetView(depth_formats[0], VK_IMAGE_ASPECT_DEPTH_BIT);
2480
2481 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2482 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
2483 depth_attachment.imageView = depth_image_view;
2484
2485 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2486 begin_rendering_info.layerCount = 1;
2487 begin_rendering_info.pDepthAttachment = &depth_attachment;
2488
2489 m_commandBuffer->begin();
2490 m_commandBuffer->BeginRendering(begin_rendering_info);
2491
2492 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_);
2493 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
2494
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002495 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06197");
2496 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_);
2497 m_errorMonitor->VerifyFound();
2498
2499 m_commandBuffer->EndRendering();
2500 m_commandBuffer->end();
2501}
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002502
2503TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoColorAttachments) {
2504 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo color attachment incompatible with previously used pipeline");
2505
2506 SetTargetApiVersion(VK_API_VERSION_1_1);
2507 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2508 ASSERT_NO_FATAL_FAILURE(InitFramework());
2509
2510 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002511 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002512 }
sjfricked700bc02022-05-30 16:35:06 +09002513 if (!AreRequiredExtensionsEnabled()) {
2514 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002515 }
2516
2517 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09002518 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002519 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002520 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002521 }
2522
2523 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2524 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2525
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002526 VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
2527 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2528 pipeline_rendering_info.colorAttachmentCount = 1;
2529 pipeline_rendering_info.pColorAttachmentFormats = &format;
2530
2531 CreatePipelineHelper pipe1(*this);
2532 pipe1.InitInfo();
2533 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2534 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2535 pipe1.InitState();
2536 pipe1.CreateGraphicsPipeline();
2537
2538 format = VK_FORMAT_B8G8R8A8_UNORM;
2539
2540 CreatePipelineHelper pipe2(*this);
2541 pipe2.InitInfo();
2542 pipe2.gp_ci_.pNext = &pipeline_rendering_info;
2543 pipe2.gp_ci_.renderPass = VK_NULL_HANDLE;
2544 pipe2.InitState();
2545 pipe2.CreateGraphicsPipeline();
2546
2547 VkImageObj image(m_device);
2548 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2549 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
2550
2551 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2552 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2553 color_attachment.imageView = image_view;
2554
2555 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2556 begin_rendering_info.layerCount = 1;
2557 begin_rendering_info.colorAttachmentCount = 1;
2558 begin_rendering_info.pColorAttachments = &color_attachment;
2559
2560 m_commandBuffer->begin();
2561 m_commandBuffer->BeginRendering(begin_rendering_info);
2562
2563 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_);
2564 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
2565
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002566 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06196");
2567 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_);
2568 m_errorMonitor->VerifyFound();
2569
2570 m_commandBuffer->EndRendering();
2571 m_commandBuffer->end();
2572}
ziga-lunargacd79322022-04-21 18:36:34 +02002573
2574TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoColorAttachmentCount) {
2575 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo color attachment count incompatible with previously used pipeline");
2576
2577 SetTargetApiVersion(VK_API_VERSION_1_1);
2578 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2579 ASSERT_NO_FATAL_FAILURE(InitFramework());
2580
2581 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002582 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargacd79322022-04-21 18:36:34 +02002583 }
sjfricked700bc02022-05-30 16:35:06 +09002584 if (!AreRequiredExtensionsEnabled()) {
2585 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargacd79322022-04-21 18:36:34 +02002586 }
2587
2588 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09002589 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargacd79322022-04-21 18:36:34 +02002590 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002591 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargacd79322022-04-21 18:36:34 +02002592 }
2593
2594 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2595 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2596
ziga-lunargacd79322022-04-21 18:36:34 +02002597 VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
2598 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2599 pipeline_rendering_info.colorAttachmentCount = 1;
2600 pipeline_rendering_info.pColorAttachmentFormats = &format;
2601
2602 CreatePipelineHelper pipe1(*this);
2603 pipe1.InitInfo();
2604 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2605 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2606 pipe1.InitState();
2607 pipe1.CreateGraphicsPipeline();
2608
2609 pipeline_rendering_info.colorAttachmentCount = 0;
2610
2611 CreatePipelineHelper pipe2(*this);
2612 pipe2.InitInfo();
2613 pipe2.gp_ci_.pNext = &pipeline_rendering_info;
2614 pipe2.gp_ci_.renderPass = VK_NULL_HANDLE;
2615 pipe2.InitState();
2616 pipe2.CreateGraphicsPipeline();
2617
2618 VkImageObj image(m_device);
2619 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2620 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
2621
2622 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2623 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2624 color_attachment.imageView = image_view;
2625
2626 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2627 begin_rendering_info.layerCount = 1;
2628 begin_rendering_info.colorAttachmentCount = 1;
2629 begin_rendering_info.pColorAttachments = &color_attachment;
2630
2631 m_commandBuffer->begin();
2632 m_commandBuffer->BeginRendering(begin_rendering_info);
2633
2634 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_);
2635 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
2636
ziga-lunargacd79322022-04-21 18:36:34 +02002637 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06195");
2638 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_);
2639 m_errorMonitor->VerifyFound();
2640
2641 m_commandBuffer->EndRendering();
2642 m_commandBuffer->end();
ziga-lunarge3f11282022-04-21 18:39:55 +02002643}
2644
2645TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoStencilFormat) {
2646 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo StencilFormat incompatible with previously used pipeline");
2647
2648 SetTargetApiVersion(VK_API_VERSION_1_1);
2649 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2650 ASSERT_NO_FATAL_FAILURE(InitFramework());
2651
2652 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002653 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge3f11282022-04-21 18:39:55 +02002654 }
sjfricked700bc02022-05-30 16:35:06 +09002655 if (!AreRequiredExtensionsEnabled()) {
2656 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge3f11282022-04-21 18:39:55 +02002657 }
2658
2659 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09002660 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarge3f11282022-04-21 18:39:55 +02002661 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002662 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge3f11282022-04-21 18:39:55 +02002663 }
2664
2665 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2666 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2667
ziga-lunarge3f11282022-04-21 18:39:55 +02002668 std::vector<VkFormat> stencil_formats;
2669 const VkFormat ds_formats[] = {VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT};
2670 for (uint32_t i = 0; i < size(ds_formats); ++i) {
2671 VkFormatProperties format_props;
2672 vk::GetPhysicalDeviceFormatProperties(gpu(), ds_formats[i], &format_props);
2673
2674 if (format_props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) {
2675 stencil_formats.push_back(ds_formats[i]);
2676 }
2677 }
2678
2679 if (stencil_formats.size() < 2) {
2680 printf("%s Test requires 2 stencil formats, skipping test.\n", kSkipPrefix);
2681 return;
2682 }
2683
2684 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2685 pipeline_rendering_info.stencilAttachmentFormat = stencil_formats[0];
2686
2687 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
2688
2689 CreatePipelineHelper pipe1(*this);
2690 pipe1.InitInfo();
2691 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2692 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2693 pipe1.InitState();
2694 pipe1.ds_ci_ = ds_ci;
2695 pipe1.CreateGraphicsPipeline();
2696
2697 pipeline_rendering_info.stencilAttachmentFormat = stencil_formats[1];
2698
2699 CreatePipelineHelper pipe2(*this);
2700 pipe2.InitInfo();
2701 pipe2.gp_ci_.pNext = &pipeline_rendering_info;
2702 pipe2.gp_ci_.renderPass = VK_NULL_HANDLE;
2703 pipe2.InitState();
2704 pipe2.ds_ci_ = ds_ci;
2705 pipe2.CreateGraphicsPipeline();
2706
2707 VkImageObj image(m_device);
2708 image.Init(32, 32, 1, stencil_formats[0], VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2709 VkImageView stencil_image_view = image.targetView(stencil_formats[0], VK_IMAGE_ASPECT_DEPTH_BIT);
2710
2711 VkRenderingAttachmentInfoKHR stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2712 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL;
2713 stencil_attachment.imageView = stencil_image_view;
2714
2715 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2716 begin_rendering_info.layerCount = 1;
2717 begin_rendering_info.pStencilAttachment = &stencil_attachment;
2718
2719 m_commandBuffer->begin();
2720 m_commandBuffer->BeginRendering(begin_rendering_info);
2721
2722 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_);
2723 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
2724
ziga-lunarge3f11282022-04-21 18:39:55 +02002725 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06194");
2726 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_);
2727 m_errorMonitor->VerifyFound();
2728
2729 m_commandBuffer->EndRendering();
2730 m_commandBuffer->end();
2731}
ziga-lunarg155ed452022-04-21 23:54:06 +02002732
2733TEST_F(VkLayerTest, DynamicRenderingWithInvalidShaderLayerBuiltIn) {
2734 TEST_DESCRIPTION("Create invalid pipeline that writes to Layer built-in");
2735
2736 SetTargetApiVersion(VK_API_VERSION_1_1);
2737 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2738 ASSERT_NO_FATAL_FAILURE(InitFramework());
2739
2740 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002741 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg155ed452022-04-21 23:54:06 +02002742 }
sjfricked700bc02022-05-30 16:35:06 +09002743 if (!AreRequiredExtensionsEnabled()) {
2744 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg155ed452022-04-21 23:54:06 +02002745 }
2746
2747 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2748 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>(&dynamic_rendering_features);
sjfricke11db0c72022-08-18 13:23:11 +09002749 auto features2 = GetPhysicalDeviceFeatures2(multiview_features);
ziga-lunarg155ed452022-04-21 23:54:06 +02002750 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002751 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg155ed452022-04-21 23:54:06 +02002752 }
2753 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002754 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg155ed452022-04-21 23:54:06 +02002755 }
2756 if (multiview_features.multiviewGeometryShader == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002757 GTEST_SKIP() << "Test requires (unsupported) multiviewGeometryShader";
ziga-lunarg155ed452022-04-21 23:54:06 +02002758 }
2759
2760 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2761 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2762
2763 static char const *gsSource = R"glsl(
2764 #version 450
2765 layout (triangles) in;
2766 layout (triangle_strip) out;
2767 layout (max_vertices = 1) out;
2768 void main() {
2769 gl_Position = vec4(1.0, 0.5, 0.5, 0.0);
2770 EmitVertex();
2771 gl_Layer = 4;
2772 }
2773 )glsl";
2774
2775 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
2776 VkShaderObj gs(this, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT);
2777
2778 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2779
2780 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2781 pipeline_rendering_info.colorAttachmentCount = 1;
2782 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2783 pipeline_rendering_info.viewMask = 0x1;
2784
2785 CreatePipelineHelper pipe(*this);
2786 pipe.InitInfo();
2787 pipe.shader_stages_ = {vs.GetStageCreateInfo(), gs.GetStageCreateInfo(), pipe.fs_->GetStageCreateInfo()};
2788 pipe.gp_ci_.pNext = &pipeline_rendering_info;
2789 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2790 pipe.InitState();
2791 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06059");
2792 pipe.CreateGraphicsPipeline();
2793 m_errorMonitor->VerifyFound();
2794}
ziga-lunarg6feb4632022-04-22 00:20:21 +02002795
2796TEST_F(VkLayerTest, DynamicRenderingWithInputAttachmentCapability) {
2797 TEST_DESCRIPTION("Create invalid pipeline that uses InputAttachment capability");
2798
2799 SetTargetApiVersion(VK_API_VERSION_1_1);
2800 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2801 ASSERT_NO_FATAL_FAILURE(InitFramework());
2802
2803 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002804 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg6feb4632022-04-22 00:20:21 +02002805 }
sjfricked700bc02022-05-30 16:35:06 +09002806 if (!AreRequiredExtensionsEnabled()) {
2807 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6feb4632022-04-22 00:20:21 +02002808 }
2809
2810 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09002811 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg6feb4632022-04-22 00:20:21 +02002812 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002813 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6feb4632022-04-22 00:20:21 +02002814 }
2815
2816 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2817 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2818
sjfricke394227a2022-06-20 16:47:38 +09002819 const char *fsSource = R"(
ziga-lunarg6feb4632022-04-22 00:20:21 +02002820 OpCapability Shader
2821 OpCapability InputAttachment
2822 %1 = OpExtInstImport "GLSL.std.450"
2823 OpMemoryModel Logical GLSL450
2824 OpEntryPoint Fragment %main "main"
2825 OpExecutionMode %main OriginUpperLeft
2826
2827 ; Debug Information
2828 OpSource GLSL 450
2829 OpName %main "main" ; id %4
2830
2831 ; Types, variables and constants
2832 %void = OpTypeVoid
2833 %3 = OpTypeFunction %void
2834
2835 ; Function main
2836 %main = OpFunction %void None %3
2837 %5 = OpLabel
2838 OpReturn
2839 OpFunctionEnd
2840 )";
2841
2842 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, SPV_ENV_VULKAN_1_0, SPV_SOURCE_ASM);
2843
2844 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2845
2846 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2847 pipeline_rendering_info.colorAttachmentCount = 1;
2848 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2849
2850 CreatePipelineHelper pipe(*this);
2851 pipe.InitInfo();
2852 pipe.shader_stages_ = {pipe.vs_->GetStageCreateInfo(), fs.GetStageCreateInfo()};
2853 pipe.gp_ci_.pNext = &pipeline_rendering_info;
2854 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2855 pipe.InitState();
2856 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06061");
2857 pipe.CreateGraphicsPipeline();
2858 m_errorMonitor->VerifyFound();
2859}
ziga-lunarga62b6ce2022-04-22 14:33:47 +02002860
2861TEST_F(VkLayerTest, InvalidRenderingInfoColorAttachmentFormat) {
2862 TEST_DESCRIPTION("Create pipeline with invalid color attachment format");
2863
2864 SetTargetApiVersion(VK_API_VERSION_1_1);
2865 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2866 ASSERT_NO_FATAL_FAILURE(InitFramework());
2867
2868 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002869 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarga62b6ce2022-04-22 14:33:47 +02002870 }
sjfricked700bc02022-05-30 16:35:06 +09002871 if (!AreRequiredExtensionsEnabled()) {
2872 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarga62b6ce2022-04-22 14:33:47 +02002873 }
2874
2875 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09002876 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarga62b6ce2022-04-22 14:33:47 +02002877 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002878 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarga62b6ce2022-04-22 14:33:47 +02002879 }
2880
2881 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2882 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2883
2884 VkFormat color_format = VK_FORMAT_MAX_ENUM;
2885
2886 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2887 pipeline_rendering_info.colorAttachmentCount = 1;
2888 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2889
2890 CreatePipelineHelper pipe(*this);
2891 pipe.InitInfo();
2892 pipe.gp_ci_.pNext = &pipeline_rendering_info;
2893 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2894 pipe.InitState();
2895 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06579");
2896 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06580");
2897 pipe.CreateGraphicsPipeline();
2898 m_errorMonitor->VerifyFound();
2899}
ziga-lunargf7fb9202022-04-22 17:19:10 +02002900
2901TEST_F(VkLayerTest, InvalidDynamicRenderingLibraryViewMask) {
2902 TEST_DESCRIPTION("Create pipeline with invalid view mask");
2903
2904 SetTargetApiVersion(VK_API_VERSION_1_1);
2905 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2906 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
2907 ASSERT_NO_FATAL_FAILURE(InitFramework());
2908
2909 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002910 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargf7fb9202022-04-22 17:19:10 +02002911 }
sjfricked700bc02022-05-30 16:35:06 +09002912 if (!AreRequiredExtensionsEnabled()) {
2913 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargf7fb9202022-04-22 17:19:10 +02002914 }
2915
2916 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
2917 auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>(&multiview_features);
2918 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features);
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06002919 GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargf7fb9202022-04-22 17:19:10 +02002920 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002921 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargf7fb9202022-04-22 17:19:10 +02002922 }
2923 if (library_features.graphicsPipelineLibrary == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002924 GTEST_SKIP() << "Test requires (unsupported) graphicsPipelineLibrary";
ziga-lunargf7fb9202022-04-22 17:19:10 +02002925 }
2926 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002927 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunargf7fb9202022-04-22 17:19:10 +02002928 }
2929
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06002930 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &dynamic_rendering_features));
ziga-lunargf7fb9202022-04-22 17:19:10 +02002931 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2932
2933 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2934
2935 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2936 pipeline_rendering_info.colorAttachmentCount = 1;
2937 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2938
2939 auto graphics_library_create_info = LvlInitStruct<VkGraphicsPipelineLibraryCreateInfoEXT>(&pipeline_rendering_info);
2940 graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT;
2941 auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>(&graphics_library_create_info);
2942
2943 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
2944 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
2945 color_blend_state_create_info.attachmentCount = 1;
2946 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
2947
ziga-lunargf7fb9202022-04-22 17:19:10 +02002948 CreatePipelineHelper lib(*this);
2949 lib.cb_ci_ = color_blend_state_create_info;
2950 lib.InitInfo();
2951 lib.gp_ci_.pNext = &library_create_info;
2952 lib.gp_ci_.renderPass = VK_NULL_HANDLE;
2953 lib.InitState();
2954 lib.CreateGraphicsPipeline();
ziga-lunargf7fb9202022-04-22 17:19:10 +02002955
2956 graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT;
2957 library_create_info.libraryCount = 1;
2958 library_create_info.pLibraries = &lib.pipeline_;
2959 pipeline_rendering_info.viewMask = 0x1;
2960
2961 CreatePipelineHelper pipe(*this);
2962 pipe.InitInfo();
2963 pipe.gp_ci_.pNext = &library_create_info;
2964 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06002965 pipe.shader_stages_ = {pipe.fs_->GetStageCreateInfo()};
ziga-lunargf7fb9202022-04-22 17:19:10 +02002966 pipe.InitState();
2967 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06626");
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06002968 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06626");
ziga-lunargf7fb9202022-04-22 17:19:10 +02002969 pipe.CreateGraphicsPipeline();
2970 m_errorMonitor->VerifyFound();
2971}
ziga-lunarge151ca62022-04-22 17:40:51 +02002972
2973TEST_F(VkLayerTest, InvalidAttachmentSampleCount) {
2974 TEST_DESCRIPTION("Create pipeline with invalid color attachment samples");
2975
2976 SetTargetApiVersion(VK_API_VERSION_1_1);
2977 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2978 ASSERT_NO_FATAL_FAILURE(InitFramework());
2979
2980 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002981 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge151ca62022-04-22 17:40:51 +02002982 }
sjfricked700bc02022-05-30 16:35:06 +09002983 if (!AreRequiredExtensionsEnabled()) {
2984 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge151ca62022-04-22 17:40:51 +02002985 }
2986
2987 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09002988 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarge151ca62022-04-22 17:40:51 +02002989 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002990 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge151ca62022-04-22 17:40:51 +02002991 }
2992
2993 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2994 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2995
2996 VkSampleCountFlagBits color_attachment_samples = VK_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM;
2997
2998 auto samples_info = LvlInitStruct<VkAttachmentSampleCountInfoAMD>();
2999 samples_info.colorAttachmentCount = 1;
3000 samples_info.pColorAttachmentSamples = &color_attachment_samples;
3001 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(&samples_info);
3002
3003 CreatePipelineHelper pipe(*this);
3004 pipe.InitInfo();
3005 pipe.gp_ci_.pNext = &pipeline_rendering_info;
3006 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3007 pipe.InitState();
3008 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-pColorAttachmentSamples-06592");
3009 pipe.CreateGraphicsPipeline();
3010 m_errorMonitor->VerifyFound();
3011}
ziga-lunargb81597d2022-04-22 19:11:51 +02003012
3013TEST_F(VkLayerTest, InvalidDynamicRenderingLibrariesViewMask) {
3014 TEST_DESCRIPTION("Create pipeline with libaries that have incompatible view mask");
3015
3016 SetTargetApiVersion(VK_API_VERSION_1_1);
3017 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3018 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
3019 ASSERT_NO_FATAL_FAILURE(InitFramework());
3020
3021 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003022 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargb81597d2022-04-22 19:11:51 +02003023 }
sjfricked700bc02022-05-30 16:35:06 +09003024 if (!AreRequiredExtensionsEnabled()) {
3025 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargb81597d2022-04-22 19:11:51 +02003026 }
3027
3028 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3029 auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>(&multiview_features);
3030 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features);
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003031 GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargb81597d2022-04-22 19:11:51 +02003032 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003033 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargb81597d2022-04-22 19:11:51 +02003034 }
3035 if (library_features.graphicsPipelineLibrary == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003036 GTEST_SKIP() << "Test requires (unsupported) graphicsPipelineLibrary";
ziga-lunargb81597d2022-04-22 19:11:51 +02003037 }
3038 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003039 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunargb81597d2022-04-22 19:11:51 +02003040 }
3041
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003042 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &dynamic_rendering_features));
ziga-lunargb81597d2022-04-22 19:11:51 +02003043 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3044
3045 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
3046
3047 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
3048 pipeline_rendering_info.colorAttachmentCount = 1;
3049 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
3050
ziga-lunargb81597d2022-04-22 19:11:51 +02003051 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
3052 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
3053 color_blend_state_create_info.attachmentCount = 1;
3054 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
3055
ziga-lunargb81597d2022-04-22 19:11:51 +02003056 CreatePipelineHelper lib1(*this);
3057 lib1.cb_ci_ = color_blend_state_create_info;
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003058 lib1.InitFragmentOutputLibInfo(&pipeline_rendering_info);
ziga-lunargb81597d2022-04-22 19:11:51 +02003059 lib1.gp_ci_.renderPass = VK_NULL_HANDLE;
3060 lib1.InitState();
3061 lib1.CreateGraphicsPipeline();
3062
ziga-lunargb81597d2022-04-22 19:11:51 +02003063 pipeline_rendering_info.viewMask = 0x1;
3064
3065 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
3066
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003067 const auto fs_spv = GLSLToSPV(VK_SHADER_STAGE_FRAGMENT_BIT, bindStateFragShaderText);
3068 auto fs_ci = LvlInitStruct<VkShaderModuleCreateInfo>();
3069 fs_ci.codeSize = fs_spv.size() * sizeof(decltype(fs_spv)::value_type);
3070 fs_ci.pCode = fs_spv.data();
3071
3072 auto fs_stage_ci = LvlInitStruct<VkPipelineShaderStageCreateInfo>(&fs_ci);
3073 fs_stage_ci.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
3074 fs_stage_ci.module = VK_NULL_HANDLE;
3075 fs_stage_ci.pName = "main";
3076
ziga-lunargb81597d2022-04-22 19:11:51 +02003077 CreatePipelineHelper lib2(*this);
3078 lib2.cb_ci_ = color_blend_state_create_info;
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003079 lib2.InitFragmentLibInfo(1, &fs_stage_ci, &pipeline_rendering_info);
ziga-lunargb81597d2022-04-22 19:11:51 +02003080 lib2.gp_ci_.renderPass = VK_NULL_HANDLE;
3081 lib2.ds_ci_ = ds_ci;
3082 lib2.InitState();
3083 lib2.CreateGraphicsPipeline();
ziga-lunargb81597d2022-04-22 19:11:51 +02003084
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003085 pipeline_rendering_info.viewMask = 0;
3086 auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>();
ziga-lunargb81597d2022-04-22 19:11:51 +02003087 library_create_info.libraryCount = 2;
3088 VkPipeline libraries[2] = {lib1.pipeline_, lib2.pipeline_};
3089 library_create_info.pLibraries = libraries;
ziga-lunargb81597d2022-04-22 19:11:51 +02003090
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003091 auto pipe_ci = LvlInitStruct<VkGraphicsPipelineCreateInfo>(&library_create_info);
ziga-lunarg7f25dff2022-05-06 17:49:34 +02003092 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-pLibraries-06627");
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003093 vk_testing::Pipeline pipe(*m_device, pipe_ci);
ziga-lunargb81597d2022-04-22 19:11:51 +02003094 m_errorMonitor->VerifyFound();
3095}
ziga-lunarg2e302312022-04-22 19:47:32 +02003096
3097TEST_F(VkLayerTest, InvalidDynamicRenderingLibraryRenderPass) {
3098 TEST_DESCRIPTION("Create pipeline with invalid library render pass");
3099
3100 SetTargetApiVersion(VK_API_VERSION_1_1);
3101 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3102 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
3103 ASSERT_NO_FATAL_FAILURE(InitFramework());
3104
3105 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003106 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg2e302312022-04-22 19:47:32 +02003107 }
sjfricked700bc02022-05-30 16:35:06 +09003108 if (!AreRequiredExtensionsEnabled()) {
3109 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg2e302312022-04-22 19:47:32 +02003110 }
3111
3112 auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>();
3113 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features);
sjfricke11db0c72022-08-18 13:23:11 +09003114 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg2e302312022-04-22 19:47:32 +02003115 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003116 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg2e302312022-04-22 19:47:32 +02003117 }
3118 if (library_features.graphicsPipelineLibrary == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003119 GTEST_SKIP() << "Test requires (unsupported) graphicsPipelineLibrary";
ziga-lunarg2e302312022-04-22 19:47:32 +02003120 }
3121
3122 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3123 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3124
3125 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
3126
3127 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
3128 pipeline_rendering_info.colorAttachmentCount = 1;
3129 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
3130
ziga-lunarg2e302312022-04-22 19:47:32 +02003131 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
3132 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
3133 color_blend_state_create_info.attachmentCount = 1;
3134 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
3135
ziga-lunarg2e302312022-04-22 19:47:32 +02003136 CreatePipelineHelper lib(*this);
3137 lib.cb_ci_ = color_blend_state_create_info;
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003138 lib.InitFragmentOutputLibInfo(&pipeline_rendering_info);
ziga-lunarg2e302312022-04-22 19:47:32 +02003139 lib.InitState();
3140 lib.CreateGraphicsPipeline();
ziga-lunarg2e302312022-04-22 19:47:32 +02003141
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003142 auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>(&pipeline_rendering_info);
ziga-lunarg2e302312022-04-22 19:47:32 +02003143 library_create_info.libraryCount = 1;
3144 library_create_info.pLibraries = &lib.pipeline_;
3145
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003146 const auto fs_spv = GLSLToSPV(VK_SHADER_STAGE_FRAGMENT_BIT, bindStateFragShaderText);
3147 auto fs_ci = LvlInitStruct<VkShaderModuleCreateInfo>();
3148 fs_ci.codeSize = fs_spv.size() * sizeof(decltype(fs_spv)::value_type);
3149 fs_ci.pCode = fs_spv.data();
3150
3151 auto fs_stage_ci = LvlInitStruct<VkPipelineShaderStageCreateInfo>(&fs_ci);
3152 fs_stage_ci.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
3153 fs_stage_ci.module = VK_NULL_HANDLE;
3154 fs_stage_ci.pName = "main";
3155
ziga-lunarg2e302312022-04-22 19:47:32 +02003156 CreatePipelineHelper pipe(*this);
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003157 pipe.InitFragmentLibInfo(1, &fs_stage_ci, &library_create_info);
ziga-lunarg2e302312022-04-22 19:47:32 +02003158 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3159 pipe.InitState();
3160 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderpass-06625");
3161 pipe.CreateGraphicsPipeline();
3162 m_errorMonitor->VerifyFound();
3163}
ziga-lunarg7ba5a1c2022-04-22 19:56:49 +02003164
3165TEST_F(VkLayerTest, PipelineMissingMultisampleState) {
3166 TEST_DESCRIPTION("Create pipeline with missing multisample state");
3167
3168 SetTargetApiVersion(VK_API_VERSION_1_1);
3169 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3170 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
3171 ASSERT_NO_FATAL_FAILURE(InitFramework());
3172
3173 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003174 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7ba5a1c2022-04-22 19:56:49 +02003175 }
sjfricked700bc02022-05-30 16:35:06 +09003176 if (!AreRequiredExtensionsEnabled()) {
3177 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7ba5a1c2022-04-22 19:56:49 +02003178 }
3179
3180 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09003181 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg7ba5a1c2022-04-22 19:56:49 +02003182 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003183 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7ba5a1c2022-04-22 19:56:49 +02003184 }
3185
3186 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3187 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3188
3189 CreatePipelineHelper pipe(*this);
3190 pipe.InitInfo();
3191 pipe.gp_ci_.pMultisampleState = nullptr;
3192 pipe.InitState();
3193 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderpass-06631");
3194 pipe.CreateGraphicsPipeline();
3195 m_errorMonitor->VerifyFound();
ziga-lunarg14222532022-04-22 23:27:17 +02003196}
3197
ziga-lunargd7737482022-04-25 11:16:37 +02003198TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachment) {
3199 TEST_DESCRIPTION("Use invalid VkRenderingFragmentDensityMapAttachmentInfoEXT");
ziga-lunarg14222532022-04-22 23:27:17 +02003200
3201 SetTargetApiVersion(VK_API_VERSION_1_1);
3202 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3203 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3204 ASSERT_NO_FATAL_FAILURE(InitFramework());
3205
3206 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003207 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg14222532022-04-22 23:27:17 +02003208 }
sjfricked700bc02022-05-30 16:35:06 +09003209 if (!AreRequiredExtensionsEnabled()) {
3210 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg14222532022-04-22 23:27:17 +02003211 }
3212
ziga-lunargd7737482022-04-25 11:16:37 +02003213 auto multiview_featuers = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3214 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&multiview_featuers);
sjfricke11db0c72022-08-18 13:23:11 +09003215 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg14222532022-04-22 23:27:17 +02003216 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003217 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg14222532022-04-22 23:27:17 +02003218 }
ziga-lunargd7737482022-04-25 11:16:37 +02003219 if (multiview_featuers.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003220 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunargd7737482022-04-25 11:16:37 +02003221 }
ziga-lunarg14222532022-04-22 23:27:17 +02003222
3223 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3224 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3225
3226 VkImageObj image(m_device);
3227 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
3228 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, VK_IMAGE_TILING_LINEAR, 0);
3229 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3230
3231 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3232 rendering_fragment_density.imageView = image_view;
3233 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3234 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3235 begin_rendering_info.layerCount = 1;
3236
3237 m_commandBuffer->begin();
ziga-lunargd7737482022-04-25 11:16:37 +02003238
ziga-lunarg14222532022-04-22 23:27:17 +02003239 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06157");
3240 m_commandBuffer->BeginRendering(begin_rendering_info);
3241 m_errorMonitor->VerifyFound();
ziga-lunargd7737482022-04-25 11:16:37 +02003242
3243 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3244
3245 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3246 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3247 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
3248 image_create_info.extent = {32, 32, 1};
3249 image_create_info.mipLevels = 1;
3250 image_create_info.arrayLayers = 2;
3251 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
3252 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3253 image_create_info.usage = VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT;
3254 VkImageObj image2(m_device);
3255 image2.Init(image_create_info);
3256 VkImageView image_view2 = image2.targetView(VK_FORMAT_R8G8B8A8_UINT);
3257 rendering_fragment_density.imageView = image_view2;
3258 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06160");
3259 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06109");
3260 m_commandBuffer->BeginRendering(begin_rendering_info);
3261 m_errorMonitor->VerifyFound();
3262
ziga-lunarg14222532022-04-22 23:27:17 +02003263 m_commandBuffer->end();
3264}
ziga-lunarga81df9d2022-04-22 23:33:13 +02003265
3266TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentUsage) {
3267 TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid imageLayout");
3268
3269 SetTargetApiVersion(VK_API_VERSION_1_1);
3270 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3271 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3272 ASSERT_NO_FATAL_FAILURE(InitFramework());
3273
3274 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003275 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarga81df9d2022-04-22 23:33:13 +02003276 }
sjfricked700bc02022-05-30 16:35:06 +09003277 if (!AreRequiredExtensionsEnabled()) {
3278 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarga81df9d2022-04-22 23:33:13 +02003279 }
3280
3281 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09003282 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarga81df9d2022-04-22 23:33:13 +02003283 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003284 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarga81df9d2022-04-22 23:33:13 +02003285 }
3286
3287 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3288 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3289
3290 VkImageObj image(m_device);
3291 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
3292 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3293
3294 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3295 rendering_fragment_density.imageView = image_view;
3296 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3297 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3298 begin_rendering_info.layerCount = 1;
3299
3300 m_commandBuffer->begin();
3301 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06158");
3302 m_commandBuffer->BeginRendering(begin_rendering_info);
3303 m_errorMonitor->VerifyFound();
3304 m_commandBuffer->end();
3305}
ziga-lunarg7c411b32022-04-22 23:37:48 +02003306
3307TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentCreateFlags) {
3308 TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid image create flags");
3309
3310 SetTargetApiVersion(VK_API_VERSION_1_1);
3311 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3312 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3313 ASSERT_NO_FATAL_FAILURE(InitFramework());
3314
3315 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003316 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7c411b32022-04-22 23:37:48 +02003317 }
sjfricked700bc02022-05-30 16:35:06 +09003318 if (!AreRequiredExtensionsEnabled()) {
3319 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7c411b32022-04-22 23:37:48 +02003320 }
3321
3322 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09003323 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg7c411b32022-04-22 23:37:48 +02003324 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003325 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7c411b32022-04-22 23:37:48 +02003326 }
3327
3328 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3329 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3330
3331 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3332 image_create_info.flags = VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT;
3333 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3334 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
3335 image_create_info.extent = {32, 32, 4};
3336 image_create_info.mipLevels = 1;
3337 image_create_info.arrayLayers = 1;
3338 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
3339 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3340 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT;
3341
3342 VkImageObj image(m_device);
3343 image.Init(image_create_info);
3344 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3345
3346 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3347 rendering_fragment_density.imageView = image_view;
3348 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3349 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3350 begin_rendering_info.layerCount = 1;
3351
3352 m_commandBuffer->begin();
3353 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06159");
3354 m_commandBuffer->BeginRendering(begin_rendering_info);
3355 m_errorMonitor->VerifyFound();
3356 m_commandBuffer->end();
3357}
ziga-lunarg66569a72022-04-22 23:43:26 +02003358
3359TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentLayerCount) {
3360 TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid layer count");
3361
3362 SetTargetApiVersion(VK_API_VERSION_1_1);
3363 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3364 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3365 ASSERT_NO_FATAL_FAILURE(InitFramework());
3366
3367 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003368 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg66569a72022-04-22 23:43:26 +02003369 }
sjfricked700bc02022-05-30 16:35:06 +09003370 if (!AreRequiredExtensionsEnabled()) {
3371 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg66569a72022-04-22 23:43:26 +02003372 }
3373
3374 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3375 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&multiview_features);
sjfricke11db0c72022-08-18 13:23:11 +09003376 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg66569a72022-04-22 23:43:26 +02003377 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003378 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg66569a72022-04-22 23:43:26 +02003379 }
3380 if (!multiview_features.multiview) {
sjfricke50955f32022-06-05 10:12:52 +09003381 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg66569a72022-04-22 23:43:26 +02003382 }
3383
3384 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3385 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3386
3387 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3388 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3389 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
3390 image_create_info.extent = {32, 32, 4};
3391 image_create_info.mipLevels = 1;
3392 image_create_info.arrayLayers = 2;
3393 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
3394 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3395 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT;
3396
3397 VkImageObj image(m_device);
3398 image.Init(image_create_info);
3399 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3400
3401 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3402 rendering_fragment_density.imageView = image_view;
3403 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3404 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3405 begin_rendering_info.layerCount = 1;
3406 begin_rendering_info.viewMask = 0x1;
3407
3408 m_commandBuffer->begin();
3409 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06160");
3410 m_commandBuffer->BeginRendering(begin_rendering_info);
3411 m_errorMonitor->VerifyFound();
3412 m_commandBuffer->end();
3413}
ziga-lunarg323c11d2022-04-22 23:56:32 +02003414
3415TEST_F(VkLayerTest, InvalidRenderingPNextImageView) {
3416 TEST_DESCRIPTION(
3417 "Use different image views in VkRenderingFragmentShadingRateAttachmentInfoKHR and "
3418 "VkRenderingFragmentDensityMapAttachmentInfoEXT");
3419
3420 SetTargetApiVersion(VK_API_VERSION_1_1);
3421 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3422 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3423 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
3424 ASSERT_NO_FATAL_FAILURE(InitFramework());
3425
3426 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003427 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg323c11d2022-04-22 23:56:32 +02003428 }
sjfricked700bc02022-05-30 16:35:06 +09003429 if (!AreRequiredExtensionsEnabled()) {
3430 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg323c11d2022-04-22 23:56:32 +02003431 }
3432
3433 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3434 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&multiview_features);
sjfricke11db0c72022-08-18 13:23:11 +09003435 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg323c11d2022-04-22 23:56:32 +02003436 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003437 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg323c11d2022-04-22 23:56:32 +02003438 }
3439 if (!multiview_features.multiview) {
sjfricke50955f32022-06-05 10:12:52 +09003440 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg323c11d2022-04-22 23:56:32 +02003441 }
3442
3443 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3444 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3445
3446 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
3447
3448 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
sjfricke74a1aad2022-08-17 14:41:33 +09003449 GetPhysicalDeviceProperties2(phys_dev_props_2);
ziga-lunarg323c11d2022-04-22 23:56:32 +02003450
3451 VkImageObj image1(m_device);
3452 image1.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
3453 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR,
3454 VK_IMAGE_TILING_LINEAR, 0);
3455 VkImageView image_view1 = image1.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3456 VkImageObj image2(m_device);
3457 image2.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
3458 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, VK_IMAGE_TILING_LINEAR, 0);
3459 VkImageView image_view2 = image2.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3460
3461 auto rendering_fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
3462 rendering_fragment_shading_rate.imageView = image_view1;
3463 rendering_fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3464 rendering_fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
3465 auto rendering_fragment_density =
3466 LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>(&rendering_fragment_shading_rate);
3467 rendering_fragment_density.imageView = image_view2;
3468 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3469 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3470 begin_rendering_info.layerCount = 1;
3471 begin_rendering_info.viewMask = 0x1;
3472
3473 m_commandBuffer->begin();
3474 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06126");
3475 m_commandBuffer->BeginRendering(begin_rendering_info);
3476 m_errorMonitor->VerifyFound();
3477 m_commandBuffer->end();
3478}
ziga-lunarg95f20d42022-04-23 00:06:42 +02003479
3480TEST_F(VkLayerTest, InvalidRenderingRenderArea) {
3481 TEST_DESCRIPTION("Use negative offset in RenderingInfo render area");
3482
3483 SetTargetApiVersion(VK_API_VERSION_1_0);
3484 AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
3485 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3486 ASSERT_NO_FATAL_FAILURE(InitFramework());
3487
3488 if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
sjfricke50955f32022-06-05 10:12:52 +09003489 GTEST_SKIP() << "Tests for 1.0 only";
ziga-lunarg95f20d42022-04-23 00:06:42 +02003490 }
sjfricked700bc02022-05-30 16:35:06 +09003491 if (!AreRequiredExtensionsEnabled()) {
3492 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg95f20d42022-04-23 00:06:42 +02003493 }
3494
ziga-lunarg95f20d42022-04-23 00:06:42 +02003495 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09003496 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg95f20d42022-04-23 00:06:42 +02003497 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003498 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg95f20d42022-04-23 00:06:42 +02003499 }
3500
3501 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3502 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3503
3504 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3505 begin_rendering_info.layerCount = 1;
3506 begin_rendering_info.renderArea.offset.x = -1;
ziga-lunarg9b6a95f2022-04-23 00:13:38 +02003507 begin_rendering_info.renderArea.extent.width = 32;
3508 begin_rendering_info.renderArea.extent.height = 32;
ziga-lunarg95f20d42022-04-23 00:06:42 +02003509
3510 m_commandBuffer->begin();
3511
3512 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06071");
3513 m_commandBuffer->BeginRendering(begin_rendering_info);
3514 m_errorMonitor->VerifyFound();
3515
3516 begin_rendering_info.renderArea.offset.x = 0;
3517 begin_rendering_info.renderArea.offset.y = -1;
3518
3519 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06072");
3520 m_commandBuffer->BeginRendering(begin_rendering_info);
3521 m_errorMonitor->VerifyFound();
3522
ziga-lunarg9b6a95f2022-04-23 00:13:38 +02003523 begin_rendering_info.renderArea.offset.y = 0;
3524 begin_rendering_info.renderArea.offset.x = m_device->phy().properties().limits.maxFramebufferWidth - 16;
3525 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06073");
3526 m_commandBuffer->BeginRendering(begin_rendering_info);
3527 m_errorMonitor->VerifyFound();
3528
3529 begin_rendering_info.renderArea.offset.x = 0;
3530 begin_rendering_info.renderArea.offset.y = m_device->phy().properties().limits.maxFramebufferHeight - 16;
3531 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06074");
3532 m_commandBuffer->BeginRendering(begin_rendering_info);
3533 m_errorMonitor->VerifyFound();
3534
ziga-lunarg95f20d42022-04-23 00:06:42 +02003535 m_commandBuffer->end();
3536}
ziga-lunarg6662a882022-04-23 00:21:27 +02003537
3538TEST_F(VkLayerTest, InvalidRenderingInfoViewMask) {
3539 TEST_DESCRIPTION("Use negative offset in RenderingInfo render area");
3540
3541 SetTargetApiVersion(VK_API_VERSION_1_1);
3542 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3543 ASSERT_NO_FATAL_FAILURE(InitFramework());
3544
3545 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003546 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg6662a882022-04-23 00:21:27 +02003547 }
sjfricked700bc02022-05-30 16:35:06 +09003548 if (!AreRequiredExtensionsEnabled()) {
3549 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6662a882022-04-23 00:21:27 +02003550 }
3551
3552 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3553 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(&multiview_features);
sjfricke11db0c72022-08-18 13:23:11 +09003554 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg6662a882022-04-23 00:21:27 +02003555 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003556 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6662a882022-04-23 00:21:27 +02003557 }
3558 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003559 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg6662a882022-04-23 00:21:27 +02003560 }
3561
3562 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3563 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3564
3565 VkPhysicalDeviceMultiviewProperties multiview_props = LvlInitStruct<VkPhysicalDeviceMultiviewProperties>();
3566 VkPhysicalDeviceProperties2 pd_props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&multiview_props);
sjfricke74a1aad2022-08-17 14:41:33 +09003567 GetPhysicalDeviceProperties2(pd_props2);
ziga-lunarg6662a882022-04-23 00:21:27 +02003568
3569 if (multiview_props.maxMultiviewViewCount == 32) {
3570 printf("%s VUID is not testable as maxMultiviewViewCount is 32, skipping test\n", kSkipPrefix);
3571 return;
3572 }
3573
3574 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3575 begin_rendering_info.layerCount = 1;
3576 begin_rendering_info.renderArea.extent.width = 32;
3577 begin_rendering_info.renderArea.extent.height = 32;
3578 begin_rendering_info.viewMask = 1u << multiview_props.maxMultiviewViewCount;
3579
3580 m_commandBuffer->begin();
3581
3582 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-viewMask-06128");
3583 m_commandBuffer->BeginRendering(begin_rendering_info);
3584 m_errorMonitor->VerifyFound();
3585
3586 m_commandBuffer->end();
3587}
ziga-lunargae75b8a2022-04-23 10:54:37 +02003588
3589TEST_F(VkLayerTest, InvalidRenderingColorAttachmentFormat) {
3590 TEST_DESCRIPTION("Use format with missing potential format features in rendering color attachment");
3591
3592 SetTargetApiVersion(VK_API_VERSION_1_1);
3593 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3594 AddRequiredExtensions(VK_NV_LINEAR_COLOR_ATTACHMENT_EXTENSION_NAME);
3595 ASSERT_NO_FATAL_FAILURE(InitFramework());
3596
3597 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003598 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargae75b8a2022-04-23 10:54:37 +02003599 }
sjfricked700bc02022-05-30 16:35:06 +09003600 if (!AreRequiredExtensionsEnabled()) {
3601 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargae75b8a2022-04-23 10:54:37 +02003602 }
3603
3604 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09003605 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargae75b8a2022-04-23 10:54:37 +02003606 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003607 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargae75b8a2022-04-23 10:54:37 +02003608 }
3609
3610 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3611 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3612
3613 VkFormat format = FindSupportedDepthStencilFormat(gpu());
3614 if (format == VK_FORMAT_UNDEFINED) {
3615 printf("%s No Depth + Stencil format found. Skipped.\n", kSkipPrefix);
3616 return;
3617 }
3618
3619 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
3620 pipeline_rendering_info.colorAttachmentCount = 1;
3621 pipeline_rendering_info.pColorAttachmentFormats = &format;
3622
3623 CreatePipelineHelper pipe(*this);
3624 pipe.InitInfo();
3625 pipe.gp_ci_.pNext = &pipeline_rendering_info;
3626 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3627 pipe.InitState();
3628
3629 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06582");
3630 pipe.CreateGraphicsPipeline();
3631 m_errorMonitor->VerifyFound();
3632}
ziga-lunargeac390f2022-04-23 11:05:28 +02003633
sjfricke483c1082022-06-05 10:21:44 +09003634TEST_F(VkLayerTest, InvalidResolveModeWithNonIntegerColorFormat) {
3635 TEST_DESCRIPTION("Use invalid resolve mode with non integer color format");
3636
3637 SetTargetApiVersion(VK_API_VERSION_1_1);
3638 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3639 ASSERT_NO_FATAL_FAILURE(InitFramework());
3640
3641 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
3642 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
3643 }
sjfricked700bc02022-05-30 16:35:06 +09003644 if (!AreRequiredExtensionsEnabled()) {
3645 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
sjfricke483c1082022-06-05 10:21:44 +09003646 }
3647
3648 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09003649 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
sjfricke483c1082022-06-05 10:21:44 +09003650 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
3651 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
3652 }
3653
3654 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3655 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3656
3657 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3658 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3659 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; // not int color
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06003660 image_create_info.extent = {32, 32, 1};
sjfricke483c1082022-06-05 10:21:44 +09003661 image_create_info.mipLevels = 1;
3662 image_create_info.arrayLayers = 1;
3663 image_create_info.samples = VK_SAMPLE_COUNT_4_BIT;
3664 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3665 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
3666 VkImageObj image(m_device);
3667 image.Init(image_create_info);
3668 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3669
Tony-LunarGf088c6b2022-07-08 11:29:53 -06003670 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
3671 VkImageObj resolve_image(m_device);
3672 resolve_image.Init(image_create_info);
3673 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3674
sjfricke483c1082022-06-05 10:21:44 +09003675 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3676 color_attachment.imageView = image_view;
3677 color_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT; // not allowed for format
3678 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3679 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
Tony-LunarGf088c6b2022-07-08 11:29:53 -06003680 color_attachment.resolveImageView = resolve_image_view;
sjfricke483c1082022-06-05 10:21:44 +09003681
3682 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3683 begin_rendering_info.colorAttachmentCount = 1;
3684 begin_rendering_info.pColorAttachments = &color_attachment;
3685 begin_rendering_info.layerCount = 1;
3686
3687 m_commandBuffer->begin();
3688
3689 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06129");
3690 m_commandBuffer->BeginRendering(begin_rendering_info);
3691 m_errorMonitor->VerifyFound();
3692
3693 m_commandBuffer->end();
3694}
3695
ziga-lunargeac390f2022-04-23 11:05:28 +02003696TEST_F(VkLayerTest, InvalidResolveModeWithIntegerColorFormat) {
3697 TEST_DESCRIPTION("Use invalid resolve mode with integer color format");
3698
3699 SetTargetApiVersion(VK_API_VERSION_1_1);
3700 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3701 ASSERT_NO_FATAL_FAILURE(InitFramework());
3702
3703 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003704 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargeac390f2022-04-23 11:05:28 +02003705 }
sjfricked700bc02022-05-30 16:35:06 +09003706 if (!AreRequiredExtensionsEnabled()) {
3707 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargeac390f2022-04-23 11:05:28 +02003708 }
3709
3710 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09003711 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargeac390f2022-04-23 11:05:28 +02003712 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003713 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargeac390f2022-04-23 11:05:28 +02003714 }
3715
3716 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3717 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3718
3719 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3720 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3721 image_create_info.format = VK_FORMAT_R8G8B8A8_UINT;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06003722 image_create_info.extent = {32, 32, 1};
ziga-lunargeac390f2022-04-23 11:05:28 +02003723 image_create_info.mipLevels = 1;
3724 image_create_info.arrayLayers = 1;
3725 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
3726 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3727 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
3728 VkImageObj image(m_device);
3729 image.Init(image_create_info);
3730 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
3731
Tony-LunarGf088c6b2022-07-08 11:29:53 -06003732 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
3733 VkImageObj resolve_image(m_device);
3734 resolve_image.Init(image_create_info);
3735 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UINT);
3736
ziga-lunargeac390f2022-04-23 11:05:28 +02003737 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3738 color_attachment.imageView = image_view;
3739 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3740 color_attachment.resolveMode = VK_RESOLVE_MODE_MAX_BIT;
3741 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
Tony-LunarGf088c6b2022-07-08 11:29:53 -06003742 color_attachment.resolveImageView = resolve_image_view;
ziga-lunargeac390f2022-04-23 11:05:28 +02003743
3744 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3745 begin_rendering_info.colorAttachmentCount = 1;
3746 begin_rendering_info.pColorAttachments = &color_attachment;
3747 begin_rendering_info.layerCount = 1;
3748
3749 m_commandBuffer->begin();
3750
3751 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06130");
3752 m_commandBuffer->BeginRendering(begin_rendering_info);
3753 m_errorMonitor->VerifyFound();
3754
3755 m_commandBuffer->end();
3756}
ziga-lunargdf2a3202022-04-23 11:07:46 +02003757
3758TEST_F(VkLayerTest, InvalidResolveModeSamples) {
3759 TEST_DESCRIPTION("Use invalid sample count with resolve mode that is not none");
3760
3761 SetTargetApiVersion(VK_API_VERSION_1_1);
3762 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3763 ASSERT_NO_FATAL_FAILURE(InitFramework());
3764
3765 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003766 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargdf2a3202022-04-23 11:07:46 +02003767 }
sjfricked700bc02022-05-30 16:35:06 +09003768 if (!AreRequiredExtensionsEnabled()) {
3769 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargdf2a3202022-04-23 11:07:46 +02003770 }
3771
3772 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09003773 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargdf2a3202022-04-23 11:07:46 +02003774 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003775 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargdf2a3202022-04-23 11:07:46 +02003776 }
3777
3778 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3779 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3780
3781 VkImageObj image(m_device);
3782 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
3783 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3784
3785 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3786 color_attachment.imageView = image_view;
3787 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3788 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
3789 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
Tony-LunarGf088c6b2022-07-08 11:29:53 -06003790 color_attachment.resolveImageView = image_view;
ziga-lunargdf2a3202022-04-23 11:07:46 +02003791
3792 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3793 begin_rendering_info.colorAttachmentCount = 1;
3794 begin_rendering_info.pColorAttachments = &color_attachment;
3795 begin_rendering_info.layerCount = 1;
3796
3797 m_commandBuffer->begin();
3798
3799 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06132");
3800 m_commandBuffer->BeginRendering(begin_rendering_info);
3801 m_errorMonitor->VerifyFound();
3802
3803 m_commandBuffer->end();
3804}
ziga-lunargb7693aa2022-04-23 11:21:57 +02003805
3806TEST_F(VkLayerTest, InvalidResolveImageViewSamples) {
3807 TEST_DESCRIPTION("Use resolve image view with invalid sample count");
3808
3809 SetTargetApiVersion(VK_API_VERSION_1_1);
3810 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3811 ASSERT_NO_FATAL_FAILURE(InitFramework());
3812
3813 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003814 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargb7693aa2022-04-23 11:21:57 +02003815 }
sjfricked700bc02022-05-30 16:35:06 +09003816 if (!AreRequiredExtensionsEnabled()) {
3817 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargb7693aa2022-04-23 11:21:57 +02003818 }
3819
3820 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09003821 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargb7693aa2022-04-23 11:21:57 +02003822 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003823 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargb7693aa2022-04-23 11:21:57 +02003824 }
3825
3826 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3827 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3828
3829 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3830 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3831 image_create_info.format = VK_FORMAT_R8G8B8A8_UINT;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06003832 image_create_info.extent = {32, 32, 1};
ziga-lunargb7693aa2022-04-23 11:21:57 +02003833 image_create_info.mipLevels = 1;
3834 image_create_info.arrayLayers = 1;
3835 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
3836 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3837 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
3838
3839 VkImageObj image(m_device);
3840 image.Init(image_create_info);
3841 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
3842
3843 VkImageObj resolve_image(m_device);
3844 resolve_image.Init(image_create_info);
3845 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UINT);
3846
3847 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3848 color_attachment.imageView = image_view;
3849 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3850 color_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
3851 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
3852 color_attachment.resolveImageView = resolve_image_view;
3853
3854 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3855 begin_rendering_info.colorAttachmentCount = 1;
3856 begin_rendering_info.pColorAttachments = &color_attachment;
3857 begin_rendering_info.layerCount = 1;
3858
3859 m_commandBuffer->begin();
3860
Tony-LunarG7384f7e2022-07-05 14:20:42 -06003861 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06864");
ziga-lunargb7693aa2022-04-23 11:21:57 +02003862 m_commandBuffer->BeginRendering(begin_rendering_info);
3863 m_errorMonitor->VerifyFound();
3864
Tony-LunarGeb7156a2022-07-26 13:36:31 -06003865 color_attachment.resolveImageView = VK_NULL_HANDLE;
3866 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06860");
3867 m_commandBuffer->BeginRendering(begin_rendering_info);
3868 m_errorMonitor->VerifyFound();
3869
ziga-lunargb7693aa2022-04-23 11:21:57 +02003870 m_commandBuffer->end();
ziga-lunargd12cbce2022-04-23 11:35:20 +02003871}
3872
3873TEST_F(VkLayerTest, InvalidResolveImageViewFormatMatch) {
3874 TEST_DESCRIPTION("Use resolve image view with different format from image view");
3875
3876 SetTargetApiVersion(VK_API_VERSION_1_1);
3877 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3878 ASSERT_NO_FATAL_FAILURE(InitFramework());
3879
3880 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003881 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargd12cbce2022-04-23 11:35:20 +02003882 }
sjfricked700bc02022-05-30 16:35:06 +09003883 if (!AreRequiredExtensionsEnabled()) {
3884 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargd12cbce2022-04-23 11:35:20 +02003885 }
3886
3887 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09003888 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargd12cbce2022-04-23 11:35:20 +02003889 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003890 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargd12cbce2022-04-23 11:35:20 +02003891 }
3892
3893 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3894 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3895
3896 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3897 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3898 image_create_info.format = VK_FORMAT_R8G8B8A8_UINT;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06003899 image_create_info.extent = {32, 32, 1};
ziga-lunargd12cbce2022-04-23 11:35:20 +02003900 image_create_info.mipLevels = 1;
3901 image_create_info.arrayLayers = 1;
3902 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
3903 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3904 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
3905
3906 VkImageObj image(m_device);
3907 image.Init(image_create_info);
3908 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
3909
3910 VkImageObj resolve_image(m_device);
3911 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
3912 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3913
3914 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3915 color_attachment.imageView = image_view;
3916 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3917 color_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
3918 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
3919 color_attachment.resolveImageView = resolve_image_view;
3920
3921 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3922 begin_rendering_info.colorAttachmentCount = 1;
3923 begin_rendering_info.pColorAttachments = &color_attachment;
3924 begin_rendering_info.layerCount = 1;
3925
3926 m_commandBuffer->begin();
3927
Tony-LunarG7384f7e2022-07-05 14:20:42 -06003928 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06865");
ziga-lunargd12cbce2022-04-23 11:35:20 +02003929 m_commandBuffer->BeginRendering(begin_rendering_info);
3930 m_errorMonitor->VerifyFound();
3931
3932 m_commandBuffer->end();
3933}
ziga-lunarge579a3b2022-04-23 11:38:02 +02003934
3935TEST_F(VkLayerTest, InvalidRenderingAttachmentImageViewLayout) {
3936 TEST_DESCRIPTION("Use rendering attachment image view with invalid layout");
3937
3938 SetTargetApiVersion(VK_API_VERSION_1_1);
3939 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3940 ASSERT_NO_FATAL_FAILURE(InitFramework());
3941
3942 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003943 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge579a3b2022-04-23 11:38:02 +02003944 }
sjfricked700bc02022-05-30 16:35:06 +09003945 if (!AreRequiredExtensionsEnabled()) {
3946 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge579a3b2022-04-23 11:38:02 +02003947 }
3948
3949 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09003950 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarge579a3b2022-04-23 11:38:02 +02003951 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003952 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge579a3b2022-04-23 11:38:02 +02003953 }
3954
3955 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3956 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3957
3958 VkImageObj image(m_device);
3959 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
3960 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3961
3962 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3963 color_attachment.imageView = image_view;
3964 color_attachment.imageLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
3965
3966 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3967 begin_rendering_info.colorAttachmentCount = 1;
3968 begin_rendering_info.pColorAttachments = &color_attachment;
3969 begin_rendering_info.layerCount = 1;
3970
3971 m_commandBuffer->begin();
3972
3973 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06135");
3974 m_commandBuffer->BeginRendering(begin_rendering_info);
3975 m_errorMonitor->VerifyFound();
3976
3977 m_commandBuffer->end();
3978}
ziga-lunarg409f8212022-04-23 11:40:53 +02003979
3980TEST_F(VkLayerTest, InvalidResolveImageViewLayout) {
3981 TEST_DESCRIPTION("Use resolve image view with invalid layout");
3982
3983 SetTargetApiVersion(VK_API_VERSION_1_1);
3984 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3985 ASSERT_NO_FATAL_FAILURE(InitFramework());
3986
3987 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003988 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg409f8212022-04-23 11:40:53 +02003989 }
sjfricked700bc02022-05-30 16:35:06 +09003990 if (!AreRequiredExtensionsEnabled()) {
3991 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg409f8212022-04-23 11:40:53 +02003992 }
3993
3994 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09003995 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg409f8212022-04-23 11:40:53 +02003996 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003997 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg409f8212022-04-23 11:40:53 +02003998 }
3999
4000 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4001 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4002
4003 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4004 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4005 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004006 image_create_info.extent = {32, 32, 1};
ziga-lunarg409f8212022-04-23 11:40:53 +02004007 image_create_info.mipLevels = 1;
4008 image_create_info.arrayLayers = 1;
4009 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4010 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4011 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4012
4013 VkImageObj image(m_device);
4014 image.Init(image_create_info);
4015 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4016
4017 VkImageObj resolve_image(m_device);
4018 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4019 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4020
4021 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4022 color_attachment.imageView = image_view;
4023 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4024 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4025 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
4026 color_attachment.resolveImageView = resolve_image_view;
4027
4028 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4029 begin_rendering_info.colorAttachmentCount = 1;
4030 begin_rendering_info.pColorAttachments = &color_attachment;
4031 begin_rendering_info.layerCount = 1;
4032
4033 m_commandBuffer->begin();
4034
4035 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06136");
4036 m_commandBuffer->BeginRendering(begin_rendering_info);
4037 m_errorMonitor->VerifyFound();
4038
4039 m_commandBuffer->end();
4040}
ziga-lunargbbbef242022-04-23 12:12:10 +02004041
4042TEST_F(VkLayerTest, InvalidResolveImageViewLayoutSeparateDepthStencil) {
4043 TEST_DESCRIPTION("Use resolve image view with invalid layout");
4044
4045 SetTargetApiVersion(VK_API_VERSION_1_1);
4046 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4047 AddRequiredExtensions(VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_EXTENSION_NAME);
4048 ASSERT_NO_FATAL_FAILURE(InitFramework());
4049
4050 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004051 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargbbbef242022-04-23 12:12:10 +02004052 }
sjfricked700bc02022-05-30 16:35:06 +09004053 if (!AreRequiredExtensionsEnabled()) {
4054 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargbbbef242022-04-23 12:12:10 +02004055 }
4056
4057 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09004058 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargbbbef242022-04-23 12:12:10 +02004059 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004060 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargbbbef242022-04-23 12:12:10 +02004061 }
4062
4063 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4064 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4065
4066 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4067 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4068 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004069 image_create_info.extent = {32, 32, 1};
ziga-lunargbbbef242022-04-23 12:12:10 +02004070 image_create_info.mipLevels = 1;
4071 image_create_info.arrayLayers = 1;
4072 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4073 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4074 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4075
4076 VkImageObj image(m_device);
4077 image.Init(image_create_info);
4078 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4079
4080 VkImageObj resolve_image(m_device);
4081 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4082 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4083
4084 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4085 color_attachment.imageView = image_view;
4086 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4087 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4088 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL;
4089 color_attachment.resolveImageView = resolve_image_view;
4090
4091 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4092 begin_rendering_info.colorAttachmentCount = 1;
4093 begin_rendering_info.pColorAttachments = &color_attachment;
4094 begin_rendering_info.layerCount = 1;
4095
4096 m_commandBuffer->begin();
4097
4098 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06137");
4099 m_commandBuffer->BeginRendering(begin_rendering_info);
4100 m_errorMonitor->VerifyFound();
4101
4102 m_commandBuffer->end();
4103}
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004104
4105TEST_F(VkLayerTest, InvalidRenderingAttachmentImageViewShadingRateLayout) {
4106 TEST_DESCRIPTION("Use image view with invalid layout");
4107
4108 SetTargetApiVersion(VK_API_VERSION_1_1);
4109 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
sjfricke6e8fb402022-06-05 09:47:58 +09004110 AddOptionalExtensions(VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME);
4111 AddOptionalExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004112 ASSERT_NO_FATAL_FAILURE(InitFramework());
4113
4114 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004115 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004116 }
sjfricked700bc02022-05-30 16:35:06 +09004117 if (!AreRequiredExtensionsEnabled()) {
4118 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004119 }
4120
sjfricke6e8fb402022-06-05 09:47:58 +09004121 const bool nv_shading_rate = IsExtensionsEnabled(VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME);
4122 const bool khr_fragment_shading = IsExtensionsEnabled(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
4123 if (!khr_fragment_shading && !nv_shading_rate) {
4124 GTEST_SKIP() << "shading rate / fragment shading not supported";
4125 }
4126
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004127 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09004128 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004129 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004130 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004131 }
4132
4133 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4134 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4135
4136 VkImageObj image(m_device);
4137 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4138 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4139
4140 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4141 color_attachment.imageView = image_view;
4142 color_attachment.imageLayout = VK_IMAGE_LAYOUT_SHADING_RATE_OPTIMAL_NV;
4143
4144 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4145 begin_rendering_info.colorAttachmentCount = 1;
4146 begin_rendering_info.pColorAttachments = &color_attachment;
4147 begin_rendering_info.layerCount = 1;
4148
4149 m_commandBuffer->begin();
4150
sjfricke6e8fb402022-06-05 09:47:58 +09004151 // SHADING_RATE_OPTIMAL_NV is aliased FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR so VU depends on which extensions
4152 const char *vuid =
4153 khr_fragment_shading ? "VUID-VkRenderingAttachmentInfo-imageView-06143" : "VUID-VkRenderingAttachmentInfo-imageView-06138";
4154 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid);
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004155 m_commandBuffer->BeginRendering(begin_rendering_info);
4156 m_errorMonitor->VerifyFound();
4157
4158 m_commandBuffer->end();
4159}
4160
4161TEST_F(VkLayerTest, InvalidResolveImageViewShadingRateLayout) {
4162 TEST_DESCRIPTION("Use resolve image view with invalid shading ratelayout");
4163
4164 SetTargetApiVersion(VK_API_VERSION_1_1);
4165 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
sjfricke6e8fb402022-06-05 09:47:58 +09004166 AddOptionalExtensions(VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME);
4167 AddOptionalExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004168 ASSERT_NO_FATAL_FAILURE(InitFramework());
4169
4170 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004171 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004172 }
sjfricked700bc02022-05-30 16:35:06 +09004173 if (!AreRequiredExtensionsEnabled()) {
4174 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004175 }
4176
sjfricke6e8fb402022-06-05 09:47:58 +09004177 const bool nv_shading_rate = IsExtensionsEnabled(VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME);
4178 const bool khr_fragment_shading = IsExtensionsEnabled(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
4179 if (!khr_fragment_shading && !nv_shading_rate) {
4180 GTEST_SKIP() << "shading rate / fragment shading not supported";
4181 }
4182
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004183 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09004184 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004185 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004186 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004187 }
4188
4189 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4190 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4191
4192 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4193 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4194 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004195 image_create_info.extent = {32, 32, 1};
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004196 image_create_info.mipLevels = 1;
4197 image_create_info.arrayLayers = 1;
4198 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4199 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4200 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4201
4202 VkImageObj image(m_device);
4203 image.Init(image_create_info);
4204 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4205
4206 VkImageObj resolve_image(m_device);
4207 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4208 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4209
4210 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4211 color_attachment.imageView = image_view;
4212 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4213 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4214 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_SHADING_RATE_OPTIMAL_NV;
4215 color_attachment.resolveImageView = resolve_image_view;
4216
4217 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4218 begin_rendering_info.colorAttachmentCount = 1;
4219 begin_rendering_info.pColorAttachments = &color_attachment;
4220 begin_rendering_info.layerCount = 1;
4221
4222 m_commandBuffer->begin();
4223
sjfricke6e8fb402022-06-05 09:47:58 +09004224 // SHADING_RATE_OPTIMAL_NV is aliased FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR so VU depends on which extensions
4225 const char *vuid =
4226 khr_fragment_shading ? "VUID-VkRenderingAttachmentInfo-imageView-06144" : "VUID-VkRenderingAttachmentInfo-imageView-06139";
4227 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid);
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004228 m_commandBuffer->BeginRendering(begin_rendering_info);
4229 m_errorMonitor->VerifyFound();
4230
4231 m_commandBuffer->end();
4232}
ziga-lunarge7503952022-04-23 12:19:14 +02004233
4234TEST_F(VkLayerTest, InvalidRenderingAttachmentImageViewFragmentDensityLayout) {
4235 TEST_DESCRIPTION("Use image view with invalid layout");
4236
4237 SetTargetApiVersion(VK_API_VERSION_1_1);
4238 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4239 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
4240 ASSERT_NO_FATAL_FAILURE(InitFramework());
4241
4242 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004243 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge7503952022-04-23 12:19:14 +02004244 }
sjfricked700bc02022-05-30 16:35:06 +09004245 if (!AreRequiredExtensionsEnabled()) {
4246 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge7503952022-04-23 12:19:14 +02004247 }
4248
4249 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09004250 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarge7503952022-04-23 12:19:14 +02004251 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004252 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge7503952022-04-23 12:19:14 +02004253 }
4254
4255 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4256 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4257
4258 VkImageObj image(m_device);
4259 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4260 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4261
4262 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4263 color_attachment.imageView = image_view;
4264 color_attachment.imageLayout = VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT;
4265
4266 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4267 begin_rendering_info.colorAttachmentCount = 1;
4268 begin_rendering_info.pColorAttachments = &color_attachment;
4269 begin_rendering_info.layerCount = 1;
4270
4271 m_commandBuffer->begin();
4272
4273 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06140");
4274 m_commandBuffer->BeginRendering(begin_rendering_info);
4275 m_errorMonitor->VerifyFound();
4276
4277 m_commandBuffer->end();
ziga-lunarg10cd0fb2022-04-23 12:20:46 +02004278}
4279
4280TEST_F(VkLayerTest, InvalidResolveImageViewFragmentDensityLayout) {
4281 TEST_DESCRIPTION("Use resolve image view with invalid fragment density layout");
4282
4283 SetTargetApiVersion(VK_API_VERSION_1_1);
4284 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4285 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
4286 ASSERT_NO_FATAL_FAILURE(InitFramework());
4287
4288 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004289 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg10cd0fb2022-04-23 12:20:46 +02004290 }
sjfricked700bc02022-05-30 16:35:06 +09004291 if (!AreRequiredExtensionsEnabled()) {
4292 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg10cd0fb2022-04-23 12:20:46 +02004293 }
4294
4295 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09004296 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg10cd0fb2022-04-23 12:20:46 +02004297 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004298 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg10cd0fb2022-04-23 12:20:46 +02004299 }
4300
4301 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4302 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4303
4304 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4305 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4306 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
4307 image_create_info.extent = {32, 32, 4};
4308 image_create_info.mipLevels = 1;
4309 image_create_info.arrayLayers = 1;
4310 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4311 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4312 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4313
4314 VkImageObj image(m_device);
4315 image.Init(image_create_info);
4316 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4317
4318 VkImageObj resolve_image(m_device);
4319 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4320 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4321
4322 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4323 color_attachment.imageView = image_view;
4324 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4325 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4326 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT;
4327 color_attachment.resolveImageView = resolve_image_view;
4328
4329 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4330 begin_rendering_info.colorAttachmentCount = 1;
4331 begin_rendering_info.pColorAttachments = &color_attachment;
4332 begin_rendering_info.layerCount = 1;
4333
4334 m_commandBuffer->begin();
4335
4336 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06141");
4337 m_commandBuffer->BeginRendering(begin_rendering_info);
4338 m_errorMonitor->VerifyFound();
4339
4340 m_commandBuffer->end();
4341}
ziga-lunargdfa31d12022-04-23 12:22:18 +02004342
4343TEST_F(VkLayerTest, InvalidResolveImageViewReadOnlyOptimalLayout) {
4344 TEST_DESCRIPTION("Use resolve image view with invalid read only optimal layout");
4345
4346 SetTargetApiVersion(VK_API_VERSION_1_1);
4347 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4348 ASSERT_NO_FATAL_FAILURE(InitFramework());
4349
4350 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004351 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargdfa31d12022-04-23 12:22:18 +02004352 }
sjfricked700bc02022-05-30 16:35:06 +09004353 if (!AreRequiredExtensionsEnabled()) {
4354 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargdfa31d12022-04-23 12:22:18 +02004355 }
4356
4357 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09004358 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargdfa31d12022-04-23 12:22:18 +02004359 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004360 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargdfa31d12022-04-23 12:22:18 +02004361 }
4362
4363 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4364 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4365
4366 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4367 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4368 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004369 image_create_info.extent = {32, 32, 1};
ziga-lunargdfa31d12022-04-23 12:22:18 +02004370 image_create_info.mipLevels = 1;
4371 image_create_info.arrayLayers = 1;
4372 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4373 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4374 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4375
4376 VkImageObj image(m_device);
4377 image.Init(image_create_info);
4378 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4379
4380 VkImageObj resolve_image(m_device);
4381 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4382 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4383
4384 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4385 color_attachment.imageView = image_view;
4386 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4387 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4388 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL;
4389 color_attachment.resolveImageView = resolve_image_view;
4390
4391 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4392 begin_rendering_info.colorAttachmentCount = 1;
4393 begin_rendering_info.pColorAttachments = &color_attachment;
4394 begin_rendering_info.layerCount = 1;
4395
4396 m_commandBuffer->begin();
4397
4398 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06142");
4399 m_commandBuffer->BeginRendering(begin_rendering_info);
4400 m_errorMonitor->VerifyFound();
4401
4402 m_commandBuffer->end();
4403}
ziga-lunarg735aa322022-04-24 14:17:47 +02004404
4405TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRateImageView) {
4406 TEST_DESCRIPTION("Test BeginRenderingInfo image view with FragmentShadingRateAttachment.");
4407
4408 SetTargetApiVersion(VK_API_VERSION_1_1);
4409 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4410 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
4411
4412 ASSERT_NO_FATAL_FAILURE(InitFramework());
4413
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004414 if (IsDriver(VK_DRIVER_ID_AMD_PROPRIETARY)) {
4415 GTEST_SKIP() << "Skipping on AMD proprietary driver pending further investigation.";
4416 }
4417
ziga-lunarg735aa322022-04-24 14:17:47 +02004418 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004419 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg735aa322022-04-24 14:17:47 +02004420 }
4421
sjfricked700bc02022-05-30 16:35:06 +09004422 if (!AreRequiredExtensionsEnabled()) {
4423 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg735aa322022-04-24 14:17:47 +02004424 }
4425
4426 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09004427 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg735aa322022-04-24 14:17:47 +02004428
4429 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004430 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg735aa322022-04-24 14:17:47 +02004431 }
4432
4433 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
4434
4435 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
sjfricke74a1aad2022-08-17 14:41:33 +09004436 GetPhysicalDeviceProperties2(phys_dev_props_2);
ziga-lunarg735aa322022-04-24 14:17:47 +02004437
4438 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4439 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4440
4441 VkImageObj image(m_device);
4442 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
4443 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR,
4444 VK_IMAGE_TILING_LINEAR, 0);
4445 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4446
4447 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
4448 fragment_shading_rate.imageView = image_view;
4449 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4450 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
4451
4452 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
4453 begin_rendering_info.layerCount = 1;
4454
4455 m_commandBuffer->begin();
4456
4457 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06147");
4458 m_commandBuffer->BeginRendering(begin_rendering_info);
4459 m_errorMonitor->VerifyFound();
4460
4461 m_commandBuffer->end();
4462}
ziga-lunarg644c0552022-04-24 17:50:58 +02004463
4464TEST_F(VkLayerTest, TestRenderingInfoColorAttachment) {
4465 TEST_DESCRIPTION("Test RenderingInfo color attachment.");
4466
4467 SetTargetApiVersion(VK_API_VERSION_1_1);
4468 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4469
4470 ASSERT_NO_FATAL_FAILURE(InitFramework());
4471
4472 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004473 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg644c0552022-04-24 17:50:58 +02004474 }
4475
sjfricked700bc02022-05-30 16:35:06 +09004476 if (!AreRequiredExtensionsEnabled()) {
4477 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg644c0552022-04-24 17:50:58 +02004478 }
4479
4480 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09004481 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg644c0552022-04-24 17:50:58 +02004482
4483 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004484 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg644c0552022-04-24 17:50:58 +02004485 }
4486
4487 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4488 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4489
4490 VkImageObj invalid_image(m_device);
4491 invalid_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_SAMPLED_BIT, VK_IMAGE_TILING_LINEAR, 0);
4492 VkImageView invalid_image_view = invalid_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4493
4494 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4495 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4496 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004497 image_create_info.extent = {32, 32, 1};
ziga-lunarg644c0552022-04-24 17:50:58 +02004498 image_create_info.mipLevels = 1;
4499 image_create_info.arrayLayers = 1;
4500 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4501 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4502 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4503 image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
4504 VkImageObj image(m_device);
4505 image.Init(image_create_info);
4506 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4507
Tony-LunarGf088c6b2022-07-08 11:29:53 -06004508 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
4509 VkImageObj resolve_image(m_device);
4510 resolve_image.Init(image_create_info);
4511 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4512
ziga-lunarg644c0552022-04-24 17:50:58 +02004513 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4514 color_attachment.imageView = invalid_image_view;
4515 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
Tony-LunarGf088c6b2022-07-08 11:29:53 -06004516 color_attachment.resolveImageView = resolve_image_view;
ziga-lunarg644c0552022-04-24 17:50:58 +02004517
4518 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4519 begin_rendering_info.layerCount = 1;
4520 begin_rendering_info.colorAttachmentCount = 1;
4521 begin_rendering_info.pColorAttachments = &color_attachment;
4522
4523 m_commandBuffer->begin();
4524
4525 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06087");
4526 m_commandBuffer->BeginRendering(begin_rendering_info);
4527 m_errorMonitor->VerifyFound();
4528
4529 color_attachment.imageView = image_view;
4530 color_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4531
4532 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06090");
4533 m_commandBuffer->BeginRendering(begin_rendering_info);
4534 m_errorMonitor->VerifyFound();
4535
4536 color_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
4537 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06096");
4538 m_commandBuffer->BeginRendering(begin_rendering_info);
4539 m_errorMonitor->VerifyFound();
4540
4541 color_attachment.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL;
4542 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06100");
4543 m_commandBuffer->BeginRendering(begin_rendering_info);
4544 m_errorMonitor->VerifyFound();
4545
4546 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4547 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4548 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4549
4550 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06091");
4551 m_commandBuffer->BeginRendering(begin_rendering_info);
4552 m_errorMonitor->VerifyFound();
4553
4554 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
4555 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06097");
4556 m_commandBuffer->BeginRendering(begin_rendering_info);
4557 m_errorMonitor->VerifyFound();
4558
4559 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
4560 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06101");
4561 m_commandBuffer->BeginRendering(begin_rendering_info);
4562 m_errorMonitor->VerifyFound();
4563
4564 color_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
sjfricke483c1082022-06-05 10:21:44 +09004565
ziga-lunarg644c0552022-04-24 17:50:58 +02004566 const uint32_t max_color_attachments = m_device->phy().properties().limits.maxColorAttachments + 1;
4567 std::vector<VkRenderingAttachmentInfoKHR> color_attachments(max_color_attachments);
4568 for (auto &attachment : color_attachments) {
4569 attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4570 attachment.imageView = image_view;
4571 attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4572 }
4573 begin_rendering_info.colorAttachmentCount = max_color_attachments;
4574 begin_rendering_info.pColorAttachments = color_attachments.data();
4575 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06106");
4576 m_commandBuffer->BeginRendering(begin_rendering_info);
4577 m_errorMonitor->VerifyFound();
4578
4579 m_commandBuffer->end();
4580}
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004581
4582TEST_F(VkLayerTest, TestRenderingInfoDepthAttachment) {
4583 TEST_DESCRIPTION("Test RenderingInfo depth attachment.");
4584
4585 SetTargetApiVersion(VK_API_VERSION_1_1);
4586 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4587 AddRequiredExtensions(VK_KHR_DEPTH_STENCIL_RESOLVE_EXTENSION_NAME);
4588
4589 ASSERT_NO_FATAL_FAILURE(InitFramework());
4590
4591 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004592 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004593 }
4594
sjfricked700bc02022-05-30 16:35:06 +09004595 if (!AreRequiredExtensionsEnabled()) {
4596 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004597 }
4598
4599 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09004600 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004601
4602 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004603 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004604 }
4605
4606 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4607 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4608
4609 VkFormat ds_format = FindSupportedDepthStencilFormat(gpu());
4610 if (ds_format == VK_FORMAT_UNDEFINED) {
4611 printf("%s No Depth + Stencil format found, skipping test..\n", kSkipPrefix);
4612 return;
4613 }
4614
4615 auto depth_stencil_resolve_properties = LvlInitStruct<VkPhysicalDeviceDepthStencilResolveProperties>();
4616 auto properties2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&depth_stencil_resolve_properties);
sjfricke74a1aad2022-08-17 14:41:33 +09004617 GetPhysicalDeviceProperties2(properties2);
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004618 bool has_depth_resolve_mode_average =
4619 (depth_stencil_resolve_properties.supportedDepthResolveModes & VK_RESOLVE_MODE_AVERAGE_BIT) != 0;
4620 bool has_stencil_resolve_mode_average =
4621 (depth_stencil_resolve_properties.supportedStencilResolveModes & VK_RESOLVE_MODE_AVERAGE_BIT) != 0;
4622
4623 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4624 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4625 image_create_info.format = ds_format;
4626 image_create_info.extent = {32, 32, 1};
4627 image_create_info.mipLevels = 1;
4628 image_create_info.arrayLayers = 1;
4629 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4630 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4631 image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
4632 VkImageObj image(m_device);
4633 image.Init(image_create_info);
4634
4635 VkImageObj depth_image(m_device);
4636 depth_image.Init(image_create_info);
4637 VkImageView depth_image_view = depth_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4638 VkImageObj stencil_image(m_device);
4639 stencil_image.Init(image_create_info);
4640 VkImageView stencil_image_view = stencil_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4641
4642 VkImageObj depth_resolvel_image(m_device);
4643 depth_resolvel_image.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0);
4644 VkImageView depth_resolve_image_view =
4645 depth_resolvel_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4646
4647 VkImageObj stencil_resolvel_image(m_device);
4648 stencil_resolvel_image.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0);
4649 VkImageView stencil_resolve_image_view =
4650 stencil_resolvel_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4651
4652 VkImageObj invalid_image(m_device);
4653 image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
4654 invalid_image.Init(image_create_info);
4655 VkImageView invalid_image_view = invalid_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT);
4656
4657 auto depth_attachment = LvlInitStruct<VkRenderingAttachmentInfo>();
4658 depth_attachment.imageView = depth_image_view;
4659 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4660
4661 auto stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfo>();
4662 stencil_attachment.imageView = stencil_image_view;
4663 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4664
4665 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4666 begin_rendering_info.layerCount = 1;
4667 begin_rendering_info.pDepthAttachment = &depth_attachment;
4668 begin_rendering_info.pStencilAttachment = &stencil_attachment;
4669
4670 m_commandBuffer->begin();
4671
4672 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06085");
4673 m_commandBuffer->BeginRendering(begin_rendering_info);
4674 m_errorMonitor->VerifyFound();
4675
4676 depth_attachment.imageView = VK_NULL_HANDLE;
4677 stencil_attachment.imageView = VK_NULL_HANDLE;
4678 depth_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4679 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4680 depth_attachment.resolveImageView = depth_resolve_image_view;
4681 stencil_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4682 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4683 stencil_attachment.resolveImageView = stencil_resolve_image_view;
4684
4685 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06086");
4686 m_commandBuffer->BeginRendering(begin_rendering_info);
4687 m_errorMonitor->VerifyFound();
4688
4689 depth_attachment.imageView = depth_image_view;
4690 stencil_attachment.imageView = depth_image_view;
4691 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4692 stencil_attachment.resolveImageView = depth_resolve_image_view;
4693
4694 if (!has_depth_resolve_mode_average) {
4695 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06102");
4696 }
4697 if (!has_stencil_resolve_mode_average) {
4698 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06103");
4699 }
4700 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06093");
4701 m_commandBuffer->BeginRendering(begin_rendering_info);
4702 m_errorMonitor->VerifyFound();
4703
4704 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
4705 if (has_depth_resolve_mode_average && has_stencil_resolve_mode_average) {
4706 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06098");
4707 m_commandBuffer->BeginRendering(begin_rendering_info);
4708 m_errorMonitor->VerifyFound();
4709 }
4710
4711 depth_attachment.imageView = invalid_image_view;
4712 stencil_attachment.imageView = invalid_image_view;
4713 depth_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
4714 stencil_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
4715 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06088");
4716 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06089");
4717 m_commandBuffer->BeginRendering(begin_rendering_info);
4718 m_errorMonitor->VerifyFound();
4719
4720 depth_attachment.imageView = depth_image_view;
4721 stencil_attachment.imageView = depth_image_view;
4722 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4723 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06092");
4724 m_commandBuffer->BeginRendering(begin_rendering_info);
4725 m_errorMonitor->VerifyFound();
4726
4727 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4728 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4729 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4730 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4731 depth_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4732 if (depth_stencil_resolve_properties.independentResolveNone == VK_FALSE && has_depth_resolve_mode_average) {
4733 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06104");
4734 m_commandBuffer->BeginRendering(begin_rendering_info);
4735 m_errorMonitor->VerifyFound();
4736 }
4737 if (depth_stencil_resolve_properties.independentResolve == VK_FALSE && has_depth_resolve_mode_average) {
4738 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06105");
4739 m_commandBuffer->BeginRendering(begin_rendering_info);
4740 m_errorMonitor->VerifyFound();
4741 }
4742
ziga-lunargf35a7d72022-04-25 01:00:41 +02004743 stencil_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4744 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4745 if (has_stencil_resolve_mode_average) {
4746 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06095");
4747 m_commandBuffer->BeginRendering(begin_rendering_info);
4748 m_errorMonitor->VerifyFound();
4749 }
4750 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL;
4751 if (has_stencil_resolve_mode_average) {
4752 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06099");
4753 m_commandBuffer->BeginRendering(begin_rendering_info);
4754 m_errorMonitor->VerifyFound();
4755 }
4756
4757 depth_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
4758 stencil_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
4759 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4760 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06094");
4761 m_commandBuffer->BeginRendering(begin_rendering_info);
4762 m_errorMonitor->VerifyFound();
4763
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004764 m_commandBuffer->end();
4765}
ziga-lunarg002e6562022-04-25 00:54:16 +02004766
4767TEST_F(VkLayerTest, InvalidRenderingRenderAreaWithDeviceGroupExt) {
4768 TEST_DESCRIPTION("Use negative offset in RenderingInfo render area");
4769
4770 SetTargetApiVersion(VK_API_VERSION_1_1);
4771 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4772 ASSERT_NO_FATAL_FAILURE(InitFramework());
4773
4774 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004775 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg002e6562022-04-25 00:54:16 +02004776 }
sjfricked700bc02022-05-30 16:35:06 +09004777 if (!AreRequiredExtensionsEnabled()) {
4778 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg002e6562022-04-25 00:54:16 +02004779 }
4780
4781 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09004782 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
4783 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
4784 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
4785 }
ziga-lunarg002e6562022-04-25 00:54:16 +02004786
4787 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4788 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4789
4790 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4791 begin_rendering_info.layerCount = 1;
4792 begin_rendering_info.renderArea.offset.x = -1;
4793 begin_rendering_info.renderArea.extent.width = 32;
4794 begin_rendering_info.renderArea.extent.height = 32;
4795
4796 m_commandBuffer->begin();
4797
4798 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06077");
4799 m_commandBuffer->BeginRendering(begin_rendering_info);
4800 m_errorMonitor->VerifyFound();
4801
4802 begin_rendering_info.renderArea.offset.x = 0;
4803 begin_rendering_info.renderArea.offset.y = -1;
4804
4805 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06078");
4806 m_commandBuffer->BeginRendering(begin_rendering_info);
4807 m_errorMonitor->VerifyFound();
4808
4809 m_commandBuffer->end();
4810}
ziga-lunarg6e4f9da2022-04-25 01:05:22 +02004811
4812TEST_F(VkLayerTest, TestDynamicRenderingPipeline) {
4813 TEST_DESCRIPTION("Use pipeline created with render pass in dynamic render pass.");
4814
4815 SetTargetApiVersion(VK_API_VERSION_1_1);
4816 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4817
4818 ASSERT_NO_FATAL_FAILURE(InitFramework());
4819
4820 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004821 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg6e4f9da2022-04-25 01:05:22 +02004822 }
4823
sjfricked700bc02022-05-30 16:35:06 +09004824 if (!AreRequiredExtensionsEnabled()) {
4825 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6e4f9da2022-04-25 01:05:22 +02004826 }
4827
4828 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09004829 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg6e4f9da2022-04-25 01:05:22 +02004830
4831 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004832 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6e4f9da2022-04-25 01:05:22 +02004833 }
4834
4835 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4836 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4837
4838 CreatePipelineHelper pipe(*this);
4839 pipe.InitInfo();
4840 pipe.InitState();
4841 pipe.CreateGraphicsPipeline();
4842
4843 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4844 begin_rendering_info.layerCount = 1;
4845
4846 m_commandBuffer->begin();
4847 m_commandBuffer->BeginRendering(begin_rendering_info);
4848
4849 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_);
4850 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-renderPass-06198");
4851 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
4852 m_errorMonitor->VerifyFound();
4853
4854 m_commandBuffer->EndRendering();
4855 m_commandBuffer->end();
ziga-lunarg67551632022-04-25 15:20:20 +02004856}
4857
4858TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRateAttachmentSize) {
4859 TEST_DESCRIPTION("Test FragmentShadingRateAttachment size.");
4860
4861 SetTargetApiVersion(VK_API_VERSION_1_0);
4862 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4863 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004864 AddRequiredExtensions(VK_KHR_MULTIVIEW_EXTENSION_NAME);
ziga-lunarg67551632022-04-25 15:20:20 +02004865
4866 ASSERT_NO_FATAL_FAILURE(InitFramework());
4867
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004868 if (IsDriver(VK_DRIVER_ID_AMD_PROPRIETARY)) {
4869 GTEST_SKIP() << "Skipping on AMD proprietary driver pending further investigation.";
4870 }
4871
ziga-lunarg67551632022-04-25 15:20:20 +02004872 if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
sjfricke50955f32022-06-05 10:12:52 +09004873 GTEST_SKIP() << "Tests for 1.0 only";
ziga-lunarg67551632022-04-25 15:20:20 +02004874 }
4875
sjfricked700bc02022-05-30 16:35:06 +09004876 if (!AreRequiredExtensionsEnabled()) {
4877 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg67551632022-04-25 15:20:20 +02004878 }
4879
ziga-lunarg67551632022-04-25 15:20:20 +02004880 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004881 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeaturesKHR>(&dynamic_rendering_features);
sjfricke11db0c72022-08-18 13:23:11 +09004882 auto features2 = GetPhysicalDeviceFeatures2(multiview_features);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004883 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004884 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg67551632022-04-25 15:20:20 +02004885 }
4886 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004887 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg67551632022-04-25 15:20:20 +02004888 }
4889
4890 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
4891
4892 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
sjfricke74a1aad2022-08-17 14:41:33 +09004893 GetPhysicalDeviceProperties2(phys_dev_props_2);
ziga-lunarg67551632022-04-25 15:20:20 +02004894
4895 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
4896
4897 VkImageObj image(m_device);
4898 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
4899 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR,
4900 VK_IMAGE_TILING_LINEAR, 0);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004901 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
ziga-lunarg67551632022-04-25 15:20:20 +02004902
4903 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
4904 fragment_shading_rate.imageView = image_view;
4905 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
4906 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
4907
4908 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
4909 begin_rendering_info.layerCount = 1;
4910 begin_rendering_info.renderArea.offset.x = fragment_shading_rate.shadingRateAttachmentTexelSize.width * 64;
4911
4912 m_commandBuffer->begin();
4913
4914 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06117");
4915 m_commandBuffer->BeginRendering(begin_rendering_info);
4916 m_errorMonitor->VerifyFound();
4917
4918 begin_rendering_info.renderArea.offset.x = 0;
4919 begin_rendering_info.renderArea.offset.y = fragment_shading_rate.shadingRateAttachmentTexelSize.height * 64;
4920
4921 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06118");
4922 m_commandBuffer->BeginRendering(begin_rendering_info);
4923 m_errorMonitor->VerifyFound();
4924}
4925
4926TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRateAttachmentSizeWithDeviceGroupExt) {
4927 TEST_DESCRIPTION("Test FragmentShadingRateAttachment size with device group extension.");
4928
4929 SetTargetApiVersion(VK_API_VERSION_1_1);
4930 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4931 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004932 AddRequiredExtensions(VK_KHR_MULTIVIEW_EXTENSION_NAME);
ziga-lunarg67551632022-04-25 15:20:20 +02004933
4934 ASSERT_NO_FATAL_FAILURE(InitFramework());
4935
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004936 if (IsDriver(VK_DRIVER_ID_AMD_PROPRIETARY)) {
4937 GTEST_SKIP() << "Skipping on AMD proprietary driver pending further investigation.";
4938 }
4939
ziga-lunarg67551632022-04-25 15:20:20 +02004940 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004941 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg67551632022-04-25 15:20:20 +02004942 }
4943
sjfricked700bc02022-05-30 16:35:06 +09004944 if (!AreRequiredExtensionsEnabled()) {
4945 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg67551632022-04-25 15:20:20 +02004946 }
4947
4948 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004949 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeaturesKHR>(&dynamic_rendering_features);
sjfricke11db0c72022-08-18 13:23:11 +09004950 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(multiview_features);
ziga-lunarg67551632022-04-25 15:20:20 +02004951
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004952 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004953 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg67551632022-04-25 15:20:20 +02004954 }
4955 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004956 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg67551632022-04-25 15:20:20 +02004957 }
4958
4959 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
4960
4961 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
sjfricke74a1aad2022-08-17 14:41:33 +09004962 GetPhysicalDeviceProperties2(phys_dev_props_2);
ziga-lunarg67551632022-04-25 15:20:20 +02004963
4964 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
4965
4966 VkImageObj image(m_device);
4967 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
4968 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR,
4969 VK_IMAGE_TILING_LINEAR, 0);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004970 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
ziga-lunarg67551632022-04-25 15:20:20 +02004971
4972 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
4973 fragment_shading_rate.imageView = image_view;
4974 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
4975 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
4976
4977 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
4978 begin_rendering_info.layerCount = 1;
4979 begin_rendering_info.renderArea.offset.x = fragment_shading_rate.shadingRateAttachmentTexelSize.width * 64;
4980
4981 m_commandBuffer->begin();
4982
4983 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06119");
4984 m_commandBuffer->BeginRendering(begin_rendering_info);
4985 m_errorMonitor->VerifyFound();
4986
4987 begin_rendering_info.renderArea.offset.x = 0;
4988 begin_rendering_info.renderArea.offset.y = fragment_shading_rate.shadingRateAttachmentTexelSize.height * 64;
4989
ziga-lunarg8f9de2a2022-04-25 15:59:19 +02004990 VkRect2D render_area = {};
4991 render_area.offset.x = 0;
4992 render_area.offset.y = 0;
4993 render_area.extent.width = 64 * fragment_shading_rate.shadingRateAttachmentTexelSize.width;
4994 render_area.extent.height = 32;
4995
4996 auto device_group_render_pass_begin_info = LvlInitStruct<VkDeviceGroupRenderPassBeginInfo>();
4997 device_group_render_pass_begin_info.deviceRenderAreaCount = 1;
4998 device_group_render_pass_begin_info.pDeviceRenderAreas = &render_area;
4999 fragment_shading_rate.pNext = &device_group_render_pass_begin_info;
5000
ziga-lunarg7f25dff2022-05-06 17:49:34 +02005001 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06120");
ziga-lunarg8f9de2a2022-04-25 15:59:19 +02005002 m_commandBuffer->BeginRendering(begin_rendering_info);
5003 m_errorMonitor->VerifyFound();
5004
5005 render_area.extent.width = 32;
5006 render_area.extent.height = 64 * fragment_shading_rate.shadingRateAttachmentTexelSize.height;
5007
5008 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06122");
ziga-lunarg67551632022-04-25 15:20:20 +02005009 m_commandBuffer->BeginRendering(begin_rendering_info);
5010 m_errorMonitor->VerifyFound();
5011}
ziga-lunarge966a9a2022-04-25 22:42:08 +02005012
5013TEST_F(VkLayerTest, TestSuspendingRenderPassInstance) {
5014 TEST_DESCRIPTION("Test suspending render pass instance.");
5015
5016 SetTargetApiVersion(VK_API_VERSION_1_1);
5017 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
5018
5019 ASSERT_NO_FATAL_FAILURE(InitFramework());
5020
5021 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09005022 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005023 }
5024
sjfricked700bc02022-05-30 16:35:06 +09005025 if (!AreRequiredExtensionsEnabled()) {
5026 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005027 }
5028
5029 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09005030 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarge966a9a2022-04-25 22:42:08 +02005031
5032 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09005033 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005034 }
5035
5036 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
5037
ziga-lunarge966a9a2022-04-25 22:42:08 +02005038 VkCommandPoolObj command_pool(m_device, m_device->graphics_queue_node_index_);
5039 VkCommandBufferObj cmd_buffer1(m_device, &command_pool);
5040 VkCommandBufferObj cmd_buffer2(m_device, &command_pool);
5041 VkCommandBufferObj cmd_buffer3(m_device, &command_pool);
5042
5043 VkRenderingInfo suspend_rendering_info = LvlInitStruct<VkRenderingInfo>();
5044 suspend_rendering_info.flags = VK_RENDERING_SUSPENDING_BIT;
5045 suspend_rendering_info.layerCount = 1;
5046
5047 VkRenderingInfo resume_rendering_info = LvlInitStruct<VkRenderingInfo>();
5048 resume_rendering_info.flags = VK_RENDERING_RESUMING_BIT;
5049 resume_rendering_info.layerCount = 1;
5050
5051 VkRenderingInfo rendering_info = LvlInitStruct<VkRenderingInfo>();
5052 rendering_info.layerCount = 1;
5053
5054 auto cmd_begin = LvlInitStruct<VkCommandBufferBeginInfo>();
5055
5056 cmd_buffer1.begin(&cmd_begin);
5057 cmd_buffer1.BeginRendering(suspend_rendering_info);
5058 cmd_buffer1.EndRendering();
5059 cmd_buffer1.end();
5060
5061 cmd_buffer2.begin(&cmd_begin);
5062 cmd_buffer2.BeginRendering(resume_rendering_info);
5063 cmd_buffer2.EndRendering();
5064 cmd_buffer2.end();
5065
5066 cmd_buffer3.begin(&cmd_begin);
5067 cmd_buffer3.BeginRendering(rendering_info);
5068 cmd_buffer3.EndRendering();
5069 cmd_buffer3.end();
5070
5071 VkCommandBuffer command_buffers[3] = {cmd_buffer1.handle(), cmd_buffer2.handle()};
5072
5073 VkSubmitInfo submit_info = LvlInitStruct<VkSubmitInfo>();
5074 submit_info.commandBufferCount = 2;
5075 submit_info.pCommandBuffers = command_buffers;
5076 vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5077 vk::QueueWaitIdle(m_device->m_queue);
5078
ziga-lunarge966a9a2022-04-25 22:42:08 +02005079 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo-pCommandBuffers-06014");
5080
5081 submit_info.commandBufferCount = 1;
5082 vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5083 vk::QueueWaitIdle(m_device->m_queue);
5084
5085 m_errorMonitor->VerifyFound();
5086
5087 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo-pCommandBuffers-06016");
5088
5089 command_buffers[1] = cmd_buffer3.handle();
5090 command_buffers[2] = cmd_buffer2.handle();
5091 submit_info.commandBufferCount = 3;
5092 vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5093 vk::QueueWaitIdle(m_device->m_queue);
5094
5095 m_errorMonitor->VerifyFound();
5096
5097 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo-pCommandBuffers-06193");
5098
5099 command_buffers[0] = cmd_buffer2.handle();
5100 submit_info.commandBufferCount = 1;
5101 vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5102 vk::QueueWaitIdle(m_device->m_queue);
5103
5104 m_errorMonitor->VerifyFound();
5105}
5106
5107TEST_F(VkLayerTest, TestSuspendingRenderPassInstanceQueueSubmit2) {
5108 TEST_DESCRIPTION("Test suspending render pass instance with QueueSubmit2.");
5109
5110 SetTargetApiVersion(VK_API_VERSION_1_1);
5111 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
5112 AddRequiredExtensions(VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME);
5113
5114 ASSERT_NO_FATAL_FAILURE(InitFramework());
5115
5116 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09005117 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005118 }
5119
sjfricked700bc02022-05-30 16:35:06 +09005120 if (!AreRequiredExtensionsEnabled()) {
5121 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005122 }
5123
5124 auto synchronization2 = LvlInitStruct<VkPhysicalDeviceSynchronization2Features>();
5125 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&synchronization2);
sjfricke11db0c72022-08-18 13:23:11 +09005126 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarge966a9a2022-04-25 22:42:08 +02005127
5128 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09005129 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005130 }
5131 if (synchronization2.synchronization2 == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09005132 GTEST_SKIP() << "Test requires (unsupported) synchronization2";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005133 }
5134
5135 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
5136
5137 auto vkQueueSubmit2KHR =
5138 reinterpret_cast<PFN_vkQueueSubmit2KHR>(vk::GetDeviceProcAddr(m_device->device(), "vkQueueSubmit2KHR"));
5139 ASSERT_TRUE(vkQueueSubmit2KHR != nullptr);
5140
ziga-lunarge966a9a2022-04-25 22:42:08 +02005141 VkCommandPoolObj command_pool(m_device, m_device->graphics_queue_node_index_);
5142 VkCommandBufferObj cmd_buffer1(m_device, &command_pool);
5143 VkCommandBufferObj cmd_buffer2(m_device, &command_pool);
5144 VkCommandBufferObj cmd_buffer3(m_device, &command_pool);
5145
5146 VkRenderingInfo suspend_rendering_info = LvlInitStruct<VkRenderingInfo>();
5147 suspend_rendering_info.flags = VK_RENDERING_SUSPENDING_BIT;
5148 suspend_rendering_info.layerCount = 1;
5149
5150 VkRenderingInfo resume_rendering_info = LvlInitStruct<VkRenderingInfo>();
5151 resume_rendering_info.flags = VK_RENDERING_RESUMING_BIT;
5152 resume_rendering_info.layerCount = 1;
5153
5154 VkRenderingInfo rendering_info = LvlInitStruct<VkRenderingInfo>();
5155 rendering_info.layerCount = 1;
5156
5157 auto cmd_begin = LvlInitStruct<VkCommandBufferBeginInfo>();
5158
5159 cmd_buffer1.begin(&cmd_begin);
5160 cmd_buffer1.BeginRendering(suspend_rendering_info);
5161 cmd_buffer1.EndRendering();
5162 cmd_buffer1.end();
5163
5164 cmd_buffer2.begin(&cmd_begin);
5165 cmd_buffer2.BeginRendering(resume_rendering_info);
5166 cmd_buffer2.EndRendering();
5167 cmd_buffer2.end();
5168
5169 cmd_buffer3.begin(&cmd_begin);
5170 cmd_buffer3.BeginRendering(rendering_info);
5171 cmd_buffer3.EndRendering();
5172 cmd_buffer3.end();
5173
5174 VkCommandBufferSubmitInfo command_buffer_submit_info[3];
5175 command_buffer_submit_info[0] = LvlInitStruct<VkCommandBufferSubmitInfo>();
5176 command_buffer_submit_info[1] = LvlInitStruct<VkCommandBufferSubmitInfo>();
5177 command_buffer_submit_info[2] = LvlInitStruct<VkCommandBufferSubmitInfo>();
5178
5179 command_buffer_submit_info[0].commandBuffer = cmd_buffer1.handle();
5180 command_buffer_submit_info[1].commandBuffer = cmd_buffer2.handle();
5181
5182 VkSubmitInfo2KHR submit_info = LvlInitStruct<VkSubmitInfo2KHR>();
5183 submit_info.commandBufferInfoCount = 2;
5184 submit_info.pCommandBufferInfos = command_buffer_submit_info;
5185 vkQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5186 vk::QueueWaitIdle(m_device->m_queue);
5187
ziga-lunarge966a9a2022-04-25 22:42:08 +02005188 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo2KHR-commandBuffer-06010");
5189
5190 submit_info.commandBufferInfoCount = 1;
5191 vkQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5192 vk::QueueWaitIdle(m_device->m_queue);
5193
5194 m_errorMonitor->VerifyFound();
5195
5196 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo2KHR-commandBuffer-06012");
5197
5198 command_buffer_submit_info[1].commandBuffer = cmd_buffer3.handle();
5199 command_buffer_submit_info[2].commandBuffer = cmd_buffer2.handle();
5200 submit_info.commandBufferInfoCount = 3;
5201 vkQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5202 vk::QueueWaitIdle(m_device->m_queue);
5203
5204 m_errorMonitor->VerifyFound();
5205
5206 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo2KHR-commandBuffer-06192");
5207
5208 command_buffer_submit_info[0].commandBuffer = cmd_buffer2.handle();
5209 submit_info.commandBufferInfoCount = 1;
5210 vkQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5211 vk::QueueWaitIdle(m_device->m_queue);
5212
5213 m_errorMonitor->VerifyFound();
5214}
paul-lunarg8636b212022-09-14 17:13:17 +02005215
5216TEST_F(VkLayerTest, DynamicNullDepthStencilExecuteCommands) {
5217 TEST_DESCRIPTION(
5218 "Test for NULL depth stencil attachments in dynamic rendering with secondary command buffer with depth stencil format "
5219 "inheritance info");
5220
5221 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
5222 AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
5223 ASSERT_NO_FATAL_FAILURE(InitFramework());
5224
5225 if (!AreRequiredExtensionsEnabled()) {
5226 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported.";
5227 }
5228
5229 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
5230 dynamic_rendering_features.dynamicRendering = VK_TRUE;
5231 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
5232
5233 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
5234
5235 // Create secondary command buffer
5236 VkCommandPoolObj pool(m_device, m_device->graphics_queue_node_index_, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT);
5237 VkCommandBufferObj secondary(m_device, &pool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
5238
5239 VkFormat depth_stencil_format = FindSupportedDepthStencilFormat(gpu());
5240
5241 if (depth_stencil_format == VK_FORMAT_UNDEFINED) {
5242 GTEST_SKIP() << "No found depth stencil format";
5243 }
5244
5245 auto cbiri = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>();
5246 // format is defined, although no image view provided in dynamic rendering
5247 cbiri.depthAttachmentFormat = depth_stencil_format;
5248 cbiri.stencilAttachmentFormat = depth_stencil_format;
5249 cbiri.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
5250 auto cbii = LvlInitStruct<VkCommandBufferInheritanceInfo>(&cbiri);
5251
5252 auto cbbi = LvlInitStruct<VkCommandBufferBeginInfo>();
5253 cbbi.pInheritanceInfo = &cbii;
5254 cbbi.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT | VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
5255
5256 // Prepare primary dynamic rendering cmd buffer
5257 VkDepthStencilObj depth_stencil(m_device);
5258 depth_stencil.Init(m_device, 32, 32, depth_stencil_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
5259 VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
5260
5261 auto rai = LvlInitStruct<VkRenderingAttachmentInfo>();
5262 rai.imageView = *depth_stencil.BindInfo();
5263 rai.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
5264
5265 auto ri = LvlInitStruct<VkRenderingInfoKHR>();
5266 ri.flags = VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR;
5267 ri.layerCount = 1;
5268 ri.pDepthAttachment = &rai;
5269 ri.pStencilAttachment = &rai;
5270
5271 // Record secondary cmd buffer with depth stencil format
5272 secondary.begin(&cbbi);
5273 secondary.end();
5274
5275 // Record primary cmd buffer with depth stencil
5276 m_commandBuffer->begin();
5277 m_commandBuffer->BeginRendering(ri);
5278 vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle());
5279 m_commandBuffer->EndRendering();
5280 m_commandBuffer->end();
5281
5282 // Retry with null depth stencil attachment image view
5283 rai.imageView = VK_NULL_HANDLE;
5284
5285 m_commandBuffer->begin();
5286 m_commandBuffer->BeginRendering(ri);
5287 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pDepthAttachment-06774");
5288 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pStencilAttachment-06775");
5289 vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle());
5290 m_errorMonitor->VerifyFound();
5291 m_commandBuffer->EndRendering();
5292 m_commandBuffer->end();
5293
5294 // Retry with nullptr attachment struct
5295 ri.pDepthAttachment = nullptr;
5296 ri.pStencilAttachment = nullptr;
5297
5298 m_commandBuffer->begin();
5299 m_commandBuffer->BeginRendering(ri);
5300 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pDepthAttachment-06774");
5301 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pStencilAttachment-06775");
5302 vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle());
5303 m_errorMonitor->VerifyFound();
5304 m_commandBuffer->EndRendering();
5305 m_commandBuffer->end();
5306
5307 // Retry with no format in inheritance info
5308 cbiri.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
5309 cbiri.stencilAttachmentFormat = VK_FORMAT_UNDEFINED;
5310
5311 secondary.begin(&cbbi);
5312 secondary.end();
5313
5314 m_commandBuffer->begin();
5315 m_commandBuffer->BeginRendering(ri);
5316 vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary.handle());
5317 m_commandBuffer->EndRendering();
5318 m_commandBuffer->end();
5319}