blob: 1d74882a32c7167dc51841fcb1806b7ba6db6f18 [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>();
sjfricke11db0c72022-08-18 13:23:11 +090041 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
Nathaniel Cesarioa06135e2022-03-02 21:22:30 -070042 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +090043 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
Aaron Haganaca50442021-12-07 22:26:29 -050044 }
45
ziga-lunargf54cb2a2022-03-11 02:54:27 +010046 features2.features.variableMultisampleRate = VK_FALSE;
47
Nathaniel Cesarioa06135e2022-03-02 21:22:30 -070048 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
49
Aaron Haganaca50442021-12-07 22:26:29 -050050 VkPhysicalDeviceMultiviewProperties multiview_props = LvlInitStruct<VkPhysicalDeviceMultiviewProperties>();
51 VkPhysicalDeviceProperties2 pd_props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&multiview_props);
sjfricke74a1aad2022-08-17 14:41:33 +090052 GetPhysicalDeviceProperties2(pd_props2);
Aaron Haganaca50442021-12-07 22:26:29 -050053
54 if (multiview_props.maxMultiviewViewCount == 32) {
55 printf("%s VUID is not testable as maxMultiviewViewCount is 32, skipping test\n", kSkipPrefix);
56 return;
57 }
58
59 VkFormat color_format = VK_FORMAT_D32_SFLOAT;
60
61 auto cmd_buffer_inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>();
62 cmd_buffer_inheritance_rendering_info.colorAttachmentCount = 1;
63 cmd_buffer_inheritance_rendering_info.pColorAttachmentFormats = &color_format;
64 cmd_buffer_inheritance_rendering_info.depthAttachmentFormat = VK_FORMAT_R8G8B8_UNORM;
65 cmd_buffer_inheritance_rendering_info.stencilAttachmentFormat = VK_FORMAT_R8G8B8_SNORM;
66 cmd_buffer_inheritance_rendering_info.viewMask = 1 << multiview_props.maxMultiviewViewCount;
67
68 auto sample_count_info_amd = LvlInitStruct<VkAttachmentSampleCountInfoAMD>();
69 sample_count_info_amd.pNext = &cmd_buffer_inheritance_rendering_info;
70 sample_count_info_amd.colorAttachmentCount = 2;
sfricke-samsungae54c1e2022-01-21 05:35:21 -080071
Aaron Haganaca50442021-12-07 22:26:29 -050072 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
73 cmd_buffer_inheritance_info.pNext = &sample_count_info_amd;
74
75 auto cmd_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>();
76 cmd_buffer_allocate_info.commandPool = m_commandPool->handle();
77 cmd_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY;
78 cmd_buffer_allocate_info.commandBufferCount = 0x1;
79
80 VkCommandBuffer secondary_cmd_buffer;
81 VkResult err = vk::AllocateCommandBuffers(m_device->device(), &cmd_buffer_allocate_info, &secondary_cmd_buffer);
82 ASSERT_VK_SUCCESS(err);
83 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06003");
Tony-LunarGbbd2ab92021-12-02 08:31:24 -070084 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-colorAttachmentCount-06004");
85 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-variableMultisampleRate-06005");
86 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-depthAttachmentFormat-06007");
87 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-multiview-06008");
88 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-viewMask-06009");
ziga-lunarg813fa012022-04-09 14:09:57 +020089 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-stencilAttachmentFormat-06199");
90 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-depthAttachmentFormat-06200");
91 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-pColorAttachmentFormats-06006");
92 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-depthAttachmentFormat-06540");
ziga-lunarga3cc8482022-04-29 14:58:29 +020093 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-stencilAttachmentFormat-06541");
Aaron Haganaca50442021-12-07 22:26:29 -050094
95 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
96 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
97 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
98 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
99 m_errorMonitor->VerifyFound();
100}
101
Aaron Haganb54466d2022-02-18 15:02:54 -0500102TEST_F(VkLayerTest, DynamicRenderingCommandDraw) {
Aaron Haganaca50442021-12-07 22:26:29 -0500103 TEST_DESCRIPTION("vkCmdDraw* Dynamic Rendering Tests.");
104
105 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2);
106 if (version < VK_API_VERSION_1_2) {
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600107 GTEST_SKIP() << "At least Vulkan version 1.2 is required, skipping test.";
Aaron Haganaca50442021-12-07 22:26:29 -0500108 }
109
110 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
111
112 ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor));
113
114 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900115 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
Aaron Haganaca50442021-12-07 22:26:29 -0500116 }
117
sjfricked700bc02022-05-30 16:35:06 +0900118 if (!AreRequiredExtensionsEnabled()) {
119 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
Aaron Haganaca50442021-12-07 22:26:29 -0500120 }
121
122 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +0900123 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
Aaron Haganaca50442021-12-07 22:26:29 -0500124 if (!dynamic_rendering_features.dynamicRendering) {
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600125 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering , skipping.";
Aaron Haganaca50442021-12-07 22:26:29 -0500126 }
127
128 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
129
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800130 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
131 VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT);
Aaron Haganaca50442021-12-07 22:26:29 -0500132
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600133 auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
134
Aaron Haganaca50442021-12-07 22:26:29 -0500135 VkPipelineObj pipe(m_device);
136 pipe.AddShader(&vs);
137 pipe.AddShader(&fs);
138 pipe.AddDefaultColorAttachment();
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600139 pipe.SetDepthStencil(&ds_state);
Aaron Haganaca50442021-12-07 22:26:29 -0500140
141 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
142 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
143 const VkPipelineLayoutObj pl(m_device, {&dsl});
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800144
Aaron Haganaca50442021-12-07 22:26:29 -0500145 VkFormat depth_format = VK_FORMAT_D32_SFLOAT_S8_UINT;
146 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
Aaron Hagan80034ea2021-12-23 11:24:09 -0500147 pipeline_rendering_info.depthAttachmentFormat = depth_format;
148 pipeline_rendering_info.stencilAttachmentFormat = depth_format;
Aaron Haganaca50442021-12-07 22:26:29 -0500149
150 auto multisample_state_create_info = LvlInitStruct<VkPipelineMultisampleStateCreateInfo>();
151 multisample_state_create_info.rasterizationSamples = VK_SAMPLE_COUNT_2_BIT;
152
153 auto create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
154 pipe.InitGraphicsPipelineCreateInfo(&create_info);
155 create_info.pMultisampleState = &multisample_state_create_info;
156 create_info.renderPass = VkRenderPass(0x1);
157 create_info.pNext = &pipeline_rendering_info;
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800158
Aaron Haganaca50442021-12-07 22:26:29 -0500159 VkResult err = pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
160 ASSERT_VK_SUCCESS(err);
161
162 VkViewport viewport = {0, 0, 16, 16, 0, 1};
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800163 VkRect2D scissor = {{0, 0}, {16, 16}};
Aaron Haganaca50442021-12-07 22:26:29 -0500164
165 VkImageObj image(m_device);
166 image.Init(32, 32, 1, depth_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
167 ASSERT_TRUE(image.initialized());
168
169 VkImageViewCreateInfo ivci = {VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
170 nullptr,
171 0,
172 image.handle(),
173 VK_IMAGE_VIEW_TYPE_2D,
174 depth_format,
175 {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
176 VK_COMPONENT_SWIZZLE_IDENTITY},
177 {VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, 0, 1, 0, 1}};
178
paul-lunarg18e16342022-07-12 14:02:23 -0600179 vk_testing::ImageView depth_image_view(*m_device, ivci);
Aaron Haganaca50442021-12-07 22:26:29 -0500180
181 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
182 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
paul-lunarg18e16342022-07-12 14:02:23 -0600183 depth_attachment.imageView = depth_image_view.handle();
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800184
Aaron Haganaca50442021-12-07 22:26:29 -0500185 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
186 begin_rendering_info.pDepthAttachment = &depth_attachment;
187 begin_rendering_info.pStencilAttachment = &depth_attachment;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600188 begin_rendering_info.layerCount = 1;
Aaron Haganaca50442021-12-07 22:26:29 -0500189
190 m_commandBuffer->begin();
191 m_commandBuffer->BeginRendering(begin_rendering_info);
192 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle());
193 vk::CmdSetViewport(m_commandBuffer->handle(), 0, 1, &viewport);
194 vk::CmdSetScissor(m_commandBuffer->handle(), 0, 1, &scissor);
195 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06189");
196 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06190");
197 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
198 m_errorMonitor->VerifyFound();
199 m_commandBuffer->EndRendering();
200 m_commandBuffer->end();
201}
202
203TEST_F(VkLayerTest, DynamicRenderingGraphicsPipelineCreateInfo) {
204 TEST_DESCRIPTION("Test graphics pipeline creation with dynamic rendering.");
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800205
Aaron Haganaca50442021-12-07 22:26:29 -0500206 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2);
207 if (version < VK_API_VERSION_1_2) {
208 printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix);
209 return;
210 }
211
212 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
213
214 ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor));
215
216 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900217 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
Aaron Haganaca50442021-12-07 22:26:29 -0500218 }
219
sjfricked700bc02022-05-30 16:35:06 +0900220 if (!AreRequiredExtensionsEnabled()) {
221 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
Aaron Haganaca50442021-12-07 22:26:29 -0500222 }
223
224 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +0900225 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
Aaron Haganaca50442021-12-07 22:26:29 -0500226 if (!dynamic_rendering_features.dynamicRendering) {
227 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
228 return;
229 }
230
231 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
232
233 const VkPipelineLayoutObj pl(m_device);
234 VkPipelineObj pipe(m_device);
235
236 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
237
238 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
239 color_blend_state_create_info.attachmentCount = 1;
240 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
241
242 VkFormat color_format[2] = {VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_D32_SFLOAT_S8_UINT};
243
244 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
245 pipeline_rendering_info.colorAttachmentCount = 2;
246 pipeline_rendering_info.pColorAttachmentFormats = &color_format[0];
247 pipeline_rendering_info.viewMask = 0x2;
Aaron Hagan80034ea2021-12-23 11:24:09 -0500248 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
Aaron Haganaca50442021-12-07 22:26:29 -0500249
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800250 auto pipeline_tessellation_state_info = LvlInitStruct<VkPipelineTessellationStateCreateInfo>();
Aaron Haganaca50442021-12-07 22:26:29 -0500251 pipeline_tessellation_state_info.patchControlPoints = 1;
252
253 auto pipeline_input_assembly_state_info = LvlInitStruct<VkPipelineInputAssemblyStateCreateInfo>();
254 pipeline_input_assembly_state_info.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST;
255
256 auto create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
Aaron Hagan80034ea2021-12-23 11:24:09 -0500257
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800258 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
259 VkShaderObj gs(this, bindStateGeomShaderText, VK_SHADER_STAGE_GEOMETRY_BIT);
260 VkShaderObj te(this, bindStateTeshaderText, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT);
261 VkShaderObj tc(this, bindStateTscShaderText, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT);
Aaron Hagan80034ea2021-12-23 11:24:09 -0500262 VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT);
263
Aaron Haganaca50442021-12-07 22:26:29 -0500264 pipe.AddShader(&vs);
265 pipe.AddShader(&gs);
266 pipe.AddShader(&te);
267 pipe.AddShader(&tc);
Aaron Hagan80034ea2021-12-23 11:24:09 -0500268 pipe.AddShader(&fs);
Aaron Haganaca50442021-12-07 22:26:29 -0500269 pipe.InitGraphicsPipelineCreateInfo(&create_info);
Nathaniel Cesario72f29552022-03-24 05:11:11 -0600270
Aaron Haganaca50442021-12-07 22:26:29 -0500271 create_info.pColorBlendState = &color_blend_state_create_info;
272 create_info.pNext = &pipeline_rendering_info;
273 create_info.pTessellationState = &pipeline_tessellation_state_info;
274 create_info.pInputAssemblyState = &pipeline_input_assembly_state_info;
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800275
Aaron Hagan80034ea2021-12-23 11:24:09 -0500276 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06053");
Nathaniel Cesario72f29552022-03-24 05:11:11 -0600277 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06581");
Aaron Haganaca50442021-12-07 22:26:29 -0500278 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06055");
279 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06057");
280 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06058");
Nathaniel Cesarioa6118572022-03-24 04:48:33 -0600281 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-multiview-06577");
Aaron Haganaca50442021-12-07 22:26:29 -0500282 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
283 m_errorMonitor->VerifyFound();
284
Aaron Hagan80034ea2021-12-23 11:24:09 -0500285 create_info.pColorBlendState = nullptr;
286 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
287 pipeline_rendering_info.viewMask = 0x0;
288 pipeline_rendering_info.colorAttachmentCount = 1;
289 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06054");
290 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
291 m_errorMonitor->VerifyFound();
Aaron Haganb54466d2022-02-18 15:02:54 -0500292
ziga-lunarg5e671602022-03-17 19:06:55 +0100293 color_format[0] = VK_FORMAT_D32_SFLOAT_S8_UINT;
294 color_blend_attachment_state.blendEnable = VK_TRUE;
295 create_info.pColorBlendState = &color_blend_state_create_info;
Nathaniel Cesario72f29552022-03-24 05:11:11 -0600296 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06581");
ziga-lunarg5e671602022-03-17 19:06:55 +0100297 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06062");
ziga-lunarg5e671602022-03-17 19:06:55 +0100298 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
299 m_errorMonitor->VerifyFound();
300 color_format[0] = VK_FORMAT_R8G8B8A8_UNORM;
301
Aaron Haganb54466d2022-02-18 15:02:54 -0500302 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
303 ds_ci.flags = VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM;
304 color_blend_state_create_info.flags = VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM;
305 create_info.pColorBlendState = &color_blend_state_create_info;
306 create_info.pDepthStencilState = &ds_ci;
307 create_info.renderPass = VK_NULL_HANDLE;
308 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
309 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06482");
310 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06483");
311 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
312 m_errorMonitor->VerifyFound();
stusmith15f24a82021-12-24 15:21:19 +0000313}
314
315TEST_F(VkLayerTest, DynamicRenderingWithMismatchingViewMask) {
316 TEST_DESCRIPTION("Draw with Dynamic Rendering and a mismatching viewMask");
317
318 SetTargetApiVersion(VK_API_VERSION_1_1);
319
320 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
321
322 ASSERT_NO_FATAL_FAILURE(InitFramework());
323
sjfricked700bc02022-05-30 16:35:06 +0900324 if (!AreRequiredExtensionsEnabled()) {
325 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
stusmith15f24a82021-12-24 15:21:19 +0000326 }
327
328 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900329 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
stusmith15f24a82021-12-24 15:21:19 +0000330 }
331
332 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
333 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(&multiview_features);
sjfricke11db0c72022-08-18 13:23:11 +0900334 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
stusmith15f24a82021-12-24 15:21:19 +0000335 if (!dynamic_rendering_features.dynamicRendering) {
336 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
337 return;
338 }
339 if (!multiview_features.multiview) {
340 printf("%s Test requires (unsupported) multiview , skipping\n", kSkipPrefix);
341 return;
342 }
343
344 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
345
346 char const *fsSource = R"glsl(
347 #version 450
348 layout(location=0) out vec4 color;
349 void main() {
350 color = vec4(1.0f);
351 }
352 )glsl";
353
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800354 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
355 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000356
357 VkPipelineObj pipe(m_device);
358 pipe.AddShader(&vs);
359 pipe.AddShader(&fs);
360 pipe.AddDefaultColorAttachment();
361
362 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
363 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
364 const VkPipelineLayoutObj pl(m_device, {&dsl});
365
366 VkFormat color_formats = {VK_FORMAT_R8G8B8A8_UNORM};
367 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
368 pipeline_rendering_info.colorAttachmentCount = 1;
369 pipeline_rendering_info.pColorAttachmentFormats = &color_formats;
370 pipeline_rendering_info.viewMask = 1;
371
372 VkViewport viewport = {0, 0, 16, 16, 0, 1};
373 VkRect2D scissor = {{0, 0}, {16, 16}};
374 m_viewports.push_back(viewport);
375 m_scissors.push_back(scissor);
376 pipe.SetViewport(m_viewports);
377 pipe.SetScissor(m_scissors);
378
379 auto create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
380 pipe.InitGraphicsPipelineCreateInfo(&create_info);
381 create_info.pNext = &pipeline_rendering_info;
382
383 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
384
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800385 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000386 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
387
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800388 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000389 begin_rendering_info.colorAttachmentCount = 1;
390 begin_rendering_info.pColorAttachments = &color_attachment;
391 begin_rendering_info.viewMask = 2;
392 begin_rendering_info.layerCount = 1;
393
394 m_commandBuffer->begin();
395 m_commandBuffer->BeginRendering(begin_rendering_info);
396 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle());
397 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-viewMask-06178");
398 m_commandBuffer->Draw(1, 1, 0, 0);
399 m_errorMonitor->VerifyFound();
400 m_commandBuffer->EndRendering();
401 m_commandBuffer->end();
402}
403
404TEST_F(VkLayerTest, DynamicRenderingWithMistmatchingAttachments) {
405 TEST_DESCRIPTION("Draw with Dynamic Rendering with mismatching color attachment counts and depth/stencil formats");
406
407 SetTargetApiVersion(VK_API_VERSION_1_1);
408
409 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
410
411 ASSERT_NO_FATAL_FAILURE(InitFramework());
412
sjfricked700bc02022-05-30 16:35:06 +0900413 if (!AreRequiredExtensionsEnabled()) {
414 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
stusmith15f24a82021-12-24 15:21:19 +0000415 }
416
417 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900418 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
stusmith15f24a82021-12-24 15:21:19 +0000419 }
420
421 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +0900422 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
stusmith15f24a82021-12-24 15:21:19 +0000423 if (!dynamic_rendering_features.dynamicRendering) {
424 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
425 return;
426 }
427
428 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
429
430 char const *fsSource = R"glsl(
431 #version 450
432 layout(location=0) out vec4 color;
433 void main() {
434 color = vec4(1.0f);
435 }
436 )glsl";
437
438 VkViewport viewport = {0, 0, 16, 16, 0, 1};
439 VkRect2D scissor = {{0, 0}, {16, 16}};
440 m_viewports.push_back(viewport);
441 m_scissors.push_back(scissor);
442
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800443 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
444 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000445
446 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
447 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
448 const VkPipelineLayoutObj pl(m_device, {&dsl});
449
450 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
451
452 VkPipelineObj pipe1(m_device);
453 pipe1.AddShader(&vs);
454 pipe1.AddShader(&fs);
455 pipe1.AddDefaultColorAttachment();
456 pipe1.SetViewport(m_viewports);
457 pipe1.SetScissor(m_scissors);
458
459 VkFormat color_formats[] = {VK_FORMAT_R8G8B8A8_UNORM};
460 pipeline_rendering_info.colorAttachmentCount = 1;
461 pipeline_rendering_info.pColorAttachmentFormats = color_formats;
462
463 auto create_info1 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
464 pipe1.InitGraphicsPipelineCreateInfo(&create_info1);
465 create_info1.pNext = &pipeline_rendering_info;
466
467 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
468
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600469 auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
470
stusmith15f24a82021-12-24 15:21:19 +0000471 VkPipelineObj pipe2(m_device);
472 pipe2.AddShader(&vs);
473 pipe2.AddShader(&fs);
474 pipe2.AddDefaultColorAttachment();
475 pipe2.SetViewport(m_viewports);
476 pipe2.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600477 pipe2.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000478
479 pipeline_rendering_info.colorAttachmentCount = 0;
480 pipeline_rendering_info.pColorAttachmentFormats = nullptr;
481 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_D16_UNORM;
482
483 auto create_info2 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
484 pipe2.InitGraphicsPipelineCreateInfo(&create_info2);
485 create_info2.pNext = &pipeline_rendering_info;
486
487 pipe2.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info2);
488
489 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
490 ASSERT_TRUE(depthStencilFormat != 0);
491
492 bool testStencil = false;
493 VkFormat stencilFormat = VK_FORMAT_UNDEFINED;
494
495 if (ImageFormatIsSupported(gpu(), VK_FORMAT_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
496 stencilFormat = VK_FORMAT_S8_UINT;
497 testStencil = true;
498 } else if ((depthStencilFormat != VK_FORMAT_D16_UNORM_S8_UINT) &&
499 ImageFormatIsSupported(gpu(), VK_FORMAT_D16_UNORM_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
500 stencilFormat = VK_FORMAT_D16_UNORM_S8_UINT;
501 testStencil = true;
502 } else if ((depthStencilFormat != VK_FORMAT_D24_UNORM_S8_UINT) &&
503 ImageFormatIsSupported(gpu(), VK_FORMAT_D24_UNORM_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
504 stencilFormat = VK_FORMAT_D24_UNORM_S8_UINT;
505 testStencil = true;
506 } else if ((depthStencilFormat != VK_FORMAT_D32_SFLOAT_S8_UINT) &&
507 ImageFormatIsSupported(gpu(), VK_FORMAT_D32_SFLOAT_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
508 stencilFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
509 testStencil = true;
510 }
511
512 VkPipelineObj pipe3(m_device);
513
514 if (testStencil) {
515 pipe3.AddShader(&vs);
516 pipe3.AddShader(&fs);
517 pipe3.AddDefaultColorAttachment();
518 pipe3.SetViewport(m_viewports);
519 pipe3.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600520 pipe3.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000521
522 pipeline_rendering_info.colorAttachmentCount = 0;
523 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
524 pipeline_rendering_info.stencilAttachmentFormat = stencilFormat;
525
526 auto create_info3 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
527 pipe3.InitGraphicsPipelineCreateInfo(&create_info3);
528 create_info3.pNext = &pipeline_rendering_info;
529
530 pipe3.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info3);
531 }
532
533 VkImageObj colorImage(m_device);
534 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
535 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
536
537 VkImageObj depthStencilImage(m_device);
538 depthStencilImage.Init(32, 32, 1, depthStencilFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
539 VkImageView depthStencilImageView =
540 depthStencilImage.targetView(depthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
541
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800542 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000543 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
544 color_attachment.imageView = colorImageView;
545
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800546 VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000547 depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
548 depth_stencil_attachment.imageView = depthStencilImageView;
549
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800550 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600551 begin_rendering_info.layerCount = 1;
stusmith15f24a82021-12-24 15:21:19 +0000552 m_commandBuffer->begin();
553
554 // Mismatching color attachment count
555 m_commandBuffer->BeginRendering(begin_rendering_info);
556 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
557 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06179");
558 m_commandBuffer->Draw(1, 1, 0, 0);
559 m_errorMonitor->VerifyFound();
560 m_commandBuffer->EndRendering();
561
562 // Mismatching color formats
563 begin_rendering_info.colorAttachmentCount = 1;
564 begin_rendering_info.pColorAttachments = &color_attachment;
565 m_commandBuffer->BeginRendering(begin_rendering_info);
566 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
567 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06180");
568 m_commandBuffer->Draw(1, 1, 0, 0);
569 m_errorMonitor->VerifyFound();
570 m_commandBuffer->EndRendering();
571
572 // Mismatching depth format
573 begin_rendering_info.colorAttachmentCount = 0;
574 begin_rendering_info.pColorAttachments = nullptr;
575 begin_rendering_info.pDepthAttachment = &depth_stencil_attachment;
576 m_commandBuffer->BeginRendering(begin_rendering_info);
577 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.handle());
578 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06181");
579 m_commandBuffer->Draw(1, 1, 0, 0);
580 m_errorMonitor->VerifyFound();
581 m_commandBuffer->EndRendering();
582
583 // Mismatching stencil format
584 if (testStencil) {
585 begin_rendering_info.pDepthAttachment = nullptr;
586 begin_rendering_info.pStencilAttachment = &depth_stencil_attachment;
587 m_commandBuffer->BeginRendering(begin_rendering_info);
588 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe3.handle());
589 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06182");
590 m_commandBuffer->Draw(1, 1, 0, 0);
591 m_errorMonitor->VerifyFound();
592 m_commandBuffer->EndRendering();
593 }
594
595 m_commandBuffer->end();
596}
597
598TEST_F(VkLayerTest, DynamicRenderingWithMistmatchingAttachmentSamples) {
599 TEST_DESCRIPTION("Draw with Dynamic Rendering with mismatching color/depth/stencil sample counts");
600
601 SetTargetApiVersion(VK_API_VERSION_1_1);
602
603 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
604
605 ASSERT_NO_FATAL_FAILURE(InitFramework());
606
sjfricked700bc02022-05-30 16:35:06 +0900607 if (!AreRequiredExtensionsEnabled()) {
608 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
stusmith15f24a82021-12-24 15:21:19 +0000609 }
610
611 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900612 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
stusmith15f24a82021-12-24 15:21:19 +0000613 }
614
615 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +0900616 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
stusmith15f24a82021-12-24 15:21:19 +0000617 if (!dynamic_rendering_features.dynamicRendering) {
618 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
619 return;
620 }
621
622 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
623
624 char const *fsSource = R"glsl(
625 #version 450
626 layout(location=0) out vec4 color;
627 void main() {
628 color = vec4(1.0f);
629 }
630 )glsl";
631
632 VkViewport viewport = {0, 0, 16, 16, 0, 1};
633 VkRect2D scissor = {{0, 0}, {16, 16}};
634 m_viewports.push_back(viewport);
635 m_scissors.push_back(scissor);
636
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800637 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
638 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000639
640 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
641 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
642 const VkPipelineLayoutObj pl(m_device, {&dsl});
643
644 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
645
stusmith15f24a82021-12-24 15:21:19 +0000646 VkPipelineObj pipe1(m_device);
647 pipe1.AddShader(&vs);
648 pipe1.AddShader(&fs);
649 pipe1.AddDefaultColorAttachment();
650 pipe1.SetViewport(m_viewports);
651 pipe1.SetScissor(m_scissors);
652
653 VkFormat color_formats[] = {VK_FORMAT_R8G8B8A8_UNORM};
654 pipeline_rendering_info.colorAttachmentCount = 1;
655 pipeline_rendering_info.pColorAttachmentFormats = color_formats;
656
657 auto create_info1 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
658 pipe1.InitGraphicsPipelineCreateInfo(&create_info1);
659 create_info1.pNext = &pipeline_rendering_info;
660
661 auto multisample_state_create_info = LvlInitStruct<VkPipelineMultisampleStateCreateInfo>();
662 multisample_state_create_info.rasterizationSamples = VK_SAMPLE_COUNT_2_BIT;
663 create_info1.pMultisampleState = &multisample_state_create_info;
664
665 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
666
stusmith15f24a82021-12-24 15:21:19 +0000667 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
668 ASSERT_TRUE(depthStencilFormat != 0);
669
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600670 auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
671
stusmith15f24a82021-12-24 15:21:19 +0000672 VkPipelineObj pipe2(m_device);
673 pipe2.AddShader(&vs);
674 pipe2.AddShader(&fs);
675 pipe2.AddDefaultColorAttachment();
676 pipe2.SetViewport(m_viewports);
677 pipe2.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600678 pipe2.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000679
680 pipeline_rendering_info.colorAttachmentCount = 0;
681 pipeline_rendering_info.pColorAttachmentFormats = nullptr;
682 pipeline_rendering_info.depthAttachmentFormat = depthStencilFormat;
683
684 auto create_info2 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
685 pipe2.InitGraphicsPipelineCreateInfo(&create_info2);
686 create_info2.pNext = &pipeline_rendering_info;
687
688 create_info2.pMultisampleState = &multisample_state_create_info;
689
690 pipe2.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info2);
691
stusmith15f24a82021-12-24 15:21:19 +0000692 VkPipelineObj pipe3(m_device);
693
694 pipe3.AddShader(&vs);
695 pipe3.AddShader(&fs);
696 pipe3.AddDefaultColorAttachment();
697 pipe3.SetViewport(m_viewports);
698 pipe3.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600699 pipe3.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000700
701 pipeline_rendering_info.colorAttachmentCount = 0;
702 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
703 pipeline_rendering_info.stencilAttachmentFormat = depthStencilFormat;
704
705 auto create_info3 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
706 pipe3.InitGraphicsPipelineCreateInfo(&create_info3);
707 create_info3.pNext = &pipeline_rendering_info;
708
709 create_info3.pMultisampleState = &multisample_state_create_info;
710
711 pipe3.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info3);
712
stusmith15f24a82021-12-24 15:21:19 +0000713 VkImageObj colorImage(m_device);
714 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
715 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UNORM);
716
717 VkImageObj depthStencilImage(m_device);
718 depthStencilImage.Init(32, 32, 1, depthStencilFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
719 VkImageView depthStencilImageView =
720 depthStencilImage.targetView(depthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
721
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800722 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000723 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
724 color_attachment.imageView = colorImageView;
725
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800726 VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000727 depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
728 depth_stencil_attachment.imageView = depthStencilImageView;
729
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800730 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600731 begin_rendering_info.layerCount = 1;
stusmith15f24a82021-12-24 15:21:19 +0000732 m_commandBuffer->begin();
733
734 // Mismatching color samples
735 begin_rendering_info.colorAttachmentCount = 1;
736 begin_rendering_info.pColorAttachments = &color_attachment;
737 m_commandBuffer->BeginRendering(begin_rendering_info);
738 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
739 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06188");
740 m_commandBuffer->Draw(1, 1, 0, 0);
741 m_errorMonitor->VerifyFound();
742 m_commandBuffer->EndRendering();
743
744 // Mismatching depth samples
745 begin_rendering_info.colorAttachmentCount = 0;
746 begin_rendering_info.pColorAttachments = nullptr;
747 begin_rendering_info.pDepthAttachment = &depth_stencil_attachment;
748 m_commandBuffer->BeginRendering(begin_rendering_info);
749 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.handle());
750 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06189");
751 m_commandBuffer->Draw(1, 1, 0, 0);
752 m_errorMonitor->VerifyFound();
753 m_commandBuffer->EndRendering();
754
755 // Mismatching stencil samples
756 begin_rendering_info.pDepthAttachment = nullptr;
757 begin_rendering_info.pStencilAttachment = &depth_stencil_attachment;
758 m_commandBuffer->BeginRendering(begin_rendering_info);
759 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe3.handle());
760 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06190");
761 m_commandBuffer->Draw(1, 1, 0, 0);
762 m_errorMonitor->VerifyFound();
763 m_commandBuffer->EndRendering();
764
765 m_commandBuffer->end();
766}
767
ziga-lunarga3cc8482022-04-29 14:58:29 +0200768TEST_F(VkLayerTest, DynamicRenderingWithMismatchingMixedAttachmentSamples) {
stusmith15f24a82021-12-24 15:21:19 +0000769 TEST_DESCRIPTION("Draw with Dynamic Rendering with mismatching mixed color/depth/stencil sample counts");
770
771 SetTargetApiVersion(VK_API_VERSION_1_1);
772
773 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
774
775 ASSERT_NO_FATAL_FAILURE(InitFramework());
776
sjfricked700bc02022-05-30 16:35:06 +0900777 if (!AreRequiredExtensionsEnabled()) {
778 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
stusmith15f24a82021-12-24 15:21:19 +0000779 }
780
781 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900782 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
stusmith15f24a82021-12-24 15:21:19 +0000783 }
784
785 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +0900786 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
stusmith15f24a82021-12-24 15:21:19 +0000787 if (!dynamic_rendering_features.dynamicRendering) {
788 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
789 return;
790 }
791
792 bool amd_samples = false;
793 if (DeviceExtensionSupported(gpu(), nullptr, VK_AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME)) {
794 m_device_extension_names.push_back(VK_AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME);
795 amd_samples = true;
796 }
797
798 bool nv_samples = false;
799 if (DeviceExtensionSupported(gpu(), nullptr, VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME)) {
800 m_device_extension_names.push_back(VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME);
801 nv_samples = true;
802 }
803
804 if (!amd_samples && !nv_samples) {
805 printf("%s Test requires either VK_AMD_mixed_attachment_samples or VK_NV_framebuffer_mixed_samples, skipping\n",
806 kSkipPrefix);
807 return;
808 }
809
810 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
811
812 char const *fsSource = R"glsl(
813 #version 450
814 layout(location=0) out vec4 color;
815 void main() {
816 color = vec4(1.0f);
817 }
818 )glsl";
819
820 VkViewport viewport = {0, 0, 16, 16, 0, 1};
821 VkRect2D scissor = {{0, 0}, {16, 16}};
822 m_viewports.push_back(viewport);
823 m_scissors.push_back(scissor);
824
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800825 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
826 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000827
828 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
829 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
830 const VkPipelineLayoutObj pl(m_device, {&dsl});
831
ziga-lunarga3cc8482022-04-29 14:58:29 +0200832 VkSampleCountFlagBits counts[2] = {VK_SAMPLE_COUNT_2_BIT, VK_SAMPLE_COUNT_2_BIT};
stusmith15f24a82021-12-24 15:21:19 +0000833 auto samples_info = LvlInitStruct<VkAttachmentSampleCountInfoAMD>();
834
835 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(&samples_info);
836
837 VkPipelineObj pipe1(m_device);
838 pipe1.AddShader(&vs);
839 pipe1.AddShader(&fs);
840 pipe1.AddDefaultColorAttachment();
841 pipe1.SetViewport(m_viewports);
842 pipe1.SetScissor(m_scissors);
843
844 VkFormat color_formats[] = {VK_FORMAT_R8G8B8A8_UNORM};
845 pipeline_rendering_info.colorAttachmentCount = 1;
846 pipeline_rendering_info.pColorAttachmentFormats = color_formats;
847
848 samples_info.colorAttachmentCount = 1;
ziga-lunarga3cc8482022-04-29 14:58:29 +0200849 samples_info.pColorAttachmentSamples = counts;
stusmith15f24a82021-12-24 15:21:19 +0000850
851 auto create_info1 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
852 pipe1.InitGraphicsPipelineCreateInfo(&create_info1);
853 create_info1.pNext = &pipeline_rendering_info;
854
Aaron Haganb54466d2022-02-18 15:02:54 -0500855 samples_info.colorAttachmentCount = 2;
856 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06063");
857 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
858 m_errorMonitor->VerifyFound();
859
860 samples_info.colorAttachmentCount = 1;
stusmith15f24a82021-12-24 15:21:19 +0000861 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
862
863 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
864 ASSERT_TRUE(depthStencilFormat != 0);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600865 auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
stusmith15f24a82021-12-24 15:21:19 +0000866
867 VkPipelineObj pipe2(m_device);
868 pipe2.AddShader(&vs);
869 pipe2.AddShader(&fs);
870 pipe2.AddDefaultColorAttachment();
871 pipe2.SetViewport(m_viewports);
872 pipe2.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600873 pipe2.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000874
875 pipeline_rendering_info.colorAttachmentCount = 0;
876 pipeline_rendering_info.pColorAttachmentFormats = nullptr;
877 pipeline_rendering_info.depthAttachmentFormat = depthStencilFormat;
878
879 samples_info.colorAttachmentCount = 0;
880 samples_info.pColorAttachmentSamples = nullptr;
ziga-lunarga3cc8482022-04-29 14:58:29 +0200881 samples_info.depthStencilAttachmentSamples = counts[0];
stusmith15f24a82021-12-24 15:21:19 +0000882
883 auto create_info2 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
884 pipe2.InitGraphicsPipelineCreateInfo(&create_info2);
885 create_info2.pNext = &pipeline_rendering_info;
886
887 pipe2.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info2);
888
889 VkPipelineObj pipe3(m_device);
890
891 pipe3.AddShader(&vs);
892 pipe3.AddShader(&fs);
893 pipe3.AddDefaultColorAttachment();
894 pipe3.SetViewport(m_viewports);
895 pipe3.SetScissor(m_scissors);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600896 pipe3.SetDepthStencil(&ds_state);
stusmith15f24a82021-12-24 15:21:19 +0000897
898 pipeline_rendering_info.colorAttachmentCount = 0;
899 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
900 pipeline_rendering_info.stencilAttachmentFormat = depthStencilFormat;
901
902 auto create_info3 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
903 pipe3.InitGraphicsPipelineCreateInfo(&create_info3);
904 create_info3.pNext = &pipeline_rendering_info;
905
906 pipe3.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info3);
907
908 VkImageObj colorImage(m_device);
909 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
910 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UNORM);
911
912 VkImageObj depthStencilImage(m_device);
913 depthStencilImage.Init(32, 32, 1, depthStencilFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
914 VkImageView depthStencilImageView =
915 depthStencilImage.targetView(depthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
916
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800917 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000918 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
919 color_attachment.imageView = colorImageView;
920
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800921 VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000922 depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
923 depth_stencil_attachment.imageView = depthStencilImageView;
924
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800925 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000926 m_commandBuffer->begin();
927
928 // Mismatching color samples
929 begin_rendering_info.colorAttachmentCount = 1;
930 begin_rendering_info.pColorAttachments = &color_attachment;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600931 begin_rendering_info.layerCount = 1;
stusmith15f24a82021-12-24 15:21:19 +0000932 m_commandBuffer->BeginRendering(begin_rendering_info);
933 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
934 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06185");
935 m_commandBuffer->Draw(1, 1, 0, 0);
936 m_errorMonitor->VerifyFound();
937 m_commandBuffer->EndRendering();
938
939 // Mismatching depth samples
940 begin_rendering_info.colorAttachmentCount = 0;
941 begin_rendering_info.pColorAttachments = nullptr;
942 begin_rendering_info.pDepthAttachment = &depth_stencil_attachment;
943 m_commandBuffer->BeginRendering(begin_rendering_info);
944 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.handle());
945 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06186");
946 m_commandBuffer->Draw(1, 1, 0, 0);
947 m_errorMonitor->VerifyFound();
948 m_commandBuffer->EndRendering();
949
950 // Mismatching stencil samples
951 begin_rendering_info.pDepthAttachment = nullptr;
952 begin_rendering_info.pStencilAttachment = &depth_stencil_attachment;
953 m_commandBuffer->BeginRendering(begin_rendering_info);
954 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe3.handle());
955 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06187");
956 m_commandBuffer->Draw(1, 1, 0, 0);
957 m_errorMonitor->VerifyFound();
958 m_commandBuffer->EndRendering();
959
960 m_commandBuffer->end();
961}
Aaron Hagan80034ea2021-12-23 11:24:09 -0500962
963TEST_F(VkLayerTest, DynamicRenderingAttachmentInfo) {
964 TEST_DESCRIPTION("AttachmentInfo Dynamic Rendering Tests.");
965
966 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2);
967 if (version < VK_API_VERSION_1_2) {
968 printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix);
969 return;
970 }
971
972 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
973
974 ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor));
975
976 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
sjfrickebdd58dd2022-05-20 14:22:50 +0900977 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
Aaron Hagan80034ea2021-12-23 11:24:09 -0500978 }
979
sjfricked700bc02022-05-30 16:35:06 +0900980 if (!AreRequiredExtensionsEnabled()) {
981 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
Aaron Hagan80034ea2021-12-23 11:24:09 -0500982 }
983
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600984 auto fdm_features = LvlInitStruct<VkPhysicalDeviceFragmentDensityMapFeaturesEXT>();
985 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(&fdm_features);
986 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
Aaron Hagan80034ea2021-12-23 11:24:09 -0500987 if (!dynamic_rendering_features.dynamicRendering) {
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600988 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering , skipping";
989 }
990 if (!fdm_features.fragmentDensityMapNonSubsampledImages) {
991 GTEST_SKIP() << "fragmentDensityMapNonSubsampledImages not supported.";
Aaron Hagan80034ea2021-12-23 11:24:09 -0500992 }
993
994 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
995
996 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
997 VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT);
998
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -0600999 auto ds_state = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
1000
Aaron Hagan80034ea2021-12-23 11:24:09 -05001001 VkPipelineObj pipe(m_device);
1002 pipe.AddShader(&vs);
1003 pipe.AddShader(&fs);
1004 pipe.AddDefaultColorAttachment();
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001005 pipe.SetDepthStencil(&ds_state);
Aaron Hagan80034ea2021-12-23 11:24:09 -05001006
1007 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
1008 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
1009 const VkPipelineLayoutObj pl(m_device, {&dsl});
1010
1011 VkFormat depth_format = VK_FORMAT_D32_SFLOAT_S8_UINT;
1012 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
1013 pipeline_rendering_info.depthAttachmentFormat = depth_format;
1014
1015 auto pipeline_create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
1016 pipe.InitGraphicsPipelineCreateInfo(&pipeline_create_info);
1017 pipeline_create_info.pNext = &pipeline_rendering_info;
1018
1019 VkResult err = pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &pipeline_create_info);
1020 ASSERT_VK_SUCCESS(err);
1021
1022 VkImageObj image(m_device);
1023 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
1024 image_create_info.imageType = VK_IMAGE_TYPE_2D;
1025 image_create_info.format = depth_format;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001026 image_create_info.extent = {64, 64, 1};
Aaron Hagan80034ea2021-12-23 11:24:09 -05001027 image_create_info.mipLevels = 1;
1028 image_create_info.arrayLayers = 1;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001029 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
Aaron Hagan80034ea2021-12-23 11:24:09 -05001030 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
ziga-lunarga3cc8482022-04-29 14:58:29 +02001031 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 -05001032 image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
1033
1034 image.Init(image_create_info);
1035 ASSERT_TRUE(image.initialized());
1036
1037 VkImageViewCreateInfo ivci = {VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
1038 nullptr,
1039 0,
1040 image.handle(),
1041 VK_IMAGE_VIEW_TYPE_2D,
1042 depth_format,
1043 {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
1044 VK_COMPONENT_SWIZZLE_IDENTITY},
1045 {VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, 0, 1, 0, 1}};
1046
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001047 VkImageView depth_image_view = image.targetView(ivci);
1048 ASSERT_NE(depth_image_view, VK_NULL_HANDLE);
Aaron Hagan80034ea2021-12-23 11:24:09 -05001049
1050 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1051 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
1052 depth_attachment.imageView = depth_image_view;
1053 depth_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
1054 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
1055
1056 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
1057 begin_rendering_info.pDepthAttachment = &depth_attachment;
1058 begin_rendering_info.viewMask = 0x4;
1059
1060 VkRenderingFragmentDensityMapAttachmentInfoEXT fragment_density_map =
1061 LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
1062 fragment_density_map.imageView = depth_image_view;
ziga-lunarga3cc8482022-04-29 14:58:29 +02001063 fragment_density_map.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
Aaron Hagan80034ea2021-12-23 11:24:09 -05001064 begin_rendering_info.pNext = &fragment_density_map;
1065
1066 m_commandBuffer->begin();
1067 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-multiview-06127");
Jeremy Gebben09c1a072022-02-08 09:42:47 -07001068 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06107");
1069 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06108");
1070 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06116");
Jeremy Gebben09c1a072022-02-08 09:42:47 -07001071 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06145");
1072 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06146");
Aaron Hagan80034ea2021-12-23 11:24:09 -05001073 m_commandBuffer->BeginRendering(begin_rendering_info);
1074 m_errorMonitor->VerifyFound();
1075}
Aaron Haganb54466d2022-02-18 15:02:54 -05001076
1077TEST_F(VkLayerTest, DynamicRenderingBufferBeginInfoLegacy) {
1078 TEST_DESCRIPTION("VkCommandBufferBeginInfo Dynamic Rendering Tests.");
1079
1080 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2);
1081 if (version < VK_API_VERSION_1_2) {
1082 printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix);
1083 return;
1084 }
1085
1086 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1087
1088 ASSERT_NO_FATAL_FAILURE(Init(nullptr, nullptr, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1089
1090 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001091 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
Aaron Haganb54466d2022-02-18 15:02:54 -05001092 }
1093
sjfricked700bc02022-05-30 16:35:06 +09001094 if (!AreRequiredExtensionsEnabled()) {
1095 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
Aaron Haganb54466d2022-02-18 15:02:54 -05001096 }
1097
1098 auto cmd_buffer_inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>();
1099 cmd_buffer_inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
1100
1101 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
1102 cmd_buffer_inheritance_info.pNext = &cmd_buffer_inheritance_rendering_info;
1103 cmd_buffer_inheritance_info.renderPass = VK_NULL_HANDLE;
1104
1105 auto cmd_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>();
1106 cmd_buffer_allocate_info.commandPool = m_commandPool->handle();
1107 cmd_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY;
1108 cmd_buffer_allocate_info.commandBufferCount = 0x1;
1109
1110 VkCommandBuffer secondary_cmd_buffer;
1111 VkResult err = vk::AllocateCommandBuffers(m_device->device(), &cmd_buffer_allocate_info, &secondary_cmd_buffer);
1112 ASSERT_VK_SUCCESS(err);
1113
1114 // Invalid RenderPass
1115 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-00053");
1116 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
1117 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
1118 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
1119 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
1120 m_errorMonitor->VerifyFound();
1121
1122 // Valid RenderPass
1123 VkAttachmentDescription attach[] = {
1124 {0, VK_FORMAT_B8G8R8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE,
1125 VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_IMAGE_LAYOUT_UNDEFINED,
1126 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL},
1127 };
1128 VkAttachmentReference att_ref = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL};
1129
1130 VkSubpassDescription subpass = {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &att_ref, nullptr, nullptr, 0, nullptr};
1131 VkRenderPassCreateInfo rpci = {VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, 0, 1, attach, 1, &subpass, 0, nullptr};
1132
1133 vk_testing::RenderPass rp1;
1134 rp1.init(*m_device, rpci);
1135
1136 cmd_buffer_inheritance_info.renderPass = rp1.handle();
1137 cmd_buffer_inheritance_info.subpass = 0x5;
1138 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-00054");
1139 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
1140 m_errorMonitor->VerifyFound();
1141}
1142
1143TEST_F(VkLayerTest, DynamicRenderingSecondaryCommandBuffer) {
1144 TEST_DESCRIPTION("VkCommandBufferBeginInfo Dynamic Rendering Tests.");
1145
1146 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_3);
1147 if (version < VK_API_VERSION_1_3) {
1148 printf("%s At least Vulkan version 1.3 is required, skipping test.\n", kSkipPrefix);
1149 return;
1150 }
1151
1152 ASSERT_NO_FATAL_FAILURE(Init());
1153
1154 if (DeviceValidationVersion() < VK_API_VERSION_1_3) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001155 GTEST_SKIP() << "At least Vulkan version 1.3 is required";
Aaron Haganb54466d2022-02-18 15:02:54 -05001156 }
1157
1158 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
1159
1160 // Force the failure by not setting the Renderpass and Framebuffer fields
1161 VkCommandBufferInheritanceInfo cmd_buf_hinfo = LvlInitStruct<VkCommandBufferInheritanceInfo>();
1162 cmd_buf_hinfo.renderPass = VkRenderPass(0x1);
1163 VkCommandBufferBeginInfo cmd_buf_info = LvlInitStruct<VkCommandBufferBeginInfo>();
1164 cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
1165 cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo;
1166
1167 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06000");
1168 vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info);
1169 m_errorMonitor->VerifyFound();
1170
1171 // Valid RenderPass
1172 VkAttachmentDescription attach[] = {
1173 {0, VK_FORMAT_B8G8R8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE,
1174 VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_IMAGE_LAYOUT_UNDEFINED,
1175 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL},
1176 };
1177 VkAttachmentReference att_ref = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL};
1178
1179 VkSubpassDescription subpass = {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &att_ref, nullptr, nullptr, 0, nullptr};
1180 VkRenderPassCreateInfo rpci = {VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, 0, 1, attach, 1, &subpass, 0, nullptr};
1181
1182 vk_testing::RenderPass rp1;
1183 rp1.init(*m_device, rpci);
1184
1185 cmd_buf_hinfo.renderPass = rp1.handle();
1186 cmd_buf_hinfo.subpass = 0x5;
1187 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06001");
1188 vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info);
1189 m_errorMonitor->VerifyFound();
1190
1191 cmd_buf_hinfo.renderPass = VK_NULL_HANDLE;
1192 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06002");
1193 vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info);
1194 m_errorMonitor->VerifyFound();
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001195}
1196
1197TEST_F(VkLayerTest, TestDynamicRenderingPipelineMissingFlags) {
1198 TEST_DESCRIPTION("Test dynamic rendering with pipeline missing flags.");
1199
1200 SetTargetApiVersion(VK_API_VERSION_1_1);
1201 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001202 AddOptionalExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1203 AddOptionalExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001204
1205 ASSERT_NO_FATAL_FAILURE(InitFramework());
1206
1207 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001208 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001209 }
1210
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001211 if (!IsExtensionsEnabled(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
sjfricked700bc02022-05-30 16:35:06 +09001212 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001213 }
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001214 bool fragment_density = IsExtensionsEnabled(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1215 bool shading_rate = IsExtensionsEnabled(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001216
1217 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09001218 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001219 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001220 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001221 }
1222
1223 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
1224
1225 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
sjfricke74a1aad2022-08-17 14:41:33 +09001226 GetPhysicalDeviceProperties2(phys_dev_props_2);
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001227
1228 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1229 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
1230
1231 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
1232 ASSERT_TRUE(depthStencilFormat != 0);
1233
1234 VkImageObj image(m_device);
1235 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
1236 image_create_info.imageType = VK_IMAGE_TYPE_2D;
1237 image_create_info.format = depthStencilFormat;
1238 image_create_info.extent = {64, 64, 1};
1239 image_create_info.mipLevels = 1;
1240 image_create_info.arrayLayers = 1;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001241 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001242 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
Tony-LunarGbc7a5372022-08-16 08:53:14 -06001243 image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001244 image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
1245
Tony-LunarGbc7a5372022-08-16 08:53:14 -06001246 if (shading_rate) image_create_info.usage |= VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR;
1247
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001248 image.Init(image_create_info);
1249 ASSERT_TRUE(image.initialized());
1250
1251 VkImageViewCreateInfo ivci = {VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
1252 nullptr,
1253 0,
1254 image.handle(),
1255 VK_IMAGE_VIEW_TYPE_2D,
1256 depthStencilFormat,
1257 {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
1258 VK_COMPONENT_SWIZZLE_IDENTITY},
1259 {VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, 0, 1, 0, 1}};
1260
1261 vk_testing::ImageView depth_image_view;
1262 depth_image_view.init(*m_device, ivci);
1263
1264 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1265 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1266
1267 if (shading_rate) {
1268 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-imageView-06183");
1269 VkRenderingFragmentShadingRateAttachmentInfoKHR fragment_shading_rate =
1270 LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
1271 fragment_shading_rate.imageView = depth_image_view.handle();
1272 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1273 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
1274
1275 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
ziga-lunargaa97cbb2022-03-18 19:06:35 +01001276 begin_rendering_info.layerCount = 1;
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001277 begin_rendering_info.colorAttachmentCount = 1;
1278 begin_rendering_info.pColorAttachments = &color_attachment;
1279
1280 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
1281
1282 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
1283 pipeline_rendering_info.colorAttachmentCount = 1;
1284 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
1285
1286 CreatePipelineHelper pipe(*this);
1287 pipe.InitInfo();
1288 pipe.gp_ci_.pNext = &pipeline_rendering_info;
1289 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
1290 pipe.InitState();
1291 pipe.CreateGraphicsPipeline();
1292
1293 m_commandBuffer->begin();
1294 m_commandBuffer->BeginRendering(begin_rendering_info);
1295 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_);
1296 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
1297 m_commandBuffer->EndRendering();
1298 m_commandBuffer->end();
1299
1300 m_errorMonitor->VerifyFound();
1301 }
1302
1303 if (fragment_density) {
1304 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-imageView-06184");
1305 VkRenderingFragmentDensityMapAttachmentInfoEXT fragment_density_map =
1306 LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
1307 fragment_density_map.imageView = depth_image_view.handle();
1308
1309 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_density_map);
ziga-lunargaa97cbb2022-03-18 19:06:35 +01001310 begin_rendering_info.layerCount = 1;
ziga-lunarg6c8f1622022-03-14 20:14:04 +01001311 begin_rendering_info.colorAttachmentCount = 1;
1312 begin_rendering_info.pColorAttachments = &color_attachment;
1313
1314 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
1315
1316 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
1317 pipeline_rendering_info.colorAttachmentCount = 1;
1318 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
1319
1320 CreatePipelineHelper pipe(*this);
1321 pipe.InitInfo();
1322 pipe.gp_ci_.pNext = &pipeline_rendering_info;
1323 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
1324 pipe.InitState();
1325 pipe.CreateGraphicsPipeline();
1326
1327 m_commandBuffer->begin();
1328 m_commandBuffer->BeginRendering(begin_rendering_info);
1329 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_);
1330 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
1331 m_commandBuffer->EndRendering();
1332 m_commandBuffer->end();
1333
1334 m_errorMonitor->VerifyFound();
1335 }
1336}
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001337
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001338TEST_F(VkLayerTest, DynamicRenderingLayerCount) {
1339 TEST_DESCRIPTION("Test dynamic rendering with viewMask 0 and invalid layer count.");
1340
1341 SetTargetApiVersion(VK_API_VERSION_1_1);
1342 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1343
1344 ASSERT_NO_FATAL_FAILURE(InitFramework());
1345
1346 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001347 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001348 }
1349
1350 if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
sjfricked700bc02022-05-30 16:35:06 +09001351 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001352 }
1353
1354 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09001355 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001356 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001357 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg2c9067e2022-03-18 18:33:52 +01001358 }
1359
1360 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1361
1362 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
1363
1364 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-viewMask-06069");
1365 m_commandBuffer->begin();
1366 m_commandBuffer->BeginRendering(begin_rendering_info);
1367 m_commandBuffer->end();
1368 m_errorMonitor->VerifyFound();
1369}
1370
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001371TEST_F(VkLayerTest, TestRenderingInfoMismatchedSamples) {
1372 TEST_DESCRIPTION("Test beginning rendering with mismatched sample counts.");
1373
1374 SetTargetApiVersion(VK_API_VERSION_1_1);
1375 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1376
1377 ASSERT_NO_FATAL_FAILURE(InitFramework());
1378
1379 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001380 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001381 }
1382
1383 if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
sjfricked700bc02022-05-30 16:35:06 +09001384 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001385 }
1386
1387 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09001388 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001389 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001390 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001391 }
1392
1393 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1394
1395 VkImageCreateInfo image_ci = LvlInitStruct<VkImageCreateInfo>();
1396 image_ci.imageType = VK_IMAGE_TYPE_2D;
1397 image_ci.format = VK_FORMAT_R8G8B8A8_UNORM;
1398 image_ci.extent.width = 64;
1399 image_ci.extent.height = 64;
1400 image_ci.extent.depth = 1;
1401 image_ci.mipLevels = 1;
1402 image_ci.arrayLayers = 1;
1403 image_ci.samples = VK_SAMPLE_COUNT_2_BIT;
1404 image_ci.tiling = VK_IMAGE_TILING_OPTIMAL;
1405 image_ci.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
1406
1407 VkImageObj color_image(m_device);
1408 color_image.init(&image_ci);
1409
1410 VkImageViewCreateInfo civ_ci = LvlInitStruct<VkImageViewCreateInfo>();
1411 civ_ci.image = color_image.handle();
1412 civ_ci.viewType = VK_IMAGE_VIEW_TYPE_2D;
1413 civ_ci.format = VK_FORMAT_R8G8B8A8_UNORM;
1414 civ_ci.subresourceRange.layerCount = 1;
1415 civ_ci.subresourceRange.baseMipLevel = 0;
1416 civ_ci.subresourceRange.levelCount = 1;
1417 civ_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
1418
1419 vk_testing::ImageView color_image_view;
1420 color_image_view.init(*m_device, civ_ci);
1421
1422 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1423 color_attachment.imageView = color_image_view.handle();
1424 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1425 color_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
1426
1427 const VkFormat depth_format = FindSupportedDepthOnlyFormat(gpu());
1428 if (depth_format == VK_FORMAT_UNDEFINED) {
1429 printf("%s requires a depth only format, skipping.\n", kSkipPrefix);
1430 return;
1431 }
1432
1433 VkImageObj depth_image(m_device);
1434 depth_image.Init(64, 64, 1, depth_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL);
1435
1436 VkImageViewCreateInfo div_ci = LvlInitStruct<VkImageViewCreateInfo>();
1437 div_ci.image = depth_image.handle();
1438 div_ci.viewType = VK_IMAGE_VIEW_TYPE_2D;
1439 div_ci.format = depth_format;
1440 div_ci.subresourceRange.layerCount = 1;
1441 div_ci.subresourceRange.baseMipLevel = 0;
1442 div_ci.subresourceRange.levelCount = 1;
1443 div_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
1444
1445 vk_testing::ImageView depth_image_view;
1446 depth_image_view.init(*m_device, div_ci);
1447
1448 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1449 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1450 depth_attachment.imageView = depth_image_view.handle();
1451 depth_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
1452
1453 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
ziga-lunargaa97cbb2022-03-18 19:06:35 +01001454 begin_rendering_info.layerCount = 1;
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001455 begin_rendering_info.colorAttachmentCount = 1;
1456 begin_rendering_info.pColorAttachments = &color_attachment;
1457 begin_rendering_info.pDepthAttachment = &depth_attachment;
1458
Tony-LunarG7384f7e2022-07-05 14:20:42 -06001459 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-multisampledRenderToSingleSampled-06857");
ziga-lunargbc6d8ad2022-03-18 13:04:20 +01001460 m_commandBuffer->BeginRendering(begin_rendering_info);
1461 m_errorMonitor->VerifyFound();
1462}
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001463
ziga-lunargb7fec142022-03-18 22:08:17 +01001464TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRate) {
1465 TEST_DESCRIPTION("Test BeginRenderingInfo with FragmentShadingRateAttachment.");
1466
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001467 SetTargetApiVersion(VK_API_VERSION_1_2);
ziga-lunargb7fec142022-03-18 22:08:17 +01001468 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1469 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
1470
1471 ASSERT_NO_FATAL_FAILURE(InitFramework());
1472
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001473 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
1474 GTEST_SKIP() << "At least Vulkan version 1.2 is required";
ziga-lunargb7fec142022-03-18 22:08:17 +01001475 }
1476
sjfricked700bc02022-05-30 16:35:06 +09001477 if (!AreRequiredExtensionsEnabled()) {
1478 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargb7fec142022-03-18 22:08:17 +01001479 }
1480
1481 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
1482 auto features11 = LvlInitStruct<VkPhysicalDeviceVulkan11Features>(&dynamic_rendering_features);
sjfricke11db0c72022-08-18 13:23:11 +09001483 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(features11);
ziga-lunargb7fec142022-03-18 22:08:17 +01001484
1485 if (features11.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001486 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunargb7fec142022-03-18 22:08:17 +01001487 }
1488 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001489 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargb7fec142022-03-18 22:08:17 +01001490 }
1491
1492 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
1493
1494 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
sjfricke74a1aad2022-08-17 14:41:33 +09001495 GetPhysicalDeviceProperties2(phys_dev_props_2);
ziga-lunargb7fec142022-03-18 22:08:17 +01001496
1497 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1498 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
1499
1500 auto image_ci = LvlInitStruct<VkImageCreateInfo>(nullptr);
1501 image_ci.imageType = VK_IMAGE_TYPE_2D;
1502 image_ci.format = VK_FORMAT_R8G8B8A8_UNORM;
1503 image_ci.extent.width = 32;
1504 image_ci.extent.height = 32;
1505 image_ci.extent.depth = 1;
1506 image_ci.mipLevels = 1;
1507 image_ci.arrayLayers = 2;
1508 image_ci.samples = VK_SAMPLE_COUNT_1_BIT;
1509 image_ci.tiling = VK_IMAGE_TILING_OPTIMAL;
ziga-lunargade1d9e2022-04-25 10:59:15 +02001510 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 +01001511
1512 VkImageObj image(m_device);
1513 image.init(&image_ci);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001514 VkImageView image_view =
1515 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 +01001516
ziga-lunargade1d9e2022-04-25 10:59:15 +02001517 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
ziga-lunargb7fec142022-03-18 22:08:17 +01001518 fragment_shading_rate.imageView = image_view;
1519 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1520 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
1521
1522 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
1523 begin_rendering_info.layerCount = 4;
1524
1525 m_commandBuffer->begin();
1526
1527 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06123");
1528 m_commandBuffer->BeginRendering(begin_rendering_info);
1529 m_errorMonitor->VerifyFound();
1530
1531 begin_rendering_info.viewMask = 0xF;
1532 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06124");
1533 m_commandBuffer->BeginRendering(begin_rendering_info);
1534 m_errorMonitor->VerifyFound();
1535
ziga-lunargade1d9e2022-04-25 10:59:15 +02001536 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1537 color_attachment.imageView = image_view;
1538 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1539
1540 begin_rendering_info.layerCount = 2;
1541 begin_rendering_info.colorAttachmentCount = 1;
1542 begin_rendering_info.pColorAttachments = &color_attachment;
1543 begin_rendering_info.viewMask = 0;
1544 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06125");
1545 m_commandBuffer->BeginRendering(begin_rendering_info);
1546 m_errorMonitor->VerifyFound();
1547
ziga-lunargb7fec142022-03-18 22:08:17 +01001548 m_commandBuffer->end();
ziga-lunargb7fec142022-03-18 22:08:17 +01001549}
1550
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001551TEST_F(VkLayerTest, TestDeviceGroupRenderPassBeginInfo) {
1552 TEST_DESCRIPTION("Test render area of DeviceGroupRenderPassBeginInfo.");
1553
1554 SetTargetApiVersion(VK_API_VERSION_1_1);
1555 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1556
1557 ASSERT_NO_FATAL_FAILURE(InitFramework());
1558
1559 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001560 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001561 }
1562
1563 if (!DeviceExtensionSupported(gpu(), nullptr, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)) {
sjfricked700bc02022-05-30 16:35:06 +09001564 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001565 }
1566
1567 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09001568 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001569 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001570 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001571 }
1572
1573 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1574
1575 VkRect2D render_area = {};
1576 render_area.offset.x = 0;
1577 render_area.offset.y = 0;
1578 render_area.extent.width = 32;
1579 render_area.extent.height = 32;
1580
1581 auto device_group_render_pass_begin_info = LvlInitStruct<VkDeviceGroupRenderPassBeginInfo>();
1582 device_group_render_pass_begin_info.deviceRenderAreaCount = 1;
1583 device_group_render_pass_begin_info.pDeviceRenderAreas = &render_area;
1584
1585 VkImageObj colorImage(m_device);
1586 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
1587 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
1588
1589 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1590 color_attachment.imageView = colorImageView;
1591 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1592
1593 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&device_group_render_pass_begin_info);
ziga-lunarg1fec6332022-03-20 14:39:54 +01001594 begin_rendering_info.layerCount = 1;
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001595 begin_rendering_info.colorAttachmentCount = 1;
1596 begin_rendering_info.pColorAttachments = &color_attachment;
1597
1598 m_commandBuffer->begin();
1599
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001600 m_commandBuffer->BeginRendering(begin_rendering_info);
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001601
1602 render_area.offset.x = 1;
1603 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06083");
1604 m_commandBuffer->BeginRendering(begin_rendering_info);
1605 m_errorMonitor->VerifyFound();
1606
1607 render_area.offset.x = 0;
1608 render_area.offset.y = 16;
1609 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06084");
1610 m_commandBuffer->BeginRendering(begin_rendering_info);
1611 m_errorMonitor->VerifyFound();
ziga-lunarg7e7138c2022-03-18 19:02:31 +01001612}
1613
ziga-lunarg184a20b2022-03-18 20:54:48 +01001614TEST_F(VkLayerTest, TestBeginRenderingInvalidFragmentShadingRateImage) {
1615 TEST_DESCRIPTION("Test BeginRendering with FragmentShadingRateAttachmentInfo with missing image usage bit.");
1616
1617 SetTargetApiVersion(VK_API_VERSION_1_1);
1618 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1619 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
1620
1621 ASSERT_NO_FATAL_FAILURE(InitFramework());
1622
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06001623 if (IsDriver(VK_DRIVER_ID_AMD_PROPRIETARY)) {
1624 GTEST_SKIP() << "Skipping on AMD proprietary driver pending further investigation.";
1625 }
1626
ziga-lunarg184a20b2022-03-18 20:54:48 +01001627 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001628 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg184a20b2022-03-18 20:54:48 +01001629 }
1630
sjfricked700bc02022-05-30 16:35:06 +09001631 if (!AreRequiredExtensionsEnabled()) {
1632 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg184a20b2022-03-18 20:54:48 +01001633 }
1634
1635 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09001636 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg184a20b2022-03-18 20:54:48 +01001637 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001638 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg184a20b2022-03-18 20:54:48 +01001639 }
1640 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1641
1642 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
1643 auto properties2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
sjfricke74a1aad2022-08-17 14:41:33 +09001644 GetPhysicalDeviceProperties2(properties2);
ziga-lunarg184a20b2022-03-18 20:54:48 +01001645
1646 VkImageObj image(m_device);
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001647 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT,
1648 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR);
ziga-lunarg184a20b2022-03-18 20:54:48 +01001649 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
1650
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001651 VkImageObj invalid_image(m_device);
1652 invalid_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
1653 VkImageView invalid_image_view = invalid_image.targetView(VK_FORMAT_R8G8B8A8_UINT);
1654
ziga-lunarg184a20b2022-03-18 20:54:48 +01001655 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001656 fragment_shading_rate.imageView = invalid_image_view;
ziga-lunarg184a20b2022-03-18 20:54:48 +01001657 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1658 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
1659
1660 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001661 begin_rendering_info.layerCount = 1;
1662
1663 m_commandBuffer->begin();
ziga-lunarg184a20b2022-03-18 20:54:48 +01001664
1665 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06148");
ziga-lunarg184a20b2022-03-18 20:54:48 +01001666 m_commandBuffer->BeginRendering(begin_rendering_info);
ziga-lunarg184a20b2022-03-18 20:54:48 +01001667 m_errorMonitor->VerifyFound();
ziga-lunargd3de6ce2022-03-18 21:14:57 +01001668 fragment_shading_rate.imageView = image_view;
1669
1670 fragment_shading_rate.shadingRateAttachmentTexelSize.width = fsr_properties.minFragmentShadingRateAttachmentTexelSize.width + 1;
1671 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06149");
1672 if (fragment_shading_rate.shadingRateAttachmentTexelSize.width >
1673 fsr_properties.minFragmentShadingRateAttachmentTexelSize.width) {
1674 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06150");
1675 }
1676 m_commandBuffer->BeginRendering(begin_rendering_info);
1677 m_errorMonitor->VerifyFound();
1678
1679 if (fsr_properties.minFragmentShadingRateAttachmentTexelSize.width > 1) {
1680 fragment_shading_rate.shadingRateAttachmentTexelSize.width =
1681 fsr_properties.minFragmentShadingRateAttachmentTexelSize.width / 2;
1682 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06151");
1683 if (fragment_shading_rate.shadingRateAttachmentTexelSize.height /
1684 fragment_shading_rate.shadingRateAttachmentTexelSize.width >=
1685 fsr_properties.maxFragmentShadingRateAttachmentTexelSizeAspectRatio) {
1686 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06156");
1687 }
1688 m_commandBuffer->BeginRendering(begin_rendering_info);
1689 m_errorMonitor->VerifyFound();
1690 }
1691
1692 fragment_shading_rate.shadingRateAttachmentTexelSize.width = fsr_properties.minFragmentShadingRateAttachmentTexelSize.width;
1693
1694 fragment_shading_rate.shadingRateAttachmentTexelSize.height =
1695 fsr_properties.minFragmentShadingRateAttachmentTexelSize.height + 1;
1696 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06152");
1697 if (fragment_shading_rate.shadingRateAttachmentTexelSize.height >
1698 fsr_properties.minFragmentShadingRateAttachmentTexelSize.height) {
1699 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06153");
1700 }
1701 m_commandBuffer->BeginRendering(begin_rendering_info);
1702 m_errorMonitor->VerifyFound();
1703
1704 if (fsr_properties.minFragmentShadingRateAttachmentTexelSize.height > 1) {
1705 fragment_shading_rate.shadingRateAttachmentTexelSize.height =
1706 fsr_properties.minFragmentShadingRateAttachmentTexelSize.height / 2;
1707 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06154");
1708 if (fragment_shading_rate.shadingRateAttachmentTexelSize.width /
1709 fragment_shading_rate.shadingRateAttachmentTexelSize.height >
1710 fsr_properties.maxFragmentShadingRateAttachmentTexelSizeAspectRatio) {
1711 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06155");
1712 }
1713 m_commandBuffer->BeginRendering(begin_rendering_info);
1714 m_errorMonitor->VerifyFound();
1715 }
1716
1717 m_commandBuffer->end();
ziga-lunarg184a20b2022-03-18 20:54:48 +01001718}
1719
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001720TEST_F(VkLayerTest, BeginRenderingInvalidDepthAttachmentFormat) {
1721 TEST_DESCRIPTION("Test begin rendering with a depth attachment that has an invalid format");
1722
1723 SetTargetApiVersion(VK_API_VERSION_1_3);
1724 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1725
1726 ASSERT_NO_FATAL_FAILURE(InitFramework());
1727
1728 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001729 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001730 }
1731
sjfricked700bc02022-05-30 16:35:06 +09001732 if (!AreRequiredExtensionsEnabled()) {
1733 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001734 }
1735
1736 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09001737 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001738 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001739 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001740 }
1741
1742 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1743
1744 VkFormat stencil_format = FindSupportedStencilOnlyFormat(gpu());
1745 if (stencil_format == VK_FORMAT_UNDEFINED) {
1746 printf("%s requires a stencil only format format.\n", kSkipPrefix);
1747 return;
1748 }
1749
1750 VkImageObj image(m_device);
1751 image.Init(32, 32, 1, stencil_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
1752 VkImageView image_view = image.targetView(stencil_format, VK_IMAGE_ASPECT_STENCIL_BIT);
1753
1754 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1755 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
1756 depth_attachment.imageView = image_view;
1757
1758 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
ziga-lunarg1fec6332022-03-20 14:39:54 +01001759 begin_rendering_info.layerCount = 1;
ziga-lunargec0ac1c2022-03-18 19:25:17 +01001760 begin_rendering_info.pDepthAttachment = &depth_attachment;
1761
1762 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06547");
1763 m_commandBuffer->BeginRendering(begin_rendering_info);
1764 m_errorMonitor->VerifyFound();
1765}
ziga-lunarg4b5bb5b2022-03-20 00:49:04 +01001766
ziga-lunarg14a69782022-03-20 00:39:31 +01001767TEST_F(VkLayerTest, TestFragmentDensityMapRenderArea) {
1768 TEST_DESCRIPTION("Validate VkRenderingFragmentDensityMapAttachmentInfo attachment image view extent.");
1769
1770 SetTargetApiVersion(VK_API_VERSION_1_1);
1771 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1772 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1773
1774 ASSERT_NO_FATAL_FAILURE(InitFramework());
1775
1776 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001777 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg14a69782022-03-20 00:39:31 +01001778 }
1779
sjfricked700bc02022-05-30 16:35:06 +09001780 if (!AreRequiredExtensionsEnabled()) {
1781 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg14a69782022-03-20 00:39:31 +01001782 }
1783
1784 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09001785 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg14a69782022-03-20 00:39:31 +01001786 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001787 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg14a69782022-03-20 00:39:31 +01001788 }
1789
1790 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1791
1792 auto fdm_props = LvlInitStruct<VkPhysicalDeviceFragmentDensityMapPropertiesEXT>();
1793 auto props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fdm_props);
sjfricke74a1aad2022-08-17 14:41:33 +09001794 GetPhysicalDeviceProperties2(props2);
ziga-lunarg14a69782022-03-20 00:39:31 +01001795
1796 VkImageObj image(m_device);
ziga-lunarg2aa8d592022-04-25 14:29:13 +02001797 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT,
1798 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT);
ziga-lunarg14a69782022-03-20 00:39:31 +01001799 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1);
1800
1801 auto fragment_density_map = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
1802 fragment_density_map.imageView = image_view;
ziga-lunarg2aa8d592022-04-25 14:29:13 +02001803 fragment_density_map.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1804
ziga-lunarg14a69782022-03-20 00:39:31 +01001805 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_density_map);
1806 begin_rendering_info.layerCount = 1;
1807 begin_rendering_info.renderArea.extent.width = 64 * fdm_props.maxFragmentDensityTexelSize.width;
1808 begin_rendering_info.renderArea.extent.height = 32 * fdm_props.maxFragmentDensityTexelSize.height;
1809
1810 m_commandBuffer->begin();
1811
1812 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06112");
1813 m_commandBuffer->BeginRendering(begin_rendering_info);
1814 m_errorMonitor->VerifyFound();
1815
1816 begin_rendering_info.renderArea.extent.width = 32 * fdm_props.maxFragmentDensityTexelSize.width;
1817 begin_rendering_info.renderArea.extent.height = 64 * fdm_props.maxFragmentDensityTexelSize.height;
1818
1819 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06114");
1820 m_commandBuffer->BeginRendering(begin_rendering_info);
1821 m_errorMonitor->VerifyFound();
1822
1823 VkRect2D device_render_area = {};
1824 device_render_area.extent.width = 64 * fdm_props.maxFragmentDensityTexelSize.width;
1825 device_render_area.extent.height = 32 * fdm_props.maxFragmentDensityTexelSize.height;
1826 auto device_group_render_pass_begin_info = LvlInitStruct<VkDeviceGroupRenderPassBeginInfo>();
1827 device_group_render_pass_begin_info.deviceRenderAreaCount = 1;
1828 device_group_render_pass_begin_info.pDeviceRenderAreas = &device_render_area;
1829 fragment_density_map.pNext = &device_group_render_pass_begin_info;
1830
1831 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06113");
1832 m_commandBuffer->BeginRendering(begin_rendering_info);
1833 m_errorMonitor->VerifyFound();
1834
1835 device_render_area.extent.width = 32 * fdm_props.maxFragmentDensityTexelSize.width;
1836 device_render_area.extent.height = 64 * fdm_props.maxFragmentDensityTexelSize.height;
1837
1838 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06115");
1839 m_commandBuffer->BeginRendering(begin_rendering_info);
1840 m_errorMonitor->VerifyFound();
1841
1842 m_commandBuffer->end();
1843}
1844
ziga-lunarg50253b92022-04-25 14:36:13 +02001845TEST_F(VkLayerTest, TestFragmentDensityMapRenderAreaWithoutDeviceGroupExt) {
1846 TEST_DESCRIPTION("Validate VkRenderingFragmentDensityMapAttachmentInfo attachment image view extent.");
1847
1848 SetTargetApiVersion(VK_API_VERSION_1_0);
1849 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1850 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
1851
1852 ASSERT_NO_FATAL_FAILURE(InitFramework());
1853
1854 if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
sjfricke50955f32022-06-05 10:12:52 +09001855 GTEST_SKIP() << "Tests for 1.0 only";
ziga-lunarg50253b92022-04-25 14:36:13 +02001856 }
1857
sjfricked700bc02022-05-30 16:35:06 +09001858 if (!AreRequiredExtensionsEnabled()) {
1859 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg50253b92022-04-25 14:36:13 +02001860 }
1861
ziga-lunarg50253b92022-04-25 14:36:13 +02001862 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09001863 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg50253b92022-04-25 14:36:13 +02001864 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001865 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg50253b92022-04-25 14:36:13 +02001866 }
1867
1868 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1869
1870 auto fdm_props = LvlInitStruct<VkPhysicalDeviceFragmentDensityMapPropertiesEXT>();
1871 auto props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fdm_props);
sjfricke74a1aad2022-08-17 14:41:33 +09001872 GetPhysicalDeviceProperties2(props2);
ziga-lunarg50253b92022-04-25 14:36:13 +02001873
1874 VkImageObj image(m_device);
1875 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT,
1876 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT);
1877 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1);
1878
1879 auto fragment_density_map = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
1880 fragment_density_map.imageView = image_view;
1881 fragment_density_map.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1882
1883 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_density_map);
1884 begin_rendering_info.layerCount = 1;
1885 begin_rendering_info.renderArea.extent.width = 64 * fdm_props.maxFragmentDensityTexelSize.width;
1886 begin_rendering_info.renderArea.extent.height = 32 * fdm_props.maxFragmentDensityTexelSize.height;
1887
1888 m_commandBuffer->begin();
1889
1890 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06110");
1891 m_commandBuffer->BeginRendering(begin_rendering_info);
1892 m_errorMonitor->VerifyFound();
1893
1894 begin_rendering_info.renderArea.extent.width = 32 * fdm_props.maxFragmentDensityTexelSize.width;
1895 begin_rendering_info.renderArea.extent.height = 64 * fdm_props.maxFragmentDensityTexelSize.height;
1896
1897 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06111");
1898 m_commandBuffer->BeginRendering(begin_rendering_info);
1899 m_errorMonitor->VerifyFound();
1900
1901 m_commandBuffer->end();
1902}
1903
ziga-lunarge7279ba2022-03-31 20:55:27 +02001904TEST_F(VkLayerTest, TestBarrierWithDynamicRendering) {
1905 TEST_DESCRIPTION("Test setting buffer memory barrier when dynamic rendering is active.");
1906
1907 SetTargetApiVersion(VK_API_VERSION_1_3);
1908
1909 ASSERT_NO_FATAL_FAILURE(InitFramework());
1910
1911 if (DeviceValidationVersion() < VK_API_VERSION_1_3) {
sjfrickebdd58dd2022-05-20 14:22:50 +09001912 GTEST_SKIP() << "At least Vulkan version 1.3 is required";
ziga-lunarge7279ba2022-03-31 20:55:27 +02001913 }
1914
1915 auto vk13features = LvlInitStruct<VkPhysicalDeviceVulkan13Features>();
sjfricke11db0c72022-08-18 13:23:11 +09001916 auto features2 = GetPhysicalDeviceFeatures2(vk13features);
ziga-lunarge7279ba2022-03-31 20:55:27 +02001917 if (!vk13features.dynamicRendering) {
1918 printf("%s Test requires (unsupported) dynamicRendering, skipping\n", kSkipPrefix);
1919 return;
1920 }
1921 if (!vk13features.synchronization2) {
1922 printf("%s Test requires (unsupported) synchronization2, skipping\n", kSkipPrefix);
1923 return;
1924 }
1925
1926 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1927 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
1928
1929 PFN_vkCmdBeginRendering vkCmdBeginRendering =
1930 reinterpret_cast<PFN_vkCmdBeginRendering>(vk::GetDeviceProcAddr(m_device->device(), "vkCmdBeginRendering"));
1931 assert(vkCmdBeginRendering != nullptr);
1932 PFN_vkCmdEndRendering vkCmdEndRendering =
1933 reinterpret_cast<PFN_vkCmdEndRendering>(vk::GetDeviceProcAddr(m_device->device(), "vkCmdEndRendering"));
1934 assert(vkCmdEndRendering != nullptr);
1935
1936 m_commandBuffer->begin();
1937
1938 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
1939 VkClearRect clear_rect = {{{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}, 0, 1};
1940 begin_rendering_info.renderArea = clear_rect.rect;
1941 begin_rendering_info.layerCount = 1;
1942
1943 vkCmdBeginRendering(m_commandBuffer->handle(), &begin_rendering_info);
1944
1945 VkBufferObj buffer;
1946 VkMemoryPropertyFlags mem_reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
1947 buffer.init_as_src_and_dst(*m_device, 256, mem_reqs);
1948
1949 auto buf_barrier = lvl_init_struct<VkBufferMemoryBarrier2KHR>();
1950 buf_barrier.buffer = buffer.handle();
1951 buf_barrier.offset = 0;
1952 buf_barrier.size = VK_WHOLE_SIZE;
1953 buf_barrier.srcStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
1954 buf_barrier.dstStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
1955
1956 auto dependency_info = lvl_init_struct<VkDependencyInfoKHR>();
1957 dependency_info.bufferMemoryBarrierCount = 1;
1958 dependency_info.pBufferMemoryBarriers = &buf_barrier;
1959 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPipelineBarrier2-None-06191");
1960 vk::CmdPipelineBarrier2(m_commandBuffer->handle(), &dependency_info);
1961 m_errorMonitor->VerifyFound();
1962
1963 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdPipelineBarrier-None-06191");
1964 vk::CmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, 0,
1965 nullptr, 0, nullptr, 0, nullptr);
1966 m_errorMonitor->VerifyFound();
1967
1968 vkCmdEndRendering(m_commandBuffer->handle());
1969 m_commandBuffer->end();
1970}
1971
ziga-lunarg5e0a2452022-04-20 19:29:37 +02001972TEST_F(VkLayerTest, BeginRenderingInvalidStencilAttachmentFormat) {
1973 TEST_DESCRIPTION("Test begin rendering with a stencil attachment that has an invalid format");
1974
1975 SetTargetApiVersion(VK_API_VERSION_1_3);
1976 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1977
1978 ASSERT_NO_FATAL_FAILURE(InitFramework());
1979
1980 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
1981 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
1982 }
1983
sjfricked700bc02022-05-30 16:35:06 +09001984 if (!AreRequiredExtensionsEnabled()) {
1985 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg5e0a2452022-04-20 19:29:37 +02001986 }
1987
1988 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09001989 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg5e0a2452022-04-20 19:29:37 +02001990 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09001991 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg5e0a2452022-04-20 19:29:37 +02001992 }
1993
1994 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
1995
1996 VkFormat depth_format = FindSupportedDepthOnlyFormat(gpu());
1997 if (depth_format == VK_FORMAT_UNDEFINED) {
1998 printf("%s requires a stencil only format format.\n", kSkipPrefix);
1999 return;
2000 }
2001
2002 VkImageObj image(m_device);
2003 image.Init(32, 32, 1, depth_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
2004 VkImageView image_view = image.targetView(depth_format, VK_IMAGE_ASPECT_DEPTH_BIT);
2005
2006 VkRenderingAttachmentInfoKHR stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2007 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL;
2008 stencil_attachment.imageView = image_view;
2009
2010 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2011 begin_rendering_info.layerCount = 1;
2012 begin_rendering_info.pStencilAttachment = &stencil_attachment;
2013
2014 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06548");
2015 m_commandBuffer->BeginRendering(begin_rendering_info);
2016 m_errorMonitor->VerifyFound();
2017}
2018
2019TEST_F(VkLayerTest, TestInheritanceRenderingInfoStencilAttachmentFormat) {
2020 TEST_DESCRIPTION("Test begin rendering with a stencil attachment that has an invalid format");
2021
2022 SetTargetApiVersion(VK_API_VERSION_1_3);
2023 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2024
2025 ASSERT_NO_FATAL_FAILURE(InitFramework());
2026
2027 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
2028 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
2029 }
2030
sjfricked700bc02022-05-30 16:35:06 +09002031 if (!AreRequiredExtensionsEnabled()) {
2032 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002033 }
2034
2035 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09002036 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002037 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002038 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002039 }
2040
2041 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2042
2043 VkFormat depth_format = FindSupportedDepthOnlyFormat(gpu());
2044 if (depth_format == VK_FORMAT_UNDEFINED) {
2045 printf("%s requires a stencil only format format.\n", kSkipPrefix);
2046 return;
2047 }
2048
2049 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2050
2051 auto cmd_buffer_inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>();
2052 cmd_buffer_inheritance_rendering_info.colorAttachmentCount = 1;
2053 cmd_buffer_inheritance_rendering_info.pColorAttachmentFormats = &color_format;
2054 cmd_buffer_inheritance_rendering_info.depthAttachmentFormat = depth_format;
2055 cmd_buffer_inheritance_rendering_info.stencilAttachmentFormat = depth_format;
2056 cmd_buffer_inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
2057
2058 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2059 cmd_buffer_inheritance_info.pNext = &cmd_buffer_inheritance_rendering_info;
2060 cmd_buffer_inheritance_info.renderPass = VK_NULL_HANDLE;
2061
2062 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2063 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2064 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2065
2066 auto cmd_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>();
2067 cmd_buffer_allocate_info.commandPool = m_commandPool->handle();
2068 cmd_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY;
2069 cmd_buffer_allocate_info.commandBufferCount = 1;
2070
2071 VkCommandBuffer secondary_cmd_buffer;
ziga-lunarga3cc8482022-04-29 14:58:29 +02002072 vk::AllocateCommandBuffers(m_device->device(), &cmd_buffer_allocate_info, &secondary_cmd_buffer);
ziga-lunarg5e0a2452022-04-20 19:29:37 +02002073
2074 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-stencilAttachmentFormat-06541");
2075 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
2076 m_errorMonitor->VerifyFound();
2077}
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002078
2079TEST_F(VkLayerTest, CreateGraphicsPipelineWithInvalidAttachmentSampleCount) {
2080 TEST_DESCRIPTION("Create pipeline with fragment shader that uses samples, but multisample state not begin set");
2081
ziga-lunarg7f25dff2022-05-06 17:49:34 +02002082 SetTargetApiVersion(VK_API_VERSION_1_1);
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002083 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2084 AddRequiredExtensions(VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME);
2085
2086 ASSERT_NO_FATAL_FAILURE(InitFramework());
2087
2088 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002089 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002090 }
2091
sjfricked700bc02022-05-30 16:35:06 +09002092 if (!AreRequiredExtensionsEnabled()) {
2093 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002094 }
2095
2096 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09002097 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002098 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002099 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002100 }
2101
2102 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2103 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2104
2105 auto sample_count_info_amd = LvlInitStruct<VkAttachmentSampleCountInfoNV>();
2106 sample_count_info_amd.colorAttachmentCount = 1;
ziga-lunarg7f25dff2022-05-06 17:49:34 +02002107 sample_count_info_amd.depthStencilAttachmentSamples = static_cast<VkSampleCountFlagBits>(0x3);
ziga-lunargeb4a69c2022-04-20 21:52:00 +02002108
2109 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(&sample_count_info_amd);
2110 pipeline_rendering_info.colorAttachmentCount = 1;
2111 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2112
2113 CreatePipelineHelper pipe(*this);
2114 pipe.InitInfo();
2115 pipe.gp_ci_.pNext = &pipeline_rendering_info;
2116 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2117 pipe.InitState();
2118
2119 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-depthStencilAttachmentSamples-06593");
2120 pipe.CreateGraphicsPipeline();
2121 m_errorMonitor->VerifyFound();
2122}
ziga-lunargd680bf22022-04-20 22:01:00 +02002123
2124TEST_F(VkLayerTest, CreatePipelineUsingDynamicRenderingWithoutFeature) {
2125 TEST_DESCRIPTION("Create graphcis pipeline that uses dynamic rendering, but feature is not enabled");
2126
2127 SetTargetApiVersion(VK_API_VERSION_1_3);
2128 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2129 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
2130
2131 ASSERT_NO_FATAL_FAILURE(InitFramework());
2132
2133 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002134 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargd680bf22022-04-20 22:01:00 +02002135 }
2136
sjfricked700bc02022-05-30 16:35:06 +09002137 if (!AreRequiredExtensionsEnabled()) {
2138 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargd680bf22022-04-20 22:01:00 +02002139 }
2140
2141 ASSERT_NO_FATAL_FAILURE(InitState());
2142
2143 CreatePipelineHelper pipe(*this);
2144 pipe.InitInfo();
2145 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2146 pipe.InitState();
2147
2148 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-dynamicRendering-06576");
2149 pipe.CreateGraphicsPipeline();
2150 m_errorMonitor->VerifyFound();
2151}
ziga-lunargf20d7952022-04-20 22:11:40 +02002152
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002153TEST_F(VkLayerTest, DynamicRenderingAreaGreaterThanAttachmentExtent) {
2154 TEST_DESCRIPTION("Begin dynamic rendering with render area greater than extent of attachments");
2155
2156 SetTargetApiVersion(VK_API_VERSION_1_0);
2157 AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
2158 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2159 ASSERT_NO_FATAL_FAILURE(InitFramework());
2160
2161 if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
sjfricke50955f32022-06-05 10:12:52 +09002162 GTEST_SKIP() << "Tests for 1.0 only";
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002163 }
sjfricked700bc02022-05-30 16:35:06 +09002164 if (!AreRequiredExtensionsEnabled()) {
2165 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002166 }
2167
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002168 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09002169 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002170 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002171 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002172 }
2173
2174 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2175
2176 VkImageObj colorImage(m_device);
2177 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
2178 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
2179
ziga-lunarga51287c2022-04-20 23:24:37 +02002180 auto color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002181 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2182 color_attachment.imageView = colorImageView;
2183
ziga-lunarga51287c2022-04-20 23:24:37 +02002184 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
ziga-lunarg6ed1dad2022-04-20 23:14:53 +02002185 begin_rendering_info.layerCount = 1;
2186 begin_rendering_info.colorAttachmentCount = 1;
2187 begin_rendering_info.pColorAttachments = &color_attachment;
2188 begin_rendering_info.renderArea.extent.width = 64;
2189 begin_rendering_info.renderArea.extent.height = 32;
2190
2191 m_commandBuffer->begin();
2192
2193 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06075");
2194 m_commandBuffer->BeginRendering(begin_rendering_info);
2195 m_errorMonitor->VerifyFound();
2196
2197 begin_rendering_info.renderArea.extent.width = 32;
2198 begin_rendering_info.renderArea.extent.height = 64;
2199
2200 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06076");
2201 m_commandBuffer->BeginRendering(begin_rendering_info);
2202 m_errorMonitor->VerifyFound();
2203
2204 const VkFormat ds_format = FindSupportedDepthStencilFormat(gpu());
2205 if (ds_format != VK_FORMAT_UNDEFINED) {
2206 VkImageObj depthImage(m_device);
2207 depthImage.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
2208 VkImageView depthImageView = depthImage.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT);
2209
2210 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2211 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
2212 depth_attachment.imageView = depthImageView;
2213
2214 begin_rendering_info.colorAttachmentCount = 0;
2215 begin_rendering_info.pDepthAttachment = &depth_attachment;
2216
2217 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06076");
2218 m_commandBuffer->BeginRendering(begin_rendering_info);
2219 m_errorMonitor->VerifyFound();
2220 }
2221
2222 m_commandBuffer->end();
2223}
ziga-lunarga51287c2022-04-20 23:24:37 +02002224
2225TEST_F(VkLayerTest, DynamicRenderingDeviceGroupAreaGreaterThanAttachmentExtent) {
2226 TEST_DESCRIPTION("Begin dynamic rendering with device group with render area greater than extent of attachments");
2227
2228 SetTargetApiVersion(VK_API_VERSION_1_1);
2229 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2230 ASSERT_NO_FATAL_FAILURE(InitFramework());
2231
2232 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002233 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarga51287c2022-04-20 23:24:37 +02002234 }
sjfricked700bc02022-05-30 16:35:06 +09002235 if (!AreRequiredExtensionsEnabled()) {
2236 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarga51287c2022-04-20 23:24:37 +02002237 }
2238
2239 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09002240 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarga51287c2022-04-20 23:24:37 +02002241 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002242 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarga51287c2022-04-20 23:24:37 +02002243 }
2244
2245 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2246
2247 VkImageObj colorImage(m_device);
2248 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
2249 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
2250
2251 auto color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2252 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2253 color_attachment.imageView = colorImageView;
2254
2255 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2256 begin_rendering_info.layerCount = 1;
2257 begin_rendering_info.colorAttachmentCount = 1;
2258 begin_rendering_info.pColorAttachments = &color_attachment;
2259 begin_rendering_info.renderArea.extent.width = 64;
2260 begin_rendering_info.renderArea.extent.height = 32;
2261
2262 m_commandBuffer->begin();
2263
2264 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06079");
2265 m_commandBuffer->BeginRendering(begin_rendering_info);
2266 m_errorMonitor->VerifyFound();
2267
2268 begin_rendering_info.renderArea.extent.width = 32;
2269 begin_rendering_info.renderArea.extent.height = 64;
2270
2271 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06080");
2272 m_commandBuffer->BeginRendering(begin_rendering_info);
2273 m_errorMonitor->VerifyFound();
2274
2275 const VkFormat ds_format = FindSupportedDepthStencilFormat(gpu());
2276 if (ds_format != VK_FORMAT_UNDEFINED) {
2277 VkImageObj depthImage(m_device);
2278 depthImage.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
2279 VkImageView depthImageView = depthImage.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT);
2280
2281 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2282 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
2283 depth_attachment.imageView = depthImageView;
2284
2285 begin_rendering_info.colorAttachmentCount = 0;
2286 begin_rendering_info.pDepthAttachment = &depth_attachment;
2287
2288 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06080");
2289 m_commandBuffer->BeginRendering(begin_rendering_info);
2290 m_errorMonitor->VerifyFound();
2291 }
2292
2293 m_commandBuffer->end();
2294}
ziga-lunargd4105c12022-04-21 13:54:20 +02002295
2296TEST_F(VkLayerTest, SecondaryCommandBufferIncompatibleRenderPass) {
2297 TEST_DESCRIPTION("Execute secondary command buffers within render pass instance with incompatible render pass");
2298
2299 SetTargetApiVersion(VK_API_VERSION_1_1);
2300 ASSERT_NO_FATAL_FAILURE(InitFramework());
2301
2302 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002303 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargd4105c12022-04-21 13:54:20 +02002304 }
2305
2306 ASSERT_NO_FATAL_FAILURE(InitState());
2307 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2308
ziga-lunarga3cc8482022-04-29 14:58:29 +02002309 VkSubpassDescription subpass = {};
ziga-lunargd4105c12022-04-21 13:54:20 +02002310 auto render_pass_ci = LvlInitStruct<VkRenderPassCreateInfo>();
ziga-lunarga3cc8482022-04-29 14:58:29 +02002311 render_pass_ci.subpassCount = 1;
2312 render_pass_ci.pSubpasses = &subpass;
ziga-lunargd4105c12022-04-21 13:54:20 +02002313
2314 vk_testing::RenderPass render_pass;
2315 render_pass.init(*m_device, render_pass_ci);
2316
2317 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2318 VkCommandBuffer secondary_handle = cb.handle();
2319
2320 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2321 cmd_buffer_inheritance_info.renderPass = render_pass.handle();
2322 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2323 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2324 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2325
2326 cb.begin(&cmd_buffer_begin_info);
2327 cb.end();
2328
2329 m_commandBuffer->begin();
2330 m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
2331
2332 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pBeginInfo-06020");
2333 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pInheritanceInfo-00098");
2334 vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle);
2335 m_errorMonitor->VerifyFound();
2336
2337 m_commandBuffer->EndRenderPass();
2338 m_commandBuffer->end();
2339}
ziga-lunarg590e0292022-04-21 14:07:22 +02002340
2341TEST_F(VkLayerTest, SecondaryCommandBufferIncompatibleSubpass) {
2342 TEST_DESCRIPTION("Execute secondary command buffers with different subpass");
2343
2344 SetTargetApiVersion(VK_API_VERSION_1_1);
2345 ASSERT_NO_FATAL_FAILURE(InitFramework());
2346
2347 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002348 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg590e0292022-04-21 14:07:22 +02002349 }
2350
2351 ASSERT_NO_FATAL_FAILURE(InitState());
2352
2353 VkSubpassDescription subpasses[2] = {};
2354
2355 auto render_pass_ci = LvlInitStruct<VkRenderPassCreateInfo>();
2356 render_pass_ci.subpassCount = 2;
2357 render_pass_ci.pSubpasses = subpasses;
2358
2359 vk_testing::RenderPass render_pass;
2360 render_pass.init(*m_device, render_pass_ci);
2361
2362 auto framebuffer_ci = LvlInitStruct<VkFramebufferCreateInfo>();
2363 framebuffer_ci.renderPass = render_pass.handle();
2364 framebuffer_ci.width = 32;
2365 framebuffer_ci.height = 32;
ziga-lunarg143bdbf2022-05-04 19:04:58 +02002366 framebuffer_ci.layers = 1;
ziga-lunarg590e0292022-04-21 14:07:22 +02002367
2368 vk_testing::Framebuffer framebuffer;
2369 framebuffer.init(*m_device, framebuffer_ci);
2370
2371 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2372 VkCommandBuffer secondary_handle = cb.handle();
2373
2374 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2375 cmd_buffer_inheritance_info.renderPass = render_pass.handle();
2376 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2377 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2378 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2379
2380 cb.begin(&cmd_buffer_begin_info);
2381 cb.end();
2382
2383 auto render_pass_begin_info = LvlInitStruct<VkRenderPassBeginInfo>();
2384 render_pass_begin_info.renderPass = render_pass.handle();
2385 render_pass_begin_info.renderArea.extent = {32, 32};
2386 render_pass_begin_info.framebuffer = framebuffer.handle();
2387
2388 m_commandBuffer->begin();
2389 m_commandBuffer->BeginRenderPass(render_pass_begin_info, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
2390 vk::CmdNextSubpass(m_commandBuffer->handle(), VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
2391
2392 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pCommandBuffers-00097");
2393 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-pCommandBuffers-06019");
2394 vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle);
2395 m_errorMonitor->VerifyFound();
2396
2397 m_commandBuffer->EndRenderPass();
2398 m_commandBuffer->end();
2399}
ziga-lunarg343193b2022-04-21 14:15:17 +02002400
2401TEST_F(VkLayerTest, SecondaryCommandBufferInvalidContents) {
2402 TEST_DESCRIPTION("Execute secondary command buffers within active render pass that was not begun with VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS");
2403
2404 SetTargetApiVersion(VK_API_VERSION_1_1);
2405 ASSERT_NO_FATAL_FAILURE(InitFramework());
2406
2407 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002408 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg343193b2022-04-21 14:15:17 +02002409 }
2410
2411 ASSERT_NO_FATAL_FAILURE(InitState());
2412 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2413
ziga-lunarg343193b2022-04-21 14:15:17 +02002414 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2415 VkCommandBuffer secondary_handle = cb.handle();
2416
2417 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
2418 cmd_buffer_inheritance_info.renderPass = m_renderPass;
2419 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
2420 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2421 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
2422
2423 cb.begin(&cmd_buffer_begin_info);
2424 cb.end();
2425
2426 m_commandBuffer->begin();
2427 m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo);
2428
2429 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-contents-00095");
2430 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdExecuteCommands-contents-06018");
2431 vk::CmdExecuteCommands(m_commandBuffer->handle(), 1, &secondary_handle);
2432 m_errorMonitor->VerifyFound();
2433
2434 m_commandBuffer->EndRenderPass();
2435 m_commandBuffer->end();
2436}
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002437
2438TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoDepthFormat) {
2439 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo DepthFormat incompatible with previously used pipeline");
2440
2441 SetTargetApiVersion(VK_API_VERSION_1_1);
2442 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2443 ASSERT_NO_FATAL_FAILURE(InitFramework());
2444
2445 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002446 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002447 }
sjfricked700bc02022-05-30 16:35:06 +09002448 if (!AreRequiredExtensionsEnabled()) {
2449 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002450 }
2451
2452 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09002453 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002454 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002455 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002456 }
2457
2458 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2459 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2460
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002461 std::vector<VkFormat> depth_formats;
2462 const VkFormat ds_formats[] = {VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT};
2463 for (uint32_t i = 0; i < size(ds_formats); ++i) {
2464 VkFormatProperties format_props;
2465 vk::GetPhysicalDeviceFormatProperties(gpu(), ds_formats[i], &format_props);
2466
2467 if (format_props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) {
2468 depth_formats.push_back(ds_formats[i]);
2469 }
2470 }
2471
2472 if (depth_formats.size() < 2) {
2473 printf("%s Test requires 2 depth formats, skipping test.\n", kSkipPrefix);
2474 return;
2475 }
2476
2477 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2478 pipeline_rendering_info.depthAttachmentFormat = depth_formats[0];
2479
2480 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
2481
2482 CreatePipelineHelper pipe1(*this);
2483 pipe1.InitInfo();
2484 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2485 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2486 pipe1.InitState();
2487 pipe1.ds_ci_ = ds_ci;
2488 pipe1.CreateGraphicsPipeline();
2489
2490 pipeline_rendering_info.depthAttachmentFormat = depth_formats[1];
2491
2492 CreatePipelineHelper pipe2(*this);
2493 pipe2.InitInfo();
2494 pipe2.gp_ci_.pNext = &pipeline_rendering_info;
2495 pipe2.gp_ci_.renderPass = VK_NULL_HANDLE;
2496 pipe2.InitState();
2497 pipe2.ds_ci_ = ds_ci;
2498 pipe2.CreateGraphicsPipeline();
2499
2500 VkImageObj image(m_device);
2501 image.Init(32, 32, 1, depth_formats[0], VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2502 VkImageView depth_image_view = image.targetView(depth_formats[0], VK_IMAGE_ASPECT_DEPTH_BIT);
2503
2504 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2505 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
2506 depth_attachment.imageView = depth_image_view;
2507
2508 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2509 begin_rendering_info.layerCount = 1;
2510 begin_rendering_info.pDepthAttachment = &depth_attachment;
2511
2512 m_commandBuffer->begin();
2513 m_commandBuffer->BeginRendering(begin_rendering_info);
2514
2515 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_);
2516 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
2517
ziga-lunarg9104e0a2022-04-21 16:45:09 +02002518 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06197");
2519 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_);
2520 m_errorMonitor->VerifyFound();
2521
2522 m_commandBuffer->EndRendering();
2523 m_commandBuffer->end();
2524}
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002525
2526TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoColorAttachments) {
2527 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo color attachment incompatible with previously used pipeline");
2528
2529 SetTargetApiVersion(VK_API_VERSION_1_1);
2530 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2531 ASSERT_NO_FATAL_FAILURE(InitFramework());
2532
2533 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002534 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002535 }
sjfricked700bc02022-05-30 16:35:06 +09002536 if (!AreRequiredExtensionsEnabled()) {
2537 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002538 }
2539
2540 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09002541 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002542 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002543 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002544 }
2545
2546 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2547 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2548
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002549 VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
2550 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2551 pipeline_rendering_info.colorAttachmentCount = 1;
2552 pipeline_rendering_info.pColorAttachmentFormats = &format;
2553
2554 CreatePipelineHelper pipe1(*this);
2555 pipe1.InitInfo();
2556 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2557 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2558 pipe1.InitState();
2559 pipe1.CreateGraphicsPipeline();
2560
2561 format = VK_FORMAT_B8G8R8A8_UNORM;
2562
2563 CreatePipelineHelper pipe2(*this);
2564 pipe2.InitInfo();
2565 pipe2.gp_ci_.pNext = &pipeline_rendering_info;
2566 pipe2.gp_ci_.renderPass = VK_NULL_HANDLE;
2567 pipe2.InitState();
2568 pipe2.CreateGraphicsPipeline();
2569
2570 VkImageObj image(m_device);
2571 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2572 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
2573
2574 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2575 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2576 color_attachment.imageView = image_view;
2577
2578 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2579 begin_rendering_info.layerCount = 1;
2580 begin_rendering_info.colorAttachmentCount = 1;
2581 begin_rendering_info.pColorAttachments = &color_attachment;
2582
2583 m_commandBuffer->begin();
2584 m_commandBuffer->BeginRendering(begin_rendering_info);
2585
2586 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_);
2587 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
2588
ziga-lunarg1ac9b672022-04-21 17:55:28 +02002589 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06196");
2590 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_);
2591 m_errorMonitor->VerifyFound();
2592
2593 m_commandBuffer->EndRendering();
2594 m_commandBuffer->end();
2595}
ziga-lunargacd79322022-04-21 18:36:34 +02002596
2597TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoColorAttachmentCount) {
2598 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo color attachment count incompatible with previously used pipeline");
2599
2600 SetTargetApiVersion(VK_API_VERSION_1_1);
2601 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2602 ASSERT_NO_FATAL_FAILURE(InitFramework());
2603
2604 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002605 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargacd79322022-04-21 18:36:34 +02002606 }
sjfricked700bc02022-05-30 16:35:06 +09002607 if (!AreRequiredExtensionsEnabled()) {
2608 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargacd79322022-04-21 18:36:34 +02002609 }
2610
2611 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09002612 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargacd79322022-04-21 18:36:34 +02002613 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002614 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargacd79322022-04-21 18:36:34 +02002615 }
2616
2617 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2618 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2619
ziga-lunargacd79322022-04-21 18:36:34 +02002620 VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
2621 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2622 pipeline_rendering_info.colorAttachmentCount = 1;
2623 pipeline_rendering_info.pColorAttachmentFormats = &format;
2624
2625 CreatePipelineHelper pipe1(*this);
2626 pipe1.InitInfo();
2627 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2628 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2629 pipe1.InitState();
2630 pipe1.CreateGraphicsPipeline();
2631
2632 pipeline_rendering_info.colorAttachmentCount = 0;
2633
2634 CreatePipelineHelper pipe2(*this);
2635 pipe2.InitInfo();
2636 pipe2.gp_ci_.pNext = &pipeline_rendering_info;
2637 pipe2.gp_ci_.renderPass = VK_NULL_HANDLE;
2638 pipe2.InitState();
2639 pipe2.CreateGraphicsPipeline();
2640
2641 VkImageObj image(m_device);
2642 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2643 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
2644
2645 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2646 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2647 color_attachment.imageView = image_view;
2648
2649 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2650 begin_rendering_info.layerCount = 1;
2651 begin_rendering_info.colorAttachmentCount = 1;
2652 begin_rendering_info.pColorAttachments = &color_attachment;
2653
2654 m_commandBuffer->begin();
2655 m_commandBuffer->BeginRendering(begin_rendering_info);
2656
2657 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_);
2658 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
2659
ziga-lunargacd79322022-04-21 18:36:34 +02002660 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06195");
2661 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_);
2662 m_errorMonitor->VerifyFound();
2663
2664 m_commandBuffer->EndRendering();
2665 m_commandBuffer->end();
ziga-lunarge3f11282022-04-21 18:39:55 +02002666}
2667
2668TEST_F(VkLayerTest, BindPipelineWithIncompatibleRenderingInfoStencilFormat) {
2669 TEST_DESCRIPTION("Bind pipeline that has RenderingInfo StencilFormat incompatible with previously used pipeline");
2670
2671 SetTargetApiVersion(VK_API_VERSION_1_1);
2672 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2673 ASSERT_NO_FATAL_FAILURE(InitFramework());
2674
2675 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002676 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge3f11282022-04-21 18:39:55 +02002677 }
sjfricked700bc02022-05-30 16:35:06 +09002678 if (!AreRequiredExtensionsEnabled()) {
2679 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge3f11282022-04-21 18:39:55 +02002680 }
2681
2682 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09002683 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarge3f11282022-04-21 18:39:55 +02002684 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002685 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge3f11282022-04-21 18:39:55 +02002686 }
2687
2688 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2689 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2690
ziga-lunarge3f11282022-04-21 18:39:55 +02002691 std::vector<VkFormat> stencil_formats;
2692 const VkFormat ds_formats[] = {VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT};
2693 for (uint32_t i = 0; i < size(ds_formats); ++i) {
2694 VkFormatProperties format_props;
2695 vk::GetPhysicalDeviceFormatProperties(gpu(), ds_formats[i], &format_props);
2696
2697 if (format_props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) {
2698 stencil_formats.push_back(ds_formats[i]);
2699 }
2700 }
2701
2702 if (stencil_formats.size() < 2) {
2703 printf("%s Test requires 2 stencil formats, skipping test.\n", kSkipPrefix);
2704 return;
2705 }
2706
2707 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2708 pipeline_rendering_info.stencilAttachmentFormat = stencil_formats[0];
2709
2710 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
2711
2712 CreatePipelineHelper pipe1(*this);
2713 pipe1.InitInfo();
2714 pipe1.gp_ci_.pNext = &pipeline_rendering_info;
2715 pipe1.gp_ci_.renderPass = VK_NULL_HANDLE;
2716 pipe1.InitState();
2717 pipe1.ds_ci_ = ds_ci;
2718 pipe1.CreateGraphicsPipeline();
2719
2720 pipeline_rendering_info.stencilAttachmentFormat = stencil_formats[1];
2721
2722 CreatePipelineHelper pipe2(*this);
2723 pipe2.InitInfo();
2724 pipe2.gp_ci_.pNext = &pipeline_rendering_info;
2725 pipe2.gp_ci_.renderPass = VK_NULL_HANDLE;
2726 pipe2.InitState();
2727 pipe2.ds_ci_ = ds_ci;
2728 pipe2.CreateGraphicsPipeline();
2729
2730 VkImageObj image(m_device);
2731 image.Init(32, 32, 1, stencil_formats[0], VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
2732 VkImageView stencil_image_view = image.targetView(stencil_formats[0], VK_IMAGE_ASPECT_DEPTH_BIT);
2733
2734 VkRenderingAttachmentInfoKHR stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
2735 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL;
2736 stencil_attachment.imageView = stencil_image_view;
2737
2738 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
2739 begin_rendering_info.layerCount = 1;
2740 begin_rendering_info.pStencilAttachment = &stencil_attachment;
2741
2742 m_commandBuffer->begin();
2743 m_commandBuffer->BeginRendering(begin_rendering_info);
2744
2745 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.pipeline_);
2746 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
2747
ziga-lunarge3f11282022-04-21 18:39:55 +02002748 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdBindPipeline-pipeline-06194");
2749 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.pipeline_);
2750 m_errorMonitor->VerifyFound();
2751
2752 m_commandBuffer->EndRendering();
2753 m_commandBuffer->end();
2754}
ziga-lunarg155ed452022-04-21 23:54:06 +02002755
2756TEST_F(VkLayerTest, DynamicRenderingWithInvalidShaderLayerBuiltIn) {
2757 TEST_DESCRIPTION("Create invalid pipeline that writes to Layer built-in");
2758
2759 SetTargetApiVersion(VK_API_VERSION_1_1);
2760 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2761 ASSERT_NO_FATAL_FAILURE(InitFramework());
2762
2763 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002764 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg155ed452022-04-21 23:54:06 +02002765 }
sjfricked700bc02022-05-30 16:35:06 +09002766 if (!AreRequiredExtensionsEnabled()) {
2767 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg155ed452022-04-21 23:54:06 +02002768 }
2769
2770 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
2771 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>(&dynamic_rendering_features);
sjfricke11db0c72022-08-18 13:23:11 +09002772 auto features2 = GetPhysicalDeviceFeatures2(multiview_features);
ziga-lunarg155ed452022-04-21 23:54:06 +02002773 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002774 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg155ed452022-04-21 23:54:06 +02002775 }
2776 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002777 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg155ed452022-04-21 23:54:06 +02002778 }
2779 if (multiview_features.multiviewGeometryShader == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002780 GTEST_SKIP() << "Test requires (unsupported) multiviewGeometryShader";
ziga-lunarg155ed452022-04-21 23:54:06 +02002781 }
2782
2783 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2784 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2785
2786 static char const *gsSource = R"glsl(
2787 #version 450
2788 layout (triangles) in;
2789 layout (triangle_strip) out;
2790 layout (max_vertices = 1) out;
2791 void main() {
2792 gl_Position = vec4(1.0, 0.5, 0.5, 0.0);
2793 EmitVertex();
2794 gl_Layer = 4;
2795 }
2796 )glsl";
2797
2798 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
2799 VkShaderObj gs(this, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT);
2800
2801 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2802
2803 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2804 pipeline_rendering_info.colorAttachmentCount = 1;
2805 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2806 pipeline_rendering_info.viewMask = 0x1;
2807
2808 CreatePipelineHelper pipe(*this);
2809 pipe.InitInfo();
2810 pipe.shader_stages_ = {vs.GetStageCreateInfo(), gs.GetStageCreateInfo(), pipe.fs_->GetStageCreateInfo()};
2811 pipe.gp_ci_.pNext = &pipeline_rendering_info;
2812 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2813 pipe.InitState();
2814 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06059");
2815 pipe.CreateGraphicsPipeline();
2816 m_errorMonitor->VerifyFound();
2817}
ziga-lunarg6feb4632022-04-22 00:20:21 +02002818
2819TEST_F(VkLayerTest, DynamicRenderingWithInputAttachmentCapability) {
2820 TEST_DESCRIPTION("Create invalid pipeline that uses InputAttachment capability");
2821
2822 SetTargetApiVersion(VK_API_VERSION_1_1);
2823 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2824 ASSERT_NO_FATAL_FAILURE(InitFramework());
2825
2826 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002827 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg6feb4632022-04-22 00:20:21 +02002828 }
sjfricked700bc02022-05-30 16:35:06 +09002829 if (!AreRequiredExtensionsEnabled()) {
2830 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6feb4632022-04-22 00:20:21 +02002831 }
2832
2833 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09002834 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg6feb4632022-04-22 00:20:21 +02002835 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002836 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6feb4632022-04-22 00:20:21 +02002837 }
2838
2839 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2840 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2841
sjfricke394227a2022-06-20 16:47:38 +09002842 const char *fsSource = R"(
ziga-lunarg6feb4632022-04-22 00:20:21 +02002843 OpCapability Shader
2844 OpCapability InputAttachment
2845 %1 = OpExtInstImport "GLSL.std.450"
2846 OpMemoryModel Logical GLSL450
2847 OpEntryPoint Fragment %main "main"
2848 OpExecutionMode %main OriginUpperLeft
2849
2850 ; Debug Information
2851 OpSource GLSL 450
2852 OpName %main "main" ; id %4
2853
2854 ; Types, variables and constants
2855 %void = OpTypeVoid
2856 %3 = OpTypeFunction %void
2857
2858 ; Function main
2859 %main = OpFunction %void None %3
2860 %5 = OpLabel
2861 OpReturn
2862 OpFunctionEnd
2863 )";
2864
2865 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, SPV_ENV_VULKAN_1_0, SPV_SOURCE_ASM);
2866
2867 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2868
2869 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2870 pipeline_rendering_info.colorAttachmentCount = 1;
2871 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2872
2873 CreatePipelineHelper pipe(*this);
2874 pipe.InitInfo();
2875 pipe.shader_stages_ = {pipe.vs_->GetStageCreateInfo(), fs.GetStageCreateInfo()};
2876 pipe.gp_ci_.pNext = &pipeline_rendering_info;
2877 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2878 pipe.InitState();
2879 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06061");
2880 pipe.CreateGraphicsPipeline();
2881 m_errorMonitor->VerifyFound();
2882}
ziga-lunarga62b6ce2022-04-22 14:33:47 +02002883
2884TEST_F(VkLayerTest, InvalidRenderingInfoColorAttachmentFormat) {
2885 TEST_DESCRIPTION("Create pipeline with invalid color attachment format");
2886
2887 SetTargetApiVersion(VK_API_VERSION_1_1);
2888 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2889 ASSERT_NO_FATAL_FAILURE(InitFramework());
2890
2891 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002892 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarga62b6ce2022-04-22 14:33:47 +02002893 }
sjfricked700bc02022-05-30 16:35:06 +09002894 if (!AreRequiredExtensionsEnabled()) {
2895 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarga62b6ce2022-04-22 14:33:47 +02002896 }
2897
2898 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09002899 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarga62b6ce2022-04-22 14:33:47 +02002900 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002901 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarga62b6ce2022-04-22 14:33:47 +02002902 }
2903
2904 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
2905 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2906
2907 VkFormat color_format = VK_FORMAT_MAX_ENUM;
2908
2909 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2910 pipeline_rendering_info.colorAttachmentCount = 1;
2911 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2912
2913 CreatePipelineHelper pipe(*this);
2914 pipe.InitInfo();
2915 pipe.gp_ci_.pNext = &pipeline_rendering_info;
2916 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
2917 pipe.InitState();
2918 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06579");
2919 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06580");
2920 pipe.CreateGraphicsPipeline();
2921 m_errorMonitor->VerifyFound();
2922}
ziga-lunargf7fb9202022-04-22 17:19:10 +02002923
2924TEST_F(VkLayerTest, InvalidDynamicRenderingLibraryViewMask) {
2925 TEST_DESCRIPTION("Create pipeline with invalid view mask");
2926
2927 SetTargetApiVersion(VK_API_VERSION_1_1);
2928 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
2929 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
2930 ASSERT_NO_FATAL_FAILURE(InitFramework());
2931
2932 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09002933 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargf7fb9202022-04-22 17:19:10 +02002934 }
sjfricked700bc02022-05-30 16:35:06 +09002935 if (!AreRequiredExtensionsEnabled()) {
2936 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargf7fb9202022-04-22 17:19:10 +02002937 }
2938
2939 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
2940 auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>(&multiview_features);
2941 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features);
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06002942 GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargf7fb9202022-04-22 17:19:10 +02002943 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002944 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargf7fb9202022-04-22 17:19:10 +02002945 }
2946 if (library_features.graphicsPipelineLibrary == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002947 GTEST_SKIP() << "Test requires (unsupported) graphicsPipelineLibrary";
ziga-lunargf7fb9202022-04-22 17:19:10 +02002948 }
2949 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09002950 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunargf7fb9202022-04-22 17:19:10 +02002951 }
2952
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06002953 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &dynamic_rendering_features));
ziga-lunargf7fb9202022-04-22 17:19:10 +02002954 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
2955
2956 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
2957
2958 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
2959 pipeline_rendering_info.colorAttachmentCount = 1;
2960 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
2961
2962 auto graphics_library_create_info = LvlInitStruct<VkGraphicsPipelineLibraryCreateInfoEXT>(&pipeline_rendering_info);
2963 graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT;
2964 auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>(&graphics_library_create_info);
2965
2966 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
2967 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
2968 color_blend_state_create_info.attachmentCount = 1;
2969 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
2970
ziga-lunargf7fb9202022-04-22 17:19:10 +02002971 CreatePipelineHelper lib(*this);
2972 lib.cb_ci_ = color_blend_state_create_info;
2973 lib.InitInfo();
2974 lib.gp_ci_.pNext = &library_create_info;
2975 lib.gp_ci_.renderPass = VK_NULL_HANDLE;
2976 lib.InitState();
2977 lib.CreateGraphicsPipeline();
ziga-lunargf7fb9202022-04-22 17:19:10 +02002978
2979 graphics_library_create_info.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT;
2980 library_create_info.libraryCount = 1;
2981 library_create_info.pLibraries = &lib.pipeline_;
2982 pipeline_rendering_info.viewMask = 0x1;
2983
2984 CreatePipelineHelper pipe(*this);
2985 pipe.InitInfo();
2986 pipe.gp_ci_.pNext = &library_create_info;
2987 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06002988 pipe.shader_stages_ = {pipe.fs_->GetStageCreateInfo()};
ziga-lunargf7fb9202022-04-22 17:19:10 +02002989 pipe.InitState();
2990 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06626");
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06002991 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06626");
ziga-lunargf7fb9202022-04-22 17:19:10 +02002992 pipe.CreateGraphicsPipeline();
2993 m_errorMonitor->VerifyFound();
2994}
ziga-lunarge151ca62022-04-22 17:40:51 +02002995
2996TEST_F(VkLayerTest, InvalidAttachmentSampleCount) {
2997 TEST_DESCRIPTION("Create pipeline with invalid color attachment samples");
2998
2999 SetTargetApiVersion(VK_API_VERSION_1_1);
3000 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3001 ASSERT_NO_FATAL_FAILURE(InitFramework());
3002
3003 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003004 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge151ca62022-04-22 17:40:51 +02003005 }
sjfricked700bc02022-05-30 16:35:06 +09003006 if (!AreRequiredExtensionsEnabled()) {
3007 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge151ca62022-04-22 17:40:51 +02003008 }
3009
3010 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09003011 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarge151ca62022-04-22 17:40:51 +02003012 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003013 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge151ca62022-04-22 17:40:51 +02003014 }
3015
3016 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3017 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3018
3019 VkSampleCountFlagBits color_attachment_samples = VK_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM;
3020
3021 auto samples_info = LvlInitStruct<VkAttachmentSampleCountInfoAMD>();
3022 samples_info.colorAttachmentCount = 1;
3023 samples_info.pColorAttachmentSamples = &color_attachment_samples;
3024 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(&samples_info);
3025
3026 CreatePipelineHelper pipe(*this);
3027 pipe.InitInfo();
3028 pipe.gp_ci_.pNext = &pipeline_rendering_info;
3029 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3030 pipe.InitState();
3031 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-pColorAttachmentSamples-06592");
3032 pipe.CreateGraphicsPipeline();
3033 m_errorMonitor->VerifyFound();
3034}
ziga-lunargb81597d2022-04-22 19:11:51 +02003035
3036TEST_F(VkLayerTest, InvalidDynamicRenderingLibrariesViewMask) {
3037 TEST_DESCRIPTION("Create pipeline with libaries that have incompatible view mask");
3038
3039 SetTargetApiVersion(VK_API_VERSION_1_1);
3040 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3041 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
3042 ASSERT_NO_FATAL_FAILURE(InitFramework());
3043
3044 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003045 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargb81597d2022-04-22 19:11:51 +02003046 }
sjfricked700bc02022-05-30 16:35:06 +09003047 if (!AreRequiredExtensionsEnabled()) {
3048 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargb81597d2022-04-22 19:11:51 +02003049 }
3050
3051 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3052 auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>(&multiview_features);
3053 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features);
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003054 GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargb81597d2022-04-22 19:11:51 +02003055 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003056 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargb81597d2022-04-22 19:11:51 +02003057 }
3058 if (library_features.graphicsPipelineLibrary == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003059 GTEST_SKIP() << "Test requires (unsupported) graphicsPipelineLibrary";
ziga-lunargb81597d2022-04-22 19:11:51 +02003060 }
3061 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003062 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunargb81597d2022-04-22 19:11:51 +02003063 }
3064
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003065 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &dynamic_rendering_features));
ziga-lunargb81597d2022-04-22 19:11:51 +02003066 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3067
3068 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
3069
3070 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
3071 pipeline_rendering_info.colorAttachmentCount = 1;
3072 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
3073
ziga-lunargb81597d2022-04-22 19:11:51 +02003074 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
3075 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
3076 color_blend_state_create_info.attachmentCount = 1;
3077 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
3078
ziga-lunargb81597d2022-04-22 19:11:51 +02003079 CreatePipelineHelper lib1(*this);
3080 lib1.cb_ci_ = color_blend_state_create_info;
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003081 lib1.InitFragmentOutputLibInfo(&pipeline_rendering_info);
ziga-lunargb81597d2022-04-22 19:11:51 +02003082 lib1.gp_ci_.renderPass = VK_NULL_HANDLE;
3083 lib1.InitState();
3084 lib1.CreateGraphicsPipeline();
3085
ziga-lunargb81597d2022-04-22 19:11:51 +02003086 pipeline_rendering_info.viewMask = 0x1;
3087
3088 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
3089
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003090 const auto fs_spv = GLSLToSPV(VK_SHADER_STAGE_FRAGMENT_BIT, bindStateFragShaderText);
3091 auto fs_ci = LvlInitStruct<VkShaderModuleCreateInfo>();
3092 fs_ci.codeSize = fs_spv.size() * sizeof(decltype(fs_spv)::value_type);
3093 fs_ci.pCode = fs_spv.data();
3094
3095 auto fs_stage_ci = LvlInitStruct<VkPipelineShaderStageCreateInfo>(&fs_ci);
3096 fs_stage_ci.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
3097 fs_stage_ci.module = VK_NULL_HANDLE;
3098 fs_stage_ci.pName = "main";
3099
ziga-lunargb81597d2022-04-22 19:11:51 +02003100 CreatePipelineHelper lib2(*this);
3101 lib2.cb_ci_ = color_blend_state_create_info;
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003102 lib2.InitFragmentLibInfo(1, &fs_stage_ci, &pipeline_rendering_info);
ziga-lunargb81597d2022-04-22 19:11:51 +02003103 lib2.gp_ci_.renderPass = VK_NULL_HANDLE;
3104 lib2.ds_ci_ = ds_ci;
3105 lib2.InitState();
3106 lib2.CreateGraphicsPipeline();
ziga-lunargb81597d2022-04-22 19:11:51 +02003107
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003108 pipeline_rendering_info.viewMask = 0;
3109 auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>();
ziga-lunargb81597d2022-04-22 19:11:51 +02003110 library_create_info.libraryCount = 2;
3111 VkPipeline libraries[2] = {lib1.pipeline_, lib2.pipeline_};
3112 library_create_info.pLibraries = libraries;
ziga-lunargb81597d2022-04-22 19:11:51 +02003113
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003114 auto pipe_ci = LvlInitStruct<VkGraphicsPipelineCreateInfo>(&library_create_info);
ziga-lunarg7f25dff2022-05-06 17:49:34 +02003115 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-pLibraries-06627");
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003116 vk_testing::Pipeline pipe(*m_device, pipe_ci);
ziga-lunargb81597d2022-04-22 19:11:51 +02003117 m_errorMonitor->VerifyFound();
3118}
ziga-lunarg2e302312022-04-22 19:47:32 +02003119
3120TEST_F(VkLayerTest, InvalidDynamicRenderingLibraryRenderPass) {
3121 TEST_DESCRIPTION("Create pipeline with invalid library render pass");
3122
3123 SetTargetApiVersion(VK_API_VERSION_1_1);
3124 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3125 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
3126 ASSERT_NO_FATAL_FAILURE(InitFramework());
3127
3128 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003129 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg2e302312022-04-22 19:47:32 +02003130 }
sjfricked700bc02022-05-30 16:35:06 +09003131 if (!AreRequiredExtensionsEnabled()) {
3132 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg2e302312022-04-22 19:47:32 +02003133 }
3134
3135 auto library_features = LvlInitStruct<VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT>();
3136 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&library_features);
sjfricke11db0c72022-08-18 13:23:11 +09003137 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg2e302312022-04-22 19:47:32 +02003138 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003139 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg2e302312022-04-22 19:47:32 +02003140 }
3141 if (library_features.graphicsPipelineLibrary == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003142 GTEST_SKIP() << "Test requires (unsupported) graphicsPipelineLibrary";
ziga-lunarg2e302312022-04-22 19:47:32 +02003143 }
3144
3145 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3146 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3147
3148 VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM;
3149
3150 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
3151 pipeline_rendering_info.colorAttachmentCount = 1;
3152 pipeline_rendering_info.pColorAttachmentFormats = &color_format;
3153
ziga-lunarg2e302312022-04-22 19:47:32 +02003154 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
3155 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
3156 color_blend_state_create_info.attachmentCount = 1;
3157 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
3158
ziga-lunarg2e302312022-04-22 19:47:32 +02003159 CreatePipelineHelper lib(*this);
3160 lib.cb_ci_ = color_blend_state_create_info;
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003161 lib.InitFragmentOutputLibInfo(&pipeline_rendering_info);
ziga-lunarg2e302312022-04-22 19:47:32 +02003162 lib.InitState();
3163 lib.CreateGraphicsPipeline();
ziga-lunarg2e302312022-04-22 19:47:32 +02003164
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003165 auto library_create_info = LvlInitStruct<VkPipelineLibraryCreateInfoKHR>(&pipeline_rendering_info);
ziga-lunarg2e302312022-04-22 19:47:32 +02003166 library_create_info.libraryCount = 1;
3167 library_create_info.pLibraries = &lib.pipeline_;
3168
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003169 const auto fs_spv = GLSLToSPV(VK_SHADER_STAGE_FRAGMENT_BIT, bindStateFragShaderText);
3170 auto fs_ci = LvlInitStruct<VkShaderModuleCreateInfo>();
3171 fs_ci.codeSize = fs_spv.size() * sizeof(decltype(fs_spv)::value_type);
3172 fs_ci.pCode = fs_spv.data();
3173
3174 auto fs_stage_ci = LvlInitStruct<VkPipelineShaderStageCreateInfo>(&fs_ci);
3175 fs_stage_ci.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
3176 fs_stage_ci.module = VK_NULL_HANDLE;
3177 fs_stage_ci.pName = "main";
3178
ziga-lunarg2e302312022-04-22 19:47:32 +02003179 CreatePipelineHelper pipe(*this);
Nathaniel Cesario13da77b2022-07-15 14:51:12 -06003180 pipe.InitFragmentLibInfo(1, &fs_stage_ci, &library_create_info);
ziga-lunarg2e302312022-04-22 19:47:32 +02003181 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3182 pipe.InitState();
3183 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderpass-06625");
3184 pipe.CreateGraphicsPipeline();
3185 m_errorMonitor->VerifyFound();
3186}
ziga-lunarg7ba5a1c2022-04-22 19:56:49 +02003187
3188TEST_F(VkLayerTest, PipelineMissingMultisampleState) {
3189 TEST_DESCRIPTION("Create pipeline with missing multisample state");
3190
3191 SetTargetApiVersion(VK_API_VERSION_1_1);
3192 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3193 AddRequiredExtensions(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
3194 ASSERT_NO_FATAL_FAILURE(InitFramework());
3195
3196 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003197 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7ba5a1c2022-04-22 19:56:49 +02003198 }
sjfricked700bc02022-05-30 16:35:06 +09003199 if (!AreRequiredExtensionsEnabled()) {
3200 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7ba5a1c2022-04-22 19:56:49 +02003201 }
3202
3203 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09003204 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg7ba5a1c2022-04-22 19:56:49 +02003205 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003206 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7ba5a1c2022-04-22 19:56:49 +02003207 }
3208
3209 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3210 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3211
3212 CreatePipelineHelper pipe(*this);
3213 pipe.InitInfo();
3214 pipe.gp_ci_.pMultisampleState = nullptr;
3215 pipe.InitState();
3216 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderpass-06631");
3217 pipe.CreateGraphicsPipeline();
3218 m_errorMonitor->VerifyFound();
ziga-lunarg14222532022-04-22 23:27:17 +02003219}
3220
ziga-lunargd7737482022-04-25 11:16:37 +02003221TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachment) {
3222 TEST_DESCRIPTION("Use invalid VkRenderingFragmentDensityMapAttachmentInfoEXT");
ziga-lunarg14222532022-04-22 23:27:17 +02003223
3224 SetTargetApiVersion(VK_API_VERSION_1_1);
3225 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3226 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3227 ASSERT_NO_FATAL_FAILURE(InitFramework());
3228
3229 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003230 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg14222532022-04-22 23:27:17 +02003231 }
sjfricked700bc02022-05-30 16:35:06 +09003232 if (!AreRequiredExtensionsEnabled()) {
3233 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg14222532022-04-22 23:27:17 +02003234 }
3235
ziga-lunargd7737482022-04-25 11:16:37 +02003236 auto multiview_featuers = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3237 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&multiview_featuers);
sjfricke11db0c72022-08-18 13:23:11 +09003238 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg14222532022-04-22 23:27:17 +02003239 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003240 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg14222532022-04-22 23:27:17 +02003241 }
ziga-lunargd7737482022-04-25 11:16:37 +02003242 if (multiview_featuers.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003243 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunargd7737482022-04-25 11:16:37 +02003244 }
ziga-lunarg14222532022-04-22 23:27:17 +02003245
3246 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3247 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3248
3249 VkImageObj image(m_device);
3250 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
3251 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, VK_IMAGE_TILING_LINEAR, 0);
3252 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3253
3254 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3255 rendering_fragment_density.imageView = image_view;
3256 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3257 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3258 begin_rendering_info.layerCount = 1;
3259
3260 m_commandBuffer->begin();
ziga-lunargd7737482022-04-25 11:16:37 +02003261
ziga-lunarg14222532022-04-22 23:27:17 +02003262 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06157");
3263 m_commandBuffer->BeginRendering(begin_rendering_info);
3264 m_errorMonitor->VerifyFound();
ziga-lunargd7737482022-04-25 11:16:37 +02003265
3266 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3267
3268 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3269 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3270 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
3271 image_create_info.extent = {32, 32, 1};
3272 image_create_info.mipLevels = 1;
3273 image_create_info.arrayLayers = 2;
3274 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
3275 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3276 image_create_info.usage = VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT;
3277 VkImageObj image2(m_device);
3278 image2.Init(image_create_info);
3279 VkImageView image_view2 = image2.targetView(VK_FORMAT_R8G8B8A8_UINT);
3280 rendering_fragment_density.imageView = image_view2;
3281 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06160");
3282 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06109");
3283 m_commandBuffer->BeginRendering(begin_rendering_info);
3284 m_errorMonitor->VerifyFound();
3285
ziga-lunarg14222532022-04-22 23:27:17 +02003286 m_commandBuffer->end();
3287}
ziga-lunarga81df9d2022-04-22 23:33:13 +02003288
3289TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentUsage) {
3290 TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid imageLayout");
3291
3292 SetTargetApiVersion(VK_API_VERSION_1_1);
3293 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3294 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3295 ASSERT_NO_FATAL_FAILURE(InitFramework());
3296
3297 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003298 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarga81df9d2022-04-22 23:33:13 +02003299 }
sjfricked700bc02022-05-30 16:35:06 +09003300 if (!AreRequiredExtensionsEnabled()) {
3301 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarga81df9d2022-04-22 23:33:13 +02003302 }
3303
3304 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09003305 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarga81df9d2022-04-22 23:33:13 +02003306 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003307 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarga81df9d2022-04-22 23:33:13 +02003308 }
3309
3310 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3311 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3312
3313 VkImageObj image(m_device);
3314 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
3315 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3316
3317 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3318 rendering_fragment_density.imageView = image_view;
3319 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3320 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3321 begin_rendering_info.layerCount = 1;
3322
3323 m_commandBuffer->begin();
3324 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06158");
3325 m_commandBuffer->BeginRendering(begin_rendering_info);
3326 m_errorMonitor->VerifyFound();
3327 m_commandBuffer->end();
3328}
ziga-lunarg7c411b32022-04-22 23:37:48 +02003329
3330TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentCreateFlags) {
3331 TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid image create flags");
3332
3333 SetTargetApiVersion(VK_API_VERSION_1_1);
3334 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3335 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3336 ASSERT_NO_FATAL_FAILURE(InitFramework());
3337
3338 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003339 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7c411b32022-04-22 23:37:48 +02003340 }
sjfricked700bc02022-05-30 16:35:06 +09003341 if (!AreRequiredExtensionsEnabled()) {
3342 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7c411b32022-04-22 23:37:48 +02003343 }
3344
3345 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09003346 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg7c411b32022-04-22 23:37:48 +02003347 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003348 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7c411b32022-04-22 23:37:48 +02003349 }
3350
3351 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3352 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3353
3354 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3355 image_create_info.flags = VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT;
3356 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3357 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
3358 image_create_info.extent = {32, 32, 4};
3359 image_create_info.mipLevels = 1;
3360 image_create_info.arrayLayers = 1;
3361 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
3362 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3363 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT;
3364
3365 VkImageObj image(m_device);
3366 image.Init(image_create_info);
3367 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3368
3369 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3370 rendering_fragment_density.imageView = image_view;
3371 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3372 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3373 begin_rendering_info.layerCount = 1;
3374
3375 m_commandBuffer->begin();
3376 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06159");
3377 m_commandBuffer->BeginRendering(begin_rendering_info);
3378 m_errorMonitor->VerifyFound();
3379 m_commandBuffer->end();
3380}
ziga-lunarg66569a72022-04-22 23:43:26 +02003381
3382TEST_F(VkLayerTest, InvalidRenderingFragmentDensityMapAttachmentLayerCount) {
3383 TEST_DESCRIPTION("Use VkRenderingFragmentDensityMapAttachmentInfoEXT with invalid layer count");
3384
3385 SetTargetApiVersion(VK_API_VERSION_1_1);
3386 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3387 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3388 ASSERT_NO_FATAL_FAILURE(InitFramework());
3389
3390 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003391 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg66569a72022-04-22 23:43:26 +02003392 }
sjfricked700bc02022-05-30 16:35:06 +09003393 if (!AreRequiredExtensionsEnabled()) {
3394 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg66569a72022-04-22 23:43:26 +02003395 }
3396
3397 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3398 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&multiview_features);
sjfricke11db0c72022-08-18 13:23:11 +09003399 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg66569a72022-04-22 23:43:26 +02003400 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003401 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg66569a72022-04-22 23:43:26 +02003402 }
3403 if (!multiview_features.multiview) {
sjfricke50955f32022-06-05 10:12:52 +09003404 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg66569a72022-04-22 23:43:26 +02003405 }
3406
3407 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3408 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3409
3410 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3411 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3412 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
3413 image_create_info.extent = {32, 32, 4};
3414 image_create_info.mipLevels = 1;
3415 image_create_info.arrayLayers = 2;
3416 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
3417 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3418 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT;
3419
3420 VkImageObj image(m_device);
3421 image.Init(image_create_info);
3422 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3423
3424 auto rendering_fragment_density = LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
3425 rendering_fragment_density.imageView = image_view;
3426 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3427 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3428 begin_rendering_info.layerCount = 1;
3429 begin_rendering_info.viewMask = 0x1;
3430
3431 m_commandBuffer->begin();
3432 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentDensityMapAttachmentInfoEXT-imageView-06160");
3433 m_commandBuffer->BeginRendering(begin_rendering_info);
3434 m_errorMonitor->VerifyFound();
3435 m_commandBuffer->end();
3436}
ziga-lunarg323c11d2022-04-22 23:56:32 +02003437
3438TEST_F(VkLayerTest, InvalidRenderingPNextImageView) {
3439 TEST_DESCRIPTION(
3440 "Use different image views in VkRenderingFragmentShadingRateAttachmentInfoKHR and "
3441 "VkRenderingFragmentDensityMapAttachmentInfoEXT");
3442
3443 SetTargetApiVersion(VK_API_VERSION_1_1);
3444 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3445 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
3446 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
3447 ASSERT_NO_FATAL_FAILURE(InitFramework());
3448
3449 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003450 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg323c11d2022-04-22 23:56:32 +02003451 }
sjfricked700bc02022-05-30 16:35:06 +09003452 if (!AreRequiredExtensionsEnabled()) {
3453 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg323c11d2022-04-22 23:56:32 +02003454 }
3455
3456 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3457 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&multiview_features);
sjfricke11db0c72022-08-18 13:23:11 +09003458 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg323c11d2022-04-22 23:56:32 +02003459 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003460 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg323c11d2022-04-22 23:56:32 +02003461 }
3462 if (!multiview_features.multiview) {
sjfricke50955f32022-06-05 10:12:52 +09003463 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg323c11d2022-04-22 23:56:32 +02003464 }
3465
3466 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3467 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3468
3469 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
3470
3471 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
sjfricke74a1aad2022-08-17 14:41:33 +09003472 GetPhysicalDeviceProperties2(phys_dev_props_2);
ziga-lunarg323c11d2022-04-22 23:56:32 +02003473
3474 VkImageObj image1(m_device);
3475 image1.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
3476 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR,
3477 VK_IMAGE_TILING_LINEAR, 0);
3478 VkImageView image_view1 = image1.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3479 VkImageObj image2(m_device);
3480 image2.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
3481 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, VK_IMAGE_TILING_LINEAR, 0);
3482 VkImageView image_view2 = image2.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3483
3484 auto rendering_fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
3485 rendering_fragment_shading_rate.imageView = image_view1;
3486 rendering_fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3487 rendering_fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
3488 auto rendering_fragment_density =
3489 LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>(&rendering_fragment_shading_rate);
3490 rendering_fragment_density.imageView = image_view2;
3491 rendering_fragment_density.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
3492 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&rendering_fragment_density);
3493 begin_rendering_info.layerCount = 1;
3494 begin_rendering_info.viewMask = 0x1;
3495
3496 m_commandBuffer->begin();
3497 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06126");
3498 m_commandBuffer->BeginRendering(begin_rendering_info);
3499 m_errorMonitor->VerifyFound();
3500 m_commandBuffer->end();
3501}
ziga-lunarg95f20d42022-04-23 00:06:42 +02003502
3503TEST_F(VkLayerTest, InvalidRenderingRenderArea) {
3504 TEST_DESCRIPTION("Use negative offset in RenderingInfo render area");
3505
3506 SetTargetApiVersion(VK_API_VERSION_1_0);
3507 AddRequiredExtensions(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
3508 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3509 ASSERT_NO_FATAL_FAILURE(InitFramework());
3510
3511 if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
sjfricke50955f32022-06-05 10:12:52 +09003512 GTEST_SKIP() << "Tests for 1.0 only";
ziga-lunarg95f20d42022-04-23 00:06:42 +02003513 }
sjfricked700bc02022-05-30 16:35:06 +09003514 if (!AreRequiredExtensionsEnabled()) {
3515 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg95f20d42022-04-23 00:06:42 +02003516 }
3517
ziga-lunarg95f20d42022-04-23 00:06:42 +02003518 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09003519 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg95f20d42022-04-23 00:06:42 +02003520 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003521 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg95f20d42022-04-23 00:06:42 +02003522 }
3523
3524 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3525 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3526
3527 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3528 begin_rendering_info.layerCount = 1;
3529 begin_rendering_info.renderArea.offset.x = -1;
ziga-lunarg9b6a95f2022-04-23 00:13:38 +02003530 begin_rendering_info.renderArea.extent.width = 32;
3531 begin_rendering_info.renderArea.extent.height = 32;
ziga-lunarg95f20d42022-04-23 00:06:42 +02003532
3533 m_commandBuffer->begin();
3534
3535 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06071");
3536 m_commandBuffer->BeginRendering(begin_rendering_info);
3537 m_errorMonitor->VerifyFound();
3538
3539 begin_rendering_info.renderArea.offset.x = 0;
3540 begin_rendering_info.renderArea.offset.y = -1;
3541
3542 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06072");
3543 m_commandBuffer->BeginRendering(begin_rendering_info);
3544 m_errorMonitor->VerifyFound();
3545
ziga-lunarg9b6a95f2022-04-23 00:13:38 +02003546 begin_rendering_info.renderArea.offset.y = 0;
3547 begin_rendering_info.renderArea.offset.x = m_device->phy().properties().limits.maxFramebufferWidth - 16;
3548 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06073");
3549 m_commandBuffer->BeginRendering(begin_rendering_info);
3550 m_errorMonitor->VerifyFound();
3551
3552 begin_rendering_info.renderArea.offset.x = 0;
3553 begin_rendering_info.renderArea.offset.y = m_device->phy().properties().limits.maxFramebufferHeight - 16;
3554 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-renderArea-06074");
3555 m_commandBuffer->BeginRendering(begin_rendering_info);
3556 m_errorMonitor->VerifyFound();
3557
ziga-lunarg95f20d42022-04-23 00:06:42 +02003558 m_commandBuffer->end();
3559}
ziga-lunarg6662a882022-04-23 00:21:27 +02003560
3561TEST_F(VkLayerTest, InvalidRenderingInfoViewMask) {
3562 TEST_DESCRIPTION("Use negative offset in RenderingInfo render area");
3563
3564 SetTargetApiVersion(VK_API_VERSION_1_1);
3565 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3566 ASSERT_NO_FATAL_FAILURE(InitFramework());
3567
3568 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003569 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg6662a882022-04-23 00:21:27 +02003570 }
sjfricked700bc02022-05-30 16:35:06 +09003571 if (!AreRequiredExtensionsEnabled()) {
3572 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6662a882022-04-23 00:21:27 +02003573 }
3574
3575 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
3576 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(&multiview_features);
sjfricke11db0c72022-08-18 13:23:11 +09003577 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg6662a882022-04-23 00:21:27 +02003578 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003579 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6662a882022-04-23 00:21:27 +02003580 }
3581 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003582 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg6662a882022-04-23 00:21:27 +02003583 }
3584
3585 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3586 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3587
3588 VkPhysicalDeviceMultiviewProperties multiview_props = LvlInitStruct<VkPhysicalDeviceMultiviewProperties>();
3589 VkPhysicalDeviceProperties2 pd_props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&multiview_props);
sjfricke74a1aad2022-08-17 14:41:33 +09003590 GetPhysicalDeviceProperties2(pd_props2);
ziga-lunarg6662a882022-04-23 00:21:27 +02003591
3592 if (multiview_props.maxMultiviewViewCount == 32) {
3593 printf("%s VUID is not testable as maxMultiviewViewCount is 32, skipping test\n", kSkipPrefix);
3594 return;
3595 }
3596
3597 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3598 begin_rendering_info.layerCount = 1;
3599 begin_rendering_info.renderArea.extent.width = 32;
3600 begin_rendering_info.renderArea.extent.height = 32;
3601 begin_rendering_info.viewMask = 1u << multiview_props.maxMultiviewViewCount;
3602
3603 m_commandBuffer->begin();
3604
3605 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-viewMask-06128");
3606 m_commandBuffer->BeginRendering(begin_rendering_info);
3607 m_errorMonitor->VerifyFound();
3608
3609 m_commandBuffer->end();
3610}
ziga-lunargae75b8a2022-04-23 10:54:37 +02003611
3612TEST_F(VkLayerTest, InvalidRenderingColorAttachmentFormat) {
3613 TEST_DESCRIPTION("Use format with missing potential format features in rendering color attachment");
3614
3615 SetTargetApiVersion(VK_API_VERSION_1_1);
3616 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3617 AddRequiredExtensions(VK_NV_LINEAR_COLOR_ATTACHMENT_EXTENSION_NAME);
3618 ASSERT_NO_FATAL_FAILURE(InitFramework());
3619
3620 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003621 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargae75b8a2022-04-23 10:54:37 +02003622 }
sjfricked700bc02022-05-30 16:35:06 +09003623 if (!AreRequiredExtensionsEnabled()) {
3624 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargae75b8a2022-04-23 10:54:37 +02003625 }
3626
3627 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09003628 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargae75b8a2022-04-23 10:54:37 +02003629 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003630 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargae75b8a2022-04-23 10:54:37 +02003631 }
3632
3633 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3634 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3635
3636 VkFormat format = FindSupportedDepthStencilFormat(gpu());
3637 if (format == VK_FORMAT_UNDEFINED) {
3638 printf("%s No Depth + Stencil format found. Skipped.\n", kSkipPrefix);
3639 return;
3640 }
3641
3642 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
3643 pipeline_rendering_info.colorAttachmentCount = 1;
3644 pipeline_rendering_info.pColorAttachmentFormats = &format;
3645
3646 CreatePipelineHelper pipe(*this);
3647 pipe.InitInfo();
3648 pipe.gp_ci_.pNext = &pipeline_rendering_info;
3649 pipe.gp_ci_.renderPass = VK_NULL_HANDLE;
3650 pipe.InitState();
3651
3652 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06582");
3653 pipe.CreateGraphicsPipeline();
3654 m_errorMonitor->VerifyFound();
3655}
ziga-lunargeac390f2022-04-23 11:05:28 +02003656
sjfricke483c1082022-06-05 10:21:44 +09003657TEST_F(VkLayerTest, InvalidResolveModeWithNonIntegerColorFormat) {
3658 TEST_DESCRIPTION("Use invalid resolve mode with non integer color format");
3659
3660 SetTargetApiVersion(VK_API_VERSION_1_1);
3661 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3662 ASSERT_NO_FATAL_FAILURE(InitFramework());
3663
3664 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
3665 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
3666 }
sjfricked700bc02022-05-30 16:35:06 +09003667 if (!AreRequiredExtensionsEnabled()) {
3668 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
sjfricke483c1082022-06-05 10:21:44 +09003669 }
3670
3671 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09003672 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
sjfricke483c1082022-06-05 10:21:44 +09003673 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
3674 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
3675 }
3676
3677 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3678 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3679
3680 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3681 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3682 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; // not int color
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06003683 image_create_info.extent = {32, 32, 1};
sjfricke483c1082022-06-05 10:21:44 +09003684 image_create_info.mipLevels = 1;
3685 image_create_info.arrayLayers = 1;
3686 image_create_info.samples = VK_SAMPLE_COUNT_4_BIT;
3687 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3688 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
3689 VkImageObj image(m_device);
3690 image.Init(image_create_info);
3691 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3692
Tony-LunarGf088c6b2022-07-08 11:29:53 -06003693 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
3694 VkImageObj resolve_image(m_device);
3695 resolve_image.Init(image_create_info);
3696 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3697
sjfricke483c1082022-06-05 10:21:44 +09003698 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3699 color_attachment.imageView = image_view;
3700 color_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT; // not allowed for format
3701 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3702 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
Tony-LunarGf088c6b2022-07-08 11:29:53 -06003703 color_attachment.resolveImageView = resolve_image_view;
sjfricke483c1082022-06-05 10:21:44 +09003704
3705 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3706 begin_rendering_info.colorAttachmentCount = 1;
3707 begin_rendering_info.pColorAttachments = &color_attachment;
3708 begin_rendering_info.layerCount = 1;
3709
3710 m_commandBuffer->begin();
3711
3712 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06129");
3713 m_commandBuffer->BeginRendering(begin_rendering_info);
3714 m_errorMonitor->VerifyFound();
3715
3716 m_commandBuffer->end();
3717}
3718
ziga-lunargeac390f2022-04-23 11:05:28 +02003719TEST_F(VkLayerTest, InvalidResolveModeWithIntegerColorFormat) {
3720 TEST_DESCRIPTION("Use invalid resolve mode with integer color format");
3721
3722 SetTargetApiVersion(VK_API_VERSION_1_1);
3723 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3724 ASSERT_NO_FATAL_FAILURE(InitFramework());
3725
3726 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003727 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargeac390f2022-04-23 11:05:28 +02003728 }
sjfricked700bc02022-05-30 16:35:06 +09003729 if (!AreRequiredExtensionsEnabled()) {
3730 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargeac390f2022-04-23 11:05:28 +02003731 }
3732
3733 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09003734 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargeac390f2022-04-23 11:05:28 +02003735 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003736 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargeac390f2022-04-23 11:05:28 +02003737 }
3738
3739 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3740 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3741
3742 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3743 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3744 image_create_info.format = VK_FORMAT_R8G8B8A8_UINT;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06003745 image_create_info.extent = {32, 32, 1};
ziga-lunargeac390f2022-04-23 11:05:28 +02003746 image_create_info.mipLevels = 1;
3747 image_create_info.arrayLayers = 1;
3748 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
3749 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3750 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
3751 VkImageObj image(m_device);
3752 image.Init(image_create_info);
3753 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
3754
Tony-LunarGf088c6b2022-07-08 11:29:53 -06003755 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
3756 VkImageObj resolve_image(m_device);
3757 resolve_image.Init(image_create_info);
3758 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UINT);
3759
ziga-lunargeac390f2022-04-23 11:05:28 +02003760 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3761 color_attachment.imageView = image_view;
3762 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3763 color_attachment.resolveMode = VK_RESOLVE_MODE_MAX_BIT;
3764 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
Tony-LunarGf088c6b2022-07-08 11:29:53 -06003765 color_attachment.resolveImageView = resolve_image_view;
ziga-lunargeac390f2022-04-23 11:05:28 +02003766
3767 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3768 begin_rendering_info.colorAttachmentCount = 1;
3769 begin_rendering_info.pColorAttachments = &color_attachment;
3770 begin_rendering_info.layerCount = 1;
3771
3772 m_commandBuffer->begin();
3773
3774 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06130");
3775 m_commandBuffer->BeginRendering(begin_rendering_info);
3776 m_errorMonitor->VerifyFound();
3777
3778 m_commandBuffer->end();
3779}
ziga-lunargdf2a3202022-04-23 11:07:46 +02003780
3781TEST_F(VkLayerTest, InvalidResolveModeSamples) {
3782 TEST_DESCRIPTION("Use invalid sample count with resolve mode that is not none");
3783
3784 SetTargetApiVersion(VK_API_VERSION_1_1);
3785 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3786 ASSERT_NO_FATAL_FAILURE(InitFramework());
3787
3788 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003789 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargdf2a3202022-04-23 11:07:46 +02003790 }
sjfricked700bc02022-05-30 16:35:06 +09003791 if (!AreRequiredExtensionsEnabled()) {
3792 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargdf2a3202022-04-23 11:07:46 +02003793 }
3794
3795 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09003796 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargdf2a3202022-04-23 11:07:46 +02003797 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003798 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargdf2a3202022-04-23 11:07:46 +02003799 }
3800
3801 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3802 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3803
3804 VkImageObj image(m_device);
3805 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
3806 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3807
3808 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3809 color_attachment.imageView = image_view;
3810 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3811 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
3812 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
Tony-LunarGf088c6b2022-07-08 11:29:53 -06003813 color_attachment.resolveImageView = image_view;
ziga-lunargdf2a3202022-04-23 11:07:46 +02003814
3815 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3816 begin_rendering_info.colorAttachmentCount = 1;
3817 begin_rendering_info.pColorAttachments = &color_attachment;
3818 begin_rendering_info.layerCount = 1;
3819
3820 m_commandBuffer->begin();
3821
3822 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06132");
3823 m_commandBuffer->BeginRendering(begin_rendering_info);
3824 m_errorMonitor->VerifyFound();
3825
3826 m_commandBuffer->end();
3827}
ziga-lunargb7693aa2022-04-23 11:21:57 +02003828
3829TEST_F(VkLayerTest, InvalidResolveImageViewSamples) {
3830 TEST_DESCRIPTION("Use resolve image view with invalid sample count");
3831
3832 SetTargetApiVersion(VK_API_VERSION_1_1);
3833 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3834 ASSERT_NO_FATAL_FAILURE(InitFramework());
3835
3836 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003837 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargb7693aa2022-04-23 11:21:57 +02003838 }
sjfricked700bc02022-05-30 16:35:06 +09003839 if (!AreRequiredExtensionsEnabled()) {
3840 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargb7693aa2022-04-23 11:21:57 +02003841 }
3842
3843 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09003844 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargb7693aa2022-04-23 11:21:57 +02003845 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003846 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargb7693aa2022-04-23 11:21:57 +02003847 }
3848
3849 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3850 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3851
3852 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3853 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3854 image_create_info.format = VK_FORMAT_R8G8B8A8_UINT;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06003855 image_create_info.extent = {32, 32, 1};
ziga-lunargb7693aa2022-04-23 11:21:57 +02003856 image_create_info.mipLevels = 1;
3857 image_create_info.arrayLayers = 1;
3858 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
3859 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3860 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
3861
3862 VkImageObj image(m_device);
3863 image.Init(image_create_info);
3864 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
3865
3866 VkImageObj resolve_image(m_device);
3867 resolve_image.Init(image_create_info);
3868 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UINT);
3869
3870 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3871 color_attachment.imageView = image_view;
3872 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3873 color_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
3874 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
3875 color_attachment.resolveImageView = resolve_image_view;
3876
3877 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3878 begin_rendering_info.colorAttachmentCount = 1;
3879 begin_rendering_info.pColorAttachments = &color_attachment;
3880 begin_rendering_info.layerCount = 1;
3881
3882 m_commandBuffer->begin();
3883
Tony-LunarG7384f7e2022-07-05 14:20:42 -06003884 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06864");
ziga-lunargb7693aa2022-04-23 11:21:57 +02003885 m_commandBuffer->BeginRendering(begin_rendering_info);
3886 m_errorMonitor->VerifyFound();
3887
Tony-LunarGeb7156a2022-07-26 13:36:31 -06003888 color_attachment.resolveImageView = VK_NULL_HANDLE;
3889 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06860");
3890 m_commandBuffer->BeginRendering(begin_rendering_info);
3891 m_errorMonitor->VerifyFound();
3892
ziga-lunargb7693aa2022-04-23 11:21:57 +02003893 m_commandBuffer->end();
ziga-lunargd12cbce2022-04-23 11:35:20 +02003894}
3895
3896TEST_F(VkLayerTest, InvalidResolveImageViewFormatMatch) {
3897 TEST_DESCRIPTION("Use resolve image view with different format from image view");
3898
3899 SetTargetApiVersion(VK_API_VERSION_1_1);
3900 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3901 ASSERT_NO_FATAL_FAILURE(InitFramework());
3902
3903 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003904 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargd12cbce2022-04-23 11:35:20 +02003905 }
sjfricked700bc02022-05-30 16:35:06 +09003906 if (!AreRequiredExtensionsEnabled()) {
3907 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargd12cbce2022-04-23 11:35:20 +02003908 }
3909
3910 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09003911 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargd12cbce2022-04-23 11:35:20 +02003912 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003913 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargd12cbce2022-04-23 11:35:20 +02003914 }
3915
3916 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3917 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3918
3919 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
3920 image_create_info.imageType = VK_IMAGE_TYPE_2D;
3921 image_create_info.format = VK_FORMAT_R8G8B8A8_UINT;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06003922 image_create_info.extent = {32, 32, 1};
ziga-lunargd12cbce2022-04-23 11:35:20 +02003923 image_create_info.mipLevels = 1;
3924 image_create_info.arrayLayers = 1;
3925 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
3926 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
3927 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
3928
3929 VkImageObj image(m_device);
3930 image.Init(image_create_info);
3931 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UINT);
3932
3933 VkImageObj resolve_image(m_device);
3934 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
3935 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3936
3937 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3938 color_attachment.imageView = image_view;
3939 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3940 color_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
3941 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL;
3942 color_attachment.resolveImageView = resolve_image_view;
3943
3944 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3945 begin_rendering_info.colorAttachmentCount = 1;
3946 begin_rendering_info.pColorAttachments = &color_attachment;
3947 begin_rendering_info.layerCount = 1;
3948
3949 m_commandBuffer->begin();
3950
Tony-LunarG7384f7e2022-07-05 14:20:42 -06003951 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06865");
ziga-lunargd12cbce2022-04-23 11:35:20 +02003952 m_commandBuffer->BeginRendering(begin_rendering_info);
3953 m_errorMonitor->VerifyFound();
3954
3955 m_commandBuffer->end();
3956}
ziga-lunarge579a3b2022-04-23 11:38:02 +02003957
3958TEST_F(VkLayerTest, InvalidRenderingAttachmentImageViewLayout) {
3959 TEST_DESCRIPTION("Use rendering attachment image view with invalid layout");
3960
3961 SetTargetApiVersion(VK_API_VERSION_1_1);
3962 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
3963 ASSERT_NO_FATAL_FAILURE(InitFramework());
3964
3965 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09003966 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge579a3b2022-04-23 11:38:02 +02003967 }
sjfricked700bc02022-05-30 16:35:06 +09003968 if (!AreRequiredExtensionsEnabled()) {
3969 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge579a3b2022-04-23 11:38:02 +02003970 }
3971
3972 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09003973 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarge579a3b2022-04-23 11:38:02 +02003974 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09003975 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge579a3b2022-04-23 11:38:02 +02003976 }
3977
3978 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
3979 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
3980
3981 VkImageObj image(m_device);
3982 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
3983 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
3984
3985 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
3986 color_attachment.imageView = image_view;
3987 color_attachment.imageLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
3988
3989 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
3990 begin_rendering_info.colorAttachmentCount = 1;
3991 begin_rendering_info.pColorAttachments = &color_attachment;
3992 begin_rendering_info.layerCount = 1;
3993
3994 m_commandBuffer->begin();
3995
3996 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06135");
3997 m_commandBuffer->BeginRendering(begin_rendering_info);
3998 m_errorMonitor->VerifyFound();
3999
4000 m_commandBuffer->end();
4001}
ziga-lunarg409f8212022-04-23 11:40:53 +02004002
4003TEST_F(VkLayerTest, InvalidResolveImageViewLayout) {
4004 TEST_DESCRIPTION("Use resolve image view with invalid layout");
4005
4006 SetTargetApiVersion(VK_API_VERSION_1_1);
4007 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4008 ASSERT_NO_FATAL_FAILURE(InitFramework());
4009
4010 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004011 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg409f8212022-04-23 11:40:53 +02004012 }
sjfricked700bc02022-05-30 16:35:06 +09004013 if (!AreRequiredExtensionsEnabled()) {
4014 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg409f8212022-04-23 11:40:53 +02004015 }
4016
4017 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09004018 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg409f8212022-04-23 11:40:53 +02004019 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004020 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg409f8212022-04-23 11:40:53 +02004021 }
4022
4023 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4024 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4025
4026 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4027 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4028 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004029 image_create_info.extent = {32, 32, 1};
ziga-lunarg409f8212022-04-23 11:40:53 +02004030 image_create_info.mipLevels = 1;
4031 image_create_info.arrayLayers = 1;
4032 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4033 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4034 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4035
4036 VkImageObj image(m_device);
4037 image.Init(image_create_info);
4038 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4039
4040 VkImageObj resolve_image(m_device);
4041 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4042 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4043
4044 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4045 color_attachment.imageView = image_view;
4046 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4047 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4048 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
4049 color_attachment.resolveImageView = resolve_image_view;
4050
4051 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4052 begin_rendering_info.colorAttachmentCount = 1;
4053 begin_rendering_info.pColorAttachments = &color_attachment;
4054 begin_rendering_info.layerCount = 1;
4055
4056 m_commandBuffer->begin();
4057
4058 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06136");
4059 m_commandBuffer->BeginRendering(begin_rendering_info);
4060 m_errorMonitor->VerifyFound();
4061
4062 m_commandBuffer->end();
4063}
ziga-lunargbbbef242022-04-23 12:12:10 +02004064
4065TEST_F(VkLayerTest, InvalidResolveImageViewLayoutSeparateDepthStencil) {
4066 TEST_DESCRIPTION("Use resolve image view with invalid layout");
4067
4068 SetTargetApiVersion(VK_API_VERSION_1_1);
4069 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4070 AddRequiredExtensions(VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_EXTENSION_NAME);
4071 ASSERT_NO_FATAL_FAILURE(InitFramework());
4072
4073 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004074 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargbbbef242022-04-23 12:12:10 +02004075 }
sjfricked700bc02022-05-30 16:35:06 +09004076 if (!AreRequiredExtensionsEnabled()) {
4077 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargbbbef242022-04-23 12:12:10 +02004078 }
4079
4080 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09004081 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargbbbef242022-04-23 12:12:10 +02004082 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004083 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargbbbef242022-04-23 12:12:10 +02004084 }
4085
4086 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4087 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4088
4089 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4090 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4091 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004092 image_create_info.extent = {32, 32, 1};
ziga-lunargbbbef242022-04-23 12:12:10 +02004093 image_create_info.mipLevels = 1;
4094 image_create_info.arrayLayers = 1;
4095 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4096 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4097 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4098
4099 VkImageObj image(m_device);
4100 image.Init(image_create_info);
4101 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4102
4103 VkImageObj resolve_image(m_device);
4104 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4105 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4106
4107 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4108 color_attachment.imageView = image_view;
4109 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4110 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4111 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL;
4112 color_attachment.resolveImageView = resolve_image_view;
4113
4114 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4115 begin_rendering_info.colorAttachmentCount = 1;
4116 begin_rendering_info.pColorAttachments = &color_attachment;
4117 begin_rendering_info.layerCount = 1;
4118
4119 m_commandBuffer->begin();
4120
4121 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06137");
4122 m_commandBuffer->BeginRendering(begin_rendering_info);
4123 m_errorMonitor->VerifyFound();
4124
4125 m_commandBuffer->end();
4126}
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004127
4128TEST_F(VkLayerTest, InvalidRenderingAttachmentImageViewShadingRateLayout) {
4129 TEST_DESCRIPTION("Use image view with invalid layout");
4130
4131 SetTargetApiVersion(VK_API_VERSION_1_1);
4132 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
sjfricke6e8fb402022-06-05 09:47:58 +09004133 AddOptionalExtensions(VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME);
4134 AddOptionalExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004135 ASSERT_NO_FATAL_FAILURE(InitFramework());
4136
4137 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004138 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004139 }
sjfricked700bc02022-05-30 16:35:06 +09004140 if (!AreRequiredExtensionsEnabled()) {
4141 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004142 }
4143
sjfricke6e8fb402022-06-05 09:47:58 +09004144 const bool nv_shading_rate = IsExtensionsEnabled(VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME);
4145 const bool khr_fragment_shading = IsExtensionsEnabled(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
4146 if (!khr_fragment_shading && !nv_shading_rate) {
4147 GTEST_SKIP() << "shading rate / fragment shading not supported";
4148 }
4149
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004150 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09004151 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004152 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004153 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004154 }
4155
4156 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4157 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4158
4159 VkImageObj image(m_device);
4160 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4161 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4162
4163 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4164 color_attachment.imageView = image_view;
4165 color_attachment.imageLayout = VK_IMAGE_LAYOUT_SHADING_RATE_OPTIMAL_NV;
4166
4167 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4168 begin_rendering_info.colorAttachmentCount = 1;
4169 begin_rendering_info.pColorAttachments = &color_attachment;
4170 begin_rendering_info.layerCount = 1;
4171
4172 m_commandBuffer->begin();
4173
sjfricke6e8fb402022-06-05 09:47:58 +09004174 // SHADING_RATE_OPTIMAL_NV is aliased FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR so VU depends on which extensions
4175 const char *vuid =
4176 khr_fragment_shading ? "VUID-VkRenderingAttachmentInfo-imageView-06143" : "VUID-VkRenderingAttachmentInfo-imageView-06138";
4177 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid);
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004178 m_commandBuffer->BeginRendering(begin_rendering_info);
4179 m_errorMonitor->VerifyFound();
4180
4181 m_commandBuffer->end();
4182}
4183
4184TEST_F(VkLayerTest, InvalidResolveImageViewShadingRateLayout) {
4185 TEST_DESCRIPTION("Use resolve image view with invalid shading ratelayout");
4186
4187 SetTargetApiVersion(VK_API_VERSION_1_1);
4188 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
sjfricke6e8fb402022-06-05 09:47:58 +09004189 AddOptionalExtensions(VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME);
4190 AddOptionalExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004191 ASSERT_NO_FATAL_FAILURE(InitFramework());
4192
4193 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004194 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004195 }
sjfricked700bc02022-05-30 16:35:06 +09004196 if (!AreRequiredExtensionsEnabled()) {
4197 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004198 }
4199
sjfricke6e8fb402022-06-05 09:47:58 +09004200 const bool nv_shading_rate = IsExtensionsEnabled(VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME);
4201 const bool khr_fragment_shading = IsExtensionsEnabled(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
4202 if (!khr_fragment_shading && !nv_shading_rate) {
4203 GTEST_SKIP() << "shading rate / fragment shading not supported";
4204 }
4205
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004206 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09004207 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004208 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004209 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004210 }
4211
4212 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4213 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4214
4215 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4216 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4217 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004218 image_create_info.extent = {32, 32, 1};
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004219 image_create_info.mipLevels = 1;
4220 image_create_info.arrayLayers = 1;
4221 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4222 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4223 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4224
4225 VkImageObj image(m_device);
4226 image.Init(image_create_info);
4227 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4228
4229 VkImageObj resolve_image(m_device);
4230 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4231 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4232
4233 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4234 color_attachment.imageView = image_view;
4235 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4236 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4237 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_SHADING_RATE_OPTIMAL_NV;
4238 color_attachment.resolveImageView = resolve_image_view;
4239
4240 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4241 begin_rendering_info.colorAttachmentCount = 1;
4242 begin_rendering_info.pColorAttachments = &color_attachment;
4243 begin_rendering_info.layerCount = 1;
4244
4245 m_commandBuffer->begin();
4246
sjfricke6e8fb402022-06-05 09:47:58 +09004247 // SHADING_RATE_OPTIMAL_NV is aliased FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR so VU depends on which extensions
4248 const char *vuid =
4249 khr_fragment_shading ? "VUID-VkRenderingAttachmentInfo-imageView-06144" : "VUID-VkRenderingAttachmentInfo-imageView-06139";
4250 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, vuid);
ziga-lunarg7d2c1112022-04-23 12:17:33 +02004251 m_commandBuffer->BeginRendering(begin_rendering_info);
4252 m_errorMonitor->VerifyFound();
4253
4254 m_commandBuffer->end();
4255}
ziga-lunarge7503952022-04-23 12:19:14 +02004256
4257TEST_F(VkLayerTest, InvalidRenderingAttachmentImageViewFragmentDensityLayout) {
4258 TEST_DESCRIPTION("Use image view with invalid layout");
4259
4260 SetTargetApiVersion(VK_API_VERSION_1_1);
4261 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4262 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
4263 ASSERT_NO_FATAL_FAILURE(InitFramework());
4264
4265 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004266 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge7503952022-04-23 12:19:14 +02004267 }
sjfricked700bc02022-05-30 16:35:06 +09004268 if (!AreRequiredExtensionsEnabled()) {
4269 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge7503952022-04-23 12:19:14 +02004270 }
4271
4272 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09004273 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarge7503952022-04-23 12:19:14 +02004274 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004275 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge7503952022-04-23 12:19:14 +02004276 }
4277
4278 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4279 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4280
4281 VkImageObj image(m_device);
4282 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4283 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4284
4285 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4286 color_attachment.imageView = image_view;
4287 color_attachment.imageLayout = VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT;
4288
4289 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4290 begin_rendering_info.colorAttachmentCount = 1;
4291 begin_rendering_info.pColorAttachments = &color_attachment;
4292 begin_rendering_info.layerCount = 1;
4293
4294 m_commandBuffer->begin();
4295
4296 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06140");
4297 m_commandBuffer->BeginRendering(begin_rendering_info);
4298 m_errorMonitor->VerifyFound();
4299
4300 m_commandBuffer->end();
ziga-lunarg10cd0fb2022-04-23 12:20:46 +02004301}
4302
4303TEST_F(VkLayerTest, InvalidResolveImageViewFragmentDensityLayout) {
4304 TEST_DESCRIPTION("Use resolve image view with invalid fragment density layout");
4305
4306 SetTargetApiVersion(VK_API_VERSION_1_1);
4307 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4308 AddRequiredExtensions(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
4309 ASSERT_NO_FATAL_FAILURE(InitFramework());
4310
4311 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004312 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg10cd0fb2022-04-23 12:20:46 +02004313 }
sjfricked700bc02022-05-30 16:35:06 +09004314 if (!AreRequiredExtensionsEnabled()) {
4315 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg10cd0fb2022-04-23 12:20:46 +02004316 }
4317
4318 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09004319 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg10cd0fb2022-04-23 12:20:46 +02004320 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004321 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg10cd0fb2022-04-23 12:20:46 +02004322 }
4323
4324 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4325 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4326
4327 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4328 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4329 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
4330 image_create_info.extent = {32, 32, 4};
4331 image_create_info.mipLevels = 1;
4332 image_create_info.arrayLayers = 1;
4333 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4334 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4335 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4336
4337 VkImageObj image(m_device);
4338 image.Init(image_create_info);
4339 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4340
4341 VkImageObj resolve_image(m_device);
4342 resolve_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
4343 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4344
4345 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4346 color_attachment.imageView = image_view;
4347 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4348 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4349 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT;
4350 color_attachment.resolveImageView = resolve_image_view;
4351
4352 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4353 begin_rendering_info.colorAttachmentCount = 1;
4354 begin_rendering_info.pColorAttachments = &color_attachment;
4355 begin_rendering_info.layerCount = 1;
4356
4357 m_commandBuffer->begin();
4358
4359 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06141");
4360 m_commandBuffer->BeginRendering(begin_rendering_info);
4361 m_errorMonitor->VerifyFound();
4362
4363 m_commandBuffer->end();
4364}
ziga-lunargdfa31d12022-04-23 12:22:18 +02004365
4366TEST_F(VkLayerTest, InvalidResolveImageViewReadOnlyOptimalLayout) {
4367 TEST_DESCRIPTION("Use resolve image view with invalid read only optimal layout");
4368
4369 SetTargetApiVersion(VK_API_VERSION_1_1);
4370 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4371 ASSERT_NO_FATAL_FAILURE(InitFramework());
4372
4373 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004374 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunargdfa31d12022-04-23 12:22:18 +02004375 }
sjfricked700bc02022-05-30 16:35:06 +09004376 if (!AreRequiredExtensionsEnabled()) {
4377 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunargdfa31d12022-04-23 12:22:18 +02004378 }
4379
4380 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
sjfricke11db0c72022-08-18 13:23:11 +09004381 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunargdfa31d12022-04-23 12:22:18 +02004382 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004383 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunargdfa31d12022-04-23 12:22:18 +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;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004392 image_create_info.extent = {32, 32, 1};
ziga-lunargdfa31d12022-04-23 12:22:18 +02004393 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_READ_ONLY_OPTIMAL;
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-06142");
4422 m_commandBuffer->BeginRendering(begin_rendering_info);
4423 m_errorMonitor->VerifyFound();
4424
4425 m_commandBuffer->end();
4426}
ziga-lunarg735aa322022-04-24 14:17:47 +02004427
4428TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRateImageView) {
4429 TEST_DESCRIPTION("Test BeginRenderingInfo image view with FragmentShadingRateAttachment.");
4430
4431 SetTargetApiVersion(VK_API_VERSION_1_1);
4432 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4433 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
4434
4435 ASSERT_NO_FATAL_FAILURE(InitFramework());
4436
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004437 if (IsDriver(VK_DRIVER_ID_AMD_PROPRIETARY)) {
4438 GTEST_SKIP() << "Skipping on AMD proprietary driver pending further investigation.";
4439 }
4440
ziga-lunarg735aa322022-04-24 14:17:47 +02004441 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004442 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg735aa322022-04-24 14:17:47 +02004443 }
4444
sjfricked700bc02022-05-30 16:35:06 +09004445 if (!AreRequiredExtensionsEnabled()) {
4446 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg735aa322022-04-24 14:17:47 +02004447 }
4448
4449 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09004450 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg735aa322022-04-24 14:17:47 +02004451
4452 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004453 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg735aa322022-04-24 14:17:47 +02004454 }
4455
4456 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
4457
4458 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
sjfricke74a1aad2022-08-17 14:41:33 +09004459 GetPhysicalDeviceProperties2(phys_dev_props_2);
ziga-lunarg735aa322022-04-24 14:17:47 +02004460
4461 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4462 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4463
4464 VkImageObj image(m_device);
4465 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
4466 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR,
4467 VK_IMAGE_TILING_LINEAR, 0);
4468 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4469
4470 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
4471 fragment_shading_rate.imageView = image_view;
4472 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4473 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
4474
4475 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
4476 begin_rendering_info.layerCount = 1;
4477
4478 m_commandBuffer->begin();
4479
4480 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingFragmentShadingRateAttachmentInfoKHR-imageView-06147");
4481 m_commandBuffer->BeginRendering(begin_rendering_info);
4482 m_errorMonitor->VerifyFound();
4483
4484 m_commandBuffer->end();
4485}
ziga-lunarg644c0552022-04-24 17:50:58 +02004486
4487TEST_F(VkLayerTest, TestRenderingInfoColorAttachment) {
4488 TEST_DESCRIPTION("Test RenderingInfo color attachment.");
4489
4490 SetTargetApiVersion(VK_API_VERSION_1_1);
4491 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4492
4493 ASSERT_NO_FATAL_FAILURE(InitFramework());
4494
4495 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004496 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg644c0552022-04-24 17:50:58 +02004497 }
4498
sjfricked700bc02022-05-30 16:35:06 +09004499 if (!AreRequiredExtensionsEnabled()) {
4500 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg644c0552022-04-24 17:50:58 +02004501 }
4502
4503 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09004504 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg644c0552022-04-24 17:50:58 +02004505
4506 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004507 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg644c0552022-04-24 17:50:58 +02004508 }
4509
4510 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4511 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4512
4513 VkImageObj invalid_image(m_device);
4514 invalid_image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_SAMPLED_BIT, VK_IMAGE_TILING_LINEAR, 0);
4515 VkImageView invalid_image_view = invalid_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4516
4517 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4518 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4519 image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004520 image_create_info.extent = {32, 32, 1};
ziga-lunarg644c0552022-04-24 17:50:58 +02004521 image_create_info.mipLevels = 1;
4522 image_create_info.arrayLayers = 1;
4523 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4524 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4525 image_create_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4526 image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
4527 VkImageObj image(m_device);
4528 image.Init(image_create_info);
4529 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4530
Tony-LunarGf088c6b2022-07-08 11:29:53 -06004531 image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
4532 VkImageObj resolve_image(m_device);
4533 resolve_image.Init(image_create_info);
4534 VkImageView resolve_image_view = resolve_image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
4535
ziga-lunarg644c0552022-04-24 17:50:58 +02004536 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4537 color_attachment.imageView = invalid_image_view;
4538 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
Tony-LunarGf088c6b2022-07-08 11:29:53 -06004539 color_attachment.resolveImageView = resolve_image_view;
ziga-lunarg644c0552022-04-24 17:50:58 +02004540
4541 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4542 begin_rendering_info.layerCount = 1;
4543 begin_rendering_info.colorAttachmentCount = 1;
4544 begin_rendering_info.pColorAttachments = &color_attachment;
4545
4546 m_commandBuffer->begin();
4547
4548 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06087");
4549 m_commandBuffer->BeginRendering(begin_rendering_info);
4550 m_errorMonitor->VerifyFound();
4551
4552 color_attachment.imageView = image_view;
4553 color_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4554
4555 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06090");
4556 m_commandBuffer->BeginRendering(begin_rendering_info);
4557 m_errorMonitor->VerifyFound();
4558
4559 color_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
4560 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06096");
4561 m_commandBuffer->BeginRendering(begin_rendering_info);
4562 m_errorMonitor->VerifyFound();
4563
4564 color_attachment.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL;
4565 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06100");
4566 m_commandBuffer->BeginRendering(begin_rendering_info);
4567 m_errorMonitor->VerifyFound();
4568
4569 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4570 color_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4571 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4572
4573 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06091");
4574 m_commandBuffer->BeginRendering(begin_rendering_info);
4575 m_errorMonitor->VerifyFound();
4576
4577 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
4578 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06097");
4579 m_commandBuffer->BeginRendering(begin_rendering_info);
4580 m_errorMonitor->VerifyFound();
4581
4582 color_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
4583 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06101");
4584 m_commandBuffer->BeginRendering(begin_rendering_info);
4585 m_errorMonitor->VerifyFound();
4586
4587 color_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
sjfricke483c1082022-06-05 10:21:44 +09004588
ziga-lunarg644c0552022-04-24 17:50:58 +02004589 const uint32_t max_color_attachments = m_device->phy().properties().limits.maxColorAttachments + 1;
4590 std::vector<VkRenderingAttachmentInfoKHR> color_attachments(max_color_attachments);
4591 for (auto &attachment : color_attachments) {
4592 attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
4593 attachment.imageView = image_view;
4594 attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4595 }
4596 begin_rendering_info.colorAttachmentCount = max_color_attachments;
4597 begin_rendering_info.pColorAttachments = color_attachments.data();
4598 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-colorAttachmentCount-06106");
4599 m_commandBuffer->BeginRendering(begin_rendering_info);
4600 m_errorMonitor->VerifyFound();
4601
4602 m_commandBuffer->end();
4603}
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004604
4605TEST_F(VkLayerTest, TestRenderingInfoDepthAttachment) {
4606 TEST_DESCRIPTION("Test RenderingInfo depth attachment.");
4607
4608 SetTargetApiVersion(VK_API_VERSION_1_1);
4609 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4610 AddRequiredExtensions(VK_KHR_DEPTH_STENCIL_RESOLVE_EXTENSION_NAME);
4611
4612 ASSERT_NO_FATAL_FAILURE(InitFramework());
4613
4614 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004615 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004616 }
4617
sjfricked700bc02022-05-30 16:35:06 +09004618 if (!AreRequiredExtensionsEnabled()) {
4619 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004620 }
4621
4622 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09004623 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004624
4625 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004626 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004627 }
4628
4629 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4630 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4631
4632 VkFormat ds_format = FindSupportedDepthStencilFormat(gpu());
4633 if (ds_format == VK_FORMAT_UNDEFINED) {
4634 printf("%s No Depth + Stencil format found, skipping test..\n", kSkipPrefix);
4635 return;
4636 }
4637
4638 auto depth_stencil_resolve_properties = LvlInitStruct<VkPhysicalDeviceDepthStencilResolveProperties>();
4639 auto properties2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&depth_stencil_resolve_properties);
sjfricke74a1aad2022-08-17 14:41:33 +09004640 GetPhysicalDeviceProperties2(properties2);
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004641 bool has_depth_resolve_mode_average =
4642 (depth_stencil_resolve_properties.supportedDepthResolveModes & VK_RESOLVE_MODE_AVERAGE_BIT) != 0;
4643 bool has_stencil_resolve_mode_average =
4644 (depth_stencil_resolve_properties.supportedStencilResolveModes & VK_RESOLVE_MODE_AVERAGE_BIT) != 0;
4645
4646 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
4647 image_create_info.imageType = VK_IMAGE_TYPE_2D;
4648 image_create_info.format = ds_format;
4649 image_create_info.extent = {32, 32, 1};
4650 image_create_info.mipLevels = 1;
4651 image_create_info.arrayLayers = 1;
4652 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
4653 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
4654 image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
4655 VkImageObj image(m_device);
4656 image.Init(image_create_info);
4657
4658 VkImageObj depth_image(m_device);
4659 depth_image.Init(image_create_info);
4660 VkImageView depth_image_view = depth_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4661 VkImageObj stencil_image(m_device);
4662 stencil_image.Init(image_create_info);
4663 VkImageView stencil_image_view = stencil_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4664
4665 VkImageObj depth_resolvel_image(m_device);
4666 depth_resolvel_image.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0);
4667 VkImageView depth_resolve_image_view =
4668 depth_resolvel_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4669
4670 VkImageObj stencil_resolvel_image(m_device);
4671 stencil_resolvel_image.Init(32, 32, 1, ds_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0);
4672 VkImageView stencil_resolve_image_view =
4673 stencil_resolvel_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
4674
4675 VkImageObj invalid_image(m_device);
4676 image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
4677 invalid_image.Init(image_create_info);
4678 VkImageView invalid_image_view = invalid_image.targetView(ds_format, VK_IMAGE_ASPECT_DEPTH_BIT);
4679
4680 auto depth_attachment = LvlInitStruct<VkRenderingAttachmentInfo>();
4681 depth_attachment.imageView = depth_image_view;
4682 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4683
4684 auto stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfo>();
4685 stencil_attachment.imageView = stencil_image_view;
4686 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4687
4688 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4689 begin_rendering_info.layerCount = 1;
4690 begin_rendering_info.pDepthAttachment = &depth_attachment;
4691 begin_rendering_info.pStencilAttachment = &stencil_attachment;
4692
4693 m_commandBuffer->begin();
4694
4695 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06085");
4696 m_commandBuffer->BeginRendering(begin_rendering_info);
4697 m_errorMonitor->VerifyFound();
4698
4699 depth_attachment.imageView = VK_NULL_HANDLE;
4700 stencil_attachment.imageView = VK_NULL_HANDLE;
4701 depth_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4702 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4703 depth_attachment.resolveImageView = depth_resolve_image_view;
4704 stencil_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4705 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4706 stencil_attachment.resolveImageView = stencil_resolve_image_view;
4707
4708 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06086");
4709 m_commandBuffer->BeginRendering(begin_rendering_info);
4710 m_errorMonitor->VerifyFound();
4711
4712 depth_attachment.imageView = depth_image_view;
4713 stencil_attachment.imageView = depth_image_view;
4714 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4715 stencil_attachment.resolveImageView = depth_resolve_image_view;
4716
4717 if (!has_depth_resolve_mode_average) {
4718 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06102");
4719 }
4720 if (!has_stencil_resolve_mode_average) {
4721 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06103");
4722 }
4723 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06093");
4724 m_commandBuffer->BeginRendering(begin_rendering_info);
4725 m_errorMonitor->VerifyFound();
4726
4727 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
4728 if (has_depth_resolve_mode_average && has_stencil_resolve_mode_average) {
4729 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06098");
4730 m_commandBuffer->BeginRendering(begin_rendering_info);
4731 m_errorMonitor->VerifyFound();
4732 }
4733
4734 depth_attachment.imageView = invalid_image_view;
4735 stencil_attachment.imageView = invalid_image_view;
4736 depth_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
4737 stencil_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
4738 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06088");
4739 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06089");
4740 m_commandBuffer->BeginRendering(begin_rendering_info);
4741 m_errorMonitor->VerifyFound();
4742
4743 depth_attachment.imageView = depth_image_view;
4744 stencil_attachment.imageView = depth_image_view;
4745 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4746 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06092");
4747 m_commandBuffer->BeginRendering(begin_rendering_info);
4748 m_errorMonitor->VerifyFound();
4749
4750 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4751 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4752 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4753 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
4754 depth_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4755 if (depth_stencil_resolve_properties.independentResolveNone == VK_FALSE && has_depth_resolve_mode_average) {
4756 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06104");
4757 m_commandBuffer->BeginRendering(begin_rendering_info);
4758 m_errorMonitor->VerifyFound();
4759 }
4760 if (depth_stencil_resolve_properties.independentResolve == VK_FALSE && has_depth_resolve_mode_average) {
4761 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pDepthAttachment-06105");
4762 m_commandBuffer->BeginRendering(begin_rendering_info);
4763 m_errorMonitor->VerifyFound();
4764 }
4765
ziga-lunargf35a7d72022-04-25 01:00:41 +02004766 stencil_attachment.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
4767 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4768 if (has_stencil_resolve_mode_average) {
4769 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06095");
4770 m_commandBuffer->BeginRendering(begin_rendering_info);
4771 m_errorMonitor->VerifyFound();
4772 }
4773 stencil_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL;
4774 if (has_stencil_resolve_mode_average) {
4775 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06099");
4776 m_commandBuffer->BeginRendering(begin_rendering_info);
4777 m_errorMonitor->VerifyFound();
4778 }
4779
4780 depth_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
4781 stencil_attachment.resolveMode = VK_RESOLVE_MODE_NONE;
4782 stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
4783 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pStencilAttachment-06094");
4784 m_commandBuffer->BeginRendering(begin_rendering_info);
4785 m_errorMonitor->VerifyFound();
4786
ziga-lunarg7a69bd92022-04-25 00:33:18 +02004787 m_commandBuffer->end();
4788}
ziga-lunarg002e6562022-04-25 00:54:16 +02004789
4790TEST_F(VkLayerTest, InvalidRenderingRenderAreaWithDeviceGroupExt) {
4791 TEST_DESCRIPTION("Use negative offset in RenderingInfo render area");
4792
4793 SetTargetApiVersion(VK_API_VERSION_1_1);
4794 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4795 ASSERT_NO_FATAL_FAILURE(InitFramework());
4796
4797 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004798 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg002e6562022-04-25 00:54:16 +02004799 }
sjfricked700bc02022-05-30 16:35:06 +09004800 if (!AreRequiredExtensionsEnabled()) {
4801 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg002e6562022-04-25 00:54:16 +02004802 }
4803
4804 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09004805 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
4806 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
4807 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
4808 }
ziga-lunarg002e6562022-04-25 00:54:16 +02004809
4810 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4811 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4812
4813 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4814 begin_rendering_info.layerCount = 1;
4815 begin_rendering_info.renderArea.offset.x = -1;
4816 begin_rendering_info.renderArea.extent.width = 32;
4817 begin_rendering_info.renderArea.extent.height = 32;
4818
4819 m_commandBuffer->begin();
4820
4821 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06077");
4822 m_commandBuffer->BeginRendering(begin_rendering_info);
4823 m_errorMonitor->VerifyFound();
4824
4825 begin_rendering_info.renderArea.offset.x = 0;
4826 begin_rendering_info.renderArea.offset.y = -1;
4827
4828 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06078");
4829 m_commandBuffer->BeginRendering(begin_rendering_info);
4830 m_errorMonitor->VerifyFound();
4831
4832 m_commandBuffer->end();
4833}
ziga-lunarg6e4f9da2022-04-25 01:05:22 +02004834
4835TEST_F(VkLayerTest, TestDynamicRenderingPipeline) {
4836 TEST_DESCRIPTION("Use pipeline created with render pass in dynamic render pass.");
4837
4838 SetTargetApiVersion(VK_API_VERSION_1_1);
4839 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4840
4841 ASSERT_NO_FATAL_FAILURE(InitFramework());
4842
4843 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09004844 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarg6e4f9da2022-04-25 01:05:22 +02004845 }
4846
sjfricked700bc02022-05-30 16:35:06 +09004847 if (!AreRequiredExtensionsEnabled()) {
4848 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg6e4f9da2022-04-25 01:05:22 +02004849 }
4850
4851 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09004852 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarg6e4f9da2022-04-25 01:05:22 +02004853
4854 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004855 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg6e4f9da2022-04-25 01:05:22 +02004856 }
4857
4858 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
4859 ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
4860
4861 CreatePipelineHelper pipe(*this);
4862 pipe.InitInfo();
4863 pipe.InitState();
4864 pipe.CreateGraphicsPipeline();
4865
4866 auto begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
4867 begin_rendering_info.layerCount = 1;
4868
4869 m_commandBuffer->begin();
4870 m_commandBuffer->BeginRendering(begin_rendering_info);
4871
4872 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.pipeline_);
4873 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-renderPass-06198");
4874 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
4875 m_errorMonitor->VerifyFound();
4876
4877 m_commandBuffer->EndRendering();
4878 m_commandBuffer->end();
ziga-lunarg67551632022-04-25 15:20:20 +02004879}
4880
4881TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRateAttachmentSize) {
4882 TEST_DESCRIPTION("Test FragmentShadingRateAttachment size.");
4883
4884 SetTargetApiVersion(VK_API_VERSION_1_0);
4885 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
4886 AddRequiredExtensions(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004887 AddRequiredExtensions(VK_KHR_MULTIVIEW_EXTENSION_NAME);
ziga-lunarg67551632022-04-25 15:20:20 +02004888
4889 ASSERT_NO_FATAL_FAILURE(InitFramework());
4890
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004891 if (IsDriver(VK_DRIVER_ID_AMD_PROPRIETARY)) {
4892 GTEST_SKIP() << "Skipping on AMD proprietary driver pending further investigation.";
4893 }
4894
ziga-lunarg67551632022-04-25 15:20:20 +02004895 if (DeviceValidationVersion() != VK_API_VERSION_1_0) {
sjfricke50955f32022-06-05 10:12:52 +09004896 GTEST_SKIP() << "Tests for 1.0 only";
ziga-lunarg67551632022-04-25 15:20:20 +02004897 }
4898
sjfricked700bc02022-05-30 16:35:06 +09004899 if (!AreRequiredExtensionsEnabled()) {
4900 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarg67551632022-04-25 15:20:20 +02004901 }
4902
ziga-lunarg67551632022-04-25 15:20:20 +02004903 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004904 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeaturesKHR>(&dynamic_rendering_features);
sjfricke11db0c72022-08-18 13:23:11 +09004905 auto features2 = GetPhysicalDeviceFeatures2(multiview_features);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004906 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004907 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg67551632022-04-25 15:20:20 +02004908 }
4909 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004910 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg67551632022-04-25 15:20:20 +02004911 }
4912
4913 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
4914
4915 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
sjfricke74a1aad2022-08-17 14:41:33 +09004916 GetPhysicalDeviceProperties2(phys_dev_props_2);
ziga-lunarg67551632022-04-25 15:20:20 +02004917
4918 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
4919
4920 VkImageObj image(m_device);
4921 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
4922 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR,
4923 VK_IMAGE_TILING_LINEAR, 0);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004924 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
ziga-lunarg67551632022-04-25 15:20:20 +02004925
4926 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
4927 fragment_shading_rate.imageView = image_view;
4928 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
4929 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
4930
4931 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
4932 begin_rendering_info.layerCount = 1;
4933 begin_rendering_info.renderArea.offset.x = fragment_shading_rate.shadingRateAttachmentTexelSize.width * 64;
4934
4935 m_commandBuffer->begin();
4936
4937 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06117");
4938 m_commandBuffer->BeginRendering(begin_rendering_info);
4939 m_errorMonitor->VerifyFound();
4940
4941 begin_rendering_info.renderArea.offset.x = 0;
4942 begin_rendering_info.renderArea.offset.y = fragment_shading_rate.shadingRateAttachmentTexelSize.height * 64;
4943
4944 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06118");
4945 m_commandBuffer->BeginRendering(begin_rendering_info);
4946 m_errorMonitor->VerifyFound();
4947}
4948
4949TEST_F(VkLayerTest, TestBeginRenderingFragmentShadingRateAttachmentSizeWithDeviceGroupExt) {
4950 TEST_DESCRIPTION("Test FragmentShadingRateAttachment size with device group extension.");
4951
4952 SetTargetApiVersion(VK_API_VERSION_1_1);
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_1) {
sjfricke50955f32022-06-05 10:12:52 +09004964 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
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 dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004972 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeaturesKHR>(&dynamic_rendering_features);
sjfricke11db0c72022-08-18 13:23:11 +09004973 VkPhysicalDeviceFeatures2 features2 = GetPhysicalDeviceFeatures2(multiview_features);
ziga-lunarg67551632022-04-25 15:20:20 +02004974
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004975 if (multiview_features.multiview == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004976 GTEST_SKIP() << "Test requires (unsupported) multiview";
ziga-lunarg67551632022-04-25 15:20:20 +02004977 }
4978 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09004979 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarg67551632022-04-25 15:20:20 +02004980 }
4981
4982 auto fsr_properties = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>();
4983
4984 auto phys_dev_props_2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fsr_properties);
sjfricke74a1aad2022-08-17 14:41:33 +09004985 GetPhysicalDeviceProperties2(phys_dev_props_2);
ziga-lunarg67551632022-04-25 15:20:20 +02004986
4987 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
4988
4989 VkImageObj image(m_device);
4990 image.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM,
4991 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR,
4992 VK_IMAGE_TILING_LINEAR, 0);
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06004993 VkImageView image_view = image.targetView(VK_FORMAT_R8G8B8A8_UNORM);
ziga-lunarg67551632022-04-25 15:20:20 +02004994
4995 auto fragment_shading_rate = LvlInitStruct<VkRenderingFragmentShadingRateAttachmentInfoKHR>();
4996 fragment_shading_rate.imageView = image_view;
4997 fragment_shading_rate.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
4998 fragment_shading_rate.shadingRateAttachmentTexelSize = fsr_properties.minFragmentShadingRateAttachmentTexelSize;
4999
5000 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>(&fragment_shading_rate);
5001 begin_rendering_info.layerCount = 1;
5002 begin_rendering_info.renderArea.offset.x = fragment_shading_rate.shadingRateAttachmentTexelSize.width * 64;
5003
5004 m_commandBuffer->begin();
5005
5006 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06119");
5007 m_commandBuffer->BeginRendering(begin_rendering_info);
5008 m_errorMonitor->VerifyFound();
5009
5010 begin_rendering_info.renderArea.offset.x = 0;
5011 begin_rendering_info.renderArea.offset.y = fragment_shading_rate.shadingRateAttachmentTexelSize.height * 64;
5012
ziga-lunarg8f9de2a2022-04-25 15:59:19 +02005013 VkRect2D render_area = {};
5014 render_area.offset.x = 0;
5015 render_area.offset.y = 0;
5016 render_area.extent.width = 64 * fragment_shading_rate.shadingRateAttachmentTexelSize.width;
5017 render_area.extent.height = 32;
5018
5019 auto device_group_render_pass_begin_info = LvlInitStruct<VkDeviceGroupRenderPassBeginInfo>();
5020 device_group_render_pass_begin_info.deviceRenderAreaCount = 1;
5021 device_group_render_pass_begin_info.pDeviceRenderAreas = &render_area;
5022 fragment_shading_rate.pNext = &device_group_render_pass_begin_info;
5023
ziga-lunarg7f25dff2022-05-06 17:49:34 +02005024 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06120");
ziga-lunarg8f9de2a2022-04-25 15:59:19 +02005025 m_commandBuffer->BeginRendering(begin_rendering_info);
5026 m_errorMonitor->VerifyFound();
5027
5028 render_area.extent.width = 32;
5029 render_area.extent.height = 64 * fragment_shading_rate.shadingRateAttachmentTexelSize.height;
5030
5031 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-pNext-06122");
ziga-lunarg67551632022-04-25 15:20:20 +02005032 m_commandBuffer->BeginRendering(begin_rendering_info);
5033 m_errorMonitor->VerifyFound();
5034}
ziga-lunarge966a9a2022-04-25 22:42:08 +02005035
5036TEST_F(VkLayerTest, TestSuspendingRenderPassInstance) {
5037 TEST_DESCRIPTION("Test suspending render pass instance.");
5038
5039 SetTargetApiVersion(VK_API_VERSION_1_1);
5040 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
5041
5042 ASSERT_NO_FATAL_FAILURE(InitFramework());
5043
5044 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09005045 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005046 }
5047
sjfricked700bc02022-05-30 16:35:06 +09005048 if (!AreRequiredExtensionsEnabled()) {
5049 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005050 }
5051
5052 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
sjfricke11db0c72022-08-18 13:23:11 +09005053 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarge966a9a2022-04-25 22:42:08 +02005054
5055 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09005056 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005057 }
5058
5059 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
5060
ziga-lunarge966a9a2022-04-25 22:42:08 +02005061 VkCommandPoolObj command_pool(m_device, m_device->graphics_queue_node_index_);
5062 VkCommandBufferObj cmd_buffer1(m_device, &command_pool);
5063 VkCommandBufferObj cmd_buffer2(m_device, &command_pool);
5064 VkCommandBufferObj cmd_buffer3(m_device, &command_pool);
5065
5066 VkRenderingInfo suspend_rendering_info = LvlInitStruct<VkRenderingInfo>();
5067 suspend_rendering_info.flags = VK_RENDERING_SUSPENDING_BIT;
5068 suspend_rendering_info.layerCount = 1;
5069
5070 VkRenderingInfo resume_rendering_info = LvlInitStruct<VkRenderingInfo>();
5071 resume_rendering_info.flags = VK_RENDERING_RESUMING_BIT;
5072 resume_rendering_info.layerCount = 1;
5073
5074 VkRenderingInfo rendering_info = LvlInitStruct<VkRenderingInfo>();
5075 rendering_info.layerCount = 1;
5076
5077 auto cmd_begin = LvlInitStruct<VkCommandBufferBeginInfo>();
5078
5079 cmd_buffer1.begin(&cmd_begin);
5080 cmd_buffer1.BeginRendering(suspend_rendering_info);
5081 cmd_buffer1.EndRendering();
5082 cmd_buffer1.end();
5083
5084 cmd_buffer2.begin(&cmd_begin);
5085 cmd_buffer2.BeginRendering(resume_rendering_info);
5086 cmd_buffer2.EndRendering();
5087 cmd_buffer2.end();
5088
5089 cmd_buffer3.begin(&cmd_begin);
5090 cmd_buffer3.BeginRendering(rendering_info);
5091 cmd_buffer3.EndRendering();
5092 cmd_buffer3.end();
5093
5094 VkCommandBuffer command_buffers[3] = {cmd_buffer1.handle(), cmd_buffer2.handle()};
5095
5096 VkSubmitInfo submit_info = LvlInitStruct<VkSubmitInfo>();
5097 submit_info.commandBufferCount = 2;
5098 submit_info.pCommandBuffers = command_buffers;
5099 vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5100 vk::QueueWaitIdle(m_device->m_queue);
5101
ziga-lunarge966a9a2022-04-25 22:42:08 +02005102 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo-pCommandBuffers-06014");
5103
5104 submit_info.commandBufferCount = 1;
5105 vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5106 vk::QueueWaitIdle(m_device->m_queue);
5107
5108 m_errorMonitor->VerifyFound();
5109
5110 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo-pCommandBuffers-06016");
5111
5112 command_buffers[1] = cmd_buffer3.handle();
5113 command_buffers[2] = cmd_buffer2.handle();
5114 submit_info.commandBufferCount = 3;
5115 vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5116 vk::QueueWaitIdle(m_device->m_queue);
5117
5118 m_errorMonitor->VerifyFound();
5119
5120 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo-pCommandBuffers-06193");
5121
5122 command_buffers[0] = cmd_buffer2.handle();
5123 submit_info.commandBufferCount = 1;
5124 vk::QueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5125 vk::QueueWaitIdle(m_device->m_queue);
5126
5127 m_errorMonitor->VerifyFound();
5128}
5129
5130TEST_F(VkLayerTest, TestSuspendingRenderPassInstanceQueueSubmit2) {
5131 TEST_DESCRIPTION("Test suspending render pass instance with QueueSubmit2.");
5132
5133 SetTargetApiVersion(VK_API_VERSION_1_1);
5134 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
5135 AddRequiredExtensions(VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME);
5136
5137 ASSERT_NO_FATAL_FAILURE(InitFramework());
5138
5139 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
sjfricke50955f32022-06-05 10:12:52 +09005140 GTEST_SKIP() << "At least Vulkan version 1.1 is required";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005141 }
5142
sjfricked700bc02022-05-30 16:35:06 +09005143 if (!AreRequiredExtensionsEnabled()) {
5144 GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005145 }
5146
5147 auto synchronization2 = LvlInitStruct<VkPhysicalDeviceSynchronization2Features>();
5148 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>(&synchronization2);
sjfricke11db0c72022-08-18 13:23:11 +09005149 auto features2 = GetPhysicalDeviceFeatures2(dynamic_rendering_features);
ziga-lunarge966a9a2022-04-25 22:42:08 +02005150
5151 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09005152 GTEST_SKIP() << "Test requires (unsupported) dynamicRendering";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005153 }
5154 if (synchronization2.synchronization2 == VK_FALSE) {
sjfricke50955f32022-06-05 10:12:52 +09005155 GTEST_SKIP() << "Test requires (unsupported) synchronization2";
ziga-lunarge966a9a2022-04-25 22:42:08 +02005156 }
5157
5158 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
5159
5160 auto vkQueueSubmit2KHR =
5161 reinterpret_cast<PFN_vkQueueSubmit2KHR>(vk::GetDeviceProcAddr(m_device->device(), "vkQueueSubmit2KHR"));
5162 ASSERT_TRUE(vkQueueSubmit2KHR != nullptr);
5163
ziga-lunarge966a9a2022-04-25 22:42:08 +02005164 VkCommandPoolObj command_pool(m_device, m_device->graphics_queue_node_index_);
5165 VkCommandBufferObj cmd_buffer1(m_device, &command_pool);
5166 VkCommandBufferObj cmd_buffer2(m_device, &command_pool);
5167 VkCommandBufferObj cmd_buffer3(m_device, &command_pool);
5168
5169 VkRenderingInfo suspend_rendering_info = LvlInitStruct<VkRenderingInfo>();
5170 suspend_rendering_info.flags = VK_RENDERING_SUSPENDING_BIT;
5171 suspend_rendering_info.layerCount = 1;
5172
5173 VkRenderingInfo resume_rendering_info = LvlInitStruct<VkRenderingInfo>();
5174 resume_rendering_info.flags = VK_RENDERING_RESUMING_BIT;
5175 resume_rendering_info.layerCount = 1;
5176
5177 VkRenderingInfo rendering_info = LvlInitStruct<VkRenderingInfo>();
5178 rendering_info.layerCount = 1;
5179
5180 auto cmd_begin = LvlInitStruct<VkCommandBufferBeginInfo>();
5181
5182 cmd_buffer1.begin(&cmd_begin);
5183 cmd_buffer1.BeginRendering(suspend_rendering_info);
5184 cmd_buffer1.EndRendering();
5185 cmd_buffer1.end();
5186
5187 cmd_buffer2.begin(&cmd_begin);
5188 cmd_buffer2.BeginRendering(resume_rendering_info);
5189 cmd_buffer2.EndRendering();
5190 cmd_buffer2.end();
5191
5192 cmd_buffer3.begin(&cmd_begin);
5193 cmd_buffer3.BeginRendering(rendering_info);
5194 cmd_buffer3.EndRendering();
5195 cmd_buffer3.end();
5196
5197 VkCommandBufferSubmitInfo command_buffer_submit_info[3];
5198 command_buffer_submit_info[0] = LvlInitStruct<VkCommandBufferSubmitInfo>();
5199 command_buffer_submit_info[1] = LvlInitStruct<VkCommandBufferSubmitInfo>();
5200 command_buffer_submit_info[2] = LvlInitStruct<VkCommandBufferSubmitInfo>();
5201
5202 command_buffer_submit_info[0].commandBuffer = cmd_buffer1.handle();
5203 command_buffer_submit_info[1].commandBuffer = cmd_buffer2.handle();
5204
5205 VkSubmitInfo2KHR submit_info = LvlInitStruct<VkSubmitInfo2KHR>();
5206 submit_info.commandBufferInfoCount = 2;
5207 submit_info.pCommandBufferInfos = command_buffer_submit_info;
5208 vkQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5209 vk::QueueWaitIdle(m_device->m_queue);
5210
ziga-lunarge966a9a2022-04-25 22:42:08 +02005211 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo2KHR-commandBuffer-06010");
5212
5213 submit_info.commandBufferInfoCount = 1;
5214 vkQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5215 vk::QueueWaitIdle(m_device->m_queue);
5216
5217 m_errorMonitor->VerifyFound();
5218
5219 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo2KHR-commandBuffer-06012");
5220
5221 command_buffer_submit_info[1].commandBuffer = cmd_buffer3.handle();
5222 command_buffer_submit_info[2].commandBuffer = cmd_buffer2.handle();
5223 submit_info.commandBufferInfoCount = 3;
5224 vkQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5225 vk::QueueWaitIdle(m_device->m_queue);
5226
5227 m_errorMonitor->VerifyFound();
5228
5229 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkSubmitInfo2KHR-commandBuffer-06192");
5230
5231 command_buffer_submit_info[0].commandBuffer = cmd_buffer2.handle();
5232 submit_info.commandBufferInfoCount = 1;
5233 vkQueueSubmit2KHR(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE);
5234 vk::QueueWaitIdle(m_device->m_queue);
5235
5236 m_errorMonitor->VerifyFound();
5237}