blob: 6637ab0cba295b67b775a989cbdd5fc353c528d9 [file] [log] [blame]
Aaron Haganaca50442021-12-07 22:26:29 -05001/*
stusmith15f24a82021-12-24 15:21:19 +00002 * Copyright (c) 2015-2022 The Khronos Group Inc.
3 * Copyright (c) 2015-2022 Valve Corporation
4 * Copyright (c) 2015-2022 LunarG, Inc.
5 * Copyright (c) 2015-2022 Google, Inc.
6 * Modifications Copyright (C) 2020-2022 Advanced Micro Devices, Inc. All rights reserved.
Tony-LunarG4c253372022-01-18 13:51:07 -07007 * Modifications Copyright (C) 2021-2022 ARM, Inc. All rights reserved.
Aaron Haganaca50442021-12-07 22:26:29 -05008 *
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 */
16
17#include "cast_utils.h"
18#include "layer_validation_tests.h"
19
Aaron Haganb54466d2022-02-18 15:02:54 -050020TEST_F(VkLayerTest, DynamicRenderingCommandBufferInheritanceRenderingInfo) {
Aaron Haganaca50442021-12-07 22:26:29 -050021 TEST_DESCRIPTION("VkCommandBufferInheritanceRenderingInfoKHR Dynamic Rendering Tests.");
22
23 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2);
24 if (version < VK_API_VERSION_1_2) {
25 printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix);
26 return;
27 }
sfricke-samsungae54c1e2022-01-21 05:35:21 -080028
Aaron Haganaca50442021-12-07 22:26:29 -050029 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
Nathaniel Cesarioa06135e2022-03-02 21:22:30 -070030 ASSERT_NO_FATAL_FAILURE(InitFramework());
Aaron Haganaca50442021-12-07 22:26:29 -050031
sjfricked700bc02022-05-30 16:35:06 +090032 if (!AreRequiredExtensionsEnabled()) {
33 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
Aaron Haganb54466d2022-02-18 15:02:54 -050034 }
35
Aaron Haganaca50442021-12-07 22:26:29 -050036 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
sjfrickebdd58dd2022-05-20 14:22:50 +090037 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
Aaron Haganaca50442021-12-07 22:26:29 -050038 }
sfricke-samsungae54c1e2022-01-21 05:35:21 -080039
Nathaniel Cesarioa06135e2022-03-02 21:22:30 -070040 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
41 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
42 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
43 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +090044 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
Aaron Haganaca50442021-12-07 22:26:29 -050045 }
46
ziga-lunargf54cb2a2022-03-11 02:54:27 +010047 features2.features.variableMultisampleRate = VK_FALSE;
48
Nathaniel Cesarioa06135e2022-03-02 21:22:30 -070049 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
50
Aaron Haganaca50442021-12-07 22:26:29 -050051 VkPhysicalDeviceMultiviewProperties multiview_props = LvlInitStruct<VkPhysicalDeviceMultiviewProperties>();
52 VkPhysicalDeviceProperties2 pd_props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&multiview_props);
53 vk::GetPhysicalDeviceProperties2(gpu(), &pd_props2);
54
55 if (multiview_props.maxMultiviewViewCount == 32) {
56 printf("%s VUID is not testable as maxMultiviewViewCount is 32, skipping test\n", kSkipPrefix);
57 return;
58 }
59
60 VkFormat color_format = VK_FORMAT_D32_SFLOAT;
61
62 auto cmd_buffer_inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>();
63 cmd_buffer_inheritance_rendering_info.colorAttachmentCount = 1;
64 cmd_buffer_inheritance_rendering_info.pColorAttachmentFormats = &color_format;
65 cmd_buffer_inheritance_rendering_info.depthAttachmentFormat = VK_FORMAT_R8G8B8_UNORM;
66 cmd_buffer_inheritance_rendering_info.stencilAttachmentFormat = VK_FORMAT_R8G8B8_SNORM;
67 cmd_buffer_inheritance_rendering_info.viewMask = 1 << multiview_props.maxMultiviewViewCount;
68
69 auto sample_count_info_amd = LvlInitStruct<VkAttachmentSampleCountInfoAMD>();
70 sample_count_info_amd.pNext = &cmd_buffer_inheritance_rendering_info;
71 sample_count_info_amd.colorAttachmentCount = 2;
sfricke-samsungae54c1e2022-01-21 05:35:21 -080072
Aaron Haganaca50442021-12-07 22:26:29 -050073 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
74 cmd_buffer_inheritance_info.pNext = &sample_count_info_amd;
75
76 auto cmd_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>();
77 cmd_buffer_allocate_info.commandPool = m_commandPool->handle();
78 cmd_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY;
79 cmd_buffer_allocate_info.commandBufferCount = 0x1;
80
81 VkCommandBuffer secondary_cmd_buffer;
82 VkResult err = vk::AllocateCommandBuffers(m_device->device(), &cmd_buffer_allocate_info, &secondary_cmd_buffer);
83 ASSERT_VK_SUCCESS(err);
84 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06003");
Tony-LunarGbbd2ab92021-12-02 08:31:24 -070085 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-colorAttachmentCount-06004");
86 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-variableMultisampleRate-06005");
87 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-depthAttachmentFormat-06007");
88 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-multiview-06008");
89 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-viewMask-06009");
ziga-lunarg813fa012022-04-09 14:09:57 +020090 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-stencilAttachmentFormat-06199");
91 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-depthAttachmentFormat-06200");
92 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-pColorAttachmentFormats-06006");
93 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-depthAttachmentFormat-06540");
ziga-lunarga3cc8482022-04-29 14:58:29 +020094 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-stencilAttachmentFormat-06541");
Aaron Haganaca50442021-12-07 22:26:29 -050095
96 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
97 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
98 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
99 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
100 m_errorMonitor->VerifyFound();
101}
102
Aaron Haganb54466d2022-02-18 15:02:54 -0500103TEST_F(VkLayerTest, DynamicRenderingCommandDraw) {
Aaron Haganaca50442021-12-07 22:26:29 -0500104 TEST_DESCRIPTION("vkCmdDraw* Dynamic Rendering Tests.");
105
106 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2);
107 if (version < VK_API_VERSION_1_2) {
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600108 GTEST_SKIP() << "At least Vulkan version 1.2 is required, skipping test.";
Aaron Haganaca50442021-12-07 22:26:29 -0500109 }
110
111 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
112
113 ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor));
114
115 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900116 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
Aaron Haganaca50442021-12-07 22:26:29 -0500117 }
118
sjfricked700bc02022-05-30 16:35:06 +0900119 if (!AreRequiredExtensionsEnabled()) {
120 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
Aaron Haganaca50442021-12-07 22:26:29 -0500121 }
122
123 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
124 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
125 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
126 if (!dynamic_rendering_features.dynamicRendering) {
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600127 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering , skipping.";
Aaron Haganaca50442021-12-07 22:26:29 -0500128 }
129
130 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
131
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800132 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
133 VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT);
Aaron Haganaca50442021-12-07 22:26:29 -0500134
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600135 auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
136
Aaron Haganaca50442021-12-07 22:26:29 -0500137 VkPipelineObj pipe(m_device);
138 pipe.AddShader(&vs);
139 pipe.AddShader(&fs);
140 pipe.AddDefaultColorAttachment();
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600141 pipe.SetDepthStencil(&ds_state);
Aaron Haganaca50442021-12-07 22:26:29 -0500142
143 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
144 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
145 const VkPipelineLayoutObj pl(m_device, {&dsl});
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800146
Aaron Haganaca50442021-12-07 22:26:29 -0500147 VkFormat depth_format = VK_FORMAT_D32_SFLOAT_S8_UINT;
148 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
Aaron Hagan80034ea2021-12-23 11:24:09 -0500149 pipeline_rendering_info.depthAttachmentFormat = depth_format;
150 pipeline_rendering_info.stencilAttachmentFormat = depth_format;
Aaron Haganaca50442021-12-07 22:26:29 -0500151
152 auto multisample_state_create_info = LvlInitStruct<VkPipelineMultisampleStateCreateInfo>();
153 multisample_state_create_info.rasterizationSamples = VK_SAMPLE_COUNT_2_BIT;
154
155 auto create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
156 pipe.InitGraphicsPipelineCreateInfo(&create_info);
157 create_info.pMultisampleState = &multisample_state_create_info;
158 create_info.renderPass = VkRenderPass(0x1);
159 create_info.pNext = &pipeline_rendering_info;
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800160
Aaron Haganaca50442021-12-07 22:26:29 -0500161 VkResult err = pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
162 ASSERT_VK_SUCCESS(err);
163
164 VkViewport viewport = {0, 0, 16, 16, 0, 1};
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800165 VkRect2D scissor = {{0, 0}, {16, 16}};
Aaron Haganaca50442021-12-07 22:26:29 -0500166
167 VkImageObj image(m_device);
168 image.Init(32, 32, 1, depth_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
169 ASSERT_TRUE(image.initialized());
170
171 VkImageViewCreateInfo ivci = {VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
172 nullptr,
173 0,
174 image.handle(),
175 VK_IMAGE_VIEW_TYPE_2D,
176 depth_format,
177 {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
178 VK_COMPONENT_SWIZZLE_IDENTITY},
179 {VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, 0, 1, 0, 1}};
180
paul-lunarg18e16342022-07-12 14:02:23 -0600181 vk_testing::ImageView depth_image_view(*m_device, ivci);
Aaron Haganaca50442021-12-07 22:26:29 -0500182
183 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
184 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
paul-lunarg18e16342022-07-12 14:02:23 -0600185 depth_attachment.imageView = depth_image_view.handle();
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800186
Aaron Haganaca50442021-12-07 22:26:29 -0500187 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
188 begin_rendering_info.pDepthAttachment = &depth_attachment;
189 begin_rendering_info.pStencilAttachment = &depth_attachment;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600190 begin_rendering_info.layerCount = 1;
Aaron Haganaca50442021-12-07 22:26:29 -0500191
192 m_commandBuffer->begin();
193 m_commandBuffer->BeginRendering(begin_rendering_info);
194 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle());
195 vk::CmdSetViewport(m_commandBuffer->handle(), 0, 1, &viewport);
196 vk::CmdSetScissor(m_commandBuffer->handle(), 0, 1, &scissor);
197 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06189");
198 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06190");
199 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
200 m_errorMonitor->VerifyFound();
201 m_commandBuffer->EndRendering();
202 m_commandBuffer->end();
203}
204
205TEST_F(VkLayerTest, DynamicRenderingGraphicsPipelineCreateInfo) {
206 TEST_DESCRIPTION("Test graphics pipeline creation with dynamic rendering.");
Nathaniel Cesario72f29552022-03-24 05:11:11 -0600207 m_errorMonitor->ExpectSuccess();
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800208
Aaron Haganaca50442021-12-07 22:26:29 -0500209 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2);
210 if (version < VK_API_VERSION_1_2) {
211 printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix);
212 return;
213 }
214
215 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
216
217 ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor));
218
219 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900220 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
Aaron Haganaca50442021-12-07 22:26:29 -0500221 }
222
sjfricked700bc02022-05-30 16:35:06 +0900223 if (!AreRequiredExtensionsEnabled()) {
224 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
Aaron Haganaca50442021-12-07 22:26:29 -0500225 }
226
227 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
228 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
229 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
230 if (!dynamic_rendering_features.dynamicRendering) {
231 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
232 return;
233 }
234
235 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
236
237 const VkPipelineLayoutObj pl(m_device);
238 VkPipelineObj pipe(m_device);
239
240 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
241
242 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
243 color_blend_state_create_info.attachmentCount = 1;
244 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
245
246 VkFormat color_format[2] = {VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_D32_SFLOAT_S8_UINT};
247
248 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
249 pipeline_rendering_info.colorAttachmentCount = 2;
250 pipeline_rendering_info.pColorAttachmentFormats = &color_format[0];
251 pipeline_rendering_info.viewMask = 0x2;
Aaron Hagan80034ea2021-12-23 11:24:09 -0500252 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
Aaron Haganaca50442021-12-07 22:26:29 -0500253
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800254 auto pipeline_tessellation_state_info = LvlInitStruct<VkPipelineTessellationStateCreateInfo>();
Aaron Haganaca50442021-12-07 22:26:29 -0500255 pipeline_tessellation_state_info.patchControlPoints = 1;
256
257 auto pipeline_input_assembly_state_info = LvlInitStruct<VkPipelineInputAssemblyStateCreateInfo>();
258 pipeline_input_assembly_state_info.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST;
259
260 auto create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
Aaron Hagan80034ea2021-12-23 11:24:09 -0500261
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800262 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
263 VkShaderObj gs(this, bindStateGeomShaderText, VK_SHADER_STAGE_GEOMETRY_BIT);
264 VkShaderObj te(this, bindStateTeshaderText, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT);
265 VkShaderObj tc(this, bindStateTscShaderText, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT);
Aaron Hagan80034ea2021-12-23 11:24:09 -0500266 VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT);
267
Aaron Haganaca50442021-12-07 22:26:29 -0500268 pipe.AddShader(&vs);
269 pipe.AddShader(&gs);
270 pipe.AddShader(&te);
271 pipe.AddShader(&tc);
Aaron Hagan80034ea2021-12-23 11:24:09 -0500272 pipe.AddShader(&fs);
Aaron Haganaca50442021-12-07 22:26:29 -0500273 pipe.InitGraphicsPipelineCreateInfo(&create_info);
Nathaniel Cesario72f29552022-03-24 05:11:11 -0600274 m_errorMonitor->VerifyNotFound();
275
Aaron Haganaca50442021-12-07 22:26:29 -0500276 create_info.pColorBlendState = &color_blend_state_create_info;
277 create_info.pNext = &pipeline_rendering_info;
278 create_info.pTessellationState = &pipeline_tessellation_state_info;
279 create_info.pInputAssemblyState = &pipeline_input_assembly_state_info;
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800280
Aaron Hagan80034ea2021-12-23 11:24:09 -0500281 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06053");
Nathaniel Cesario72f29552022-03-24 05:11:11 -0600282 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06581");
Aaron Haganaca50442021-12-07 22:26:29 -0500283 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06055");
284 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06057");
285 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06058");
Nathaniel Cesarioa6118572022-03-24 04:48:33 -0600286 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-multiview-06577");
Aaron Haganaca50442021-12-07 22:26:29 -0500287 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
288 m_errorMonitor->VerifyFound();
289
Aaron Hagan80034ea2021-12-23 11:24:09 -0500290 create_info.pColorBlendState = nullptr;
291 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
292 pipeline_rendering_info.viewMask = 0x0;
293 pipeline_rendering_info.colorAttachmentCount = 1;
294 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06054");
295 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
296 m_errorMonitor->VerifyFound();
Aaron Haganb54466d2022-02-18 15:02:54 -0500297
ziga-lunarg5e671602022-03-17 19:06:55 +0100298 color_format[0] = VK_FORMAT_D32_SFLOAT_S8_UINT;
299 color_blend_attachment_state.blendEnable = VK_TRUE;
300 create_info.pColorBlendState = &color_blend_state_create_info;
Nathaniel Cesario72f29552022-03-24 05:11:11 -0600301 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06581");
ziga-lunarg5e671602022-03-17 19:06:55 +0100302 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06062");
ziga-lunarg5e671602022-03-17 19:06:55 +0100303 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
304 m_errorMonitor->VerifyFound();
305 color_format[0] = VK_FORMAT_R8G8B8A8_UNORM;
306
Aaron Haganb54466d2022-02-18 15:02:54 -0500307 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
308 ds_ci.flags = VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM;
309 color_blend_state_create_info.flags = VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM;
310 create_info.pColorBlendState = &color_blend_state_create_info;
311 create_info.pDepthStencilState = &ds_ci;
312 create_info.renderPass = VK_NULL_HANDLE;
313 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
314 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06482");
315 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06483");
316 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
317 m_errorMonitor->VerifyFound();
stusmith15f24a82021-12-24 15:21:19 +0000318}
319
320TEST_F(VkLayerTest, DynamicRenderingWithMismatchingViewMask) {
321 TEST_DESCRIPTION("Draw with Dynamic Rendering and a mismatching viewMask");
322
323 SetTargetApiVersion(VK_API_VERSION_1_1);
324
325 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
326
327 ASSERT_NO_FATAL_FAILURE(InitFramework());
328
sjfricked700bc02022-05-30 16:35:06 +0900329 if (!AreRequiredExtensionsEnabled()) {
330 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
stusmith15f24a82021-12-24 15:21:19 +0000331 }
332
333 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900334 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
stusmith15f24a82021-12-24 15:21:19 +0000335 }
336
337 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
338 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(&multiview_features);
339 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
340 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
341 if (!dynamic_rendering_features.dynamicRendering) {
342 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
343 return;
344 }
345 if (!multiview_features.multiview) {
346 printf("%s Test requires (unsupported) multiview , skipping\n", kSkipPrefix);
347 return;
348 }
349
350 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
351
352 char const *fsSource = R"glsl(
353 #version 450
354 layout(location=0) out vec4 color;
355 void main() {
356 color = vec4(1.0f);
357 }
358 )glsl";
359
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800360 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
361 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000362
363 VkPipelineObj pipe(m_device);
364 pipe.AddShader(&vs);
365 pipe.AddShader(&fs);
366 pipe.AddDefaultColorAttachment();
367
368 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
369 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
370 const VkPipelineLayoutObj pl(m_device, {&dsl});
371
372 VkFormat color_formats = {VK_FORMAT_R8G8B8A8_UNORM};
373 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
374 pipeline_rendering_info.colorAttachmentCount = 1;
375 pipeline_rendering_info.pColorAttachmentFormats = &color_formats;
376 pipeline_rendering_info.viewMask = 1;
377
378 VkViewport viewport = {0, 0, 16, 16, 0, 1};
379 VkRect2D scissor = {{0, 0}, {16, 16}};
380 m_viewports.push_back(viewport);
381 m_scissors.push_back(scissor);
382 pipe.SetViewport(m_viewports);
383 pipe.SetScissor(m_scissors);
384
385 auto create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
386 pipe.InitGraphicsPipelineCreateInfo(&create_info);
387 create_info.pNext = &pipeline_rendering_info;
388
389 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
390
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800391 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000392 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
393
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800394 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000395 begin_rendering_info.colorAttachmentCount = 1;
396 begin_rendering_info.pColorAttachments = &color_attachment;
397 begin_rendering_info.viewMask = 2;
398 begin_rendering_info.layerCount = 1;
399
400 m_commandBuffer->begin();
401 m_commandBuffer->BeginRendering(begin_rendering_info);
402 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle());
403 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-viewMask-06178");
404 m_commandBuffer->Draw(1, 1, 0, 0);
405 m_errorMonitor->VerifyFound();
406 m_commandBuffer->EndRendering();
407 m_commandBuffer->end();
408}
409
410TEST_F(VkLayerTest, DynamicRenderingWithMistmatchingAttachments) {
411 TEST_DESCRIPTION("Draw with Dynamic Rendering with mismatching color attachment counts and depth/stencil formats");
412
413 SetTargetApiVersion(VK_API_VERSION_1_1);
414
415 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
416
417 ASSERT_NO_FATAL_FAILURE(InitFramework());
418
sjfricked700bc02022-05-30 16:35:06 +0900419 if (!AreRequiredExtensionsEnabled()) {
420 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
stusmith15f24a82021-12-24 15:21:19 +0000421 }
422
423 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900424 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
stusmith15f24a82021-12-24 15:21:19 +0000425 }
426
427 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
428 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
429 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
430 if (!dynamic_rendering_features.dynamicRendering) {
431 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
432 return;
433 }
434
435 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
436
437 char const *fsSource = R"glsl(
438 #version 450
439 layout(location=0) out vec4 color;
440 void main() {
441 color = vec4(1.0f);
442 }
443 )glsl";
444
445 VkViewport viewport = {0, 0, 16, 16, 0, 1};
446 VkRect2D scissor = {{0, 0}, {16, 16}};
447 m_viewports.push_back(viewport);
448 m_scissors.push_back(scissor);
449
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800450 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
451 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000452
453 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
454 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
455 const VkPipelineLayoutObj pl(m_device, {&dsl});
456
457 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
458
459 VkPipelineObj pipe1(m_device);
460 pipe1.AddShader(&vs);
461 pipe1.AddShader(&fs);
462 pipe1.AddDefaultColorAttachment();
463 pipe1.SetViewport(m_viewports);
464 pipe1.SetScissor(m_scissors);
465
466 VkFormat color_formats[] = {VK_FORMAT_R8G8B8A8_UNORM};
467 pipeline_rendering_info.colorAttachmentCount = 1;
468 pipeline_rendering_info.pColorAttachmentFormats = color_formats;
469
470 auto create_info1 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
471 pipe1.InitGraphicsPipelineCreateInfo(&create_info1);
472 create_info1.pNext = &pipeline_rendering_info;
473
474 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
475
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600476 auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
477
stusmith15f24a82021-12-24 15:21:19 +0000478 VkPipelineObj pipe2(m_device);
479 pipe2.AddShader(&vs);
480 pipe2.AddShader(&fs);
481 pipe2.AddDefaultColorAttachment();
482 pipe2.SetViewport(m_viewports);
483 pipe2.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600484 pipe2.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000485
486 pipeline_rendering_info.colorAttachmentCount = 0;
487 pipeline_rendering_info.pColorAttachmentFormats = nullptr;
488 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_D16_UNORM;
489
490 auto create_info2 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
491 pipe2.InitGraphicsPipelineCreateInfo(&create_info2);
492 create_info2.pNext = &pipeline_rendering_info;
493
494 pipe2.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info2);
495
496 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
497 ASSERT_TRUE(depthStencilFormat != 0);
498
499 bool testStencil = false;
500 VkFormat stencilFormat = VK_FORMAT_UNDEFINED;
501
502 if (ImageFormatIsSupported(gpu(), VK_FORMAT_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
503 stencilFormat = VK_FORMAT_S8_UINT;
504 testStencil = true;
505 } else if ((depthStencilFormat != VK_FORMAT_D16_UNORM_S8_UINT) &&
506 ImageFormatIsSupported(gpu(), VK_FORMAT_D16_UNORM_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
507 stencilFormat = VK_FORMAT_D16_UNORM_S8_UINT;
508 testStencil = true;
509 } else if ((depthStencilFormat != VK_FORMAT_D24_UNORM_S8_UINT) &&
510 ImageFormatIsSupported(gpu(), VK_FORMAT_D24_UNORM_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
511 stencilFormat = VK_FORMAT_D24_UNORM_S8_UINT;
512 testStencil = true;
513 } else if ((depthStencilFormat != VK_FORMAT_D32_SFLOAT_S8_UINT) &&
514 ImageFormatIsSupported(gpu(), VK_FORMAT_D32_SFLOAT_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
515 stencilFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
516 testStencil = true;
517 }
518
519 VkPipelineObj pipe3(m_device);
520
521 if (testStencil) {
522 pipe3.AddShader(&vs);
523 pipe3.AddShader(&fs);
524 pipe3.AddDefaultColorAttachment();
525 pipe3.SetViewport(m_viewports);
526 pipe3.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600527 pipe3.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000528
529 pipeline_rendering_info.colorAttachmentCount = 0;
530 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
531 pipeline_rendering_info.stencilAttachmentFormat = stencilFormat;
532
533 auto create_info3 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
534 pipe3.InitGraphicsPipelineCreateInfo(&create_info3);
535 create_info3.pNext = &pipeline_rendering_info;
536
537 pipe3.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info3);
538 }
539
540 VkImageObj colorImage(m_device);
541 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
542 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
543
544 VkImageObj depthStencilImage(m_device);
545 depthStencilImage.Init(32, 32, 1, depthStencilFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
546 VkImageView depthStencilImageView =
547 depthStencilImage.targetView(depthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
548
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800549 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000550 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
551 color_attachment.imageView = colorImageView;
552
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800553 VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000554 depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
555 depth_stencil_attachment.imageView = depthStencilImageView;
556
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800557 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600558 begin_rendering_info.layerCount = 1;
stusmith15f24a82021-12-24 15:21:19 +0000559 m_commandBuffer->begin();
560
561 // Mismatching color attachment count
562 m_commandBuffer->BeginRendering(begin_rendering_info);
563 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
564 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06179");
565 m_commandBuffer->Draw(1, 1, 0, 0);
566 m_errorMonitor->VerifyFound();
567 m_commandBuffer->EndRendering();
568
569 // Mismatching color formats
570 begin_rendering_info.colorAttachmentCount = 1;
571 begin_rendering_info.pColorAttachments = &color_attachment;
572 m_commandBuffer->BeginRendering(begin_rendering_info);
573 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
574 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06180");
575 m_commandBuffer->Draw(1, 1, 0, 0);
576 m_errorMonitor->VerifyFound();
577 m_commandBuffer->EndRendering();
578
579 // Mismatching depth format
580 begin_rendering_info.colorAttachmentCount = 0;
581 begin_rendering_info.pColorAttachments = nullptr;
582 begin_rendering_info.pDepthAttachment = &depth_stencil_attachment;
583 m_commandBuffer->BeginRendering(begin_rendering_info);
584 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.handle());
585 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06181");
586 m_commandBuffer->Draw(1, 1, 0, 0);
587 m_errorMonitor->VerifyFound();
588 m_commandBuffer->EndRendering();
589
590 // Mismatching stencil format
591 if (testStencil) {
592 begin_rendering_info.pDepthAttachment = nullptr;
593 begin_rendering_info.pStencilAttachment = &depth_stencil_attachment;
594 m_commandBuffer->BeginRendering(begin_rendering_info);
595 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe3.handle());
596 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06182");
597 m_commandBuffer->Draw(1, 1, 0, 0);
598 m_errorMonitor->VerifyFound();
599 m_commandBuffer->EndRendering();
600 }
601
602 m_commandBuffer->end();
603}
604
605TEST_F(VkLayerTest, DynamicRenderingWithMistmatchingAttachmentSamples) {
606 TEST_DESCRIPTION("Draw with Dynamic Rendering with mismatching color/depth/stencil sample counts");
607
608 SetTargetApiVersion(VK_API_VERSION_1_1);
609
610 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
611
612 ASSERT_NO_FATAL_FAILURE(InitFramework());
613
sjfricked700bc02022-05-30 16:35:06 +0900614 if (!AreRequiredExtensionsEnabled()) {
615 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
stusmith15f24a82021-12-24 15:21:19 +0000616 }
617
618 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900619 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
stusmith15f24a82021-12-24 15:21:19 +0000620 }
621
622 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
623 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
624 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
625 if (!dynamic_rendering_features.dynamicRendering) {
626 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
627 return;
628 }
629
630 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
631
632 char const *fsSource = R"glsl(
633 #version 450
634 layout(location=0) out vec4 color;
635 void main() {
636 color = vec4(1.0f);
637 }
638 )glsl";
639
640 VkViewport viewport = {0, 0, 16, 16, 0, 1};
641 VkRect2D scissor = {{0, 0}, {16, 16}};
642 m_viewports.push_back(viewport);
643 m_scissors.push_back(scissor);
644
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800645 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
646 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000647
648 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
649 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
650 const VkPipelineLayoutObj pl(m_device, {&dsl});
651
652 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
653
stusmith15f24a82021-12-24 15:21:19 +0000654 VkPipelineObj pipe1(m_device);
655 pipe1.AddShader(&vs);
656 pipe1.AddShader(&fs);
657 pipe1.AddDefaultColorAttachment();
658 pipe1.SetViewport(m_viewports);
659 pipe1.SetScissor(m_scissors);
660
661 VkFormat color_formats[] = {VK_FORMAT_R8G8B8A8_UNORM};
662 pipeline_rendering_info.colorAttachmentCount = 1;
663 pipeline_rendering_info.pColorAttachmentFormats = color_formats;
664
665 auto create_info1 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
666 pipe1.InitGraphicsPipelineCreateInfo(&create_info1);
667 create_info1.pNext = &pipeline_rendering_info;
668
669 auto multisample_state_create_info = LvlInitStruct<VkPipelineMultisampleStateCreateInfo>();
670 multisample_state_create_info.rasterizationSamples = VK_SAMPLE_COUNT_2_BIT;
671 create_info1.pMultisampleState = &multisample_state_create_info;
672
673 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
674
stusmith15f24a82021-12-24 15:21:19 +0000675 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
676 ASSERT_TRUE(depthStencilFormat != 0);
677
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600678 auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
679
stusmith15f24a82021-12-24 15:21:19 +0000680 VkPipelineObj pipe2(m_device);
681 pipe2.AddShader(&vs);
682 pipe2.AddShader(&fs);
683 pipe2.AddDefaultColorAttachment();
684 pipe2.SetViewport(m_viewports);
685 pipe2.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600686 pipe2.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000687
688 pipeline_rendering_info.colorAttachmentCount = 0;
689 pipeline_rendering_info.pColorAttachmentFormats = nullptr;
690 pipeline_rendering_info.depthAttachmentFormat = depthStencilFormat;
691
692 auto create_info2 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
693 pipe2.InitGraphicsPipelineCreateInfo(&create_info2);
694 create_info2.pNext = &pipeline_rendering_info;
695
696 create_info2.pMultisampleState = &multisample_state_create_info;
697
698 pipe2.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info2);
699
stusmith15f24a82021-12-24 15:21:19 +0000700 VkPipelineObj pipe3(m_device);
701
702 pipe3.AddShader(&vs);
703 pipe3.AddShader(&fs);
704 pipe3.AddDefaultColorAttachment();
705 pipe3.SetViewport(m_viewports);
706 pipe3.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600707 pipe3.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000708
709 pipeline_rendering_info.colorAttachmentCount = 0;
710 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
711 pipeline_rendering_info.stencilAttachmentFormat = depthStencilFormat;
712
713 auto create_info3 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
714 pipe3.InitGraphicsPipelineCreateInfo(&create_info3);
715 create_info3.pNext = &pipeline_rendering_info;
716
717 create_info3.pMultisampleState = &multisample_state_create_info;
718
719 pipe3.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info3);
720
stusmith15f24a82021-12-24 15:21:19 +0000721 VkImageObj colorImage(m_device);
722 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
723 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UNORM);
724
725 VkImageObj depthStencilImage(m_device);
726 depthStencilImage.Init(32, 32, 1, depthStencilFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
727 VkImageView depthStencilImageView =
728 depthStencilImage.targetView(depthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
729
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800730 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000731 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
732 color_attachment.imageView = colorImageView;
733
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800734 VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000735 depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
736 depth_stencil_attachment.imageView = depthStencilImageView;
737
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800738 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600739 begin_rendering_info.layerCount = 1;
stusmith15f24a82021-12-24 15:21:19 +0000740 m_commandBuffer->begin();
741
742 // Mismatching color samples
743 begin_rendering_info.colorAttachmentCount = 1;
744 begin_rendering_info.pColorAttachments = &color_attachment;
745 m_commandBuffer->BeginRendering(begin_rendering_info);
746 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
747 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06188");
748 m_commandBuffer->Draw(1, 1, 0, 0);
749 m_errorMonitor->VerifyFound();
750 m_commandBuffer->EndRendering();
751
752 // Mismatching depth samples
753 begin_rendering_info.colorAttachmentCount = 0;
754 begin_rendering_info.pColorAttachments = nullptr;
755 begin_rendering_info.pDepthAttachment = &depth_stencil_attachment;
756 m_commandBuffer->BeginRendering(begin_rendering_info);
757 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.handle());
758 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06189");
759 m_commandBuffer->Draw(1, 1, 0, 0);
760 m_errorMonitor->VerifyFound();
761 m_commandBuffer->EndRendering();
762
763 // Mismatching stencil samples
764 begin_rendering_info.pDepthAttachment = nullptr;
765 begin_rendering_info.pStencilAttachment = &depth_stencil_attachment;
766 m_commandBuffer->BeginRendering(begin_rendering_info);
767 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe3.handle());
768 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06190");
769 m_commandBuffer->Draw(1, 1, 0, 0);
770 m_errorMonitor->VerifyFound();
771 m_commandBuffer->EndRendering();
772
773 m_commandBuffer->end();
774}
775
ziga-lunarga3cc8482022-04-29 14:58:29 +0200776TEST_F(VkLayerTest, DynamicRenderingWithMismatchingMixedAttachmentSamples) {
stusmith15f24a82021-12-24 15:21:19 +0000777 TEST_DESCRIPTION("Draw with Dynamic Rendering with mismatching mixed color/depth/stencil sample counts");
778
779 SetTargetApiVersion(VK_API_VERSION_1_1);
780
781 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
782
783 ASSERT_NO_FATAL_FAILURE(InitFramework());
784
sjfricked700bc02022-05-30 16:35:06 +0900785 if (!AreRequiredExtensionsEnabled()) {
786 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
stusmith15f24a82021-12-24 15:21:19 +0000787 }
788
789 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900790 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
stusmith15f24a82021-12-24 15:21:19 +0000791 }
792
793 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
794 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
795 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
796 if (!dynamic_rendering_features.dynamicRendering) {
797 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
798 return;
799 }
800
801 bool amd_samples = false;
802 if (DeviceExtensionSupported(gpu(), nullptr, VK_AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME)) {
803 m_device_extension_names.push_back(VK_AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME);
804 amd_samples = true;
805 }
806
807 bool nv_samples = false;
808 if (DeviceExtensionSupported(gpu(), nullptr, VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME)) {
809 m_device_extension_names.push_back(VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME);
810 nv_samples = true;
811 }
812
813 if (!amd_samples && !nv_samples) {
814 printf("%s Test requires either VK_AMD_mixed_attachment_samples or VK_NV_framebuffer_mixed_samples, skipping\n",
815 kSkipPrefix);
816 return;
817 }
818
819 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
820
821 char const *fsSource = R"glsl(
822 #version 450
823 layout(location=0) out vec4 color;
824 void main() {
825 color = vec4(1.0f);
826 }
827 )glsl";
828
829 VkViewport viewport = {0, 0, 16, 16, 0, 1};
830 VkRect2D scissor = {{0, 0}, {16, 16}};
831 m_viewports.push_back(viewport);
832 m_scissors.push_back(scissor);
833
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800834 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
835 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000836
837 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
838 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
839 const VkPipelineLayoutObj pl(m_device, {&dsl});
840
ziga-lunarga3cc8482022-04-29 14:58:29 +0200841 VkSampleCountFlagBits counts[2] = {VK_SAMPLE_COUNT_2_BIT, VK_SAMPLE_COUNT_2_BIT};
stusmith15f24a82021-12-24 15:21:19 +0000842 auto samples_info = LvlInitStruct<VkAttachmentSampleCountInfoAMD>();
843
844 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(&samples_info);
845
846 VkPipelineObj pipe1(m_device);
847 pipe1.AddShader(&vs);
848 pipe1.AddShader(&fs);
849 pipe1.AddDefaultColorAttachment();
850 pipe1.SetViewport(m_viewports);
851 pipe1.SetScissor(m_scissors);
852
853 VkFormat color_formats[] = {VK_FORMAT_R8G8B8A8_UNORM};
854 pipeline_rendering_info.colorAttachmentCount = 1;
855 pipeline_rendering_info.pColorAttachmentFormats = color_formats;
856
857 samples_info.colorAttachmentCount = 1;
ziga-lunarga3cc8482022-04-29 14:58:29 +0200858 samples_info.pColorAttachmentSamples = counts;
stusmith15f24a82021-12-24 15:21:19 +0000859
860 auto create_info1 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
861 pipe1.InitGraphicsPipelineCreateInfo(&create_info1);
862 create_info1.pNext = &pipeline_rendering_info;
863
Aaron Haganb54466d2022-02-18 15:02:54 -0500864 samples_info.colorAttachmentCount = 2;
865 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06063");
866 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
867 m_errorMonitor->VerifyFound();
868
869 samples_info.colorAttachmentCount = 1;
stusmith15f24a82021-12-24 15:21:19 +0000870 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
871
872 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
873 ASSERT_TRUE(depthStencilFormat != 0);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600874 auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
stusmith15f24a82021-12-24 15:21:19 +0000875
876 VkPipelineObj pipe2(m_device);
877 pipe2.AddShader(&vs);
878 pipe2.AddShader(&fs);
879 pipe2.AddDefaultColorAttachment();
880 pipe2.SetViewport(m_viewports);
881 pipe2.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600882 pipe2.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000883
884 pipeline_rendering_info.colorAttachmentCount = 0;
885 pipeline_rendering_info.pColorAttachmentFormats = nullptr;
886 pipeline_rendering_info.depthAttachmentFormat = depthStencilFormat;
887
888 samples_info.colorAttachmentCount = 0;
889 samples_info.pColorAttachmentSamples = nullptr;
ziga-lunarga3cc8482022-04-29 14:58:29 +0200890 samples_info.depthStencilAttachmentSamples = counts[0];
stusmith15f24a82021-12-24 15:21:19 +0000891
892 auto create_info2 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
893 pipe2.InitGraphicsPipelineCreateInfo(&create_info2);
894 create_info2.pNext = &pipeline_rendering_info;
895
896 pipe2.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info2);
897
898 VkPipelineObj pipe3(m_device);
899
900 pipe3.AddShader(&vs);
901 pipe3.AddShader(&fs);
902 pipe3.AddDefaultColorAttachment();
903 pipe3.SetViewport(m_viewports);
904 pipe3.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600905 pipe3.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000906
907 pipeline_rendering_info.colorAttachmentCount = 0;
908 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
909 pipeline_rendering_info.stencilAttachmentFormat = depthStencilFormat;
910
911 auto create_info3 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
912 pipe3.InitGraphicsPipelineCreateInfo(&create_info3);
913 create_info3.pNext = &pipeline_rendering_info;
914
915 pipe3.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info3);
916
917 VkImageObj colorImage(m_device);
918 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
919 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UNORM);
920
921 VkImageObj depthStencilImage(m_device);
922 depthStencilImage.Init(32, 32, 1, depthStencilFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
923 VkImageView depthStencilImageView =
924 depthStencilImage.targetView(depthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
925
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800926 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000927 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
928 color_attachment.imageView = colorImageView;
929
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800930 VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000931 depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
932 depth_stencil_attachment.imageView = depthStencilImageView;
933
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800934 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000935 m_commandBuffer->begin();
936
937 // Mismatching color samples
938 begin_rendering_info.colorAttachmentCount = 1;
939 begin_rendering_info.pColorAttachments = &color_attachment;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600940 begin_rendering_info.layerCount = 1;
stusmith15f24a82021-12-24 15:21:19 +0000941 m_commandBuffer->BeginRendering(begin_rendering_info);
942 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
943 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06185");
944 m_commandBuffer->Draw(1, 1, 0, 0);
945 m_errorMonitor->VerifyFound();
946 m_commandBuffer->EndRendering();
947
948 // Mismatching depth samples
949 begin_rendering_info.colorAttachmentCount = 0;
950 begin_rendering_info.pColorAttachments = nullptr;
951 begin_rendering_info.pDepthAttachment = &depth_stencil_attachment;
952 m_commandBuffer->BeginRendering(begin_rendering_info);
953 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.handle());
954 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06186");
955 m_commandBuffer->Draw(1, 1, 0, 0);
956 m_errorMonitor->VerifyFound();
957 m_commandBuffer->EndRendering();
958
959 // Mismatching stencil samples
960 begin_rendering_info.pDepthAttachment = nullptr;
961 begin_rendering_info.pStencilAttachment = &depth_stencil_attachment;
962 m_commandBuffer->BeginRendering(begin_rendering_info);
963 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe3.handle());
964 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06187");
965 m_commandBuffer->Draw(1, 1, 0, 0);
966 m_errorMonitor->VerifyFound();
967 m_commandBuffer->EndRendering();
968
969 m_commandBuffer->end();
970}
Aaron Hagan80034ea2021-12-23 11:24:09 -0500971
972TEST_F(VkLayerTest, DynamicRenderingAttachmentInfo) {
973 TEST_DESCRIPTION("AttachmentInfo Dynamic Rendering Tests.");
974
975 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2);
976 if (version < VK_API_VERSION_1_2) {
977 printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix);
978 return;
979 }
980
981 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
982
983 ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor));
984
985 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900986 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
Aaron Hagan80034ea2021-12-23 11:24:09 -0500987 }
988
sjfricked700bc02022-05-30 16:35:06 +0900989 if (!AreRequiredExtensionsEnabled()) {
990 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
Aaron Hagan80034ea2021-12-23 11:24:09 -0500991 }
992
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600993 auto fdm_features = LvlInitStruct<VkPhysicalDeviceFragmentDensityMapFeaturesEXT>();
994 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(&fdm_features);
995 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
Aaron Hagan80034ea2021-12-23 11:24:09 -0500996 if (!dynamic_rendering_features.dynamicRendering) {
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600997 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering , skipping";
998 }
999 if (!fdm_features.fragmentDensityMapNonSubsampledImages) {
1000 GTEST_SKIP() << "fragmentDensityMapNonSubsampledImages not supported.";
Aaron Hagan80034ea2021-12-23 11:24:09 -05001001 }
1002
1003 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1004
1005 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
1006 VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT);
1007
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001008 auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
1009
Aaron Hagan80034ea2021-12-23 11:24:09 -05001010 VkPipelineObj pipe(m_device);
1011 pipe.AddShader(&vs);
1012 pipe.AddShader(&fs);
1013 pipe.AddDefaultColorAttachment();
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001014 pipe.SetDepthStencil(&ds_state);
Aaron Hagan80034ea2021-12-23 11:24:09 -05001015
1016 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
1017 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
1018 const VkPipelineLayoutObj pl(m_device, {&dsl});
1019
1020 VkFormat depth_format = VK_FORMAT_D32_SFLOAT_S8_UINT;
1021 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
1022 pipeline_rendering_info.depthAttachmentFormat = depth_format;
1023
1024 auto pipeline_create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
1025 pipe.InitGraphicsPipelineCreateInfo(&pipeline_create_info);
1026 pipeline_create_info.pNext = &pipeline_rendering_info;
1027
1028 VkResult err = pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &pipeline_create_info);
1029 ASSERT_VK_SUCCESS(err);
1030
1031 VkImageObj image(m_device);
1032 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
1033 image_create_info.imageType = VK_IMAGE_TYPE_2D;
1034 image_create_info.format = depth_format;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001035 image_create_info.extent = {64, 64, 1};
Aaron Hagan80034ea2021-12-23 11:24:09 -05001036 image_create_info.mipLevels = 1;
1037 image_create_info.arrayLayers = 1;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001038 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
Aaron Hagan80034ea2021-12-23 11:24:09 -05001039 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
ziga-lunarga3cc8482022-04-29 14:58:29 +02001040 image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT;
Aaron Hagan80034ea2021-12-23 11:24:09 -05001041 image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
1042
1043 image.Init(image_create_info);
1044 ASSERT_TRUE(image.initialized());
1045
1046 VkImageViewCreateInfo ivci = {VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
1047 nullptr,
1048 0,
1049 image.handle(),
1050 VK_IMAGE_VIEW_TYPE_2D,
1051 depth_format,
1052 {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
1053 VK_COMPONENT_SWIZZLE_IDENTITY},
1054 {VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, 0, 1, 0, 1}};
1055
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001056 VkImageView depth_image_view = image.targetView(ivci);
1057 ASSERT_NE(depth_image_view, VK_NULL_HANDLE);
Aaron Hagan80034ea2021-12-23 11:24:09 -05001058
1059 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1060 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
1061 depth_attachment.imageView = depth_image_view;
1062 depth_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
1063 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
1064
1065 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
1066 begin_rendering_info.pDepthAttachment = &depth_attachment;
1067 begin_rendering_info.viewMask = 0x4;
1068
1069 VkRenderingFragmentDensityMapAttachmentInfoEXT fragment_density_map =
1070 LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
1071 fragment_density_map.imageView = depth_image_view;
ziga-lunarga3cc8482022-04-29 14:58:29 +02001072 fragment_density_map.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
Aaron Hagan80034ea2021-12-23 11:24:09 -05001073 begin_rendering_info.pNext = &fragment_density_map;
1074
1075 m_commandBuffer->begin();
1076 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-multiview-06127");
Jeremy Gebben09c1a072022-02-08 09:42:47 -07001077 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06107");
1078 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06108");
1079 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06116");
Jeremy Gebben09c1a072022-02-08 09:42:47 -07001080 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06145");
1081 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06146");
Aaron Hagan80034ea2021-12-23 11:24:09 -05001082 m_commandBuffer->BeginRendering(begin_rendering_info);
1083 m_errorMonitor->VerifyFound();
1084}
Aaron Haganb54466d2022-02-18 15:02:54 -05001085
1086TEST_F(VkLayerTest, DynamicRenderingBufferBeginInfoLegacy) {
1087 TEST_DESCRIPTION("VkCommandBufferBeginInfo Dynamic Rendering Tests.");
1088
1089 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2);
1090 if (version < VK_API_VERSION_1_2) {
1091 printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix);
1092 return;
1093 }
1094
1095 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1096
1097 ASSERT_NO_FATAL_FAILURE(Init(nullptr, nullptr, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1098
1099 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001100 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
Aaron Haganb54466d2022-02-18 15:02:54 -05001101 }
1102
sjfricked700bc02022-05-30 16:35:06 +09001103 if (!AreRequiredExtensionsEnabled()) {
1104 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
Aaron Haganb54466d2022-02-18 15:02:54 -05001105 }
1106
1107 auto cmd_buffer_inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>();
1108 cmd_buffer_inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
1109
1110 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
1111 cmd_buffer_inheritance_info.pNext = &cmd_buffer_inheritance_rendering_info;
1112 cmd_buffer_inheritance_info.renderPass = VK_NULL_HANDLE;
1113
1114 auto cmd_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>();
1115 cmd_buffer_allocate_info.commandPool = m_commandPool->handle();
1116 cmd_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY;
1117 cmd_buffer_allocate_info.commandBufferCount = 0x1;
1118
1119 VkCommandBuffer secondary_cmd_buffer;
1120 VkResult err = vk::AllocateCommandBuffers(m_device->device(), &cmd_buffer_allocate_info, &secondary_cmd_buffer);
1121 ASSERT_VK_SUCCESS(err);
1122
1123 // Invalid RenderPass
1124 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-00053");
1125 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
1126 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
1127 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
1128 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
1129 m_errorMonitor->VerifyFound();
1130
1131 // Valid RenderPass
1132 VkAttachmentDescription attach[] = {
1133 {0, VK_FORMAT_B8G8R8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE,
1134 VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_IMAGE_LAYOUT_UNDEFINED,
1135 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL},
1136 };
1137 VkAttachmentReference att_ref = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL};
1138
1139 VkSubpassDescription subpass = {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &att_ref, nullptr, nullptr, 0, nullptr};
1140 VkRenderPassCreateInfo rpci = {VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, 0, 1, attach, 1, &subpass, 0, nullptr};
1141
1142 vk_testing::RenderPass rp1;
1143 rp1.init(*m_device, rpci);
1144
1145 cmd_buffer_inheritance_info.renderPass = rp1.handle();
1146 cmd_buffer_inheritance_info.subpass = 0x5;
1147 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-00054");
1148 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
1149 m_errorMonitor->VerifyFound();
1150}
1151
1152TEST_F(VkLayerTest, DynamicRenderingSecondaryCommandBuffer) {
1153 TEST_DESCRIPTION("VkCommandBufferBeginInfo Dynamic Rendering Tests.");
1154
1155 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_3);
1156 if (version < VK_API_VERSION_1_3) {
1157 printf("%s At least Vulkan version 1.3 is required, skipping test.\n", kSkipPrefix);
1158 return;
1159 }
1160
1161 ASSERT_NO_FATAL_FAILURE(Init());
1162
1163 if (DeviceValidationVersion() < VK_API_VERSION_1_3) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001164 GTEST_SKIP() << "At least Vulkan version 1.3 is required";
Aaron Haganb54466d2022-02-18 15:02:54 -05001165 }
1166
1167 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
1168
1169 // Force the failure by not setting the Renderpass and Framebuffer fields
1170 VkCommandBufferInheritanceInfo cmd_buf_hinfo = LvlInitStruct<VkCommandBufferInheritanceInfo>();
1171 cmd_buf_hinfo.renderPass = VkRenderPass(0x1);
1172 VkCommandBufferBeginInfo cmd_buf_info = LvlInitStruct<VkCommandBufferBeginInfo>();
1173 cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
1174 cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo;
1175
1176 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06000");
1177 vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info);
1178 m_errorMonitor->VerifyFound();
1179
1180 // Valid RenderPass
1181 VkAttachmentDescription attach[] = {
1182 {0, VK_FORMAT_B8G8R8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE,
1183 VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_IMAGE_LAYOUT_UNDEFINED,
1184 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL},
1185 };
1186 VkAttachmentReference att_ref = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL};
1187
1188 VkSubpassDescription subpass = {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &att_ref, nullptr, nullptr, 0, nullptr};
1189 VkRenderPassCreateInfo rpci = {VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, 0, 1, attach, 1, &subpass, 0, nullptr};
1190
1191 vk_testing::RenderPass rp1;
1192 rp1.init(*m_device, rpci);
1193
1194 cmd_buf_hinfo.renderPass = rp1.handle();
1195 cmd_buf_hinfo.subpass = 0x5;
1196 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06001");
1197 vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info);
1198 m_errorMonitor->VerifyFound();
1199
1200 cmd_buf_hinfo.renderPass = VK_NULL_HANDLE;
1201 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06002");
1202 vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info);
1203 m_errorMonitor->VerifyFound();
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001204}
1205
1206TEST_F(VkLayerTest, TestDynamicRenderingPipelineMissingFlags) {
1207 TEST_DESCRIPTION("Test dynamic rendering with pipeline missing flags.");
1208
1209 SetTargetApiVersion(VK_API_VERSION_1_1);
1210 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001211 AddOptionalExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1212 AddOptionalExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001213
1214 ASSERT_NO_FATAL_FAILURE(InitFramework());
1215
1216 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001217 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001218 }
1219
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001220 if (!IsExtensionsEnabled(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
sjfricked700bc02022-05-30 16:35:06 +09001221 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001222 }
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001223 bool fragment_density = IsExtensionsEnabled(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1224 bool shading_rate = IsExtensionsEnabled(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001225
1226 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1227 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1228 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1229 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001230 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001231 }
1232
1233 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
1234
1235 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
1236 vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2);
1237
1238 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1239 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
1240
1241 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
1242 ASSERT_TRUE(depthStencilFormat != 0);
1243
1244 VkImageObj image(m_device);
1245 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
1246 image_create_info.imageType = VK_IMAGE_TYPE_2D;
1247 image_create_info.format = depthStencilFormat;
1248 image_create_info.extent = {64, 64, 1};
1249 image_create_info.mipLevels = 1;
1250 image_create_info.arrayLayers = 1;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001251 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001252 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001253 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 +01001254 image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
1255
1256 image.Init(image_create_info);
1257 ASSERT_TRUE(image.initialized());
1258
1259 VkImageViewCreateInfo ivci = {VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
1260 nullptr,
1261 0,
1262 image.handle(),
1263 VK_IMAGE_VIEW_TYPE_2D,
1264 depthStencilFormat,
1265 {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
1266 VK_COMPONENT_SWIZZLE_IDENTITY},
1267 {VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, 0, 1, 0, 1}};
1268
1269 vk_testing::ImageView depth_image_view;
1270 depth_image_view.init(*m_device, ivci);
1271
1272 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1273 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1274
1275 if (shading_rate) {
1276 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-imageView-06183");
1277 VkRenderingFragmentShadingRateAttachmentInfoKHR fragment_shading_rate =
1278 LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
1279 fragment_shading_rate.imageView = depth_image_view.handle();
1280 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1281 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
1282
1283 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
ziga-lunargaa97cbb2022-03-18 19:06:35 +01001284 begin_rendering_info.layerCount = 1;
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001285 begin_rendering_info.colorAttachmentCount = 1;
1286 begin_rendering_info.pColorAttachments = &color_attachment;
1287
1288 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
1289
1290 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
1291 pipeline_rendering_info.colorAttachmentCount = 1;
1292 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
1293
1294 CreatePipelineHelper pipe(*this);
1295 pipe.InitInfo();
1296 pipe.gp_ci_.pNext = &pipeline_rendering_info;
1297 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
1298 pipe.InitState();
1299 pipe.CreateGraphicsPipeline();
1300
1301 m_commandBuffer->begin();
1302 m_commandBuffer->BeginRendering(begin_rendering_info);
1303 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_);
1304 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
1305 m_commandBuffer->EndRendering();
1306 m_commandBuffer->end();
1307
1308 m_errorMonitor->VerifyFound();
1309 }
1310
1311 if (fragment_density) {
1312 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-imageView-06184");
1313 VkRenderingFragmentDensityMapAttachmentInfoEXT fragment_density_map =
1314 LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
1315 fragment_density_map.imageView = depth_image_view.handle();
1316
1317 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_density_map);
ziga-lunargaa97cbb2022-03-18 19:06:35 +01001318 begin_rendering_info.layerCount = 1;
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001319 begin_rendering_info.colorAttachmentCount = 1;
1320 begin_rendering_info.pColorAttachments = &color_attachment;
1321
1322 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
1323
1324 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
1325 pipeline_rendering_info.colorAttachmentCount = 1;
1326 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
1327
1328 CreatePipelineHelper pipe(*this);
1329 pipe.InitInfo();
1330 pipe.gp_ci_.pNext = &pipeline_rendering_info;
1331 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
1332 pipe.InitState();
1333 pipe.CreateGraphicsPipeline();
1334
1335 m_commandBuffer->begin();
1336 m_commandBuffer->BeginRendering(begin_rendering_info);
1337 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_);
1338 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
1339 m_commandBuffer->EndRendering();
1340 m_commandBuffer->end();
1341
1342 m_errorMonitor->VerifyFound();
1343 }
1344}
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001345
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001346TEST_F(VkLayerTest, DynamicRenderingLayerCount) {
1347 TEST_DESCRIPTION("Test dynamic rendering with viewMask 0 and invalid layer count.");
1348
1349 SetTargetApiVersion(VK_API_VERSION_1_1);
1350 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1351
1352 ASSERT_NO_FATAL_FAILURE(InitFramework());
1353
1354 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001355 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001356 }
1357
1358 if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
sjfricked700bc02022-05-30 16:35:06 +09001359 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001360 }
1361
1362 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1363 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1364 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1365 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001366 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001367 }
1368
1369 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1370
1371 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
1372
1373 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-viewMask-06069");
1374 m_commandBuffer->begin();
1375 m_commandBuffer->BeginRendering(begin_rendering_info);
1376 m_commandBuffer->end();
1377 m_errorMonitor->VerifyFound();
1378}
1379
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001380TEST_F(VkLayerTest, TestRenderingInfoMismatchedSamples) {
1381 TEST_DESCRIPTION("Test beginning rendering with mismatched sample counts.");
1382
1383 SetTargetApiVersion(VK_API_VERSION_1_1);
1384 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1385
1386 ASSERT_NO_FATAL_FAILURE(InitFramework());
1387
1388 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001389 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001390 }
1391
1392 if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
sjfricked700bc02022-05-30 16:35:06 +09001393 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001394 }
1395
1396 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1397 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1398 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1399 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001400 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001401 }
1402
1403 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1404
1405 VkImageCreateInfo image_ci = LvlInitStruct<VkImageCreateInfo>();
1406 image_ci.imageType = VK_IMAGE_TYPE_2D;
1407 image_ci.format = VK_FORMAT_R8G8B8A8_UNORM;
1408 image_ci.extent.width = 64;
1409 image_ci.extent.height = 64;
1410 image_ci.extent.depth = 1;
1411 image_ci.mipLevels = 1;
1412 image_ci.arrayLayers = 1;
1413 image_ci.samples = VK_SAMPLE_COUNT_2_BIT;
1414 image_ci.tiling = VK_IMAGE_TILING_OPTIMAL;
1415 image_ci.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
1416
1417 VkImageObj color_image(m_device);
1418 color_image.init(&image_ci);
1419
1420 VkImageViewCreateInfo civ_ci = LvlInitStruct<VkImageViewCreateInfo>();
1421 civ_ci.image = color_image.handle();
1422 civ_ci.viewType = VK_IMAGE_VIEW_TYPE_2D;
1423 civ_ci.format = VK_FORMAT_R8G8B8A8_UNORM;
1424 civ_ci.subresourceRange.layerCount = 1;
1425 civ_ci.subresourceRange.baseMipLevel = 0;
1426 civ_ci.subresourceRange.levelCount = 1;
1427 civ_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
1428
1429 vk_testing::ImageView color_image_view;
1430 color_image_view.init(*m_device, civ_ci);
1431
1432 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1433 color_attachment.imageView = color_image_view.handle();
1434 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1435 color_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
1436
1437 const VkFormat depth_format = FindSupportedDepthOnlyFormat(gpu());
1438 if (depth_format == VK_FORMAT_UNDEFINED) {
1439 printf("%s requires a depth only format, skipping.\n", kSkipPrefix);
1440 return;
1441 }
1442
1443 VkImageObj depth_image(m_device);
1444 depth_image.Init(64, 64, 1, depth_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL);
1445
1446 VkImageViewCreateInfo div_ci = LvlInitStruct<VkImageViewCreateInfo>();
1447 div_ci.image = depth_image.handle();
1448 div_ci.viewType = VK_IMAGE_VIEW_TYPE_2D;
1449 div_ci.format = depth_format;
1450 div_ci.subresourceRange.layerCount = 1;
1451 div_ci.subresourceRange.baseMipLevel = 0;
1452 div_ci.subresourceRange.levelCount = 1;
1453 div_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
1454
1455 vk_testing::ImageView depth_image_view;
1456 depth_image_view.init(*m_device, div_ci);
1457
1458 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1459 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1460 depth_attachment.imageView = depth_image_view.handle();
1461 depth_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
1462
1463 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
ziga-lunargaa97cbb2022-03-18 19:06:35 +01001464 begin_rendering_info.layerCount = 1;
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001465 begin_rendering_info.colorAttachmentCount = 1;
1466 begin_rendering_info.pColorAttachments = &color_attachment;
1467 begin_rendering_info.pDepthAttachment = &depth_attachment;
1468
1469 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06070");
1470 m_commandBuffer->BeginRendering(begin_rendering_info);
1471 m_errorMonitor->VerifyFound();
1472}
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001473
ziga-lunargb7fec142022-03-18 22:08:17 +01001474TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRate) {
1475 TEST_DESCRIPTION("Test BeginRenderingInfo with FragmentShadingRateAttachment.");
1476
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001477 SetTargetApiVersion(VK_API_VERSION_1_2);
ziga-lunargb7fec142022-03-18 22:08:17 +01001478 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1479 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
1480
1481 ASSERT_NO_FATAL_FAILURE(InitFramework());
1482
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001483 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
1484 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
ziga-lunargb7fec142022-03-18 22:08:17 +01001485 }
1486
sjfricked700bc02022-05-30 16:35:06 +09001487 if (!AreRequiredExtensionsEnabled()) {
1488 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargb7fec142022-03-18 22:08:17 +01001489 }
1490
1491 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1492 auto features11 = LvlInitStruct<VkPhysicalDeviceVulkan11Features>(&dynamic_rendering_features);
1493 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&features11);
1494 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1495
1496 if (features11.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001497 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunargb7fec142022-03-18 22:08:17 +01001498 }
1499 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001500 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargb7fec142022-03-18 22:08:17 +01001501 }
1502
1503 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
1504
1505 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
1506 vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2);
1507
1508 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1509 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
1510
1511 auto image_ci = LvlInitStruct<VkImageCreateInfo>(nullptr);
1512 image_ci.imageType = VK_IMAGE_TYPE_2D;
1513 image_ci.format = VK_FORMAT_R8G8B8A8_UNORM;
1514 image_ci.extent.width = 32;
1515 image_ci.extent.height = 32;
1516 image_ci.extent.depth = 1;
1517 image_ci.mipLevels = 1;
1518 image_ci.arrayLayers = 2;
1519 image_ci.samples = VK_SAMPLE_COUNT_1_BIT;
1520 image_ci.tiling = VK_IMAGE_TILING_OPTIMAL;
ziga-lunargade1d9e2022-04-25 10:59:15 +02001521 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 +01001522
1523 VkImageObj image(m_device);
1524 image.init(&image_ci);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001525 VkImageView image_view =
1526 image.targetView(VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 2, VK_IMAGE_VIEW_TYPE_2D_ARRAY);
ziga-lunargb7fec142022-03-18 22:08:17 +01001527
ziga-lunargade1d9e2022-04-25 10:59:15 +02001528 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
ziga-lunargb7fec142022-03-18 22:08:17 +01001529 fragment_shading_rate.imageView = image_view;
1530 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1531 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
1532
1533 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
1534 begin_rendering_info.layerCount = 4;
1535
1536 m_commandBuffer->begin();
1537
1538 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06123");
1539 m_commandBuffer->BeginRendering(begin_rendering_info);
1540 m_errorMonitor->VerifyFound();
1541
1542 begin_rendering_info.viewMask = 0xF;
1543 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06124");
1544 m_commandBuffer->BeginRendering(begin_rendering_info);
1545 m_errorMonitor->VerifyFound();
1546
ziga-lunargade1d9e2022-04-25 10:59:15 +02001547 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1548 color_attachment.imageView = image_view;
1549 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1550
1551 begin_rendering_info.layerCount = 2;
1552 begin_rendering_info.colorAttachmentCount = 1;
1553 begin_rendering_info.pColorAttachments = &color_attachment;
1554 begin_rendering_info.viewMask = 0;
1555 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06125");
1556 m_commandBuffer->BeginRendering(begin_rendering_info);
1557 m_errorMonitor->VerifyFound();
1558
ziga-lunargb7fec142022-03-18 22:08:17 +01001559 m_commandBuffer->end();
ziga-lunargb7fec142022-03-18 22:08:17 +01001560}
1561
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001562TEST_F(VkLayerTest, TestDeviceGroupRenderPassBeginInfo) {
1563 TEST_DESCRIPTION("Test render area of DeviceGroupRenderPassBeginInfo.");
1564
1565 SetTargetApiVersion(VK_API_VERSION_1_1);
1566 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1567
1568 ASSERT_NO_FATAL_FAILURE(InitFramework());
1569
1570 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001571 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001572 }
1573
1574 if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
sjfricked700bc02022-05-30 16:35:06 +09001575 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001576 }
1577
1578 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1579 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1580 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1581 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001582 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001583 }
1584
1585 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1586
1587 VkRect2D render_area = {};
1588 render_area.offset.x = 0;
1589 render_area.offset.y = 0;
1590 render_area.extent.width = 32;
1591 render_area.extent.height = 32;
1592
1593 auto device_group_render_pass_begin_info = LvlInitStruct<VkDeviceGroupRenderPassBeginInfo>();
1594 device_group_render_pass_begin_info.deviceRenderAreaCount = 1;
1595 device_group_render_pass_begin_info.pDeviceRenderAreas = &render_area;
1596
1597 VkImageObj colorImage(m_device);
1598 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
1599 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
1600
1601 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1602 color_attachment.imageView = colorImageView;
1603 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1604
1605 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&device_group_render_pass_begin_info);
ziga-lunarg1fec6332022-03-20 14:39:54 +01001606 begin_rendering_info.layerCount = 1;
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001607 begin_rendering_info.colorAttachmentCount = 1;
1608 begin_rendering_info.pColorAttachments = &color_attachment;
1609
1610 m_commandBuffer->begin();
1611
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001612 m_commandBuffer->BeginRendering(begin_rendering_info);
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001613
1614 render_area.offset.x = 1;
1615 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06083");
1616 m_commandBuffer->BeginRendering(begin_rendering_info);
1617 m_errorMonitor->VerifyFound();
1618
1619 render_area.offset.x = 0;
1620 render_area.offset.y = 16;
1621 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06084");
1622 m_commandBuffer->BeginRendering(begin_rendering_info);
1623 m_errorMonitor->VerifyFound();
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001624}
1625
ziga-lunarg184a20b2022-03-18 20:54:48 +01001626TEST_F(VkLayerTest, TestBeginRenderingInvalidFragmentShadingRateImage) {
1627 TEST_DESCRIPTION("Test BeginRendering with FragmentShadingRateAttachmentInfo with missing image usage bit.");
1628
1629 SetTargetApiVersion(VK_API_VERSION_1_1);
1630 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1631 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
1632
1633 ASSERT_NO_FATAL_FAILURE(InitFramework());
1634
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001635 if (IsDriver(VK_DRIVER_ID_AMD_PROPRIETARY)) {
1636 GTEST_SKIP() << "Skipping on AMD proprietary driver pending further investigation.";
1637 }
1638
ziga-lunarg184a20b2022-03-18 20:54:48 +01001639 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001640 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg184a20b2022-03-18 20:54:48 +01001641 }
1642
sjfricked700bc02022-05-30 16:35:06 +09001643 if (!AreRequiredExtensionsEnabled()) {
1644 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg184a20b2022-03-18 20:54:48 +01001645 }
1646
1647 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1648 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1649 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1650 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001651 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg184a20b2022-03-18 20:54:48 +01001652 }
1653 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1654
1655 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
1656 auto properties2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
1657 vk::GetPhysicalDeviceProperties2(gpu(), &properties2);
1658
1659 VkImageObj image(m_device);
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001660 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT,
1661 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR);
ziga-lunarg184a20b2022-03-18 20:54:48 +01001662 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
1663
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001664 VkImageObj invalid_image(m_device);
1665 invalid_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
1666 VkImageView invalid_image_view = invalid_image.targetView(VK_FORMAT_R8G8B8A8_UINT);
1667
ziga-lunarg184a20b2022-03-18 20:54:48 +01001668 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001669 fragment_shading_rate.imageView = invalid_image_view;
ziga-lunarg184a20b2022-03-18 20:54:48 +01001670 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1671 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
1672
1673 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001674 begin_rendering_info.layerCount = 1;
1675
1676 m_commandBuffer->begin();
ziga-lunarg184a20b2022-03-18 20:54:48 +01001677
1678 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06148");
ziga-lunarg184a20b2022-03-18 20:54:48 +01001679 m_commandBuffer->BeginRendering(begin_rendering_info);
ziga-lunarg184a20b2022-03-18 20:54:48 +01001680 m_errorMonitor->VerifyFound();
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001681 fragment_shading_rate.imageView = image_view;
1682
1683 fragment_shading_rate.shadingRateAttachmentTexelSize.width = fsr_properties.minFragmentShadingRateAttachmentTexelSize.width + 1;
1684 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06149");
1685 if (fragment_shading_rate.shadingRateAttachmentTexelSize.width >
1686 fsr_properties.minFragmentShadingRateAttachmentTexelSize.width) {
1687 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06150");
1688 }
1689 m_commandBuffer->BeginRendering(begin_rendering_info);
1690 m_errorMonitor->VerifyFound();
1691
1692 if (fsr_properties.minFragmentShadingRateAttachmentTexelSize.width > 1) {
1693 fragment_shading_rate.shadingRateAttachmentTexelSize.width =
1694 fsr_properties.minFragmentShadingRateAttachmentTexelSize.width / 2;
1695 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06151");
1696 if (fragment_shading_rate.shadingRateAttachmentTexelSize.height /
1697 fragment_shading_rate.shadingRateAttachmentTexelSize.width >=
1698 fsr_properties.maxFragmentShadingRateAttachmentTexelSizeAspectRatio) {
1699 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06156");
1700 }
1701 m_commandBuffer->BeginRendering(begin_rendering_info);
1702 m_errorMonitor->VerifyFound();
1703 }
1704
1705 fragment_shading_rate.shadingRateAttachmentTexelSize.width = fsr_properties.minFragmentShadingRateAttachmentTexelSize.width;
1706
1707 fragment_shading_rate.shadingRateAttachmentTexelSize.height =
1708 fsr_properties.minFragmentShadingRateAttachmentTexelSize.height + 1;
1709 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06152");
1710 if (fragment_shading_rate.shadingRateAttachmentTexelSize.height >
1711 fsr_properties.minFragmentShadingRateAttachmentTexelSize.height) {
1712 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06153");
1713 }
1714 m_commandBuffer->BeginRendering(begin_rendering_info);
1715 m_errorMonitor->VerifyFound();
1716
1717 if (fsr_properties.minFragmentShadingRateAttachmentTexelSize.height > 1) {
1718 fragment_shading_rate.shadingRateAttachmentTexelSize.height =
1719 fsr_properties.minFragmentShadingRateAttachmentTexelSize.height / 2;
1720 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06154");
1721 if (fragment_shading_rate.shadingRateAttachmentTexelSize.width /
1722 fragment_shading_rate.shadingRateAttachmentTexelSize.height >
1723 fsr_properties.maxFragmentShadingRateAttachmentTexelSizeAspectRatio) {
1724 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06155");
1725 }
1726 m_commandBuffer->BeginRendering(begin_rendering_info);
1727 m_errorMonitor->VerifyFound();
1728 }
1729
1730 m_commandBuffer->end();
ziga-lunarg184a20b2022-03-18 20:54:48 +01001731}
1732
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001733TEST_F(VkLayerTest, BeginRenderingInvalidDepthAttachmentFormat) {
1734 TEST_DESCRIPTION("Test begin rendering with a depth attachment that has an invalid format");
1735
1736 SetTargetApiVersion(VK_API_VERSION_1_3);
1737 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1738
1739 ASSERT_NO_FATAL_FAILURE(InitFramework());
1740
1741 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001742 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001743 }
1744
sjfricked700bc02022-05-30 16:35:06 +09001745 if (!AreRequiredExtensionsEnabled()) {
1746 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001747 }
1748
1749 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1750 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1751 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1752 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001753 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001754 }
1755
1756 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1757
1758 VkFormat stencil_format = FindSupportedStencilOnlyFormat(gpu());
1759 if (stencil_format == VK_FORMAT_UNDEFINED) {
1760 printf("%s requires a stencil only format format.\n", kSkipPrefix);
1761 return;
1762 }
1763
1764 VkImageObj image(m_device);
1765 image.Init(32, 32, 1, stencil_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
1766 VkImageView image_view = image.targetView(stencil_format, VK_IMAGE_ASPECT_STENCIL_BIT);
1767
1768 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1769 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
1770 depth_attachment.imageView = image_view;
1771
1772 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
ziga-lunarg1fec6332022-03-20 14:39:54 +01001773 begin_rendering_info.layerCount = 1;
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001774 begin_rendering_info.pDepthAttachment = &depth_attachment;
1775
1776 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06547");
1777 m_commandBuffer->BeginRendering(begin_rendering_info);
1778 m_errorMonitor->VerifyFound();
1779}
ziga-lunarg4b5bb5b2022-03-20 00:49:04 +01001780
ziga-lunarg14a69782022-03-20 00:39:31 +01001781TEST_F(VkLayerTest, TestFragmentDensityMapRenderArea) {
1782 TEST_DESCRIPTION("Validate VkRenderingFragmentDensityMapAttachmentInfo attachment image view extent.");
1783
1784 SetTargetApiVersion(VK_API_VERSION_1_1);
1785 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1786 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1787
1788 ASSERT_NO_FATAL_FAILURE(InitFramework());
1789
1790 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001791 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg14a69782022-03-20 00:39:31 +01001792 }
1793
sjfricked700bc02022-05-30 16:35:06 +09001794 if (!AreRequiredExtensionsEnabled()) {
1795 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg14a69782022-03-20 00:39:31 +01001796 }
1797
1798 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1799 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1800 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1801 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001802 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg14a69782022-03-20 00:39:31 +01001803 }
1804
1805 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1806
1807 auto fdm_props = LvlInitStruct<VkPhysicalDeviceFragmentDensityMapPropertiesEXT>();
1808 auto props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fdm_props);
1809 vk::GetPhysicalDeviceProperties2(gpu(), &props2);
1810
1811 VkImageObj image(m_device);
ziga-lunarg2aa8d592022-04-25 14:29:13 +02001812 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT,
1813 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT);
ziga-lunarg14a69782022-03-20 00:39:31 +01001814 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1);
1815
1816 auto fragment_density_map = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
1817 fragment_density_map.imageView = image_view;
ziga-lunarg2aa8d592022-04-25 14:29:13 +02001818 fragment_density_map.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1819
ziga-lunarg14a69782022-03-20 00:39:31 +01001820 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_density_map);
1821 begin_rendering_info.layerCount = 1;
1822 begin_rendering_info.renderArea.extent.width = 64 * fdm_props.maxFragmentDensityTexelSize.width;
1823 begin_rendering_info.renderArea.extent.height = 32 * fdm_props.maxFragmentDensityTexelSize.height;
1824
1825 m_commandBuffer->begin();
1826
1827 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06112");
1828 m_commandBuffer->BeginRendering(begin_rendering_info);
1829 m_errorMonitor->VerifyFound();
1830
1831 begin_rendering_info.renderArea.extent.width = 32 * fdm_props.maxFragmentDensityTexelSize.width;
1832 begin_rendering_info.renderArea.extent.height = 64 * fdm_props.maxFragmentDensityTexelSize.height;
1833
1834 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06114");
1835 m_commandBuffer->BeginRendering(begin_rendering_info);
1836 m_errorMonitor->VerifyFound();
1837
1838 VkRect2D device_render_area = {};
1839 device_render_area.extent.width = 64 * fdm_props.maxFragmentDensityTexelSize.width;
1840 device_render_area.extent.height = 32 * fdm_props.maxFragmentDensityTexelSize.height;
1841 auto device_group_render_pass_begin_info = LvlInitStruct<VkDeviceGroupRenderPassBeginInfo>();
1842 device_group_render_pass_begin_info.deviceRenderAreaCount = 1;
1843 device_group_render_pass_begin_info.pDeviceRenderAreas = &device_render_area;
1844 fragment_density_map.pNext = &device_group_render_pass_begin_info;
1845
1846 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06113");
1847 m_commandBuffer->BeginRendering(begin_rendering_info);
1848 m_errorMonitor->VerifyFound();
1849
1850 device_render_area.extent.width = 32 * fdm_props.maxFragmentDensityTexelSize.width;
1851 device_render_area.extent.height = 64 * fdm_props.maxFragmentDensityTexelSize.height;
1852
1853 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06115");
1854 m_commandBuffer->BeginRendering(begin_rendering_info);
1855 m_errorMonitor->VerifyFound();
1856
1857 m_commandBuffer->end();
1858}
1859
ziga-lunarg50253b92022-04-25 14:36:13 +02001860TEST_F(VkLayerTest, TestFragmentDensityMapRenderAreaWithoutDeviceGroupExt) {
1861 TEST_DESCRIPTION("Validate VkRenderingFragmentDensityMapAttachmentInfo attachment image view extent.");
1862
1863 SetTargetApiVersion(VK_API_VERSION_1_0);
1864 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1865 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1866
1867 ASSERT_NO_FATAL_FAILURE(InitFramework());
1868
1869 if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
sjfricke50955f32022-06-05 10:12:52 +09001870 GTEST_SKIP() << "Tests for 1.0 only";
ziga-lunarg50253b92022-04-25 14:36:13 +02001871 }
1872
sjfricked700bc02022-05-30 16:35:06 +09001873 if (!AreRequiredExtensionsEnabled()) {
1874 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg50253b92022-04-25 14:36:13 +02001875 }
1876
1877 auto vkGetPhysicalDeviceFeatures2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2KHR>(
1878 vk::GetInstanceProcAddr(instance(), "vkGetPhysicalDeviceFeatures2KHR"));
1879 ASSERT_TRUE(vkGetPhysicalDeviceFeatures2KHR != nullptr);
1880
1881 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1882 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2KHR>(&dynamic_rendering_features);
1883 vkGetPhysicalDeviceFeatures2KHR(gpu(), &features2);
1884 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001885 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg50253b92022-04-25 14:36:13 +02001886 }
1887
1888 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1889
1890 auto fdm_props = LvlInitStruct<VkPhysicalDeviceFragmentDensityMapPropertiesEXT>();
1891 auto props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fdm_props);
1892 vk::GetPhysicalDeviceProperties2(gpu(), &props2);
1893
1894 VkImageObj image(m_device);
1895 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT,
1896 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT);
1897 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1);
1898
1899 auto fragment_density_map = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
1900 fragment_density_map.imageView = image_view;
1901 fragment_density_map.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1902
1903 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_density_map);
1904 begin_rendering_info.layerCount = 1;
1905 begin_rendering_info.renderArea.extent.width = 64 * fdm_props.maxFragmentDensityTexelSize.width;
1906 begin_rendering_info.renderArea.extent.height = 32 * fdm_props.maxFragmentDensityTexelSize.height;
1907
1908 m_commandBuffer->begin();
1909
1910 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06110");
1911 m_commandBuffer->BeginRendering(begin_rendering_info);
1912 m_errorMonitor->VerifyFound();
1913
1914 begin_rendering_info.renderArea.extent.width = 32 * fdm_props.maxFragmentDensityTexelSize.width;
1915 begin_rendering_info.renderArea.extent.height = 64 * fdm_props.maxFragmentDensityTexelSize.height;
1916
1917 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06111");
1918 m_commandBuffer->BeginRendering(begin_rendering_info);
1919 m_errorMonitor->VerifyFound();
1920
1921 m_commandBuffer->end();
1922}
1923
ziga-lunarge7279ba2022-03-31 20:55:27 +02001924TEST_F(VkLayerTest, TestBarrierWithDynamicRendering) {
1925 TEST_DESCRIPTION("Test setting buffer memory barrier when dynamic rendering is active.");
1926
1927 SetTargetApiVersion(VK_API_VERSION_1_3);
1928
1929 ASSERT_NO_FATAL_FAILURE(InitFramework());
1930
1931 if (DeviceValidationVersion() < VK_API_VERSION_1_3) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001932 GTEST_SKIP() << "At least Vulkan version 1.3 is required";
ziga-lunarge7279ba2022-03-31 20:55:27 +02001933 }
1934
1935 auto vk13features = LvlInitStruct<VkPhysicalDeviceVulkan13Features>();
1936 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&vk13features);
1937 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1938 if (!vk13features.dynamicRendering) {
1939 printf("%s Test requires (unsupported) dynamicRendering, skipping\n", kSkipPrefix);
1940 return;
1941 }
1942 if (!vk13features.synchronization2) {
1943 printf("%s Test requires (unsupported) synchronization2, skipping\n", kSkipPrefix);
1944 return;
1945 }
1946
1947 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1948 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
1949
1950 PFN_vkCmdBeginRendering vkCmdBeginRendering =
1951 reinterpret_cast<PFN_vkCmdBeginRendering>(vk::GetDeviceProcAddr(m_device->device(), "vkCmdBeginRendering"));
1952 assert(vkCmdBeginRendering != nullptr);
1953 PFN_vkCmdEndRendering vkCmdEndRendering =
1954 reinterpret_cast<PFN_vkCmdEndRendering>(vk::GetDeviceProcAddr(m_device->device(), "vkCmdEndRendering"));
1955 assert(vkCmdEndRendering != nullptr);
1956
1957 m_commandBuffer->begin();
1958
1959 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
1960 VkClearRect clear_rect = {{{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}, 0, 1};
1961 begin_rendering_info.renderArea = clear_rect.rect;
1962 begin_rendering_info.layerCount = 1;
1963
1964 vkCmdBeginRendering(m_commandBuffer->handle(), &begin_rendering_info);
1965
1966 VkBufferObj buffer;
1967 VkMemoryPropertyFlags mem_reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
1968 buffer.init_as_src_and_dst(*m_device, 256, mem_reqs);
1969
1970 auto buf_barrier = lvl_init_struct<VkBufferMemoryBarrier2KHR>();
1971 buf_barrier.buffer = buffer.handle();
1972 buf_barrier.offset = 0;
1973 buf_barrier.size = VK_WHOLE_SIZE;
1974 buf_barrier.srcStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
1975 buf_barrier.dstStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
1976
1977 auto dependency_info = lvl_init_struct<VkDependencyInfoKHR>();
1978 dependency_info.bufferMemoryBarrierCount = 1;
1979 dependency_info.pBufferMemoryBarriers = &buf_barrier;
1980 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPipelineBarrier2-None-06191");
1981 vk::CmdPipelineBarrier2(m_commandBuffer->handle(), &dependency_info);
1982 m_errorMonitor->VerifyFound();
1983
1984 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPipelineBarrier-None-06191");
1985 vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, 0,
1986 nullptr, 0, nullptr, 0, nullptr);
1987 m_errorMonitor->VerifyFound();
1988
1989 vkCmdEndRendering(m_commandBuffer->handle());
1990 m_commandBuffer->end();
1991}
1992
ziga-lunarg5e0a2452022-04-20 19:29:37 +02001993TEST_F(VkLayerTest, BeginRenderingInvalidStencilAttachmentFormat) {
1994 TEST_DESCRIPTION("Test begin rendering with a stencil attachment that has an invalid format");
1995
1996 SetTargetApiVersion(VK_API_VERSION_1_3);
1997 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1998
1999 ASSERT_NO_FATAL_FAILURE(InitFramework());
2000
2001 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
2002 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
2003 }
2004
sjfricked700bc02022-05-30 16:35:06 +09002005 if (!AreRequiredExtensionsEnabled()) {
2006 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002007 }
2008
2009 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2010 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2011 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2012 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002013 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002014 }
2015
2016 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2017
2018 VkFormat depth_format = FindSupportedDepthOnlyFormat(gpu());
2019 if (depth_format == VK_FORMAT_UNDEFINED) {
2020 printf("%s requires a stencil only format format.\n", kSkipPrefix);
2021 return;
2022 }
2023
2024 VkImageObj image(m_device);
2025 image.Init(32, 32, 1, depth_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
2026 VkImageView image_view = image.targetView(depth_format, VK_IMAGE_ASPECT_DEPTH_BIT);
2027
2028 VkRenderingAttachmentInfoKHR stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2029 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL;
2030 stencil_attachment.imageView = image_view;
2031
2032 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2033 begin_rendering_info.layerCount = 1;
2034 begin_rendering_info.pStencilAttachment = &stencil_attachment;
2035
2036 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06548");
2037 m_commandBuffer->BeginRendering(begin_rendering_info);
2038 m_errorMonitor->VerifyFound();
2039}
2040
2041TEST_F(VkLayerTest, TestInheritanceRenderingInfoStencilAttachmentFormat) {
2042 TEST_DESCRIPTION("Test begin rendering with a stencil attachment that has an invalid format");
2043
2044 SetTargetApiVersion(VK_API_VERSION_1_3);
2045 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2046
2047 ASSERT_NO_FATAL_FAILURE(InitFramework());
2048
2049 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
2050 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
2051 }
2052
sjfricked700bc02022-05-30 16:35:06 +09002053 if (!AreRequiredExtensionsEnabled()) {
2054 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002055 }
2056
2057 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2058 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2059 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2060 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002061 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002062 }
2063
2064 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2065
2066 VkFormat depth_format = FindSupportedDepthOnlyFormat(gpu());
2067 if (depth_format == VK_FORMAT_UNDEFINED) {
2068 printf("%s requires a stencil only format format.\n", kSkipPrefix);
2069 return;
2070 }
2071
2072 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2073
2074 auto cmd_buffer_inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>();
2075 cmd_buffer_inheritance_rendering_info.colorAttachmentCount = 1;
2076 cmd_buffer_inheritance_rendering_info.pColorAttachmentFormats = &color_format;
2077 cmd_buffer_inheritance_rendering_info.depthAttachmentFormat = depth_format;
2078 cmd_buffer_inheritance_rendering_info.stencilAttachmentFormat = depth_format;
2079 cmd_buffer_inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
2080
2081 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2082 cmd_buffer_inheritance_info.pNext = &cmd_buffer_inheritance_rendering_info;
2083 cmd_buffer_inheritance_info.renderPass = VK_NULL_HANDLE;
2084
2085 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2086 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2087 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2088
2089 auto cmd_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>();
2090 cmd_buffer_allocate_info.commandPool = m_commandPool->handle();
2091 cmd_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY;
2092 cmd_buffer_allocate_info.commandBufferCount = 1;
2093
2094 VkCommandBuffer secondary_cmd_buffer;
ziga-lunarga3cc8482022-04-29 14:58:29 +02002095 vk::AllocateCommandBuffers(m_device->device(), &cmd_buffer_allocate_info, &secondary_cmd_buffer);
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002096
2097 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-stencilAttachmentFormat-06541");
2098 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
2099 m_errorMonitor->VerifyFound();
2100}
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002101
2102TEST_F(VkLayerTest, CreateGraphicsPipelineWithInvalidAttachmentSampleCount) {
2103 TEST_DESCRIPTION("Create pipeline with fragment shader that uses samples, but multisample state not begin set");
2104
ziga-lunarg7f25dff2022-05-06 17:49:34 +02002105 SetTargetApiVersion(VK_API_VERSION_1_1);
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002106 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2107 AddRequiredExtensions(VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME);
2108
2109 ASSERT_NO_FATAL_FAILURE(InitFramework());
2110
2111 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002112 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002113 }
2114
sjfricked700bc02022-05-30 16:35:06 +09002115 if (!AreRequiredExtensionsEnabled()) {
2116 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002117 }
2118
2119 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2120 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2121 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2122 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002123 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002124 }
2125
2126 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2127 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2128
2129 auto sample_count_info_amd = LvlInitStruct<VkAttachmentSampleCountInfoNV>();
2130 sample_count_info_amd.colorAttachmentCount = 1;
ziga-lunarg7f25dff2022-05-06 17:49:34 +02002131 sample_count_info_amd.depthStencilAttachmentSamples = static_cast<VkSampleCountFlagBits>(0x3);
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002132
2133 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(&sample_count_info_amd);
2134 pipeline_rendering_info.colorAttachmentCount = 1;
2135 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2136
2137 CreatePipelineHelper pipe(*this);
2138 pipe.InitInfo();
2139 pipe.gp_ci_.pNext = &pipeline_rendering_info;
2140 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2141 pipe.InitState();
2142
2143 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-depthStencilAttachmentSamples-06593");
2144 pipe.CreateGraphicsPipeline();
2145 m_errorMonitor->VerifyFound();
2146}
ziga-lunargd680bf22022-04-20 22:01:00 +02002147
2148TEST_F(VkLayerTest, CreatePipelineUsingDynamicRenderingWithoutFeature) {
2149 TEST_DESCRIPTION("Create graphcis pipeline that uses dynamic rendering, but feature is not enabled");
2150
2151 SetTargetApiVersion(VK_API_VERSION_1_3);
2152 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2153 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
2154
2155 ASSERT_NO_FATAL_FAILURE(InitFramework());
2156
2157 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002158 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargd680bf22022-04-20 22:01:00 +02002159 }
2160
sjfricked700bc02022-05-30 16:35:06 +09002161 if (!AreRequiredExtensionsEnabled()) {
2162 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargd680bf22022-04-20 22:01:00 +02002163 }
2164
2165 ASSERT_NO_FATAL_FAILURE(InitState());
2166
2167 CreatePipelineHelper pipe(*this);
2168 pipe.InitInfo();
2169 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2170 pipe.InitState();
2171
2172 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-dynamicRendering-06576");
2173 pipe.CreateGraphicsPipeline();
2174 m_errorMonitor->VerifyFound();
2175}
ziga-lunargf20d7952022-04-20 22:11:40 +02002176
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002177TEST_F(VkLayerTest, DynamicRenderingAreaGreaterThanAttachmentExtent) {
2178 TEST_DESCRIPTION("Begin dynamic rendering with render area greater than extent of attachments");
2179
2180 SetTargetApiVersion(VK_API_VERSION_1_0);
2181 AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
2182 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2183 ASSERT_NO_FATAL_FAILURE(InitFramework());
2184
2185 if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
sjfricke50955f32022-06-05 10:12:52 +09002186 GTEST_SKIP() << "Tests for 1.0 only";
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002187 }
sjfricked700bc02022-05-30 16:35:06 +09002188 if (!AreRequiredExtensionsEnabled()) {
2189 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002190 }
2191
ziga-lunarga51287c2022-04-20 23:24:37 +02002192 auto vkGetPhysicalDeviceFeatures2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2KHR>(
2193 vk::GetInstanceProcAddr(instance(), "vkGetPhysicalDeviceFeatures2KHR"));
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002194 ASSERT_TRUE(vkGetPhysicalDeviceFeatures2KHR != nullptr);
2195
2196 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2197 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2KHR>(&dynamic_rendering_features);
2198 vkGetPhysicalDeviceFeatures2KHR(gpu(), &features2);
2199 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002200 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002201 }
2202
2203 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2204
2205 VkImageObj colorImage(m_device);
2206 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
2207 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
2208
ziga-lunarga51287c2022-04-20 23:24:37 +02002209 auto color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002210 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2211 color_attachment.imageView = colorImageView;
2212
ziga-lunarga51287c2022-04-20 23:24:37 +02002213 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002214 begin_rendering_info.layerCount = 1;
2215 begin_rendering_info.colorAttachmentCount = 1;
2216 begin_rendering_info.pColorAttachments = &color_attachment;
2217 begin_rendering_info.renderArea.extent.width = 64;
2218 begin_rendering_info.renderArea.extent.height = 32;
2219
2220 m_commandBuffer->begin();
2221
2222 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06075");
2223 m_commandBuffer->BeginRendering(begin_rendering_info);
2224 m_errorMonitor->VerifyFound();
2225
2226 begin_rendering_info.renderArea.extent.width = 32;
2227 begin_rendering_info.renderArea.extent.height = 64;
2228
2229 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06076");
2230 m_commandBuffer->BeginRendering(begin_rendering_info);
2231 m_errorMonitor->VerifyFound();
2232
2233 const VkFormat ds_format = FindSupportedDepthStencilFormat(gpu());
2234 if (ds_format != VK_FORMAT_UNDEFINED) {
2235 VkImageObj depthImage(m_device);
2236 depthImage.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
2237 VkImageView depthImageView = depthImage.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT);
2238
2239 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2240 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
2241 depth_attachment.imageView = depthImageView;
2242
2243 begin_rendering_info.colorAttachmentCount = 0;
2244 begin_rendering_info.pDepthAttachment = &depth_attachment;
2245
2246 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06076");
2247 m_commandBuffer->BeginRendering(begin_rendering_info);
2248 m_errorMonitor->VerifyFound();
2249 }
2250
2251 m_commandBuffer->end();
2252}
ziga-lunarga51287c2022-04-20 23:24:37 +02002253
2254TEST_F(VkLayerTest, DynamicRenderingDeviceGroupAreaGreaterThanAttachmentExtent) {
2255 TEST_DESCRIPTION("Begin dynamic rendering with device group with render area greater than extent of attachments");
2256
2257 SetTargetApiVersion(VK_API_VERSION_1_1);
2258 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2259 ASSERT_NO_FATAL_FAILURE(InitFramework());
2260
2261 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002262 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarga51287c2022-04-20 23:24:37 +02002263 }
sjfricked700bc02022-05-30 16:35:06 +09002264 if (!AreRequiredExtensionsEnabled()) {
2265 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarga51287c2022-04-20 23:24:37 +02002266 }
2267
2268 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2269 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2270 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2271 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002272 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarga51287c2022-04-20 23:24:37 +02002273 }
2274
2275 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2276
2277 VkImageObj colorImage(m_device);
2278 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
2279 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
2280
2281 auto color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2282 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2283 color_attachment.imageView = colorImageView;
2284
2285 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2286 begin_rendering_info.layerCount = 1;
2287 begin_rendering_info.colorAttachmentCount = 1;
2288 begin_rendering_info.pColorAttachments = &color_attachment;
2289 begin_rendering_info.renderArea.extent.width = 64;
2290 begin_rendering_info.renderArea.extent.height = 32;
2291
2292 m_commandBuffer->begin();
2293
2294 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06079");
2295 m_commandBuffer->BeginRendering(begin_rendering_info);
2296 m_errorMonitor->VerifyFound();
2297
2298 begin_rendering_info.renderArea.extent.width = 32;
2299 begin_rendering_info.renderArea.extent.height = 64;
2300
2301 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06080");
2302 m_commandBuffer->BeginRendering(begin_rendering_info);
2303 m_errorMonitor->VerifyFound();
2304
2305 const VkFormat ds_format = FindSupportedDepthStencilFormat(gpu());
2306 if (ds_format != VK_FORMAT_UNDEFINED) {
2307 VkImageObj depthImage(m_device);
2308 depthImage.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
2309 VkImageView depthImageView = depthImage.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT);
2310
2311 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2312 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
2313 depth_attachment.imageView = depthImageView;
2314
2315 begin_rendering_info.colorAttachmentCount = 0;
2316 begin_rendering_info.pDepthAttachment = &depth_attachment;
2317
2318 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06080");
2319 m_commandBuffer->BeginRendering(begin_rendering_info);
2320 m_errorMonitor->VerifyFound();
2321 }
2322
2323 m_commandBuffer->end();
2324}
ziga-lunargd4105c12022-04-21 13:54:20 +02002325
2326TEST_F(VkLayerTest, SecondaryCommandBufferIncompatibleRenderPass) {
2327 TEST_DESCRIPTION("Execute secondary command buffers within render pass instance with incompatible render pass");
2328
2329 SetTargetApiVersion(VK_API_VERSION_1_1);
2330 ASSERT_NO_FATAL_FAILURE(InitFramework());
2331
2332 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002333 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargd4105c12022-04-21 13:54:20 +02002334 }
2335
2336 ASSERT_NO_FATAL_FAILURE(InitState());
2337 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2338
ziga-lunarga3cc8482022-04-29 14:58:29 +02002339 VkSubpassDescription subpass = {};
ziga-lunargd4105c12022-04-21 13:54:20 +02002340 auto render_pass_ci = LvlInitStruct<VkRenderPassCreateInfo>();
ziga-lunarga3cc8482022-04-29 14:58:29 +02002341 render_pass_ci.subpassCount = 1;
2342 render_pass_ci.pSubpasses = &subpass;
ziga-lunargd4105c12022-04-21 13:54:20 +02002343
2344 vk_testing::RenderPass render_pass;
2345 render_pass.init(*m_device, render_pass_ci);
2346
2347 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2348 VkCommandBuffer secondary_handle = cb.handle();
2349
2350 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2351 cmd_buffer_inheritance_info.renderPass = render_pass.handle();
2352 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2353 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2354 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2355
2356 cb.begin(&cmd_buffer_begin_info);
2357 cb.end();
2358
2359 m_commandBuffer->begin();
2360 m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
2361
2362 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pBeginInfo-06020");
2363 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pInheritanceInfo-00098");
2364 vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle);
2365 m_errorMonitor->VerifyFound();
2366
2367 m_commandBuffer->EndRenderPass();
2368 m_commandBuffer->end();
2369}
ziga-lunarg590e0292022-04-21 14:07:22 +02002370
2371TEST_F(VkLayerTest, SecondaryCommandBufferIncompatibleSubpass) {
2372 TEST_DESCRIPTION("Execute secondary command buffers with different subpass");
2373
2374 SetTargetApiVersion(VK_API_VERSION_1_1);
2375 ASSERT_NO_FATAL_FAILURE(InitFramework());
2376
2377 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002378 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg590e0292022-04-21 14:07:22 +02002379 }
2380
2381 ASSERT_NO_FATAL_FAILURE(InitState());
2382
2383 VkSubpassDescription subpasses[2] = {};
2384
2385 auto render_pass_ci = LvlInitStruct<VkRenderPassCreateInfo>();
2386 render_pass_ci.subpassCount = 2;
2387 render_pass_ci.pSubpasses = subpasses;
2388
2389 vk_testing::RenderPass render_pass;
2390 render_pass.init(*m_device, render_pass_ci);
2391
2392 auto framebuffer_ci = LvlInitStruct<VkFramebufferCreateInfo>();
2393 framebuffer_ci.renderPass = render_pass.handle();
2394 framebuffer_ci.width = 32;
2395 framebuffer_ci.height = 32;
ziga-lunarg143bdbf2022-05-04 19:04:58 +02002396 framebuffer_ci.layers = 1;
ziga-lunarg590e0292022-04-21 14:07:22 +02002397
2398 vk_testing::Framebuffer framebuffer;
2399 framebuffer.init(*m_device, framebuffer_ci);
2400
2401 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2402 VkCommandBuffer secondary_handle = cb.handle();
2403
2404 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2405 cmd_buffer_inheritance_info.renderPass = render_pass.handle();
2406 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2407 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2408 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2409
2410 cb.begin(&cmd_buffer_begin_info);
2411 cb.end();
2412
2413 auto render_pass_begin_info = LvlInitStruct<VkRenderPassBeginInfo>();
2414 render_pass_begin_info.renderPass = render_pass.handle();
2415 render_pass_begin_info.renderArea.extent = {32, 32};
2416 render_pass_begin_info.framebuffer = framebuffer.handle();
2417
2418 m_commandBuffer->begin();
2419 m_commandBuffer->BeginRenderPass(render_pass_begin_info, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
2420 vk::CmdNextSubpass(m_commandBuffer->handle(), VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
2421
2422 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pCommandBuffers-00097");
2423 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pCommandBuffers-06019");
2424 vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle);
2425 m_errorMonitor->VerifyFound();
2426
2427 m_commandBuffer->EndRenderPass();
2428 m_commandBuffer->end();
2429}
ziga-lunarg343193b2022-04-21 14:15:17 +02002430
2431TEST_F(VkLayerTest, SecondaryCommandBufferInvalidContents) {
2432 TEST_DESCRIPTION("Execute secondary command buffers within active render pass that was not begun with VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS");
2433
2434 SetTargetApiVersion(VK_API_VERSION_1_1);
2435 ASSERT_NO_FATAL_FAILURE(InitFramework());
2436
2437 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002438 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg343193b2022-04-21 14:15:17 +02002439 }
2440
2441 ASSERT_NO_FATAL_FAILURE(InitState());
2442 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2443
ziga-lunarg343193b2022-04-21 14:15:17 +02002444 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2445 VkCommandBuffer secondary_handle = cb.handle();
2446
2447 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2448 cmd_buffer_inheritance_info.renderPass = m_renderPass;
2449 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2450 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2451 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2452
2453 cb.begin(&cmd_buffer_begin_info);
2454 cb.end();
2455
2456 m_commandBuffer->begin();
2457 m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo);
2458
2459 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-contents-00095");
2460 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-contents-06018");
2461 vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle);
2462 m_errorMonitor->VerifyFound();
2463
2464 m_commandBuffer->EndRenderPass();
2465 m_commandBuffer->end();
2466}
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002467
2468TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoDepthFormat) {
2469 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo DepthFormat incompatible with previously used pipeline");
2470
2471 SetTargetApiVersion(VK_API_VERSION_1_1);
2472 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2473 ASSERT_NO_FATAL_FAILURE(InitFramework());
2474
2475 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002476 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002477 }
sjfricked700bc02022-05-30 16:35:06 +09002478 if (!AreRequiredExtensionsEnabled()) {
2479 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002480 }
2481
2482 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2483 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2484 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2485 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002486 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002487 }
2488
2489 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2490 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2491
2492 m_errorMonitor->ExpectSuccess();
2493
2494 std::vector<VkFormat> depth_formats;
2495 const VkFormat ds_formats[] = {VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT};
2496 for (uint32_t i = 0; i < size(ds_formats); ++i) {
2497 VkFormatProperties format_props;
2498 vk::GetPhysicalDeviceFormatProperties(gpu(), ds_formats[i], &format_props);
2499
2500 if (format_props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) {
2501 depth_formats.push_back(ds_formats[i]);
2502 }
2503 }
2504
2505 if (depth_formats.size() < 2) {
2506 printf("%s Test requires 2 depth formats, skipping test.\n", kSkipPrefix);
2507 return;
2508 }
2509
2510 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2511 pipeline_rendering_info.depthAttachmentFormat = depth_formats[0];
2512
2513 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
2514
2515 CreatePipelineHelper pipe1(*this);
2516 pipe1.InitInfo();
2517 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2518 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2519 pipe1.InitState();
2520 pipe1.ds_ci_ = ds_ci;
2521 pipe1.CreateGraphicsPipeline();
2522
2523 pipeline_rendering_info.depthAttachmentFormat = depth_formats[1];
2524
2525 CreatePipelineHelper pipe2(*this);
2526 pipe2.InitInfo();
2527 pipe2.gp_ci_.pNext = &pipeline_rendering_info;
2528 pipe2.gp_ci_.renderPass = VK_NULL_HANDLE;
2529 pipe2.InitState();
2530 pipe2.ds_ci_ = ds_ci;
2531 pipe2.CreateGraphicsPipeline();
2532
2533 VkImageObj image(m_device);
2534 image.Init(32, 32, 1, depth_formats[0], VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2535 VkImageView depth_image_view = image.targetView(depth_formats[0], VK_IMAGE_ASPECT_DEPTH_BIT);
2536
2537 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2538 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
2539 depth_attachment.imageView = depth_image_view;
2540
2541 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2542 begin_rendering_info.layerCount = 1;
2543 begin_rendering_info.pDepthAttachment = &depth_attachment;
2544
2545 m_commandBuffer->begin();
2546 m_commandBuffer->BeginRendering(begin_rendering_info);
2547
2548 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_);
2549 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
2550
2551 m_errorMonitor->VerifyNotFound();
2552
2553 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06197");
2554 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_);
2555 m_errorMonitor->VerifyFound();
2556
2557 m_commandBuffer->EndRendering();
2558 m_commandBuffer->end();
2559}
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002560
2561TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoColorAttachments) {
2562 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo color attachment incompatible with previously used pipeline");
2563
2564 SetTargetApiVersion(VK_API_VERSION_1_1);
2565 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2566 ASSERT_NO_FATAL_FAILURE(InitFramework());
2567
2568 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002569 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002570 }
sjfricked700bc02022-05-30 16:35:06 +09002571 if (!AreRequiredExtensionsEnabled()) {
2572 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002573 }
2574
2575 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2576 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2577 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2578 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002579 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002580 }
2581
2582 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2583 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2584
2585 m_errorMonitor->ExpectSuccess();
2586
2587 VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
2588 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2589 pipeline_rendering_info.colorAttachmentCount = 1;
2590 pipeline_rendering_info.pColorAttachmentFormats = &format;
2591
2592 CreatePipelineHelper pipe1(*this);
2593 pipe1.InitInfo();
2594 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2595 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2596 pipe1.InitState();
2597 pipe1.CreateGraphicsPipeline();
2598
2599 format = VK_FORMAT_B8G8R8A8_UNORM;
2600
2601 CreatePipelineHelper pipe2(*this);
2602 pipe2.InitInfo();
2603 pipe2.gp_ci_.pNext = &pipeline_rendering_info;
2604 pipe2.gp_ci_.renderPass = VK_NULL_HANDLE;
2605 pipe2.InitState();
2606 pipe2.CreateGraphicsPipeline();
2607
2608 VkImageObj image(m_device);
2609 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2610 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
2611
2612 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2613 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2614 color_attachment.imageView = image_view;
2615
2616 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2617 begin_rendering_info.layerCount = 1;
2618 begin_rendering_info.colorAttachmentCount = 1;
2619 begin_rendering_info.pColorAttachments = &color_attachment;
2620
2621 m_commandBuffer->begin();
2622 m_commandBuffer->BeginRendering(begin_rendering_info);
2623
2624 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_);
2625 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
2626
2627 m_errorMonitor->VerifyNotFound();
2628
2629 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06196");
2630 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_);
2631 m_errorMonitor->VerifyFound();
2632
2633 m_commandBuffer->EndRendering();
2634 m_commandBuffer->end();
2635}
ziga-lunargacd79322022-04-21 18:36:34 +02002636
2637TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoColorAttachmentCount) {
2638 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo color attachment count incompatible with previously used pipeline");
2639
2640 SetTargetApiVersion(VK_API_VERSION_1_1);
2641 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2642 ASSERT_NO_FATAL_FAILURE(InitFramework());
2643
2644 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002645 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargacd79322022-04-21 18:36:34 +02002646 }
sjfricked700bc02022-05-30 16:35:06 +09002647 if (!AreRequiredExtensionsEnabled()) {
2648 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargacd79322022-04-21 18:36:34 +02002649 }
2650
2651 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2652 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2653 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2654 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002655 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargacd79322022-04-21 18:36:34 +02002656 }
2657
2658 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2659 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2660
2661 m_errorMonitor->ExpectSuccess();
2662
2663 VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
2664 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2665 pipeline_rendering_info.colorAttachmentCount = 1;
2666 pipeline_rendering_info.pColorAttachmentFormats = &format;
2667
2668 CreatePipelineHelper pipe1(*this);
2669 pipe1.InitInfo();
2670 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2671 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2672 pipe1.InitState();
2673 pipe1.CreateGraphicsPipeline();
2674
2675 pipeline_rendering_info.colorAttachmentCount = 0;
2676
2677 CreatePipelineHelper pipe2(*this);
2678 pipe2.InitInfo();
2679 pipe2.gp_ci_.pNext = &pipeline_rendering_info;
2680 pipe2.gp_ci_.renderPass = VK_NULL_HANDLE;
2681 pipe2.InitState();
2682 pipe2.CreateGraphicsPipeline();
2683
2684 VkImageObj image(m_device);
2685 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2686 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
2687
2688 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2689 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2690 color_attachment.imageView = image_view;
2691
2692 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2693 begin_rendering_info.layerCount = 1;
2694 begin_rendering_info.colorAttachmentCount = 1;
2695 begin_rendering_info.pColorAttachments = &color_attachment;
2696
2697 m_commandBuffer->begin();
2698 m_commandBuffer->BeginRendering(begin_rendering_info);
2699
2700 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_);
2701 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
2702
2703 m_errorMonitor->VerifyNotFound();
2704
2705 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06195");
2706 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_);
2707 m_errorMonitor->VerifyFound();
2708
2709 m_commandBuffer->EndRendering();
2710 m_commandBuffer->end();
ziga-lunarge3f11282022-04-21 18:39:55 +02002711}
2712
2713TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoStencilFormat) {
2714 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo StencilFormat incompatible with previously used pipeline");
2715
2716 SetTargetApiVersion(VK_API_VERSION_1_1);
2717 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2718 ASSERT_NO_FATAL_FAILURE(InitFramework());
2719
2720 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002721 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge3f11282022-04-21 18:39:55 +02002722 }
sjfricked700bc02022-05-30 16:35:06 +09002723 if (!AreRequiredExtensionsEnabled()) {
2724 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge3f11282022-04-21 18:39:55 +02002725 }
2726
2727 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2728 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2729 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2730 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002731 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge3f11282022-04-21 18:39:55 +02002732 }
2733
2734 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2735 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2736
2737 m_errorMonitor->ExpectSuccess();
2738
2739 std::vector<VkFormat> stencil_formats;
2740 const VkFormat ds_formats[] = {VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT};
2741 for (uint32_t i = 0; i < size(ds_formats); ++i) {
2742 VkFormatProperties format_props;
2743 vk::GetPhysicalDeviceFormatProperties(gpu(), ds_formats[i], &format_props);
2744
2745 if (format_props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) {
2746 stencil_formats.push_back(ds_formats[i]);
2747 }
2748 }
2749
2750 if (stencil_formats.size() < 2) {
2751 printf("%s Test requires 2 stencil formats, skipping test.\n", kSkipPrefix);
2752 return;
2753 }
2754
2755 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2756 pipeline_rendering_info.stencilAttachmentFormat = stencil_formats[0];
2757
2758 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
2759
2760 CreatePipelineHelper pipe1(*this);
2761 pipe1.InitInfo();
2762 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2763 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2764 pipe1.InitState();
2765 pipe1.ds_ci_ = ds_ci;
2766 pipe1.CreateGraphicsPipeline();
2767
2768 pipeline_rendering_info.stencilAttachmentFormat = stencil_formats[1];
2769
2770 CreatePipelineHelper pipe2(*this);
2771 pipe2.InitInfo();
2772 pipe2.gp_ci_.pNext = &pipeline_rendering_info;
2773 pipe2.gp_ci_.renderPass = VK_NULL_HANDLE;
2774 pipe2.InitState();
2775 pipe2.ds_ci_ = ds_ci;
2776 pipe2.CreateGraphicsPipeline();
2777
2778 VkImageObj image(m_device);
2779 image.Init(32, 32, 1, stencil_formats[0], VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2780 VkImageView stencil_image_view = image.targetView(stencil_formats[0], VK_IMAGE_ASPECT_DEPTH_BIT);
2781
2782 VkRenderingAttachmentInfoKHR stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2783 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL;
2784 stencil_attachment.imageView = stencil_image_view;
2785
2786 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2787 begin_rendering_info.layerCount = 1;
2788 begin_rendering_info.pStencilAttachment = &stencil_attachment;
2789
2790 m_commandBuffer->begin();
2791 m_commandBuffer->BeginRendering(begin_rendering_info);
2792
2793 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_);
2794 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
2795
2796 m_errorMonitor->VerifyNotFound();
2797
2798 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06194");
2799 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_);
2800 m_errorMonitor->VerifyFound();
2801
2802 m_commandBuffer->EndRendering();
2803 m_commandBuffer->end();
2804}
ziga-lunarg155ed452022-04-21 23:54:06 +02002805
2806TEST_F(VkLayerTest, DynamicRenderingWithInvalidShaderLayerBuiltIn) {
2807 TEST_DESCRIPTION("Create invalid pipeline that writes to Layer built-in");
2808
2809 SetTargetApiVersion(VK_API_VERSION_1_1);
2810 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2811 ASSERT_NO_FATAL_FAILURE(InitFramework());
2812
2813 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002814 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg155ed452022-04-21 23:54:06 +02002815 }
sjfricked700bc02022-05-30 16:35:06 +09002816 if (!AreRequiredExtensionsEnabled()) {
2817 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg155ed452022-04-21 23:54:06 +02002818 }
2819
2820 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2821 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>(&dynamic_rendering_features);
2822 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&multiview_features);
2823 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2824 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002825 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg155ed452022-04-21 23:54:06 +02002826 }
2827 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002828 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg155ed452022-04-21 23:54:06 +02002829 }
2830 if (multiview_features.multiviewGeometryShader == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002831 GTEST_SKIP() << "Test requires (unsupported) multiviewGeometryShader";
ziga-lunarg155ed452022-04-21 23:54:06 +02002832 }
2833
2834 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2835 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2836
2837 static char const *gsSource = R"glsl(
2838 #version 450
2839 layout (triangles) in;
2840 layout (triangle_strip) out;
2841 layout (max_vertices = 1) out;
2842 void main() {
2843 gl_Position = vec4(1.0, 0.5, 0.5, 0.0);
2844 EmitVertex();
2845 gl_Layer = 4;
2846 }
2847 )glsl";
2848
2849 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
2850 VkShaderObj gs(this, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT);
2851
2852 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2853
2854 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2855 pipeline_rendering_info.colorAttachmentCount = 1;
2856 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2857 pipeline_rendering_info.viewMask = 0x1;
2858
2859 CreatePipelineHelper pipe(*this);
2860 pipe.InitInfo();
2861 pipe.shader_stages_ = {vs.GetStageCreateInfo(), gs.GetStageCreateInfo(), pipe.fs_->GetStageCreateInfo()};
2862 pipe.gp_ci_.pNext = &pipeline_rendering_info;
2863 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2864 pipe.InitState();
2865 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06059");
2866 pipe.CreateGraphicsPipeline();
2867 m_errorMonitor->VerifyFound();
2868}
ziga-lunarg6feb4632022-04-22 00:20:21 +02002869
2870TEST_F(VkLayerTest, DynamicRenderingWithInputAttachmentCapability) {
2871 TEST_DESCRIPTION("Create invalid pipeline that uses InputAttachment capability");
2872
2873 SetTargetApiVersion(VK_API_VERSION_1_1);
2874 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2875 ASSERT_NO_FATAL_FAILURE(InitFramework());
2876
2877 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002878 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg6feb4632022-04-22 00:20:21 +02002879 }
sjfricked700bc02022-05-30 16:35:06 +09002880 if (!AreRequiredExtensionsEnabled()) {
2881 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6feb4632022-04-22 00:20:21 +02002882 }
2883
2884 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2885 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2886 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2887 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002888 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6feb4632022-04-22 00:20:21 +02002889 }
2890
2891 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2892 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2893
sjfricke394227a2022-06-20 16:47:38 +09002894 const char *fsSource = R"(
ziga-lunarg6feb4632022-04-22 00:20:21 +02002895 OpCapability Shader
2896 OpCapability InputAttachment
2897 %1 = OpExtInstImport "GLSL.std.450"
2898 OpMemoryModel Logical GLSL450
2899 OpEntryPoint Fragment %main "main"
2900 OpExecutionMode %main OriginUpperLeft
2901
2902 ; Debug Information
2903 OpSource GLSL 450
2904 OpName %main "main" ; id %4
2905
2906 ; Types, variables and constants
2907 %void = OpTypeVoid
2908 %3 = OpTypeFunction %void
2909
2910 ; Function main
2911 %main = OpFunction %void None %3
2912 %5 = OpLabel
2913 OpReturn
2914 OpFunctionEnd
2915 )";
2916
2917 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, SPV_ENV_VULKAN_1_0, SPV_SOURCE_ASM);
2918
2919 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2920
2921 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2922 pipeline_rendering_info.colorAttachmentCount = 1;
2923 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2924
2925 CreatePipelineHelper pipe(*this);
2926 pipe.InitInfo();
2927 pipe.shader_stages_ = {pipe.vs_->GetStageCreateInfo(), fs.GetStageCreateInfo()};
2928 pipe.gp_ci_.pNext = &pipeline_rendering_info;
2929 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2930 pipe.InitState();
2931 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06061");
2932 pipe.CreateGraphicsPipeline();
2933 m_errorMonitor->VerifyFound();
2934}
ziga-lunarga62b6ce2022-04-22 14:33:47 +02002935
2936TEST_F(VkLayerTest, InvalidRenderingInfoColorAttachmentFormat) {
2937 TEST_DESCRIPTION("Create pipeline with invalid color attachment format");
2938
2939 SetTargetApiVersion(VK_API_VERSION_1_1);
2940 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2941 ASSERT_NO_FATAL_FAILURE(InitFramework());
2942
2943 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002944 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarga62b6ce2022-04-22 14:33:47 +02002945 }
sjfricked700bc02022-05-30 16:35:06 +09002946 if (!AreRequiredExtensionsEnabled()) {
2947 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarga62b6ce2022-04-22 14:33:47 +02002948 }
2949
2950 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2951 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2952 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2953 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002954 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarga62b6ce2022-04-22 14:33:47 +02002955 }
2956
2957 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2958 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2959
2960 VkFormat color_format = VK_FORMAT_MAX_ENUM;
2961
2962 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2963 pipeline_rendering_info.colorAttachmentCount = 1;
2964 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2965
2966 CreatePipelineHelper pipe(*this);
2967 pipe.InitInfo();
2968 pipe.gp_ci_.pNext = &pipeline_rendering_info;
2969 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2970 pipe.InitState();
2971 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06579");
2972 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06580");
2973 pipe.CreateGraphicsPipeline();
2974 m_errorMonitor->VerifyFound();
2975}
ziga-lunargf7fb9202022-04-22 17:19:10 +02002976
2977TEST_F(VkLayerTest, InvalidDynamicRenderingLibraryViewMask) {
2978 TEST_DESCRIPTION("Create pipeline with invalid view mask");
2979
2980 SetTargetApiVersion(VK_API_VERSION_1_1);
2981 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2982 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
2983 ASSERT_NO_FATAL_FAILURE(InitFramework());
2984
2985 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002986 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargf7fb9202022-04-22 17:19:10 +02002987 }
sjfricked700bc02022-05-30 16:35:06 +09002988 if (!AreRequiredExtensionsEnabled()) {
2989 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargf7fb9202022-04-22 17:19:10 +02002990 }
2991
2992 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
2993 auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>(&multiview_features);
2994 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features);
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06002995 GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargf7fb9202022-04-22 17:19:10 +02002996 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002997 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargf7fb9202022-04-22 17:19:10 +02002998 }
2999 if (library_features.graphicsPipelineLibrary == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003000 GTEST_SKIP() << "Test requires (unsupported) graphicsPipelineLibrary";
ziga-lunargf7fb9202022-04-22 17:19:10 +02003001 }
3002 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003003 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunargf7fb9202022-04-22 17:19:10 +02003004 }
3005
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003006 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &dynamic_rendering_features));
ziga-lunargf7fb9202022-04-22 17:19:10 +02003007 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3008
3009 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
3010
3011 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
3012 pipeline_rendering_info.colorAttachmentCount = 1;
3013 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
3014
3015 auto graphics_library_create_info = LvlInitStruct<VkGraphicsPipelineLibraryCreateInfoEXT>(&pipeline_rendering_info);
3016 graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT;
3017 auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>(&graphics_library_create_info);
3018
3019 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
3020 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
3021 color_blend_state_create_info.attachmentCount = 1;
3022 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
3023
ziga-lunargf7fb9202022-04-22 17:19:10 +02003024 CreatePipelineHelper lib(*this);
3025 lib.cb_ci_ = color_blend_state_create_info;
3026 lib.InitInfo();
3027 lib.gp_ci_.pNext = &library_create_info;
3028 lib.gp_ci_.renderPass = VK_NULL_HANDLE;
3029 lib.InitState();
3030 lib.CreateGraphicsPipeline();
ziga-lunargf7fb9202022-04-22 17:19:10 +02003031
3032 graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT;
3033 library_create_info.libraryCount = 1;
3034 library_create_info.pLibraries = &lib.pipeline_;
3035 pipeline_rendering_info.viewMask = 0x1;
3036
3037 CreatePipelineHelper pipe(*this);
3038 pipe.InitInfo();
3039 pipe.gp_ci_.pNext = &library_create_info;
3040 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003041 pipe.shader_stages_ = {pipe.fs_->GetStageCreateInfo()};
ziga-lunargf7fb9202022-04-22 17:19:10 +02003042 pipe.InitState();
3043 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06626");
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06003044 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06626");
ziga-lunargf7fb9202022-04-22 17:19:10 +02003045 pipe.CreateGraphicsPipeline();
3046 m_errorMonitor->VerifyFound();
3047}
ziga-lunarge151ca62022-04-22 17:40:51 +02003048
3049TEST_F(VkLayerTest, InvalidAttachmentSampleCount) {
3050 TEST_DESCRIPTION("Create pipeline with invalid color attachment samples");
3051
3052 SetTargetApiVersion(VK_API_VERSION_1_1);
3053 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3054 ASSERT_NO_FATAL_FAILURE(InitFramework());
3055
3056 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003057 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge151ca62022-04-22 17:40:51 +02003058 }
sjfricked700bc02022-05-30 16:35:06 +09003059 if (!AreRequiredExtensionsEnabled()) {
3060 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge151ca62022-04-22 17:40:51 +02003061 }
3062
3063 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
3064 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3065 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3066 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003067 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge151ca62022-04-22 17:40:51 +02003068 }
3069
3070 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3071 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3072
3073 VkSampleCountFlagBits color_attachment_samples = VK_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM;
3074
3075 auto samples_info = LvlInitStruct<VkAttachmentSampleCountInfoAMD>();
3076 samples_info.colorAttachmentCount = 1;
3077 samples_info.pColorAttachmentSamples = &color_attachment_samples;
3078 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(&samples_info);
3079
3080 CreatePipelineHelper pipe(*this);
3081 pipe.InitInfo();
3082 pipe.gp_ci_.pNext = &pipeline_rendering_info;
3083 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3084 pipe.InitState();
3085 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-pColorAttachmentSamples-06592");
3086 pipe.CreateGraphicsPipeline();
3087 m_errorMonitor->VerifyFound();
3088}
ziga-lunargb81597d2022-04-22 19:11:51 +02003089
3090TEST_F(VkLayerTest, InvalidDynamicRenderingLibrariesViewMask) {
3091 TEST_DESCRIPTION("Create pipeline with libaries that have incompatible view mask");
3092
3093 SetTargetApiVersion(VK_API_VERSION_1_1);
3094 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3095 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
3096 ASSERT_NO_FATAL_FAILURE(InitFramework());
3097
3098 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003099 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargb81597d2022-04-22 19:11:51 +02003100 }
sjfricked700bc02022-05-30 16:35:06 +09003101 if (!AreRequiredExtensionsEnabled()) {
3102 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargb81597d2022-04-22 19:11:51 +02003103 }
3104
3105 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3106 auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>(&multiview_features);
3107 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features);
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003108 GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargb81597d2022-04-22 19:11:51 +02003109 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003110 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargb81597d2022-04-22 19:11:51 +02003111 }
3112 if (library_features.graphicsPipelineLibrary == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003113 GTEST_SKIP() << "Test requires (unsupported) graphicsPipelineLibrary";
ziga-lunargb81597d2022-04-22 19:11:51 +02003114 }
3115 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003116 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunargb81597d2022-04-22 19:11:51 +02003117 }
3118
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003119 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &dynamic_rendering_features));
ziga-lunargb81597d2022-04-22 19:11:51 +02003120 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3121
3122 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
3123
3124 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
3125 pipeline_rendering_info.colorAttachmentCount = 1;
3126 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
3127
ziga-lunargb81597d2022-04-22 19:11:51 +02003128 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
3129 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
3130 color_blend_state_create_info.attachmentCount = 1;
3131 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
3132
ziga-lunargb81597d2022-04-22 19:11:51 +02003133 CreatePipelineHelper lib1(*this);
3134 lib1.cb_ci_ = color_blend_state_create_info;
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003135 lib1.InitFragmentOutputLibInfo(&pipeline_rendering_info);
ziga-lunargb81597d2022-04-22 19:11:51 +02003136 lib1.gp_ci_.renderPass = VK_NULL_HANDLE;
3137 lib1.InitState();
3138 lib1.CreateGraphicsPipeline();
3139
ziga-lunargb81597d2022-04-22 19:11:51 +02003140 pipeline_rendering_info.viewMask = 0x1;
3141
3142 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
3143
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003144 const auto fs_spv = GLSLToSPV(VK_SHADER_STAGE_FRAGMENT_BIT, bindStateFragShaderText);
3145 auto fs_ci = LvlInitStruct<VkShaderModuleCreateInfo>();
3146 fs_ci.codeSize = fs_spv.size() * sizeof(decltype(fs_spv)::value_type);
3147 fs_ci.pCode = fs_spv.data();
3148
3149 auto fs_stage_ci = LvlInitStruct<VkPipelineShaderStageCreateInfo>(&fs_ci);
3150 fs_stage_ci.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
3151 fs_stage_ci.module = VK_NULL_HANDLE;
3152 fs_stage_ci.pName = "main";
3153
ziga-lunargb81597d2022-04-22 19:11:51 +02003154 CreatePipelineHelper lib2(*this);
3155 lib2.cb_ci_ = color_blend_state_create_info;
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003156 lib2.InitFragmentLibInfo(1, &fs_stage_ci, &pipeline_rendering_info);
ziga-lunargb81597d2022-04-22 19:11:51 +02003157 lib2.gp_ci_.renderPass = VK_NULL_HANDLE;
3158 lib2.ds_ci_ = ds_ci;
3159 lib2.InitState();
3160 lib2.CreateGraphicsPipeline();
ziga-lunargb81597d2022-04-22 19:11:51 +02003161
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003162 pipeline_rendering_info.viewMask = 0;
3163 auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>();
ziga-lunargb81597d2022-04-22 19:11:51 +02003164 library_create_info.libraryCount = 2;
3165 VkPipeline libraries[2] = {lib1.pipeline_, lib2.pipeline_};
3166 library_create_info.pLibraries = libraries;
ziga-lunargb81597d2022-04-22 19:11:51 +02003167
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003168 auto pipe_ci = LvlInitStruct<VkGraphicsPipelineCreateInfo>(&library_create_info);
ziga-lunarg7f25dff2022-05-06 17:49:34 +02003169 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-pLibraries-06627");
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003170 vk_testing::Pipeline pipe(*m_device, pipe_ci);
ziga-lunargb81597d2022-04-22 19:11:51 +02003171 m_errorMonitor->VerifyFound();
3172}
ziga-lunarg2e302312022-04-22 19:47:32 +02003173
3174TEST_F(VkLayerTest, InvalidDynamicRenderingLibraryRenderPass) {
3175 TEST_DESCRIPTION("Create pipeline with invalid library render pass");
3176
3177 SetTargetApiVersion(VK_API_VERSION_1_1);
3178 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3179 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
3180 ASSERT_NO_FATAL_FAILURE(InitFramework());
3181
3182 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003183 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg2e302312022-04-22 19:47:32 +02003184 }
sjfricked700bc02022-05-30 16:35:06 +09003185 if (!AreRequiredExtensionsEnabled()) {
3186 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg2e302312022-04-22 19:47:32 +02003187 }
3188
3189 auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>();
3190 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features);
3191 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3192 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3193 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003194 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg2e302312022-04-22 19:47:32 +02003195 }
3196 if (library_features.graphicsPipelineLibrary == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003197 GTEST_SKIP() << "Test requires (unsupported) graphicsPipelineLibrary";
ziga-lunarg2e302312022-04-22 19:47:32 +02003198 }
3199
3200 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3201 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3202
3203 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
3204
3205 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
3206 pipeline_rendering_info.colorAttachmentCount = 1;
3207 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
3208
ziga-lunarg2e302312022-04-22 19:47:32 +02003209 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
3210 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
3211 color_blend_state_create_info.attachmentCount = 1;
3212 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
3213
ziga-lunarg2e302312022-04-22 19:47:32 +02003214 CreatePipelineHelper lib(*this);
3215 lib.cb_ci_ = color_blend_state_create_info;
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003216 lib.InitFragmentOutputLibInfo(&pipeline_rendering_info);
ziga-lunarg2e302312022-04-22 19:47:32 +02003217 lib.InitState();
3218 lib.CreateGraphicsPipeline();
ziga-lunarg2e302312022-04-22 19:47:32 +02003219
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003220 auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>(&pipeline_rendering_info);
ziga-lunarg2e302312022-04-22 19:47:32 +02003221 library_create_info.libraryCount = 1;
3222 library_create_info.pLibraries = &lib.pipeline_;
3223
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003224 const auto fs_spv = GLSLToSPV(VK_SHADER_STAGE_FRAGMENT_BIT, bindStateFragShaderText);
3225 auto fs_ci = LvlInitStruct<VkShaderModuleCreateInfo>();
3226 fs_ci.codeSize = fs_spv.size() * sizeof(decltype(fs_spv)::value_type);
3227 fs_ci.pCode = fs_spv.data();
3228
3229 auto fs_stage_ci = LvlInitStruct<VkPipelineShaderStageCreateInfo>(&fs_ci);
3230 fs_stage_ci.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
3231 fs_stage_ci.module = VK_NULL_HANDLE;
3232 fs_stage_ci.pName = "main";
3233
ziga-lunarg2e302312022-04-22 19:47:32 +02003234 CreatePipelineHelper pipe(*this);
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003235 pipe.InitFragmentLibInfo(1, &fs_stage_ci, &library_create_info);
ziga-lunarg2e302312022-04-22 19:47:32 +02003236 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3237 pipe.InitState();
3238 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderpass-06625");
3239 pipe.CreateGraphicsPipeline();
3240 m_errorMonitor->VerifyFound();
3241}
ziga-lunarg7ba5a1c2022-04-22 19:56:49 +02003242
3243TEST_F(VkLayerTest, PipelineMissingMultisampleState) {
3244 TEST_DESCRIPTION("Create pipeline with missing multisample state");
3245
3246 SetTargetApiVersion(VK_API_VERSION_1_1);
3247 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3248 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
3249 ASSERT_NO_FATAL_FAILURE(InitFramework());
3250
3251 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003252 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7ba5a1c2022-04-22 19:56:49 +02003253 }
sjfricked700bc02022-05-30 16:35:06 +09003254 if (!AreRequiredExtensionsEnabled()) {
3255 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7ba5a1c2022-04-22 19:56:49 +02003256 }
3257
3258 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
3259 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3260 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3261 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003262 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7ba5a1c2022-04-22 19:56:49 +02003263 }
3264
3265 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3266 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3267
3268 CreatePipelineHelper pipe(*this);
3269 pipe.InitInfo();
3270 pipe.gp_ci_.pMultisampleState = nullptr;
3271 pipe.InitState();
3272 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderpass-06631");
3273 pipe.CreateGraphicsPipeline();
3274 m_errorMonitor->VerifyFound();
ziga-lunarg14222532022-04-22 23:27:17 +02003275}
3276
ziga-lunargd7737482022-04-25 11:16:37 +02003277TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachment) {
3278 TEST_DESCRIPTION("Use invalid VkRenderingFragmentDensityMapAttachmentInfoEXT");
ziga-lunarg14222532022-04-22 23:27:17 +02003279
3280 SetTargetApiVersion(VK_API_VERSION_1_1);
3281 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3282 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3283 ASSERT_NO_FATAL_FAILURE(InitFramework());
3284
3285 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003286 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg14222532022-04-22 23:27:17 +02003287 }
sjfricked700bc02022-05-30 16:35:06 +09003288 if (!AreRequiredExtensionsEnabled()) {
3289 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg14222532022-04-22 23:27:17 +02003290 }
3291
ziga-lunargd7737482022-04-25 11:16:37 +02003292 auto multiview_featuers = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3293 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&multiview_featuers);
ziga-lunarg14222532022-04-22 23:27:17 +02003294 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3295 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3296 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003297 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg14222532022-04-22 23:27:17 +02003298 }
ziga-lunargd7737482022-04-25 11:16:37 +02003299 if (multiview_featuers.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003300 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunargd7737482022-04-25 11:16:37 +02003301 }
ziga-lunarg14222532022-04-22 23:27:17 +02003302
3303 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3304 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3305
3306 VkImageObj image(m_device);
3307 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
3308 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, VK_IMAGE_TILING_LINEAR, 0);
3309 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3310
3311 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3312 rendering_fragment_density.imageView = image_view;
3313 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3314 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3315 begin_rendering_info.layerCount = 1;
3316
3317 m_commandBuffer->begin();
ziga-lunargd7737482022-04-25 11:16:37 +02003318
ziga-lunarg14222532022-04-22 23:27:17 +02003319 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06157");
3320 m_commandBuffer->BeginRendering(begin_rendering_info);
3321 m_errorMonitor->VerifyFound();
ziga-lunargd7737482022-04-25 11:16:37 +02003322
3323 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3324
3325 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3326 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3327 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
3328 image_create_info.extent = {32, 32, 1};
3329 image_create_info.mipLevels = 1;
3330 image_create_info.arrayLayers = 2;
3331 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
3332 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3333 image_create_info.usage = VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT;
3334 VkImageObj image2(m_device);
3335 image2.Init(image_create_info);
3336 VkImageView image_view2 = image2.targetView(VK_FORMAT_R8G8B8A8_UINT);
3337 rendering_fragment_density.imageView = image_view2;
3338 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06160");
3339 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06109");
3340 m_commandBuffer->BeginRendering(begin_rendering_info);
3341 m_errorMonitor->VerifyFound();
3342
ziga-lunarg14222532022-04-22 23:27:17 +02003343 m_commandBuffer->end();
3344}
ziga-lunarga81df9d2022-04-22 23:33:13 +02003345
3346TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentUsage) {
3347 TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid imageLayout");
3348
3349 SetTargetApiVersion(VK_API_VERSION_1_1);
3350 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3351 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3352 ASSERT_NO_FATAL_FAILURE(InitFramework());
3353
3354 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003355 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarga81df9d2022-04-22 23:33:13 +02003356 }
sjfricked700bc02022-05-30 16:35:06 +09003357 if (!AreRequiredExtensionsEnabled()) {
3358 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarga81df9d2022-04-22 23:33:13 +02003359 }
3360
3361 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
3362 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3363 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3364 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003365 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarga81df9d2022-04-22 23:33:13 +02003366 }
3367
3368 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3369 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3370
3371 VkImageObj image(m_device);
3372 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
3373 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3374
3375 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3376 rendering_fragment_density.imageView = image_view;
3377 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3378 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3379 begin_rendering_info.layerCount = 1;
3380
3381 m_commandBuffer->begin();
3382 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06158");
3383 m_commandBuffer->BeginRendering(begin_rendering_info);
3384 m_errorMonitor->VerifyFound();
3385 m_commandBuffer->end();
3386}
ziga-lunarg7c411b32022-04-22 23:37:48 +02003387
3388TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentCreateFlags) {
3389 TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid image create flags");
3390
3391 SetTargetApiVersion(VK_API_VERSION_1_1);
3392 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3393 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3394 ASSERT_NO_FATAL_FAILURE(InitFramework());
3395
3396 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003397 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7c411b32022-04-22 23:37:48 +02003398 }
sjfricked700bc02022-05-30 16:35:06 +09003399 if (!AreRequiredExtensionsEnabled()) {
3400 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7c411b32022-04-22 23:37:48 +02003401 }
3402
3403 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
3404 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3405 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3406 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003407 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7c411b32022-04-22 23:37:48 +02003408 }
3409
3410 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3411 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3412
3413 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3414 image_create_info.flags = VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT;
3415 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3416 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
3417 image_create_info.extent = {32, 32, 4};
3418 image_create_info.mipLevels = 1;
3419 image_create_info.arrayLayers = 1;
3420 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
3421 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3422 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT;
3423
3424 VkImageObj image(m_device);
3425 image.Init(image_create_info);
3426 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3427
3428 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3429 rendering_fragment_density.imageView = image_view;
3430 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3431 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3432 begin_rendering_info.layerCount = 1;
3433
3434 m_commandBuffer->begin();
3435 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06159");
3436 m_commandBuffer->BeginRendering(begin_rendering_info);
3437 m_errorMonitor->VerifyFound();
3438 m_commandBuffer->end();
3439}
ziga-lunarg66569a72022-04-22 23:43:26 +02003440
3441TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentLayerCount) {
3442 TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid layer count");
3443
3444 SetTargetApiVersion(VK_API_VERSION_1_1);
3445 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3446 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3447 ASSERT_NO_FATAL_FAILURE(InitFramework());
3448
3449 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003450 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg66569a72022-04-22 23:43:26 +02003451 }
sjfricked700bc02022-05-30 16:35:06 +09003452 if (!AreRequiredExtensionsEnabled()) {
3453 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg66569a72022-04-22 23:43:26 +02003454 }
3455
3456 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3457 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&multiview_features);
3458 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3459 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3460 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003461 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg66569a72022-04-22 23:43:26 +02003462 }
3463 if (!multiview_features.multiview) {
sjfricke50955f32022-06-05 10:12:52 +09003464 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg66569a72022-04-22 23:43:26 +02003465 }
3466
3467 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3468 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3469
3470 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3471 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3472 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
3473 image_create_info.extent = {32, 32, 4};
3474 image_create_info.mipLevels = 1;
3475 image_create_info.arrayLayers = 2;
3476 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
3477 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3478 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT;
3479
3480 VkImageObj image(m_device);
3481 image.Init(image_create_info);
3482 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3483
3484 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3485 rendering_fragment_density.imageView = image_view;
3486 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3487 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3488 begin_rendering_info.layerCount = 1;
3489 begin_rendering_info.viewMask = 0x1;
3490
3491 m_commandBuffer->begin();
3492 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06160");
3493 m_commandBuffer->BeginRendering(begin_rendering_info);
3494 m_errorMonitor->VerifyFound();
3495 m_commandBuffer->end();
3496}
ziga-lunarg323c11d2022-04-22 23:56:32 +02003497
3498TEST_F(VkLayerTest, InvalidRenderingPNextImageView) {
3499 TEST_DESCRIPTION(
3500 "Use different image views in VkRenderingFragmentShadingRateAttachmentInfoKHR and "
3501 "VkRenderingFragmentDensityMapAttachmentInfoEXT");
3502
3503 SetTargetApiVersion(VK_API_VERSION_1_1);
3504 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3505 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3506 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
3507 ASSERT_NO_FATAL_FAILURE(InitFramework());
3508
3509 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003510 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg323c11d2022-04-22 23:56:32 +02003511 }
sjfricked700bc02022-05-30 16:35:06 +09003512 if (!AreRequiredExtensionsEnabled()) {
3513 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg323c11d2022-04-22 23:56:32 +02003514 }
3515
3516 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3517 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&multiview_features);
3518 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3519 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3520 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003521 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg323c11d2022-04-22 23:56:32 +02003522 }
3523 if (!multiview_features.multiview) {
sjfricke50955f32022-06-05 10:12:52 +09003524 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg323c11d2022-04-22 23:56:32 +02003525 }
3526
3527 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3528 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3529
3530 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
3531
3532 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
3533 vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2);
3534
3535 VkImageObj image1(m_device);
3536 image1.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
3537 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR,
3538 VK_IMAGE_TILING_LINEAR, 0);
3539 VkImageView image_view1 = image1.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3540 VkImageObj image2(m_device);
3541 image2.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
3542 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, VK_IMAGE_TILING_LINEAR, 0);
3543 VkImageView image_view2 = image2.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3544
3545 auto rendering_fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
3546 rendering_fragment_shading_rate.imageView = image_view1;
3547 rendering_fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3548 rendering_fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
3549 auto rendering_fragment_density =
3550 LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>(&rendering_fragment_shading_rate);
3551 rendering_fragment_density.imageView = image_view2;
3552 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3553 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3554 begin_rendering_info.layerCount = 1;
3555 begin_rendering_info.viewMask = 0x1;
3556
3557 m_commandBuffer->begin();
3558 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06126");
3559 m_commandBuffer->BeginRendering(begin_rendering_info);
3560 m_errorMonitor->VerifyFound();
3561 m_commandBuffer->end();
3562}
ziga-lunarg95f20d42022-04-23 00:06:42 +02003563
3564TEST_F(VkLayerTest, InvalidRenderingRenderArea) {
3565 TEST_DESCRIPTION("Use negative offset in RenderingInfo render area");
3566
3567 SetTargetApiVersion(VK_API_VERSION_1_0);
3568 AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
3569 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3570 ASSERT_NO_FATAL_FAILURE(InitFramework());
3571
3572 if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
sjfricke50955f32022-06-05 10:12:52 +09003573 GTEST_SKIP() << "Tests for 1.0 only";
ziga-lunarg95f20d42022-04-23 00:06:42 +02003574 }
sjfricked700bc02022-05-30 16:35:06 +09003575 if (!AreRequiredExtensionsEnabled()) {
3576 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg95f20d42022-04-23 00:06:42 +02003577 }
3578
3579 auto vkGetPhysicalDeviceFeatures2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2KHR>(
3580 vk::GetInstanceProcAddr(instance(), "vkGetPhysicalDeviceFeatures2KHR"));
3581 ASSERT_TRUE(vkGetPhysicalDeviceFeatures2KHR != nullptr);
3582
3583 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
3584 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2KHR>(&dynamic_rendering_features);
3585 vkGetPhysicalDeviceFeatures2KHR(gpu(), &features2);
3586 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003587 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg95f20d42022-04-23 00:06:42 +02003588 }
3589
3590 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3591 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3592
3593 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3594 begin_rendering_info.layerCount = 1;
3595 begin_rendering_info.renderArea.offset.x = -1;
ziga-lunarg9b6a95f2022-04-23 00:13:38 +02003596 begin_rendering_info.renderArea.extent.width = 32;
3597 begin_rendering_info.renderArea.extent.height = 32;
ziga-lunarg95f20d42022-04-23 00:06:42 +02003598
3599 m_commandBuffer->begin();
3600
3601 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06071");
3602 m_commandBuffer->BeginRendering(begin_rendering_info);
3603 m_errorMonitor->VerifyFound();
3604
3605 begin_rendering_info.renderArea.offset.x = 0;
3606 begin_rendering_info.renderArea.offset.y = -1;
3607
3608 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06072");
3609 m_commandBuffer->BeginRendering(begin_rendering_info);
3610 m_errorMonitor->VerifyFound();
3611
ziga-lunarg9b6a95f2022-04-23 00:13:38 +02003612 begin_rendering_info.renderArea.offset.y = 0;
3613 begin_rendering_info.renderArea.offset.x = m_device->phy().properties().limits.maxFramebufferWidth - 16;
3614 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06073");
3615 m_commandBuffer->BeginRendering(begin_rendering_info);
3616 m_errorMonitor->VerifyFound();
3617
3618 begin_rendering_info.renderArea.offset.x = 0;
3619 begin_rendering_info.renderArea.offset.y = m_device->phy().properties().limits.maxFramebufferHeight - 16;
3620 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06074");
3621 m_commandBuffer->BeginRendering(begin_rendering_info);
3622 m_errorMonitor->VerifyFound();
3623
ziga-lunarg95f20d42022-04-23 00:06:42 +02003624 m_commandBuffer->end();
3625}
ziga-lunarg6662a882022-04-23 00:21:27 +02003626
3627TEST_F(VkLayerTest, InvalidRenderingInfoViewMask) {
3628 TEST_DESCRIPTION("Use negative offset in RenderingInfo render area");
3629
3630 SetTargetApiVersion(VK_API_VERSION_1_1);
3631 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3632 ASSERT_NO_FATAL_FAILURE(InitFramework());
3633
3634 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003635 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg6662a882022-04-23 00:21:27 +02003636 }
sjfricked700bc02022-05-30 16:35:06 +09003637 if (!AreRequiredExtensionsEnabled()) {
3638 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6662a882022-04-23 00:21:27 +02003639 }
3640
3641 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3642 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(&multiview_features);
3643 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3644 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3645 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003646 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6662a882022-04-23 00:21:27 +02003647 }
3648 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003649 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg6662a882022-04-23 00:21:27 +02003650 }
3651
3652 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3653 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3654
3655 VkPhysicalDeviceMultiviewProperties multiview_props = LvlInitStruct<VkPhysicalDeviceMultiviewProperties>();
3656 VkPhysicalDeviceProperties2 pd_props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&multiview_props);
3657 vk::GetPhysicalDeviceProperties2(gpu(), &pd_props2);
3658
3659 if (multiview_props.maxMultiviewViewCount == 32) {
3660 printf("%s VUID is not testable as maxMultiviewViewCount is 32, skipping test\n", kSkipPrefix);
3661 return;
3662 }
3663
3664 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3665 begin_rendering_info.layerCount = 1;
3666 begin_rendering_info.renderArea.extent.width = 32;
3667 begin_rendering_info.renderArea.extent.height = 32;
3668 begin_rendering_info.viewMask = 1u << multiview_props.maxMultiviewViewCount;
3669
3670 m_commandBuffer->begin();
3671
3672 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-viewMask-06128");
3673 m_commandBuffer->BeginRendering(begin_rendering_info);
3674 m_errorMonitor->VerifyFound();
3675
3676 m_commandBuffer->end();
3677}
ziga-lunargae75b8a2022-04-23 10:54:37 +02003678
3679TEST_F(VkLayerTest, InvalidRenderingColorAttachmentFormat) {
3680 TEST_DESCRIPTION("Use format with missing potential format features in rendering color attachment");
3681
3682 SetTargetApiVersion(VK_API_VERSION_1_1);
3683 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3684 AddRequiredExtensions(VK_NV_LINEAR_COLOR_ATTACHMENT_EXTENSION_NAME);
3685 ASSERT_NO_FATAL_FAILURE(InitFramework());
3686
3687 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003688 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargae75b8a2022-04-23 10:54:37 +02003689 }
sjfricked700bc02022-05-30 16:35:06 +09003690 if (!AreRequiredExtensionsEnabled()) {
3691 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargae75b8a2022-04-23 10:54:37 +02003692 }
3693
3694 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
3695 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3696 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3697 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003698 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargae75b8a2022-04-23 10:54:37 +02003699 }
3700
3701 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3702 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3703
3704 VkFormat format = FindSupportedDepthStencilFormat(gpu());
3705 if (format == VK_FORMAT_UNDEFINED) {
3706 printf("%s No Depth + Stencil format found. Skipped.\n", kSkipPrefix);
3707 return;
3708 }
3709
3710 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
3711 pipeline_rendering_info.colorAttachmentCount = 1;
3712 pipeline_rendering_info.pColorAttachmentFormats = &format;
3713
3714 CreatePipelineHelper pipe(*this);
3715 pipe.InitInfo();
3716 pipe.gp_ci_.pNext = &pipeline_rendering_info;
3717 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3718 pipe.InitState();
3719
3720 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06582");
3721 pipe.CreateGraphicsPipeline();
3722 m_errorMonitor->VerifyFound();
3723}
ziga-lunargeac390f2022-04-23 11:05:28 +02003724
sjfricke483c1082022-06-05 10:21:44 +09003725TEST_F(VkLayerTest, InvalidResolveModeWithNonIntegerColorFormat) {
3726 TEST_DESCRIPTION("Use invalid resolve mode with non integer color format");
3727
3728 SetTargetApiVersion(VK_API_VERSION_1_1);
3729 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3730 ASSERT_NO_FATAL_FAILURE(InitFramework());
3731
3732 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
3733 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
3734 }
sjfricked700bc02022-05-30 16:35:06 +09003735 if (!AreRequiredExtensionsEnabled()) {
3736 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
sjfricke483c1082022-06-05 10:21:44 +09003737 }
3738
3739 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
3740 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3741 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3742 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
3743 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
3744 }
3745
3746 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3747 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3748
3749 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3750 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3751 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; // not int color
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06003752 image_create_info.extent = {32, 32, 1};
sjfricke483c1082022-06-05 10:21:44 +09003753 image_create_info.mipLevels = 1;
3754 image_create_info.arrayLayers = 1;
3755 image_create_info.samples = VK_SAMPLE_COUNT_4_BIT;
3756 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3757 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
3758 VkImageObj image(m_device);
3759 image.Init(image_create_info);
3760 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3761
3762 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3763 color_attachment.imageView = image_view;
3764 color_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT; // not allowed for format
3765 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3766 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
3767
3768 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3769 begin_rendering_info.colorAttachmentCount = 1;
3770 begin_rendering_info.pColorAttachments = &color_attachment;
3771 begin_rendering_info.layerCount = 1;
3772
3773 m_commandBuffer->begin();
3774
3775 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06129");
3776 m_commandBuffer->BeginRendering(begin_rendering_info);
3777 m_errorMonitor->VerifyFound();
3778
3779 m_commandBuffer->end();
3780}
3781
ziga-lunargeac390f2022-04-23 11:05:28 +02003782TEST_F(VkLayerTest, InvalidResolveModeWithIntegerColorFormat) {
3783 TEST_DESCRIPTION("Use invalid resolve mode with integer color format");
3784
3785 SetTargetApiVersion(VK_API_VERSION_1_1);
3786 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3787 ASSERT_NO_FATAL_FAILURE(InitFramework());
3788
3789 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003790 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargeac390f2022-04-23 11:05:28 +02003791 }
sjfricked700bc02022-05-30 16:35:06 +09003792 if (!AreRequiredExtensionsEnabled()) {
3793 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargeac390f2022-04-23 11:05:28 +02003794 }
3795
3796 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
3797 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3798 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3799 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003800 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargeac390f2022-04-23 11:05:28 +02003801 }
3802
3803 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3804 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3805
3806 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3807 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3808 image_create_info.format = VK_FORMAT_R8G8B8A8_UINT;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06003809 image_create_info.extent = {32, 32, 1};
ziga-lunargeac390f2022-04-23 11:05:28 +02003810 image_create_info.mipLevels = 1;
3811 image_create_info.arrayLayers = 1;
3812 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
3813 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3814 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
3815 VkImageObj image(m_device);
3816 image.Init(image_create_info);
3817 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
3818
3819 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3820 color_attachment.imageView = image_view;
3821 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3822 color_attachment.resolveMode = VK_RESOLVE_MODE_MAX_BIT;
3823 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
3824
3825 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3826 begin_rendering_info.colorAttachmentCount = 1;
3827 begin_rendering_info.pColorAttachments = &color_attachment;
3828 begin_rendering_info.layerCount = 1;
3829
3830 m_commandBuffer->begin();
3831
3832 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06130");
3833 m_commandBuffer->BeginRendering(begin_rendering_info);
3834 m_errorMonitor->VerifyFound();
3835
3836 m_commandBuffer->end();
3837}
ziga-lunargdf2a3202022-04-23 11:07:46 +02003838
3839TEST_F(VkLayerTest, InvalidResolveModeSamples) {
3840 TEST_DESCRIPTION("Use invalid sample count with resolve mode that is not none");
3841
3842 SetTargetApiVersion(VK_API_VERSION_1_1);
3843 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3844 ASSERT_NO_FATAL_FAILURE(InitFramework());
3845
3846 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003847 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargdf2a3202022-04-23 11:07:46 +02003848 }
sjfricked700bc02022-05-30 16:35:06 +09003849 if (!AreRequiredExtensionsEnabled()) {
3850 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargdf2a3202022-04-23 11:07:46 +02003851 }
3852
3853 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
3854 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3855 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3856 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003857 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargdf2a3202022-04-23 11:07:46 +02003858 }
3859
3860 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3861 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3862
3863 VkImageObj image(m_device);
3864 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
3865 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3866
3867 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3868 color_attachment.imageView = image_view;
3869 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3870 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
3871 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
3872
3873 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3874 begin_rendering_info.colorAttachmentCount = 1;
3875 begin_rendering_info.pColorAttachments = &color_attachment;
3876 begin_rendering_info.layerCount = 1;
3877
3878 m_commandBuffer->begin();
3879
3880 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06132");
3881 m_commandBuffer->BeginRendering(begin_rendering_info);
3882 m_errorMonitor->VerifyFound();
3883
3884 m_commandBuffer->end();
3885}
ziga-lunargb7693aa2022-04-23 11:21:57 +02003886
3887TEST_F(VkLayerTest, InvalidResolveImageViewSamples) {
3888 TEST_DESCRIPTION("Use resolve image view with invalid sample count");
3889
3890 SetTargetApiVersion(VK_API_VERSION_1_1);
3891 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3892 ASSERT_NO_FATAL_FAILURE(InitFramework());
3893
3894 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003895 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargb7693aa2022-04-23 11:21:57 +02003896 }
sjfricked700bc02022-05-30 16:35:06 +09003897 if (!AreRequiredExtensionsEnabled()) {
3898 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargb7693aa2022-04-23 11:21:57 +02003899 }
3900
3901 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
3902 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3903 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3904 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003905 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargb7693aa2022-04-23 11:21:57 +02003906 }
3907
3908 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3909 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3910
3911 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3912 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3913 image_create_info.format = VK_FORMAT_R8G8B8A8_UINT;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06003914 image_create_info.extent = {32, 32, 1};
ziga-lunargb7693aa2022-04-23 11:21:57 +02003915 image_create_info.mipLevels = 1;
3916 image_create_info.arrayLayers = 1;
3917 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
3918 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3919 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
3920
3921 VkImageObj image(m_device);
3922 image.Init(image_create_info);
3923 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
3924
3925 VkImageObj resolve_image(m_device);
3926 resolve_image.Init(image_create_info);
3927 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UINT);
3928
3929 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3930 color_attachment.imageView = image_view;
3931 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3932 color_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
3933 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
3934 color_attachment.resolveImageView = resolve_image_view;
3935
3936 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3937 begin_rendering_info.colorAttachmentCount = 1;
3938 begin_rendering_info.pColorAttachments = &color_attachment;
3939 begin_rendering_info.layerCount = 1;
3940
3941 m_commandBuffer->begin();
3942
3943 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06133");
3944 m_commandBuffer->BeginRendering(begin_rendering_info);
3945 m_errorMonitor->VerifyFound();
3946
3947 m_commandBuffer->end();
ziga-lunargd12cbce2022-04-23 11:35:20 +02003948}
3949
3950TEST_F(VkLayerTest, InvalidResolveImageViewFormatMatch) {
3951 TEST_DESCRIPTION("Use resolve image view with different format from image view");
3952
3953 SetTargetApiVersion(VK_API_VERSION_1_1);
3954 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3955 ASSERT_NO_FATAL_FAILURE(InitFramework());
3956
3957 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003958 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargd12cbce2022-04-23 11:35:20 +02003959 }
sjfricked700bc02022-05-30 16:35:06 +09003960 if (!AreRequiredExtensionsEnabled()) {
3961 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargd12cbce2022-04-23 11:35:20 +02003962 }
3963
3964 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
3965 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3966 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3967 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003968 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargd12cbce2022-04-23 11:35:20 +02003969 }
3970
3971 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3972 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3973
3974 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3975 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3976 image_create_info.format = VK_FORMAT_R8G8B8A8_UINT;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06003977 image_create_info.extent = {32, 32, 1};
ziga-lunargd12cbce2022-04-23 11:35:20 +02003978 image_create_info.mipLevels = 1;
3979 image_create_info.arrayLayers = 1;
3980 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
3981 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3982 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
3983
3984 VkImageObj image(m_device);
3985 image.Init(image_create_info);
3986 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
3987
3988 VkImageObj resolve_image(m_device);
3989 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
3990 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3991
3992 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3993 color_attachment.imageView = image_view;
3994 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3995 color_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
3996 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
3997 color_attachment.resolveImageView = resolve_image_view;
3998
3999 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4000 begin_rendering_info.colorAttachmentCount = 1;
4001 begin_rendering_info.pColorAttachments = &color_attachment;
4002 begin_rendering_info.layerCount = 1;
4003
4004 m_commandBuffer->begin();
4005
4006 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06134");
4007 m_commandBuffer->BeginRendering(begin_rendering_info);
4008 m_errorMonitor->VerifyFound();
4009
4010 m_commandBuffer->end();
4011}
ziga-lunarge579a3b2022-04-23 11:38:02 +02004012
4013TEST_F(VkLayerTest, InvalidRenderingAttachmentImageViewLayout) {
4014 TEST_DESCRIPTION("Use rendering attachment image view with invalid layout");
4015
4016 SetTargetApiVersion(VK_API_VERSION_1_1);
4017 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4018 ASSERT_NO_FATAL_FAILURE(InitFramework());
4019
4020 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004021 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge579a3b2022-04-23 11:38:02 +02004022 }
sjfricked700bc02022-05-30 16:35:06 +09004023 if (!AreRequiredExtensionsEnabled()) {
4024 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge579a3b2022-04-23 11:38:02 +02004025 }
4026
4027 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4028 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4029 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4030 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004031 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge579a3b2022-04-23 11:38:02 +02004032 }
4033
4034 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4035 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4036
4037 VkImageObj image(m_device);
4038 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4039 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4040
4041 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4042 color_attachment.imageView = image_view;
4043 color_attachment.imageLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
4044
4045 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4046 begin_rendering_info.colorAttachmentCount = 1;
4047 begin_rendering_info.pColorAttachments = &color_attachment;
4048 begin_rendering_info.layerCount = 1;
4049
4050 m_commandBuffer->begin();
4051
4052 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06135");
4053 m_commandBuffer->BeginRendering(begin_rendering_info);
4054 m_errorMonitor->VerifyFound();
4055
4056 m_commandBuffer->end();
4057}
ziga-lunarg409f8212022-04-23 11:40:53 +02004058
4059TEST_F(VkLayerTest, InvalidResolveImageViewLayout) {
4060 TEST_DESCRIPTION("Use resolve image view with invalid layout");
4061
4062 SetTargetApiVersion(VK_API_VERSION_1_1);
4063 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4064 ASSERT_NO_FATAL_FAILURE(InitFramework());
4065
4066 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004067 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg409f8212022-04-23 11:40:53 +02004068 }
sjfricked700bc02022-05-30 16:35:06 +09004069 if (!AreRequiredExtensionsEnabled()) {
4070 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg409f8212022-04-23 11:40:53 +02004071 }
4072
4073 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4074 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4075 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4076 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004077 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg409f8212022-04-23 11:40:53 +02004078 }
4079
4080 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4081 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4082
4083 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4084 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4085 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004086 image_create_info.extent = {32, 32, 1};
ziga-lunarg409f8212022-04-23 11:40:53 +02004087 image_create_info.mipLevels = 1;
4088 image_create_info.arrayLayers = 1;
4089 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4090 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4091 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4092
4093 VkImageObj image(m_device);
4094 image.Init(image_create_info);
4095 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4096
4097 VkImageObj resolve_image(m_device);
4098 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4099 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4100
4101 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4102 color_attachment.imageView = image_view;
4103 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4104 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4105 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
4106 color_attachment.resolveImageView = resolve_image_view;
4107
4108 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4109 begin_rendering_info.colorAttachmentCount = 1;
4110 begin_rendering_info.pColorAttachments = &color_attachment;
4111 begin_rendering_info.layerCount = 1;
4112
4113 m_commandBuffer->begin();
4114
4115 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06136");
4116 m_commandBuffer->BeginRendering(begin_rendering_info);
4117 m_errorMonitor->VerifyFound();
4118
4119 m_commandBuffer->end();
4120}
ziga-lunargbbbef242022-04-23 12:12:10 +02004121
4122TEST_F(VkLayerTest, InvalidResolveImageViewLayoutSeparateDepthStencil) {
4123 TEST_DESCRIPTION("Use resolve image view with invalid layout");
4124
4125 SetTargetApiVersion(VK_API_VERSION_1_1);
4126 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4127 AddRequiredExtensions(VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_EXTENSION_NAME);
4128 ASSERT_NO_FATAL_FAILURE(InitFramework());
4129
4130 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004131 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargbbbef242022-04-23 12:12:10 +02004132 }
sjfricked700bc02022-05-30 16:35:06 +09004133 if (!AreRequiredExtensionsEnabled()) {
4134 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargbbbef242022-04-23 12:12:10 +02004135 }
4136
4137 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4138 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4139 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4140 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004141 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargbbbef242022-04-23 12:12:10 +02004142 }
4143
4144 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4145 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4146
4147 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4148 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4149 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004150 image_create_info.extent = {32, 32, 1};
ziga-lunargbbbef242022-04-23 12:12:10 +02004151 image_create_info.mipLevels = 1;
4152 image_create_info.arrayLayers = 1;
4153 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4154 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4155 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4156
4157 VkImageObj image(m_device);
4158 image.Init(image_create_info);
4159 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4160
4161 VkImageObj resolve_image(m_device);
4162 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4163 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4164
4165 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4166 color_attachment.imageView = image_view;
4167 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4168 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4169 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL;
4170 color_attachment.resolveImageView = resolve_image_view;
4171
4172 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4173 begin_rendering_info.colorAttachmentCount = 1;
4174 begin_rendering_info.pColorAttachments = &color_attachment;
4175 begin_rendering_info.layerCount = 1;
4176
4177 m_commandBuffer->begin();
4178
4179 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06137");
4180 m_commandBuffer->BeginRendering(begin_rendering_info);
4181 m_errorMonitor->VerifyFound();
4182
4183 m_commandBuffer->end();
4184}
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004185
4186TEST_F(VkLayerTest, InvalidRenderingAttachmentImageViewShadingRateLayout) {
4187 TEST_DESCRIPTION("Use image view with invalid layout");
4188
4189 SetTargetApiVersion(VK_API_VERSION_1_1);
4190 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
sjfricke6e8fb402022-06-05 09:47:58 +09004191 AddOptionalExtensions(VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME);
4192 AddOptionalExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004193 ASSERT_NO_FATAL_FAILURE(InitFramework());
4194
4195 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004196 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004197 }
sjfricked700bc02022-05-30 16:35:06 +09004198 if (!AreRequiredExtensionsEnabled()) {
4199 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004200 }
4201
sjfricke6e8fb402022-06-05 09:47:58 +09004202 const bool nv_shading_rate = IsExtensionsEnabled(VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME);
4203 const bool khr_fragment_shading = IsExtensionsEnabled(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
4204 if (!khr_fragment_shading && !nv_shading_rate) {
4205 GTEST_SKIP() << "shading rate / fragment shading not supported";
4206 }
4207
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004208 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4209 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4210 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4211 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004212 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004213 }
4214
4215 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4216 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4217
4218 VkImageObj image(m_device);
4219 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4220 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4221
4222 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4223 color_attachment.imageView = image_view;
4224 color_attachment.imageLayout = VK_IMAGE_LAYOUT_SHADING_RATE_OPTIMAL_NV;
4225
4226 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4227 begin_rendering_info.colorAttachmentCount = 1;
4228 begin_rendering_info.pColorAttachments = &color_attachment;
4229 begin_rendering_info.layerCount = 1;
4230
4231 m_commandBuffer->begin();
4232
sjfricke6e8fb402022-06-05 09:47:58 +09004233 // SHADING_RATE_OPTIMAL_NV is aliased FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR so VU depends on which extensions
4234 const char *vuid =
4235 khr_fragment_shading ? "VUID-VkRenderingAttachmentInfo-imageView-06143" : "VUID-VkRenderingAttachmentInfo-imageView-06138";
4236 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid);
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004237 m_commandBuffer->BeginRendering(begin_rendering_info);
4238 m_errorMonitor->VerifyFound();
4239
4240 m_commandBuffer->end();
4241}
4242
4243TEST_F(VkLayerTest, InvalidResolveImageViewShadingRateLayout) {
4244 TEST_DESCRIPTION("Use resolve image view with invalid shading ratelayout");
4245
4246 SetTargetApiVersion(VK_API_VERSION_1_1);
4247 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
sjfricke6e8fb402022-06-05 09:47:58 +09004248 AddOptionalExtensions(VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME);
4249 AddOptionalExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004250 ASSERT_NO_FATAL_FAILURE(InitFramework());
4251
4252 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004253 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004254 }
sjfricked700bc02022-05-30 16:35:06 +09004255 if (!AreRequiredExtensionsEnabled()) {
4256 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004257 }
4258
sjfricke6e8fb402022-06-05 09:47:58 +09004259 const bool nv_shading_rate = IsExtensionsEnabled(VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME);
4260 const bool khr_fragment_shading = IsExtensionsEnabled(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
4261 if (!khr_fragment_shading && !nv_shading_rate) {
4262 GTEST_SKIP() << "shading rate / fragment shading not supported";
4263 }
4264
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004265 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4266 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4267 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4268 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004269 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004270 }
4271
4272 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4273 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4274
4275 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4276 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4277 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004278 image_create_info.extent = {32, 32, 1};
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004279 image_create_info.mipLevels = 1;
4280 image_create_info.arrayLayers = 1;
4281 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4282 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4283 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4284
4285 VkImageObj image(m_device);
4286 image.Init(image_create_info);
4287 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4288
4289 VkImageObj resolve_image(m_device);
4290 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4291 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4292
4293 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4294 color_attachment.imageView = image_view;
4295 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4296 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4297 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_SHADING_RATE_OPTIMAL_NV;
4298 color_attachment.resolveImageView = resolve_image_view;
4299
4300 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4301 begin_rendering_info.colorAttachmentCount = 1;
4302 begin_rendering_info.pColorAttachments = &color_attachment;
4303 begin_rendering_info.layerCount = 1;
4304
4305 m_commandBuffer->begin();
4306
sjfricke6e8fb402022-06-05 09:47:58 +09004307 // SHADING_RATE_OPTIMAL_NV is aliased FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR so VU depends on which extensions
4308 const char *vuid =
4309 khr_fragment_shading ? "VUID-VkRenderingAttachmentInfo-imageView-06144" : "VUID-VkRenderingAttachmentInfo-imageView-06139";
4310 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid);
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004311 m_commandBuffer->BeginRendering(begin_rendering_info);
4312 m_errorMonitor->VerifyFound();
4313
4314 m_commandBuffer->end();
4315}
ziga-lunarge7503952022-04-23 12:19:14 +02004316
4317TEST_F(VkLayerTest, InvalidRenderingAttachmentImageViewFragmentDensityLayout) {
4318 TEST_DESCRIPTION("Use image view with invalid layout");
4319
4320 SetTargetApiVersion(VK_API_VERSION_1_1);
4321 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4322 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
4323 ASSERT_NO_FATAL_FAILURE(InitFramework());
4324
4325 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004326 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge7503952022-04-23 12:19:14 +02004327 }
sjfricked700bc02022-05-30 16:35:06 +09004328 if (!AreRequiredExtensionsEnabled()) {
4329 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge7503952022-04-23 12:19:14 +02004330 }
4331
4332 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4333 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4334 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4335 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004336 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge7503952022-04-23 12:19:14 +02004337 }
4338
4339 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4340 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4341
4342 VkImageObj image(m_device);
4343 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4344 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4345
4346 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4347 color_attachment.imageView = image_view;
4348 color_attachment.imageLayout = VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT;
4349
4350 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4351 begin_rendering_info.colorAttachmentCount = 1;
4352 begin_rendering_info.pColorAttachments = &color_attachment;
4353 begin_rendering_info.layerCount = 1;
4354
4355 m_commandBuffer->begin();
4356
4357 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06140");
4358 m_commandBuffer->BeginRendering(begin_rendering_info);
4359 m_errorMonitor->VerifyFound();
4360
4361 m_commandBuffer->end();
ziga-lunarg10cd0fb2022-04-23 12:20:46 +02004362}
4363
4364TEST_F(VkLayerTest, InvalidResolveImageViewFragmentDensityLayout) {
4365 TEST_DESCRIPTION("Use resolve image view with invalid fragment density layout");
4366
4367 SetTargetApiVersion(VK_API_VERSION_1_1);
4368 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4369 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
4370 ASSERT_NO_FATAL_FAILURE(InitFramework());
4371
4372 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004373 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg10cd0fb2022-04-23 12:20:46 +02004374 }
sjfricked700bc02022-05-30 16:35:06 +09004375 if (!AreRequiredExtensionsEnabled()) {
4376 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg10cd0fb2022-04-23 12:20:46 +02004377 }
4378
4379 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4380 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4381 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4382 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004383 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg10cd0fb2022-04-23 12:20:46 +02004384 }
4385
4386 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4387 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4388
4389 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4390 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4391 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
4392 image_create_info.extent = {32, 32, 4};
4393 image_create_info.mipLevels = 1;
4394 image_create_info.arrayLayers = 1;
4395 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4396 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4397 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4398
4399 VkImageObj image(m_device);
4400 image.Init(image_create_info);
4401 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4402
4403 VkImageObj resolve_image(m_device);
4404 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4405 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4406
4407 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4408 color_attachment.imageView = image_view;
4409 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4410 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4411 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT;
4412 color_attachment.resolveImageView = resolve_image_view;
4413
4414 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4415 begin_rendering_info.colorAttachmentCount = 1;
4416 begin_rendering_info.pColorAttachments = &color_attachment;
4417 begin_rendering_info.layerCount = 1;
4418
4419 m_commandBuffer->begin();
4420
4421 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06141");
4422 m_commandBuffer->BeginRendering(begin_rendering_info);
4423 m_errorMonitor->VerifyFound();
4424
4425 m_commandBuffer->end();
4426}
ziga-lunargdfa31d12022-04-23 12:22:18 +02004427
4428TEST_F(VkLayerTest, InvalidResolveImageViewReadOnlyOptimalLayout) {
4429 TEST_DESCRIPTION("Use resolve image view with invalid read only optimal layout");
4430
4431 SetTargetApiVersion(VK_API_VERSION_1_1);
4432 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4433 ASSERT_NO_FATAL_FAILURE(InitFramework());
4434
4435 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004436 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargdfa31d12022-04-23 12:22:18 +02004437 }
sjfricked700bc02022-05-30 16:35:06 +09004438 if (!AreRequiredExtensionsEnabled()) {
4439 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargdfa31d12022-04-23 12:22:18 +02004440 }
4441
4442 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
4443 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4444 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4445 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004446 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargdfa31d12022-04-23 12:22:18 +02004447 }
4448
4449 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4450 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4451
4452 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4453 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4454 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004455 image_create_info.extent = {32, 32, 1};
ziga-lunargdfa31d12022-04-23 12:22:18 +02004456 image_create_info.mipLevels = 1;
4457 image_create_info.arrayLayers = 1;
4458 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4459 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4460 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4461
4462 VkImageObj image(m_device);
4463 image.Init(image_create_info);
4464 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4465
4466 VkImageObj resolve_image(m_device);
4467 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4468 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4469
4470 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4471 color_attachment.imageView = image_view;
4472 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4473 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4474 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL;
4475 color_attachment.resolveImageView = resolve_image_view;
4476
4477 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4478 begin_rendering_info.colorAttachmentCount = 1;
4479 begin_rendering_info.pColorAttachments = &color_attachment;
4480 begin_rendering_info.layerCount = 1;
4481
4482 m_commandBuffer->begin();
4483
4484 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06142");
4485 m_commandBuffer->BeginRendering(begin_rendering_info);
4486 m_errorMonitor->VerifyFound();
4487
4488 m_commandBuffer->end();
4489}
ziga-lunarg735aa322022-04-24 14:17:47 +02004490
4491TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRateImageView) {
4492 TEST_DESCRIPTION("Test BeginRenderingInfo image view with FragmentShadingRateAttachment.");
4493
4494 SetTargetApiVersion(VK_API_VERSION_1_1);
4495 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4496 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
4497
4498 ASSERT_NO_FATAL_FAILURE(InitFramework());
4499
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004500 if (IsDriver(VK_DRIVER_ID_AMD_PROPRIETARY)) {
4501 GTEST_SKIP() << "Skipping on AMD proprietary driver pending further investigation.";
4502 }
4503
ziga-lunarg735aa322022-04-24 14:17:47 +02004504 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004505 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg735aa322022-04-24 14:17:47 +02004506 }
4507
sjfricked700bc02022-05-30 16:35:06 +09004508 if (!AreRequiredExtensionsEnabled()) {
4509 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg735aa322022-04-24 14:17:47 +02004510 }
4511
4512 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
4513 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4514 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4515
4516 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004517 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg735aa322022-04-24 14:17:47 +02004518 }
4519
4520 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
4521
4522 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
4523 vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2);
4524
4525 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4526 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4527
4528 VkImageObj image(m_device);
4529 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
4530 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR,
4531 VK_IMAGE_TILING_LINEAR, 0);
4532 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4533
4534 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
4535 fragment_shading_rate.imageView = image_view;
4536 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4537 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
4538
4539 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
4540 begin_rendering_info.layerCount = 1;
4541
4542 m_commandBuffer->begin();
4543
4544 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06147");
4545 m_commandBuffer->BeginRendering(begin_rendering_info);
4546 m_errorMonitor->VerifyFound();
4547
4548 m_commandBuffer->end();
4549}
ziga-lunarg644c0552022-04-24 17:50:58 +02004550
4551TEST_F(VkLayerTest, TestRenderingInfoColorAttachment) {
4552 TEST_DESCRIPTION("Test RenderingInfo color attachment.");
4553
4554 SetTargetApiVersion(VK_API_VERSION_1_1);
4555 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4556
4557 ASSERT_NO_FATAL_FAILURE(InitFramework());
4558
4559 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004560 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg644c0552022-04-24 17:50:58 +02004561 }
4562
sjfricked700bc02022-05-30 16:35:06 +09004563 if (!AreRequiredExtensionsEnabled()) {
4564 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg644c0552022-04-24 17:50:58 +02004565 }
4566
4567 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
4568 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4569 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4570
4571 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004572 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg644c0552022-04-24 17:50:58 +02004573 }
4574
4575 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4576 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4577
4578 VkImageObj invalid_image(m_device);
4579 invalid_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_SAMPLED_BIT, VK_IMAGE_TILING_LINEAR, 0);
4580 VkImageView invalid_image_view = invalid_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4581
4582 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4583 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4584 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004585 image_create_info.extent = {32, 32, 1};
ziga-lunarg644c0552022-04-24 17:50:58 +02004586 image_create_info.mipLevels = 1;
4587 image_create_info.arrayLayers = 1;
4588 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4589 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4590 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4591 image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
4592 VkImageObj image(m_device);
4593 image.Init(image_create_info);
4594 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4595
4596 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4597 color_attachment.imageView = invalid_image_view;
4598 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4599
4600 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4601 begin_rendering_info.layerCount = 1;
4602 begin_rendering_info.colorAttachmentCount = 1;
4603 begin_rendering_info.pColorAttachments = &color_attachment;
4604
4605 m_commandBuffer->begin();
4606
4607 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06087");
4608 m_commandBuffer->BeginRendering(begin_rendering_info);
4609 m_errorMonitor->VerifyFound();
4610
4611 color_attachment.imageView = image_view;
4612 color_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4613
4614 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06090");
4615 m_commandBuffer->BeginRendering(begin_rendering_info);
4616 m_errorMonitor->VerifyFound();
4617
4618 color_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
4619 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06096");
4620 m_commandBuffer->BeginRendering(begin_rendering_info);
4621 m_errorMonitor->VerifyFound();
4622
4623 color_attachment.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL;
4624 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06100");
4625 m_commandBuffer->BeginRendering(begin_rendering_info);
4626 m_errorMonitor->VerifyFound();
4627
4628 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4629 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4630 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4631
4632 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06091");
4633 m_commandBuffer->BeginRendering(begin_rendering_info);
4634 m_errorMonitor->VerifyFound();
4635
4636 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
4637 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06097");
4638 m_commandBuffer->BeginRendering(begin_rendering_info);
4639 m_errorMonitor->VerifyFound();
4640
4641 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
4642 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06101");
4643 m_commandBuffer->BeginRendering(begin_rendering_info);
4644 m_errorMonitor->VerifyFound();
4645
4646 color_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
sjfricke483c1082022-06-05 10:21:44 +09004647
ziga-lunarg644c0552022-04-24 17:50:58 +02004648 const uint32_t max_color_attachments = m_device->phy().properties().limits.maxColorAttachments + 1;
4649 std::vector<VkRenderingAttachmentInfoKHR> color_attachments(max_color_attachments);
4650 for (auto &attachment : color_attachments) {
4651 attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4652 attachment.imageView = image_view;
4653 attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4654 }
4655 begin_rendering_info.colorAttachmentCount = max_color_attachments;
4656 begin_rendering_info.pColorAttachments = color_attachments.data();
4657 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06106");
4658 m_commandBuffer->BeginRendering(begin_rendering_info);
4659 m_errorMonitor->VerifyFound();
4660
4661 m_commandBuffer->end();
4662}
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004663
4664TEST_F(VkLayerTest, TestRenderingInfoDepthAttachment) {
4665 TEST_DESCRIPTION("Test RenderingInfo depth attachment.");
4666
4667 SetTargetApiVersion(VK_API_VERSION_1_1);
4668 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4669 AddRequiredExtensions(VK_KHR_DEPTH_STENCIL_RESOLVE_EXTENSION_NAME);
4670
4671 ASSERT_NO_FATAL_FAILURE(InitFramework());
4672
4673 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004674 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004675 }
4676
sjfricked700bc02022-05-30 16:35:06 +09004677 if (!AreRequiredExtensionsEnabled()) {
4678 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004679 }
4680
4681 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
4682 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4683 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4684
4685 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004686 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004687 }
4688
4689 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4690 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4691
4692 VkFormat ds_format = FindSupportedDepthStencilFormat(gpu());
4693 if (ds_format == VK_FORMAT_UNDEFINED) {
4694 printf("%s No Depth + Stencil format found, skipping test..\n", kSkipPrefix);
4695 return;
4696 }
4697
4698 auto depth_stencil_resolve_properties = LvlInitStruct<VkPhysicalDeviceDepthStencilResolveProperties>();
4699 auto properties2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&depth_stencil_resolve_properties);
4700 vk::GetPhysicalDeviceProperties2(gpu(), &properties2);
4701 bool has_depth_resolve_mode_average =
4702 (depth_stencil_resolve_properties.supportedDepthResolveModes & VK_RESOLVE_MODE_AVERAGE_BIT) != 0;
4703 bool has_stencil_resolve_mode_average =
4704 (depth_stencil_resolve_properties.supportedStencilResolveModes & VK_RESOLVE_MODE_AVERAGE_BIT) != 0;
4705
4706 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4707 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4708 image_create_info.format = ds_format;
4709 image_create_info.extent = {32, 32, 1};
4710 image_create_info.mipLevels = 1;
4711 image_create_info.arrayLayers = 1;
4712 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4713 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4714 image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
4715 VkImageObj image(m_device);
4716 image.Init(image_create_info);
4717
4718 VkImageObj depth_image(m_device);
4719 depth_image.Init(image_create_info);
4720 VkImageView depth_image_view = depth_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4721 VkImageObj stencil_image(m_device);
4722 stencil_image.Init(image_create_info);
4723 VkImageView stencil_image_view = stencil_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4724
4725 VkImageObj depth_resolvel_image(m_device);
4726 depth_resolvel_image.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0);
4727 VkImageView depth_resolve_image_view =
4728 depth_resolvel_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4729
4730 VkImageObj stencil_resolvel_image(m_device);
4731 stencil_resolvel_image.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0);
4732 VkImageView stencil_resolve_image_view =
4733 stencil_resolvel_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4734
4735 VkImageObj invalid_image(m_device);
4736 image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
4737 invalid_image.Init(image_create_info);
4738 VkImageView invalid_image_view = invalid_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT);
4739
4740 auto depth_attachment = LvlInitStruct<VkRenderingAttachmentInfo>();
4741 depth_attachment.imageView = depth_image_view;
4742 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4743
4744 auto stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfo>();
4745 stencil_attachment.imageView = stencil_image_view;
4746 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4747
4748 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4749 begin_rendering_info.layerCount = 1;
4750 begin_rendering_info.pDepthAttachment = &depth_attachment;
4751 begin_rendering_info.pStencilAttachment = &stencil_attachment;
4752
4753 m_commandBuffer->begin();
4754
4755 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06085");
4756 m_commandBuffer->BeginRendering(begin_rendering_info);
4757 m_errorMonitor->VerifyFound();
4758
4759 depth_attachment.imageView = VK_NULL_HANDLE;
4760 stencil_attachment.imageView = VK_NULL_HANDLE;
4761 depth_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4762 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4763 depth_attachment.resolveImageView = depth_resolve_image_view;
4764 stencil_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4765 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4766 stencil_attachment.resolveImageView = stencil_resolve_image_view;
4767
4768 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06086");
4769 m_commandBuffer->BeginRendering(begin_rendering_info);
4770 m_errorMonitor->VerifyFound();
4771
4772 depth_attachment.imageView = depth_image_view;
4773 stencil_attachment.imageView = depth_image_view;
4774 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4775 stencil_attachment.resolveImageView = depth_resolve_image_view;
4776
4777 if (!has_depth_resolve_mode_average) {
4778 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06102");
4779 }
4780 if (!has_stencil_resolve_mode_average) {
4781 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06103");
4782 }
4783 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06093");
4784 m_commandBuffer->BeginRendering(begin_rendering_info);
4785 m_errorMonitor->VerifyFound();
4786
4787 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
4788 if (has_depth_resolve_mode_average && has_stencil_resolve_mode_average) {
4789 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06098");
4790 m_commandBuffer->BeginRendering(begin_rendering_info);
4791 m_errorMonitor->VerifyFound();
4792 }
4793
4794 depth_attachment.imageView = invalid_image_view;
4795 stencil_attachment.imageView = invalid_image_view;
4796 depth_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
4797 stencil_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
4798 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06088");
4799 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06089");
4800 m_commandBuffer->BeginRendering(begin_rendering_info);
4801 m_errorMonitor->VerifyFound();
4802
4803 depth_attachment.imageView = depth_image_view;
4804 stencil_attachment.imageView = depth_image_view;
4805 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4806 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06092");
4807 m_commandBuffer->BeginRendering(begin_rendering_info);
4808 m_errorMonitor->VerifyFound();
4809
4810 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4811 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4812 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4813 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4814 depth_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4815 if (depth_stencil_resolve_properties.independentResolveNone == VK_FALSE && has_depth_resolve_mode_average) {
4816 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06104");
4817 m_commandBuffer->BeginRendering(begin_rendering_info);
4818 m_errorMonitor->VerifyFound();
4819 }
4820 if (depth_stencil_resolve_properties.independentResolve == VK_FALSE && has_depth_resolve_mode_average) {
4821 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06105");
4822 m_commandBuffer->BeginRendering(begin_rendering_info);
4823 m_errorMonitor->VerifyFound();
4824 }
4825
ziga-lunargf35a7d72022-04-25 01:00:41 +02004826 stencil_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4827 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4828 if (has_stencil_resolve_mode_average) {
4829 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06095");
4830 m_commandBuffer->BeginRendering(begin_rendering_info);
4831 m_errorMonitor->VerifyFound();
4832 }
4833 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL;
4834 if (has_stencil_resolve_mode_average) {
4835 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06099");
4836 m_commandBuffer->BeginRendering(begin_rendering_info);
4837 m_errorMonitor->VerifyFound();
4838 }
4839
4840 depth_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
4841 stencil_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
4842 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4843 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06094");
4844 m_commandBuffer->BeginRendering(begin_rendering_info);
4845 m_errorMonitor->VerifyFound();
4846
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004847 m_commandBuffer->end();
4848}
ziga-lunarg002e6562022-04-25 00:54:16 +02004849
4850TEST_F(VkLayerTest, InvalidRenderingRenderAreaWithDeviceGroupExt) {
4851 TEST_DESCRIPTION("Use negative offset in RenderingInfo render area");
4852
4853 SetTargetApiVersion(VK_API_VERSION_1_1);
4854 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4855 ASSERT_NO_FATAL_FAILURE(InitFramework());
4856
4857 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004858 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg002e6562022-04-25 00:54:16 +02004859 }
sjfricked700bc02022-05-30 16:35:06 +09004860 if (!AreRequiredExtensionsEnabled()) {
4861 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg002e6562022-04-25 00:54:16 +02004862 }
4863
4864 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
4865 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4866 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4867 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004868 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg002e6562022-04-25 00:54:16 +02004869 }
4870
4871 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4872 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4873
4874 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4875 begin_rendering_info.layerCount = 1;
4876 begin_rendering_info.renderArea.offset.x = -1;
4877 begin_rendering_info.renderArea.extent.width = 32;
4878 begin_rendering_info.renderArea.extent.height = 32;
4879
4880 m_commandBuffer->begin();
4881
4882 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06077");
4883 m_commandBuffer->BeginRendering(begin_rendering_info);
4884 m_errorMonitor->VerifyFound();
4885
4886 begin_rendering_info.renderArea.offset.x = 0;
4887 begin_rendering_info.renderArea.offset.y = -1;
4888
4889 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06078");
4890 m_commandBuffer->BeginRendering(begin_rendering_info);
4891 m_errorMonitor->VerifyFound();
4892
4893 m_commandBuffer->end();
4894}
ziga-lunarg6e4f9da2022-04-25 01:05:22 +02004895
4896TEST_F(VkLayerTest, TestDynamicRenderingPipeline) {
4897 TEST_DESCRIPTION("Use pipeline created with render pass in dynamic render pass.");
4898
4899 SetTargetApiVersion(VK_API_VERSION_1_1);
4900 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4901
4902 ASSERT_NO_FATAL_FAILURE(InitFramework());
4903
4904 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004905 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg6e4f9da2022-04-25 01:05:22 +02004906 }
4907
sjfricked700bc02022-05-30 16:35:06 +09004908 if (!AreRequiredExtensionsEnabled()) {
4909 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6e4f9da2022-04-25 01:05:22 +02004910 }
4911
4912 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
4913 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4914 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4915
4916 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004917 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6e4f9da2022-04-25 01:05:22 +02004918 }
4919
4920 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4921 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4922
4923 CreatePipelineHelper pipe(*this);
4924 pipe.InitInfo();
4925 pipe.InitState();
4926 pipe.CreateGraphicsPipeline();
4927
4928 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4929 begin_rendering_info.layerCount = 1;
4930
4931 m_commandBuffer->begin();
4932 m_commandBuffer->BeginRendering(begin_rendering_info);
4933
4934 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_);
4935 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-renderPass-06198");
4936 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
4937 m_errorMonitor->VerifyFound();
4938
4939 m_commandBuffer->EndRendering();
4940 m_commandBuffer->end();
ziga-lunarg67551632022-04-25 15:20:20 +02004941}
4942
4943TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRateAttachmentSize) {
4944 TEST_DESCRIPTION("Test FragmentShadingRateAttachment size.");
4945
4946 SetTargetApiVersion(VK_API_VERSION_1_0);
4947 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4948 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004949 AddRequiredExtensions(VK_KHR_MULTIVIEW_EXTENSION_NAME);
ziga-lunarg67551632022-04-25 15:20:20 +02004950
4951 ASSERT_NO_FATAL_FAILURE(InitFramework());
4952
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004953 if (IsDriver(VK_DRIVER_ID_AMD_PROPRIETARY)) {
4954 GTEST_SKIP() << "Skipping on AMD proprietary driver pending further investigation.";
4955 }
4956
ziga-lunarg67551632022-04-25 15:20:20 +02004957 if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
sjfricke50955f32022-06-05 10:12:52 +09004958 GTEST_SKIP() << "Tests for 1.0 only";
ziga-lunarg67551632022-04-25 15:20:20 +02004959 }
4960
sjfricked700bc02022-05-30 16:35:06 +09004961 if (!AreRequiredExtensionsEnabled()) {
4962 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg67551632022-04-25 15:20:20 +02004963 }
4964
4965 auto vkGetPhysicalDeviceFeatures2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2KHR>(
4966 vk::GetInstanceProcAddr(instance(), "vkGetPhysicalDeviceFeatures2KHR"));
4967 ASSERT_TRUE(vkGetPhysicalDeviceFeatures2KHR != nullptr);
4968
4969 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004970 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeaturesKHR>(&dynamic_rendering_features);
4971 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2KHR>(&multiview_features);
ziga-lunarg67551632022-04-25 15:20:20 +02004972 vkGetPhysicalDeviceFeatures2KHR(gpu(), &features2);
4973
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004974 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004975 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg67551632022-04-25 15:20:20 +02004976 }
4977 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004978 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg67551632022-04-25 15:20:20 +02004979 }
4980
4981 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
4982
4983 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
4984 vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2);
4985
4986 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
4987
4988 VkImageObj image(m_device);
4989 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
4990 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR,
4991 VK_IMAGE_TILING_LINEAR, 0);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004992 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
ziga-lunarg67551632022-04-25 15:20:20 +02004993
4994 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
4995 fragment_shading_rate.imageView = image_view;
4996 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
4997 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
4998
4999 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
5000 begin_rendering_info.layerCount = 1;
5001 begin_rendering_info.renderArea.offset.x = fragment_shading_rate.shadingRateAttachmentTexelSize.width * 64;
5002
5003 m_commandBuffer->begin();
5004
5005 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06117");
5006 m_commandBuffer->BeginRendering(begin_rendering_info);
5007 m_errorMonitor->VerifyFound();
5008
5009 begin_rendering_info.renderArea.offset.x = 0;
5010 begin_rendering_info.renderArea.offset.y = fragment_shading_rate.shadingRateAttachmentTexelSize.height * 64;
5011
5012 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06118");
5013 m_commandBuffer->BeginRendering(begin_rendering_info);
5014 m_errorMonitor->VerifyFound();
5015}
5016
5017TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRateAttachmentSizeWithDeviceGroupExt) {
5018 TEST_DESCRIPTION("Test FragmentShadingRateAttachment size with device group extension.");
5019
5020 SetTargetApiVersion(VK_API_VERSION_1_1);
5021 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
5022 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06005023 AddRequiredExtensions(VK_KHR_MULTIVIEW_EXTENSION_NAME);
ziga-lunarg67551632022-04-25 15:20:20 +02005024
5025 ASSERT_NO_FATAL_FAILURE(InitFramework());
5026
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06005027 if (IsDriver(VK_DRIVER_ID_AMD_PROPRIETARY)) {
5028 GTEST_SKIP() << "Skipping on AMD proprietary driver pending further investigation.";
5029 }
5030
ziga-lunarg67551632022-04-25 15:20:20 +02005031 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09005032 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg67551632022-04-25 15:20:20 +02005033 }
5034
sjfricked700bc02022-05-30 16:35:06 +09005035 if (!AreRequiredExtensionsEnabled()) {
5036 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg67551632022-04-25 15:20:20 +02005037 }
5038
5039 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06005040 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeaturesKHR>(&dynamic_rendering_features);
5041 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&multiview_features);
ziga-lunarg67551632022-04-25 15:20:20 +02005042 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
5043
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06005044 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09005045 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg67551632022-04-25 15:20:20 +02005046 }
5047 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09005048 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg67551632022-04-25 15:20:20 +02005049 }
5050
5051 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
5052
5053 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
5054 vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2);
5055
5056 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
5057
5058 VkImageObj image(m_device);
5059 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
5060 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR,
5061 VK_IMAGE_TILING_LINEAR, 0);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06005062 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
ziga-lunarg67551632022-04-25 15:20:20 +02005063
5064 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
5065 fragment_shading_rate.imageView = image_view;
5066 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
5067 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
5068
5069 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
5070 begin_rendering_info.layerCount = 1;
5071 begin_rendering_info.renderArea.offset.x = fragment_shading_rate.shadingRateAttachmentTexelSize.width * 64;
5072
5073 m_commandBuffer->begin();
5074
5075 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06119");
5076 m_commandBuffer->BeginRendering(begin_rendering_info);
5077 m_errorMonitor->VerifyFound();
5078
5079 begin_rendering_info.renderArea.offset.x = 0;
5080 begin_rendering_info.renderArea.offset.y = fragment_shading_rate.shadingRateAttachmentTexelSize.height * 64;
5081
ziga-lunarg8f9de2a2022-04-25 15:59:19 +02005082 VkRect2D render_area = {};
5083 render_area.offset.x = 0;
5084 render_area.offset.y = 0;
5085 render_area.extent.width = 64 * fragment_shading_rate.shadingRateAttachmentTexelSize.width;
5086 render_area.extent.height = 32;
5087
5088 auto device_group_render_pass_begin_info = LvlInitStruct<VkDeviceGroupRenderPassBeginInfo>();
5089 device_group_render_pass_begin_info.deviceRenderAreaCount = 1;
5090 device_group_render_pass_begin_info.pDeviceRenderAreas = &render_area;
5091 fragment_shading_rate.pNext = &device_group_render_pass_begin_info;
5092
ziga-lunarg7f25dff2022-05-06 17:49:34 +02005093 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06120");
ziga-lunarg8f9de2a2022-04-25 15:59:19 +02005094 m_commandBuffer->BeginRendering(begin_rendering_info);
5095 m_errorMonitor->VerifyFound();
5096
5097 render_area.extent.width = 32;
5098 render_area.extent.height = 64 * fragment_shading_rate.shadingRateAttachmentTexelSize.height;
5099
5100 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06122");
ziga-lunarg67551632022-04-25 15:20:20 +02005101 m_commandBuffer->BeginRendering(begin_rendering_info);
5102 m_errorMonitor->VerifyFound();
5103}
ziga-lunarge966a9a2022-04-25 22:42:08 +02005104
5105TEST_F(VkLayerTest, TestSuspendingRenderPassInstance) {
5106 TEST_DESCRIPTION("Test suspending render pass instance.");
5107
5108 SetTargetApiVersion(VK_API_VERSION_1_1);
5109 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
5110
5111 ASSERT_NO_FATAL_FAILURE(InitFramework());
5112
5113 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09005114 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005115 }
5116
sjfricked700bc02022-05-30 16:35:06 +09005117 if (!AreRequiredExtensionsEnabled()) {
5118 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005119 }
5120
5121 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
5122 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
5123 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
5124
5125 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09005126 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005127 }
5128
5129 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
5130
5131 m_errorMonitor->ExpectSuccess();
5132
5133 VkCommandPoolObj command_pool(m_device, m_device->graphics_queue_node_index_);
5134 VkCommandBufferObj cmd_buffer1(m_device, &command_pool);
5135 VkCommandBufferObj cmd_buffer2(m_device, &command_pool);
5136 VkCommandBufferObj cmd_buffer3(m_device, &command_pool);
5137
5138 VkRenderingInfo suspend_rendering_info = LvlInitStruct<VkRenderingInfo>();
5139 suspend_rendering_info.flags = VK_RENDERING_SUSPENDING_BIT;
5140 suspend_rendering_info.layerCount = 1;
5141
5142 VkRenderingInfo resume_rendering_info = LvlInitStruct<VkRenderingInfo>();
5143 resume_rendering_info.flags = VK_RENDERING_RESUMING_BIT;
5144 resume_rendering_info.layerCount = 1;
5145
5146 VkRenderingInfo rendering_info = LvlInitStruct<VkRenderingInfo>();
5147 rendering_info.layerCount = 1;
5148
5149 auto cmd_begin = LvlInitStruct<VkCommandBufferBeginInfo>();
5150
5151 cmd_buffer1.begin(&cmd_begin);
5152 cmd_buffer1.BeginRendering(suspend_rendering_info);
5153 cmd_buffer1.EndRendering();
5154 cmd_buffer1.end();
5155
5156 cmd_buffer2.begin(&cmd_begin);
5157 cmd_buffer2.BeginRendering(resume_rendering_info);
5158 cmd_buffer2.EndRendering();
5159 cmd_buffer2.end();
5160
5161 cmd_buffer3.begin(&cmd_begin);
5162 cmd_buffer3.BeginRendering(rendering_info);
5163 cmd_buffer3.EndRendering();
5164 cmd_buffer3.end();
5165
5166 VkCommandBuffer command_buffers[3] = {cmd_buffer1.handle(), cmd_buffer2.handle()};
5167
5168 VkSubmitInfo submit_info = LvlInitStruct<VkSubmitInfo>();
5169 submit_info.commandBufferCount = 2;
5170 submit_info.pCommandBuffers = command_buffers;
5171 vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5172 vk::QueueWaitIdle(m_device->m_queue);
5173
5174 m_errorMonitor->VerifyNotFound();
5175
5176 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo-pCommandBuffers-06014");
5177
5178 submit_info.commandBufferCount = 1;
5179 vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5180 vk::QueueWaitIdle(m_device->m_queue);
5181
5182 m_errorMonitor->VerifyFound();
5183
5184 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo-pCommandBuffers-06016");
5185
5186 command_buffers[1] = cmd_buffer3.handle();
5187 command_buffers[2] = cmd_buffer2.handle();
5188 submit_info.commandBufferCount = 3;
5189 vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5190 vk::QueueWaitIdle(m_device->m_queue);
5191
5192 m_errorMonitor->VerifyFound();
5193
5194 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo-pCommandBuffers-06193");
5195
5196 command_buffers[0] = cmd_buffer2.handle();
5197 submit_info.commandBufferCount = 1;
5198 vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5199 vk::QueueWaitIdle(m_device->m_queue);
5200
5201 m_errorMonitor->VerifyFound();
5202}
5203
5204TEST_F(VkLayerTest, TestSuspendingRenderPassInstanceQueueSubmit2) {
5205 TEST_DESCRIPTION("Test suspending render pass instance with QueueSubmit2.");
5206
5207 SetTargetApiVersion(VK_API_VERSION_1_1);
5208 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
5209 AddRequiredExtensions(VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME);
5210
5211 ASSERT_NO_FATAL_FAILURE(InitFramework());
5212
5213 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09005214 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005215 }
5216
sjfricked700bc02022-05-30 16:35:06 +09005217 if (!AreRequiredExtensionsEnabled()) {
5218 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005219 }
5220
5221 auto synchronization2 = LvlInitStruct<VkPhysicalDeviceSynchronization2Features>();
5222 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&synchronization2);
5223 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
5224 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
5225
5226 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09005227 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005228 }
5229 if (synchronization2.synchronization2 == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09005230 GTEST_SKIP() << "Test requires (unsupported) synchronization2";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005231 }
5232
5233 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
5234
5235 auto vkQueueSubmit2KHR =
5236 reinterpret_cast<PFN_vkQueueSubmit2KHR>(vk::GetDeviceProcAddr(m_device->device(), "vkQueueSubmit2KHR"));
5237 ASSERT_TRUE(vkQueueSubmit2KHR != nullptr);
5238
5239 m_errorMonitor->ExpectSuccess();
5240
5241 VkCommandPoolObj command_pool(m_device, m_device->graphics_queue_node_index_);
5242 VkCommandBufferObj cmd_buffer1(m_device, &command_pool);
5243 VkCommandBufferObj cmd_buffer2(m_device, &command_pool);
5244 VkCommandBufferObj cmd_buffer3(m_device, &command_pool);
5245
5246 VkRenderingInfo suspend_rendering_info = LvlInitStruct<VkRenderingInfo>();
5247 suspend_rendering_info.flags = VK_RENDERING_SUSPENDING_BIT;
5248 suspend_rendering_info.layerCount = 1;
5249
5250 VkRenderingInfo resume_rendering_info = LvlInitStruct<VkRenderingInfo>();
5251 resume_rendering_info.flags = VK_RENDERING_RESUMING_BIT;
5252 resume_rendering_info.layerCount = 1;
5253
5254 VkRenderingInfo rendering_info = LvlInitStruct<VkRenderingInfo>();
5255 rendering_info.layerCount = 1;
5256
5257 auto cmd_begin = LvlInitStruct<VkCommandBufferBeginInfo>();
5258
5259 cmd_buffer1.begin(&cmd_begin);
5260 cmd_buffer1.BeginRendering(suspend_rendering_info);
5261 cmd_buffer1.EndRendering();
5262 cmd_buffer1.end();
5263
5264 cmd_buffer2.begin(&cmd_begin);
5265 cmd_buffer2.BeginRendering(resume_rendering_info);
5266 cmd_buffer2.EndRendering();
5267 cmd_buffer2.end();
5268
5269 cmd_buffer3.begin(&cmd_begin);
5270 cmd_buffer3.BeginRendering(rendering_info);
5271 cmd_buffer3.EndRendering();
5272 cmd_buffer3.end();
5273
5274 VkCommandBufferSubmitInfo command_buffer_submit_info[3];
5275 command_buffer_submit_info[0] = LvlInitStruct<VkCommandBufferSubmitInfo>();
5276 command_buffer_submit_info[1] = LvlInitStruct<VkCommandBufferSubmitInfo>();
5277 command_buffer_submit_info[2] = LvlInitStruct<VkCommandBufferSubmitInfo>();
5278
5279 command_buffer_submit_info[0].commandBuffer = cmd_buffer1.handle();
5280 command_buffer_submit_info[1].commandBuffer = cmd_buffer2.handle();
5281
5282 VkSubmitInfo2KHR submit_info = LvlInitStruct<VkSubmitInfo2KHR>();
5283 submit_info.commandBufferInfoCount = 2;
5284 submit_info.pCommandBufferInfos = command_buffer_submit_info;
5285 vkQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5286 vk::QueueWaitIdle(m_device->m_queue);
5287
5288 m_errorMonitor->VerifyNotFound();
5289
5290 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo2KHR-commandBuffer-06010");
5291
5292 submit_info.commandBufferInfoCount = 1;
5293 vkQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5294 vk::QueueWaitIdle(m_device->m_queue);
5295
5296 m_errorMonitor->VerifyFound();
5297
5298 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo2KHR-commandBuffer-06012");
5299
5300 command_buffer_submit_info[1].commandBuffer = cmd_buffer3.handle();
5301 command_buffer_submit_info[2].commandBuffer = cmd_buffer2.handle();
5302 submit_info.commandBufferInfoCount = 3;
5303 vkQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5304 vk::QueueWaitIdle(m_device->m_queue);
5305
5306 m_errorMonitor->VerifyFound();
5307
5308 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo2KHR-commandBuffer-06192");
5309
5310 command_buffer_submit_info[0].commandBuffer = cmd_buffer2.handle();
5311 submit_info.commandBufferInfoCount = 1;
5312 vkQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5313 vk::QueueWaitIdle(m_device->m_queue);
5314
5315 m_errorMonitor->VerifyFound();
5316}