1 /*-------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2015 Google 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 RenderPass tests
22 *//*--------------------------------------------------------------------*/
24 #include "vktRenderPassTests.hpp"
25 #include "vktRenderPassTestsUtil.hpp"
26 #include "vktRenderPassGroupParams.hpp"
27 #include "vktRenderPassMultisampleTests.hpp"
28 #include "vktRenderPassMultisampleResolveTests.hpp"
29 #include "vktRenderPassSampleReadTests.hpp"
30 #ifndef CTS_USES_VULKANSC
31 #include "vktRenderPassSparseRenderTargetTests.hpp"
32 #endif // CTS_USES_VULKANSC
33 #include "vktRenderPassSubpassDependencyTests.hpp"
34 #include "vktRenderPassUnusedAttachmentTests.hpp"
35 #include "vktRenderPassUnusedClearAttachmentTests.hpp"
36 #include "vktRenderPassDepthStencilResolveTests.hpp"
37 #include "vktRenderPassUnusedAttachmentSparseFillingTests.hpp"
38 #include "vktRenderPassFragmentDensityMapTests.hpp"
39 #include "vktRenderPassMultipleSubpassesMultipleCommandBuffersTests.hpp"
40 #ifndef CTS_USES_VULKANSC
41 #include "vktRenderPassLoadStoreOpNoneTests.hpp"
42 #include "vktDynamicRenderingTests.hpp"
43 #endif // CTS_USES_VULKANSC
44 #include "vktRenderPassDepthStencilWriteConditionsTests.hpp"
45 #include "vktRenderPassSubpassMergeFeedbackTests.hpp"
46 #include "vktDynamicRenderingRandomTests.hpp"
47 #include "vktRenderPassDitheringTests.hpp"
49 #include "vktTestCaseUtil.hpp"
50 #include "vktTestGroupUtil.hpp"
53 #include "vkDeviceUtil.hpp"
54 #include "vkImageUtil.hpp"
55 #include "vkMemUtil.hpp"
56 #include "vkPlatform.hpp"
57 #include "vkPrograms.hpp"
58 #include "vkQueryUtil.hpp"
60 #include "vkRefUtil.hpp"
61 #include "vkStrUtil.hpp"
62 #include "vkTypeUtil.hpp"
63 #include "vkCmdUtil.hpp"
64 #include "vkObjUtil.hpp"
65 #include "vkBufferWithMemory.hpp"
66 #include "vkImageWithMemory.hpp"
67 #include "vkBarrierUtil.hpp"
69 #include "tcuFloat.hpp"
70 #include "tcuFormatUtil.hpp"
71 #include "tcuMaybe.hpp"
72 #include "tcuResultCollector.hpp"
73 #include "tcuTestLog.hpp"
74 #include "tcuTextureUtil.hpp"
75 #include "tcuVectorUtil.hpp"
77 #include "deRandom.hpp"
78 #include "deSTLUtil.hpp"
79 #include "deSharedPtr.hpp"
80 #include "deStringUtil.hpp"
81 #include "deUniquePtr.hpp"
102 using tcu::ConstPixelBufferAccess;
103 using tcu::PixelBufferAccess;
118 using namespace renderpass;
120 typedef vector<deUint8> DepthValuesArray;
122 static const deUint8 DEPTH_VALUES[] = { 0u, 255u, 1u };
126 ALLOCATION_KIND_SUBALLOCATED,
127 ALLOCATION_KIND_DEDICATED,
130 struct TestConfigExternal
132 TestConfigExternal (AllocationKind allocationKind_,
133 const SharedGroupParams groupParams_)
134 : allocationKind (allocationKind_)
135 , groupParams (groupParams_)
139 AllocationKind allocationKind;
140 const SharedGroupParams groupParams;
143 de::MovePtr<Allocation> allocateBuffer (const InstanceInterface& vki,
144 const DeviceInterface& vkd,
145 const VkPhysicalDevice& physDevice,
146 const VkDevice device,
147 const VkBuffer& buffer,
148 const MemoryRequirement requirement,
149 Allocator& allocator,
150 AllocationKind allocationKind)
152 switch (allocationKind)
154 case ALLOCATION_KIND_SUBALLOCATED:
156 const VkMemoryRequirements memoryRequirements = getBufferMemoryRequirements(vkd, device, buffer);
158 return allocator.allocate(memoryRequirements, requirement);
161 case ALLOCATION_KIND_DEDICATED:
163 return allocateDedicated(vki, vkd, physDevice, device, buffer, requirement);
168 TCU_THROW(InternalError, "Invalid allocation kind");
173 de::MovePtr<Allocation> allocateImage (const InstanceInterface& vki,
174 const DeviceInterface& vkd,
175 const VkPhysicalDevice& physDevice,
176 const VkDevice device,
177 const VkImage& image,
178 const MemoryRequirement requirement,
179 Allocator& allocator,
180 AllocationKind allocationKind)
182 switch (allocationKind)
184 case ALLOCATION_KIND_SUBALLOCATED:
186 const VkMemoryRequirements memoryRequirements = getImageMemoryRequirements(vkd, device, image);
188 return allocator.allocate(memoryRequirements, requirement);
191 case ALLOCATION_KIND_DEDICATED:
193 return allocateDedicated(vki, vkd, physDevice, device, image, requirement);
198 TCU_THROW(InternalError, "Invalid allocation kind");
211 const char* boolOpToString (BoolOp op)
228 DE_FATAL("Unknown boolean operation.");
233 bool performBoolOp (BoolOp op, bool a, bool b)
250 DE_FATAL("Unknown boolean operation.");
255 BoolOp boolOpFromIndex (size_t index)
265 return ops[index % DE_LENGTH_OF_ARRAY(ops)];
268 static float requiredDepthEpsilon(VkFormat format)
270 // Possible precision loss in the unorm depth pipeline means that we need to check depths
271 // that go in and back out of the depth buffer with an epsilon rather than an exact match
272 deUint32 unormBits = 0;
276 case VK_FORMAT_D16_UNORM:
279 case VK_FORMAT_X8_D24_UNORM_PACK32:
280 case VK_FORMAT_D24_UNORM_S8_UINT:
283 case VK_FORMAT_D32_SFLOAT:
284 case VK_FORMAT_D32_SFLOAT_S8_UINT:
291 return 1.0f / (float)((1 << unormBits) - 1);
293 return 0.0f; // Require exact match
296 static bool depthsEqual(float a, float b, float epsilon)
298 return fabs(a - b) <= epsilon;
301 Move<VkFramebuffer> createFramebuffer (const DeviceInterface& vk,
303 VkFramebufferCreateFlags pCreateInfo_flags,
304 VkRenderPass pCreateInfo_renderPass,
305 deUint32 pCreateInfo_attachmentCount,
306 const VkImageView* pCreateInfo_pAttachments,
307 deUint32 pCreateInfo_width,
308 deUint32 pCreateInfo_height,
309 deUint32 pCreateInfo_layers)
311 const VkFramebufferCreateInfo pCreateInfo =
313 VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
316 pCreateInfo_renderPass,
317 pCreateInfo_attachmentCount,
318 pCreateInfo_pAttachments,
323 return createFramebuffer(vk, device, &pCreateInfo);
326 Move<VkImage> createImage (const DeviceInterface& vk,
328 VkImageCreateFlags pCreateInfo_flags,
329 VkImageType pCreateInfo_imageType,
330 VkFormat pCreateInfo_format,
331 VkExtent3D pCreateInfo_extent,
332 deUint32 pCreateInfo_mipLevels,
333 deUint32 pCreateInfo_arrayLayers,
334 VkSampleCountFlagBits pCreateInfo_samples,
335 VkImageTiling pCreateInfo_tiling,
336 VkImageUsageFlags pCreateInfo_usage,
337 VkSharingMode pCreateInfo_sharingMode,
338 deUint32 pCreateInfo_queueFamilyCount,
339 const deUint32* pCreateInfo_pQueueFamilyIndices,
340 VkImageLayout pCreateInfo_initialLayout)
342 const VkImageCreateInfo pCreateInfo =
344 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
347 pCreateInfo_imageType,
350 pCreateInfo_mipLevels,
351 pCreateInfo_arrayLayers,
355 pCreateInfo_sharingMode,
356 pCreateInfo_queueFamilyCount,
357 pCreateInfo_pQueueFamilyIndices,
358 pCreateInfo_initialLayout
360 return createImage(vk, device, &pCreateInfo);
363 void bindBufferMemory (const DeviceInterface& vk, VkDevice device, VkBuffer buffer, VkDeviceMemory mem, VkDeviceSize memOffset)
365 VK_CHECK(vk.bindBufferMemory(device, buffer, mem, memOffset));
368 void bindImageMemory (const DeviceInterface& vk, VkDevice device, VkImage image, VkDeviceMemory mem, VkDeviceSize memOffset)
370 VK_CHECK(vk.bindImageMemory(device, image, mem, memOffset));
373 Move<VkImageView> createImageView (const DeviceInterface& vk,
375 VkImageViewCreateFlags pCreateInfo_flags,
376 VkImage pCreateInfo_image,
377 VkImageViewType pCreateInfo_viewType,
378 VkFormat pCreateInfo_format,
379 VkComponentMapping pCreateInfo_components,
380 VkImageSubresourceRange pCreateInfo_subresourceRange)
382 const VkImageViewCreateInfo pCreateInfo =
384 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
388 pCreateInfo_viewType,
390 pCreateInfo_components,
391 pCreateInfo_subresourceRange,
393 return createImageView(vk, device, &pCreateInfo);
396 Move<VkBuffer> createBuffer (const DeviceInterface& vk,
398 VkBufferCreateFlags pCreateInfo_flags,
399 VkDeviceSize pCreateInfo_size,
400 VkBufferUsageFlags pCreateInfo_usage,
401 VkSharingMode pCreateInfo_sharingMode,
402 deUint32 pCreateInfo_queueFamilyCount,
403 const deUint32* pCreateInfo_pQueueFamilyIndices)
405 const VkBufferCreateInfo pCreateInfo =
407 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
412 pCreateInfo_sharingMode,
413 pCreateInfo_queueFamilyCount,
414 pCreateInfo_pQueueFamilyIndices,
416 return createBuffer(vk, device, &pCreateInfo);
419 VkRenderPassBeginInfo createRenderPassBeginInfo (VkRenderPass pRenderPassBegin_renderPass,
420 VkFramebuffer pRenderPassBegin_framebuffer,
421 VkRect2D pRenderPassBegin_renderArea,
422 deUint32 pRenderPassBegin_clearValueCount,
423 const VkClearValue* pRenderPassBegin_pAttachmentClearValues)
425 const VkRenderPassBeginInfo renderPassBeginInfo =
427 VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
429 pRenderPassBegin_renderPass,
430 pRenderPassBegin_framebuffer,
431 pRenderPassBegin_renderArea,
432 pRenderPassBegin_clearValueCount,
433 pRenderPassBegin_pAttachmentClearValues,
436 return renderPassBeginInfo;
439 void queueSubmit (const DeviceInterface& vk, VkQueue queue, deUint32 cmdBufferCount, const VkCommandBuffer* pCmdBuffers, VkFence fence)
441 const VkSubmitInfo submitInfo =
443 VK_STRUCTURE_TYPE_SUBMIT_INFO,
445 0u, // waitSemaphoreCount
446 (const VkSemaphore*)DE_NULL, // pWaitSemaphores
447 (const VkPipelineStageFlags*)DE_NULL,
448 cmdBufferCount, // commandBufferCount
450 0u, // signalSemaphoreCount
451 (const VkSemaphore*)DE_NULL, // pSignalSemaphores
453 VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo, fence));
456 void waitForFences (const DeviceInterface& vk, VkDevice device, deUint32 fenceCount, const VkFence* pFences, VkBool32 waitAll, deUint64 timeout)
458 VK_CHECK(vk.waitForFences(device, fenceCount, pFences, waitAll, timeout));
461 VkImageAspectFlags getImageAspectFlags (VkFormat vkFormat)
463 const tcu::TextureFormat format = mapVkFormat(vkFormat);
465 DE_STATIC_ASSERT(tcu::TextureFormat::CHANNELORDER_LAST == 22);
467 switch (format.order)
469 case tcu::TextureFormat::DS:
470 return VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_DEPTH_BIT;
472 case tcu::TextureFormat::D:
473 return VK_IMAGE_ASPECT_DEPTH_BIT;
475 case tcu::TextureFormat::S:
476 return VK_IMAGE_ASPECT_STENCIL_BIT;
479 return VK_IMAGE_ASPECT_COLOR_BIT;
483 VkAccessFlags getAllMemoryReadFlags (void)
485 return VK_ACCESS_TRANSFER_READ_BIT
486 | VK_ACCESS_UNIFORM_READ_BIT
487 | VK_ACCESS_HOST_READ_BIT
488 | VK_ACCESS_INDEX_READ_BIT
489 | VK_ACCESS_SHADER_READ_BIT
490 | VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT
491 | VK_ACCESS_INDIRECT_COMMAND_READ_BIT
492 | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT
493 | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT
494 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT;
497 VkAccessFlags getAllMemoryWriteFlags (void)
499 return VK_ACCESS_TRANSFER_WRITE_BIT
500 | VK_ACCESS_HOST_WRITE_BIT
501 | VK_ACCESS_SHADER_WRITE_BIT
502 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT
503 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
506 VkAccessFlags getMemoryFlagsForLayout (const VkImageLayout layout)
510 case VK_IMAGE_LAYOUT_GENERAL: return getAllMemoryReadFlags() | getAllMemoryWriteFlags();
511 case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: return VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
512 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: return VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
513 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: return VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT;
514 case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL: return VK_ACCESS_SHADER_READ_BIT;
515 case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL: return VK_ACCESS_TRANSFER_READ_BIT;
516 case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL: return VK_ACCESS_TRANSFER_WRITE_BIT;
517 case VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL: return VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | VK_ACCESS_SHADER_READ_BIT;
518 case VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL: return VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | VK_ACCESS_SHADER_READ_BIT;
520 return (VkAccessFlags)0;
524 VkPipelineStageFlags getAllPipelineStageFlags (void)
526 /* All relevant flags for a pipeline containing VS+PS. */
527 return VK_PIPELINE_STAGE_TRANSFER_BIT
528 | VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT
529 | VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT
530 | VK_PIPELINE_STAGE_VERTEX_INPUT_BIT
531 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT
532 | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
533 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
534 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT
535 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
536 | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT
537 | VK_PIPELINE_STAGE_HOST_BIT;
540 class AttachmentReference
543 AttachmentReference (deUint32 attachment,
544 VkImageLayout layout,
545 VkImageAspectFlags aspectMask = static_cast<VkImageAspectFlags>(0u))
546 : m_attachment (attachment)
548 , m_aspectMask (aspectMask)
552 deUint32 getAttachment (void) const { return m_attachment; }
553 VkImageLayout getImageLayout (void) const { return m_layout; }
554 VkImageAspectFlags getAspectMask (void) const { return m_aspectMask; }
555 void setImageLayout (VkImageLayout layout) { m_layout = layout; }
558 deUint32 m_attachment;
559 VkImageLayout m_layout;
560 VkImageAspectFlags m_aspectMask;
566 Subpass (VkPipelineBindPoint pipelineBindPoint,
567 VkSubpassDescriptionFlags flags,
568 const vector<AttachmentReference>& inputAttachments,
569 const vector<AttachmentReference>& colorAttachments,
570 const vector<AttachmentReference>& resolveAttachments,
571 AttachmentReference depthStencilAttachment,
572 const vector<deUint32>& preserveAttachments,
573 bool omitBlendState = false)
574 : m_pipelineBindPoint (pipelineBindPoint)
576 , m_inputAttachments (inputAttachments)
577 , m_colorAttachments (colorAttachments)
578 , m_resolveAttachments (resolveAttachments)
579 , m_depthStencilAttachment (depthStencilAttachment)
580 , m_preserveAttachments (preserveAttachments)
581 , m_omitBlendState (omitBlendState)
585 VkPipelineBindPoint getPipelineBindPoint (void) const { return m_pipelineBindPoint; }
586 VkSubpassDescriptionFlags getFlags (void) const { return m_flags; }
587 const vector<AttachmentReference>& getInputAttachments (void) const { return m_inputAttachments; }
588 const vector<AttachmentReference>& getColorAttachments (void) const { return m_colorAttachments; }
589 const vector<AttachmentReference>& getResolveAttachments (void) const { return m_resolveAttachments; }
590 const AttachmentReference& getDepthStencilAttachment (void) const { return m_depthStencilAttachment; }
591 const vector<deUint32>& getPreserveAttachments (void) const { return m_preserveAttachments; }
592 bool getOmitBlendState (void) const { return m_omitBlendState; }
595 VkPipelineBindPoint m_pipelineBindPoint;
596 VkSubpassDescriptionFlags m_flags;
598 vector<AttachmentReference> m_inputAttachments;
599 vector<AttachmentReference> m_colorAttachments;
600 vector<AttachmentReference> m_resolveAttachments;
601 AttachmentReference m_depthStencilAttachment;
603 vector<deUint32> m_preserveAttachments;
604 bool m_omitBlendState;
607 class SubpassDependency
610 SubpassDependency (deUint32 srcPass,
613 VkPipelineStageFlags srcStageMask,
614 VkPipelineStageFlags dstStageMask,
616 VkAccessFlags srcAccessMask,
617 VkAccessFlags dstAccessMask,
619 VkDependencyFlags flags)
620 : m_srcPass (srcPass)
621 , m_dstPass (dstPass)
623 , m_srcStageMask (srcStageMask)
624 , m_dstStageMask (dstStageMask)
626 , m_srcAccessMask (srcAccessMask)
627 , m_dstAccessMask (dstAccessMask)
632 deUint32 getSrcPass (void) const { return m_srcPass; }
633 deUint32 getDstPass (void) const { return m_dstPass; }
635 VkPipelineStageFlags getSrcStageMask (void) const { return m_srcStageMask; }
636 VkPipelineStageFlags getDstStageMask (void) const { return m_dstStageMask; }
638 VkAccessFlags getSrcAccessMask (void) const { return m_srcAccessMask; }
639 VkAccessFlags getDstAccessMask (void) const { return m_dstAccessMask; }
641 VkDependencyFlags getFlags (void) const { return m_flags; }
643 void setSrcAccessMask (const VkAccessFlags& flags) { m_srcAccessMask = flags; }
644 void setDstAccessMask (const VkAccessFlags& flags) { m_dstAccessMask = flags; }
650 VkPipelineStageFlags m_srcStageMask;
651 VkPipelineStageFlags m_dstStageMask;
653 VkAccessFlags m_srcAccessMask;
654 VkAccessFlags m_dstAccessMask;
655 VkDependencyFlags m_flags;
661 Attachment (VkFormat format,
662 VkSampleCountFlagBits samples,
664 VkAttachmentLoadOp loadOp,
665 VkAttachmentStoreOp storeOp,
667 VkAttachmentLoadOp stencilLoadOp,
668 VkAttachmentStoreOp stencilStoreOp,
670 VkImageLayout initialLayout,
671 VkImageLayout finalLayout)
673 , m_samples (samples)
676 , m_storeOp (storeOp)
678 , m_stencilLoadOp (stencilLoadOp)
679 , m_stencilStoreOp (stencilStoreOp)
681 , m_initialLayout (initialLayout)
682 , m_finalLayout (finalLayout)
686 VkFormat getFormat (void) const { return m_format; }
687 VkSampleCountFlagBits getSamples (void) const { return m_samples; }
689 VkAttachmentLoadOp getLoadOp (void) const { return m_loadOp; }
690 VkAttachmentStoreOp getStoreOp (void) const { return m_storeOp; }
693 VkAttachmentLoadOp getStencilLoadOp (void) const { return m_stencilLoadOp; }
694 VkAttachmentStoreOp getStencilStoreOp (void) const { return m_stencilStoreOp; }
696 VkImageLayout getInitialLayout (void) const { return m_initialLayout; }
697 VkImageLayout getFinalLayout (void) const { return m_finalLayout; }
701 VkSampleCountFlagBits m_samples;
703 VkAttachmentLoadOp m_loadOp;
704 VkAttachmentStoreOp m_storeOp;
706 VkAttachmentLoadOp m_stencilLoadOp;
707 VkAttachmentStoreOp m_stencilStoreOp;
709 VkImageLayout m_initialLayout;
710 VkImageLayout m_finalLayout;
716 RenderPass (const vector<Attachment>& attachments,
717 const vector<Subpass>& subpasses,
718 const vector<SubpassDependency>& dependencies,
719 const vector<VkInputAttachmentAspectReference> inputAspects = vector<VkInputAttachmentAspectReference>())
720 : m_attachments (attachments)
721 , m_subpasses (subpasses)
722 , m_dependencies (dependencies)
723 , m_inputAspects (inputAspects)
727 const vector<Attachment>& getAttachments (void) const { return m_attachments; }
728 const vector<Subpass>& getSubpasses (void) const { return m_subpasses; }
729 const vector<SubpassDependency>& getDependencies (void) const { return m_dependencies; }
730 const vector<VkInputAttachmentAspectReference>& getInputAspects (void) const { return m_inputAspects; }
733 const vector<Attachment> m_attachments;
734 const vector<Subpass> m_subpasses;
735 const vector<SubpassDependency> m_dependencies;
736 const vector<VkInputAttachmentAspectReference> m_inputAspects;
743 RENDERTYPES_NONE = 0,
744 RENDERTYPES_CLEAR = (1<<1),
745 RENDERTYPES_DRAW = (1<<2)
748 enum CommandBufferTypes
750 COMMANDBUFFERTYPES_INLINE = (1<<0),
751 COMMANDBUFFERTYPES_SECONDARY = (1<<1)
756 IMAGEMEMORY_STRICT = (1<<0),
757 IMAGEMEMORY_LAZY = (1<<1)
760 TestConfig (const RenderPass& renderPass_,
761 RenderTypes renderTypes_,
762 CommandBufferTypes commandBufferTypes_,
763 ImageMemory imageMemory_,
764 const UVec2& targetSize_,
765 const UVec2& renderPos_,
766 const UVec2& renderSize_,
767 deBool useFormatCompCount_,
769 deUint32 drawStartNdx_,
770 AllocationKind allocationKind_,
771 SharedGroupParams groupParams_,
772 vector<DeviceCoreFeature> requiredFeatures_ = vector<DeviceCoreFeature>())
773 : renderPass (renderPass_)
774 , renderTypes (renderTypes_)
775 , commandBufferTypes (commandBufferTypes_)
776 , imageMemory (imageMemory_)
777 , targetSize (targetSize_)
778 , renderPos (renderPos_)
779 , renderSize (renderSize_)
780 , useFormatCompCount (useFormatCompCount_)
782 , drawStartNdx (drawStartNdx_)
783 , allocationKind (allocationKind_)
784 , groupParams (groupParams_)
785 , requiredFeatures (requiredFeatures_)
787 DepthValuesArray shuffledDepthValues (&DEPTH_VALUES[0], &DEPTH_VALUES[DE_LENGTH_OF_ARRAY(DEPTH_VALUES)]);
788 de::Random rng (seed + 1);
790 rng.shuffle(shuffledDepthValues.begin(), shuffledDepthValues.end());
792 depthValues.push_back(shuffledDepthValues[0]);
793 depthValues.push_back(shuffledDepthValues[1]);
796 RenderPass renderPass;
797 RenderTypes renderTypes;
798 CommandBufferTypes commandBufferTypes;
799 ImageMemory imageMemory;
803 deBool useFormatCompCount;
805 deUint32 drawStartNdx;
806 AllocationKind allocationKind;
807 SharedGroupParams groupParams;
808 vector<DeviceCoreFeature> requiredFeatures;
809 DepthValuesArray depthValues;
812 TestConfig::RenderTypes operator| (TestConfig::RenderTypes a, TestConfig::RenderTypes b)
814 return (TestConfig::RenderTypes)(((deUint32)a) | ((deUint32)b));
817 TestConfig::CommandBufferTypes operator| (TestConfig::CommandBufferTypes a, TestConfig::CommandBufferTypes b)
819 return (TestConfig::CommandBufferTypes)(((deUint32)a) | ((deUint32)b));
822 TestConfig::ImageMemory operator| (TestConfig::ImageMemory a, TestConfig::ImageMemory b)
824 return (TestConfig::ImageMemory)(((deUint32)a) | ((deUint32)b));
827 void checkSupport (Context& context, TestConfig config)
829 for (size_t featureNdx = 0; featureNdx < config.requiredFeatures.size(); featureNdx++)
830 context.requireDeviceCoreFeature(config.requiredFeatures[featureNdx]);
833 void logRenderPassInfo (TestLog& log,
834 const RenderPass& renderPass)
836 const bool useExternalInputAspect = !renderPass.getInputAspects().empty();
837 const tcu::ScopedLogSection section (log, "RenderPass", "RenderPass");
840 const tcu::ScopedLogSection attachmentsSection (log, "Attachments", "Attachments");
841 const vector<Attachment>& attachments = renderPass.getAttachments();
843 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
845 const tcu::ScopedLogSection attachmentSection (log, "Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx));
846 const Attachment& attachment = attachments[attachmentNdx];
848 log << TestLog::Message << "Format: " << attachment.getFormat() << TestLog::EndMessage;
849 log << TestLog::Message << "Samples: " << attachment.getSamples() << TestLog::EndMessage;
851 log << TestLog::Message << "LoadOp: " << attachment.getLoadOp() << TestLog::EndMessage;
852 log << TestLog::Message << "StoreOp: " << attachment.getStoreOp() << TestLog::EndMessage;
854 log << TestLog::Message << "StencilLoadOp: " << attachment.getStencilLoadOp() << TestLog::EndMessage;
855 log << TestLog::Message << "StencilStoreOp: " << attachment.getStencilStoreOp() << TestLog::EndMessage;
857 log << TestLog::Message << "InitialLayout: " << attachment.getInitialLayout() << TestLog::EndMessage;
858 log << TestLog::Message << "FinalLayout: " << attachment.getFinalLayout() << TestLog::EndMessage;
862 if (useExternalInputAspect)
864 const tcu::ScopedLogSection inputAspectSection (log, "InputAspects", "InputAspects");
866 for (size_t aspectNdx = 0; aspectNdx < renderPass.getInputAspects().size(); aspectNdx++)
868 const VkInputAttachmentAspectReference& inputAspect (renderPass.getInputAspects()[aspectNdx]);
870 log << TestLog::Message << "Subpass: " << inputAspect.subpass << TestLog::EndMessage;
871 log << TestLog::Message << "InputAttachmentIndex: " << inputAspect.inputAttachmentIndex << TestLog::EndMessage;
872 log << TestLog::Message << "AspectFlags: " << getImageAspectFlagsStr(inputAspect.aspectMask) << TestLog::EndMessage;
877 const tcu::ScopedLogSection subpassesSection (log, "Subpasses", "Subpasses");
878 const vector<Subpass>& subpasses = renderPass.getSubpasses();
880 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
882 const tcu::ScopedLogSection subpassSection (log, "Subpass" + de::toString(subpassNdx), "Subpass " + de::toString(subpassNdx));
883 const Subpass& subpass = subpasses[subpassNdx];
885 const vector<AttachmentReference>& inputAttachments = subpass.getInputAttachments();
886 const vector<AttachmentReference>& colorAttachments = subpass.getColorAttachments();
887 const vector<AttachmentReference>& resolveAttachments = subpass.getResolveAttachments();
888 const vector<deUint32>& preserveAttachments = subpass.getPreserveAttachments();
890 if (!inputAttachments.empty())
892 const tcu::ScopedLogSection inputAttachmentsSection (log, "Inputs", "Inputs");
894 for (size_t inputNdx = 0; inputNdx < inputAttachments.size(); inputNdx++)
896 const tcu::ScopedLogSection inputAttachmentSection (log, "Input" + de::toString(inputNdx), "Input " + de::toString(inputNdx));
897 const AttachmentReference& inputAttachment = inputAttachments[inputNdx];
899 log << TestLog::Message << "Attachment: " << inputAttachment.getAttachment() << TestLog::EndMessage;
900 log << TestLog::Message << "Layout: " << inputAttachment.getImageLayout() << TestLog::EndMessage;
901 if (!useExternalInputAspect)
902 log << TestLog::Message << "AspectMask: " << inputAttachment.getAspectMask() << TestLog::EndMessage;
906 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
908 const tcu::ScopedLogSection depthStencilAttachmentSection (log, "DepthStencil", "DepthStencil");
909 const AttachmentReference& depthStencilAttachment = subpass.getDepthStencilAttachment();
911 log << TestLog::Message << "Attachment: " << depthStencilAttachment.getAttachment() << TestLog::EndMessage;
912 log << TestLog::Message << "Layout: " << depthStencilAttachment.getImageLayout() << TestLog::EndMessage;
915 if (!colorAttachments.empty())
917 const tcu::ScopedLogSection colorAttachmentsSection (log, "Colors", "Colors");
919 for (size_t colorNdx = 0; colorNdx < colorAttachments.size(); colorNdx++)
921 const tcu::ScopedLogSection colorAttachmentSection (log, "Color" + de::toString(colorNdx), "Color " + de::toString(colorNdx));
922 const AttachmentReference& colorAttachment = colorAttachments[colorNdx];
924 log << TestLog::Message << "Attachment: " << colorAttachment.getAttachment() << TestLog::EndMessage;
925 log << TestLog::Message << "Layout: " << colorAttachment.getImageLayout() << TestLog::EndMessage;
929 if (!resolveAttachments.empty())
931 const tcu::ScopedLogSection resolveAttachmentsSection (log, "Resolves", "Resolves");
933 for (size_t resolveNdx = 0; resolveNdx < resolveAttachments.size(); resolveNdx++)
935 const tcu::ScopedLogSection resolveAttachmentSection (log, "Resolve" + de::toString(resolveNdx), "Resolve " + de::toString(resolveNdx));
936 const AttachmentReference& resolveAttachment = resolveAttachments[resolveNdx];
938 log << TestLog::Message << "Attachment: " << resolveAttachment.getAttachment() << TestLog::EndMessage;
939 log << TestLog::Message << "Layout: " << resolveAttachment.getImageLayout() << TestLog::EndMessage;
943 if (!preserveAttachments.empty())
945 const tcu::ScopedLogSection preserveAttachmentsSection (log, "Preserves", "Preserves");
947 for (size_t preserveNdx = 0; preserveNdx < preserveAttachments.size(); preserveNdx++)
949 const tcu::ScopedLogSection preserveAttachmentSection (log, "Preserve" + de::toString(preserveNdx), "Preserve " + de::toString(preserveNdx));
950 const deUint32 preserveAttachment = preserveAttachments[preserveNdx];
952 log << TestLog::Message << "Attachment: " << preserveAttachment << TestLog::EndMessage;
959 if (!renderPass.getDependencies().empty())
961 const tcu::ScopedLogSection dependenciesSection (log, "Dependencies", "Dependencies");
963 for (size_t depNdx = 0; depNdx < renderPass.getDependencies().size(); depNdx++)
965 const tcu::ScopedLogSection dependencySection (log, "Dependency" + de::toString(depNdx), "Dependency " + de::toString(depNdx));
966 const SubpassDependency& dep = renderPass.getDependencies()[depNdx];
968 log << TestLog::Message << "Source: " << dep.getSrcPass() << TestLog::EndMessage;
969 log << TestLog::Message << "Destination: " << dep.getDstPass() << TestLog::EndMessage;
971 log << TestLog::Message << "Source Stage Mask: " << dep.getSrcStageMask() << TestLog::EndMessage;
972 log << TestLog::Message << "Destination Stage Mask: " << dep.getDstStageMask() << TestLog::EndMessage;
974 log << TestLog::Message << "Input Mask: " << dep.getDstAccessMask() << TestLog::EndMessage;
975 log << TestLog::Message << "Output Mask: " << dep.getSrcAccessMask() << TestLog::EndMessage;
976 log << TestLog::Message << "Dependency Flags: " << getDependencyFlagsStr(dep.getFlags()) << TestLog::EndMessage;
981 std::string clearColorToString (VkFormat vkFormat, VkClearColorValue value, deBool useFormatCompCount)
983 const tcu::TextureFormat format = mapVkFormat(vkFormat);
984 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
985 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
986 const deUint32 componentCount = (useFormatCompCount ? (deUint32)tcu::getNumUsedChannels(format.order) : 4);
988 std::ostringstream stream;
992 switch (channelClass)
994 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
995 for (deUint32 i = 0; i < componentCount; i++)
1001 stream << value.int32[i];
1007 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
1008 for (deUint32 i = 0; i < componentCount; i++)
1014 stream << value.uint32[i];
1020 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
1021 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
1022 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
1023 for (deUint32 i = 0; i < componentCount; i++)
1029 stream << value.float32[i];
1036 DE_FATAL("Unknown channel class");
1041 return stream.str();
1044 std::string clearValueToString (VkFormat vkFormat, VkClearValue value, deBool useFormatCompCount)
1046 const tcu::TextureFormat format = mapVkFormat(vkFormat);
1048 if (tcu::hasStencilComponent(format.order) || tcu::hasDepthComponent(format.order))
1050 std::ostringstream stream;
1054 if (tcu::hasStencilComponent(format.order))
1055 stream << "stencil: " << value.depthStencil.stencil;
1057 if (tcu::hasStencilComponent(format.order) && tcu::hasDepthComponent(format.order))
1060 if (tcu::hasDepthComponent(format.order))
1061 stream << "depth: " << value.depthStencil.depth;
1065 return stream.str();
1068 return clearColorToString(vkFormat, value.color, useFormatCompCount);
1071 VkClearColorValue randomColorClearValue (const Attachment& attachment, de::Random& rng, deBool useFormatCompCount)
1073 const float clearNan = tcu::Float32::nan().asFloat();
1074 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
1075 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
1076 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
1077 const deUint32 componentCount = (useFormatCompCount ? (deUint32)tcu::getNumUsedChannels(format.order) : 4);
1078 VkClearColorValue clearColor;
1080 switch (channelClass)
1082 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
1084 for (deUint32 ndx = 0; ndx < componentCount; ndx++)
1086 if (!channelMask[ndx])
1087 clearColor.int32[ndx] = std::numeric_limits<deInt32>::min();
1089 clearColor.uint32[ndx] = rng.getBool() ? 1u : 0u;
1094 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
1096 for (deUint32 ndx = 0; ndx < componentCount; ndx++)
1098 if (!channelMask[ndx])
1099 clearColor.uint32[ndx] = std::numeric_limits<deUint32>::max();
1101 clearColor.uint32[ndx] = rng.getBool() ? 1u : 0u;
1106 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
1107 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
1108 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
1110 for (deUint32 ndx = 0; ndx < componentCount; ndx++)
1112 if (!channelMask[ndx])
1113 clearColor.float32[ndx] = clearNan;
1115 clearColor.float32[ndx] = rng.getBool() ? 1.0f : 0.0f;
1121 DE_FATAL("Unknown channel class");
1127 template <typename AttachmentDesc>
1128 AttachmentDesc createAttachmentDescription (const Attachment& attachment)
1130 const AttachmentDesc attachmentDescription // VkAttachmentDescription || VkAttachmentDescription2KHR
1132 // || VkStructureType sType;
1133 DE_NULL, // || const void* pNext;
1134 0u, // VkAttachmentDescriptionFlags flags; || VkAttachmentDescriptionFlags flags;
1135 attachment.getFormat(), // VkFormat format; || VkFormat format;
1136 attachment.getSamples(), // VkSampleCountFlagBits samples; || VkSampleCountFlagBits samples;
1137 attachment.getLoadOp(), // VkAttachmentLoadOp loadOp; || VkAttachmentLoadOp loadOp;
1138 attachment.getStoreOp(), // VkAttachmentStoreOp storeOp; || VkAttachmentStoreOp storeOp;
1139 attachment.getStencilLoadOp(), // VkAttachmentLoadOp stencilLoadOp; || VkAttachmentLoadOp stencilLoadOp;
1140 attachment.getStencilStoreOp(), // VkAttachmentStoreOp stencilStoreOp; || VkAttachmentStoreOp stencilStoreOp;
1141 attachment.getInitialLayout(), // VkImageLayout initialLayout; || VkImageLayout initialLayout;
1142 attachment.getFinalLayout() // VkImageLayout finalLayout; || VkImageLayout finalLayout;
1145 return attachmentDescription;
1148 template <typename AttachmentRef>
1149 AttachmentRef createAttachmentReference (const AttachmentReference& referenceInfo)
1151 const AttachmentRef reference // VkAttachmentReference || VkAttachmentReference2KHR
1153 // || VkStructureType sType;
1154 DE_NULL, // || const void* pNext;
1155 referenceInfo.getAttachment(), // deUint32 attachment; || deUint32 attachment;
1156 referenceInfo.getImageLayout(), // VkImageLayout layout; || VkImageLayout layout;
1157 referenceInfo.getAspectMask() // || VkImageAspectFlags aspectMask;
1163 template <typename SubpassDesc, typename AttachmentRef>
1164 SubpassDesc createSubpassDescription (const Subpass& subpass,
1165 vector<AttachmentRef>* attachmentReferenceLists,
1166 vector<deUint32>* preserveAttachmentReferences)
1168 vector<AttachmentRef>& inputAttachmentReferences = attachmentReferenceLists[0];
1169 vector<AttachmentRef>& colorAttachmentReferences = attachmentReferenceLists[1];
1170 vector<AttachmentRef>& resolveAttachmentReferences = attachmentReferenceLists[2];
1171 vector<AttachmentRef>& depthStencilAttachmentReferences = attachmentReferenceLists[3];
1173 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
1174 colorAttachmentReferences.push_back(createAttachmentReference<AttachmentRef>(subpass.getColorAttachments()[attachmentNdx]));
1176 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
1177 inputAttachmentReferences.push_back(createAttachmentReference<AttachmentRef>(subpass.getInputAttachments()[attachmentNdx]));
1179 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getResolveAttachments().size(); attachmentNdx++)
1180 resolveAttachmentReferences.push_back(createAttachmentReference<AttachmentRef>(subpass.getResolveAttachments()[attachmentNdx]));
1182 depthStencilAttachmentReferences.push_back(createAttachmentReference<AttachmentRef>(subpass.getDepthStencilAttachment()));
1184 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getPreserveAttachments().size(); attachmentNdx++)
1185 preserveAttachmentReferences->push_back(subpass.getPreserveAttachments()[attachmentNdx]);
1187 DE_ASSERT(resolveAttachmentReferences.empty() || colorAttachmentReferences.size() == resolveAttachmentReferences.size());
1190 const SubpassDesc subpassDescription // VkSubpassDescription || VkSubpassDescription2KHR
1192 // || VkStructureType sType;
1193 DE_NULL, // || const void* pNext;
1194 subpass.getFlags(), // VkSubpassDescriptionFlags flags; || VkSubpassDescriptionFlags flags;
1195 subpass.getPipelineBindPoint(), // VkPipelineBindPoint pipelineBindPoint; || VkPipelineBindPoint pipelineBindPoint;
1196 0u, // || deUint32 viewMask;
1197 (deUint32)inputAttachmentReferences.size(), // deUint32 inputAttachmentCount; || deUint32 inputAttachmentCount;
1198 inputAttachmentReferences.empty() ? DE_NULL : &inputAttachmentReferences[0], // const VkAttachmentReference* pInputAttachments; || const VkAttachmentReference2KHR* pInputAttachments;
1199 (deUint32)colorAttachmentReferences.size(), // deUint32 colorAttachmentCount; || deUint32 colorAttachmentCount;
1200 colorAttachmentReferences.empty() ? DE_NULL : &colorAttachmentReferences[0], // const VkAttachmentReference* pColorAttachments; || const VkAttachmentReference2KHR* pColorAttachments;
1201 resolveAttachmentReferences.empty() ? DE_NULL : &resolveAttachmentReferences[0], // const VkAttachmentReference* pResolveAttachments; || const VkAttachmentReference2KHR* pResolveAttachments;
1202 &depthStencilAttachmentReferences[0], // const VkAttachmentReference* pDepthStencilAttachment; || const VkAttachmentReference2KHR* pDepthStencilAttachment;
1203 (deUint32)preserveAttachmentReferences->size(), // deUint32 preserveAttachmentCount; || deUint32 preserveAttachmentCount;
1204 preserveAttachmentReferences->empty() ? DE_NULL : &(*preserveAttachmentReferences)[0] // const deUint32* pPreserveAttachments; || const deUint32* pPreserveAttachments;
1207 return subpassDescription;
1211 template <typename SubpassDep>
1212 SubpassDep createSubpassDependency (const SubpassDependency& dependencyInfo)
1214 const SubpassDep dependency // VkSubpassDependency || VkSubpassDependency2KHR
1216 // || VkStructureType sType;
1217 DE_NULL, // || const void* pNext;
1218 dependencyInfo.getSrcPass(), // deUint32 srcSubpass; || deUint32 srcSubpass;
1219 dependencyInfo.getDstPass(), // deUint32 dstSubpass; || deUint32 dstSubpass;
1220 dependencyInfo.getSrcStageMask(), // VkPipelineStageFlags srcStageMask; || VkPipelineStageFlags srcStageMask;
1221 dependencyInfo.getDstStageMask(), // VkPipelineStageFlags dstStageMask; || VkPipelineStageFlags dstStageMask;
1222 dependencyInfo.getSrcAccessMask(), // VkAccessFlags srcAccessMask; || VkAccessFlags srcAccessMask;
1223 dependencyInfo.getDstAccessMask(), // VkAccessFlags dstAccessMask; || VkAccessFlags dstAccessMask;
1224 dependencyInfo.getFlags(), // VkDependencyFlags dependencyFlags; || VkDependencyFlags dependencyFlags;
1225 0u // || deInt32 viewOffset;
1231 de::MovePtr<VkRenderPassInputAttachmentAspectCreateInfo> createRenderPassInputAttachmentAspectCreateInfo(const RenderPass& renderPassInfo)
1233 de::MovePtr<VkRenderPassInputAttachmentAspectCreateInfo> result (DE_NULL);
1235 if (!renderPassInfo.getInputAspects().empty())
1237 const VkRenderPassInputAttachmentAspectCreateInfo inputAspectCreateInfo =
1239 VK_STRUCTURE_TYPE_RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO,
1242 (deUint32)renderPassInfo.getInputAspects().size(),
1243 renderPassInfo.getInputAspects().data(),
1246 result = de::MovePtr<VkRenderPassInputAttachmentAspectCreateInfo>(new VkRenderPassInputAttachmentAspectCreateInfo(inputAspectCreateInfo));
1252 template<typename AttachmentDesc, typename AttachmentRef, typename SubpassDesc, typename SubpassDep, typename RenderPassCreateInfo>
1253 Move<VkRenderPass> createRenderPass (const DeviceInterface& vk,
1255 const RenderPass& renderPassInfo)
1257 const size_t perSubpassAttachmentReferenceLists = 4;
1258 vector<AttachmentDesc> attachments;
1259 vector<SubpassDesc> subpasses;
1260 vector<SubpassDep> dependencies;
1261 vector<vector<AttachmentRef> > attachmentReferenceLists(renderPassInfo.getSubpasses().size() * perSubpassAttachmentReferenceLists);
1262 vector<vector<deUint32> > preserveAttachments(renderPassInfo.getSubpasses().size());
1263 de::MovePtr<VkRenderPassInputAttachmentAspectCreateInfo> inputAspectCreateInfo(createRenderPassInputAttachmentAspectCreateInfo(renderPassInfo));
1265 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
1266 attachments.push_back(createAttachmentDescription<AttachmentDesc>(renderPassInfo.getAttachments()[attachmentNdx]));
1268 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); subpassNdx++)
1269 subpasses.push_back(createSubpassDescription<SubpassDesc>(renderPassInfo.getSubpasses()[subpassNdx], &(attachmentReferenceLists[subpassNdx * perSubpassAttachmentReferenceLists]), &preserveAttachments[subpassNdx]));
1271 for (size_t depNdx = 0; depNdx < renderPassInfo.getDependencies().size(); depNdx++)
1272 dependencies.push_back(createSubpassDependency<SubpassDep>(renderPassInfo.getDependencies()[depNdx]));
1274 const RenderPassCreateInfo renderPassCreator // VkRenderPassCreateInfo || VkRenderPassCreateInfo2KHR
1276 // VkStructureType sType; || VkStructureType sType;
1277 inputAspectCreateInfo.get(), // const void* pNext; || const void* pNext;
1278 (VkRenderPassCreateFlags)0u, // VkRenderPassCreateFlags flags; || VkRenderPassCreateFlags flags;
1279 (deUint32)attachments.size(), // deUint32 attachmentCount; || deUint32 attachmentCount;
1280 (attachments.empty() ? DE_NULL : &attachments[0]), // const VkAttachmentDescription* pAttachments; || const VkAttachmentDescription2KHR* pAttachments;
1281 (deUint32)subpasses.size(), // deUint32 subpassCount; || deUint32 subpassCount;
1282 (subpasses.empty() ? DE_NULL : &subpasses[0]), // const VkSubpassDescription* pSubpasses; || const VkSubpassDescription2KHR* pSubpasses;
1283 (deUint32)dependencies.size(), // deUint32 dependencyCount; || deUint32 dependencyCount;
1284 (dependencies.empty() ? DE_NULL : &dependencies[0]), // const VkSubpassDependency* pDependencies; || const VkSubpassDependency2KHR* pDependencies;
1285 0u, // || deUint32 correlatedViewMaskCount;
1286 DE_NULL // || const deUint32* pCorrelatedViewMasks;
1289 return renderPassCreator.createRenderPass(vk, device);
1292 Move<VkRenderPass> createRenderPass (const DeviceInterface& vk,
1294 const RenderPass& renderPassInfo,
1295 const RenderingType renderPassType)
1297 switch (renderPassType)
1299 case RENDERING_TYPE_RENDERPASS_LEGACY:
1300 return createRenderPass<AttachmentDescription1, AttachmentReference1, SubpassDescription1, SubpassDependency1, RenderPassCreateInfo1>(vk, device, renderPassInfo);
1301 case RENDERING_TYPE_RENDERPASS2:
1302 return createRenderPass<AttachmentDescription2, AttachmentReference2, SubpassDescription2, SubpassDependency2, RenderPassCreateInfo2>(vk, device, renderPassInfo);
1304 TCU_THROW(InternalError, "Impossible");
1308 Move<VkFramebuffer> createFramebuffer (const DeviceInterface& vk,
1310 VkRenderPass renderPass,
1312 const vector<VkImageView>& attachments)
1314 return createFramebuffer(vk, device, 0u, renderPass, (deUint32)attachments.size(), attachments.empty() ? DE_NULL : &attachments[0], size.x(), size.y(), 1u);
1317 Move<VkImage> createAttachmentImage (const DeviceInterface& vk,
1319 deUint32 queueIndex,
1322 VkSampleCountFlagBits samples,
1323 VkImageUsageFlags usageFlags,
1324 VkImageLayout layout)
1326 VkImageUsageFlags targetUsageFlags = 0;
1327 const tcu::TextureFormat textureFormat = mapVkFormat(format);
1329 DE_ASSERT(!(tcu::hasDepthComponent(vk::mapVkFormat(format).order) || tcu::hasStencilComponent(vk::mapVkFormat(format).order))
1330 || ((usageFlags & vk::VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) == 0));
1332 DE_ASSERT((tcu::hasDepthComponent(vk::mapVkFormat(format).order) || tcu::hasStencilComponent(vk::mapVkFormat(format).order))
1333 || ((usageFlags & vk::VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0));
1335 if (tcu::hasDepthComponent(textureFormat.order) || tcu::hasStencilComponent(textureFormat.order))
1336 targetUsageFlags |= vk::VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
1338 targetUsageFlags |= vk::VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
1340 return createImage(vk, device,
1341 (VkImageCreateFlags)0,
1344 vk::makeExtent3D(size.x(), size.y(), 1u),
1348 VK_IMAGE_TILING_OPTIMAL,
1349 usageFlags | targetUsageFlags,
1350 VK_SHARING_MODE_EXCLUSIVE,
1356 de::MovePtr<Allocation> createImageMemory (const InstanceInterface& vki,
1357 const VkPhysicalDevice& vkd,
1358 const DeviceInterface& vk,
1360 Allocator& allocator,
1363 AllocationKind allocationKind)
1365 const MemoryRequirement memoryRequirement = lazy ? MemoryRequirement::LazilyAllocated : MemoryRequirement::Any;
1366 de::MovePtr<Allocation> allocation = allocateImage(vki, vk, vkd, device, image, memoryRequirement, allocator, allocationKind);
1368 bindImageMemory(vk, device, image, allocation->getMemory(), allocation->getOffset());
1373 Move<VkImageView> createImageAttachmentView (const DeviceInterface& vk,
1377 VkImageAspectFlags aspect)
1379 const VkImageSubresourceRange range =
1388 return createImageView(vk, device, 0u, image, VK_IMAGE_VIEW_TYPE_2D, format, makeComponentMappingRGBA(), range);
1391 VkClearValue randomClearValue (const Attachment& attachment, de::Random& rng, deBool useFormatCompCount, const DepthValuesArray& depthValues)
1393 const float clearNan = tcu::Float32::nan().asFloat();
1394 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
1396 if (tcu::hasStencilComponent(format.order) || tcu::hasDepthComponent(format.order))
1398 VkClearValue clearValue;
1400 clearValue.depthStencil.depth = clearNan;
1401 clearValue.depthStencil.stencil = 0xCDu;
1403 if (tcu::hasStencilComponent(format.order))
1404 clearValue.depthStencil.stencil = rng.getBool()
1408 if (tcu::hasDepthComponent(format.order))
1409 clearValue.depthStencil.depth = float(depthValues[rng.getBool() ? 1 : 0]) / 255.0f;
1415 VkClearValue clearValue;
1417 clearValue.color = randomColorClearValue(attachment, rng, useFormatCompCount);
1423 class AttachmentResources
1426 AttachmentResources (const InstanceInterface& vki,
1427 const VkPhysicalDevice& physDevice,
1428 const DeviceInterface& vk,
1430 Allocator& allocator,
1431 deUint32 queueIndex,
1433 const Attachment& attachmentInfo,
1434 VkImageUsageFlags usageFlags,
1435 const AllocationKind allocationKind)
1436 : m_image (createAttachmentImage(vk, device, queueIndex, size, attachmentInfo.getFormat(), attachmentInfo.getSamples(), usageFlags, VK_IMAGE_LAYOUT_UNDEFINED))
1437 , m_imageMemory (createImageMemory(vki, physDevice, vk, device, allocator, *m_image, ((usageFlags & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0), allocationKind))
1438 , m_attachmentView (createImageAttachmentView(vk, device, *m_image, attachmentInfo.getFormat(), getImageAspectFlags(attachmentInfo.getFormat())))
1440 const tcu::TextureFormat format = mapVkFormat(attachmentInfo.getFormat());
1441 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
1442 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
1444 if (isDepthFormat && isStencilFormat)
1446 m_depthInputAttachmentView = createImageAttachmentView(vk, device, *m_image, attachmentInfo.getFormat(), VK_IMAGE_ASPECT_DEPTH_BIT);
1447 m_stencilInputAttachmentView = createImageAttachmentView(vk, device, *m_image, attachmentInfo.getFormat(), VK_IMAGE_ASPECT_STENCIL_BIT);
1449 m_inputAttachmentViews = std::make_pair(*m_depthInputAttachmentView, *m_stencilInputAttachmentView);
1452 m_inputAttachmentViews = std::make_pair(*m_attachmentView, (vk::VkImageView)0u);
1454 if ((usageFlags & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)
1456 if (tcu::hasDepthComponent(format.order) && tcu::hasStencilComponent(format.order))
1458 const tcu::TextureFormat depthFormat = getDepthCopyFormat(attachmentInfo.getFormat());
1459 const tcu::TextureFormat stencilFormat = getStencilCopyFormat(attachmentInfo.getFormat());
1461 m_bufferSize = size.x() * size.y() * depthFormat.getPixelSize();
1462 m_secondaryBufferSize = size.x() * size.y() * stencilFormat.getPixelSize();
1464 m_buffer = createBuffer(vk, device, 0, m_bufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_SHARING_MODE_EXCLUSIVE, 1, &queueIndex);
1465 m_bufferMemory = allocateBuffer(vki, vk, physDevice, device, *m_buffer, MemoryRequirement::HostVisible, allocator, allocationKind);
1467 bindBufferMemory(vk, device, *m_buffer, m_bufferMemory->getMemory(), m_bufferMemory->getOffset());
1469 m_secondaryBuffer = createBuffer(vk, device, 0, m_secondaryBufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_SHARING_MODE_EXCLUSIVE, 1, &queueIndex);
1470 m_secondaryBufferMemory = allocateBuffer(vki, vk, physDevice, device, *m_secondaryBuffer, MemoryRequirement::HostVisible, allocator, allocationKind);
1472 bindBufferMemory(vk, device, *m_secondaryBuffer, m_secondaryBufferMemory->getMemory(), m_secondaryBufferMemory->getOffset());
1476 m_bufferSize = size.x() * size.y() * format.getPixelSize();
1478 m_buffer = createBuffer(vk, device, 0, m_bufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_SHARING_MODE_EXCLUSIVE, 1, &queueIndex);
1479 m_bufferMemory = allocateBuffer(vki, vk, physDevice, device, *m_buffer, MemoryRequirement::HostVisible, allocator, allocationKind);
1481 bindBufferMemory(vk, device, *m_buffer, m_bufferMemory->getMemory(), m_bufferMemory->getOffset());
1486 const pair<VkImageView, VkImageView>& getInputAttachmentViews (void) const
1488 return m_inputAttachmentViews;
1491 ~AttachmentResources (void)
1495 VkImageView getAttachmentView (void) const
1497 return *m_attachmentView;
1500 VkImage getImage (void) const
1505 VkBuffer getBuffer (void) const
1507 DE_ASSERT(*m_buffer != DE_NULL);
1511 VkDeviceSize getBufferSize (void) const
1513 DE_ASSERT(*m_buffer != DE_NULL);
1514 return m_bufferSize;
1517 const Allocation& getResultMemory (void) const
1519 DE_ASSERT(m_bufferMemory);
1520 return *m_bufferMemory;
1523 VkBuffer getSecondaryBuffer (void) const
1525 DE_ASSERT(*m_secondaryBuffer != DE_NULL);
1526 return *m_secondaryBuffer;
1529 VkDeviceSize getSecondaryBufferSize (void) const
1531 DE_ASSERT(*m_secondaryBuffer != DE_NULL);
1532 return m_secondaryBufferSize;
1535 const Allocation& getSecondaryResultMemory (void) const
1537 DE_ASSERT(m_secondaryBufferMemory);
1538 return *m_secondaryBufferMemory;
1542 const Unique<VkImage> m_image;
1543 const UniquePtr<Allocation> m_imageMemory;
1544 const Unique<VkImageView> m_attachmentView;
1546 Move<VkImageView> m_depthInputAttachmentView;
1547 Move<VkImageView> m_stencilInputAttachmentView;
1548 pair<VkImageView, VkImageView> m_inputAttachmentViews;
1550 Move<VkBuffer> m_buffer;
1551 VkDeviceSize m_bufferSize;
1552 de::MovePtr<Allocation> m_bufferMemory;
1554 Move<VkBuffer> m_secondaryBuffer;
1555 VkDeviceSize m_secondaryBufferSize;
1556 de::MovePtr<Allocation> m_secondaryBufferMemory;
1559 void uploadBufferData (const DeviceInterface& vk,
1561 const Allocation& memory,
1564 VkDeviceSize nonCoherentAtomSize)
1566 // Expand the range to flush to account for the nonCoherentAtomSize
1567 const VkDeviceSize roundedOffset = de::roundDown(memory.getOffset(), nonCoherentAtomSize);
1568 const VkDeviceSize roundedSize = de::roundUp(memory.getOffset() - roundedOffset + static_cast<VkDeviceSize>(size), nonCoherentAtomSize);
1570 const VkMappedMemoryRange range =
1572 VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // sType;
1574 memory.getMemory(), // mem;
1575 roundedOffset, // offset;
1576 roundedSize, // size;
1578 void* const ptr = memory.getHostPtr();
1580 deMemcpy(ptr, data, size);
1581 VK_CHECK(vk.flushMappedMemoryRanges(device, 1, &range));
1584 VkImageAspectFlagBits getPrimaryImageAspect (tcu::TextureFormat::ChannelOrder order)
1586 DE_STATIC_ASSERT(tcu::TextureFormat::CHANNELORDER_LAST == 22);
1590 case tcu::TextureFormat::D:
1591 case tcu::TextureFormat::DS:
1592 return VK_IMAGE_ASPECT_DEPTH_BIT;
1594 case tcu::TextureFormat::S:
1595 return VK_IMAGE_ASPECT_STENCIL_BIT;
1598 return VK_IMAGE_ASPECT_COLOR_BIT;
1602 deUint32 getAttachmentNdx (const vector<AttachmentReference>& colorAttachments, size_t ndx)
1604 return (colorAttachments[ndx].getAttachment() == VK_ATTACHMENT_UNUSED) ? (deUint32)ndx : colorAttachments[ndx].getAttachment();
1610 RenderQuad (const Vec2& posA, const Vec2& posB)
1613 m_vertices[0] = posA;
1614 m_vertices[1] = Vec2(posA[0], posB[1]);
1615 m_vertices[2] = posB;
1617 m_vertices[3] = posB;
1618 m_vertices[4] = Vec2(posB[0], posA[1]);
1619 m_vertices[5] = posA;
1622 const Vec2& getCornerA (void) const
1624 return m_vertices[0];
1627 const Vec2& getCornerB (void) const
1629 return m_vertices[2];
1632 const void* getVertexPointer (void) const
1634 return &m_vertices[0];
1637 size_t getVertexDataSize (void) const
1639 return sizeof(Vec2) * m_vertices.size();
1643 vector<Vec2> m_vertices;
1649 ColorClear (const UVec2& offset,
1651 const VkClearColorValue& color)
1658 const UVec2& getOffset (void) const { return m_offset; }
1659 const UVec2& getSize (void) const { return m_size; }
1660 const VkClearColorValue& getColor (void) const { return m_color; }
1665 VkClearColorValue m_color;
1668 class DepthStencilClear
1671 DepthStencilClear (const UVec2& offset,
1678 , m_stencil (stencil)
1682 const UVec2& getOffset (void) const { return m_offset; }
1683 const UVec2& getSize (void) const { return m_size; }
1684 float getDepth (void) const { return m_depth; }
1685 deUint32 getStencil (void) const { return m_stencil; }
1688 const UVec2 m_offset;
1691 const float m_depth;
1692 const deUint32 m_stencil;
1695 class SubpassRenderInfo
1698 SubpassRenderInfo (const RenderPass& renderPass,
1699 deUint32 subpassIndex,
1700 deUint32 drawStartNdx,
1703 bool omitBlendState_,
1705 const UVec2& viewportOffset,
1706 const UVec2& viewportSize,
1708 const Maybe<RenderQuad>& renderQuad,
1709 const vector<ColorClear>& colorClears,
1710 const Maybe<DepthStencilClear>& depthStencilClear)
1711 : m_viewportOffset (viewportOffset)
1712 , m_viewportSize (viewportSize)
1713 , m_subpassIndex (subpassIndex)
1714 , m_drawStartNdx (drawStartNdx)
1715 , m_isSecondary (isSecondary_)
1716 , m_omitBlendState (omitBlendState_)
1717 , m_flags (renderPass.getSubpasses()[subpassIndex].getFlags())
1718 , m_renderQuad (renderQuad)
1719 , m_colorClears (colorClears)
1720 , m_depthStencilClear (depthStencilClear)
1721 , m_colorAttachments (renderPass.getSubpasses()[subpassIndex].getColorAttachments())
1722 , m_inputAttachments (renderPass.getSubpasses()[subpassIndex].getInputAttachments())
1724 for (deUint32 attachmentNdx = 0; attachmentNdx < (deUint32)m_colorAttachments.size(); attachmentNdx++)
1725 m_colorAttachmentInfo.push_back(renderPass.getAttachments()[getAttachmentNdx(m_colorAttachments, attachmentNdx)]);
1727 if (renderPass.getSubpasses()[subpassIndex].getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
1729 m_depthStencilAttachment = tcu::just(renderPass.getSubpasses()[subpassIndex].getDepthStencilAttachment());
1730 m_depthStencilAttachmentInfo = tcu::just(renderPass.getAttachments()[renderPass.getSubpasses()[subpassIndex].getDepthStencilAttachment().getAttachment()]);
1734 const UVec2& getViewportOffset (void) const { return m_viewportOffset; }
1735 const UVec2& getViewportSize (void) const { return m_viewportSize; }
1737 deUint32 getSubpassIndex (void) const { return m_subpassIndex; }
1738 deUint32 getDrawStartNdx (void) const { return m_drawStartNdx; }
1739 bool isSecondary (void) const { return m_isSecondary; }
1740 bool getOmitBlendState (void) const { return m_omitBlendState; }
1742 const Maybe<RenderQuad>& getRenderQuad (void) const { return m_renderQuad; }
1743 const vector<ColorClear>& getColorClears (void) const { return m_colorClears; }
1744 const Maybe<DepthStencilClear>& getDepthStencilClear (void) const { return m_depthStencilClear; }
1746 deUint32 getInputAttachmentCount (void) const { return (deUint32)m_inputAttachments.size(); }
1747 deUint32 getInputAttachmentIndex (deUint32 attachmentNdx) const { return m_inputAttachments[attachmentNdx].getAttachment(); }
1748 VkImageLayout getInputAttachmentLayout (deUint32 attachmentNdx) const { return m_inputAttachments[attachmentNdx].getImageLayout(); }
1750 deUint32 getColorAttachmentCount (void) const { return (deUint32)m_colorAttachments.size(); }
1751 VkImageLayout getColorAttachmentLayout (deUint32 attachmentNdx) const { return m_colorAttachments[attachmentNdx].getImageLayout(); }
1752 deUint32 getColorAttachmentIndex (deUint32 attachmentNdx) const { return m_colorAttachments[attachmentNdx].getAttachment(); }
1753 const Attachment& getColorAttachment (deUint32 attachmentNdx) const { return m_colorAttachmentInfo[attachmentNdx]; }
1754 Maybe<VkImageLayout> getDepthStencilAttachmentLayout (void) const { return m_depthStencilAttachment ? tcu::just(m_depthStencilAttachment->getImageLayout()) : tcu::Nothing; }
1755 Maybe<deUint32> getDepthStencilAttachmentIndex (void) const { return m_depthStencilAttachment ? tcu::just(m_depthStencilAttachment->getAttachment()) : tcu::Nothing; }
1756 const Maybe<Attachment>& getDepthStencilAttachment (void) const { return m_depthStencilAttachmentInfo; }
1757 VkSubpassDescriptionFlags getSubpassFlags (void) const { return m_flags; }
1760 UVec2 m_viewportOffset;
1761 UVec2 m_viewportSize;
1763 deUint32 m_subpassIndex;
1764 deUint32 m_drawStartNdx;
1766 bool m_omitBlendState;
1767 VkSubpassDescriptionFlags m_flags;
1769 Maybe<RenderQuad> m_renderQuad;
1770 vector<ColorClear> m_colorClears;
1771 Maybe<DepthStencilClear> m_depthStencilClear;
1773 vector<AttachmentReference> m_colorAttachments;
1774 vector<Attachment> m_colorAttachmentInfo;
1776 Maybe<AttachmentReference> m_depthStencilAttachment;
1777 Maybe<Attachment> m_depthStencilAttachmentInfo;
1779 vector<AttachmentReference> m_inputAttachments;
1782 void beginCommandBuffer (const DeviceInterface& vk,
1783 VkCommandBuffer cmdBuffer,
1784 VkRenderPass pInheritanceInfo_renderPass,
1785 deUint32 pInheritanceInfo_subpass,
1786 VkFramebuffer pInheritanceInfo_framebuffer,
1787 VkBool32 pInheritanceInfo_occlusionQueryEnable,
1788 VkQueryControlFlags pInheritanceInfo_queryFlags,
1789 VkQueryPipelineStatisticFlags pInheritanceInfo_pipelineStatistics,
1790 const SubpassRenderInfo* pRenderInfo = 0,
1791 bool dynamicRenderPass = false,
1792 bool secondaryCmdBufferCompletelyContainsRenderpass = false)
1794 VkCommandBufferUsageFlags usageFlags = (VkCommandBufferUsageFlags)0;
1795 VkCommandBufferInheritanceInfo pInheritanceInfo
1797 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO,
1799 pInheritanceInfo_renderPass,
1800 pInheritanceInfo_subpass,
1801 pInheritanceInfo_framebuffer,
1802 pInheritanceInfo_occlusionQueryEnable,
1803 pInheritanceInfo_queryFlags,
1804 pInheritanceInfo_pipelineStatistics,
1807 #ifndef CTS_USES_VULKANSC
1809 std::vector<vk::VkFormat> colorAttachmentFormats;
1810 VkCommandBufferInheritanceRenderingInfoKHR inheritanceRenderingInfo = initVulkanStructure();
1812 if (dynamicRenderPass && pRenderInfo)
1814 if (secondaryCmdBufferCompletelyContainsRenderpass)
1815 inheritanceRenderingInfo.flags = VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT;
1817 usageFlags |= VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
1819 for (deUint32 i = 0; i < pRenderInfo->getColorAttachmentCount(); ++i)
1820 colorAttachmentFormats.push_back(pRenderInfo->getColorAttachment(i).getFormat());
1822 inheritanceRenderingInfo.colorAttachmentCount = static_cast<deUint32>(colorAttachmentFormats.size());
1823 inheritanceRenderingInfo.pColorAttachmentFormats = colorAttachmentFormats.data();
1824 if (pRenderInfo->getDepthStencilAttachment())
1826 const VkFormat dsFormat = pRenderInfo->getDepthStencilAttachment()->getFormat();
1827 inheritanceRenderingInfo.depthAttachmentFormat = tcu::hasDepthComponent(mapVkFormat(dsFormat).order) ? dsFormat : VK_FORMAT_UNDEFINED;
1828 inheritanceRenderingInfo.stencilAttachmentFormat = tcu::hasStencilComponent(mapVkFormat(dsFormat).order) ? dsFormat : VK_FORMAT_UNDEFINED;
1831 if (pRenderInfo->getColorAttachmentCount())
1832 inheritanceRenderingInfo.rasterizationSamples = pRenderInfo->getColorAttachment(0).getSamples();
1833 else if (pRenderInfo->getDepthStencilAttachment())
1834 inheritanceRenderingInfo.rasterizationSamples = pRenderInfo->getDepthStencilAttachment()->getSamples();
1836 inheritanceRenderingInfo.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
1838 pInheritanceInfo.pNext = &inheritanceRenderingInfo;
1840 else if (!secondaryCmdBufferCompletelyContainsRenderpass)
1841 usageFlags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
1844 DE_UNREF(pRenderInfo);
1845 DE_UNREF(dynamicRenderPass);
1846 DE_UNREF(secondaryCmdBufferCompletelyContainsRenderpass);
1848 usageFlags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
1850 #endif // CTS_USES_VULKANSC
1852 const VkCommandBufferBeginInfo pBeginInfo
1854 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
1859 VK_CHECK(vk.beginCommandBuffer(cmdBuffer, &pBeginInfo));
1862 Move<VkPipeline> createSubpassPipeline (const DeviceInterface& vk,
1864 VkRenderPass renderPass,
1865 VkShaderModule vertexShaderModule,
1866 VkShaderModule fragmentShaderModule,
1867 VkPipelineLayout pipelineLayout,
1868 const SubpassRenderInfo& renderInfo)
1870 Maybe<VkSampleCountFlagBits> rasterSamples;
1871 vector<VkPipelineColorBlendAttachmentState> attachmentBlendStates;
1873 for (deUint32 attachmentNdx = 0; attachmentNdx < renderInfo.getColorAttachmentCount(); attachmentNdx++)
1875 const Attachment& attachment = renderInfo.getColorAttachment(attachmentNdx);
1877 DE_ASSERT(!rasterSamples || *rasterSamples == attachment.getSamples());
1879 rasterSamples = attachment.getSamples();
1882 const VkPipelineColorBlendAttachmentState attachmentBlendState =
1884 VK_FALSE, // blendEnable
1885 VK_BLEND_FACTOR_SRC_ALPHA, // srcBlendColor
1886 VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, // destBlendColor
1887 VK_BLEND_OP_ADD, // blendOpColor
1888 VK_BLEND_FACTOR_ONE, // srcBlendAlpha
1889 VK_BLEND_FACTOR_ONE, // destBlendAlpha
1890 VK_BLEND_OP_ADD, // blendOpAlpha
1891 (attachmentNdx < renderInfo.getDrawStartNdx() ? (deUint32)0 :
1892 VK_COLOR_COMPONENT_R_BIT|VK_COLOR_COMPONENT_G_BIT|VK_COLOR_COMPONENT_B_BIT|VK_COLOR_COMPONENT_A_BIT) // channelWriteMask
1895 attachmentBlendStates.push_back(attachmentBlendState);
1899 if (renderInfo.getDepthStencilAttachment())
1901 const Attachment& attachment = *renderInfo.getDepthStencilAttachment();
1903 DE_ASSERT(!rasterSamples || *rasterSamples == attachment.getSamples());
1904 rasterSamples = attachment.getSamples();
1907 // If there are no attachment use single sample
1909 rasterSamples = VK_SAMPLE_COUNT_1_BIT;
1911 const VkVertexInputBindingDescription vertexBinding =
1914 (deUint32)sizeof(tcu::Vec2), // strideInBytes
1915 VK_VERTEX_INPUT_RATE_VERTEX, // stepRate
1918 const VkVertexInputAttributeDescription vertexAttrib =
1922 VK_FORMAT_R32G32_SFLOAT, // format
1923 0u, // offsetInBytes
1926 const VkPipelineVertexInputStateCreateInfo vertexInputState =
1928 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // sType
1930 (VkPipelineVertexInputStateCreateFlags)0u,
1932 &vertexBinding, // pVertexBindingDescriptions
1933 1u, // attributeCount
1934 &vertexAttrib, // pVertexAttributeDescriptions
1937 const VkPipelineInputAssemblyStateCreateInfo inputAssemblyState =
1939 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, // VkStructureType sType
1940 DE_NULL, // const void* pNext
1941 0u, // VkPipelineInputAssemblyStateCreateFlags flags
1942 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, // VkPrimitiveTopology topology
1943 VK_FALSE // VkBool32 primitiveRestartEnable
1946 const VkViewport viewport =
1948 (float)renderInfo.getViewportOffset().x(), (float)renderInfo.getViewportOffset().y(),
1949 (float)renderInfo.getViewportSize().x(), (float)renderInfo.getViewportSize().y(),
1953 const VkRect2D scissor =
1955 { (deInt32)renderInfo.getViewportOffset().x(), (deInt32)renderInfo.getViewportOffset().y() },
1956 { renderInfo.getViewportSize().x(), renderInfo.getViewportSize().y() }
1959 const VkPipelineViewportStateCreateInfo viewportState =
1961 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, // VkStructureType sType
1962 DE_NULL, // const void* pNext
1963 (VkPipelineViewportStateCreateFlags)0, // VkPipelineViewportStateCreateFlags flags
1964 1u, // deUint32 viewportCount
1965 &viewport, // const VkViewport* pViewports
1966 1u, // deUint32 scissorCount
1967 &scissor // const VkRect2D* pScissors
1970 const VkPipelineRasterizationStateCreateInfo rasterizationState =
1972 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, // VkStructureType sType
1973 DE_NULL, // const void* pNext
1974 0u, // VkPipelineRasterizationStateCreateFlags flags
1975 VK_FALSE, // VkBool32 depthClampEnable
1976 VK_FALSE, // VkBool32 rasterizerDiscardEnable
1977 VK_POLYGON_MODE_FILL, // VkPolygonMode polygonMode
1978 VK_CULL_MODE_NONE, // VkCullModeFlags cullMode
1979 VK_FRONT_FACE_COUNTER_CLOCKWISE, // VkFrontFace frontFace
1980 VK_FALSE, // VkBool32 depthBiasEnable
1981 0.0f, // float depthBiasConstantFactor
1982 0.0f, // float depthBiasClamp
1983 0.0f, // float depthBiasSlopeFactor
1984 1.0f // float lineWidth
1987 const VkPipelineMultisampleStateCreateInfo multisampleState =
1989 VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, // sType
1991 (VkPipelineMultisampleStateCreateFlags)0u,
1992 *rasterSamples, // rasterSamples
1993 VK_FALSE, // sampleShadingEnable
1994 0.0f, // minSampleShading
1995 DE_NULL, // pSampleMask
1996 VK_FALSE, // alphaToCoverageEnable
1997 VK_FALSE, // alphaToOneEnable
1999 const size_t stencilIndex = renderInfo.getSubpassIndex();
2001 const VkBool32 writeDepth = renderInfo.getDepthStencilAttachmentLayout()
2002 && *renderInfo.getDepthStencilAttachmentLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
2003 && *renderInfo.getDepthStencilAttachmentLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL
2007 const VkBool32 writeStencil = renderInfo.getDepthStencilAttachmentLayout()
2008 && *renderInfo.getDepthStencilAttachmentLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
2009 && *renderInfo.getDepthStencilAttachmentLayout() != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
2013 VkStencilOp stencilOp = writeStencil ? VK_STENCIL_OP_REPLACE : VK_STENCIL_OP_KEEP;
2015 const VkPipelineDepthStencilStateCreateInfo depthStencilState =
2017 VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, // sType
2019 (VkPipelineDepthStencilStateCreateFlags)0u,
2020 writeDepth, // depthTestEnable
2021 writeDepth, // depthWriteEnable
2022 VK_COMPARE_OP_ALWAYS, // depthCompareOp
2023 VK_FALSE, // depthBoundsEnable
2024 writeStencil, // stencilTestEnable
2026 stencilOp, // stencilFailOp
2027 stencilOp, // stencilPassOp
2028 stencilOp, // stencilDepthFailOp
2029 VK_COMPARE_OP_ALWAYS, // stencilCompareOp
2030 ~0u, // stencilCompareMask
2031 ~0u, // stencilWriteMask
2032 ((stencilIndex % 2) == 0) ? ~0x0u : 0x0u // stencilReference
2035 stencilOp, // stencilFailOp
2036 stencilOp, // stencilPassOp
2037 stencilOp, // stencilDepthFailOp
2038 VK_COMPARE_OP_ALWAYS, // stencilCompareOp
2039 ~0u, // stencilCompareMask
2040 ~0u, // stencilWriteMask
2041 ((stencilIndex % 2) == 0) ? ~0x0u : 0x0u // stencilReference
2044 0.0f, // minDepthBounds;
2045 1.0f // maxDepthBounds;
2048 const VkPipelineColorBlendStateCreateInfo blendState =
2050 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // sType
2052 (VkPipelineColorBlendStateCreateFlags)0u,
2053 VK_FALSE, // logicOpEnable
2054 VK_LOGIC_OP_COPY, // logicOp
2055 (deUint32)attachmentBlendStates.size(), // attachmentCount
2056 attachmentBlendStates.empty() ? DE_NULL : &attachmentBlendStates[0],// pAttachments
2057 { 0.0f, 0.0f, 0.0f, 0.0f } // blendConst
2060 #ifndef CTS_USES_VULKANSC
2061 std::vector<vk::VkFormat> colorAttachmentFormats;
2062 for (deUint32 i = 0; i < renderInfo.getColorAttachmentCount(); ++i)
2063 colorAttachmentFormats.push_back(renderInfo.getColorAttachment(i).getFormat());
2065 vk::VkFormat depthFormat = VK_FORMAT_UNDEFINED;
2066 vk::VkFormat stencilFormat = VK_FORMAT_UNDEFINED;
2067 if (renderInfo.getDepthStencilAttachment())
2069 const Attachment& attachment = *renderInfo.getDepthStencilAttachment();
2070 vk::VkFormat depthStencilFormat = attachment.getFormat();
2071 if (depthStencilFormat != VK_FORMAT_UNDEFINED)
2073 if (tcu::hasDepthComponent(mapVkFormat(depthStencilFormat).order))
2075 depthFormat = depthStencilFormat;
2077 if (tcu::hasStencilComponent(mapVkFormat(depthStencilFormat).order))
2079 stencilFormat = depthStencilFormat;
2085 VkPipelineRenderingCreateInfoKHR renderingCreateInfo
2087 VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR,
2090 static_cast<deUint32>(colorAttachmentFormats.size()),
2091 colorAttachmentFormats.data(),
2095 #endif // CTS_USES_VULKANSC
2097 return makeGraphicsPipeline(vk, // const DeviceInterface& vk
2098 device, // const VkDevice device
2099 pipelineLayout, // const VkPipelineLayout pipelineLayout
2100 vertexShaderModule, // const VkShaderModule vertexShaderModule
2101 DE_NULL, // const VkShaderModule tessellationControlShaderModule
2102 DE_NULL, // const VkShaderModule tessellationEvalShaderModule
2103 DE_NULL, // const VkShaderModule geometryShaderModule
2104 fragmentShaderModule, // const VkShaderModule fragmentShaderModule
2105 renderPass, // const VkRenderPass renderPass
2106 renderInfo.getSubpassIndex(), // const deUint32 subpass
2107 &vertexInputState, // const VkPipelineVertexInputStateCreateInfo* vertexInputStateCreateInfo
2108 &inputAssemblyState, // const VkPipelineInputAssemblyStateCreateInfo* pInputAssemblyState;
2109 DE_NULL, // const VkPipelineRasterizationStateCreateInfo* rasterizationStateCreateInfo
2110 &viewportState, // const VkPipelineViewportStateCreateInfo* pViewportStat;
2111 &rasterizationState, // const VkPipelineRasterizationStateCreateInfo* pRasterizationState
2112 &multisampleState, // const VkPipelineMultisampleStateCreateInfo* multisampleStateCreateInfo
2113 &depthStencilState, // const VkPipelineDepthStencilStateCreateInfo* depthStencilStateCreateInfo
2114 renderInfo.getOmitBlendState()
2115 ? DE_NULL : &blendState, // const VkPipelineColorBlendStateCreateInfo* colorBlendStateCreateInfo
2116 DE_NULL, // const VkPipelineDynamicStateCreateInfo* dynamicStateCreateInfo
2117 #ifndef CTS_USES_VULKANSC
2118 (renderPass == DE_NULL)
2119 ? &renderingCreateInfo : DE_NULL); // const void* pNext)
2121 DE_NULL); // const void* pNext)
2122 #endif // CTS_USES_VULKANSC
2125 #ifndef CTS_USES_VULKANSC
2126 void beginDynamicRendering(const DeviceInterface& vk,
2127 VkCommandBuffer commandBuffer,
2128 const RenderPass& renderPassInfo,
2129 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
2130 const VkRect2D& renderArea,
2131 const vector<Maybe<VkClearValue> >& renderPassClearValues,
2132 const VkRenderingFlagsKHR renderingFlags = 0u)
2134 const float clearNan = tcu::Float32::nan().asFloat();
2135 const VkClearValue clearValueNan = makeClearValueColorF32(clearNan, clearNan, clearNan, clearNan);
2137 // translate structures that were prepared to construct renderpass to structures needed for dynamic rendering
2139 std::vector<vk::VkRenderingAttachmentInfoKHR> colorAttachmentVect;
2140 const Subpass& subpassInfo = renderPassInfo.getSubpasses()[0];
2141 const vector<AttachmentReference>& colorAttachmentsInfo = subpassInfo.getColorAttachments();
2142 const vector<AttachmentReference>& resolveAttachmentsInfo = subpassInfo.getResolveAttachments();
2144 for (deUint32 i = 0; i < colorAttachmentsInfo.size(); ++i)
2146 const AttachmentReference& colorAttachmentReference = colorAttachmentsInfo[i];
2147 const deUint32 colorAttachmentIndex = colorAttachmentReference.getAttachment();
2148 const Attachment& colorAttachmentInfo = renderPassInfo.getAttachments()[colorAttachmentIndex];
2150 VkResolveModeFlagBits resolveMode = VK_RESOLVE_MODE_NONE;
2151 VkImageView resolveImageView = DE_NULL;
2152 VkImageLayout resolveImageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
2154 // handle resolve attachments if they were specified
2155 if (!resolveAttachmentsInfo.empty())
2157 const AttachmentReference& resolveAttachmentReference = resolveAttachmentsInfo[i];
2158 const deUint32 resolveAttachmentIndex = resolveAttachmentReference.getAttachment();
2159 const Attachment& resolveAttachmentInfo = renderPassInfo.getAttachments()[resolveAttachmentIndex];
2161 resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
2162 resolveImageView = attachmentResources[resolveAttachmentIndex]->getAttachmentView();
2163 resolveImageLayout = resolveAttachmentInfo.getInitialLayout();
2166 colorAttachmentVect.push_back({
2167 vk::VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR, // VkStructureType sType
2168 DE_NULL, // const void* pNext
2169 attachmentResources[colorAttachmentIndex]->getAttachmentView(), // VkImageView imageView
2170 colorAttachmentReference.getImageLayout(), // VkImageLayout imageLayout
2171 resolveMode, // VkResolveModeFlagBits resolveMode
2172 resolveImageView, // VkImageView resolveImageView
2173 resolveImageLayout, // VkImageLayout resolveImageLayout
2174 colorAttachmentInfo.getLoadOp(), // VkAttachmentLoadOp loadOp
2175 colorAttachmentInfo.getStoreOp(), // VkAttachmentStoreOp storeOp
2176 (renderPassClearValues[colorAttachmentIndex] ?
2177 *renderPassClearValues[colorAttachmentIndex] :
2178 clearValueNan) // VkClearValue clearValue
2182 VkRenderingAttachmentInfoKHR* pDepthAttachment = DE_NULL;
2183 VkRenderingAttachmentInfoKHR* pStencilAttachment = DE_NULL;
2184 VkRenderingAttachmentInfoKHR depthAttachment
2186 vk::VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR, // VkStructureType sType;
2187 DE_NULL, // const void* pNext;
2188 DE_NULL, // VkImageView imageView;
2189 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout imageLayout;
2190 VK_RESOLVE_MODE_NONE, // VkResolveModeFlagBits resolveMode;
2191 DE_NULL, // VkImageView resolveImageView;
2192 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout resolveImageLayout;
2193 VK_ATTACHMENT_LOAD_OP_LOAD, // VkAttachmentLoadOp loadOp;
2194 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp;
2195 clearValueNan // VkClearValue clearValue;
2197 VkRenderingAttachmentInfoKHR stencilAttachment = depthAttachment;
2198 const AttachmentReference& depthStencilAttachmentReference = subpassInfo.getDepthStencilAttachment();
2199 const deUint32 dsAttachmentIndex = depthStencilAttachmentReference.getAttachment();
2201 if (dsAttachmentIndex != VK_ATTACHMENT_UNUSED)
2203 const Attachment& dsAttachmentInfo = renderPassInfo.getAttachments()[dsAttachmentIndex];
2204 const tcu::TextureFormat format = mapVkFormat(dsAttachmentInfo.getFormat());
2206 if (tcu::hasDepthComponent(format.order))
2208 depthAttachment.imageView = attachmentResources[dsAttachmentIndex]->getAttachmentView();
2209 depthAttachment.imageLayout = depthStencilAttachmentReference.getImageLayout();
2210 depthAttachment.loadOp = dsAttachmentInfo.getLoadOp();
2211 depthAttachment.storeOp = dsAttachmentInfo.getStoreOp();
2213 if (renderPassClearValues[dsAttachmentIndex])
2214 depthAttachment.clearValue = *renderPassClearValues[dsAttachmentIndex];
2216 pDepthAttachment = &depthAttachment;
2219 if (tcu::hasStencilComponent(format.order))
2221 stencilAttachment.imageView = attachmentResources[dsAttachmentIndex]->getAttachmentView();
2222 stencilAttachment.imageLayout = depthStencilAttachmentReference.getImageLayout();
2223 stencilAttachment.loadOp = dsAttachmentInfo.getStencilLoadOp();
2224 stencilAttachment.storeOp = dsAttachmentInfo.getStencilStoreOp();
2226 if (renderPassClearValues[dsAttachmentIndex])
2227 stencilAttachment.clearValue = *renderPassClearValues[dsAttachmentIndex];
2229 pStencilAttachment = &stencilAttachment;
2233 vk::VkRenderingInfoKHR renderingInfo
2235 vk::VK_STRUCTURE_TYPE_RENDERING_INFO_KHR,
2237 renderingFlags, // VkRenderingFlagsKHR flags;
2238 renderArea, // VkRect2D renderArea;
2239 1u, // deUint32 layerCount;
2240 0u, // deUint32 viewMask;
2241 static_cast<deUint32>(colorAttachmentVect.size()), // deUint32 colorAttachmentCount;
2242 colorAttachmentVect.empty() ? DE_NULL : &colorAttachmentVect[0], // const VkRenderingAttachmentInfoKHR* pColorAttachments;
2243 pDepthAttachment, // const VkRenderingAttachmentInfoKHR* pDepthAttachment;
2244 pStencilAttachment // const VkRenderingAttachmentInfoKHR* pStencilAttachment;
2247 vk.cmdBeginRendering(commandBuffer, &renderingInfo);
2250 void endDynamicRendering(const DeviceInterface& vk, VkCommandBuffer commandBuffer)
2252 vk.cmdEndRendering(commandBuffer);
2254 #endif // CTS_USES_VULKANSC
2256 class SubpassRenderer
2259 SubpassRenderer (Context& context,
2260 const DeviceInterface& vk,
2262 Allocator& allocator,
2263 const RenderPass& renderPassInfo,
2264 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
2265 const VkRect2D& renderArea,
2266 const vector<Maybe<VkClearValue> >& renderPassClearValues,
2267 VkRenderPass renderPass,
2268 VkFramebuffer framebuffer,
2269 VkCommandPool commandBufferPool,
2270 deUint32 queueFamilyIndex,
2271 const vector<VkImage>& attachmentImages,
2272 const vector<pair<VkImageView, VkImageView> >& attachmentViews,
2273 const SubpassRenderInfo& renderInfo,
2274 const AllocationKind allocationKind,
2275 const bool dynamicRendering,
2276 const bool secondaryCmdBufferCompletelyContainsDynamicRenderpass)
2277 : m_renderInfo (renderInfo)
2279 // unreference values not used by Vulkan SC, no need to pu this under ifdef
2280 DE_UNREF(attachmentResources);
2281 DE_UNREF(renderArea);
2282 DE_UNREF(renderPassClearValues);
2284 const InstanceInterface& vki = context.getInstanceInterface();
2285 const VkPhysicalDevice& physDevice = context.getPhysicalDevice();
2286 const vector<Attachment>& attachmentInfos = renderPassInfo.getAttachments();
2287 const deUint32 subpassIndex = renderInfo.getSubpassIndex();
2288 vector<VkDescriptorSetLayoutBinding> bindings;
2290 for (deUint32 colorAttachmentNdx = 0; colorAttachmentNdx < renderInfo.getColorAttachmentCount(); colorAttachmentNdx++)
2292 const deUint32 attachmentNdx = (renderInfo.getColorAttachmentIndex(colorAttachmentNdx) == VK_ATTACHMENT_UNUSED) ? colorAttachmentNdx
2293 : renderInfo.getColorAttachmentIndex(colorAttachmentNdx);
2295 m_colorAttachmentImages.push_back(attachmentImages[attachmentNdx]);
2298 if (renderInfo.getDepthStencilAttachmentIndex())
2299 m_depthStencilAttachmentImage = attachmentImages[*renderInfo.getDepthStencilAttachmentIndex()];
2301 if (renderInfo.getRenderQuad())
2303 const RenderQuad& renderQuad = *renderInfo.getRenderQuad();
2305 if (renderInfo.getInputAttachmentCount() > 0)
2307 deUint32 bindingIndex = 0;
2309 for (deUint32 inputAttachmentNdx = 0; inputAttachmentNdx < renderInfo.getInputAttachmentCount(); inputAttachmentNdx++)
2311 const Attachment attachmentInfo = attachmentInfos[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)];
2312 const VkImageLayout layout = renderInfo.getInputAttachmentLayout(inputAttachmentNdx);
2313 const tcu::TextureFormat format = mapVkFormat(attachmentInfo.getFormat());
2314 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
2315 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
2316 const deUint32 bindingCount = (isDepthFormat && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
2317 && (isStencilFormat && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
2321 for (deUint32 bindingNdx = 0; bindingNdx < bindingCount; bindingNdx++)
2323 const VkDescriptorSetLayoutBinding binding =
2326 vk::VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2328 vk::VK_SHADER_STAGE_FRAGMENT_BIT,
2332 bindings.push_back(binding);
2337 const VkDescriptorSetLayoutCreateInfo createInfo =
2339 vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
2343 (deUint32)bindings.size(),
2347 m_descriptorSetLayout = vk::createDescriptorSetLayout(vk, device, &createInfo);
2350 const VkDescriptorSetLayout descriptorSetLayout = *m_descriptorSetLayout;
2351 const VkPipelineLayoutCreateInfo pipelineLayoutParams =
2353 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // sType;
2355 (vk::VkPipelineLayoutCreateFlags)0,
2356 m_descriptorSetLayout ? 1u :0u , // setLayoutCount;
2357 m_descriptorSetLayout ? &descriptorSetLayout : DE_NULL, // pSetLayouts;
2358 0u, // pushConstantRangeCount;
2359 DE_NULL, // pPushConstantRanges;
2362 m_vertexShaderModule = createShaderModule(vk, device, context.getBinaryCollection().get(de::toString(subpassIndex) + "-vert"), 0u);
2363 m_fragmentShaderModule = createShaderModule(vk, device, context.getBinaryCollection().get(de::toString(subpassIndex) + "-frag"), 0u);
2364 m_pipelineLayout = createPipelineLayout(vk, device, &pipelineLayoutParams);
2365 m_pipeline = createSubpassPipeline(vk, device, renderPass, *m_vertexShaderModule, *m_fragmentShaderModule, *m_pipelineLayout, m_renderInfo);
2367 // Round up the vertex buffer size to honor nonCoherentAtomSize.
2368 const auto properties = vk::getPhysicalDeviceProperties(context.getInstanceInterface(), context.getPhysicalDevice());
2369 const auto vertexBufferSize = de::roundUp(static_cast<VkDeviceSize>(renderQuad.getVertexDataSize()), properties.limits.nonCoherentAtomSize);
2371 m_vertexBuffer = createBuffer(vk, device, 0u, vertexBufferSize, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, VK_SHARING_MODE_EXCLUSIVE, 1u, &queueFamilyIndex);
2372 m_vertexBufferMemory = allocateBuffer(vki, vk, physDevice, device, *m_vertexBuffer, MemoryRequirement::HostVisible, allocator, allocationKind);
2374 bindBufferMemory(vk, device, *m_vertexBuffer, m_vertexBufferMemory->getMemory(), m_vertexBufferMemory->getOffset());
2376 uploadBufferData(vk, device, *m_vertexBufferMemory, renderQuad.getVertexDataSize(), renderQuad.getVertexPointer(), properties.limits.nonCoherentAtomSize);
2378 if (renderInfo.getInputAttachmentCount() > 0)
2381 const VkDescriptorPoolSize poolSize =
2383 vk::VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2384 // \note Reserve 2 per input attachment since depthStencil attachments require 2.
2385 renderInfo.getInputAttachmentCount() * 2u
2387 const VkDescriptorPoolCreateInfo createInfo =
2389 vk::VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
2391 VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
2393 // \note Reserve 2 per input attachment since depthStencil attachments require 2.
2394 renderInfo.getInputAttachmentCount() * 2u,
2399 m_descriptorPool = vk::createDescriptorPool(vk, device, &createInfo);
2402 const VkDescriptorSetAllocateInfo allocateInfo =
2404 vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
2409 &descriptorSetLayout
2412 m_descriptorSet = vk::allocateDescriptorSet(vk, device, &allocateInfo);
2415 vector<VkWriteDescriptorSet> writes (bindings.size());
2416 vector<VkDescriptorImageInfo> imageInfos (bindings.size());
2417 deUint32 bindingIndex = 0;
2419 for (deUint32 inputAttachmentNdx = 0; inputAttachmentNdx < renderInfo.getInputAttachmentCount(); inputAttachmentNdx++)
2421 const Attachment attachmentInfo = attachmentInfos[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)];
2422 const tcu::TextureFormat format = mapVkFormat(attachmentInfo.getFormat());
2423 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
2424 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
2425 const VkImageLayout inputAttachmentLayout = renderInfo.getInputAttachmentLayout(inputAttachmentNdx);
2428 if (isDepthFormat && isStencilFormat)
2430 if (inputAttachmentLayout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
2432 const VkDescriptorImageInfo imageInfo =
2435 attachmentViews[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)].first,
2436 inputAttachmentLayout
2438 imageInfos[bindingIndex] = imageInfo;
2441 const VkWriteDescriptorSet write =
2443 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2450 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2451 &imageInfos[bindingIndex],
2455 writes[bindingIndex] = write;
2461 if (inputAttachmentLayout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
2463 const VkDescriptorImageInfo imageInfo =
2466 attachmentViews[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)].second,
2467 inputAttachmentLayout
2469 imageInfos[bindingIndex] = imageInfo;
2472 const VkWriteDescriptorSet write =
2474 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2481 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2482 &imageInfos[bindingIndex],
2486 writes[bindingIndex] = write;
2494 const VkDescriptorImageInfo imageInfo =
2497 attachmentViews[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)].first,
2498 inputAttachmentLayout
2500 imageInfos[bindingIndex] = imageInfo;
2503 const VkWriteDescriptorSet write =
2505 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2512 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2513 &imageInfos[bindingIndex],
2517 writes[bindingIndex] = write;
2524 vk.updateDescriptorSets(device, (deUint32)writes.size(), &writes[0], 0u, DE_NULL);
2529 if (renderInfo.isSecondary())
2531 m_commandBuffer = allocateCommandBuffer(vk, device, commandBufferPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2533 beginCommandBuffer(vk, *m_commandBuffer, renderPass, subpassIndex, framebuffer, VK_FALSE, (VkQueryControlFlags)0,
2534 (VkQueryPipelineStatisticFlags)0, &renderInfo, dynamicRendering, secondaryCmdBufferCompletelyContainsDynamicRenderpass);
2536 if (dynamicRendering && secondaryCmdBufferCompletelyContainsDynamicRenderpass)
2538 #ifndef CTS_USES_VULKANSC
2539 beginDynamicRendering(vk, *m_commandBuffer, renderPassInfo, attachmentResources, renderArea, renderPassClearValues);
2540 pushRenderCommands(vk, *m_commandBuffer);
2541 endDynamicRendering(vk, *m_commandBuffer);
2542 #endif // CTS_USES_VULKANSC
2545 pushRenderCommands(vk, *m_commandBuffer);
2547 endCommandBuffer(vk, *m_commandBuffer);
2551 bool isSecondary (void) const
2553 return !!m_commandBuffer;
2556 VkCommandBuffer getCommandBuffer (void) const
2558 DE_ASSERT(isSecondary());
2559 return *m_commandBuffer;
2562 void pushRenderCommands (const DeviceInterface& vk,
2563 VkCommandBuffer commandBuffer)
2565 if (!m_renderInfo.getColorClears().empty())
2567 const vector<ColorClear>& colorClears (m_renderInfo.getColorClears());
2569 for (deUint32 attachmentNdx = 0; attachmentNdx < m_renderInfo.getColorAttachmentCount(); attachmentNdx++)
2571 const ColorClear& colorClear = colorClears[attachmentNdx];
2572 const VkClearAttachment attachment =
2574 VK_IMAGE_ASPECT_COLOR_BIT,
2576 makeClearValue(colorClear.getColor()),
2578 const VkClearRect rect =
2581 { (deInt32)colorClear.getOffset().x(), (deInt32)colorClear.getOffset().y() },
2582 { colorClear.getSize().x(), colorClear.getSize().y() }
2584 0u, // baseArrayLayer
2588 vk.cmdClearAttachments(commandBuffer, 1u, &attachment, 1u, &rect);
2592 if (m_renderInfo.getDepthStencilClear())
2594 const DepthStencilClear& depthStencilClear = *m_renderInfo.getDepthStencilClear();
2595 const deUint32 attachmentNdx = m_renderInfo.getColorAttachmentCount();
2596 tcu::TextureFormat format = mapVkFormat(m_renderInfo.getDepthStencilAttachment()->getFormat());
2597 const VkImageLayout layout = *m_renderInfo.getDepthStencilAttachmentLayout();
2598 const VkClearAttachment attachment =
2600 (VkImageAspectFlags)((hasDepthComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL ? VK_IMAGE_ASPECT_DEPTH_BIT : 0)
2601 | (hasStencilComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL ? VK_IMAGE_ASPECT_STENCIL_BIT : 0)),
2603 makeClearValueDepthStencil(depthStencilClear.getDepth(), depthStencilClear.getStencil())
2605 const VkClearRect rect =
2608 { (deInt32)depthStencilClear.getOffset().x(), (deInt32)depthStencilClear.getOffset().y() },
2609 { depthStencilClear.getSize().x(), depthStencilClear.getSize().y() }
2611 0u, // baseArrayLayer
2615 if ((tcu::hasDepthComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
2616 || (tcu::hasStencilComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL))
2618 vk.cmdClearAttachments(commandBuffer, 1u, &attachment, 1u, &rect);
2622 vector<VkImageMemoryBarrier> selfDeps;
2623 VkPipelineStageFlags srcStages = 0;
2624 VkPipelineStageFlags dstStages = 0;
2626 for (deUint32 inputAttachmentNdx = 0; inputAttachmentNdx < m_renderInfo.getInputAttachmentCount(); inputAttachmentNdx++)
2628 for (deUint32 colorAttachmentNdx = 0; colorAttachmentNdx < m_renderInfo.getColorAttachmentCount(); colorAttachmentNdx++)
2630 if (m_renderInfo.getInputAttachmentIndex(inputAttachmentNdx) == m_renderInfo.getColorAttachmentIndex(colorAttachmentNdx))
2632 const VkImageMemoryBarrier barrier =
2634 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2637 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // srcAccessMask
2638 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT, // dstAccessMask
2640 VK_IMAGE_LAYOUT_GENERAL, // oldLayout
2641 VK_IMAGE_LAYOUT_GENERAL, // newLayout
2643 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex
2644 VK_QUEUE_FAMILY_IGNORED, // destQueueFamilyIndex
2646 m_colorAttachmentImages[colorAttachmentNdx], // image
2647 { // subresourceRange
2648 VK_IMAGE_ASPECT_COLOR_BIT, // aspect
2651 0, // baseArraySlice
2656 srcStages |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
2657 dstStages |= VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
2659 selfDeps.push_back(barrier);
2663 if (m_renderInfo.getDepthStencilAttachmentIndex() && (m_renderInfo.getInputAttachmentIndex(inputAttachmentNdx) == *m_renderInfo.getDepthStencilAttachmentIndex()))
2665 const tcu::TextureFormat format = mapVkFormat(m_renderInfo.getDepthStencilAttachment()->getFormat());
2666 const bool hasDepth = hasDepthComponent(format.order);
2667 const bool hasStencil = hasStencilComponent(format.order);
2668 const VkImageMemoryBarrier barrier =
2670 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
2673 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, // srcAccessMask
2674 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT, // dstAccessMask
2676 m_renderInfo.getInputAttachmentLayout(inputAttachmentNdx), // oldLayout
2677 m_renderInfo.getInputAttachmentLayout(inputAttachmentNdx), // newLayout;
2679 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex;
2680 VK_QUEUE_FAMILY_IGNORED, // destQueueFamilyIndex;
2682 m_depthStencilAttachmentImage, // image;
2683 { // subresourceRange;
2684 (hasDepth ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
2685 | (hasStencil ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u), // aspect;
2688 0, // baseArraySlice;
2693 srcStages |= VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT;
2694 dstStages |= VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
2696 selfDeps.push_back(barrier);
2700 if (!selfDeps.empty())
2702 DE_ASSERT(srcStages != 0);
2703 DE_ASSERT(dstStages != 0);
2704 vk.cmdPipelineBarrier(commandBuffer, srcStages, dstStages, VK_DEPENDENCY_BY_REGION_BIT, 0, DE_NULL, 0, DE_NULL, (deUint32)selfDeps.size(), &selfDeps[0]);
2707 if (m_renderInfo.getRenderQuad())
2709 const VkDeviceSize offset = 0;
2710 const VkBuffer vertexBuffer = *m_vertexBuffer;
2712 vk.cmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
2714 if (m_descriptorSet)
2716 const VkDescriptorSet descriptorSet = *m_descriptorSet;
2717 vk.cmdBindDescriptorSets(commandBuffer, vk::VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipelineLayout, 0u, 1u, &descriptorSet, 0u, NULL);
2720 vk.cmdBindVertexBuffers(commandBuffer, 0u, 1u, &vertexBuffer, &offset);
2721 vk.cmdDraw(commandBuffer, 6u, 1u, 0u, 0u);
2726 const SubpassRenderInfo m_renderInfo;
2727 Move<VkCommandBuffer> m_commandBuffer;
2728 Move<VkPipeline> m_pipeline;
2729 Move<VkDescriptorSetLayout> m_descriptorSetLayout;
2730 Move<VkPipelineLayout> m_pipelineLayout;
2732 Move<VkShaderModule> m_vertexShaderModule;
2733 Move<VkShaderModule> m_fragmentShaderModule;
2735 Move<VkDescriptorPool> m_descriptorPool;
2736 Move<VkDescriptorSet> m_descriptorSet;
2737 Move<VkBuffer> m_vertexBuffer;
2738 de::MovePtr<Allocation> m_vertexBufferMemory;
2739 vector<VkImage> m_colorAttachmentImages;
2740 VkImage m_depthStencilAttachmentImage;
2743 void pushImageInitializationCommands (const DeviceInterface& vk,
2744 VkCommandBuffer commandBuffer,
2745 const vector<Attachment>& attachmentInfo,
2746 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
2747 deUint32 queueIndex,
2748 const vector<Maybe<VkClearValue> >& clearValues)
2751 vector<VkImageMemoryBarrier> initializeLayouts;
2753 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2755 if (!clearValues[attachmentNdx])
2758 const VkImageMemoryBarrier barrier =
2760 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
2763 (VkAccessFlags)0, // srcAccessMask
2764 getAllMemoryReadFlags() | VK_ACCESS_TRANSFER_WRITE_BIT, // dstAccessMask
2766 VK_IMAGE_LAYOUT_UNDEFINED, // oldLayout
2767 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // newLayout;
2769 queueIndex, // srcQueueFamilyIndex;
2770 queueIndex, // destQueueFamilyIndex;
2772 attachmentResources[attachmentNdx]->getImage(), // image;
2773 { // subresourceRange;
2774 getImageAspectFlags(attachmentInfo[attachmentNdx].getFormat()), // aspect;
2777 0, // baseArraySlice;
2782 initializeLayouts.push_back(barrier);
2785 if (!initializeLayouts.empty())
2786 vk.cmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT,
2787 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, (VkDependencyFlags)0,
2788 0, (const VkMemoryBarrier*)DE_NULL,
2789 0, (const VkBufferMemoryBarrier*)DE_NULL,
2790 (deUint32)initializeLayouts.size(), &initializeLayouts[0]);
2793 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2795 if (!clearValues[attachmentNdx])
2798 const tcu::TextureFormat format = mapVkFormat(attachmentInfo[attachmentNdx].getFormat());
2800 if (hasStencilComponent(format.order) || hasDepthComponent(format.order))
2802 const float clearNan = tcu::Float32::nan().asFloat();
2803 const float clearDepth = hasDepthComponent(format.order) ? clearValues[attachmentNdx]->depthStencil.depth : clearNan;
2804 const deUint32 clearStencil = hasStencilComponent(format.order) ? clearValues[attachmentNdx]->depthStencil.stencil : 0xDEu;
2805 const VkClearDepthStencilValue depthStencil =
2810 const VkImageSubresourceRange range =
2812 (VkImageAspectFlags)((hasDepthComponent(format.order) ? VK_IMAGE_ASPECT_DEPTH_BIT : 0)
2813 | (hasStencilComponent(format.order) ? VK_IMAGE_ASPECT_STENCIL_BIT : 0)),
2820 vk.cmdClearDepthStencilImage(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &depthStencil, 1, &range);
2824 const VkImageSubresourceRange range =
2826 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask;
2829 0, // baseArrayLayer;
2832 const VkClearColorValue clearColor = clearValues[attachmentNdx]->color;
2834 vk.cmdClearColorImage(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clearColor, 1, &range);
2839 vector<VkImageMemoryBarrier> renderPassLayouts;
2841 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2843 const VkImageLayout oldLayout = clearValues[attachmentNdx] ? VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL : VK_IMAGE_LAYOUT_UNDEFINED;
2844 const VkImageMemoryBarrier barrier =
2846 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
2849 getMemoryFlagsForLayout(oldLayout), // srcAccessMask
2850 getAllMemoryReadFlags() | getMemoryFlagsForLayout(attachmentInfo[attachmentNdx].getInitialLayout()), // dstAccessMask
2852 oldLayout, // oldLayout
2853 attachmentInfo[attachmentNdx].getInitialLayout(), // newLayout;
2855 queueIndex, // srcQueueFamilyIndex;
2856 queueIndex, // destQueueFamilyIndex;
2858 attachmentResources[attachmentNdx]->getImage(), // image;
2859 { // subresourceRange;
2860 getImageAspectFlags(attachmentInfo[attachmentNdx].getFormat()), // aspect;
2863 0, // baseArraySlice;
2868 renderPassLayouts.push_back(barrier);
2871 if (!renderPassLayouts.empty())
2872 vk.cmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT,
2873 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, (VkDependencyFlags)0,
2874 0, (const VkMemoryBarrier*)DE_NULL,
2875 0, (const VkBufferMemoryBarrier*)DE_NULL,
2876 (deUint32)renderPassLayouts.size(), &renderPassLayouts[0]);
2880 template<typename RenderpassSubpass>
2881 void pushRenderPassCommands (const DeviceInterface& vk,
2882 VkCommandBuffer commandBuffer,
2883 VkRenderPass renderPass,
2884 VkFramebuffer framebuffer,
2885 const vector<de::SharedPtr<SubpassRenderer> >& subpassRenderers,
2886 const VkRect2D& renderArea,
2887 const vector<Maybe<VkClearValue> >& renderPassClearValues,
2888 TestConfig::RenderTypes render)
2890 const float clearNan = tcu::Float32::nan().asFloat();
2891 vector<VkClearValue> attachmentClearValues;
2892 const typename RenderpassSubpass::SubpassEndInfo subpassEndInfo (DE_NULL);
2894 for (size_t attachmentNdx = 0; attachmentNdx < renderPassClearValues.size(); attachmentNdx++)
2896 if (renderPassClearValues[attachmentNdx])
2897 attachmentClearValues.push_back(*renderPassClearValues[attachmentNdx]);
2899 attachmentClearValues.push_back(makeClearValueColorF32(clearNan, clearNan, clearNan, clearNan));
2903 for (size_t subpassNdx = 0; subpassNdx < subpassRenderers.size(); subpassNdx++)
2905 const VkSubpassContents contents = subpassRenderers[subpassNdx]->isSecondary() ? VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS : VK_SUBPASS_CONTENTS_INLINE;
2906 const typename RenderpassSubpass::SubpassBeginInfo subpassBeginInfo (DE_NULL, contents);
2907 const VkRenderPassBeginInfo renderPassBeginInfo = createRenderPassBeginInfo(renderPass,
2910 (deUint32)attachmentClearValues.size(),
2911 attachmentClearValues.empty() ? DE_NULL : &attachmentClearValues[0]);
2913 if (subpassNdx == 0)
2914 RenderpassSubpass::cmdBeginRenderPass(vk, commandBuffer, &renderPassBeginInfo, &subpassBeginInfo);
2916 RenderpassSubpass::cmdNextSubpass(vk, commandBuffer, &subpassBeginInfo, &subpassEndInfo);
2920 if (contents == VK_SUBPASS_CONTENTS_INLINE)
2922 subpassRenderers[subpassNdx]->pushRenderCommands(vk, commandBuffer);
2924 else if (contents == VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS)
2926 const VkCommandBuffer cmd = subpassRenderers[subpassNdx]->getCommandBuffer();
2927 vk.cmdExecuteCommands(commandBuffer, 1, &cmd);
2930 DE_FATAL("Invalid contents");
2934 RenderpassSubpass::cmdEndRenderPass(vk, commandBuffer, &subpassEndInfo);
2938 #ifndef CTS_USES_VULKANSC
2939 void pushDynamicRenderingCommands (const DeviceInterface& vk,
2940 VkCommandBuffer commandBuffer,
2941 const RenderPass& renderPassInfo,
2942 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
2943 const vector<de::SharedPtr<SubpassRenderer> >& subpassRenderers,
2944 const VkRect2D& renderArea,
2945 const vector<Maybe<VkClearValue> >& renderPassClearValues,
2946 deUint32 queueIndex,
2947 TestConfig::RenderTypes renderType,
2948 bool secondaryCmdBufferCompletelyContainsDynamicRenderpass)
2950 DE_ASSERT(subpassRenderers.size() == 1);
2952 vector<VkImageMemoryBarrier> imageBarriersBeforeRendering;
2953 vector<VkImageMemoryBarrier> imageBarriersAfterRendering;
2955 const Subpass& subpassInfo = renderPassInfo.getSubpasses()[0];
2956 const vector<AttachmentReference>& colorAttachmentsInfo = subpassInfo.getColorAttachments();
2958 for (deUint32 i = 0 ; i < colorAttachmentsInfo.size() ; ++i)
2960 const AttachmentReference& colorAttachmentReference = colorAttachmentsInfo[i];
2961 const deUint32 colorAttachmentIndex = colorAttachmentReference.getAttachment();
2962 const Attachment& colorAttachmentInfo = renderPassInfo.getAttachments()[colorAttachmentIndex];
2964 const VkImageLayout initialLayout = colorAttachmentInfo.getInitialLayout();
2965 const VkImageLayout renderingLayout = colorAttachmentReference.getImageLayout();
2966 const VkImageLayout finalLayout = colorAttachmentInfo.getFinalLayout();
2968 const VkImageMemoryBarrier barrierBeforeRendering
2970 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2973 getAllMemoryWriteFlags() | getMemoryFlagsForLayout(initialLayout), // srcAccessMask
2974 getMemoryFlagsForLayout(renderingLayout), // dstAccessMask
2976 initialLayout, // oldLayout
2977 renderingLayout, // newLayout
2979 queueIndex, // srcQueueFamilyIndex
2980 queueIndex, // destQueueFamilyIndex
2982 attachmentResources[colorAttachmentIndex]->getImage(), // image
2983 { // subresourceRange
2984 getImageAspectFlags(colorAttachmentInfo.getFormat()), // aspect;
2987 0, // baseArraySlice
2991 imageBarriersBeforeRendering.push_back(barrierBeforeRendering);
2993 const VkImageMemoryBarrier barrierAfterRendering
2995 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2998 getMemoryFlagsForLayout(renderingLayout), // srcAccessMask
2999 getAllMemoryReadFlags() | getMemoryFlagsForLayout(finalLayout), // dstAccessMask
3001 renderingLayout, // oldLayout
3002 finalLayout, // newLayout
3004 queueIndex, // srcQueueFamilyIndex
3005 queueIndex, // destQueueFamilyIndex
3007 attachmentResources[colorAttachmentIndex]->getImage(), // image
3008 { // subresourceRange
3009 getImageAspectFlags(colorAttachmentInfo.getFormat()), // aspect;
3012 0, // baseArraySlice
3016 imageBarriersAfterRendering.push_back(barrierAfterRendering);
3019 const AttachmentReference& depthStencilAttachmentReference = subpassInfo.getDepthStencilAttachment();
3020 const deUint32 dsAttachmentIndex = depthStencilAttachmentReference.getAttachment();
3022 if (dsAttachmentIndex != VK_ATTACHMENT_UNUSED)
3024 const Attachment& dsAttachmentInfo = renderPassInfo.getAttachments()[dsAttachmentIndex];
3026 const VkImageLayout initialLayout = dsAttachmentInfo.getInitialLayout();
3027 const VkImageLayout renderingLayout = depthStencilAttachmentReference.getImageLayout();
3028 const VkImageLayout finalLayout = dsAttachmentInfo.getFinalLayout();
3030 const VkImageMemoryBarrier barrierBeforeRendering
3032 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
3035 getAllMemoryWriteFlags() | getMemoryFlagsForLayout(initialLayout), // srcAccessMask
3036 getMemoryFlagsForLayout(renderingLayout), // dstAccessMask
3038 initialLayout, // oldLayout
3039 renderingLayout, // newLayout
3041 queueIndex, // srcQueueFamilyIndex
3042 queueIndex, // destQueueFamilyIndex
3044 attachmentResources[dsAttachmentIndex]->getImage(), // image
3045 { // subresourceRange
3046 getImageAspectFlags(dsAttachmentInfo.getFormat()), // aspect;
3049 0, // baseArraySlice
3053 imageBarriersBeforeRendering.push_back(barrierBeforeRendering);
3055 const VkImageMemoryBarrier barrierAfterRendering
3057 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
3060 getMemoryFlagsForLayout(renderingLayout), // srcAccessMask
3061 getAllMemoryReadFlags() | getMemoryFlagsForLayout(finalLayout), // dstAccessMask
3063 renderingLayout, // oldLayout
3064 finalLayout, // newLayout
3066 queueIndex, // srcQueueFamilyIndex
3067 queueIndex, // destQueueFamilyIndex
3069 attachmentResources[dsAttachmentIndex]->getImage(), // image
3070 { // subresourceRange
3071 getImageAspectFlags(dsAttachmentInfo.getFormat()), // aspect;
3074 0, // baseArraySlice
3078 imageBarriersAfterRendering.push_back(barrierAfterRendering);
3081 if (!imageBarriersBeforeRendering.empty())
3082 vk.cmdPipelineBarrier(commandBuffer,
3083 getAllPipelineStageFlags(),
3084 getAllPipelineStageFlags(),
3085 (VkDependencyFlags)0,
3086 0, (const VkMemoryBarrier*)DE_NULL,
3087 0, (const VkBufferMemoryBarrier*)DE_NULL,
3088 (deUint32)imageBarriersBeforeRendering.size(),
3089 &imageBarriersBeforeRendering[0]);
3091 bool executeRenderCommands = (renderType != TestConfig::RENDERTYPES_NONE);
3093 if (secondaryCmdBufferCompletelyContainsDynamicRenderpass)
3095 // when secondary command buffer completely contains dynamic renderpass
3096 // then we need to execute it even when render type is none
3097 executeRenderCommands = true;
3101 VkRenderingFlagsKHR renderingFlags = 0u;
3102 if (subpassRenderers[0]->isSecondary())
3103 renderingFlags = VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR;
3105 beginDynamicRendering(vk, commandBuffer, renderPassInfo, attachmentResources, renderArea, renderPassClearValues, renderingFlags);
3108 if (executeRenderCommands)
3110 if (subpassRenderers[0]->isSecondary())
3112 const VkCommandBuffer cmd = subpassRenderers[0]->getCommandBuffer();
3113 vk.cmdExecuteCommands(commandBuffer, 1, &cmd);
3116 subpassRenderers[0]->pushRenderCommands(vk, commandBuffer);
3119 if (!secondaryCmdBufferCompletelyContainsDynamicRenderpass)
3120 endDynamicRendering(vk, commandBuffer);
3122 if (!imageBarriersAfterRendering.empty())
3123 vk.cmdPipelineBarrier(commandBuffer,
3124 getAllPipelineStageFlags(),
3125 getAllPipelineStageFlags(),
3126 (VkDependencyFlags)0,
3127 0, (const VkMemoryBarrier*)DE_NULL,
3128 0, (const VkBufferMemoryBarrier*)DE_NULL,
3129 (deUint32)imageBarriersAfterRendering.size(),
3130 &imageBarriersAfterRendering[0]);
3132 #endif // CTS_USES_VULKANSC
3134 void pushRenderPassCommands (const DeviceInterface& vk,
3135 VkCommandBuffer commandBuffer,
3136 VkRenderPass renderPass,
3137 const RenderPass& renderPassInfo,
3138 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
3139 VkFramebuffer framebuffer,
3140 const vector<de::SharedPtr<SubpassRenderer> >& subpassRenderers,
3141 const VkRect2D& renderArea,
3142 const vector<Maybe<VkClearValue> >& renderPassClearValues,
3143 deUint32 queueIndex,
3144 TestConfig::RenderTypes render,
3145 RenderingType renderingType,
3146 bool secondaryCmdBufferCompletelyContainsDynamicRenderpass)
3148 // unreference arguments not used by Vulkan SC, no need to put them under ifdef
3149 DE_UNREF(renderPassInfo);
3150 DE_UNREF(attachmentResources);
3151 DE_UNREF(queueIndex);
3152 DE_UNREF(secondaryCmdBufferCompletelyContainsDynamicRenderpass);
3154 switch (renderingType)
3156 case RENDERING_TYPE_RENDERPASS_LEGACY:
3157 return pushRenderPassCommands<RenderpassSubpass1>(vk, commandBuffer, renderPass, framebuffer, subpassRenderers, renderArea, renderPassClearValues, render);
3158 case RENDERING_TYPE_RENDERPASS2:
3159 return pushRenderPassCommands<RenderpassSubpass2>(vk, commandBuffer, renderPass, framebuffer, subpassRenderers, renderArea, renderPassClearValues, render);
3161 #ifndef CTS_USES_VULKANSC
3162 case RENDERING_TYPE_DYNAMIC_RENDERING:
3163 return pushDynamicRenderingCommands(vk, commandBuffer, renderPassInfo, attachmentResources, subpassRenderers, renderArea, renderPassClearValues, queueIndex, render, secondaryCmdBufferCompletelyContainsDynamicRenderpass);
3164 #endif // CTS_USES_VULKANSC
3167 TCU_THROW(InternalError, "Impossible");
3171 void pushReadImagesToBuffers (const DeviceInterface& vk,
3172 VkCommandBuffer commandBuffer,
3173 deUint32 queueIndex,
3175 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
3176 const vector<Attachment>& attachmentInfo,
3177 const vector<bool>& isLazy,
3179 const UVec2& targetSize)
3182 vector<VkImageMemoryBarrier> imageBarriers;
3184 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
3186 if (isLazy[attachmentNdx])
3189 const VkImageLayout oldLayout = attachmentInfo[attachmentNdx].getFinalLayout();
3190 const VkImageMemoryBarrier barrier =
3192 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
3195 getAllMemoryWriteFlags() | getMemoryFlagsForLayout(oldLayout), // srcAccessMask
3196 getAllMemoryReadFlags(), // dstAccessMask
3198 oldLayout, // oldLayout
3199 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // newLayout
3201 queueIndex, // srcQueueFamilyIndex
3202 queueIndex, // destQueueFamilyIndex
3204 attachmentResources[attachmentNdx]->getImage(), // image
3205 { // subresourceRange
3206 getImageAspectFlags(attachmentInfo[attachmentNdx].getFormat()), // aspect;
3209 0, // baseArraySlice
3214 imageBarriers.push_back(barrier);
3217 if (!imageBarriers.empty())
3218 vk.cmdPipelineBarrier(commandBuffer,
3219 getAllPipelineStageFlags(),
3220 getAllPipelineStageFlags(),
3221 (VkDependencyFlags)0,
3222 0, (const VkMemoryBarrier*)DE_NULL,
3223 0, (const VkBufferMemoryBarrier*)DE_NULL,
3224 (deUint32)imageBarriers.size(), &imageBarriers[0]);
3227 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
3229 if (isLazy[attachmentNdx])
3232 const tcu::TextureFormat::ChannelOrder order = mapVkFormat(attachmentInfo[attachmentNdx].getFormat()).order;
3233 const VkBufferImageCopy rect =
3236 0, // bufferRowLength
3237 0, // bufferImageHeight
3238 { // imageSubresource
3239 (vk::VkImageAspectFlags)getPrimaryImageAspect(mapVkFormat(attachmentInfo[attachmentNdx].getFormat()).order), // aspect
3244 { 0, 0, 0 }, // imageOffset
3245 { targetSize.x(), targetSize.y(), 1u } // imageExtent
3248 vk.cmdCopyImageToBuffer(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, attachmentResources[attachmentNdx]->getBuffer(), 1, &rect);
3250 if (tcu::TextureFormat::DS == order)
3252 const VkBufferImageCopy stencilRect =
3255 0, // bufferRowLength
3256 0, // bufferImageHeight
3257 { // imageSubresource
3258 VK_IMAGE_ASPECT_STENCIL_BIT, // aspect
3263 { 0, 0, 0 }, // imageOffset
3264 { targetSize.x(), targetSize.y(), 1u } // imageExtent
3267 vk.cmdCopyImageToBuffer(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, attachmentResources[attachmentNdx]->getSecondaryBuffer(), 1, &stencilRect);
3272 vector<VkBufferMemoryBarrier> bufferBarriers;
3274 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
3276 if (isLazy[attachmentNdx])
3279 const tcu::TextureFormat::ChannelOrder order = mapVkFormat(attachmentInfo[attachmentNdx].getFormat()).order;
3280 const VkBufferMemoryBarrier bufferBarrier =
3282 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
3285 getAllMemoryWriteFlags(),
3286 getAllMemoryReadFlags(),
3291 attachmentResources[attachmentNdx]->getBuffer(),
3293 attachmentResources[attachmentNdx]->getBufferSize()
3296 bufferBarriers.push_back(bufferBarrier);
3298 if (tcu::TextureFormat::DS == order)
3300 const VkBufferMemoryBarrier secondaryBufferBarrier =
3302 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
3305 getAllMemoryWriteFlags(),
3306 getAllMemoryReadFlags(),
3311 attachmentResources[attachmentNdx]->getSecondaryBuffer(),
3313 attachmentResources[attachmentNdx]->getSecondaryBufferSize()
3316 bufferBarriers.push_back(secondaryBufferBarrier);
3320 if (!bufferBarriers.empty())
3321 vk.cmdPipelineBarrier(commandBuffer,
3322 getAllPipelineStageFlags(),
3323 getAllPipelineStageFlags(),
3324 (VkDependencyFlags)0,
3325 0, (const VkMemoryBarrier*)DE_NULL,
3326 (deUint32)bufferBarriers.size(), &bufferBarriers[0],
3327 0, (const VkImageMemoryBarrier*)DE_NULL);
3334 PixelValue (const Maybe<bool>& x = tcu::Nothing,
3335 const Maybe<bool>& y = tcu::Nothing,
3336 const Maybe<bool>& z = tcu::Nothing,
3337 const Maybe<bool>& w = tcu::Nothing);
3339 void setUndefined (size_t ndx);
3340 void setValue (size_t ndx, bool value);
3341 Maybe<bool> getValue (size_t ndx) const;
3347 PixelValue::PixelValue (const Maybe<bool>& x,
3348 const Maybe<bool>& y,
3349 const Maybe<bool>& z,
3350 const Maybe<bool>& w)
3353 const Maybe<bool> values[] =
3358 for (size_t ndx = 0; ndx < DE_LENGTH_OF_ARRAY(values); ndx++)
3361 setValue(ndx, *values[ndx]);
3366 DE_ASSERT(m_status <= 0xFFu);
3369 void PixelValue::setUndefined (size_t ndx)
3372 DE_ASSERT(m_status <= 0xFFu);
3374 m_status &= (deUint16)~(0x1u << (deUint16)(ndx * 2));
3375 DE_ASSERT(m_status <= 0xFFu);
3378 void PixelValue::setValue (size_t ndx, bool value)
3381 DE_ASSERT(m_status <= 0xFFu);
3383 m_status = (deUint16)(m_status | (deUint16)(0x1u << (ndx * 2)));
3386 m_status = (deUint16)(m_status | (deUint16)(0x1u << (ndx * 2 + 1)));
3388 m_status &= (deUint16)~(0x1u << (deUint16)(ndx * 2 + 1));
3390 DE_ASSERT(m_status <= 0xFFu);
3393 Maybe<bool> PixelValue::getValue (size_t ndx) const
3396 DE_ASSERT(m_status <= 0xFFu);
3398 if ((m_status & (0x1u << (deUint16)(ndx * 2))) != 0)
3400 return just((m_status & (0x1u << (deUint32)(ndx * 2 + 1))) != 0);
3403 return tcu::Nothing;
3406 void clearReferenceValues (vector<PixelValue>& values,
3407 const UVec2& targetSize,
3408 const UVec2& offset,
3411 const PixelValue& value)
3413 DE_ASSERT(targetSize.x() * targetSize.y() == (deUint32)values.size());
3414 DE_ASSERT(offset.x() + size.x() <= targetSize.x());
3415 DE_ASSERT(offset.y() + size.y() <= targetSize.y());
3417 for (deUint32 y = offset.y(); y < offset.y() + size.y(); y++)
3418 for (deUint32 x = offset.x(); x < offset.x() + size.x(); x++)
3420 for (int compNdx = 0; compNdx < 4; compNdx++)
3424 if (value.getValue(compNdx))
3425 values[x + y * targetSize.x()].setValue(compNdx, *value.getValue(compNdx));
3427 values[x + y * targetSize.x()].setUndefined(compNdx);
3433 void markUndefined (vector<PixelValue>& values,
3435 const UVec2& targetSize,
3436 const UVec2& offset,
3439 DE_ASSERT(targetSize.x() * targetSize.y() == (deUint32)values.size());
3441 for (deUint32 y = offset.y(); y < offset.y() + size.y(); y++)
3442 for (deUint32 x = offset.x(); x < offset.x() + size.x(); x++)
3444 for (int compNdx = 0; compNdx < 4; compNdx++)
3447 values[x + y * targetSize.x()].setUndefined(compNdx);
3452 PixelValue clearValueToPixelValue (const VkClearValue& value,
3453 const tcu::TextureFormat& format,
3454 const DepthValuesArray& depthValues)
3456 const bool isDepthAttachment = hasDepthComponent(format.order);
3457 const bool isStencilAttachment = hasStencilComponent(format.order);
3458 const bool isDepthOrStencilAttachment = isDepthAttachment || isStencilAttachment;
3459 PixelValue pixelValue;
3461 if (isDepthOrStencilAttachment)
3463 if (isDepthAttachment)
3465 if (value.depthStencil.depth == float(depthValues[1]) / 255.0f)
3466 pixelValue.setValue(0, true);
3467 else if (value.depthStencil.depth == float(depthValues[0]) / 255.0f)
3468 pixelValue.setValue(0, false);
3470 DE_FATAL("Unknown depth value");
3473 if (isStencilAttachment)
3475 if (value.depthStencil.stencil == 0xFFu)
3476 pixelValue.setValue(1, true);
3477 else if (value.depthStencil.stencil == 0x0u)
3478 pixelValue.setValue(1, false);
3480 DE_FATAL("Unknown stencil value");
3485 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
3486 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
3488 switch (channelClass)
3490 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
3491 for (int i = 0; i < 4; i++)
3495 if (value.color.int32[i] == 1)
3496 pixelValue.setValue(i, true);
3497 else if (value.color.int32[i] == 0)
3498 pixelValue.setValue(i, false);
3500 DE_FATAL("Unknown clear color value");
3505 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
3506 for (int i = 0; i < 4; i++)
3510 if (value.color.uint32[i] == 1u)
3511 pixelValue.setValue(i, true);
3512 else if (value.color.uint32[i] == 0u)
3513 pixelValue.setValue(i, false);
3515 DE_FATAL("Unknown clear color value");
3520 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
3521 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
3522 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
3523 for (int i = 0; i < 4; i++)
3527 if (value.color.float32[i] == 1.0f)
3528 pixelValue.setValue(i, true);
3529 else if (value.color.float32[i] == 0.0f)
3530 pixelValue.setValue(i, false);
3532 DE_FATAL("Unknown clear color value");
3538 DE_FATAL("Unknown channel class");
3545 void renderReferenceValues (vector<vector<PixelValue> >& referenceAttachments,
3546 const RenderPass& renderPassInfo,
3547 const UVec2& targetSize,
3548 const vector<Maybe<VkClearValue> >& imageClearValues,
3549 const vector<Maybe<VkClearValue> >& renderPassClearValues,
3550 const vector<SubpassRenderInfo>& subpassRenderInfo,
3551 const UVec2& renderPos,
3552 const UVec2& renderSize,
3553 const deUint32 drawStartNdx,
3554 const DepthValuesArray& depthValues)
3556 const vector<Subpass>& subpasses = renderPassInfo.getSubpasses();
3557 vector<bool> attachmentUsed (renderPassInfo.getAttachments().size(), false);
3559 referenceAttachments.resize(renderPassInfo.getAttachments().size());
3561 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
3563 const Attachment attachment = renderPassInfo.getAttachments()[attachmentNdx];
3564 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3565 vector<PixelValue>& reference = referenceAttachments[attachmentNdx];
3567 reference.resize(targetSize.x() * targetSize.y());
3569 if (imageClearValues[attachmentNdx])
3570 clearReferenceValues(reference, targetSize, UVec2(0, 0), targetSize, BVec4(true), clearValueToPixelValue(*imageClearValues[attachmentNdx], format, depthValues));
3573 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
3575 const Subpass& subpass = subpasses[subpassNdx];
3576 const SubpassRenderInfo& renderInfo = subpassRenderInfo[subpassNdx];
3577 const vector<AttachmentReference>& colorAttachments = subpass.getColorAttachments();
3579 // Apply load op if attachment was used for the first time
3580 for (size_t attachmentNdx = 0; attachmentNdx < colorAttachments.size(); attachmentNdx++)
3582 const deUint32 attachmentIndex = getAttachmentNdx(colorAttachments, attachmentNdx);
3584 if (!attachmentUsed[attachmentIndex] && colorAttachments[attachmentNdx].getAttachment() != VK_ATTACHMENT_UNUSED)
3586 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3587 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3588 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3590 DE_ASSERT(!tcu::hasDepthComponent(format.order));
3591 DE_ASSERT(!tcu::hasStencilComponent(format.order));
3593 if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
3594 clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(true), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format, depthValues));
3595 else if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
3596 markUndefined(reference, BVec4(true), targetSize, renderPos, renderSize);
3598 attachmentUsed[attachmentIndex] = true;
3602 // Apply load op to depth/stencil attachment if it was used for the first time
3603 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
3605 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3607 // Apply load op if attachment was used for the first time
3608 if (!attachmentUsed[attachmentIndex])
3610 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3611 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3612 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3614 if (tcu::hasDepthComponent(format.order))
3616 if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
3617 clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(true, false, false, false), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format, depthValues));
3618 else if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
3619 markUndefined(reference, BVec4(true, false, false, false), targetSize, renderPos, renderSize);
3622 if (tcu::hasStencilComponent(format.order))
3624 if (attachment.getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
3625 clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(false, true, false, false), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format, depthValues));
3626 else if (attachment.getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
3627 markUndefined(reference, BVec4(false, true, false, false), targetSize, renderPos, renderSize);
3630 attachmentUsed[attachmentIndex] = true;
3634 for (size_t colorClearNdx = 0; colorClearNdx < renderInfo.getColorClears().size(); colorClearNdx++)
3636 const ColorClear& colorClear = renderInfo.getColorClears()[colorClearNdx];
3637 const UVec2 offset = colorClear.getOffset();
3638 const UVec2 size = colorClear.getSize();
3639 const deUint32 attachmentIndex = subpass.getColorAttachments()[colorClearNdx].getAttachment();
3640 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3641 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3642 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3645 value.color = colorClear.getColor();
3647 clearReferenceValues(reference, targetSize, offset, size, BVec4(true), clearValueToPixelValue(value, format, depthValues));
3650 if (renderInfo.getDepthStencilClear())
3652 const DepthStencilClear& dsClear = *renderInfo.getDepthStencilClear();
3653 const UVec2 offset = dsClear.getOffset();
3654 const UVec2 size = dsClear.getSize();
3655 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3656 const VkImageLayout layout = subpass.getDepthStencilAttachment().getImageLayout();
3657 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3658 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3659 const bool hasStencil = tcu::hasStencilComponent(format.order)
3660 && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL;
3661 const bool hasDepth = tcu::hasDepthComponent(format.order)
3662 && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
3663 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3666 value.depthStencil.depth = dsClear.getDepth();
3667 value.depthStencil.stencil = dsClear.getStencil();
3669 clearReferenceValues(reference, targetSize, offset, size, BVec4(hasDepth, hasStencil, false, false), clearValueToPixelValue(value, format, depthValues));
3672 if (renderInfo.getRenderQuad())
3674 const RenderQuad& renderQuad = *renderInfo.getRenderQuad();
3675 const Vec2 posA = renderQuad.getCornerA();
3676 const Vec2 posB = renderQuad.getCornerB();
3677 const Vec2 origin = Vec2((float)renderInfo.getViewportOffset().x(), (float)renderInfo.getViewportOffset().y()) + Vec2((float)renderInfo.getViewportSize().x(), (float)renderInfo.getViewportSize().y()) / Vec2(2.0f);
3678 const Vec2 p = Vec2((float)renderInfo.getViewportSize().x(), (float)renderInfo.getViewportSize().y()) / Vec2(2.0f);
3679 const IVec2 posAI (deRoundFloatToInt32(origin.x() + (p.x() * posA.x())),
3680 deRoundFloatToInt32(origin.y() + (p.y() * posA.y())));
3681 const IVec2 posBI (deRoundFloatToInt32(origin.x() + (p.x() * posB.x())),
3682 deRoundFloatToInt32(origin.y() + (p.y() * posB.y())));
3684 DE_ASSERT(posAI.x() < posBI.x());
3685 DE_ASSERT(posAI.y() < posBI.y());
3687 if (subpass.getInputAttachments().empty())
3689 for (size_t attachmentRefNdx = drawStartNdx; attachmentRefNdx < subpass.getColorAttachments().size(); attachmentRefNdx++)
3691 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentRefNdx].getAttachment();
3693 if (attachmentIndex == VK_ATTACHMENT_UNUSED)
3696 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3697 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3698 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
3699 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3701 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3702 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3704 for (int compNdx = 0; compNdx < 4; compNdx++)
3706 const size_t index = subpassNdx + attachmentIndex + compNdx;
3707 const BoolOp op = boolOpFromIndex(index);
3708 const bool boolX = x % 2 == (int)(index % 2);
3709 const bool boolY = y % 2 == (int)((index / 2) % 2);
3711 if (channelMask[compNdx])
3712 reference[x + y * targetSize.x()].setValue(compNdx, performBoolOp(op, boolX, boolY));
3717 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
3719 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3720 const VkImageLayout layout = subpass.getDepthStencilAttachment().getImageLayout();
3721 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3722 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3723 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3725 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3726 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3728 if (tcu::hasDepthComponent(format.order)
3729 && layout != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3730 && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
3732 const size_t index = subpassNdx + 1;
3733 const BoolOp op = boolOpFromIndex(index);
3734 const bool boolX = x % 2 == (int)(index % 2);
3735 const bool boolY = y % 2 == (int)((index / 2) % 2);
3737 reference[x + y * targetSize.x()].setValue(0, performBoolOp(op, boolX, boolY));
3740 if (tcu::hasStencilComponent(format.order)
3741 && layout != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3742 && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
3744 const size_t index = subpassNdx;
3745 reference[x + y * targetSize.x()].setValue(1, (index % 2) == 0);
3752 size_t outputComponentCount = 0;
3753 vector<Maybe<bool> > inputs;
3755 DE_ASSERT(posAI.x() < posBI.x());
3756 DE_ASSERT(posAI.y() < posBI.y());
3758 for (size_t attachmentRefNdx = 0; attachmentRefNdx < subpass.getColorAttachments().size(); attachmentRefNdx++)
3760 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentRefNdx].getAttachment();
3761 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3762 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3763 const int componentCount = tcu::getNumUsedChannels(format.order);
3765 outputComponentCount += (size_t)componentCount;
3768 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3769 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3770 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
3772 const Attachment& attachment (renderPassInfo.getAttachments()[subpass.getDepthStencilAttachment().getAttachment()]);
3773 const tcu::TextureFormat format (mapVkFormat(attachment.getFormat()));
3775 if (tcu::hasDepthComponent(format.order))
3776 outputComponentCount++;
3779 if (outputComponentCount > 0)
3781 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3782 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3784 for (size_t inputAttachmentNdx = 0; inputAttachmentNdx < subpass.getInputAttachments().size(); inputAttachmentNdx++)
3786 const deUint32 attachmentIndex = subpass.getInputAttachments()[inputAttachmentNdx].getAttachment();
3787 const VkImageLayout layout = subpass.getInputAttachments()[inputAttachmentNdx].getImageLayout();
3788 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3789 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3790 const int componentCount = tcu::getNumUsedChannels(format.order);
3792 for (int compNdx = 0; compNdx < componentCount; compNdx++)
3794 if ((compNdx != 0 || layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
3795 && (compNdx != 1 || layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL))
3797 inputs.push_back(referenceAttachments[attachmentIndex][x + y * targetSize.x()].getValue(compNdx));
3802 const size_t inputsPerOutput = inputs.size() >= outputComponentCount
3803 ? ((inputs.size() / outputComponentCount)
3804 + ((inputs.size() % outputComponentCount) != 0 ? 1 : 0))
3807 size_t outputValueNdx = 0;
3809 for (size_t attachmentRefNdx = 0; attachmentRefNdx < subpass.getColorAttachments().size(); attachmentRefNdx++)
3811 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentRefNdx].getAttachment();
3812 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3813 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3814 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3815 const int componentCount = tcu::getNumUsedChannels(format.order);
3817 for (int compNdx = 0; compNdx < componentCount; compNdx++)
3819 const size_t index = subpassNdx + attachmentIndex + outputValueNdx;
3820 const BoolOp op = boolOpFromIndex(index);
3821 const bool boolX = x % 2 == (int)(index % 2);
3822 const bool boolY = y % 2 == (int)((index / 2) % 2);
3823 Maybe<bool> output = tcu::just(performBoolOp(op, boolX, boolY));
3825 for (size_t i = 0; i < inputsPerOutput; i++)
3829 else if (!inputs[((outputValueNdx + compNdx) * inputsPerOutput + i) % inputs.size()])
3830 output = tcu::Nothing;
3832 output = (*output) == (*inputs[((outputValueNdx + compNdx) * inputsPerOutput + i) % inputs.size()]);
3836 reference[x + y * targetSize.x()].setValue(compNdx, *output);
3838 reference[x + y * targetSize.x()].setUndefined(compNdx);
3841 outputValueNdx += componentCount;
3844 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3845 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3846 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
3848 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3849 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3850 const size_t index = subpassNdx + attachmentIndex;
3851 const BoolOp op = boolOpFromIndex(index);
3852 const bool boolX = x % 2 == (int)(index % 2);
3853 const bool boolY = y % 2 == (int)((index / 2) % 2);
3854 Maybe<bool> output = tcu::just(performBoolOp(op, boolX, boolY));
3856 for (size_t i = 0; i < inputsPerOutput; i++)
3860 else if (inputs[(outputValueNdx * inputsPerOutput + i) % inputs.size()])
3861 output = (*output) == (*inputs[(outputValueNdx * inputsPerOutput + i) % inputs.size()]);
3863 output = tcu::Nothing;
3867 reference[x + y * targetSize.x()].setValue(0, *output);
3869 reference[x + y * targetSize.x()].setUndefined(0);
3876 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3877 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3878 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
3880 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3881 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3882 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3883 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3885 if (tcu::hasStencilComponent(format.order))
3887 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3888 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3890 const size_t index = subpassNdx;
3891 reference[x + y * targetSize.x()].setValue(1, (index % 2) == 0);
3899 // Mark all attachments that were used but not stored as undefined
3900 for (size_t attachmentIndex = 0; attachmentIndex < renderPassInfo.getAttachments().size(); attachmentIndex++)
3902 const Attachment attachment = renderPassInfo.getAttachments()[attachmentIndex];
3903 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3904 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3905 const bool isStencilAttachment = hasStencilComponent(format.order);
3906 const bool isDepthOrStencilAttachment = hasDepthComponent(format.order) || isStencilAttachment;
3908 if (attachmentUsed[attachmentIndex] && renderPassInfo.getAttachments()[attachmentIndex].getStoreOp() == VK_ATTACHMENT_STORE_OP_DONT_CARE)
3910 if (isDepthOrStencilAttachment)
3911 markUndefined(reference, BVec4(true, false, false, false), targetSize, renderPos, renderSize);
3913 markUndefined(reference, BVec4(true), targetSize, renderPos, renderSize);
3916 if (attachmentUsed[attachmentIndex] && isStencilAttachment && renderPassInfo.getAttachments()[attachmentIndex].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_DONT_CARE)
3917 markUndefined(reference, BVec4(false, true, false, false), targetSize, renderPos, renderSize);
3921 void renderReferenceImagesFromValues (vector<tcu::TextureLevel>& referenceImages,
3922 const vector<vector<PixelValue> >& referenceValues,
3923 const UVec2& targetSize,
3924 const RenderPass& renderPassInfo,
3925 const DepthValuesArray& depthValues)
3927 referenceImages.resize(referenceValues.size());
3929 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
3931 const Attachment attachment = renderPassInfo.getAttachments()[attachmentNdx];
3932 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3933 const vector<PixelValue>& reference = referenceValues[attachmentNdx];
3934 const bool hasDepth = tcu::hasDepthComponent(format.order);
3935 const bool hasStencil = tcu::hasStencilComponent(format.order);
3936 const bool hasDepthOrStencil = hasDepth || hasStencil;
3937 tcu::TextureLevel& referenceImage = referenceImages[attachmentNdx];
3939 referenceImage.setStorage(format, targetSize.x(), targetSize.y());
3941 if (hasDepthOrStencil)
3945 const PixelBufferAccess depthAccess (tcu::getEffectiveDepthStencilAccess(referenceImage.getAccess(), tcu::Sampler::MODE_DEPTH));
3947 for (deUint32 y = 0; y < targetSize.y(); y++)
3948 for (deUint32 x = 0; x < targetSize.x(); x++)
3950 if (reference[x + y * targetSize.x()].getValue(0))
3952 if (*reference[x + y * targetSize.x()].getValue(0))
3953 depthAccess.setPixDepth(float(depthValues[1]) / 255.0f, x, y);
3955 depthAccess.setPixDepth(float(depthValues[0]) / 255.0f, x, y);
3957 else // Fill with 3x3 grid
3958 depthAccess.setPixDepth(((x / 3) % 2) == ((y / 3) % 2) ? 0.33f : 0.66f, x, y);
3964 const PixelBufferAccess stencilAccess (tcu::getEffectiveDepthStencilAccess(referenceImage.getAccess(), tcu::Sampler::MODE_STENCIL));
3966 for (deUint32 y = 0; y < targetSize.y(); y++)
3967 for (deUint32 x = 0; x < targetSize.x(); x++)
3969 if (reference[x + y * targetSize.x()].getValue(1))
3971 if (*reference[x + y * targetSize.x()].getValue(1))
3972 stencilAccess.setPixStencil(0xFFu, x, y);
3974 stencilAccess.setPixStencil(0x0u, x, y);
3976 else // Fill with 3x3 grid
3977 stencilAccess.setPixStencil(((x / 3) % 2) == ((y / 3) % 2) ? 85 : 170, x, y);
3983 for (deUint32 y = 0; y < targetSize.y(); y++)
3984 for (deUint32 x = 0; x < targetSize.x(); x++)
3988 for (int compNdx = 0; compNdx < 4; compNdx++)
3990 if (reference[x + y * targetSize.x()].getValue(compNdx))
3992 if (*reference[x + y * targetSize.x()].getValue(compNdx))
3993 color[compNdx] = 1.0f;
3995 color[compNdx] = 0.0f;
3997 else // Fill with 3x3 grid
3998 color[compNdx] = ((compNdx + (x / 3)) % 2) == ((y / 3) % 2) ? 0.33f : 0.66f;
4001 referenceImage.getAccess().setPixel(color, x, y);
4007 bool verifyColorAttachment (const vector<PixelValue>& reference,
4008 const ConstPixelBufferAccess& result,
4009 const PixelBufferAccess& errorImage,
4010 const deBool useFormatCompCount)
4012 const Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
4013 const Vec4 green (0.0f, 1.0f, 0.0f, 1.0f);
4016 DE_ASSERT(result.getWidth() * result.getHeight() == (int)reference.size());
4017 DE_ASSERT(result.getWidth() == errorImage.getWidth());
4018 DE_ASSERT(result.getHeight() == errorImage.getHeight());
4020 for (int y = 0; y < result.getHeight(); y++)
4021 for (int x = 0; x < result.getWidth(); x++)
4023 const Vec4 resultColor = result.getPixel(x, y);
4024 const PixelValue& referenceValue = reference[x + y * result.getWidth()];
4025 bool pixelOk = true;
4026 const deUint32 componentCount = useFormatCompCount ? (deUint32)tcu::getNumUsedChannels(result.getFormat().order) : 4;
4028 for (deUint32 compNdx = 0; compNdx < componentCount; compNdx++)
4030 const Maybe<bool> maybeValue = referenceValue.getValue(compNdx);
4034 const bool value = *maybeValue;
4036 if ((value && (resultColor[compNdx] != 1.0f))
4037 || (!value && resultColor[compNdx] != 0.0f))
4044 errorImage.setPixel(red, x, y);
4048 errorImage.setPixel(green, x, y);
4054 // Setting the alpha value to 1.0f by default helps visualization when the alpha channel is not used.
4055 const tcu::Vec4 kDefaultColorForLog {0.0f, 0.0f, 0.0f, 1.0f};
4056 const float kTrueComponent = 1.0f;
4057 const float kFalseComponent = 0.5f;
4058 const float kUnsetComponentLow = 0.0f;
4059 const float kUnsetComponentHigh = 0.25f;
4061 std::unique_ptr<tcu::TextureLevel> renderColorImageForLog (const ConstPixelBufferAccess& image, int numChannels)
4063 // Same channel order, but using UNORM_INT8 for the color format.
4064 const auto order = image.getFormat().order;
4065 const tcu::TextureFormat loggableFormat {order, tcu::TextureFormat::UNORM_INT8};
4066 const int width = image.getWidth();
4067 const int height = image.getHeight();
4068 std::unique_ptr<tcu::TextureLevel> result {new tcu::TextureLevel{loggableFormat, width, height}};
4069 auto access = result->getAccess();
4070 tcu::Vec4 outColor = kDefaultColorForLog;
4072 for (int x = 0; x < width; ++x)
4073 for (int y = 0; y < height; ++y)
4075 const auto value = image.getPixel(x, y);
4076 for (int c = 0; c < numChannels; ++c)
4078 if (value[c] == 0.0f)
4079 outColor[c] = kFalseComponent;
4080 else if (value[c] == 1.0f)
4081 outColor[c] = kTrueComponent;
4085 access.setPixel(outColor, x, y);
4091 std::unique_ptr<tcu::TextureLevel> renderColorImageForLog (const vector<PixelValue>& reference, const UVec2& targetSize, int numChannels)
4093 const tcu::TextureFormat loggableFormat {tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8};
4094 const int width = static_cast<int>(targetSize.x());
4095 const int height = static_cast<int>(targetSize.y());
4096 std::unique_ptr<tcu::TextureLevel> result {new tcu::TextureLevel{loggableFormat, width, height}};
4097 auto access = result->getAccess();
4098 tcu::Vec4 outColor = kDefaultColorForLog;
4100 for (int x = 0; x < width; ++x)
4101 for (int y = 0; y < height; ++y)
4103 const int index = x + y * width;
4104 for (int c = 0; c < numChannels; ++c)
4106 const auto maybeValue = reference[index].getValue(c);
4108 outColor[c] = ((*maybeValue) ? kTrueComponent : kFalseComponent);
4110 outColor[c] = ((((x / 3) % 2) == ((y / 3) % 2)) ? kUnsetComponentLow : kUnsetComponentHigh);
4112 access.setPixel(outColor, x, y);
4118 bool verifyDepthAttachment (const vector<PixelValue>& reference,
4119 const ConstPixelBufferAccess& result,
4120 const PixelBufferAccess& errorImage,
4121 const DepthValuesArray& depthValues,
4124 const Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
4125 const Vec4 green (0.0f, 1.0f, 0.0f, 1.0f);
4128 DE_ASSERT(result.getWidth() * result.getHeight() == (int)reference.size());
4129 DE_ASSERT(result.getWidth() == errorImage.getWidth());
4130 DE_ASSERT(result.getHeight() == errorImage.getHeight());
4132 for (int y = 0; y < result.getHeight(); y++)
4133 for (int x = 0; x < result.getWidth(); x++)
4135 bool pixelOk = true;
4137 const float resultDepth = result.getPixDepth(x, y);
4138 const PixelValue& referenceValue = reference[x + y * result.getWidth()];
4139 const Maybe<bool> maybeValue = referenceValue.getValue(0);
4143 const bool value = *maybeValue;
4145 if ((value && !depthsEqual(resultDepth, float(depthValues[1]) / 255.0f, epsilon))
4146 || (!value && !depthsEqual(resultDepth, float(depthValues[0]) / 255.0f, epsilon)))
4152 errorImage.setPixel(red, x, y);
4156 errorImage.setPixel(green, x, y);
4162 bool verifyStencilAttachment (const vector<PixelValue>& reference,
4163 const ConstPixelBufferAccess& result,
4164 const PixelBufferAccess& errorImage)
4166 const Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
4167 const Vec4 green (0.0f, 1.0f, 0.0f, 1.0f);
4170 DE_ASSERT(result.getWidth() * result.getHeight() == (int)reference.size());
4171 DE_ASSERT(result.getWidth() == errorImage.getWidth());
4172 DE_ASSERT(result.getHeight() == errorImage.getHeight());
4174 for (int y = 0; y < result.getHeight(); y++)
4175 for (int x = 0; x < result.getWidth(); x++)
4177 bool pixelOk = true;
4179 const deUint32 resultStencil = result.getPixStencil(x, y);
4180 const PixelValue& referenceValue = reference[x + y * result.getWidth()];
4181 const Maybe<bool> maybeValue = referenceValue.getValue(1);
4185 const bool value = *maybeValue;
4187 if ((value && (resultStencil != 0xFFu))
4188 || (!value && resultStencil != 0x0u))
4194 errorImage.setPixel(red, x, y);
4198 errorImage.setPixel(green, x, y);
4204 bool logAndVerifyImages (TestLog& log,
4205 const DeviceInterface& vk,
4207 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
4208 const vector<bool>& attachmentIsLazy,
4209 const RenderPass& renderPassInfo,
4210 const vector<Maybe<VkClearValue> >& renderPassClearValues,
4211 const vector<Maybe<VkClearValue> >& imageClearValues,
4212 const vector<SubpassRenderInfo>& subpassRenderInfo,
4213 const UVec2& targetSize,
4214 const TestConfig& config)
4216 vector<vector<PixelValue> > referenceValues;
4217 vector<tcu::TextureLevel> referenceAttachments;
4220 log << TestLog::Message << "Reference images fill undefined pixels with 3x3 grid pattern." << TestLog::EndMessage;
4222 renderReferenceValues(referenceValues, renderPassInfo, targetSize, imageClearValues, renderPassClearValues, subpassRenderInfo, config.renderPos, config.renderSize, config.drawStartNdx, config.depthValues);
4223 renderReferenceImagesFromValues(referenceAttachments, referenceValues, targetSize, renderPassInfo, config.depthValues);
4225 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
4227 if (!attachmentIsLazy[attachmentNdx])
4229 bool attachmentOK = true;
4230 const Attachment attachment = renderPassInfo.getAttachments()[attachmentNdx];
4231 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4233 if (tcu::hasDepthComponent(format.order) && tcu::hasStencilComponent(format.order))
4235 const tcu::TextureFormat depthFormat = getDepthCopyFormat(attachment.getFormat());
4236 void* const depthPtr = attachmentResources[attachmentNdx]->getResultMemory().getHostPtr();
4238 const tcu::TextureFormat stencilFormat = getStencilCopyFormat(attachment.getFormat());
4239 void* const stencilPtr = attachmentResources[attachmentNdx]->getSecondaryResultMemory().getHostPtr();
4241 invalidateAlloc(vk, device, attachmentResources[attachmentNdx]->getResultMemory());
4242 invalidateAlloc(vk, device, attachmentResources[attachmentNdx]->getSecondaryResultMemory());
4245 bool depthOK = true;
4246 bool stencilOK = true;
4247 const ConstPixelBufferAccess depthAccess (depthFormat, targetSize.x(), targetSize.y(), 1, depthPtr);
4248 const ConstPixelBufferAccess stencilAccess (stencilFormat, targetSize.x(), targetSize.y(), 1, stencilPtr);
4249 tcu::TextureLevel depthErrorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
4250 tcu::TextureLevel stencilErrorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
4252 if (renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE
4253 && !verifyDepthAttachment(referenceValues[attachmentNdx], depthAccess, depthErrorImage.getAccess(), config.depthValues, requiredDepthEpsilon(attachment.getFormat())))
4258 if (renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE
4259 && !verifyStencilAttachment(referenceValues[attachmentNdx], stencilAccess, stencilErrorImage.getAccess()))
4264 if (!depthOK || !stencilOK)
4266 const auto attachmentNdxStr = de::toString(attachmentNdx);
4269 log << TestLog::ImageSet("OutputAttachments" + attachmentNdxStr, "Output depth and stencil attachments " + attachmentNdxStr);
4270 log << TestLog::Image("Attachment" + attachmentNdxStr + "Depth", "Attachment " + attachmentNdxStr + " Depth", depthAccess);
4271 log << TestLog::Image("Attachment" + attachmentNdxStr + "Stencil", "Attachment " + attachmentNdxStr + " Stencil", stencilAccess);
4272 log << TestLog::EndImageSet;
4274 // Reference images. These will be logged as image sets due to having depth and stencil aspects.
4275 log << TestLog::Image("AttachmentReferences" + attachmentNdxStr, "Reference images " + attachmentNdxStr, referenceAttachments[attachmentNdx].getAccess());
4278 log << TestLog::ImageSet("ErrorMasks" + attachmentNdxStr, "Error masks " + attachmentNdxStr);
4280 log << TestLog::Image("DepthAttachmentError" + attachmentNdxStr, "Depth Attachment Error " + attachmentNdxStr, depthErrorImage.getAccess());
4282 log << TestLog::Image("StencilAttachmentError" + attachmentNdxStr, "Stencil Attachment Error " + attachmentNdxStr, stencilErrorImage.getAccess());
4283 log << TestLog::EndImageSet;
4285 attachmentOK = false;
4291 void* const ptr = attachmentResources[attachmentNdx]->getResultMemory().getHostPtr();
4293 invalidateAlloc(vk, device, attachmentResources[attachmentNdx]->getResultMemory());
4295 bool depthOK = true;
4296 bool stencilOK = true;
4297 bool colorOK = true;
4298 const ConstPixelBufferAccess access (format, targetSize.x(), targetSize.y(), 1, ptr);
4299 tcu::TextureLevel errorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
4301 if (tcu::hasDepthComponent(format.order))
4303 if ((renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE || renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE)
4304 && !verifyDepthAttachment(referenceValues[attachmentNdx], access, errorImage.getAccess(), config.depthValues, requiredDepthEpsilon(attachment.getFormat())))
4309 else if (tcu::hasStencilComponent(format.order))
4311 if ((renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE || renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE)
4312 && !verifyStencilAttachment(referenceValues[attachmentNdx], access, errorImage.getAccess()))
4319 if ((renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE || renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE)
4320 && !verifyColorAttachment(referenceValues[attachmentNdx], access, errorImage.getAccess(), config.useFormatCompCount))
4326 if (!depthOK || !stencilOK || !colorOK)
4328 log << TestLog::ImageSet("TestImages", "Output attachment, reference image and error mask");
4329 if (!depthOK || !stencilOK)
4331 // Log without conversions.
4332 log << TestLog::Image("Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx), access);
4333 log << TestLog::Image("AttachmentReference" + de::toString(attachmentNdx), "Attachment reference " + de::toString(attachmentNdx), referenceAttachments[attachmentNdx].getAccess());
4337 // Convert color images to better reflect test status and output in any format.
4338 const auto numChannels = tcu::getNumUsedChannels(access.getFormat().order);
4339 const auto attachmentForLog = renderColorImageForLog(access, numChannels);
4340 const auto referenceForLog = renderColorImageForLog(referenceValues[attachmentNdx], targetSize, numChannels);
4342 log << TestLog::Message << "Check the attachment formats and test data to verify which components affect the test result." << TestLog::EndMessage;
4343 log << TestLog::Message << "In the reference image, unset pixel components are marked with a 3x3 grid storing values 0.0 and 0.25, pixel components set to false are stored as 0.5 and pixel components set to true are stored as 1.0." << TestLog::EndMessage;
4344 log << TestLog::Message << "Output attachment pixel components are always set to 0.5 or 1.0 but may not be taken into account if not set in the reference image." << TestLog::EndMessage;
4346 log << TestLog::Image("Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx), attachmentForLog->getAccess());
4347 log << TestLog::Image("AttachmentReference" + de::toString(attachmentNdx), "Attachment reference " + de::toString(attachmentNdx), referenceForLog->getAccess());
4349 log << TestLog::Image("AttachmentError" + de::toString(attachmentNdx), "Attachment Error " + de::toString(attachmentNdx), errorImage.getAccess());
4350 log << TestLog::EndImageSet;
4352 attachmentOK = false;
4364 std::string getInputAttachmentType (VkFormat vkFormat)
4366 const tcu::TextureFormat format = mapVkFormat(vkFormat);
4367 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
4369 switch (channelClass)
4371 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
4372 return "isubpassInput";
4374 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
4375 return "usubpassInput";
4377 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
4378 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
4379 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
4380 return "subpassInput";
4383 DE_FATAL("Unknown channel class");
4388 std::string getAttachmentType (VkFormat vkFormat, deBool useFormatCompCount)
4390 const tcu::TextureFormat format = mapVkFormat(vkFormat);
4391 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
4392 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4394 switch (channelClass)
4396 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
4397 if (useFormatCompCount)
4398 return (componentCount == 1 ? "int" : "ivec" + de::toString(componentCount));
4402 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
4403 if (useFormatCompCount)
4404 return (componentCount == 1 ? "uint" : "uvec" + de::toString(componentCount));
4408 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
4409 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
4410 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
4411 if (useFormatCompCount)
4412 return (componentCount == 1 ? "float" : "vec" + de::toString(componentCount));
4417 DE_FATAL("Unknown channel class");
4422 void createTestShaders (SourceCollections& dst, TestConfig config)
4424 if (config.renderTypes & TestConfig::RENDERTYPES_DRAW)
4426 const vector<Subpass>& subpasses = config.renderPass.getSubpasses();
4428 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
4430 const Subpass& subpass = subpasses[subpassNdx];
4431 deUint32 inputAttachmentBinding = 0;
4432 std::ostringstream vertexShader;
4433 std::ostringstream fragmentShader;
4435 vertexShader << "#version 310 es\n"
4436 << "layout(location = 0) in highp vec2 a_position;\n"
4437 << "void main (void) {\n"
4438 << "\tgl_Position = vec4(a_position, 1.0, 1.0);\n"
4441 fragmentShader << "#version 310 es\n"
4442 << "precision highp float;\n";
4444 bool hasAnyDepthFormats = false;
4446 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
4448 const deUint32 attachmentIndex = subpass.getInputAttachments()[attachmentNdx].getAttachment();
4449 const VkImageLayout layout = subpass.getInputAttachments()[attachmentNdx].getImageLayout();
4450 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4451 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4452 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
4453 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
4455 if (isDepthFormat || isStencilFormat)
4457 if (isDepthFormat && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
4459 hasAnyDepthFormats = true;
4460 fragmentShader << "layout(input_attachment_index = " << attachmentNdx << ", set=0, binding=" << inputAttachmentBinding << ") uniform highp subpassInput i_depth" << attachmentNdx << ";\n";
4461 inputAttachmentBinding++;
4464 if (isStencilFormat && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4466 fragmentShader << "layout(input_attachment_index = " << attachmentNdx << ", set=0, binding=" << inputAttachmentBinding << ") uniform highp usubpassInput i_stencil" << attachmentNdx << ";\n";
4467 inputAttachmentBinding++;
4472 const std::string attachmentType = getInputAttachmentType(attachment.getFormat());
4474 fragmentShader << "layout(input_attachment_index = " << attachmentNdx << ", set=0, binding=" << inputAttachmentBinding << ") uniform highp " << attachmentType << " i_color" << attachmentNdx << ";\n";
4475 inputAttachmentBinding++;
4479 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
4481 const std::string attachmentType = getAttachmentType(config.renderPass.getAttachments()[getAttachmentNdx(subpass.getColorAttachments(), attachmentNdx)].getFormat(), config.useFormatCompCount);
4482 fragmentShader << "layout(location = " << attachmentNdx << ") out highp " << attachmentType << " o_color" << attachmentNdx << ";\n";
4485 if (hasAnyDepthFormats)
4486 fragmentShader << "\nbool depthsEqual(float a, float b, float epsilon) {\n"
4487 << "\treturn abs(a - b) <= epsilon;\n}\n\n";
4489 fragmentShader << "void main (void) {\n";
4491 if (subpass.getInputAttachments().empty())
4493 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
4495 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentNdx].getAttachment();
4497 if (attachmentIndex == VK_ATTACHMENT_UNUSED)
4500 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4501 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4502 const size_t componentCount = config.useFormatCompCount ? (size_t)tcu::getNumUsedChannels(format.order) : 4;
4503 const std::string attachmentType = getAttachmentType(attachment.getFormat(), config.useFormatCompCount);
4505 fragmentShader << "\to_color" << attachmentNdx << " = " << attachmentType << "(" << attachmentType + "(";
4507 for (size_t compNdx = 0; compNdx < componentCount; compNdx++)
4509 const size_t index = subpassNdx + attachmentIndex + compNdx;
4510 const BoolOp op = boolOpFromIndex(index);
4513 fragmentShader << ",\n\t\t";
4515 fragmentShader << "((int(gl_FragCoord.x) % 2 == " << (index % 2)
4516 << ") " << boolOpToString(op) << " ("
4517 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
4518 << ") ? 1.0 : 0.0)";
4521 fragmentShader << "));\n";
4524 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
4525 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
4526 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4528 const size_t index = subpassNdx + 1;
4529 const BoolOp op = boolOpFromIndex(index);
4531 fragmentShader << "\tgl_FragDepth = ((int(gl_FragCoord.x) % 2 == " << (index % 2)
4532 << ") " << boolOpToString(op) << " ("
4533 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
4534 << ") ? " << deUint32(config.depthValues[1]) << ".0f/255.0f : " << deUint32(config.depthValues[0]) << ".0f/255.0f);\n";
4539 size_t inputComponentCount = 0;
4540 size_t outputComponentCount = 0;
4542 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
4544 const deUint32 attachmentIndex = subpass.getInputAttachments()[attachmentNdx].getAttachment();
4545 const VkImageLayout layout = subpass.getInputAttachments()[attachmentNdx].getImageLayout();
4546 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4547 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4548 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4550 if (layout == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4551 inputComponentCount += 1;
4552 else if (layout == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
4553 inputComponentCount += 1;
4555 inputComponentCount += componentCount;
4558 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
4560 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentNdx].getAttachment();
4561 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4562 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4563 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4565 outputComponentCount += componentCount;
4568 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
4569 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
4570 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4572 outputComponentCount++;
4575 if (outputComponentCount > 0)
4577 const size_t inputsPerOutput = inputComponentCount >= outputComponentCount
4578 ? ((inputComponentCount / outputComponentCount)
4579 + ((inputComponentCount % outputComponentCount) != 0 ? 1 : 0))
4582 fragmentShader << "\tbool inputs[" << inputComponentCount << "];\n";
4584 if (outputComponentCount > 0)
4585 fragmentShader << "\tbool outputs[" << outputComponentCount << "];\n";
4587 size_t inputValueNdx = 0;
4589 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
4591 const char* const components[] =
4595 const deUint32 attachmentIndex = subpass.getInputAttachments()[attachmentNdx].getAttachment();
4596 const VkImageLayout layout = subpass.getInputAttachments()[attachmentNdx].getImageLayout();
4597 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4598 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4599 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4600 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
4601 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
4603 if (isDepthFormat || isStencilFormat)
4605 if (isDepthFormat && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
4607 fragmentShader << "\tinputs[" << inputValueNdx << "] = depthsEqual(" << deUint32(config.depthValues[1]) <<
4608 ".0f/255.0f, float(subpassLoad(i_depth" << attachmentNdx << ").x), " <<
4609 std::fixed << std::setprecision(12) << requiredDepthEpsilon(attachment.getFormat()) << ");\n";
4613 if (isStencilFormat && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4615 fragmentShader << "\tinputs[" << inputValueNdx << "] = 255u == subpassLoad(i_stencil" << attachmentNdx << ").x;\n";
4621 for (size_t compNdx = 0; compNdx < componentCount; compNdx++)
4623 fragmentShader << "\tinputs[" << inputValueNdx << "] = 1.0 == float(subpassLoad(i_color" << attachmentNdx << ")." << components[compNdx] << ");\n";
4629 size_t outputValueNdx = 0;
4631 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
4633 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentNdx].getAttachment();
4634 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4635 const std::string attachmentType = getAttachmentType(config.renderPass.getAttachments()[attachmentIndex].getFormat(), config.useFormatCompCount);
4636 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4637 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4639 for (size_t compNdx = 0; compNdx < componentCount; compNdx++)
4641 const size_t index = subpassNdx + attachmentIndex + outputValueNdx;
4642 const BoolOp op = boolOpFromIndex(index);
4644 fragmentShader << "\toutputs[" << outputValueNdx + compNdx << "] = "
4645 << "(int(gl_FragCoord.x) % 2 == " << (index % 2)
4646 << ") " << boolOpToString(op) << " ("
4647 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
4650 for (size_t i = 0; i < inputsPerOutput; i++)
4651 fragmentShader << "\toutputs[" << outputValueNdx + compNdx << "] = outputs[" << outputValueNdx + compNdx << "] == inputs[" << ((outputValueNdx + compNdx) * inputsPerOutput + i) % inputComponentCount << "];\n";
4654 fragmentShader << "\to_color" << attachmentNdx << " = " << attachmentType << "(";
4656 for (size_t compNdx = 0; compNdx < (config.useFormatCompCount ? componentCount : 4); compNdx++)
4659 fragmentShader << ", ";
4661 if (compNdx < componentCount)
4662 fragmentShader << "outputs[" << outputValueNdx + compNdx << "]";
4664 fragmentShader << "0";
4667 outputValueNdx += componentCount;
4669 fragmentShader << ");\n";
4672 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
4673 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
4674 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4676 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
4677 const size_t index = subpassNdx + attachmentIndex;
4678 const BoolOp op = boolOpFromIndex(index);
4680 fragmentShader << "\toutputs[" << outputValueNdx << "] = "
4681 << "(int(gl_FragCoord.x) % 2 == " << (index % 2)
4682 << ") " << boolOpToString(op) << " ("
4683 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
4686 for (size_t i = 0; i < inputsPerOutput; i++)
4687 fragmentShader << "\toutputs[" << outputValueNdx << "] = outputs[" << outputValueNdx << "] == inputs[" << (outputValueNdx * inputsPerOutput + i) % inputComponentCount << "];\n";
4689 fragmentShader << "\tgl_FragDepth = outputs[" << outputValueNdx << "] ? " << deUint32(config.depthValues[1]) << ".0f/255.0f : " << deUint32(config.depthValues[0]) << ".0f/255.0f;\n";
4694 fragmentShader << "}\n";
4696 dst.glslSources.add(de::toString(subpassNdx) + "-vert") << glu::VertexSource(vertexShader.str());
4697 dst.glslSources.add(de::toString(subpassNdx) + "-frag") << glu::FragmentSource(fragmentShader.str());
4702 void initializeAttachmentIsLazy (vector<bool>& attachmentIsLazy, const vector<Attachment>& attachments, TestConfig::ImageMemory imageMemory)
4704 bool lastAttachmentWasLazy = false;
4706 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4708 if (attachments[attachmentNdx].getLoadOp() != VK_ATTACHMENT_LOAD_OP_LOAD
4709 && attachments[attachmentNdx].getStoreOp() != VK_ATTACHMENT_STORE_OP_STORE
4710 && attachments[attachmentNdx].getStencilLoadOp() != VK_ATTACHMENT_LOAD_OP_LOAD
4711 && attachments[attachmentNdx].getStencilStoreOp() != VK_ATTACHMENT_STORE_OP_STORE)
4713 if (imageMemory == TestConfig::IMAGEMEMORY_LAZY || (imageMemory & TestConfig::IMAGEMEMORY_LAZY && !lastAttachmentWasLazy))
4715 attachmentIsLazy.push_back(true);
4717 lastAttachmentWasLazy = true;
4719 else if (imageMemory & TestConfig::IMAGEMEMORY_STRICT)
4721 attachmentIsLazy.push_back(false);
4722 lastAttachmentWasLazy = false;
4725 DE_FATAL("Unknown imageMemory");
4728 attachmentIsLazy.push_back(false);
4732 enum AttachmentRefType
4734 ATTACHMENTREFTYPE_COLOR,
4735 ATTACHMENTREFTYPE_DEPTH_STENCIL,
4736 ATTACHMENTREFTYPE_INPUT,
4737 ATTACHMENTREFTYPE_RESOLVE,
4740 VkImageUsageFlags getImageUsageFromLayout (VkImageLayout layout)
4744 case VK_IMAGE_LAYOUT_GENERAL:
4745 case VK_IMAGE_LAYOUT_PREINITIALIZED:
4748 case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
4749 return VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4751 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
4752 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL:
4753 return VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
4755 case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
4756 return VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
4758 case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
4759 return VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
4761 case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
4762 return VK_IMAGE_USAGE_TRANSFER_DST_BIT;
4765 DE_FATAL("Unexpected image layout");
4770 void getImageUsageFromAttachmentReferences(vector<VkImageUsageFlags>& attachmentImageUsage, AttachmentRefType refType, size_t count, const AttachmentReference* references)
4772 for (size_t referenceNdx = 0; referenceNdx < count; ++referenceNdx)
4774 const deUint32 attachment = references[referenceNdx].getAttachment();
4776 if (attachment != VK_ATTACHMENT_UNUSED)
4778 VkImageUsageFlags usage;
4782 case ATTACHMENTREFTYPE_COLOR:
4783 case ATTACHMENTREFTYPE_RESOLVE:
4784 usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4787 case ATTACHMENTREFTYPE_DEPTH_STENCIL:
4788 usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
4791 case ATTACHMENTREFTYPE_INPUT:
4792 usage = VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
4796 DE_FATAL("Unexpected attachment reference type");
4801 attachmentImageUsage[attachment] |= usage;
4806 void getImageUsageFromAttachmentReferences(vector<VkImageUsageFlags>& attachmentImageUsage, AttachmentRefType refType, const vector<AttachmentReference>& references)
4808 if (!references.empty())
4810 getImageUsageFromAttachmentReferences(attachmentImageUsage, refType, references.size(), &references[0]);
4814 void initializeAttachmentImageUsage (Context &context, vector<VkImageUsageFlags>& attachmentImageUsage, const RenderPass& renderPassInfo, const vector<bool>& attachmentIsLazy, const vector<Maybe<VkClearValue> >& clearValues)
4816 attachmentImageUsage.resize(renderPassInfo.getAttachments().size(), VkImageUsageFlags(0));
4818 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); ++subpassNdx)
4820 const Subpass& subpass = renderPassInfo.getSubpasses()[subpassNdx];
4822 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_COLOR, subpass.getColorAttachments());
4823 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_DEPTH_STENCIL, 1, &subpass.getDepthStencilAttachment());
4824 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_INPUT, subpass.getInputAttachments());
4825 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_RESOLVE, subpass.getResolveAttachments());
4828 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
4830 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentNdx];
4831 const VkFormatProperties formatProperties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), attachment.getFormat());
4832 const VkFormatFeatureFlags supportedFeatures = formatProperties.optimalTilingFeatures;
4834 if ((supportedFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0)
4835 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_SAMPLED_BIT;
4837 if ((supportedFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) != 0)
4838 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_STORAGE_BIT;
4840 attachmentImageUsage[attachmentNdx] |= getImageUsageFromLayout(attachment.getInitialLayout());
4841 attachmentImageUsage[attachmentNdx] |= getImageUsageFromLayout(attachment.getFinalLayout());
4843 if (!attachmentIsLazy[attachmentNdx])
4845 if (clearValues[attachmentNdx])
4846 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
4848 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
4852 const VkImageUsageFlags allowedTransientBits = static_cast<VkImageUsageFlags>(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4854 attachmentImageUsage[attachmentNdx] &= allowedTransientBits;
4855 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4860 void initializeSubpassIsSecondary (vector<bool>& subpassIsSecondary, const vector<Subpass>& subpasses, TestConfig::CommandBufferTypes commandBuffer)
4862 bool lastSubpassWasSecondary = false;
4864 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
4866 if (commandBuffer == TestConfig::COMMANDBUFFERTYPES_SECONDARY || (commandBuffer & TestConfig::COMMANDBUFFERTYPES_SECONDARY && !lastSubpassWasSecondary))
4868 subpassIsSecondary.push_back(true);
4869 lastSubpassWasSecondary = true;
4871 else if (commandBuffer & TestConfig::COMMANDBUFFERTYPES_INLINE)
4873 subpassIsSecondary.push_back(false);
4874 lastSubpassWasSecondary = false;
4877 DE_FATAL("Unknown commandBuffer");
4881 void initializeImageClearValues (de::Random& rng, vector<Maybe<VkClearValue> >& clearValues, const vector<Attachment>& attachments, const vector<bool>& isLazy, deBool useFormatCompCount, const DepthValuesArray& depthValues)
4883 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4885 if (!isLazy[attachmentNdx])
4886 clearValues.push_back(just(randomClearValue(attachments[attachmentNdx], rng, useFormatCompCount, depthValues)));
4888 clearValues.push_back(tcu::Nothing);
4892 void initializeRenderPassClearValues (de::Random& rng, vector<Maybe<VkClearValue> >& clearValues, const vector<Attachment>& attachments, deBool useFormatCompCount, const DepthValuesArray& depthValues)
4894 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4896 if (attachments[attachmentNdx].getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR
4897 || attachments[attachmentNdx].getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
4899 clearValues.push_back(just(randomClearValue(attachments[attachmentNdx], rng, useFormatCompCount, depthValues)));
4902 clearValues.push_back(tcu::Nothing);
4906 void logSubpassRenderInfo (TestLog& log, const SubpassRenderInfo& info, TestConfig config)
4908 log << TestLog::Message << "Viewport, offset: " << info.getViewportOffset() << ", size: " << info.getViewportSize() << TestLog::EndMessage;
4910 if (info.isSecondary())
4911 log << TestLog::Message << "Subpass uses secondary command buffers" << TestLog::EndMessage;
4913 log << TestLog::Message << "Subpass uses inlined commands" << TestLog::EndMessage;
4915 for (deUint32 attachmentNdx = 0; attachmentNdx < info.getColorClears().size(); attachmentNdx++)
4917 const ColorClear& colorClear = info.getColorClears()[attachmentNdx];
4919 log << TestLog::Message << "Clearing color attachment " << attachmentNdx
4920 << ". Offset: " << colorClear.getOffset()
4921 << ", Size: " << colorClear.getSize()
4922 << ", Color: " << clearColorToString(info.getColorAttachment(attachmentNdx).getFormat(), colorClear.getColor(), config.useFormatCompCount) << TestLog::EndMessage;
4925 if (info.getDepthStencilClear())
4927 const DepthStencilClear& depthStencilClear = *info.getDepthStencilClear();
4929 log << TestLog::Message << "Clearing depth stencil attachment"
4930 << ". Offset: " << depthStencilClear.getOffset()
4931 << ", Size: " << depthStencilClear.getSize()
4932 << ", Depth: " << depthStencilClear.getDepth()
4933 << ", Stencil: " << depthStencilClear.getStencil() << TestLog::EndMessage;
4936 if (info.getRenderQuad())
4938 const RenderQuad& renderQuad = *info.getRenderQuad();
4940 log << TestLog::Message << "Rendering grid quad to " << renderQuad.getCornerA() << " -> " << renderQuad.getCornerB() << TestLog::EndMessage;
4944 void logTestCaseInfo (TestLog& log,
4945 const TestConfig& config,
4946 const vector<bool>& attachmentIsLazy,
4947 const vector<Maybe<VkClearValue> >& imageClearValues,
4948 const vector<Maybe<VkClearValue> >& renderPassClearValues,
4949 const vector<SubpassRenderInfo>& subpassRenderInfo)
4951 const RenderPass& renderPass = config.renderPass;
4953 logRenderPassInfo(log, renderPass);
4955 DE_ASSERT(attachmentIsLazy.size() == renderPass.getAttachments().size());
4956 DE_ASSERT(imageClearValues.size() == renderPass.getAttachments().size());
4957 DE_ASSERT(renderPassClearValues.size() == renderPass.getAttachments().size());
4959 log << TestLog::Message << "TargetSize: " << config.targetSize << TestLog::EndMessage;
4960 log << TestLog::Message << "Render area, Offset: " << config.renderPos << ", Size: " << config.renderSize << TestLog::EndMessage;
4962 for (size_t attachmentNdx = 0; attachmentNdx < attachmentIsLazy.size(); attachmentNdx++)
4964 const tcu::ScopedLogSection section (log, "Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx));
4966 if (attachmentIsLazy[attachmentNdx])
4967 log << TestLog::Message << "Is lazy." << TestLog::EndMessage;
4969 if (imageClearValues[attachmentNdx])
4970 log << TestLog::Message << "Image is cleared to " << clearValueToString(renderPass.getAttachments()[attachmentNdx].getFormat(),
4971 *imageClearValues[attachmentNdx], config.useFormatCompCount) << " before rendering." << TestLog::EndMessage;
4973 if (renderPass.getAttachments()[attachmentNdx].getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR && renderPassClearValues[attachmentNdx])
4974 log << TestLog::Message << "Attachment is cleared to " << clearValueToString(renderPass.getAttachments()[attachmentNdx].getFormat(),
4975 *renderPassClearValues[attachmentNdx], config.useFormatCompCount) << " in the beginning of the render pass." << TestLog::EndMessage;
4978 for (size_t subpassNdx = 0; subpassNdx < renderPass.getSubpasses().size(); subpassNdx++)
4980 const tcu::ScopedLogSection section (log, "Subpass" + de::toString(subpassNdx), "Subpass " + de::toString(subpassNdx));
4982 logSubpassRenderInfo(log, subpassRenderInfo[subpassNdx], config);
4986 float roundToViewport (float x, deUint32 offset, deUint32 size)
4988 const float origin = (float)(offset) + ((float(size) / 2.0f));
4989 const float p = (float)(size) / 2.0f;
4990 const deInt32 xi = deRoundFloatToInt32(origin + (p * x));
4992 return (((float)xi) - origin) / p;
4995 void initializeSubpassRenderInfo (vector<SubpassRenderInfo>& renderInfos, de::Random& rng, const RenderPass& renderPass, const TestConfig& config)
4997 const TestConfig::CommandBufferTypes commandBuffer = config.commandBufferTypes;
4998 const vector<Subpass>& subpasses = renderPass.getSubpasses();
4999 bool lastSubpassWasSecondary = false;
5001 for (deUint32 subpassNdx = 0; subpassNdx < (deUint32)subpasses.size(); subpassNdx++)
5003 const Subpass& subpass = subpasses[subpassNdx];
5004 const bool subpassIsSecondary = commandBuffer == TestConfig::COMMANDBUFFERTYPES_SECONDARY
5005 || (commandBuffer & TestConfig::COMMANDBUFFERTYPES_SECONDARY && !lastSubpassWasSecondary) ? true : false;
5006 const bool omitBlendState = subpass.getOmitBlendState();
5007 const UVec2 viewportSize ((config.renderSize * UVec2(2)) / UVec2(3));
5008 const UVec2 viewportOffset (config.renderPos.x() + (subpassNdx % 2) * (config.renderSize.x() / 3),
5009 config.renderPos.y() + ((subpassNdx / 2) % 2) * (config.renderSize.y() / 3));
5011 vector<ColorClear> colorClears;
5012 Maybe<DepthStencilClear> depthStencilClear;
5013 Maybe<RenderQuad> renderQuad;
5015 lastSubpassWasSecondary = subpassIsSecondary;
5017 if (config.renderTypes & TestConfig::RENDERTYPES_CLEAR)
5019 const vector<AttachmentReference>& colorAttachments = subpass.getColorAttachments();
5021 for (size_t attachmentRefNdx = 0; attachmentRefNdx < colorAttachments.size(); attachmentRefNdx++)
5023 const AttachmentReference& attachmentRef = colorAttachments[attachmentRefNdx];
5024 const Attachment& attachment = renderPass.getAttachments()[attachmentRef.getAttachment()];
5025 const UVec2 size ((viewportSize * UVec2(2)) / UVec2(3));
5026 const UVec2 offset (viewportOffset.x() + ((deUint32)attachmentRefNdx % 2u) * (viewportSize.x() / 3u),
5027 viewportOffset.y() + (((deUint32)attachmentRefNdx / 2u) % 2u) * (viewportSize.y() / 3u));
5028 const VkClearColorValue color = randomColorClearValue(attachment, rng, config.useFormatCompCount);
5030 colorClears.push_back(ColorClear(offset, size, color));
5033 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
5035 const Attachment& attachment = renderPass.getAttachments()[subpass.getDepthStencilAttachment().getAttachment()];
5036 const UVec2 size ((viewportSize * UVec2(2)) / UVec2(3));
5037 const UVec2 offset (viewportOffset.x() + ((deUint32)colorAttachments.size() % 2u) * (viewportSize.x() / 3u),
5038 viewportOffset.y() + (((deUint32)colorAttachments.size() / 2u) % 2u) * (viewportSize.y() / 3u));
5039 const VkClearValue value = randomClearValue(attachment, rng, config.useFormatCompCount, config.depthValues);
5041 depthStencilClear = tcu::just(DepthStencilClear(offset, size, value.depthStencil.depth, value.depthStencil.stencil));
5045 if (config.renderTypes & TestConfig::RENDERTYPES_DRAW)
5047 const float w = (subpassNdx % 2) == 0 ? 1.0f : 1.25f;
5048 const float h = (subpassNdx % 2) == 0 ? 1.25f : 1.0f;
5050 const float x0 = roundToViewport((subpassNdx % 2) == 0 ? 1.0f - w : -1.0f, viewportOffset.x(), viewportSize.x());
5051 const float x1 = roundToViewport((subpassNdx % 2) == 0 ? 1.0f : -1.0f + w, viewportOffset.x(), viewportSize.x());
5053 const float y0 = roundToViewport(((subpassNdx / 2) % 2) == 0 ? 1.0f - h : -1.0f, viewportOffset.y(), viewportSize.y());
5054 const float y1 = roundToViewport(((subpassNdx / 2) % 2) == 0 ? 1.0f : -1.0f + h, viewportOffset.y(), viewportSize.y());
5056 renderQuad = tcu::just(RenderQuad(tcu::Vec2(x0, y0), tcu::Vec2(x1, y1)));
5059 renderInfos.push_back(SubpassRenderInfo(renderPass, subpassNdx, config.drawStartNdx, subpassIsSecondary, omitBlendState, viewportOffset, viewportSize, renderQuad, colorClears, depthStencilClear));
5063 void checkTextureFormatSupport (TestLog& log,
5064 const InstanceInterface& vk,
5065 VkPhysicalDevice device,
5066 const vector<Attachment>& attachments)
5068 bool supported = true;
5070 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
5072 const Attachment& attachment = attachments[attachmentNdx];
5073 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
5074 const bool isDepthOrStencilAttachment = hasDepthComponent(format.order) || hasStencilComponent(format.order);
5075 const VkFormatFeatureFlags flags = isDepthOrStencilAttachment? VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT : VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
5076 VkFormatProperties properties;
5078 vk.getPhysicalDeviceFormatProperties(device, attachment.getFormat(), &properties);
5080 if ((properties.optimalTilingFeatures & flags) != flags)
5083 log << TestLog::Message << "Format: " << attachment.getFormat() << " not supported as " << (isDepthOrStencilAttachment ? "depth stencil attachment" : "color attachment") << TestLog::EndMessage;
5088 TCU_THROW(NotSupportedError, "Format not supported");
5091 tcu::TestStatus renderPassTest (Context& context, TestConfig config)
5093 const UVec2 targetSize = config.targetSize;
5094 const UVec2 renderPos = config.renderPos;
5095 const UVec2 renderSize = config.renderSize;
5096 const RenderPass& renderPassInfo = config.renderPass;
5098 TestLog& log = context.getTestContext().getLog();
5099 de::Random rng (config.seed);
5101 vector<bool> attachmentIsLazy;
5102 vector<VkImageUsageFlags> attachmentImageUsage;
5103 vector<Maybe<VkClearValue> > imageClearValues;
5104 vector<Maybe<VkClearValue> > renderPassClearValues;
5106 vector<bool> subpassIsSecondary;
5107 vector<SubpassRenderInfo> subpassRenderInfo;
5109 if (config.groupParams->renderingType == RENDERING_TYPE_RENDERPASS2)
5110 context.requireDeviceFunctionality("VK_KHR_create_renderpass2");
5112 if (config.groupParams->renderingType == RENDERING_TYPE_DYNAMIC_RENDERING)
5113 context.requireDeviceFunctionality("VK_KHR_dynamic_rendering");
5115 if (config.allocationKind == ALLOCATION_KIND_DEDICATED)
5117 if (!context.isDeviceFunctionalitySupported("VK_KHR_dedicated_allocation"))
5118 TCU_THROW(NotSupportedError, "VK_KHR_dedicated_allocation is not supported");
5121 if (!renderPassInfo.getInputAspects().empty())
5123 if (!context.isDeviceFunctionalitySupported("VK_KHR_maintenance2"))
5124 TCU_THROW(NotSupportedError, "Extension VK_KHR_maintenance2 not supported.");
5128 bool requireDepthStencilLayout = false;
5130 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
5132 if (renderPassInfo.getAttachments()[attachmentNdx].getInitialLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5133 || renderPassInfo.getAttachments()[attachmentNdx].getInitialLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL
5134 || renderPassInfo.getAttachments()[attachmentNdx].getFinalLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5135 || renderPassInfo.getAttachments()[attachmentNdx].getFinalLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5137 requireDepthStencilLayout = true;
5142 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size() && !requireDepthStencilLayout; subpassNdx++)
5144 const Subpass& subpass (renderPassInfo.getSubpasses()[subpassNdx]);
5146 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
5148 if (subpass.getColorAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5149 || subpass.getColorAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5151 requireDepthStencilLayout = true;
5156 for (size_t attachmentNdx = 0; !requireDepthStencilLayout && attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
5158 if (subpass.getInputAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5159 || subpass.getInputAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5161 requireDepthStencilLayout = true;
5166 for (size_t attachmentNdx = 0; !requireDepthStencilLayout && attachmentNdx < subpass.getResolveAttachments().size(); attachmentNdx++)
5168 if (subpass.getResolveAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5169 || subpass.getResolveAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5171 requireDepthStencilLayout = true;
5176 if (subpass.getDepthStencilAttachment().getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5177 || subpass.getDepthStencilAttachment().getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5179 requireDepthStencilLayout = true;
5184 if (requireDepthStencilLayout && !context.isDeviceFunctionalitySupported("VK_KHR_maintenance2"))
5185 TCU_THROW(NotSupportedError, "VK_KHR_maintenance2 is not supported");
5188 initializeAttachmentIsLazy(attachmentIsLazy, renderPassInfo.getAttachments(), config.imageMemory);
5189 initializeImageClearValues(rng, imageClearValues, renderPassInfo.getAttachments(), attachmentIsLazy, config.useFormatCompCount, config.depthValues);
5190 initializeAttachmentImageUsage(context, attachmentImageUsage, renderPassInfo, attachmentIsLazy, imageClearValues);
5191 initializeRenderPassClearValues(rng, renderPassClearValues, renderPassInfo.getAttachments(), config.useFormatCompCount, config.depthValues);
5193 initializeSubpassIsSecondary(subpassIsSecondary, renderPassInfo.getSubpasses(), config.commandBufferTypes);
5194 initializeSubpassRenderInfo(subpassRenderInfo, rng, renderPassInfo, config);
5196 logTestCaseInfo(log, config, attachmentIsLazy, imageClearValues, renderPassClearValues, subpassRenderInfo);
5198 checkTextureFormatSupport(log, context.getInstanceInterface(), context.getPhysicalDevice(), config.renderPass.getAttachments());
5201 const vk::VkPhysicalDeviceProperties properties = vk::getPhysicalDeviceProperties(context.getInstanceInterface(), context.getPhysicalDevice());
5203 log << TestLog::Message << "Max color attachments: " << properties.limits.maxColorAttachments << TestLog::EndMessage;
5205 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); subpassNdx++)
5207 if (renderPassInfo.getSubpasses()[subpassNdx].getColorAttachments().size() > (size_t)properties.limits.maxColorAttachments)
5208 TCU_THROW(NotSupportedError, "Subpass uses more than maxColorAttachments.");
5213 const InstanceInterface& vki = context.getInstanceInterface();
5214 const VkPhysicalDevice& physDevice = context.getPhysicalDevice();
5215 const VkDevice device = context.getDevice();
5216 const DeviceInterface& vk = context.getDeviceInterface();
5217 const VkQueue queue = context.getUniversalQueue();
5218 const deUint32 queueIndex = context.getUniversalQueueFamilyIndex();
5219 Allocator& allocator = context.getDefaultAllocator();
5221 const Unique<VkCommandPool> commandBufferPool (createCommandPool(vk, device, 0, queueIndex));
5222 const Unique<VkCommandBuffer> initializeImagesCommandBuffer (allocateCommandBuffer(vk, device, *commandBufferPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
5223 const Unique<VkCommandBuffer> renderCommandBuffer (allocateCommandBuffer(vk, device, *commandBufferPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
5224 const Unique<VkCommandBuffer> readImagesToBuffersCommandBuffer (allocateCommandBuffer(vk, device, *commandBufferPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
5226 vector<de::SharedPtr<AttachmentResources> > attachmentResources;
5227 vector<de::SharedPtr<SubpassRenderer> > subpassRenderers;
5228 vector<VkImage> attachmentImages;
5229 vector<VkImageView> attachmentViews;
5230 vector<pair<VkImageView, VkImageView> > inputAttachmentViews;
5232 Move<VkRenderPass> renderPass;
5233 if (config.groupParams->renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
5234 renderPass = createRenderPass(vk, device, renderPassInfo, config.groupParams->renderingType);
5236 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
5238 const Attachment& attachmentInfo = renderPassInfo.getAttachments()[attachmentNdx];
5240 attachmentResources.push_back(de::SharedPtr<AttachmentResources>(new AttachmentResources(vki, physDevice, vk, device, allocator, queueIndex, targetSize, attachmentInfo, attachmentImageUsage[attachmentNdx], config.allocationKind)));
5241 attachmentViews.push_back(attachmentResources[attachmentNdx]->getAttachmentView());
5242 attachmentImages.push_back(attachmentResources[attachmentNdx]->getImage());
5244 inputAttachmentViews.push_back(attachmentResources[attachmentNdx]->getInputAttachmentViews());
5247 beginCommandBuffer(vk, *initializeImagesCommandBuffer, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0);
5248 pushImageInitializationCommands(vk, *initializeImagesCommandBuffer, renderPassInfo.getAttachments(), attachmentResources, queueIndex, imageClearValues);
5249 endCommandBuffer(vk, *initializeImagesCommandBuffer);
5252 Move<VkFramebuffer> framebuffer;
5253 if (config.groupParams->renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
5254 framebuffer = createFramebuffer(vk, device, *renderPass, targetSize, attachmentViews);
5256 const VkRect2D renderArea
5258 { (deInt32)renderPos.x(), (deInt32)renderPos.y() },
5259 { renderSize.x(), renderSize.y() }
5261 const bool dynamicRendering = (config.groupParams->renderingType == RENDERING_TYPE_DYNAMIC_RENDERING);
5262 const bool secondaryCmdBufferCompletelyContainsDynamicRenderpass = (config.commandBufferTypes == TestConfig::COMMANDBUFFERTYPES_SECONDARY) &&
5263 config.groupParams->secondaryCmdBufferCompletelyContainsDynamicRenderpass;
5265 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); subpassNdx++)
5267 subpassRenderers.push_back(de::SharedPtr<SubpassRenderer>(new SubpassRenderer(context, vk, device, allocator, renderPassInfo, attachmentResources,
5268 renderArea, renderPassClearValues, *renderPass, *framebuffer,
5269 *commandBufferPool, queueIndex, attachmentImages, inputAttachmentViews,
5270 subpassRenderInfo[subpassNdx], config.allocationKind, dynamicRendering,
5271 secondaryCmdBufferCompletelyContainsDynamicRenderpass)));
5274 beginCommandBuffer(vk, *renderCommandBuffer, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0);
5275 pushRenderPassCommands(vk, *renderCommandBuffer, *renderPass, renderPassInfo, attachmentResources, *framebuffer, subpassRenderers, renderArea,
5276 renderPassClearValues, queueIndex, config.renderTypes, config.groupParams->renderingType, secondaryCmdBufferCompletelyContainsDynamicRenderpass);
5277 endCommandBuffer(vk, *renderCommandBuffer);
5279 beginCommandBuffer(vk, *readImagesToBuffersCommandBuffer, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0);
5280 pushReadImagesToBuffers(vk, *readImagesToBuffersCommandBuffer, queueIndex, attachmentResources, renderPassInfo.getAttachments(), attachmentIsLazy, targetSize);
5281 endCommandBuffer(vk, *readImagesToBuffersCommandBuffer);
5283 const VkCommandBuffer commandBuffers[] =
5285 *initializeImagesCommandBuffer,
5286 *renderCommandBuffer,
5287 *readImagesToBuffersCommandBuffer
5289 const Unique<VkFence> fence (createFence(vk, device, 0u));
5291 queueSubmit(vk, queue, DE_LENGTH_OF_ARRAY(commandBuffers), commandBuffers, *fence);
5292 waitForFences(vk, device, 1, &fence.get(), VK_TRUE, ~0ull);
5295 #ifdef CTS_USES_VULKANSC
5296 if (!context.getTestContext().getCommandLine().isSubProcess())
5297 return tcu::TestStatus::pass("Pass");
5299 if (logAndVerifyImages(log, vk, device, attachmentResources, attachmentIsLazy, renderPassInfo, renderPassClearValues, imageClearValues, subpassRenderInfo, targetSize, config))
5300 return tcu::TestStatus::pass("Pass");
5302 return tcu::TestStatus::fail("Result verification failed");
5306 class RenderPassNoDrawLoadStoreTestCase : public vkt::TestCase
5309 RenderPassNoDrawLoadStoreTestCase(tcu::TestContext& context, const std::string& name, const std::string& description, bool useRenderPass2);
5310 TestInstance* createInstance (Context& context) const override;
5315 class RenderPassNoDrawLoadStoreTestInstance : public vkt::TestInstance
5318 RenderPassNoDrawLoadStoreTestInstance(Context& context, bool useRenderPass2);
5320 template<typename AttachmentDesc, typename AttachmentRef, typename SubpassDesc, typename SubpassDep, typename RenderPassCreateInfo>
5321 Move<VkRenderPass> createRenderPass (const DeviceInterface& vk, VkDevice vkDevice, RenderingType type);
5322 virtual tcu::TestStatus iterate(void);
5327 RenderPassNoDrawLoadStoreTestCase::RenderPassNoDrawLoadStoreTestCase(tcu::TestContext& context, const std::string& name, const std::string& description, bool useRenderPass2)
5328 : vkt::TestCase(context, name, description), m_renderPass2(useRenderPass2) {}
5330 RenderPassNoDrawLoadStoreTestInstance::RenderPassNoDrawLoadStoreTestInstance(Context& context, bool useRenderPass2) : vkt::TestInstance(context), m_renderPass2(useRenderPass2) { }
5332 TestInstance* RenderPassNoDrawLoadStoreTestCase::createInstance(Context& context) const {
5333 return new RenderPassNoDrawLoadStoreTestInstance(context, m_renderPass2);
5336 template<typename AttachmentDesc, typename AttachmentRef, typename SubpassDesc, typename SubpassDep, typename RenderPassCreateInfo>
5337 Move<VkRenderPass> RenderPassNoDrawLoadStoreTestInstance::createRenderPass (const DeviceInterface& vk,
5341 const VkImageAspectFlags aspectMask = type == RENDERING_TYPE_RENDERPASS_LEGACY ? 0 : VK_IMAGE_ASPECT_COLOR_BIT;
5343 const AttachmentDesc attachmentDescription =
5344 // Result attachment
5346 nullptr, // const void* pNext
5347 (VkAttachmentDescriptionFlags)0, // VkAttachmentDescriptionFlags flags
5348 VK_FORMAT_R8G8B8A8_UNORM, // VkFormat format
5349 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples
5350 VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp
5351 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp
5352 VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp
5353 VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp
5354 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout
5355 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout finalLayout
5358 const AttachmentRef resultAttachmentRefSubpass0 (
5359 nullptr, // const void* pNext
5360 0u, // deUint32 attachment
5361 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout layout
5362 aspectMask // VkImageAspectFlags aspectMask
5365 const SubpassDesc subpassDescription =
5368 (VkSubpassDescriptionFlags)0, // VkSubpassDescriptionFlags flags
5369 VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint
5370 0u, // deUint32 viewMask
5371 0u, // deUint32 inputAttachmentCount
5372 nullptr, // const VkAttachmentReference* pInputAttachments
5373 1u, // deUint32 colorAttachmentCount
5374 &resultAttachmentRefSubpass0, // const VkAttachmentReference* pColorAttachments
5375 nullptr, // const VkAttachmentReference* pResolveAttachments
5376 nullptr, // const VkAttachmentReference* pDepthStencilAttachment
5377 0u, // deUint32 preserveAttachmentCount
5378 nullptr // const deUint32* pPreserveAttachments
5381 const RenderPassCreateInfo renderPassInfo (
5382 nullptr, // const void* pNext
5383 (VkRenderPassCreateFlags)0, // VkRenderPassCreateFlags flags
5384 1u, // deUint32 attachmentCount
5385 &attachmentDescription, // const VkAttachmentDescription* pAttachments
5386 1u, // deUint32 subpassCount
5387 &subpassDescription, // const VkSubpassDescription* pSubpasses
5388 0u, // deUint32 dependencyCount
5389 nullptr, // const VkSubpassDependency* pDependencies
5390 0u, // deUint32 correlatedViewMaskCount
5391 nullptr // const deUint32* pCorrelatedViewMasks
5393 return renderPassInfo.createRenderPass(vk, vkDevice);
5396 tcu::TestStatus RenderPassNoDrawLoadStoreTestInstance::iterate() {
5397 const auto& vkd = m_context.getDeviceInterface();
5398 const auto device = m_context.getDevice();
5399 auto& alloc = m_context.getDefaultAllocator();
5401 auto imageFormat = VK_FORMAT_R8G8B8A8_UNORM;
5402 auto imageExtent = makeExtent3D(1, 1, 1u);
5404 const tcu::IVec3 imageDim (static_cast<int>(imageExtent.width), static_cast<int>(imageExtent.height), static_cast<int>(imageExtent.depth));
5405 const tcu::IVec2 imageSize (imageDim.x(), imageDim.y());
5407 const std::vector<VkViewport> viewports { makeViewport(imageExtent) };
5408 const std::vector<VkRect2D> scissors { makeRect2D(imageExtent) };
5410 de::MovePtr<ImageWithMemory> colorAttachment;
5412 const auto qIndex = m_context.getUniversalQueueFamilyIndex();
5414 const auto subresourceRange = makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u);
5415 const auto imageUsage = static_cast<VkImageUsageFlags>(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT);
5416 const VkImageCreateInfo imageCreateInfo =
5418 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
5419 nullptr, // const void* pNext;
5420 0u, // VkImageCreateFlags flags;
5421 VK_IMAGE_TYPE_2D, // VkImageType imageType;
5422 imageFormat, // VkFormat format;
5423 imageExtent, // VkExtent3D extent;
5424 1u, // deUint32 mipLevels;
5425 1u, // deUint32 arrayLayers;
5426 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples;
5427 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
5428 imageUsage, // VkImageUsageFlags usage;
5429 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
5430 0u, // deUint32 queueFamilyIndexCount;
5431 nullptr, // const deUint32* pQueueFamilyIndices;
5432 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
5435 colorAttachment = de::MovePtr<ImageWithMemory>(new ImageWithMemory(vkd, device, alloc, imageCreateInfo, MemoryRequirement::Any));
5436 auto colorAttachmentView = makeImageView(vkd, device, colorAttachment->get(), VK_IMAGE_VIEW_TYPE_2D, imageFormat, subresourceRange);
5438 const auto tcuFormat = mapVkFormat(imageFormat);
5439 const auto outBufferSize = static_cast<VkDeviceSize>(static_cast<uint32_t>(tcu::getPixelSize(tcuFormat)) * imageExtent.width * imageExtent.height);
5441 BufferWithMemory outBuffer (vkd, device, alloc, makeBufferCreateInfo(outBufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT), MemoryRequirement::HostVisible);
5442 auto& outBufferAlloc = outBuffer.getAllocation();
5443 void* outBufferData = outBufferAlloc.getHostPtr();
5445 Move<VkRenderPass> renderPass;
5446 if (m_renderPass2) {
5447 renderPass = createRenderPass<AttachmentDescription1, AttachmentReference1, SubpassDescription1, SubpassDependency1, RenderPassCreateInfo1>
5448 (vkd, device, RENDERING_TYPE_RENDERPASS_LEGACY);
5450 renderPass = createRenderPass<AttachmentDescription2, AttachmentReference2, SubpassDescription2, SubpassDependency2, RenderPassCreateInfo2>
5451 (vkd, device, RENDERING_TYPE_RENDERPASS2);
5455 const auto framebuffer = makeFramebuffer(vkd, device, renderPass.get(), colorAttachmentView.get(), imageExtent.width, imageExtent.height);
5457 const auto clearValueColor = makeClearValueColor(tcu::Vec4(1.0f, 0.0f, 1.0f, 1.0f));
5459 auto graphicsPipelineLayout = makePipelineLayout(vkd, device);
5460 auto commandPool = createCommandPool(vkd, device, VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, qIndex);
5461 auto commandBuffer = allocateCommandBuffer(vkd, device, commandPool.get(), VK_COMMAND_BUFFER_LEVEL_PRIMARY);
5463 beginCommandBuffer(vkd, commandBuffer.get());
5465 const VkRenderPassBeginInfo renderPassBeginInfo =
5467 VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, // VkStructureType sType;
5468 nullptr, // const void* pNext;
5469 *renderPass, // VkRenderPass renderPass;
5470 *framebuffer, // VkFramebuffer framebuffer;
5471 scissors.at(0), // VkRect2D renderArea;
5472 1, // uint32_t clearValueCount;
5473 &clearValueColor, // const VkClearValue* pClearValues;
5475 vkd.cmdBeginRenderPass(*commandBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
5476 vkd.cmdEndRenderPass(*commandBuffer);
5477 auto barrier = makeImageMemoryBarrier(VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT,
5478 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, colorAttachment->get(), subresourceRange);
5479 cmdPipelineImageMemoryBarrier(vkd, *commandBuffer, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, &barrier);
5480 copyImageToBuffer(vkd, commandBuffer.get(), colorAttachment.get()->get(), outBuffer.get(), imageSize);
5481 endCommandBuffer(vkd, commandBuffer.get());
5482 submitCommandsAndWait(vkd, device, m_context.getUniversalQueue(), commandBuffer.get());
5483 invalidateAlloc(vkd, device, outBufferAlloc);
5485 tcu::ConstPixelBufferAccess outPixels(tcuFormat, imageDim, outBufferData);
5486 auto pixel = outPixels.getPixel(0, 0);
5487 auto expected = tcu::Vec4(1.0f, 0.0f, 1.0f, 1.0f);
5489 if (pixel != expected) {
5490 std::stringstream output("Pixel isn't equal to clear color: ");
5491 output << pixel << " instead of " << expected;
5492 return tcu::TestStatus::fail(output.str());
5495 return tcu::TestStatus::pass("Pass");
5498 static const VkFormat s_coreColorFormats[] =
5500 VK_FORMAT_R5G6B5_UNORM_PACK16,
5505 VK_FORMAT_R8G8_UNORM,
5506 VK_FORMAT_R8G8_SNORM,
5507 VK_FORMAT_R8G8_UINT,
5508 VK_FORMAT_R8G8_SINT,
5509 VK_FORMAT_R8G8B8A8_UNORM,
5510 VK_FORMAT_R8G8B8A8_SNORM,
5511 VK_FORMAT_R8G8B8A8_UINT,
5512 VK_FORMAT_R8G8B8A8_SINT,
5513 VK_FORMAT_R8G8B8A8_SRGB,
5514 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
5515 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
5516 VK_FORMAT_A8B8G8R8_UINT_PACK32,
5517 VK_FORMAT_A8B8G8R8_SINT_PACK32,
5518 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
5519 VK_FORMAT_B8G8R8A8_UNORM,
5520 VK_FORMAT_B8G8R8A8_SRGB,
5521 VK_FORMAT_A2R10G10B10_UNORM_PACK32,
5522 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
5523 VK_FORMAT_A2B10G10R10_UINT_PACK32,
5524 VK_FORMAT_R16_UNORM,
5525 VK_FORMAT_R16_SNORM,
5528 VK_FORMAT_R16_SFLOAT,
5529 VK_FORMAT_R16G16_UNORM,
5530 VK_FORMAT_R16G16_SNORM,
5531 VK_FORMAT_R16G16_UINT,
5532 VK_FORMAT_R16G16_SINT,
5533 VK_FORMAT_R16G16_SFLOAT,
5534 VK_FORMAT_R16G16B16A16_UNORM,
5535 VK_FORMAT_R16G16B16A16_SNORM,
5536 VK_FORMAT_R16G16B16A16_UINT,
5537 VK_FORMAT_R16G16B16A16_SINT,
5538 VK_FORMAT_R16G16B16A16_SFLOAT,
5541 VK_FORMAT_R32_SFLOAT,
5542 VK_FORMAT_R32G32_UINT,
5543 VK_FORMAT_R32G32_SINT,
5544 VK_FORMAT_R32G32_SFLOAT,
5545 VK_FORMAT_R32G32B32A32_UINT,
5546 VK_FORMAT_R32G32B32A32_SINT,
5547 VK_FORMAT_R32G32B32A32_SFLOAT
5550 static const VkFormat s_coreDepthStencilFormats[] =
5552 VK_FORMAT_D16_UNORM,
5554 VK_FORMAT_X8_D24_UNORM_PACK32,
5555 VK_FORMAT_D32_SFLOAT,
5557 VK_FORMAT_D24_UNORM_S8_UINT,
5558 VK_FORMAT_D32_SFLOAT_S8_UINT
5561 void addAttachmentTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
5563 const deUint32 attachmentCounts[] = { 1, 3, 4, 8 };
5564 const VkAttachmentLoadOp loadOps[] =
5566 VK_ATTACHMENT_LOAD_OP_LOAD,
5567 VK_ATTACHMENT_LOAD_OP_CLEAR,
5568 VK_ATTACHMENT_LOAD_OP_DONT_CARE
5571 const VkAttachmentStoreOp storeOps[] =
5573 VK_ATTACHMENT_STORE_OP_STORE,
5574 VK_ATTACHMENT_STORE_OP_DONT_CARE
5577 const VkImageLayout initialAndFinalColorLayouts[] =
5579 VK_IMAGE_LAYOUT_GENERAL,
5580 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5581 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
5582 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
5583 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
5586 const VkImageLayout initialAndFinalColorLayoutsLazy[] =
5588 VK_IMAGE_LAYOUT_GENERAL,
5589 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5590 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
5593 const VkImageLayout initialAndFinalDepthStencilLayouts[] =
5595 VK_IMAGE_LAYOUT_GENERAL,
5596 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5597 VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL,
5598 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
5599 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
5600 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
5603 const VkImageLayout initialAndFinalDepthStencilLayoutsLazy[] =
5605 VK_IMAGE_LAYOUT_GENERAL,
5606 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5607 VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL,
5608 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
5611 const VkImageLayout subpassLayouts[] =
5613 VK_IMAGE_LAYOUT_GENERAL,
5614 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
5617 const VkImageLayout depthStencilLayouts[] =
5619 VK_IMAGE_LAYOUT_GENERAL,
5620 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
5623 const TestConfig::RenderTypes renderCommands[] =
5625 TestConfig::RENDERTYPES_NONE,
5626 TestConfig::RENDERTYPES_CLEAR,
5627 TestConfig::RENDERTYPES_DRAW,
5628 TestConfig::RENDERTYPES_CLEAR|TestConfig::RENDERTYPES_DRAW,
5631 const TestConfig::CommandBufferTypes commandBuffers[] =
5633 TestConfig::COMMANDBUFFERTYPES_INLINE,
5634 TestConfig::COMMANDBUFFERTYPES_SECONDARY,
5635 TestConfig::COMMANDBUFFERTYPES_INLINE|TestConfig::COMMANDBUFFERTYPES_SECONDARY
5638 const TestConfig::ImageMemory imageMemories[] =
5640 TestConfig::IMAGEMEMORY_STRICT,
5641 TestConfig::IMAGEMEMORY_LAZY,
5642 TestConfig::IMAGEMEMORY_STRICT|TestConfig::IMAGEMEMORY_LAZY
5645 const UVec2 targetSizes[] =
5651 const UVec2 renderPositions[] =
5657 const UVec2 renderSizes[] =
5663 tcu::TestContext& testCtx (group->getTestContext());
5664 bool useDynamicRendering (testConfigExternal.groupParams->renderingType == RENDERING_TYPE_DYNAMIC_RENDERING);
5665 de::Random rng (1433774382u);
5667 for (size_t attachmentCountNdx = 0; attachmentCountNdx < DE_LENGTH_OF_ARRAY(attachmentCounts); attachmentCountNdx++)
5669 const deUint32 attachmentCount = attachmentCounts[attachmentCountNdx];
5670 const deUint32 testCaseCount = (attachmentCount == 1 ? 100 : 200);
5671 de::MovePtr<tcu::TestCaseGroup> attachmentCountGroup (new tcu::TestCaseGroup(testCtx, de::toString(attachmentCount).c_str(), de::toString(attachmentCount).c_str()));
5673 for (size_t testCaseNdx = 0; testCaseNdx < testCaseCount; testCaseNdx++)
5675 const bool useDepthStencil = rng.getBool();
5676 const TestConfig::ImageMemory imageMemory = rng.choose<TestConfig::ImageMemory>(DE_ARRAY_BEGIN(imageMemories), DE_ARRAY_END(imageMemories));
5677 VkImageLayout depthStencilLayout = VK_IMAGE_LAYOUT_GENERAL;
5678 vector<Attachment> attachments;
5679 vector<AttachmentReference> colorAttachmentReferences;
5681 // we want to make sure that dynamic rendering test cases have corresponding renderpass
5682 // cases as this will allow drivers to easily compare GPU batches; since configurations
5683 // for those tests are generated we need to generate configurations for all cases
5684 // even when we know earlier that for dynamic rendering we will skip it
5685 bool executeForDynamicRendering = true;
5687 for (size_t attachmentNdx = 0; attachmentNdx < attachmentCount; attachmentNdx++)
5689 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
5690 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreColorFormats), DE_ARRAY_END(s_coreColorFormats));
5691 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5692 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5694 const VkImageLayout initialLayout = (imageMemory == TestConfig::IMAGEMEMORY_STRICT)
5695 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts))
5696 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayoutsLazy), DE_ARRAY_END(initialAndFinalColorLayoutsLazy));
5697 VkImageLayout finalizeLayout = (imageMemory == TestConfig::IMAGEMEMORY_STRICT)
5698 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts))
5699 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayoutsLazy), DE_ARRAY_END(initialAndFinalColorLayoutsLazy));
5700 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayouts), DE_ARRAY_END(subpassLayouts));
5702 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5703 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5705 if (useDynamicRendering)
5707 // with renderpass we can have automatic layout transitions; to do the same with dynamic rendering cases
5708 // we would need to add addtional barries but since those tests won't add coverage we are skipping them
5709 if ((initialLayout == VK_IMAGE_LAYOUT_GENERAL) ||
5710 (initialLayout == VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL))
5711 finalizeLayout = initialLayout;
5713 executeForDynamicRendering = false;
5716 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5717 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
5720 if (useDepthStencil)
5722 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
5723 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreDepthStencilFormats), DE_ARRAY_END(s_coreDepthStencilFormats));
5724 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5725 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5727 const VkImageLayout initialLayout = (imageMemory == TestConfig::IMAGEMEMORY_STRICT)
5728 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
5729 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayoutsLazy), DE_ARRAY_END(initialAndFinalDepthStencilLayoutsLazy));
5730 VkImageLayout finalizeLayout = (imageMemory == TestConfig::IMAGEMEMORY_STRICT)
5731 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
5732 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayoutsLazy), DE_ARRAY_END(initialAndFinalDepthStencilLayoutsLazy));
5734 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5735 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5737 if (useDynamicRendering)
5739 if ((initialLayout == VK_IMAGE_LAYOUT_GENERAL) ||
5740 (initialLayout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL) ||
5741 (initialLayout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL))
5742 finalizeLayout = initialLayout;
5744 executeForDynamicRendering = false;
5747 depthStencilLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(depthStencilLayouts), DE_ARRAY_END(depthStencilLayouts));
5748 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5752 const TestConfig::RenderTypes render = rng.choose<TestConfig::RenderTypes>(DE_ARRAY_BEGIN(renderCommands), DE_ARRAY_END(renderCommands));
5753 const TestConfig::CommandBufferTypes commandBuffer = rng.choose<TestConfig::CommandBufferTypes>(DE_ARRAY_BEGIN(commandBuffers), DE_ARRAY_END(commandBuffers));
5754 const vector<Subpass> subpasses (1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u, vector<AttachmentReference>(), colorAttachmentReferences, vector<AttachmentReference>(), AttachmentReference((useDepthStencil ? (deUint32)(attachments.size() - 1) : VK_ATTACHMENT_UNUSED), depthStencilLayout), vector<deUint32>()));
5755 const vector<SubpassDependency> deps;
5756 const string testCaseName = de::toString(attachmentCountNdx * testCaseCount + testCaseNdx);
5757 const RenderPass renderPass (attachments, subpasses, deps);
5758 const UVec2 targetSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(targetSizes), DE_ARRAY_END(targetSizes));
5759 const UVec2 renderPos = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderPositions), DE_ARRAY_END(renderPositions));
5760 const UVec2 renderSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderSizes), DE_ARRAY_END(renderSizes));
5762 if (useDynamicRendering)
5764 // skip dynamic rendering cases (that don't add coverage) this can be done not earlier than after grabbing all
5765 // random numbers as we need to make sure that those tests that will be created for dynamic rendering have
5766 // corresponding renderpass tests with the same name
5767 if (!executeForDynamicRendering)
5770 // dont repeat non secondary buffer cases when testing secondaryCmdBufferCompletelyContainsDynamicRenderpass flag
5771 if (testConfigExternal.groupParams->secondaryCmdBufferCompletelyContainsDynamicRenderpass &&
5772 (commandBuffer != TestConfig::COMMANDBUFFERTYPES_SECONDARY))
5778 const TestConfig testConfig (renderPass,
5788 testConfigExternal.allocationKind,
5789 testConfigExternal.groupParams);
5791 addFunctionCaseWithPrograms<TestConfig>(attachmentCountGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, testConfig);
5795 group->addChild(attachmentCountGroup.release());
5799 void addAttachmentWriteMaskTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
5801 const deUint32 attachmentCounts[] = { 1, 2, 3, 4, 8 };
5803 const VkFormat attachmentFormats[] =
5805 VK_FORMAT_R8G8B8A8_UINT,
5806 VK_FORMAT_R8G8B8A8_UNORM,
5807 VK_FORMAT_R5G6B5_UNORM_PACK16,
5808 VK_FORMAT_R8G8_UNORM
5811 tcu::TestContext& testCtx = group->getTestContext();
5813 for (deUint32 attachmentCountNdx = 0; attachmentCountNdx < DE_LENGTH_OF_ARRAY(attachmentCounts); attachmentCountNdx++)
5815 const deUint32 attachmentCount = attachmentCounts[attachmentCountNdx];
5816 const string groupName = "attachment_count_" + de::toString(attachmentCount);
5818 de::MovePtr<tcu::TestCaseGroup> attachmentCountGroup(new tcu::TestCaseGroup(testCtx, groupName.c_str(), de::toString(attachmentCount).c_str()));
5820 for (deUint32 drawStartNdx = 0; drawStartNdx < (attachmentCount); drawStartNdx++)
5822 deUint32 formatNdx = 0;
5823 vector<Attachment> attachments;
5824 vector<AttachmentReference> colorAttachmentReferences;
5826 for (deUint32 attachmentNdx = 0; attachmentNdx < attachmentCount; attachmentNdx++)
5828 const VkFormat format = attachmentFormats[formatNdx];
5829 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
5830 const VkAttachmentLoadOp loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
5831 const VkAttachmentStoreOp storeOp = VK_ATTACHMENT_STORE_OP_STORE;
5832 const VkAttachmentLoadOp stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
5833 const VkAttachmentStoreOp stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
5834 const VkImageLayout initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
5835 const VkImageLayout finalizeLayout = (testConfigExternal.groupParams->renderingType == RENDERING_TYPE_DYNAMIC_RENDERING)
5836 ? initialLayout : VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
5837 const VkImageLayout subpassLayout = VK_IMAGE_LAYOUT_GENERAL;
5839 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5840 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
5842 if (++formatNdx == DE_LENGTH_OF_ARRAY(attachmentFormats))
5847 const VkImageLayout depthStencilLayout = VK_IMAGE_LAYOUT_GENERAL;
5848 const vector<Subpass> subpass (1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u, vector<AttachmentReference>(), colorAttachmentReferences, vector<AttachmentReference>(), AttachmentReference(VK_ATTACHMENT_UNUSED, depthStencilLayout), vector<deUint32>()));
5849 const vector<SubpassDependency> deps;
5851 const string testCaseName = "start_index_" + de::toString(drawStartNdx);
5852 const RenderPass renderPass (attachments, subpass, deps);
5854 const TestConfig::RenderTypes render = TestConfig::RENDERTYPES_DRAW;
5855 const TestConfig::CommandBufferTypes commandBuffer = TestConfig::COMMANDBUFFERTYPES_INLINE;
5856 const TestConfig::ImageMemory imageMemory = TestConfig::IMAGEMEMORY_LAZY;
5857 const UVec2 targetSize = UVec2(64, 64);
5858 const UVec2 renderPos = UVec2(0, 0);
5859 const UVec2 renderSize = UVec2(64, 64);
5860 const deBool useFormatCompCount = DE_TRUE;
5861 const vector<DeviceCoreFeature> requiredFeatures = {DEVICE_CORE_FEATURE_INDEPENDENT_BLEND};
5862 const TestConfig testConfig (renderPass,
5872 testConfigExternal.allocationKind,
5873 testConfigExternal.groupParams,
5876 addFunctionCaseWithPrograms<TestConfig>(attachmentCountGroup.get(), testCaseName.c_str(), testCaseName.c_str(), checkSupport, createTestShaders, renderPassTest, testConfig);
5880 group->addChild(attachmentCountGroup.release());
5884 template<typename T>
5885 T chooseRandom (de::Random& rng, const set<T>& values)
5887 size_t ndx = ((size_t)rng.getUint32()) % values.size();
5888 typename set<T>::const_iterator iter = values.begin();
5890 for (; ndx > 0; ndx--)
5896 void addAttachmentAllocationTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
5898 const deUint32 attachmentCounts[] = { 4, 8 };
5899 const VkAttachmentLoadOp loadOps[] =
5901 VK_ATTACHMENT_LOAD_OP_LOAD,
5902 VK_ATTACHMENT_LOAD_OP_CLEAR,
5903 VK_ATTACHMENT_LOAD_OP_DONT_CARE
5906 const VkAttachmentStoreOp storeOps[] =
5908 VK_ATTACHMENT_STORE_OP_STORE,
5909 VK_ATTACHMENT_STORE_OP_DONT_CARE
5912 const VkImageLayout initialAndFinalColorLayouts[] =
5914 VK_IMAGE_LAYOUT_GENERAL,
5915 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5916 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
5917 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
5918 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
5921 const VkImageLayout initialAndFinalDepthStencilLayouts[] =
5923 VK_IMAGE_LAYOUT_GENERAL,
5924 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5925 VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL,
5926 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
5927 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
5928 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
5931 const VkImageLayout subpassLayoutsColor[] =
5933 VK_IMAGE_LAYOUT_GENERAL,
5934 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
5937 const VkImageLayout subpassLayoutsDepthStencil[] =
5939 VK_IMAGE_LAYOUT_GENERAL,
5940 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
5943 const VkImageLayout subpassLayoutsInput[] =
5945 VK_IMAGE_LAYOUT_GENERAL,
5946 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
5951 // Each pass uses one more attachmen than previous one
5952 ALLOCATIONTYPE_GROW,
5953 // Each pass uses one less attachment than previous one
5954 ALLOCATIONTYPE_SHRINK,
5955 // Each pass drops one attachment and picks up new one
5956 ALLOCATIONTYPE_ROLL,
5957 // Start by growing and end by shrinking
5958 ALLOCATIONTYPE_GROW_SHRINK,
5959 // Each subpass has single input and single output attachment
5960 ALLOCATIONTYPE_IO_CHAIN,
5961 // Each subpass has multiple inputs and multiple outputs attachment
5962 ALLOCATIONTYPE_IO_GENERIC
5965 const AllocationType allocationTypes[] =
5967 ALLOCATIONTYPE_GROW,
5968 ALLOCATIONTYPE_SHRINK,
5969 ALLOCATIONTYPE_ROLL,
5970 ALLOCATIONTYPE_GROW_SHRINK,
5971 ALLOCATIONTYPE_IO_CHAIN,
5972 ALLOCATIONTYPE_IO_GENERIC
5975 const char* const allocationTypeStr[] =
5981 "input_output_chain",
5985 const TestConfig::RenderTypes renderCommands[] =
5987 TestConfig::RENDERTYPES_NONE,
5988 TestConfig::RENDERTYPES_CLEAR,
5989 TestConfig::RENDERTYPES_DRAW,
5990 TestConfig::RENDERTYPES_CLEAR|TestConfig::RENDERTYPES_DRAW,
5993 const TestConfig::CommandBufferTypes commandBuffers[] =
5995 TestConfig::COMMANDBUFFERTYPES_INLINE,
5996 TestConfig::COMMANDBUFFERTYPES_SECONDARY,
5997 TestConfig::COMMANDBUFFERTYPES_INLINE|TestConfig::COMMANDBUFFERTYPES_SECONDARY
6000 const TestConfig::ImageMemory imageMemories[] =
6002 TestConfig::IMAGEMEMORY_STRICT,
6003 TestConfig::IMAGEMEMORY_LAZY,
6004 TestConfig::IMAGEMEMORY_STRICT|TestConfig::IMAGEMEMORY_LAZY
6007 const UVec2 targetSizes[] =
6013 const UVec2 renderPositions[] =
6019 const UVec2 renderSizes[] =
6025 tcu::TestContext& testCtx = group->getTestContext();
6026 de::Random rng (3700649827u);
6028 for (size_t allocationTypeNdx = 0; allocationTypeNdx < DE_LENGTH_OF_ARRAY(allocationTypes); allocationTypeNdx++)
6030 const AllocationType allocationType = allocationTypes[allocationTypeNdx];
6031 const size_t testCaseCount = 100;
6032 de::MovePtr<tcu::TestCaseGroup> allocationTypeGroup (new tcu::TestCaseGroup(testCtx, allocationTypeStr[allocationTypeNdx], allocationTypeStr[allocationTypeNdx]));
6034 for (size_t testCaseNdx = 0; testCaseNdx < testCaseCount; testCaseNdx++)
6036 if (allocationType == ALLOCATIONTYPE_IO_GENERIC)
6038 const deUint32 attachmentCount = 4u + rng.getUint32() % 31u;
6039 const deUint32 subpassCount = 4u + rng.getUint32() % 31u;
6040 vector<Attachment> attachments;
6042 set<deUint32> definedAttachments;
6044 vector<Subpass> subpasses;
6045 set<deUint32> colorAttachments;
6046 set<deUint32> depthStencilAttachments;
6048 for (deUint32 attachmentIndex = 0; attachmentIndex < attachmentCount; attachmentIndex++)
6050 const bool isDepthStencilAttachment = rng.getFloat() < 0.01f;
6051 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
6052 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
6053 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
6055 const VkImageLayout initialLayout = isDepthStencilAttachment
6056 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
6057 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
6058 const VkImageLayout finalizeLayout = isDepthStencilAttachment
6059 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
6060 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
6062 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
6063 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
6065 if (isDepthStencilAttachment)
6067 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreDepthStencilFormats), DE_ARRAY_END(s_coreDepthStencilFormats));
6069 if (loadOp == VK_ATTACHMENT_LOAD_OP_LOAD || loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR
6070 || stencilLoadOp == VK_ATTACHMENT_LOAD_OP_LOAD || stencilLoadOp == VK_ATTACHMENT_LOAD_OP_CLEAR)
6071 definedAttachments.insert(attachmentIndex);
6073 depthStencilAttachments.insert(attachmentIndex);
6075 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
6079 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreColorFormats), DE_ARRAY_END(s_coreColorFormats));
6081 if (loadOp == VK_ATTACHMENT_LOAD_OP_LOAD || loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR)
6082 definedAttachments.insert(attachmentIndex);
6084 colorAttachments.insert(attachmentIndex);
6086 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
6089 vector<Maybe<deUint32> > lastUseOfAttachment (attachments.size(), tcu::Nothing);
6090 vector<SubpassDependency> deps;
6092 for (deUint32 subpassIndex = 0; subpassIndex < subpassCount; subpassIndex++)
6094 const deUint32 colorAttachmentCount = depthStencilAttachments.empty()
6095 ? 1 + rng.getUint32() % de::min(4u, (deUint32)colorAttachments.size())
6096 : rng.getUint32() % (de::min(4u, (deUint32)colorAttachments.size()) + 1u);
6097 const deUint32 inputAttachmentCount = rng.getUint32() % (deUint32)(de::min<size_t>(4, definedAttachments.size()) + 1);
6098 const bool useDepthStencilAttachment = !depthStencilAttachments.empty() && (colorAttachmentCount == 0 || rng.getBool());
6099 std::vector<deUint32> subpassColorAttachments (colorAttachmentCount);
6100 std::vector<deUint32> subpassInputAttachments (inputAttachmentCount);
6101 Maybe<deUint32> depthStencilAttachment (useDepthStencilAttachment
6102 ? just(chooseRandom(rng, depthStencilAttachments))
6104 std::vector<deUint32> subpassPreserveAttachments;
6106 rng.choose(colorAttachments.begin(), colorAttachments.end(), subpassColorAttachments.begin(), colorAttachmentCount);
6107 rng.choose(definedAttachments.begin(), definedAttachments.end(), subpassInputAttachments.begin(), inputAttachmentCount);
6109 for (size_t colorAttachmentNdx = 0; colorAttachmentNdx < subpassColorAttachments.size(); colorAttachmentNdx++)
6110 definedAttachments.insert(subpassColorAttachments[colorAttachmentNdx]);
6112 if (depthStencilAttachment)
6113 definedAttachments.insert(*depthStencilAttachment);
6116 std::vector<AttachmentReference> inputAttachmentReferences;
6117 std::vector<AttachmentReference> colorAttachmentReferences;
6118 AttachmentReference depthStencilAttachmentReference (VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL);
6120 for (size_t colorAttachmentNdx = 0; colorAttachmentNdx < subpassColorAttachments.size(); colorAttachmentNdx++)
6122 const deUint32 colorAttachmentIndex = subpassColorAttachments[colorAttachmentNdx];
6124 if (lastUseOfAttachment[colorAttachmentIndex])
6126 deBool foundDuplicate = false;
6128 const deUint32 srcPass = *lastUseOfAttachment[colorAttachmentIndex];
6129 const deUint32 dstPass = subpassIndex;
6130 const VkDependencyFlags dependencyFlags = rng.getBool() ? (VkDependencyFlags) VK_DEPENDENCY_BY_REGION_BIT : 0u;
6132 const SubpassDependency newDependency(srcPass, dstPass,
6133 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
6134 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
6135 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
6136 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6138 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
6139 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
6140 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
6141 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6143 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6144 VK_ACCESS_COLOR_ATTACHMENT_READ_BIT,
6148 for (SubpassDependency& dependency : deps)
6150 if (dependency.getSrcPass() == srcPass && dependency.getDstPass() == dstPass)
6152 const VkAccessFlags newDstFlags = dependency.getDstAccessMask() | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT;
6153 dependency.setDstAccessMask(newDstFlags);
6154 foundDuplicate = true;
6159 if (!foundDuplicate)
6161 deps.push_back(newDependency);
6165 lastUseOfAttachment[colorAttachmentIndex] = just(subpassIndex);
6167 colorAttachmentReferences.push_back(AttachmentReference((deUint32)subpassColorAttachments[colorAttachmentNdx], VK_IMAGE_LAYOUT_GENERAL));
6170 for (size_t inputAttachmentNdx = 0; inputAttachmentNdx < subpassInputAttachments.size(); inputAttachmentNdx++)
6172 const deUint32 inputAttachmentIndex = subpassInputAttachments[inputAttachmentNdx];
6174 if(lastUseOfAttachment[inputAttachmentIndex])
6176 deBool foundDuplicate = false;
6178 const deUint32 srcPass = *lastUseOfAttachment[inputAttachmentIndex];
6179 const deUint32 dstPass = subpassIndex;
6180 const VkDependencyFlags dependencyFlags = ((srcPass == subpassIndex) || rng.getBool()) ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u;
6182 const SubpassDependency newDependency(srcPass, dstPass,
6183 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
6184 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
6185 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
6186 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6188 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
6189 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
6190 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
6191 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6193 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
6194 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6197 for (SubpassDependency& dependency : deps)
6199 if (dependency.getSrcPass() == srcPass && dependency.getDstPass() == dstPass)
6201 const VkAccessFlags newSrcFlags = dependency.getSrcAccessMask() | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
6202 const VkAccessFlags newDstFlags = dependency.getDstAccessMask() | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT;
6203 dependency.setDstAccessMask(newSrcFlags);
6204 dependency.setDstAccessMask(newDstFlags);
6205 foundDuplicate = true;
6210 if (!foundDuplicate)
6212 deps.push_back(newDependency);
6215 lastUseOfAttachment[inputAttachmentIndex] = just(subpassIndex);
6217 VkImageAspectFlags aspect = 0u;
6218 if (testConfigExternal.groupParams->renderingType == RENDERING_TYPE_RENDERPASS2)
6220 bool col = colorAttachments.find(inputAttachmentIndex) != colorAttachments.end();
6221 aspect = col ? VK_IMAGE_ASPECT_COLOR_BIT : VK_IMAGE_ASPECT_DEPTH_BIT;
6223 inputAttachmentReferences.push_back(AttachmentReference((deUint32)subpassInputAttachments[inputAttachmentNdx], VK_IMAGE_LAYOUT_GENERAL, aspect));
6227 if (depthStencilAttachment)
6229 if (lastUseOfAttachment[*depthStencilAttachment])
6231 deBool foundDuplicate = false;
6233 const deUint32 srcPass = *lastUseOfAttachment[*depthStencilAttachment];
6234 const deUint32 dstPass = subpassIndex;
6235 const VkDependencyFlags dependencyFlags = ((srcPass == subpassIndex) || rng.getBool()) ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u;
6237 const SubpassDependency newDependency(srcPass, dstPass,
6238 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
6239 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
6240 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
6241 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6243 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
6244 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
6245 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
6246 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6248 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
6249 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT
6250 | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6253 for (SubpassDependency& dependency : deps)
6255 if (dependency.getSrcPass() == srcPass && dependency.getDstPass() == dstPass)
6257 const VkAccessFlags newSrcFlags = dependency.getSrcAccessMask() | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
6258 const VkAccessFlags newDstFlags = dependency.getDstAccessMask() | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT;
6259 dependency.setDstAccessMask(newSrcFlags);
6260 dependency.setDstAccessMask(newDstFlags);
6261 foundDuplicate = true;
6266 if (!foundDuplicate)
6268 deps.push_back(newDependency);
6272 lastUseOfAttachment[*depthStencilAttachment] = just(subpassIndex);
6274 depthStencilAttachmentReference = AttachmentReference(*depthStencilAttachment, VK_IMAGE_LAYOUT_GENERAL);
6277 depthStencilAttachmentReference = AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL);
6279 vector<deUint32> preserveAttachments;
6280 for (deUint32 attachmentIndex = 0; attachmentIndex < (deUint32)attachments.size(); attachmentIndex++)
6282 if (lastUseOfAttachment[attachmentIndex] && (*lastUseOfAttachment[attachmentIndex]) != subpassIndex)
6283 preserveAttachments.push_back(attachmentIndex);
6286 // Use random image layout when possible
6287 for (size_t colorRefIdx = 0; colorRefIdx < colorAttachmentReferences.size(); ++colorRefIdx)
6289 bool usedAsInput = false;
6290 for (size_t inputRefIdx = 0; inputRefIdx < inputAttachmentReferences.size(); ++inputRefIdx)
6291 if (colorAttachmentReferences[colorRefIdx].getAttachment() == inputAttachmentReferences[inputRefIdx].getAttachment())
6295 colorAttachmentReferences[colorRefIdx].setImageLayout(rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor)));
6297 for (size_t inputRefIdx = 0; inputRefIdx < inputAttachmentReferences.size(); ++inputRefIdx)
6299 bool usedAsDepthStencil = inputAttachmentReferences[inputRefIdx].getAttachment() == depthStencilAttachmentReference.getAttachment();
6300 bool usedAsColor = false;
6301 for (size_t colorRefIdx = 0; colorRefIdx < colorAttachmentReferences.size(); ++colorRefIdx)
6302 if (inputAttachmentReferences[inputRefIdx].getAttachment() == colorAttachmentReferences[colorRefIdx].getAttachment())
6305 if (!usedAsColor && !usedAsDepthStencil)
6306 inputAttachmentReferences[inputRefIdx].setImageLayout(rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsInput), DE_ARRAY_END(subpassLayoutsInput)));
6309 bool usedAsInput = false;
6310 for (size_t inputRefIdx = 0; inputRefIdx < inputAttachmentReferences.size(); ++inputRefIdx)
6311 if (depthStencilAttachmentReference.getAttachment() == inputAttachmentReferences[inputRefIdx].getAttachment())
6315 depthStencilAttachmentReference.setImageLayout(rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsDepthStencil), DE_ARRAY_END(subpassLayoutsDepthStencil)));
6318 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6319 inputAttachmentReferences,
6320 colorAttachmentReferences,
6321 vector<AttachmentReference>(),
6322 depthStencilAttachmentReference,
6323 preserveAttachments));
6327 const TestConfig::RenderTypes render = rng.choose<TestConfig::RenderTypes>(DE_ARRAY_BEGIN(renderCommands), DE_ARRAY_END(renderCommands));
6328 const TestConfig::CommandBufferTypes commandBuffer = rng.choose<TestConfig::CommandBufferTypes>(DE_ARRAY_BEGIN(commandBuffers), DE_ARRAY_END(commandBuffers));
6329 const TestConfig::ImageMemory imageMemory = rng.choose<TestConfig::ImageMemory>(DE_ARRAY_BEGIN(imageMemories), DE_ARRAY_END(imageMemories));
6331 const string testCaseName = de::toString(testCaseNdx);
6332 const UVec2 targetSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(targetSizes), DE_ARRAY_END(targetSizes));
6333 const UVec2 renderPos = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderPositions), DE_ARRAY_END(renderPositions));
6334 const UVec2 renderSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderSizes), DE_ARRAY_END(renderSizes));
6336 const RenderPass renderPass (attachments, subpasses, deps);
6337 const TestConfig testConfig (renderPass,
6347 testConfigExternal.allocationKind,
6348 testConfigExternal.groupParams);
6350 addFunctionCaseWithPrograms<TestConfig>(allocationTypeGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, testConfig);
6355 const deUint32 attachmentCount = rng.choose<deUint32>(DE_ARRAY_BEGIN(attachmentCounts), DE_ARRAY_END(attachmentCounts));
6356 vector<Attachment> attachments;
6357 vector<Subpass> subpasses;
6359 for (size_t attachmentNdx = 0; attachmentNdx < attachmentCount; attachmentNdx++)
6361 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
6362 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreColorFormats), DE_ARRAY_END(s_coreColorFormats));
6363 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
6364 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
6366 const VkImageLayout initialLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
6367 const VkImageLayout finalizeLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
6369 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
6370 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
6372 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
6375 if (allocationType == ALLOCATIONTYPE_GROW)
6377 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
6379 vector<AttachmentReference> colorAttachmentReferences;
6381 for (size_t attachmentNdx = 0; attachmentNdx < subpassNdx + 1; attachmentNdx++)
6383 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6385 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
6388 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6389 vector<AttachmentReference>(),
6390 colorAttachmentReferences,
6391 vector<AttachmentReference>(),
6392 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6393 vector<deUint32>()));
6396 else if (allocationType == ALLOCATIONTYPE_SHRINK)
6398 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
6400 vector<AttachmentReference> colorAttachmentReferences;
6402 for (size_t attachmentNdx = 0; attachmentNdx < (attachmentCount - subpassNdx); attachmentNdx++)
6404 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6406 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
6409 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6410 vector<AttachmentReference>(),
6411 colorAttachmentReferences,
6412 vector<AttachmentReference>(),
6413 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6414 vector<deUint32>()));
6417 else if (allocationType == ALLOCATIONTYPE_ROLL)
6419 for (size_t subpassNdx = 0; subpassNdx < attachmentCount / 2; subpassNdx++)
6421 vector<AttachmentReference> colorAttachmentReferences;
6423 for (size_t attachmentNdx = 0; attachmentNdx < attachmentCount / 2; attachmentNdx++)
6425 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6427 colorAttachmentReferences.push_back(AttachmentReference((deUint32)(subpassNdx + attachmentNdx), subpassLayout));
6430 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6431 vector<AttachmentReference>(),
6432 colorAttachmentReferences,
6433 vector<AttachmentReference>(),
6434 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6435 vector<deUint32>()));
6438 else if (allocationType == ALLOCATIONTYPE_GROW_SHRINK)
6440 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
6442 vector<AttachmentReference> colorAttachmentReferences;
6444 for (size_t attachmentNdx = 0; attachmentNdx < subpassNdx + 1; attachmentNdx++)
6446 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6448 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
6451 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6452 vector<AttachmentReference>(),
6453 colorAttachmentReferences,
6454 vector<AttachmentReference>(),
6455 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6456 vector<deUint32>()));
6458 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
6460 vector<AttachmentReference> colorAttachmentReferences;
6462 for (size_t attachmentNdx = 0; attachmentNdx < (attachmentCount - subpassNdx); attachmentNdx++)
6464 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6466 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
6469 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6470 vector<AttachmentReference>(),
6471 colorAttachmentReferences,
6472 vector<AttachmentReference>(),
6473 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6474 vector<deUint32>()));
6477 else if (allocationType == ALLOCATIONTYPE_IO_CHAIN)
6479 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6480 vector<AttachmentReference>(),
6481 vector<AttachmentReference>(1, AttachmentReference(0, rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor)))),
6482 vector<AttachmentReference>(),
6483 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6484 vector<deUint32>()));
6486 for (size_t subpassNdx = 1; subpassNdx < attachmentCount; subpassNdx++)
6488 const VkImageAspectFlags inputAttachmentAspectMask = (testConfigExternal.groupParams->renderingType == RENDERING_TYPE_RENDERPASS2) ? VK_IMAGE_ASPECT_COLOR_BIT : static_cast<VkImageAspectFlagBits>(0);
6489 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6490 vector<AttachmentReference>(1, AttachmentReference((deUint32)(subpassNdx - 1), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
6491 vector<AttachmentReference>(1, AttachmentReference((deUint32)(subpassNdx), rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor)))),
6492 vector<AttachmentReference>(),
6493 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6494 vector<deUint32>()));
6498 DE_FATAL("Unknown allocation type");
6501 const TestConfig::RenderTypes render = rng.choose<TestConfig::RenderTypes>(DE_ARRAY_BEGIN(renderCommands), DE_ARRAY_END(renderCommands));
6502 const TestConfig::CommandBufferTypes commandBuffer = rng.choose<TestConfig::CommandBufferTypes>(DE_ARRAY_BEGIN(commandBuffers), DE_ARRAY_END(commandBuffers));
6503 const TestConfig::ImageMemory imageMemory = rng.choose<TestConfig::ImageMemory>(DE_ARRAY_BEGIN(imageMemories), DE_ARRAY_END(imageMemories));
6505 const string testCaseName = de::toString(testCaseNdx);
6506 const UVec2 targetSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(targetSizes), DE_ARRAY_END(targetSizes));
6507 const UVec2 renderPos = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderPositions), DE_ARRAY_END(renderPositions));
6508 const UVec2 renderSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderSizes), DE_ARRAY_END(renderSizes));
6510 vector<SubpassDependency> deps;
6512 for (size_t subpassNdx = 0; subpassNdx < subpasses.size() - 1; subpassNdx++)
6514 const bool byRegion = rng.getBool();
6515 deps.push_back(SubpassDependency((deUint32)subpassNdx, (deUint32)subpassNdx + 1,
6516 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
6517 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
6518 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
6519 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6521 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
6522 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
6523 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
6524 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6526 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6527 (VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT),
6529 byRegion ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u));
6532 const RenderPass renderPass (attachments, subpasses, deps);
6533 const TestConfig testConfig (renderPass,
6543 testConfigExternal.allocationKind,
6544 testConfigExternal.groupParams);
6546 addFunctionCaseWithPrograms<TestConfig>(allocationTypeGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, testConfig);
6550 group->addChild(allocationTypeGroup.release());
6554 void addSimpleTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
6556 const UVec2 targetSize (64, 64);
6557 const UVec2 renderPos (0, 0);
6558 const UVec2 renderSize (64, 64);
6562 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6563 VK_SAMPLE_COUNT_1_BIT,
6564 VK_ATTACHMENT_LOAD_OP_CLEAR,
6565 VK_ATTACHMENT_STORE_OP_STORE,
6566 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6567 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6568 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6569 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6570 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6572 vector<AttachmentReference>(),
6573 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6574 vector<AttachmentReference>(),
6575 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6576 vector<deUint32>())),
6577 vector<SubpassDependency>());
6578 const TestConfig testConfig (renderPass,
6579 TestConfig::RENDERTYPES_DRAW,
6580 TestConfig::COMMANDBUFFERTYPES_INLINE,
6581 TestConfig::IMAGEMEMORY_STRICT,
6588 testConfigExternal.allocationKind,
6589 testConfigExternal.groupParams);
6591 addFunctionCaseWithPrograms<TestConfig>(group, "color", "Single color attachment case.", createTestShaders, renderPassTest, testConfig);
6596 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_X8_D24_UNORM_PACK32,
6597 VK_SAMPLE_COUNT_1_BIT,
6598 VK_ATTACHMENT_LOAD_OP_CLEAR,
6599 VK_ATTACHMENT_STORE_OP_STORE,
6600 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6601 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6602 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6603 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6604 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6606 vector<AttachmentReference>(),
6607 vector<AttachmentReference>(),
6608 vector<AttachmentReference>(),
6609 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6610 vector<deUint32>())),
6611 vector<SubpassDependency>());
6612 const TestConfig testConfig (renderPass,
6613 TestConfig::RENDERTYPES_DRAW,
6614 TestConfig::COMMANDBUFFERTYPES_INLINE,
6615 TestConfig::IMAGEMEMORY_STRICT,
6622 testConfigExternal.allocationKind,
6623 testConfigExternal.groupParams);
6625 addFunctionCaseWithPrograms<TestConfig>(group, "depth", "Single depth attachment case.", createTestShaders, renderPassTest, testConfig);
6630 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_S8_UINT,
6631 VK_SAMPLE_COUNT_1_BIT,
6632 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6633 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6634 VK_ATTACHMENT_LOAD_OP_CLEAR,
6635 VK_ATTACHMENT_STORE_OP_STORE,
6636 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6637 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6638 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6640 vector<AttachmentReference>(),
6641 vector<AttachmentReference>(),
6642 vector<AttachmentReference>(),
6643 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6644 vector<deUint32>())),
6645 vector<SubpassDependency>());
6646 const TestConfig testConfig (renderPass,
6647 TestConfig::RENDERTYPES_DRAW,
6648 TestConfig::COMMANDBUFFERTYPES_INLINE,
6649 TestConfig::IMAGEMEMORY_STRICT,
6656 testConfigExternal.allocationKind,
6657 testConfigExternal.groupParams);
6659 addFunctionCaseWithPrograms<TestConfig>(group, "stencil", "Single stencil attachment case.", createTestShaders, renderPassTest, testConfig);
6664 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_D24_UNORM_S8_UINT,
6665 VK_SAMPLE_COUNT_1_BIT,
6666 VK_ATTACHMENT_LOAD_OP_CLEAR,
6667 VK_ATTACHMENT_STORE_OP_STORE,
6668 VK_ATTACHMENT_LOAD_OP_CLEAR,
6669 VK_ATTACHMENT_STORE_OP_STORE,
6670 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6671 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6672 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6674 vector<AttachmentReference>(),
6675 vector<AttachmentReference>(),
6676 vector<AttachmentReference>(),
6677 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6678 vector<deUint32>())),
6679 vector<SubpassDependency>());
6680 const TestConfig testConfig (renderPass,
6681 TestConfig::RENDERTYPES_DRAW,
6682 TestConfig::COMMANDBUFFERTYPES_INLINE,
6683 TestConfig::IMAGEMEMORY_STRICT,
6690 testConfigExternal.allocationKind,
6691 testConfigExternal.groupParams);
6693 addFunctionCaseWithPrograms<TestConfig>(group, "depth_stencil", "Single depth stencil attachment case.", createTestShaders, renderPassTest, testConfig);
6698 const Attachment attachments[] =
6700 Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6701 VK_SAMPLE_COUNT_1_BIT,
6702 VK_ATTACHMENT_LOAD_OP_CLEAR,
6703 VK_ATTACHMENT_STORE_OP_STORE,
6704 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6705 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6706 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6707 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL),
6708 Attachment(VK_FORMAT_X8_D24_UNORM_PACK32,
6709 VK_SAMPLE_COUNT_1_BIT,
6710 VK_ATTACHMENT_LOAD_OP_CLEAR,
6711 VK_ATTACHMENT_STORE_OP_STORE,
6712 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6713 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6714 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6715 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6718 const RenderPass renderPass (vector<Attachment>(DE_ARRAY_BEGIN(attachments), DE_ARRAY_END(attachments)),
6719 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6721 vector<AttachmentReference>(),
6722 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6723 vector<AttachmentReference>(),
6724 AttachmentReference(1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6725 vector<deUint32>())),
6726 vector<SubpassDependency>());
6727 const TestConfig testConfig (renderPass,
6728 TestConfig::RENDERTYPES_DRAW,
6729 TestConfig::COMMANDBUFFERTYPES_INLINE,
6730 TestConfig::IMAGEMEMORY_STRICT,
6737 testConfigExternal.allocationKind,
6738 testConfigExternal.groupParams);
6740 addFunctionCaseWithPrograms<TestConfig>(group, "color_depth", "Color and depth attachment case.", createTestShaders, renderPassTest, testConfig);
6745 const Attachment attachments[] =
6747 Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6748 VK_SAMPLE_COUNT_1_BIT,
6749 VK_ATTACHMENT_LOAD_OP_CLEAR,
6750 VK_ATTACHMENT_STORE_OP_STORE,
6751 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6752 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6753 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6754 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL),
6755 Attachment(VK_FORMAT_S8_UINT,
6756 VK_SAMPLE_COUNT_1_BIT,
6757 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6758 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6759 VK_ATTACHMENT_LOAD_OP_CLEAR,
6760 VK_ATTACHMENT_STORE_OP_STORE,
6761 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6762 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6765 const RenderPass renderPass (vector<Attachment>(DE_ARRAY_BEGIN(attachments), DE_ARRAY_END(attachments)),
6766 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6768 vector<AttachmentReference>(),
6769 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6770 vector<AttachmentReference>(),
6771 AttachmentReference(1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6772 vector<deUint32>())),
6773 vector<SubpassDependency>());
6774 const TestConfig testConfig (renderPass,
6775 TestConfig::RENDERTYPES_DRAW,
6776 TestConfig::COMMANDBUFFERTYPES_INLINE,
6777 TestConfig::IMAGEMEMORY_STRICT,
6784 testConfigExternal.allocationKind,
6785 testConfigExternal.groupParams);
6787 addFunctionCaseWithPrograms<TestConfig>(group, "color_stencil", "Color and stencil attachment case.", createTestShaders, renderPassTest, testConfig);
6790 // color_depth_stencil
6792 const Attachment attachments[] =
6794 Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6795 VK_SAMPLE_COUNT_1_BIT,
6796 VK_ATTACHMENT_LOAD_OP_CLEAR,
6797 VK_ATTACHMENT_STORE_OP_STORE,
6798 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6799 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6800 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6801 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL),
6802 Attachment(VK_FORMAT_D24_UNORM_S8_UINT,
6803 VK_SAMPLE_COUNT_1_BIT,
6804 VK_ATTACHMENT_LOAD_OP_CLEAR,
6805 VK_ATTACHMENT_STORE_OP_STORE,
6806 VK_ATTACHMENT_LOAD_OP_CLEAR,
6807 VK_ATTACHMENT_STORE_OP_STORE,
6808 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6809 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6812 const RenderPass renderPass (vector<Attachment>(DE_ARRAY_BEGIN(attachments), DE_ARRAY_END(attachments)),
6813 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6815 vector<AttachmentReference>(),
6816 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6817 vector<AttachmentReference>(),
6818 AttachmentReference(1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6819 vector<deUint32>())),
6820 vector<SubpassDependency>());
6821 const TestConfig testConfig (renderPass,
6822 TestConfig::RENDERTYPES_DRAW,
6823 TestConfig::COMMANDBUFFERTYPES_INLINE,
6824 TestConfig::IMAGEMEMORY_STRICT,
6831 testConfigExternal.allocationKind,
6832 testConfigExternal.groupParams);
6834 addFunctionCaseWithPrograms<TestConfig>(group, "color_depth_stencil", "Color, depth and stencil attachment case.", createTestShaders, renderPassTest, testConfig);
6839 const RenderPass renderPass (vector<Attachment>(),
6840 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6842 vector<AttachmentReference>(),
6843 vector<AttachmentReference>(),
6844 vector<AttachmentReference>(),
6845 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6846 vector<deUint32>())),
6847 vector<SubpassDependency>());
6848 const TestConfig testConfig (renderPass,
6849 TestConfig::RENDERTYPES_DRAW,
6850 TestConfig::COMMANDBUFFERTYPES_INLINE,
6851 TestConfig::IMAGEMEMORY_STRICT,
6858 testConfigExternal.allocationKind,
6859 testConfigExternal.groupParams);
6861 addFunctionCaseWithPrograms<TestConfig>(group, "no_attachments", "No attachments case.", createTestShaders, renderPassTest, testConfig);
6864 // color_unused_omit_blend_state
6865 if (testConfigExternal.groupParams->renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
6867 vector<Subpass> subpasses;
6869 // First subpass: use color attachment, create pipeline with color blend state
6870 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6872 vector<AttachmentReference>(),
6873 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6874 vector<AttachmentReference>(),
6875 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6879 // Second subpass: don't use color attachment, create pipeline without color blend state
6880 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6882 vector<AttachmentReference>(),
6883 vector<AttachmentReference>(1, AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6884 vector<AttachmentReference>(),
6885 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6889 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6890 VK_SAMPLE_COUNT_1_BIT,
6891 VK_ATTACHMENT_LOAD_OP_CLEAR,
6892 VK_ATTACHMENT_STORE_OP_STORE,
6893 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6894 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6895 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6896 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6898 vector<SubpassDependency>());
6900 const TestConfig testConfig (renderPass,
6901 TestConfig::RENDERTYPES_DRAW,
6902 TestConfig::COMMANDBUFFERTYPES_INLINE,
6903 TestConfig::IMAGEMEMORY_STRICT,
6910 testConfigExternal.allocationKind,
6911 testConfigExternal.groupParams);
6912 addFunctionCaseWithPrograms<TestConfig>(group, "color_unused_omit_blend_state", "Two unused color attachment case without blend state", createTestShaders, renderPassTest, testConfig);
6916 std::string formatToName (VkFormat format)
6918 const std::string formatStr = de::toString(format);
6919 const std::string prefix = "VK_FORMAT_";
6921 DE_ASSERT(formatStr.substr(0, prefix.length()) == prefix);
6923 return de::toLower(formatStr.substr(prefix.length()));
6926 void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
6928 tcu::TestContext& testCtx = group->getTestContext();
6930 const UVec2 targetSize (64, 64);
6931 const UVec2 renderPos (0, 0);
6932 const UVec2 renderSize (64, 64);
6936 const char* const str;
6937 const VkAttachmentStoreOp op;
6940 { "store", VK_ATTACHMENT_STORE_OP_STORE },
6941 { "dont_care", VK_ATTACHMENT_STORE_OP_DONT_CARE }
6946 const char* const str;
6947 const VkAttachmentLoadOp op;
6950 { "clear", VK_ATTACHMENT_LOAD_OP_CLEAR },
6951 { "load", VK_ATTACHMENT_LOAD_OP_LOAD },
6952 { "dont_care", VK_ATTACHMENT_LOAD_OP_DONT_CARE }
6957 const char* const str;
6958 const TestConfig::RenderTypes types;
6961 { "clear", TestConfig::RENDERTYPES_CLEAR },
6962 { "draw", TestConfig::RENDERTYPES_DRAW },
6963 { "clear_draw", TestConfig::RENDERTYPES_CLEAR|TestConfig::RENDERTYPES_DRAW }
6967 for (size_t formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_coreColorFormats); formatNdx++)
6969 const VkFormat format = s_coreColorFormats[formatNdx];
6970 de::MovePtr<tcu::TestCaseGroup> formatGroup (new tcu::TestCaseGroup(testCtx, formatToName(format).c_str(), de::toString(format).c_str()));
6972 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
6974 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
6975 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
6977 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
6979 const RenderPass renderPass (vector<Attachment>(1, Attachment(format,
6980 VK_SAMPLE_COUNT_1_BIT,
6982 VK_ATTACHMENT_STORE_OP_STORE,
6983 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6984 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6985 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6986 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6987 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6989 vector<AttachmentReference>(),
6990 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6991 vector<AttachmentReference>(),
6992 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6993 vector<deUint32>())),
6994 vector<SubpassDependency>());
6995 const TestConfig testConfig (renderPass,
6996 renderTypes[renderTypeNdx].types,
6997 TestConfig::COMMANDBUFFERTYPES_INLINE,
6998 TestConfig::IMAGEMEMORY_STRICT,
7005 testConfigExternal.allocationKind,
7006 testConfigExternal.groupParams);
7008 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), renderTypes[renderTypeNdx].str, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7011 formatGroup->addChild(loadOpGroup.release());
7014 if (testConfigExternal.groupParams->renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
7016 de::MovePtr<tcu::TestCaseGroup> inputGroup (new tcu::TestCaseGroup(testCtx, "input", "Test attachment format as input"));
7018 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
7020 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
7021 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
7023 for (size_t storeOpNdx = 0; storeOpNdx < DE_LENGTH_OF_ARRAY(storeOps); storeOpNdx++)
7025 const VkImageAspectFlags inputAttachmentAspectMask = (testConfigExternal.groupParams->renderingType == RENDERING_TYPE_RENDERPASS2)
7026 ? static_cast<VkImageAspectFlags>(VK_IMAGE_ASPECT_COLOR_BIT)
7027 : static_cast<VkImageAspectFlags>(0);
7028 const VkAttachmentStoreOp storeOp = storeOps[storeOpNdx].op;
7029 de::MovePtr<tcu::TestCaseGroup> storeOpGroup (new tcu::TestCaseGroup(testCtx, storeOps[storeOpNdx].str, storeOps[storeOpNdx].str));
7031 for (size_t useInputAspectNdx = 0; useInputAspectNdx < 2; useInputAspectNdx++)
7033 const bool useInputAspect = useInputAspectNdx != 0;
7035 if (testConfigExternal.groupParams->renderingType == RENDERING_TYPE_RENDERPASS2 && useInputAspect)
7038 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
7041 vector<Attachment> attachments;
7042 vector<Subpass> subpasses;
7043 vector<SubpassDependency> deps;
7044 vector<VkInputAttachmentAspectReference> inputAspects;
7046 attachments.push_back(Attachment(format,
7047 VK_SAMPLE_COUNT_1_BIT,
7050 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7051 VK_ATTACHMENT_STORE_OP_DONT_CARE,
7052 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
7053 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
7055 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
7056 VK_SAMPLE_COUNT_1_BIT,
7057 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7058 VK_ATTACHMENT_STORE_OP_STORE,
7059 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7060 VK_ATTACHMENT_STORE_OP_DONT_CARE,
7061 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
7062 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
7064 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7066 vector<AttachmentReference>(),
7067 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
7068 vector<AttachmentReference>(),
7069 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
7070 vector<deUint32>()));
7071 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7073 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
7074 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
7075 vector<AttachmentReference>(),
7076 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
7077 vector<deUint32>()));
7079 deps.push_back(SubpassDependency(0, 1,
7081 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
7082 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7084 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
7085 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7086 vk::VK_DEPENDENCY_BY_REGION_BIT));
7090 const VkInputAttachmentAspectReference inputAspect =
7094 VK_IMAGE_ASPECT_COLOR_BIT
7097 inputAspects.push_back(inputAspect);
7101 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7102 const TestConfig testConfig (renderPass,
7103 renderTypes[renderTypeNdx].types,
7104 TestConfig::COMMANDBUFFERTYPES_INLINE,
7105 TestConfig::IMAGEMEMORY_STRICT,
7112 testConfigExternal.allocationKind,
7113 testConfigExternal.groupParams);
7114 const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : ""));
7116 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7120 vector<Attachment> attachments;
7121 vector<Subpass> subpasses;
7122 vector<SubpassDependency> deps;
7123 vector<VkInputAttachmentAspectReference> inputAspects;
7125 attachments.push_back(Attachment(format,
7126 VK_SAMPLE_COUNT_1_BIT,
7129 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7130 VK_ATTACHMENT_STORE_OP_DONT_CARE,
7131 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
7132 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
7134 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7136 vector<AttachmentReference>(),
7137 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
7138 vector<AttachmentReference>(),
7139 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
7140 vector<deUint32>()));
7141 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7143 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL, inputAttachmentAspectMask)),
7144 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL)),
7145 vector<AttachmentReference>(),
7146 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
7147 vector<deUint32>()));
7149 deps.push_back(SubpassDependency(0, 1,
7150 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
7151 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7153 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
7154 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7155 vk::VK_DEPENDENCY_BY_REGION_BIT));
7157 deps.push_back(SubpassDependency(1, 1,
7158 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
7159 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7161 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
7162 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7163 vk::VK_DEPENDENCY_BY_REGION_BIT));
7167 const VkInputAttachmentAspectReference inputAspect =
7171 VK_IMAGE_ASPECT_COLOR_BIT
7174 inputAspects.push_back(inputAspect);
7178 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7179 const TestConfig testConfig (renderPass,
7180 renderTypes[renderTypeNdx].types,
7181 TestConfig::COMMANDBUFFERTYPES_INLINE,
7182 TestConfig::IMAGEMEMORY_STRICT,
7189 testConfigExternal.allocationKind,
7190 testConfigExternal.groupParams);
7191 const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : ""));
7193 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7199 loadOpGroup->addChild(storeOpGroup.release());
7202 inputGroup->addChild(loadOpGroup.release());
7205 formatGroup->addChild(inputGroup.release());
7208 group->addChild(formatGroup.release());
7211 // Depth stencil formats
7212 for (size_t formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_coreDepthStencilFormats); formatNdx++)
7214 const VkFormat vkFormat = s_coreDepthStencilFormats[formatNdx];
7215 const tcu::TextureFormat format = mapVkFormat(vkFormat);
7216 const bool isStencilAttachment = hasStencilComponent(format.order);
7217 const bool isDepthAttachment = hasDepthComponent(format.order);
7218 const VkImageAspectFlags formatAspectFlags = (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7219 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u);
7220 de::MovePtr<tcu::TestCaseGroup> formatGroup (new tcu::TestCaseGroup(testCtx, formatToName(vkFormat).c_str(), de::toString(vkFormat).c_str()));
7222 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
7224 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
7225 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
7227 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
7230 const RenderPass renderPass (vector<Attachment>(1, Attachment(vkFormat,
7231 VK_SAMPLE_COUNT_1_BIT,
7232 isDepthAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7233 isDepthAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
7234 isStencilAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7235 isStencilAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
7236 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7237 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
7238 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7240 vector<AttachmentReference>(),
7241 vector<AttachmentReference>(),
7242 vector<AttachmentReference>(),
7243 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7244 vector<deUint32>())),
7245 vector<SubpassDependency>());
7246 const TestConfig testConfig (renderPass,
7247 renderTypes[renderTypeNdx].types,
7248 TestConfig::COMMANDBUFFERTYPES_INLINE,
7249 TestConfig::IMAGEMEMORY_STRICT,
7256 testConfigExternal.allocationKind,
7257 testConfigExternal.groupParams);
7259 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), renderTypes[renderTypeNdx].str, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7262 if (isStencilAttachment && isDepthAttachment && loadOp != VK_ATTACHMENT_LOAD_OP_CLEAR)
7265 const RenderPass renderPass (vector<Attachment>(1, Attachment(vkFormat,
7266 VK_SAMPLE_COUNT_1_BIT,
7267 isDepthAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7268 isDepthAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
7269 isStencilAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7270 isStencilAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
7271 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7272 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
7273 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7275 vector<AttachmentReference>(),
7276 vector<AttachmentReference>(),
7277 vector<AttachmentReference>(),
7278 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL),
7279 vector<deUint32>())),
7280 vector<SubpassDependency>());
7281 const TestConfig testConfig (renderPass,
7282 renderTypes[renderTypeNdx].types,
7283 TestConfig::COMMANDBUFFERTYPES_INLINE,
7284 TestConfig::IMAGEMEMORY_STRICT,
7291 testConfigExternal.allocationKind,
7292 testConfigExternal.groupParams);
7293 const string testName (string(renderTypes[renderTypeNdx].str) + "_depth_read_only");
7295 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7299 const RenderPass renderPass (vector<Attachment>(1, Attachment(vkFormat,
7300 VK_SAMPLE_COUNT_1_BIT,
7301 isDepthAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7302 isDepthAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
7303 isStencilAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7304 isStencilAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
7305 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7306 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
7307 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7309 vector<AttachmentReference>(),
7310 vector<AttachmentReference>(),
7311 vector<AttachmentReference>(),
7312 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL),
7313 vector<deUint32>())),
7314 vector<SubpassDependency>());
7315 const TestConfig testConfig (renderPass,
7316 renderTypes[renderTypeNdx].types,
7317 TestConfig::COMMANDBUFFERTYPES_INLINE,
7318 TestConfig::IMAGEMEMORY_STRICT,
7325 testConfigExternal.allocationKind,
7326 testConfigExternal.groupParams);
7327 const string testName (string(renderTypes[renderTypeNdx].str) + "_stencil_read_only");
7329 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7334 formatGroup->addChild(loadOpGroup.release());
7337 if (testConfigExternal.groupParams->renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
7339 de::MovePtr<tcu::TestCaseGroup> inputGroup (new tcu::TestCaseGroup(testCtx, "input", "Test attachment format as input"));
7341 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
7343 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
7344 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
7346 for (size_t storeOpNdx = 0; storeOpNdx < DE_LENGTH_OF_ARRAY(storeOps); storeOpNdx++)
7348 const VkImageAspectFlags inputAttachmentAspectMask = (testConfigExternal.groupParams->renderingType == RENDERING_TYPE_RENDERPASS2)
7350 : static_cast<VkImageAspectFlags>(0);
7351 const VkAttachmentStoreOp storeOp = storeOps[storeOpNdx].op;
7352 de::MovePtr<tcu::TestCaseGroup> storeOpGroup (new tcu::TestCaseGroup(testCtx, storeOps[storeOpNdx].str, storeOps[storeOpNdx].str));
7354 for (size_t useInputAspectNdx = 0; useInputAspectNdx < 2; useInputAspectNdx++)
7356 const bool useInputAspect = useInputAspectNdx != 0;
7358 if (testConfigExternal.groupParams->renderingType == RENDERING_TYPE_RENDERPASS2 && useInputAspect)
7361 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
7364 vector<Attachment> attachments;
7365 vector<Subpass> subpasses;
7366 vector<SubpassDependency> deps;
7367 vector<VkInputAttachmentAspectReference> inputAspects;
7369 attachments.push_back(Attachment(vkFormat,
7370 VK_SAMPLE_COUNT_1_BIT,
7375 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7376 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7378 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
7379 VK_SAMPLE_COUNT_1_BIT,
7380 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7381 VK_ATTACHMENT_STORE_OP_STORE,
7382 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7383 VK_ATTACHMENT_STORE_OP_DONT_CARE,
7384 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
7385 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
7387 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7389 vector<AttachmentReference>(),
7390 vector<AttachmentReference>(),
7391 vector<AttachmentReference>(),
7392 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7393 vector<deUint32>()));
7394 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7396 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
7397 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
7398 vector<AttachmentReference>(),
7399 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
7400 vector<deUint32>()));
7402 deps.push_back(SubpassDependency(0, 1,
7403 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7404 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7406 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7407 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7412 const VkInputAttachmentAspectReference inputAspect =
7416 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7417 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7420 inputAspects.push_back(inputAspect);
7424 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7425 const TestConfig testConfig (renderPass,
7426 renderTypes[renderTypeNdx].types,
7427 TestConfig::COMMANDBUFFERTYPES_INLINE,
7428 TestConfig::IMAGEMEMORY_STRICT,
7435 testConfigExternal.allocationKind,
7436 testConfigExternal.groupParams);
7437 const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : ""));
7439 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7443 vector<Attachment> attachments;
7444 vector<Subpass> subpasses;
7445 vector<SubpassDependency> deps;
7446 vector<VkInputAttachmentAspectReference> inputAspects;
7448 attachments.push_back(Attachment(vkFormat,
7449 VK_SAMPLE_COUNT_1_BIT,
7452 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7453 VK_ATTACHMENT_STORE_OP_DONT_CARE,
7454 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7455 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7457 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7459 vector<AttachmentReference>(),
7460 vector<AttachmentReference>(),
7461 vector<AttachmentReference>(),
7462 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7463 vector<deUint32>()));
7464 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7466 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL, inputAttachmentAspectMask)),
7467 vector<AttachmentReference>(),
7468 vector<AttachmentReference>(),
7469 AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL),
7470 vector<deUint32>()));
7472 deps.push_back(SubpassDependency(0, 1,
7473 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7474 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7476 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7477 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7478 vk::VK_DEPENDENCY_BY_REGION_BIT));
7480 deps.push_back(SubpassDependency(1, 1,
7481 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7482 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7483 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7484 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7485 vk::VK_DEPENDENCY_BY_REGION_BIT));
7490 const VkInputAttachmentAspectReference inputAspect =
7495 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7496 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7499 inputAspects.push_back(inputAspect);
7503 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7504 const TestConfig testConfig (renderPass,
7505 renderTypes[renderTypeNdx].types,
7506 TestConfig::COMMANDBUFFERTYPES_INLINE,
7507 TestConfig::IMAGEMEMORY_STRICT,
7514 testConfigExternal.allocationKind,
7515 testConfigExternal.groupParams);
7516 const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : ""));
7518 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7522 if (isStencilAttachment && isDepthAttachment)
7526 vector<Attachment> attachments;
7527 vector<Subpass> subpasses;
7528 vector<SubpassDependency> deps;
7529 vector<VkInputAttachmentAspectReference> inputAspects;
7531 attachments.push_back(Attachment(vkFormat,
7532 VK_SAMPLE_COUNT_1_BIT,
7537 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7538 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7540 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
7541 VK_SAMPLE_COUNT_1_BIT,
7542 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7543 VK_ATTACHMENT_STORE_OP_STORE,
7544 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7545 VK_ATTACHMENT_STORE_OP_DONT_CARE,
7546 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
7547 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
7549 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7551 vector<AttachmentReference>(),
7552 vector<AttachmentReference>(),
7553 vector<AttachmentReference>(),
7554 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7555 vector<deUint32>()));
7556 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7558 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL, inputAttachmentAspectMask)),
7559 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
7560 vector<AttachmentReference>(),
7561 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
7562 vector<deUint32>()));
7564 deps.push_back(SubpassDependency(0, 1,
7565 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7566 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7568 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7569 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7574 const VkInputAttachmentAspectReference inputAspect =
7579 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7580 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7583 inputAspects.push_back(inputAspect);
7587 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7588 const TestConfig testConfig (renderPass,
7589 renderTypes[renderTypeNdx].types,
7590 TestConfig::COMMANDBUFFERTYPES_INLINE,
7591 TestConfig::IMAGEMEMORY_STRICT,
7598 testConfigExternal.allocationKind,
7599 testConfigExternal.groupParams);
7600 const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : "") + "_depth_read_only");
7602 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7606 vector<Attachment> attachments;
7607 vector<Subpass> subpasses;
7608 vector<SubpassDependency> deps;
7609 vector<VkInputAttachmentAspectReference> inputAspects;
7611 attachments.push_back(Attachment(vkFormat,
7612 VK_SAMPLE_COUNT_1_BIT,
7617 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7618 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7620 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7622 vector<AttachmentReference>(),
7623 vector<AttachmentReference>(),
7624 vector<AttachmentReference>(),
7625 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7626 vector<deUint32>()));
7627 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7629 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL, inputAttachmentAspectMask)),
7630 vector<AttachmentReference>(),
7631 vector<AttachmentReference>(),
7632 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL),
7633 vector<deUint32>()));
7635 deps.push_back(SubpassDependency(0, 1,
7636 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7637 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7639 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7640 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7641 vk::VK_DEPENDENCY_BY_REGION_BIT));
7643 deps.push_back(SubpassDependency(1, 1,
7644 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7645 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7647 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7648 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7649 vk::VK_DEPENDENCY_BY_REGION_BIT));
7653 const VkInputAttachmentAspectReference inputAspect =
7658 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7659 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7662 inputAspects.push_back(inputAspect);
7666 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7667 const TestConfig testConfig (renderPass,
7668 renderTypes[renderTypeNdx].types,
7669 TestConfig::COMMANDBUFFERTYPES_INLINE,
7670 TestConfig::IMAGEMEMORY_STRICT,
7677 testConfigExternal.allocationKind,
7678 testConfigExternal.groupParams);
7679 const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : "") + "_depth_read_only");
7681 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7684 // Stencil read only
7686 vector<Attachment> attachments;
7687 vector<Subpass> subpasses;
7688 vector<SubpassDependency> deps;
7689 vector<VkInputAttachmentAspectReference> inputAspects;
7691 attachments.push_back(Attachment(vkFormat,
7692 VK_SAMPLE_COUNT_1_BIT,
7697 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7698 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7700 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
7701 VK_SAMPLE_COUNT_1_BIT,
7702 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7703 VK_ATTACHMENT_STORE_OP_STORE,
7704 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7705 VK_ATTACHMENT_STORE_OP_DONT_CARE,
7706 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
7707 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
7709 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7711 vector<AttachmentReference>(),
7712 vector<AttachmentReference>(),
7713 vector<AttachmentReference>(),
7714 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7715 vector<deUint32>()));
7716 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7718 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
7719 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
7720 vector<AttachmentReference>(),
7721 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
7722 vector<deUint32>()));
7724 deps.push_back(SubpassDependency(0, 1,
7725 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
7726 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7728 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7729 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7734 const VkInputAttachmentAspectReference inputAspect =
7739 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7740 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7743 inputAspects.push_back(inputAspect);
7747 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7748 const TestConfig testConfig (renderPass,
7749 renderTypes[renderTypeNdx].types,
7750 TestConfig::COMMANDBUFFERTYPES_INLINE,
7751 TestConfig::IMAGEMEMORY_STRICT,
7758 testConfigExternal.allocationKind,
7759 testConfigExternal.groupParams);
7760 const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : "") + "_stencil_read_only");
7762 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7766 vector<Attachment> attachments;
7767 vector<Subpass> subpasses;
7768 vector<SubpassDependency> deps;
7769 vector<VkInputAttachmentAspectReference> inputAspects;
7771 attachments.push_back(Attachment(vkFormat,
7772 VK_SAMPLE_COUNT_1_BIT,
7777 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7778 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7780 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7782 vector<AttachmentReference>(),
7783 vector<AttachmentReference>(),
7784 vector<AttachmentReference>(),
7785 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7786 vector<deUint32>()));
7787 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7789 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
7790 vector<AttachmentReference>(),
7791 vector<AttachmentReference>(),
7792 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL),
7793 vector<deUint32>()));
7795 deps.push_back(SubpassDependency(0, 1,
7796 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7797 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7799 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7800 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7801 vk::VK_DEPENDENCY_BY_REGION_BIT));
7803 deps.push_back(SubpassDependency(1, 1,
7804 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7805 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7807 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7808 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7809 vk::VK_DEPENDENCY_BY_REGION_BIT));
7814 const VkInputAttachmentAspectReference inputAspect =
7819 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7820 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7823 inputAspects.push_back(inputAspect);
7827 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7828 const TestConfig testConfig (renderPass,
7829 renderTypes[renderTypeNdx].types,
7830 TestConfig::COMMANDBUFFERTYPES_INLINE,
7831 TestConfig::IMAGEMEMORY_STRICT,
7838 testConfigExternal.allocationKind,
7839 testConfigExternal.groupParams);
7840 const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : "") + "_stencil_read_only");
7842 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7849 loadOpGroup->addChild(storeOpGroup.release());
7852 inputGroup->addChild(loadOpGroup.release());
7855 formatGroup->addChild(inputGroup.release());
7858 group->addChild(formatGroup.release());
7862 void addRenderPassTests (tcu::TestCaseGroup* group, const AllocationKind allocationKind, const SharedGroupParams groupParams)
7864 // tests added by this function have both primary and secondary cases and there is no need to repeat them for useSecondaryCmdBuffer flag;
7865 // but cases defined in other files that are later added to those groups in createRenderPassTestsInternal had to be adjusted and run
7866 // for useSecondaryCmdBuffer flag
7867 if (groupParams->useSecondaryCmdBuffer && !groupParams->secondaryCmdBufferCompletelyContainsDynamicRenderpass)
7870 const TestConfigExternal testConfigExternal (allocationKind, groupParams);
7872 // don't repeat cases that don't use CommandBufferTypes::COMMANDBUFFERTYPES_SECONDARY
7873 if (!groupParams->secondaryCmdBufferCompletelyContainsDynamicRenderpass)
7875 addTestGroup(group, "simple", "Simple basic render pass tests", addSimpleTests, testConfigExternal);
7876 addTestGroup(group, "formats", "Tests for different image formats.", addFormatTests, testConfigExternal);
7879 addTestGroup(group, "attachment", "Attachment format and count tests with load and store ops and image layouts", addAttachmentTests, testConfigExternal);
7881 // don't repeat cases that don't use CommandBufferTypes::COMMANDBUFFERTYPES_SECONDARY
7882 if (!groupParams->secondaryCmdBufferCompletelyContainsDynamicRenderpass)
7883 addTestGroup(group, "attachment_write_mask", "Attachment write mask tests", addAttachmentWriteMaskTests, testConfigExternal);
7885 if (groupParams->renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
7886 addTestGroup(group, "attachment_allocation", "Attachment allocation tests", addAttachmentAllocationTests, testConfigExternal);
7889 de::MovePtr<tcu::TestCaseGroup> createSuballocationTests(tcu::TestContext& testCtx, const SharedGroupParams groupParams)
7891 de::MovePtr<tcu::TestCaseGroup> suballocationTestsGroup(new tcu::TestCaseGroup(testCtx, "suballocation", "Suballocation RenderPass Tests"));
7893 addRenderPassTests(suballocationTestsGroup.get(), ALLOCATION_KIND_SUBALLOCATED, groupParams);
7895 return suballocationTestsGroup;
7898 de::MovePtr<tcu::TestCaseGroup> createDedicatedAllocationTests(tcu::TestContext& testCtx, const SharedGroupParams groupParams)
7900 de::MovePtr<tcu::TestCaseGroup> dedicatedAllocationTestsGroup(new tcu::TestCaseGroup(testCtx, "dedicated_allocation", "RenderPass Tests For Dedicated Allocation"));
7902 addRenderPassTests(dedicatedAllocationTestsGroup.get(), ALLOCATION_KIND_DEDICATED, groupParams);
7904 return dedicatedAllocationTestsGroup;
7907 tcu::TestCaseGroup* createRenderPassTestsInternal (tcu::TestContext& testCtx, const char* groupName, const SharedGroupParams groupParams)
7909 de::MovePtr<tcu::TestCaseGroup> renderingTests (new tcu::TestCaseGroup(testCtx, groupName, ""));
7910 de::MovePtr<tcu::TestCaseGroup> suballocationTestGroup = createSuballocationTests(testCtx, groupParams);
7911 de::MovePtr<tcu::TestCaseGroup> dedicatedAllocationTestGroup = createDedicatedAllocationTests(testCtx, groupParams);
7912 de::MovePtr<tcu::TestCaseGroup> noDrawGroup {new tcu::TestCaseGroup{testCtx, "no_draws", ""}};
7914 const RenderingType renderingType = groupParams->renderingType;
7916 switch (renderingType)
7918 case RENDERING_TYPE_RENDERPASS_LEGACY:
7919 suballocationTestGroup->addChild(createRenderPassMultisampleTests(testCtx));
7920 suballocationTestGroup->addChild(createRenderPassMultisampleResolveTests(testCtx, groupParams));
7921 suballocationTestGroup->addChild(createRenderPassSubpassDependencyTests(testCtx));
7922 suballocationTestGroup->addChild(createRenderPassSampleReadTests(testCtx));
7923 noDrawGroup->addChild(new RenderPassNoDrawLoadStoreTestCase(testCtx, "render_pass_no_draw_clear_load_store", "Test clears in a renderpass with no drawing commands", false));
7925 #ifndef CTS_USES_VULKANSC
7926 suballocationTestGroup->addChild(createRenderPassSparseRenderTargetTests(testCtx, groupParams));
7927 renderingTests->addChild(createDepthStencilWriteConditionsTests(testCtx));
7928 #endif // CTS_USES_VULKANSC
7930 renderingTests->addChild(createRenderPassMultipleSubpassesMultipleCommandBuffersTests(testCtx));
7934 case RENDERING_TYPE_RENDERPASS2:
7935 suballocationTestGroup->addChild(createRenderPass2MultisampleTests(testCtx));
7936 suballocationTestGroup->addChild(createRenderPass2MultisampleResolveTests(testCtx, groupParams));
7937 suballocationTestGroup->addChild(createRenderPass2SubpassDependencyTests(testCtx));
7938 suballocationTestGroup->addChild(createRenderPass2SampleReadTests(testCtx));
7939 noDrawGroup->addChild(new RenderPassNoDrawLoadStoreTestCase(testCtx, "render_pass2_no_draw_clear_load_store", "Test clears in a renderpass with no drawing commands", true));
7941 #ifndef CTS_USES_VULKANSC
7942 suballocationTestGroup->addChild(createRenderPass2SparseRenderTargetTests(testCtx, groupParams));
7943 #endif // CTS_USES_VULKANSC
7945 renderingTests->addChild(createRenderPass2DepthStencilResolveTests(testCtx));
7948 #ifndef CTS_USES_VULKANSC
7949 case RENDERING_TYPE_DYNAMIC_RENDERING:
7950 suballocationTestGroup->addChild(createDynamicRenderingMultisampleResolveTests(testCtx, groupParams));
7951 suballocationTestGroup->addChild(createDynamicRenderingSparseRenderTargetTests(testCtx, groupParams));
7953 if (groupParams->useSecondaryCmdBuffer == false)
7955 renderingTests->addChild(createDynamicRenderingRandomTests(testCtx));
7956 renderingTests->addChild(createDynamicRenderingBasicTests(testCtx));
7959 #endif // CTS_USES_VULKANSC
7965 if (renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
7967 suballocationTestGroup->addChild(createRenderPassUnusedAttachmentTests(testCtx, renderingType));
7968 suballocationTestGroup->addChild(createRenderPassUnusedAttachmentSparseFillingTests(testCtx, renderingType));
7971 suballocationTestGroup->addChild(createRenderPassUnusedClearAttachmentTests(testCtx, groupParams));
7973 #ifndef CTS_USES_VULKANSC
7974 suballocationTestGroup->addChild(createRenderPassLoadStoreOpNoneTests(testCtx, groupParams));
7976 if (renderingType == RENDERING_TYPE_RENDERPASS2)
7978 suballocationTestGroup->addChild(createRenderPassSubpassMergeFeedbackTests(testCtx, renderingType));
7981 renderingTests->addChild(createFragmentDensityMapTests(testCtx, groupParams));
7982 renderingTests->addChild(createRenderPassDitheringTests(testCtx, renderingType));
7983 #endif // CTS_USES_VULKANSC
7985 renderingTests->addChild(suballocationTestGroup.release());
7986 renderingTests->addChild(dedicatedAllocationTestGroup.release());
7987 renderingTests->addChild(noDrawGroup.release());
7989 return renderingTests.release();
7994 tcu::TestCaseGroup* createRenderPassTests (tcu::TestContext& testCtx)
7996 SharedGroupParams groupParams(
7999 RENDERING_TYPE_RENDERPASS_LEGACY, // RenderingType renderingType;
8000 false, // bool useSecondaryCmdBuffer;
8001 false, // bool secondaryCmdBufferCompletelyContainsDynamicRenderpass;
8003 return createRenderPassTestsInternal(testCtx, "renderpass", groupParams);
8006 tcu::TestCaseGroup* createRenderPass2Tests (tcu::TestContext& testCtx)
8008 SharedGroupParams groupParams(
8011 RENDERING_TYPE_RENDERPASS2, // RenderingType renderingType;
8012 false, // bool useSecondaryCmdBuffer;
8013 false, // bool secondaryCmdBufferCompletelyContainsDynamicRenderpass;
8015 return createRenderPassTestsInternal(testCtx, "renderpass2", groupParams);
8018 tcu::TestCaseGroup* createDynamicRenderingTests(tcu::TestContext& testCtx)
8020 de::MovePtr<tcu::TestCaseGroup> dynamicRenderingGroup(new tcu::TestCaseGroup(testCtx, "dynamic_rendering", "Draw using VK_KHR_dynamic_rendering"));
8022 dynamicRenderingGroup->addChild(createRenderPassTestsInternal(testCtx, "primary_cmd_buff", SharedGroupParams(
8025 RENDERING_TYPE_DYNAMIC_RENDERING, // RenderingType renderingType;
8026 false, // bool useSecondaryCmdBuffer;
8027 false, // bool secondaryCmdBufferCompletelyContainsDynamicRenderpass;
8029 dynamicRenderingGroup->addChild(createRenderPassTestsInternal(testCtx, "partial_secondary_cmd_buff", SharedGroupParams(
8032 RENDERING_TYPE_DYNAMIC_RENDERING, // RenderingType renderingType;
8033 true, // bool useSecondaryCmdBuffer;
8034 false, // bool secondaryCmdBufferCompletelyContainsDynamicRenderpass;
8036 dynamicRenderingGroup->addChild(createRenderPassTestsInternal(testCtx, "complete_secondary_cmd_buff", SharedGroupParams(
8039 RENDERING_TYPE_DYNAMIC_RENDERING, // RenderingType renderingType;
8040 true, // bool useSecondaryCmdBuffer;
8041 true, // bool secondaryCmdBufferCompletelyContainsDynamicRenderpass;
8044 return dynamicRenderingGroup.release();