blob: a4c159df552597b8486d3d8086c9afa49bc33fb3 [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
23 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2);
24 if (version < VK_API_VERSION_1_2) {
25 printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix);
26 return;
27 }
sfricke-samsungae54c1e2022-01-21 05:35:21 -080028
Aaron Haganaca50442021-12-07 22:26:29 -050029 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
Nathaniel Cesarioa06135e2022-03-02 21:22:30 -070030 ASSERT_NO_FATAL_FAILURE(InitFramework());
Aaron Haganaca50442021-12-07 22:26:29 -050031
sjfricked700bc02022-05-30 16:35:06 +090032 if (!AreRequiredExtensionsEnabled()) {
33 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
Aaron Haganb54466d2022-02-18 15:02:54 -050034 }
35
Aaron Haganaca50442021-12-07 22:26:29 -050036 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
sjfrickebdd58dd2022-05-20 14:22:50 +090037 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
Aaron Haganaca50442021-12-07 22:26:29 -050038 }
sfricke-samsungae54c1e2022-01-21 05:35:21 -080039
Nathaniel Cesarioa06135e2022-03-02 21:22:30 -070040 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
41 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
42 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
43 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +090044 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
Aaron Haganaca50442021-12-07 22:26:29 -050045 }
46
ziga-lunargf54cb2a2022-03-11 02:54:27 +010047 features2.features.variableMultisampleRate = VK_FALSE;
48
Nathaniel Cesarioa06135e2022-03-02 21:22:30 -070049 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
50
Aaron Haganaca50442021-12-07 22:26:29 -050051 VkPhysicalDeviceMultiviewProperties multiview_props = LvlInitStruct<VkPhysicalDeviceMultiviewProperties>();
52 VkPhysicalDeviceProperties2 pd_props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&multiview_props);
53 vk::GetPhysicalDeviceProperties2(gpu(), &pd_props2);
54
55 if (multiview_props.maxMultiviewViewCount == 32) {
56 printf("%s VUID is not testable as maxMultiviewViewCount is 32, skipping test\n", kSkipPrefix);
57 return;
58 }
59
60 VkFormat color_format = VK_FORMAT_D32_SFLOAT;
61
62 auto cmd_buffer_inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>();
63 cmd_buffer_inheritance_rendering_info.colorAttachmentCount = 1;
64 cmd_buffer_inheritance_rendering_info.pColorAttachmentFormats = &color_format;
65 cmd_buffer_inheritance_rendering_info.depthAttachmentFormat = VK_FORMAT_R8G8B8_UNORM;
66 cmd_buffer_inheritance_rendering_info.stencilAttachmentFormat = VK_FORMAT_R8G8B8_SNORM;
67 cmd_buffer_inheritance_rendering_info.viewMask = 1 << multiview_props.maxMultiviewViewCount;
68
69 auto sample_count_info_amd = LvlInitStruct<VkAttachmentSampleCountInfoAMD>();
70 sample_count_info_amd.pNext = &cmd_buffer_inheritance_rendering_info;
71 sample_count_info_amd.colorAttachmentCount = 2;
sfricke-samsungae54c1e2022-01-21 05:35:21 -080072
Aaron Haganaca50442021-12-07 22:26:29 -050073 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
74 cmd_buffer_inheritance_info.pNext = &sample_count_info_amd;
75
76 auto cmd_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>();
77 cmd_buffer_allocate_info.commandPool = m_commandPool->handle();
78 cmd_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY;
79 cmd_buffer_allocate_info.commandBufferCount = 0x1;
80
81 VkCommandBuffer secondary_cmd_buffer;
82 VkResult err = vk::AllocateCommandBuffers(m_device->device(), &cmd_buffer_allocate_info, &secondary_cmd_buffer);
83 ASSERT_VK_SUCCESS(err);
84 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06003");
Tony-LunarGbbd2ab92021-12-02 08:31:24 -070085 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-colorAttachmentCount-06004");
86 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-variableMultisampleRate-06005");
87 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-depthAttachmentFormat-06007");
88 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-multiview-06008");
89 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-viewMask-06009");
ziga-lunarg813fa012022-04-09 14:09:57 +020090 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-stencilAttachmentFormat-06199");
91 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-depthAttachmentFormat-06200");
92 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-pColorAttachmentFormats-06006");
93 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-depthAttachmentFormat-06540");
ziga-lunarga3cc8482022-04-29 14:58:29 +020094 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-stencilAttachmentFormat-06541");
Aaron Haganaca50442021-12-07 22:26:29 -050095
96 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
97 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
98 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
99 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
100 m_errorMonitor->VerifyFound();
101}
102
Aaron Haganb54466d2022-02-18 15:02:54 -0500103TEST_F(VkLayerTest, DynamicRenderingCommandDraw) {
Aaron Haganaca50442021-12-07 22:26:29 -0500104 TEST_DESCRIPTION("vkCmdDraw* Dynamic Rendering Tests.");
105
106 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2);
107 if (version < VK_API_VERSION_1_2) {
108 printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix);
109 return;
110 }
111
112 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
113
114 ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor));
115
116 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900117 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
Aaron Haganaca50442021-12-07 22:26:29 -0500118 }
119
sjfricked700bc02022-05-30 16:35:06 +0900120 if (!AreRequiredExtensionsEnabled()) {
121 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
Aaron Haganaca50442021-12-07 22:26:29 -0500122 }
123
124 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
125 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
126 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
127 if (!dynamic_rendering_features.dynamicRendering) {
128 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
129 return;
130 }
131
132 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
133
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800134 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
135 VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT);
Aaron Haganaca50442021-12-07 22:26:29 -0500136
137 VkPipelineObj pipe(m_device);
138 pipe.AddShader(&vs);
139 pipe.AddShader(&fs);
140 pipe.AddDefaultColorAttachment();
141
142 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
143 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
144 const VkPipelineLayoutObj pl(m_device, {&dsl});
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800145
Aaron Haganaca50442021-12-07 22:26:29 -0500146 VkFormat depth_format = VK_FORMAT_D32_SFLOAT_S8_UINT;
147 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
Aaron Hagan80034ea2021-12-23 11:24:09 -0500148 pipeline_rendering_info.depthAttachmentFormat = depth_format;
149 pipeline_rendering_info.stencilAttachmentFormat = depth_format;
Aaron Haganaca50442021-12-07 22:26:29 -0500150
151 auto multisample_state_create_info = LvlInitStruct<VkPipelineMultisampleStateCreateInfo>();
152 multisample_state_create_info.rasterizationSamples = VK_SAMPLE_COUNT_2_BIT;
153
154 auto create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
155 pipe.InitGraphicsPipelineCreateInfo(&create_info);
156 create_info.pMultisampleState = &multisample_state_create_info;
157 create_info.renderPass = VkRenderPass(0x1);
158 create_info.pNext = &pipeline_rendering_info;
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800159
Aaron Haganaca50442021-12-07 22:26:29 -0500160 VkResult err = pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
161 ASSERT_VK_SUCCESS(err);
162
163 VkViewport viewport = {0, 0, 16, 16, 0, 1};
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800164 VkRect2D scissor = {{0, 0}, {16, 16}};
Aaron Haganaca50442021-12-07 22:26:29 -0500165
166 VkImageObj image(m_device);
167 image.Init(32, 32, 1, depth_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
168 ASSERT_TRUE(image.initialized());
169
170 VkImageViewCreateInfo ivci = {VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
171 nullptr,
172 0,
173 image.handle(),
174 VK_IMAGE_VIEW_TYPE_2D,
175 depth_format,
176 {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
177 VK_COMPONENT_SWIZZLE_IDENTITY},
178 {VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, 0, 1, 0, 1}};
179
180 VkImageView depth_image_view;
181 err = vk::CreateImageView(m_device->device(), &ivci, nullptr, &depth_image_view);
182 ASSERT_VK_SUCCESS(err);
183
184 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
185 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
186 depth_attachment.imageView = depth_image_view;
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800187
Aaron Haganaca50442021-12-07 22:26:29 -0500188 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
189 begin_rendering_info.pDepthAttachment = &depth_attachment;
190 begin_rendering_info.pStencilAttachment = &depth_attachment;
191
192 m_commandBuffer->begin();
193 m_commandBuffer->BeginRendering(begin_rendering_info);
194 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle());
195 vk::CmdSetViewport(m_commandBuffer->handle(), 0, 1, &viewport);
196 vk::CmdSetScissor(m_commandBuffer->handle(), 0, 1, &scissor);
197 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06189");
198 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06190");
199 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
200 m_errorMonitor->VerifyFound();
201 m_commandBuffer->EndRendering();
202 m_commandBuffer->end();
203}
204
205TEST_F(VkLayerTest, DynamicRenderingGraphicsPipelineCreateInfo) {
206 TEST_DESCRIPTION("Test graphics pipeline creation with dynamic rendering.");
Nathaniel Cesario72f29552022-03-24 05:11:11 -0600207 m_errorMonitor->ExpectSuccess();
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800208
Aaron Haganaca50442021-12-07 22:26:29 -0500209 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2);
210 if (version < VK_API_VERSION_1_2) {
211 printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix);
212 return;
213 }
214
215 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
216
217 ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor));
218
219 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900220 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
Aaron Haganaca50442021-12-07 22:26:29 -0500221 }
222
sjfricked700bc02022-05-30 16:35:06 +0900223 if (!AreRequiredExtensionsEnabled()) {
224 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
Aaron Haganaca50442021-12-07 22:26:29 -0500225 }
226
227 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
228 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
229 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
230 if (!dynamic_rendering_features.dynamicRendering) {
231 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
232 return;
233 }
234
235 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
236
237 const VkPipelineLayoutObj pl(m_device);
238 VkPipelineObj pipe(m_device);
239
240 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
241
242 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
243 color_blend_state_create_info.attachmentCount = 1;
244 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
245
246 VkFormat color_format[2] = {VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_D32_SFLOAT_S8_UINT};
247
248 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
249 pipeline_rendering_info.colorAttachmentCount = 2;
250 pipeline_rendering_info.pColorAttachmentFormats = &color_format[0];
251 pipeline_rendering_info.viewMask = 0x2;
Aaron Hagan80034ea2021-12-23 11:24:09 -0500252 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
Aaron Haganaca50442021-12-07 22:26:29 -0500253
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800254 auto pipeline_tessellation_state_info = LvlInitStruct<VkPipelineTessellationStateCreateInfo>();
Aaron Haganaca50442021-12-07 22:26:29 -0500255 pipeline_tessellation_state_info.patchControlPoints = 1;
256
257 auto pipeline_input_assembly_state_info = LvlInitStruct<VkPipelineInputAssemblyStateCreateInfo>();
258 pipeline_input_assembly_state_info.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST;
259
260 auto create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
Aaron Hagan80034ea2021-12-23 11:24:09 -0500261
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800262 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
263 VkShaderObj gs(this, bindStateGeomShaderText, VK_SHADER_STAGE_GEOMETRY_BIT);
264 VkShaderObj te(this, bindStateTeshaderText, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT);
265 VkShaderObj tc(this, bindStateTscShaderText, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT);
Aaron Hagan80034ea2021-12-23 11:24:09 -0500266 VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT);
267
Aaron Haganaca50442021-12-07 22:26:29 -0500268 pipe.AddShader(&vs);
269 pipe.AddShader(&gs);
270 pipe.AddShader(&te);
271 pipe.AddShader(&tc);
Aaron Hagan80034ea2021-12-23 11:24:09 -0500272 pipe.AddShader(&fs);
Aaron Haganaca50442021-12-07 22:26:29 -0500273 pipe.InitGraphicsPipelineCreateInfo(&create_info);
Nathaniel Cesario72f29552022-03-24 05:11:11 -0600274 m_errorMonitor->VerifyNotFound();
275
Aaron Haganaca50442021-12-07 22:26:29 -0500276 create_info.pColorBlendState = &color_blend_state_create_info;
277 create_info.pNext = &pipeline_rendering_info;
278 create_info.pTessellationState = &pipeline_tessellation_state_info;
279 create_info.pInputAssemblyState = &pipeline_input_assembly_state_info;
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800280
Aaron Hagan80034ea2021-12-23 11:24:09 -0500281 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06053");
Nathaniel Cesario72f29552022-03-24 05:11:11 -0600282 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06581");
Aaron Haganaca50442021-12-07 22:26:29 -0500283 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06055");
284 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06057");
285 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06058");
286 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06060");
Nathaniel Cesarioa6118572022-03-24 04:48:33 -0600287 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-multiview-06577");
Aaron Haganaca50442021-12-07 22:26:29 -0500288 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
289 m_errorMonitor->VerifyFound();
290
Aaron Hagan80034ea2021-12-23 11:24:09 -0500291 create_info.pColorBlendState = nullptr;
292 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
293 pipeline_rendering_info.viewMask = 0x0;
294 pipeline_rendering_info.colorAttachmentCount = 1;
295 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06054");
296 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
297 m_errorMonitor->VerifyFound();
Aaron Haganb54466d2022-02-18 15:02:54 -0500298
ziga-lunarg5e671602022-03-17 19:06:55 +0100299 color_format[0] = VK_FORMAT_D32_SFLOAT_S8_UINT;
300 color_blend_attachment_state.blendEnable = VK_TRUE;
301 create_info.pColorBlendState = &color_blend_state_create_info;
Nathaniel Cesario72f29552022-03-24 05:11:11 -0600302 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06581");
ziga-lunarg5e671602022-03-17 19:06:55 +0100303 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06062");
ziga-lunarg5e671602022-03-17 19:06:55 +0100304 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
305 m_errorMonitor->VerifyFound();
306 color_format[0] = VK_FORMAT_R8G8B8A8_UNORM;
307
Aaron Haganb54466d2022-02-18 15:02:54 -0500308 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
309 ds_ci.flags = VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM;
310 color_blend_state_create_info.flags = VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM;
311 create_info.pColorBlendState = &color_blend_state_create_info;
312 create_info.pDepthStencilState = &ds_ci;
313 create_info.renderPass = VK_NULL_HANDLE;
314 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
315 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06482");
316 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06483");
317 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
318 m_errorMonitor->VerifyFound();
stusmith15f24a82021-12-24 15:21:19 +0000319}
320
321TEST_F(VkLayerTest, DynamicRenderingWithMismatchingViewMask) {
322 TEST_DESCRIPTION("Draw with Dynamic Rendering and a mismatching viewMask");
323
324 SetTargetApiVersion(VK_API_VERSION_1_1);
325
326 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
327
328 ASSERT_NO_FATAL_FAILURE(InitFramework());
329
sjfricked700bc02022-05-30 16:35:06 +0900330 if (!AreRequiredExtensionsEnabled()) {
331 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
stusmith15f24a82021-12-24 15:21:19 +0000332 }
333
334 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900335 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
stusmith15f24a82021-12-24 15:21:19 +0000336 }
337
338 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
339 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(&multiview_features);
340 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
341 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
342 if (!dynamic_rendering_features.dynamicRendering) {
343 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
344 return;
345 }
346 if (!multiview_features.multiview) {
347 printf("%s Test requires (unsupported) multiview , skipping\n", kSkipPrefix);
348 return;
349 }
350
351 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
352
353 char const *fsSource = R"glsl(
354 #version 450
355 layout(location=0) out vec4 color;
356 void main() {
357 color = vec4(1.0f);
358 }
359 )glsl";
360
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800361 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
362 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000363
364 VkPipelineObj pipe(m_device);
365 pipe.AddShader(&vs);
366 pipe.AddShader(&fs);
367 pipe.AddDefaultColorAttachment();
368
369 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
370 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
371 const VkPipelineLayoutObj pl(m_device, {&dsl});
372
373 VkFormat color_formats = {VK_FORMAT_R8G8B8A8_UNORM};
374 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
375 pipeline_rendering_info.colorAttachmentCount = 1;
376 pipeline_rendering_info.pColorAttachmentFormats = &color_formats;
377 pipeline_rendering_info.viewMask = 1;
378
379 VkViewport viewport = {0, 0, 16, 16, 0, 1};
380 VkRect2D scissor = {{0, 0}, {16, 16}};
381 m_viewports.push_back(viewport);
382 m_scissors.push_back(scissor);
383 pipe.SetViewport(m_viewports);
384 pipe.SetScissor(m_scissors);
385
386 auto create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
387 pipe.InitGraphicsPipelineCreateInfo(&create_info);
388 create_info.pNext = &pipeline_rendering_info;
389
390 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
391
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800392 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000393 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
394
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800395 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000396 begin_rendering_info.colorAttachmentCount = 1;
397 begin_rendering_info.pColorAttachments = &color_attachment;
398 begin_rendering_info.viewMask = 2;
399 begin_rendering_info.layerCount = 1;
400
401 m_commandBuffer->begin();
402 m_commandBuffer->BeginRendering(begin_rendering_info);
403 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle());
404 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-viewMask-06178");
405 m_commandBuffer->Draw(1, 1, 0, 0);
406 m_errorMonitor->VerifyFound();
407 m_commandBuffer->EndRendering();
408 m_commandBuffer->end();
409}
410
411TEST_F(VkLayerTest, DynamicRenderingWithMistmatchingAttachments) {
412 TEST_DESCRIPTION("Draw with Dynamic Rendering with mismatching color attachment counts and depth/stencil formats");
413
414 SetTargetApiVersion(VK_API_VERSION_1_1);
415
416 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
417
418 ASSERT_NO_FATAL_FAILURE(InitFramework());
419
sjfricked700bc02022-05-30 16:35:06 +0900420 if (!AreRequiredExtensionsEnabled()) {
421 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
stusmith15f24a82021-12-24 15:21:19 +0000422 }
423
424 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900425 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
stusmith15f24a82021-12-24 15:21:19 +0000426 }
427
428 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
429 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
430 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
431 if (!dynamic_rendering_features.dynamicRendering) {
432 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
433 return;
434 }
435
436 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
437
438 char const *fsSource = R"glsl(
439 #version 450
440 layout(location=0) out vec4 color;
441 void main() {
442 color = vec4(1.0f);
443 }
444 )glsl";
445
446 VkViewport viewport = {0, 0, 16, 16, 0, 1};
447 VkRect2D scissor = {{0, 0}, {16, 16}};
448 m_viewports.push_back(viewport);
449 m_scissors.push_back(scissor);
450
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800451 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
452 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000453
454 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
455 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
456 const VkPipelineLayoutObj pl(m_device, {&dsl});
457
458 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
459
460 VkPipelineObj pipe1(m_device);
461 pipe1.AddShader(&vs);
462 pipe1.AddShader(&fs);
463 pipe1.AddDefaultColorAttachment();
464 pipe1.SetViewport(m_viewports);
465 pipe1.SetScissor(m_scissors);
466
467 VkFormat color_formats[] = {VK_FORMAT_R8G8B8A8_UNORM};
468 pipeline_rendering_info.colorAttachmentCount = 1;
469 pipeline_rendering_info.pColorAttachmentFormats = color_formats;
470
471 auto create_info1 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
472 pipe1.InitGraphicsPipelineCreateInfo(&create_info1);
473 create_info1.pNext = &pipeline_rendering_info;
474
475 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
476
477 VkPipelineObj pipe2(m_device);
478 pipe2.AddShader(&vs);
479 pipe2.AddShader(&fs);
480 pipe2.AddDefaultColorAttachment();
481 pipe2.SetViewport(m_viewports);
482 pipe2.SetScissor(m_scissors);
483
484 pipeline_rendering_info.colorAttachmentCount = 0;
485 pipeline_rendering_info.pColorAttachmentFormats = nullptr;
486 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_D16_UNORM;
487
488 auto create_info2 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
489 pipe2.InitGraphicsPipelineCreateInfo(&create_info2);
490 create_info2.pNext = &pipeline_rendering_info;
491
492 pipe2.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info2);
493
494 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
495 ASSERT_TRUE(depthStencilFormat != 0);
496
497 bool testStencil = false;
498 VkFormat stencilFormat = VK_FORMAT_UNDEFINED;
499
500 if (ImageFormatIsSupported(gpu(), VK_FORMAT_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
501 stencilFormat = VK_FORMAT_S8_UINT;
502 testStencil = true;
503 } else if ((depthStencilFormat != VK_FORMAT_D16_UNORM_S8_UINT) &&
504 ImageFormatIsSupported(gpu(), VK_FORMAT_D16_UNORM_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
505 stencilFormat = VK_FORMAT_D16_UNORM_S8_UINT;
506 testStencil = true;
507 } else if ((depthStencilFormat != VK_FORMAT_D24_UNORM_S8_UINT) &&
508 ImageFormatIsSupported(gpu(), VK_FORMAT_D24_UNORM_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
509 stencilFormat = VK_FORMAT_D24_UNORM_S8_UINT;
510 testStencil = true;
511 } else if ((depthStencilFormat != VK_FORMAT_D32_SFLOAT_S8_UINT) &&
512 ImageFormatIsSupported(gpu(), VK_FORMAT_D32_SFLOAT_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
513 stencilFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
514 testStencil = true;
515 }
516
517 VkPipelineObj pipe3(m_device);
518
519 if (testStencil) {
520 pipe3.AddShader(&vs);
521 pipe3.AddShader(&fs);
522 pipe3.AddDefaultColorAttachment();
523 pipe3.SetViewport(m_viewports);
524 pipe3.SetScissor(m_scissors);
525
526 pipeline_rendering_info.colorAttachmentCount = 0;
527 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
528 pipeline_rendering_info.stencilAttachmentFormat = stencilFormat;
529
530 auto create_info3 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
531 pipe3.InitGraphicsPipelineCreateInfo(&create_info3);
532 create_info3.pNext = &pipeline_rendering_info;
533
534 pipe3.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info3);
535 }
536
537 VkImageObj colorImage(m_device);
538 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
539 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
540
541 VkImageObj depthStencilImage(m_device);
542 depthStencilImage.Init(32, 32, 1, depthStencilFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
543 VkImageView depthStencilImageView =
544 depthStencilImage.targetView(depthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
545
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800546 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000547 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
548 color_attachment.imageView = colorImageView;
549
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800550 VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000551 depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
552 depth_stencil_attachment.imageView = depthStencilImageView;
553
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800554 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000555 m_commandBuffer->begin();
556
557 // Mismatching color attachment count
558 m_commandBuffer->BeginRendering(begin_rendering_info);
559 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
560 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06179");
561 m_commandBuffer->Draw(1, 1, 0, 0);
562 m_errorMonitor->VerifyFound();
563 m_commandBuffer->EndRendering();
564
565 // Mismatching color formats
566 begin_rendering_info.colorAttachmentCount = 1;
567 begin_rendering_info.pColorAttachments = &color_attachment;
568 m_commandBuffer->BeginRendering(begin_rendering_info);
569 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
570 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06180");
571 m_commandBuffer->Draw(1, 1, 0, 0);
572 m_errorMonitor->VerifyFound();
573 m_commandBuffer->EndRendering();
574
575 // Mismatching depth format
576 begin_rendering_info.colorAttachmentCount = 0;
577 begin_rendering_info.pColorAttachments = nullptr;
578 begin_rendering_info.pDepthAttachment = &depth_stencil_attachment;
579 m_commandBuffer->BeginRendering(begin_rendering_info);
580 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.handle());
581 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06181");
582 m_commandBuffer->Draw(1, 1, 0, 0);
583 m_errorMonitor->VerifyFound();
584 m_commandBuffer->EndRendering();
585
586 // Mismatching stencil format
587 if (testStencil) {
588 begin_rendering_info.pDepthAttachment = nullptr;
589 begin_rendering_info.pStencilAttachment = &depth_stencil_attachment;
590 m_commandBuffer->BeginRendering(begin_rendering_info);
591 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe3.handle());
592 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06182");
593 m_commandBuffer->Draw(1, 1, 0, 0);
594 m_errorMonitor->VerifyFound();
595 m_commandBuffer->EndRendering();
596 }
597
598 m_commandBuffer->end();
599}
600
601TEST_F(VkLayerTest, DynamicRenderingWithMistmatchingAttachmentSamples) {
602 TEST_DESCRIPTION("Draw with Dynamic Rendering with mismatching color/depth/stencil sample counts");
603
604 SetTargetApiVersion(VK_API_VERSION_1_1);
605
606 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
607
608 ASSERT_NO_FATAL_FAILURE(InitFramework());
609
sjfricked700bc02022-05-30 16:35:06 +0900610 if (!AreRequiredExtensionsEnabled()) {
611 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
stusmith15f24a82021-12-24 15:21:19 +0000612 }
613
614 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900615 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
stusmith15f24a82021-12-24 15:21:19 +0000616 }
617
618 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
619 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
620 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
621 if (!dynamic_rendering_features.dynamicRendering) {
622 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
623 return;
624 }
625
626 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
627
628 char const *fsSource = R"glsl(
629 #version 450
630 layout(location=0) out vec4 color;
631 void main() {
632 color = vec4(1.0f);
633 }
634 )glsl";
635
636 VkViewport viewport = {0, 0, 16, 16, 0, 1};
637 VkRect2D scissor = {{0, 0}, {16, 16}};
638 m_viewports.push_back(viewport);
639 m_scissors.push_back(scissor);
640
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800641 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
642 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000643
644 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
645 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
646 const VkPipelineLayoutObj pl(m_device, {&dsl});
647
648 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
649
stusmith15f24a82021-12-24 15:21:19 +0000650 VkPipelineObj pipe1(m_device);
651 pipe1.AddShader(&vs);
652 pipe1.AddShader(&fs);
653 pipe1.AddDefaultColorAttachment();
654 pipe1.SetViewport(m_viewports);
655 pipe1.SetScissor(m_scissors);
656
657 VkFormat color_formats[] = {VK_FORMAT_R8G8B8A8_UNORM};
658 pipeline_rendering_info.colorAttachmentCount = 1;
659 pipeline_rendering_info.pColorAttachmentFormats = color_formats;
660
661 auto create_info1 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
662 pipe1.InitGraphicsPipelineCreateInfo(&create_info1);
663 create_info1.pNext = &pipeline_rendering_info;
664
665 auto multisample_state_create_info = LvlInitStruct<VkPipelineMultisampleStateCreateInfo>();
666 multisample_state_create_info.rasterizationSamples = VK_SAMPLE_COUNT_2_BIT;
667 create_info1.pMultisampleState = &multisample_state_create_info;
668
669 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
670
stusmith15f24a82021-12-24 15:21:19 +0000671 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
672 ASSERT_TRUE(depthStencilFormat != 0);
673
stusmith15f24a82021-12-24 15:21:19 +0000674 VkPipelineObj pipe2(m_device);
675 pipe2.AddShader(&vs);
676 pipe2.AddShader(&fs);
677 pipe2.AddDefaultColorAttachment();
678 pipe2.SetViewport(m_viewports);
679 pipe2.SetScissor(m_scissors);
680
681 pipeline_rendering_info.colorAttachmentCount = 0;
682 pipeline_rendering_info.pColorAttachmentFormats = nullptr;
683 pipeline_rendering_info.depthAttachmentFormat = depthStencilFormat;
684
685 auto create_info2 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
686 pipe2.InitGraphicsPipelineCreateInfo(&create_info2);
687 create_info2.pNext = &pipeline_rendering_info;
688
689 create_info2.pMultisampleState = &multisample_state_create_info;
690
691 pipe2.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info2);
692
stusmith15f24a82021-12-24 15:21:19 +0000693 VkPipelineObj pipe3(m_device);
694
695 pipe3.AddShader(&vs);
696 pipe3.AddShader(&fs);
697 pipe3.AddDefaultColorAttachment();
698 pipe3.SetViewport(m_viewports);
699 pipe3.SetScissor(m_scissors);
700
701 pipeline_rendering_info.colorAttachmentCount = 0;
702 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
703 pipeline_rendering_info.stencilAttachmentFormat = depthStencilFormat;
704
705 auto create_info3 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
706 pipe3.InitGraphicsPipelineCreateInfo(&create_info3);
707 create_info3.pNext = &pipeline_rendering_info;
708
709 create_info3.pMultisampleState = &multisample_state_create_info;
710
711 pipe3.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info3);
712
stusmith15f24a82021-12-24 15:21:19 +0000713 VkImageObj colorImage(m_device);
714 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
715 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UNORM);
716
717 VkImageObj depthStencilImage(m_device);
718 depthStencilImage.Init(32, 32, 1, depthStencilFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
719 VkImageView depthStencilImageView =
720 depthStencilImage.targetView(depthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
721
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800722 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000723 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
724 color_attachment.imageView = colorImageView;
725
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800726 VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000727 depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
728 depth_stencil_attachment.imageView = depthStencilImageView;
729
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800730 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000731 m_commandBuffer->begin();
732
733 // Mismatching color samples
734 begin_rendering_info.colorAttachmentCount = 1;
735 begin_rendering_info.pColorAttachments = &color_attachment;
736 m_commandBuffer->BeginRendering(begin_rendering_info);
737 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
738 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06188");
739 m_commandBuffer->Draw(1, 1, 0, 0);
740 m_errorMonitor->VerifyFound();
741 m_commandBuffer->EndRendering();
742
743 // Mismatching depth samples
744 begin_rendering_info.colorAttachmentCount = 0;
745 begin_rendering_info.pColorAttachments = nullptr;
746 begin_rendering_info.pDepthAttachment = &depth_stencil_attachment;
747 m_commandBuffer->BeginRendering(begin_rendering_info);
748 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.handle());
749 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06189");
750 m_commandBuffer->Draw(1, 1, 0, 0);
751 m_errorMonitor->VerifyFound();
752 m_commandBuffer->EndRendering();
753
754 // Mismatching stencil samples
755 begin_rendering_info.pDepthAttachment = nullptr;
756 begin_rendering_info.pStencilAttachment = &depth_stencil_attachment;
757 m_commandBuffer->BeginRendering(begin_rendering_info);
758 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe3.handle());
759 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06190");
760 m_commandBuffer->Draw(1, 1, 0, 0);
761 m_errorMonitor->VerifyFound();
762 m_commandBuffer->EndRendering();
763
764 m_commandBuffer->end();
765}
766
ziga-lunarga3cc8482022-04-29 14:58:29 +0200767TEST_F(VkLayerTest, DynamicRenderingWithMismatchingMixedAttachmentSamples) {
stusmith15f24a82021-12-24 15:21:19 +0000768 TEST_DESCRIPTION("Draw with Dynamic Rendering with mismatching mixed color/depth/stencil sample counts");
769
770 SetTargetApiVersion(VK_API_VERSION_1_1);
771
772 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
773
774 ASSERT_NO_FATAL_FAILURE(InitFramework());
775
sjfricked700bc02022-05-30 16:35:06 +0900776 if (!AreRequiredExtensionsEnabled()) {
777 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
stusmith15f24a82021-12-24 15:21:19 +0000778 }
779
780 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900781 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
stusmith15f24a82021-12-24 15:21:19 +0000782 }
783
784 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
785 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
786 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
787 if (!dynamic_rendering_features.dynamicRendering) {
788 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
789 return;
790 }
791
792 bool amd_samples = false;
793 if (DeviceExtensionSupported(gpu(), nullptr, VK_AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME)) {
794 m_device_extension_names.push_back(VK_AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME);
795 amd_samples = true;
796 }
797
798 bool nv_samples = false;
799 if (DeviceExtensionSupported(gpu(), nullptr, VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME)) {
800 m_device_extension_names.push_back(VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME);
801 nv_samples = true;
802 }
803
804 if (!amd_samples && !nv_samples) {
805 printf("%s Test requires either VK_AMD_mixed_attachment_samples or VK_NV_framebuffer_mixed_samples, skipping\n",
806 kSkipPrefix);
807 return;
808 }
809
810 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
811
812 char const *fsSource = R"glsl(
813 #version 450
814 layout(location=0) out vec4 color;
815 void main() {
816 color = vec4(1.0f);
817 }
818 )glsl";
819
820 VkViewport viewport = {0, 0, 16, 16, 0, 1};
821 VkRect2D scissor = {{0, 0}, {16, 16}};
822 m_viewports.push_back(viewport);
823 m_scissors.push_back(scissor);
824
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800825 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
826 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000827
828 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
829 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
830 const VkPipelineLayoutObj pl(m_device, {&dsl});
831
ziga-lunarga3cc8482022-04-29 14:58:29 +0200832 VkSampleCountFlagBits counts[2] = {VK_SAMPLE_COUNT_2_BIT, VK_SAMPLE_COUNT_2_BIT};
stusmith15f24a82021-12-24 15:21:19 +0000833 auto samples_info = LvlInitStruct<VkAttachmentSampleCountInfoAMD>();
834
835 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(&samples_info);
836
837 VkPipelineObj pipe1(m_device);
838 pipe1.AddShader(&vs);
839 pipe1.AddShader(&fs);
840 pipe1.AddDefaultColorAttachment();
841 pipe1.SetViewport(m_viewports);
842 pipe1.SetScissor(m_scissors);
843
844 VkFormat color_formats[] = {VK_FORMAT_R8G8B8A8_UNORM};
845 pipeline_rendering_info.colorAttachmentCount = 1;
846 pipeline_rendering_info.pColorAttachmentFormats = color_formats;
847
848 samples_info.colorAttachmentCount = 1;
ziga-lunarga3cc8482022-04-29 14:58:29 +0200849 samples_info.pColorAttachmentSamples = counts;
stusmith15f24a82021-12-24 15:21:19 +0000850
851 auto create_info1 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
852 pipe1.InitGraphicsPipelineCreateInfo(&create_info1);
853 create_info1.pNext = &pipeline_rendering_info;
854
Aaron Haganb54466d2022-02-18 15:02:54 -0500855 samples_info.colorAttachmentCount = 2;
856 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06063");
857 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
858 m_errorMonitor->VerifyFound();
859
860 samples_info.colorAttachmentCount = 1;
stusmith15f24a82021-12-24 15:21:19 +0000861 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
862
863 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
864 ASSERT_TRUE(depthStencilFormat != 0);
865
866 VkPipelineObj pipe2(m_device);
867 pipe2.AddShader(&vs);
868 pipe2.AddShader(&fs);
869 pipe2.AddDefaultColorAttachment();
870 pipe2.SetViewport(m_viewports);
871 pipe2.SetScissor(m_scissors);
872
873 pipeline_rendering_info.colorAttachmentCount = 0;
874 pipeline_rendering_info.pColorAttachmentFormats = nullptr;
875 pipeline_rendering_info.depthAttachmentFormat = depthStencilFormat;
876
877 samples_info.colorAttachmentCount = 0;
878 samples_info.pColorAttachmentSamples = nullptr;
ziga-lunarga3cc8482022-04-29 14:58:29 +0200879 samples_info.depthStencilAttachmentSamples = counts[0];
stusmith15f24a82021-12-24 15:21:19 +0000880
881 auto create_info2 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
882 pipe2.InitGraphicsPipelineCreateInfo(&create_info2);
883 create_info2.pNext = &pipeline_rendering_info;
884
885 pipe2.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info2);
886
887 VkPipelineObj pipe3(m_device);
888
889 pipe3.AddShader(&vs);
890 pipe3.AddShader(&fs);
891 pipe3.AddDefaultColorAttachment();
892 pipe3.SetViewport(m_viewports);
893 pipe3.SetScissor(m_scissors);
894
895 pipeline_rendering_info.colorAttachmentCount = 0;
896 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
897 pipeline_rendering_info.stencilAttachmentFormat = depthStencilFormat;
898
899 auto create_info3 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
900 pipe3.InitGraphicsPipelineCreateInfo(&create_info3);
901 create_info3.pNext = &pipeline_rendering_info;
902
903 pipe3.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info3);
904
905 VkImageObj colorImage(m_device);
906 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
907 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UNORM);
908
909 VkImageObj depthStencilImage(m_device);
910 depthStencilImage.Init(32, 32, 1, depthStencilFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
911 VkImageView depthStencilImageView =
912 depthStencilImage.targetView(depthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
913
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800914 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000915 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
916 color_attachment.imageView = colorImageView;
917
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800918 VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000919 depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
920 depth_stencil_attachment.imageView = depthStencilImageView;
921
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800922 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000923 m_commandBuffer->begin();
924
925 // Mismatching color samples
926 begin_rendering_info.colorAttachmentCount = 1;
927 begin_rendering_info.pColorAttachments = &color_attachment;
928 m_commandBuffer->BeginRendering(begin_rendering_info);
929 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
930 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06185");
931 m_commandBuffer->Draw(1, 1, 0, 0);
932 m_errorMonitor->VerifyFound();
933 m_commandBuffer->EndRendering();
934
935 // Mismatching depth samples
936 begin_rendering_info.colorAttachmentCount = 0;
937 begin_rendering_info.pColorAttachments = nullptr;
938 begin_rendering_info.pDepthAttachment = &depth_stencil_attachment;
939 m_commandBuffer->BeginRendering(begin_rendering_info);
940 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.handle());
941 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06186");
942 m_commandBuffer->Draw(1, 1, 0, 0);
943 m_errorMonitor->VerifyFound();
944 m_commandBuffer->EndRendering();
945
946 // Mismatching stencil samples
947 begin_rendering_info.pDepthAttachment = nullptr;
948 begin_rendering_info.pStencilAttachment = &depth_stencil_attachment;
949 m_commandBuffer->BeginRendering(begin_rendering_info);
950 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe3.handle());
951 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06187");
952 m_commandBuffer->Draw(1, 1, 0, 0);
953 m_errorMonitor->VerifyFound();
954 m_commandBuffer->EndRendering();
955
956 m_commandBuffer->end();
957}
Aaron Hagan80034ea2021-12-23 11:24:09 -0500958
959TEST_F(VkLayerTest, DynamicRenderingAttachmentInfo) {
960 TEST_DESCRIPTION("AttachmentInfo Dynamic Rendering Tests.");
961
962 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2);
963 if (version < VK_API_VERSION_1_2) {
964 printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix);
965 return;
966 }
967
968 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
969
970 ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor));
971
972 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900973 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
Aaron Hagan80034ea2021-12-23 11:24:09 -0500974 }
975
sjfricked700bc02022-05-30 16:35:06 +0900976 if (!AreRequiredExtensionsEnabled()) {
977 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
Aaron Hagan80034ea2021-12-23 11:24:09 -0500978 }
979
980 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
981 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
982 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
983 if (!dynamic_rendering_features.dynamicRendering) {
984 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
985 return;
986 }
987
988 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
989
990 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
991 VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT);
992
993 VkPipelineObj pipe(m_device);
994 pipe.AddShader(&vs);
995 pipe.AddShader(&fs);
996 pipe.AddDefaultColorAttachment();
997
998 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
999 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
1000 const VkPipelineLayoutObj pl(m_device, {&dsl});
1001
1002 VkFormat depth_format = VK_FORMAT_D32_SFLOAT_S8_UINT;
1003 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
1004 pipeline_rendering_info.depthAttachmentFormat = depth_format;
1005
1006 auto pipeline_create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
1007 pipe.InitGraphicsPipelineCreateInfo(&pipeline_create_info);
1008 pipeline_create_info.pNext = &pipeline_rendering_info;
1009
1010 VkResult err = pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &pipeline_create_info);
1011 ASSERT_VK_SUCCESS(err);
1012
1013 VkImageObj image(m_device);
1014 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
1015 image_create_info.imageType = VK_IMAGE_TYPE_2D;
1016 image_create_info.format = depth_format;
1017 image_create_info.extent = {64, 64, 4};
1018 image_create_info.mipLevels = 1;
1019 image_create_info.arrayLayers = 1;
1020 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
1021 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
ziga-lunarga3cc8482022-04-29 14:58:29 +02001022 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 -05001023 image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
1024
1025 image.Init(image_create_info);
1026 ASSERT_TRUE(image.initialized());
1027
1028 VkImageViewCreateInfo ivci = {VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
1029 nullptr,
1030 0,
1031 image.handle(),
1032 VK_IMAGE_VIEW_TYPE_2D,
1033 depth_format,
1034 {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
1035 VK_COMPONENT_SWIZZLE_IDENTITY},
1036 {VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, 0, 1, 0, 1}};
1037
1038 VkImageView depth_image_view;
1039 err = vk::CreateImageView(m_device->device(), &ivci, nullptr, &depth_image_view);
1040 ASSERT_VK_SUCCESS(err);
1041
1042 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1043 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
1044 depth_attachment.imageView = depth_image_view;
1045 depth_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
1046 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
1047
1048 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
1049 begin_rendering_info.pDepthAttachment = &depth_attachment;
1050 begin_rendering_info.viewMask = 0x4;
1051
1052 VkRenderingFragmentDensityMapAttachmentInfoEXT fragment_density_map =
1053 LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
1054 fragment_density_map.imageView = depth_image_view;
ziga-lunarga3cc8482022-04-29 14:58:29 +02001055 fragment_density_map.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
Aaron Hagan80034ea2021-12-23 11:24:09 -05001056 begin_rendering_info.pNext = &fragment_density_map;
1057
1058 m_commandBuffer->begin();
1059 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-multiview-06127");
Jeremy Gebben09c1a072022-02-08 09:42:47 -07001060 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06107");
1061 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06108");
1062 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06116");
Jeremy Gebben09c1a072022-02-08 09:42:47 -07001063 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06145");
1064 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06146");
Aaron Hagan80034ea2021-12-23 11:24:09 -05001065 m_commandBuffer->BeginRendering(begin_rendering_info);
1066 m_errorMonitor->VerifyFound();
1067}
Aaron Haganb54466d2022-02-18 15:02:54 -05001068
1069TEST_F(VkLayerTest, DynamicRenderingBufferBeginInfoLegacy) {
1070 TEST_DESCRIPTION("VkCommandBufferBeginInfo Dynamic Rendering Tests.");
1071
1072 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2);
1073 if (version < VK_API_VERSION_1_2) {
1074 printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix);
1075 return;
1076 }
1077
1078 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1079
1080 ASSERT_NO_FATAL_FAILURE(Init(nullptr, nullptr, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1081
1082 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001083 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
Aaron Haganb54466d2022-02-18 15:02:54 -05001084 }
1085
sjfricked700bc02022-05-30 16:35:06 +09001086 if (!AreRequiredExtensionsEnabled()) {
1087 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
Aaron Haganb54466d2022-02-18 15:02:54 -05001088 }
1089
1090 auto cmd_buffer_inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>();
1091 cmd_buffer_inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
1092
1093 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
1094 cmd_buffer_inheritance_info.pNext = &cmd_buffer_inheritance_rendering_info;
1095 cmd_buffer_inheritance_info.renderPass = VK_NULL_HANDLE;
1096
1097 auto cmd_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>();
1098 cmd_buffer_allocate_info.commandPool = m_commandPool->handle();
1099 cmd_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY;
1100 cmd_buffer_allocate_info.commandBufferCount = 0x1;
1101
1102 VkCommandBuffer secondary_cmd_buffer;
1103 VkResult err = vk::AllocateCommandBuffers(m_device->device(), &cmd_buffer_allocate_info, &secondary_cmd_buffer);
1104 ASSERT_VK_SUCCESS(err);
1105
1106 // Invalid RenderPass
1107 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-00053");
1108 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
1109 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
1110 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
1111 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
1112 m_errorMonitor->VerifyFound();
1113
1114 // Valid RenderPass
1115 VkAttachmentDescription attach[] = {
1116 {0, VK_FORMAT_B8G8R8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE,
1117 VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_IMAGE_LAYOUT_UNDEFINED,
1118 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL},
1119 };
1120 VkAttachmentReference att_ref = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL};
1121
1122 VkSubpassDescription subpass = {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &att_ref, nullptr, nullptr, 0, nullptr};
1123 VkRenderPassCreateInfo rpci = {VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, 0, 1, attach, 1, &subpass, 0, nullptr};
1124
1125 vk_testing::RenderPass rp1;
1126 rp1.init(*m_device, rpci);
1127
1128 cmd_buffer_inheritance_info.renderPass = rp1.handle();
1129 cmd_buffer_inheritance_info.subpass = 0x5;
1130 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-00054");
1131 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
1132 m_errorMonitor->VerifyFound();
1133}
1134
1135TEST_F(VkLayerTest, DynamicRenderingSecondaryCommandBuffer) {
1136 TEST_DESCRIPTION("VkCommandBufferBeginInfo Dynamic Rendering Tests.");
1137
1138 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_3);
1139 if (version < VK_API_VERSION_1_3) {
1140 printf("%s At least Vulkan version 1.3 is required, skipping test.\n", kSkipPrefix);
1141 return;
1142 }
1143
1144 ASSERT_NO_FATAL_FAILURE(Init());
1145
1146 if (DeviceValidationVersion() < VK_API_VERSION_1_3) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001147 GTEST_SKIP() << "At least Vulkan version 1.3 is required";
Aaron Haganb54466d2022-02-18 15:02:54 -05001148 }
1149
1150 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
1151
1152 // Force the failure by not setting the Renderpass and Framebuffer fields
1153 VkCommandBufferInheritanceInfo cmd_buf_hinfo = LvlInitStruct<VkCommandBufferInheritanceInfo>();
1154 cmd_buf_hinfo.renderPass = VkRenderPass(0x1);
1155 VkCommandBufferBeginInfo cmd_buf_info = LvlInitStruct<VkCommandBufferBeginInfo>();
1156 cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
1157 cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo;
1158
1159 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06000");
1160 vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info);
1161 m_errorMonitor->VerifyFound();
1162
1163 // Valid RenderPass
1164 VkAttachmentDescription attach[] = {
1165 {0, VK_FORMAT_B8G8R8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE,
1166 VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_IMAGE_LAYOUT_UNDEFINED,
1167 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL},
1168 };
1169 VkAttachmentReference att_ref = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL};
1170
1171 VkSubpassDescription subpass = {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &att_ref, nullptr, nullptr, 0, nullptr};
1172 VkRenderPassCreateInfo rpci = {VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, 0, 1, attach, 1, &subpass, 0, nullptr};
1173
1174 vk_testing::RenderPass rp1;
1175 rp1.init(*m_device, rpci);
1176
1177 cmd_buf_hinfo.renderPass = rp1.handle();
1178 cmd_buf_hinfo.subpass = 0x5;
1179 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06001");
1180 vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info);
1181 m_errorMonitor->VerifyFound();
1182
1183 cmd_buf_hinfo.renderPass = VK_NULL_HANDLE;
1184 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06002");
1185 vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info);
1186 m_errorMonitor->VerifyFound();
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001187}
1188
1189TEST_F(VkLayerTest, TestDynamicRenderingPipelineMissingFlags) {
1190 TEST_DESCRIPTION("Test dynamic rendering with pipeline missing flags.");
1191
1192 SetTargetApiVersion(VK_API_VERSION_1_1);
1193 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1194 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1195 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
1196
1197 ASSERT_NO_FATAL_FAILURE(InitFramework());
1198
1199 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001200 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001201 }
1202
1203 if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
sjfricked700bc02022-05-30 16:35:06 +09001204 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001205 }
1206 bool fragment_density = DeviceExtensionSupported(gpu(), nullptr, VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1207 bool shading_rate = DeviceExtensionSupported(gpu(), nullptr, VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
1208
1209 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1210 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1211 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1212 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001213 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001214 }
1215
1216 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
1217
1218 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
1219 vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2);
1220
1221 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1222 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
1223
1224 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
1225 ASSERT_TRUE(depthStencilFormat != 0);
1226
1227 VkImageObj image(m_device);
1228 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
1229 image_create_info.imageType = VK_IMAGE_TYPE_2D;
1230 image_create_info.format = depthStencilFormat;
1231 image_create_info.extent = {64, 64, 1};
1232 image_create_info.mipLevels = 1;
1233 image_create_info.arrayLayers = 1;
1234 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
1235 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001236 image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR;
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001237 image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
1238
1239 image.Init(image_create_info);
1240 ASSERT_TRUE(image.initialized());
1241
1242 VkImageViewCreateInfo ivci = {VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
1243 nullptr,
1244 0,
1245 image.handle(),
1246 VK_IMAGE_VIEW_TYPE_2D,
1247 depthStencilFormat,
1248 {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
1249 VK_COMPONENT_SWIZZLE_IDENTITY},
1250 {VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, 0, 1, 0, 1}};
1251
1252 vk_testing::ImageView depth_image_view;
1253 depth_image_view.init(*m_device, ivci);
1254
1255 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1256 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1257
1258 if (shading_rate) {
1259 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-imageView-06183");
1260 VkRenderingFragmentShadingRateAttachmentInfoKHR fragment_shading_rate =
1261 LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
1262 fragment_shading_rate.imageView = depth_image_view.handle();
1263 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1264 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
1265
1266 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
ziga-lunargaa97cbb2022-03-18 19:06:35 +01001267 begin_rendering_info.layerCount = 1;
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001268 begin_rendering_info.colorAttachmentCount = 1;
1269 begin_rendering_info.pColorAttachments = &color_attachment;
1270
1271 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
1272
1273 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
1274 pipeline_rendering_info.colorAttachmentCount = 1;
1275 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
1276
1277 CreatePipelineHelper pipe(*this);
1278 pipe.InitInfo();
1279 pipe.gp_ci_.pNext = &pipeline_rendering_info;
1280 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
1281 pipe.InitState();
1282 pipe.CreateGraphicsPipeline();
1283
1284 m_commandBuffer->begin();
1285 m_commandBuffer->BeginRendering(begin_rendering_info);
1286 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_);
1287 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
1288 m_commandBuffer->EndRendering();
1289 m_commandBuffer->end();
1290
1291 m_errorMonitor->VerifyFound();
1292 }
1293
1294 if (fragment_density) {
1295 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-imageView-06184");
1296 VkRenderingFragmentDensityMapAttachmentInfoEXT fragment_density_map =
1297 LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
1298 fragment_density_map.imageView = depth_image_view.handle();
1299
1300 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_density_map);
ziga-lunargaa97cbb2022-03-18 19:06:35 +01001301 begin_rendering_info.layerCount = 1;
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001302 begin_rendering_info.colorAttachmentCount = 1;
1303 begin_rendering_info.pColorAttachments = &color_attachment;
1304
1305 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
1306
1307 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
1308 pipeline_rendering_info.colorAttachmentCount = 1;
1309 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
1310
1311 CreatePipelineHelper pipe(*this);
1312 pipe.InitInfo();
1313 pipe.gp_ci_.pNext = &pipeline_rendering_info;
1314 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
1315 pipe.InitState();
1316 pipe.CreateGraphicsPipeline();
1317
1318 m_commandBuffer->begin();
1319 m_commandBuffer->BeginRendering(begin_rendering_info);
1320 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_);
1321 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
1322 m_commandBuffer->EndRendering();
1323 m_commandBuffer->end();
1324
1325 m_errorMonitor->VerifyFound();
1326 }
1327}
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001328
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001329TEST_F(VkLayerTest, DynamicRenderingLayerCount) {
1330 TEST_DESCRIPTION("Test dynamic rendering with viewMask 0 and invalid layer count.");
1331
1332 SetTargetApiVersion(VK_API_VERSION_1_1);
1333 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1334
1335 ASSERT_NO_FATAL_FAILURE(InitFramework());
1336
1337 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001338 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001339 }
1340
1341 if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
sjfricked700bc02022-05-30 16:35:06 +09001342 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001343 }
1344
1345 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1346 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1347 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1348 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001349 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001350 }
1351
1352 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1353
1354 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
1355
1356 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-viewMask-06069");
1357 m_commandBuffer->begin();
1358 m_commandBuffer->BeginRendering(begin_rendering_info);
1359 m_commandBuffer->end();
1360 m_errorMonitor->VerifyFound();
1361}
1362
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001363TEST_F(VkLayerTest, TestRenderingInfoMismatchedSamples) {
1364 TEST_DESCRIPTION("Test beginning rendering with mismatched sample counts.");
1365
1366 SetTargetApiVersion(VK_API_VERSION_1_1);
1367 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1368
1369 ASSERT_NO_FATAL_FAILURE(InitFramework());
1370
1371 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001372 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001373 }
1374
1375 if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
sjfricked700bc02022-05-30 16:35:06 +09001376 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001377 }
1378
1379 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1380 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1381 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1382 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001383 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001384 }
1385
1386 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1387
1388 VkImageCreateInfo image_ci = LvlInitStruct<VkImageCreateInfo>();
1389 image_ci.imageType = VK_IMAGE_TYPE_2D;
1390 image_ci.format = VK_FORMAT_R8G8B8A8_UNORM;
1391 image_ci.extent.width = 64;
1392 image_ci.extent.height = 64;
1393 image_ci.extent.depth = 1;
1394 image_ci.mipLevels = 1;
1395 image_ci.arrayLayers = 1;
1396 image_ci.samples = VK_SAMPLE_COUNT_2_BIT;
1397 image_ci.tiling = VK_IMAGE_TILING_OPTIMAL;
1398 image_ci.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
1399
1400 VkImageObj color_image(m_device);
1401 color_image.init(&image_ci);
1402
1403 VkImageViewCreateInfo civ_ci = LvlInitStruct<VkImageViewCreateInfo>();
1404 civ_ci.image = color_image.handle();
1405 civ_ci.viewType = VK_IMAGE_VIEW_TYPE_2D;
1406 civ_ci.format = VK_FORMAT_R8G8B8A8_UNORM;
1407 civ_ci.subresourceRange.layerCount = 1;
1408 civ_ci.subresourceRange.baseMipLevel = 0;
1409 civ_ci.subresourceRange.levelCount = 1;
1410 civ_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
1411
1412 vk_testing::ImageView color_image_view;
1413 color_image_view.init(*m_device, civ_ci);
1414
1415 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1416 color_attachment.imageView = color_image_view.handle();
1417 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1418 color_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
1419
1420 const VkFormat depth_format = FindSupportedDepthOnlyFormat(gpu());
1421 if (depth_format == VK_FORMAT_UNDEFINED) {
1422 printf("%s requires a depth only format, skipping.\n", kSkipPrefix);
1423 return;
1424 }
1425
1426 VkImageObj depth_image(m_device);
1427 depth_image.Init(64, 64, 1, depth_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL);
1428
1429 VkImageViewCreateInfo div_ci = LvlInitStruct<VkImageViewCreateInfo>();
1430 div_ci.image = depth_image.handle();
1431 div_ci.viewType = VK_IMAGE_VIEW_TYPE_2D;
1432 div_ci.format = depth_format;
1433 div_ci.subresourceRange.layerCount = 1;
1434 div_ci.subresourceRange.baseMipLevel = 0;
1435 div_ci.subresourceRange.levelCount = 1;
1436 div_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
1437
1438 vk_testing::ImageView depth_image_view;
1439 depth_image_view.init(*m_device, div_ci);
1440
1441 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1442 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1443 depth_attachment.imageView = depth_image_view.handle();
1444 depth_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
1445
1446 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
ziga-lunargaa97cbb2022-03-18 19:06:35 +01001447 begin_rendering_info.layerCount = 1;
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001448 begin_rendering_info.colorAttachmentCount = 1;
1449 begin_rendering_info.pColorAttachments = &color_attachment;
1450 begin_rendering_info.pDepthAttachment = &depth_attachment;
1451
1452 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06070");
1453 m_commandBuffer->BeginRendering(begin_rendering_info);
1454 m_errorMonitor->VerifyFound();
1455}
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001456
ziga-lunargb7fec142022-03-18 22:08:17 +01001457TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRate) {
1458 TEST_DESCRIPTION("Test BeginRenderingInfo with FragmentShadingRateAttachment.");
1459
1460 SetTargetApiVersion(VK_API_VERSION_1_1);
1461 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1462 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
1463
1464 ASSERT_NO_FATAL_FAILURE(InitFramework());
1465
1466 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001467 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargb7fec142022-03-18 22:08:17 +01001468 }
1469
sjfricked700bc02022-05-30 16:35:06 +09001470 if (!AreRequiredExtensionsEnabled()) {
1471 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargb7fec142022-03-18 22:08:17 +01001472 }
1473
1474 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1475 auto features11 = LvlInitStruct<VkPhysicalDeviceVulkan11Features>(&dynamic_rendering_features);
1476 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&features11);
1477 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1478
1479 if (features11.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001480 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunargb7fec142022-03-18 22:08:17 +01001481 }
1482 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001483 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargb7fec142022-03-18 22:08:17 +01001484 }
1485
1486 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
1487
1488 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
1489 vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2);
1490
1491 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1492 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
1493
1494 auto image_ci = LvlInitStruct<VkImageCreateInfo>(nullptr);
1495 image_ci.imageType = VK_IMAGE_TYPE_2D;
1496 image_ci.format = VK_FORMAT_R8G8B8A8_UNORM;
1497 image_ci.extent.width = 32;
1498 image_ci.extent.height = 32;
1499 image_ci.extent.depth = 1;
1500 image_ci.mipLevels = 1;
1501 image_ci.arrayLayers = 2;
1502 image_ci.samples = VK_SAMPLE_COUNT_1_BIT;
1503 image_ci.tiling = VK_IMAGE_TILING_OPTIMAL;
ziga-lunargade1d9e2022-04-25 10:59:15 +02001504 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 +01001505
1506 VkImageObj image(m_device);
1507 image.init(&image_ci);
1508 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 2);
1509
ziga-lunargade1d9e2022-04-25 10:59:15 +02001510 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
ziga-lunargb7fec142022-03-18 22:08:17 +01001511 fragment_shading_rate.imageView = image_view;
1512 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1513 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
1514
1515 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
1516 begin_rendering_info.layerCount = 4;
1517
1518 m_commandBuffer->begin();
1519
1520 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06123");
1521 m_commandBuffer->BeginRendering(begin_rendering_info);
1522 m_errorMonitor->VerifyFound();
1523
1524 begin_rendering_info.viewMask = 0xF;
1525 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06124");
1526 m_commandBuffer->BeginRendering(begin_rendering_info);
1527 m_errorMonitor->VerifyFound();
1528
ziga-lunargade1d9e2022-04-25 10:59:15 +02001529 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1530 color_attachment.imageView = image_view;
1531 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1532
1533 begin_rendering_info.layerCount = 2;
1534 begin_rendering_info.colorAttachmentCount = 1;
1535 begin_rendering_info.pColorAttachments = &color_attachment;
1536 begin_rendering_info.viewMask = 0;
1537 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06125");
1538 m_commandBuffer->BeginRendering(begin_rendering_info);
1539 m_errorMonitor->VerifyFound();
1540
ziga-lunargb7fec142022-03-18 22:08:17 +01001541 m_commandBuffer->end();
ziga-lunargb7fec142022-03-18 22:08:17 +01001542}
1543
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001544TEST_F(VkLayerTest, TestDeviceGroupRenderPassBeginInfo) {
1545 TEST_DESCRIPTION("Test render area of DeviceGroupRenderPassBeginInfo.");
1546
1547 SetTargetApiVersion(VK_API_VERSION_1_1);
1548 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1549
1550 ASSERT_NO_FATAL_FAILURE(InitFramework());
1551
1552 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001553 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001554 }
1555
1556 if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
sjfricked700bc02022-05-30 16:35:06 +09001557 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001558 }
1559
1560 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1561 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1562 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1563 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001564 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001565 }
1566
1567 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1568
1569 VkRect2D render_area = {};
1570 render_area.offset.x = 0;
1571 render_area.offset.y = 0;
1572 render_area.extent.width = 32;
1573 render_area.extent.height = 32;
1574
1575 auto device_group_render_pass_begin_info = LvlInitStruct<VkDeviceGroupRenderPassBeginInfo>();
1576 device_group_render_pass_begin_info.deviceRenderAreaCount = 1;
1577 device_group_render_pass_begin_info.pDeviceRenderAreas = &render_area;
1578
1579 VkImageObj colorImage(m_device);
1580 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
1581 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
1582
1583 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1584 color_attachment.imageView = colorImageView;
1585 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1586
1587 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&device_group_render_pass_begin_info);
ziga-lunarg1fec6332022-03-20 14:39:54 +01001588 begin_rendering_info.layerCount = 1;
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001589 begin_rendering_info.colorAttachmentCount = 1;
1590 begin_rendering_info.pColorAttachments = &color_attachment;
1591
1592 m_commandBuffer->begin();
1593
1594 m_errorMonitor->ExpectSuccess();
1595 m_commandBuffer->BeginRendering(begin_rendering_info);
1596 m_errorMonitor->VerifyNotFound();
1597
1598 render_area.offset.x = 1;
1599 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06083");
1600 m_commandBuffer->BeginRendering(begin_rendering_info);
1601 m_errorMonitor->VerifyFound();
1602
1603 render_area.offset.x = 0;
1604 render_area.offset.y = 16;
1605 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06084");
1606 m_commandBuffer->BeginRendering(begin_rendering_info);
1607 m_errorMonitor->VerifyFound();
1608
1609 m_commandBuffer->end();
1610}
1611
ziga-lunarg184a20b2022-03-18 20:54:48 +01001612TEST_F(VkLayerTest, TestBeginRenderingInvalidFragmentShadingRateImage) {
1613 TEST_DESCRIPTION("Test BeginRendering with FragmentShadingRateAttachmentInfo with missing image usage bit.");
1614
1615 SetTargetApiVersion(VK_API_VERSION_1_1);
1616 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1617 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
1618
1619 ASSERT_NO_FATAL_FAILURE(InitFramework());
1620
1621 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001622 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg184a20b2022-03-18 20:54:48 +01001623 }
1624
sjfricked700bc02022-05-30 16:35:06 +09001625 if (!AreRequiredExtensionsEnabled()) {
1626 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg184a20b2022-03-18 20:54:48 +01001627 }
1628
1629 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1630 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1631 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1632 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001633 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg184a20b2022-03-18 20:54:48 +01001634 }
1635 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1636
1637 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
1638 auto properties2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
1639 vk::GetPhysicalDeviceProperties2(gpu(), &properties2);
1640
1641 VkImageObj image(m_device);
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001642 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT,
1643 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR);
ziga-lunarg184a20b2022-03-18 20:54:48 +01001644 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
1645
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001646 VkImageObj invalid_image(m_device);
1647 invalid_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
1648 VkImageView invalid_image_view = invalid_image.targetView(VK_FORMAT_R8G8B8A8_UINT);
1649
ziga-lunarg184a20b2022-03-18 20:54:48 +01001650 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001651 fragment_shading_rate.imageView = invalid_image_view;
ziga-lunarg184a20b2022-03-18 20:54:48 +01001652 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1653 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
1654
1655 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001656 begin_rendering_info.layerCount = 1;
1657
1658 m_commandBuffer->begin();
ziga-lunarg184a20b2022-03-18 20:54:48 +01001659
1660 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06148");
ziga-lunarg184a20b2022-03-18 20:54:48 +01001661 m_commandBuffer->BeginRendering(begin_rendering_info);
ziga-lunarg184a20b2022-03-18 20:54:48 +01001662 m_errorMonitor->VerifyFound();
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001663 fragment_shading_rate.imageView = image_view;
1664
1665 fragment_shading_rate.shadingRateAttachmentTexelSize.width = fsr_properties.minFragmentShadingRateAttachmentTexelSize.width + 1;
1666 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06149");
1667 if (fragment_shading_rate.shadingRateAttachmentTexelSize.width >
1668 fsr_properties.minFragmentShadingRateAttachmentTexelSize.width) {
1669 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06150");
1670 }
1671 m_commandBuffer->BeginRendering(begin_rendering_info);
1672 m_errorMonitor->VerifyFound();
1673
1674 if (fsr_properties.minFragmentShadingRateAttachmentTexelSize.width > 1) {
1675 fragment_shading_rate.shadingRateAttachmentTexelSize.width =
1676 fsr_properties.minFragmentShadingRateAttachmentTexelSize.width / 2;
1677 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06151");
1678 if (fragment_shading_rate.shadingRateAttachmentTexelSize.height /
1679 fragment_shading_rate.shadingRateAttachmentTexelSize.width >=
1680 fsr_properties.maxFragmentShadingRateAttachmentTexelSizeAspectRatio) {
1681 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06156");
1682 }
1683 m_commandBuffer->BeginRendering(begin_rendering_info);
1684 m_errorMonitor->VerifyFound();
1685 }
1686
1687 fragment_shading_rate.shadingRateAttachmentTexelSize.width = fsr_properties.minFragmentShadingRateAttachmentTexelSize.width;
1688
1689 fragment_shading_rate.shadingRateAttachmentTexelSize.height =
1690 fsr_properties.minFragmentShadingRateAttachmentTexelSize.height + 1;
1691 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06152");
1692 if (fragment_shading_rate.shadingRateAttachmentTexelSize.height >
1693 fsr_properties.minFragmentShadingRateAttachmentTexelSize.height) {
1694 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06153");
1695 }
1696 m_commandBuffer->BeginRendering(begin_rendering_info);
1697 m_errorMonitor->VerifyFound();
1698
1699 if (fsr_properties.minFragmentShadingRateAttachmentTexelSize.height > 1) {
1700 fragment_shading_rate.shadingRateAttachmentTexelSize.height =
1701 fsr_properties.minFragmentShadingRateAttachmentTexelSize.height / 2;
1702 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06154");
1703 if (fragment_shading_rate.shadingRateAttachmentTexelSize.width /
1704 fragment_shading_rate.shadingRateAttachmentTexelSize.height >
1705 fsr_properties.maxFragmentShadingRateAttachmentTexelSizeAspectRatio) {
1706 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06155");
1707 }
1708 m_commandBuffer->BeginRendering(begin_rendering_info);
1709 m_errorMonitor->VerifyFound();
1710 }
1711
1712 m_commandBuffer->end();
ziga-lunarg184a20b2022-03-18 20:54:48 +01001713}
1714
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001715TEST_F(VkLayerTest, BeginRenderingInvalidDepthAttachmentFormat) {
1716 TEST_DESCRIPTION("Test begin rendering with a depth attachment that has an invalid format");
1717
1718 SetTargetApiVersion(VK_API_VERSION_1_3);
1719 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1720
1721 ASSERT_NO_FATAL_FAILURE(InitFramework());
1722
1723 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001724 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001725 }
1726
sjfricked700bc02022-05-30 16:35:06 +09001727 if (!AreRequiredExtensionsEnabled()) {
1728 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001729 }
1730
1731 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1732 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1733 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1734 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001735 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001736 }
1737
1738 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1739
1740 VkFormat stencil_format = FindSupportedStencilOnlyFormat(gpu());
1741 if (stencil_format == VK_FORMAT_UNDEFINED) {
1742 printf("%s requires a stencil only format format.\n", kSkipPrefix);
1743 return;
1744 }
1745
1746 VkImageObj image(m_device);
1747 image.Init(32, 32, 1, stencil_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
1748 VkImageView image_view = image.targetView(stencil_format, VK_IMAGE_ASPECT_STENCIL_BIT);
1749
1750 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1751 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
1752 depth_attachment.imageView = image_view;
1753
1754 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
ziga-lunarg1fec6332022-03-20 14:39:54 +01001755 begin_rendering_info.layerCount = 1;
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001756 begin_rendering_info.pDepthAttachment = &depth_attachment;
1757
1758 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06547");
1759 m_commandBuffer->BeginRendering(begin_rendering_info);
1760 m_errorMonitor->VerifyFound();
1761}
ziga-lunarg4b5bb5b2022-03-20 00:49:04 +01001762
ziga-lunarg14a69782022-03-20 00:39:31 +01001763TEST_F(VkLayerTest, TestFragmentDensityMapRenderArea) {
1764 TEST_DESCRIPTION("Validate VkRenderingFragmentDensityMapAttachmentInfo attachment image view extent.");
1765
1766 SetTargetApiVersion(VK_API_VERSION_1_1);
1767 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1768 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1769
1770 ASSERT_NO_FATAL_FAILURE(InitFramework());
1771
1772 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001773 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg14a69782022-03-20 00:39:31 +01001774 }
1775
sjfricked700bc02022-05-30 16:35:06 +09001776 if (!AreRequiredExtensionsEnabled()) {
1777 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg14a69782022-03-20 00:39:31 +01001778 }
1779
1780 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1781 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1782 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1783 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001784 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg14a69782022-03-20 00:39:31 +01001785 }
1786
1787 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1788
1789 auto fdm_props = LvlInitStruct<VkPhysicalDeviceFragmentDensityMapPropertiesEXT>();
1790 auto props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fdm_props);
1791 vk::GetPhysicalDeviceProperties2(gpu(), &props2);
1792
1793 VkImageObj image(m_device);
ziga-lunarg2aa8d592022-04-25 14:29:13 +02001794 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT,
1795 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT);
ziga-lunarg14a69782022-03-20 00:39:31 +01001796 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1);
1797
1798 auto fragment_density_map = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
1799 fragment_density_map.imageView = image_view;
ziga-lunarg2aa8d592022-04-25 14:29:13 +02001800 fragment_density_map.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1801
ziga-lunarg14a69782022-03-20 00:39:31 +01001802 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_density_map);
1803 begin_rendering_info.layerCount = 1;
1804 begin_rendering_info.renderArea.extent.width = 64 * fdm_props.maxFragmentDensityTexelSize.width;
1805 begin_rendering_info.renderArea.extent.height = 32 * fdm_props.maxFragmentDensityTexelSize.height;
1806
1807 m_commandBuffer->begin();
1808
1809 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06112");
1810 m_commandBuffer->BeginRendering(begin_rendering_info);
1811 m_errorMonitor->VerifyFound();
1812
1813 begin_rendering_info.renderArea.extent.width = 32 * fdm_props.maxFragmentDensityTexelSize.width;
1814 begin_rendering_info.renderArea.extent.height = 64 * fdm_props.maxFragmentDensityTexelSize.height;
1815
1816 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06114");
1817 m_commandBuffer->BeginRendering(begin_rendering_info);
1818 m_errorMonitor->VerifyFound();
1819
1820 VkRect2D device_render_area = {};
1821 device_render_area.extent.width = 64 * fdm_props.maxFragmentDensityTexelSize.width;
1822 device_render_area.extent.height = 32 * fdm_props.maxFragmentDensityTexelSize.height;
1823 auto device_group_render_pass_begin_info = LvlInitStruct<VkDeviceGroupRenderPassBeginInfo>();
1824 device_group_render_pass_begin_info.deviceRenderAreaCount = 1;
1825 device_group_render_pass_begin_info.pDeviceRenderAreas = &device_render_area;
1826 fragment_density_map.pNext = &device_group_render_pass_begin_info;
1827
1828 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06113");
1829 m_commandBuffer->BeginRendering(begin_rendering_info);
1830 m_errorMonitor->VerifyFound();
1831
1832 device_render_area.extent.width = 32 * fdm_props.maxFragmentDensityTexelSize.width;
1833 device_render_area.extent.height = 64 * fdm_props.maxFragmentDensityTexelSize.height;
1834
1835 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06115");
1836 m_commandBuffer->BeginRendering(begin_rendering_info);
1837 m_errorMonitor->VerifyFound();
1838
1839 m_commandBuffer->end();
1840}
1841
ziga-lunarg50253b92022-04-25 14:36:13 +02001842TEST_F(VkLayerTest, TestFragmentDensityMapRenderAreaWithoutDeviceGroupExt) {
1843 TEST_DESCRIPTION("Validate VkRenderingFragmentDensityMapAttachmentInfo attachment image view extent.");
1844
1845 SetTargetApiVersion(VK_API_VERSION_1_0);
1846 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1847 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1848
1849 ASSERT_NO_FATAL_FAILURE(InitFramework());
1850
1851 if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
sjfricke50955f32022-06-05 10:12:52 +09001852 GTEST_SKIP() << "Tests for 1.0 only";
ziga-lunarg50253b92022-04-25 14:36:13 +02001853 }
1854
sjfricked700bc02022-05-30 16:35:06 +09001855 if (!AreRequiredExtensionsEnabled()) {
1856 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg50253b92022-04-25 14:36:13 +02001857 }
1858
1859 auto vkGetPhysicalDeviceFeatures2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2KHR>(
1860 vk::GetInstanceProcAddr(instance(), "vkGetPhysicalDeviceFeatures2KHR"));
1861 ASSERT_TRUE(vkGetPhysicalDeviceFeatures2KHR != nullptr);
1862
1863 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1864 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2KHR>(&dynamic_rendering_features);
1865 vkGetPhysicalDeviceFeatures2KHR(gpu(), &features2);
1866 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001867 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg50253b92022-04-25 14:36:13 +02001868 }
1869
1870 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1871
1872 auto fdm_props = LvlInitStruct<VkPhysicalDeviceFragmentDensityMapPropertiesEXT>();
1873 auto props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fdm_props);
1874 vk::GetPhysicalDeviceProperties2(gpu(), &props2);
1875
1876 VkImageObj image(m_device);
1877 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT,
1878 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT);
1879 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1);
1880
1881 auto fragment_density_map = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
1882 fragment_density_map.imageView = image_view;
1883 fragment_density_map.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1884
1885 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_density_map);
1886 begin_rendering_info.layerCount = 1;
1887 begin_rendering_info.renderArea.extent.width = 64 * fdm_props.maxFragmentDensityTexelSize.width;
1888 begin_rendering_info.renderArea.extent.height = 32 * fdm_props.maxFragmentDensityTexelSize.height;
1889
1890 m_commandBuffer->begin();
1891
1892 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06110");
1893 m_commandBuffer->BeginRendering(begin_rendering_info);
1894 m_errorMonitor->VerifyFound();
1895
1896 begin_rendering_info.renderArea.extent.width = 32 * fdm_props.maxFragmentDensityTexelSize.width;
1897 begin_rendering_info.renderArea.extent.height = 64 * fdm_props.maxFragmentDensityTexelSize.height;
1898
1899 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06111");
1900 m_commandBuffer->BeginRendering(begin_rendering_info);
1901 m_errorMonitor->VerifyFound();
1902
1903 m_commandBuffer->end();
1904}
1905
ziga-lunarge7279ba2022-03-31 20:55:27 +02001906TEST_F(VkLayerTest, TestBarrierWithDynamicRendering) {
1907 TEST_DESCRIPTION("Test setting buffer memory barrier when dynamic rendering is active.");
1908
1909 SetTargetApiVersion(VK_API_VERSION_1_3);
1910
1911 ASSERT_NO_FATAL_FAILURE(InitFramework());
1912
1913 if (DeviceValidationVersion() < VK_API_VERSION_1_3) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001914 GTEST_SKIP() << "At least Vulkan version 1.3 is required";
ziga-lunarge7279ba2022-03-31 20:55:27 +02001915 }
1916
1917 auto vk13features = LvlInitStruct<VkPhysicalDeviceVulkan13Features>();
1918 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&vk13features);
1919 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1920 if (!vk13features.dynamicRendering) {
1921 printf("%s Test requires (unsupported) dynamicRendering, skipping\n", kSkipPrefix);
1922 return;
1923 }
1924 if (!vk13features.synchronization2) {
1925 printf("%s Test requires (unsupported) synchronization2, skipping\n", kSkipPrefix);
1926 return;
1927 }
1928
1929 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1930 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
1931
1932 PFN_vkCmdBeginRendering vkCmdBeginRendering =
1933 reinterpret_cast<PFN_vkCmdBeginRendering>(vk::GetDeviceProcAddr(m_device->device(), "vkCmdBeginRendering"));
1934 assert(vkCmdBeginRendering != nullptr);
1935 PFN_vkCmdEndRendering vkCmdEndRendering =
1936 reinterpret_cast<PFN_vkCmdEndRendering>(vk::GetDeviceProcAddr(m_device->device(), "vkCmdEndRendering"));
1937 assert(vkCmdEndRendering != nullptr);
1938
1939 m_commandBuffer->begin();
1940
1941 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
1942 VkClearRect clear_rect = {{{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}, 0, 1};
1943 begin_rendering_info.renderArea = clear_rect.rect;
1944 begin_rendering_info.layerCount = 1;
1945
1946 vkCmdBeginRendering(m_commandBuffer->handle(), &begin_rendering_info);
1947
1948 VkBufferObj buffer;
1949 VkMemoryPropertyFlags mem_reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
1950 buffer.init_as_src_and_dst(*m_device, 256, mem_reqs);
1951
1952 auto buf_barrier = lvl_init_struct<VkBufferMemoryBarrier2KHR>();
1953 buf_barrier.buffer = buffer.handle();
1954 buf_barrier.offset = 0;
1955 buf_barrier.size = VK_WHOLE_SIZE;
1956 buf_barrier.srcStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
1957 buf_barrier.dstStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
1958
1959 auto dependency_info = lvl_init_struct<VkDependencyInfoKHR>();
1960 dependency_info.bufferMemoryBarrierCount = 1;
1961 dependency_info.pBufferMemoryBarriers = &buf_barrier;
1962 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPipelineBarrier2-None-06191");
1963 vk::CmdPipelineBarrier2(m_commandBuffer->handle(), &dependency_info);
1964 m_errorMonitor->VerifyFound();
1965
1966 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPipelineBarrier-None-06191");
1967 vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, 0,
1968 nullptr, 0, nullptr, 0, nullptr);
1969 m_errorMonitor->VerifyFound();
1970
1971 vkCmdEndRendering(m_commandBuffer->handle());
1972 m_commandBuffer->end();
1973}
1974
ziga-lunarg5e0a2452022-04-20 19:29:37 +02001975TEST_F(VkLayerTest, BeginRenderingInvalidStencilAttachmentFormat) {
1976 TEST_DESCRIPTION("Test begin rendering with a stencil attachment that has an invalid format");
1977
1978 SetTargetApiVersion(VK_API_VERSION_1_3);
1979 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1980
1981 ASSERT_NO_FATAL_FAILURE(InitFramework());
1982
1983 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
1984 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
1985 }
1986
sjfricked700bc02022-05-30 16:35:06 +09001987 if (!AreRequiredExtensionsEnabled()) {
1988 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg5e0a2452022-04-20 19:29:37 +02001989 }
1990
1991 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1992 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1993 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1994 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001995 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg5e0a2452022-04-20 19:29:37 +02001996 }
1997
1998 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1999
2000 VkFormat depth_format = FindSupportedDepthOnlyFormat(gpu());
2001 if (depth_format == VK_FORMAT_UNDEFINED) {
2002 printf("%s requires a stencil only format format.\n", kSkipPrefix);
2003 return;
2004 }
2005
2006 VkImageObj image(m_device);
2007 image.Init(32, 32, 1, depth_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
2008 VkImageView image_view = image.targetView(depth_format, VK_IMAGE_ASPECT_DEPTH_BIT);
2009
2010 VkRenderingAttachmentInfoKHR stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2011 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL;
2012 stencil_attachment.imageView = image_view;
2013
2014 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2015 begin_rendering_info.layerCount = 1;
2016 begin_rendering_info.pStencilAttachment = &stencil_attachment;
2017
2018 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06548");
2019 m_commandBuffer->BeginRendering(begin_rendering_info);
2020 m_errorMonitor->VerifyFound();
2021}
2022
2023TEST_F(VkLayerTest, TestInheritanceRenderingInfoStencilAttachmentFormat) {
2024 TEST_DESCRIPTION("Test begin rendering with a stencil attachment that has an invalid format");
2025
2026 SetTargetApiVersion(VK_API_VERSION_1_3);
2027 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2028
2029 ASSERT_NO_FATAL_FAILURE(InitFramework());
2030
2031 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
2032 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
2033 }
2034
sjfricked700bc02022-05-30 16:35:06 +09002035 if (!AreRequiredExtensionsEnabled()) {
2036 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002037 }
2038
2039 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2040 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2041 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2042 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002043 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002044 }
2045
2046 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2047
2048 VkFormat depth_format = FindSupportedDepthOnlyFormat(gpu());
2049 if (depth_format == VK_FORMAT_UNDEFINED) {
2050 printf("%s requires a stencil only format format.\n", kSkipPrefix);
2051 return;
2052 }
2053
2054 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2055
2056 auto cmd_buffer_inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>();
2057 cmd_buffer_inheritance_rendering_info.colorAttachmentCount = 1;
2058 cmd_buffer_inheritance_rendering_info.pColorAttachmentFormats = &color_format;
2059 cmd_buffer_inheritance_rendering_info.depthAttachmentFormat = depth_format;
2060 cmd_buffer_inheritance_rendering_info.stencilAttachmentFormat = depth_format;
2061 cmd_buffer_inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
2062
2063 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2064 cmd_buffer_inheritance_info.pNext = &cmd_buffer_inheritance_rendering_info;
2065 cmd_buffer_inheritance_info.renderPass = VK_NULL_HANDLE;
2066
2067 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2068 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2069 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2070
2071 auto cmd_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>();
2072 cmd_buffer_allocate_info.commandPool = m_commandPool->handle();
2073 cmd_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY;
2074 cmd_buffer_allocate_info.commandBufferCount = 1;
2075
2076 VkCommandBuffer secondary_cmd_buffer;
ziga-lunarga3cc8482022-04-29 14:58:29 +02002077 vk::AllocateCommandBuffers(m_device->device(), &cmd_buffer_allocate_info, &secondary_cmd_buffer);
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002078
2079 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-stencilAttachmentFormat-06541");
2080 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
2081 m_errorMonitor->VerifyFound();
2082}
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002083
2084TEST_F(VkLayerTest, CreateGraphicsPipelineWithInvalidAttachmentSampleCount) {
2085 TEST_DESCRIPTION("Create pipeline with fragment shader that uses samples, but multisample state not begin set");
2086
ziga-lunarg7f25dff2022-05-06 17:49:34 +02002087 SetTargetApiVersion(VK_API_VERSION_1_1);
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002088 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2089 AddRequiredExtensions(VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME);
2090
2091 ASSERT_NO_FATAL_FAILURE(InitFramework());
2092
2093 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002094 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002095 }
2096
sjfricked700bc02022-05-30 16:35:06 +09002097 if (!AreRequiredExtensionsEnabled()) {
2098 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002099 }
2100
2101 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2102 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2103 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2104 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002105 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002106 }
2107
2108 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2109 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2110
2111 auto sample_count_info_amd = LvlInitStruct<VkAttachmentSampleCountInfoNV>();
2112 sample_count_info_amd.colorAttachmentCount = 1;
ziga-lunarg7f25dff2022-05-06 17:49:34 +02002113 sample_count_info_amd.depthStencilAttachmentSamples = static_cast<VkSampleCountFlagBits>(0x3);
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002114
2115 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(&sample_count_info_amd);
2116 pipeline_rendering_info.colorAttachmentCount = 1;
2117 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2118
2119 CreatePipelineHelper pipe(*this);
2120 pipe.InitInfo();
2121 pipe.gp_ci_.pNext = &pipeline_rendering_info;
2122 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2123 pipe.InitState();
2124
2125 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-depthStencilAttachmentSamples-06593");
2126 pipe.CreateGraphicsPipeline();
2127 m_errorMonitor->VerifyFound();
2128}
ziga-lunargd680bf22022-04-20 22:01:00 +02002129
2130TEST_F(VkLayerTest, CreatePipelineUsingDynamicRenderingWithoutFeature) {
2131 TEST_DESCRIPTION("Create graphcis pipeline that uses dynamic rendering, but feature is not enabled");
2132
2133 SetTargetApiVersion(VK_API_VERSION_1_3);
2134 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2135 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
2136
2137 ASSERT_NO_FATAL_FAILURE(InitFramework());
2138
2139 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002140 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargd680bf22022-04-20 22:01:00 +02002141 }
2142
sjfricked700bc02022-05-30 16:35:06 +09002143 if (!AreRequiredExtensionsEnabled()) {
2144 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargd680bf22022-04-20 22:01:00 +02002145 }
2146
2147 ASSERT_NO_FATAL_FAILURE(InitState());
2148
2149 CreatePipelineHelper pipe(*this);
2150 pipe.InitInfo();
2151 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2152 pipe.InitState();
2153
2154 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-dynamicRendering-06576");
2155 pipe.CreateGraphicsPipeline();
2156 m_errorMonitor->VerifyFound();
2157}
ziga-lunargf20d7952022-04-20 22:11:40 +02002158
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002159TEST_F(VkLayerTest, DynamicRenderingAreaGreaterThanAttachmentExtent) {
2160 TEST_DESCRIPTION("Begin dynamic rendering with render area greater than extent of attachments");
2161
2162 SetTargetApiVersion(VK_API_VERSION_1_0);
2163 AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
2164 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2165 ASSERT_NO_FATAL_FAILURE(InitFramework());
2166
2167 if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
sjfricke50955f32022-06-05 10:12:52 +09002168 GTEST_SKIP() << "Tests for 1.0 only";
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002169 }
sjfricked700bc02022-05-30 16:35:06 +09002170 if (!AreRequiredExtensionsEnabled()) {
2171 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002172 }
2173
ziga-lunarga51287c2022-04-20 23:24:37 +02002174 auto vkGetPhysicalDeviceFeatures2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2KHR>(
2175 vk::GetInstanceProcAddr(instance(), "vkGetPhysicalDeviceFeatures2KHR"));
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002176 ASSERT_TRUE(vkGetPhysicalDeviceFeatures2KHR != nullptr);
2177
2178 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2179 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2KHR>(&dynamic_rendering_features);
2180 vkGetPhysicalDeviceFeatures2KHR(gpu(), &features2);
2181 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002182 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002183 }
2184
2185 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2186
2187 VkImageObj colorImage(m_device);
2188 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
2189 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
2190
ziga-lunarga51287c2022-04-20 23:24:37 +02002191 auto color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002192 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2193 color_attachment.imageView = colorImageView;
2194
ziga-lunarga51287c2022-04-20 23:24:37 +02002195 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002196 begin_rendering_info.layerCount = 1;
2197 begin_rendering_info.colorAttachmentCount = 1;
2198 begin_rendering_info.pColorAttachments = &color_attachment;
2199 begin_rendering_info.renderArea.extent.width = 64;
2200 begin_rendering_info.renderArea.extent.height = 32;
2201
2202 m_commandBuffer->begin();
2203
2204 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06075");
2205 m_commandBuffer->BeginRendering(begin_rendering_info);
2206 m_errorMonitor->VerifyFound();
2207
2208 begin_rendering_info.renderArea.extent.width = 32;
2209 begin_rendering_info.renderArea.extent.height = 64;
2210
2211 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06076");
2212 m_commandBuffer->BeginRendering(begin_rendering_info);
2213 m_errorMonitor->VerifyFound();
2214
2215 const VkFormat ds_format = FindSupportedDepthStencilFormat(gpu());
2216 if (ds_format != VK_FORMAT_UNDEFINED) {
2217 VkImageObj depthImage(m_device);
2218 depthImage.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
2219 VkImageView depthImageView = depthImage.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT);
2220
2221 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2222 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
2223 depth_attachment.imageView = depthImageView;
2224
2225 begin_rendering_info.colorAttachmentCount = 0;
2226 begin_rendering_info.pDepthAttachment = &depth_attachment;
2227
2228 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06076");
2229 m_commandBuffer->BeginRendering(begin_rendering_info);
2230 m_errorMonitor->VerifyFound();
2231 }
2232
2233 m_commandBuffer->end();
2234}
ziga-lunarga51287c2022-04-20 23:24:37 +02002235
2236TEST_F(VkLayerTest, DynamicRenderingDeviceGroupAreaGreaterThanAttachmentExtent) {
2237 TEST_DESCRIPTION("Begin dynamic rendering with device group with render area greater than extent of attachments");
2238
2239 SetTargetApiVersion(VK_API_VERSION_1_1);
2240 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2241 ASSERT_NO_FATAL_FAILURE(InitFramework());
2242
2243 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002244 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarga51287c2022-04-20 23:24:37 +02002245 }
sjfricked700bc02022-05-30 16:35:06 +09002246 if (!AreRequiredExtensionsEnabled()) {
2247 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarga51287c2022-04-20 23:24:37 +02002248 }
2249
2250 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2251 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2252 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2253 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002254 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarga51287c2022-04-20 23:24:37 +02002255 }
2256
2257 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2258
2259 VkImageObj colorImage(m_device);
2260 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
2261 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
2262
2263 auto color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2264 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2265 color_attachment.imageView = colorImageView;
2266
2267 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2268 begin_rendering_info.layerCount = 1;
2269 begin_rendering_info.colorAttachmentCount = 1;
2270 begin_rendering_info.pColorAttachments = &color_attachment;
2271 begin_rendering_info.renderArea.extent.width = 64;
2272 begin_rendering_info.renderArea.extent.height = 32;
2273
2274 m_commandBuffer->begin();
2275
2276 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06079");
2277 m_commandBuffer->BeginRendering(begin_rendering_info);
2278 m_errorMonitor->VerifyFound();
2279
2280 begin_rendering_info.renderArea.extent.width = 32;
2281 begin_rendering_info.renderArea.extent.height = 64;
2282
2283 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06080");
2284 m_commandBuffer->BeginRendering(begin_rendering_info);
2285 m_errorMonitor->VerifyFound();
2286
2287 const VkFormat ds_format = FindSupportedDepthStencilFormat(gpu());
2288 if (ds_format != VK_FORMAT_UNDEFINED) {
2289 VkImageObj depthImage(m_device);
2290 depthImage.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
2291 VkImageView depthImageView = depthImage.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT);
2292
2293 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2294 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
2295 depth_attachment.imageView = depthImageView;
2296
2297 begin_rendering_info.colorAttachmentCount = 0;
2298 begin_rendering_info.pDepthAttachment = &depth_attachment;
2299
2300 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06080");
2301 m_commandBuffer->BeginRendering(begin_rendering_info);
2302 m_errorMonitor->VerifyFound();
2303 }
2304
2305 m_commandBuffer->end();
2306}
ziga-lunargd4105c12022-04-21 13:54:20 +02002307
2308TEST_F(VkLayerTest, SecondaryCommandBufferIncompatibleRenderPass) {
2309 TEST_DESCRIPTION("Execute secondary command buffers within render pass instance with incompatible render pass");
2310
2311 SetTargetApiVersion(VK_API_VERSION_1_1);
2312 ASSERT_NO_FATAL_FAILURE(InitFramework());
2313
2314 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002315 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargd4105c12022-04-21 13:54:20 +02002316 }
2317
2318 ASSERT_NO_FATAL_FAILURE(InitState());
2319 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2320
ziga-lunarga3cc8482022-04-29 14:58:29 +02002321 VkSubpassDescription subpass = {};
ziga-lunargd4105c12022-04-21 13:54:20 +02002322 auto render_pass_ci = LvlInitStruct<VkRenderPassCreateInfo>();
ziga-lunarga3cc8482022-04-29 14:58:29 +02002323 render_pass_ci.subpassCount = 1;
2324 render_pass_ci.pSubpasses = &subpass;
ziga-lunargd4105c12022-04-21 13:54:20 +02002325
2326 vk_testing::RenderPass render_pass;
2327 render_pass.init(*m_device, render_pass_ci);
2328
2329 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2330 VkCommandBuffer secondary_handle = cb.handle();
2331
2332 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2333 cmd_buffer_inheritance_info.renderPass = render_pass.handle();
2334 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2335 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2336 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2337
2338 cb.begin(&cmd_buffer_begin_info);
2339 cb.end();
2340
2341 m_commandBuffer->begin();
2342 m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
2343
2344 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pBeginInfo-06020");
2345 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pInheritanceInfo-00098");
2346 vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle);
2347 m_errorMonitor->VerifyFound();
2348
2349 m_commandBuffer->EndRenderPass();
2350 m_commandBuffer->end();
2351}
ziga-lunarg590e0292022-04-21 14:07:22 +02002352
2353TEST_F(VkLayerTest, SecondaryCommandBufferIncompatibleSubpass) {
2354 TEST_DESCRIPTION("Execute secondary command buffers with different subpass");
2355
2356 SetTargetApiVersion(VK_API_VERSION_1_1);
2357 ASSERT_NO_FATAL_FAILURE(InitFramework());
2358
2359 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002360 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg590e0292022-04-21 14:07:22 +02002361 }
2362
2363 ASSERT_NO_FATAL_FAILURE(InitState());
2364
2365 VkSubpassDescription subpasses[2] = {};
2366
2367 auto render_pass_ci = LvlInitStruct<VkRenderPassCreateInfo>();
2368 render_pass_ci.subpassCount = 2;
2369 render_pass_ci.pSubpasses = subpasses;
2370
2371 vk_testing::RenderPass render_pass;
2372 render_pass.init(*m_device, render_pass_ci);
2373
2374 auto framebuffer_ci = LvlInitStruct<VkFramebufferCreateInfo>();
2375 framebuffer_ci.renderPass = render_pass.handle();
2376 framebuffer_ci.width = 32;
2377 framebuffer_ci.height = 32;
ziga-lunarg143bdbf2022-05-04 19:04:58 +02002378 framebuffer_ci.layers = 1;
ziga-lunarg590e0292022-04-21 14:07:22 +02002379
2380 vk_testing::Framebuffer framebuffer;
2381 framebuffer.init(*m_device, framebuffer_ci);
2382
2383 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2384 VkCommandBuffer secondary_handle = cb.handle();
2385
2386 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2387 cmd_buffer_inheritance_info.renderPass = render_pass.handle();
2388 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2389 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2390 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2391
2392 cb.begin(&cmd_buffer_begin_info);
2393 cb.end();
2394
2395 auto render_pass_begin_info = LvlInitStruct<VkRenderPassBeginInfo>();
2396 render_pass_begin_info.renderPass = render_pass.handle();
2397 render_pass_begin_info.renderArea.extent = {32, 32};
2398 render_pass_begin_info.framebuffer = framebuffer.handle();
2399
2400 m_commandBuffer->begin();
2401 m_commandBuffer->BeginRenderPass(render_pass_begin_info, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
2402 vk::CmdNextSubpass(m_commandBuffer->handle(), VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
2403
2404 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pCommandBuffers-00097");
2405 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pCommandBuffers-06019");
2406 vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle);
2407 m_errorMonitor->VerifyFound();
2408
2409 m_commandBuffer->EndRenderPass();
2410 m_commandBuffer->end();
2411}
ziga-lunarg343193b2022-04-21 14:15:17 +02002412
2413TEST_F(VkLayerTest, SecondaryCommandBufferInvalidContents) {
2414 TEST_DESCRIPTION("Execute secondary command buffers within active render pass that was not begun with VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS");
2415
2416 SetTargetApiVersion(VK_API_VERSION_1_1);
2417 ASSERT_NO_FATAL_FAILURE(InitFramework());
2418
2419 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002420 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg343193b2022-04-21 14:15:17 +02002421 }
2422
2423 ASSERT_NO_FATAL_FAILURE(InitState());
2424 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2425
ziga-lunarg343193b2022-04-21 14:15:17 +02002426 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2427 VkCommandBuffer secondary_handle = cb.handle();
2428
2429 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2430 cmd_buffer_inheritance_info.renderPass = m_renderPass;
2431 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2432 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2433 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2434
2435 cb.begin(&cmd_buffer_begin_info);
2436 cb.end();
2437
2438 m_commandBuffer->begin();
2439 m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo);
2440
2441 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-contents-00095");
2442 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-contents-06018");
2443 vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle);
2444 m_errorMonitor->VerifyFound();
2445
2446 m_commandBuffer->EndRenderPass();
2447 m_commandBuffer->end();
2448}
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002449
2450TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoDepthFormat) {
2451 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo DepthFormat incompatible with previously used pipeline");
2452
2453 SetTargetApiVersion(VK_API_VERSION_1_1);
2454 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2455 ASSERT_NO_FATAL_FAILURE(InitFramework());
2456
2457 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002458 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002459 }
sjfricked700bc02022-05-30 16:35:06 +09002460 if (!AreRequiredExtensionsEnabled()) {
2461 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002462 }
2463
2464 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2465 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2466 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2467 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002468 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002469 }
2470
2471 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2472 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2473
2474 m_errorMonitor->ExpectSuccess();
2475
2476 std::vector<VkFormat> depth_formats;
2477 const VkFormat ds_formats[] = {VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT};
2478 for (uint32_t i = 0; i < size(ds_formats); ++i) {
2479 VkFormatProperties format_props;
2480 vk::GetPhysicalDeviceFormatProperties(gpu(), ds_formats[i], &format_props);
2481
2482 if (format_props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) {
2483 depth_formats.push_back(ds_formats[i]);
2484 }
2485 }
2486
2487 if (depth_formats.size() < 2) {
2488 printf("%s Test requires 2 depth formats, skipping test.\n", kSkipPrefix);
2489 return;
2490 }
2491
2492 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2493 pipeline_rendering_info.depthAttachmentFormat = depth_formats[0];
2494
2495 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
2496
2497 CreatePipelineHelper pipe1(*this);
2498 pipe1.InitInfo();
2499 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2500 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2501 pipe1.InitState();
2502 pipe1.ds_ci_ = ds_ci;
2503 pipe1.CreateGraphicsPipeline();
2504
2505 pipeline_rendering_info.depthAttachmentFormat = depth_formats[1];
2506
2507 CreatePipelineHelper pipe2(*this);
2508 pipe2.InitInfo();
2509 pipe2.gp_ci_.pNext = &pipeline_rendering_info;
2510 pipe2.gp_ci_.renderPass = VK_NULL_HANDLE;
2511 pipe2.InitState();
2512 pipe2.ds_ci_ = ds_ci;
2513 pipe2.CreateGraphicsPipeline();
2514
2515 VkImageObj image(m_device);
2516 image.Init(32, 32, 1, depth_formats[0], VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2517 VkImageView depth_image_view = image.targetView(depth_formats[0], VK_IMAGE_ASPECT_DEPTH_BIT);
2518
2519 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2520 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
2521 depth_attachment.imageView = depth_image_view;
2522
2523 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2524 begin_rendering_info.layerCount = 1;
2525 begin_rendering_info.pDepthAttachment = &depth_attachment;
2526
2527 m_commandBuffer->begin();
2528 m_commandBuffer->BeginRendering(begin_rendering_info);
2529
2530 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_);
2531 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
2532
2533 m_errorMonitor->VerifyNotFound();
2534
2535 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06197");
2536 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_);
2537 m_errorMonitor->VerifyFound();
2538
2539 m_commandBuffer->EndRendering();
2540 m_commandBuffer->end();
2541}
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002542
2543TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoColorAttachments) {
2544 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo color attachment incompatible with previously used pipeline");
2545
2546 SetTargetApiVersion(VK_API_VERSION_1_1);
2547 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2548 ASSERT_NO_FATAL_FAILURE(InitFramework());
2549
2550 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002551 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002552 }
sjfricked700bc02022-05-30 16:35:06 +09002553 if (!AreRequiredExtensionsEnabled()) {
2554 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002555 }
2556
2557 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2558 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2559 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2560 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002561 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002562 }
2563
2564 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2565 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2566
2567 m_errorMonitor->ExpectSuccess();
2568
2569 VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
2570 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2571 pipeline_rendering_info.colorAttachmentCount = 1;
2572 pipeline_rendering_info.pColorAttachmentFormats = &format;
2573
2574 CreatePipelineHelper pipe1(*this);
2575 pipe1.InitInfo();
2576 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2577 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2578 pipe1.InitState();
2579 pipe1.CreateGraphicsPipeline();
2580
2581 format = VK_FORMAT_B8G8R8A8_UNORM;
2582
2583 CreatePipelineHelper pipe2(*this);
2584 pipe2.InitInfo();
2585 pipe2.gp_ci_.pNext = &pipeline_rendering_info;
2586 pipe2.gp_ci_.renderPass = VK_NULL_HANDLE;
2587 pipe2.InitState();
2588 pipe2.CreateGraphicsPipeline();
2589
2590 VkImageObj image(m_device);
2591 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2592 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
2593
2594 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2595 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2596 color_attachment.imageView = image_view;
2597
2598 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2599 begin_rendering_info.layerCount = 1;
2600 begin_rendering_info.colorAttachmentCount = 1;
2601 begin_rendering_info.pColorAttachments = &color_attachment;
2602
2603 m_commandBuffer->begin();
2604 m_commandBuffer->BeginRendering(begin_rendering_info);
2605
2606 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_);
2607 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
2608
2609 m_errorMonitor->VerifyNotFound();
2610
2611 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06196");
2612 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_);
2613 m_errorMonitor->VerifyFound();
2614
2615 m_commandBuffer->EndRendering();
2616 m_commandBuffer->end();
2617}
ziga-lunargacd79322022-04-21 18:36:34 +02002618
2619TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoColorAttachmentCount) {
2620 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo color attachment count incompatible with previously used pipeline");
2621
2622 SetTargetApiVersion(VK_API_VERSION_1_1);
2623 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2624 ASSERT_NO_FATAL_FAILURE(InitFramework());
2625
2626 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002627 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargacd79322022-04-21 18:36:34 +02002628 }
sjfricked700bc02022-05-30 16:35:06 +09002629 if (!AreRequiredExtensionsEnabled()) {
2630 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargacd79322022-04-21 18:36:34 +02002631 }
2632
2633 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2634 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2635 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2636 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002637 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargacd79322022-04-21 18:36:34 +02002638 }
2639
2640 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2641 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2642
2643 m_errorMonitor->ExpectSuccess();
2644
2645 VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
2646 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2647 pipeline_rendering_info.colorAttachmentCount = 1;
2648 pipeline_rendering_info.pColorAttachmentFormats = &format;
2649
2650 CreatePipelineHelper pipe1(*this);
2651 pipe1.InitInfo();
2652 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2653 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2654 pipe1.InitState();
2655 pipe1.CreateGraphicsPipeline();
2656
2657 pipeline_rendering_info.colorAttachmentCount = 0;
2658
2659 CreatePipelineHelper pipe2(*this);
2660 pipe2.InitInfo();
2661 pipe2.gp_ci_.pNext = &pipeline_rendering_info;
2662 pipe2.gp_ci_.renderPass = VK_NULL_HANDLE;
2663 pipe2.InitState();
2664 pipe2.CreateGraphicsPipeline();
2665
2666 VkImageObj image(m_device);
2667 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2668 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
2669
2670 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2671 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2672 color_attachment.imageView = image_view;
2673
2674 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2675 begin_rendering_info.layerCount = 1;
2676 begin_rendering_info.colorAttachmentCount = 1;
2677 begin_rendering_info.pColorAttachments = &color_attachment;
2678
2679 m_commandBuffer->begin();
2680 m_commandBuffer->BeginRendering(begin_rendering_info);
2681
2682 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_);
2683 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
2684
2685 m_errorMonitor->VerifyNotFound();
2686
2687 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06195");
2688 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_);
2689 m_errorMonitor->VerifyFound();
2690
2691 m_commandBuffer->EndRendering();
2692 m_commandBuffer->end();
ziga-lunarge3f11282022-04-21 18:39:55 +02002693}
2694
2695TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoStencilFormat) {
2696 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo StencilFormat incompatible with previously used pipeline");
2697
2698 SetTargetApiVersion(VK_API_VERSION_1_1);
2699 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2700 ASSERT_NO_FATAL_FAILURE(InitFramework());
2701
2702 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002703 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge3f11282022-04-21 18:39:55 +02002704 }
sjfricked700bc02022-05-30 16:35:06 +09002705 if (!AreRequiredExtensionsEnabled()) {
2706 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge3f11282022-04-21 18:39:55 +02002707 }
2708
2709 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2710 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2711 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2712 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002713 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge3f11282022-04-21 18:39:55 +02002714 }
2715
2716 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2717 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2718
2719 m_errorMonitor->ExpectSuccess();
2720
2721 std::vector<VkFormat> stencil_formats;
2722 const VkFormat ds_formats[] = {VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT};
2723 for (uint32_t i = 0; i < size(ds_formats); ++i) {
2724 VkFormatProperties format_props;
2725 vk::GetPhysicalDeviceFormatProperties(gpu(), ds_formats[i], &format_props);
2726
2727 if (format_props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) {
2728 stencil_formats.push_back(ds_formats[i]);
2729 }
2730 }
2731
2732 if (stencil_formats.size() < 2) {
2733 printf("%s Test requires 2 stencil formats, skipping test.\n", kSkipPrefix);
2734 return;
2735 }
2736
2737 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2738 pipeline_rendering_info.stencilAttachmentFormat = stencil_formats[0];
2739
2740 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
2741
2742 CreatePipelineHelper pipe1(*this);
2743 pipe1.InitInfo();
2744 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2745 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2746 pipe1.InitState();
2747 pipe1.ds_ci_ = ds_ci;
2748 pipe1.CreateGraphicsPipeline();
2749
2750 pipeline_rendering_info.stencilAttachmentFormat = stencil_formats[1];
2751
2752 CreatePipelineHelper pipe2(*this);
2753 pipe2.InitInfo();
2754 pipe2.gp_ci_.pNext = &pipeline_rendering_info;
2755 pipe2.gp_ci_.renderPass = VK_NULL_HANDLE;
2756 pipe2.InitState();
2757 pipe2.ds_ci_ = ds_ci;
2758 pipe2.CreateGraphicsPipeline();
2759
2760 VkImageObj image(m_device);
2761 image.Init(32, 32, 1, stencil_formats[0], VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2762 VkImageView stencil_image_view = image.targetView(stencil_formats[0], VK_IMAGE_ASPECT_DEPTH_BIT);
2763
2764 VkRenderingAttachmentInfoKHR stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2765 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL;
2766 stencil_attachment.imageView = stencil_image_view;
2767
2768 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2769 begin_rendering_info.layerCount = 1;
2770 begin_rendering_info.pStencilAttachment = &stencil_attachment;
2771
2772 m_commandBuffer->begin();
2773 m_commandBuffer->BeginRendering(begin_rendering_info);
2774
2775 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_);
2776 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
2777
2778 m_errorMonitor->VerifyNotFound();
2779
2780 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06194");
2781 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_);
2782 m_errorMonitor->VerifyFound();
2783
2784 m_commandBuffer->EndRendering();
2785 m_commandBuffer->end();
2786}
ziga-lunarg155ed452022-04-21 23:54:06 +02002787
2788TEST_F(VkLayerTest, DynamicRenderingWithInvalidShaderLayerBuiltIn) {
2789 TEST_DESCRIPTION("Create invalid pipeline that writes to Layer built-in");
2790
2791 SetTargetApiVersion(VK_API_VERSION_1_1);
2792 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2793 ASSERT_NO_FATAL_FAILURE(InitFramework());
2794
2795 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002796 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg155ed452022-04-21 23:54:06 +02002797 }
sjfricked700bc02022-05-30 16:35:06 +09002798 if (!AreRequiredExtensionsEnabled()) {
2799 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg155ed452022-04-21 23:54:06 +02002800 }
2801
2802 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2803 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>(&dynamic_rendering_features);
2804 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&multiview_features);
2805 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2806 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002807 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg155ed452022-04-21 23:54:06 +02002808 }
2809 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002810 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg155ed452022-04-21 23:54:06 +02002811 }
2812 if (multiview_features.multiviewGeometryShader == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002813 GTEST_SKIP() << "Test requires (unsupported) multiviewGeometryShader";
ziga-lunarg155ed452022-04-21 23:54:06 +02002814 }
2815
2816 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2817 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2818
2819 static char const *gsSource = R"glsl(
2820 #version 450
2821 layout (triangles) in;
2822 layout (triangle_strip) out;
2823 layout (max_vertices = 1) out;
2824 void main() {
2825 gl_Position = vec4(1.0, 0.5, 0.5, 0.0);
2826 EmitVertex();
2827 gl_Layer = 4;
2828 }
2829 )glsl";
2830
2831 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
2832 VkShaderObj gs(this, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT);
2833
2834 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2835
2836 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2837 pipeline_rendering_info.colorAttachmentCount = 1;
2838 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2839 pipeline_rendering_info.viewMask = 0x1;
2840
2841 CreatePipelineHelper pipe(*this);
2842 pipe.InitInfo();
2843 pipe.shader_stages_ = {vs.GetStageCreateInfo(), gs.GetStageCreateInfo(), pipe.fs_->GetStageCreateInfo()};
2844 pipe.gp_ci_.pNext = &pipeline_rendering_info;
2845 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2846 pipe.InitState();
2847 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06059");
2848 pipe.CreateGraphicsPipeline();
2849 m_errorMonitor->VerifyFound();
2850}
ziga-lunarg6feb4632022-04-22 00:20:21 +02002851
2852TEST_F(VkLayerTest, DynamicRenderingWithInputAttachmentCapability) {
2853 TEST_DESCRIPTION("Create invalid pipeline that uses InputAttachment capability");
2854
2855 SetTargetApiVersion(VK_API_VERSION_1_1);
2856 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2857 ASSERT_NO_FATAL_FAILURE(InitFramework());
2858
2859 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002860 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg6feb4632022-04-22 00:20:21 +02002861 }
sjfricked700bc02022-05-30 16:35:06 +09002862 if (!AreRequiredExtensionsEnabled()) {
2863 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6feb4632022-04-22 00:20:21 +02002864 }
2865
2866 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2867 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2868 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2869 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002870 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6feb4632022-04-22 00:20:21 +02002871 }
2872
2873 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2874 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2875
2876 const std::string fsSource = R"(
2877 OpCapability Shader
2878 OpCapability InputAttachment
2879 %1 = OpExtInstImport "GLSL.std.450"
2880 OpMemoryModel Logical GLSL450
2881 OpEntryPoint Fragment %main "main"
2882 OpExecutionMode %main OriginUpperLeft
2883
2884 ; Debug Information
2885 OpSource GLSL 450
2886 OpName %main "main" ; id %4
2887
2888 ; Types, variables and constants
2889 %void = OpTypeVoid
2890 %3 = OpTypeFunction %void
2891
2892 ; Function main
2893 %main = OpFunction %void None %3
2894 %5 = OpLabel
2895 OpReturn
2896 OpFunctionEnd
2897 )";
2898
2899 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, SPV_ENV_VULKAN_1_0, SPV_SOURCE_ASM);
2900
2901 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2902
2903 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2904 pipeline_rendering_info.colorAttachmentCount = 1;
2905 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2906
2907 CreatePipelineHelper pipe(*this);
2908 pipe.InitInfo();
2909 pipe.shader_stages_ = {pipe.vs_->GetStageCreateInfo(), fs.GetStageCreateInfo()};
2910 pipe.gp_ci_.pNext = &pipeline_rendering_info;
2911 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2912 pipe.InitState();
2913 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06061");
2914 pipe.CreateGraphicsPipeline();
2915 m_errorMonitor->VerifyFound();
2916}
ziga-lunarga62b6ce2022-04-22 14:33:47 +02002917
2918TEST_F(VkLayerTest, InvalidRenderingInfoColorAttachmentFormat) {
2919 TEST_DESCRIPTION("Create pipeline with invalid color attachment format");
2920
2921 SetTargetApiVersion(VK_API_VERSION_1_1);
2922 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2923 ASSERT_NO_FATAL_FAILURE(InitFramework());
2924
2925 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002926 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarga62b6ce2022-04-22 14:33:47 +02002927 }
sjfricked700bc02022-05-30 16:35:06 +09002928 if (!AreRequiredExtensionsEnabled()) {
2929 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarga62b6ce2022-04-22 14:33:47 +02002930 }
2931
2932 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2933 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2934 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2935 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002936 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarga62b6ce2022-04-22 14:33:47 +02002937 }
2938
2939 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2940 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2941
2942 VkFormat color_format = VK_FORMAT_MAX_ENUM;
2943
2944 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2945 pipeline_rendering_info.colorAttachmentCount = 1;
2946 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2947
2948 CreatePipelineHelper pipe(*this);
2949 pipe.InitInfo();
2950 pipe.gp_ci_.pNext = &pipeline_rendering_info;
2951 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2952 pipe.InitState();
2953 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06579");
2954 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06580");
2955 pipe.CreateGraphicsPipeline();
2956 m_errorMonitor->VerifyFound();
2957}
ziga-lunargf7fb9202022-04-22 17:19:10 +02002958
2959TEST_F(VkLayerTest, InvalidDynamicRenderingLibraryViewMask) {
2960 TEST_DESCRIPTION("Create pipeline with invalid view mask");
2961
2962 SetTargetApiVersion(VK_API_VERSION_1_1);
2963 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2964 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
2965 ASSERT_NO_FATAL_FAILURE(InitFramework());
2966
2967 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002968 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargf7fb9202022-04-22 17:19:10 +02002969 }
sjfricked700bc02022-05-30 16:35:06 +09002970 if (!AreRequiredExtensionsEnabled()) {
2971 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargf7fb9202022-04-22 17:19:10 +02002972 }
2973
2974 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
2975 auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>(&multiview_features);
2976 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features);
2977 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2978 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2979 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002980 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargf7fb9202022-04-22 17:19:10 +02002981 }
2982 if (library_features.graphicsPipelineLibrary == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002983 GTEST_SKIP() << "Test requires (unsupported) graphicsPipelineLibrary";
ziga-lunargf7fb9202022-04-22 17:19:10 +02002984 }
2985 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002986 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunargf7fb9202022-04-22 17:19:10 +02002987 }
2988
2989 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2990 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2991
2992 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2993
2994 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2995 pipeline_rendering_info.colorAttachmentCount = 1;
2996 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2997
2998 auto graphics_library_create_info = LvlInitStruct<VkGraphicsPipelineLibraryCreateInfoEXT>(&pipeline_rendering_info);
2999 graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT;
3000 auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>(&graphics_library_create_info);
3001
3002 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
3003 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
3004 color_blend_state_create_info.attachmentCount = 1;
3005 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
3006
3007 m_errorMonitor->ExpectSuccess();
3008 CreatePipelineHelper lib(*this);
3009 lib.cb_ci_ = color_blend_state_create_info;
3010 lib.InitInfo();
3011 lib.gp_ci_.pNext = &library_create_info;
3012 lib.gp_ci_.renderPass = VK_NULL_HANDLE;
3013 lib.InitState();
3014 lib.CreateGraphicsPipeline();
3015 m_errorMonitor->VerifyNotFound();
3016
3017 graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT;
3018 library_create_info.libraryCount = 1;
3019 library_create_info.pLibraries = &lib.pipeline_;
3020 pipeline_rendering_info.viewMask = 0x1;
3021
3022 CreatePipelineHelper pipe(*this);
3023 pipe.InitInfo();
3024 pipe.gp_ci_.pNext = &library_create_info;
3025 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3026 pipe.InitState();
3027 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06626");
3028 pipe.CreateGraphicsPipeline();
3029 m_errorMonitor->VerifyFound();
3030}
ziga-lunarge151ca62022-04-22 17:40:51 +02003031
3032TEST_F(VkLayerTest, InvalidAttachmentSampleCount) {
3033 TEST_DESCRIPTION("Create pipeline with invalid color attachment samples");
3034
3035 SetTargetApiVersion(VK_API_VERSION_1_1);
3036 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3037 ASSERT_NO_FATAL_FAILURE(InitFramework());
3038
3039 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003040 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge151ca62022-04-22 17:40:51 +02003041 }
sjfricked700bc02022-05-30 16:35:06 +09003042 if (!AreRequiredExtensionsEnabled()) {
3043 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge151ca62022-04-22 17:40:51 +02003044 }
3045
3046 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
3047 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3048 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3049 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003050 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge151ca62022-04-22 17:40:51 +02003051 }
3052
3053 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3054 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3055
3056 VkSampleCountFlagBits color_attachment_samples = VK_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM;
3057
3058 auto samples_info = LvlInitStruct<VkAttachmentSampleCountInfoAMD>();
3059 samples_info.colorAttachmentCount = 1;
3060 samples_info.pColorAttachmentSamples = &color_attachment_samples;
3061 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(&samples_info);
3062
3063 CreatePipelineHelper pipe(*this);
3064 pipe.InitInfo();
3065 pipe.gp_ci_.pNext = &pipeline_rendering_info;
3066 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3067 pipe.InitState();
3068 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-pColorAttachmentSamples-06592");
3069 pipe.CreateGraphicsPipeline();
3070 m_errorMonitor->VerifyFound();
3071}
ziga-lunargb81597d2022-04-22 19:11:51 +02003072
3073TEST_F(VkLayerTest, InvalidDynamicRenderingLibrariesViewMask) {
3074 TEST_DESCRIPTION("Create pipeline with libaries that have incompatible view mask");
3075
3076 SetTargetApiVersion(VK_API_VERSION_1_1);
3077 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3078 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
3079 ASSERT_NO_FATAL_FAILURE(InitFramework());
3080
3081 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003082 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargb81597d2022-04-22 19:11:51 +02003083 }
sjfricked700bc02022-05-30 16:35:06 +09003084 if (!AreRequiredExtensionsEnabled()) {
3085 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargb81597d2022-04-22 19:11:51 +02003086 }
3087
3088 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3089 auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>(&multiview_features);
3090 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features);
3091 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3092 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3093 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003094 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargb81597d2022-04-22 19:11:51 +02003095 }
3096 if (library_features.graphicsPipelineLibrary == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003097 GTEST_SKIP() << "Test requires (unsupported) graphicsPipelineLibrary";
ziga-lunargb81597d2022-04-22 19:11:51 +02003098 }
3099 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003100 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunargb81597d2022-04-22 19:11:51 +02003101 }
3102
3103 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3104 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3105
3106 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
3107
3108 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
3109 pipeline_rendering_info.colorAttachmentCount = 1;
3110 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
3111
3112 auto graphics_library_create_info = LvlInitStruct<VkGraphicsPipelineLibraryCreateInfoEXT>(&pipeline_rendering_info);
3113 graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT;
3114 auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>(&graphics_library_create_info);
3115
3116 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
3117 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
3118 color_blend_state_create_info.attachmentCount = 1;
3119 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
3120
3121 m_errorMonitor->ExpectSuccess();
3122 CreatePipelineHelper lib1(*this);
3123 lib1.cb_ci_ = color_blend_state_create_info;
3124 lib1.InitInfo();
3125 lib1.gp_ci_.pNext = &library_create_info;
3126 lib1.gp_ci_.renderPass = VK_NULL_HANDLE;
3127 lib1.InitState();
3128 lib1.CreateGraphicsPipeline();
3129
3130 graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT;
3131 pipeline_rendering_info.viewMask = 0x1;
3132
3133 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
3134
3135 CreatePipelineHelper lib2(*this);
3136 lib2.cb_ci_ = color_blend_state_create_info;
3137 lib2.InitInfo();
3138 lib2.gp_ci_.pNext = &library_create_info;
3139 lib2.gp_ci_.renderPass = VK_NULL_HANDLE;
3140 lib2.ds_ci_ = ds_ci;
3141 lib2.InitState();
3142 lib2.CreateGraphicsPipeline();
3143 m_errorMonitor->VerifyNotFound();
3144
3145 graphics_library_create_info.flags =
3146 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT | VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT;
3147 library_create_info.libraryCount = 2;
3148 VkPipeline libraries[2] = {lib1.pipeline_, lib2.pipeline_};
3149 library_create_info.pLibraries = libraries;
3150 pipeline_rendering_info.viewMask = 0;
3151
3152 CreatePipelineHelper pipe(*this);
3153 pipe.InitInfo();
3154 pipe.gp_ci_.pNext = &library_create_info;
3155 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3156 pipe.InitState();
ziga-lunarg7f25dff2022-05-06 17:49:34 +02003157 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-pLibraries-06627");
ziga-lunargb81597d2022-04-22 19:11:51 +02003158 pipe.CreateGraphicsPipeline();
3159 m_errorMonitor->VerifyFound();
3160}
ziga-lunarg2e302312022-04-22 19:47:32 +02003161
3162TEST_F(VkLayerTest, InvalidDynamicRenderingLibraryRenderPass) {
3163 TEST_DESCRIPTION("Create pipeline with invalid library render pass");
3164
3165 SetTargetApiVersion(VK_API_VERSION_1_1);
3166 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3167 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
3168 ASSERT_NO_FATAL_FAILURE(InitFramework());
3169
3170 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003171 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg2e302312022-04-22 19:47:32 +02003172 }
sjfricked700bc02022-05-30 16:35:06 +09003173 if (!AreRequiredExtensionsEnabled()) {
3174 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg2e302312022-04-22 19:47:32 +02003175 }
3176
3177 auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>();
3178 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features);
3179 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3180 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3181 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003182 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg2e302312022-04-22 19:47:32 +02003183 }
3184 if (library_features.graphicsPipelineLibrary == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003185 GTEST_SKIP() << "Test requires (unsupported) graphicsPipelineLibrary";
ziga-lunarg2e302312022-04-22 19:47:32 +02003186 }
3187
3188 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3189 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3190
3191 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
3192
3193 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
3194 pipeline_rendering_info.colorAttachmentCount = 1;
3195 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
3196
3197 auto graphics_library_create_info = LvlInitStruct<VkGraphicsPipelineLibraryCreateInfoEXT>(&pipeline_rendering_info);
3198 graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT;
3199 auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>(&graphics_library_create_info);
3200
3201 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
3202 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
3203 color_blend_state_create_info.attachmentCount = 1;
3204 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
3205
3206 m_errorMonitor->ExpectSuccess();
3207 CreatePipelineHelper lib(*this);
3208 lib.cb_ci_ = color_blend_state_create_info;
3209 lib.InitInfo();
3210 lib.gp_ci_.pNext = &library_create_info;
3211 lib.InitState();
3212 lib.CreateGraphicsPipeline();
3213 m_errorMonitor->VerifyNotFound();
3214
3215 graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT;
3216 library_create_info.libraryCount = 1;
3217 library_create_info.pLibraries = &lib.pipeline_;
3218
3219 CreatePipelineHelper pipe(*this);
3220 pipe.InitInfo();
3221 pipe.gp_ci_.pNext = &library_create_info;
3222 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3223 pipe.InitState();
3224 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderpass-06625");
3225 pipe.CreateGraphicsPipeline();
3226 m_errorMonitor->VerifyFound();
3227}
ziga-lunarg7ba5a1c2022-04-22 19:56:49 +02003228
3229TEST_F(VkLayerTest, PipelineMissingMultisampleState) {
3230 TEST_DESCRIPTION("Create pipeline with missing multisample state");
3231
3232 SetTargetApiVersion(VK_API_VERSION_1_1);
3233 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3234 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
3235 ASSERT_NO_FATAL_FAILURE(InitFramework());
3236
3237 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003238 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7ba5a1c2022-04-22 19:56:49 +02003239 }
sjfricked700bc02022-05-30 16:35:06 +09003240 if (!AreRequiredExtensionsEnabled()) {
3241 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7ba5a1c2022-04-22 19:56:49 +02003242 }
3243
3244 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
3245 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3246 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3247 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003248 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7ba5a1c2022-04-22 19:56:49 +02003249 }
3250
3251 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3252 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3253
3254 CreatePipelineHelper pipe(*this);
3255 pipe.InitInfo();
3256 pipe.gp_ci_.pMultisampleState = nullptr;
3257 pipe.InitState();
3258 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderpass-06631");
3259 pipe.CreateGraphicsPipeline();
3260 m_errorMonitor->VerifyFound();
ziga-lunarg14222532022-04-22 23:27:17 +02003261}
3262
ziga-lunargd7737482022-04-25 11:16:37 +02003263TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachment) {
3264 TEST_DESCRIPTION("Use invalid VkRenderingFragmentDensityMapAttachmentInfoEXT");
ziga-lunarg14222532022-04-22 23:27:17 +02003265
3266 SetTargetApiVersion(VK_API_VERSION_1_1);
3267 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3268 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3269 ASSERT_NO_FATAL_FAILURE(InitFramework());
3270
3271 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003272 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg14222532022-04-22 23:27:17 +02003273 }
sjfricked700bc02022-05-30 16:35:06 +09003274 if (!AreRequiredExtensionsEnabled()) {
3275 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg14222532022-04-22 23:27:17 +02003276 }
3277
ziga-lunargd7737482022-04-25 11:16:37 +02003278 auto multiview_featuers = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3279 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&multiview_featuers);
ziga-lunarg14222532022-04-22 23:27:17 +02003280 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3281 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3282 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003283 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg14222532022-04-22 23:27:17 +02003284 }
ziga-lunargd7737482022-04-25 11:16:37 +02003285 if (multiview_featuers.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003286 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunargd7737482022-04-25 11:16:37 +02003287 }
ziga-lunarg14222532022-04-22 23:27:17 +02003288
3289 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3290 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3291
3292 VkImageObj image(m_device);
3293 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
3294 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, VK_IMAGE_TILING_LINEAR, 0);
3295 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3296
3297 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3298 rendering_fragment_density.imageView = image_view;
3299 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3300 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3301 begin_rendering_info.layerCount = 1;
3302
3303 m_commandBuffer->begin();
ziga-lunargd7737482022-04-25 11:16:37 +02003304
ziga-lunarg14222532022-04-22 23:27:17 +02003305 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06157");
3306 m_commandBuffer->BeginRendering(begin_rendering_info);
3307 m_errorMonitor->VerifyFound();
ziga-lunargd7737482022-04-25 11:16:37 +02003308
3309 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3310
3311 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3312 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3313 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
3314 image_create_info.extent = {32, 32, 1};
3315 image_create_info.mipLevels = 1;
3316 image_create_info.arrayLayers = 2;
3317 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
3318 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3319 image_create_info.usage = VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT;
3320 VkImageObj image2(m_device);
3321 image2.Init(image_create_info);
3322 VkImageView image_view2 = image2.targetView(VK_FORMAT_R8G8B8A8_UINT);
3323 rendering_fragment_density.imageView = image_view2;
3324 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06160");
3325 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06109");
3326 m_commandBuffer->BeginRendering(begin_rendering_info);
3327 m_errorMonitor->VerifyFound();
3328
ziga-lunarg14222532022-04-22 23:27:17 +02003329 m_commandBuffer->end();
3330}
ziga-lunarga81df9d2022-04-22 23:33:13 +02003331
3332TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentUsage) {
3333 TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid imageLayout");
3334
3335 SetTargetApiVersion(VK_API_VERSION_1_1);
3336 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3337 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3338 ASSERT_NO_FATAL_FAILURE(InitFramework());
3339
3340 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003341 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarga81df9d2022-04-22 23:33:13 +02003342 }
sjfricked700bc02022-05-30 16:35:06 +09003343 if (!AreRequiredExtensionsEnabled()) {
3344 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarga81df9d2022-04-22 23:33:13 +02003345 }
3346
3347 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
3348 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3349 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3350 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003351 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarga81df9d2022-04-22 23:33:13 +02003352 }
3353
3354 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3355 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3356
3357 VkImageObj image(m_device);
3358 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
3359 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3360
3361 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3362 rendering_fragment_density.imageView = image_view;
3363 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3364 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3365 begin_rendering_info.layerCount = 1;
3366
3367 m_commandBuffer->begin();
3368 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06158");
3369 m_commandBuffer->BeginRendering(begin_rendering_info);
3370 m_errorMonitor->VerifyFound();
3371 m_commandBuffer->end();
3372}
ziga-lunarg7c411b32022-04-22 23:37:48 +02003373
3374TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentCreateFlags) {
3375 TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid image create flags");
3376
3377 SetTargetApiVersion(VK_API_VERSION_1_1);
3378 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3379 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3380 ASSERT_NO_FATAL_FAILURE(InitFramework());
3381
3382 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003383 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7c411b32022-04-22 23:37:48 +02003384 }
sjfricked700bc02022-05-30 16:35:06 +09003385 if (!AreRequiredExtensionsEnabled()) {
3386 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7c411b32022-04-22 23:37:48 +02003387 }
3388
3389 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
3390 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3391 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3392 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003393 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7c411b32022-04-22 23:37:48 +02003394 }
3395
3396 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3397 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3398
3399 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3400 image_create_info.flags = VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT;
3401 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3402 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
3403 image_create_info.extent = {32, 32, 4};
3404 image_create_info.mipLevels = 1;
3405 image_create_info.arrayLayers = 1;
3406 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
3407 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3408 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT;
3409
3410 VkImageObj image(m_device);
3411 image.Init(image_create_info);
3412 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3413
3414 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3415 rendering_fragment_density.imageView = image_view;
3416 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3417 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3418 begin_rendering_info.layerCount = 1;
3419
3420 m_commandBuffer->begin();
3421 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06159");
3422 m_commandBuffer->BeginRendering(begin_rendering_info);
3423 m_errorMonitor->VerifyFound();
3424 m_commandBuffer->end();
3425}
ziga-lunarg66569a72022-04-22 23:43:26 +02003426
3427TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentLayerCount) {
3428 TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid layer count");
3429
3430 SetTargetApiVersion(VK_API_VERSION_1_1);
3431 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3432 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3433 ASSERT_NO_FATAL_FAILURE(InitFramework());
3434
3435 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003436 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg66569a72022-04-22 23:43:26 +02003437 }
sjfricked700bc02022-05-30 16:35:06 +09003438 if (!AreRequiredExtensionsEnabled()) {
3439 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg66569a72022-04-22 23:43:26 +02003440 }
3441
3442 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3443 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&multiview_features);
3444 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3445 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3446 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003447 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg66569a72022-04-22 23:43:26 +02003448 }
3449 if (!multiview_features.multiview) {
sjfricke50955f32022-06-05 10:12:52 +09003450 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg66569a72022-04-22 23:43:26 +02003451 }
3452
3453 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3454 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3455
3456 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3457 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3458 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
3459 image_create_info.extent = {32, 32, 4};
3460 image_create_info.mipLevels = 1;
3461 image_create_info.arrayLayers = 2;
3462 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
3463 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3464 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT;
3465
3466 VkImageObj image(m_device);
3467 image.Init(image_create_info);
3468 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3469
3470 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3471 rendering_fragment_density.imageView = image_view;
3472 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3473 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3474 begin_rendering_info.layerCount = 1;
3475 begin_rendering_info.viewMask = 0x1;
3476
3477 m_commandBuffer->begin();
3478 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06160");
3479 m_commandBuffer->BeginRendering(begin_rendering_info);
3480 m_errorMonitor->VerifyFound();
3481 m_commandBuffer->end();
3482}
ziga-lunarg323c11d2022-04-22 23:56:32 +02003483
3484TEST_F(VkLayerTest, InvalidRenderingPNextImageView) {
3485 TEST_DESCRIPTION(
3486 "Use different image views in VkRenderingFragmentShadingRateAttachmentInfoKHR and "
3487 "VkRenderingFragmentDensityMapAttachmentInfoEXT");
3488
3489 SetTargetApiVersion(VK_API_VERSION_1_1);
3490 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3491 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3492 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
3493 ASSERT_NO_FATAL_FAILURE(InitFramework());
3494
3495 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003496 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg323c11d2022-04-22 23:56:32 +02003497 }
sjfricked700bc02022-05-30 16:35:06 +09003498 if (!AreRequiredExtensionsEnabled()) {
3499 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg323c11d2022-04-22 23:56:32 +02003500 }
3501
3502 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3503 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&multiview_features);
3504 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3505 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3506 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003507 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg323c11d2022-04-22 23:56:32 +02003508 }
3509 if (!multiview_features.multiview) {
sjfricke50955f32022-06-05 10:12:52 +09003510 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg323c11d2022-04-22 23:56:32 +02003511 }
3512
3513 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3514 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3515
3516 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
3517
3518 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
3519 vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2);
3520
3521 VkImageObj image1(m_device);
3522 image1.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
3523 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR,
3524 VK_IMAGE_TILING_LINEAR, 0);
3525 VkImageView image_view1 = image1.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3526 VkImageObj image2(m_device);
3527 image2.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
3528 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, VK_IMAGE_TILING_LINEAR, 0);
3529 VkImageView image_view2 = image2.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3530
3531 auto rendering_fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
3532 rendering_fragment_shading_rate.imageView = image_view1;
3533 rendering_fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3534 rendering_fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
3535 auto rendering_fragment_density =
3536 LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>(&rendering_fragment_shading_rate);
3537 rendering_fragment_density.imageView = image_view2;
3538 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3539 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3540 begin_rendering_info.layerCount = 1;
3541 begin_rendering_info.viewMask = 0x1;
3542
3543 m_commandBuffer->begin();
3544 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06126");
3545 m_commandBuffer->BeginRendering(begin_rendering_info);
3546 m_errorMonitor->VerifyFound();
3547 m_commandBuffer->end();
3548}
ziga-lunarg95f20d42022-04-23 00:06:42 +02003549
3550TEST_F(VkLayerTest, InvalidRenderingRenderArea) {
3551 TEST_DESCRIPTION("Use negative offset in RenderingInfo render area");
3552
3553 SetTargetApiVersion(VK_API_VERSION_1_0);
3554 AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
3555 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3556 ASSERT_NO_FATAL_FAILURE(InitFramework());
3557
3558 if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
sjfricke50955f32022-06-05 10:12:52 +09003559 GTEST_SKIP() << "Tests for 1.0 only";
ziga-lunarg95f20d42022-04-23 00:06:42 +02003560 }
sjfricked700bc02022-05-30 16:35:06 +09003561 if (!AreRequiredExtensionsEnabled()) {
3562 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg95f20d42022-04-23 00:06:42 +02003563 }
3564
3565 auto vkGetPhysicalDeviceFeatures2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2KHR>(
3566 vk::GetInstanceProcAddr(instance(), "vkGetPhysicalDeviceFeatures2KHR"));
3567 ASSERT_TRUE(vkGetPhysicalDeviceFeatures2KHR != nullptr);
3568
3569 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
3570 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2KHR>(&dynamic_rendering_features);
3571 vkGetPhysicalDeviceFeatures2KHR(gpu(), &features2);
3572 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003573 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg95f20d42022-04-23 00:06:42 +02003574 }
3575
3576 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3577 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3578
3579 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3580 begin_rendering_info.layerCount = 1;
3581 begin_rendering_info.renderArea.offset.x = -1;
ziga-lunarg9b6a95f2022-04-23 00:13:38 +02003582 begin_rendering_info.renderArea.extent.width = 32;
3583 begin_rendering_info.renderArea.extent.height = 32;
ziga-lunarg95f20d42022-04-23 00:06:42 +02003584
3585 m_commandBuffer->begin();
3586
3587 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06071");
3588 m_commandBuffer->BeginRendering(begin_rendering_info);
3589 m_errorMonitor->VerifyFound();
3590
3591 begin_rendering_info.renderArea.offset.x = 0;
3592 begin_rendering_info.renderArea.offset.y = -1;
3593
3594 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06072");
3595 m_commandBuffer->BeginRendering(begin_rendering_info);
3596 m_errorMonitor->VerifyFound();
3597
ziga-lunarg9b6a95f2022-04-23 00:13:38 +02003598 begin_rendering_info.renderArea.offset.y = 0;
3599 begin_rendering_info.renderArea.offset.x = m_device->phy().properties().limits.maxFramebufferWidth - 16;
3600 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06073");
3601 m_commandBuffer->BeginRendering(begin_rendering_info);
3602 m_errorMonitor->VerifyFound();
3603
3604 begin_rendering_info.renderArea.offset.x = 0;
3605 begin_rendering_info.renderArea.offset.y = m_device->phy().properties().limits.maxFramebufferHeight - 16;
3606 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06074");
3607 m_commandBuffer->BeginRendering(begin_rendering_info);
3608 m_errorMonitor->VerifyFound();
3609
ziga-lunarg95f20d42022-04-23 00:06:42 +02003610 m_commandBuffer->end();
3611}
ziga-lunarg6662a882022-04-23 00:21:27 +02003612
3613TEST_F(VkLayerTest, InvalidRenderingInfoViewMask) {
3614 TEST_DESCRIPTION("Use negative offset in RenderingInfo render area");
3615
3616 SetTargetApiVersion(VK_API_VERSION_1_1);
3617 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3618 ASSERT_NO_FATAL_FAILURE(InitFramework());
3619
3620 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003621 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg6662a882022-04-23 00:21:27 +02003622 }
sjfricked700bc02022-05-30 16:35:06 +09003623 if (!AreRequiredExtensionsEnabled()) {
3624 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6662a882022-04-23 00:21:27 +02003625 }
3626
3627 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3628 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(&multiview_features);
3629 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3630 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3631 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003632 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6662a882022-04-23 00:21:27 +02003633 }
3634 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003635 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg6662a882022-04-23 00:21:27 +02003636 }
3637
3638 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3639 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3640
3641 VkPhysicalDeviceMultiviewProperties multiview_props = LvlInitStruct<VkPhysicalDeviceMultiviewProperties>();
3642 VkPhysicalDeviceProperties2 pd_props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&multiview_props);
3643 vk::GetPhysicalDeviceProperties2(gpu(), &pd_props2);
3644
3645 if (multiview_props.maxMultiviewViewCount == 32) {
3646 printf("%s VUID is not testable as maxMultiviewViewCount is 32, skipping test\n", kSkipPrefix);
3647 return;
3648 }
3649
3650 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3651 begin_rendering_info.layerCount = 1;
3652 begin_rendering_info.renderArea.extent.width = 32;
3653 begin_rendering_info.renderArea.extent.height = 32;
3654 begin_rendering_info.viewMask = 1u << multiview_props.maxMultiviewViewCount;
3655
3656 m_commandBuffer->begin();
3657
3658 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-viewMask-06128");
3659 m_commandBuffer->BeginRendering(begin_rendering_info);
3660 m_errorMonitor->VerifyFound();
3661
3662 m_commandBuffer->end();
3663}
ziga-lunargae75b8a2022-04-23 10:54:37 +02003664
3665TEST_F(VkLayerTest, InvalidRenderingColorAttachmentFormat) {
3666 TEST_DESCRIPTION("Use format with missing potential format features in rendering color attachment");
3667
3668 SetTargetApiVersion(VK_API_VERSION_1_1);
3669 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3670 AddRequiredExtensions(VK_NV_LINEAR_COLOR_ATTACHMENT_EXTENSION_NAME);
3671 ASSERT_NO_FATAL_FAILURE(InitFramework());
3672
3673 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003674 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargae75b8a2022-04-23 10:54:37 +02003675 }
sjfricked700bc02022-05-30 16:35:06 +09003676 if (!AreRequiredExtensionsEnabled()) {
3677 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargae75b8a2022-04-23 10:54:37 +02003678 }
3679
3680 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
3681 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3682 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3683 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003684 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargae75b8a2022-04-23 10:54:37 +02003685 }
3686
3687 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3688 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3689
3690 VkFormat format = FindSupportedDepthStencilFormat(gpu());
3691 if (format == VK_FORMAT_UNDEFINED) {
3692 printf("%s No Depth + Stencil format found. Skipped.\n", kSkipPrefix);
3693 return;
3694 }
3695
3696 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
3697 pipeline_rendering_info.colorAttachmentCount = 1;
3698 pipeline_rendering_info.pColorAttachmentFormats = &format;
3699
3700 CreatePipelineHelper pipe(*this);
3701 pipe.InitInfo();
3702 pipe.gp_ci_.pNext = &pipeline_rendering_info;
3703 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3704 pipe.InitState();
3705
3706 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06582");
3707 pipe.CreateGraphicsPipeline();
3708 m_errorMonitor->VerifyFound();
3709}
ziga-lunargeac390f2022-04-23 11:05:28 +02003710
sjfricke483c1082022-06-05 10:21:44 +09003711TEST_F(VkLayerTest, InvalidResolveModeWithNonIntegerColorFormat) {
3712 TEST_DESCRIPTION("Use invalid resolve mode with non integer color format");
3713
3714 SetTargetApiVersion(VK_API_VERSION_1_1);
3715 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3716 ASSERT_NO_FATAL_FAILURE(InitFramework());
3717
3718 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
3719 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
3720 }
sjfricked700bc02022-05-30 16:35:06 +09003721 if (!AreRequiredExtensionsEnabled()) {
3722 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
sjfricke483c1082022-06-05 10:21:44 +09003723 }
3724
3725 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
3726 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3727 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3728 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
3729 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
3730 }
3731
3732 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3733 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3734
3735 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3736 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3737 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; // not int color
3738 image_create_info.extent = {32, 32, 4};
3739 image_create_info.mipLevels = 1;
3740 image_create_info.arrayLayers = 1;
3741 image_create_info.samples = VK_SAMPLE_COUNT_4_BIT;
3742 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3743 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
3744 VkImageObj image(m_device);
3745 image.Init(image_create_info);
3746 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3747
3748 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3749 color_attachment.imageView = image_view;
3750 color_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT; // not allowed for format
3751 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3752 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
3753
3754 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3755 begin_rendering_info.colorAttachmentCount = 1;
3756 begin_rendering_info.pColorAttachments = &color_attachment;
3757 begin_rendering_info.layerCount = 1;
3758
3759 m_commandBuffer->begin();
3760
3761 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06129");
3762 m_commandBuffer->BeginRendering(begin_rendering_info);
3763 m_errorMonitor->VerifyFound();
3764
3765 m_commandBuffer->end();
3766}
3767
ziga-lunargeac390f2022-04-23 11:05:28 +02003768TEST_F(VkLayerTest, InvalidResolveModeWithIntegerColorFormat) {
3769 TEST_DESCRIPTION("Use invalid resolve mode with integer color format");
3770
3771 SetTargetApiVersion(VK_API_VERSION_1_1);
3772 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3773 ASSERT_NO_FATAL_FAILURE(InitFramework());
3774
3775 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003776 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargeac390f2022-04-23 11:05:28 +02003777 }
sjfricked700bc02022-05-30 16:35:06 +09003778 if (!AreRequiredExtensionsEnabled()) {
3779 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargeac390f2022-04-23 11:05:28 +02003780 }
3781
3782 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
3783 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3784 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3785 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003786 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargeac390f2022-04-23 11:05:28 +02003787 }
3788
3789 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3790 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3791
3792 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3793 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3794 image_create_info.format = VK_FORMAT_R8G8B8A8_UINT;
3795 image_create_info.extent = {32, 32, 4};
3796 image_create_info.mipLevels = 1;
3797 image_create_info.arrayLayers = 1;
3798 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
3799 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3800 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
3801 VkImageObj image(m_device);
3802 image.Init(image_create_info);
3803 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
3804
3805 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3806 color_attachment.imageView = image_view;
3807 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3808 color_attachment.resolveMode = VK_RESOLVE_MODE_MAX_BIT;
3809 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
3810
3811 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3812 begin_rendering_info.colorAttachmentCount = 1;
3813 begin_rendering_info.pColorAttachments = &color_attachment;
3814 begin_rendering_info.layerCount = 1;
3815
3816 m_commandBuffer->begin();
3817
3818 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06130");
3819 m_commandBuffer->BeginRendering(begin_rendering_info);
3820 m_errorMonitor->VerifyFound();
3821
3822 m_commandBuffer->end();
3823}
ziga-lunargdf2a3202022-04-23 11:07:46 +02003824
3825TEST_F(VkLayerTest, InvalidResolveModeSamples) {
3826 TEST_DESCRIPTION("Use invalid sample count with resolve mode that is not none");
3827
3828 SetTargetApiVersion(VK_API_VERSION_1_1);
3829 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3830 ASSERT_NO_FATAL_FAILURE(InitFramework());
3831
3832 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003833 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargdf2a3202022-04-23 11:07:46 +02003834 }
sjfricked700bc02022-05-30 16:35:06 +09003835 if (!AreRequiredExtensionsEnabled()) {
3836 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargdf2a3202022-04-23 11:07:46 +02003837 }
3838
3839 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
3840 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3841 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3842 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003843 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargdf2a3202022-04-23 11:07:46 +02003844 }
3845
3846 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3847 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3848
3849 VkImageObj image(m_device);
3850 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
3851 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3852
3853 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3854 color_attachment.imageView = image_view;
3855 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3856 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
3857 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
3858
3859 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3860 begin_rendering_info.colorAttachmentCount = 1;
3861 begin_rendering_info.pColorAttachments = &color_attachment;
3862 begin_rendering_info.layerCount = 1;
3863
3864 m_commandBuffer->begin();
3865
3866 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06132");
3867 m_commandBuffer->BeginRendering(begin_rendering_info);
3868 m_errorMonitor->VerifyFound();
3869
3870 m_commandBuffer->end();
3871}
ziga-lunargb7693aa2022-04-23 11:21:57 +02003872
3873TEST_F(VkLayerTest, InvalidResolveImageViewSamples) {
3874 TEST_DESCRIPTION("Use resolve image view with invalid sample count");
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-lunargb7693aa2022-04-23 11:21:57 +02003882 }
sjfricked700bc02022-05-30 16:35:06 +09003883 if (!AreRequiredExtensionsEnabled()) {
3884 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargb7693aa2022-04-23 11:21:57 +02003885 }
3886
3887 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
3888 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3889 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3890 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003891 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargb7693aa2022-04-23 11:21:57 +02003892 }
3893
3894 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3895 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3896
3897 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3898 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3899 image_create_info.format = VK_FORMAT_R8G8B8A8_UINT;
3900 image_create_info.extent = {32, 32, 4};
3901 image_create_info.mipLevels = 1;
3902 image_create_info.arrayLayers = 1;
3903 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
3904 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3905 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
3906
3907 VkImageObj image(m_device);
3908 image.Init(image_create_info);
3909 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
3910
3911 VkImageObj resolve_image(m_device);
3912 resolve_image.Init(image_create_info);
3913 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UINT);
3914
3915 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3916 color_attachment.imageView = image_view;
3917 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3918 color_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
3919 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
3920 color_attachment.resolveImageView = resolve_image_view;
3921
3922 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3923 begin_rendering_info.colorAttachmentCount = 1;
3924 begin_rendering_info.pColorAttachments = &color_attachment;
3925 begin_rendering_info.layerCount = 1;
3926
3927 m_commandBuffer->begin();
3928
3929 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06133");
3930 m_commandBuffer->BeginRendering(begin_rendering_info);
3931 m_errorMonitor->VerifyFound();
3932
3933 m_commandBuffer->end();
ziga-lunargd12cbce2022-04-23 11:35:20 +02003934}
3935
3936TEST_F(VkLayerTest, InvalidResolveImageViewFormatMatch) {
3937 TEST_DESCRIPTION("Use resolve image view with different format from image view");
3938
3939 SetTargetApiVersion(VK_API_VERSION_1_1);
3940 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3941 ASSERT_NO_FATAL_FAILURE(InitFramework());
3942
3943 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003944 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargd12cbce2022-04-23 11:35:20 +02003945 }
sjfricked700bc02022-05-30 16:35:06 +09003946 if (!AreRequiredExtensionsEnabled()) {
3947 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargd12cbce2022-04-23 11:35:20 +02003948 }
3949
3950 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
3951 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3952 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3953 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003954 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargd12cbce2022-04-23 11:35:20 +02003955 }
3956
3957 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3958 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3959
3960 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3961 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3962 image_create_info.format = VK_FORMAT_R8G8B8A8_UINT;
3963 image_create_info.extent = {32, 32, 4};
3964 image_create_info.mipLevels = 1;
3965 image_create_info.arrayLayers = 1;
3966 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
3967 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3968 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
3969
3970 VkImageObj image(m_device);
3971 image.Init(image_create_info);
3972 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
3973
3974 VkImageObj resolve_image(m_device);
3975 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
3976 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3977
3978 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3979 color_attachment.imageView = image_view;
3980 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3981 color_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
3982 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
3983 color_attachment.resolveImageView = resolve_image_view;
3984
3985 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3986 begin_rendering_info.colorAttachmentCount = 1;
3987 begin_rendering_info.pColorAttachments = &color_attachment;
3988 begin_rendering_info.layerCount = 1;
3989
3990 m_commandBuffer->begin();
3991
3992 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06134");
3993 m_commandBuffer->BeginRendering(begin_rendering_info);
3994 m_errorMonitor->VerifyFound();
3995
3996 m_commandBuffer->end();
3997}
ziga-lunarge579a3b2022-04-23 11:38:02 +02003998
3999TEST_F(VkLayerTest, InvalidRenderingAttachmentImageViewLayout) {
4000 TEST_DESCRIPTION("Use rendering attachment image view with invalid layout");
4001
4002 SetTargetApiVersion(VK_API_VERSION_1_1);
4003 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4004 ASSERT_NO_FATAL_FAILURE(InitFramework());
4005
4006 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004007 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge579a3b2022-04-23 11:38:02 +02004008 }
sjfricked700bc02022-05-30 16:35:06 +09004009 if (!AreRequiredExtensionsEnabled()) {
4010 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge579a3b2022-04-23 11:38:02 +02004011 }
4012
4013 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4014 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4015 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4016 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004017 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge579a3b2022-04-23 11:38:02 +02004018 }
4019
4020 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4021 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4022
4023 VkImageObj image(m_device);
4024 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4025 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4026
4027 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4028 color_attachment.imageView = image_view;
4029 color_attachment.imageLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
4030
4031 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4032 begin_rendering_info.colorAttachmentCount = 1;
4033 begin_rendering_info.pColorAttachments = &color_attachment;
4034 begin_rendering_info.layerCount = 1;
4035
4036 m_commandBuffer->begin();
4037
4038 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06135");
4039 m_commandBuffer->BeginRendering(begin_rendering_info);
4040 m_errorMonitor->VerifyFound();
4041
4042 m_commandBuffer->end();
4043}
ziga-lunarg409f8212022-04-23 11:40:53 +02004044
4045TEST_F(VkLayerTest, InvalidResolveImageViewLayout) {
4046 TEST_DESCRIPTION("Use resolve image view with invalid layout");
4047
4048 SetTargetApiVersion(VK_API_VERSION_1_1);
4049 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4050 ASSERT_NO_FATAL_FAILURE(InitFramework());
4051
4052 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004053 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg409f8212022-04-23 11:40:53 +02004054 }
sjfricked700bc02022-05-30 16:35:06 +09004055 if (!AreRequiredExtensionsEnabled()) {
4056 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg409f8212022-04-23 11:40:53 +02004057 }
4058
4059 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4060 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4061 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4062 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004063 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg409f8212022-04-23 11:40:53 +02004064 }
4065
4066 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4067 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4068
4069 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4070 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4071 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
4072 image_create_info.extent = {32, 32, 4};
4073 image_create_info.mipLevels = 1;
4074 image_create_info.arrayLayers = 1;
4075 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4076 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4077 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4078
4079 VkImageObj image(m_device);
4080 image.Init(image_create_info);
4081 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4082
4083 VkImageObj resolve_image(m_device);
4084 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4085 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4086
4087 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4088 color_attachment.imageView = image_view;
4089 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4090 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4091 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
4092 color_attachment.resolveImageView = resolve_image_view;
4093
4094 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4095 begin_rendering_info.colorAttachmentCount = 1;
4096 begin_rendering_info.pColorAttachments = &color_attachment;
4097 begin_rendering_info.layerCount = 1;
4098
4099 m_commandBuffer->begin();
4100
4101 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06136");
4102 m_commandBuffer->BeginRendering(begin_rendering_info);
4103 m_errorMonitor->VerifyFound();
4104
4105 m_commandBuffer->end();
4106}
ziga-lunargbbbef242022-04-23 12:12:10 +02004107
4108TEST_F(VkLayerTest, InvalidResolveImageViewLayoutSeparateDepthStencil) {
4109 TEST_DESCRIPTION("Use resolve image view with invalid layout");
4110
4111 SetTargetApiVersion(VK_API_VERSION_1_1);
4112 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4113 AddRequiredExtensions(VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_EXTENSION_NAME);
4114 ASSERT_NO_FATAL_FAILURE(InitFramework());
4115
4116 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004117 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargbbbef242022-04-23 12:12:10 +02004118 }
sjfricked700bc02022-05-30 16:35:06 +09004119 if (!AreRequiredExtensionsEnabled()) {
4120 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargbbbef242022-04-23 12:12:10 +02004121 }
4122
4123 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4124 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4125 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4126 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004127 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargbbbef242022-04-23 12:12:10 +02004128 }
4129
4130 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4131 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4132
4133 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4134 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4135 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
4136 image_create_info.extent = {32, 32, 4};
4137 image_create_info.mipLevels = 1;
4138 image_create_info.arrayLayers = 1;
4139 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4140 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4141 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4142
4143 VkImageObj image(m_device);
4144 image.Init(image_create_info);
4145 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4146
4147 VkImageObj resolve_image(m_device);
4148 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4149 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4150
4151 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4152 color_attachment.imageView = image_view;
4153 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4154 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4155 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL;
4156 color_attachment.resolveImageView = resolve_image_view;
4157
4158 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4159 begin_rendering_info.colorAttachmentCount = 1;
4160 begin_rendering_info.pColorAttachments = &color_attachment;
4161 begin_rendering_info.layerCount = 1;
4162
4163 m_commandBuffer->begin();
4164
4165 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06137");
4166 m_commandBuffer->BeginRendering(begin_rendering_info);
4167 m_errorMonitor->VerifyFound();
4168
4169 m_commandBuffer->end();
4170}
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004171
4172TEST_F(VkLayerTest, InvalidRenderingAttachmentImageViewShadingRateLayout) {
4173 TEST_DESCRIPTION("Use image view with invalid layout");
4174
4175 SetTargetApiVersion(VK_API_VERSION_1_1);
4176 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4177 AddRequiredExtensions(VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME);
4178 ASSERT_NO_FATAL_FAILURE(InitFramework());
4179
4180 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004181 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004182 }
sjfricked700bc02022-05-30 16:35:06 +09004183 if (!AreRequiredExtensionsEnabled()) {
4184 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004185 }
4186
4187 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4188 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4189 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4190 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004191 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004192 }
4193
4194 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4195 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4196
4197 VkImageObj image(m_device);
4198 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4199 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4200
4201 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4202 color_attachment.imageView = image_view;
4203 color_attachment.imageLayout = VK_IMAGE_LAYOUT_SHADING_RATE_OPTIMAL_NV;
4204
4205 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4206 begin_rendering_info.colorAttachmentCount = 1;
4207 begin_rendering_info.pColorAttachments = &color_attachment;
4208 begin_rendering_info.layerCount = 1;
4209
4210 m_commandBuffer->begin();
4211
4212 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06138");
4213 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06143");
4214 m_commandBuffer->BeginRendering(begin_rendering_info);
4215 m_errorMonitor->VerifyFound();
4216
4217 m_commandBuffer->end();
4218}
4219
4220TEST_F(VkLayerTest, InvalidResolveImageViewShadingRateLayout) {
4221 TEST_DESCRIPTION("Use resolve image view with invalid shading ratelayout");
4222
4223 SetTargetApiVersion(VK_API_VERSION_1_1);
4224 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4225 AddRequiredExtensions(VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME);
4226 ASSERT_NO_FATAL_FAILURE(InitFramework());
4227
4228 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004229 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004230 }
sjfricked700bc02022-05-30 16:35:06 +09004231 if (!AreRequiredExtensionsEnabled()) {
4232 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004233 }
4234
4235 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4236 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4237 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4238 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004239 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004240 }
4241
4242 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4243 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4244
4245 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4246 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4247 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
4248 image_create_info.extent = {32, 32, 4};
4249 image_create_info.mipLevels = 1;
4250 image_create_info.arrayLayers = 1;
4251 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4252 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4253 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4254
4255 VkImageObj image(m_device);
4256 image.Init(image_create_info);
4257 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4258
4259 VkImageObj resolve_image(m_device);
4260 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4261 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4262
4263 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4264 color_attachment.imageView = image_view;
4265 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4266 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4267 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_SHADING_RATE_OPTIMAL_NV;
4268 color_attachment.resolveImageView = resolve_image_view;
4269
4270 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4271 begin_rendering_info.colorAttachmentCount = 1;
4272 begin_rendering_info.pColorAttachments = &color_attachment;
4273 begin_rendering_info.layerCount = 1;
4274
4275 m_commandBuffer->begin();
4276
4277 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06139");
4278 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06144");
4279 m_commandBuffer->BeginRendering(begin_rendering_info);
4280 m_errorMonitor->VerifyFound();
4281
4282 m_commandBuffer->end();
4283}
ziga-lunarge7503952022-04-23 12:19:14 +02004284
4285TEST_F(VkLayerTest, InvalidRenderingAttachmentImageViewFragmentDensityLayout) {
4286 TEST_DESCRIPTION("Use image view with invalid layout");
4287
4288 SetTargetApiVersion(VK_API_VERSION_1_1);
4289 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4290 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
4291 ASSERT_NO_FATAL_FAILURE(InitFramework());
4292
4293 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004294 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge7503952022-04-23 12:19:14 +02004295 }
sjfricked700bc02022-05-30 16:35:06 +09004296 if (!AreRequiredExtensionsEnabled()) {
4297 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge7503952022-04-23 12:19:14 +02004298 }
4299
4300 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4301 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4302 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4303 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004304 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge7503952022-04-23 12:19:14 +02004305 }
4306
4307 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4308 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4309
4310 VkImageObj image(m_device);
4311 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4312 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4313
4314 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4315 color_attachment.imageView = image_view;
4316 color_attachment.imageLayout = VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT;
4317
4318 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4319 begin_rendering_info.colorAttachmentCount = 1;
4320 begin_rendering_info.pColorAttachments = &color_attachment;
4321 begin_rendering_info.layerCount = 1;
4322
4323 m_commandBuffer->begin();
4324
4325 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06140");
4326 m_commandBuffer->BeginRendering(begin_rendering_info);
4327 m_errorMonitor->VerifyFound();
4328
4329 m_commandBuffer->end();
ziga-lunarg10cd0fb2022-04-23 12:20:46 +02004330}
4331
4332TEST_F(VkLayerTest, InvalidResolveImageViewFragmentDensityLayout) {
4333 TEST_DESCRIPTION("Use resolve image view with invalid fragment density layout");
4334
4335 SetTargetApiVersion(VK_API_VERSION_1_1);
4336 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4337 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
4338 ASSERT_NO_FATAL_FAILURE(InitFramework());
4339
4340 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004341 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg10cd0fb2022-04-23 12:20:46 +02004342 }
sjfricked700bc02022-05-30 16:35:06 +09004343 if (!AreRequiredExtensionsEnabled()) {
4344 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg10cd0fb2022-04-23 12:20:46 +02004345 }
4346
4347 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4348 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4349 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4350 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004351 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg10cd0fb2022-04-23 12:20:46 +02004352 }
4353
4354 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4355 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4356
4357 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4358 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4359 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
4360 image_create_info.extent = {32, 32, 4};
4361 image_create_info.mipLevels = 1;
4362 image_create_info.arrayLayers = 1;
4363 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4364 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4365 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4366
4367 VkImageObj image(m_device);
4368 image.Init(image_create_info);
4369 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4370
4371 VkImageObj resolve_image(m_device);
4372 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4373 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4374
4375 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4376 color_attachment.imageView = image_view;
4377 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4378 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4379 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT;
4380 color_attachment.resolveImageView = resolve_image_view;
4381
4382 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4383 begin_rendering_info.colorAttachmentCount = 1;
4384 begin_rendering_info.pColorAttachments = &color_attachment;
4385 begin_rendering_info.layerCount = 1;
4386
4387 m_commandBuffer->begin();
4388
4389 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06141");
4390 m_commandBuffer->BeginRendering(begin_rendering_info);
4391 m_errorMonitor->VerifyFound();
4392
4393 m_commandBuffer->end();
4394}
ziga-lunargdfa31d12022-04-23 12:22:18 +02004395
4396TEST_F(VkLayerTest, InvalidResolveImageViewReadOnlyOptimalLayout) {
4397 TEST_DESCRIPTION("Use resolve image view with invalid read only optimal layout");
4398
4399 SetTargetApiVersion(VK_API_VERSION_1_1);
4400 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4401 ASSERT_NO_FATAL_FAILURE(InitFramework());
4402
4403 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004404 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargdfa31d12022-04-23 12:22:18 +02004405 }
sjfricked700bc02022-05-30 16:35:06 +09004406 if (!AreRequiredExtensionsEnabled()) {
4407 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargdfa31d12022-04-23 12:22:18 +02004408 }
4409
4410 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4411 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4412 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4413 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004414 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargdfa31d12022-04-23 12:22:18 +02004415 }
4416
4417 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4418 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4419
4420 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4421 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4422 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
4423 image_create_info.extent = {32, 32, 4};
4424 image_create_info.mipLevels = 1;
4425 image_create_info.arrayLayers = 1;
4426 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4427 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4428 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4429
4430 VkImageObj image(m_device);
4431 image.Init(image_create_info);
4432 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4433
4434 VkImageObj resolve_image(m_device);
4435 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4436 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4437
4438 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4439 color_attachment.imageView = image_view;
4440 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4441 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4442 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL;
4443 color_attachment.resolveImageView = resolve_image_view;
4444
4445 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4446 begin_rendering_info.colorAttachmentCount = 1;
4447 begin_rendering_info.pColorAttachments = &color_attachment;
4448 begin_rendering_info.layerCount = 1;
4449
4450 m_commandBuffer->begin();
4451
4452 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06142");
4453 m_commandBuffer->BeginRendering(begin_rendering_info);
4454 m_errorMonitor->VerifyFound();
4455
4456 m_commandBuffer->end();
4457}
ziga-lunarg735aa322022-04-24 14:17:47 +02004458
4459TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRateImageView) {
4460 TEST_DESCRIPTION("Test BeginRenderingInfo image view with FragmentShadingRateAttachment.");
4461
4462 SetTargetApiVersion(VK_API_VERSION_1_1);
4463 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4464 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
4465
4466 ASSERT_NO_FATAL_FAILURE(InitFramework());
4467
4468 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004469 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg735aa322022-04-24 14:17:47 +02004470 }
4471
sjfricked700bc02022-05-30 16:35:06 +09004472 if (!AreRequiredExtensionsEnabled()) {
4473 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg735aa322022-04-24 14:17:47 +02004474 }
4475
4476 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
4477 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4478 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4479
4480 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004481 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg735aa322022-04-24 14:17:47 +02004482 }
4483
4484 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
4485
4486 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
4487 vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2);
4488
4489 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4490 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4491
4492 VkImageObj image(m_device);
4493 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
4494 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR,
4495 VK_IMAGE_TILING_LINEAR, 0);
4496 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4497
4498 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
4499 fragment_shading_rate.imageView = image_view;
4500 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4501 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
4502
4503 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
4504 begin_rendering_info.layerCount = 1;
4505
4506 m_commandBuffer->begin();
4507
4508 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06147");
4509 m_commandBuffer->BeginRendering(begin_rendering_info);
4510 m_errorMonitor->VerifyFound();
4511
4512 m_commandBuffer->end();
4513}
ziga-lunarg644c0552022-04-24 17:50:58 +02004514
4515TEST_F(VkLayerTest, TestRenderingInfoColorAttachment) {
4516 TEST_DESCRIPTION("Test RenderingInfo color attachment.");
4517
4518 SetTargetApiVersion(VK_API_VERSION_1_1);
4519 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4520
4521 ASSERT_NO_FATAL_FAILURE(InitFramework());
4522
4523 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004524 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg644c0552022-04-24 17:50:58 +02004525 }
4526
sjfricked700bc02022-05-30 16:35:06 +09004527 if (!AreRequiredExtensionsEnabled()) {
4528 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg644c0552022-04-24 17:50:58 +02004529 }
4530
4531 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
4532 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4533 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4534
4535 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004536 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg644c0552022-04-24 17:50:58 +02004537 }
4538
4539 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4540 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4541
4542 VkImageObj invalid_image(m_device);
4543 invalid_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_SAMPLED_BIT, VK_IMAGE_TILING_LINEAR, 0);
4544 VkImageView invalid_image_view = invalid_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4545
4546 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4547 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4548 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
4549 image_create_info.extent = {32, 32, 4};
4550 image_create_info.mipLevels = 1;
4551 image_create_info.arrayLayers = 1;
4552 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4553 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4554 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4555 image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
4556 VkImageObj image(m_device);
4557 image.Init(image_create_info);
4558 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4559
4560 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4561 color_attachment.imageView = invalid_image_view;
4562 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4563
4564 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4565 begin_rendering_info.layerCount = 1;
4566 begin_rendering_info.colorAttachmentCount = 1;
4567 begin_rendering_info.pColorAttachments = &color_attachment;
4568
4569 m_commandBuffer->begin();
4570
4571 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06087");
4572 m_commandBuffer->BeginRendering(begin_rendering_info);
4573 m_errorMonitor->VerifyFound();
4574
4575 color_attachment.imageView = image_view;
4576 color_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4577
4578 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06090");
4579 m_commandBuffer->BeginRendering(begin_rendering_info);
4580 m_errorMonitor->VerifyFound();
4581
4582 color_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
4583 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06096");
4584 m_commandBuffer->BeginRendering(begin_rendering_info);
4585 m_errorMonitor->VerifyFound();
4586
4587 color_attachment.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL;
4588 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06100");
4589 m_commandBuffer->BeginRendering(begin_rendering_info);
4590 m_errorMonitor->VerifyFound();
4591
4592 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4593 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4594 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4595
4596 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06091");
4597 m_commandBuffer->BeginRendering(begin_rendering_info);
4598 m_errorMonitor->VerifyFound();
4599
4600 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
4601 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06097");
4602 m_commandBuffer->BeginRendering(begin_rendering_info);
4603 m_errorMonitor->VerifyFound();
4604
4605 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
4606 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06101");
4607 m_commandBuffer->BeginRendering(begin_rendering_info);
4608 m_errorMonitor->VerifyFound();
4609
4610 color_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
sjfricke483c1082022-06-05 10:21:44 +09004611
ziga-lunarg644c0552022-04-24 17:50:58 +02004612 const uint32_t max_color_attachments = m_device->phy().properties().limits.maxColorAttachments + 1;
4613 std::vector<VkRenderingAttachmentInfoKHR> color_attachments(max_color_attachments);
4614 for (auto &attachment : color_attachments) {
4615 attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4616 attachment.imageView = image_view;
4617 attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4618 }
4619 begin_rendering_info.colorAttachmentCount = max_color_attachments;
4620 begin_rendering_info.pColorAttachments = color_attachments.data();
4621 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06106");
4622 m_commandBuffer->BeginRendering(begin_rendering_info);
4623 m_errorMonitor->VerifyFound();
4624
4625 m_commandBuffer->end();
4626}
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004627
4628TEST_F(VkLayerTest, TestRenderingInfoDepthAttachment) {
4629 TEST_DESCRIPTION("Test RenderingInfo depth attachment.");
4630
4631 SetTargetApiVersion(VK_API_VERSION_1_1);
4632 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4633 AddRequiredExtensions(VK_KHR_DEPTH_STENCIL_RESOLVE_EXTENSION_NAME);
4634
4635 ASSERT_NO_FATAL_FAILURE(InitFramework());
4636
4637 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004638 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004639 }
4640
sjfricked700bc02022-05-30 16:35:06 +09004641 if (!AreRequiredExtensionsEnabled()) {
4642 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004643 }
4644
4645 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
4646 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4647 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4648
4649 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004650 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004651 }
4652
4653 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4654 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4655
4656 VkFormat ds_format = FindSupportedDepthStencilFormat(gpu());
4657 if (ds_format == VK_FORMAT_UNDEFINED) {
4658 printf("%s No Depth + Stencil format found, skipping test..\n", kSkipPrefix);
4659 return;
4660 }
4661
4662 auto depth_stencil_resolve_properties = LvlInitStruct<VkPhysicalDeviceDepthStencilResolveProperties>();
4663 auto properties2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&depth_stencil_resolve_properties);
4664 vk::GetPhysicalDeviceProperties2(gpu(), &properties2);
4665 bool has_depth_resolve_mode_average =
4666 (depth_stencil_resolve_properties.supportedDepthResolveModes & VK_RESOLVE_MODE_AVERAGE_BIT) != 0;
4667 bool has_stencil_resolve_mode_average =
4668 (depth_stencil_resolve_properties.supportedStencilResolveModes & VK_RESOLVE_MODE_AVERAGE_BIT) != 0;
4669
4670 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4671 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4672 image_create_info.format = ds_format;
4673 image_create_info.extent = {32, 32, 1};
4674 image_create_info.mipLevels = 1;
4675 image_create_info.arrayLayers = 1;
4676 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4677 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4678 image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
4679 VkImageObj image(m_device);
4680 image.Init(image_create_info);
4681
4682 VkImageObj depth_image(m_device);
4683 depth_image.Init(image_create_info);
4684 VkImageView depth_image_view = depth_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4685 VkImageObj stencil_image(m_device);
4686 stencil_image.Init(image_create_info);
4687 VkImageView stencil_image_view = stencil_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4688
4689 VkImageObj depth_resolvel_image(m_device);
4690 depth_resolvel_image.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0);
4691 VkImageView depth_resolve_image_view =
4692 depth_resolvel_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4693
4694 VkImageObj stencil_resolvel_image(m_device);
4695 stencil_resolvel_image.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0);
4696 VkImageView stencil_resolve_image_view =
4697 stencil_resolvel_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4698
4699 VkImageObj invalid_image(m_device);
4700 image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
4701 invalid_image.Init(image_create_info);
4702 VkImageView invalid_image_view = invalid_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT);
4703
4704 auto depth_attachment = LvlInitStruct<VkRenderingAttachmentInfo>();
4705 depth_attachment.imageView = depth_image_view;
4706 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4707
4708 auto stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfo>();
4709 stencil_attachment.imageView = stencil_image_view;
4710 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4711
4712 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4713 begin_rendering_info.layerCount = 1;
4714 begin_rendering_info.pDepthAttachment = &depth_attachment;
4715 begin_rendering_info.pStencilAttachment = &stencil_attachment;
4716
4717 m_commandBuffer->begin();
4718
4719 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06085");
4720 m_commandBuffer->BeginRendering(begin_rendering_info);
4721 m_errorMonitor->VerifyFound();
4722
4723 depth_attachment.imageView = VK_NULL_HANDLE;
4724 stencil_attachment.imageView = VK_NULL_HANDLE;
4725 depth_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4726 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4727 depth_attachment.resolveImageView = depth_resolve_image_view;
4728 stencil_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4729 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4730 stencil_attachment.resolveImageView = stencil_resolve_image_view;
4731
4732 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06086");
4733 m_commandBuffer->BeginRendering(begin_rendering_info);
4734 m_errorMonitor->VerifyFound();
4735
4736 depth_attachment.imageView = depth_image_view;
4737 stencil_attachment.imageView = depth_image_view;
4738 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4739 stencil_attachment.resolveImageView = depth_resolve_image_view;
4740
4741 if (!has_depth_resolve_mode_average) {
4742 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06102");
4743 }
4744 if (!has_stencil_resolve_mode_average) {
4745 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06103");
4746 }
4747 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06093");
4748 m_commandBuffer->BeginRendering(begin_rendering_info);
4749 m_errorMonitor->VerifyFound();
4750
4751 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
4752 if (has_depth_resolve_mode_average && has_stencil_resolve_mode_average) {
4753 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06098");
4754 m_commandBuffer->BeginRendering(begin_rendering_info);
4755 m_errorMonitor->VerifyFound();
4756 }
4757
4758 depth_attachment.imageView = invalid_image_view;
4759 stencil_attachment.imageView = invalid_image_view;
4760 depth_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
4761 stencil_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
4762 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06088");
4763 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06089");
4764 m_commandBuffer->BeginRendering(begin_rendering_info);
4765 m_errorMonitor->VerifyFound();
4766
4767 depth_attachment.imageView = depth_image_view;
4768 stencil_attachment.imageView = depth_image_view;
4769 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4770 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06092");
4771 m_commandBuffer->BeginRendering(begin_rendering_info);
4772 m_errorMonitor->VerifyFound();
4773
4774 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4775 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4776 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4777 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4778 depth_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4779 if (depth_stencil_resolve_properties.independentResolveNone == VK_FALSE && has_depth_resolve_mode_average) {
4780 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06104");
4781 m_commandBuffer->BeginRendering(begin_rendering_info);
4782 m_errorMonitor->VerifyFound();
4783 }
4784 if (depth_stencil_resolve_properties.independentResolve == VK_FALSE && has_depth_resolve_mode_average) {
4785 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06105");
4786 m_commandBuffer->BeginRendering(begin_rendering_info);
4787 m_errorMonitor->VerifyFound();
4788 }
4789
ziga-lunargf35a7d72022-04-25 01:00:41 +02004790 stencil_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4791 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4792 if (has_stencil_resolve_mode_average) {
4793 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06095");
4794 m_commandBuffer->BeginRendering(begin_rendering_info);
4795 m_errorMonitor->VerifyFound();
4796 }
4797 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL;
4798 if (has_stencil_resolve_mode_average) {
4799 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06099");
4800 m_commandBuffer->BeginRendering(begin_rendering_info);
4801 m_errorMonitor->VerifyFound();
4802 }
4803
4804 depth_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
4805 stencil_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
4806 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4807 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06094");
4808 m_commandBuffer->BeginRendering(begin_rendering_info);
4809 m_errorMonitor->VerifyFound();
4810
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004811 m_commandBuffer->end();
4812}
ziga-lunarg002e6562022-04-25 00:54:16 +02004813
4814TEST_F(VkLayerTest, InvalidRenderingRenderAreaWithDeviceGroupExt) {
4815 TEST_DESCRIPTION("Use negative offset in RenderingInfo render area");
4816
4817 SetTargetApiVersion(VK_API_VERSION_1_1);
4818 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4819 ASSERT_NO_FATAL_FAILURE(InitFramework());
4820
4821 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004822 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg002e6562022-04-25 00:54:16 +02004823 }
sjfricked700bc02022-05-30 16:35:06 +09004824 if (!AreRequiredExtensionsEnabled()) {
4825 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg002e6562022-04-25 00:54:16 +02004826 }
4827
4828 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
4829 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4830 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4831 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004832 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg002e6562022-04-25 00:54:16 +02004833 }
4834
4835 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4836 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4837
4838 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4839 begin_rendering_info.layerCount = 1;
4840 begin_rendering_info.renderArea.offset.x = -1;
4841 begin_rendering_info.renderArea.extent.width = 32;
4842 begin_rendering_info.renderArea.extent.height = 32;
4843
4844 m_commandBuffer->begin();
4845
4846 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06077");
4847 m_commandBuffer->BeginRendering(begin_rendering_info);
4848 m_errorMonitor->VerifyFound();
4849
4850 begin_rendering_info.renderArea.offset.x = 0;
4851 begin_rendering_info.renderArea.offset.y = -1;
4852
4853 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06078");
4854 m_commandBuffer->BeginRendering(begin_rendering_info);
4855 m_errorMonitor->VerifyFound();
4856
4857 m_commandBuffer->end();
4858}
ziga-lunarg6e4f9da2022-04-25 01:05:22 +02004859
4860TEST_F(VkLayerTest, TestDynamicRenderingPipeline) {
4861 TEST_DESCRIPTION("Use pipeline created with render pass in dynamic render pass.");
4862
4863 SetTargetApiVersion(VK_API_VERSION_1_1);
4864 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4865
4866 ASSERT_NO_FATAL_FAILURE(InitFramework());
4867
4868 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004869 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg6e4f9da2022-04-25 01:05:22 +02004870 }
4871
sjfricked700bc02022-05-30 16:35:06 +09004872 if (!AreRequiredExtensionsEnabled()) {
4873 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6e4f9da2022-04-25 01:05:22 +02004874 }
4875
4876 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
4877 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4878 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4879
4880 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004881 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6e4f9da2022-04-25 01:05:22 +02004882 }
4883
4884 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4885 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4886
4887 CreatePipelineHelper pipe(*this);
4888 pipe.InitInfo();
4889 pipe.InitState();
4890 pipe.CreateGraphicsPipeline();
4891
4892 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4893 begin_rendering_info.layerCount = 1;
4894
4895 m_commandBuffer->begin();
4896 m_commandBuffer->BeginRendering(begin_rendering_info);
4897
4898 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_);
4899 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-renderPass-06198");
4900 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
4901 m_errorMonitor->VerifyFound();
4902
4903 m_commandBuffer->EndRendering();
4904 m_commandBuffer->end();
ziga-lunarg67551632022-04-25 15:20:20 +02004905}
4906
4907TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRateAttachmentSize) {
4908 TEST_DESCRIPTION("Test FragmentShadingRateAttachment size.");
4909
4910 SetTargetApiVersion(VK_API_VERSION_1_0);
4911 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4912 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
4913
4914 ASSERT_NO_FATAL_FAILURE(InitFramework());
4915
4916 if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
sjfricke50955f32022-06-05 10:12:52 +09004917 GTEST_SKIP() << "Tests for 1.0 only";
ziga-lunarg67551632022-04-25 15:20:20 +02004918 }
4919
sjfricked700bc02022-05-30 16:35:06 +09004920 if (!AreRequiredExtensionsEnabled()) {
4921 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg67551632022-04-25 15:20:20 +02004922 }
4923
4924 auto vkGetPhysicalDeviceFeatures2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2KHR>(
4925 vk::GetInstanceProcAddr(instance(), "vkGetPhysicalDeviceFeatures2KHR"));
4926 ASSERT_TRUE(vkGetPhysicalDeviceFeatures2KHR != nullptr);
4927
4928 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
4929 auto features11 = LvlInitStruct<VkPhysicalDeviceVulkan11Features>(&dynamic_rendering_features);
4930 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2KHR>(&features11);
4931 vkGetPhysicalDeviceFeatures2KHR(gpu(), &features2);
4932
4933 if (features11.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004934 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg67551632022-04-25 15:20:20 +02004935 }
4936 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004937 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg67551632022-04-25 15:20:20 +02004938 }
4939
4940 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
4941
4942 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
4943 vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2);
4944
4945 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
4946
4947 VkImageObj image(m_device);
4948 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
4949 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR,
4950 VK_IMAGE_TILING_LINEAR, 0);
4951 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
4952
4953 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
4954 fragment_shading_rate.imageView = image_view;
4955 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
4956 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
4957
4958 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
4959 begin_rendering_info.layerCount = 1;
4960 begin_rendering_info.renderArea.offset.x = fragment_shading_rate.shadingRateAttachmentTexelSize.width * 64;
4961
4962 m_commandBuffer->begin();
4963
4964 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06117");
4965 m_commandBuffer->BeginRendering(begin_rendering_info);
4966 m_errorMonitor->VerifyFound();
4967
4968 begin_rendering_info.renderArea.offset.x = 0;
4969 begin_rendering_info.renderArea.offset.y = fragment_shading_rate.shadingRateAttachmentTexelSize.height * 64;
4970
4971 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06118");
4972 m_commandBuffer->BeginRendering(begin_rendering_info);
4973 m_errorMonitor->VerifyFound();
4974}
4975
4976TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRateAttachmentSizeWithDeviceGroupExt) {
4977 TEST_DESCRIPTION("Test FragmentShadingRateAttachment size with device group extension.");
4978
4979 SetTargetApiVersion(VK_API_VERSION_1_1);
4980 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4981 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
4982
4983 ASSERT_NO_FATAL_FAILURE(InitFramework());
4984
4985 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004986 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg67551632022-04-25 15:20:20 +02004987 }
4988
sjfricked700bc02022-05-30 16:35:06 +09004989 if (!AreRequiredExtensionsEnabled()) {
4990 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg67551632022-04-25 15:20:20 +02004991 }
4992
4993 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
4994 auto features11 = LvlInitStruct<VkPhysicalDeviceVulkan11Features>(&dynamic_rendering_features);
4995 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&features11);
4996 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4997
4998 if (features11.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004999 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg67551632022-04-25 15:20:20 +02005000 }
5001 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09005002 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg67551632022-04-25 15:20:20 +02005003 }
5004
5005 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
5006
5007 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
5008 vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2);
5009
5010 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
5011
5012 VkImageObj image(m_device);
5013 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
5014 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR,
5015 VK_IMAGE_TILING_LINEAR, 0);
5016 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
5017
5018 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
5019 fragment_shading_rate.imageView = image_view;
5020 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
5021 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
5022
5023 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
5024 begin_rendering_info.layerCount = 1;
5025 begin_rendering_info.renderArea.offset.x = fragment_shading_rate.shadingRateAttachmentTexelSize.width * 64;
5026
5027 m_commandBuffer->begin();
5028
5029 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06119");
5030 m_commandBuffer->BeginRendering(begin_rendering_info);
5031 m_errorMonitor->VerifyFound();
5032
5033 begin_rendering_info.renderArea.offset.x = 0;
5034 begin_rendering_info.renderArea.offset.y = fragment_shading_rate.shadingRateAttachmentTexelSize.height * 64;
5035
ziga-lunarg8f9de2a2022-04-25 15:59:19 +02005036 VkRect2D render_area = {};
5037 render_area.offset.x = 0;
5038 render_area.offset.y = 0;
5039 render_area.extent.width = 64 * fragment_shading_rate.shadingRateAttachmentTexelSize.width;
5040 render_area.extent.height = 32;
5041
5042 auto device_group_render_pass_begin_info = LvlInitStruct<VkDeviceGroupRenderPassBeginInfo>();
5043 device_group_render_pass_begin_info.deviceRenderAreaCount = 1;
5044 device_group_render_pass_begin_info.pDeviceRenderAreas = &render_area;
5045 fragment_shading_rate.pNext = &device_group_render_pass_begin_info;
5046
ziga-lunarg7f25dff2022-05-06 17:49:34 +02005047 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06120");
ziga-lunarg8f9de2a2022-04-25 15:59:19 +02005048 m_commandBuffer->BeginRendering(begin_rendering_info);
5049 m_errorMonitor->VerifyFound();
5050
5051 render_area.extent.width = 32;
5052 render_area.extent.height = 64 * fragment_shading_rate.shadingRateAttachmentTexelSize.height;
5053
5054 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06122");
ziga-lunarg67551632022-04-25 15:20:20 +02005055 m_commandBuffer->BeginRendering(begin_rendering_info);
5056 m_errorMonitor->VerifyFound();
5057}
ziga-lunarge966a9a2022-04-25 22:42:08 +02005058
5059TEST_F(VkLayerTest, TestSuspendingRenderPassInstance) {
5060 TEST_DESCRIPTION("Test suspending render pass instance.");
5061
5062 SetTargetApiVersion(VK_API_VERSION_1_1);
5063 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
5064
5065 ASSERT_NO_FATAL_FAILURE(InitFramework());
5066
5067 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09005068 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005069 }
5070
sjfricked700bc02022-05-30 16:35:06 +09005071 if (!AreRequiredExtensionsEnabled()) {
5072 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005073 }
5074
5075 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
5076 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
5077 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
5078
5079 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09005080 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005081 }
5082
5083 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
5084
5085 m_errorMonitor->ExpectSuccess();
5086
5087 VkCommandPoolObj command_pool(m_device, m_device->graphics_queue_node_index_);
5088 VkCommandBufferObj cmd_buffer1(m_device, &command_pool);
5089 VkCommandBufferObj cmd_buffer2(m_device, &command_pool);
5090 VkCommandBufferObj cmd_buffer3(m_device, &command_pool);
5091
5092 VkRenderingInfo suspend_rendering_info = LvlInitStruct<VkRenderingInfo>();
5093 suspend_rendering_info.flags = VK_RENDERING_SUSPENDING_BIT;
5094 suspend_rendering_info.layerCount = 1;
5095
5096 VkRenderingInfo resume_rendering_info = LvlInitStruct<VkRenderingInfo>();
5097 resume_rendering_info.flags = VK_RENDERING_RESUMING_BIT;
5098 resume_rendering_info.layerCount = 1;
5099
5100 VkRenderingInfo rendering_info = LvlInitStruct<VkRenderingInfo>();
5101 rendering_info.layerCount = 1;
5102
5103 auto cmd_begin = LvlInitStruct<VkCommandBufferBeginInfo>();
5104
5105 cmd_buffer1.begin(&cmd_begin);
5106 cmd_buffer1.BeginRendering(suspend_rendering_info);
5107 cmd_buffer1.EndRendering();
5108 cmd_buffer1.end();
5109
5110 cmd_buffer2.begin(&cmd_begin);
5111 cmd_buffer2.BeginRendering(resume_rendering_info);
5112 cmd_buffer2.EndRendering();
5113 cmd_buffer2.end();
5114
5115 cmd_buffer3.begin(&cmd_begin);
5116 cmd_buffer3.BeginRendering(rendering_info);
5117 cmd_buffer3.EndRendering();
5118 cmd_buffer3.end();
5119
5120 VkCommandBuffer command_buffers[3] = {cmd_buffer1.handle(), cmd_buffer2.handle()};
5121
5122 VkSubmitInfo submit_info = LvlInitStruct<VkSubmitInfo>();
5123 submit_info.commandBufferCount = 2;
5124 submit_info.pCommandBuffers = command_buffers;
5125 vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5126 vk::QueueWaitIdle(m_device->m_queue);
5127
5128 m_errorMonitor->VerifyNotFound();
5129
5130 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo-pCommandBuffers-06014");
5131
5132 submit_info.commandBufferCount = 1;
5133 vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5134 vk::QueueWaitIdle(m_device->m_queue);
5135
5136 m_errorMonitor->VerifyFound();
5137
5138 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo-pCommandBuffers-06016");
5139
5140 command_buffers[1] = cmd_buffer3.handle();
5141 command_buffers[2] = cmd_buffer2.handle();
5142 submit_info.commandBufferCount = 3;
5143 vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5144 vk::QueueWaitIdle(m_device->m_queue);
5145
5146 m_errorMonitor->VerifyFound();
5147
5148 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo-pCommandBuffers-06193");
5149
5150 command_buffers[0] = cmd_buffer2.handle();
5151 submit_info.commandBufferCount = 1;
5152 vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5153 vk::QueueWaitIdle(m_device->m_queue);
5154
5155 m_errorMonitor->VerifyFound();
5156}
5157
5158TEST_F(VkLayerTest, TestSuspendingRenderPassInstanceQueueSubmit2) {
5159 TEST_DESCRIPTION("Test suspending render pass instance with QueueSubmit2.");
5160
5161 SetTargetApiVersion(VK_API_VERSION_1_1);
5162 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
5163 AddRequiredExtensions(VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME);
5164
5165 ASSERT_NO_FATAL_FAILURE(InitFramework());
5166
5167 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09005168 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005169 }
5170
sjfricked700bc02022-05-30 16:35:06 +09005171 if (!AreRequiredExtensionsEnabled()) {
5172 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005173 }
5174
5175 auto synchronization2 = LvlInitStruct<VkPhysicalDeviceSynchronization2Features>();
5176 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&synchronization2);
5177 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
5178 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
5179
5180 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09005181 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005182 }
5183 if (synchronization2.synchronization2 == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09005184 GTEST_SKIP() << "Test requires (unsupported) synchronization2";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005185 }
5186
5187 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
5188
5189 auto vkQueueSubmit2KHR =
5190 reinterpret_cast<PFN_vkQueueSubmit2KHR>(vk::GetDeviceProcAddr(m_device->device(), "vkQueueSubmit2KHR"));
5191 ASSERT_TRUE(vkQueueSubmit2KHR != nullptr);
5192
5193 m_errorMonitor->ExpectSuccess();
5194
5195 VkCommandPoolObj command_pool(m_device, m_device->graphics_queue_node_index_);
5196 VkCommandBufferObj cmd_buffer1(m_device, &command_pool);
5197 VkCommandBufferObj cmd_buffer2(m_device, &command_pool);
5198 VkCommandBufferObj cmd_buffer3(m_device, &command_pool);
5199
5200 VkRenderingInfo suspend_rendering_info = LvlInitStruct<VkRenderingInfo>();
5201 suspend_rendering_info.flags = VK_RENDERING_SUSPENDING_BIT;
5202 suspend_rendering_info.layerCount = 1;
5203
5204 VkRenderingInfo resume_rendering_info = LvlInitStruct<VkRenderingInfo>();
5205 resume_rendering_info.flags = VK_RENDERING_RESUMING_BIT;
5206 resume_rendering_info.layerCount = 1;
5207
5208 VkRenderingInfo rendering_info = LvlInitStruct<VkRenderingInfo>();
5209 rendering_info.layerCount = 1;
5210
5211 auto cmd_begin = LvlInitStruct<VkCommandBufferBeginInfo>();
5212
5213 cmd_buffer1.begin(&cmd_begin);
5214 cmd_buffer1.BeginRendering(suspend_rendering_info);
5215 cmd_buffer1.EndRendering();
5216 cmd_buffer1.end();
5217
5218 cmd_buffer2.begin(&cmd_begin);
5219 cmd_buffer2.BeginRendering(resume_rendering_info);
5220 cmd_buffer2.EndRendering();
5221 cmd_buffer2.end();
5222
5223 cmd_buffer3.begin(&cmd_begin);
5224 cmd_buffer3.BeginRendering(rendering_info);
5225 cmd_buffer3.EndRendering();
5226 cmd_buffer3.end();
5227
5228 VkCommandBufferSubmitInfo command_buffer_submit_info[3];
5229 command_buffer_submit_info[0] = LvlInitStruct<VkCommandBufferSubmitInfo>();
5230 command_buffer_submit_info[1] = LvlInitStruct<VkCommandBufferSubmitInfo>();
5231 command_buffer_submit_info[2] = LvlInitStruct<VkCommandBufferSubmitInfo>();
5232
5233 command_buffer_submit_info[0].commandBuffer = cmd_buffer1.handle();
5234 command_buffer_submit_info[1].commandBuffer = cmd_buffer2.handle();
5235
5236 VkSubmitInfo2KHR submit_info = LvlInitStruct<VkSubmitInfo2KHR>();
5237 submit_info.commandBufferInfoCount = 2;
5238 submit_info.pCommandBufferInfos = command_buffer_submit_info;
5239 vkQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5240 vk::QueueWaitIdle(m_device->m_queue);
5241
5242 m_errorMonitor->VerifyNotFound();
5243
5244 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo2KHR-commandBuffer-06010");
5245
5246 submit_info.commandBufferInfoCount = 1;
5247 vkQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5248 vk::QueueWaitIdle(m_device->m_queue);
5249
5250 m_errorMonitor->VerifyFound();
5251
5252 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo2KHR-commandBuffer-06012");
5253
5254 command_buffer_submit_info[1].commandBuffer = cmd_buffer3.handle();
5255 command_buffer_submit_info[2].commandBuffer = cmd_buffer2.handle();
5256 submit_info.commandBufferInfoCount = 3;
5257 vkQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5258 vk::QueueWaitIdle(m_device->m_queue);
5259
5260 m_errorMonitor->VerifyFound();
5261
5262 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo2KHR-commandBuffer-06192");
5263
5264 command_buffer_submit_info[0].commandBuffer = cmd_buffer2.handle();
5265 submit_info.commandBufferInfoCount = 1;
5266 vkQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5267 vk::QueueWaitIdle(m_device->m_queue);
5268
5269 m_errorMonitor->VerifyFound();
5270}