blob: 6077ef17ec0c696e888172c05bfd8004098fdc8b [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
Nathaniel Cesarioa06135e2022-03-02 21:22:30 -070032 if (!AreRequestedExtensionsEnabled()) {
sjfrickec935ec72022-05-19 15:26:10 +090033 GTEST_SKIP() << RequestedExtensionsNotSupported() << " 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) {
44 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
Aaron Haganaca50442021-12-07 22:26:29 -050045 return;
46 }
47
ziga-lunargf54cb2a2022-03-11 02:54:27 +010048 features2.features.variableMultisampleRate = VK_FALSE;
49
Nathaniel Cesarioa06135e2022-03-02 21:22:30 -070050 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
51
Aaron Haganaca50442021-12-07 22:26:29 -050052 VkPhysicalDeviceMultiviewProperties multiview_props = LvlInitStruct<VkPhysicalDeviceMultiviewProperties>();
53 VkPhysicalDeviceProperties2 pd_props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&multiview_props);
54 vk::GetPhysicalDeviceProperties2(gpu(), &pd_props2);
55
56 if (multiview_props.maxMultiviewViewCount == 32) {
57 printf("%s VUID is not testable as maxMultiviewViewCount is 32, skipping test\n", kSkipPrefix);
58 return;
59 }
60
61 VkFormat color_format = VK_FORMAT_D32_SFLOAT;
62
63 auto cmd_buffer_inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>();
64 cmd_buffer_inheritance_rendering_info.colorAttachmentCount = 1;
65 cmd_buffer_inheritance_rendering_info.pColorAttachmentFormats = &color_format;
66 cmd_buffer_inheritance_rendering_info.depthAttachmentFormat = VK_FORMAT_R8G8B8_UNORM;
67 cmd_buffer_inheritance_rendering_info.stencilAttachmentFormat = VK_FORMAT_R8G8B8_SNORM;
68 cmd_buffer_inheritance_rendering_info.viewMask = 1 << multiview_props.maxMultiviewViewCount;
69
70 auto sample_count_info_amd = LvlInitStruct<VkAttachmentSampleCountInfoAMD>();
71 sample_count_info_amd.pNext = &cmd_buffer_inheritance_rendering_info;
72 sample_count_info_amd.colorAttachmentCount = 2;
sfricke-samsungae54c1e2022-01-21 05:35:21 -080073
Aaron Haganaca50442021-12-07 22:26:29 -050074 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
75 cmd_buffer_inheritance_info.pNext = &sample_count_info_amd;
76
77 auto cmd_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>();
78 cmd_buffer_allocate_info.commandPool = m_commandPool->handle();
79 cmd_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY;
80 cmd_buffer_allocate_info.commandBufferCount = 0x1;
81
82 VkCommandBuffer secondary_cmd_buffer;
83 VkResult err = vk::AllocateCommandBuffers(m_device->device(), &cmd_buffer_allocate_info, &secondary_cmd_buffer);
84 ASSERT_VK_SUCCESS(err);
85 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06003");
Tony-LunarGbbd2ab92021-12-02 08:31:24 -070086 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-colorAttachmentCount-06004");
87 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-variableMultisampleRate-06005");
88 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-depthAttachmentFormat-06007");
89 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-multiview-06008");
90 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-viewMask-06009");
ziga-lunarg813fa012022-04-09 14:09:57 +020091 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-stencilAttachmentFormat-06199");
92 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-depthAttachmentFormat-06200");
93 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-pColorAttachmentFormats-06006");
94 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-depthAttachmentFormat-06540");
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
120 if (!AreRequestedExtensionsEnabled()) {
sjfrickec935ec72022-05-19 15:26:10 +0900121 GTEST_SKIP() << RequestedExtensionsNotSupported() << " 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
223 if (!AreRequestedExtensionsEnabled()) {
sjfrickec935ec72022-05-19 15:26:10 +0900224 GTEST_SKIP() << RequestedExtensionsNotSupported() << " 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
330 if (!AreRequestedExtensionsEnabled()) {
sjfrickec935ec72022-05-19 15:26:10 +0900331 GTEST_SKIP() << RequestedExtensionsNotSupported() << " 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
420 if (!AreRequestedExtensionsEnabled()) {
sjfrickec935ec72022-05-19 15:26:10 +0900421 GTEST_SKIP() << RequestedExtensionsNotSupported() << " 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
610 if (!AreRequestedExtensionsEnabled()) {
sjfrickec935ec72022-05-19 15:26:10 +0900611 GTEST_SKIP() << RequestedExtensionsNotSupported() << " 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
767TEST_F(VkLayerTest, DynamicRenderingWithMistmatchingMixedAttachmentSamples) {
768 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
776 if (!AreRequestedExtensionsEnabled()) {
sjfrickec935ec72022-05-19 15:26:10 +0900777 GTEST_SKIP() << RequestedExtensionsNotSupported() << " 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
832 VkSampleCountFlagBits counts = {VK_SAMPLE_COUNT_2_BIT};
833 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;
849 samples_info.pColorAttachmentSamples = &counts;
850
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;
879 samples_info.depthStencilAttachmentSamples = counts;
880
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
976 if (!AreRequestedExtensionsEnabled()) {
sjfrickec935ec72022-05-19 15:26:10 +0900977 GTEST_SKIP() << RequestedExtensionsNotSupported() << " 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;
1022 image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
1023 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;
1055 begin_rendering_info.pNext = &fragment_density_map;
1056
1057 m_commandBuffer->begin();
1058 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-multiview-06127");
Jeremy Gebben09c1a072022-02-08 09:42:47 -07001059 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06107");
1060 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06108");
1061 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06116");
Jeremy Gebben09c1a072022-02-08 09:42:47 -07001062 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06145");
1063 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06146");
Aaron Hagan80034ea2021-12-23 11:24:09 -05001064 m_commandBuffer->BeginRendering(begin_rendering_info);
1065 m_errorMonitor->VerifyFound();
1066}
Aaron Haganb54466d2022-02-18 15:02:54 -05001067
1068TEST_F(VkLayerTest, DynamicRenderingBufferBeginInfoLegacy) {
1069 TEST_DESCRIPTION("VkCommandBufferBeginInfo Dynamic Rendering Tests.");
1070
1071 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2);
1072 if (version < VK_API_VERSION_1_2) {
1073 printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix);
1074 return;
1075 }
1076
1077 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1078
1079 ASSERT_NO_FATAL_FAILURE(Init(nullptr, nullptr, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1080
1081 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001082 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
Aaron Haganb54466d2022-02-18 15:02:54 -05001083 }
1084
1085 if (!AreRequestedExtensionsEnabled()) {
sjfrickec935ec72022-05-19 15:26:10 +09001086 GTEST_SKIP() << RequestedExtensionsNotSupported() << " not supported";
Aaron Haganb54466d2022-02-18 15:02:54 -05001087 }
1088
1089 auto cmd_buffer_inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>();
1090 cmd_buffer_inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
1091
1092 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
1093 cmd_buffer_inheritance_info.pNext = &cmd_buffer_inheritance_rendering_info;
1094 cmd_buffer_inheritance_info.renderPass = VK_NULL_HANDLE;
1095
1096 auto cmd_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>();
1097 cmd_buffer_allocate_info.commandPool = m_commandPool->handle();
1098 cmd_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY;
1099 cmd_buffer_allocate_info.commandBufferCount = 0x1;
1100
1101 VkCommandBuffer secondary_cmd_buffer;
1102 VkResult err = vk::AllocateCommandBuffers(m_device->device(), &cmd_buffer_allocate_info, &secondary_cmd_buffer);
1103 ASSERT_VK_SUCCESS(err);
1104
1105 // Invalid RenderPass
1106 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-00053");
1107 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
1108 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
1109 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
1110 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
1111 m_errorMonitor->VerifyFound();
1112
1113 // Valid RenderPass
1114 VkAttachmentDescription attach[] = {
1115 {0, VK_FORMAT_B8G8R8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE,
1116 VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_IMAGE_LAYOUT_UNDEFINED,
1117 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL},
1118 };
1119 VkAttachmentReference att_ref = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL};
1120
1121 VkSubpassDescription subpass = {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &att_ref, nullptr, nullptr, 0, nullptr};
1122 VkRenderPassCreateInfo rpci = {VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, 0, 1, attach, 1, &subpass, 0, nullptr};
1123
1124 vk_testing::RenderPass rp1;
1125 rp1.init(*m_device, rpci);
1126
1127 cmd_buffer_inheritance_info.renderPass = rp1.handle();
1128 cmd_buffer_inheritance_info.subpass = 0x5;
1129 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-00054");
1130 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
1131 m_errorMonitor->VerifyFound();
1132}
1133
1134TEST_F(VkLayerTest, DynamicRenderingSecondaryCommandBuffer) {
1135 TEST_DESCRIPTION("VkCommandBufferBeginInfo Dynamic Rendering Tests.");
1136
1137 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_3);
1138 if (version < VK_API_VERSION_1_3) {
1139 printf("%s At least Vulkan version 1.3 is required, skipping test.\n", kSkipPrefix);
1140 return;
1141 }
1142
1143 ASSERT_NO_FATAL_FAILURE(Init());
1144
1145 if (DeviceValidationVersion() < VK_API_VERSION_1_3) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001146 GTEST_SKIP() << "At least Vulkan version 1.3 is required";
Aaron Haganb54466d2022-02-18 15:02:54 -05001147 }
1148
1149 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
1150
1151 // Force the failure by not setting the Renderpass and Framebuffer fields
1152 VkCommandBufferInheritanceInfo cmd_buf_hinfo = LvlInitStruct<VkCommandBufferInheritanceInfo>();
1153 cmd_buf_hinfo.renderPass = VkRenderPass(0x1);
1154 VkCommandBufferBeginInfo cmd_buf_info = LvlInitStruct<VkCommandBufferBeginInfo>();
1155 cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
1156 cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo;
1157
1158 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06000");
1159 vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info);
1160 m_errorMonitor->VerifyFound();
1161
1162 // Valid RenderPass
1163 VkAttachmentDescription attach[] = {
1164 {0, VK_FORMAT_B8G8R8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE,
1165 VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_IMAGE_LAYOUT_UNDEFINED,
1166 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL},
1167 };
1168 VkAttachmentReference att_ref = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL};
1169
1170 VkSubpassDescription subpass = {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &att_ref, nullptr, nullptr, 0, nullptr};
1171 VkRenderPassCreateInfo rpci = {VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, 0, 1, attach, 1, &subpass, 0, nullptr};
1172
1173 vk_testing::RenderPass rp1;
1174 rp1.init(*m_device, rpci);
1175
1176 cmd_buf_hinfo.renderPass = rp1.handle();
1177 cmd_buf_hinfo.subpass = 0x5;
1178 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06001");
1179 vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info);
1180 m_errorMonitor->VerifyFound();
1181
1182 cmd_buf_hinfo.renderPass = VK_NULL_HANDLE;
1183 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06002");
1184 vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info);
1185 m_errorMonitor->VerifyFound();
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001186}
1187
ziga-lunarg1b46f192022-04-20 21:52:22 +02001188TEST_F(VkLayerTest, DynamicRenderingDepthFormatAndResolveMode) {
1189 TEST_DESCRIPTION("Test VkRenderingAttachmentInfo imageView with depth format.");
1190
1191 SetTargetApiVersion(VK_API_VERSION_1_1);
1192 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1193 ASSERT_NO_FATAL_FAILURE(InitFramework());
1194
1195 if (DeviceValidationVersion() != VK_API_VERSION_1_1) {
1196 printf("%s Vulkan version 1.1 is required for device, skipping test\n", kSkipPrefix);
1197 return;
1198 }
1199 if (!AreRequestedExtensionsEnabled()) {
1200 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1201 return;
1202 }
1203
1204 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1205 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1206 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1207 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
1208 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
1209 return;
1210 }
1211
1212 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1213
1214 auto depth_stencil_props = LvlInitStruct<VkPhysicalDeviceDepthStencilResolveProperties>();
1215 auto props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&depth_stencil_props);
1216 vk::GetPhysicalDeviceProperties2(gpu(), &props2);
1217
1218 if ((depth_stencil_props.supportedDepthResolveModes & VK_RESOLVE_MODE_AVERAGE_BIT) == 0) {
1219 printf("%s Required depth resolve mode not supported, skipping.\n", kSkipPrefix);
1220 return;
1221 }
1222
1223 VkFormat depth_format = FindSupportedDepthStencilFormat(gpu());
1224 if (depth_format == VK_FORMAT_UNDEFINED) {
1225 printf("%s No Depth + Stencil format found, skipping.\n", kSkipPrefix);
1226 return;
1227 }
1228
1229 VkImageObj image(m_device);
1230 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
1231 image_create_info.imageType = VK_IMAGE_TYPE_2D;
1232 image_create_info.format = depth_format;
1233 image_create_info.extent = {64, 64, 1};
1234 image_create_info.mipLevels = 1;
1235 image_create_info.arrayLayers = 1;
1236 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
1237 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
1238 image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
1239 image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
1240
1241 image.Init(image_create_info);
1242 ASSERT_TRUE(image.initialized());
1243
1244 VkImageViewCreateInfo ivci = {VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
1245 nullptr,
1246 0,
1247 image.handle(),
1248 VK_IMAGE_VIEW_TYPE_2D,
1249 depth_format,
1250 {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
1251 VK_COMPONENT_SWIZZLE_IDENTITY},
1252 {VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, 0, 1, 0, 1}};
1253
1254 vk_testing::ImageView depth_image_view;
1255 depth_image_view.init(*m_device, ivci);
1256
1257 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1258 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
1259 depth_attachment.imageView = depth_image_view.handle();
1260 depth_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
1261 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
1262
1263 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
1264 begin_rendering_info.layerCount = 1;
1265 begin_rendering_info.pDepthAttachment = &depth_attachment;
1266
1267 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06131");
1268
1269 m_commandBuffer->begin();
1270 m_commandBuffer->BeginRendering(begin_rendering_info);
1271 m_commandBuffer->end();
1272
1273 m_errorMonitor->VerifyFound();
1274}
1275
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001276TEST_F(VkLayerTest, TestDynamicRenderingPipelineMissingFlags) {
1277 TEST_DESCRIPTION("Test dynamic rendering with pipeline missing flags.");
1278
1279 SetTargetApiVersion(VK_API_VERSION_1_1);
1280 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1281 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1282 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
1283
1284 ASSERT_NO_FATAL_FAILURE(InitFramework());
1285
1286 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001287 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001288 }
1289
1290 if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
1291 printf("%s %s not supported, skipping test\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1292 return;
1293 }
1294 bool fragment_density = DeviceExtensionSupported(gpu(), nullptr, VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1295 bool shading_rate = DeviceExtensionSupported(gpu(), nullptr, VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
1296
1297 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1298 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1299 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1300 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
1301 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
1302 return;
1303 }
1304
1305 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
1306
1307 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
1308 vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2);
1309
1310 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1311 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
1312
1313 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
1314 ASSERT_TRUE(depthStencilFormat != 0);
1315
1316 VkImageObj image(m_device);
1317 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
1318 image_create_info.imageType = VK_IMAGE_TYPE_2D;
1319 image_create_info.format = depthStencilFormat;
1320 image_create_info.extent = {64, 64, 1};
1321 image_create_info.mipLevels = 1;
1322 image_create_info.arrayLayers = 1;
1323 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
1324 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001325 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 +01001326 image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
1327
1328 image.Init(image_create_info);
1329 ASSERT_TRUE(image.initialized());
1330
1331 VkImageViewCreateInfo ivci = {VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
1332 nullptr,
1333 0,
1334 image.handle(),
1335 VK_IMAGE_VIEW_TYPE_2D,
1336 depthStencilFormat,
1337 {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
1338 VK_COMPONENT_SWIZZLE_IDENTITY},
1339 {VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, 0, 1, 0, 1}};
1340
1341 vk_testing::ImageView depth_image_view;
1342 depth_image_view.init(*m_device, ivci);
1343
1344 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1345 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1346
1347 if (shading_rate) {
1348 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-imageView-06183");
1349 VkRenderingFragmentShadingRateAttachmentInfoKHR fragment_shading_rate =
1350 LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
1351 fragment_shading_rate.imageView = depth_image_view.handle();
1352 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1353 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
1354
1355 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
ziga-lunargaa97cbb2022-03-18 19:06:35 +01001356 begin_rendering_info.layerCount = 1;
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001357 begin_rendering_info.colorAttachmentCount = 1;
1358 begin_rendering_info.pColorAttachments = &color_attachment;
1359
1360 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
1361
1362 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
1363 pipeline_rendering_info.colorAttachmentCount = 1;
1364 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
1365
1366 CreatePipelineHelper pipe(*this);
1367 pipe.InitInfo();
1368 pipe.gp_ci_.pNext = &pipeline_rendering_info;
1369 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
1370 pipe.InitState();
1371 pipe.CreateGraphicsPipeline();
1372
1373 m_commandBuffer->begin();
1374 m_commandBuffer->BeginRendering(begin_rendering_info);
1375 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_);
1376 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
1377 m_commandBuffer->EndRendering();
1378 m_commandBuffer->end();
1379
1380 m_errorMonitor->VerifyFound();
1381 }
1382
1383 if (fragment_density) {
1384 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-imageView-06184");
1385 VkRenderingFragmentDensityMapAttachmentInfoEXT fragment_density_map =
1386 LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
1387 fragment_density_map.imageView = depth_image_view.handle();
1388
1389 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_density_map);
ziga-lunargaa97cbb2022-03-18 19:06:35 +01001390 begin_rendering_info.layerCount = 1;
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001391 begin_rendering_info.colorAttachmentCount = 1;
1392 begin_rendering_info.pColorAttachments = &color_attachment;
1393
1394 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
1395
1396 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
1397 pipeline_rendering_info.colorAttachmentCount = 1;
1398 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
1399
1400 CreatePipelineHelper pipe(*this);
1401 pipe.InitInfo();
1402 pipe.gp_ci_.pNext = &pipeline_rendering_info;
1403 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
1404 pipe.InitState();
1405 pipe.CreateGraphicsPipeline();
1406
1407 m_commandBuffer->begin();
1408 m_commandBuffer->BeginRendering(begin_rendering_info);
1409 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_);
1410 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
1411 m_commandBuffer->EndRendering();
1412 m_commandBuffer->end();
1413
1414 m_errorMonitor->VerifyFound();
1415 }
1416}
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001417
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001418TEST_F(VkLayerTest, DynamicRenderingLayerCount) {
1419 TEST_DESCRIPTION("Test dynamic rendering with viewMask 0 and invalid layer count.");
1420
1421 SetTargetApiVersion(VK_API_VERSION_1_1);
1422 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1423
1424 ASSERT_NO_FATAL_FAILURE(InitFramework());
1425
1426 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001427 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001428 }
1429
1430 if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
1431 printf("%s %s not supported, skipping test\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1432 return;
1433 }
1434
1435 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1436 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1437 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1438 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
1439 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
1440 return;
1441 }
1442
1443 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1444
1445 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
1446
1447 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-viewMask-06069");
1448 m_commandBuffer->begin();
1449 m_commandBuffer->BeginRendering(begin_rendering_info);
1450 m_commandBuffer->end();
1451 m_errorMonitor->VerifyFound();
1452}
1453
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001454TEST_F(VkLayerTest, TestRenderingInfoMismatchedSamples) {
1455 TEST_DESCRIPTION("Test beginning rendering with mismatched sample counts.");
1456
1457 SetTargetApiVersion(VK_API_VERSION_1_1);
1458 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1459
1460 ASSERT_NO_FATAL_FAILURE(InitFramework());
1461
1462 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001463 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001464 }
1465
1466 if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
1467 printf("%s %s not supported, skipping test\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1468 return;
1469 }
1470
1471 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1472 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1473 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1474 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
1475 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
1476 return;
1477 }
1478
1479 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1480
1481 VkImageCreateInfo image_ci = LvlInitStruct<VkImageCreateInfo>();
1482 image_ci.imageType = VK_IMAGE_TYPE_2D;
1483 image_ci.format = VK_FORMAT_R8G8B8A8_UNORM;
1484 image_ci.extent.width = 64;
1485 image_ci.extent.height = 64;
1486 image_ci.extent.depth = 1;
1487 image_ci.mipLevels = 1;
1488 image_ci.arrayLayers = 1;
1489 image_ci.samples = VK_SAMPLE_COUNT_2_BIT;
1490 image_ci.tiling = VK_IMAGE_TILING_OPTIMAL;
1491 image_ci.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
1492
1493 VkImageObj color_image(m_device);
1494 color_image.init(&image_ci);
1495
1496 VkImageViewCreateInfo civ_ci = LvlInitStruct<VkImageViewCreateInfo>();
1497 civ_ci.image = color_image.handle();
1498 civ_ci.viewType = VK_IMAGE_VIEW_TYPE_2D;
1499 civ_ci.format = VK_FORMAT_R8G8B8A8_UNORM;
1500 civ_ci.subresourceRange.layerCount = 1;
1501 civ_ci.subresourceRange.baseMipLevel = 0;
1502 civ_ci.subresourceRange.levelCount = 1;
1503 civ_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
1504
1505 vk_testing::ImageView color_image_view;
1506 color_image_view.init(*m_device, civ_ci);
1507
1508 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1509 color_attachment.imageView = color_image_view.handle();
1510 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1511 color_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
1512
1513 const VkFormat depth_format = FindSupportedDepthOnlyFormat(gpu());
1514 if (depth_format == VK_FORMAT_UNDEFINED) {
1515 printf("%s requires a depth only format, skipping.\n", kSkipPrefix);
1516 return;
1517 }
1518
1519 VkImageObj depth_image(m_device);
1520 depth_image.Init(64, 64, 1, depth_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL);
1521
1522 VkImageViewCreateInfo div_ci = LvlInitStruct<VkImageViewCreateInfo>();
1523 div_ci.image = depth_image.handle();
1524 div_ci.viewType = VK_IMAGE_VIEW_TYPE_2D;
1525 div_ci.format = depth_format;
1526 div_ci.subresourceRange.layerCount = 1;
1527 div_ci.subresourceRange.baseMipLevel = 0;
1528 div_ci.subresourceRange.levelCount = 1;
1529 div_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
1530
1531 vk_testing::ImageView depth_image_view;
1532 depth_image_view.init(*m_device, div_ci);
1533
1534 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1535 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1536 depth_attachment.imageView = depth_image_view.handle();
1537 depth_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
1538
1539 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
ziga-lunargaa97cbb2022-03-18 19:06:35 +01001540 begin_rendering_info.layerCount = 1;
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001541 begin_rendering_info.colorAttachmentCount = 1;
1542 begin_rendering_info.pColorAttachments = &color_attachment;
1543 begin_rendering_info.pDepthAttachment = &depth_attachment;
1544
1545 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06070");
1546 m_commandBuffer->BeginRendering(begin_rendering_info);
1547 m_errorMonitor->VerifyFound();
1548}
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001549
ziga-lunargb7fec142022-03-18 22:08:17 +01001550TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRate) {
1551 TEST_DESCRIPTION("Test BeginRenderingInfo with FragmentShadingRateAttachment.");
1552
1553 SetTargetApiVersion(VK_API_VERSION_1_1);
1554 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1555 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
1556
1557 ASSERT_NO_FATAL_FAILURE(InitFramework());
1558
1559 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001560 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargb7fec142022-03-18 22:08:17 +01001561 }
1562
1563 if (!AreRequestedExtensionsEnabled()) {
sjfrickec935ec72022-05-19 15:26:10 +09001564 GTEST_SKIP() << RequestedExtensionsNotSupported() << " not supported";
ziga-lunargb7fec142022-03-18 22:08:17 +01001565 }
1566
1567 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1568 auto features11 = LvlInitStruct<VkPhysicalDeviceVulkan11Features>(&dynamic_rendering_features);
1569 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&features11);
1570 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1571
1572 if (features11.multiview == VK_FALSE) {
1573 printf("%s Test requires (unsupported) multiview , skipping\n", kSkipPrefix);
1574 return;
1575 }
1576 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
1577 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
1578 return;
1579 }
1580
1581 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
1582
1583 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
1584 vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2);
1585
1586 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1587 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
1588
1589 auto image_ci = LvlInitStruct<VkImageCreateInfo>(nullptr);
1590 image_ci.imageType = VK_IMAGE_TYPE_2D;
1591 image_ci.format = VK_FORMAT_R8G8B8A8_UNORM;
1592 image_ci.extent.width = 32;
1593 image_ci.extent.height = 32;
1594 image_ci.extent.depth = 1;
1595 image_ci.mipLevels = 1;
1596 image_ci.arrayLayers = 2;
1597 image_ci.samples = VK_SAMPLE_COUNT_1_BIT;
1598 image_ci.tiling = VK_IMAGE_TILING_OPTIMAL;
ziga-lunargade1d9e2022-04-25 10:59:15 +02001599 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 +01001600
1601 VkImageObj image(m_device);
1602 image.init(&image_ci);
1603 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 2);
1604
ziga-lunargade1d9e2022-04-25 10:59:15 +02001605 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
ziga-lunargb7fec142022-03-18 22:08:17 +01001606 fragment_shading_rate.imageView = image_view;
1607 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1608 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
1609
1610 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
1611 begin_rendering_info.layerCount = 4;
1612
1613 m_commandBuffer->begin();
1614
1615 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06123");
1616 m_commandBuffer->BeginRendering(begin_rendering_info);
1617 m_errorMonitor->VerifyFound();
1618
1619 begin_rendering_info.viewMask = 0xF;
1620 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06124");
1621 m_commandBuffer->BeginRendering(begin_rendering_info);
1622 m_errorMonitor->VerifyFound();
1623
ziga-lunargade1d9e2022-04-25 10:59:15 +02001624 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1625 color_attachment.imageView = image_view;
1626 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1627
1628 begin_rendering_info.layerCount = 2;
1629 begin_rendering_info.colorAttachmentCount = 1;
1630 begin_rendering_info.pColorAttachments = &color_attachment;
1631 begin_rendering_info.viewMask = 0;
1632 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06125");
1633 m_commandBuffer->BeginRendering(begin_rendering_info);
1634 m_errorMonitor->VerifyFound();
1635
ziga-lunargb7fec142022-03-18 22:08:17 +01001636 m_commandBuffer->end();
ziga-lunargb7fec142022-03-18 22:08:17 +01001637}
1638
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001639TEST_F(VkLayerTest, TestDeviceGroupRenderPassBeginInfo) {
1640 TEST_DESCRIPTION("Test render area of DeviceGroupRenderPassBeginInfo.");
1641
1642 SetTargetApiVersion(VK_API_VERSION_1_1);
1643 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1644
1645 ASSERT_NO_FATAL_FAILURE(InitFramework());
1646
1647 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001648 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001649 }
1650
1651 if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
1652 printf("%s %s not supported, skipping test\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1653 return;
1654 }
1655
1656 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1657 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1658 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1659 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
1660 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
1661 return;
1662 }
1663
1664 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1665
1666 VkRect2D render_area = {};
1667 render_area.offset.x = 0;
1668 render_area.offset.y = 0;
1669 render_area.extent.width = 32;
1670 render_area.extent.height = 32;
1671
1672 auto device_group_render_pass_begin_info = LvlInitStruct<VkDeviceGroupRenderPassBeginInfo>();
1673 device_group_render_pass_begin_info.deviceRenderAreaCount = 1;
1674 device_group_render_pass_begin_info.pDeviceRenderAreas = &render_area;
1675
1676 VkImageObj colorImage(m_device);
1677 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
1678 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
1679
1680 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1681 color_attachment.imageView = colorImageView;
1682 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1683
1684 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&device_group_render_pass_begin_info);
ziga-lunarg1fec6332022-03-20 14:39:54 +01001685 begin_rendering_info.layerCount = 1;
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001686 begin_rendering_info.colorAttachmentCount = 1;
1687 begin_rendering_info.pColorAttachments = &color_attachment;
1688
1689 m_commandBuffer->begin();
1690
1691 m_errorMonitor->ExpectSuccess();
1692 m_commandBuffer->BeginRendering(begin_rendering_info);
1693 m_errorMonitor->VerifyNotFound();
1694
1695 render_area.offset.x = 1;
1696 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06083");
1697 m_commandBuffer->BeginRendering(begin_rendering_info);
1698 m_errorMonitor->VerifyFound();
1699
1700 render_area.offset.x = 0;
1701 render_area.offset.y = 16;
1702 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06084");
1703 m_commandBuffer->BeginRendering(begin_rendering_info);
1704 m_errorMonitor->VerifyFound();
1705
1706 m_commandBuffer->end();
1707}
1708
ziga-lunarg184a20b2022-03-18 20:54:48 +01001709TEST_F(VkLayerTest, TestBeginRenderingInvalidFragmentShadingRateImage) {
1710 TEST_DESCRIPTION("Test BeginRendering with FragmentShadingRateAttachmentInfo with missing image usage bit.");
1711
1712 SetTargetApiVersion(VK_API_VERSION_1_1);
1713 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1714 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
1715
1716 ASSERT_NO_FATAL_FAILURE(InitFramework());
1717
1718 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001719 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg184a20b2022-03-18 20:54:48 +01001720 }
1721
1722 if (!AreRequestedExtensionsEnabled()) {
sjfrickec935ec72022-05-19 15:26:10 +09001723 GTEST_SKIP() << RequestedExtensionsNotSupported() << " not supported";
ziga-lunarg184a20b2022-03-18 20:54:48 +01001724 }
1725
1726 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1727 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1728 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1729 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
1730 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
1731 return;
1732 }
1733 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1734
1735 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
1736 auto properties2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
1737 vk::GetPhysicalDeviceProperties2(gpu(), &properties2);
1738
1739 VkImageObj image(m_device);
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001740 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT,
1741 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR);
ziga-lunarg184a20b2022-03-18 20:54:48 +01001742 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
1743
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001744 VkImageObj invalid_image(m_device);
1745 invalid_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
1746 VkImageView invalid_image_view = invalid_image.targetView(VK_FORMAT_R8G8B8A8_UINT);
1747
ziga-lunarg184a20b2022-03-18 20:54:48 +01001748 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001749 fragment_shading_rate.imageView = invalid_image_view;
ziga-lunarg184a20b2022-03-18 20:54:48 +01001750 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1751 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
1752
1753 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001754 begin_rendering_info.layerCount = 1;
1755
1756 m_commandBuffer->begin();
ziga-lunarg184a20b2022-03-18 20:54:48 +01001757
1758 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06148");
ziga-lunarg184a20b2022-03-18 20:54:48 +01001759 m_commandBuffer->BeginRendering(begin_rendering_info);
ziga-lunarg184a20b2022-03-18 20:54:48 +01001760 m_errorMonitor->VerifyFound();
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001761 fragment_shading_rate.imageView = image_view;
1762
1763 fragment_shading_rate.shadingRateAttachmentTexelSize.width = fsr_properties.minFragmentShadingRateAttachmentTexelSize.width + 1;
1764 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06149");
1765 if (fragment_shading_rate.shadingRateAttachmentTexelSize.width >
1766 fsr_properties.minFragmentShadingRateAttachmentTexelSize.width) {
1767 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06150");
1768 }
1769 m_commandBuffer->BeginRendering(begin_rendering_info);
1770 m_errorMonitor->VerifyFound();
1771
1772 if (fsr_properties.minFragmentShadingRateAttachmentTexelSize.width > 1) {
1773 fragment_shading_rate.shadingRateAttachmentTexelSize.width =
1774 fsr_properties.minFragmentShadingRateAttachmentTexelSize.width / 2;
1775 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06151");
1776 if (fragment_shading_rate.shadingRateAttachmentTexelSize.height /
1777 fragment_shading_rate.shadingRateAttachmentTexelSize.width >=
1778 fsr_properties.maxFragmentShadingRateAttachmentTexelSizeAspectRatio) {
1779 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06156");
1780 }
1781 m_commandBuffer->BeginRendering(begin_rendering_info);
1782 m_errorMonitor->VerifyFound();
1783 }
1784
1785 fragment_shading_rate.shadingRateAttachmentTexelSize.width = fsr_properties.minFragmentShadingRateAttachmentTexelSize.width;
1786
1787 fragment_shading_rate.shadingRateAttachmentTexelSize.height =
1788 fsr_properties.minFragmentShadingRateAttachmentTexelSize.height + 1;
1789 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06152");
1790 if (fragment_shading_rate.shadingRateAttachmentTexelSize.height >
1791 fsr_properties.minFragmentShadingRateAttachmentTexelSize.height) {
1792 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06153");
1793 }
1794 m_commandBuffer->BeginRendering(begin_rendering_info);
1795 m_errorMonitor->VerifyFound();
1796
1797 if (fsr_properties.minFragmentShadingRateAttachmentTexelSize.height > 1) {
1798 fragment_shading_rate.shadingRateAttachmentTexelSize.height =
1799 fsr_properties.minFragmentShadingRateAttachmentTexelSize.height / 2;
1800 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06154");
1801 if (fragment_shading_rate.shadingRateAttachmentTexelSize.width /
1802 fragment_shading_rate.shadingRateAttachmentTexelSize.height >
1803 fsr_properties.maxFragmentShadingRateAttachmentTexelSizeAspectRatio) {
1804 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06155");
1805 }
1806 m_commandBuffer->BeginRendering(begin_rendering_info);
1807 m_errorMonitor->VerifyFound();
1808 }
1809
1810 m_commandBuffer->end();
ziga-lunarg184a20b2022-03-18 20:54:48 +01001811}
1812
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001813TEST_F(VkLayerTest, BeginRenderingInvalidDepthAttachmentFormat) {
1814 TEST_DESCRIPTION("Test begin rendering with a depth attachment that has an invalid format");
1815
1816 SetTargetApiVersion(VK_API_VERSION_1_3);
1817 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1818
1819 ASSERT_NO_FATAL_FAILURE(InitFramework());
1820
1821 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001822 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001823 }
1824
1825 if (!AreRequestedExtensionsEnabled()) {
sjfrickec935ec72022-05-19 15:26:10 +09001826 GTEST_SKIP() << RequestedExtensionsNotSupported() << " not supported";
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001827 }
1828
1829 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1830 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1831 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1832 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
1833 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
1834 return;
1835 }
1836
1837 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1838
1839 VkFormat stencil_format = FindSupportedStencilOnlyFormat(gpu());
1840 if (stencil_format == VK_FORMAT_UNDEFINED) {
1841 printf("%s requires a stencil only format format.\n", kSkipPrefix);
1842 return;
1843 }
1844
1845 VkImageObj image(m_device);
1846 image.Init(32, 32, 1, stencil_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
1847 VkImageView image_view = image.targetView(stencil_format, VK_IMAGE_ASPECT_STENCIL_BIT);
1848
1849 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1850 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
1851 depth_attachment.imageView = image_view;
1852
1853 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
ziga-lunarg1fec6332022-03-20 14:39:54 +01001854 begin_rendering_info.layerCount = 1;
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001855 begin_rendering_info.pDepthAttachment = &depth_attachment;
1856
1857 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06547");
1858 m_commandBuffer->BeginRendering(begin_rendering_info);
1859 m_errorMonitor->VerifyFound();
1860}
ziga-lunarg4b5bb5b2022-03-20 00:49:04 +01001861
ziga-lunarg14a69782022-03-20 00:39:31 +01001862TEST_F(VkLayerTest, TestFragmentDensityMapRenderArea) {
1863 TEST_DESCRIPTION("Validate VkRenderingFragmentDensityMapAttachmentInfo attachment image view extent.");
1864
1865 SetTargetApiVersion(VK_API_VERSION_1_1);
1866 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1867 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1868
1869 ASSERT_NO_FATAL_FAILURE(InitFramework());
1870
1871 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001872 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg14a69782022-03-20 00:39:31 +01001873 }
1874
1875 if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
1876 printf("%s %s not supported, skipping test\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1877 return;
1878 }
1879
1880 if (!DeviceExtensionSupported(gpu(), nullptr, VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME)) {
1881 printf("%s %s not supported, skipping test\n", kSkipPrefix, VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1882 return;
1883 }
1884
1885 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1886 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1887 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1888 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
1889 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
1890 return;
1891 }
1892
1893 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1894
1895 auto fdm_props = LvlInitStruct<VkPhysicalDeviceFragmentDensityMapPropertiesEXT>();
1896 auto props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fdm_props);
1897 vk::GetPhysicalDeviceProperties2(gpu(), &props2);
1898
1899 VkImageObj image(m_device);
1900 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
1901 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1);
1902
1903 auto fragment_density_map = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
1904 fragment_density_map.imageView = image_view;
1905 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_density_map);
1906 begin_rendering_info.layerCount = 1;
1907 begin_rendering_info.renderArea.extent.width = 64 * fdm_props.maxFragmentDensityTexelSize.width;
1908 begin_rendering_info.renderArea.extent.height = 32 * fdm_props.maxFragmentDensityTexelSize.height;
1909
1910 m_commandBuffer->begin();
1911
1912 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06112");
1913 m_commandBuffer->BeginRendering(begin_rendering_info);
1914 m_errorMonitor->VerifyFound();
1915
1916 begin_rendering_info.renderArea.extent.width = 32 * fdm_props.maxFragmentDensityTexelSize.width;
1917 begin_rendering_info.renderArea.extent.height = 64 * fdm_props.maxFragmentDensityTexelSize.height;
1918
1919 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06114");
1920 m_commandBuffer->BeginRendering(begin_rendering_info);
1921 m_errorMonitor->VerifyFound();
1922
1923 VkRect2D device_render_area = {};
1924 device_render_area.extent.width = 64 * fdm_props.maxFragmentDensityTexelSize.width;
1925 device_render_area.extent.height = 32 * fdm_props.maxFragmentDensityTexelSize.height;
1926 auto device_group_render_pass_begin_info = LvlInitStruct<VkDeviceGroupRenderPassBeginInfo>();
1927 device_group_render_pass_begin_info.deviceRenderAreaCount = 1;
1928 device_group_render_pass_begin_info.pDeviceRenderAreas = &device_render_area;
1929 fragment_density_map.pNext = &device_group_render_pass_begin_info;
1930
1931 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06113");
1932 m_commandBuffer->BeginRendering(begin_rendering_info);
1933 m_errorMonitor->VerifyFound();
1934
1935 device_render_area.extent.width = 32 * fdm_props.maxFragmentDensityTexelSize.width;
1936 device_render_area.extent.height = 64 * fdm_props.maxFragmentDensityTexelSize.height;
1937
1938 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06115");
1939 m_commandBuffer->BeginRendering(begin_rendering_info);
1940 m_errorMonitor->VerifyFound();
1941
1942 m_commandBuffer->end();
1943}
1944
ziga-lunarge7279ba2022-03-31 20:55:27 +02001945TEST_F(VkLayerTest, TestBarrierWithDynamicRendering) {
1946 TEST_DESCRIPTION("Test setting buffer memory barrier when dynamic rendering is active.");
1947
1948 SetTargetApiVersion(VK_API_VERSION_1_3);
1949
1950 ASSERT_NO_FATAL_FAILURE(InitFramework());
1951
1952 if (DeviceValidationVersion() < VK_API_VERSION_1_3) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001953 GTEST_SKIP() << "At least Vulkan version 1.3 is required";
ziga-lunarge7279ba2022-03-31 20:55:27 +02001954 }
1955
1956 auto vk13features = LvlInitStruct<VkPhysicalDeviceVulkan13Features>();
1957 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&vk13features);
1958 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1959 if (!vk13features.dynamicRendering) {
1960 printf("%s Test requires (unsupported) dynamicRendering, skipping\n", kSkipPrefix);
1961 return;
1962 }
1963 if (!vk13features.synchronization2) {
1964 printf("%s Test requires (unsupported) synchronization2, skipping\n", kSkipPrefix);
1965 return;
1966 }
1967
1968 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1969 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
1970
1971 PFN_vkCmdBeginRendering vkCmdBeginRendering =
1972 reinterpret_cast<PFN_vkCmdBeginRendering>(vk::GetDeviceProcAddr(m_device->device(), "vkCmdBeginRendering"));
1973 assert(vkCmdBeginRendering != nullptr);
1974 PFN_vkCmdEndRendering vkCmdEndRendering =
1975 reinterpret_cast<PFN_vkCmdEndRendering>(vk::GetDeviceProcAddr(m_device->device(), "vkCmdEndRendering"));
1976 assert(vkCmdEndRendering != nullptr);
1977
1978 m_commandBuffer->begin();
1979
1980 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
1981 VkClearRect clear_rect = {{{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}, 0, 1};
1982 begin_rendering_info.renderArea = clear_rect.rect;
1983 begin_rendering_info.layerCount = 1;
1984
1985 vkCmdBeginRendering(m_commandBuffer->handle(), &begin_rendering_info);
1986
1987 VkBufferObj buffer;
1988 VkMemoryPropertyFlags mem_reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
1989 buffer.init_as_src_and_dst(*m_device, 256, mem_reqs);
1990
1991 auto buf_barrier = lvl_init_struct<VkBufferMemoryBarrier2KHR>();
1992 buf_barrier.buffer = buffer.handle();
1993 buf_barrier.offset = 0;
1994 buf_barrier.size = VK_WHOLE_SIZE;
1995 buf_barrier.srcStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
1996 buf_barrier.dstStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
1997
1998 auto dependency_info = lvl_init_struct<VkDependencyInfoKHR>();
1999 dependency_info.bufferMemoryBarrierCount = 1;
2000 dependency_info.pBufferMemoryBarriers = &buf_barrier;
2001 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPipelineBarrier2-None-06191");
2002 vk::CmdPipelineBarrier2(m_commandBuffer->handle(), &dependency_info);
2003 m_errorMonitor->VerifyFound();
2004
2005 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPipelineBarrier-None-06191");
2006 vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, 0,
2007 nullptr, 0, nullptr, 0, nullptr);
2008 m_errorMonitor->VerifyFound();
2009
2010 vkCmdEndRendering(m_commandBuffer->handle());
2011 m_commandBuffer->end();
2012}
2013
ziga-lunargce90b522022-04-27 23:59:46 +02002014TEST_F(VkLayerTest, UseStencilAttachmentWithIntegerFormat) {
2015 TEST_DESCRIPTION("Use stencil attachment with integer format");
2016
2017 m_errorMonitor->ExpectSuccess();
2018
2019 SetTargetApiVersion(VK_API_VERSION_1_1);
2020 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2021 ASSERT_NO_FATAL_FAILURE(InitFramework());
2022
2023 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002024 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
2025 return;
ziga-lunargce90b522022-04-27 23:59:46 +02002026 }
2027 if (!AreRequestedExtensionsEnabled()) {
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002028 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2029 return;
ziga-lunargce90b522022-04-27 23:59:46 +02002030 }
2031
2032 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
2033 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2034 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2035 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
2036 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
2037 return;
2038 }
2039
2040 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2041 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2042
2043 if (ImageFormatIsSupported(gpu(), VK_FORMAT_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
2044 printf("%s VK_FORMAT_S8_UINT format not supported, skipping test.\n", kSkipPrefix);
2045 return;
2046 }
2047
2048 auto depth_stencil_resolve_properties = LvlInitStruct<VkPhysicalDeviceDepthStencilResolveProperties>();
2049 auto properties2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&depth_stencil_resolve_properties);
2050 vk::GetPhysicalDeviceProperties2(gpu(), &properties2);
2051 if (depth_stencil_resolve_properties.supportedStencilResolveModes & VK_RESOLVE_MODE_AVERAGE_BIT) {
2052 printf("%s VK_RESOLVE_MODE_AVERAGE_BIT not supported for VK_FORMAT_S8_UINT, skipping test.\n", kSkipPrefix);
2053 return;
2054 }
2055
2056 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
2057 image_create_info.imageType = VK_IMAGE_TYPE_2D;
2058 image_create_info.format = VK_FORMAT_S8_UINT;
2059 image_create_info.extent = {32, 32, 1};
2060 image_create_info.mipLevels = 1;
2061 image_create_info.arrayLayers = 1;
2062 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
2063 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
2064 image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
2065 VkImageObj image(m_device);
2066 image.Init(image_create_info);
2067 VkImageView image_view = image.targetView(VK_FORMAT_S8_UINT, VK_IMAGE_ASPECT_STENCIL_BIT);
2068
2069 VkRenderingAttachmentInfoKHR stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2070 stencil_attachment.imageView = image_view;
2071 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
2072 stencil_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
2073 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
2074
2075 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2076 begin_rendering_info.pStencilAttachment = &stencil_attachment;
2077 begin_rendering_info.layerCount = 1;
2078
2079 m_commandBuffer->begin();
2080
2081 m_errorMonitor->VerifyNotFound();
2082
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002083 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06131");
ziga-lunargce90b522022-04-27 23:59:46 +02002084 m_commandBuffer->BeginRendering(begin_rendering_info);
2085 m_errorMonitor->VerifyFound();
2086
2087 m_commandBuffer->end();
2088}
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002089
2090TEST_F(VkLayerTest, BeginRenderingInvalidStencilAttachmentFormat) {
2091 TEST_DESCRIPTION("Test begin rendering with a stencil attachment that has an invalid format");
2092
2093 SetTargetApiVersion(VK_API_VERSION_1_3);
2094 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2095
2096 ASSERT_NO_FATAL_FAILURE(InitFramework());
2097
2098 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
2099 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
2100 }
2101
2102 if (!AreRequestedExtensionsEnabled()) {
2103 GTEST_SKIP() << RequestedExtensionsNotSupported() << " not supported";
2104 }
2105
2106 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2107 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2108 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2109 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
2110 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
2111 return;
2112 }
2113
2114 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2115
2116 VkFormat depth_format = FindSupportedDepthOnlyFormat(gpu());
2117 if (depth_format == VK_FORMAT_UNDEFINED) {
2118 printf("%s requires a stencil only format format.\n", kSkipPrefix);
2119 return;
2120 }
2121
2122 VkImageObj image(m_device);
2123 image.Init(32, 32, 1, depth_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
2124 VkImageView image_view = image.targetView(depth_format, VK_IMAGE_ASPECT_DEPTH_BIT);
2125
2126 VkRenderingAttachmentInfoKHR stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2127 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL;
2128 stencil_attachment.imageView = image_view;
2129
2130 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2131 begin_rendering_info.layerCount = 1;
2132 begin_rendering_info.pStencilAttachment = &stencil_attachment;
2133
2134 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06548");
2135 m_commandBuffer->BeginRendering(begin_rendering_info);
2136 m_errorMonitor->VerifyFound();
2137}
2138
2139TEST_F(VkLayerTest, TestInheritanceRenderingInfoStencilAttachmentFormat) {
2140 TEST_DESCRIPTION("Test begin rendering with a stencil attachment that has an invalid format");
2141
2142 SetTargetApiVersion(VK_API_VERSION_1_3);
2143 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2144
2145 ASSERT_NO_FATAL_FAILURE(InitFramework());
2146
2147 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
2148 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
2149 }
2150
2151 if (!AreRequestedExtensionsEnabled()) {
2152 GTEST_SKIP() << RequestedExtensionsNotSupported() << " not supported";
2153 }
2154
2155 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2156 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2157 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2158 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
2159 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
2160 return;
2161 }
2162
2163 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2164
2165 VkFormat depth_format = FindSupportedDepthOnlyFormat(gpu());
2166 if (depth_format == VK_FORMAT_UNDEFINED) {
2167 printf("%s requires a stencil only format format.\n", kSkipPrefix);
2168 return;
2169 }
2170
2171 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2172
2173 auto cmd_buffer_inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>();
2174 cmd_buffer_inheritance_rendering_info.colorAttachmentCount = 1;
2175 cmd_buffer_inheritance_rendering_info.pColorAttachmentFormats = &color_format;
2176 cmd_buffer_inheritance_rendering_info.depthAttachmentFormat = depth_format;
2177 cmd_buffer_inheritance_rendering_info.stencilAttachmentFormat = depth_format;
2178 cmd_buffer_inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
2179
2180 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2181 cmd_buffer_inheritance_info.pNext = &cmd_buffer_inheritance_rendering_info;
2182 cmd_buffer_inheritance_info.renderPass = VK_NULL_HANDLE;
2183
2184 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2185 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2186 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2187
2188 auto cmd_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>();
2189 cmd_buffer_allocate_info.commandPool = m_commandPool->handle();
2190 cmd_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY;
2191 cmd_buffer_allocate_info.commandBufferCount = 1;
2192
2193 VkCommandBuffer secondary_cmd_buffer;
2194 VkResult err = vk::AllocateCommandBuffers(m_device->device(), &cmd_buffer_allocate_info, &secondary_cmd_buffer);
2195
2196 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-stencilAttachmentFormat-06541");
2197 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
2198 m_errorMonitor->VerifyFound();
2199}
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002200
2201TEST_F(VkLayerTest, CreateGraphicsPipelineWithInvalidAttachmentSampleCount) {
2202 TEST_DESCRIPTION("Create pipeline with fragment shader that uses samples, but multisample state not begin set");
2203
2204 SetTargetApiVersion(VK_API_VERSION_1_3);
2205 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2206 AddRequiredExtensions(VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME);
2207
2208 ASSERT_NO_FATAL_FAILURE(InitFramework());
2209
2210 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
2211 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
2212 return;
2213 }
2214
2215 if (!AreRequestedExtensionsEnabled()) {
2216 printf("%s Extension %s or %s not supported, skipping tests\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME,
2217 VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME);
2218 return;
2219 }
2220
2221 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2222 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2223 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2224 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
2225 printf("%s Test requires (unsupported) dynamicRendering, skipping\n", kSkipPrefix);
2226 return;
2227 }
2228
2229 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2230 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2231
2232 auto sample_count_info_amd = LvlInitStruct<VkAttachmentSampleCountInfoNV>();
2233 sample_count_info_amd.colorAttachmentCount = 1;
2234 sample_count_info_amd.depthStencilAttachmentSamples = static_cast<VkSampleCountFlagBits>(0x00000400);
2235
2236 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(&sample_count_info_amd);
2237 pipeline_rendering_info.colorAttachmentCount = 1;
2238 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2239
2240 CreatePipelineHelper pipe(*this);
2241 pipe.InitInfo();
2242 pipe.gp_ci_.pNext = &pipeline_rendering_info;
2243 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2244 pipe.InitState();
2245
2246 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-depthStencilAttachmentSamples-06593");
2247 pipe.CreateGraphicsPipeline();
2248 m_errorMonitor->VerifyFound();
2249}
ziga-lunargd680bf22022-04-20 22:01:00 +02002250
2251TEST_F(VkLayerTest, CreatePipelineUsingDynamicRenderingWithoutFeature) {
2252 TEST_DESCRIPTION("Create graphcis pipeline that uses dynamic rendering, but feature is not enabled");
2253
2254 SetTargetApiVersion(VK_API_VERSION_1_3);
2255 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2256 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
2257
2258 ASSERT_NO_FATAL_FAILURE(InitFramework());
2259
2260 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
2261 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
2262 return;
2263 }
2264
2265 if (!AreRequestedExtensionsEnabled()) {
2266 printf("%s Extension %s or %s not supported, skipping tests\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME,
2267 VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
2268 return;
2269 }
2270
2271 ASSERT_NO_FATAL_FAILURE(InitState());
2272
2273 CreatePipelineHelper pipe(*this);
2274 pipe.InitInfo();
2275 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2276 pipe.InitState();
2277
2278 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-dynamicRendering-06576");
2279 pipe.CreateGraphicsPipeline();
2280 m_errorMonitor->VerifyFound();
2281}
ziga-lunargf20d7952022-04-20 22:11:40 +02002282
2283TEST_F(VkLayerTest, CreateGraphicsPipelineWithMissingMultisampleState) {
2284 TEST_DESCRIPTION("Create pipeline with fragment shader that uses samples, but multisample state not begin set");
2285
2286 SetTargetApiVersion(VK_API_VERSION_1_1);
2287 ASSERT_NO_FATAL_FAILURE(InitFramework());
2288
2289 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
2290 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
2291 return;
2292 }
2293
2294 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2295 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2296 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2297 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
2298 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
2299 return;
2300 }
2301
2302 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2303
2304 CreatePipelineHelper pipe(*this);
2305 pipe.InitInfo();
2306 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2307 pipe.gp_ci_.pMultisampleState = nullptr;
2308 pipe.InitState();
2309
2310 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-pMultisampleState-06630");
2311 pipe.CreateGraphicsPipeline();
2312 m_errorMonitor->VerifyFound();
2313}
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002314
2315TEST_F(VkLayerTest, DynamicRenderingAreaGreaterThanAttachmentExtent) {
2316 TEST_DESCRIPTION("Begin dynamic rendering with render area greater than extent of attachments");
2317
2318 SetTargetApiVersion(VK_API_VERSION_1_0);
2319 AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
2320 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2321 ASSERT_NO_FATAL_FAILURE(InitFramework());
2322
2323 if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
2324 printf("%s Tests requires Vulkan 1.0, skipping test\n", kSkipPrefix);
2325 return;
2326 }
2327 if (!AreRequestedExtensionsEnabled()) {
2328 printf("%s Extension %s not supported, skipping tests\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2329 return;
2330 }
2331
ziga-lunarga51287c2022-04-20 23:24:37 +02002332 auto vkGetPhysicalDeviceFeatures2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2KHR>(
2333 vk::GetInstanceProcAddr(instance(), "vkGetPhysicalDeviceFeatures2KHR"));
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002334 ASSERT_TRUE(vkGetPhysicalDeviceFeatures2KHR != nullptr);
2335
2336 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2337 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2KHR>(&dynamic_rendering_features);
2338 vkGetPhysicalDeviceFeatures2KHR(gpu(), &features2);
2339 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
2340 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
2341 return;
2342 }
2343
2344 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2345
2346 VkImageObj colorImage(m_device);
2347 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
2348 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
2349
ziga-lunarga51287c2022-04-20 23:24:37 +02002350 auto color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002351 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2352 color_attachment.imageView = colorImageView;
2353
ziga-lunarga51287c2022-04-20 23:24:37 +02002354 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002355 begin_rendering_info.layerCount = 1;
2356 begin_rendering_info.colorAttachmentCount = 1;
2357 begin_rendering_info.pColorAttachments = &color_attachment;
2358 begin_rendering_info.renderArea.extent.width = 64;
2359 begin_rendering_info.renderArea.extent.height = 32;
2360
2361 m_commandBuffer->begin();
2362
2363 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06075");
2364 m_commandBuffer->BeginRendering(begin_rendering_info);
2365 m_errorMonitor->VerifyFound();
2366
2367 begin_rendering_info.renderArea.extent.width = 32;
2368 begin_rendering_info.renderArea.extent.height = 64;
2369
2370 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06076");
2371 m_commandBuffer->BeginRendering(begin_rendering_info);
2372 m_errorMonitor->VerifyFound();
2373
2374 const VkFormat ds_format = FindSupportedDepthStencilFormat(gpu());
2375 if (ds_format != VK_FORMAT_UNDEFINED) {
2376 VkImageObj depthImage(m_device);
2377 depthImage.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
2378 VkImageView depthImageView = depthImage.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT);
2379
2380 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2381 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
2382 depth_attachment.imageView = depthImageView;
2383
2384 begin_rendering_info.colorAttachmentCount = 0;
2385 begin_rendering_info.pDepthAttachment = &depth_attachment;
2386
2387 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06076");
2388 m_commandBuffer->BeginRendering(begin_rendering_info);
2389 m_errorMonitor->VerifyFound();
2390 }
2391
2392 m_commandBuffer->end();
2393}
ziga-lunarga51287c2022-04-20 23:24:37 +02002394
2395TEST_F(VkLayerTest, DynamicRenderingDeviceGroupAreaGreaterThanAttachmentExtent) {
2396 TEST_DESCRIPTION("Begin dynamic rendering with device group with render area greater than extent of attachments");
2397
2398 SetTargetApiVersion(VK_API_VERSION_1_1);
2399 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2400 ASSERT_NO_FATAL_FAILURE(InitFramework());
2401
2402 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
2403 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
2404 return;
2405 }
2406 if (!AreRequestedExtensionsEnabled()) {
2407 printf("%s Extension %s not supported, skipping tests\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2408 return;
2409 }
2410
2411 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2412 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2413 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2414 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
2415 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
2416 return;
2417 }
2418
2419 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2420
2421 VkImageObj colorImage(m_device);
2422 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
2423 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
2424
2425 auto color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2426 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2427 color_attachment.imageView = colorImageView;
2428
2429 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2430 begin_rendering_info.layerCount = 1;
2431 begin_rendering_info.colorAttachmentCount = 1;
2432 begin_rendering_info.pColorAttachments = &color_attachment;
2433 begin_rendering_info.renderArea.extent.width = 64;
2434 begin_rendering_info.renderArea.extent.height = 32;
2435
2436 m_commandBuffer->begin();
2437
2438 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06079");
2439 m_commandBuffer->BeginRendering(begin_rendering_info);
2440 m_errorMonitor->VerifyFound();
2441
2442 begin_rendering_info.renderArea.extent.width = 32;
2443 begin_rendering_info.renderArea.extent.height = 64;
2444
2445 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06080");
2446 m_commandBuffer->BeginRendering(begin_rendering_info);
2447 m_errorMonitor->VerifyFound();
2448
2449 const VkFormat ds_format = FindSupportedDepthStencilFormat(gpu());
2450 if (ds_format != VK_FORMAT_UNDEFINED) {
2451 VkImageObj depthImage(m_device);
2452 depthImage.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
2453 VkImageView depthImageView = depthImage.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT);
2454
2455 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2456 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
2457 depth_attachment.imageView = depthImageView;
2458
2459 begin_rendering_info.colorAttachmentCount = 0;
2460 begin_rendering_info.pDepthAttachment = &depth_attachment;
2461
2462 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06080");
2463 m_commandBuffer->BeginRendering(begin_rendering_info);
2464 m_errorMonitor->VerifyFound();
2465 }
2466
2467 m_commandBuffer->end();
2468}
ziga-lunargd4105c12022-04-21 13:54:20 +02002469
2470TEST_F(VkLayerTest, SecondaryCommandBufferIncompatibleRenderPass) {
2471 TEST_DESCRIPTION("Execute secondary command buffers within render pass instance with incompatible render pass");
2472
2473 SetTargetApiVersion(VK_API_VERSION_1_1);
2474 ASSERT_NO_FATAL_FAILURE(InitFramework());
2475
2476 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
2477 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
2478 return;
2479 }
2480
2481 ASSERT_NO_FATAL_FAILURE(InitState());
2482 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2483
2484 auto render_pass_ci = LvlInitStruct<VkRenderPassCreateInfo>();
2485
2486 vk_testing::RenderPass render_pass;
2487 render_pass.init(*m_device, render_pass_ci);
2488
2489 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2490 VkCommandBuffer secondary_handle = cb.handle();
2491
2492 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2493 cmd_buffer_inheritance_info.renderPass = render_pass.handle();
2494 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2495 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2496 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2497
2498 cb.begin(&cmd_buffer_begin_info);
2499 cb.end();
2500
2501 m_commandBuffer->begin();
2502 m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
2503
2504 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pBeginInfo-06020");
2505 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pInheritanceInfo-00098");
2506 vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle);
2507 m_errorMonitor->VerifyFound();
2508
2509 m_commandBuffer->EndRenderPass();
2510 m_commandBuffer->end();
2511}
ziga-lunarg590e0292022-04-21 14:07:22 +02002512
2513TEST_F(VkLayerTest, SecondaryCommandBufferIncompatibleSubpass) {
2514 TEST_DESCRIPTION("Execute secondary command buffers with different subpass");
2515
2516 SetTargetApiVersion(VK_API_VERSION_1_1);
2517 ASSERT_NO_FATAL_FAILURE(InitFramework());
2518
2519 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
2520 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
2521 return;
2522 }
2523
2524 ASSERT_NO_FATAL_FAILURE(InitState());
2525
2526 VkSubpassDescription subpasses[2] = {};
2527
2528 auto render_pass_ci = LvlInitStruct<VkRenderPassCreateInfo>();
2529 render_pass_ci.subpassCount = 2;
2530 render_pass_ci.pSubpasses = subpasses;
2531
2532 vk_testing::RenderPass render_pass;
2533 render_pass.init(*m_device, render_pass_ci);
2534
2535 auto framebuffer_ci = LvlInitStruct<VkFramebufferCreateInfo>();
2536 framebuffer_ci.renderPass = render_pass.handle();
2537 framebuffer_ci.width = 32;
2538 framebuffer_ci.height = 32;
2539
2540 vk_testing::Framebuffer framebuffer;
2541 framebuffer.init(*m_device, framebuffer_ci);
2542
2543 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2544 VkCommandBuffer secondary_handle = cb.handle();
2545
2546 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2547 cmd_buffer_inheritance_info.renderPass = render_pass.handle();
2548 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2549 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2550 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2551
2552 cb.begin(&cmd_buffer_begin_info);
2553 cb.end();
2554
2555 auto render_pass_begin_info = LvlInitStruct<VkRenderPassBeginInfo>();
2556 render_pass_begin_info.renderPass = render_pass.handle();
2557 render_pass_begin_info.renderArea.extent = {32, 32};
2558 render_pass_begin_info.framebuffer = framebuffer.handle();
2559
2560 m_commandBuffer->begin();
2561 m_commandBuffer->BeginRenderPass(render_pass_begin_info, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
2562 vk::CmdNextSubpass(m_commandBuffer->handle(), VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
2563
2564 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pCommandBuffers-00097");
2565 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pCommandBuffers-06019");
2566 vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle);
2567 m_errorMonitor->VerifyFound();
2568
2569 m_commandBuffer->EndRenderPass();
2570 m_commandBuffer->end();
2571}
ziga-lunarg343193b2022-04-21 14:15:17 +02002572
2573TEST_F(VkLayerTest, SecondaryCommandBufferInvalidContents) {
2574 TEST_DESCRIPTION("Execute secondary command buffers within active render pass that was not begun with VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS");
2575
2576 SetTargetApiVersion(VK_API_VERSION_1_1);
2577 ASSERT_NO_FATAL_FAILURE(InitFramework());
2578
2579 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
2580 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
2581 return;
2582 }
2583
2584 ASSERT_NO_FATAL_FAILURE(InitState());
2585 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2586
2587 auto render_pass_ci = LvlInitStruct<VkRenderPassCreateInfo>();
2588
2589 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2590 VkCommandBuffer secondary_handle = cb.handle();
2591
2592 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2593 cmd_buffer_inheritance_info.renderPass = m_renderPass;
2594 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2595 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2596 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2597
2598 cb.begin(&cmd_buffer_begin_info);
2599 cb.end();
2600
2601 m_commandBuffer->begin();
2602 m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo);
2603
2604 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-contents-00095");
2605 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-contents-06018");
2606 vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle);
2607 m_errorMonitor->VerifyFound();
2608
2609 m_commandBuffer->EndRenderPass();
2610 m_commandBuffer->end();
2611}
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002612
2613TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoDepthFormat) {
2614 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo DepthFormat incompatible with previously used pipeline");
2615
2616 SetTargetApiVersion(VK_API_VERSION_1_1);
2617 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2618 ASSERT_NO_FATAL_FAILURE(InitFramework());
2619
2620 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
2621 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
2622 return;
2623 }
2624 if (!AreRequestedExtensionsEnabled()) {
2625 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2626 return;
2627 }
2628
2629 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2630 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2631 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2632 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
2633 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
2634 return;
2635 }
2636
2637 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2638 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2639
2640 m_errorMonitor->ExpectSuccess();
2641
2642 std::vector<VkFormat> depth_formats;
2643 const VkFormat ds_formats[] = {VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT};
2644 for (uint32_t i = 0; i < size(ds_formats); ++i) {
2645 VkFormatProperties format_props;
2646 vk::GetPhysicalDeviceFormatProperties(gpu(), ds_formats[i], &format_props);
2647
2648 if (format_props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) {
2649 depth_formats.push_back(ds_formats[i]);
2650 }
2651 }
2652
2653 if (depth_formats.size() < 2) {
2654 printf("%s Test requires 2 depth formats, skipping test.\n", kSkipPrefix);
2655 return;
2656 }
2657
2658 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2659 pipeline_rendering_info.depthAttachmentFormat = depth_formats[0];
2660
2661 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
2662
2663 CreatePipelineHelper pipe1(*this);
2664 pipe1.InitInfo();
2665 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2666 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2667 pipe1.InitState();
2668 pipe1.ds_ci_ = ds_ci;
2669 pipe1.CreateGraphicsPipeline();
2670
2671 pipeline_rendering_info.depthAttachmentFormat = depth_formats[1];
2672
2673 CreatePipelineHelper pipe2(*this);
2674 pipe2.InitInfo();
2675 pipe2.gp_ci_.pNext = &pipeline_rendering_info;
2676 pipe2.gp_ci_.renderPass = VK_NULL_HANDLE;
2677 pipe2.InitState();
2678 pipe2.ds_ci_ = ds_ci;
2679 pipe2.CreateGraphicsPipeline();
2680
2681 VkImageObj image(m_device);
2682 image.Init(32, 32, 1, depth_formats[0], VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2683 VkImageView depth_image_view = image.targetView(depth_formats[0], VK_IMAGE_ASPECT_DEPTH_BIT);
2684
2685 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2686 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
2687 depth_attachment.imageView = depth_image_view;
2688
2689 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2690 begin_rendering_info.layerCount = 1;
2691 begin_rendering_info.pDepthAttachment = &depth_attachment;
2692
2693 m_commandBuffer->begin();
2694 m_commandBuffer->BeginRendering(begin_rendering_info);
2695
2696 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_);
2697 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
2698
2699 m_errorMonitor->VerifyNotFound();
2700
2701 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06197");
2702 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_);
2703 m_errorMonitor->VerifyFound();
2704
2705 m_commandBuffer->EndRendering();
2706 m_commandBuffer->end();
2707}
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002708
2709TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoColorAttachments) {
2710 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo color attachment incompatible with previously used pipeline");
2711
2712 SetTargetApiVersion(VK_API_VERSION_1_1);
2713 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2714 ASSERT_NO_FATAL_FAILURE(InitFramework());
2715
2716 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
2717 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
2718 return;
2719 }
2720 if (!AreRequestedExtensionsEnabled()) {
2721 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2722 return;
2723 }
2724
2725 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2726 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2727 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2728 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
2729 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
2730 return;
2731 }
2732
2733 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2734 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2735
2736 m_errorMonitor->ExpectSuccess();
2737
2738 VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
2739 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2740 pipeline_rendering_info.colorAttachmentCount = 1;
2741 pipeline_rendering_info.pColorAttachmentFormats = &format;
2742
2743 CreatePipelineHelper pipe1(*this);
2744 pipe1.InitInfo();
2745 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2746 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2747 pipe1.InitState();
2748 pipe1.CreateGraphicsPipeline();
2749
2750 format = VK_FORMAT_B8G8R8A8_UNORM;
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.CreateGraphicsPipeline();
2758
2759 VkImageObj image(m_device);
2760 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2761 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
2762
2763 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2764 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2765 color_attachment.imageView = image_view;
2766
2767 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2768 begin_rendering_info.layerCount = 1;
2769 begin_rendering_info.colorAttachmentCount = 1;
2770 begin_rendering_info.pColorAttachments = &color_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-06196");
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-lunargacd79322022-04-21 18:36:34 +02002787
2788TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoColorAttachmentCount) {
2789 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo color attachment count incompatible with previously used pipeline");
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) {
2796 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
2797 return;
2798 }
2799 if (!AreRequestedExtensionsEnabled()) {
2800 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2801 return;
2802 }
2803
2804 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2805 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2806 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2807 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
2808 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
2809 return;
2810 }
2811
2812 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2813 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2814
2815 m_errorMonitor->ExpectSuccess();
2816
2817 VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
2818 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2819 pipeline_rendering_info.colorAttachmentCount = 1;
2820 pipeline_rendering_info.pColorAttachmentFormats = &format;
2821
2822 CreatePipelineHelper pipe1(*this);
2823 pipe1.InitInfo();
2824 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2825 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2826 pipe1.InitState();
2827 pipe1.CreateGraphicsPipeline();
2828
2829 pipeline_rendering_info.colorAttachmentCount = 0;
2830
2831 CreatePipelineHelper pipe2(*this);
2832 pipe2.InitInfo();
2833 pipe2.gp_ci_.pNext = &pipeline_rendering_info;
2834 pipe2.gp_ci_.renderPass = VK_NULL_HANDLE;
2835 pipe2.InitState();
2836 pipe2.CreateGraphicsPipeline();
2837
2838 VkImageObj image(m_device);
2839 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2840 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
2841
2842 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2843 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2844 color_attachment.imageView = image_view;
2845
2846 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2847 begin_rendering_info.layerCount = 1;
2848 begin_rendering_info.colorAttachmentCount = 1;
2849 begin_rendering_info.pColorAttachments = &color_attachment;
2850
2851 m_commandBuffer->begin();
2852 m_commandBuffer->BeginRendering(begin_rendering_info);
2853
2854 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_);
2855 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
2856
2857 m_errorMonitor->VerifyNotFound();
2858
2859 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06195");
2860 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_);
2861 m_errorMonitor->VerifyFound();
2862
2863 m_commandBuffer->EndRendering();
2864 m_commandBuffer->end();
ziga-lunarge3f11282022-04-21 18:39:55 +02002865}
2866
2867TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoStencilFormat) {
2868 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo StencilFormat incompatible with previously used pipeline");
2869
2870 SetTargetApiVersion(VK_API_VERSION_1_1);
2871 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2872 ASSERT_NO_FATAL_FAILURE(InitFramework());
2873
2874 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
2875 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
2876 return;
2877 }
2878 if (!AreRequestedExtensionsEnabled()) {
2879 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2880 return;
2881 }
2882
2883 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2884 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2885 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2886 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
2887 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
2888 return;
2889 }
2890
2891 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2892 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2893
2894 m_errorMonitor->ExpectSuccess();
2895
2896 std::vector<VkFormat> stencil_formats;
2897 const VkFormat ds_formats[] = {VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT};
2898 for (uint32_t i = 0; i < size(ds_formats); ++i) {
2899 VkFormatProperties format_props;
2900 vk::GetPhysicalDeviceFormatProperties(gpu(), ds_formats[i], &format_props);
2901
2902 if (format_props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) {
2903 stencil_formats.push_back(ds_formats[i]);
2904 }
2905 }
2906
2907 if (stencil_formats.size() < 2) {
2908 printf("%s Test requires 2 stencil formats, skipping test.\n", kSkipPrefix);
2909 return;
2910 }
2911
2912 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2913 pipeline_rendering_info.stencilAttachmentFormat = stencil_formats[0];
2914
2915 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
2916
2917 CreatePipelineHelper pipe1(*this);
2918 pipe1.InitInfo();
2919 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2920 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2921 pipe1.InitState();
2922 pipe1.ds_ci_ = ds_ci;
2923 pipe1.CreateGraphicsPipeline();
2924
2925 pipeline_rendering_info.stencilAttachmentFormat = stencil_formats[1];
2926
2927 CreatePipelineHelper pipe2(*this);
2928 pipe2.InitInfo();
2929 pipe2.gp_ci_.pNext = &pipeline_rendering_info;
2930 pipe2.gp_ci_.renderPass = VK_NULL_HANDLE;
2931 pipe2.InitState();
2932 pipe2.ds_ci_ = ds_ci;
2933 pipe2.CreateGraphicsPipeline();
2934
2935 VkImageObj image(m_device);
2936 image.Init(32, 32, 1, stencil_formats[0], VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2937 VkImageView stencil_image_view = image.targetView(stencil_formats[0], VK_IMAGE_ASPECT_DEPTH_BIT);
2938
2939 VkRenderingAttachmentInfoKHR stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2940 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL;
2941 stencil_attachment.imageView = stencil_image_view;
2942
2943 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2944 begin_rendering_info.layerCount = 1;
2945 begin_rendering_info.pStencilAttachment = &stencil_attachment;
2946
2947 m_commandBuffer->begin();
2948 m_commandBuffer->BeginRendering(begin_rendering_info);
2949
2950 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_);
2951 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
2952
2953 m_errorMonitor->VerifyNotFound();
2954
2955 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06194");
2956 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_);
2957 m_errorMonitor->VerifyFound();
2958
2959 m_commandBuffer->EndRendering();
2960 m_commandBuffer->end();
2961}
ziga-lunarg155ed452022-04-21 23:54:06 +02002962
2963TEST_F(VkLayerTest, DynamicRenderingWithInvalidShaderLayerBuiltIn) {
2964 TEST_DESCRIPTION("Create invalid pipeline that writes to Layer built-in");
2965
2966 SetTargetApiVersion(VK_API_VERSION_1_1);
2967 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2968 ASSERT_NO_FATAL_FAILURE(InitFramework());
2969
2970 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
2971 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
2972 return;
2973 }
2974 if (!AreRequestedExtensionsEnabled()) {
2975 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2976 return;
2977 }
2978
2979 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2980 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>(&dynamic_rendering_features);
2981 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&multiview_features);
2982 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2983 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
2984 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
2985 return;
2986 }
2987 if (multiview_features.multiview == VK_FALSE) {
2988 printf("%s Test requires (unsupported) multiview , skipping\n", kSkipPrefix);
2989 return;
2990 }
2991 if (multiview_features.multiviewGeometryShader == VK_FALSE) {
2992 printf("%s Test requires (unsupported) multiviewGeometryShader , skipping\n", kSkipPrefix);
2993 return;
2994 }
2995
2996 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2997 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2998
2999 static char const *gsSource = R"glsl(
3000 #version 450
3001 layout (triangles) in;
3002 layout (triangle_strip) out;
3003 layout (max_vertices = 1) out;
3004 void main() {
3005 gl_Position = vec4(1.0, 0.5, 0.5, 0.0);
3006 EmitVertex();
3007 gl_Layer = 4;
3008 }
3009 )glsl";
3010
3011 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
3012 VkShaderObj gs(this, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT);
3013
3014 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
3015
3016 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
3017 pipeline_rendering_info.colorAttachmentCount = 1;
3018 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
3019 pipeline_rendering_info.viewMask = 0x1;
3020
3021 CreatePipelineHelper pipe(*this);
3022 pipe.InitInfo();
3023 pipe.shader_stages_ = {vs.GetStageCreateInfo(), gs.GetStageCreateInfo(), pipe.fs_->GetStageCreateInfo()};
3024 pipe.gp_ci_.pNext = &pipeline_rendering_info;
3025 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3026 pipe.InitState();
3027 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06059");
3028 pipe.CreateGraphicsPipeline();
3029 m_errorMonitor->VerifyFound();
3030}
ziga-lunarg6feb4632022-04-22 00:20:21 +02003031
3032TEST_F(VkLayerTest, DynamicRenderingWithInputAttachmentCapability) {
3033 TEST_DESCRIPTION("Create invalid pipeline that uses InputAttachment capability");
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) {
3040 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
3041 return;
3042 }
3043 if (!AreRequestedExtensionsEnabled()) {
3044 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3045 return;
3046 }
3047
3048 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
3049 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3050 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3051 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
3052 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
3053 return;
3054 }
3055
3056 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3057 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3058
3059 const std::string fsSource = R"(
3060 OpCapability Shader
3061 OpCapability InputAttachment
3062 %1 = OpExtInstImport "GLSL.std.450"
3063 OpMemoryModel Logical GLSL450
3064 OpEntryPoint Fragment %main "main"
3065 OpExecutionMode %main OriginUpperLeft
3066
3067 ; Debug Information
3068 OpSource GLSL 450
3069 OpName %main "main" ; id %4
3070
3071 ; Types, variables and constants
3072 %void = OpTypeVoid
3073 %3 = OpTypeFunction %void
3074
3075 ; Function main
3076 %main = OpFunction %void None %3
3077 %5 = OpLabel
3078 OpReturn
3079 OpFunctionEnd
3080 )";
3081
3082 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, SPV_ENV_VULKAN_1_0, SPV_SOURCE_ASM);
3083
3084 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
3085
3086 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
3087 pipeline_rendering_info.colorAttachmentCount = 1;
3088 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
3089
3090 CreatePipelineHelper pipe(*this);
3091 pipe.InitInfo();
3092 pipe.shader_stages_ = {pipe.vs_->GetStageCreateInfo(), fs.GetStageCreateInfo()};
3093 pipe.gp_ci_.pNext = &pipeline_rendering_info;
3094 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3095 pipe.InitState();
3096 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06061");
3097 pipe.CreateGraphicsPipeline();
3098 m_errorMonitor->VerifyFound();
3099}
ziga-lunarga62b6ce2022-04-22 14:33:47 +02003100
3101TEST_F(VkLayerTest, InvalidRenderingInfoColorAttachmentFormat) {
3102 TEST_DESCRIPTION("Create pipeline with invalid color attachment format");
3103
3104 SetTargetApiVersion(VK_API_VERSION_1_1);
3105 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3106 ASSERT_NO_FATAL_FAILURE(InitFramework());
3107
3108 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
3109 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
3110 return;
3111 }
3112 if (!AreRequestedExtensionsEnabled()) {
3113 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3114 return;
3115 }
3116
3117 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
3118 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3119 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3120 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
3121 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
3122 return;
3123 }
3124
3125 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3126 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3127
3128 VkFormat color_format = VK_FORMAT_MAX_ENUM;
3129
3130 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
3131 pipeline_rendering_info.colorAttachmentCount = 1;
3132 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
3133
3134 CreatePipelineHelper pipe(*this);
3135 pipe.InitInfo();
3136 pipe.gp_ci_.pNext = &pipeline_rendering_info;
3137 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3138 pipe.InitState();
3139 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06579");
3140 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06580");
3141 pipe.CreateGraphicsPipeline();
3142 m_errorMonitor->VerifyFound();
3143}
ziga-lunargf7fb9202022-04-22 17:19:10 +02003144
3145TEST_F(VkLayerTest, InvalidDynamicRenderingLibraryViewMask) {
3146 TEST_DESCRIPTION("Create pipeline with invalid view mask");
3147
3148 SetTargetApiVersion(VK_API_VERSION_1_1);
3149 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3150 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
3151 ASSERT_NO_FATAL_FAILURE(InitFramework());
3152
3153 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
3154 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
3155 return;
3156 }
3157 if (!AreRequestedExtensionsEnabled()) {
3158 printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME,
3159 VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
3160 return;
3161 }
3162
3163 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3164 auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>(&multiview_features);
3165 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features);
3166 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3167 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3168 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
3169 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
3170 return;
3171 }
3172 if (library_features.graphicsPipelineLibrary == VK_FALSE) {
3173 printf("%s Test requires (unsupported) graphicsPipelineLibrary , skipping\n", kSkipPrefix);
3174 return;
3175 }
3176 if (multiview_features.multiview == VK_FALSE) {
3177 printf("%s Test requires (unsupported) multiview , skipping\n", kSkipPrefix);
3178 return;
3179 }
3180
3181 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3182 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3183
3184 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
3185
3186 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
3187 pipeline_rendering_info.colorAttachmentCount = 1;
3188 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
3189
3190 auto graphics_library_create_info = LvlInitStruct<VkGraphicsPipelineLibraryCreateInfoEXT>(&pipeline_rendering_info);
3191 graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT;
3192 auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>(&graphics_library_create_info);
3193
3194 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
3195 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
3196 color_blend_state_create_info.attachmentCount = 1;
3197 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
3198
3199 m_errorMonitor->ExpectSuccess();
3200 CreatePipelineHelper lib(*this);
3201 lib.cb_ci_ = color_blend_state_create_info;
3202 lib.InitInfo();
3203 lib.gp_ci_.pNext = &library_create_info;
3204 lib.gp_ci_.renderPass = VK_NULL_HANDLE;
3205 lib.InitState();
3206 lib.CreateGraphicsPipeline();
3207 m_errorMonitor->VerifyNotFound();
3208
3209 graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT;
3210 library_create_info.libraryCount = 1;
3211 library_create_info.pLibraries = &lib.pipeline_;
3212 pipeline_rendering_info.viewMask = 0x1;
3213
3214 CreatePipelineHelper pipe(*this);
3215 pipe.InitInfo();
3216 pipe.gp_ci_.pNext = &library_create_info;
3217 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3218 pipe.InitState();
3219 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06626");
3220 pipe.CreateGraphicsPipeline();
3221 m_errorMonitor->VerifyFound();
3222}
ziga-lunarge151ca62022-04-22 17:40:51 +02003223
3224TEST_F(VkLayerTest, InvalidAttachmentSampleCount) {
3225 TEST_DESCRIPTION("Create pipeline with invalid color attachment samples");
3226
3227 SetTargetApiVersion(VK_API_VERSION_1_1);
3228 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3229 ASSERT_NO_FATAL_FAILURE(InitFramework());
3230
3231 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
3232 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
3233 return;
3234 }
3235 if (!AreRequestedExtensionsEnabled()) {
3236 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3237 return;
3238 }
3239
3240 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
3241 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3242 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3243 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
3244 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
3245 return;
3246 }
3247
3248 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3249 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3250
3251 VkSampleCountFlagBits color_attachment_samples = VK_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM;
3252
3253 auto samples_info = LvlInitStruct<VkAttachmentSampleCountInfoAMD>();
3254 samples_info.colorAttachmentCount = 1;
3255 samples_info.pColorAttachmentSamples = &color_attachment_samples;
3256 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(&samples_info);
3257
3258 CreatePipelineHelper pipe(*this);
3259 pipe.InitInfo();
3260 pipe.gp_ci_.pNext = &pipeline_rendering_info;
3261 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3262 pipe.InitState();
3263 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-pColorAttachmentSamples-06592");
3264 pipe.CreateGraphicsPipeline();
3265 m_errorMonitor->VerifyFound();
3266}
ziga-lunargb81597d2022-04-22 19:11:51 +02003267
3268TEST_F(VkLayerTest, InvalidDynamicRenderingLibrariesViewMask) {
3269 TEST_DESCRIPTION("Create pipeline with libaries that have incompatible view mask");
3270
3271 SetTargetApiVersion(VK_API_VERSION_1_1);
3272 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3273 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
3274 ASSERT_NO_FATAL_FAILURE(InitFramework());
3275
3276 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
3277 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
3278 return;
3279 }
3280 if (!AreRequestedExtensionsEnabled()) {
3281 printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME,
3282 VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
3283 return;
3284 }
3285
3286 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3287 auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>(&multiview_features);
3288 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features);
3289 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3290 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3291 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
3292 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
3293 return;
3294 }
3295 if (library_features.graphicsPipelineLibrary == VK_FALSE) {
3296 printf("%s Test requires (unsupported) graphicsPipelineLibrary , skipping\n", kSkipPrefix);
3297 return;
3298 }
3299 if (multiview_features.multiview == VK_FALSE) {
3300 printf("%s Test requires (unsupported) multiview , skipping\n", kSkipPrefix);
3301 return;
3302 }
3303
3304 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3305 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3306
3307 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
3308
3309 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
3310 pipeline_rendering_info.colorAttachmentCount = 1;
3311 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
3312
3313 auto graphics_library_create_info = LvlInitStruct<VkGraphicsPipelineLibraryCreateInfoEXT>(&pipeline_rendering_info);
3314 graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT;
3315 auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>(&graphics_library_create_info);
3316
3317 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
3318 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
3319 color_blend_state_create_info.attachmentCount = 1;
3320 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
3321
3322 m_errorMonitor->ExpectSuccess();
3323 CreatePipelineHelper lib1(*this);
3324 lib1.cb_ci_ = color_blend_state_create_info;
3325 lib1.InitInfo();
3326 lib1.gp_ci_.pNext = &library_create_info;
3327 lib1.gp_ci_.renderPass = VK_NULL_HANDLE;
3328 lib1.InitState();
3329 lib1.CreateGraphicsPipeline();
3330
3331 graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT;
3332 pipeline_rendering_info.viewMask = 0x1;
3333
3334 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
3335
3336 CreatePipelineHelper lib2(*this);
3337 lib2.cb_ci_ = color_blend_state_create_info;
3338 lib2.InitInfo();
3339 lib2.gp_ci_.pNext = &library_create_info;
3340 lib2.gp_ci_.renderPass = VK_NULL_HANDLE;
3341 lib2.ds_ci_ = ds_ci;
3342 lib2.InitState();
3343 lib2.CreateGraphicsPipeline();
3344 m_errorMonitor->VerifyNotFound();
3345
3346 graphics_library_create_info.flags =
3347 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT | VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT;
3348 library_create_info.libraryCount = 2;
3349 VkPipeline libraries[2] = {lib1.pipeline_, lib2.pipeline_};
3350 library_create_info.pLibraries = libraries;
3351 pipeline_rendering_info.viewMask = 0;
3352
3353 CreatePipelineHelper pipe(*this);
3354 pipe.InitInfo();
3355 pipe.gp_ci_.pNext = &library_create_info;
3356 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3357 pipe.InitState();
3358 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06627");
3359 pipe.CreateGraphicsPipeline();
3360 m_errorMonitor->VerifyFound();
3361}
ziga-lunarg2e302312022-04-22 19:47:32 +02003362
3363TEST_F(VkLayerTest, InvalidDynamicRenderingLibraryRenderPass) {
3364 TEST_DESCRIPTION("Create pipeline with invalid library render pass");
3365
3366 SetTargetApiVersion(VK_API_VERSION_1_1);
3367 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3368 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
3369 ASSERT_NO_FATAL_FAILURE(InitFramework());
3370
3371 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
3372 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
3373 return;
3374 }
3375 if (!AreRequestedExtensionsEnabled()) {
3376 printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME,
3377 VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
3378 return;
3379 }
3380
3381 auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>();
3382 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features);
3383 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3384 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3385 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
3386 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
3387 return;
3388 }
3389 if (library_features.graphicsPipelineLibrary == VK_FALSE) {
3390 printf("%s Test requires (unsupported) graphicsPipelineLibrary , skipping\n", kSkipPrefix);
3391 return;
3392 }
3393
3394 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3395 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3396
3397 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
3398
3399 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
3400 pipeline_rendering_info.colorAttachmentCount = 1;
3401 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
3402
3403 auto graphics_library_create_info = LvlInitStruct<VkGraphicsPipelineLibraryCreateInfoEXT>(&pipeline_rendering_info);
3404 graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT;
3405 auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>(&graphics_library_create_info);
3406
3407 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
3408 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
3409 color_blend_state_create_info.attachmentCount = 1;
3410 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
3411
3412 m_errorMonitor->ExpectSuccess();
3413 CreatePipelineHelper lib(*this);
3414 lib.cb_ci_ = color_blend_state_create_info;
3415 lib.InitInfo();
3416 lib.gp_ci_.pNext = &library_create_info;
3417 lib.InitState();
3418 lib.CreateGraphicsPipeline();
3419 m_errorMonitor->VerifyNotFound();
3420
3421 graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT;
3422 library_create_info.libraryCount = 1;
3423 library_create_info.pLibraries = &lib.pipeline_;
3424
3425 CreatePipelineHelper pipe(*this);
3426 pipe.InitInfo();
3427 pipe.gp_ci_.pNext = &library_create_info;
3428 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3429 pipe.InitState();
3430 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderpass-06625");
3431 pipe.CreateGraphicsPipeline();
3432 m_errorMonitor->VerifyFound();
3433}
ziga-lunarg7ba5a1c2022-04-22 19:56:49 +02003434
3435TEST_F(VkLayerTest, PipelineMissingMultisampleState) {
3436 TEST_DESCRIPTION("Create pipeline with missing multisample state");
3437
3438 SetTargetApiVersion(VK_API_VERSION_1_1);
3439 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3440 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
3441 ASSERT_NO_FATAL_FAILURE(InitFramework());
3442
3443 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
3444 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
3445 return;
3446 }
3447 if (!AreRequestedExtensionsEnabled()) {
3448 printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME,
3449 VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
3450 return;
3451 }
3452
3453 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
3454 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3455 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3456 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
3457 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
3458 return;
3459 }
3460
3461 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3462 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3463
3464 CreatePipelineHelper pipe(*this);
3465 pipe.InitInfo();
3466 pipe.gp_ci_.pMultisampleState = nullptr;
3467 pipe.InitState();
3468 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderpass-06631");
3469 pipe.CreateGraphicsPipeline();
3470 m_errorMonitor->VerifyFound();
ziga-lunarg14222532022-04-22 23:27:17 +02003471}
3472
3473TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentLayout) {
3474 TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid imageLayout");
3475
3476 SetTargetApiVersion(VK_API_VERSION_1_1);
3477 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3478 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3479 ASSERT_NO_FATAL_FAILURE(InitFramework());
3480
3481 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
3482 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
3483 return;
3484 }
3485 if (!AreRequestedExtensionsEnabled()) {
3486 printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME,
3487 VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3488 return;
3489 }
3490
3491 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
3492 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3493 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3494 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
3495 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
3496 return;
3497 }
3498
3499 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3500 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3501
3502 VkImageObj image(m_device);
3503 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
3504 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, VK_IMAGE_TILING_LINEAR, 0);
3505 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3506
3507 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3508 rendering_fragment_density.imageView = image_view;
3509 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3510 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3511 begin_rendering_info.layerCount = 1;
3512
3513 m_commandBuffer->begin();
3514 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06157");
3515 m_commandBuffer->BeginRendering(begin_rendering_info);
3516 m_errorMonitor->VerifyFound();
3517 m_commandBuffer->end();
3518}
ziga-lunarga81df9d2022-04-22 23:33:13 +02003519
3520TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentUsage) {
3521 TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid imageLayout");
3522
3523 SetTargetApiVersion(VK_API_VERSION_1_1);
3524 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3525 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3526 ASSERT_NO_FATAL_FAILURE(InitFramework());
3527
3528 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
3529 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
3530 return;
3531 }
3532 if (!AreRequestedExtensionsEnabled()) {
3533 printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME,
3534 VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3535 return;
3536 }
3537
3538 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
3539 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3540 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3541 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
3542 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
3543 return;
3544 }
3545
3546 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3547 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3548
3549 VkImageObj image(m_device);
3550 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
3551 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3552
3553 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3554 rendering_fragment_density.imageView = image_view;
3555 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3556 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3557 begin_rendering_info.layerCount = 1;
3558
3559 m_commandBuffer->begin();
3560 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06158");
3561 m_commandBuffer->BeginRendering(begin_rendering_info);
3562 m_errorMonitor->VerifyFound();
3563 m_commandBuffer->end();
3564}
ziga-lunarg7c411b32022-04-22 23:37:48 +02003565
3566TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentCreateFlags) {
3567 TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid image create flags");
3568
3569 SetTargetApiVersion(VK_API_VERSION_1_1);
3570 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3571 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3572 ASSERT_NO_FATAL_FAILURE(InitFramework());
3573
3574 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
3575 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
3576 return;
3577 }
3578 if (!AreRequestedExtensionsEnabled()) {
3579 printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME,
3580 VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3581 return;
3582 }
3583
3584 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
3585 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3586 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3587 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
3588 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
3589 return;
3590 }
3591
3592 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3593 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3594
3595 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3596 image_create_info.flags = VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT;
3597 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3598 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
3599 image_create_info.extent = {32, 32, 4};
3600 image_create_info.mipLevels = 1;
3601 image_create_info.arrayLayers = 1;
3602 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
3603 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3604 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT;
3605
3606 VkImageObj image(m_device);
3607 image.Init(image_create_info);
3608 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3609
3610 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3611 rendering_fragment_density.imageView = image_view;
3612 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3613 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3614 begin_rendering_info.layerCount = 1;
3615
3616 m_commandBuffer->begin();
3617 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06159");
3618 m_commandBuffer->BeginRendering(begin_rendering_info);
3619 m_errorMonitor->VerifyFound();
3620 m_commandBuffer->end();
3621}
ziga-lunarg66569a72022-04-22 23:43:26 +02003622
3623TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentLayerCount) {
3624 TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid layer count");
3625
3626 SetTargetApiVersion(VK_API_VERSION_1_1);
3627 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3628 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3629 ASSERT_NO_FATAL_FAILURE(InitFramework());
3630
3631 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
3632 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
3633 return;
3634 }
3635 if (!AreRequestedExtensionsEnabled()) {
3636 printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME,
3637 VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3638 return;
3639 }
3640
3641 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3642 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&multiview_features);
3643 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3644 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3645 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
3646 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
3647 return;
3648 }
3649 if (!multiview_features.multiview) {
3650 printf("%s Test requires (unsupported) multiview , skipping\n", kSkipPrefix);
3651 return;
3652 }
3653
3654 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3655 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3656
3657 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3658 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3659 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
3660 image_create_info.extent = {32, 32, 4};
3661 image_create_info.mipLevels = 1;
3662 image_create_info.arrayLayers = 2;
3663 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
3664 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3665 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT;
3666
3667 VkImageObj image(m_device);
3668 image.Init(image_create_info);
3669 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3670
3671 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3672 rendering_fragment_density.imageView = image_view;
3673 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3674 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3675 begin_rendering_info.layerCount = 1;
3676 begin_rendering_info.viewMask = 0x1;
3677
3678 m_commandBuffer->begin();
3679 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06160");
3680 m_commandBuffer->BeginRendering(begin_rendering_info);
3681 m_errorMonitor->VerifyFound();
3682 m_commandBuffer->end();
3683}
ziga-lunarg323c11d2022-04-22 23:56:32 +02003684
3685TEST_F(VkLayerTest, InvalidRenderingPNextImageView) {
3686 TEST_DESCRIPTION(
3687 "Use different image views in VkRenderingFragmentShadingRateAttachmentInfoKHR and "
3688 "VkRenderingFragmentDensityMapAttachmentInfoEXT");
3689
3690 SetTargetApiVersion(VK_API_VERSION_1_1);
3691 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3692 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3693 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
3694 ASSERT_NO_FATAL_FAILURE(InitFramework());
3695
3696 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
3697 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
3698 return;
3699 }
3700 if (!AreRequestedExtensionsEnabled()) {
3701 printf("%s %s or %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME,
3702 VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME, VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
3703 return;
3704 }
3705
3706 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3707 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&multiview_features);
3708 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3709 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3710 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
3711 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
3712 return;
3713 }
3714 if (!multiview_features.multiview) {
3715 printf("%s Test requires (unsupported) multiview , skipping\n", kSkipPrefix);
3716 return;
3717 }
3718
3719 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3720 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3721
3722 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
3723
3724 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
3725 vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2);
3726
3727 VkImageObj image1(m_device);
3728 image1.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
3729 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR,
3730 VK_IMAGE_TILING_LINEAR, 0);
3731 VkImageView image_view1 = image1.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3732 VkImageObj image2(m_device);
3733 image2.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
3734 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, VK_IMAGE_TILING_LINEAR, 0);
3735 VkImageView image_view2 = image2.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3736
3737 auto rendering_fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
3738 rendering_fragment_shading_rate.imageView = image_view1;
3739 rendering_fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3740 rendering_fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
3741 auto rendering_fragment_density =
3742 LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>(&rendering_fragment_shading_rate);
3743 rendering_fragment_density.imageView = image_view2;
3744 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3745 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3746 begin_rendering_info.layerCount = 1;
3747 begin_rendering_info.viewMask = 0x1;
3748
3749 m_commandBuffer->begin();
3750 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06126");
3751 m_commandBuffer->BeginRendering(begin_rendering_info);
3752 m_errorMonitor->VerifyFound();
3753 m_commandBuffer->end();
3754}
ziga-lunarg95f20d42022-04-23 00:06:42 +02003755
3756TEST_F(VkLayerTest, InvalidRenderingRenderArea) {
3757 TEST_DESCRIPTION("Use negative offset in RenderingInfo render area");
3758
3759 SetTargetApiVersion(VK_API_VERSION_1_0);
3760 AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
3761 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3762 ASSERT_NO_FATAL_FAILURE(InitFramework());
3763
3764 if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
3765 printf("%s Tests requires Vulkan 1.0, skipping test\n", kSkipPrefix);
3766 return;
3767 }
3768 if (!AreRequestedExtensionsEnabled()) {
3769 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3770 return;
3771 }
3772
3773 auto vkGetPhysicalDeviceFeatures2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2KHR>(
3774 vk::GetInstanceProcAddr(instance(), "vkGetPhysicalDeviceFeatures2KHR"));
3775 ASSERT_TRUE(vkGetPhysicalDeviceFeatures2KHR != nullptr);
3776
3777 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
3778 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2KHR>(&dynamic_rendering_features);
3779 vkGetPhysicalDeviceFeatures2KHR(gpu(), &features2);
3780 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
3781 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
3782 return;
3783 }
3784
3785 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3786 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3787
3788 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3789 begin_rendering_info.layerCount = 1;
3790 begin_rendering_info.renderArea.offset.x = -1;
ziga-lunarg9b6a95f2022-04-23 00:13:38 +02003791 begin_rendering_info.renderArea.extent.width = 32;
3792 begin_rendering_info.renderArea.extent.height = 32;
ziga-lunarg95f20d42022-04-23 00:06:42 +02003793
3794 m_commandBuffer->begin();
3795
3796 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06071");
3797 m_commandBuffer->BeginRendering(begin_rendering_info);
3798 m_errorMonitor->VerifyFound();
3799
3800 begin_rendering_info.renderArea.offset.x = 0;
3801 begin_rendering_info.renderArea.offset.y = -1;
3802
3803 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06072");
3804 m_commandBuffer->BeginRendering(begin_rendering_info);
3805 m_errorMonitor->VerifyFound();
3806
ziga-lunarg9b6a95f2022-04-23 00:13:38 +02003807 begin_rendering_info.renderArea.offset.y = 0;
3808 begin_rendering_info.renderArea.offset.x = m_device->phy().properties().limits.maxFramebufferWidth - 16;
3809 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06073");
3810 m_commandBuffer->BeginRendering(begin_rendering_info);
3811 m_errorMonitor->VerifyFound();
3812
3813 begin_rendering_info.renderArea.offset.x = 0;
3814 begin_rendering_info.renderArea.offset.y = m_device->phy().properties().limits.maxFramebufferHeight - 16;
3815 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06074");
3816 m_commandBuffer->BeginRendering(begin_rendering_info);
3817 m_errorMonitor->VerifyFound();
3818
ziga-lunarg95f20d42022-04-23 00:06:42 +02003819 m_commandBuffer->end();
3820}
ziga-lunarg6662a882022-04-23 00:21:27 +02003821
3822TEST_F(VkLayerTest, InvalidRenderingInfoViewMask) {
3823 TEST_DESCRIPTION("Use negative offset in RenderingInfo render area");
3824
3825 SetTargetApiVersion(VK_API_VERSION_1_1);
3826 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3827 ASSERT_NO_FATAL_FAILURE(InitFramework());
3828
3829 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
3830 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
3831 return;
3832 }
3833 if (!AreRequestedExtensionsEnabled()) {
3834 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3835 return;
3836 }
3837
3838 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3839 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(&multiview_features);
3840 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3841 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3842 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
3843 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
3844 return;
3845 }
3846 if (multiview_features.multiview == VK_FALSE) {
3847 printf("%s Test requires (unsupported) multiview , skipping\n", kSkipPrefix);
3848 return;
3849 }
3850
3851 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3852 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3853
3854 VkPhysicalDeviceMultiviewProperties multiview_props = LvlInitStruct<VkPhysicalDeviceMultiviewProperties>();
3855 VkPhysicalDeviceProperties2 pd_props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&multiview_props);
3856 vk::GetPhysicalDeviceProperties2(gpu(), &pd_props2);
3857
3858 if (multiview_props.maxMultiviewViewCount == 32) {
3859 printf("%s VUID is not testable as maxMultiviewViewCount is 32, skipping test\n", kSkipPrefix);
3860 return;
3861 }
3862
3863 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3864 begin_rendering_info.layerCount = 1;
3865 begin_rendering_info.renderArea.extent.width = 32;
3866 begin_rendering_info.renderArea.extent.height = 32;
3867 begin_rendering_info.viewMask = 1u << multiview_props.maxMultiviewViewCount;
3868
3869 m_commandBuffer->begin();
3870
3871 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-viewMask-06128");
3872 m_commandBuffer->BeginRendering(begin_rendering_info);
3873 m_errorMonitor->VerifyFound();
3874
3875 m_commandBuffer->end();
3876}
ziga-lunargae75b8a2022-04-23 10:54:37 +02003877
3878TEST_F(VkLayerTest, InvalidRenderingColorAttachmentFormat) {
3879 TEST_DESCRIPTION("Use format with missing potential format features in rendering color attachment");
3880
3881 SetTargetApiVersion(VK_API_VERSION_1_1);
3882 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3883 AddRequiredExtensions(VK_NV_LINEAR_COLOR_ATTACHMENT_EXTENSION_NAME);
3884 ASSERT_NO_FATAL_FAILURE(InitFramework());
3885
3886 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
3887 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
3888 return;
3889 }
3890 if (!AreRequestedExtensionsEnabled()) {
3891 printf("%s %s or %s is not supported, skipping test.\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME,
3892 VK_NV_LINEAR_COLOR_ATTACHMENT_EXTENSION_NAME);
3893 return;
3894 }
3895
3896 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
3897 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3898 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3899 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
3900 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
3901 return;
3902 }
3903
3904 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3905 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3906
3907 VkFormat format = FindSupportedDepthStencilFormat(gpu());
3908 if (format == VK_FORMAT_UNDEFINED) {
3909 printf("%s No Depth + Stencil format found. Skipped.\n", kSkipPrefix);
3910 return;
3911 }
3912
3913 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
3914 pipeline_rendering_info.colorAttachmentCount = 1;
3915 pipeline_rendering_info.pColorAttachmentFormats = &format;
3916
3917 CreatePipelineHelper pipe(*this);
3918 pipe.InitInfo();
3919 pipe.gp_ci_.pNext = &pipeline_rendering_info;
3920 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3921 pipe.InitState();
3922
3923 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06582");
3924 pipe.CreateGraphicsPipeline();
3925 m_errorMonitor->VerifyFound();
3926}
ziga-lunargeac390f2022-04-23 11:05:28 +02003927
3928TEST_F(VkLayerTest, InvalidResolveModeWithIntegerColorFormat) {
3929 TEST_DESCRIPTION("Use invalid resolve mode with integer color format");
3930
3931 SetTargetApiVersion(VK_API_VERSION_1_1);
3932 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3933 ASSERT_NO_FATAL_FAILURE(InitFramework());
3934
3935 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
3936 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
3937 return;
3938 }
3939 if (!AreRequestedExtensionsEnabled()) {
3940 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3941 return;
3942 }
3943
3944 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
3945 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3946 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3947 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
3948 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
3949 return;
3950 }
3951
3952 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3953 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3954
3955 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3956 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3957 image_create_info.format = VK_FORMAT_R8G8B8A8_UINT;
3958 image_create_info.extent = {32, 32, 4};
3959 image_create_info.mipLevels = 1;
3960 image_create_info.arrayLayers = 1;
3961 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
3962 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3963 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
3964 VkImageObj image(m_device);
3965 image.Init(image_create_info);
3966 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
3967
3968 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3969 color_attachment.imageView = image_view;
3970 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3971 color_attachment.resolveMode = VK_RESOLVE_MODE_MAX_BIT;
3972 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
3973
3974 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3975 begin_rendering_info.colorAttachmentCount = 1;
3976 begin_rendering_info.pColorAttachments = &color_attachment;
3977 begin_rendering_info.layerCount = 1;
3978
3979 m_commandBuffer->begin();
3980
3981 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06130");
3982 m_commandBuffer->BeginRendering(begin_rendering_info);
3983 m_errorMonitor->VerifyFound();
3984
3985 m_commandBuffer->end();
3986}
ziga-lunargdf2a3202022-04-23 11:07:46 +02003987
3988TEST_F(VkLayerTest, InvalidResolveModeSamples) {
3989 TEST_DESCRIPTION("Use invalid sample count with resolve mode that is not none");
3990
3991 SetTargetApiVersion(VK_API_VERSION_1_1);
3992 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3993 ASSERT_NO_FATAL_FAILURE(InitFramework());
3994
3995 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
3996 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
3997 return;
3998 }
3999 if (!AreRequestedExtensionsEnabled()) {
4000 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4001 return;
4002 }
4003
4004 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4005 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4006 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4007 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
4008 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
4009 return;
4010 }
4011
4012 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4013 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4014
4015 VkImageObj image(m_device);
4016 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4017 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4018
4019 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4020 color_attachment.imageView = image_view;
4021 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4022 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4023 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
4024
4025 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4026 begin_rendering_info.colorAttachmentCount = 1;
4027 begin_rendering_info.pColorAttachments = &color_attachment;
4028 begin_rendering_info.layerCount = 1;
4029
4030 m_commandBuffer->begin();
4031
4032 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06132");
4033 m_commandBuffer->BeginRendering(begin_rendering_info);
4034 m_errorMonitor->VerifyFound();
4035
4036 m_commandBuffer->end();
4037}
ziga-lunargb7693aa2022-04-23 11:21:57 +02004038
4039TEST_F(VkLayerTest, InvalidResolveImageViewSamples) {
4040 TEST_DESCRIPTION("Use resolve image view with invalid sample count");
4041
4042 SetTargetApiVersion(VK_API_VERSION_1_1);
4043 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4044 ASSERT_NO_FATAL_FAILURE(InitFramework());
4045
4046 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
4047 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
4048 return;
4049 }
4050 if (!AreRequestedExtensionsEnabled()) {
4051 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4052 return;
4053 }
4054
4055 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4056 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4057 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4058 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
4059 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
4060 return;
4061 }
4062
4063 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4064 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4065
4066 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4067 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4068 image_create_info.format = VK_FORMAT_R8G8B8A8_UINT;
4069 image_create_info.extent = {32, 32, 4};
4070 image_create_info.mipLevels = 1;
4071 image_create_info.arrayLayers = 1;
4072 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4073 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4074 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4075
4076 VkImageObj image(m_device);
4077 image.Init(image_create_info);
4078 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
4079
4080 VkImageObj resolve_image(m_device);
4081 resolve_image.Init(image_create_info);
4082 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UINT);
4083
4084 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4085 color_attachment.imageView = image_view;
4086 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4087 color_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
4088 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
4089 color_attachment.resolveImageView = resolve_image_view;
4090
4091 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4092 begin_rendering_info.colorAttachmentCount = 1;
4093 begin_rendering_info.pColorAttachments = &color_attachment;
4094 begin_rendering_info.layerCount = 1;
4095
4096 m_commandBuffer->begin();
4097
4098 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06133");
4099 m_commandBuffer->BeginRendering(begin_rendering_info);
4100 m_errorMonitor->VerifyFound();
4101
4102 m_commandBuffer->end();
ziga-lunargd12cbce2022-04-23 11:35:20 +02004103}
4104
4105TEST_F(VkLayerTest, InvalidResolveImageViewFormatMatch) {
4106 TEST_DESCRIPTION("Use resolve image view with different format from image view");
4107
4108 SetTargetApiVersion(VK_API_VERSION_1_1);
4109 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4110 ASSERT_NO_FATAL_FAILURE(InitFramework());
4111
4112 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
4113 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
4114 return;
4115 }
4116 if (!AreRequestedExtensionsEnabled()) {
4117 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4118 return;
4119 }
4120
4121 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4122 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4123 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4124 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
4125 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
4126 return;
4127 }
4128
4129 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4130 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4131
4132 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4133 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4134 image_create_info.format = VK_FORMAT_R8G8B8A8_UINT;
4135 image_create_info.extent = {32, 32, 4};
4136 image_create_info.mipLevels = 1;
4137 image_create_info.arrayLayers = 1;
4138 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4139 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4140 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4141
4142 VkImageObj image(m_device);
4143 image.Init(image_create_info);
4144 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
4145
4146 VkImageObj resolve_image(m_device);
4147 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4148 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4149
4150 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4151 color_attachment.imageView = image_view;
4152 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4153 color_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
4154 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
4155 color_attachment.resolveImageView = resolve_image_view;
4156
4157 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4158 begin_rendering_info.colorAttachmentCount = 1;
4159 begin_rendering_info.pColorAttachments = &color_attachment;
4160 begin_rendering_info.layerCount = 1;
4161
4162 m_commandBuffer->begin();
4163
4164 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06134");
4165 m_commandBuffer->BeginRendering(begin_rendering_info);
4166 m_errorMonitor->VerifyFound();
4167
4168 m_commandBuffer->end();
4169}
ziga-lunarge579a3b2022-04-23 11:38:02 +02004170
4171TEST_F(VkLayerTest, InvalidRenderingAttachmentImageViewLayout) {
4172 TEST_DESCRIPTION("Use rendering attachment image view with invalid layout");
4173
4174 SetTargetApiVersion(VK_API_VERSION_1_1);
4175 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4176 ASSERT_NO_FATAL_FAILURE(InitFramework());
4177
4178 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
4179 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
4180 return;
4181 }
4182 if (!AreRequestedExtensionsEnabled()) {
4183 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4184 return;
4185 }
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) {
4191 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
4192 return;
4193 }
4194
4195 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4196 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4197
4198 VkImageObj image(m_device);
4199 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4200 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4201
4202 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4203 color_attachment.imageView = image_view;
4204 color_attachment.imageLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
4205
4206 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4207 begin_rendering_info.colorAttachmentCount = 1;
4208 begin_rendering_info.pColorAttachments = &color_attachment;
4209 begin_rendering_info.layerCount = 1;
4210
4211 m_commandBuffer->begin();
4212
4213 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06135");
4214 m_commandBuffer->BeginRendering(begin_rendering_info);
4215 m_errorMonitor->VerifyFound();
4216
4217 m_commandBuffer->end();
4218}
ziga-lunarg409f8212022-04-23 11:40:53 +02004219
4220TEST_F(VkLayerTest, InvalidResolveImageViewLayout) {
4221 TEST_DESCRIPTION("Use resolve image view with invalid layout");
4222
4223 SetTargetApiVersion(VK_API_VERSION_1_1);
4224 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4225 ASSERT_NO_FATAL_FAILURE(InitFramework());
4226
4227 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
4228 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
4229 return;
4230 }
4231 if (!AreRequestedExtensionsEnabled()) {
4232 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4233 return;
4234 }
4235
4236 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4237 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4238 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4239 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
4240 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
4241 return;
4242 }
4243
4244 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4245 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4246
4247 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4248 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4249 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
4250 image_create_info.extent = {32, 32, 4};
4251 image_create_info.mipLevels = 1;
4252 image_create_info.arrayLayers = 1;
4253 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4254 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4255 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4256
4257 VkImageObj image(m_device);
4258 image.Init(image_create_info);
4259 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4260
4261 VkImageObj resolve_image(m_device);
4262 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4263 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4264
4265 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4266 color_attachment.imageView = image_view;
4267 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4268 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4269 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
4270 color_attachment.resolveImageView = resolve_image_view;
4271
4272 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4273 begin_rendering_info.colorAttachmentCount = 1;
4274 begin_rendering_info.pColorAttachments = &color_attachment;
4275 begin_rendering_info.layerCount = 1;
4276
4277 m_commandBuffer->begin();
4278
4279 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06136");
4280 m_commandBuffer->BeginRendering(begin_rendering_info);
4281 m_errorMonitor->VerifyFound();
4282
4283 m_commandBuffer->end();
4284}
ziga-lunargbbbef242022-04-23 12:12:10 +02004285
4286TEST_F(VkLayerTest, InvalidResolveImageViewLayoutSeparateDepthStencil) {
4287 TEST_DESCRIPTION("Use resolve image view with invalid layout");
4288
4289 SetTargetApiVersion(VK_API_VERSION_1_1);
4290 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4291 AddRequiredExtensions(VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_EXTENSION_NAME);
4292 ASSERT_NO_FATAL_FAILURE(InitFramework());
4293
4294 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
4295 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
4296 return;
4297 }
4298 if (!AreRequestedExtensionsEnabled()) {
4299 printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME,
4300 VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_EXTENSION_NAME);
4301 return;
4302 }
4303
4304 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4305 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4306 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4307 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
4308 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
4309 return;
4310 }
4311
4312 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4313 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4314
4315 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4316 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4317 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
4318 image_create_info.extent = {32, 32, 4};
4319 image_create_info.mipLevels = 1;
4320 image_create_info.arrayLayers = 1;
4321 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4322 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4323 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4324
4325 VkImageObj image(m_device);
4326 image.Init(image_create_info);
4327 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4328
4329 VkImageObj resolve_image(m_device);
4330 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4331 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4332
4333 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4334 color_attachment.imageView = image_view;
4335 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4336 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4337 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL;
4338 color_attachment.resolveImageView = resolve_image_view;
4339
4340 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4341 begin_rendering_info.colorAttachmentCount = 1;
4342 begin_rendering_info.pColorAttachments = &color_attachment;
4343 begin_rendering_info.layerCount = 1;
4344
4345 m_commandBuffer->begin();
4346
4347 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06137");
4348 m_commandBuffer->BeginRendering(begin_rendering_info);
4349 m_errorMonitor->VerifyFound();
4350
4351 m_commandBuffer->end();
4352}
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004353
4354TEST_F(VkLayerTest, InvalidRenderingAttachmentImageViewShadingRateLayout) {
4355 TEST_DESCRIPTION("Use image view with invalid layout");
4356
4357 SetTargetApiVersion(VK_API_VERSION_1_1);
4358 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4359 AddRequiredExtensions(VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME);
4360 ASSERT_NO_FATAL_FAILURE(InitFramework());
4361
4362 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
4363 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
4364 return;
4365 }
4366 if (!AreRequestedExtensionsEnabled()) {
4367 printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME,
4368 VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME);
4369 return;
4370 }
4371
4372 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4373 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4374 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4375 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
4376 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
4377 return;
4378 }
4379
4380 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4381 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4382
4383 VkImageObj image(m_device);
4384 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4385 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4386
4387 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4388 color_attachment.imageView = image_view;
4389 color_attachment.imageLayout = VK_IMAGE_LAYOUT_SHADING_RATE_OPTIMAL_NV;
4390
4391 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4392 begin_rendering_info.colorAttachmentCount = 1;
4393 begin_rendering_info.pColorAttachments = &color_attachment;
4394 begin_rendering_info.layerCount = 1;
4395
4396 m_commandBuffer->begin();
4397
4398 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06138");
4399 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06143");
4400 m_commandBuffer->BeginRendering(begin_rendering_info);
4401 m_errorMonitor->VerifyFound();
4402
4403 m_commandBuffer->end();
4404}
4405
4406TEST_F(VkLayerTest, InvalidResolveImageViewShadingRateLayout) {
4407 TEST_DESCRIPTION("Use resolve image view with invalid shading ratelayout");
4408
4409 SetTargetApiVersion(VK_API_VERSION_1_1);
4410 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4411 AddRequiredExtensions(VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME);
4412 ASSERT_NO_FATAL_FAILURE(InitFramework());
4413
4414 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
4415 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
4416 return;
4417 }
4418 if (!AreRequestedExtensionsEnabled()) {
4419 printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME,
4420 VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME);
4421 return;
4422 }
4423
4424 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4425 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4426 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4427 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
4428 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
4429 return;
4430 }
4431
4432 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4433 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4434
4435 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4436 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4437 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
4438 image_create_info.extent = {32, 32, 4};
4439 image_create_info.mipLevels = 1;
4440 image_create_info.arrayLayers = 1;
4441 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4442 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4443 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4444
4445 VkImageObj image(m_device);
4446 image.Init(image_create_info);
4447 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4448
4449 VkImageObj resolve_image(m_device);
4450 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4451 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4452
4453 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4454 color_attachment.imageView = image_view;
4455 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4456 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4457 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_SHADING_RATE_OPTIMAL_NV;
4458 color_attachment.resolveImageView = resolve_image_view;
4459
4460 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4461 begin_rendering_info.colorAttachmentCount = 1;
4462 begin_rendering_info.pColorAttachments = &color_attachment;
4463 begin_rendering_info.layerCount = 1;
4464
4465 m_commandBuffer->begin();
4466
4467 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06139");
4468 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06144");
4469 m_commandBuffer->BeginRendering(begin_rendering_info);
4470 m_errorMonitor->VerifyFound();
4471
4472 m_commandBuffer->end();
4473}
ziga-lunarge7503952022-04-23 12:19:14 +02004474
4475TEST_F(VkLayerTest, InvalidRenderingAttachmentImageViewFragmentDensityLayout) {
4476 TEST_DESCRIPTION("Use image view with invalid layout");
4477
4478 SetTargetApiVersion(VK_API_VERSION_1_1);
4479 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4480 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
4481 ASSERT_NO_FATAL_FAILURE(InitFramework());
4482
4483 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
4484 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
4485 return;
4486 }
4487 if (!AreRequestedExtensionsEnabled()) {
4488 printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME,
4489 VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
4490 return;
4491 }
4492
4493 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4494 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4495 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4496 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
4497 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
4498 return;
4499 }
4500
4501 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4502 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4503
4504 VkImageObj image(m_device);
4505 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4506 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4507
4508 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4509 color_attachment.imageView = image_view;
4510 color_attachment.imageLayout = VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT;
4511
4512 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4513 begin_rendering_info.colorAttachmentCount = 1;
4514 begin_rendering_info.pColorAttachments = &color_attachment;
4515 begin_rendering_info.layerCount = 1;
4516
4517 m_commandBuffer->begin();
4518
4519 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06140");
4520 m_commandBuffer->BeginRendering(begin_rendering_info);
4521 m_errorMonitor->VerifyFound();
4522
4523 m_commandBuffer->end();
ziga-lunarg10cd0fb2022-04-23 12:20:46 +02004524}
4525
4526TEST_F(VkLayerTest, InvalidResolveImageViewFragmentDensityLayout) {
4527 TEST_DESCRIPTION("Use resolve image view with invalid fragment density layout");
4528
4529 SetTargetApiVersion(VK_API_VERSION_1_1);
4530 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4531 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
4532 ASSERT_NO_FATAL_FAILURE(InitFramework());
4533
4534 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
4535 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
4536 return;
4537 }
4538 if (!AreRequestedExtensionsEnabled()) {
4539 printf("%s %s or %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME,
4540 VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
4541 return;
4542 }
4543
4544 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4545 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4546 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4547 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
4548 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
4549 return;
4550 }
4551
4552 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4553 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4554
4555 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4556 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4557 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
4558 image_create_info.extent = {32, 32, 4};
4559 image_create_info.mipLevels = 1;
4560 image_create_info.arrayLayers = 1;
4561 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4562 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4563 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4564
4565 VkImageObj image(m_device);
4566 image.Init(image_create_info);
4567 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4568
4569 VkImageObj resolve_image(m_device);
4570 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4571 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4572
4573 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4574 color_attachment.imageView = image_view;
4575 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4576 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4577 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT;
4578 color_attachment.resolveImageView = resolve_image_view;
4579
4580 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4581 begin_rendering_info.colorAttachmentCount = 1;
4582 begin_rendering_info.pColorAttachments = &color_attachment;
4583 begin_rendering_info.layerCount = 1;
4584
4585 m_commandBuffer->begin();
4586
4587 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06141");
4588 m_commandBuffer->BeginRendering(begin_rendering_info);
4589 m_errorMonitor->VerifyFound();
4590
4591 m_commandBuffer->end();
4592}
ziga-lunargdfa31d12022-04-23 12:22:18 +02004593
4594TEST_F(VkLayerTest, InvalidResolveImageViewReadOnlyOptimalLayout) {
4595 TEST_DESCRIPTION("Use resolve image view with invalid read only optimal layout");
4596
4597 SetTargetApiVersion(VK_API_VERSION_1_1);
4598 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4599 ASSERT_NO_FATAL_FAILURE(InitFramework());
4600
4601 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
4602 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
4603 return;
4604 }
4605 if (!AreRequestedExtensionsEnabled()) {
4606 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4607 return;
4608 }
4609
4610 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4611 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4612 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4613 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
4614 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
4615 return;
4616 }
4617
4618 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4619 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4620
4621 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4622 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4623 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
4624 image_create_info.extent = {32, 32, 4};
4625 image_create_info.mipLevels = 1;
4626 image_create_info.arrayLayers = 1;
4627 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4628 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4629 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4630
4631 VkImageObj image(m_device);
4632 image.Init(image_create_info);
4633 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4634
4635 VkImageObj resolve_image(m_device);
4636 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4637 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4638
4639 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4640 color_attachment.imageView = image_view;
4641 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4642 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4643 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL;
4644 color_attachment.resolveImageView = resolve_image_view;
4645
4646 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4647 begin_rendering_info.colorAttachmentCount = 1;
4648 begin_rendering_info.pColorAttachments = &color_attachment;
4649 begin_rendering_info.layerCount = 1;
4650
4651 m_commandBuffer->begin();
4652
4653 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06142");
4654 m_commandBuffer->BeginRendering(begin_rendering_info);
4655 m_errorMonitor->VerifyFound();
4656
4657 m_commandBuffer->end();
4658}
ziga-lunarg735aa322022-04-24 14:17:47 +02004659
4660TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRateImageView) {
4661 TEST_DESCRIPTION("Test BeginRenderingInfo image view with FragmentShadingRateAttachment.");
4662
4663 SetTargetApiVersion(VK_API_VERSION_1_1);
4664 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4665 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
4666
4667 ASSERT_NO_FATAL_FAILURE(InitFramework());
4668
4669 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
4670 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
4671 return;
4672 }
4673
4674 if (!AreRequestedExtensionsEnabled()) {
4675 printf("%s %s or %s not supported, skipping test\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME,
4676 VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
4677 return;
4678 }
4679
4680 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
4681 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4682 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4683
4684 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
4685 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
4686 return;
4687 }
4688
4689 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
4690
4691 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
4692 vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2);
4693
4694 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4695 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4696
4697 VkImageObj image(m_device);
4698 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
4699 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR,
4700 VK_IMAGE_TILING_LINEAR, 0);
4701 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4702
4703 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
4704 fragment_shading_rate.imageView = image_view;
4705 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4706 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
4707
4708 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
4709 begin_rendering_info.layerCount = 1;
4710
4711 m_commandBuffer->begin();
4712
4713 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06147");
4714 m_commandBuffer->BeginRendering(begin_rendering_info);
4715 m_errorMonitor->VerifyFound();
4716
4717 m_commandBuffer->end();
4718}
ziga-lunarg644c0552022-04-24 17:50:58 +02004719
4720TEST_F(VkLayerTest, TestRenderingInfoColorAttachment) {
4721 TEST_DESCRIPTION("Test RenderingInfo color attachment.");
4722
4723 SetTargetApiVersion(VK_API_VERSION_1_1);
4724 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4725
4726 ASSERT_NO_FATAL_FAILURE(InitFramework());
4727
4728 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
4729 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
4730 return;
4731 }
4732
4733 if (!AreRequestedExtensionsEnabled()) {
4734 printf("%s %s not supported, skipping test\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4735 return;
4736 }
4737
4738 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
4739 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4740 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4741
4742 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
4743 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
4744 return;
4745 }
4746
4747 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4748 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4749
4750 VkImageObj invalid_image(m_device);
4751 invalid_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_SAMPLED_BIT, VK_IMAGE_TILING_LINEAR, 0);
4752 VkImageView invalid_image_view = invalid_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4753
4754 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4755 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4756 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
4757 image_create_info.extent = {32, 32, 4};
4758 image_create_info.mipLevels = 1;
4759 image_create_info.arrayLayers = 1;
4760 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4761 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4762 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4763 image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
4764 VkImageObj image(m_device);
4765 image.Init(image_create_info);
4766 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4767
4768 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4769 color_attachment.imageView = invalid_image_view;
4770 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4771
4772 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4773 begin_rendering_info.layerCount = 1;
4774 begin_rendering_info.colorAttachmentCount = 1;
4775 begin_rendering_info.pColorAttachments = &color_attachment;
4776
4777 m_commandBuffer->begin();
4778
4779 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06087");
4780 m_commandBuffer->BeginRendering(begin_rendering_info);
4781 m_errorMonitor->VerifyFound();
4782
4783 color_attachment.imageView = image_view;
4784 color_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4785
4786 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06090");
4787 m_commandBuffer->BeginRendering(begin_rendering_info);
4788 m_errorMonitor->VerifyFound();
4789
4790 color_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
4791 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06096");
4792 m_commandBuffer->BeginRendering(begin_rendering_info);
4793 m_errorMonitor->VerifyFound();
4794
4795 color_attachment.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL;
4796 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06100");
4797 m_commandBuffer->BeginRendering(begin_rendering_info);
4798 m_errorMonitor->VerifyFound();
4799
4800 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4801 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4802 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4803
4804 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06091");
4805 m_commandBuffer->BeginRendering(begin_rendering_info);
4806 m_errorMonitor->VerifyFound();
4807
4808 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
4809 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06097");
4810 m_commandBuffer->BeginRendering(begin_rendering_info);
4811 m_errorMonitor->VerifyFound();
4812
4813 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
4814 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06101");
4815 m_commandBuffer->BeginRendering(begin_rendering_info);
4816 m_errorMonitor->VerifyFound();
4817
4818 color_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
4819
4820 const uint32_t max_color_attachments = m_device->phy().properties().limits.maxColorAttachments + 1;
4821 std::vector<VkRenderingAttachmentInfoKHR> color_attachments(max_color_attachments);
4822 for (auto &attachment : color_attachments) {
4823 attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4824 attachment.imageView = image_view;
4825 attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4826 }
4827 begin_rendering_info.colorAttachmentCount = max_color_attachments;
4828 begin_rendering_info.pColorAttachments = color_attachments.data();
4829 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06106");
4830 m_commandBuffer->BeginRendering(begin_rendering_info);
4831 m_errorMonitor->VerifyFound();
4832
4833 m_commandBuffer->end();
4834}
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004835
4836TEST_F(VkLayerTest, TestRenderingInfoDepthAttachment) {
4837 TEST_DESCRIPTION("Test RenderingInfo depth attachment.");
4838
4839 SetTargetApiVersion(VK_API_VERSION_1_1);
4840 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4841 AddRequiredExtensions(VK_KHR_DEPTH_STENCIL_RESOLVE_EXTENSION_NAME);
4842
4843 ASSERT_NO_FATAL_FAILURE(InitFramework());
4844
4845 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
4846 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
4847 return;
4848 }
4849
4850 if (!AreRequestedExtensionsEnabled()) {
4851 printf("%s %s or %s not supported, skipping test\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME,
4852 VK_KHR_DEPTH_STENCIL_RESOLVE_EXTENSION_NAME);
4853 return;
4854 }
4855
4856 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
4857 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4858 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4859
4860 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
4861 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
4862 return;
4863 }
4864
4865 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4866 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4867
4868 VkFormat ds_format = FindSupportedDepthStencilFormat(gpu());
4869 if (ds_format == VK_FORMAT_UNDEFINED) {
4870 printf("%s No Depth + Stencil format found, skipping test..\n", kSkipPrefix);
4871 return;
4872 }
4873
4874 auto depth_stencil_resolve_properties = LvlInitStruct<VkPhysicalDeviceDepthStencilResolveProperties>();
4875 auto properties2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&depth_stencil_resolve_properties);
4876 vk::GetPhysicalDeviceProperties2(gpu(), &properties2);
4877 bool has_depth_resolve_mode_average =
4878 (depth_stencil_resolve_properties.supportedDepthResolveModes & VK_RESOLVE_MODE_AVERAGE_BIT) != 0;
4879 bool has_stencil_resolve_mode_average =
4880 (depth_stencil_resolve_properties.supportedStencilResolveModes & VK_RESOLVE_MODE_AVERAGE_BIT) != 0;
4881
4882 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4883 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4884 image_create_info.format = ds_format;
4885 image_create_info.extent = {32, 32, 1};
4886 image_create_info.mipLevels = 1;
4887 image_create_info.arrayLayers = 1;
4888 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4889 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4890 image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
4891 VkImageObj image(m_device);
4892 image.Init(image_create_info);
4893
4894 VkImageObj depth_image(m_device);
4895 depth_image.Init(image_create_info);
4896 VkImageView depth_image_view = depth_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4897 VkImageObj stencil_image(m_device);
4898 stencil_image.Init(image_create_info);
4899 VkImageView stencil_image_view = stencil_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4900
4901 VkImageObj depth_resolvel_image(m_device);
4902 depth_resolvel_image.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0);
4903 VkImageView depth_resolve_image_view =
4904 depth_resolvel_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4905
4906 VkImageObj stencil_resolvel_image(m_device);
4907 stencil_resolvel_image.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0);
4908 VkImageView stencil_resolve_image_view =
4909 stencil_resolvel_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4910
4911 VkImageObj invalid_image(m_device);
4912 image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
4913 invalid_image.Init(image_create_info);
4914 VkImageView invalid_image_view = invalid_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT);
4915
4916 auto depth_attachment = LvlInitStruct<VkRenderingAttachmentInfo>();
4917 depth_attachment.imageView = depth_image_view;
4918 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4919
4920 auto stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfo>();
4921 stencil_attachment.imageView = stencil_image_view;
4922 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4923
4924 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4925 begin_rendering_info.layerCount = 1;
4926 begin_rendering_info.pDepthAttachment = &depth_attachment;
4927 begin_rendering_info.pStencilAttachment = &stencil_attachment;
4928
4929 m_commandBuffer->begin();
4930
4931 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06085");
4932 m_commandBuffer->BeginRendering(begin_rendering_info);
4933 m_errorMonitor->VerifyFound();
4934
4935 depth_attachment.imageView = VK_NULL_HANDLE;
4936 stencil_attachment.imageView = VK_NULL_HANDLE;
4937 depth_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4938 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4939 depth_attachment.resolveImageView = depth_resolve_image_view;
4940 stencil_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4941 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4942 stencil_attachment.resolveImageView = stencil_resolve_image_view;
4943
4944 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06086");
4945 m_commandBuffer->BeginRendering(begin_rendering_info);
4946 m_errorMonitor->VerifyFound();
4947
4948 depth_attachment.imageView = depth_image_view;
4949 stencil_attachment.imageView = depth_image_view;
4950 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4951 stencil_attachment.resolveImageView = depth_resolve_image_view;
4952
4953 if (!has_depth_resolve_mode_average) {
4954 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06102");
4955 }
4956 if (!has_stencil_resolve_mode_average) {
4957 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06103");
4958 }
4959 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06093");
4960 m_commandBuffer->BeginRendering(begin_rendering_info);
4961 m_errorMonitor->VerifyFound();
4962
4963 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
4964 if (has_depth_resolve_mode_average && has_stencil_resolve_mode_average) {
4965 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06098");
4966 m_commandBuffer->BeginRendering(begin_rendering_info);
4967 m_errorMonitor->VerifyFound();
4968 }
4969
4970 depth_attachment.imageView = invalid_image_view;
4971 stencil_attachment.imageView = invalid_image_view;
4972 depth_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
4973 stencil_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
4974 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06088");
4975 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06089");
4976 m_commandBuffer->BeginRendering(begin_rendering_info);
4977 m_errorMonitor->VerifyFound();
4978
4979 depth_attachment.imageView = depth_image_view;
4980 stencil_attachment.imageView = depth_image_view;
4981 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4982 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06092");
4983 m_commandBuffer->BeginRendering(begin_rendering_info);
4984 m_errorMonitor->VerifyFound();
4985
4986 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4987 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4988 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4989 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4990 depth_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4991 if (depth_stencil_resolve_properties.independentResolveNone == VK_FALSE && has_depth_resolve_mode_average) {
4992 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06104");
4993 m_commandBuffer->BeginRendering(begin_rendering_info);
4994 m_errorMonitor->VerifyFound();
4995 }
4996 if (depth_stencil_resolve_properties.independentResolve == VK_FALSE && has_depth_resolve_mode_average) {
4997 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06105");
4998 m_commandBuffer->BeginRendering(begin_rendering_info);
4999 m_errorMonitor->VerifyFound();
5000 }
5001
ziga-lunargf35a7d72022-04-25 01:00:41 +02005002 stencil_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
5003 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
5004 if (has_stencil_resolve_mode_average) {
5005 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06095");
5006 m_commandBuffer->BeginRendering(begin_rendering_info);
5007 m_errorMonitor->VerifyFound();
5008 }
5009 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL;
5010 if (has_stencil_resolve_mode_average) {
5011 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06099");
5012 m_commandBuffer->BeginRendering(begin_rendering_info);
5013 m_errorMonitor->VerifyFound();
5014 }
5015
5016 depth_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
5017 stencil_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
5018 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
5019 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06094");
5020 m_commandBuffer->BeginRendering(begin_rendering_info);
5021 m_errorMonitor->VerifyFound();
5022
ziga-lunarg7a69bd92022-04-25 00:33:18 +02005023 m_commandBuffer->end();
5024}
ziga-lunarg002e6562022-04-25 00:54:16 +02005025
5026TEST_F(VkLayerTest, InvalidRenderingRenderAreaWithDeviceGroupExt) {
5027 TEST_DESCRIPTION("Use negative offset in RenderingInfo render area");
5028
5029 SetTargetApiVersion(VK_API_VERSION_1_1);
5030 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
5031 ASSERT_NO_FATAL_FAILURE(InitFramework());
5032
5033 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
5034 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
5035 return;
5036 }
5037 if (!AreRequestedExtensionsEnabled()) {
5038 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
5039 return;
5040 }
5041
5042 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
5043 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
5044 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
5045 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
5046 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
5047 return;
5048 }
5049
5050 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
5051 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
5052
5053 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
5054 begin_rendering_info.layerCount = 1;
5055 begin_rendering_info.renderArea.offset.x = -1;
5056 begin_rendering_info.renderArea.extent.width = 32;
5057 begin_rendering_info.renderArea.extent.height = 32;
5058
5059 m_commandBuffer->begin();
5060
5061 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06077");
5062 m_commandBuffer->BeginRendering(begin_rendering_info);
5063 m_errorMonitor->VerifyFound();
5064
5065 begin_rendering_info.renderArea.offset.x = 0;
5066 begin_rendering_info.renderArea.offset.y = -1;
5067
5068 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06078");
5069 m_commandBuffer->BeginRendering(begin_rendering_info);
5070 m_errorMonitor->VerifyFound();
5071
5072 m_commandBuffer->end();
5073}
ziga-lunarg6e4f9da2022-04-25 01:05:22 +02005074
5075TEST_F(VkLayerTest, TestDynamicRenderingPipeline) {
5076 TEST_DESCRIPTION("Use pipeline created with render pass in dynamic render pass.");
5077
5078 SetTargetApiVersion(VK_API_VERSION_1_1);
5079 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
5080
5081 ASSERT_NO_FATAL_FAILURE(InitFramework());
5082
5083 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
5084 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
5085 return;
5086 }
5087
5088 if (!AreRequestedExtensionsEnabled()) {
5089 printf("%s %s not supported, skipping test\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
5090 return;
5091 }
5092
5093 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
5094 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
5095 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
5096
5097 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
5098 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
5099 return;
5100 }
5101
5102 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
5103 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
5104
5105 CreatePipelineHelper pipe(*this);
5106 pipe.InitInfo();
5107 pipe.InitState();
5108 pipe.CreateGraphicsPipeline();
5109
5110 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
5111 begin_rendering_info.layerCount = 1;
5112
5113 m_commandBuffer->begin();
5114 m_commandBuffer->BeginRendering(begin_rendering_info);
5115
5116 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_);
5117 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-renderPass-06198");
5118 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
5119 m_errorMonitor->VerifyFound();
5120
5121 m_commandBuffer->EndRendering();
5122 m_commandBuffer->end();
5123}