blob: 3d9a278b5c4338ca42e5deb2cf4620e3f98f79c0 [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);
30
Aaron Haganb54466d2022-02-18 15:02:54 -050031 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeatures>();
32 dynamic_rendering_features.dynamicRendering = VK_TRUE;
33 VkPhysicalDeviceFeatures2 features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
Aaron Haganaca50442021-12-07 22:26:29 -050034 ASSERT_NO_FATAL_FAILURE(Init(nullptr, &features2, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
35
Aaron Haganb54466d2022-02-18 15:02:54 -050036 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
37 if (dynamic_rendering_features.dynamicRendering == VK_FALSE) {
38 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
39 return;
40 }
41
Aaron Haganaca50442021-12-07 22:26:29 -050042 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
43 printf("%s At least Vulkan version 1.2 is required for device, skipping test\n", kSkipPrefix);
44 return;
45 }
sfricke-samsungae54c1e2022-01-21 05:35:21 -080046
Aaron Haganaca50442021-12-07 22:26:29 -050047 if (!AreRequestedExtensionsEnabled()) {
48 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
49 return;
50 }
51
52 VkPhysicalDeviceMultiviewProperties multiview_props = LvlInitStruct<VkPhysicalDeviceMultiviewProperties>();
53 VkPhysicalDeviceProperties2 pd_props2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&multiview_props);
54 vk::GetPhysicalDeviceProperties2(gpu(), &pd_props2);
55
56 if (multiview_props.maxMultiviewViewCount == 32) {
57 printf("%s VUID is not testable as maxMultiviewViewCount is 32, skipping test\n", kSkipPrefix);
58 return;
59 }
60
61 VkFormat color_format = VK_FORMAT_D32_SFLOAT;
62
63 auto cmd_buffer_inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>();
64 cmd_buffer_inheritance_rendering_info.colorAttachmentCount = 1;
65 cmd_buffer_inheritance_rendering_info.pColorAttachmentFormats = &color_format;
66 cmd_buffer_inheritance_rendering_info.depthAttachmentFormat = VK_FORMAT_R8G8B8_UNORM;
67 cmd_buffer_inheritance_rendering_info.stencilAttachmentFormat = VK_FORMAT_R8G8B8_SNORM;
68 cmd_buffer_inheritance_rendering_info.viewMask = 1 << multiview_props.maxMultiviewViewCount;
69
70 auto sample_count_info_amd = LvlInitStruct<VkAttachmentSampleCountInfoAMD>();
71 sample_count_info_amd.pNext = &cmd_buffer_inheritance_rendering_info;
72 sample_count_info_amd.colorAttachmentCount = 2;
sfricke-samsungae54c1e2022-01-21 05:35:21 -080073
Aaron Haganaca50442021-12-07 22:26:29 -050074 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
75 cmd_buffer_inheritance_info.pNext = &sample_count_info_amd;
76
77 auto cmd_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>();
78 cmd_buffer_allocate_info.commandPool = m_commandPool->handle();
79 cmd_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY;
80 cmd_buffer_allocate_info.commandBufferCount = 0x1;
81
82 VkCommandBuffer secondary_cmd_buffer;
83 VkResult err = vk::AllocateCommandBuffers(m_device->device(), &cmd_buffer_allocate_info, &secondary_cmd_buffer);
84 ASSERT_VK_SUCCESS(err);
85 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06003");
Tony-LunarGbbd2ab92021-12-02 08:31:24 -070086 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-colorAttachmentCount-06004");
87 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-variableMultisampleRate-06005");
88 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-depthAttachmentFormat-06007");
89 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-multiview-06008");
90 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferInheritanceRenderingInfo-viewMask-06009");
Aaron Haganaca50442021-12-07 22:26:29 -050091 m_errorMonitor->SetDesiredFailureMsg(kErrorBit,
Tony-LunarGbbd2ab92021-12-02 08:31:24 -070092 "VUID-VkCommandBufferInheritanceRenderingInfo-stencilAttachmentFormat-06199");
Aaron Haganaca50442021-12-07 22:26:29 -050093 m_errorMonitor->SetDesiredFailureMsg(kErrorBit,
Tony-LunarGbbd2ab92021-12-02 08:31:24 -070094 "VUID-VkCommandBufferInheritanceRenderingInfo-depthAttachmentFormat-06200");
Aaron Haganaca50442021-12-07 22:26:29 -050095 m_errorMonitor->SetDesiredFailureMsg(kErrorBit,
Tony-LunarGbbd2ab92021-12-02 08:31:24 -070096 "VUID-VkCommandBufferInheritanceRenderingInfo-pColorAttachmentFormats-06006");
Aaron Haganaca50442021-12-07 22:26:29 -050097
98 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
99 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
100 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
101 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
102 m_errorMonitor->VerifyFound();
103}
104
Aaron Haganb54466d2022-02-18 15:02:54 -0500105TEST_F(VkLayerTest, DynamicRenderingCommandDraw) {
Aaron Haganaca50442021-12-07 22:26:29 -0500106 TEST_DESCRIPTION("vkCmdDraw* Dynamic Rendering Tests.");
107
108 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2);
109 if (version < VK_API_VERSION_1_2) {
110 printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix);
111 return;
112 }
113
114 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
115
116 ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor));
117
118 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
119 printf("%s At least Vulkan version 1.2 is required for device, skipping test\n", kSkipPrefix);
120 return;
121 }
122
123 if (!AreRequestedExtensionsEnabled()) {
124 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
125 return;
126 }
127
128 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
129 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
130 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
131 if (!dynamic_rendering_features.dynamicRendering) {
132 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
133 return;
134 }
135
136 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
137
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800138 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
139 VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT);
Aaron Haganaca50442021-12-07 22:26:29 -0500140
141 VkPipelineObj pipe(m_device);
142 pipe.AddShader(&vs);
143 pipe.AddShader(&fs);
144 pipe.AddDefaultColorAttachment();
145
146 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
147 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
148 const VkPipelineLayoutObj pl(m_device, {&dsl});
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800149
Aaron Haganaca50442021-12-07 22:26:29 -0500150 VkFormat depth_format = VK_FORMAT_D32_SFLOAT_S8_UINT;
151 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
Aaron Hagan80034ea2021-12-23 11:24:09 -0500152 pipeline_rendering_info.depthAttachmentFormat = depth_format;
153 pipeline_rendering_info.stencilAttachmentFormat = depth_format;
Aaron Haganaca50442021-12-07 22:26:29 -0500154
155 auto multisample_state_create_info = LvlInitStruct<VkPipelineMultisampleStateCreateInfo>();
156 multisample_state_create_info.rasterizationSamples = VK_SAMPLE_COUNT_2_BIT;
157
158 auto create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
159 pipe.InitGraphicsPipelineCreateInfo(&create_info);
160 create_info.pMultisampleState = &multisample_state_create_info;
161 create_info.renderPass = VkRenderPass(0x1);
162 create_info.pNext = &pipeline_rendering_info;
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800163
Aaron Haganaca50442021-12-07 22:26:29 -0500164 VkResult err = pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
165 ASSERT_VK_SUCCESS(err);
166
167 VkViewport viewport = {0, 0, 16, 16, 0, 1};
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800168 VkRect2D scissor = {{0, 0}, {16, 16}};
Aaron Haganaca50442021-12-07 22:26:29 -0500169
170 VkImageObj image(m_device);
171 image.Init(32, 32, 1, depth_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0);
172 ASSERT_TRUE(image.initialized());
173
174 VkImageViewCreateInfo ivci = {VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
175 nullptr,
176 0,
177 image.handle(),
178 VK_IMAGE_VIEW_TYPE_2D,
179 depth_format,
180 {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
181 VK_COMPONENT_SWIZZLE_IDENTITY},
182 {VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, 0, 1, 0, 1}};
183
184 VkImageView depth_image_view;
185 err = vk::CreateImageView(m_device->device(), &ivci, nullptr, &depth_image_view);
186 ASSERT_VK_SUCCESS(err);
187
188 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
189 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
190 depth_attachment.imageView = depth_image_view;
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800191
Aaron Haganaca50442021-12-07 22:26:29 -0500192 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
193 begin_rendering_info.pDepthAttachment = &depth_attachment;
194 begin_rendering_info.pStencilAttachment = &depth_attachment;
195
196 m_commandBuffer->begin();
197 m_commandBuffer->BeginRendering(begin_rendering_info);
198 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle());
199 vk::CmdSetViewport(m_commandBuffer->handle(), 0, 1, &viewport);
200 vk::CmdSetScissor(m_commandBuffer->handle(), 0, 1, &scissor);
201 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06189");
202 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06190");
203 vk::CmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);
204 m_errorMonitor->VerifyFound();
205 m_commandBuffer->EndRendering();
206 m_commandBuffer->end();
207}
208
209TEST_F(VkLayerTest, DynamicRenderingGraphicsPipelineCreateInfo) {
210 TEST_DESCRIPTION("Test graphics pipeline creation with dynamic rendering.");
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800211
Aaron Haganaca50442021-12-07 22:26:29 -0500212 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2);
213 if (version < VK_API_VERSION_1_2) {
214 printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix);
215 return;
216 }
217
218 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
219
220 ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor));
221
222 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
223 printf("%s At least Vulkan version 1.2 is required for device, skipping test\n", kSkipPrefix);
224 return;
225 }
226
227 if (!AreRequestedExtensionsEnabled()) {
228 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
229 return;
230 }
231
232 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
233 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
234 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
235 if (!dynamic_rendering_features.dynamicRendering) {
236 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
237 return;
238 }
239
240 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
241
242 const VkPipelineLayoutObj pl(m_device);
243 VkPipelineObj pipe(m_device);
244
245 VkPipelineColorBlendAttachmentState color_blend_attachment_state = {};
246
247 auto color_blend_state_create_info = LvlInitStruct<VkPipelineColorBlendStateCreateInfo>();
248 color_blend_state_create_info.attachmentCount = 1;
249 color_blend_state_create_info.pAttachments = &color_blend_attachment_state;
250
251 VkFormat color_format[2] = {VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_D32_SFLOAT_S8_UINT};
252
253 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
254 pipeline_rendering_info.colorAttachmentCount = 2;
255 pipeline_rendering_info.pColorAttachmentFormats = &color_format[0];
256 pipeline_rendering_info.viewMask = 0x2;
Aaron Hagan80034ea2021-12-23 11:24:09 -0500257 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
Aaron Haganaca50442021-12-07 22:26:29 -0500258
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800259 auto pipeline_tessellation_state_info = LvlInitStruct<VkPipelineTessellationStateCreateInfo>();
Aaron Haganaca50442021-12-07 22:26:29 -0500260 pipeline_tessellation_state_info.patchControlPoints = 1;
261
262 auto pipeline_input_assembly_state_info = LvlInitStruct<VkPipelineInputAssemblyStateCreateInfo>();
263 pipeline_input_assembly_state_info.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST;
264
265 auto create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
Aaron Hagan80034ea2021-12-23 11:24:09 -0500266
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800267 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
268 VkShaderObj gs(this, bindStateGeomShaderText, VK_SHADER_STAGE_GEOMETRY_BIT);
269 VkShaderObj te(this, bindStateTeshaderText, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT);
270 VkShaderObj tc(this, bindStateTscShaderText, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT);
Aaron Hagan80034ea2021-12-23 11:24:09 -0500271 VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT);
272
Aaron Haganaca50442021-12-07 22:26:29 -0500273 pipe.AddShader(&vs);
274 pipe.AddShader(&gs);
275 pipe.AddShader(&te);
276 pipe.AddShader(&tc);
Aaron Hagan80034ea2021-12-23 11:24:09 -0500277 pipe.AddShader(&fs);
Aaron Haganaca50442021-12-07 22:26:29 -0500278 pipe.InitGraphicsPipelineCreateInfo(&create_info);
279 create_info.pColorBlendState = &color_blend_state_create_info;
280 create_info.pNext = &pipeline_rendering_info;
281 create_info.pTessellationState = &pipeline_tessellation_state_info;
282 create_info.pInputAssemblyState = &pipeline_input_assembly_state_info;
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800283
Aaron Hagan80034ea2021-12-23 11:24:09 -0500284 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06053");
Aaron Haganaca50442021-12-07 22:26:29 -0500285 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06055");
286 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06057");
287 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06058");
288 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06060");
289 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06062");
Tony-LunarGbbd2ab92021-12-02 08:31:24 -0700290 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkPipelineRenderingCreateInfo-multiview-06066");
291 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkPipelineRenderingCreateInfo-pColorAttachmentFormats-06064");
Aaron Haganaca50442021-12-07 22:26:29 -0500292 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
293 m_errorMonitor->VerifyFound();
294
Aaron Hagan80034ea2021-12-23 11:24:09 -0500295 create_info.pColorBlendState = nullptr;
296 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
297 pipeline_rendering_info.viewMask = 0x0;
298 pipeline_rendering_info.colorAttachmentCount = 1;
299 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06054");
300 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
301 m_errorMonitor->VerifyFound();
Aaron Haganb54466d2022-02-18 15:02:54 -0500302
303 auto ds_ci = LvlInitStruct<VkPipelineDepthStencilStateCreateInfo>();
304 ds_ci.flags = VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM;
305 color_blend_state_create_info.flags = VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM;
306 create_info.pColorBlendState = &color_blend_state_create_info;
307 create_info.pDepthStencilState = &ds_ci;
308 create_info.renderPass = VK_NULL_HANDLE;
309 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
310 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06482");
311 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-flags-06483");
312 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
313 m_errorMonitor->VerifyFound();
stusmith15f24a82021-12-24 15:21:19 +0000314}
315
316TEST_F(VkLayerTest, DynamicRenderingWithMismatchingViewMask) {
317 TEST_DESCRIPTION("Draw with Dynamic Rendering and a mismatching viewMask");
318
319 SetTargetApiVersion(VK_API_VERSION_1_1);
320
321 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
322
323 ASSERT_NO_FATAL_FAILURE(InitFramework());
324
325 if (!AreRequestedExtensionsEnabled()) {
326 printf("%s %s Extension not supported, skipping tests\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
327 return;
328 }
329
330 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
331 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
332 return;
333 }
334
335 auto multiview_features = LvlInitStruct<VkPhysicalDeviceMultiviewFeatures>();
336 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>(&multiview_features);
337 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
338 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
339 if (!dynamic_rendering_features.dynamicRendering) {
340 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
341 return;
342 }
343 if (!multiview_features.multiview) {
344 printf("%s Test requires (unsupported) multiview , skipping\n", kSkipPrefix);
345 return;
346 }
347
348 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
349
350 char const *fsSource = R"glsl(
351 #version 450
352 layout(location=0) out vec4 color;
353 void main() {
354 color = vec4(1.0f);
355 }
356 )glsl";
357
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800358 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
359 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000360
361 VkPipelineObj pipe(m_device);
362 pipe.AddShader(&vs);
363 pipe.AddShader(&fs);
364 pipe.AddDefaultColorAttachment();
365
366 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
367 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
368 const VkPipelineLayoutObj pl(m_device, {&dsl});
369
370 VkFormat color_formats = {VK_FORMAT_R8G8B8A8_UNORM};
371 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
372 pipeline_rendering_info.colorAttachmentCount = 1;
373 pipeline_rendering_info.pColorAttachmentFormats = &color_formats;
374 pipeline_rendering_info.viewMask = 1;
375
376 VkViewport viewport = {0, 0, 16, 16, 0, 1};
377 VkRect2D scissor = {{0, 0}, {16, 16}};
378 m_viewports.push_back(viewport);
379 m_scissors.push_back(scissor);
380 pipe.SetViewport(m_viewports);
381 pipe.SetScissor(m_scissors);
382
383 auto create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
384 pipe.InitGraphicsPipelineCreateInfo(&create_info);
385 create_info.pNext = &pipeline_rendering_info;
386
387 pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info);
388
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800389 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000390 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
391
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800392 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000393 begin_rendering_info.colorAttachmentCount = 1;
394 begin_rendering_info.pColorAttachments = &color_attachment;
395 begin_rendering_info.viewMask = 2;
396 begin_rendering_info.layerCount = 1;
397
398 m_commandBuffer->begin();
399 m_commandBuffer->BeginRendering(begin_rendering_info);
400 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle());
401 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-viewMask-06178");
402 m_commandBuffer->Draw(1, 1, 0, 0);
403 m_errorMonitor->VerifyFound();
404 m_commandBuffer->EndRendering();
405 m_commandBuffer->end();
406}
407
408TEST_F(VkLayerTest, DynamicRenderingWithMistmatchingAttachments) {
409 TEST_DESCRIPTION("Draw with Dynamic Rendering with mismatching color attachment counts and depth/stencil formats");
410
411 SetTargetApiVersion(VK_API_VERSION_1_1);
412
413 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
414
415 ASSERT_NO_FATAL_FAILURE(InitFramework());
416
417 if (!AreRequestedExtensionsEnabled()) {
418 printf("%s %s Extension not supported, skipping tests\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
419 return;
420 }
421
422 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
423 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
424 return;
425 }
426
427 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
428 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
429 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
430 if (!dynamic_rendering_features.dynamicRendering) {
431 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
432 return;
433 }
434
435 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
436
437 char const *fsSource = R"glsl(
438 #version 450
439 layout(location=0) out vec4 color;
440 void main() {
441 color = vec4(1.0f);
442 }
443 )glsl";
444
445 VkViewport viewport = {0, 0, 16, 16, 0, 1};
446 VkRect2D scissor = {{0, 0}, {16, 16}};
447 m_viewports.push_back(viewport);
448 m_scissors.push_back(scissor);
449
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800450 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
451 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000452
453 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
454 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
455 const VkPipelineLayoutObj pl(m_device, {&dsl});
456
457 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
458
459 VkPipelineObj pipe1(m_device);
460 pipe1.AddShader(&vs);
461 pipe1.AddShader(&fs);
462 pipe1.AddDefaultColorAttachment();
463 pipe1.SetViewport(m_viewports);
464 pipe1.SetScissor(m_scissors);
465
466 VkFormat color_formats[] = {VK_FORMAT_R8G8B8A8_UNORM};
467 pipeline_rendering_info.colorAttachmentCount = 1;
468 pipeline_rendering_info.pColorAttachmentFormats = color_formats;
469
470 auto create_info1 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
471 pipe1.InitGraphicsPipelineCreateInfo(&create_info1);
472 create_info1.pNext = &pipeline_rendering_info;
473
474 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
475
476 VkPipelineObj pipe2(m_device);
477 pipe2.AddShader(&vs);
478 pipe2.AddShader(&fs);
479 pipe2.AddDefaultColorAttachment();
480 pipe2.SetViewport(m_viewports);
481 pipe2.SetScissor(m_scissors);
482
483 pipeline_rendering_info.colorAttachmentCount = 0;
484 pipeline_rendering_info.pColorAttachmentFormats = nullptr;
485 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_D16_UNORM;
486
487 auto create_info2 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
488 pipe2.InitGraphicsPipelineCreateInfo(&create_info2);
489 create_info2.pNext = &pipeline_rendering_info;
490
491 pipe2.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info2);
492
493 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
494 ASSERT_TRUE(depthStencilFormat != 0);
495
496 bool testStencil = false;
497 VkFormat stencilFormat = VK_FORMAT_UNDEFINED;
498
499 if (ImageFormatIsSupported(gpu(), VK_FORMAT_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
500 stencilFormat = VK_FORMAT_S8_UINT;
501 testStencil = true;
502 } else if ((depthStencilFormat != VK_FORMAT_D16_UNORM_S8_UINT) &&
503 ImageFormatIsSupported(gpu(), VK_FORMAT_D16_UNORM_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
504 stencilFormat = VK_FORMAT_D16_UNORM_S8_UINT;
505 testStencil = true;
506 } else if ((depthStencilFormat != VK_FORMAT_D24_UNORM_S8_UINT) &&
507 ImageFormatIsSupported(gpu(), VK_FORMAT_D24_UNORM_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
508 stencilFormat = VK_FORMAT_D24_UNORM_S8_UINT;
509 testStencil = true;
510 } else if ((depthStencilFormat != VK_FORMAT_D32_SFLOAT_S8_UINT) &&
511 ImageFormatIsSupported(gpu(), VK_FORMAT_D32_SFLOAT_S8_UINT, VK_IMAGE_TILING_OPTIMAL)) {
512 stencilFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
513 testStencil = true;
514 }
515
516 VkPipelineObj pipe3(m_device);
517
518 if (testStencil) {
519 pipe3.AddShader(&vs);
520 pipe3.AddShader(&fs);
521 pipe3.AddDefaultColorAttachment();
522 pipe3.SetViewport(m_viewports);
523 pipe3.SetScissor(m_scissors);
524
525 pipeline_rendering_info.colorAttachmentCount = 0;
526 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
527 pipeline_rendering_info.stencilAttachmentFormat = stencilFormat;
528
529 auto create_info3 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
530 pipe3.InitGraphicsPipelineCreateInfo(&create_info3);
531 create_info3.pNext = &pipeline_rendering_info;
532
533 pipe3.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info3);
534 }
535
536 VkImageObj colorImage(m_device);
537 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UINT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
538 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UINT);
539
540 VkImageObj depthStencilImage(m_device);
541 depthStencilImage.Init(32, 32, 1, depthStencilFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
542 VkImageView depthStencilImageView =
543 depthStencilImage.targetView(depthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
544
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800545 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000546 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
547 color_attachment.imageView = colorImageView;
548
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800549 VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000550 depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
551 depth_stencil_attachment.imageView = depthStencilImageView;
552
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800553 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000554 m_commandBuffer->begin();
555
556 // Mismatching color attachment count
557 m_commandBuffer->BeginRendering(begin_rendering_info);
558 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
559 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06179");
560 m_commandBuffer->Draw(1, 1, 0, 0);
561 m_errorMonitor->VerifyFound();
562 m_commandBuffer->EndRendering();
563
564 // Mismatching color formats
565 begin_rendering_info.colorAttachmentCount = 1;
566 begin_rendering_info.pColorAttachments = &color_attachment;
567 m_commandBuffer->BeginRendering(begin_rendering_info);
568 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
569 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06180");
570 m_commandBuffer->Draw(1, 1, 0, 0);
571 m_errorMonitor->VerifyFound();
572 m_commandBuffer->EndRendering();
573
574 // Mismatching depth format
575 begin_rendering_info.colorAttachmentCount = 0;
576 begin_rendering_info.pColorAttachments = nullptr;
577 begin_rendering_info.pDepthAttachment = &depth_stencil_attachment;
578 m_commandBuffer->BeginRendering(begin_rendering_info);
579 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.handle());
580 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06181");
581 m_commandBuffer->Draw(1, 1, 0, 0);
582 m_errorMonitor->VerifyFound();
583 m_commandBuffer->EndRendering();
584
585 // Mismatching stencil format
586 if (testStencil) {
587 begin_rendering_info.pDepthAttachment = nullptr;
588 begin_rendering_info.pStencilAttachment = &depth_stencil_attachment;
589 m_commandBuffer->BeginRendering(begin_rendering_info);
590 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe3.handle());
591 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06182");
592 m_commandBuffer->Draw(1, 1, 0, 0);
593 m_errorMonitor->VerifyFound();
594 m_commandBuffer->EndRendering();
595 }
596
597 m_commandBuffer->end();
598}
599
600TEST_F(VkLayerTest, DynamicRenderingWithMistmatchingAttachmentSamples) {
601 TEST_DESCRIPTION("Draw with Dynamic Rendering with mismatching color/depth/stencil sample counts");
602
603 SetTargetApiVersion(VK_API_VERSION_1_1);
604
605 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
606
607 ASSERT_NO_FATAL_FAILURE(InitFramework());
608
609 if (!AreRequestedExtensionsEnabled()) {
610 printf("%s %s Extension not supported, skipping tests\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
611 return;
612 }
613
614 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
615 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
616 return;
617 }
618
619 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
620 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
621 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
622 if (!dynamic_rendering_features.dynamicRendering) {
623 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
624 return;
625 }
626
627 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
628
629 char const *fsSource = R"glsl(
630 #version 450
631 layout(location=0) out vec4 color;
632 void main() {
633 color = vec4(1.0f);
634 }
635 )glsl";
636
637 VkViewport viewport = {0, 0, 16, 16, 0, 1};
638 VkRect2D scissor = {{0, 0}, {16, 16}};
639 m_viewports.push_back(viewport);
640 m_scissors.push_back(scissor);
641
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800642 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
643 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000644
645 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
646 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
647 const VkPipelineLayoutObj pl(m_device, {&dsl});
648
649 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
650
651
652 VkPipelineObj pipe1(m_device);
653 pipe1.AddShader(&vs);
654 pipe1.AddShader(&fs);
655 pipe1.AddDefaultColorAttachment();
656 pipe1.SetViewport(m_viewports);
657 pipe1.SetScissor(m_scissors);
658
659 VkFormat color_formats[] = {VK_FORMAT_R8G8B8A8_UNORM};
660 pipeline_rendering_info.colorAttachmentCount = 1;
661 pipeline_rendering_info.pColorAttachmentFormats = color_formats;
662
663 auto create_info1 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
664 pipe1.InitGraphicsPipelineCreateInfo(&create_info1);
665 create_info1.pNext = &pipeline_rendering_info;
666
667 auto multisample_state_create_info = LvlInitStruct<VkPipelineMultisampleStateCreateInfo>();
668 multisample_state_create_info.rasterizationSamples = VK_SAMPLE_COUNT_2_BIT;
669 create_info1.pMultisampleState = &multisample_state_create_info;
670
671 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
672
673
674 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
675 ASSERT_TRUE(depthStencilFormat != 0);
676
677
678 VkPipelineObj pipe2(m_device);
679 pipe2.AddShader(&vs);
680 pipe2.AddShader(&fs);
681 pipe2.AddDefaultColorAttachment();
682 pipe2.SetViewport(m_viewports);
683 pipe2.SetScissor(m_scissors);
684
685 pipeline_rendering_info.colorAttachmentCount = 0;
686 pipeline_rendering_info.pColorAttachmentFormats = nullptr;
687 pipeline_rendering_info.depthAttachmentFormat = depthStencilFormat;
688
689 auto create_info2 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
690 pipe2.InitGraphicsPipelineCreateInfo(&create_info2);
691 create_info2.pNext = &pipeline_rendering_info;
692
693 create_info2.pMultisampleState = &multisample_state_create_info;
694
695 pipe2.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info2);
696
697
698 VkPipelineObj pipe3(m_device);
699
700 pipe3.AddShader(&vs);
701 pipe3.AddShader(&fs);
702 pipe3.AddDefaultColorAttachment();
703 pipe3.SetViewport(m_viewports);
704 pipe3.SetScissor(m_scissors);
705
706 pipeline_rendering_info.colorAttachmentCount = 0;
707 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
708 pipeline_rendering_info.stencilAttachmentFormat = depthStencilFormat;
709
710 auto create_info3 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
711 pipe3.InitGraphicsPipelineCreateInfo(&create_info3);
712 create_info3.pNext = &pipeline_rendering_info;
713
714 create_info3.pMultisampleState = &multisample_state_create_info;
715
716 pipe3.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info3);
717
718
719 VkImageObj colorImage(m_device);
720 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
721 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UNORM);
722
723 VkImageObj depthStencilImage(m_device);
724 depthStencilImage.Init(32, 32, 1, depthStencilFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
725 VkImageView depthStencilImageView =
726 depthStencilImage.targetView(depthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
727
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800728 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000729 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
730 color_attachment.imageView = colorImageView;
731
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800732 VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000733 depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
734 depth_stencil_attachment.imageView = depthStencilImageView;
735
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800736 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000737 m_commandBuffer->begin();
738
739 // Mismatching color samples
740 begin_rendering_info.colorAttachmentCount = 1;
741 begin_rendering_info.pColorAttachments = &color_attachment;
742 m_commandBuffer->BeginRendering(begin_rendering_info);
743 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
744 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06188");
745 m_commandBuffer->Draw(1, 1, 0, 0);
746 m_errorMonitor->VerifyFound();
747 m_commandBuffer->EndRendering();
748
749 // Mismatching depth samples
750 begin_rendering_info.colorAttachmentCount = 0;
751 begin_rendering_info.pColorAttachments = nullptr;
752 begin_rendering_info.pDepthAttachment = &depth_stencil_attachment;
753 m_commandBuffer->BeginRendering(begin_rendering_info);
754 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.handle());
755 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06189");
756 m_commandBuffer->Draw(1, 1, 0, 0);
757 m_errorMonitor->VerifyFound();
758 m_commandBuffer->EndRendering();
759
760 // Mismatching stencil samples
761 begin_rendering_info.pDepthAttachment = nullptr;
762 begin_rendering_info.pStencilAttachment = &depth_stencil_attachment;
763 m_commandBuffer->BeginRendering(begin_rendering_info);
764 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe3.handle());
765 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06190");
766 m_commandBuffer->Draw(1, 1, 0, 0);
767 m_errorMonitor->VerifyFound();
768 m_commandBuffer->EndRendering();
769
770 m_commandBuffer->end();
771}
772
773TEST_F(VkLayerTest, DynamicRenderingWithMistmatchingMixedAttachmentSamples) {
774 TEST_DESCRIPTION("Draw with Dynamic Rendering with mismatching mixed color/depth/stencil sample counts");
775
776 SetTargetApiVersion(VK_API_VERSION_1_1);
777
778 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
779
780 ASSERT_NO_FATAL_FAILURE(InitFramework());
781
782 if (!AreRequestedExtensionsEnabled()) {
783 printf("%s %s Extension not supported, skipping tests\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
784 return;
785 }
786
787 if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
788 printf("%s Tests requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
789 return;
790 }
791
792 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
793 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
794 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
795 if (!dynamic_rendering_features.dynamicRendering) {
796 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
797 return;
798 }
799
800 bool amd_samples = false;
801 if (DeviceExtensionSupported(gpu(), nullptr, VK_AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME)) {
802 m_device_extension_names.push_back(VK_AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME);
803 amd_samples = true;
804 }
805
806 bool nv_samples = false;
807 if (DeviceExtensionSupported(gpu(), nullptr, VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME)) {
808 m_device_extension_names.push_back(VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME);
809 nv_samples = true;
810 }
811
812 if (!amd_samples && !nv_samples) {
813 printf("%s Test requires either VK_AMD_mixed_attachment_samples or VK_NV_framebuffer_mixed_samples, skipping\n",
814 kSkipPrefix);
815 return;
816 }
817
818 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
819
820 char const *fsSource = R"glsl(
821 #version 450
822 layout(location=0) out vec4 color;
823 void main() {
824 color = vec4(1.0f);
825 }
826 )glsl";
827
828 VkViewport viewport = {0, 0, 16, 16, 0, 1};
829 VkRect2D scissor = {{0, 0}, {16, 16}};
830 m_viewports.push_back(viewport);
831 m_scissors.push_back(scissor);
832
sfricke-samsungae54c1e2022-01-21 05:35:21 -0800833 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
834 VkShaderObj fs(this, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT);
stusmith15f24a82021-12-24 15:21:19 +0000835
836 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
837 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
838 const VkPipelineLayoutObj pl(m_device, {&dsl});
839
840 VkSampleCountFlagBits counts = {VK_SAMPLE_COUNT_2_BIT};
841 auto samples_info = LvlInitStruct<VkAttachmentSampleCountInfoAMD>();
842
843 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>(&samples_info);
844
845 VkPipelineObj pipe1(m_device);
846 pipe1.AddShader(&vs);
847 pipe1.AddShader(&fs);
848 pipe1.AddDefaultColorAttachment();
849 pipe1.SetViewport(m_viewports);
850 pipe1.SetScissor(m_scissors);
851
852 VkFormat color_formats[] = {VK_FORMAT_R8G8B8A8_UNORM};
853 pipeline_rendering_info.colorAttachmentCount = 1;
854 pipeline_rendering_info.pColorAttachmentFormats = color_formats;
855
856 samples_info.colorAttachmentCount = 1;
857 samples_info.pColorAttachmentSamples = &counts;
858
859 auto create_info1 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
860 pipe1.InitGraphicsPipelineCreateInfo(&create_info1);
861 create_info1.pNext = &pipeline_rendering_info;
862
Aaron Haganb54466d2022-02-18 15:02:54 -0500863 samples_info.colorAttachmentCount = 2;
864 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06063");
865 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
866 m_errorMonitor->VerifyFound();
867
868 samples_info.colorAttachmentCount = 1;
stusmith15f24a82021-12-24 15:21:19 +0000869 pipe1.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info1);
870
871 VkFormat depthStencilFormat = FindSupportedDepthStencilFormat(gpu());
872 ASSERT_TRUE(depthStencilFormat != 0);
873
874 VkPipelineObj pipe2(m_device);
875 pipe2.AddShader(&vs);
876 pipe2.AddShader(&fs);
877 pipe2.AddDefaultColorAttachment();
878 pipe2.SetViewport(m_viewports);
879 pipe2.SetScissor(m_scissors);
880
881 pipeline_rendering_info.colorAttachmentCount = 0;
882 pipeline_rendering_info.pColorAttachmentFormats = nullptr;
883 pipeline_rendering_info.depthAttachmentFormat = depthStencilFormat;
884
885 samples_info.colorAttachmentCount = 0;
886 samples_info.pColorAttachmentSamples = nullptr;
887 samples_info.depthStencilAttachmentSamples = counts;
888
889 auto create_info2 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
890 pipe2.InitGraphicsPipelineCreateInfo(&create_info2);
891 create_info2.pNext = &pipeline_rendering_info;
892
893 pipe2.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info2);
894
895 VkPipelineObj pipe3(m_device);
896
897 pipe3.AddShader(&vs);
898 pipe3.AddShader(&fs);
899 pipe3.AddDefaultColorAttachment();
900 pipe3.SetViewport(m_viewports);
901 pipe3.SetScissor(m_scissors);
902
903 pipeline_rendering_info.colorAttachmentCount = 0;
904 pipeline_rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
905 pipeline_rendering_info.stencilAttachmentFormat = depthStencilFormat;
906
907 auto create_info3 = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
908 pipe3.InitGraphicsPipelineCreateInfo(&create_info3);
909 create_info3.pNext = &pipeline_rendering_info;
910
911 pipe3.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &create_info3);
912
913 VkImageObj colorImage(m_device);
914 colorImage.Init(32, 32, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
915 VkImageView colorImageView = colorImage.targetView(VK_FORMAT_R8G8B8A8_UNORM);
916
917 VkImageObj depthStencilImage(m_device);
918 depthStencilImage.Init(32, 32, 1, depthStencilFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
919 VkImageView depthStencilImageView =
920 depthStencilImage.targetView(depthStencilFormat, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
921
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800922 VkRenderingAttachmentInfoKHR color_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000923 color_attachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
924 color_attachment.imageView = colorImageView;
925
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800926 VkRenderingAttachmentInfoKHR depth_stencil_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000927 depth_stencil_attachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
928 depth_stencil_attachment.imageView = depthStencilImageView;
929
sfricke-samsung6fc3e322022-02-15 22:41:29 -0800930 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
stusmith15f24a82021-12-24 15:21:19 +0000931 m_commandBuffer->begin();
932
933 // Mismatching color samples
934 begin_rendering_info.colorAttachmentCount = 1;
935 begin_rendering_info.pColorAttachments = &color_attachment;
936 m_commandBuffer->BeginRendering(begin_rendering_info);
937 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe1.handle());
938 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-colorAttachmentCount-06185");
939 m_commandBuffer->Draw(1, 1, 0, 0);
940 m_errorMonitor->VerifyFound();
941 m_commandBuffer->EndRendering();
942
943 // Mismatching depth samples
944 begin_rendering_info.colorAttachmentCount = 0;
945 begin_rendering_info.pColorAttachments = nullptr;
946 begin_rendering_info.pDepthAttachment = &depth_stencil_attachment;
947 m_commandBuffer->BeginRendering(begin_rendering_info);
948 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe2.handle());
949 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pDepthAttachment-06186");
950 m_commandBuffer->Draw(1, 1, 0, 0);
951 m_errorMonitor->VerifyFound();
952 m_commandBuffer->EndRendering();
953
954 // Mismatching stencil samples
955 begin_rendering_info.pDepthAttachment = nullptr;
956 begin_rendering_info.pStencilAttachment = &depth_stencil_attachment;
957 m_commandBuffer->BeginRendering(begin_rendering_info);
958 vk::CmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe3.handle());
959 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdDraw-pStencilAttachment-06187");
960 m_commandBuffer->Draw(1, 1, 0, 0);
961 m_errorMonitor->VerifyFound();
962 m_commandBuffer->EndRendering();
963
964 m_commandBuffer->end();
965}
Aaron Hagan80034ea2021-12-23 11:24:09 -0500966
967TEST_F(VkLayerTest, DynamicRenderingAttachmentInfo) {
968 TEST_DESCRIPTION("AttachmentInfo Dynamic Rendering Tests.");
969
970 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2);
971 if (version < VK_API_VERSION_1_2) {
972 printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix);
973 return;
974 }
975
976 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
977
978 ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor));
979
980 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
981 printf("%s At least Vulkan version 1.2 is required for device, skipping test\n", kSkipPrefix);
982 return;
983 }
984
985 if (!AreRequestedExtensionsEnabled()) {
986 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
987 return;
988 }
989
990 auto dynamic_rendering_features = LvlInitStruct<VkPhysicalDeviceDynamicRenderingFeaturesKHR>();
991 auto features2 = LvlInitStruct<VkPhysicalDeviceFeatures2>(&dynamic_rendering_features);
992 vk::GetPhysicalDeviceFeatures2(gpu(), &features2);
993 if (!dynamic_rendering_features.dynamicRendering) {
994 printf("%s Test requires (unsupported) dynamicRendering , skipping\n", kSkipPrefix);
995 return;
996 }
997
998 ASSERT_NO_FATAL_FAILURE(InitState(nullptr, &features2));
999
1000 VkShaderObj vs(this, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT);
1001 VkShaderObj fs(this, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT);
1002
1003 VkPipelineObj pipe(m_device);
1004 pipe.AddShader(&vs);
1005 pipe.AddShader(&fs);
1006 pipe.AddDefaultColorAttachment();
1007
1008 VkDescriptorSetLayoutBinding dslb = {0, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr};
1009 const VkDescriptorSetLayoutObj dsl(m_device, {dslb});
1010 const VkPipelineLayoutObj pl(m_device, {&dsl});
1011
1012 VkFormat depth_format = VK_FORMAT_D32_SFLOAT_S8_UINT;
1013 auto pipeline_rendering_info = LvlInitStruct<VkPipelineRenderingCreateInfoKHR>();
1014 pipeline_rendering_info.depthAttachmentFormat = depth_format;
1015
1016 auto pipeline_create_info = LvlInitStruct<VkGraphicsPipelineCreateInfo>();
1017 pipe.InitGraphicsPipelineCreateInfo(&pipeline_create_info);
1018 pipeline_create_info.pNext = &pipeline_rendering_info;
1019
1020 VkResult err = pipe.CreateVKPipeline(pl.handle(), VK_NULL_HANDLE, &pipeline_create_info);
1021 ASSERT_VK_SUCCESS(err);
1022
1023 VkImageObj image(m_device);
1024 VkImageCreateInfo image_create_info = LvlInitStruct<VkImageCreateInfo>();
1025 image_create_info.imageType = VK_IMAGE_TYPE_2D;
1026 image_create_info.format = depth_format;
1027 image_create_info.extent = {64, 64, 4};
1028 image_create_info.mipLevels = 1;
1029 image_create_info.arrayLayers = 1;
1030 image_create_info.samples = VK_SAMPLE_COUNT_2_BIT;
1031 image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
1032 image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
1033 image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
1034
1035 image.Init(image_create_info);
1036 ASSERT_TRUE(image.initialized());
1037
1038 VkImageViewCreateInfo ivci = {VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
1039 nullptr,
1040 0,
1041 image.handle(),
1042 VK_IMAGE_VIEW_TYPE_2D,
1043 depth_format,
1044 {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
1045 VK_COMPONENT_SWIZZLE_IDENTITY},
1046 {VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, 0, 1, 0, 1}};
1047
1048 VkImageView depth_image_view;
1049 err = vk::CreateImageView(m_device->device(), &ivci, nullptr, &depth_image_view);
1050 ASSERT_VK_SUCCESS(err);
1051
1052 VkRenderingAttachmentInfoKHR depth_attachment = LvlInitStruct<VkRenderingAttachmentInfoKHR>();
1053 depth_attachment.imageLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
1054 depth_attachment.imageView = depth_image_view;
1055 depth_attachment.resolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
1056 depth_attachment.resolveImageLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
1057
1058 VkRenderingInfoKHR begin_rendering_info = LvlInitStruct<VkRenderingInfoKHR>();
1059 begin_rendering_info.pDepthAttachment = &depth_attachment;
1060 begin_rendering_info.viewMask = 0x4;
1061
1062 VkRenderingFragmentDensityMapAttachmentInfoEXT fragment_density_map =
1063 LvlInitStruct<VkRenderingFragmentDensityMapAttachmentInfoEXT>();
1064 fragment_density_map.imageView = depth_image_view;
1065 begin_rendering_info.pNext = &fragment_density_map;
1066
1067 m_commandBuffer->begin();
1068 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-multiview-06127");
1069 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-viewMask-06069");
Jeremy Gebben09c1a072022-02-08 09:42:47 -07001070 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06107");
1071 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06108");
1072 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingInfo-imageView-06116");
Aaron Hagan80034ea2021-12-23 11:24:09 -05001073 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06129");
Jeremy Gebben09c1a072022-02-08 09:42:47 -07001074 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06145");
1075 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkRenderingAttachmentInfo-imageView-06146");
Aaron Hagan80034ea2021-12-23 11:24:09 -05001076 m_commandBuffer->BeginRendering(begin_rendering_info);
1077 m_errorMonitor->VerifyFound();
1078}
Aaron Haganb54466d2022-02-18 15:02:54 -05001079
1080TEST_F(VkLayerTest, DynamicRenderingBufferBeginInfoLegacy) {
1081 TEST_DESCRIPTION("VkCommandBufferBeginInfo Dynamic Rendering Tests.");
1082
1083 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_2);
1084 if (version < VK_API_VERSION_1_2) {
1085 printf("%s At least Vulkan version 1.2 is required, skipping test.\n", kSkipPrefix);
1086 return;
1087 }
1088
1089 AddRequiredExtensions(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1090
1091 ASSERT_NO_FATAL_FAILURE(Init(nullptr, nullptr, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
1092
1093 if (DeviceValidationVersion() < VK_API_VERSION_1_2) {
1094 printf("%s At least Vulkan version 1.2 is required for device, skipping test\n", kSkipPrefix);
1095 return;
1096 }
1097
1098 if (!AreRequestedExtensionsEnabled()) {
1099 printf("%s %s is not supported; skipping\n", kSkipPrefix, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
1100 return;
1101 }
1102
1103 auto cmd_buffer_inheritance_rendering_info = LvlInitStruct<VkCommandBufferInheritanceRenderingInfoKHR>();
1104 cmd_buffer_inheritance_rendering_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
1105
1106 auto cmd_buffer_inheritance_info = LvlInitStruct<VkCommandBufferInheritanceInfo>();
1107 cmd_buffer_inheritance_info.pNext = &cmd_buffer_inheritance_rendering_info;
1108 cmd_buffer_inheritance_info.renderPass = VK_NULL_HANDLE;
1109
1110 auto cmd_buffer_allocate_info = LvlInitStruct<VkCommandBufferAllocateInfo>();
1111 cmd_buffer_allocate_info.commandPool = m_commandPool->handle();
1112 cmd_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY;
1113 cmd_buffer_allocate_info.commandBufferCount = 0x1;
1114
1115 VkCommandBuffer secondary_cmd_buffer;
1116 VkResult err = vk::AllocateCommandBuffers(m_device->device(), &cmd_buffer_allocate_info, &secondary_cmd_buffer);
1117 ASSERT_VK_SUCCESS(err);
1118
1119 // Invalid RenderPass
1120 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-00053");
1121 VkCommandBufferBeginInfo cmd_buffer_begin_info = LvlInitStruct<VkCommandBufferBeginInfo>();
1122 cmd_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
1123 cmd_buffer_begin_info.pInheritanceInfo = &cmd_buffer_inheritance_info;
1124 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
1125 m_errorMonitor->VerifyFound();
1126
1127 // Valid RenderPass
1128 VkAttachmentDescription attach[] = {
1129 {0, VK_FORMAT_B8G8R8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE,
1130 VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_IMAGE_LAYOUT_UNDEFINED,
1131 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL},
1132 };
1133 VkAttachmentReference att_ref = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL};
1134
1135 VkSubpassDescription subpass = {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &att_ref, nullptr, nullptr, 0, nullptr};
1136 VkRenderPassCreateInfo rpci = {VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, 0, 1, attach, 1, &subpass, 0, nullptr};
1137
1138 vk_testing::RenderPass rp1;
1139 rp1.init(*m_device, rpci);
1140
1141 cmd_buffer_inheritance_info.renderPass = rp1.handle();
1142 cmd_buffer_inheritance_info.subpass = 0x5;
1143 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-00054");
1144 vk::BeginCommandBuffer(secondary_cmd_buffer, &cmd_buffer_begin_info);
1145 m_errorMonitor->VerifyFound();
1146}
1147
1148TEST_F(VkLayerTest, DynamicRenderingSecondaryCommandBuffer) {
1149 TEST_DESCRIPTION("VkCommandBufferBeginInfo Dynamic Rendering Tests.");
1150
1151 uint32_t version = SetTargetApiVersion(VK_API_VERSION_1_3);
1152 if (version < VK_API_VERSION_1_3) {
1153 printf("%s At least Vulkan version 1.3 is required, skipping test.\n", kSkipPrefix);
1154 return;
1155 }
1156
1157 ASSERT_NO_FATAL_FAILURE(Init());
1158
1159 if (DeviceValidationVersion() < VK_API_VERSION_1_3) {
1160 printf("%s At least Vulkan version 1.3 is required for device, skipping test\n", kSkipPrefix);
1161 return;
1162 }
1163
1164 VkCommandBufferObj cb(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
1165
1166 // Force the failure by not setting the Renderpass and Framebuffer fields
1167 VkCommandBufferInheritanceInfo cmd_buf_hinfo = LvlInitStruct<VkCommandBufferInheritanceInfo>();
1168 cmd_buf_hinfo.renderPass = VkRenderPass(0x1);
1169 VkCommandBufferBeginInfo cmd_buf_info = LvlInitStruct<VkCommandBufferBeginInfo>();
1170 cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
1171 cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo;
1172
1173 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06000");
1174 vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info);
1175 m_errorMonitor->VerifyFound();
1176
1177 // Valid RenderPass
1178 VkAttachmentDescription attach[] = {
1179 {0, VK_FORMAT_B8G8R8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE,
1180 VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_IMAGE_LAYOUT_UNDEFINED,
1181 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL},
1182 };
1183 VkAttachmentReference att_ref = {0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL};
1184
1185 VkSubpassDescription subpass = {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, 1, &att_ref, nullptr, nullptr, 0, nullptr};
1186 VkRenderPassCreateInfo rpci = {VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, 0, 1, attach, 1, &subpass, 0, nullptr};
1187
1188 vk_testing::RenderPass rp1;
1189 rp1.init(*m_device, rpci);
1190
1191 cmd_buf_hinfo.renderPass = rp1.handle();
1192 cmd_buf_hinfo.subpass = 0x5;
1193 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06001");
1194 vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info);
1195 m_errorMonitor->VerifyFound();
1196
1197 cmd_buf_hinfo.renderPass = VK_NULL_HANDLE;
1198 m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-VkCommandBufferBeginInfo-flags-06002");
1199 vk::BeginCommandBuffer(cb.handle(), &cmd_buf_info);
1200 m_errorMonitor->VerifyFound();
1201}