blob: 8a818d5e41869c77558b7b6364dd24f6b700f26b [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.");
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800207
Aaron Haganaca50442021-12-07 22:26:29 -0500208 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2);
209 if (version < VK_API_VERSION_1_2) {
210 printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix);
211 return;
212 }
213
214 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
215
216 ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor));
217
218 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900219 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
Aaron Haganaca50442021-12-07 22:26:29 -0500220 }
221
sjfricked700bc02022-05-30 16:35:06 +0900222 if (!AreRequiredExtensionsEnabled()) {
223 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
Aaron Haganaca50442021-12-07 22:26:29 -0500224 }
225
226 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
227 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
228 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
229 if (!dynamic_rendering_features.dynamicRendering) {
230 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
231 return;
232 }
233
234 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
235
236 const VkPipelineLayoutObj pl(m_device);
237 VkPipelineObj pipe(m_device);
238
239 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
240
241 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
242 color_blend_state_create_info.attachmentCount = 1;
243 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
244
245 VkFormat color_format[2] = {VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_D32_SFLOAT_S8_UINT};
246
247 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
248 pipeline_rendering_info.colorAttachmentCount = 2;
249 pipeline_rendering_info.pColorAttachmentFormats = &color_format[0];
250 pipeline_rendering_info.viewMask = 0x2;
Aaron Hagan80034ea2021-12-23 11:24:09 -0500251 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
Aaron Haganaca50442021-12-07 22:26:29 -0500252
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800253 auto pipeline_tessellation_state_info = LvlInitStruct<VkPipelineTessellationStateCreateInfo>();
Aaron Haganaca50442021-12-07 22:26:29 -0500254 pipeline_tessellation_state_info.patchControlPoints = 1;
255
256 auto pipeline_input_assembly_state_info = LvlInitStruct<VkPipelineInputAssemblyStateCreateInfo>();
257 pipeline_input_assembly_state_info.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST;
258
259 auto create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
Aaron Hagan80034ea2021-12-23 11:24:09 -0500260
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800261 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
262 VkShaderObj gs(this, bindStateGeomShaderText, VK_SHADER_STAGE_GEOMETRY_BIT);
263 VkShaderObj te(this, bindStateTeshaderText, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT);
264 VkShaderObj tc(this, bindStateTscShaderText, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT);
Aaron Hagan80034ea2021-12-23 11:24:09 -0500265 VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT);
266
Aaron Haganaca50442021-12-07 22:26:29 -0500267 pipe.AddShader(&vs);
268 pipe.AddShader(&gs);
269 pipe.AddShader(&te);
270 pipe.AddShader(&tc);
Aaron Hagan80034ea2021-12-23 11:24:09 -0500271 pipe.AddShader(&fs);
Aaron Haganaca50442021-12-07 22:26:29 -0500272 pipe.InitGraphicsPipelineCreateInfo(&create_info);
Nathaniel Cesario72f29552022-03-24 05:11:11 -0600273
Aaron Haganaca50442021-12-07 22:26:29 -0500274 create_info.pColorBlendState = &color_blend_state_create_info;
275 create_info.pNext = &pipeline_rendering_info;
276 create_info.pTessellationState = &pipeline_tessellation_state_info;
277 create_info.pInputAssemblyState = &pipeline_input_assembly_state_info;
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800278
Aaron Hagan80034ea2021-12-23 11:24:09 -0500279 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06053");
Nathaniel Cesario72f29552022-03-24 05:11:11 -0600280 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06581");
Aaron Haganaca50442021-12-07 22:26:29 -0500281 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06055");
282 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06057");
283 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06058");
Nathaniel Cesarioa6118572022-03-24 04:48:33 -0600284 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-multiview-06577");
Aaron Haganaca50442021-12-07 22:26:29 -0500285 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
286 m_errorMonitor->VerifyFound();
287
Aaron Hagan80034ea2021-12-23 11:24:09 -0500288 create_info.pColorBlendState = nullptr;
289 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
290 pipeline_rendering_info.viewMask = 0x0;
291 pipeline_rendering_info.colorAttachmentCount = 1;
292 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06054");
293 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
294 m_errorMonitor->VerifyFound();
Aaron Haganb54466d2022-02-18 15:02:54 -0500295
ziga-lunarg5e671602022-03-17 19:06:55 +0100296 color_format[0] = VK_FORMAT_D32_SFLOAT_S8_UINT;
297 color_blend_attachment_state.blendEnable = VK_TRUE;
298 create_info.pColorBlendState = &color_blend_state_create_info;
Nathaniel Cesario72f29552022-03-24 05:11:11 -0600299 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06581");
ziga-lunarg5e671602022-03-17 19:06:55 +0100300 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06062");
ziga-lunarg5e671602022-03-17 19:06:55 +0100301 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
302 m_errorMonitor->VerifyFound();
303 color_format[0] = VK_FORMAT_R8G8B8A8_UNORM;
304
Aaron Haganb54466d2022-02-18 15:02:54 -0500305 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
306 ds_ci.flags = VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM;
307 color_blend_state_create_info.flags = VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM;
308 create_info.pColorBlendState = &color_blend_state_create_info;
309 create_info.pDepthStencilState = &ds_ci;
310 create_info.renderPass = VK_NULL_HANDLE;
311 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
312 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06482");
313 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06483");
314 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
315 m_errorMonitor->VerifyFound();
stusmith15f24a82021-12-24 15:21:19 +0000316}
317
318TEST_F(VkLayerTest, DynamicRenderingWithMismatchingViewMask) {
319 TEST_DESCRIPTION("Draw with Dynamic Rendering and a mismatching viewMask");
320
321 SetTargetApiVersion(VK_API_VERSION_1_1);
322
323 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
324
325 ASSERT_NO_FATAL_FAILURE(InitFramework());
326
sjfricked700bc02022-05-30 16:35:06 +0900327 if (!AreRequiredExtensionsEnabled()) {
328 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
stusmith15f24a82021-12-24 15:21:19 +0000329 }
330
331 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900332 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
stusmith15f24a82021-12-24 15:21:19 +0000333 }
334
335 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
336 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(&multiview_features);
337 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
338 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
339 if (!dynamic_rendering_features.dynamicRendering) {
340 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
341 return;
342 }
343 if (!multiview_features.multiview) {
344 printf("%s Test requires (unsupported) multiview , skipping\n", kSkipPrefix);
345 return;
346 }
347
348 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
349
350 char const *fsSource = R"glsl(
351 #version 450
352 layout(location=0) out vec4 color;
353 void main() {
354 color = vec4(1.0f);
355 }
356 )glsl";
357
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800358 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
359 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000360
361 VkPipelineObj pipe(m_device);
362 pipe.AddShader(&vs);
363 pipe.AddShader(&fs);
364 pipe.AddDefaultColorAttachment();
365
366 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
367 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
368 const VkPipelineLayoutObj pl(m_device, {&dsl});
369
370 VkFormat color_formats = {VK_FORMAT_R8G8B8A8_UNORM};
371 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
372 pipeline_rendering_info.colorAttachmentCount = 1;
373 pipeline_rendering_info.pColorAttachmentFormats = &color_formats;
374 pipeline_rendering_info.viewMask = 1;
375
376 VkViewport viewport = {0, 0, 16, 16, 0, 1};
377 VkRect2D scissor = {{0, 0}, {16, 16}};
378 m_viewports.push_back(viewport);
379 m_scissors.push_back(scissor);
380 pipe.SetViewport(m_viewports);
381 pipe.SetScissor(m_scissors);
382
383 auto create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
384 pipe.InitGraphicsPipelineCreateInfo(&create_info);
385 create_info.pNext = &pipeline_rendering_info;
386
387 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
388
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800389 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000390 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
391
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800392 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000393 begin_rendering_info.colorAttachmentCount = 1;
394 begin_rendering_info.pColorAttachments = &color_attachment;
395 begin_rendering_info.viewMask = 2;
396 begin_rendering_info.layerCount = 1;
397
398 m_commandBuffer->begin();
399 m_commandBuffer->BeginRendering(begin_rendering_info);
400 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle());
401 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-viewMask-06178");
402 m_commandBuffer->Draw(1, 1, 0, 0);
403 m_errorMonitor->VerifyFound();
404 m_commandBuffer->EndRendering();
405 m_commandBuffer->end();
406}
407
408TEST_F(VkLayerTest, DynamicRenderingWithMistmatchingAttachments) {
409 TEST_DESCRIPTION("Draw with Dynamic Rendering with mismatching color attachment counts and depth/stencil formats");
410
411 SetTargetApiVersion(VK_API_VERSION_1_1);
412
413 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
414
415 ASSERT_NO_FATAL_FAILURE(InitFramework());
416
sjfricked700bc02022-05-30 16:35:06 +0900417 if (!AreRequiredExtensionsEnabled()) {
418 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
stusmith15f24a82021-12-24 15:21:19 +0000419 }
420
421 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900422 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
stusmith15f24a82021-12-24 15:21:19 +0000423 }
424
425 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
426 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
427 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
428 if (!dynamic_rendering_features.dynamicRendering) {
429 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
430 return;
431 }
432
433 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
434
435 char const *fsSource = R"glsl(
436 #version 450
437 layout(location=0) out vec4 color;
438 void main() {
439 color = vec4(1.0f);
440 }
441 )glsl";
442
443 VkViewport viewport = {0, 0, 16, 16, 0, 1};
444 VkRect2D scissor = {{0, 0}, {16, 16}};
445 m_viewports.push_back(viewport);
446 m_scissors.push_back(scissor);
447
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800448 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
449 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000450
451 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
452 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
453 const VkPipelineLayoutObj pl(m_device, {&dsl});
454
455 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
456
457 VkPipelineObj pipe1(m_device);
458 pipe1.AddShader(&vs);
459 pipe1.AddShader(&fs);
460 pipe1.AddDefaultColorAttachment();
461 pipe1.SetViewport(m_viewports);
462 pipe1.SetScissor(m_scissors);
463
464 VkFormat color_formats[] = {VK_FORMAT_R8G8B8A8_UNORM};
465 pipeline_rendering_info.colorAttachmentCount = 1;
466 pipeline_rendering_info.pColorAttachmentFormats = color_formats;
467
468 auto create_info1 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
469 pipe1.InitGraphicsPipelineCreateInfo(&create_info1);
470 create_info1.pNext = &pipeline_rendering_info;
471
472 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
473
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600474 auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
475
stusmith15f24a82021-12-24 15:21:19 +0000476 VkPipelineObj pipe2(m_device);
477 pipe2.AddShader(&vs);
478 pipe2.AddShader(&fs);
479 pipe2.AddDefaultColorAttachment();
480 pipe2.SetViewport(m_viewports);
481 pipe2.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600482 pipe2.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000483
484 pipeline_rendering_info.colorAttachmentCount = 0;
485 pipeline_rendering_info.pColorAttachmentFormats = nullptr;
486 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_D16_UNORM;
487
488 auto create_info2 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
489 pipe2.InitGraphicsPipelineCreateInfo(&create_info2);
490 create_info2.pNext = &pipeline_rendering_info;
491
492 pipe2.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info2);
493
494 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
495 ASSERT_TRUE(depthStencilFormat != 0);
496
497 bool testStencil = false;
498 VkFormat stencilFormat = VK_FORMAT_UNDEFINED;
499
500 if (ImageFormatIsSupported(gpu(), VK_FORMAT_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
501 stencilFormat = VK_FORMAT_S8_UINT;
502 testStencil = true;
503 } else if ((depthStencilFormat != VK_FORMAT_D16_UNORM_S8_UINT) &&
504 ImageFormatIsSupported(gpu(), VK_FORMAT_D16_UNORM_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
505 stencilFormat = VK_FORMAT_D16_UNORM_S8_UINT;
506 testStencil = true;
507 } else if ((depthStencilFormat != VK_FORMAT_D24_UNORM_S8_UINT) &&
508 ImageFormatIsSupported(gpu(), VK_FORMAT_D24_UNORM_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
509 stencilFormat = VK_FORMAT_D24_UNORM_S8_UINT;
510 testStencil = true;
511 } else if ((depthStencilFormat != VK_FORMAT_D32_SFLOAT_S8_UINT) &&
512 ImageFormatIsSupported(gpu(), VK_FORMAT_D32_SFLOAT_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
513 stencilFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
514 testStencil = true;
515 }
516
517 VkPipelineObj pipe3(m_device);
518
519 if (testStencil) {
520 pipe3.AddShader(&vs);
521 pipe3.AddShader(&fs);
522 pipe3.AddDefaultColorAttachment();
523 pipe3.SetViewport(m_viewports);
524 pipe3.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600525 pipe3.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000526
527 pipeline_rendering_info.colorAttachmentCount = 0;
528 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
529 pipeline_rendering_info.stencilAttachmentFormat = stencilFormat;
530
531 auto create_info3 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
532 pipe3.InitGraphicsPipelineCreateInfo(&create_info3);
533 create_info3.pNext = &pipeline_rendering_info;
534
535 pipe3.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info3);
536 }
537
538 VkImageObj colorImage(m_device);
539 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
540 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
541
542 VkImageObj depthStencilImage(m_device);
543 depthStencilImage.Init(32, 32, 1, depthStencilFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
544 VkImageView depthStencilImageView =
545 depthStencilImage.targetView(depthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
546
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800547 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000548 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
549 color_attachment.imageView = colorImageView;
550
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800551 VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000552 depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
553 depth_stencil_attachment.imageView = depthStencilImageView;
554
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800555 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600556 begin_rendering_info.layerCount = 1;
stusmith15f24a82021-12-24 15:21:19 +0000557 m_commandBuffer->begin();
558
559 // Mismatching color attachment count
560 m_commandBuffer->BeginRendering(begin_rendering_info);
561 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
562 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06179");
563 m_commandBuffer->Draw(1, 1, 0, 0);
564 m_errorMonitor->VerifyFound();
565 m_commandBuffer->EndRendering();
566
567 // Mismatching color formats
568 begin_rendering_info.colorAttachmentCount = 1;
569 begin_rendering_info.pColorAttachments = &color_attachment;
570 m_commandBuffer->BeginRendering(begin_rendering_info);
571 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
572 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06180");
573 m_commandBuffer->Draw(1, 1, 0, 0);
574 m_errorMonitor->VerifyFound();
575 m_commandBuffer->EndRendering();
576
577 // Mismatching depth format
578 begin_rendering_info.colorAttachmentCount = 0;
579 begin_rendering_info.pColorAttachments = nullptr;
580 begin_rendering_info.pDepthAttachment = &depth_stencil_attachment;
581 m_commandBuffer->BeginRendering(begin_rendering_info);
582 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.handle());
583 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06181");
584 m_commandBuffer->Draw(1, 1, 0, 0);
585 m_errorMonitor->VerifyFound();
586 m_commandBuffer->EndRendering();
587
588 // Mismatching stencil format
589 if (testStencil) {
590 begin_rendering_info.pDepthAttachment = nullptr;
591 begin_rendering_info.pStencilAttachment = &depth_stencil_attachment;
592 m_commandBuffer->BeginRendering(begin_rendering_info);
593 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe3.handle());
594 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06182");
595 m_commandBuffer->Draw(1, 1, 0, 0);
596 m_errorMonitor->VerifyFound();
597 m_commandBuffer->EndRendering();
598 }
599
600 m_commandBuffer->end();
601}
602
603TEST_F(VkLayerTest, DynamicRenderingWithMistmatchingAttachmentSamples) {
604 TEST_DESCRIPTION("Draw with Dynamic Rendering with mismatching color/depth/stencil sample counts");
605
606 SetTargetApiVersion(VK_API_VERSION_1_1);
607
608 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
609
610 ASSERT_NO_FATAL_FAILURE(InitFramework());
611
sjfricked700bc02022-05-30 16:35:06 +0900612 if (!AreRequiredExtensionsEnabled()) {
613 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
stusmith15f24a82021-12-24 15:21:19 +0000614 }
615
616 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900617 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
stusmith15f24a82021-12-24 15:21:19 +0000618 }
619
620 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
621 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
622 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
623 if (!dynamic_rendering_features.dynamicRendering) {
624 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
625 return;
626 }
627
628 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
629
630 char const *fsSource = R"glsl(
631 #version 450
632 layout(location=0) out vec4 color;
633 void main() {
634 color = vec4(1.0f);
635 }
636 )glsl";
637
638 VkViewport viewport = {0, 0, 16, 16, 0, 1};
639 VkRect2D scissor = {{0, 0}, {16, 16}};
640 m_viewports.push_back(viewport);
641 m_scissors.push_back(scissor);
642
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800643 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
644 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000645
646 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
647 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
648 const VkPipelineLayoutObj pl(m_device, {&dsl});
649
650 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
651
stusmith15f24a82021-12-24 15:21:19 +0000652 VkPipelineObj pipe1(m_device);
653 pipe1.AddShader(&vs);
654 pipe1.AddShader(&fs);
655 pipe1.AddDefaultColorAttachment();
656 pipe1.SetViewport(m_viewports);
657 pipe1.SetScissor(m_scissors);
658
659 VkFormat color_formats[] = {VK_FORMAT_R8G8B8A8_UNORM};
660 pipeline_rendering_info.colorAttachmentCount = 1;
661 pipeline_rendering_info.pColorAttachmentFormats = color_formats;
662
663 auto create_info1 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
664 pipe1.InitGraphicsPipelineCreateInfo(&create_info1);
665 create_info1.pNext = &pipeline_rendering_info;
666
667 auto multisample_state_create_info = LvlInitStruct<VkPipelineMultisampleStateCreateInfo>();
668 multisample_state_create_info.rasterizationSamples = VK_SAMPLE_COUNT_2_BIT;
669 create_info1.pMultisampleState = &multisample_state_create_info;
670
671 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
672
stusmith15f24a82021-12-24 15:21:19 +0000673 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
674 ASSERT_TRUE(depthStencilFormat != 0);
675
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600676 auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
677
stusmith15f24a82021-12-24 15:21:19 +0000678 VkPipelineObj pipe2(m_device);
679 pipe2.AddShader(&vs);
680 pipe2.AddShader(&fs);
681 pipe2.AddDefaultColorAttachment();
682 pipe2.SetViewport(m_viewports);
683 pipe2.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600684 pipe2.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000685
686 pipeline_rendering_info.colorAttachmentCount = 0;
687 pipeline_rendering_info.pColorAttachmentFormats = nullptr;
688 pipeline_rendering_info.depthAttachmentFormat = depthStencilFormat;
689
690 auto create_info2 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
691 pipe2.InitGraphicsPipelineCreateInfo(&create_info2);
692 create_info2.pNext = &pipeline_rendering_info;
693
694 create_info2.pMultisampleState = &multisample_state_create_info;
695
696 pipe2.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info2);
697
stusmith15f24a82021-12-24 15:21:19 +0000698 VkPipelineObj pipe3(m_device);
699
700 pipe3.AddShader(&vs);
701 pipe3.AddShader(&fs);
702 pipe3.AddDefaultColorAttachment();
703 pipe3.SetViewport(m_viewports);
704 pipe3.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600705 pipe3.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000706
707 pipeline_rendering_info.colorAttachmentCount = 0;
708 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
709 pipeline_rendering_info.stencilAttachmentFormat = depthStencilFormat;
710
711 auto create_info3 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
712 pipe3.InitGraphicsPipelineCreateInfo(&create_info3);
713 create_info3.pNext = &pipeline_rendering_info;
714
715 create_info3.pMultisampleState = &multisample_state_create_info;
716
717 pipe3.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info3);
718
stusmith15f24a82021-12-24 15:21:19 +0000719 VkImageObj colorImage(m_device);
720 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
721 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UNORM);
722
723 VkImageObj depthStencilImage(m_device);
724 depthStencilImage.Init(32, 32, 1, depthStencilFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
725 VkImageView depthStencilImageView =
726 depthStencilImage.targetView(depthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
727
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800728 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000729 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
730 color_attachment.imageView = colorImageView;
731
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800732 VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000733 depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
734 depth_stencil_attachment.imageView = depthStencilImageView;
735
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800736 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600737 begin_rendering_info.layerCount = 1;
stusmith15f24a82021-12-24 15:21:19 +0000738 m_commandBuffer->begin();
739
740 // Mismatching color samples
741 begin_rendering_info.colorAttachmentCount = 1;
742 begin_rendering_info.pColorAttachments = &color_attachment;
743 m_commandBuffer->BeginRendering(begin_rendering_info);
744 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
745 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06188");
746 m_commandBuffer->Draw(1, 1, 0, 0);
747 m_errorMonitor->VerifyFound();
748 m_commandBuffer->EndRendering();
749
750 // Mismatching depth samples
751 begin_rendering_info.colorAttachmentCount = 0;
752 begin_rendering_info.pColorAttachments = nullptr;
753 begin_rendering_info.pDepthAttachment = &depth_stencil_attachment;
754 m_commandBuffer->BeginRendering(begin_rendering_info);
755 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.handle());
756 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06189");
757 m_commandBuffer->Draw(1, 1, 0, 0);
758 m_errorMonitor->VerifyFound();
759 m_commandBuffer->EndRendering();
760
761 // Mismatching stencil samples
762 begin_rendering_info.pDepthAttachment = nullptr;
763 begin_rendering_info.pStencilAttachment = &depth_stencil_attachment;
764 m_commandBuffer->BeginRendering(begin_rendering_info);
765 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe3.handle());
766 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06190");
767 m_commandBuffer->Draw(1, 1, 0, 0);
768 m_errorMonitor->VerifyFound();
769 m_commandBuffer->EndRendering();
770
771 m_commandBuffer->end();
772}
773
ziga-lunarga3cc8482022-04-29 14:58:29 +0200774TEST_F(VkLayerTest, DynamicRenderingWithMismatchingMixedAttachmentSamples) {
stusmith15f24a82021-12-24 15:21:19 +0000775 TEST_DESCRIPTION("Draw with Dynamic Rendering with mismatching mixed color/depth/stencil sample counts");
776
777 SetTargetApiVersion(VK_API_VERSION_1_1);
778
779 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
780
781 ASSERT_NO_FATAL_FAILURE(InitFramework());
782
sjfricked700bc02022-05-30 16:35:06 +0900783 if (!AreRequiredExtensionsEnabled()) {
784 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
stusmith15f24a82021-12-24 15:21:19 +0000785 }
786
787 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900788 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
stusmith15f24a82021-12-24 15:21:19 +0000789 }
790
791 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
792 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
793 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
794 if (!dynamic_rendering_features.dynamicRendering) {
795 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
796 return;
797 }
798
799 bool amd_samples = false;
800 if (DeviceExtensionSupported(gpu(), nullptr, VK_AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME)) {
801 m_device_extension_names.push_back(VK_AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME);
802 amd_samples = true;
803 }
804
805 bool nv_samples = false;
806 if (DeviceExtensionSupported(gpu(), nullptr, VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME)) {
807 m_device_extension_names.push_back(VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME);
808 nv_samples = true;
809 }
810
811 if (!amd_samples && !nv_samples) {
812 printf("%s Test requires either VK_AMD_mixed_attachment_samples or VK_NV_framebuffer_mixed_samples, skipping\n",
813 kSkipPrefix);
814 return;
815 }
816
817 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
818
819 char const *fsSource = R"glsl(
820 #version 450
821 layout(location=0) out vec4 color;
822 void main() {
823 color = vec4(1.0f);
824 }
825 )glsl";
826
827 VkViewport viewport = {0, 0, 16, 16, 0, 1};
828 VkRect2D scissor = {{0, 0}, {16, 16}};
829 m_viewports.push_back(viewport);
830 m_scissors.push_back(scissor);
831
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800832 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
833 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000834
835 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
836 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
837 const VkPipelineLayoutObj pl(m_device, {&dsl});
838
ziga-lunarga3cc8482022-04-29 14:58:29 +0200839 VkSampleCountFlagBits counts[2] = {VK_SAMPLE_COUNT_2_BIT, VK_SAMPLE_COUNT_2_BIT};
stusmith15f24a82021-12-24 15:21:19 +0000840 auto samples_info = LvlInitStruct<VkAttachmentSampleCountInfoAMD>();
841
842 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(&samples_info);
843
844 VkPipelineObj pipe1(m_device);
845 pipe1.AddShader(&vs);
846 pipe1.AddShader(&fs);
847 pipe1.AddDefaultColorAttachment();
848 pipe1.SetViewport(m_viewports);
849 pipe1.SetScissor(m_scissors);
850
851 VkFormat color_formats[] = {VK_FORMAT_R8G8B8A8_UNORM};
852 pipeline_rendering_info.colorAttachmentCount = 1;
853 pipeline_rendering_info.pColorAttachmentFormats = color_formats;
854
855 samples_info.colorAttachmentCount = 1;
ziga-lunarga3cc8482022-04-29 14:58:29 +0200856 samples_info.pColorAttachmentSamples = counts;
stusmith15f24a82021-12-24 15:21:19 +0000857
858 auto create_info1 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
859 pipe1.InitGraphicsPipelineCreateInfo(&create_info1);
860 create_info1.pNext = &pipeline_rendering_info;
861
Aaron Haganb54466d2022-02-18 15:02:54 -0500862 samples_info.colorAttachmentCount = 2;
863 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06063");
864 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
865 m_errorMonitor->VerifyFound();
866
867 samples_info.colorAttachmentCount = 1;
stusmith15f24a82021-12-24 15:21:19 +0000868 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
869
870 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
871 ASSERT_TRUE(depthStencilFormat != 0);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600872 auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
stusmith15f24a82021-12-24 15:21:19 +0000873
874 VkPipelineObj pipe2(m_device);
875 pipe2.AddShader(&vs);
876 pipe2.AddShader(&fs);
877 pipe2.AddDefaultColorAttachment();
878 pipe2.SetViewport(m_viewports);
879 pipe2.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600880 pipe2.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000881
882 pipeline_rendering_info.colorAttachmentCount = 0;
883 pipeline_rendering_info.pColorAttachmentFormats = nullptr;
884 pipeline_rendering_info.depthAttachmentFormat = depthStencilFormat;
885
886 samples_info.colorAttachmentCount = 0;
887 samples_info.pColorAttachmentSamples = nullptr;
ziga-lunarga3cc8482022-04-29 14:58:29 +0200888 samples_info.depthStencilAttachmentSamples = counts[0];
stusmith15f24a82021-12-24 15:21:19 +0000889
890 auto create_info2 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
891 pipe2.InitGraphicsPipelineCreateInfo(&create_info2);
892 create_info2.pNext = &pipeline_rendering_info;
893
894 pipe2.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info2);
895
896 VkPipelineObj pipe3(m_device);
897
898 pipe3.AddShader(&vs);
899 pipe3.AddShader(&fs);
900 pipe3.AddDefaultColorAttachment();
901 pipe3.SetViewport(m_viewports);
902 pipe3.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600903 pipe3.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000904
905 pipeline_rendering_info.colorAttachmentCount = 0;
906 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
907 pipeline_rendering_info.stencilAttachmentFormat = depthStencilFormat;
908
909 auto create_info3 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
910 pipe3.InitGraphicsPipelineCreateInfo(&create_info3);
911 create_info3.pNext = &pipeline_rendering_info;
912
913 pipe3.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info3);
914
915 VkImageObj colorImage(m_device);
916 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
917 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UNORM);
918
919 VkImageObj depthStencilImage(m_device);
920 depthStencilImage.Init(32, 32, 1, depthStencilFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
921 VkImageView depthStencilImageView =
922 depthStencilImage.targetView(depthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
923
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800924 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000925 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
926 color_attachment.imageView = colorImageView;
927
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800928 VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000929 depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
930 depth_stencil_attachment.imageView = depthStencilImageView;
931
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800932 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000933 m_commandBuffer->begin();
934
935 // Mismatching color samples
936 begin_rendering_info.colorAttachmentCount = 1;
937 begin_rendering_info.pColorAttachments = &color_attachment;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600938 begin_rendering_info.layerCount = 1;
stusmith15f24a82021-12-24 15:21:19 +0000939 m_commandBuffer->BeginRendering(begin_rendering_info);
940 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
941 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06185");
942 m_commandBuffer->Draw(1, 1, 0, 0);
943 m_errorMonitor->VerifyFound();
944 m_commandBuffer->EndRendering();
945
946 // Mismatching depth samples
947 begin_rendering_info.colorAttachmentCount = 0;
948 begin_rendering_info.pColorAttachments = nullptr;
949 begin_rendering_info.pDepthAttachment = &depth_stencil_attachment;
950 m_commandBuffer->BeginRendering(begin_rendering_info);
951 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.handle());
952 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06186");
953 m_commandBuffer->Draw(1, 1, 0, 0);
954 m_errorMonitor->VerifyFound();
955 m_commandBuffer->EndRendering();
956
957 // Mismatching stencil samples
958 begin_rendering_info.pDepthAttachment = nullptr;
959 begin_rendering_info.pStencilAttachment = &depth_stencil_attachment;
960 m_commandBuffer->BeginRendering(begin_rendering_info);
961 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe3.handle());
962 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06187");
963 m_commandBuffer->Draw(1, 1, 0, 0);
964 m_errorMonitor->VerifyFound();
965 m_commandBuffer->EndRendering();
966
967 m_commandBuffer->end();
968}
Aaron Hagan80034ea2021-12-23 11:24:09 -0500969
970TEST_F(VkLayerTest, DynamicRenderingAttachmentInfo) {
971 TEST_DESCRIPTION("AttachmentInfo Dynamic Rendering Tests.");
972
973 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2);
974 if (version < VK_API_VERSION_1_2) {
975 printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix);
976 return;
977 }
978
979 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
980
981 ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor));
982
983 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900984 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
Aaron Hagan80034ea2021-12-23 11:24:09 -0500985 }
986
sjfricked700bc02022-05-30 16:35:06 +0900987 if (!AreRequiredExtensionsEnabled()) {
988 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
Aaron Hagan80034ea2021-12-23 11:24:09 -0500989 }
990
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600991 auto fdm_features = LvlInitStruct<VkPhysicalDeviceFragmentDensityMapFeaturesEXT>();
992 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(&fdm_features);
993 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
Aaron Hagan80034ea2021-12-23 11:24:09 -0500994 if (!dynamic_rendering_features.dynamicRendering) {
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600995 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering , skipping";
996 }
997 if (!fdm_features.fragmentDensityMapNonSubsampledImages) {
998 GTEST_SKIP() << "fragmentDensityMapNonSubsampledImages not supported.";
Aaron Hagan80034ea2021-12-23 11:24:09 -0500999 }
1000
1001 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1002
1003 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
1004 VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT);
1005
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001006 auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
1007
Aaron Hagan80034ea2021-12-23 11:24:09 -05001008 VkPipelineObj pipe(m_device);
1009 pipe.AddShader(&vs);
1010 pipe.AddShader(&fs);
1011 pipe.AddDefaultColorAttachment();
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001012 pipe.SetDepthStencil(&ds_state);
Aaron Hagan80034ea2021-12-23 11:24:09 -05001013
1014 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
1015 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
1016 const VkPipelineLayoutObj pl(m_device, {&dsl});
1017
1018 VkFormat depth_format = VK_FORMAT_D32_SFLOAT_S8_UINT;
1019 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
1020 pipeline_rendering_info.depthAttachmentFormat = depth_format;
1021
1022 auto pipeline_create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
1023 pipe.InitGraphicsPipelineCreateInfo(&pipeline_create_info);
1024 pipeline_create_info.pNext = &pipeline_rendering_info;
1025
1026 VkResult err = pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &pipeline_create_info);
1027 ASSERT_VK_SUCCESS(err);
1028
1029 VkImageObj image(m_device);
1030 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
1031 image_create_info.imageType = VK_IMAGE_TYPE_2D;
1032 image_create_info.format = depth_format;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001033 image_create_info.extent = {64, 64, 1};
Aaron Hagan80034ea2021-12-23 11:24:09 -05001034 image_create_info.mipLevels = 1;
1035 image_create_info.arrayLayers = 1;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001036 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
Aaron Hagan80034ea2021-12-23 11:24:09 -05001037 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
ziga-lunarga3cc8482022-04-29 14:58:29 +02001038 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 -05001039 image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
1040
1041 image.Init(image_create_info);
1042 ASSERT_TRUE(image.initialized());
1043
1044 VkImageViewCreateInfo ivci = {VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
1045 nullptr,
1046 0,
1047 image.handle(),
1048 VK_IMAGE_VIEW_TYPE_2D,
1049 depth_format,
1050 {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
1051 VK_COMPONENT_SWIZZLE_IDENTITY},
1052 {VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, 0, 1, 0, 1}};
1053
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001054 VkImageView depth_image_view = image.targetView(ivci);
1055 ASSERT_NE(depth_image_view, VK_NULL_HANDLE);
Aaron Hagan80034ea2021-12-23 11:24:09 -05001056
1057 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1058 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
1059 depth_attachment.imageView = depth_image_view;
1060 depth_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
1061 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
1062
1063 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
1064 begin_rendering_info.pDepthAttachment = &depth_attachment;
1065 begin_rendering_info.viewMask = 0x4;
1066
1067 VkRenderingFragmentDensityMapAttachmentInfoEXT fragment_density_map =
1068 LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
1069 fragment_density_map.imageView = depth_image_view;
ziga-lunarga3cc8482022-04-29 14:58:29 +02001070 fragment_density_map.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
Aaron Hagan80034ea2021-12-23 11:24:09 -05001071 begin_rendering_info.pNext = &fragment_density_map;
1072
1073 m_commandBuffer->begin();
1074 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-multiview-06127");
Jeremy Gebben09c1a072022-02-08 09:42:47 -07001075 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06107");
1076 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06108");
1077 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06116");
Jeremy Gebben09c1a072022-02-08 09:42:47 -07001078 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06145");
1079 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06146");
Aaron Hagan80034ea2021-12-23 11:24:09 -05001080 m_commandBuffer->BeginRendering(begin_rendering_info);
1081 m_errorMonitor->VerifyFound();
1082}
Aaron Haganb54466d2022-02-18 15:02:54 -05001083
1084TEST_F(VkLayerTest, DynamicRenderingBufferBeginInfoLegacy) {
1085 TEST_DESCRIPTION("VkCommandBufferBeginInfo Dynamic Rendering Tests.");
1086
1087 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2);
1088 if (version < VK_API_VERSION_1_2) {
1089 printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix);
1090 return;
1091 }
1092
1093 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1094
1095 ASSERT_NO_FATAL_FAILURE(Init(nullptr, nullptr, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1096
1097 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001098 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
Aaron Haganb54466d2022-02-18 15:02:54 -05001099 }
1100
sjfricked700bc02022-05-30 16:35:06 +09001101 if (!AreRequiredExtensionsEnabled()) {
1102 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
Aaron Haganb54466d2022-02-18 15:02:54 -05001103 }
1104
1105 auto cmd_buffer_inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>();
1106 cmd_buffer_inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
1107
1108 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
1109 cmd_buffer_inheritance_info.pNext = &cmd_buffer_inheritance_rendering_info;
1110 cmd_buffer_inheritance_info.renderPass = VK_NULL_HANDLE;
1111
1112 auto cmd_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>();
1113 cmd_buffer_allocate_info.commandPool = m_commandPool->handle();
1114 cmd_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY;
1115 cmd_buffer_allocate_info.commandBufferCount = 0x1;
1116
1117 VkCommandBuffer secondary_cmd_buffer;
1118 VkResult err = vk::AllocateCommandBuffers(m_device->device(), &cmd_buffer_allocate_info, &secondary_cmd_buffer);
1119 ASSERT_VK_SUCCESS(err);
1120
1121 // Invalid RenderPass
1122 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-00053");
1123 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
1124 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
1125 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
1126 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
1127 m_errorMonitor->VerifyFound();
1128
1129 // Valid RenderPass
1130 VkAttachmentDescription attach[] = {
1131 {0, VK_FORMAT_B8G8R8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE,
1132 VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_IMAGE_LAYOUT_UNDEFINED,
1133 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL},
1134 };
1135 VkAttachmentReference att_ref = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL};
1136
1137 VkSubpassDescription subpass = {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &att_ref, nullptr, nullptr, 0, nullptr};
1138 VkRenderPassCreateInfo rpci = {VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, 0, 1, attach, 1, &subpass, 0, nullptr};
1139
1140 vk_testing::RenderPass rp1;
1141 rp1.init(*m_device, rpci);
1142
1143 cmd_buffer_inheritance_info.renderPass = rp1.handle();
1144 cmd_buffer_inheritance_info.subpass = 0x5;
1145 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-00054");
1146 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
1147 m_errorMonitor->VerifyFound();
1148}
1149
1150TEST_F(VkLayerTest, DynamicRenderingSecondaryCommandBuffer) {
1151 TEST_DESCRIPTION("VkCommandBufferBeginInfo Dynamic Rendering Tests.");
1152
1153 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_3);
1154 if (version < VK_API_VERSION_1_3) {
1155 printf("%s At least Vulkan version 1.3 is required, skipping test.\n", kSkipPrefix);
1156 return;
1157 }
1158
1159 ASSERT_NO_FATAL_FAILURE(Init());
1160
1161 if (DeviceValidationVersion() < VK_API_VERSION_1_3) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001162 GTEST_SKIP() << "At least Vulkan version 1.3 is required";
Aaron Haganb54466d2022-02-18 15:02:54 -05001163 }
1164
1165 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
1166
1167 // Force the failure by not setting the Renderpass and Framebuffer fields
1168 VkCommandBufferInheritanceInfo cmd_buf_hinfo = LvlInitStruct<VkCommandBufferInheritanceInfo>();
1169 cmd_buf_hinfo.renderPass = VkRenderPass(0x1);
1170 VkCommandBufferBeginInfo cmd_buf_info = LvlInitStruct<VkCommandBufferBeginInfo>();
1171 cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
1172 cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo;
1173
1174 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06000");
1175 vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info);
1176 m_errorMonitor->VerifyFound();
1177
1178 // Valid RenderPass
1179 VkAttachmentDescription attach[] = {
1180 {0, VK_FORMAT_B8G8R8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE,
1181 VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_IMAGE_LAYOUT_UNDEFINED,
1182 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL},
1183 };
1184 VkAttachmentReference att_ref = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL};
1185
1186 VkSubpassDescription subpass = {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &att_ref, nullptr, nullptr, 0, nullptr};
1187 VkRenderPassCreateInfo rpci = {VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, 0, 1, attach, 1, &subpass, 0, nullptr};
1188
1189 vk_testing::RenderPass rp1;
1190 rp1.init(*m_device, rpci);
1191
1192 cmd_buf_hinfo.renderPass = rp1.handle();
1193 cmd_buf_hinfo.subpass = 0x5;
1194 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06001");
1195 vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info);
1196 m_errorMonitor->VerifyFound();
1197
1198 cmd_buf_hinfo.renderPass = VK_NULL_HANDLE;
1199 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06002");
1200 vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info);
1201 m_errorMonitor->VerifyFound();
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001202}
1203
1204TEST_F(VkLayerTest, TestDynamicRenderingPipelineMissingFlags) {
1205 TEST_DESCRIPTION("Test dynamic rendering with pipeline missing flags.");
1206
1207 SetTargetApiVersion(VK_API_VERSION_1_1);
1208 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001209 AddOptionalExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1210 AddOptionalExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001211
1212 ASSERT_NO_FATAL_FAILURE(InitFramework());
1213
1214 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001215 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001216 }
1217
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001218 if (!IsExtensionsEnabled(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
sjfricked700bc02022-05-30 16:35:06 +09001219 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001220 }
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001221 bool fragment_density = IsExtensionsEnabled(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1222 bool shading_rate = IsExtensionsEnabled(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001223
1224 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1225 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1226 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1227 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001228 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001229 }
1230
1231 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
1232
1233 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
1234 vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2);
1235
1236 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1237 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
1238
1239 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
1240 ASSERT_TRUE(depthStencilFormat != 0);
1241
1242 VkImageObj image(m_device);
1243 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
1244 image_create_info.imageType = VK_IMAGE_TYPE_2D;
1245 image_create_info.format = depthStencilFormat;
1246 image_create_info.extent = {64, 64, 1};
1247 image_create_info.mipLevels = 1;
1248 image_create_info.arrayLayers = 1;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001249 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001250 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001251 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 +01001252 image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
1253
1254 image.Init(image_create_info);
1255 ASSERT_TRUE(image.initialized());
1256
1257 VkImageViewCreateInfo ivci = {VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
1258 nullptr,
1259 0,
1260 image.handle(),
1261 VK_IMAGE_VIEW_TYPE_2D,
1262 depthStencilFormat,
1263 {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
1264 VK_COMPONENT_SWIZZLE_IDENTITY},
1265 {VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, 0, 1, 0, 1}};
1266
1267 vk_testing::ImageView depth_image_view;
1268 depth_image_view.init(*m_device, ivci);
1269
1270 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1271 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1272
1273 if (shading_rate) {
1274 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-imageView-06183");
1275 VkRenderingFragmentShadingRateAttachmentInfoKHR fragment_shading_rate =
1276 LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
1277 fragment_shading_rate.imageView = depth_image_view.handle();
1278 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1279 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
1280
1281 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
ziga-lunargaa97cbb2022-03-18 19:06:35 +01001282 begin_rendering_info.layerCount = 1;
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001283 begin_rendering_info.colorAttachmentCount = 1;
1284 begin_rendering_info.pColorAttachments = &color_attachment;
1285
1286 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
1287
1288 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
1289 pipeline_rendering_info.colorAttachmentCount = 1;
1290 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
1291
1292 CreatePipelineHelper pipe(*this);
1293 pipe.InitInfo();
1294 pipe.gp_ci_.pNext = &pipeline_rendering_info;
1295 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
1296 pipe.InitState();
1297 pipe.CreateGraphicsPipeline();
1298
1299 m_commandBuffer->begin();
1300 m_commandBuffer->BeginRendering(begin_rendering_info);
1301 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_);
1302 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
1303 m_commandBuffer->EndRendering();
1304 m_commandBuffer->end();
1305
1306 m_errorMonitor->VerifyFound();
1307 }
1308
1309 if (fragment_density) {
1310 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-imageView-06184");
1311 VkRenderingFragmentDensityMapAttachmentInfoEXT fragment_density_map =
1312 LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
1313 fragment_density_map.imageView = depth_image_view.handle();
1314
1315 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_density_map);
ziga-lunargaa97cbb2022-03-18 19:06:35 +01001316 begin_rendering_info.layerCount = 1;
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001317 begin_rendering_info.colorAttachmentCount = 1;
1318 begin_rendering_info.pColorAttachments = &color_attachment;
1319
1320 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
1321
1322 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
1323 pipeline_rendering_info.colorAttachmentCount = 1;
1324 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
1325
1326 CreatePipelineHelper pipe(*this);
1327 pipe.InitInfo();
1328 pipe.gp_ci_.pNext = &pipeline_rendering_info;
1329 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
1330 pipe.InitState();
1331 pipe.CreateGraphicsPipeline();
1332
1333 m_commandBuffer->begin();
1334 m_commandBuffer->BeginRendering(begin_rendering_info);
1335 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_);
1336 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
1337 m_commandBuffer->EndRendering();
1338 m_commandBuffer->end();
1339
1340 m_errorMonitor->VerifyFound();
1341 }
1342}
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001343
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001344TEST_F(VkLayerTest, DynamicRenderingLayerCount) {
1345 TEST_DESCRIPTION("Test dynamic rendering with viewMask 0 and invalid layer count.");
1346
1347 SetTargetApiVersion(VK_API_VERSION_1_1);
1348 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1349
1350 ASSERT_NO_FATAL_FAILURE(InitFramework());
1351
1352 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001353 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001354 }
1355
1356 if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
sjfricked700bc02022-05-30 16:35:06 +09001357 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001358 }
1359
1360 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1361 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1362 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1363 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001364 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001365 }
1366
1367 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1368
1369 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
1370
1371 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-viewMask-06069");
1372 m_commandBuffer->begin();
1373 m_commandBuffer->BeginRendering(begin_rendering_info);
1374 m_commandBuffer->end();
1375 m_errorMonitor->VerifyFound();
1376}
1377
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001378TEST_F(VkLayerTest, TestRenderingInfoMismatchedSamples) {
1379 TEST_DESCRIPTION("Test beginning rendering with mismatched sample counts.");
1380
1381 SetTargetApiVersion(VK_API_VERSION_1_1);
1382 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1383
1384 ASSERT_NO_FATAL_FAILURE(InitFramework());
1385
1386 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001387 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001388 }
1389
1390 if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
sjfricked700bc02022-05-30 16:35:06 +09001391 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001392 }
1393
1394 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1395 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1396 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1397 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001398 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001399 }
1400
1401 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1402
1403 VkImageCreateInfo image_ci = LvlInitStruct<VkImageCreateInfo>();
1404 image_ci.imageType = VK_IMAGE_TYPE_2D;
1405 image_ci.format = VK_FORMAT_R8G8B8A8_UNORM;
1406 image_ci.extent.width = 64;
1407 image_ci.extent.height = 64;
1408 image_ci.extent.depth = 1;
1409 image_ci.mipLevels = 1;
1410 image_ci.arrayLayers = 1;
1411 image_ci.samples = VK_SAMPLE_COUNT_2_BIT;
1412 image_ci.tiling = VK_IMAGE_TILING_OPTIMAL;
1413 image_ci.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
1414
1415 VkImageObj color_image(m_device);
1416 color_image.init(&image_ci);
1417
1418 VkImageViewCreateInfo civ_ci = LvlInitStruct<VkImageViewCreateInfo>();
1419 civ_ci.image = color_image.handle();
1420 civ_ci.viewType = VK_IMAGE_VIEW_TYPE_2D;
1421 civ_ci.format = VK_FORMAT_R8G8B8A8_UNORM;
1422 civ_ci.subresourceRange.layerCount = 1;
1423 civ_ci.subresourceRange.baseMipLevel = 0;
1424 civ_ci.subresourceRange.levelCount = 1;
1425 civ_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
1426
1427 vk_testing::ImageView color_image_view;
1428 color_image_view.init(*m_device, civ_ci);
1429
1430 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1431 color_attachment.imageView = color_image_view.handle();
1432 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1433 color_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
1434
1435 const VkFormat depth_format = FindSupportedDepthOnlyFormat(gpu());
1436 if (depth_format == VK_FORMAT_UNDEFINED) {
1437 printf("%s requires a depth only format, skipping.\n", kSkipPrefix);
1438 return;
1439 }
1440
1441 VkImageObj depth_image(m_device);
1442 depth_image.Init(64, 64, 1, depth_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL);
1443
1444 VkImageViewCreateInfo div_ci = LvlInitStruct<VkImageViewCreateInfo>();
1445 div_ci.image = depth_image.handle();
1446 div_ci.viewType = VK_IMAGE_VIEW_TYPE_2D;
1447 div_ci.format = depth_format;
1448 div_ci.subresourceRange.layerCount = 1;
1449 div_ci.subresourceRange.baseMipLevel = 0;
1450 div_ci.subresourceRange.levelCount = 1;
1451 div_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
1452
1453 vk_testing::ImageView depth_image_view;
1454 depth_image_view.init(*m_device, div_ci);
1455
1456 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1457 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1458 depth_attachment.imageView = depth_image_view.handle();
1459 depth_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
1460
1461 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
ziga-lunargaa97cbb2022-03-18 19:06:35 +01001462 begin_rendering_info.layerCount = 1;
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001463 begin_rendering_info.colorAttachmentCount = 1;
1464 begin_rendering_info.pColorAttachments = &color_attachment;
1465 begin_rendering_info.pDepthAttachment = &depth_attachment;
1466
Tony-LunarG7384f7e2022-07-05 14:20:42 -06001467 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-multisampledRenderToSingleSampled-06857");
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001468 m_commandBuffer->BeginRendering(begin_rendering_info);
1469 m_errorMonitor->VerifyFound();
1470}
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001471
ziga-lunargb7fec142022-03-18 22:08:17 +01001472TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRate) {
1473 TEST_DESCRIPTION("Test BeginRenderingInfo with FragmentShadingRateAttachment.");
1474
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001475 SetTargetApiVersion(VK_API_VERSION_1_2);
ziga-lunargb7fec142022-03-18 22:08:17 +01001476 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1477 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
1478
1479 ASSERT_NO_FATAL_FAILURE(InitFramework());
1480
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001481 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
1482 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
ziga-lunargb7fec142022-03-18 22:08:17 +01001483 }
1484
sjfricked700bc02022-05-30 16:35:06 +09001485 if (!AreRequiredExtensionsEnabled()) {
1486 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargb7fec142022-03-18 22:08:17 +01001487 }
1488
1489 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1490 auto features11 = LvlInitStruct<VkPhysicalDeviceVulkan11Features>(&dynamic_rendering_features);
1491 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&features11);
1492 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1493
1494 if (features11.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001495 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunargb7fec142022-03-18 22:08:17 +01001496 }
1497 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001498 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargb7fec142022-03-18 22:08:17 +01001499 }
1500
1501 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
1502
1503 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
1504 vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2);
1505
1506 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1507 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
1508
1509 auto image_ci = LvlInitStruct<VkImageCreateInfo>(nullptr);
1510 image_ci.imageType = VK_IMAGE_TYPE_2D;
1511 image_ci.format = VK_FORMAT_R8G8B8A8_UNORM;
1512 image_ci.extent.width = 32;
1513 image_ci.extent.height = 32;
1514 image_ci.extent.depth = 1;
1515 image_ci.mipLevels = 1;
1516 image_ci.arrayLayers = 2;
1517 image_ci.samples = VK_SAMPLE_COUNT_1_BIT;
1518 image_ci.tiling = VK_IMAGE_TILING_OPTIMAL;
ziga-lunargade1d9e2022-04-25 10:59:15 +02001519 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 +01001520
1521 VkImageObj image(m_device);
1522 image.init(&image_ci);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001523 VkImageView image_view =
1524 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 +01001525
ziga-lunargade1d9e2022-04-25 10:59:15 +02001526 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
ziga-lunargb7fec142022-03-18 22:08:17 +01001527 fragment_shading_rate.imageView = image_view;
1528 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1529 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
1530
1531 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
1532 begin_rendering_info.layerCount = 4;
1533
1534 m_commandBuffer->begin();
1535
1536 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06123");
1537 m_commandBuffer->BeginRendering(begin_rendering_info);
1538 m_errorMonitor->VerifyFound();
1539
1540 begin_rendering_info.viewMask = 0xF;
1541 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06124");
1542 m_commandBuffer->BeginRendering(begin_rendering_info);
1543 m_errorMonitor->VerifyFound();
1544
ziga-lunargade1d9e2022-04-25 10:59:15 +02001545 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1546 color_attachment.imageView = image_view;
1547 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1548
1549 begin_rendering_info.layerCount = 2;
1550 begin_rendering_info.colorAttachmentCount = 1;
1551 begin_rendering_info.pColorAttachments = &color_attachment;
1552 begin_rendering_info.viewMask = 0;
1553 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06125");
1554 m_commandBuffer->BeginRendering(begin_rendering_info);
1555 m_errorMonitor->VerifyFound();
1556
ziga-lunargb7fec142022-03-18 22:08:17 +01001557 m_commandBuffer->end();
ziga-lunargb7fec142022-03-18 22:08:17 +01001558}
1559
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001560TEST_F(VkLayerTest, TestDeviceGroupRenderPassBeginInfo) {
1561 TEST_DESCRIPTION("Test render area of DeviceGroupRenderPassBeginInfo.");
1562
1563 SetTargetApiVersion(VK_API_VERSION_1_1);
1564 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1565
1566 ASSERT_NO_FATAL_FAILURE(InitFramework());
1567
1568 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001569 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001570 }
1571
1572 if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
sjfricked700bc02022-05-30 16:35:06 +09001573 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001574 }
1575
1576 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1577 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1578 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1579 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001580 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001581 }
1582
1583 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1584
1585 VkRect2D render_area = {};
1586 render_area.offset.x = 0;
1587 render_area.offset.y = 0;
1588 render_area.extent.width = 32;
1589 render_area.extent.height = 32;
1590
1591 auto device_group_render_pass_begin_info = LvlInitStruct<VkDeviceGroupRenderPassBeginInfo>();
1592 device_group_render_pass_begin_info.deviceRenderAreaCount = 1;
1593 device_group_render_pass_begin_info.pDeviceRenderAreas = &render_area;
1594
1595 VkImageObj colorImage(m_device);
1596 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
1597 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
1598
1599 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1600 color_attachment.imageView = colorImageView;
1601 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1602
1603 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&device_group_render_pass_begin_info);
ziga-lunarg1fec6332022-03-20 14:39:54 +01001604 begin_rendering_info.layerCount = 1;
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001605 begin_rendering_info.colorAttachmentCount = 1;
1606 begin_rendering_info.pColorAttachments = &color_attachment;
1607
1608 m_commandBuffer->begin();
1609
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001610 m_commandBuffer->BeginRendering(begin_rendering_info);
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001611
1612 render_area.offset.x = 1;
1613 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06083");
1614 m_commandBuffer->BeginRendering(begin_rendering_info);
1615 m_errorMonitor->VerifyFound();
1616
1617 render_area.offset.x = 0;
1618 render_area.offset.y = 16;
1619 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06084");
1620 m_commandBuffer->BeginRendering(begin_rendering_info);
1621 m_errorMonitor->VerifyFound();
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001622}
1623
ziga-lunarg184a20b2022-03-18 20:54:48 +01001624TEST_F(VkLayerTest, TestBeginRenderingInvalidFragmentShadingRateImage) {
1625 TEST_DESCRIPTION("Test BeginRendering with FragmentShadingRateAttachmentInfo with missing image usage bit.");
1626
1627 SetTargetApiVersion(VK_API_VERSION_1_1);
1628 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1629 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
1630
1631 ASSERT_NO_FATAL_FAILURE(InitFramework());
1632
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001633 if (IsDriver(VK_DRIVER_ID_AMD_PROPRIETARY)) {
1634 GTEST_SKIP() << "Skipping on AMD proprietary driver pending further investigation.";
1635 }
1636
ziga-lunarg184a20b2022-03-18 20:54:48 +01001637 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001638 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg184a20b2022-03-18 20:54:48 +01001639 }
1640
sjfricked700bc02022-05-30 16:35:06 +09001641 if (!AreRequiredExtensionsEnabled()) {
1642 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg184a20b2022-03-18 20:54:48 +01001643 }
1644
1645 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1646 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1647 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1648 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001649 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg184a20b2022-03-18 20:54:48 +01001650 }
1651 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1652
1653 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
1654 auto properties2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
1655 vk::GetPhysicalDeviceProperties2(gpu(), &properties2);
1656
1657 VkImageObj image(m_device);
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001658 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT,
1659 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR);
ziga-lunarg184a20b2022-03-18 20:54:48 +01001660 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
1661
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001662 VkImageObj invalid_image(m_device);
1663 invalid_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
1664 VkImageView invalid_image_view = invalid_image.targetView(VK_FORMAT_R8G8B8A8_UINT);
1665
ziga-lunarg184a20b2022-03-18 20:54:48 +01001666 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001667 fragment_shading_rate.imageView = invalid_image_view;
ziga-lunarg184a20b2022-03-18 20:54:48 +01001668 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1669 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
1670
1671 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001672 begin_rendering_info.layerCount = 1;
1673
1674 m_commandBuffer->begin();
ziga-lunarg184a20b2022-03-18 20:54:48 +01001675
1676 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06148");
ziga-lunarg184a20b2022-03-18 20:54:48 +01001677 m_commandBuffer->BeginRendering(begin_rendering_info);
ziga-lunarg184a20b2022-03-18 20:54:48 +01001678 m_errorMonitor->VerifyFound();
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001679 fragment_shading_rate.imageView = image_view;
1680
1681 fragment_shading_rate.shadingRateAttachmentTexelSize.width = fsr_properties.minFragmentShadingRateAttachmentTexelSize.width + 1;
1682 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06149");
1683 if (fragment_shading_rate.shadingRateAttachmentTexelSize.width >
1684 fsr_properties.minFragmentShadingRateAttachmentTexelSize.width) {
1685 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06150");
1686 }
1687 m_commandBuffer->BeginRendering(begin_rendering_info);
1688 m_errorMonitor->VerifyFound();
1689
1690 if (fsr_properties.minFragmentShadingRateAttachmentTexelSize.width > 1) {
1691 fragment_shading_rate.shadingRateAttachmentTexelSize.width =
1692 fsr_properties.minFragmentShadingRateAttachmentTexelSize.width / 2;
1693 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06151");
1694 if (fragment_shading_rate.shadingRateAttachmentTexelSize.height /
1695 fragment_shading_rate.shadingRateAttachmentTexelSize.width >=
1696 fsr_properties.maxFragmentShadingRateAttachmentTexelSizeAspectRatio) {
1697 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06156");
1698 }
1699 m_commandBuffer->BeginRendering(begin_rendering_info);
1700 m_errorMonitor->VerifyFound();
1701 }
1702
1703 fragment_shading_rate.shadingRateAttachmentTexelSize.width = fsr_properties.minFragmentShadingRateAttachmentTexelSize.width;
1704
1705 fragment_shading_rate.shadingRateAttachmentTexelSize.height =
1706 fsr_properties.minFragmentShadingRateAttachmentTexelSize.height + 1;
1707 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06152");
1708 if (fragment_shading_rate.shadingRateAttachmentTexelSize.height >
1709 fsr_properties.minFragmentShadingRateAttachmentTexelSize.height) {
1710 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06153");
1711 }
1712 m_commandBuffer->BeginRendering(begin_rendering_info);
1713 m_errorMonitor->VerifyFound();
1714
1715 if (fsr_properties.minFragmentShadingRateAttachmentTexelSize.height > 1) {
1716 fragment_shading_rate.shadingRateAttachmentTexelSize.height =
1717 fsr_properties.minFragmentShadingRateAttachmentTexelSize.height / 2;
1718 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06154");
1719 if (fragment_shading_rate.shadingRateAttachmentTexelSize.width /
1720 fragment_shading_rate.shadingRateAttachmentTexelSize.height >
1721 fsr_properties.maxFragmentShadingRateAttachmentTexelSizeAspectRatio) {
1722 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06155");
1723 }
1724 m_commandBuffer->BeginRendering(begin_rendering_info);
1725 m_errorMonitor->VerifyFound();
1726 }
1727
1728 m_commandBuffer->end();
ziga-lunarg184a20b2022-03-18 20:54:48 +01001729}
1730
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001731TEST_F(VkLayerTest, BeginRenderingInvalidDepthAttachmentFormat) {
1732 TEST_DESCRIPTION("Test begin rendering with a depth attachment that has an invalid format");
1733
1734 SetTargetApiVersion(VK_API_VERSION_1_3);
1735 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1736
1737 ASSERT_NO_FATAL_FAILURE(InitFramework());
1738
1739 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001740 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001741 }
1742
sjfricked700bc02022-05-30 16:35:06 +09001743 if (!AreRequiredExtensionsEnabled()) {
1744 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001745 }
1746
1747 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1748 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1749 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1750 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001751 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001752 }
1753
1754 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1755
1756 VkFormat stencil_format = FindSupportedStencilOnlyFormat(gpu());
1757 if (stencil_format == VK_FORMAT_UNDEFINED) {
1758 printf("%s requires a stencil only format format.\n", kSkipPrefix);
1759 return;
1760 }
1761
1762 VkImageObj image(m_device);
1763 image.Init(32, 32, 1, stencil_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
1764 VkImageView image_view = image.targetView(stencil_format, VK_IMAGE_ASPECT_STENCIL_BIT);
1765
1766 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1767 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
1768 depth_attachment.imageView = image_view;
1769
1770 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
ziga-lunarg1fec6332022-03-20 14:39:54 +01001771 begin_rendering_info.layerCount = 1;
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001772 begin_rendering_info.pDepthAttachment = &depth_attachment;
1773
1774 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06547");
1775 m_commandBuffer->BeginRendering(begin_rendering_info);
1776 m_errorMonitor->VerifyFound();
1777}
ziga-lunarg4b5bb5b2022-03-20 00:49:04 +01001778
ziga-lunarg14a69782022-03-20 00:39:31 +01001779TEST_F(VkLayerTest, TestFragmentDensityMapRenderArea) {
1780 TEST_DESCRIPTION("Validate VkRenderingFragmentDensityMapAttachmentInfo attachment image view extent.");
1781
1782 SetTargetApiVersion(VK_API_VERSION_1_1);
1783 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1784 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1785
1786 ASSERT_NO_FATAL_FAILURE(InitFramework());
1787
1788 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001789 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg14a69782022-03-20 00:39:31 +01001790 }
1791
sjfricked700bc02022-05-30 16:35:06 +09001792 if (!AreRequiredExtensionsEnabled()) {
1793 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg14a69782022-03-20 00:39:31 +01001794 }
1795
1796 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1797 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
1798 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1799 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001800 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg14a69782022-03-20 00:39:31 +01001801 }
1802
1803 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1804
1805 auto fdm_props = LvlInitStruct<VkPhysicalDeviceFragmentDensityMapPropertiesEXT>();
1806 auto props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fdm_props);
1807 vk::GetPhysicalDeviceProperties2(gpu(), &props2);
1808
1809 VkImageObj image(m_device);
ziga-lunarg2aa8d592022-04-25 14:29:13 +02001810 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT,
1811 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT);
ziga-lunarg14a69782022-03-20 00:39:31 +01001812 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1);
1813
1814 auto fragment_density_map = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
1815 fragment_density_map.imageView = image_view;
ziga-lunarg2aa8d592022-04-25 14:29:13 +02001816 fragment_density_map.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1817
ziga-lunarg14a69782022-03-20 00:39:31 +01001818 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_density_map);
1819 begin_rendering_info.layerCount = 1;
1820 begin_rendering_info.renderArea.extent.width = 64 * fdm_props.maxFragmentDensityTexelSize.width;
1821 begin_rendering_info.renderArea.extent.height = 32 * fdm_props.maxFragmentDensityTexelSize.height;
1822
1823 m_commandBuffer->begin();
1824
1825 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06112");
1826 m_commandBuffer->BeginRendering(begin_rendering_info);
1827 m_errorMonitor->VerifyFound();
1828
1829 begin_rendering_info.renderArea.extent.width = 32 * fdm_props.maxFragmentDensityTexelSize.width;
1830 begin_rendering_info.renderArea.extent.height = 64 * fdm_props.maxFragmentDensityTexelSize.height;
1831
1832 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06114");
1833 m_commandBuffer->BeginRendering(begin_rendering_info);
1834 m_errorMonitor->VerifyFound();
1835
1836 VkRect2D device_render_area = {};
1837 device_render_area.extent.width = 64 * fdm_props.maxFragmentDensityTexelSize.width;
1838 device_render_area.extent.height = 32 * fdm_props.maxFragmentDensityTexelSize.height;
1839 auto device_group_render_pass_begin_info = LvlInitStruct<VkDeviceGroupRenderPassBeginInfo>();
1840 device_group_render_pass_begin_info.deviceRenderAreaCount = 1;
1841 device_group_render_pass_begin_info.pDeviceRenderAreas = &device_render_area;
1842 fragment_density_map.pNext = &device_group_render_pass_begin_info;
1843
1844 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06113");
1845 m_commandBuffer->BeginRendering(begin_rendering_info);
1846 m_errorMonitor->VerifyFound();
1847
1848 device_render_area.extent.width = 32 * fdm_props.maxFragmentDensityTexelSize.width;
1849 device_render_area.extent.height = 64 * fdm_props.maxFragmentDensityTexelSize.height;
1850
1851 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06115");
1852 m_commandBuffer->BeginRendering(begin_rendering_info);
1853 m_errorMonitor->VerifyFound();
1854
1855 m_commandBuffer->end();
1856}
1857
ziga-lunarg50253b92022-04-25 14:36:13 +02001858TEST_F(VkLayerTest, TestFragmentDensityMapRenderAreaWithoutDeviceGroupExt) {
1859 TEST_DESCRIPTION("Validate VkRenderingFragmentDensityMapAttachmentInfo attachment image view extent.");
1860
1861 SetTargetApiVersion(VK_API_VERSION_1_0);
1862 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1863 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1864
1865 ASSERT_NO_FATAL_FAILURE(InitFramework());
1866
1867 if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
sjfricke50955f32022-06-05 10:12:52 +09001868 GTEST_SKIP() << "Tests for 1.0 only";
ziga-lunarg50253b92022-04-25 14:36:13 +02001869 }
1870
sjfricked700bc02022-05-30 16:35:06 +09001871 if (!AreRequiredExtensionsEnabled()) {
1872 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg50253b92022-04-25 14:36:13 +02001873 }
1874
1875 auto vkGetPhysicalDeviceFeatures2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2KHR>(
1876 vk::GetInstanceProcAddr(instance(), "vkGetPhysicalDeviceFeatures2KHR"));
1877 ASSERT_TRUE(vkGetPhysicalDeviceFeatures2KHR != nullptr);
1878
1879 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1880 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2KHR>(&dynamic_rendering_features);
1881 vkGetPhysicalDeviceFeatures2KHR(gpu(), &features2);
1882 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001883 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg50253b92022-04-25 14:36:13 +02001884 }
1885
1886 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1887
1888 auto fdm_props = LvlInitStruct<VkPhysicalDeviceFragmentDensityMapPropertiesEXT>();
1889 auto props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fdm_props);
1890 vk::GetPhysicalDeviceProperties2(gpu(), &props2);
1891
1892 VkImageObj image(m_device);
1893 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT,
1894 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT);
1895 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1);
1896
1897 auto fragment_density_map = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
1898 fragment_density_map.imageView = image_view;
1899 fragment_density_map.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1900
1901 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_density_map);
1902 begin_rendering_info.layerCount = 1;
1903 begin_rendering_info.renderArea.extent.width = 64 * fdm_props.maxFragmentDensityTexelSize.width;
1904 begin_rendering_info.renderArea.extent.height = 32 * fdm_props.maxFragmentDensityTexelSize.height;
1905
1906 m_commandBuffer->begin();
1907
1908 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06110");
1909 m_commandBuffer->BeginRendering(begin_rendering_info);
1910 m_errorMonitor->VerifyFound();
1911
1912 begin_rendering_info.renderArea.extent.width = 32 * fdm_props.maxFragmentDensityTexelSize.width;
1913 begin_rendering_info.renderArea.extent.height = 64 * fdm_props.maxFragmentDensityTexelSize.height;
1914
1915 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06111");
1916 m_commandBuffer->BeginRendering(begin_rendering_info);
1917 m_errorMonitor->VerifyFound();
1918
1919 m_commandBuffer->end();
1920}
1921
ziga-lunarge7279ba2022-03-31 20:55:27 +02001922TEST_F(VkLayerTest, TestBarrierWithDynamicRendering) {
1923 TEST_DESCRIPTION("Test setting buffer memory barrier when dynamic rendering is active.");
1924
1925 SetTargetApiVersion(VK_API_VERSION_1_3);
1926
1927 ASSERT_NO_FATAL_FAILURE(InitFramework());
1928
1929 if (DeviceValidationVersion() < VK_API_VERSION_1_3) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001930 GTEST_SKIP() << "At least Vulkan version 1.3 is required";
ziga-lunarge7279ba2022-03-31 20:55:27 +02001931 }
1932
1933 auto vk13features = LvlInitStruct<VkPhysicalDeviceVulkan13Features>();
1934 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&vk13features);
1935 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
1936 if (!vk13features.dynamicRendering) {
1937 printf("%s Test requires (unsupported) dynamicRendering, skipping\n", kSkipPrefix);
1938 return;
1939 }
1940 if (!vk13features.synchronization2) {
1941 printf("%s Test requires (unsupported) synchronization2, skipping\n", kSkipPrefix);
1942 return;
1943 }
1944
1945 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1946 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
1947
1948 PFN_vkCmdBeginRendering vkCmdBeginRendering =
1949 reinterpret_cast<PFN_vkCmdBeginRendering>(vk::GetDeviceProcAddr(m_device->device(), "vkCmdBeginRendering"));
1950 assert(vkCmdBeginRendering != nullptr);
1951 PFN_vkCmdEndRendering vkCmdEndRendering =
1952 reinterpret_cast<PFN_vkCmdEndRendering>(vk::GetDeviceProcAddr(m_device->device(), "vkCmdEndRendering"));
1953 assert(vkCmdEndRendering != nullptr);
1954
1955 m_commandBuffer->begin();
1956
1957 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
1958 VkClearRect clear_rect = {{{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}, 0, 1};
1959 begin_rendering_info.renderArea = clear_rect.rect;
1960 begin_rendering_info.layerCount = 1;
1961
1962 vkCmdBeginRendering(m_commandBuffer->handle(), &begin_rendering_info);
1963
1964 VkBufferObj buffer;
1965 VkMemoryPropertyFlags mem_reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
1966 buffer.init_as_src_and_dst(*m_device, 256, mem_reqs);
1967
1968 auto buf_barrier = lvl_init_struct<VkBufferMemoryBarrier2KHR>();
1969 buf_barrier.buffer = buffer.handle();
1970 buf_barrier.offset = 0;
1971 buf_barrier.size = VK_WHOLE_SIZE;
1972 buf_barrier.srcStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
1973 buf_barrier.dstStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
1974
1975 auto dependency_info = lvl_init_struct<VkDependencyInfoKHR>();
1976 dependency_info.bufferMemoryBarrierCount = 1;
1977 dependency_info.pBufferMemoryBarriers = &buf_barrier;
1978 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPipelineBarrier2-None-06191");
1979 vk::CmdPipelineBarrier2(m_commandBuffer->handle(), &dependency_info);
1980 m_errorMonitor->VerifyFound();
1981
1982 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPipelineBarrier-None-06191");
1983 vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, 0,
1984 nullptr, 0, nullptr, 0, nullptr);
1985 m_errorMonitor->VerifyFound();
1986
1987 vkCmdEndRendering(m_commandBuffer->handle());
1988 m_commandBuffer->end();
1989}
1990
ziga-lunarg5e0a2452022-04-20 19:29:37 +02001991TEST_F(VkLayerTest, BeginRenderingInvalidStencilAttachmentFormat) {
1992 TEST_DESCRIPTION("Test begin rendering with a stencil attachment that has an invalid format");
1993
1994 SetTargetApiVersion(VK_API_VERSION_1_3);
1995 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1996
1997 ASSERT_NO_FATAL_FAILURE(InitFramework());
1998
1999 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
2000 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
2001 }
2002
sjfricked700bc02022-05-30 16:35:06 +09002003 if (!AreRequiredExtensionsEnabled()) {
2004 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002005 }
2006
2007 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2008 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2009 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2010 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002011 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002012 }
2013
2014 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2015
2016 VkFormat depth_format = FindSupportedDepthOnlyFormat(gpu());
2017 if (depth_format == VK_FORMAT_UNDEFINED) {
2018 printf("%s requires a stencil only format format.\n", kSkipPrefix);
2019 return;
2020 }
2021
2022 VkImageObj image(m_device);
2023 image.Init(32, 32, 1, depth_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
2024 VkImageView image_view = image.targetView(depth_format, VK_IMAGE_ASPECT_DEPTH_BIT);
2025
2026 VkRenderingAttachmentInfoKHR stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2027 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL;
2028 stencil_attachment.imageView = image_view;
2029
2030 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2031 begin_rendering_info.layerCount = 1;
2032 begin_rendering_info.pStencilAttachment = &stencil_attachment;
2033
2034 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06548");
2035 m_commandBuffer->BeginRendering(begin_rendering_info);
2036 m_errorMonitor->VerifyFound();
2037}
2038
2039TEST_F(VkLayerTest, TestInheritanceRenderingInfoStencilAttachmentFormat) {
2040 TEST_DESCRIPTION("Test begin rendering with a stencil attachment that has an invalid format");
2041
2042 SetTargetApiVersion(VK_API_VERSION_1_3);
2043 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2044
2045 ASSERT_NO_FATAL_FAILURE(InitFramework());
2046
2047 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
2048 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
2049 }
2050
sjfricked700bc02022-05-30 16:35:06 +09002051 if (!AreRequiredExtensionsEnabled()) {
2052 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002053 }
2054
2055 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2056 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2057 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2058 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002059 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002060 }
2061
2062 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2063
2064 VkFormat depth_format = FindSupportedDepthOnlyFormat(gpu());
2065 if (depth_format == VK_FORMAT_UNDEFINED) {
2066 printf("%s requires a stencil only format format.\n", kSkipPrefix);
2067 return;
2068 }
2069
2070 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2071
2072 auto cmd_buffer_inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>();
2073 cmd_buffer_inheritance_rendering_info.colorAttachmentCount = 1;
2074 cmd_buffer_inheritance_rendering_info.pColorAttachmentFormats = &color_format;
2075 cmd_buffer_inheritance_rendering_info.depthAttachmentFormat = depth_format;
2076 cmd_buffer_inheritance_rendering_info.stencilAttachmentFormat = depth_format;
2077 cmd_buffer_inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
2078
2079 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2080 cmd_buffer_inheritance_info.pNext = &cmd_buffer_inheritance_rendering_info;
2081 cmd_buffer_inheritance_info.renderPass = VK_NULL_HANDLE;
2082
2083 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2084 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2085 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2086
2087 auto cmd_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>();
2088 cmd_buffer_allocate_info.commandPool = m_commandPool->handle();
2089 cmd_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY;
2090 cmd_buffer_allocate_info.commandBufferCount = 1;
2091
2092 VkCommandBuffer secondary_cmd_buffer;
ziga-lunarga3cc8482022-04-29 14:58:29 +02002093 vk::AllocateCommandBuffers(m_device->device(), &cmd_buffer_allocate_info, &secondary_cmd_buffer);
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002094
2095 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-stencilAttachmentFormat-06541");
2096 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
2097 m_errorMonitor->VerifyFound();
2098}
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002099
2100TEST_F(VkLayerTest, CreateGraphicsPipelineWithInvalidAttachmentSampleCount) {
2101 TEST_DESCRIPTION("Create pipeline with fragment shader that uses samples, but multisample state not begin set");
2102
ziga-lunarg7f25dff2022-05-06 17:49:34 +02002103 SetTargetApiVersion(VK_API_VERSION_1_1);
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002104 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2105 AddRequiredExtensions(VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME);
2106
2107 ASSERT_NO_FATAL_FAILURE(InitFramework());
2108
2109 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002110 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002111 }
2112
sjfricked700bc02022-05-30 16:35:06 +09002113 if (!AreRequiredExtensionsEnabled()) {
2114 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002115 }
2116
2117 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2118 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2119 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2120 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002121 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002122 }
2123
2124 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2125 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2126
2127 auto sample_count_info_amd = LvlInitStruct<VkAttachmentSampleCountInfoNV>();
2128 sample_count_info_amd.colorAttachmentCount = 1;
ziga-lunarg7f25dff2022-05-06 17:49:34 +02002129 sample_count_info_amd.depthStencilAttachmentSamples = static_cast<VkSampleCountFlagBits>(0x3);
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002130
2131 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(&sample_count_info_amd);
2132 pipeline_rendering_info.colorAttachmentCount = 1;
2133 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2134
2135 CreatePipelineHelper pipe(*this);
2136 pipe.InitInfo();
2137 pipe.gp_ci_.pNext = &pipeline_rendering_info;
2138 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2139 pipe.InitState();
2140
2141 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-depthStencilAttachmentSamples-06593");
2142 pipe.CreateGraphicsPipeline();
2143 m_errorMonitor->VerifyFound();
2144}
ziga-lunargd680bf22022-04-20 22:01:00 +02002145
2146TEST_F(VkLayerTest, CreatePipelineUsingDynamicRenderingWithoutFeature) {
2147 TEST_DESCRIPTION("Create graphcis pipeline that uses dynamic rendering, but feature is not enabled");
2148
2149 SetTargetApiVersion(VK_API_VERSION_1_3);
2150 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2151 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
2152
2153 ASSERT_NO_FATAL_FAILURE(InitFramework());
2154
2155 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002156 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargd680bf22022-04-20 22:01:00 +02002157 }
2158
sjfricked700bc02022-05-30 16:35:06 +09002159 if (!AreRequiredExtensionsEnabled()) {
2160 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargd680bf22022-04-20 22:01:00 +02002161 }
2162
2163 ASSERT_NO_FATAL_FAILURE(InitState());
2164
2165 CreatePipelineHelper pipe(*this);
2166 pipe.InitInfo();
2167 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2168 pipe.InitState();
2169
2170 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-dynamicRendering-06576");
2171 pipe.CreateGraphicsPipeline();
2172 m_errorMonitor->VerifyFound();
2173}
ziga-lunargf20d7952022-04-20 22:11:40 +02002174
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002175TEST_F(VkLayerTest, DynamicRenderingAreaGreaterThanAttachmentExtent) {
2176 TEST_DESCRIPTION("Begin dynamic rendering with render area greater than extent of attachments");
2177
2178 SetTargetApiVersion(VK_API_VERSION_1_0);
2179 AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
2180 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2181 ASSERT_NO_FATAL_FAILURE(InitFramework());
2182
2183 if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
sjfricke50955f32022-06-05 10:12:52 +09002184 GTEST_SKIP() << "Tests for 1.0 only";
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002185 }
sjfricked700bc02022-05-30 16:35:06 +09002186 if (!AreRequiredExtensionsEnabled()) {
2187 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002188 }
2189
ziga-lunarga51287c2022-04-20 23:24:37 +02002190 auto vkGetPhysicalDeviceFeatures2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2KHR>(
2191 vk::GetInstanceProcAddr(instance(), "vkGetPhysicalDeviceFeatures2KHR"));
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002192 ASSERT_TRUE(vkGetPhysicalDeviceFeatures2KHR != nullptr);
2193
2194 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2195 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2KHR>(&dynamic_rendering_features);
2196 vkGetPhysicalDeviceFeatures2KHR(gpu(), &features2);
2197 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002198 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002199 }
2200
2201 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2202
2203 VkImageObj colorImage(m_device);
2204 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
2205 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
2206
ziga-lunarga51287c2022-04-20 23:24:37 +02002207 auto color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002208 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2209 color_attachment.imageView = colorImageView;
2210
ziga-lunarga51287c2022-04-20 23:24:37 +02002211 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002212 begin_rendering_info.layerCount = 1;
2213 begin_rendering_info.colorAttachmentCount = 1;
2214 begin_rendering_info.pColorAttachments = &color_attachment;
2215 begin_rendering_info.renderArea.extent.width = 64;
2216 begin_rendering_info.renderArea.extent.height = 32;
2217
2218 m_commandBuffer->begin();
2219
2220 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06075");
2221 m_commandBuffer->BeginRendering(begin_rendering_info);
2222 m_errorMonitor->VerifyFound();
2223
2224 begin_rendering_info.renderArea.extent.width = 32;
2225 begin_rendering_info.renderArea.extent.height = 64;
2226
2227 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06076");
2228 m_commandBuffer->BeginRendering(begin_rendering_info);
2229 m_errorMonitor->VerifyFound();
2230
2231 const VkFormat ds_format = FindSupportedDepthStencilFormat(gpu());
2232 if (ds_format != VK_FORMAT_UNDEFINED) {
2233 VkImageObj depthImage(m_device);
2234 depthImage.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
2235 VkImageView depthImageView = depthImage.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT);
2236
2237 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2238 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
2239 depth_attachment.imageView = depthImageView;
2240
2241 begin_rendering_info.colorAttachmentCount = 0;
2242 begin_rendering_info.pDepthAttachment = &depth_attachment;
2243
2244 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06076");
2245 m_commandBuffer->BeginRendering(begin_rendering_info);
2246 m_errorMonitor->VerifyFound();
2247 }
2248
2249 m_commandBuffer->end();
2250}
ziga-lunarga51287c2022-04-20 23:24:37 +02002251
2252TEST_F(VkLayerTest, DynamicRenderingDeviceGroupAreaGreaterThanAttachmentExtent) {
2253 TEST_DESCRIPTION("Begin dynamic rendering with device group with render area greater than extent of attachments");
2254
2255 SetTargetApiVersion(VK_API_VERSION_1_1);
2256 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2257 ASSERT_NO_FATAL_FAILURE(InitFramework());
2258
2259 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002260 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarga51287c2022-04-20 23:24:37 +02002261 }
sjfricked700bc02022-05-30 16:35:06 +09002262 if (!AreRequiredExtensionsEnabled()) {
2263 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarga51287c2022-04-20 23:24:37 +02002264 }
2265
2266 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2267 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2268 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2269 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002270 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarga51287c2022-04-20 23:24:37 +02002271 }
2272
2273 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2274
2275 VkImageObj colorImage(m_device);
2276 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
2277 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
2278
2279 auto color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2280 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2281 color_attachment.imageView = colorImageView;
2282
2283 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2284 begin_rendering_info.layerCount = 1;
2285 begin_rendering_info.colorAttachmentCount = 1;
2286 begin_rendering_info.pColorAttachments = &color_attachment;
2287 begin_rendering_info.renderArea.extent.width = 64;
2288 begin_rendering_info.renderArea.extent.height = 32;
2289
2290 m_commandBuffer->begin();
2291
2292 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06079");
2293 m_commandBuffer->BeginRendering(begin_rendering_info);
2294 m_errorMonitor->VerifyFound();
2295
2296 begin_rendering_info.renderArea.extent.width = 32;
2297 begin_rendering_info.renderArea.extent.height = 64;
2298
2299 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06080");
2300 m_commandBuffer->BeginRendering(begin_rendering_info);
2301 m_errorMonitor->VerifyFound();
2302
2303 const VkFormat ds_format = FindSupportedDepthStencilFormat(gpu());
2304 if (ds_format != VK_FORMAT_UNDEFINED) {
2305 VkImageObj depthImage(m_device);
2306 depthImage.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
2307 VkImageView depthImageView = depthImage.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT);
2308
2309 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2310 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
2311 depth_attachment.imageView = depthImageView;
2312
2313 begin_rendering_info.colorAttachmentCount = 0;
2314 begin_rendering_info.pDepthAttachment = &depth_attachment;
2315
2316 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06080");
2317 m_commandBuffer->BeginRendering(begin_rendering_info);
2318 m_errorMonitor->VerifyFound();
2319 }
2320
2321 m_commandBuffer->end();
2322}
ziga-lunargd4105c12022-04-21 13:54:20 +02002323
2324TEST_F(VkLayerTest, SecondaryCommandBufferIncompatibleRenderPass) {
2325 TEST_DESCRIPTION("Execute secondary command buffers within render pass instance with incompatible render pass");
2326
2327 SetTargetApiVersion(VK_API_VERSION_1_1);
2328 ASSERT_NO_FATAL_FAILURE(InitFramework());
2329
2330 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002331 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargd4105c12022-04-21 13:54:20 +02002332 }
2333
2334 ASSERT_NO_FATAL_FAILURE(InitState());
2335 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2336
ziga-lunarga3cc8482022-04-29 14:58:29 +02002337 VkSubpassDescription subpass = {};
ziga-lunargd4105c12022-04-21 13:54:20 +02002338 auto render_pass_ci = LvlInitStruct<VkRenderPassCreateInfo>();
ziga-lunarga3cc8482022-04-29 14:58:29 +02002339 render_pass_ci.subpassCount = 1;
2340 render_pass_ci.pSubpasses = &subpass;
ziga-lunargd4105c12022-04-21 13:54:20 +02002341
2342 vk_testing::RenderPass render_pass;
2343 render_pass.init(*m_device, render_pass_ci);
2344
2345 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2346 VkCommandBuffer secondary_handle = cb.handle();
2347
2348 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2349 cmd_buffer_inheritance_info.renderPass = render_pass.handle();
2350 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2351 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2352 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2353
2354 cb.begin(&cmd_buffer_begin_info);
2355 cb.end();
2356
2357 m_commandBuffer->begin();
2358 m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
2359
2360 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pBeginInfo-06020");
2361 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pInheritanceInfo-00098");
2362 vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle);
2363 m_errorMonitor->VerifyFound();
2364
2365 m_commandBuffer->EndRenderPass();
2366 m_commandBuffer->end();
2367}
ziga-lunarg590e0292022-04-21 14:07:22 +02002368
2369TEST_F(VkLayerTest, SecondaryCommandBufferIncompatibleSubpass) {
2370 TEST_DESCRIPTION("Execute secondary command buffers with different subpass");
2371
2372 SetTargetApiVersion(VK_API_VERSION_1_1);
2373 ASSERT_NO_FATAL_FAILURE(InitFramework());
2374
2375 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002376 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg590e0292022-04-21 14:07:22 +02002377 }
2378
2379 ASSERT_NO_FATAL_FAILURE(InitState());
2380
2381 VkSubpassDescription subpasses[2] = {};
2382
2383 auto render_pass_ci = LvlInitStruct<VkRenderPassCreateInfo>();
2384 render_pass_ci.subpassCount = 2;
2385 render_pass_ci.pSubpasses = subpasses;
2386
2387 vk_testing::RenderPass render_pass;
2388 render_pass.init(*m_device, render_pass_ci);
2389
2390 auto framebuffer_ci = LvlInitStruct<VkFramebufferCreateInfo>();
2391 framebuffer_ci.renderPass = render_pass.handle();
2392 framebuffer_ci.width = 32;
2393 framebuffer_ci.height = 32;
ziga-lunarg143bdbf2022-05-04 19:04:58 +02002394 framebuffer_ci.layers = 1;
ziga-lunarg590e0292022-04-21 14:07:22 +02002395
2396 vk_testing::Framebuffer framebuffer;
2397 framebuffer.init(*m_device, framebuffer_ci);
2398
2399 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2400 VkCommandBuffer secondary_handle = cb.handle();
2401
2402 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2403 cmd_buffer_inheritance_info.renderPass = render_pass.handle();
2404 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2405 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2406 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2407
2408 cb.begin(&cmd_buffer_begin_info);
2409 cb.end();
2410
2411 auto render_pass_begin_info = LvlInitStruct<VkRenderPassBeginInfo>();
2412 render_pass_begin_info.renderPass = render_pass.handle();
2413 render_pass_begin_info.renderArea.extent = {32, 32};
2414 render_pass_begin_info.framebuffer = framebuffer.handle();
2415
2416 m_commandBuffer->begin();
2417 m_commandBuffer->BeginRenderPass(render_pass_begin_info, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
2418 vk::CmdNextSubpass(m_commandBuffer->handle(), VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
2419
2420 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pCommandBuffers-00097");
2421 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pCommandBuffers-06019");
2422 vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle);
2423 m_errorMonitor->VerifyFound();
2424
2425 m_commandBuffer->EndRenderPass();
2426 m_commandBuffer->end();
2427}
ziga-lunarg343193b2022-04-21 14:15:17 +02002428
2429TEST_F(VkLayerTest, SecondaryCommandBufferInvalidContents) {
2430 TEST_DESCRIPTION("Execute secondary command buffers within active render pass that was not begun with VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS");
2431
2432 SetTargetApiVersion(VK_API_VERSION_1_1);
2433 ASSERT_NO_FATAL_FAILURE(InitFramework());
2434
2435 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002436 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg343193b2022-04-21 14:15:17 +02002437 }
2438
2439 ASSERT_NO_FATAL_FAILURE(InitState());
2440 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2441
ziga-lunarg343193b2022-04-21 14:15:17 +02002442 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2443 VkCommandBuffer secondary_handle = cb.handle();
2444
2445 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2446 cmd_buffer_inheritance_info.renderPass = m_renderPass;
2447 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2448 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2449 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2450
2451 cb.begin(&cmd_buffer_begin_info);
2452 cb.end();
2453
2454 m_commandBuffer->begin();
2455 m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo);
2456
2457 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-contents-00095");
2458 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-contents-06018");
2459 vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle);
2460 m_errorMonitor->VerifyFound();
2461
2462 m_commandBuffer->EndRenderPass();
2463 m_commandBuffer->end();
2464}
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002465
2466TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoDepthFormat) {
2467 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo DepthFormat incompatible with previously used pipeline");
2468
2469 SetTargetApiVersion(VK_API_VERSION_1_1);
2470 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2471 ASSERT_NO_FATAL_FAILURE(InitFramework());
2472
2473 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002474 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002475 }
sjfricked700bc02022-05-30 16:35:06 +09002476 if (!AreRequiredExtensionsEnabled()) {
2477 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002478 }
2479
2480 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2481 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2482 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2483 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002484 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002485 }
2486
2487 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2488 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2489
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002490 std::vector<VkFormat> depth_formats;
2491 const VkFormat ds_formats[] = {VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT};
2492 for (uint32_t i = 0; i < size(ds_formats); ++i) {
2493 VkFormatProperties format_props;
2494 vk::GetPhysicalDeviceFormatProperties(gpu(), ds_formats[i], &format_props);
2495
2496 if (format_props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) {
2497 depth_formats.push_back(ds_formats[i]);
2498 }
2499 }
2500
2501 if (depth_formats.size() < 2) {
2502 printf("%s Test requires 2 depth formats, skipping test.\n", kSkipPrefix);
2503 return;
2504 }
2505
2506 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2507 pipeline_rendering_info.depthAttachmentFormat = depth_formats[0];
2508
2509 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
2510
2511 CreatePipelineHelper pipe1(*this);
2512 pipe1.InitInfo();
2513 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2514 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2515 pipe1.InitState();
2516 pipe1.ds_ci_ = ds_ci;
2517 pipe1.CreateGraphicsPipeline();
2518
2519 pipeline_rendering_info.depthAttachmentFormat = depth_formats[1];
2520
2521 CreatePipelineHelper pipe2(*this);
2522 pipe2.InitInfo();
2523 pipe2.gp_ci_.pNext = &pipeline_rendering_info;
2524 pipe2.gp_ci_.renderPass = VK_NULL_HANDLE;
2525 pipe2.InitState();
2526 pipe2.ds_ci_ = ds_ci;
2527 pipe2.CreateGraphicsPipeline();
2528
2529 VkImageObj image(m_device);
2530 image.Init(32, 32, 1, depth_formats[0], VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2531 VkImageView depth_image_view = image.targetView(depth_formats[0], VK_IMAGE_ASPECT_DEPTH_BIT);
2532
2533 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2534 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
2535 depth_attachment.imageView = depth_image_view;
2536
2537 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2538 begin_rendering_info.layerCount = 1;
2539 begin_rendering_info.pDepthAttachment = &depth_attachment;
2540
2541 m_commandBuffer->begin();
2542 m_commandBuffer->BeginRendering(begin_rendering_info);
2543
2544 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_);
2545 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
2546
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002547 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06197");
2548 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_);
2549 m_errorMonitor->VerifyFound();
2550
2551 m_commandBuffer->EndRendering();
2552 m_commandBuffer->end();
2553}
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002554
2555TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoColorAttachments) {
2556 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo color attachment incompatible with previously used pipeline");
2557
2558 SetTargetApiVersion(VK_API_VERSION_1_1);
2559 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2560 ASSERT_NO_FATAL_FAILURE(InitFramework());
2561
2562 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002563 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002564 }
sjfricked700bc02022-05-30 16:35:06 +09002565 if (!AreRequiredExtensionsEnabled()) {
2566 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002567 }
2568
2569 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2570 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2571 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2572 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002573 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002574 }
2575
2576 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2577 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2578
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002579 VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
2580 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2581 pipeline_rendering_info.colorAttachmentCount = 1;
2582 pipeline_rendering_info.pColorAttachmentFormats = &format;
2583
2584 CreatePipelineHelper pipe1(*this);
2585 pipe1.InitInfo();
2586 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2587 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2588 pipe1.InitState();
2589 pipe1.CreateGraphicsPipeline();
2590
2591 format = VK_FORMAT_B8G8R8A8_UNORM;
2592
2593 CreatePipelineHelper pipe2(*this);
2594 pipe2.InitInfo();
2595 pipe2.gp_ci_.pNext = &pipeline_rendering_info;
2596 pipe2.gp_ci_.renderPass = VK_NULL_HANDLE;
2597 pipe2.InitState();
2598 pipe2.CreateGraphicsPipeline();
2599
2600 VkImageObj image(m_device);
2601 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2602 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
2603
2604 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2605 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2606 color_attachment.imageView = image_view;
2607
2608 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2609 begin_rendering_info.layerCount = 1;
2610 begin_rendering_info.colorAttachmentCount = 1;
2611 begin_rendering_info.pColorAttachments = &color_attachment;
2612
2613 m_commandBuffer->begin();
2614 m_commandBuffer->BeginRendering(begin_rendering_info);
2615
2616 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_);
2617 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
2618
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002619 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06196");
2620 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_);
2621 m_errorMonitor->VerifyFound();
2622
2623 m_commandBuffer->EndRendering();
2624 m_commandBuffer->end();
2625}
ziga-lunargacd79322022-04-21 18:36:34 +02002626
2627TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoColorAttachmentCount) {
2628 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo color attachment count incompatible with previously used pipeline");
2629
2630 SetTargetApiVersion(VK_API_VERSION_1_1);
2631 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2632 ASSERT_NO_FATAL_FAILURE(InitFramework());
2633
2634 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002635 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargacd79322022-04-21 18:36:34 +02002636 }
sjfricked700bc02022-05-30 16:35:06 +09002637 if (!AreRequiredExtensionsEnabled()) {
2638 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargacd79322022-04-21 18:36:34 +02002639 }
2640
2641 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2642 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2643 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2644 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002645 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargacd79322022-04-21 18:36:34 +02002646 }
2647
2648 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2649 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2650
ziga-lunargacd79322022-04-21 18:36:34 +02002651 VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
2652 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2653 pipeline_rendering_info.colorAttachmentCount = 1;
2654 pipeline_rendering_info.pColorAttachmentFormats = &format;
2655
2656 CreatePipelineHelper pipe1(*this);
2657 pipe1.InitInfo();
2658 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2659 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2660 pipe1.InitState();
2661 pipe1.CreateGraphicsPipeline();
2662
2663 pipeline_rendering_info.colorAttachmentCount = 0;
2664
2665 CreatePipelineHelper pipe2(*this);
2666 pipe2.InitInfo();
2667 pipe2.gp_ci_.pNext = &pipeline_rendering_info;
2668 pipe2.gp_ci_.renderPass = VK_NULL_HANDLE;
2669 pipe2.InitState();
2670 pipe2.CreateGraphicsPipeline();
2671
2672 VkImageObj image(m_device);
2673 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2674 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
2675
2676 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2677 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2678 color_attachment.imageView = image_view;
2679
2680 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2681 begin_rendering_info.layerCount = 1;
2682 begin_rendering_info.colorAttachmentCount = 1;
2683 begin_rendering_info.pColorAttachments = &color_attachment;
2684
2685 m_commandBuffer->begin();
2686 m_commandBuffer->BeginRendering(begin_rendering_info);
2687
2688 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_);
2689 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
2690
ziga-lunargacd79322022-04-21 18:36:34 +02002691 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06195");
2692 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_);
2693 m_errorMonitor->VerifyFound();
2694
2695 m_commandBuffer->EndRendering();
2696 m_commandBuffer->end();
ziga-lunarge3f11282022-04-21 18:39:55 +02002697}
2698
2699TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoStencilFormat) {
2700 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo StencilFormat incompatible with previously used pipeline");
2701
2702 SetTargetApiVersion(VK_API_VERSION_1_1);
2703 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2704 ASSERT_NO_FATAL_FAILURE(InitFramework());
2705
2706 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002707 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge3f11282022-04-21 18:39:55 +02002708 }
sjfricked700bc02022-05-30 16:35:06 +09002709 if (!AreRequiredExtensionsEnabled()) {
2710 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge3f11282022-04-21 18:39:55 +02002711 }
2712
2713 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2714 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2715 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2716 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002717 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge3f11282022-04-21 18:39:55 +02002718 }
2719
2720 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2721 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2722
ziga-lunarge3f11282022-04-21 18:39:55 +02002723 std::vector<VkFormat> stencil_formats;
2724 const VkFormat ds_formats[] = {VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT};
2725 for (uint32_t i = 0; i < size(ds_formats); ++i) {
2726 VkFormatProperties format_props;
2727 vk::GetPhysicalDeviceFormatProperties(gpu(), ds_formats[i], &format_props);
2728
2729 if (format_props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) {
2730 stencil_formats.push_back(ds_formats[i]);
2731 }
2732 }
2733
2734 if (stencil_formats.size() < 2) {
2735 printf("%s Test requires 2 stencil formats, skipping test.\n", kSkipPrefix);
2736 return;
2737 }
2738
2739 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2740 pipeline_rendering_info.stencilAttachmentFormat = stencil_formats[0];
2741
2742 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
2743
2744 CreatePipelineHelper pipe1(*this);
2745 pipe1.InitInfo();
2746 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2747 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2748 pipe1.InitState();
2749 pipe1.ds_ci_ = ds_ci;
2750 pipe1.CreateGraphicsPipeline();
2751
2752 pipeline_rendering_info.stencilAttachmentFormat = stencil_formats[1];
2753
2754 CreatePipelineHelper pipe2(*this);
2755 pipe2.InitInfo();
2756 pipe2.gp_ci_.pNext = &pipeline_rendering_info;
2757 pipe2.gp_ci_.renderPass = VK_NULL_HANDLE;
2758 pipe2.InitState();
2759 pipe2.ds_ci_ = ds_ci;
2760 pipe2.CreateGraphicsPipeline();
2761
2762 VkImageObj image(m_device);
2763 image.Init(32, 32, 1, stencil_formats[0], VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2764 VkImageView stencil_image_view = image.targetView(stencil_formats[0], VK_IMAGE_ASPECT_DEPTH_BIT);
2765
2766 VkRenderingAttachmentInfoKHR stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2767 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL;
2768 stencil_attachment.imageView = stencil_image_view;
2769
2770 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2771 begin_rendering_info.layerCount = 1;
2772 begin_rendering_info.pStencilAttachment = &stencil_attachment;
2773
2774 m_commandBuffer->begin();
2775 m_commandBuffer->BeginRendering(begin_rendering_info);
2776
2777 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_);
2778 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
2779
ziga-lunarge3f11282022-04-21 18:39:55 +02002780 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06194");
2781 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_);
2782 m_errorMonitor->VerifyFound();
2783
2784 m_commandBuffer->EndRendering();
2785 m_commandBuffer->end();
2786}
ziga-lunarg155ed452022-04-21 23:54:06 +02002787
2788TEST_F(VkLayerTest, DynamicRenderingWithInvalidShaderLayerBuiltIn) {
2789 TEST_DESCRIPTION("Create invalid pipeline that writes to Layer built-in");
2790
2791 SetTargetApiVersion(VK_API_VERSION_1_1);
2792 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2793 ASSERT_NO_FATAL_FAILURE(InitFramework());
2794
2795 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002796 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg155ed452022-04-21 23:54:06 +02002797 }
sjfricked700bc02022-05-30 16:35:06 +09002798 if (!AreRequiredExtensionsEnabled()) {
2799 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg155ed452022-04-21 23:54:06 +02002800 }
2801
2802 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2803 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>(&dynamic_rendering_features);
2804 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&multiview_features);
2805 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2806 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002807 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg155ed452022-04-21 23:54:06 +02002808 }
2809 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002810 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg155ed452022-04-21 23:54:06 +02002811 }
2812 if (multiview_features.multiviewGeometryShader == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002813 GTEST_SKIP() << "Test requires (unsupported) multiviewGeometryShader";
ziga-lunarg155ed452022-04-21 23:54:06 +02002814 }
2815
2816 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2817 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2818
2819 static char const *gsSource = R"glsl(
2820 #version 450
2821 layout (triangles) in;
2822 layout (triangle_strip) out;
2823 layout (max_vertices = 1) out;
2824 void main() {
2825 gl_Position = vec4(1.0, 0.5, 0.5, 0.0);
2826 EmitVertex();
2827 gl_Layer = 4;
2828 }
2829 )glsl";
2830
2831 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
2832 VkShaderObj gs(this, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT);
2833
2834 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2835
2836 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2837 pipeline_rendering_info.colorAttachmentCount = 1;
2838 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2839 pipeline_rendering_info.viewMask = 0x1;
2840
2841 CreatePipelineHelper pipe(*this);
2842 pipe.InitInfo();
2843 pipe.shader_stages_ = {vs.GetStageCreateInfo(), gs.GetStageCreateInfo(), pipe.fs_->GetStageCreateInfo()};
2844 pipe.gp_ci_.pNext = &pipeline_rendering_info;
2845 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2846 pipe.InitState();
2847 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06059");
2848 pipe.CreateGraphicsPipeline();
2849 m_errorMonitor->VerifyFound();
2850}
ziga-lunarg6feb4632022-04-22 00:20:21 +02002851
2852TEST_F(VkLayerTest, DynamicRenderingWithInputAttachmentCapability) {
2853 TEST_DESCRIPTION("Create invalid pipeline that uses InputAttachment capability");
2854
2855 SetTargetApiVersion(VK_API_VERSION_1_1);
2856 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2857 ASSERT_NO_FATAL_FAILURE(InitFramework());
2858
2859 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002860 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg6feb4632022-04-22 00:20:21 +02002861 }
sjfricked700bc02022-05-30 16:35:06 +09002862 if (!AreRequiredExtensionsEnabled()) {
2863 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6feb4632022-04-22 00:20:21 +02002864 }
2865
2866 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2867 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2868 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2869 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002870 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6feb4632022-04-22 00:20:21 +02002871 }
2872
2873 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2874 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2875
sjfricke394227a2022-06-20 16:47:38 +09002876 const char *fsSource = R"(
ziga-lunarg6feb4632022-04-22 00:20:21 +02002877 OpCapability Shader
2878 OpCapability InputAttachment
2879 %1 = OpExtInstImport "GLSL.std.450"
2880 OpMemoryModel Logical GLSL450
2881 OpEntryPoint Fragment %main "main"
2882 OpExecutionMode %main OriginUpperLeft
2883
2884 ; Debug Information
2885 OpSource GLSL 450
2886 OpName %main "main" ; id %4
2887
2888 ; Types, variables and constants
2889 %void = OpTypeVoid
2890 %3 = OpTypeFunction %void
2891
2892 ; Function main
2893 %main = OpFunction %void None %3
2894 %5 = OpLabel
2895 OpReturn
2896 OpFunctionEnd
2897 )";
2898
2899 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, SPV_ENV_VULKAN_1_0, SPV_SOURCE_ASM);
2900
2901 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2902
2903 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2904 pipeline_rendering_info.colorAttachmentCount = 1;
2905 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2906
2907 CreatePipelineHelper pipe(*this);
2908 pipe.InitInfo();
2909 pipe.shader_stages_ = {pipe.vs_->GetStageCreateInfo(), fs.GetStageCreateInfo()};
2910 pipe.gp_ci_.pNext = &pipeline_rendering_info;
2911 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2912 pipe.InitState();
2913 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06061");
2914 pipe.CreateGraphicsPipeline();
2915 m_errorMonitor->VerifyFound();
2916}
ziga-lunarga62b6ce2022-04-22 14:33:47 +02002917
2918TEST_F(VkLayerTest, InvalidRenderingInfoColorAttachmentFormat) {
2919 TEST_DESCRIPTION("Create pipeline with invalid color attachment format");
2920
2921 SetTargetApiVersion(VK_API_VERSION_1_1);
2922 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2923 ASSERT_NO_FATAL_FAILURE(InitFramework());
2924
2925 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002926 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarga62b6ce2022-04-22 14:33:47 +02002927 }
sjfricked700bc02022-05-30 16:35:06 +09002928 if (!AreRequiredExtensionsEnabled()) {
2929 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarga62b6ce2022-04-22 14:33:47 +02002930 }
2931
2932 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2933 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
2934 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
2935 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002936 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarga62b6ce2022-04-22 14:33:47 +02002937 }
2938
2939 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2940 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2941
2942 VkFormat color_format = VK_FORMAT_MAX_ENUM;
2943
2944 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2945 pipeline_rendering_info.colorAttachmentCount = 1;
2946 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2947
2948 CreatePipelineHelper pipe(*this);
2949 pipe.InitInfo();
2950 pipe.gp_ci_.pNext = &pipeline_rendering_info;
2951 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2952 pipe.InitState();
2953 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06579");
2954 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06580");
2955 pipe.CreateGraphicsPipeline();
2956 m_errorMonitor->VerifyFound();
2957}
ziga-lunargf7fb9202022-04-22 17:19:10 +02002958
2959TEST_F(VkLayerTest, InvalidDynamicRenderingLibraryViewMask) {
2960 TEST_DESCRIPTION("Create pipeline with invalid view mask");
2961
2962 SetTargetApiVersion(VK_API_VERSION_1_1);
2963 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2964 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
2965 ASSERT_NO_FATAL_FAILURE(InitFramework());
2966
2967 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002968 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargf7fb9202022-04-22 17:19:10 +02002969 }
sjfricked700bc02022-05-30 16:35:06 +09002970 if (!AreRequiredExtensionsEnabled()) {
2971 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargf7fb9202022-04-22 17:19:10 +02002972 }
2973
2974 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
2975 auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>(&multiview_features);
2976 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features);
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06002977 GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargf7fb9202022-04-22 17:19:10 +02002978 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002979 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargf7fb9202022-04-22 17:19:10 +02002980 }
2981 if (library_features.graphicsPipelineLibrary == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002982 GTEST_SKIP() << "Test requires (unsupported) graphicsPipelineLibrary";
ziga-lunargf7fb9202022-04-22 17:19:10 +02002983 }
2984 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002985 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunargf7fb9202022-04-22 17:19:10 +02002986 }
2987
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06002988 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &dynamic_rendering_features));
ziga-lunargf7fb9202022-04-22 17:19:10 +02002989 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2990
2991 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2992
2993 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2994 pipeline_rendering_info.colorAttachmentCount = 1;
2995 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2996
2997 auto graphics_library_create_info = LvlInitStruct<VkGraphicsPipelineLibraryCreateInfoEXT>(&pipeline_rendering_info);
2998 graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT;
2999 auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>(&graphics_library_create_info);
3000
3001 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
3002 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
3003 color_blend_state_create_info.attachmentCount = 1;
3004 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
3005
ziga-lunargf7fb9202022-04-22 17:19:10 +02003006 CreatePipelineHelper lib(*this);
3007 lib.cb_ci_ = color_blend_state_create_info;
3008 lib.InitInfo();
3009 lib.gp_ci_.pNext = &library_create_info;
3010 lib.gp_ci_.renderPass = VK_NULL_HANDLE;
3011 lib.InitState();
3012 lib.CreateGraphicsPipeline();
ziga-lunargf7fb9202022-04-22 17:19:10 +02003013
3014 graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT;
3015 library_create_info.libraryCount = 1;
3016 library_create_info.pLibraries = &lib.pipeline_;
3017 pipeline_rendering_info.viewMask = 0x1;
3018
3019 CreatePipelineHelper pipe(*this);
3020 pipe.InitInfo();
3021 pipe.gp_ci_.pNext = &library_create_info;
3022 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003023 pipe.shader_stages_ = {pipe.fs_->GetStageCreateInfo()};
ziga-lunargf7fb9202022-04-22 17:19:10 +02003024 pipe.InitState();
3025 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06626");
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06003026 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06626");
ziga-lunargf7fb9202022-04-22 17:19:10 +02003027 pipe.CreateGraphicsPipeline();
3028 m_errorMonitor->VerifyFound();
3029}
ziga-lunarge151ca62022-04-22 17:40:51 +02003030
3031TEST_F(VkLayerTest, InvalidAttachmentSampleCount) {
3032 TEST_DESCRIPTION("Create pipeline with invalid color attachment samples");
3033
3034 SetTargetApiVersion(VK_API_VERSION_1_1);
3035 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3036 ASSERT_NO_FATAL_FAILURE(InitFramework());
3037
3038 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003039 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge151ca62022-04-22 17:40:51 +02003040 }
sjfricked700bc02022-05-30 16:35:06 +09003041 if (!AreRequiredExtensionsEnabled()) {
3042 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge151ca62022-04-22 17:40:51 +02003043 }
3044
3045 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
3046 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3047 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3048 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003049 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge151ca62022-04-22 17:40:51 +02003050 }
3051
3052 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3053 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3054
3055 VkSampleCountFlagBits color_attachment_samples = VK_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM;
3056
3057 auto samples_info = LvlInitStruct<VkAttachmentSampleCountInfoAMD>();
3058 samples_info.colorAttachmentCount = 1;
3059 samples_info.pColorAttachmentSamples = &color_attachment_samples;
3060 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(&samples_info);
3061
3062 CreatePipelineHelper pipe(*this);
3063 pipe.InitInfo();
3064 pipe.gp_ci_.pNext = &pipeline_rendering_info;
3065 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3066 pipe.InitState();
3067 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-pColorAttachmentSamples-06592");
3068 pipe.CreateGraphicsPipeline();
3069 m_errorMonitor->VerifyFound();
3070}
ziga-lunargb81597d2022-04-22 19:11:51 +02003071
3072TEST_F(VkLayerTest, InvalidDynamicRenderingLibrariesViewMask) {
3073 TEST_DESCRIPTION("Create pipeline with libaries that have incompatible view mask");
3074
3075 SetTargetApiVersion(VK_API_VERSION_1_1);
3076 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3077 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
3078 ASSERT_NO_FATAL_FAILURE(InitFramework());
3079
3080 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003081 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargb81597d2022-04-22 19:11:51 +02003082 }
sjfricked700bc02022-05-30 16:35:06 +09003083 if (!AreRequiredExtensionsEnabled()) {
3084 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargb81597d2022-04-22 19:11:51 +02003085 }
3086
3087 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3088 auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>(&multiview_features);
3089 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features);
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003090 GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargb81597d2022-04-22 19:11:51 +02003091 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003092 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargb81597d2022-04-22 19:11:51 +02003093 }
3094 if (library_features.graphicsPipelineLibrary == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003095 GTEST_SKIP() << "Test requires (unsupported) graphicsPipelineLibrary";
ziga-lunargb81597d2022-04-22 19:11:51 +02003096 }
3097 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003098 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunargb81597d2022-04-22 19:11:51 +02003099 }
3100
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003101 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &dynamic_rendering_features));
ziga-lunargb81597d2022-04-22 19:11:51 +02003102 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3103
3104 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
3105
3106 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
3107 pipeline_rendering_info.colorAttachmentCount = 1;
3108 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
3109
ziga-lunargb81597d2022-04-22 19:11:51 +02003110 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
3111 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
3112 color_blend_state_create_info.attachmentCount = 1;
3113 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
3114
ziga-lunargb81597d2022-04-22 19:11:51 +02003115 CreatePipelineHelper lib1(*this);
3116 lib1.cb_ci_ = color_blend_state_create_info;
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003117 lib1.InitFragmentOutputLibInfo(&pipeline_rendering_info);
ziga-lunargb81597d2022-04-22 19:11:51 +02003118 lib1.gp_ci_.renderPass = VK_NULL_HANDLE;
3119 lib1.InitState();
3120 lib1.CreateGraphicsPipeline();
3121
ziga-lunargb81597d2022-04-22 19:11:51 +02003122 pipeline_rendering_info.viewMask = 0x1;
3123
3124 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
3125
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003126 const auto fs_spv = GLSLToSPV(VK_SHADER_STAGE_FRAGMENT_BIT, bindStateFragShaderText);
3127 auto fs_ci = LvlInitStruct<VkShaderModuleCreateInfo>();
3128 fs_ci.codeSize = fs_spv.size() * sizeof(decltype(fs_spv)::value_type);
3129 fs_ci.pCode = fs_spv.data();
3130
3131 auto fs_stage_ci = LvlInitStruct<VkPipelineShaderStageCreateInfo>(&fs_ci);
3132 fs_stage_ci.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
3133 fs_stage_ci.module = VK_NULL_HANDLE;
3134 fs_stage_ci.pName = "main";
3135
ziga-lunargb81597d2022-04-22 19:11:51 +02003136 CreatePipelineHelper lib2(*this);
3137 lib2.cb_ci_ = color_blend_state_create_info;
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003138 lib2.InitFragmentLibInfo(1, &fs_stage_ci, &pipeline_rendering_info);
ziga-lunargb81597d2022-04-22 19:11:51 +02003139 lib2.gp_ci_.renderPass = VK_NULL_HANDLE;
3140 lib2.ds_ci_ = ds_ci;
3141 lib2.InitState();
3142 lib2.CreateGraphicsPipeline();
ziga-lunargb81597d2022-04-22 19:11:51 +02003143
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003144 pipeline_rendering_info.viewMask = 0;
3145 auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>();
ziga-lunargb81597d2022-04-22 19:11:51 +02003146 library_create_info.libraryCount = 2;
3147 VkPipeline libraries[2] = {lib1.pipeline_, lib2.pipeline_};
3148 library_create_info.pLibraries = libraries;
ziga-lunargb81597d2022-04-22 19:11:51 +02003149
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003150 auto pipe_ci = LvlInitStruct<VkGraphicsPipelineCreateInfo>(&library_create_info);
ziga-lunarg7f25dff2022-05-06 17:49:34 +02003151 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-pLibraries-06627");
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003152 vk_testing::Pipeline pipe(*m_device, pipe_ci);
ziga-lunargb81597d2022-04-22 19:11:51 +02003153 m_errorMonitor->VerifyFound();
3154}
ziga-lunarg2e302312022-04-22 19:47:32 +02003155
3156TEST_F(VkLayerTest, InvalidDynamicRenderingLibraryRenderPass) {
3157 TEST_DESCRIPTION("Create pipeline with invalid library render pass");
3158
3159 SetTargetApiVersion(VK_API_VERSION_1_1);
3160 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3161 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
3162 ASSERT_NO_FATAL_FAILURE(InitFramework());
3163
3164 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003165 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg2e302312022-04-22 19:47:32 +02003166 }
sjfricked700bc02022-05-30 16:35:06 +09003167 if (!AreRequiredExtensionsEnabled()) {
3168 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg2e302312022-04-22 19:47:32 +02003169 }
3170
3171 auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>();
3172 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features);
3173 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3174 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3175 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003176 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg2e302312022-04-22 19:47:32 +02003177 }
3178 if (library_features.graphicsPipelineLibrary == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003179 GTEST_SKIP() << "Test requires (unsupported) graphicsPipelineLibrary";
ziga-lunarg2e302312022-04-22 19:47:32 +02003180 }
3181
3182 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3183 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3184
3185 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
3186
3187 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
3188 pipeline_rendering_info.colorAttachmentCount = 1;
3189 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
3190
ziga-lunarg2e302312022-04-22 19:47:32 +02003191 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
3192 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
3193 color_blend_state_create_info.attachmentCount = 1;
3194 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
3195
ziga-lunarg2e302312022-04-22 19:47:32 +02003196 CreatePipelineHelper lib(*this);
3197 lib.cb_ci_ = color_blend_state_create_info;
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003198 lib.InitFragmentOutputLibInfo(&pipeline_rendering_info);
ziga-lunarg2e302312022-04-22 19:47:32 +02003199 lib.InitState();
3200 lib.CreateGraphicsPipeline();
ziga-lunarg2e302312022-04-22 19:47:32 +02003201
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003202 auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>(&pipeline_rendering_info);
ziga-lunarg2e302312022-04-22 19:47:32 +02003203 library_create_info.libraryCount = 1;
3204 library_create_info.pLibraries = &lib.pipeline_;
3205
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003206 const auto fs_spv = GLSLToSPV(VK_SHADER_STAGE_FRAGMENT_BIT, bindStateFragShaderText);
3207 auto fs_ci = LvlInitStruct<VkShaderModuleCreateInfo>();
3208 fs_ci.codeSize = fs_spv.size() * sizeof(decltype(fs_spv)::value_type);
3209 fs_ci.pCode = fs_spv.data();
3210
3211 auto fs_stage_ci = LvlInitStruct<VkPipelineShaderStageCreateInfo>(&fs_ci);
3212 fs_stage_ci.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
3213 fs_stage_ci.module = VK_NULL_HANDLE;
3214 fs_stage_ci.pName = "main";
3215
ziga-lunarg2e302312022-04-22 19:47:32 +02003216 CreatePipelineHelper pipe(*this);
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003217 pipe.InitFragmentLibInfo(1, &fs_stage_ci, &library_create_info);
ziga-lunarg2e302312022-04-22 19:47:32 +02003218 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3219 pipe.InitState();
3220 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderpass-06625");
3221 pipe.CreateGraphicsPipeline();
3222 m_errorMonitor->VerifyFound();
3223}
ziga-lunarg7ba5a1c2022-04-22 19:56:49 +02003224
3225TEST_F(VkLayerTest, PipelineMissingMultisampleState) {
3226 TEST_DESCRIPTION("Create pipeline with missing multisample state");
3227
3228 SetTargetApiVersion(VK_API_VERSION_1_1);
3229 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3230 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
3231 ASSERT_NO_FATAL_FAILURE(InitFramework());
3232
3233 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003234 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7ba5a1c2022-04-22 19:56:49 +02003235 }
sjfricked700bc02022-05-30 16:35:06 +09003236 if (!AreRequiredExtensionsEnabled()) {
3237 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7ba5a1c2022-04-22 19:56:49 +02003238 }
3239
3240 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
3241 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3242 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3243 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003244 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7ba5a1c2022-04-22 19:56:49 +02003245 }
3246
3247 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3248 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3249
3250 CreatePipelineHelper pipe(*this);
3251 pipe.InitInfo();
3252 pipe.gp_ci_.pMultisampleState = nullptr;
3253 pipe.InitState();
3254 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderpass-06631");
3255 pipe.CreateGraphicsPipeline();
3256 m_errorMonitor->VerifyFound();
ziga-lunarg14222532022-04-22 23:27:17 +02003257}
3258
ziga-lunargd7737482022-04-25 11:16:37 +02003259TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachment) {
3260 TEST_DESCRIPTION("Use invalid VkRenderingFragmentDensityMapAttachmentInfoEXT");
ziga-lunarg14222532022-04-22 23:27:17 +02003261
3262 SetTargetApiVersion(VK_API_VERSION_1_1);
3263 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3264 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3265 ASSERT_NO_FATAL_FAILURE(InitFramework());
3266
3267 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003268 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg14222532022-04-22 23:27:17 +02003269 }
sjfricked700bc02022-05-30 16:35:06 +09003270 if (!AreRequiredExtensionsEnabled()) {
3271 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg14222532022-04-22 23:27:17 +02003272 }
3273
ziga-lunargd7737482022-04-25 11:16:37 +02003274 auto multiview_featuers = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3275 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&multiview_featuers);
ziga-lunarg14222532022-04-22 23:27:17 +02003276 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3277 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3278 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003279 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg14222532022-04-22 23:27:17 +02003280 }
ziga-lunargd7737482022-04-25 11:16:37 +02003281 if (multiview_featuers.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003282 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunargd7737482022-04-25 11:16:37 +02003283 }
ziga-lunarg14222532022-04-22 23:27:17 +02003284
3285 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3286 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3287
3288 VkImageObj image(m_device);
3289 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
3290 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, VK_IMAGE_TILING_LINEAR, 0);
3291 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3292
3293 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3294 rendering_fragment_density.imageView = image_view;
3295 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3296 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3297 begin_rendering_info.layerCount = 1;
3298
3299 m_commandBuffer->begin();
ziga-lunargd7737482022-04-25 11:16:37 +02003300
ziga-lunarg14222532022-04-22 23:27:17 +02003301 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06157");
3302 m_commandBuffer->BeginRendering(begin_rendering_info);
3303 m_errorMonitor->VerifyFound();
ziga-lunargd7737482022-04-25 11:16:37 +02003304
3305 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3306
3307 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3308 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3309 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
3310 image_create_info.extent = {32, 32, 1};
3311 image_create_info.mipLevels = 1;
3312 image_create_info.arrayLayers = 2;
3313 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
3314 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3315 image_create_info.usage = VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT;
3316 VkImageObj image2(m_device);
3317 image2.Init(image_create_info);
3318 VkImageView image_view2 = image2.targetView(VK_FORMAT_R8G8B8A8_UINT);
3319 rendering_fragment_density.imageView = image_view2;
3320 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06160");
3321 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06109");
3322 m_commandBuffer->BeginRendering(begin_rendering_info);
3323 m_errorMonitor->VerifyFound();
3324
ziga-lunarg14222532022-04-22 23:27:17 +02003325 m_commandBuffer->end();
3326}
ziga-lunarga81df9d2022-04-22 23:33:13 +02003327
3328TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentUsage) {
3329 TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid imageLayout");
3330
3331 SetTargetApiVersion(VK_API_VERSION_1_1);
3332 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3333 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3334 ASSERT_NO_FATAL_FAILURE(InitFramework());
3335
3336 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003337 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarga81df9d2022-04-22 23:33:13 +02003338 }
sjfricked700bc02022-05-30 16:35:06 +09003339 if (!AreRequiredExtensionsEnabled()) {
3340 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarga81df9d2022-04-22 23:33:13 +02003341 }
3342
3343 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
3344 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3345 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3346 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003347 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarga81df9d2022-04-22 23:33:13 +02003348 }
3349
3350 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3351 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3352
3353 VkImageObj image(m_device);
3354 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
3355 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3356
3357 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3358 rendering_fragment_density.imageView = image_view;
3359 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3360 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3361 begin_rendering_info.layerCount = 1;
3362
3363 m_commandBuffer->begin();
3364 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06158");
3365 m_commandBuffer->BeginRendering(begin_rendering_info);
3366 m_errorMonitor->VerifyFound();
3367 m_commandBuffer->end();
3368}
ziga-lunarg7c411b32022-04-22 23:37:48 +02003369
3370TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentCreateFlags) {
3371 TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid image create flags");
3372
3373 SetTargetApiVersion(VK_API_VERSION_1_1);
3374 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3375 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3376 ASSERT_NO_FATAL_FAILURE(InitFramework());
3377
3378 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003379 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7c411b32022-04-22 23:37:48 +02003380 }
sjfricked700bc02022-05-30 16:35:06 +09003381 if (!AreRequiredExtensionsEnabled()) {
3382 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7c411b32022-04-22 23:37:48 +02003383 }
3384
3385 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
3386 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3387 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3388 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003389 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7c411b32022-04-22 23:37:48 +02003390 }
3391
3392 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3393 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3394
3395 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3396 image_create_info.flags = VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT;
3397 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3398 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
3399 image_create_info.extent = {32, 32, 4};
3400 image_create_info.mipLevels = 1;
3401 image_create_info.arrayLayers = 1;
3402 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
3403 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3404 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT;
3405
3406 VkImageObj image(m_device);
3407 image.Init(image_create_info);
3408 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3409
3410 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3411 rendering_fragment_density.imageView = image_view;
3412 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3413 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3414 begin_rendering_info.layerCount = 1;
3415
3416 m_commandBuffer->begin();
3417 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06159");
3418 m_commandBuffer->BeginRendering(begin_rendering_info);
3419 m_errorMonitor->VerifyFound();
3420 m_commandBuffer->end();
3421}
ziga-lunarg66569a72022-04-22 23:43:26 +02003422
3423TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentLayerCount) {
3424 TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid layer count");
3425
3426 SetTargetApiVersion(VK_API_VERSION_1_1);
3427 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3428 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3429 ASSERT_NO_FATAL_FAILURE(InitFramework());
3430
3431 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003432 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg66569a72022-04-22 23:43:26 +02003433 }
sjfricked700bc02022-05-30 16:35:06 +09003434 if (!AreRequiredExtensionsEnabled()) {
3435 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg66569a72022-04-22 23:43:26 +02003436 }
3437
3438 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3439 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&multiview_features);
3440 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3441 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3442 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003443 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg66569a72022-04-22 23:43:26 +02003444 }
3445 if (!multiview_features.multiview) {
sjfricke50955f32022-06-05 10:12:52 +09003446 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg66569a72022-04-22 23:43:26 +02003447 }
3448
3449 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3450 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3451
3452 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3453 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3454 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
3455 image_create_info.extent = {32, 32, 4};
3456 image_create_info.mipLevels = 1;
3457 image_create_info.arrayLayers = 2;
3458 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
3459 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3460 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT;
3461
3462 VkImageObj image(m_device);
3463 image.Init(image_create_info);
3464 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3465
3466 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3467 rendering_fragment_density.imageView = image_view;
3468 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3469 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3470 begin_rendering_info.layerCount = 1;
3471 begin_rendering_info.viewMask = 0x1;
3472
3473 m_commandBuffer->begin();
3474 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06160");
3475 m_commandBuffer->BeginRendering(begin_rendering_info);
3476 m_errorMonitor->VerifyFound();
3477 m_commandBuffer->end();
3478}
ziga-lunarg323c11d2022-04-22 23:56:32 +02003479
3480TEST_F(VkLayerTest, InvalidRenderingPNextImageView) {
3481 TEST_DESCRIPTION(
3482 "Use different image views in VkRenderingFragmentShadingRateAttachmentInfoKHR and "
3483 "VkRenderingFragmentDensityMapAttachmentInfoEXT");
3484
3485 SetTargetApiVersion(VK_API_VERSION_1_1);
3486 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3487 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3488 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
3489 ASSERT_NO_FATAL_FAILURE(InitFramework());
3490
3491 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003492 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg323c11d2022-04-22 23:56:32 +02003493 }
sjfricked700bc02022-05-30 16:35:06 +09003494 if (!AreRequiredExtensionsEnabled()) {
3495 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg323c11d2022-04-22 23:56:32 +02003496 }
3497
3498 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3499 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&multiview_features);
3500 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3501 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3502 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003503 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg323c11d2022-04-22 23:56:32 +02003504 }
3505 if (!multiview_features.multiview) {
sjfricke50955f32022-06-05 10:12:52 +09003506 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg323c11d2022-04-22 23:56:32 +02003507 }
3508
3509 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3510 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3511
3512 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
3513
3514 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
3515 vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2);
3516
3517 VkImageObj image1(m_device);
3518 image1.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
3519 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR,
3520 VK_IMAGE_TILING_LINEAR, 0);
3521 VkImageView image_view1 = image1.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3522 VkImageObj image2(m_device);
3523 image2.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
3524 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, VK_IMAGE_TILING_LINEAR, 0);
3525 VkImageView image_view2 = image2.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3526
3527 auto rendering_fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
3528 rendering_fragment_shading_rate.imageView = image_view1;
3529 rendering_fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3530 rendering_fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
3531 auto rendering_fragment_density =
3532 LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>(&rendering_fragment_shading_rate);
3533 rendering_fragment_density.imageView = image_view2;
3534 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3535 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3536 begin_rendering_info.layerCount = 1;
3537 begin_rendering_info.viewMask = 0x1;
3538
3539 m_commandBuffer->begin();
3540 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06126");
3541 m_commandBuffer->BeginRendering(begin_rendering_info);
3542 m_errorMonitor->VerifyFound();
3543 m_commandBuffer->end();
3544}
ziga-lunarg95f20d42022-04-23 00:06:42 +02003545
3546TEST_F(VkLayerTest, InvalidRenderingRenderArea) {
3547 TEST_DESCRIPTION("Use negative offset in RenderingInfo render area");
3548
3549 SetTargetApiVersion(VK_API_VERSION_1_0);
3550 AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
3551 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3552 ASSERT_NO_FATAL_FAILURE(InitFramework());
3553
3554 if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
sjfricke50955f32022-06-05 10:12:52 +09003555 GTEST_SKIP() << "Tests for 1.0 only";
ziga-lunarg95f20d42022-04-23 00:06:42 +02003556 }
sjfricked700bc02022-05-30 16:35:06 +09003557 if (!AreRequiredExtensionsEnabled()) {
3558 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg95f20d42022-04-23 00:06:42 +02003559 }
3560
3561 auto vkGetPhysicalDeviceFeatures2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2KHR>(
3562 vk::GetInstanceProcAddr(instance(), "vkGetPhysicalDeviceFeatures2KHR"));
3563 ASSERT_TRUE(vkGetPhysicalDeviceFeatures2KHR != nullptr);
3564
3565 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
3566 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2KHR>(&dynamic_rendering_features);
3567 vkGetPhysicalDeviceFeatures2KHR(gpu(), &features2);
3568 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003569 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg95f20d42022-04-23 00:06:42 +02003570 }
3571
3572 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3573 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3574
3575 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3576 begin_rendering_info.layerCount = 1;
3577 begin_rendering_info.renderArea.offset.x = -1;
ziga-lunarg9b6a95f2022-04-23 00:13:38 +02003578 begin_rendering_info.renderArea.extent.width = 32;
3579 begin_rendering_info.renderArea.extent.height = 32;
ziga-lunarg95f20d42022-04-23 00:06:42 +02003580
3581 m_commandBuffer->begin();
3582
3583 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06071");
3584 m_commandBuffer->BeginRendering(begin_rendering_info);
3585 m_errorMonitor->VerifyFound();
3586
3587 begin_rendering_info.renderArea.offset.x = 0;
3588 begin_rendering_info.renderArea.offset.y = -1;
3589
3590 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06072");
3591 m_commandBuffer->BeginRendering(begin_rendering_info);
3592 m_errorMonitor->VerifyFound();
3593
ziga-lunarg9b6a95f2022-04-23 00:13:38 +02003594 begin_rendering_info.renderArea.offset.y = 0;
3595 begin_rendering_info.renderArea.offset.x = m_device->phy().properties().limits.maxFramebufferWidth - 16;
3596 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06073");
3597 m_commandBuffer->BeginRendering(begin_rendering_info);
3598 m_errorMonitor->VerifyFound();
3599
3600 begin_rendering_info.renderArea.offset.x = 0;
3601 begin_rendering_info.renderArea.offset.y = m_device->phy().properties().limits.maxFramebufferHeight - 16;
3602 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06074");
3603 m_commandBuffer->BeginRendering(begin_rendering_info);
3604 m_errorMonitor->VerifyFound();
3605
ziga-lunarg95f20d42022-04-23 00:06:42 +02003606 m_commandBuffer->end();
3607}
ziga-lunarg6662a882022-04-23 00:21:27 +02003608
3609TEST_F(VkLayerTest, InvalidRenderingInfoViewMask) {
3610 TEST_DESCRIPTION("Use negative offset in RenderingInfo render area");
3611
3612 SetTargetApiVersion(VK_API_VERSION_1_1);
3613 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3614 ASSERT_NO_FATAL_FAILURE(InitFramework());
3615
3616 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003617 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg6662a882022-04-23 00:21:27 +02003618 }
sjfricked700bc02022-05-30 16:35:06 +09003619 if (!AreRequiredExtensionsEnabled()) {
3620 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6662a882022-04-23 00:21:27 +02003621 }
3622
3623 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3624 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(&multiview_features);
3625 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3626 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3627 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003628 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6662a882022-04-23 00:21:27 +02003629 }
3630 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003631 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg6662a882022-04-23 00:21:27 +02003632 }
3633
3634 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3635 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3636
3637 VkPhysicalDeviceMultiviewProperties multiview_props = LvlInitStruct<VkPhysicalDeviceMultiviewProperties>();
3638 VkPhysicalDeviceProperties2 pd_props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&multiview_props);
3639 vk::GetPhysicalDeviceProperties2(gpu(), &pd_props2);
3640
3641 if (multiview_props.maxMultiviewViewCount == 32) {
3642 printf("%s VUID is not testable as maxMultiviewViewCount is 32, skipping test\n", kSkipPrefix);
3643 return;
3644 }
3645
3646 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3647 begin_rendering_info.layerCount = 1;
3648 begin_rendering_info.renderArea.extent.width = 32;
3649 begin_rendering_info.renderArea.extent.height = 32;
3650 begin_rendering_info.viewMask = 1u << multiview_props.maxMultiviewViewCount;
3651
3652 m_commandBuffer->begin();
3653
3654 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-viewMask-06128");
3655 m_commandBuffer->BeginRendering(begin_rendering_info);
3656 m_errorMonitor->VerifyFound();
3657
3658 m_commandBuffer->end();
3659}
ziga-lunargae75b8a2022-04-23 10:54:37 +02003660
3661TEST_F(VkLayerTest, InvalidRenderingColorAttachmentFormat) {
3662 TEST_DESCRIPTION("Use format with missing potential format features in rendering color attachment");
3663
3664 SetTargetApiVersion(VK_API_VERSION_1_1);
3665 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3666 AddRequiredExtensions(VK_NV_LINEAR_COLOR_ATTACHMENT_EXTENSION_NAME);
3667 ASSERT_NO_FATAL_FAILURE(InitFramework());
3668
3669 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003670 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargae75b8a2022-04-23 10:54:37 +02003671 }
sjfricked700bc02022-05-30 16:35:06 +09003672 if (!AreRequiredExtensionsEnabled()) {
3673 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargae75b8a2022-04-23 10:54:37 +02003674 }
3675
3676 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
3677 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3678 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3679 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003680 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargae75b8a2022-04-23 10:54:37 +02003681 }
3682
3683 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3684 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3685
3686 VkFormat format = FindSupportedDepthStencilFormat(gpu());
3687 if (format == VK_FORMAT_UNDEFINED) {
3688 printf("%s No Depth + Stencil format found. Skipped.\n", kSkipPrefix);
3689 return;
3690 }
3691
3692 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
3693 pipeline_rendering_info.colorAttachmentCount = 1;
3694 pipeline_rendering_info.pColorAttachmentFormats = &format;
3695
3696 CreatePipelineHelper pipe(*this);
3697 pipe.InitInfo();
3698 pipe.gp_ci_.pNext = &pipeline_rendering_info;
3699 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3700 pipe.InitState();
3701
3702 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06582");
3703 pipe.CreateGraphicsPipeline();
3704 m_errorMonitor->VerifyFound();
3705}
ziga-lunargeac390f2022-04-23 11:05:28 +02003706
sjfricke483c1082022-06-05 10:21:44 +09003707TEST_F(VkLayerTest, InvalidResolveModeWithNonIntegerColorFormat) {
3708 TEST_DESCRIPTION("Use invalid resolve mode with non integer color format");
3709
3710 SetTargetApiVersion(VK_API_VERSION_1_1);
3711 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3712 ASSERT_NO_FATAL_FAILURE(InitFramework());
3713
3714 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
3715 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
3716 }
sjfricked700bc02022-05-30 16:35:06 +09003717 if (!AreRequiredExtensionsEnabled()) {
3718 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
sjfricke483c1082022-06-05 10:21:44 +09003719 }
3720
3721 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
3722 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3723 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3724 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
3725 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
3726 }
3727
3728 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3729 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3730
3731 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3732 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3733 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; // not int color
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06003734 image_create_info.extent = {32, 32, 1};
sjfricke483c1082022-06-05 10:21:44 +09003735 image_create_info.mipLevels = 1;
3736 image_create_info.arrayLayers = 1;
3737 image_create_info.samples = VK_SAMPLE_COUNT_4_BIT;
3738 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3739 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
3740 VkImageObj image(m_device);
3741 image.Init(image_create_info);
3742 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3743
Tony-LunarGf088c6b2022-07-08 11:29:53 -06003744 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
3745 VkImageObj resolve_image(m_device);
3746 resolve_image.Init(image_create_info);
3747 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3748
sjfricke483c1082022-06-05 10:21:44 +09003749 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3750 color_attachment.imageView = image_view;
3751 color_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT; // not allowed for format
3752 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3753 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
Tony-LunarGf088c6b2022-07-08 11:29:53 -06003754 color_attachment.resolveImageView = resolve_image_view;
sjfricke483c1082022-06-05 10:21:44 +09003755
3756 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3757 begin_rendering_info.colorAttachmentCount = 1;
3758 begin_rendering_info.pColorAttachments = &color_attachment;
3759 begin_rendering_info.layerCount = 1;
3760
3761 m_commandBuffer->begin();
3762
3763 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06129");
3764 m_commandBuffer->BeginRendering(begin_rendering_info);
3765 m_errorMonitor->VerifyFound();
3766
3767 m_commandBuffer->end();
3768}
3769
ziga-lunargeac390f2022-04-23 11:05:28 +02003770TEST_F(VkLayerTest, InvalidResolveModeWithIntegerColorFormat) {
3771 TEST_DESCRIPTION("Use invalid resolve mode with integer color format");
3772
3773 SetTargetApiVersion(VK_API_VERSION_1_1);
3774 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3775 ASSERT_NO_FATAL_FAILURE(InitFramework());
3776
3777 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003778 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargeac390f2022-04-23 11:05:28 +02003779 }
sjfricked700bc02022-05-30 16:35:06 +09003780 if (!AreRequiredExtensionsEnabled()) {
3781 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargeac390f2022-04-23 11:05:28 +02003782 }
3783
3784 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
3785 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3786 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3787 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003788 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargeac390f2022-04-23 11:05:28 +02003789 }
3790
3791 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3792 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3793
3794 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3795 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3796 image_create_info.format = VK_FORMAT_R8G8B8A8_UINT;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06003797 image_create_info.extent = {32, 32, 1};
ziga-lunargeac390f2022-04-23 11:05:28 +02003798 image_create_info.mipLevels = 1;
3799 image_create_info.arrayLayers = 1;
3800 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
3801 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3802 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
3803 VkImageObj image(m_device);
3804 image.Init(image_create_info);
3805 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
3806
Tony-LunarGf088c6b2022-07-08 11:29:53 -06003807 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
3808 VkImageObj resolve_image(m_device);
3809 resolve_image.Init(image_create_info);
3810 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UINT);
3811
ziga-lunargeac390f2022-04-23 11:05:28 +02003812 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3813 color_attachment.imageView = image_view;
3814 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3815 color_attachment.resolveMode = VK_RESOLVE_MODE_MAX_BIT;
3816 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
Tony-LunarGf088c6b2022-07-08 11:29:53 -06003817 color_attachment.resolveImageView = resolve_image_view;
ziga-lunargeac390f2022-04-23 11:05:28 +02003818
3819 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3820 begin_rendering_info.colorAttachmentCount = 1;
3821 begin_rendering_info.pColorAttachments = &color_attachment;
3822 begin_rendering_info.layerCount = 1;
3823
3824 m_commandBuffer->begin();
3825
3826 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06130");
3827 m_commandBuffer->BeginRendering(begin_rendering_info);
3828 m_errorMonitor->VerifyFound();
3829
3830 m_commandBuffer->end();
3831}
ziga-lunargdf2a3202022-04-23 11:07:46 +02003832
3833TEST_F(VkLayerTest, InvalidResolveModeSamples) {
3834 TEST_DESCRIPTION("Use invalid sample count with resolve mode that is not none");
3835
3836 SetTargetApiVersion(VK_API_VERSION_1_1);
3837 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3838 ASSERT_NO_FATAL_FAILURE(InitFramework());
3839
3840 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003841 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargdf2a3202022-04-23 11:07:46 +02003842 }
sjfricked700bc02022-05-30 16:35:06 +09003843 if (!AreRequiredExtensionsEnabled()) {
3844 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargdf2a3202022-04-23 11:07:46 +02003845 }
3846
3847 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
3848 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3849 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3850 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003851 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargdf2a3202022-04-23 11:07:46 +02003852 }
3853
3854 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3855 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3856
3857 VkImageObj image(m_device);
3858 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
3859 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3860
3861 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3862 color_attachment.imageView = image_view;
3863 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3864 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
3865 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
Tony-LunarGf088c6b2022-07-08 11:29:53 -06003866 color_attachment.resolveImageView = image_view;
ziga-lunargdf2a3202022-04-23 11:07:46 +02003867
3868 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3869 begin_rendering_info.colorAttachmentCount = 1;
3870 begin_rendering_info.pColorAttachments = &color_attachment;
3871 begin_rendering_info.layerCount = 1;
3872
3873 m_commandBuffer->begin();
3874
3875 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06132");
3876 m_commandBuffer->BeginRendering(begin_rendering_info);
3877 m_errorMonitor->VerifyFound();
3878
3879 m_commandBuffer->end();
3880}
ziga-lunargb7693aa2022-04-23 11:21:57 +02003881
3882TEST_F(VkLayerTest, InvalidResolveImageViewSamples) {
3883 TEST_DESCRIPTION("Use resolve image view with invalid sample count");
3884
3885 SetTargetApiVersion(VK_API_VERSION_1_1);
3886 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3887 ASSERT_NO_FATAL_FAILURE(InitFramework());
3888
3889 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003890 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargb7693aa2022-04-23 11:21:57 +02003891 }
sjfricked700bc02022-05-30 16:35:06 +09003892 if (!AreRequiredExtensionsEnabled()) {
3893 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargb7693aa2022-04-23 11:21:57 +02003894 }
3895
3896 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
3897 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
3898 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
3899 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003900 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargb7693aa2022-04-23 11:21:57 +02003901 }
3902
3903 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3904 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3905
3906 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3907 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3908 image_create_info.format = VK_FORMAT_R8G8B8A8_UINT;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06003909 image_create_info.extent = {32, 32, 1};
ziga-lunargb7693aa2022-04-23 11:21:57 +02003910 image_create_info.mipLevels = 1;
3911 image_create_info.arrayLayers = 1;
3912 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
3913 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3914 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
3915
3916 VkImageObj image(m_device);
3917 image.Init(image_create_info);
3918 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
3919
3920 VkImageObj resolve_image(m_device);
3921 resolve_image.Init(image_create_info);
3922 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UINT);
3923
3924 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3925 color_attachment.imageView = image_view;
3926 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3927 color_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
3928 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
3929 color_attachment.resolveImageView = resolve_image_view;
3930
3931 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3932 begin_rendering_info.colorAttachmentCount = 1;
3933 begin_rendering_info.pColorAttachments = &color_attachment;
3934 begin_rendering_info.layerCount = 1;
3935
3936 m_commandBuffer->begin();
3937
Tony-LunarG7384f7e2022-07-05 14:20:42 -06003938 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06864");
ziga-lunargb7693aa2022-04-23 11:21:57 +02003939 m_commandBuffer->BeginRendering(begin_rendering_info);
3940 m_errorMonitor->VerifyFound();
3941
Tony-LunarGeb7156a2022-07-26 13:36:31 -06003942 color_attachment.resolveImageView = VK_NULL_HANDLE;
3943 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06860");
3944 m_commandBuffer->BeginRendering(begin_rendering_info);
3945 m_errorMonitor->VerifyFound();
3946
ziga-lunargb7693aa2022-04-23 11:21:57 +02003947 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
Tony-LunarG7384f7e2022-07-05 14:20:42 -06004006 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06865");
ziga-lunargd12cbce2022-04-23 11:35:20 +02004007 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
Tony-LunarGf088c6b2022-07-08 11:29:53 -06004596 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
4597 VkImageObj resolve_image(m_device);
4598 resolve_image.Init(image_create_info);
4599 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4600
ziga-lunarg644c0552022-04-24 17:50:58 +02004601 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4602 color_attachment.imageView = invalid_image_view;
4603 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
Tony-LunarGf088c6b2022-07-08 11:29:53 -06004604 color_attachment.resolveImageView = resolve_image_view;
ziga-lunarg644c0552022-04-24 17:50:58 +02004605
4606 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4607 begin_rendering_info.layerCount = 1;
4608 begin_rendering_info.colorAttachmentCount = 1;
4609 begin_rendering_info.pColorAttachments = &color_attachment;
4610
4611 m_commandBuffer->begin();
4612
4613 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06087");
4614 m_commandBuffer->BeginRendering(begin_rendering_info);
4615 m_errorMonitor->VerifyFound();
4616
4617 color_attachment.imageView = image_view;
4618 color_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4619
4620 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06090");
4621 m_commandBuffer->BeginRendering(begin_rendering_info);
4622 m_errorMonitor->VerifyFound();
4623
4624 color_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
4625 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06096");
4626 m_commandBuffer->BeginRendering(begin_rendering_info);
4627 m_errorMonitor->VerifyFound();
4628
4629 color_attachment.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL;
4630 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06100");
4631 m_commandBuffer->BeginRendering(begin_rendering_info);
4632 m_errorMonitor->VerifyFound();
4633
4634 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4635 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4636 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4637
4638 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06091");
4639 m_commandBuffer->BeginRendering(begin_rendering_info);
4640 m_errorMonitor->VerifyFound();
4641
4642 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
4643 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06097");
4644 m_commandBuffer->BeginRendering(begin_rendering_info);
4645 m_errorMonitor->VerifyFound();
4646
4647 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
4648 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06101");
4649 m_commandBuffer->BeginRendering(begin_rendering_info);
4650 m_errorMonitor->VerifyFound();
4651
4652 color_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
sjfricke483c1082022-06-05 10:21:44 +09004653
ziga-lunarg644c0552022-04-24 17:50:58 +02004654 const uint32_t max_color_attachments = m_device->phy().properties().limits.maxColorAttachments + 1;
4655 std::vector<VkRenderingAttachmentInfoKHR> color_attachments(max_color_attachments);
4656 for (auto &attachment : color_attachments) {
4657 attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4658 attachment.imageView = image_view;
4659 attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4660 }
4661 begin_rendering_info.colorAttachmentCount = max_color_attachments;
4662 begin_rendering_info.pColorAttachments = color_attachments.data();
4663 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06106");
4664 m_commandBuffer->BeginRendering(begin_rendering_info);
4665 m_errorMonitor->VerifyFound();
4666
4667 m_commandBuffer->end();
4668}
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004669
4670TEST_F(VkLayerTest, TestRenderingInfoDepthAttachment) {
4671 TEST_DESCRIPTION("Test RenderingInfo depth attachment.");
4672
4673 SetTargetApiVersion(VK_API_VERSION_1_1);
4674 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4675 AddRequiredExtensions(VK_KHR_DEPTH_STENCIL_RESOLVE_EXTENSION_NAME);
4676
4677 ASSERT_NO_FATAL_FAILURE(InitFramework());
4678
4679 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004680 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004681 }
4682
sjfricked700bc02022-05-30 16:35:06 +09004683 if (!AreRequiredExtensionsEnabled()) {
4684 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004685 }
4686
4687 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
4688 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4689 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4690
4691 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004692 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004693 }
4694
4695 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4696 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4697
4698 VkFormat ds_format = FindSupportedDepthStencilFormat(gpu());
4699 if (ds_format == VK_FORMAT_UNDEFINED) {
4700 printf("%s No Depth + Stencil format found, skipping test..\n", kSkipPrefix);
4701 return;
4702 }
4703
4704 auto depth_stencil_resolve_properties = LvlInitStruct<VkPhysicalDeviceDepthStencilResolveProperties>();
4705 auto properties2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&depth_stencil_resolve_properties);
4706 vk::GetPhysicalDeviceProperties2(gpu(), &properties2);
4707 bool has_depth_resolve_mode_average =
4708 (depth_stencil_resolve_properties.supportedDepthResolveModes & VK_RESOLVE_MODE_AVERAGE_BIT) != 0;
4709 bool has_stencil_resolve_mode_average =
4710 (depth_stencil_resolve_properties.supportedStencilResolveModes & VK_RESOLVE_MODE_AVERAGE_BIT) != 0;
4711
4712 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4713 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4714 image_create_info.format = ds_format;
4715 image_create_info.extent = {32, 32, 1};
4716 image_create_info.mipLevels = 1;
4717 image_create_info.arrayLayers = 1;
4718 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4719 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4720 image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
4721 VkImageObj image(m_device);
4722 image.Init(image_create_info);
4723
4724 VkImageObj depth_image(m_device);
4725 depth_image.Init(image_create_info);
4726 VkImageView depth_image_view = depth_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4727 VkImageObj stencil_image(m_device);
4728 stencil_image.Init(image_create_info);
4729 VkImageView stencil_image_view = stencil_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4730
4731 VkImageObj depth_resolvel_image(m_device);
4732 depth_resolvel_image.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0);
4733 VkImageView depth_resolve_image_view =
4734 depth_resolvel_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4735
4736 VkImageObj stencil_resolvel_image(m_device);
4737 stencil_resolvel_image.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0);
4738 VkImageView stencil_resolve_image_view =
4739 stencil_resolvel_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4740
4741 VkImageObj invalid_image(m_device);
4742 image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
4743 invalid_image.Init(image_create_info);
4744 VkImageView invalid_image_view = invalid_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT);
4745
4746 auto depth_attachment = LvlInitStruct<VkRenderingAttachmentInfo>();
4747 depth_attachment.imageView = depth_image_view;
4748 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4749
4750 auto stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfo>();
4751 stencil_attachment.imageView = stencil_image_view;
4752 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4753
4754 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4755 begin_rendering_info.layerCount = 1;
4756 begin_rendering_info.pDepthAttachment = &depth_attachment;
4757 begin_rendering_info.pStencilAttachment = &stencil_attachment;
4758
4759 m_commandBuffer->begin();
4760
4761 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06085");
4762 m_commandBuffer->BeginRendering(begin_rendering_info);
4763 m_errorMonitor->VerifyFound();
4764
4765 depth_attachment.imageView = VK_NULL_HANDLE;
4766 stencil_attachment.imageView = VK_NULL_HANDLE;
4767 depth_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4768 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4769 depth_attachment.resolveImageView = depth_resolve_image_view;
4770 stencil_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4771 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4772 stencil_attachment.resolveImageView = stencil_resolve_image_view;
4773
4774 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06086");
4775 m_commandBuffer->BeginRendering(begin_rendering_info);
4776 m_errorMonitor->VerifyFound();
4777
4778 depth_attachment.imageView = depth_image_view;
4779 stencil_attachment.imageView = depth_image_view;
4780 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4781 stencil_attachment.resolveImageView = depth_resolve_image_view;
4782
4783 if (!has_depth_resolve_mode_average) {
4784 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06102");
4785 }
4786 if (!has_stencil_resolve_mode_average) {
4787 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06103");
4788 }
4789 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06093");
4790 m_commandBuffer->BeginRendering(begin_rendering_info);
4791 m_errorMonitor->VerifyFound();
4792
4793 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
4794 if (has_depth_resolve_mode_average && has_stencil_resolve_mode_average) {
4795 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06098");
4796 m_commandBuffer->BeginRendering(begin_rendering_info);
4797 m_errorMonitor->VerifyFound();
4798 }
4799
4800 depth_attachment.imageView = invalid_image_view;
4801 stencil_attachment.imageView = invalid_image_view;
4802 depth_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
4803 stencil_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
4804 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06088");
4805 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06089");
4806 m_commandBuffer->BeginRendering(begin_rendering_info);
4807 m_errorMonitor->VerifyFound();
4808
4809 depth_attachment.imageView = depth_image_view;
4810 stencil_attachment.imageView = depth_image_view;
4811 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4812 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06092");
4813 m_commandBuffer->BeginRendering(begin_rendering_info);
4814 m_errorMonitor->VerifyFound();
4815
4816 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4817 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4818 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4819 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4820 depth_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4821 if (depth_stencil_resolve_properties.independentResolveNone == VK_FALSE && has_depth_resolve_mode_average) {
4822 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06104");
4823 m_commandBuffer->BeginRendering(begin_rendering_info);
4824 m_errorMonitor->VerifyFound();
4825 }
4826 if (depth_stencil_resolve_properties.independentResolve == VK_FALSE && has_depth_resolve_mode_average) {
4827 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06105");
4828 m_commandBuffer->BeginRendering(begin_rendering_info);
4829 m_errorMonitor->VerifyFound();
4830 }
4831
ziga-lunargf35a7d72022-04-25 01:00:41 +02004832 stencil_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4833 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4834 if (has_stencil_resolve_mode_average) {
4835 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06095");
4836 m_commandBuffer->BeginRendering(begin_rendering_info);
4837 m_errorMonitor->VerifyFound();
4838 }
4839 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL;
4840 if (has_stencil_resolve_mode_average) {
4841 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06099");
4842 m_commandBuffer->BeginRendering(begin_rendering_info);
4843 m_errorMonitor->VerifyFound();
4844 }
4845
4846 depth_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
4847 stencil_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
4848 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4849 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06094");
4850 m_commandBuffer->BeginRendering(begin_rendering_info);
4851 m_errorMonitor->VerifyFound();
4852
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004853 m_commandBuffer->end();
4854}
ziga-lunarg002e6562022-04-25 00:54:16 +02004855
4856TEST_F(VkLayerTest, InvalidRenderingRenderAreaWithDeviceGroupExt) {
4857 TEST_DESCRIPTION("Use negative offset in RenderingInfo render area");
4858
4859 SetTargetApiVersion(VK_API_VERSION_1_1);
4860 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4861 ASSERT_NO_FATAL_FAILURE(InitFramework());
4862
4863 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004864 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg002e6562022-04-25 00:54:16 +02004865 }
sjfricked700bc02022-05-30 16:35:06 +09004866 if (!AreRequiredExtensionsEnabled()) {
4867 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg002e6562022-04-25 00:54:16 +02004868 }
4869
4870 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
4871 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4872 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4873 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004874 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg002e6562022-04-25 00:54:16 +02004875 }
4876
4877 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4878 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4879
4880 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4881 begin_rendering_info.layerCount = 1;
4882 begin_rendering_info.renderArea.offset.x = -1;
4883 begin_rendering_info.renderArea.extent.width = 32;
4884 begin_rendering_info.renderArea.extent.height = 32;
4885
4886 m_commandBuffer->begin();
4887
4888 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06077");
4889 m_commandBuffer->BeginRendering(begin_rendering_info);
4890 m_errorMonitor->VerifyFound();
4891
4892 begin_rendering_info.renderArea.offset.x = 0;
4893 begin_rendering_info.renderArea.offset.y = -1;
4894
4895 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06078");
4896 m_commandBuffer->BeginRendering(begin_rendering_info);
4897 m_errorMonitor->VerifyFound();
4898
4899 m_commandBuffer->end();
4900}
ziga-lunarg6e4f9da2022-04-25 01:05:22 +02004901
4902TEST_F(VkLayerTest, TestDynamicRenderingPipeline) {
4903 TEST_DESCRIPTION("Use pipeline created with render pass in dynamic render pass.");
4904
4905 SetTargetApiVersion(VK_API_VERSION_1_1);
4906 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4907
4908 ASSERT_NO_FATAL_FAILURE(InitFramework());
4909
4910 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004911 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg6e4f9da2022-04-25 01:05:22 +02004912 }
4913
sjfricked700bc02022-05-30 16:35:06 +09004914 if (!AreRequiredExtensionsEnabled()) {
4915 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6e4f9da2022-04-25 01:05:22 +02004916 }
4917
4918 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
4919 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
4920 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
4921
4922 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004923 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6e4f9da2022-04-25 01:05:22 +02004924 }
4925
4926 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4927 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4928
4929 CreatePipelineHelper pipe(*this);
4930 pipe.InitInfo();
4931 pipe.InitState();
4932 pipe.CreateGraphicsPipeline();
4933
4934 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4935 begin_rendering_info.layerCount = 1;
4936
4937 m_commandBuffer->begin();
4938 m_commandBuffer->BeginRendering(begin_rendering_info);
4939
4940 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_);
4941 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-renderPass-06198");
4942 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
4943 m_errorMonitor->VerifyFound();
4944
4945 m_commandBuffer->EndRendering();
4946 m_commandBuffer->end();
ziga-lunarg67551632022-04-25 15:20:20 +02004947}
4948
4949TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRateAttachmentSize) {
4950 TEST_DESCRIPTION("Test FragmentShadingRateAttachment size.");
4951
4952 SetTargetApiVersion(VK_API_VERSION_1_0);
4953 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4954 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004955 AddRequiredExtensions(VK_KHR_MULTIVIEW_EXTENSION_NAME);
ziga-lunarg67551632022-04-25 15:20:20 +02004956
4957 ASSERT_NO_FATAL_FAILURE(InitFramework());
4958
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004959 if (IsDriver(VK_DRIVER_ID_AMD_PROPRIETARY)) {
4960 GTEST_SKIP() << "Skipping on AMD proprietary driver pending further investigation.";
4961 }
4962
ziga-lunarg67551632022-04-25 15:20:20 +02004963 if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
sjfricke50955f32022-06-05 10:12:52 +09004964 GTEST_SKIP() << "Tests for 1.0 only";
ziga-lunarg67551632022-04-25 15:20:20 +02004965 }
4966
sjfricked700bc02022-05-30 16:35:06 +09004967 if (!AreRequiredExtensionsEnabled()) {
4968 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg67551632022-04-25 15:20:20 +02004969 }
4970
4971 auto vkGetPhysicalDeviceFeatures2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2KHR>(
4972 vk::GetInstanceProcAddr(instance(), "vkGetPhysicalDeviceFeatures2KHR"));
4973 ASSERT_TRUE(vkGetPhysicalDeviceFeatures2KHR != nullptr);
4974
4975 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004976 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeaturesKHR>(&dynamic_rendering_features);
4977 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2KHR>(&multiview_features);
ziga-lunarg67551632022-04-25 15:20:20 +02004978 vkGetPhysicalDeviceFeatures2KHR(gpu(), &features2);
4979
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004980 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004981 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg67551632022-04-25 15:20:20 +02004982 }
4983 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004984 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg67551632022-04-25 15:20:20 +02004985 }
4986
4987 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
4988
4989 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
4990 vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2);
4991
4992 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
4993
4994 VkImageObj image(m_device);
4995 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
4996 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR,
4997 VK_IMAGE_TILING_LINEAR, 0);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004998 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
ziga-lunarg67551632022-04-25 15:20:20 +02004999
5000 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
5001 fragment_shading_rate.imageView = image_view;
5002 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
5003 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
5004
5005 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
5006 begin_rendering_info.layerCount = 1;
5007 begin_rendering_info.renderArea.offset.x = fragment_shading_rate.shadingRateAttachmentTexelSize.width * 64;
5008
5009 m_commandBuffer->begin();
5010
5011 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06117");
5012 m_commandBuffer->BeginRendering(begin_rendering_info);
5013 m_errorMonitor->VerifyFound();
5014
5015 begin_rendering_info.renderArea.offset.x = 0;
5016 begin_rendering_info.renderArea.offset.y = fragment_shading_rate.shadingRateAttachmentTexelSize.height * 64;
5017
5018 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06118");
5019 m_commandBuffer->BeginRendering(begin_rendering_info);
5020 m_errorMonitor->VerifyFound();
5021}
5022
5023TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRateAttachmentSizeWithDeviceGroupExt) {
5024 TEST_DESCRIPTION("Test FragmentShadingRateAttachment size with device group extension.");
5025
5026 SetTargetApiVersion(VK_API_VERSION_1_1);
5027 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
5028 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06005029 AddRequiredExtensions(VK_KHR_MULTIVIEW_EXTENSION_NAME);
ziga-lunarg67551632022-04-25 15:20:20 +02005030
5031 ASSERT_NO_FATAL_FAILURE(InitFramework());
5032
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06005033 if (IsDriver(VK_DRIVER_ID_AMD_PROPRIETARY)) {
5034 GTEST_SKIP() << "Skipping on AMD proprietary driver pending further investigation.";
5035 }
5036
ziga-lunarg67551632022-04-25 15:20:20 +02005037 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09005038 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg67551632022-04-25 15:20:20 +02005039 }
5040
sjfricked700bc02022-05-30 16:35:06 +09005041 if (!AreRequiredExtensionsEnabled()) {
5042 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg67551632022-04-25 15:20:20 +02005043 }
5044
5045 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06005046 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeaturesKHR>(&dynamic_rendering_features);
5047 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&multiview_features);
ziga-lunarg67551632022-04-25 15:20:20 +02005048 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
5049
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06005050 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09005051 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg67551632022-04-25 15:20:20 +02005052 }
5053 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09005054 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg67551632022-04-25 15:20:20 +02005055 }
5056
5057 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
5058
5059 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
5060 vk::GetPhysicalDeviceProperties2(gpu(), &phys_dev_props_2);
5061
5062 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
5063
5064 VkImageObj image(m_device);
5065 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
5066 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR,
5067 VK_IMAGE_TILING_LINEAR, 0);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06005068 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
ziga-lunarg67551632022-04-25 15:20:20 +02005069
5070 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
5071 fragment_shading_rate.imageView = image_view;
5072 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
5073 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
5074
5075 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
5076 begin_rendering_info.layerCount = 1;
5077 begin_rendering_info.renderArea.offset.x = fragment_shading_rate.shadingRateAttachmentTexelSize.width * 64;
5078
5079 m_commandBuffer->begin();
5080
5081 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06119");
5082 m_commandBuffer->BeginRendering(begin_rendering_info);
5083 m_errorMonitor->VerifyFound();
5084
5085 begin_rendering_info.renderArea.offset.x = 0;
5086 begin_rendering_info.renderArea.offset.y = fragment_shading_rate.shadingRateAttachmentTexelSize.height * 64;
5087
ziga-lunarg8f9de2a2022-04-25 15:59:19 +02005088 VkRect2D render_area = {};
5089 render_area.offset.x = 0;
5090 render_area.offset.y = 0;
5091 render_area.extent.width = 64 * fragment_shading_rate.shadingRateAttachmentTexelSize.width;
5092 render_area.extent.height = 32;
5093
5094 auto device_group_render_pass_begin_info = LvlInitStruct<VkDeviceGroupRenderPassBeginInfo>();
5095 device_group_render_pass_begin_info.deviceRenderAreaCount = 1;
5096 device_group_render_pass_begin_info.pDeviceRenderAreas = &render_area;
5097 fragment_shading_rate.pNext = &device_group_render_pass_begin_info;
5098
ziga-lunarg7f25dff2022-05-06 17:49:34 +02005099 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06120");
ziga-lunarg8f9de2a2022-04-25 15:59:19 +02005100 m_commandBuffer->BeginRendering(begin_rendering_info);
5101 m_errorMonitor->VerifyFound();
5102
5103 render_area.extent.width = 32;
5104 render_area.extent.height = 64 * fragment_shading_rate.shadingRateAttachmentTexelSize.height;
5105
5106 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06122");
ziga-lunarg67551632022-04-25 15:20:20 +02005107 m_commandBuffer->BeginRendering(begin_rendering_info);
5108 m_errorMonitor->VerifyFound();
5109}
ziga-lunarge966a9a2022-04-25 22:42:08 +02005110
5111TEST_F(VkLayerTest, TestSuspendingRenderPassInstance) {
5112 TEST_DESCRIPTION("Test suspending render pass instance.");
5113
5114 SetTargetApiVersion(VK_API_VERSION_1_1);
5115 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
5116
5117 ASSERT_NO_FATAL_FAILURE(InitFramework());
5118
5119 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09005120 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005121 }
5122
sjfricked700bc02022-05-30 16:35:06 +09005123 if (!AreRequiredExtensionsEnabled()) {
5124 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005125 }
5126
5127 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
5128 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
5129 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
5130
5131 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09005132 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005133 }
5134
5135 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
5136
ziga-lunarge966a9a2022-04-25 22:42:08 +02005137 VkCommandPoolObj command_pool(m_device, m_device->graphics_queue_node_index_);
5138 VkCommandBufferObj cmd_buffer1(m_device, &command_pool);
5139 VkCommandBufferObj cmd_buffer2(m_device, &command_pool);
5140 VkCommandBufferObj cmd_buffer3(m_device, &command_pool);
5141
5142 VkRenderingInfo suspend_rendering_info = LvlInitStruct<VkRenderingInfo>();
5143 suspend_rendering_info.flags = VK_RENDERING_SUSPENDING_BIT;
5144 suspend_rendering_info.layerCount = 1;
5145
5146 VkRenderingInfo resume_rendering_info = LvlInitStruct<VkRenderingInfo>();
5147 resume_rendering_info.flags = VK_RENDERING_RESUMING_BIT;
5148 resume_rendering_info.layerCount = 1;
5149
5150 VkRenderingInfo rendering_info = LvlInitStruct<VkRenderingInfo>();
5151 rendering_info.layerCount = 1;
5152
5153 auto cmd_begin = LvlInitStruct<VkCommandBufferBeginInfo>();
5154
5155 cmd_buffer1.begin(&cmd_begin);
5156 cmd_buffer1.BeginRendering(suspend_rendering_info);
5157 cmd_buffer1.EndRendering();
5158 cmd_buffer1.end();
5159
5160 cmd_buffer2.begin(&cmd_begin);
5161 cmd_buffer2.BeginRendering(resume_rendering_info);
5162 cmd_buffer2.EndRendering();
5163 cmd_buffer2.end();
5164
5165 cmd_buffer3.begin(&cmd_begin);
5166 cmd_buffer3.BeginRendering(rendering_info);
5167 cmd_buffer3.EndRendering();
5168 cmd_buffer3.end();
5169
5170 VkCommandBuffer command_buffers[3] = {cmd_buffer1.handle(), cmd_buffer2.handle()};
5171
5172 VkSubmitInfo submit_info = LvlInitStruct<VkSubmitInfo>();
5173 submit_info.commandBufferCount = 2;
5174 submit_info.pCommandBuffers = command_buffers;
5175 vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5176 vk::QueueWaitIdle(m_device->m_queue);
5177
ziga-lunarge966a9a2022-04-25 22:42:08 +02005178 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo-pCommandBuffers-06014");
5179
5180 submit_info.commandBufferCount = 1;
5181 vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5182 vk::QueueWaitIdle(m_device->m_queue);
5183
5184 m_errorMonitor->VerifyFound();
5185
5186 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo-pCommandBuffers-06016");
5187
5188 command_buffers[1] = cmd_buffer3.handle();
5189 command_buffers[2] = cmd_buffer2.handle();
5190 submit_info.commandBufferCount = 3;
5191 vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5192 vk::QueueWaitIdle(m_device->m_queue);
5193
5194 m_errorMonitor->VerifyFound();
5195
5196 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo-pCommandBuffers-06193");
5197
5198 command_buffers[0] = cmd_buffer2.handle();
5199 submit_info.commandBufferCount = 1;
5200 vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5201 vk::QueueWaitIdle(m_device->m_queue);
5202
5203 m_errorMonitor->VerifyFound();
5204}
5205
5206TEST_F(VkLayerTest, TestSuspendingRenderPassInstanceQueueSubmit2) {
5207 TEST_DESCRIPTION("Test suspending render pass instance with QueueSubmit2.");
5208
5209 SetTargetApiVersion(VK_API_VERSION_1_1);
5210 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
5211 AddRequiredExtensions(VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME);
5212
5213 ASSERT_NO_FATAL_FAILURE(InitFramework());
5214
5215 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09005216 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005217 }
5218
sjfricked700bc02022-05-30 16:35:06 +09005219 if (!AreRequiredExtensionsEnabled()) {
5220 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005221 }
5222
5223 auto synchronization2 = LvlInitStruct<VkPhysicalDeviceSynchronization2Features>();
5224 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&synchronization2);
5225 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
5226 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
5227
5228 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09005229 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005230 }
5231 if (synchronization2.synchronization2 == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09005232 GTEST_SKIP() << "Test requires (unsupported) synchronization2";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005233 }
5234
5235 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
5236
5237 auto vkQueueSubmit2KHR =
5238 reinterpret_cast<PFN_vkQueueSubmit2KHR>(vk::GetDeviceProcAddr(m_device->device(), "vkQueueSubmit2KHR"));
5239 ASSERT_TRUE(vkQueueSubmit2KHR != nullptr);
5240
ziga-lunarge966a9a2022-04-25 22:42:08 +02005241 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
ziga-lunarge966a9a2022-04-25 22:42:08 +02005288 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo2KHR-commandBuffer-06010");
5289
5290 submit_info.commandBufferInfoCount = 1;
5291 vkQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5292 vk::QueueWaitIdle(m_device->m_queue);
5293
5294 m_errorMonitor->VerifyFound();
5295
5296 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo2KHR-commandBuffer-06012");
5297
5298 command_buffer_submit_info[1].commandBuffer = cmd_buffer3.handle();
5299 command_buffer_submit_info[2].commandBuffer = cmd_buffer2.handle();
5300 submit_info.commandBufferInfoCount = 3;
5301 vkQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5302 vk::QueueWaitIdle(m_device->m_queue);
5303
5304 m_errorMonitor->VerifyFound();
5305
5306 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo2KHR-commandBuffer-06192");
5307
5308 command_buffer_submit_info[0].commandBuffer = cmd_buffer2.handle();
5309 submit_info.commandBufferInfoCount = 1;
5310 vkQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5311 vk::QueueWaitIdle(m_device->m_queue);
5312
5313 m_errorMonitor->VerifyFound();
5314}