1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2021 The Khronos Group Inc.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief Vulkan Dynamic Rendering Tests
22 *//*--------------------------------------------------------------------*/
24 #include "deRandom.hpp"
25 #include "deUniquePtr.hpp"
27 #include "tcuImageCompare.hpp"
28 #include "tcuRGBA.hpp"
29 #include "tcuTestLog.hpp"
30 #include "tcuTextureUtil.hpp"
31 #include "tcuVectorUtil.hpp"
33 #include "vkBarrierUtil.hpp"
34 #include "vkBuilderUtil.hpp"
35 #include "vkCmdUtil.hpp"
36 #include "vktDrawBufferObjectUtil.hpp"
37 #include "vktDynamicRenderingTests.hpp"
38 #include "vkImageUtil.hpp"
39 #include "vkObjUtil.hpp"
40 #include "vkQueryUtil.hpp"
41 #include "vkRefUtil.hpp"
42 #include "vktTestGroupUtil.hpp"
43 #include "vktTestCase.hpp"
44 #include "vkTypeUtil.hpp"
67 constexpr auto VK_NULL_HANDLE = DE_NULL;
68 // maxColorAttachments is guaranteed to be at least 4.
69 constexpr deUint32 COLOR_ATTACHMENTS_NUMBER = 4;
71 constexpr deUint32 TEST_ATTACHMENT_LOAD_OP_LAST = 3;
75 // Draw two triangles in a single primary command buffer, beginning and ending the render pass instance.
76 TEST_TYPE_SINGLE_CMDBUF = 0,
77 // Draw two triangles in a single primary command buffer, but across two render pass instances, with the second RESUMING the first.
78 TEST_TYPE_SINGLE_CMDBUF_RESUMING,
79 // Draw two triangles in two primary command buffers, across two render pass instances, with the second RESUMING the first.
80 TEST_TYPE_TWO_CMDBUF_RESUMING,
81 // Draw two triangles in two secondary command buffers, across two render pass instances,
82 //with the second RESUMING the first, both recorded to the same primary command buffer.
83 TEST_TYPE_SECONDARY_CMDBUF_RESUMING,
84 // Draw two triangles in two secondary command buffers, across two render pass instances,
85 // with the second RESUMING the first, executed in the two primary command buffers.
86 TEST_TYPE_SECONDARY_CMDBUF_TWO_PRIMARY_RESUMING,
87 // Using CONTENTS_SECONDARY_COMMAND_BUFFER_BIT_KHR, draw two triangles in one secondary command buffer,
88 // and execute it inside a single render pass instance in one primary command buffer.
89 TEST_TYPE_CONTENTS_SECONDARY_COMMAND_BUFFER,
90 // Using CONTENTS_SECONDARY_COMMAND_BUFFER_BIT_KHR, draw two triangles in two secondary command buffers,
91 // and execute them inside a single render pass instance in one primary command buffer.
92 TEST_TYPE_CONTENTS_2_SECONDARY_COMMAND_BUFFER,
93 // Using CONTENTS_SECONDARY_COMMAND_BUFFER_BIT_KHR, draw two triangles in two secondary command buffers,
94 // and execute them inside two render pass instances, with the second RESUMING the first, both recorded in the same primary command buffer.
95 TEST_TYPE_CONTENTS_2_SECONDARY_COMMAND_BUFFER_RESUMING,
96 // Using CONTENTS_SECONDARY_COMMAND_BUFFER_BIT_KHR, draw two triangles in two secondary command buffers,
97 // and execute them inside two render pass instances, with the second RESUMING the first, recorded into two primary command buffers.
98 TEST_TYPE_CONTENTS_2_SECONDARY_2_PRIMARY_COMDBUF_RESUMING,
99 // In one primary command buffer, record two render pass instances, with the second resuming the first.In the first,
100 // draw one triangle directly in the primary command buffer.For the second, use CONTENTS_SECONDARY_COMMAND_BUFFER_BIT_KHR,
101 // draw the second triangle in a secondary command buffer, and execute it in that second render pass instance.
102 TEST_TYPE_CONTENTS_PRIMARY_SECONDARY_COMDBUF_RESUMING,
103 // In one primary command buffer, record two render pass instances, with the second resuming the first.In the first,
104 // use CONTENTS_SECONDARY_COMMAND_BUFFER_BIT_KHR, draw the first triangle in a secondary command buffer,
105 // and execute it in that first render pass instance.In the second, draw one triangle directly in the primary command buffer.
106 TEST_TYPE_CONTENTS_SECONDARY_PRIMARY_COMDBUF_RESUMING,
107 // In two primary command buffers, record two render pass instances(one in each), with the second resuming the first.In the first,
108 // draw one triangle directly in the primary command buffer.For the second, use CONTENTS_SECONDARY_COMMAND_BUFFER_BIT_KHR,
109 // draw the second triangle in a secondary command buffer, and execute it in that second render pass instance.
110 TEST_TYPE_CONTENTS_2_PRIMARY_SECONDARY_COMDBUF_RESUMING,
111 // In two primary command buffers, record two render pass instances(one in each), with the second resuming the first.In the first,
112 // use CONTENTS_SECONDARY_COMMAND_BUFFER_BIT_KHR, draw the first triangle in a secondary command buffer, and execute it in that first
113 // render pass instance.In the second, draw one triangle directly in the primary command buffer.
114 TEST_TYPE_CONTENTS_SECONDARY_2_PRIMARY_COMDBUF_RESUMING,
118 enum TestAttachmentType
120 TEST_ATTACHMENT_SINGLE_COLOR = 0,
121 TEST_ATTACHMENT_DEPTH_ATTACHMENT,
122 TEST_ATTACHMENT_STENCIL_ATTACHMENT,
123 TEST_ATTACHMENT_MULTIPLE_COLOR,
128 enum TestAttachmentStoreOp
130 TEST_ATTACHMENT_STORE_OP_STORE = VK_ATTACHMENT_STORE_OP_STORE,
131 TEST_ATTACHMENT_STORE_OP_DONT_CARE =VK_ATTACHMENT_STORE_OP_DONT_CARE,
132 TEST_ATTACHMENT_STORE_OP_LAST
135 struct TestParameters
138 const Vec4 clearColor;
139 const VkFormat imageFormat;
140 const UVec2 renderSize;
145 VkImageLayout oldColors[COLOR_ATTACHMENTS_NUMBER];
146 VkImageLayout oldStencil;
147 VkImageLayout oldDepth;
152 VkFormat colors[COLOR_ATTACHMENTS_NUMBER];
157 struct ClearAttachmentData
159 std::vector<VkClearAttachment> colorDepthClear1;
160 std::vector<VkClearAttachment> colorDepthClear2;
161 VkClearAttachment stencilClear1;
162 VkClearAttachment stencilClear2;
163 VkClearRect rectColorDepth1;
164 VkClearRect rectColorDepth2;
165 VkClearRect rectStencil1;
166 VkClearRect rectStencil2;
168 ClearAttachmentData (const deUint32 colorAtchCount,
169 const VkFormat depth,
170 const VkFormat stencil)
172 if (colorAtchCount != 0)
174 for (deUint32 atchNdx = 0; atchNdx < colorAtchCount; ++atchNdx)
176 const VkClearAttachment green =
178 VK_IMAGE_ASPECT_COLOR_BIT,
180 makeClearValueColorF32(0.0f, 1.0f, static_cast<float>(atchNdx) * 0.15f, 1.0f)
182 colorDepthClear1.push_back(green);
184 const VkClearAttachment yellow =
186 VK_IMAGE_ASPECT_COLOR_BIT,
188 makeClearValueColorF32(1.0f, 1.0f, static_cast<float>(atchNdx) * 0.15f, 1.0f)
190 colorDepthClear2.push_back(yellow);
194 if (depth != VK_FORMAT_UNDEFINED)
196 const VkClearAttachment zero =
198 VK_IMAGE_ASPECT_DEPTH_BIT,
200 makeClearValueDepthStencil(0.0f, 0)
202 colorDepthClear1.push_back(zero);
204 const VkClearAttachment one =
206 VK_IMAGE_ASPECT_DEPTH_BIT,
208 makeClearValueDepthStencil(0.2f, 0)
210 colorDepthClear2.push_back(one);
213 if (stencil != VK_FORMAT_UNDEFINED)
217 VK_IMAGE_ASPECT_STENCIL_BIT,
219 makeClearValueDepthStencil(0.0f, 1)
224 VK_IMAGE_ASPECT_STENCIL_BIT,
226 makeClearValueDepthStencil(0.0f, 2)
231 makeRect2D(0, 0, 32, 16),
238 makeRect2D(0, 16, 32, 16),
246 makeRect2D(0, 0, 16, 32),
253 makeRect2D(16, 0, 16, 32),
261 inline VkDeviceSize sizeInBytes (const std::vector<T>& vec)
263 return vec.size() * sizeof(vec[0]);
266 VkImageCreateInfo makeImageCreateInfo (const VkFormat format,
268 VkImageUsageFlags usage)
270 const VkImageCreateInfo imageParams =
272 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
273 DE_NULL, // const void* pNext;
274 (VkImageCreateFlags)0, // VkImageCreateFlags flags;
275 VK_IMAGE_TYPE_2D, // VkImageType imageType;
276 format, // VkFormat format;
277 makeExtent3D(size.x(), size.y(), 1), // VkExtent3D extent;
278 1u, // deUint32 mipLevels;
279 1u, // deUint32 arrayLayers;
280 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples;
281 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
282 usage, // VkImageUsageFlags usage;
283 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
284 0u, // deUint32 queueFamilyIndexCount;
285 DE_NULL, // const deUint32* pQueueFamilyIndices;
286 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
291 Move<VkPipeline> makeGraphicsPipeline (const DeviceInterface& vk,
292 const VkDevice device,
293 const VkPipelineLayout pipelineLayout,
294 const VkShaderModule vertexModule,
295 const VkShaderModule fragmentModule,
296 const UVec2 renderSize,
297 const deUint32 colorAttachmentCount,
298 const VkFormat* pColorAttachmentFormats,
299 const VkFormat depthStencilAttachmentFormat)
301 const VkVertexInputBindingDescription vertexInputBindingDescription =
303 0u, // uint32_t binding;
304 sizeof(Vec4), // uint32_t stride;
305 VK_VERTEX_INPUT_RATE_VERTEX, // VkVertexInputRate inputRate;
308 const VkVertexInputAttributeDescription vertexInputAttributeDescriptions[] =
311 0u, // uint32_t location;
312 0u, // uint32_t binding;
313 VK_FORMAT_R32G32B32A32_SFLOAT, // VkFormat format;
314 0u, // uint32_t offset;
318 const VkPipelineVertexInputStateCreateInfo vertexInputStateInfo =
320 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // VkStructureType sType;
321 DE_NULL, // const void* pNext;
322 (VkPipelineVertexInputStateCreateFlags)0, // VkPipelineVertexInputStateCreateFlags flags;
323 1u, // uint32_t vertexBindingDescriptionCount;
324 &vertexInputBindingDescription, // const VkVertexInputBindingDescription* pVertexBindingDescriptions;
325 DE_LENGTH_OF_ARRAY(vertexInputAttributeDescriptions), // uint32_t vertexAttributeDescriptionCount;
326 vertexInputAttributeDescriptions, // const VkVertexInputAttributeDescription* pVertexAttributeDescriptions;
329 const VkPipelineInputAssemblyStateCreateInfo pipelineInputAssemblyStateInfo =
331 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, // VkStructureType sType;
332 DE_NULL, // const void* pNext;
333 (VkPipelineInputAssemblyStateCreateFlags)0, // VkPipelineInputAssemblyStateCreateFlags flags;
334 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, // VkPrimitiveTopology topology;
335 VK_FALSE, // VkBool32 primitiveRestartEnable;
338 VkViewport viewport = makeViewport(0.0f, 0.0f, static_cast<float>(renderSize.x()), static_cast<float>(renderSize.y()), 0.0f, 1.0f);
339 const VkRect2D rectScissorRenderSize = { { 0, 0 }, { renderSize.x(), renderSize.y() } };
341 const VkPipelineViewportStateCreateInfo pipelineViewportStateInfo =
343 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, // VkStructureType sType;
344 DE_NULL, // const void* pNext;
345 (VkPipelineViewportStateCreateFlags)0, // VkPipelineViewportStateCreateFlags flags;
346 1u, // uint32_t viewportCount;
347 &viewport, // const VkViewport* pViewports;
348 1u, // uint32_t scissorCount;
349 &rectScissorRenderSize, // const VkRect2D* pScissors;
352 const VkPipelineRasterizationStateCreateInfo pipelineRasterizationStateInfo =
354 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, // VkStructureType sType;
355 DE_NULL, // const void* pNext;
356 (VkPipelineRasterizationStateCreateFlags)0, // VkPipelineRasterizationStateCreateFlags flags;
357 VK_FALSE, // VkBool32 depthClampEnable;
358 VK_FALSE, // VkBool32 rasterizerDiscardEnable;
359 VK_POLYGON_MODE_FILL, // VkPolygonMode polygonMode;
360 VK_CULL_MODE_NONE, // VkCullModeFlags cullMode;
361 VK_FRONT_FACE_COUNTER_CLOCKWISE, // VkFrontFace frontFace;
362 VK_FALSE, // VkBool32 depthBiasEnable;
363 0.0f, // float depthBiasConstantFactor;
364 0.0f, // float depthBiasClamp;
365 0.0f, // float depthBiasSlopeFactor;
366 1.0f, // float lineWidth;
369 const VkPipelineMultisampleStateCreateInfo pipelineMultisampleStateInfo =
371 VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, // VkStructureType sType;
372 DE_NULL, // const void* pNext;
373 (VkPipelineMultisampleStateCreateFlags)0, // VkPipelineMultisampleStateCreateFlags flags;
374 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits rasterizationSamples;
375 VK_FALSE, // VkBool32 sampleShadingEnable;
376 0.0f, // float minSampleShading;
377 DE_NULL, // const VkSampleMask* pSampleMask;
378 VK_FALSE, // VkBool32 alphaToCoverageEnable;
379 VK_FALSE // VkBool32 alphaToOneEnable;
382 const VkStencilOpState stencilOp = makeStencilOpState(
383 VK_STENCIL_OP_ZERO, // stencil fail
384 VK_STENCIL_OP_INCREMENT_AND_CLAMP, // depth & stencil pass
385 VK_STENCIL_OP_INCREMENT_AND_CLAMP, // depth only fail
386 VK_COMPARE_OP_NOT_EQUAL, // compare op
387 240u, // compare mask
391 VkPipelineDepthStencilStateCreateInfo pipelineDepthStencilStateInfo =
393 VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, // VkStructureType sType;
394 DE_NULL, // const void* pNext;
395 (VkPipelineDepthStencilStateCreateFlags)0, // VkPipelineDepthStencilStateCreateFlags flags;
396 VK_TRUE, // VkBool32 depthTestEnable;
397 VK_TRUE, // VkBool32 depthWriteEnable;
398 VK_COMPARE_OP_ALWAYS, // VkCompareOp depthCompareOp;
399 VK_FALSE, // VkBool32 depthBoundsTestEnable;
400 VK_TRUE, // VkBool32 stencilTestEnable;
401 stencilOp, // VkStencilOpState front;
402 stencilOp, // VkStencilOpState back;
403 0.0f, // float minDepthBounds;
404 1.0f, // float maxDepthBounds;
407 const VkColorComponentFlags colorComponentsAll = VK_COLOR_COMPONENT_R_BIT |
408 VK_COLOR_COMPONENT_G_BIT |
409 VK_COLOR_COMPONENT_B_BIT |
410 VK_COLOR_COMPONENT_A_BIT;
412 std::vector<VkPipelineColorBlendAttachmentState> colorBlendAttachmentState;
414 for (deUint32 ndx = 0 ; ndx < colorAttachmentCount; ++ndx)
416 const VkPipelineColorBlendAttachmentState pipelineColorBlendAttachmentState =
418 VK_FALSE, // VkBool32 blendEnable;
419 VK_BLEND_FACTOR_ONE, // VkBlendFactor srcColorBlendFactor;
420 VK_BLEND_FACTOR_ZERO, // VkBlendFactor dstColorBlendFactor;
421 VK_BLEND_OP_ADD, // VkBlendOp colorBlendOp;
422 VK_BLEND_FACTOR_ONE, // VkBlendFactor srcAlphaBlendFactor;
423 VK_BLEND_FACTOR_ZERO, // VkBlendFactor dstAlphaBlendFactor;
424 VK_BLEND_OP_ADD, // VkBlendOp alphaBlendOp;
425 colorComponentsAll, // VkColorComponentFlags colorWriteMask;
428 colorBlendAttachmentState.push_back(pipelineColorBlendAttachmentState);
431 const VkPipelineColorBlendStateCreateInfo pipelineColorBlendStateInfo =
433 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // VkStructureType sType;
434 DE_NULL, // const void* pNext;
435 (VkPipelineColorBlendStateCreateFlags)0, // VkPipelineColorBlendStateCreateFlags flags;
436 VK_FALSE, // VkBool32 logicOpEnable;
437 VK_LOGIC_OP_COPY, // VkLogicOp logicOp;
438 colorAttachmentCount, // deUint32 attachmentCount;
439 colorBlendAttachmentState.data(), // const VkPipelineColorBlendAttachmentState* pAttachments;
440 { 0.0f, 0.0f, 0.0f, 0.0f }, // float blendConstants[4];
443 const VkPipelineShaderStageCreateInfo pShaderStages[] =
446 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
447 DE_NULL, // const void* pNext;
448 (VkPipelineShaderStageCreateFlags)0, // VkPipelineShaderStageCreateFlags flags;
449 VK_SHADER_STAGE_VERTEX_BIT, // VkShaderStageFlagBits stage;
450 vertexModule, // VkShaderModule module;
451 "main", // const char* pName;
452 DE_NULL, // const VkSpecializationInfo* pSpecializationInfo;
455 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
456 DE_NULL, // const void* pNext;
457 (VkPipelineShaderStageCreateFlags)0, // VkPipelineShaderStageCreateFlags flags;
458 VK_SHADER_STAGE_FRAGMENT_BIT, // VkShaderStageFlagBits stage;
459 fragmentModule, // VkShaderModule module;
460 "main", // const char* pName;
461 DE_NULL, // const VkSpecializationInfo* pSpecializationInfo;
465 const VkPipelineRenderingCreateInfoKHR renderingCreateInfo
467 VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR, // VkStructureType sType;
468 DE_NULL, // const void* pNext;
469 0u, // deUint32 viewMask;
470 colorAttachmentCount, // deUint32 colorAttachmentCount;
471 pColorAttachmentFormats, // const VkFormat* pColorAttachmentFormats;
472 depthStencilAttachmentFormat, // VkFormat depthAttachmentFormat;
473 depthStencilAttachmentFormat, // VkFormat stencilAttachmentFormat;
476 const VkGraphicsPipelineCreateInfo graphicsPipelineInfo =
478 VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, // VkStructureType sType;
479 &renderingCreateInfo, // const void* pNext;
480 (VkPipelineCreateFlags)0, // VkPipelineCreateFlags flags;
481 2u, // deUint32 stageCount;
482 pShaderStages, // const VkPipelineShaderStageCreateInfo* pStages;
483 &vertexInputStateInfo, // const VkPipelineVertexInputStateCreateInfo* pVertexInputState;
484 &pipelineInputAssemblyStateInfo, // const VkPipelineInputAssemblyStateCreateInfo* pInputAssemblyState;
485 DE_NULL, // const VkPipelineTessellationStateCreateInfo* pTessellationState;
486 &pipelineViewportStateInfo, // const VkPipelineViewportStateCreateInfo* pViewportState;
487 &pipelineRasterizationStateInfo, // const VkPipelineRasterizationStateCreateInfo* pRasterizationState;
488 &pipelineMultisampleStateInfo, // const VkPipelineMultisampleStateCreateInfo* pMultisampleState;
489 &pipelineDepthStencilStateInfo, // const VkPipelineDepthStencilStateCreateInfo* pDepthStencilState;
490 &pipelineColorBlendStateInfo, // const VkPipelineColorBlendStateCreateInfo* pColorBlendState;
491 DE_NULL, // const VkPipelineDynamicStateCreateInfo* pDynamicState;
492 pipelineLayout, // VkPipelineLayout layout;
493 VK_NULL_HANDLE, // VkRenderPass renderPass;
494 0u, // deUint32 subpass;
495 DE_NULL, // VkPipeline basePipelineHandle;
496 0, // deInt32 basePipelineIndex;
499 return createGraphicsPipeline(vk, device, DE_NULL, &graphicsPipelineInfo);
502 VkFormat getSupportedStencilFormat (const InstanceInterface& vki,
503 VkPhysicalDevice physDev)
505 const VkFormat formatList[] = { VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT };
506 const VkFormatFeatureFlags requirements = (VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT |
507 VK_FORMAT_FEATURE_TRANSFER_SRC_BIT);
509 for (int i = 0; i < DE_LENGTH_OF_ARRAY(formatList); ++i)
511 const auto properties = getPhysicalDeviceFormatProperties(vki, physDev, formatList[i]);
512 if ((properties.optimalTilingFeatures & requirements) == requirements)
513 return formatList[i];
516 return VK_FORMAT_UNDEFINED;
519 tcu::TextureFormat getDepthTextureFormat (const VkFormat depthStencilFormat)
521 return ((depthStencilFormat == VK_FORMAT_D24_UNORM_S8_UINT) ?
522 tcu::TextureFormat(tcu::TextureFormat::D, tcu::TextureFormat::UNSIGNED_INT_24_8_REV) :
523 tcu::TextureFormat(tcu::TextureFormat::D, tcu::TextureFormat::FLOAT));
526 tcu::TextureLevel generateColroImage (const tcu::TextureFormat format,
527 const UVec2& renderSize,
528 const int attachmentNdx)
530 tcu::TextureLevel image (format, renderSize.x(), renderSize.y());
531 const float atchNdx = static_cast<float>(attachmentNdx);
532 const Vec4 greenColor = Vec4(0.0f, 1.0f, atchNdx * 0.15f, 1.0f);
533 const Vec4 yellowColor = Vec4(1.0f, 1.0f, atchNdx * 0.15f, 1.0f);
535 for (deUint32 y = 0; y < renderSize.y(); ++y)
537 for (deUint32 x = 0; x < renderSize.x() / 2u; ++x)
539 image.getAccess().setPixel(greenColor, x, y);
541 for (deUint32 x = renderSize.x() / 2u; x < renderSize.x(); ++x)
543 image.getAccess().setPixel(yellowColor, x, y);
550 tcu::TextureLevel generateDepthImage (const tcu::TextureFormat format,
551 const UVec2& renderSize)
553 tcu::TextureLevel image (format, renderSize.x(), renderSize.y());
554 const float value1 = 0.0f;
555 const float value2 = 0.2f;
557 for (deUint32 y = 0; y < renderSize.y(); ++y)
559 for (deUint32 x = 0; x < renderSize.x() / 2u; ++x)
561 image.getAccess().setPixDepth(value1, x, y);
563 for (deUint32 x = renderSize.x() / 2u; x < renderSize.x(); ++x)
565 image.getAccess().setPixDepth(value2, x, y);
572 tcu::TextureLevel generateStencilImage (const tcu::TextureFormat format,
573 const UVec2& renderSize)
575 tcu::TextureLevel image (format, renderSize.x(), renderSize.y());
576 const IVec4 value1 = IVec4(1,0,0,0);
577 const IVec4 value2 = IVec4(2,0,0,0);
579 for (deUint32 x = 0; x < renderSize.x(); ++x)
581 for (deUint32 y = 0; y < renderSize.y() / 2u; ++y)
583 image.getAccess().setPixel(value1, x, y);
585 for (deUint32 y = renderSize.y() / 2u; y < renderSize.y(); ++y)
587 image.getAccess().setPixel(value2, x, y);
594 void submitCommandsAndWait (const DeviceInterface& vk,
595 const VkDevice device,
597 const VkCommandBuffer commandBuffer,
598 const VkCommandBuffer commandBuffer2)
600 const Unique<VkFence> fence(createFence(vk, device));
601 const VkCommandBuffer cmdBuffers[2] = { commandBuffer, commandBuffer2 };
603 const VkSubmitInfo submitInfo =
605 VK_STRUCTURE_TYPE_SUBMIT_INFO, // VkStructureType sType;
606 DE_NULL, // const void* pNext;
607 0u, // deUint32 waitSemaphoreCount;
608 DE_NULL, // const VkSemaphore* pWaitSemaphores;
609 DE_NULL, // const VkPipelineStageFlags* pWaitDstStageMask;
610 2u, // deUint32 commandBufferCount;
611 cmdBuffers, // const VkCommandBuffer* pCommandBuffers;
612 0u, // deUint32 signalSemaphoreCount;
613 nullptr, // const VkSemaphore* pSignalSemaphores;
616 VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo, *fence));
617 VK_CHECK(vk.waitForFences(device, 1u, &fence.get(), DE_TRUE, ~0ull));
620 void beginSecondaryCmdBuffer (const DeviceInterface& vk,
621 const VkCommandBuffer commandBuffer,
622 VkRenderingFlagsKHR renderingFlags,
623 const deUint32 colorAttachmentCount,
624 const ImagesFormat& imagesFormat)
626 const VkFormat depthStencilFormat = (imagesFormat.depth != VK_FORMAT_UNDEFINED) ?
627 imagesFormat.depth : imagesFormat.stencil;
628 const VkCommandBufferInheritanceRenderingInfoKHR inheritanceRenderingInfo
630 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR, // VkStructureType sType;
631 DE_NULL, // const void* pNext;
632 renderingFlags, // VkRenderingFlagsKHR flags;
633 0u, // uint32_t viewMask;
634 colorAttachmentCount, // uint32_t colorAttachmentCount;
635 (colorAttachmentCount > 0) ? imagesFormat.colors : DE_NULL, // const VkFormat* pColorAttachmentFormats;
636 depthStencilFormat, // VkFormat depthAttachmentFormat;
637 depthStencilFormat, // VkFormat stencilAttachmentFormat;
638 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits rasterizationSamples;
641 const VkCommandBufferInheritanceInfo bufferInheritanceInfo =
643 vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, // VkStructureType sType;
644 &inheritanceRenderingInfo, // const void* pNext;
645 VK_NULL_HANDLE, // VkRenderPass renderPass;
646 0u, // deUint32 subpass;
647 VK_NULL_HANDLE, // VkFramebuffer framebuffer;
648 VK_FALSE, // VkBool32 occlusionQueryEnable;
649 (vk::VkQueryControlFlags)0u, // VkQueryControlFlags queryFlags;
650 (vk::VkQueryPipelineStatisticFlags)0u // VkQueryPipelineStatisticFlags pipelineStatistics;
653 const VkCommandBufferBeginInfo commandBufBeginParams =
655 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
656 DE_NULL, // const void* pNext;
657 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT |
658 VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, // VkCommandBufferUsageFlags flags;
659 &bufferInheritanceInfo
661 VK_CHECK(vk.beginCommandBuffer(commandBuffer, &commandBufBeginParams));
664 void beginSecondaryCmdBuffer(const DeviceInterface& vk,
665 const VkCommandBuffer commandBuffer)
667 const VkCommandBufferInheritanceInfo bufferInheritanceInfo =
669 vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, // VkStructureType sType;
670 DE_NULL, // const void* pNext;
671 VK_NULL_HANDLE, // VkRenderPass renderPass;
672 0u, // deUint32 subpass;
673 VK_NULL_HANDLE, // VkFramebuffer framebuffer;
674 VK_FALSE, // VkBool32 occlusionQueryEnable;
675 (vk::VkQueryControlFlags)0u, // VkQueryControlFlags queryFlags;
676 (vk::VkQueryPipelineStatisticFlags)0u // VkQueryPipelineStatisticFlags pipelineStatistics;
679 const VkCommandBufferBeginInfo commandBufBeginParams =
681 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
682 DE_NULL, // const void* pNext;
683 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, // VkCommandBufferUsageFlags flags;
684 &bufferInheritanceInfo
686 VK_CHECK(vk.beginCommandBuffer(commandBuffer, &commandBufBeginParams));
689 class DynamicRenderingTestInstance : public TestInstance
692 DynamicRenderingTestInstance (Context& context,
693 const TestParameters& parameters);
695 virtual tcu::TestStatus iterate (void);
696 void initialize (void);
697 void createCmdBuffer (void);
698 virtual void rendering (const VkPipeline pipeline,
699 const std::vector<VkImageView>& attachmentBindInfos,
700 const deUint32 colorAtchCount,
701 ImagesLayout& imagesLayout,
702 const ImagesFormat& imagesFormat);
703 void preBarier (const deUint32 colorAtchCount,
704 ImagesLayout& imagesLayout,
705 const ImagesFormat& imagesFormat);
706 void beginRendering (VkCommandBuffer cmdBuffer,
707 const std::vector<VkImageView>& attachmentBindInfos,
708 const VkRenderingFlagsKHR flags,
709 const deUint32 colorAtchCount,
710 const ImagesFormat& imagesFormat,
711 const VkAttachmentLoadOp loadOp,
712 const VkAttachmentStoreOp storeOp);
713 void copyImgToBuff (VkCommandBuffer commandBuffer,
714 const deUint32 colorAtchCount,
715 ImagesLayout& imagesLayout,
716 const ImagesFormat& imagesFormat);
717 void verifyResults (const deUint32 colorAtchCount,
718 const ImagesFormat& imagesFormat);
720 const TestParameters m_parameters;
721 VkFormat m_formatStencilDepthImage;
722 Move<VkImage> m_imageColor[COLOR_ATTACHMENTS_NUMBER];
723 Move<VkImage> m_imageStencilDepth;
724 Move<VkImageView> m_colorAttachmentView[COLOR_ATTACHMENTS_NUMBER];
725 Move<VkImageView> m_stencilDepthAttachmentView;
726 MovePtr<Allocation> m_imageColorAlloc[COLOR_ATTACHMENTS_NUMBER];
727 MovePtr<Allocation> m_imageStencilDepthAlloc;
728 SharedPtr<Buffer> m_imageBuffer[COLOR_ATTACHMENTS_NUMBER];
729 SharedPtr<Buffer> m_imageDepthBuffer;
730 SharedPtr<Buffer> m_imageStencilBuffer;
732 Move<VkShaderModule> m_vertexModule;
733 Move<VkShaderModule> m_fragmentModule;
734 SharedPtr<Buffer> m_vertexBuffer;
735 Move<VkPipelineLayout> m_pipelineLayout;
737 Move<VkCommandPool> m_cmdPool;
738 Move<VkCommandBuffer> m_cmdBuffer;
740 std::vector<tcu::TextureLevel> m_referenceImages;
743 DynamicRenderingTestInstance::DynamicRenderingTestInstance (Context& context,
744 const TestParameters& parameters)
745 : TestInstance (context)
746 , m_parameters (parameters)
748 const VkPhysicalDeviceDynamicRenderingFeaturesKHR& dynamicRenderingFeatures (context.getDynamicRenderingFeatures());
750 if (dynamicRenderingFeatures.dynamicRendering == DE_FALSE)
751 TCU_FAIL("dynamicRendering is not supported");
757 tcu::TestStatus DynamicRenderingTestInstance::iterate (void)
759 const DeviceInterface& vk = m_context.getDeviceInterface();
760 const VkDevice device = m_context.getDevice();
762 ImagesLayout imagesLayout
765 VK_IMAGE_LAYOUT_UNDEFINED,
766 VK_IMAGE_LAYOUT_UNDEFINED,
767 VK_IMAGE_LAYOUT_UNDEFINED,
768 VK_IMAGE_LAYOUT_UNDEFINED
770 VK_IMAGE_LAYOUT_UNDEFINED, // oldLStencil
771 VK_IMAGE_LAYOUT_UNDEFINED, // oldDepth
774 for (int attachmentTest = 0; attachmentTest < TEST_ATTACHMENT_LAST; ++attachmentTest)
776 std::vector<VkImageView> attachmentBindInfos;
778 ImagesFormat imagesFormat
781 m_parameters.imageFormat,
782 m_parameters.imageFormat,
783 m_parameters.imageFormat,
784 m_parameters.imageFormat,
786 m_formatStencilDepthImage, // depth
787 m_formatStencilDepthImage, // stencil
790 deUint32 colorAtchCount = 0u;
792 switch(attachmentTest)
794 case TEST_ATTACHMENT_SINGLE_COLOR:
796 attachmentBindInfos.push_back(*m_colorAttachmentView[0]);
797 imagesFormat.depth = VK_FORMAT_UNDEFINED;
798 imagesFormat.stencil = VK_FORMAT_UNDEFINED;
802 case TEST_ATTACHMENT_DEPTH_ATTACHMENT:
804 attachmentBindInfos.push_back(*m_stencilDepthAttachmentView);
805 imagesFormat.colors[0] = VK_FORMAT_UNDEFINED;
806 imagesFormat.stencil = VK_FORMAT_UNDEFINED;
809 case TEST_ATTACHMENT_STENCIL_ATTACHMENT:
811 attachmentBindInfos.push_back(*m_stencilDepthAttachmentView);
812 imagesFormat.colors[0] = VK_FORMAT_UNDEFINED;
813 imagesFormat.depth = VK_FORMAT_UNDEFINED;
816 case TEST_ATTACHMENT_MULTIPLE_COLOR:
818 for(deUint32 ndx = 0; ndx < COLOR_ATTACHMENTS_NUMBER; ndx++)
819 attachmentBindInfos.push_back(*m_colorAttachmentView[ndx]);
821 colorAtchCount = COLOR_ATTACHMENTS_NUMBER;
822 imagesFormat.depth = VK_FORMAT_UNDEFINED;
823 imagesFormat.stencil = VK_FORMAT_UNDEFINED;
826 case TEST_ATTACHMENT_ALL:
828 for (deUint32 ndx = 0; ndx < COLOR_ATTACHMENTS_NUMBER; ndx++)
829 attachmentBindInfos.push_back(*m_colorAttachmentView[ndx]);
831 attachmentBindInfos.push_back(*m_stencilDepthAttachmentView);
832 attachmentBindInfos.push_back(*m_stencilDepthAttachmentView);
834 colorAtchCount = COLOR_ATTACHMENTS_NUMBER;
838 DE_FATAL("Impossible");
840 Move<VkPipeline> pipeline = makeGraphicsPipeline(vk, device, *m_pipelineLayout,
841 *m_vertexModule, *m_fragmentModule,
842 m_parameters.renderSize, colorAtchCount, imagesFormat.colors,
843 ((imagesFormat.depth == VK_FORMAT_UNDEFINED) ? imagesFormat.stencil : imagesFormat.depth));
845 rendering(*pipeline, attachmentBindInfos, colorAtchCount, imagesLayout, imagesFormat);
847 return tcu::TestStatus::pass("Pass");
850 void DynamicRenderingTestInstance::initialize (void)
852 const InstanceInterface& vki = m_context.getInstanceInterface();
853 const DeviceInterface& vk = m_context.getDeviceInterface();
854 const VkPhysicalDevice physDevice = m_context.getPhysicalDevice();
855 const VkDevice device = m_context.getDevice();
856 Allocator& allocator = m_context.getDefaultAllocator();
860 std::vector<Vec4> vertices;
862 // Draw a quad covering the whole renderarea
863 vertices.push_back(Vec4(-1.0f, 1.0f, 0.0f, 1.0f));
864 vertices.push_back(Vec4(-1.0f, -1.0f, 0.0f, 1.0f));
865 vertices.push_back(Vec4( 0.0f, 1.0f, 0.0f, 1.0f));
866 vertices.push_back(Vec4( 0.0f, -1.0f, 0.0f, 1.0f));
868 vertices.push_back(Vec4(1.0f, -1.0f, 0.2f, 1.0f));
869 vertices.push_back(Vec4(0.0f, -1.0f, 0.2f, 1.0f));
870 vertices.push_back(Vec4(1.0f, 1.0f, 0.2f, 1.0f));
871 vertices.push_back(Vec4(0.0f, 1.0f, 0.2f, 1.0f));
873 vertices.push_back(Vec4(-1.0f, 1.0f, 0.0f, 1.0f));
874 vertices.push_back(Vec4(-1.0f, 0.0f, 0.0f, 1.0f));
875 vertices.push_back(Vec4( 1.0f, 1.0f, 0.0f, 1.0f));
876 vertices.push_back(Vec4( 1.0f, 0.0f, 0.0f, 1.0f));
878 const VkDeviceSize bufferSize = sizeInBytes(vertices);
879 const VkBufferCreateInfo bufferInfo = makeBufferCreateInfo(bufferSize,
880 VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
882 m_vertexBuffer = Buffer::createAndAlloc(vk, device,
885 MemoryRequirement::HostVisible);
886 deMemcpy(m_vertexBuffer->getBoundMemory().getHostPtr(), vertices.data(), static_cast<std::size_t>(bufferSize));
887 flushAlloc(vk, device, m_vertexBuffer->getBoundMemory());
890 // Images color attachment.
892 const VkImageUsageFlags imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
893 VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
894 const VkDeviceSize imageBufferSize = m_parameters.renderSize.x() *
895 m_parameters.renderSize.y() *
896 tcu::getPixelSize(mapVkFormat(m_parameters.imageFormat));
897 const VkImageSubresourceRange imageSubresource = makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u);
898 const VkImageCreateInfo imageInfo = makeImageCreateInfo(m_parameters.imageFormat,
899 m_parameters.renderSize, imageUsage);
900 const VkBufferCreateInfo bufferInfo = makeBufferCreateInfo(imageBufferSize,
901 VK_BUFFER_USAGE_TRANSFER_DST_BIT);
903 for(deUint32 ndx = 0; ndx < COLOR_ATTACHMENTS_NUMBER; ++ndx)
905 m_imageColor[ndx] = makeImage(vk, device, imageInfo);
906 m_imageColorAlloc[ndx] = bindImage(vk, device, allocator, *m_imageColor[ndx], MemoryRequirement::Any);
907 m_imageBuffer[ndx] = Buffer::createAndAlloc(vk, device, bufferInfo,
908 allocator, MemoryRequirement::HostVisible);
909 m_colorAttachmentView[ndx] = makeImageView(vk, device, *m_imageColor[ndx],
910 VK_IMAGE_VIEW_TYPE_2D, m_parameters.imageFormat, imageSubresource);
912 const Allocation alloc = m_imageBuffer[ndx]->getBoundMemory();
913 deMemset(alloc.getHostPtr(), 0, static_cast<std::size_t>(imageBufferSize));
914 flushAlloc(vk, device, alloc);
918 //Image stencil and depth attachment.
920 m_formatStencilDepthImage = getSupportedStencilFormat(vki, physDevice);
922 const VkImageAspectFlags imageDepthStencilAspec = VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_DEPTH_BIT;
923 const VkImageSubresourceRange imageStencilSubresource = makeImageSubresourceRange(imageDepthStencilAspec, 0u, 1u, 0u, 1u);
924 const VkDeviceSize imageBufferStencilSize = m_parameters.renderSize.x() *
925 m_parameters.renderSize.y() *
926 tcu::getPixelSize(mapVkFormat(VK_FORMAT_S8_UINT));
927 const VkDeviceSize imageBufferDepthlSize = m_parameters.renderSize.x() *
928 m_parameters.renderSize.y() *
929 tcu::getPixelSize(getDepthTextureFormat(m_formatStencilDepthImage));
931 const VkImageUsageFlags imageStenciDepthlUsage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
932 VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
933 const VkImageCreateInfo imageInfo = makeImageCreateInfo(m_formatStencilDepthImage,
934 m_parameters.renderSize, imageStenciDepthlUsage);
935 const VkBufferCreateInfo bufferStencilInfo = makeBufferCreateInfo(imageBufferStencilSize,
936 VK_BUFFER_USAGE_TRANSFER_DST_BIT);
937 const VkBufferCreateInfo bufferDepthlInfo = makeBufferCreateInfo(imageBufferDepthlSize,
938 VK_BUFFER_USAGE_TRANSFER_DST_BIT);
940 m_imageStencilDepth = makeImage(vk, device, imageInfo);
941 m_imageStencilDepthAlloc = bindImage(vk, device, allocator, *m_imageStencilDepth, MemoryRequirement::Any);
943 m_imageStencilBuffer = Buffer::createAndAlloc(vk, device, bufferStencilInfo,
944 allocator, MemoryRequirement::HostVisible);
945 m_imageDepthBuffer = Buffer::createAndAlloc(vk, device, bufferDepthlInfo,
946 allocator, MemoryRequirement::HostVisible);
947 m_stencilDepthAttachmentView = makeImageView(vk, device, *m_imageStencilDepth,
948 VK_IMAGE_VIEW_TYPE_2D, m_formatStencilDepthImage, imageStencilSubresource);
950 const Allocation alloc = m_imageStencilBuffer->getBoundMemory();
951 deMemset(alloc.getHostPtr(), 0, static_cast<std::size_t>(imageBufferStencilSize));
952 flushAlloc(vk, device, alloc);
954 const Allocation allocDepth = m_imageDepthBuffer->getBoundMemory();
955 deMemset(allocDepth.getHostPtr(), 0, static_cast<std::size_t>(imageBufferDepthlSize));
956 flushAlloc(vk, device, allocDepth);
959 m_pipelineLayout = makePipelineLayout(vk, device);
960 m_vertexModule = createShaderModule(vk, device, m_context.getBinaryCollection().get("vert"), 0u);
961 m_fragmentModule = createShaderModule(vk, device, m_context.getBinaryCollection().get("frag"), 0u);
963 for (deUint32 ndx = 0; ndx < COLOR_ATTACHMENTS_NUMBER; ++ndx)
965 m_referenceImages.push_back(generateColroImage(mapVkFormat(m_parameters.imageFormat),
966 m_parameters.renderSize, ndx));
969 m_referenceImages.push_back(generateDepthImage(getDepthTextureFormat(m_formatStencilDepthImage),
970 m_parameters.renderSize));
972 m_referenceImages.push_back(generateStencilImage(mapVkFormat(VK_FORMAT_S8_UINT),
973 m_parameters.renderSize));
976 void DynamicRenderingTestInstance::createCmdBuffer (void)
978 const DeviceInterface& vk = m_context.getDeviceInterface();
979 const VkDevice device = m_context.getDevice();
981 m_cmdPool = createCommandPool(vk, device,
982 VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
983 m_context.getUniversalQueueFamilyIndex());
984 m_cmdBuffer = allocateCommandBuffer(vk, device, *m_cmdPool,
985 VK_COMMAND_BUFFER_LEVEL_PRIMARY);
988 void DynamicRenderingTestInstance::rendering (const VkPipeline pipeline,
989 const std::vector<VkImageView>& attachmentBindInfos,
990 const deUint32 colorAtchCount,
991 ImagesLayout& imagesLayout,
992 const ImagesFormat& imagesFormat)
994 const DeviceInterface& vk = m_context.getDeviceInterface();
995 const VkDevice device = m_context.getDevice();
996 const VkQueue queue = m_context.getUniversalQueue();
998 for (deUint32 attachmentLoadOp = 0; attachmentLoadOp < TEST_ATTACHMENT_LOAD_OP_LAST; ++attachmentLoadOp)
999 for (deUint32 attachmentStoreOp = 0; attachmentStoreOp < TEST_ATTACHMENT_STORE_OP_LAST; ++attachmentStoreOp)
1002 beginCommandBuffer(vk, *m_cmdBuffer);
1003 preBarier(colorAtchCount, imagesLayout, imagesFormat);
1005 beginRendering(*m_cmdBuffer,
1006 attachmentBindInfos,
1010 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
1011 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
1013 vk.cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
1016 const VkBuffer vertexBuffer = m_vertexBuffer->object();
1017 const VkDeviceSize vertexBufferOffset = 0ull;
1018 vk.cmdBindVertexBuffers(*m_cmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1021 vk.cmdDraw(*m_cmdBuffer, 4u, 1u, 8u, 0u);
1022 vk.cmdDraw(*m_cmdBuffer, 4u, 1u, 0u, 0u);
1023 vk.cmdDraw(*m_cmdBuffer, 4u, 1u, 4u, 0u);
1025 vk.cmdEndRendering(*m_cmdBuffer);
1027 copyImgToBuff(*m_cmdBuffer, colorAtchCount, imagesLayout, imagesFormat);
1029 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1030 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer);
1032 if ((static_cast<VkAttachmentLoadOp>(attachmentLoadOp) == VK_ATTACHMENT_LOAD_OP_CLEAR) &&
1033 (static_cast<VkAttachmentStoreOp>(attachmentStoreOp) == VK_ATTACHMENT_STORE_OP_STORE))
1035 verifyResults(colorAtchCount, imagesFormat);
1037 const ClearAttachmentData clearData(colorAtchCount, imagesFormat.depth, imagesFormat.stencil);
1039 beginCommandBuffer(vk, *m_cmdBuffer);
1040 preBarier(colorAtchCount, imagesLayout, imagesFormat);
1042 beginRendering(*m_cmdBuffer,
1043 attachmentBindInfos,
1047 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
1048 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
1050 if (clearData.colorDepthClear1.size() != 0)
1052 vk.cmdClearAttachments(*m_cmdBuffer,
1053 static_cast<deUint32>(clearData.colorDepthClear1.size()),
1054 clearData.colorDepthClear1.data(),
1055 1, &clearData.rectColorDepth1);
1058 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
1059 vk.cmdClearAttachments(*m_cmdBuffer, 1u, &clearData.stencilClear1, 1, &clearData.rectStencil1);
1061 if (clearData.colorDepthClear2.size() != 0)
1063 vk.cmdClearAttachments(*m_cmdBuffer,
1064 static_cast<deUint32>(clearData.colorDepthClear2.size()),
1065 clearData.colorDepthClear2.data(),
1066 1, &clearData.rectColorDepth2);
1069 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
1070 vk.cmdClearAttachments(*m_cmdBuffer, 1u, &clearData.stencilClear2, 1, &clearData.rectStencil2);
1072 vk.cmdEndRendering(*m_cmdBuffer);
1074 copyImgToBuff(*m_cmdBuffer, colorAtchCount, imagesLayout, imagesFormat);
1076 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1077 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer);
1079 verifyResults(colorAtchCount, imagesFormat);
1084 void DynamicRenderingTestInstance::preBarier (const deUint32 colorAtchCount,
1085 ImagesLayout& imagesLayout,
1086 const ImagesFormat& imagesFormat)
1088 const DeviceInterface& vk = m_context.getDeviceInterface();
1090 std::vector<VkImageMemoryBarrier> barriers;
1092 for (deUint32 ndx = 0; ndx < colorAtchCount; ++ndx)
1094 const VkImageSubresourceRange subresource = makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u);
1095 const VkImageMemoryBarrier barrier = makeImageMemoryBarrier(VK_ACCESS_NONE_KHR,
1096 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
1097 imagesLayout.oldColors[ndx],
1098 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
1101 barriers.push_back(barrier);
1102 imagesLayout.oldColors[ndx] = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
1105 if (imagesFormat.depth != VK_FORMAT_UNDEFINED)
1107 const VkImageSubresourceRange subresource = makeImageSubresourceRange(VK_IMAGE_ASPECT_DEPTH_BIT, 0u, 1u, 0u, 1u);
1108 const VkImageMemoryBarrier barrier = makeImageMemoryBarrier(VK_ACCESS_NONE_KHR,
1109 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
1110 imagesLayout.oldDepth,
1111 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
1112 *m_imageStencilDepth,
1114 imagesLayout.oldDepth = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
1115 barriers.push_back(barrier);
1118 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
1120 const VkImageSubresourceRange subresource = makeImageSubresourceRange(VK_IMAGE_ASPECT_STENCIL_BIT, 0u, 1u, 0u, 1u);
1121 const VkImageMemoryBarrier barrier = makeImageMemoryBarrier(VK_ACCESS_NONE_KHR,
1122 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
1123 imagesLayout.oldStencil,
1124 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
1125 *m_imageStencilDepth,
1127 imagesLayout.oldStencil = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
1128 barriers.push_back(barrier);
1131 cmdPipelineImageMemoryBarrier(vk,
1133 VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
1134 VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT |
1135 VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
1140 void DynamicRenderingTestInstance::beginRendering (VkCommandBuffer cmdBuffer,
1141 const std::vector<VkImageView>& attachmentBindInfos,
1142 const VkRenderingFlagsKHR flags,
1143 const deUint32 colorAtchCount,
1144 const ImagesFormat& imagesFormat,
1145 const VkAttachmentLoadOp loadOp,
1146 const VkAttachmentStoreOp storeOp)
1148 const DeviceInterface& vk = m_context.getDeviceInterface();
1149 const VkClearValue clearValue = makeClearValueColor(m_parameters.clearColor);
1150 const VkRect2D renderArea =
1153 makeExtent2D(m_parameters.renderSize.x(), m_parameters.renderSize.y()),
1156 std::vector<VkRenderingAttachmentInfoKHR> attachments;
1158 for (deUint32 ndx = 0; ndx < colorAtchCount; ++ndx)
1160 const VkRenderingAttachmentInfoKHR renderingAtachInfo =
1162 VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR, // VkStructureType sType;
1163 DE_NULL, // const void* pNext;
1164 attachmentBindInfos[ndx], // VkImageView imageView;
1165 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout imageLayout;
1166 VK_RESOLVE_MODE_NONE, // VkResolveModeFlagBits resolveMode;
1167 VK_NULL_HANDLE, // VkImageView resolveImageView;
1168 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout resolveImageLayout;
1169 loadOp, // VkAttachmentLoadOp loadOp;
1170 storeOp, // VkAttachmentStoreOp storeOp;
1171 clearValue, // VkClearValue clearValue;
1174 attachments.push_back(renderingAtachInfo);
1177 if (imagesFormat.depth != VK_FORMAT_UNDEFINED)
1179 const VkRenderingAttachmentInfoKHR renderingAtachInfo =
1181 VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR, // VkStructureType sType;
1182 DE_NULL, // const void* pNext;
1183 attachmentBindInfos[colorAtchCount], // VkImageView imageView;
1184 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, // VkImageLayout imageLayout;
1185 VK_RESOLVE_MODE_NONE, // VkResolveModeFlagBits resolveMode;
1186 VK_NULL_HANDLE, // VkImageView resolveImageView;
1187 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout resolveImageLayout;
1188 loadOp, // VkAttachmentLoadOp loadOp;
1189 storeOp, // VkAttachmentStoreOp storeOp;
1190 clearValue, // VkClearValue clearValue;
1193 attachments.push_back(renderingAtachInfo);
1196 const deUint32 stencilNdx = colorAtchCount + ((imagesFormat.depth != VK_FORMAT_UNDEFINED) ? 1 : 0);
1198 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
1200 const VkRenderingAttachmentInfoKHR renderingAtachInfo =
1202 VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR, // VkStructureType sType;
1203 DE_NULL, // const void* pNext;
1204 attachmentBindInfos[stencilNdx], // VkImageView imageView;
1205 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, // VkImageLayout imageLayout;
1206 VK_RESOLVE_MODE_NONE, // VkResolveModeFlagBits resolveMode;
1207 VK_NULL_HANDLE, // VkImageView resolveImageView;
1208 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout resolveImageLayout;
1209 loadOp, // VkAttachmentLoadOp loadOp;
1210 storeOp, // VkAttachmentStoreOp storeOp;
1211 clearValue, // VkClearValue clearValue;
1214 attachments.push_back(renderingAtachInfo);
1217 const VkRenderingInfoKHR renderingInfo =
1219 VK_STRUCTURE_TYPE_RENDERING_INFO_KHR, // VkStructureType sType;
1220 DE_NULL, // const void* pNext;
1221 flags, // VkRenderingFlagsKHR flags;
1222 renderArea, // VkRect2D renderArea;
1223 1u, // deUint32 layerCount;
1224 0u, // deUint32 viewMask;
1225 colorAtchCount, // deUint32 colorAttachmentCount;
1226 ((colorAtchCount != 0) ? attachments.data() : DE_NULL), // const VkRenderingAttachmentInfoKHR* pColorAttachments;
1227 ((imagesFormat.depth != VK_FORMAT_UNDEFINED) ?
1228 &attachments[colorAtchCount] :
1229 DE_NULL), // const VkRenderingAttachmentInfoKHR* pDepthAttachment;
1230 ((imagesFormat.stencil != VK_FORMAT_UNDEFINED) ?
1231 &attachments[stencilNdx] :
1232 DE_NULL), // const VkRenderingAttachmentInfoKHR* pStencilAttachment;
1235 vk.cmdBeginRendering(cmdBuffer, &renderingInfo);
1238 void DynamicRenderingTestInstance::copyImgToBuff (VkCommandBuffer commandBuffer,
1239 const deUint32 colorAtchCount,
1240 ImagesLayout& imagesLayout,
1241 const ImagesFormat& imagesFormat)
1243 const DeviceInterface& vk = m_context.getDeviceInterface();
1245 if (imagesFormat.colors[0] != VK_FORMAT_UNDEFINED)
1247 for (deUint32 ndx = 0; ndx < colorAtchCount; ndx++)
1249 vk::copyImageToBuffer(vk, commandBuffer, *m_imageColor[ndx], m_imageBuffer[ndx]->object(),
1250 tcu::IVec2(m_parameters.renderSize.x(), m_parameters.renderSize.y()),
1251 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, imagesLayout.oldColors[ndx], 1u,
1252 VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_ASPECT_COLOR_BIT);
1253 imagesLayout.oldColors[ndx] = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
1256 if (imagesFormat.depth != VK_FORMAT_UNDEFINED)
1258 copyImageToBuffer(vk, commandBuffer, *m_imageStencilDepth, m_imageDepthBuffer->object(),
1259 tcu::IVec2(m_parameters.renderSize.x(), m_parameters.renderSize.y()),
1260 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, imagesLayout.oldDepth,
1261 1u, VK_IMAGE_ASPECT_DEPTH_BIT, VK_IMAGE_ASPECT_DEPTH_BIT);
1262 imagesLayout.oldDepth = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
1264 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
1266 copyImageToBuffer(vk, commandBuffer, *m_imageStencilDepth, m_imageStencilBuffer->object(),
1267 tcu::IVec2(m_parameters.renderSize.x(), m_parameters.renderSize.y()),
1268 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, imagesLayout.oldStencil,
1269 1u, VK_IMAGE_ASPECT_STENCIL_BIT, VK_IMAGE_ASPECT_STENCIL_BIT);
1270 imagesLayout.oldStencil = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
1274 void DynamicRenderingTestInstance::verifyResults (const deUint32 colorAtchCount,
1275 const ImagesFormat& imagesFormat)
1277 const DeviceInterface& vk = m_context.getDeviceInterface();
1278 const VkDevice device = m_context.getDevice();
1279 tcu::TestLog& log = m_context.getTestContext().getLog();
1281 if (imagesFormat.colors[0] != VK_FORMAT_UNDEFINED)
1283 for (deUint32 ndx = 0; ndx < colorAtchCount; ndx++)
1285 const Allocation allocColor = m_imageBuffer[ndx]->getBoundMemory();
1286 invalidateAlloc(vk, device, allocColor);
1287 const tcu::ConstPixelBufferAccess resultColorImage(mapVkFormat(m_parameters.imageFormat), m_parameters.renderSize.x(), m_parameters.renderSize.y(), 1u, allocColor.getHostPtr());
1289 if (!tcu::floatThresholdCompare(log, "Compare Color Image", "Result comparison",
1290 m_referenceImages[ndx].getAccess(), resultColorImage,
1291 Vec4(0.02f), tcu::COMPARE_LOG_ON_ERROR))
1293 TCU_FAIL("Rendered color image is not correct");
1298 if (imagesFormat.depth != VK_FORMAT_UNDEFINED)
1300 const Allocation allocDepth = m_imageDepthBuffer->getBoundMemory();
1301 invalidateAlloc(vk, device, allocDepth);
1303 const tcu::ConstPixelBufferAccess resultDepthImage(getDepthTextureFormat(m_formatStencilDepthImage),
1304 m_parameters.renderSize.x(),
1305 m_parameters.renderSize.y(),
1306 1u, allocDepth.getHostPtr());
1307 if (m_formatStencilDepthImage == VK_FORMAT_D24_UNORM_S8_UINT)
1309 de::MovePtr<tcu::TextureLevel> result(new tcu::TextureLevel(mapVkFormat(m_formatStencilDepthImage),
1310 m_parameters.renderSize.x(), m_parameters.renderSize.y(), 1u));
1311 tcu::copy(tcu::getEffectiveDepthStencilAccess(result->getAccess(), tcu::Sampler::MODE_DEPTH), resultDepthImage);
1313 const tcu::ConstPixelBufferAccess depthResult = tcu::getEffectiveDepthStencilAccess(result->getAccess(), tcu::Sampler::MODE_DEPTH);
1314 const tcu::ConstPixelBufferAccess expectedResult = tcu::getEffectiveDepthStencilAccess(m_referenceImages[COLOR_ATTACHMENTS_NUMBER].getAccess(), tcu::Sampler::MODE_DEPTH);
1316 if (!tcu::intThresholdCompare(log, "Compare Depth Image", "Result comparison",
1317 expectedResult, depthResult,UVec4(0, 0, 0, 0), tcu::COMPARE_LOG_ON_ERROR))
1319 TCU_FAIL("Rendered depth image is not correct");
1324 if (!tcu::floatThresholdCompare(log, "Compare Depth Image", "Result comparison",
1325 m_referenceImages[COLOR_ATTACHMENTS_NUMBER].getAccess(), resultDepthImage,
1326 Vec4(0.02f), tcu::COMPARE_LOG_ON_ERROR))
1328 TCU_FAIL("Rendered depth image is not correct");
1333 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
1335 const Allocation allocStencil = m_imageStencilBuffer->getBoundMemory();
1336 invalidateAlloc(vk, device, allocStencil);
1337 const tcu::ConstPixelBufferAccess resultStencilImage(mapVkFormat(VK_FORMAT_S8_UINT),
1338 m_parameters.renderSize.x(),
1339 m_parameters.renderSize.y(),
1340 1u, allocStencil.getHostPtr());
1342 if (!tcu::intThresholdCompare(log, "Compare Stencil Image", "Result comparison",
1343 m_referenceImages[COLOR_ATTACHMENTS_NUMBER + 1].getAccess(), resultStencilImage,
1344 UVec4(0, 0, 0, 0), tcu::COMPARE_LOG_ON_ERROR))
1346 TCU_FAIL("Rendered stencil image is not correct");
1351 class SingleCmdBufferResuming : public DynamicRenderingTestInstance
1354 SingleCmdBufferResuming (Context& context,
1355 const TestParameters& parameters);
1357 void rendering (const VkPipeline pipeline,
1358 const std::vector<VkImageView>& attachmentBindInfos,
1359 const deUint32 colorAtchCount,
1360 ImagesLayout& imagesLayout,
1361 const ImagesFormat& imagesFormat) override;
1364 SingleCmdBufferResuming::SingleCmdBufferResuming (Context& context,
1365 const TestParameters& parameters)
1366 : DynamicRenderingTestInstance(context, parameters)
1370 void SingleCmdBufferResuming::rendering (const VkPipeline pipeline,
1371 const std::vector<VkImageView>& attachmentBindInfos,
1372 const deUint32 colorAtchCount,
1373 ImagesLayout& imagesLayout,
1374 const ImagesFormat& imagesFormat)
1376 const DeviceInterface& vk = m_context.getDeviceInterface();
1377 const VkDevice device = m_context.getDevice();
1378 const VkQueue queue = m_context.getUniversalQueue();
1380 for (deUint32 attachmentLoadOp = 0; attachmentLoadOp < TEST_ATTACHMENT_LOAD_OP_LAST; ++attachmentLoadOp)
1381 for (deUint32 attachmentStoreOp = 0; attachmentStoreOp < TEST_ATTACHMENT_STORE_OP_LAST; ++attachmentStoreOp)
1383 beginCommandBuffer(vk, *m_cmdBuffer);
1384 preBarier(colorAtchCount, imagesLayout, imagesFormat);
1386 beginRendering(*m_cmdBuffer,
1387 attachmentBindInfos,
1388 VK_RENDERING_SUSPENDING_BIT_KHR,
1391 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
1392 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
1394 vk.cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
1397 const VkBuffer vertexBuffer = m_vertexBuffer->object();
1398 const VkDeviceSize vertexBufferOffset = 0ull;
1399 vk.cmdBindVertexBuffers(*m_cmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1402 vk.cmdDraw(*m_cmdBuffer, 4u, 1u, 8u, 0u);
1403 vk.cmdDraw(*m_cmdBuffer, 4u, 1u, 0u, 0u);
1404 vk.cmdEndRendering(*m_cmdBuffer);
1406 beginRendering(*m_cmdBuffer,
1407 attachmentBindInfos,
1408 VK_RENDERING_RESUMING_BIT_KHR,
1411 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
1412 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
1414 vk.cmdDraw(*m_cmdBuffer, 4u, 1u, 4u, 0u);
1416 vk.cmdEndRendering(*m_cmdBuffer);
1418 copyImgToBuff(*m_cmdBuffer, colorAtchCount, imagesLayout, imagesFormat);
1420 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1421 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer);
1423 if ((static_cast<VkAttachmentLoadOp>(attachmentLoadOp) == VK_ATTACHMENT_LOAD_OP_CLEAR) &&
1424 (static_cast<VkAttachmentStoreOp>(attachmentStoreOp) == VK_ATTACHMENT_STORE_OP_STORE))
1426 verifyResults(colorAtchCount, imagesFormat);
1428 const ClearAttachmentData clearData(colorAtchCount, imagesFormat.depth, imagesFormat.stencil);
1430 beginCommandBuffer(vk, *m_cmdBuffer);
1431 preBarier(colorAtchCount, imagesLayout, imagesFormat);
1433 beginRendering(*m_cmdBuffer,
1434 attachmentBindInfos,
1435 VK_RENDERING_SUSPENDING_BIT_KHR,
1438 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
1439 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
1441 if (clearData.colorDepthClear1.size() != 0)
1443 vk.cmdClearAttachments(*m_cmdBuffer,
1444 static_cast<deUint32>(clearData.colorDepthClear1.size()),
1445 clearData.colorDepthClear1.data(),
1446 1, &clearData.rectColorDepth1);
1449 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
1450 vk.cmdClearAttachments(*m_cmdBuffer, 1u, &clearData.stencilClear1, 1, &clearData.rectStencil1);
1452 vk.cmdEndRendering(*m_cmdBuffer);
1454 beginRendering(*m_cmdBuffer,
1455 attachmentBindInfos,
1456 VK_RENDERING_RESUMING_BIT_KHR,
1459 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
1460 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
1462 if (clearData.colorDepthClear2.size() != 0)
1464 vk.cmdClearAttachments(*m_cmdBuffer,
1465 static_cast<deUint32>(clearData.colorDepthClear2.size()),
1466 clearData.colorDepthClear2.data(),
1467 1, &clearData.rectColorDepth2);
1470 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
1471 vk.cmdClearAttachments(*m_cmdBuffer, 1u, &clearData.stencilClear2, 1, &clearData.rectStencil2);
1473 vk.cmdEndRendering(*m_cmdBuffer);
1475 copyImgToBuff(*m_cmdBuffer, colorAtchCount, imagesLayout, imagesFormat);
1477 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1478 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer);
1480 verifyResults(colorAtchCount, imagesFormat);
1485 class TwoPrimaryCmdBufferResuming : public DynamicRenderingTestInstance
1488 TwoPrimaryCmdBufferResuming (Context& context,
1489 const TestParameters& parameters);
1491 void rendering (const VkPipeline pipeline,
1492 const std::vector<VkImageView>& attachmentBindInfos,
1493 const deUint32 colorAtchCount,
1494 ImagesLayout& imagesLayout,
1495 const ImagesFormat& imagesFormat) override;
1497 Move<VkCommandBuffer> m_cmdBuffer2;
1500 TwoPrimaryCmdBufferResuming::TwoPrimaryCmdBufferResuming (Context& context,
1501 const TestParameters& parameters)
1502 : DynamicRenderingTestInstance(context, parameters)
1504 const DeviceInterface& vk = m_context.getDeviceInterface();
1505 const VkDevice device = m_context.getDevice();
1507 m_cmdBuffer2 = allocateCommandBuffer(vk, device, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY);
1510 void TwoPrimaryCmdBufferResuming::rendering (const VkPipeline pipeline,
1511 const std::vector<VkImageView>& attachmentBindInfos,
1512 const deUint32 colorAtchCount,
1513 ImagesLayout& imagesLayout,
1514 const ImagesFormat& imagesFormat)
1516 const DeviceInterface& vk = m_context.getDeviceInterface();
1517 const VkDevice device = m_context.getDevice();
1518 const VkQueue queue = m_context.getUniversalQueue();
1520 for (deUint32 attachmentLoadOp = 0; attachmentLoadOp < TEST_ATTACHMENT_LOAD_OP_LAST; ++attachmentLoadOp)
1521 for (deUint32 attachmentStoreOp = 0; attachmentStoreOp < TEST_ATTACHMENT_STORE_OP_LAST; ++attachmentStoreOp)
1523 // First Primary CommandBuffer
1524 beginCommandBuffer(vk, *m_cmdBuffer);
1525 preBarier(colorAtchCount, imagesLayout, imagesFormat);
1527 beginRendering(*m_cmdBuffer,
1528 attachmentBindInfos,
1529 VK_RENDERING_SUSPENDING_BIT_KHR,
1532 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
1533 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
1535 vk.cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
1538 const VkBuffer vertexBuffer = m_vertexBuffer->object();
1539 const VkDeviceSize vertexBufferOffset = 0ull;
1540 vk.cmdBindVertexBuffers(*m_cmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1543 vk.cmdDraw(*m_cmdBuffer, 4u, 1u, 8u, 0u);
1544 vk.cmdDraw(*m_cmdBuffer, 4u, 1u, 0u, 0u);
1546 vk.cmdEndRendering(*m_cmdBuffer);
1548 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1550 // Second Primary CommandBuffer
1551 beginCommandBuffer(vk, *m_cmdBuffer2);
1553 beginRendering(*m_cmdBuffer2,
1554 attachmentBindInfos,
1555 VK_RENDERING_RESUMING_BIT_KHR,
1558 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
1559 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
1561 vk.cmdBindPipeline(*m_cmdBuffer2, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
1564 const VkBuffer vertexBuffer = m_vertexBuffer->object();
1565 const VkDeviceSize vertexBufferOffset = 0ull;
1566 vk.cmdBindVertexBuffers(*m_cmdBuffer2, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1569 vk.cmdDraw(*m_cmdBuffer2, 4u, 1u, 4u, 0u);
1571 vk.cmdEndRendering(*m_cmdBuffer2);
1573 copyImgToBuff(*m_cmdBuffer2, colorAtchCount, imagesLayout, imagesFormat);
1575 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer2));
1577 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer, *m_cmdBuffer2);
1579 if ((static_cast<VkAttachmentLoadOp>(attachmentLoadOp) == VK_ATTACHMENT_LOAD_OP_CLEAR) &&
1580 (static_cast<VkAttachmentStoreOp>(attachmentStoreOp) == VK_ATTACHMENT_STORE_OP_STORE))
1582 verifyResults(colorAtchCount, imagesFormat);
1584 const ClearAttachmentData clearData(colorAtchCount, imagesFormat.depth, imagesFormat.stencil);
1586 // First Primary CommandBuffer
1587 beginCommandBuffer(vk, *m_cmdBuffer);
1588 preBarier(colorAtchCount, imagesLayout, imagesFormat);
1590 beginRendering(*m_cmdBuffer,
1591 attachmentBindInfos,
1592 VK_RENDERING_SUSPENDING_BIT_KHR,
1595 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
1596 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
1598 if (clearData.colorDepthClear1.size() != 0)
1600 vk.cmdClearAttachments(*m_cmdBuffer,
1601 static_cast<deUint32>(clearData.colorDepthClear1.size()),
1602 clearData.colorDepthClear1.data(),
1603 1, &clearData.rectColorDepth1);
1606 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
1607 vk.cmdClearAttachments(*m_cmdBuffer, 1u, &clearData.stencilClear1, 1, &clearData.rectStencil1);
1609 vk.cmdEndRendering(*m_cmdBuffer);
1611 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1613 // Second Primary CommandBuffer
1614 beginCommandBuffer(vk, *m_cmdBuffer2);
1616 beginRendering(*m_cmdBuffer2,
1617 attachmentBindInfos,
1618 VK_RENDERING_RESUMING_BIT_KHR,
1621 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
1622 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
1624 if (clearData.colorDepthClear2.size() != 0)
1626 vk.cmdClearAttachments(*m_cmdBuffer2,
1627 static_cast<deUint32>(clearData.colorDepthClear2.size()),
1628 clearData.colorDepthClear2.data(),
1629 1, &clearData.rectColorDepth2);
1632 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
1633 vk.cmdClearAttachments(*m_cmdBuffer2, 1u, &clearData.stencilClear2, 1, &clearData.rectStencil2);
1635 vk.cmdEndRendering(*m_cmdBuffer2);
1637 copyImgToBuff(*m_cmdBuffer2, colorAtchCount, imagesLayout, imagesFormat);
1639 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer2));
1641 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer, *m_cmdBuffer2);
1643 verifyResults(colorAtchCount, imagesFormat);
1648 class TwoSecondaryCmdBufferResuming : public DynamicRenderingTestInstance
1651 TwoSecondaryCmdBufferResuming (Context& context,
1652 const TestParameters& parameters);
1654 void rendering (const VkPipeline pipeline,
1655 const std::vector<VkImageView>& attachmentBindInfos,
1656 const deUint32 colorAtchCount,
1657 ImagesLayout& imagesLayout,
1658 const ImagesFormat& imagesFormat) override;
1660 Move<VkCommandBuffer> m_secCmdBuffers[2];
1663 TwoSecondaryCmdBufferResuming::TwoSecondaryCmdBufferResuming (Context& context,
1664 const TestParameters& parameters)
1665 : DynamicRenderingTestInstance(context, parameters)
1667 const DeviceInterface& vk = m_context.getDeviceInterface();
1668 const VkDevice device = m_context.getDevice();
1670 m_secCmdBuffers[0] = allocateCommandBuffer(vk, device, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
1671 m_secCmdBuffers[1] = allocateCommandBuffer(vk, device, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
1674 void TwoSecondaryCmdBufferResuming::rendering (const VkPipeline pipeline,
1675 const std::vector<VkImageView>& attachmentBindInfos,
1676 const deUint32 colorAtchCount,
1677 ImagesLayout& imagesLayout,
1678 const ImagesFormat& imagesFormat)
1680 const DeviceInterface& vk = m_context.getDeviceInterface();
1681 const VkDevice device = m_context.getDevice();
1682 const VkQueue queue = m_context.getUniversalQueue();
1684 for (deUint32 attachmentLoadOp = 0; attachmentLoadOp < TEST_ATTACHMENT_LOAD_OP_LAST; ++attachmentLoadOp)
1685 for (deUint32 attachmentStoreOp = 0; attachmentStoreOp < TEST_ATTACHMENT_STORE_OP_LAST; ++attachmentStoreOp)
1687 VkCommandBuffer secCmdBuffers[2] = {
1688 *(m_secCmdBuffers[0]),
1689 *(m_secCmdBuffers[1])
1691 const VkBuffer vertexBuffer = m_vertexBuffer->object();
1692 const VkDeviceSize vertexBufferOffset = 0ull;
1694 // secCmdBuffersFirst
1695 beginSecondaryCmdBuffer(vk, secCmdBuffers[0]);
1697 beginRendering(secCmdBuffers[0],
1698 attachmentBindInfos,
1699 VK_RENDERING_SUSPENDING_BIT_KHR,
1702 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
1703 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
1705 vk.cmdBindPipeline(secCmdBuffers[0], VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
1706 vk.cmdBindVertexBuffers(secCmdBuffers[0], 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1708 vk.cmdDraw(secCmdBuffers[0], 4u, 1u, 8u, 0u);
1709 vk.cmdDraw(secCmdBuffers[0], 4u, 1u, 0u, 0u);
1711 vk.cmdEndRendering(secCmdBuffers[0]);
1712 VK_CHECK(vk.endCommandBuffer(secCmdBuffers[0]));
1714 // secCmdBuffersSecond
1715 beginSecondaryCmdBuffer(vk, secCmdBuffers[1]);
1717 beginRendering(secCmdBuffers[1],
1718 attachmentBindInfos,
1719 VK_RENDERING_RESUMING_BIT_KHR,
1722 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
1723 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
1725 vk.cmdBindPipeline(secCmdBuffers[1], VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
1726 vk.cmdBindVertexBuffers(secCmdBuffers[1], 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1728 vk.cmdDraw(secCmdBuffers[1], 4u, 1u, 4u, 0u);
1730 vk.cmdEndRendering(secCmdBuffers[1]);
1731 VK_CHECK(vk.endCommandBuffer(secCmdBuffers[1]));
1733 // Primary commandBuffer
1734 beginCommandBuffer(vk, *m_cmdBuffer);
1735 preBarier(colorAtchCount, imagesLayout, imagesFormat);
1737 vk.cmdExecuteCommands(*m_cmdBuffer, 2u, secCmdBuffers);
1739 copyImgToBuff(*m_cmdBuffer, colorAtchCount, imagesLayout, imagesFormat);
1740 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1742 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer);
1744 if ((static_cast<VkAttachmentLoadOp>(attachmentLoadOp) == VK_ATTACHMENT_LOAD_OP_CLEAR) &&
1745 (static_cast<VkAttachmentStoreOp>(attachmentStoreOp) == VK_ATTACHMENT_STORE_OP_STORE))
1747 verifyResults(colorAtchCount, imagesFormat);
1749 const ClearAttachmentData clearData(colorAtchCount, imagesFormat.depth, imagesFormat.stencil);
1751 // secCmdBuffersFirst
1752 beginSecondaryCmdBuffer(vk, secCmdBuffers[0]);
1754 beginRendering(secCmdBuffers[0],
1755 attachmentBindInfos,
1756 VK_RENDERING_SUSPENDING_BIT_KHR,
1759 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
1760 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
1762 if (clearData.colorDepthClear1.size() != 0)
1764 vk.cmdClearAttachments(secCmdBuffers[0],
1765 static_cast<deUint32>(clearData.colorDepthClear1.size()),
1766 clearData.colorDepthClear1.data(),
1767 1, &clearData.rectColorDepth1);
1770 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
1771 vk.cmdClearAttachments(secCmdBuffers[0], 1u, &clearData.stencilClear1, 1, &clearData.rectStencil1);
1773 vk.cmdEndRendering(secCmdBuffers[0]);
1774 VK_CHECK(vk.endCommandBuffer(secCmdBuffers[0]));
1776 // secCmdBuffersSecond
1777 beginSecondaryCmdBuffer(vk, secCmdBuffers[1]);
1779 beginRendering(secCmdBuffers[1],
1780 attachmentBindInfos,
1781 VK_RENDERING_RESUMING_BIT_KHR,
1784 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
1785 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
1787 if (clearData.colorDepthClear2.size() != 0)
1789 vk.cmdClearAttachments(secCmdBuffers[1],
1790 static_cast<deUint32>(clearData.colorDepthClear2.size()),
1791 clearData.colorDepthClear2.data(),
1792 1, &clearData.rectColorDepth2);
1795 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
1796 vk.cmdClearAttachments(secCmdBuffers[1], 1u, &clearData.stencilClear2, 1, &clearData.rectStencil2);
1798 vk.cmdEndRendering(secCmdBuffers[1]);
1799 VK_CHECK(vk.endCommandBuffer(secCmdBuffers[1]));
1801 // Primary commandBuffer
1802 beginCommandBuffer(vk, *m_cmdBuffer);
1803 preBarier(colorAtchCount, imagesLayout, imagesFormat);
1805 vk.cmdExecuteCommands(*m_cmdBuffer, 2u, secCmdBuffers);
1807 copyImgToBuff(*m_cmdBuffer, colorAtchCount, imagesLayout, imagesFormat);
1808 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1810 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer);
1812 verifyResults(colorAtchCount, imagesFormat);
1817 class TwoSecondaryTwoPrimaryCmdBufferResuming : public DynamicRenderingTestInstance
1820 TwoSecondaryTwoPrimaryCmdBufferResuming (Context& context,
1821 const TestParameters& parameters);
1823 void rendering (const VkPipeline pipeline,
1824 const std::vector<VkImageView>& attachmentBindInfos,
1825 const deUint32 colorAtchCount,
1826 ImagesLayout& imagesLayout,
1827 const ImagesFormat& imagesFormat) override;
1829 Move<VkCommandBuffer> m_cmdBuffer2;
1830 Move<VkCommandBuffer> m_secCmdBuffers[2];
1833 TwoSecondaryTwoPrimaryCmdBufferResuming::TwoSecondaryTwoPrimaryCmdBufferResuming (Context& context,
1834 const TestParameters& parameters)
1835 : DynamicRenderingTestInstance(context, parameters)
1837 const DeviceInterface& vk = m_context.getDeviceInterface();
1838 const VkDevice device = m_context.getDevice();
1840 m_cmdBuffer2 = allocateCommandBuffer(vk, device, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY);
1841 m_secCmdBuffers[0] = allocateCommandBuffer(vk, device, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
1842 m_secCmdBuffers[1] = allocateCommandBuffer(vk, device, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
1845 void TwoSecondaryTwoPrimaryCmdBufferResuming::rendering (const VkPipeline pipeline,
1846 const std::vector<VkImageView>& attachmentBindInfos,
1847 const deUint32 colorAtchCount,
1848 ImagesLayout& imagesLayout,
1849 const ImagesFormat& imagesFormat)
1851 const DeviceInterface& vk = m_context.getDeviceInterface();
1852 const VkDevice device = m_context.getDevice();
1853 const VkQueue queue = m_context.getUniversalQueue();
1855 for (deUint32 attachmentLoadOp = 0; attachmentLoadOp < TEST_ATTACHMENT_LOAD_OP_LAST; ++attachmentLoadOp)
1856 for (deUint32 attachmentStoreOp = 0; attachmentStoreOp < TEST_ATTACHMENT_STORE_OP_LAST; ++attachmentStoreOp)
1858 VkCommandBuffer secCmdBuffers[2] = {
1859 *(m_secCmdBuffers[0]),
1860 *(m_secCmdBuffers[1])
1862 const VkBuffer vertexBuffer = m_vertexBuffer->object();
1863 const VkDeviceSize vertexBufferOffset = 0ull;
1865 // secCmdBuffersFirst
1866 beginSecondaryCmdBuffer(vk, secCmdBuffers[0]);
1868 beginRendering(secCmdBuffers[0],
1869 attachmentBindInfos,
1870 VK_RENDERING_SUSPENDING_BIT_KHR,
1873 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
1874 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
1876 vk.cmdBindPipeline(secCmdBuffers[0], VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
1877 vk.cmdBindVertexBuffers(secCmdBuffers[0], 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1879 vk.cmdDraw(secCmdBuffers[0], 4u, 1u, 8u, 0u);
1880 vk.cmdDraw(secCmdBuffers[0], 4u, 1u, 0u, 0u);
1882 vk.cmdEndRendering(secCmdBuffers[0]);
1883 VK_CHECK(vk.endCommandBuffer(secCmdBuffers[0]));
1886 // secCmdBuffersSecond
1887 beginSecondaryCmdBuffer(vk, secCmdBuffers[1]);
1889 beginRendering(secCmdBuffers[1],
1890 attachmentBindInfos,
1891 VK_RENDERING_RESUMING_BIT_KHR,
1894 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
1895 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
1897 vk.cmdBindPipeline(secCmdBuffers[1], VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
1898 vk.cmdBindVertexBuffers(secCmdBuffers[1], 0u, 1u, &vertexBuffer, &vertexBufferOffset);
1900 vk.cmdDraw(secCmdBuffers[1], 4u, 1u, 4u, 0u);
1902 vk.cmdEndRendering(secCmdBuffers[1]);
1903 VK_CHECK(vk.endCommandBuffer(secCmdBuffers[1]));
1905 // Primary commandBuffer
1906 beginCommandBuffer(vk, *m_cmdBuffer);
1907 preBarier(colorAtchCount, imagesLayout, imagesFormat);
1909 vk.cmdExecuteCommands(*m_cmdBuffer, 1u, &secCmdBuffers[0]);
1911 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1913 // Primary commandBuffer2
1914 beginCommandBuffer(vk, *m_cmdBuffer2);
1916 vk.cmdExecuteCommands(*m_cmdBuffer2, 1u, &secCmdBuffers[1]);
1918 copyImgToBuff(*m_cmdBuffer2, colorAtchCount, imagesLayout, imagesFormat);
1919 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer2));
1921 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer, *m_cmdBuffer2);
1923 if ((static_cast<VkAttachmentLoadOp>(attachmentLoadOp) == VK_ATTACHMENT_LOAD_OP_CLEAR) &&
1924 (static_cast<VkAttachmentStoreOp>(attachmentStoreOp) == VK_ATTACHMENT_STORE_OP_STORE))
1926 verifyResults(colorAtchCount, imagesFormat);
1928 const ClearAttachmentData clearData(colorAtchCount, imagesFormat.depth, imagesFormat.stencil);
1930 // secCmdBuffersFirst
1931 beginSecondaryCmdBuffer(vk, secCmdBuffers[0]);
1933 beginRendering(secCmdBuffers[0],
1934 attachmentBindInfos,
1935 VK_RENDERING_SUSPENDING_BIT_KHR,
1938 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
1939 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
1941 if (clearData.colorDepthClear1.size() != 0)
1943 vk.cmdClearAttachments(secCmdBuffers[0],
1944 static_cast<deUint32>(clearData.colorDepthClear1.size()),
1945 clearData.colorDepthClear1.data(),
1946 1, &clearData.rectColorDepth1);
1949 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
1950 vk.cmdClearAttachments(secCmdBuffers[0], 1u, &clearData.stencilClear1, 1, &clearData.rectStencil1);
1952 vk.cmdEndRendering(secCmdBuffers[0]);
1953 VK_CHECK(vk.endCommandBuffer(secCmdBuffers[0]));
1955 // secCmdBuffersSecond
1956 beginSecondaryCmdBuffer(vk, secCmdBuffers[1]);
1958 beginRendering(secCmdBuffers[1],
1959 attachmentBindInfos,
1960 VK_RENDERING_RESUMING_BIT_KHR,
1963 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
1964 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
1966 if (clearData.colorDepthClear2.size() != 0)
1968 vk.cmdClearAttachments(secCmdBuffers[1],
1969 static_cast<deUint32>(clearData.colorDepthClear2.size()),
1970 clearData.colorDepthClear2.data(),
1971 1, &clearData.rectColorDepth2);
1974 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
1975 vk.cmdClearAttachments(secCmdBuffers[1], 1u, &clearData.stencilClear2, 1, &clearData.rectStencil2);
1977 vk.cmdEndRendering(secCmdBuffers[1]);
1978 VK_CHECK(vk.endCommandBuffer(secCmdBuffers[1]));
1980 // Primary commandBuffer
1981 beginCommandBuffer(vk, *m_cmdBuffer);
1982 preBarier(colorAtchCount, imagesLayout, imagesFormat);
1984 vk.cmdExecuteCommands(*m_cmdBuffer, 1u, &secCmdBuffers[0]);
1986 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
1988 // Primary commandBuffer2
1989 beginCommandBuffer(vk, *m_cmdBuffer2);
1991 vk.cmdExecuteCommands(*m_cmdBuffer2, 1u, &secCmdBuffers[1]);
1993 copyImgToBuff(*m_cmdBuffer2, colorAtchCount, imagesLayout, imagesFormat);
1994 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer2));
1996 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer, *m_cmdBuffer2);
1998 verifyResults(colorAtchCount, imagesFormat);
2003 class ContentsSecondaryCmdBuffer : public DynamicRenderingTestInstance
2006 ContentsSecondaryCmdBuffer (Context& context,
2007 const TestParameters& parameters);
2009 void rendering (const VkPipeline pipeline,
2010 const std::vector<VkImageView>& attachmentBindInfos,
2011 const deUint32 colorAtchCount,
2012 ImagesLayout& imagesLayout,
2013 const ImagesFormat& imagesFormat) override;
2015 Move<VkCommandBuffer> m_secCmdBuffers;
2018 ContentsSecondaryCmdBuffer::ContentsSecondaryCmdBuffer (Context& context,
2019 const TestParameters& parameters)
2020 : DynamicRenderingTestInstance(context, parameters)
2022 const DeviceInterface& vk = m_context.getDeviceInterface();
2023 const VkDevice device = m_context.getDevice();
2025 m_secCmdBuffers = allocateCommandBuffer(vk, device, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2028 void ContentsSecondaryCmdBuffer::rendering (const VkPipeline pipeline,
2029 const std::vector<VkImageView>& attachmentBindInfos,
2030 const deUint32 colorAtchCount,
2031 ImagesLayout& imagesLayout,
2032 const ImagesFormat& imagesFormat)
2034 const DeviceInterface& vk = m_context.getDeviceInterface();
2035 const VkDevice device = m_context.getDevice();
2036 const VkQueue queue = m_context.getUniversalQueue();
2038 for (deUint32 attachmentLoadOp = 0; attachmentLoadOp < TEST_ATTACHMENT_LOAD_OP_LAST; ++attachmentLoadOp)
2039 for (deUint32 attachmentStoreOp = 0; attachmentStoreOp < TEST_ATTACHMENT_STORE_OP_LAST; ++attachmentStoreOp)
2041 const VkBuffer vertexBuffer = m_vertexBuffer->object();
2042 const VkDeviceSize vertexBufferOffset = 0ull;
2045 beginSecondaryCmdBuffer(vk, *m_secCmdBuffers, (VkRenderingFlagsKHR)0u, colorAtchCount, imagesFormat);
2047 vk.cmdBindPipeline(*m_secCmdBuffers, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
2048 vk.cmdBindVertexBuffers(*m_secCmdBuffers, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
2050 vk.cmdDraw(*m_secCmdBuffers, 4u, 1u, 8u, 0u);
2051 vk.cmdDraw(*m_secCmdBuffers, 4u, 1u, 0u, 0u);
2052 vk.cmdDraw(*m_secCmdBuffers, 4u, 1u, 4u, 0u);
2054 VK_CHECK(vk.endCommandBuffer(*m_secCmdBuffers));
2056 // Primary commandBuffer
2057 beginCommandBuffer(vk, *m_cmdBuffer);
2058 preBarier(colorAtchCount, imagesLayout, imagesFormat);
2060 beginRendering(*m_cmdBuffer,
2061 attachmentBindInfos,
2062 VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR,
2065 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
2066 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
2068 vk.cmdExecuteCommands(*m_cmdBuffer, 1u, &(*m_secCmdBuffers));
2070 vk.cmdEndRendering(*m_cmdBuffer);
2072 copyImgToBuff(*m_cmdBuffer, colorAtchCount, imagesLayout, imagesFormat);
2073 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
2075 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer);
2077 if ((static_cast<VkAttachmentLoadOp>(attachmentLoadOp) == VK_ATTACHMENT_LOAD_OP_CLEAR) &&
2078 (static_cast<VkAttachmentStoreOp>(attachmentStoreOp) == VK_ATTACHMENT_STORE_OP_STORE))
2080 verifyResults(colorAtchCount, imagesFormat);
2082 const ClearAttachmentData clearData(colorAtchCount, imagesFormat.depth, imagesFormat.stencil);
2085 beginSecondaryCmdBuffer(vk, *m_secCmdBuffers, (VkRenderingFlagsKHR)0u, colorAtchCount, imagesFormat);
2087 if (clearData.colorDepthClear1.size() != 0)
2089 vk.cmdClearAttachments(*m_secCmdBuffers,
2090 static_cast<deUint32>(clearData.colorDepthClear1.size()),
2091 clearData.colorDepthClear1.data(),
2092 1, &clearData.rectColorDepth1);
2095 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
2096 vk.cmdClearAttachments(*m_secCmdBuffers, 1u, &clearData.stencilClear1, 1, &clearData.rectStencil1);
2098 if (clearData.colorDepthClear2.size() != 0)
2100 vk.cmdClearAttachments(*m_secCmdBuffers,
2101 static_cast<deUint32>(clearData.colorDepthClear2.size()),
2102 clearData.colorDepthClear2.data(),
2103 1, &clearData.rectColorDepth2);
2106 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
2107 vk.cmdClearAttachments(*m_secCmdBuffers, 1u, &clearData.stencilClear2, 1, &clearData.rectStencil2);
2109 VK_CHECK(vk.endCommandBuffer(*m_secCmdBuffers));
2111 // Primary commandBuffer
2112 beginCommandBuffer(vk, *m_cmdBuffer);
2113 preBarier(colorAtchCount, imagesLayout, imagesFormat);
2115 beginRendering(*m_cmdBuffer,
2116 attachmentBindInfos,
2117 VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR,
2120 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
2121 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
2123 vk.cmdExecuteCommands(*m_cmdBuffer, 1u, &(*m_secCmdBuffers));
2125 vk.cmdEndRendering(*m_cmdBuffer);
2127 copyImgToBuff(*m_cmdBuffer, colorAtchCount, imagesLayout, imagesFormat);
2128 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
2130 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer);
2132 verifyResults(colorAtchCount, imagesFormat);
2137 class ContentsTwoSecondaryCmdBuffer : public DynamicRenderingTestInstance
2140 ContentsTwoSecondaryCmdBuffer (Context& context,
2141 const TestParameters& parameters);
2143 void rendering (const VkPipeline pipeline,
2144 const std::vector<VkImageView>& attachmentBindInfos,
2145 const deUint32 colorAtchCount,
2146 ImagesLayout& imagesLayout,
2147 const ImagesFormat& imagesFormat) override;
2149 Move<VkCommandBuffer> m_secCmdBuffers[2];
2152 ContentsTwoSecondaryCmdBuffer::ContentsTwoSecondaryCmdBuffer (Context& context,
2153 const TestParameters& parameters)
2154 : DynamicRenderingTestInstance(context, parameters)
2156 const DeviceInterface& vk = m_context.getDeviceInterface();
2157 const VkDevice device = m_context.getDevice();
2159 m_secCmdBuffers[0] = allocateCommandBuffer(vk, device, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2160 m_secCmdBuffers[1] = allocateCommandBuffer(vk, device, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2163 void ContentsTwoSecondaryCmdBuffer::rendering (const VkPipeline pipeline,
2164 const std::vector<VkImageView>& attachmentBindInfos,
2165 const deUint32 colorAtchCount,
2166 ImagesLayout& imagesLayout,
2167 const ImagesFormat& imagesFormat)
2169 const DeviceInterface& vk = m_context.getDeviceInterface();
2170 const VkDevice device = m_context.getDevice();
2171 const VkQueue queue = m_context.getUniversalQueue();
2173 VkCommandBuffer secCmdBuffers[2] = {
2174 *(m_secCmdBuffers[0]),
2175 *(m_secCmdBuffers[1])
2178 for (deUint32 attachmentLoadOp = 0; attachmentLoadOp < TEST_ATTACHMENT_LOAD_OP_LAST; ++attachmentLoadOp)
2179 for (deUint32 attachmentStoreOp = 0; attachmentStoreOp < TEST_ATTACHMENT_STORE_OP_LAST; ++attachmentStoreOp)
2181 const VkBuffer vertexBuffer = m_vertexBuffer->object();
2182 const VkDeviceSize vertexBufferOffset = 0ull;
2185 beginSecondaryCmdBuffer(vk, secCmdBuffers[0], (VkRenderingFlagsKHR)0u, colorAtchCount, imagesFormat);
2187 vk.cmdBindPipeline(secCmdBuffers[0], VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
2188 vk.cmdBindVertexBuffers(secCmdBuffers[0], 0u, 1u, &vertexBuffer, &vertexBufferOffset);
2190 vk.cmdDraw(secCmdBuffers[0], 4u, 1u, 8u, 0u);
2191 vk.cmdDraw(secCmdBuffers[0], 4u, 1u, 0u, 0u);
2193 VK_CHECK(vk.endCommandBuffer(secCmdBuffers[0]));
2196 beginSecondaryCmdBuffer(vk, secCmdBuffers[1], (VkRenderingFlagsKHR)0u, colorAtchCount, imagesFormat);
2198 vk.cmdBindPipeline(secCmdBuffers[1], VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
2199 vk.cmdBindVertexBuffers(secCmdBuffers[1], 0u, 1u, &vertexBuffer, &vertexBufferOffset);
2201 vk.cmdDraw(secCmdBuffers[1], 4u, 1u, 4u, 0u);
2203 VK_CHECK(vk.endCommandBuffer(secCmdBuffers[1]));
2205 // Primary commandBuffer
2206 beginCommandBuffer(vk, *m_cmdBuffer);
2207 preBarier(colorAtchCount, imagesLayout, imagesFormat);
2209 beginRendering(*m_cmdBuffer,
2210 attachmentBindInfos,
2211 VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR,
2214 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
2215 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
2217 vk.cmdExecuteCommands(*m_cmdBuffer, 2u, secCmdBuffers);
2219 vk.cmdEndRendering(*m_cmdBuffer);
2221 copyImgToBuff(*m_cmdBuffer, colorAtchCount, imagesLayout, imagesFormat);
2222 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
2224 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer);
2226 if ((static_cast<VkAttachmentLoadOp>(attachmentLoadOp) == VK_ATTACHMENT_LOAD_OP_CLEAR) &&
2227 (static_cast<VkAttachmentStoreOp>(attachmentStoreOp) == VK_ATTACHMENT_STORE_OP_STORE))
2229 verifyResults(colorAtchCount, imagesFormat);
2231 const ClearAttachmentData clearData(colorAtchCount, imagesFormat.depth, imagesFormat.stencil);
2234 beginSecondaryCmdBuffer(vk, secCmdBuffers[0], (VkRenderingFlagsKHR)0u, colorAtchCount, imagesFormat);
2236 if (clearData.colorDepthClear1.size() != 0)
2238 vk.cmdClearAttachments(secCmdBuffers[0],
2239 static_cast<deUint32>(clearData.colorDepthClear1.size()),
2240 clearData.colorDepthClear1.data(),
2241 1, &clearData.rectColorDepth1);
2244 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
2245 vk.cmdClearAttachments(secCmdBuffers[0], 1u, &clearData.stencilClear1, 1, &clearData.rectStencil1);
2247 VK_CHECK(vk.endCommandBuffer(secCmdBuffers[0]));
2250 beginSecondaryCmdBuffer(vk, secCmdBuffers[1], (VkRenderingFlagsKHR)0u, colorAtchCount, imagesFormat);
2252 if (clearData.colorDepthClear2.size() != 0)
2254 vk.cmdClearAttachments(secCmdBuffers[1],
2255 static_cast<deUint32>(clearData.colorDepthClear2.size()),
2256 clearData.colorDepthClear2.data(),
2257 1, &clearData.rectColorDepth2);
2260 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
2261 vk.cmdClearAttachments(secCmdBuffers[1], 1u, &clearData.stencilClear2, 1, &clearData.rectStencil2);
2263 VK_CHECK(vk.endCommandBuffer(secCmdBuffers[1]));
2265 // Primary commandBuffer
2266 beginCommandBuffer(vk, *m_cmdBuffer);
2267 preBarier(colorAtchCount, imagesLayout, imagesFormat);
2269 beginRendering(*m_cmdBuffer,
2270 attachmentBindInfos,
2271 VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR,
2274 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
2275 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
2277 vk.cmdExecuteCommands(*m_cmdBuffer, 2u, secCmdBuffers);
2279 vk.cmdEndRendering(*m_cmdBuffer);
2281 copyImgToBuff(*m_cmdBuffer, colorAtchCount, imagesLayout, imagesFormat);
2282 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
2284 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer);
2286 verifyResults(colorAtchCount, imagesFormat);
2291 class ContentsTwoSecondaryCmdBufferResuming : public DynamicRenderingTestInstance
2294 ContentsTwoSecondaryCmdBufferResuming (Context& context,
2295 const TestParameters& parameters);
2297 void rendering (const VkPipeline pipeline,
2298 const std::vector<VkImageView>& attachmentBindInfos,
2299 const deUint32 colorAtchCount,
2300 ImagesLayout& imagesLayout,
2301 const ImagesFormat& imagesFormat) override;
2303 Move<VkCommandBuffer> m_secCmdBuffers[2];
2306 ContentsTwoSecondaryCmdBufferResuming::ContentsTwoSecondaryCmdBufferResuming (Context& context,
2307 const TestParameters& parameters)
2308 : DynamicRenderingTestInstance(context, parameters)
2310 const DeviceInterface& vk = m_context.getDeviceInterface();
2311 const VkDevice device = m_context.getDevice();
2313 m_secCmdBuffers[0] = allocateCommandBuffer(vk, device, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2314 m_secCmdBuffers[1] = allocateCommandBuffer(vk, device, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2317 void ContentsTwoSecondaryCmdBufferResuming::rendering (const VkPipeline pipeline,
2318 const std::vector<VkImageView>& attachmentBindInfos,
2319 const deUint32 colorAtchCount,
2320 ImagesLayout& imagesLayout,
2321 const ImagesFormat& imagesFormat)
2323 const DeviceInterface& vk = m_context.getDeviceInterface();
2324 const VkDevice device = m_context.getDevice();
2325 const VkQueue queue = m_context.getUniversalQueue();
2327 VkCommandBuffer secCmdBuffers[2] = {
2328 *(m_secCmdBuffers[0]),
2329 *(m_secCmdBuffers[1])
2332 for (deUint32 attachmentLoadOp = 0; attachmentLoadOp < TEST_ATTACHMENT_LOAD_OP_LAST; ++attachmentLoadOp)
2333 for (deUint32 attachmentStoreOp = 0; attachmentStoreOp < TEST_ATTACHMENT_STORE_OP_LAST; ++attachmentStoreOp)
2335 const VkBuffer vertexBuffer = m_vertexBuffer->object();
2336 const VkDeviceSize vertexBufferOffset = 0ull;
2339 beginSecondaryCmdBuffer(vk, secCmdBuffers[0], VK_RENDERING_SUSPENDING_BIT_KHR, colorAtchCount, imagesFormat);
2341 vk.cmdBindPipeline(secCmdBuffers[0], VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
2342 vk.cmdBindVertexBuffers(secCmdBuffers[0], 0u, 1u, &vertexBuffer, &vertexBufferOffset);
2344 vk.cmdDraw(secCmdBuffers[0], 4u, 1u, 8u, 0u);
2345 vk.cmdDraw(secCmdBuffers[0], 4u, 1u, 0u, 0u);
2347 VK_CHECK(vk.endCommandBuffer(secCmdBuffers[0]));
2350 beginSecondaryCmdBuffer(vk, secCmdBuffers[1], VK_RENDERING_RESUMING_BIT_KHR, colorAtchCount, imagesFormat);
2352 vk.cmdBindPipeline(secCmdBuffers[1], VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
2353 vk.cmdBindVertexBuffers(secCmdBuffers[1], 0u, 1u, &vertexBuffer, &vertexBufferOffset);
2355 vk.cmdDraw(secCmdBuffers[1], 4u, 1u, 4u, 0u);
2357 VK_CHECK(vk.endCommandBuffer(secCmdBuffers[1]));
2359 // Primary commandBuffer
2360 beginCommandBuffer(vk, *m_cmdBuffer);
2361 preBarier(colorAtchCount, imagesLayout, imagesFormat);
2363 beginRendering(*m_cmdBuffer,
2364 attachmentBindInfos,
2365 VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR |
2366 VK_RENDERING_SUSPENDING_BIT_KHR,
2369 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
2370 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
2372 vk.cmdExecuteCommands(*m_cmdBuffer, 1u, &secCmdBuffers[0]);
2374 vk.cmdEndRendering(*m_cmdBuffer);
2376 beginRendering(*m_cmdBuffer,
2377 attachmentBindInfos,
2378 VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR |
2379 VK_RENDERING_RESUMING_BIT_KHR,
2382 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
2383 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
2385 vk.cmdExecuteCommands(*m_cmdBuffer, 1u, &secCmdBuffers[1]);
2387 vk.cmdEndRendering(*m_cmdBuffer);
2389 copyImgToBuff(*m_cmdBuffer, colorAtchCount, imagesLayout, imagesFormat);
2390 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
2392 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer);
2394 if ((static_cast<VkAttachmentLoadOp>(attachmentLoadOp) == VK_ATTACHMENT_LOAD_OP_CLEAR) &&
2395 (static_cast<VkAttachmentStoreOp>(attachmentStoreOp) == VK_ATTACHMENT_STORE_OP_STORE))
2397 verifyResults(colorAtchCount, imagesFormat);
2399 const ClearAttachmentData clearData(colorAtchCount, imagesFormat.depth, imagesFormat.stencil);
2402 beginSecondaryCmdBuffer(vk, secCmdBuffers[0], VK_RENDERING_SUSPENDING_BIT_KHR, colorAtchCount, imagesFormat);
2404 if (clearData.colorDepthClear1.size() != 0)
2406 vk.cmdClearAttachments(secCmdBuffers[0],
2407 static_cast<deUint32>(clearData.colorDepthClear1.size()),
2408 clearData.colorDepthClear1.data(),
2409 1, &clearData.rectColorDepth1);
2412 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
2413 vk.cmdClearAttachments(secCmdBuffers[0], 1u, &clearData.stencilClear1, 1, &clearData.rectStencil1);
2415 VK_CHECK(vk.endCommandBuffer(secCmdBuffers[0]));
2418 beginSecondaryCmdBuffer(vk, secCmdBuffers[1], VK_RENDERING_RESUMING_BIT_KHR, colorAtchCount, imagesFormat);
2420 if (clearData.colorDepthClear2.size() != 0)
2422 vk.cmdClearAttachments(secCmdBuffers[1],
2423 static_cast<deUint32>(clearData.colorDepthClear2.size()),
2424 clearData.colorDepthClear2.data(),
2425 1, &clearData.rectColorDepth2);
2428 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
2429 vk.cmdClearAttachments(secCmdBuffers[1], 1u, &clearData.stencilClear2, 1, &clearData.rectStencil2);
2431 VK_CHECK(vk.endCommandBuffer(secCmdBuffers[1]));
2433 // Primary commandBuffer
2434 beginCommandBuffer(vk, *m_cmdBuffer);
2435 preBarier(colorAtchCount, imagesLayout, imagesFormat);
2437 beginRendering(*m_cmdBuffer,
2438 attachmentBindInfos,
2439 VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR |
2440 VK_RENDERING_SUSPENDING_BIT_KHR,
2443 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
2444 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
2446 vk.cmdExecuteCommands(*m_cmdBuffer, 1u, &secCmdBuffers[0]);
2448 vk.cmdEndRendering(*m_cmdBuffer);
2450 beginRendering(*m_cmdBuffer,
2451 attachmentBindInfos,
2452 VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR |
2453 VK_RENDERING_RESUMING_BIT_KHR,
2456 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
2457 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
2459 vk.cmdExecuteCommands(*m_cmdBuffer, 1u, &secCmdBuffers[1]);
2461 vk.cmdEndRendering(*m_cmdBuffer);
2463 copyImgToBuff(*m_cmdBuffer, colorAtchCount, imagesLayout, imagesFormat);
2464 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
2466 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer);
2468 verifyResults(colorAtchCount, imagesFormat);
2473 class ContentsTwoSecondaryTwoPrimaryCmdBufferResuming : public DynamicRenderingTestInstance
2476 ContentsTwoSecondaryTwoPrimaryCmdBufferResuming (Context& context,
2477 const TestParameters& parameters);
2479 void rendering (const VkPipeline pipeline,
2480 const std::vector<VkImageView>& attachmentBindInfos,
2481 const deUint32 colorAtchCount,
2482 ImagesLayout& imagesLayout,
2483 const ImagesFormat& imagesFormat) override;
2485 Move<VkCommandBuffer> m_cmdBuffer2;
2486 Move<VkCommandBuffer> m_secCmdBuffers[2];
2489 ContentsTwoSecondaryTwoPrimaryCmdBufferResuming::ContentsTwoSecondaryTwoPrimaryCmdBufferResuming (Context& context,
2490 const TestParameters& parameters)
2491 : DynamicRenderingTestInstance(context, parameters)
2493 const DeviceInterface& vk = m_context.getDeviceInterface();
2494 const VkDevice device = m_context.getDevice();
2496 m_cmdBuffer2 = allocateCommandBuffer(vk, device, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY);
2497 m_secCmdBuffers[0] = allocateCommandBuffer(vk, device, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2498 m_secCmdBuffers[1] = allocateCommandBuffer(vk, device, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2501 void ContentsTwoSecondaryTwoPrimaryCmdBufferResuming::rendering (const VkPipeline pipeline,
2502 const std::vector<VkImageView>& attachmentBindInfos,
2503 const deUint32 colorAtchCount,
2504 ImagesLayout& imagesLayout,
2505 const ImagesFormat& imagesFormat)
2507 const DeviceInterface& vk = m_context.getDeviceInterface();
2508 const VkDevice device = m_context.getDevice();
2509 const VkQueue queue = m_context.getUniversalQueue();
2511 VkCommandBuffer secCmdBuffers[2] = {
2512 *(m_secCmdBuffers[0]),
2513 *(m_secCmdBuffers[1])
2516 for (deUint32 attachmentLoadOp = 0; attachmentLoadOp < TEST_ATTACHMENT_LOAD_OP_LAST; ++attachmentLoadOp)
2517 for (deUint32 attachmentStoreOp = 0; attachmentStoreOp < TEST_ATTACHMENT_STORE_OP_LAST; ++attachmentStoreOp)
2519 const VkBuffer vertexBuffer = m_vertexBuffer->object();
2520 const VkDeviceSize vertexBufferOffset = 0ull;
2523 beginSecondaryCmdBuffer(vk, secCmdBuffers[0], VK_RENDERING_SUSPENDING_BIT_KHR, colorAtchCount, imagesFormat);
2525 vk.cmdBindPipeline(secCmdBuffers[0], VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
2526 vk.cmdBindVertexBuffers(secCmdBuffers[0], 0u, 1u, &vertexBuffer, &vertexBufferOffset);
2528 vk.cmdDraw(secCmdBuffers[0], 4u, 1u, 8u, 0u);
2529 vk.cmdDraw(secCmdBuffers[0], 4u, 1u, 0u, 0u);
2531 VK_CHECK(vk.endCommandBuffer(secCmdBuffers[0]));
2534 beginSecondaryCmdBuffer(vk, secCmdBuffers[1], VK_RENDERING_RESUMING_BIT_KHR, colorAtchCount, imagesFormat);
2536 vk.cmdBindPipeline(secCmdBuffers[1], VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
2537 vk.cmdBindVertexBuffers(secCmdBuffers[1], 0u, 1u, &vertexBuffer, &vertexBufferOffset);
2539 vk.cmdDraw(secCmdBuffers[1], 4u, 1u, 4u, 0u);
2541 VK_CHECK(vk.endCommandBuffer(secCmdBuffers[1]));
2543 // Primary commandBuffer
2544 beginCommandBuffer(vk, *m_cmdBuffer);
2545 preBarier(colorAtchCount, imagesLayout, imagesFormat);
2547 beginRendering(*m_cmdBuffer,
2548 attachmentBindInfos,
2549 VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR |
2550 VK_RENDERING_SUSPENDING_BIT_KHR,
2553 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
2554 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
2556 vk.cmdExecuteCommands(*m_cmdBuffer, 1u, &secCmdBuffers[0]);
2558 vk.cmdEndRendering(*m_cmdBuffer);
2560 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
2562 // Primary commandBuffer2
2563 beginCommandBuffer(vk, *m_cmdBuffer2);
2565 beginRendering(*m_cmdBuffer2,
2566 attachmentBindInfos,
2567 VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR |
2568 VK_RENDERING_RESUMING_BIT_KHR,
2571 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
2572 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
2574 vk.cmdExecuteCommands(*m_cmdBuffer2, 1u, &secCmdBuffers[1]);
2576 vk.cmdEndRendering(*m_cmdBuffer2);
2578 copyImgToBuff(*m_cmdBuffer2, colorAtchCount, imagesLayout, imagesFormat);
2580 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer2));
2582 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer, *m_cmdBuffer2);
2584 if ((static_cast<VkAttachmentLoadOp>(attachmentLoadOp) == VK_ATTACHMENT_LOAD_OP_CLEAR) &&
2585 (static_cast<VkAttachmentStoreOp>(attachmentStoreOp) == VK_ATTACHMENT_STORE_OP_STORE))
2587 verifyResults(colorAtchCount, imagesFormat);
2589 const ClearAttachmentData clearData(colorAtchCount, imagesFormat.depth, imagesFormat.stencil);
2592 beginSecondaryCmdBuffer(vk, secCmdBuffers[0], VK_RENDERING_SUSPENDING_BIT_KHR, colorAtchCount, imagesFormat);
2594 if (clearData.colorDepthClear1.size() != 0)
2596 vk.cmdClearAttachments(secCmdBuffers[0],
2597 static_cast<deUint32>(clearData.colorDepthClear1.size()),
2598 clearData.colorDepthClear1.data(),
2599 1, &clearData.rectColorDepth1);
2602 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
2603 vk.cmdClearAttachments(secCmdBuffers[0], 1u, &clearData.stencilClear1, 1, &clearData.rectStencil1);
2605 VK_CHECK(vk.endCommandBuffer(secCmdBuffers[0]));
2608 beginSecondaryCmdBuffer(vk, secCmdBuffers[1], VK_RENDERING_RESUMING_BIT_KHR, colorAtchCount, imagesFormat);
2610 if (clearData.colorDepthClear2.size() != 0)
2612 vk.cmdClearAttachments(secCmdBuffers[1],
2613 static_cast<deUint32>(clearData.colorDepthClear2.size()),
2614 clearData.colorDepthClear2.data(),
2615 1, &clearData.rectColorDepth2);
2618 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
2619 vk.cmdClearAttachments(secCmdBuffers[1], 1u, &clearData.stencilClear2, 1, &clearData.rectStencil2);
2621 VK_CHECK(vk.endCommandBuffer(secCmdBuffers[1]));
2623 // Primary commandBuffer
2624 beginCommandBuffer(vk, *m_cmdBuffer);
2625 preBarier(colorAtchCount, imagesLayout, imagesFormat);
2627 beginRendering(*m_cmdBuffer,
2628 attachmentBindInfos,
2629 VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR |
2630 VK_RENDERING_SUSPENDING_BIT_KHR,
2633 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
2634 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
2636 vk.cmdExecuteCommands(*m_cmdBuffer, 1u, &secCmdBuffers[0]);
2638 vk.cmdEndRendering(*m_cmdBuffer);
2640 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
2642 // Primary commandBuffer2
2643 beginCommandBuffer(vk, *m_cmdBuffer2);
2645 beginRendering(*m_cmdBuffer2,
2646 attachmentBindInfos,
2647 VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR |
2648 VK_RENDERING_RESUMING_BIT_KHR,
2651 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
2652 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
2654 vk.cmdExecuteCommands(*m_cmdBuffer2, 1u, &secCmdBuffers[1]);
2656 vk.cmdEndRendering(*m_cmdBuffer2);
2658 copyImgToBuff(*m_cmdBuffer2, colorAtchCount, imagesLayout, imagesFormat);
2660 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer2));
2662 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer, *m_cmdBuffer2);
2664 verifyResults(colorAtchCount, imagesFormat);
2669 class ContentsPrimarySecondaryCmdBufferResuming : public DynamicRenderingTestInstance
2672 ContentsPrimarySecondaryCmdBufferResuming (Context& context,
2673 const TestParameters& parameters);
2675 void rendering (const VkPipeline pipeline,
2676 const std::vector<VkImageView>& attachmentBindInfos,
2677 const deUint32 colorAtchCount,
2678 ImagesLayout& imagesLayout,
2679 const ImagesFormat& imagesFormat) override;
2681 Move<VkCommandBuffer> m_secCmdBuffer;
2684 ContentsPrimarySecondaryCmdBufferResuming::ContentsPrimarySecondaryCmdBufferResuming (Context& context,
2685 const TestParameters& parameters)
2686 : DynamicRenderingTestInstance(context, parameters)
2688 const DeviceInterface& vk = m_context.getDeviceInterface();
2689 const VkDevice device = m_context.getDevice();
2691 m_secCmdBuffer = allocateCommandBuffer(vk, device, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2694 void ContentsPrimarySecondaryCmdBufferResuming::rendering (const VkPipeline pipeline,
2695 const std::vector<VkImageView>& attachmentBindInfos,
2696 const deUint32 colorAtchCount,
2697 ImagesLayout& imagesLayout,
2698 const ImagesFormat& imagesFormat)
2700 const DeviceInterface& vk = m_context.getDeviceInterface();
2701 const VkDevice device = m_context.getDevice();
2702 const VkQueue queue = m_context.getUniversalQueue();
2704 for (deUint32 attachmentLoadOp = 0; attachmentLoadOp < TEST_ATTACHMENT_LOAD_OP_LAST; ++attachmentLoadOp)
2705 for (deUint32 attachmentStoreOp = 0; attachmentStoreOp < TEST_ATTACHMENT_STORE_OP_LAST; ++attachmentStoreOp)
2707 const VkBuffer vertexBuffer = m_vertexBuffer->object();
2708 const VkDeviceSize vertexBufferOffset = 0ull;
2711 beginSecondaryCmdBuffer(vk, *m_secCmdBuffer, VK_RENDERING_RESUMING_BIT_KHR, colorAtchCount, imagesFormat);
2713 vk.cmdBindPipeline(*m_secCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
2714 vk.cmdBindVertexBuffers(*m_secCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
2716 vk.cmdDraw(*m_secCmdBuffer, 4u, 1u, 4u, 0u);
2718 VK_CHECK(vk.endCommandBuffer(*m_secCmdBuffer));
2720 // Primary commandBuffer
2721 beginCommandBuffer(vk, *m_cmdBuffer);
2722 preBarier(colorAtchCount, imagesLayout, imagesFormat);
2724 beginRendering(*m_cmdBuffer,
2725 attachmentBindInfos,
2726 VK_RENDERING_SUSPENDING_BIT_KHR,
2729 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
2730 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
2732 vk.cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
2733 vk.cmdBindVertexBuffers(*m_cmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
2735 vk.cmdDraw(*m_cmdBuffer, 4u, 1u, 8u, 0u);
2736 vk.cmdDraw(*m_cmdBuffer, 4u, 1u, 0u, 0u);
2738 vk.cmdEndRendering(*m_cmdBuffer);
2740 beginRendering(*m_cmdBuffer,
2741 attachmentBindInfos,
2742 VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR |
2743 VK_RENDERING_RESUMING_BIT_KHR,
2746 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
2747 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
2749 vk.cmdExecuteCommands(*m_cmdBuffer, 1u, &(*m_secCmdBuffer));
2751 vk.cmdEndRendering(*m_cmdBuffer);
2753 copyImgToBuff(*m_cmdBuffer, colorAtchCount, imagesLayout, imagesFormat);
2755 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
2757 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer);
2759 if ((static_cast<VkAttachmentLoadOp>(attachmentLoadOp) == VK_ATTACHMENT_LOAD_OP_CLEAR) &&
2760 (static_cast<VkAttachmentStoreOp>(attachmentStoreOp) == VK_ATTACHMENT_STORE_OP_STORE))
2762 verifyResults(colorAtchCount, imagesFormat);
2764 const ClearAttachmentData clearData(colorAtchCount, imagesFormat.depth, imagesFormat.stencil);
2767 beginSecondaryCmdBuffer(vk, *m_secCmdBuffer, VK_RENDERING_RESUMING_BIT_KHR, colorAtchCount, imagesFormat);
2769 if (clearData.colorDepthClear1.size() != 0)
2771 vk.cmdClearAttachments(*m_secCmdBuffer,
2772 static_cast<deUint32>(clearData.colorDepthClear1.size()),
2773 clearData.colorDepthClear1.data(),
2774 1, &clearData.rectColorDepth1);
2777 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
2778 vk.cmdClearAttachments(*m_secCmdBuffer, 1u, &clearData.stencilClear1, 1, &clearData.rectStencil1);
2780 VK_CHECK(vk.endCommandBuffer(*m_secCmdBuffer));
2782 // Primary commandBuffer
2783 beginCommandBuffer(vk, *m_cmdBuffer);
2784 preBarier(colorAtchCount, imagesLayout, imagesFormat);
2786 beginRendering(*m_cmdBuffer,
2787 attachmentBindInfos,
2788 VK_RENDERING_SUSPENDING_BIT_KHR,
2791 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
2792 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
2794 if (clearData.colorDepthClear2.size() != 0)
2796 vk.cmdClearAttachments(*m_cmdBuffer,
2797 static_cast<deUint32>(clearData.colorDepthClear2.size()),
2798 clearData.colorDepthClear2.data(),
2799 1, &clearData.rectColorDepth2);
2802 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
2803 vk.cmdClearAttachments(*m_cmdBuffer, 1u, &clearData.stencilClear2, 1, &clearData.rectStencil2);
2805 vk.cmdEndRendering(*m_cmdBuffer);
2807 beginRendering(*m_cmdBuffer,
2808 attachmentBindInfos,
2809 VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR |
2810 VK_RENDERING_RESUMING_BIT_KHR,
2813 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
2814 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
2816 vk.cmdExecuteCommands(*m_cmdBuffer, 1u, &(*m_secCmdBuffer));
2818 vk.cmdEndRendering(*m_cmdBuffer);
2820 copyImgToBuff(*m_cmdBuffer, colorAtchCount, imagesLayout, imagesFormat);
2822 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
2824 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer);
2826 verifyResults(colorAtchCount, imagesFormat);
2831 class ContentsSecondaryPrimaryCmdBufferResuming : public DynamicRenderingTestInstance
2834 ContentsSecondaryPrimaryCmdBufferResuming (Context& context,
2835 const TestParameters& parameters);
2837 void rendering (const VkPipeline pipeline,
2838 const std::vector<VkImageView>& attachmentBindInfos,
2839 const deUint32 colorAtchCount,
2840 ImagesLayout& imagesLayout,
2841 const ImagesFormat& imagesFormat) override;
2843 Move<VkCommandBuffer> m_secCmdBuffer;
2846 ContentsSecondaryPrimaryCmdBufferResuming::ContentsSecondaryPrimaryCmdBufferResuming (Context& context,
2847 const TestParameters& parameters)
2848 : DynamicRenderingTestInstance(context, parameters)
2850 const DeviceInterface& vk = m_context.getDeviceInterface();
2851 const VkDevice device = m_context.getDevice();
2853 m_secCmdBuffer = allocateCommandBuffer(vk, device, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2856 void ContentsSecondaryPrimaryCmdBufferResuming::rendering (const VkPipeline pipeline,
2857 const std::vector<VkImageView>& attachmentBindInfos,
2858 const deUint32 colorAtchCount,
2859 ImagesLayout& imagesLayout,
2860 const ImagesFormat& imagesFormat)
2862 const DeviceInterface& vk = m_context.getDeviceInterface();
2863 const VkDevice device = m_context.getDevice();
2864 const VkQueue queue = m_context.getUniversalQueue();
2866 for (deUint32 attachmentLoadOp = 0; attachmentLoadOp < TEST_ATTACHMENT_LOAD_OP_LAST; ++attachmentLoadOp)
2867 for (deUint32 attachmentStoreOp = 0; attachmentStoreOp < TEST_ATTACHMENT_STORE_OP_LAST; ++attachmentStoreOp)
2869 const VkBuffer vertexBuffer = m_vertexBuffer->object();
2870 const VkDeviceSize vertexBufferOffset = 0ull;
2873 beginSecondaryCmdBuffer(vk, *m_secCmdBuffer, VK_RENDERING_SUSPENDING_BIT_KHR, colorAtchCount, imagesFormat);
2875 vk.cmdBindPipeline(*m_secCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
2876 vk.cmdBindVertexBuffers(*m_secCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
2878 vk.cmdDraw(*m_secCmdBuffer, 4u, 1u, 8u, 0u);
2879 vk.cmdDraw(*m_secCmdBuffer, 4u, 1u, 0u, 0u);
2881 VK_CHECK(vk.endCommandBuffer(*m_secCmdBuffer));
2883 // Primary commandBuffer
2884 beginCommandBuffer(vk, *m_cmdBuffer);
2885 preBarier(colorAtchCount, imagesLayout, imagesFormat);
2887 beginRendering(*m_cmdBuffer,
2888 attachmentBindInfos,
2889 VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR |
2890 VK_RENDERING_SUSPENDING_BIT_KHR,
2893 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
2894 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
2896 vk.cmdExecuteCommands(*m_cmdBuffer, 1u, &(*m_secCmdBuffer));
2898 vk.cmdEndRendering(*m_cmdBuffer);
2900 beginRendering(*m_cmdBuffer,
2901 attachmentBindInfos,
2902 VK_RENDERING_RESUMING_BIT_KHR,
2905 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
2906 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
2908 vk.cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
2909 vk.cmdBindVertexBuffers(*m_cmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
2911 vk.cmdDraw(*m_cmdBuffer, 4u, 1u, 4u, 0u);
2913 vk.cmdEndRendering(*m_cmdBuffer);
2915 copyImgToBuff(*m_cmdBuffer, colorAtchCount, imagesLayout, imagesFormat);
2917 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
2919 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer);
2921 if ((static_cast<VkAttachmentLoadOp>(attachmentLoadOp) == VK_ATTACHMENT_LOAD_OP_CLEAR) &&
2922 (static_cast<VkAttachmentStoreOp>(attachmentStoreOp) == VK_ATTACHMENT_STORE_OP_STORE))
2924 verifyResults(colorAtchCount, imagesFormat);
2926 const ClearAttachmentData clearData(colorAtchCount, imagesFormat.depth, imagesFormat.stencil);
2929 beginSecondaryCmdBuffer(vk, *m_secCmdBuffer, VK_RENDERING_SUSPENDING_BIT_KHR, colorAtchCount, imagesFormat);
2931 if (clearData.colorDepthClear1.size() != 0)
2933 vk.cmdClearAttachments(*m_secCmdBuffer,
2934 static_cast<deUint32>(clearData.colorDepthClear1.size()),
2935 clearData.colorDepthClear1.data(),
2936 1, &clearData.rectColorDepth1);
2939 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
2940 vk.cmdClearAttachments(*m_secCmdBuffer, 1u, &clearData.stencilClear1, 1, &clearData.rectStencil1);
2942 VK_CHECK(vk.endCommandBuffer(*m_secCmdBuffer));
2944 // Primary commandBuffer
2945 beginCommandBuffer(vk, *m_cmdBuffer);
2946 preBarier(colorAtchCount, imagesLayout, imagesFormat);
2948 beginRendering(*m_cmdBuffer,
2949 attachmentBindInfos,
2950 VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR |
2951 VK_RENDERING_SUSPENDING_BIT_KHR,
2954 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
2955 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
2957 vk.cmdExecuteCommands(*m_cmdBuffer, 1u, &(*m_secCmdBuffer));
2959 vk.cmdEndRendering(*m_cmdBuffer);
2961 beginRendering(*m_cmdBuffer,
2962 attachmentBindInfos,
2963 VK_RENDERING_RESUMING_BIT_KHR,
2966 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
2967 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
2969 if (clearData.colorDepthClear2.size() != 0)
2971 vk.cmdClearAttachments(*m_cmdBuffer,
2972 static_cast<deUint32>(clearData.colorDepthClear2.size()),
2973 clearData.colorDepthClear2.data(),
2974 1, &clearData.rectColorDepth2);
2977 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
2978 vk.cmdClearAttachments(*m_cmdBuffer, 1u, &clearData.stencilClear2, 1, &clearData.rectStencil2);
2980 vk.cmdEndRendering(*m_cmdBuffer);
2982 copyImgToBuff(*m_cmdBuffer, colorAtchCount, imagesLayout, imagesFormat);
2984 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
2986 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer);
2988 verifyResults(colorAtchCount, imagesFormat);
2993 class ContentsTwoPrimarySecondaryCmdBufferResuming : public DynamicRenderingTestInstance
2996 ContentsTwoPrimarySecondaryCmdBufferResuming (Context& context,
2997 const TestParameters& parameters);
2999 void rendering (const VkPipeline pipeline,
3000 const std::vector<VkImageView>& attachmentBindInfos,
3001 const deUint32 colorAtchCount,
3002 ImagesLayout& imagesLayout,
3003 const ImagesFormat& imagesFormat) override;
3005 Move<VkCommandBuffer> m_cmdBuffer2;
3006 Move<VkCommandBuffer> m_secCmdBuffer;
3009 ContentsTwoPrimarySecondaryCmdBufferResuming::ContentsTwoPrimarySecondaryCmdBufferResuming (Context& context,
3010 const TestParameters& parameters)
3011 : DynamicRenderingTestInstance(context, parameters)
3013 const DeviceInterface& vk = m_context.getDeviceInterface();
3014 const VkDevice device = m_context.getDevice();
3016 m_cmdBuffer2 = allocateCommandBuffer(vk, device, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY);
3017 m_secCmdBuffer = allocateCommandBuffer(vk, device, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
3020 void ContentsTwoPrimarySecondaryCmdBufferResuming::rendering (const VkPipeline pipeline,
3021 const std::vector<VkImageView>& attachmentBindInfos,
3022 const deUint32 colorAtchCount,
3023 ImagesLayout& imagesLayout,
3024 const ImagesFormat& imagesFormat)
3026 const DeviceInterface& vk = m_context.getDeviceInterface();
3027 const VkDevice device = m_context.getDevice();
3028 const VkQueue queue = m_context.getUniversalQueue();
3030 for (deUint32 attachmentLoadOp = 0; attachmentLoadOp < TEST_ATTACHMENT_LOAD_OP_LAST; ++attachmentLoadOp)
3031 for (deUint32 attachmentStoreOp = 0; attachmentStoreOp < TEST_ATTACHMENT_STORE_OP_LAST; ++attachmentStoreOp)
3033 const VkBuffer vertexBuffer = m_vertexBuffer->object();
3034 const VkDeviceSize vertexBufferOffset = 0ull;
3037 beginSecondaryCmdBuffer(vk, *m_secCmdBuffer, VK_RENDERING_RESUMING_BIT_KHR, colorAtchCount, imagesFormat);
3039 vk.cmdBindPipeline(*m_secCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
3040 vk.cmdBindVertexBuffers(*m_secCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
3042 vk.cmdDraw(*m_secCmdBuffer, 4u, 1u, 4u, 0u);
3044 VK_CHECK(vk.endCommandBuffer(*m_secCmdBuffer));
3046 // Primary commandBuffer
3047 beginCommandBuffer(vk, *m_cmdBuffer);
3048 preBarier(colorAtchCount, imagesLayout, imagesFormat);
3050 beginRendering(*m_cmdBuffer,
3051 attachmentBindInfos,
3052 VK_RENDERING_SUSPENDING_BIT_KHR,
3055 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
3056 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
3058 vk.cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
3059 vk.cmdBindVertexBuffers(*m_cmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
3061 vk.cmdDraw(*m_cmdBuffer, 4u, 1u, 8u, 0u);
3062 vk.cmdDraw(*m_cmdBuffer, 4u, 1u, 0u, 0u);
3064 vk.cmdEndRendering(*m_cmdBuffer);
3065 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
3067 // Primary commandBuffer2
3068 beginCommandBuffer(vk, *m_cmdBuffer2);
3070 beginRendering(*m_cmdBuffer2,
3071 attachmentBindInfos,
3072 VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR |
3073 VK_RENDERING_RESUMING_BIT_KHR,
3076 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
3077 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
3079 vk.cmdExecuteCommands(*m_cmdBuffer2, 1u, &(*m_secCmdBuffer));
3081 vk.cmdEndRendering(*m_cmdBuffer2);
3083 copyImgToBuff(*m_cmdBuffer2, colorAtchCount, imagesLayout, imagesFormat);
3085 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer2));
3087 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer, *m_cmdBuffer2);
3089 if ((static_cast<VkAttachmentLoadOp>(attachmentLoadOp) == VK_ATTACHMENT_LOAD_OP_CLEAR) &&
3090 (static_cast<VkAttachmentStoreOp>(attachmentStoreOp) == VK_ATTACHMENT_STORE_OP_STORE))
3092 verifyResults(colorAtchCount, imagesFormat);
3094 const ClearAttachmentData clearData(colorAtchCount, imagesFormat.depth, imagesFormat.stencil);
3097 beginSecondaryCmdBuffer(vk, *m_secCmdBuffer, VK_RENDERING_RESUMING_BIT_KHR, colorAtchCount, imagesFormat);
3099 if (clearData.colorDepthClear1.size() != 0)
3101 vk.cmdClearAttachments(*m_secCmdBuffer,
3102 static_cast<deUint32>(clearData.colorDepthClear1.size()),
3103 clearData.colorDepthClear1.data(),
3104 1, &clearData.rectColorDepth1);
3107 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
3108 vk.cmdClearAttachments(*m_secCmdBuffer, 1u, &clearData.stencilClear1, 1, &clearData.rectStencil1);
3110 VK_CHECK(vk.endCommandBuffer(*m_secCmdBuffer));
3112 // Primary commandBuffer
3113 beginCommandBuffer(vk, *m_cmdBuffer);
3114 preBarier(colorAtchCount, imagesLayout, imagesFormat);
3116 beginRendering(*m_cmdBuffer,
3117 attachmentBindInfos,
3118 VK_RENDERING_SUSPENDING_BIT_KHR,
3121 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
3122 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
3124 if (clearData.colorDepthClear2.size() != 0)
3126 vk.cmdClearAttachments(*m_cmdBuffer,
3127 static_cast<deUint32>(clearData.colorDepthClear2.size()),
3128 clearData.colorDepthClear2.data(),
3129 1, &clearData.rectColorDepth2);
3132 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
3133 vk.cmdClearAttachments(*m_cmdBuffer, 1u, &clearData.stencilClear2, 1, &clearData.rectStencil2);
3135 vk.cmdEndRendering(*m_cmdBuffer);
3136 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
3138 // Primary commandBuffer2
3139 beginCommandBuffer(vk, *m_cmdBuffer2);
3141 beginRendering(*m_cmdBuffer2,
3142 attachmentBindInfos,
3143 VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR |
3144 VK_RENDERING_RESUMING_BIT_KHR,
3147 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
3148 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
3150 vk.cmdExecuteCommands(*m_cmdBuffer2, 1u, &(*m_secCmdBuffer));
3152 vk.cmdEndRendering(*m_cmdBuffer2);
3154 copyImgToBuff(*m_cmdBuffer2, colorAtchCount, imagesLayout, imagesFormat);
3156 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer2));
3158 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer, *m_cmdBuffer2);
3160 verifyResults(colorAtchCount, imagesFormat);
3165 class ContentsSecondaryTwoPrimaryCmdBufferResuming : public DynamicRenderingTestInstance
3168 ContentsSecondaryTwoPrimaryCmdBufferResuming (Context& context,
3169 const TestParameters& parameters);
3171 void rendering (const VkPipeline pipeline,
3172 const std::vector<VkImageView>& attachmentBindInfos,
3173 const deUint32 colorAtchCount,
3174 ImagesLayout& imagesLayout,
3175 const ImagesFormat& imagesFormat) override;
3177 Move<VkCommandBuffer> m_cmdBuffer2;
3178 Move<VkCommandBuffer> m_secCmdBuffer;
3181 ContentsSecondaryTwoPrimaryCmdBufferResuming::ContentsSecondaryTwoPrimaryCmdBufferResuming (Context& context,
3182 const TestParameters& parameters)
3183 : DynamicRenderingTestInstance(context, parameters)
3185 const DeviceInterface& vk = m_context.getDeviceInterface();
3186 const VkDevice device = m_context.getDevice();
3188 m_cmdBuffer2 = allocateCommandBuffer(vk, device, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY);
3189 m_secCmdBuffer = allocateCommandBuffer(vk, device, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
3192 void ContentsSecondaryTwoPrimaryCmdBufferResuming::rendering (const VkPipeline pipeline,
3193 const std::vector<VkImageView>& attachmentBindInfos,
3194 const deUint32 colorAtchCount,
3195 ImagesLayout& imagesLayout,
3196 const ImagesFormat& imagesFormat)
3198 const DeviceInterface& vk = m_context.getDeviceInterface();
3199 const VkDevice device = m_context.getDevice();
3200 const VkQueue queue = m_context.getUniversalQueue();
3202 for (deUint32 attachmentLoadOp = 0; attachmentLoadOp < TEST_ATTACHMENT_LOAD_OP_LAST; ++attachmentLoadOp)
3203 for (deUint32 attachmentStoreOp = 0; attachmentStoreOp < TEST_ATTACHMENT_STORE_OP_LAST; ++attachmentStoreOp)
3205 const VkBuffer vertexBuffer = m_vertexBuffer->object();
3206 const VkDeviceSize vertexBufferOffset = 0ull;
3209 beginSecondaryCmdBuffer(vk, *m_secCmdBuffer, VK_RENDERING_SUSPENDING_BIT_KHR, colorAtchCount, imagesFormat);
3211 vk.cmdBindPipeline(*m_secCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
3212 vk.cmdBindVertexBuffers(*m_secCmdBuffer, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
3214 vk.cmdDraw(*m_secCmdBuffer, 4u, 1u, 8u, 0u);
3215 vk.cmdDraw(*m_secCmdBuffer, 4u, 1u, 0u, 0u);
3217 VK_CHECK(vk.endCommandBuffer(*m_secCmdBuffer));
3219 // Primary commandBuffer
3220 beginCommandBuffer(vk, *m_cmdBuffer);
3221 preBarier(colorAtchCount, imagesLayout, imagesFormat);
3223 beginRendering(*m_cmdBuffer,
3224 attachmentBindInfos,
3225 VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR |
3226 VK_RENDERING_SUSPENDING_BIT_KHR,
3229 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
3230 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
3232 vk.cmdExecuteCommands(*m_cmdBuffer, 1u, &(*m_secCmdBuffer));
3234 vk.cmdEndRendering(*m_cmdBuffer);
3235 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
3237 // Primary commandBuffer2
3238 beginCommandBuffer(vk, *m_cmdBuffer2);
3240 beginRendering(*m_cmdBuffer2,
3241 attachmentBindInfos,
3242 VK_RENDERING_RESUMING_BIT_KHR,
3245 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
3246 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
3248 vk.cmdBindPipeline(*m_cmdBuffer2, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
3249 vk.cmdBindVertexBuffers(*m_cmdBuffer2, 0u, 1u, &vertexBuffer, &vertexBufferOffset);
3251 vk.cmdDraw(*m_cmdBuffer2, 4u, 1u, 4u, 0u);
3253 vk.cmdEndRendering(*m_cmdBuffer2);
3255 copyImgToBuff(*m_cmdBuffer2, colorAtchCount, imagesLayout, imagesFormat);
3257 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer2));
3259 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer, *m_cmdBuffer2);
3261 if ((static_cast<VkAttachmentLoadOp>(attachmentLoadOp) == VK_ATTACHMENT_LOAD_OP_CLEAR) &&
3262 (static_cast<VkAttachmentStoreOp>(attachmentStoreOp) == VK_ATTACHMENT_STORE_OP_STORE))
3264 verifyResults(colorAtchCount, imagesFormat);
3266 const ClearAttachmentData clearData(colorAtchCount, imagesFormat.depth, imagesFormat.stencil);
3269 beginSecondaryCmdBuffer(vk, *m_secCmdBuffer, VK_RENDERING_SUSPENDING_BIT_KHR, colorAtchCount, imagesFormat);
3271 if (clearData.colorDepthClear1.size() != 0)
3273 vk.cmdClearAttachments(*m_secCmdBuffer,
3274 static_cast<deUint32>(clearData.colorDepthClear1.size()),
3275 clearData.colorDepthClear1.data(),
3276 1, &clearData.rectColorDepth1);
3279 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
3280 vk.cmdClearAttachments(*m_secCmdBuffer, 1u, &clearData.stencilClear1, 1, &clearData.rectStencil1);
3282 VK_CHECK(vk.endCommandBuffer(*m_secCmdBuffer));
3284 // Primary commandBuffer
3285 beginCommandBuffer(vk, *m_cmdBuffer);
3286 preBarier(colorAtchCount, imagesLayout, imagesFormat);
3288 beginRendering(*m_cmdBuffer,
3289 attachmentBindInfos,
3290 VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR |
3291 VK_RENDERING_SUSPENDING_BIT_KHR,
3294 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
3295 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
3297 vk.cmdExecuteCommands(*m_cmdBuffer, 1u, &(*m_secCmdBuffer));
3299 vk.cmdEndRendering(*m_cmdBuffer);
3300 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
3302 // Primary commandBuffer2
3303 beginCommandBuffer(vk, *m_cmdBuffer2);
3305 beginRendering(*m_cmdBuffer2,
3306 attachmentBindInfos,
3307 VK_RENDERING_RESUMING_BIT_KHR,
3310 static_cast<VkAttachmentLoadOp>(attachmentLoadOp),
3311 static_cast<VkAttachmentStoreOp>(attachmentStoreOp));
3313 if (clearData.colorDepthClear2.size() != 0)
3315 vk.cmdClearAttachments(*m_cmdBuffer2,
3316 static_cast<deUint32>(clearData.colorDepthClear2.size()),
3317 clearData.colorDepthClear2.data(),
3318 1, &clearData.rectColorDepth2);
3321 if (imagesFormat.stencil != VK_FORMAT_UNDEFINED)
3322 vk.cmdClearAttachments(*m_cmdBuffer2, 1u, &clearData.stencilClear2, 1, &clearData.rectStencil2);
3324 vk.cmdEndRendering(*m_cmdBuffer2);
3326 copyImgToBuff(*m_cmdBuffer2, colorAtchCount, imagesLayout, imagesFormat);
3328 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer2));
3330 submitCommandsAndWait(vk, device, queue, *m_cmdBuffer, *m_cmdBuffer2);
3332 verifyResults(colorAtchCount, imagesFormat);
3337 class BaseTestCase : public TestCase
3340 BaseTestCase (tcu::TestContext& context,
3341 const std::string& name,
3342 const std::string& description,
3343 const TestParameters& parameters);
3344 virtual ~BaseTestCase (void);
3347 virtual void checkSupport (Context& context) const;
3348 virtual void initPrograms (SourceCollections& programCollection) const;
3349 virtual TestInstance* createInstance (Context& context) const;
3351 const TestParameters m_parameters;
3354 BaseTestCase::BaseTestCase (tcu::TestContext& context,
3355 const std::string& name,
3356 const std::string& description,
3357 const TestParameters& parameters)
3358 : TestCase (context, name, description)
3359 , m_parameters (parameters)
3363 BaseTestCase::~BaseTestCase ()
3367 void BaseTestCase::checkSupport (Context& context) const
3369 if(!context.requireDeviceFunctionality("VK_KHR_dynamic_rendering"))
3370 TCU_THROW(NotSupportedError, "VK_KHR_dynamic_rendering not supported");
3373 void BaseTestCase::initPrograms (SourceCollections& programCollection) const
3377 std::ostringstream src;
3378 src << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_440) << "\n"
3380 << "layout(location = 0) in highp vec4 position;\n"
3381 << "layout(location = 0) out highp vec4 vsColor;\n"
3383 << "out gl_PerVertex {\n"
3384 << " vec4 gl_Position;\n"
3387 << "void main (void)\n"
3389 << " gl_Position = position;\n"
3390 << " vsColor = vec4(gl_Position.z * 5.0f, 1.0f, 0.0f, 1.0f);\n"
3392 programCollection.glslSources.add("vert") << glu::VertexSource(src.str());
3395 // Fragment multi color attachment
3397 std::ostringstream src;
3398 src << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_440) << "\n"
3400 << "layout(location = 0) in highp vec4 vsColor;\n";
3402 for (deUint32 ndx = 0; ndx < COLOR_ATTACHMENTS_NUMBER; ++ndx)
3403 src << "layout(location = " << ndx << ") out highp vec4 fsColor" << ndx << ";\n";
3406 << "void main (void)\n"
3408 << " vec4 color = vsColor;\n";
3409 for (deUint32 ndx = 0; ndx < COLOR_ATTACHMENTS_NUMBER; ++ndx)
3411 src << " color.z = 0.15f * " << ndx << ".0f;\n"
3412 << " fsColor" << ndx << " = color;\n";
3415 programCollection.glslSources.add("frag") << glu::FragmentSource(src.str());
3419 TestInstance* BaseTestCase::createInstance (Context& context) const
3421 switch(m_parameters.testType)
3423 case TEST_TYPE_SINGLE_CMDBUF:
3425 return new DynamicRenderingTestInstance(context, m_parameters);
3427 case TEST_TYPE_SINGLE_CMDBUF_RESUMING:
3429 return new SingleCmdBufferResuming(context, m_parameters);
3431 case TEST_TYPE_TWO_CMDBUF_RESUMING:
3433 return new TwoPrimaryCmdBufferResuming(context, m_parameters);
3435 case TEST_TYPE_SECONDARY_CMDBUF_RESUMING:
3437 return new TwoSecondaryCmdBufferResuming(context, m_parameters);
3439 case TEST_TYPE_SECONDARY_CMDBUF_TWO_PRIMARY_RESUMING:
3441 return new TwoSecondaryTwoPrimaryCmdBufferResuming(context, m_parameters);
3443 case TEST_TYPE_CONTENTS_SECONDARY_COMMAND_BUFFER:
3445 return new ContentsSecondaryCmdBuffer(context, m_parameters);
3447 case TEST_TYPE_CONTENTS_2_SECONDARY_COMMAND_BUFFER:
3449 return new ContentsTwoSecondaryCmdBuffer(context, m_parameters);
3451 case TEST_TYPE_CONTENTS_2_SECONDARY_COMMAND_BUFFER_RESUMING:
3453 return new ContentsTwoSecondaryCmdBufferResuming(context, m_parameters);
3455 case TEST_TYPE_CONTENTS_2_SECONDARY_2_PRIMARY_COMDBUF_RESUMING:
3457 return new ContentsTwoSecondaryTwoPrimaryCmdBufferResuming(context, m_parameters);
3459 case TEST_TYPE_CONTENTS_PRIMARY_SECONDARY_COMDBUF_RESUMING:
3461 return new ContentsPrimarySecondaryCmdBufferResuming(context, m_parameters);
3463 case TEST_TYPE_CONTENTS_SECONDARY_PRIMARY_COMDBUF_RESUMING:
3465 return new ContentsSecondaryPrimaryCmdBufferResuming(context, m_parameters);
3467 case TEST_TYPE_CONTENTS_2_PRIMARY_SECONDARY_COMDBUF_RESUMING:
3469 return new ContentsTwoPrimarySecondaryCmdBufferResuming(context, m_parameters);
3471 case TEST_TYPE_CONTENTS_SECONDARY_2_PRIMARY_COMDBUF_RESUMING:
3473 return new ContentsSecondaryTwoPrimaryCmdBufferResuming(context, m_parameters);
3476 DE_FATAL("Impossible");
3481 tcu::TestNode* dynamicRenderingTests (tcu::TestContext& testCtx, const TestParameters& parameters)
3483 const std::string testName[TEST_TYPE_LAST] =
3486 "single_cmdbuffer_resuming",
3487 "2_cmdbuffers_resuming",
3488 "2_secondary_cmdbuffers_resuming",
3489 "2_secondary_2_primary_cmdbuffers_resuming",
3490 "contents_secondary_cmdbuffers",
3491 "contents_2_secondary_cmdbuffers",
3492 "contents_2_secondary_cmdbuffers_resuming",
3493 "contents_2_secondary_2_primary_cmdbuffers_resuming",
3494 "contents_primary_secondary_cmdbuffers_resuming",
3495 "contents_secondary_primary_cmdbuffers_resuming",
3496 "contents_2_primary_secondary_cmdbuffers_resuming",
3497 "contents_secondary_2_primary_cmdbuffers_resuming",
3500 return new BaseTestCase(testCtx, testName[parameters.testType], "Dynamic Rendering tests", parameters);
3505 tcu::TestCaseGroup* createDynamicRenderingBasicTests(tcu::TestContext& testCtx)
3507 de::MovePtr<tcu::TestCaseGroup> dynamicRenderingGroup (new tcu::TestCaseGroup(testCtx, "basic", "Basic dynamic rendering tests"));
3509 for (int testType = 0; testType < TEST_TYPE_LAST; ++testType)
3511 const TestParameters parameters =
3513 static_cast<TestType>(testType), // TestType testType;
3514 Vec4(0.0f, 0.0f, 0.0f, 1.0f), // const Vec4 clearColor;
3515 VK_FORMAT_R8G8B8A8_UNORM, // const VkFormat imageFormat;
3516 (UVec2(32, 32)) // const UVec2 renderSize;
3519 dynamicRenderingGroup->addChild(dynamicRenderingTests(testCtx, parameters));
3522 return dynamicRenderingGroup.release();