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"
27 #include "vktRenderPassMultisampleTests.hpp"
28 #include "vktRenderPassMultisampleResolveTests.hpp"
29 #include "vktRenderPassSampleReadTests.hpp"
30 #include "vktRenderPassSparseRenderTargetTests.hpp"
31 #include "vktRenderPassSubpassDependencyTests.hpp"
32 #include "vktRenderPassUnusedAttachmentTests.hpp"
33 #include "vktRenderPassUnusedClearAttachmentTests.hpp"
34 #include "vktRenderPassDepthStencilResolveTests.hpp"
35 #include "vktRenderPassUnusedAttachmentSparseFillingTests.hpp"
36 #include "vktRenderPassFragmentDensityMapTests.hpp"
37 #include "vktRenderPassMultipleSubpassesMultipleCommandBuffersTests.hpp"
38 #include "vktRenderPassLoadStoreOpNoneTests.hpp"
39 #include "vktDynamicRenderingTests.hpp"
41 #include "vktTestCaseUtil.hpp"
42 #include "vktTestGroupUtil.hpp"
45 #include "vkDeviceUtil.hpp"
46 #include "vkImageUtil.hpp"
47 #include "vkMemUtil.hpp"
48 #include "vkPlatform.hpp"
49 #include "vkPrograms.hpp"
50 #include "vkQueryUtil.hpp"
52 #include "vkRefUtil.hpp"
53 #include "vkStrUtil.hpp"
54 #include "vkTypeUtil.hpp"
55 #include "vkCmdUtil.hpp"
56 #include "vkObjUtil.hpp"
58 #include "tcuFloat.hpp"
59 #include "tcuFormatUtil.hpp"
60 #include "tcuMaybe.hpp"
61 #include "tcuResultCollector.hpp"
62 #include "tcuTestLog.hpp"
63 #include "tcuTextureUtil.hpp"
64 #include "tcuVectorUtil.hpp"
66 #include "deRandom.hpp"
67 #include "deSTLUtil.hpp"
68 #include "deSharedPtr.hpp"
69 #include "deStringUtil.hpp"
70 #include "deUniquePtr.hpp"
92 using tcu::ConstPixelBufferAccess;
93 using tcu::PixelBufferAccess;
108 using namespace renderpass;
110 typedef vector<deUint8> DepthValuesArray;
112 static const deUint8 DEPTH_VALUES[] = { 0u, 255u, 1u };
116 ALLOCATION_KIND_SUBALLOCATED,
117 ALLOCATION_KIND_DEDICATED,
120 struct TestConfigExternal
122 TestConfigExternal (AllocationKind allocationKind_,
123 RenderingType renderingType_)
124 : allocationKind (allocationKind_)
125 , renderingType (renderingType_)
129 AllocationKind allocationKind;
130 RenderingType renderingType;
133 de::MovePtr<Allocation> allocateBuffer (const InstanceInterface& vki,
134 const DeviceInterface& vkd,
135 const VkPhysicalDevice& physDevice,
136 const VkDevice device,
137 const VkBuffer& buffer,
138 const MemoryRequirement requirement,
139 Allocator& allocator,
140 AllocationKind allocationKind)
142 switch (allocationKind)
144 case ALLOCATION_KIND_SUBALLOCATED:
146 const VkMemoryRequirements memoryRequirements = getBufferMemoryRequirements(vkd, device, buffer);
148 return allocator.allocate(memoryRequirements, requirement);
151 case ALLOCATION_KIND_DEDICATED:
153 return allocateDedicated(vki, vkd, physDevice, device, buffer, requirement);
158 TCU_THROW(InternalError, "Invalid allocation kind");
163 de::MovePtr<Allocation> allocateImage (const InstanceInterface& vki,
164 const DeviceInterface& vkd,
165 const VkPhysicalDevice& physDevice,
166 const VkDevice device,
167 const VkImage& image,
168 const MemoryRequirement requirement,
169 Allocator& allocator,
170 AllocationKind allocationKind)
172 switch (allocationKind)
174 case ALLOCATION_KIND_SUBALLOCATED:
176 const VkMemoryRequirements memoryRequirements = getImageMemoryRequirements(vkd, device, image);
178 return allocator.allocate(memoryRequirements, requirement);
181 case ALLOCATION_KIND_DEDICATED:
183 return allocateDedicated(vki, vkd, physDevice, device, image, requirement);
188 TCU_THROW(InternalError, "Invalid allocation kind");
201 const char* boolOpToString (BoolOp op)
218 DE_FATAL("Unknown boolean operation.");
223 bool performBoolOp (BoolOp op, bool a, bool b)
240 DE_FATAL("Unknown boolean operation.");
245 BoolOp boolOpFromIndex (size_t index)
255 return ops[index % DE_LENGTH_OF_ARRAY(ops)];
258 static float requiredDepthEpsilon(VkFormat format)
260 // Possible precision loss in the unorm depth pipeline means that we need to check depths
261 // that go in and back out of the depth buffer with an epsilon rather than an exact match
262 deUint32 unormBits = 0;
266 case VK_FORMAT_D16_UNORM:
269 case VK_FORMAT_X8_D24_UNORM_PACK32:
270 case VK_FORMAT_D24_UNORM_S8_UINT:
273 case VK_FORMAT_D32_SFLOAT:
274 case VK_FORMAT_D32_SFLOAT_S8_UINT:
281 return 1.0f / (float)((1 << unormBits) - 1);
283 return 0.0f; // Require exact match
286 static bool depthsEqual(float a, float b, float epsilon)
288 return fabs(a - b) <= epsilon;
291 Move<VkFramebuffer> createFramebuffer (const DeviceInterface& vk,
293 VkFramebufferCreateFlags pCreateInfo_flags,
294 VkRenderPass pCreateInfo_renderPass,
295 deUint32 pCreateInfo_attachmentCount,
296 const VkImageView* pCreateInfo_pAttachments,
297 deUint32 pCreateInfo_width,
298 deUint32 pCreateInfo_height,
299 deUint32 pCreateInfo_layers)
301 const VkFramebufferCreateInfo pCreateInfo =
303 VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
306 pCreateInfo_renderPass,
307 pCreateInfo_attachmentCount,
308 pCreateInfo_pAttachments,
313 return createFramebuffer(vk, device, &pCreateInfo);
316 Move<VkImage> createImage (const DeviceInterface& vk,
318 VkImageCreateFlags pCreateInfo_flags,
319 VkImageType pCreateInfo_imageType,
320 VkFormat pCreateInfo_format,
321 VkExtent3D pCreateInfo_extent,
322 deUint32 pCreateInfo_mipLevels,
323 deUint32 pCreateInfo_arrayLayers,
324 VkSampleCountFlagBits pCreateInfo_samples,
325 VkImageTiling pCreateInfo_tiling,
326 VkImageUsageFlags pCreateInfo_usage,
327 VkSharingMode pCreateInfo_sharingMode,
328 deUint32 pCreateInfo_queueFamilyCount,
329 const deUint32* pCreateInfo_pQueueFamilyIndices,
330 VkImageLayout pCreateInfo_initialLayout)
332 const VkImageCreateInfo pCreateInfo =
334 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
337 pCreateInfo_imageType,
340 pCreateInfo_mipLevels,
341 pCreateInfo_arrayLayers,
345 pCreateInfo_sharingMode,
346 pCreateInfo_queueFamilyCount,
347 pCreateInfo_pQueueFamilyIndices,
348 pCreateInfo_initialLayout
350 return createImage(vk, device, &pCreateInfo);
353 void bindBufferMemory (const DeviceInterface& vk, VkDevice device, VkBuffer buffer, VkDeviceMemory mem, VkDeviceSize memOffset)
355 VK_CHECK(vk.bindBufferMemory(device, buffer, mem, memOffset));
358 void bindImageMemory (const DeviceInterface& vk, VkDevice device, VkImage image, VkDeviceMemory mem, VkDeviceSize memOffset)
360 VK_CHECK(vk.bindImageMemory(device, image, mem, memOffset));
363 Move<VkImageView> createImageView (const DeviceInterface& vk,
365 VkImageViewCreateFlags pCreateInfo_flags,
366 VkImage pCreateInfo_image,
367 VkImageViewType pCreateInfo_viewType,
368 VkFormat pCreateInfo_format,
369 VkComponentMapping pCreateInfo_components,
370 VkImageSubresourceRange pCreateInfo_subresourceRange)
372 const VkImageViewCreateInfo pCreateInfo =
374 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
378 pCreateInfo_viewType,
380 pCreateInfo_components,
381 pCreateInfo_subresourceRange,
383 return createImageView(vk, device, &pCreateInfo);
386 Move<VkBuffer> createBuffer (const DeviceInterface& vk,
388 VkBufferCreateFlags pCreateInfo_flags,
389 VkDeviceSize pCreateInfo_size,
390 VkBufferUsageFlags pCreateInfo_usage,
391 VkSharingMode pCreateInfo_sharingMode,
392 deUint32 pCreateInfo_queueFamilyCount,
393 const deUint32* pCreateInfo_pQueueFamilyIndices)
395 const VkBufferCreateInfo pCreateInfo =
397 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
402 pCreateInfo_sharingMode,
403 pCreateInfo_queueFamilyCount,
404 pCreateInfo_pQueueFamilyIndices,
406 return createBuffer(vk, device, &pCreateInfo);
409 VkRenderPassBeginInfo createRenderPassBeginInfo (VkRenderPass pRenderPassBegin_renderPass,
410 VkFramebuffer pRenderPassBegin_framebuffer,
411 VkRect2D pRenderPassBegin_renderArea,
412 deUint32 pRenderPassBegin_clearValueCount,
413 const VkClearValue* pRenderPassBegin_pAttachmentClearValues)
415 const VkRenderPassBeginInfo renderPassBeginInfo =
417 VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
419 pRenderPassBegin_renderPass,
420 pRenderPassBegin_framebuffer,
421 pRenderPassBegin_renderArea,
422 pRenderPassBegin_clearValueCount,
423 pRenderPassBegin_pAttachmentClearValues,
426 return renderPassBeginInfo;
429 void queueSubmit (const DeviceInterface& vk, VkQueue queue, deUint32 cmdBufferCount, const VkCommandBuffer* pCmdBuffers, VkFence fence)
431 const VkSubmitInfo submitInfo =
433 VK_STRUCTURE_TYPE_SUBMIT_INFO,
435 0u, // waitSemaphoreCount
436 (const VkSemaphore*)DE_NULL, // pWaitSemaphores
437 (const VkPipelineStageFlags*)DE_NULL,
438 cmdBufferCount, // commandBufferCount
440 0u, // signalSemaphoreCount
441 (const VkSemaphore*)DE_NULL, // pSignalSemaphores
443 VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo, fence));
446 void waitForFences (const DeviceInterface& vk, VkDevice device, deUint32 fenceCount, const VkFence* pFences, VkBool32 waitAll, deUint64 timeout)
448 VK_CHECK(vk.waitForFences(device, fenceCount, pFences, waitAll, timeout));
451 VkImageAspectFlags getImageAspectFlags (VkFormat vkFormat)
453 const tcu::TextureFormat format = mapVkFormat(vkFormat);
455 DE_STATIC_ASSERT(tcu::TextureFormat::CHANNELORDER_LAST == 22);
457 switch (format.order)
459 case tcu::TextureFormat::DS:
460 return VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_DEPTH_BIT;
462 case tcu::TextureFormat::D:
463 return VK_IMAGE_ASPECT_DEPTH_BIT;
465 case tcu::TextureFormat::S:
466 return VK_IMAGE_ASPECT_STENCIL_BIT;
469 return VK_IMAGE_ASPECT_COLOR_BIT;
473 VkAccessFlags getAllMemoryReadFlags (void)
475 return VK_ACCESS_TRANSFER_READ_BIT
476 | VK_ACCESS_UNIFORM_READ_BIT
477 | VK_ACCESS_HOST_READ_BIT
478 | VK_ACCESS_INDEX_READ_BIT
479 | VK_ACCESS_SHADER_READ_BIT
480 | VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT
481 | VK_ACCESS_INDIRECT_COMMAND_READ_BIT
482 | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT
483 | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT
484 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT;
487 VkAccessFlags getAllMemoryWriteFlags (void)
489 return VK_ACCESS_TRANSFER_WRITE_BIT
490 | VK_ACCESS_HOST_WRITE_BIT
491 | VK_ACCESS_SHADER_WRITE_BIT
492 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT
493 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
496 VkAccessFlags getMemoryFlagsForLayout (const VkImageLayout layout)
500 case VK_IMAGE_LAYOUT_GENERAL: return getAllMemoryReadFlags() | getAllMemoryWriteFlags();
501 case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: return VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
502 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: return VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
503 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: return VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT;
504 case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL: return VK_ACCESS_SHADER_READ_BIT;
505 case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL: return VK_ACCESS_TRANSFER_READ_BIT;
506 case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL: return VK_ACCESS_TRANSFER_WRITE_BIT;
507 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;
508 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;
510 return (VkAccessFlags)0;
514 VkPipelineStageFlags getAllPipelineStageFlags (void)
516 /* All relevant flags for a pipeline containing VS+PS. */
517 return VK_PIPELINE_STAGE_TRANSFER_BIT
518 | VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT
519 | VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT
520 | VK_PIPELINE_STAGE_VERTEX_INPUT_BIT
521 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT
522 | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
523 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
524 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT
525 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
526 | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT
527 | VK_PIPELINE_STAGE_HOST_BIT;
530 class AttachmentReference
533 AttachmentReference (deUint32 attachment,
534 VkImageLayout layout,
535 VkImageAspectFlags aspectMask = static_cast<VkImageAspectFlags>(0u))
536 : m_attachment (attachment)
538 , m_aspectMask (aspectMask)
542 deUint32 getAttachment (void) const { return m_attachment; }
543 VkImageLayout getImageLayout (void) const { return m_layout; }
544 VkImageAspectFlags getAspectMask (void) const { return m_aspectMask; }
545 void setImageLayout (VkImageLayout layout) { m_layout = layout; }
548 deUint32 m_attachment;
549 VkImageLayout m_layout;
550 VkImageAspectFlags m_aspectMask;
556 Subpass (VkPipelineBindPoint pipelineBindPoint,
557 VkSubpassDescriptionFlags flags,
558 const vector<AttachmentReference>& inputAttachments,
559 const vector<AttachmentReference>& colorAttachments,
560 const vector<AttachmentReference>& resolveAttachments,
561 AttachmentReference depthStencilAttachment,
562 const vector<deUint32>& preserveAttachments,
563 bool omitBlendState = false)
564 : m_pipelineBindPoint (pipelineBindPoint)
566 , m_inputAttachments (inputAttachments)
567 , m_colorAttachments (colorAttachments)
568 , m_resolveAttachments (resolveAttachments)
569 , m_depthStencilAttachment (depthStencilAttachment)
570 , m_preserveAttachments (preserveAttachments)
571 , m_omitBlendState (omitBlendState)
575 VkPipelineBindPoint getPipelineBindPoint (void) const { return m_pipelineBindPoint; }
576 VkSubpassDescriptionFlags getFlags (void) const { return m_flags; }
577 const vector<AttachmentReference>& getInputAttachments (void) const { return m_inputAttachments; }
578 const vector<AttachmentReference>& getColorAttachments (void) const { return m_colorAttachments; }
579 const vector<AttachmentReference>& getResolveAttachments (void) const { return m_resolveAttachments; }
580 const AttachmentReference& getDepthStencilAttachment (void) const { return m_depthStencilAttachment; }
581 const vector<deUint32>& getPreserveAttachments (void) const { return m_preserveAttachments; }
582 bool getOmitBlendState (void) const { return m_omitBlendState; }
585 VkPipelineBindPoint m_pipelineBindPoint;
586 VkSubpassDescriptionFlags m_flags;
588 vector<AttachmentReference> m_inputAttachments;
589 vector<AttachmentReference> m_colorAttachments;
590 vector<AttachmentReference> m_resolveAttachments;
591 AttachmentReference m_depthStencilAttachment;
593 vector<deUint32> m_preserveAttachments;
594 bool m_omitBlendState;
597 class SubpassDependency
600 SubpassDependency (deUint32 srcPass,
603 VkPipelineStageFlags srcStageMask,
604 VkPipelineStageFlags dstStageMask,
606 VkAccessFlags srcAccessMask,
607 VkAccessFlags dstAccessMask,
609 VkDependencyFlags flags)
610 : m_srcPass (srcPass)
611 , m_dstPass (dstPass)
613 , m_srcStageMask (srcStageMask)
614 , m_dstStageMask (dstStageMask)
616 , m_srcAccessMask (srcAccessMask)
617 , m_dstAccessMask (dstAccessMask)
622 deUint32 getSrcPass (void) const { return m_srcPass; }
623 deUint32 getDstPass (void) const { return m_dstPass; }
625 VkPipelineStageFlags getSrcStageMask (void) const { return m_srcStageMask; }
626 VkPipelineStageFlags getDstStageMask (void) const { return m_dstStageMask; }
628 VkAccessFlags getSrcAccessMask (void) const { return m_srcAccessMask; }
629 VkAccessFlags getDstAccessMask (void) const { return m_dstAccessMask; }
631 VkDependencyFlags getFlags (void) const { return m_flags; }
633 void setSrcAccessMask (const VkAccessFlags& flags) { m_srcAccessMask = flags; }
634 void setDstAccessMask (const VkAccessFlags& flags) { m_dstAccessMask = flags; }
640 VkPipelineStageFlags m_srcStageMask;
641 VkPipelineStageFlags m_dstStageMask;
643 VkAccessFlags m_srcAccessMask;
644 VkAccessFlags m_dstAccessMask;
645 VkDependencyFlags m_flags;
651 Attachment (VkFormat format,
652 VkSampleCountFlagBits samples,
654 VkAttachmentLoadOp loadOp,
655 VkAttachmentStoreOp storeOp,
657 VkAttachmentLoadOp stencilLoadOp,
658 VkAttachmentStoreOp stencilStoreOp,
660 VkImageLayout initialLayout,
661 VkImageLayout finalLayout)
663 , m_samples (samples)
666 , m_storeOp (storeOp)
668 , m_stencilLoadOp (stencilLoadOp)
669 , m_stencilStoreOp (stencilStoreOp)
671 , m_initialLayout (initialLayout)
672 , m_finalLayout (finalLayout)
676 VkFormat getFormat (void) const { return m_format; }
677 VkSampleCountFlagBits getSamples (void) const { return m_samples; }
679 VkAttachmentLoadOp getLoadOp (void) const { return m_loadOp; }
680 VkAttachmentStoreOp getStoreOp (void) const { return m_storeOp; }
683 VkAttachmentLoadOp getStencilLoadOp (void) const { return m_stencilLoadOp; }
684 VkAttachmentStoreOp getStencilStoreOp (void) const { return m_stencilStoreOp; }
686 VkImageLayout getInitialLayout (void) const { return m_initialLayout; }
687 VkImageLayout getFinalLayout (void) const { return m_finalLayout; }
691 VkSampleCountFlagBits m_samples;
693 VkAttachmentLoadOp m_loadOp;
694 VkAttachmentStoreOp m_storeOp;
696 VkAttachmentLoadOp m_stencilLoadOp;
697 VkAttachmentStoreOp m_stencilStoreOp;
699 VkImageLayout m_initialLayout;
700 VkImageLayout m_finalLayout;
706 RenderPass (const vector<Attachment>& attachments,
707 const vector<Subpass>& subpasses,
708 const vector<SubpassDependency>& dependencies,
709 const vector<VkInputAttachmentAspectReference> inputAspects = vector<VkInputAttachmentAspectReference>())
710 : m_attachments (attachments)
711 , m_subpasses (subpasses)
712 , m_dependencies (dependencies)
713 , m_inputAspects (inputAspects)
717 const vector<Attachment>& getAttachments (void) const { return m_attachments; }
718 const vector<Subpass>& getSubpasses (void) const { return m_subpasses; }
719 const vector<SubpassDependency>& getDependencies (void) const { return m_dependencies; }
720 const vector<VkInputAttachmentAspectReference>& getInputAspects (void) const { return m_inputAspects; }
723 const vector<Attachment> m_attachments;
724 const vector<Subpass> m_subpasses;
725 const vector<SubpassDependency> m_dependencies;
726 const vector<VkInputAttachmentAspectReference> m_inputAspects;
733 RENDERTYPES_NONE = 0,
734 RENDERTYPES_CLEAR = (1<<1),
735 RENDERTYPES_DRAW = (1<<2)
738 enum CommandBufferTypes
740 COMMANDBUFFERTYPES_INLINE = (1<<0),
741 COMMANDBUFFERTYPES_SECONDARY = (1<<1)
746 IMAGEMEMORY_STRICT = (1<<0),
747 IMAGEMEMORY_LAZY = (1<<1)
750 TestConfig (const RenderPass& renderPass_,
751 RenderTypes renderTypes_,
752 CommandBufferTypes commandBufferTypes_,
753 ImageMemory imageMemory_,
754 const UVec2& targetSize_,
755 const UVec2& renderPos_,
756 const UVec2& renderSize_,
757 deBool useFormatCompCount_,
759 deUint32 drawStartNdx_,
760 AllocationKind allocationKind_,
761 RenderingType renderingType_,
762 vector<DeviceCoreFeature> requiredFeatures_ = vector<DeviceCoreFeature>())
763 : renderPass (renderPass_)
764 , renderTypes (renderTypes_)
765 , commandBufferTypes (commandBufferTypes_)
766 , imageMemory (imageMemory_)
767 , targetSize (targetSize_)
768 , renderPos (renderPos_)
769 , renderSize (renderSize_)
770 , useFormatCompCount (useFormatCompCount_)
772 , drawStartNdx (drawStartNdx_)
773 , allocationKind (allocationKind_)
774 , renderingType (renderingType_)
775 , requiredFeatures (requiredFeatures_)
777 DepthValuesArray shuffledDepthValues (&DEPTH_VALUES[0], &DEPTH_VALUES[DE_LENGTH_OF_ARRAY(DEPTH_VALUES)]);
778 de::Random rng (seed + 1);
780 rng.shuffle(shuffledDepthValues.begin(), shuffledDepthValues.end());
782 depthValues.push_back(shuffledDepthValues[0]);
783 depthValues.push_back(shuffledDepthValues[1]);
786 RenderPass renderPass;
787 RenderTypes renderTypes;
788 CommandBufferTypes commandBufferTypes;
789 ImageMemory imageMemory;
793 deBool useFormatCompCount;
795 deUint32 drawStartNdx;
796 AllocationKind allocationKind;
797 RenderingType renderingType;
798 vector<DeviceCoreFeature> requiredFeatures;
799 DepthValuesArray depthValues;
802 TestConfig::RenderTypes operator| (TestConfig::RenderTypes a, TestConfig::RenderTypes b)
804 return (TestConfig::RenderTypes)(((deUint32)a) | ((deUint32)b));
807 TestConfig::CommandBufferTypes operator| (TestConfig::CommandBufferTypes a, TestConfig::CommandBufferTypes b)
809 return (TestConfig::CommandBufferTypes)(((deUint32)a) | ((deUint32)b));
812 TestConfig::ImageMemory operator| (TestConfig::ImageMemory a, TestConfig::ImageMemory b)
814 return (TestConfig::ImageMemory)(((deUint32)a) | ((deUint32)b));
817 void checkSupport (Context& context, TestConfig config)
819 for (size_t featureNdx = 0; featureNdx < config.requiredFeatures.size(); featureNdx++)
820 context.requireDeviceCoreFeature(config.requiredFeatures[featureNdx]);
823 void logRenderPassInfo (TestLog& log,
824 const RenderPass& renderPass)
826 const bool useExternalInputAspect = !renderPass.getInputAspects().empty();
827 const tcu::ScopedLogSection section (log, "RenderPass", "RenderPass");
830 const tcu::ScopedLogSection attachmentsSection (log, "Attachments", "Attachments");
831 const vector<Attachment>& attachments = renderPass.getAttachments();
833 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
835 const tcu::ScopedLogSection attachmentSection (log, "Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx));
836 const Attachment& attachment = attachments[attachmentNdx];
838 log << TestLog::Message << "Format: " << attachment.getFormat() << TestLog::EndMessage;
839 log << TestLog::Message << "Samples: " << attachment.getSamples() << TestLog::EndMessage;
841 log << TestLog::Message << "LoadOp: " << attachment.getLoadOp() << TestLog::EndMessage;
842 log << TestLog::Message << "StoreOp: " << attachment.getStoreOp() << TestLog::EndMessage;
844 log << TestLog::Message << "StencilLoadOp: " << attachment.getStencilLoadOp() << TestLog::EndMessage;
845 log << TestLog::Message << "StencilStoreOp: " << attachment.getStencilStoreOp() << TestLog::EndMessage;
847 log << TestLog::Message << "InitialLayout: " << attachment.getInitialLayout() << TestLog::EndMessage;
848 log << TestLog::Message << "FinalLayout: " << attachment.getFinalLayout() << TestLog::EndMessage;
852 if (useExternalInputAspect)
854 const tcu::ScopedLogSection inputAspectSection (log, "InputAspects", "InputAspects");
856 for (size_t aspectNdx = 0; aspectNdx < renderPass.getInputAspects().size(); aspectNdx++)
858 const VkInputAttachmentAspectReference& inputAspect (renderPass.getInputAspects()[aspectNdx]);
860 log << TestLog::Message << "Subpass: " << inputAspect.subpass << TestLog::EndMessage;
861 log << TestLog::Message << "InputAttachmentIndex: " << inputAspect.inputAttachmentIndex << TestLog::EndMessage;
862 log << TestLog::Message << "AspectFlags: " << getImageAspectFlagsStr(inputAspect.aspectMask) << TestLog::EndMessage;
867 const tcu::ScopedLogSection subpassesSection (log, "Subpasses", "Subpasses");
868 const vector<Subpass>& subpasses = renderPass.getSubpasses();
870 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
872 const tcu::ScopedLogSection subpassSection (log, "Subpass" + de::toString(subpassNdx), "Subpass " + de::toString(subpassNdx));
873 const Subpass& subpass = subpasses[subpassNdx];
875 const vector<AttachmentReference>& inputAttachments = subpass.getInputAttachments();
876 const vector<AttachmentReference>& colorAttachments = subpass.getColorAttachments();
877 const vector<AttachmentReference>& resolveAttachments = subpass.getResolveAttachments();
878 const vector<deUint32>& preserveAttachments = subpass.getPreserveAttachments();
880 if (!inputAttachments.empty())
882 const tcu::ScopedLogSection inputAttachmentsSection (log, "Inputs", "Inputs");
884 for (size_t inputNdx = 0; inputNdx < inputAttachments.size(); inputNdx++)
886 const tcu::ScopedLogSection inputAttachmentSection (log, "Input" + de::toString(inputNdx), "Input " + de::toString(inputNdx));
887 const AttachmentReference& inputAttachment = inputAttachments[inputNdx];
889 log << TestLog::Message << "Attachment: " << inputAttachment.getAttachment() << TestLog::EndMessage;
890 log << TestLog::Message << "Layout: " << inputAttachment.getImageLayout() << TestLog::EndMessage;
891 if (!useExternalInputAspect)
892 log << TestLog::Message << "AspectMask: " << inputAttachment.getAspectMask() << TestLog::EndMessage;
896 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
898 const tcu::ScopedLogSection depthStencilAttachmentSection (log, "DepthStencil", "DepthStencil");
899 const AttachmentReference& depthStencilAttachment = subpass.getDepthStencilAttachment();
901 log << TestLog::Message << "Attachment: " << depthStencilAttachment.getAttachment() << TestLog::EndMessage;
902 log << TestLog::Message << "Layout: " << depthStencilAttachment.getImageLayout() << TestLog::EndMessage;
905 if (!colorAttachments.empty())
907 const tcu::ScopedLogSection colorAttachmentsSection (log, "Colors", "Colors");
909 for (size_t colorNdx = 0; colorNdx < colorAttachments.size(); colorNdx++)
911 const tcu::ScopedLogSection colorAttachmentSection (log, "Color" + de::toString(colorNdx), "Color " + de::toString(colorNdx));
912 const AttachmentReference& colorAttachment = colorAttachments[colorNdx];
914 log << TestLog::Message << "Attachment: " << colorAttachment.getAttachment() << TestLog::EndMessage;
915 log << TestLog::Message << "Layout: " << colorAttachment.getImageLayout() << TestLog::EndMessage;
919 if (!resolveAttachments.empty())
921 const tcu::ScopedLogSection resolveAttachmentsSection (log, "Resolves", "Resolves");
923 for (size_t resolveNdx = 0; resolveNdx < resolveAttachments.size(); resolveNdx++)
925 const tcu::ScopedLogSection resolveAttachmentSection (log, "Resolve" + de::toString(resolveNdx), "Resolve " + de::toString(resolveNdx));
926 const AttachmentReference& resolveAttachment = resolveAttachments[resolveNdx];
928 log << TestLog::Message << "Attachment: " << resolveAttachment.getAttachment() << TestLog::EndMessage;
929 log << TestLog::Message << "Layout: " << resolveAttachment.getImageLayout() << TestLog::EndMessage;
933 if (!preserveAttachments.empty())
935 const tcu::ScopedLogSection preserveAttachmentsSection (log, "Preserves", "Preserves");
937 for (size_t preserveNdx = 0; preserveNdx < preserveAttachments.size(); preserveNdx++)
939 const tcu::ScopedLogSection preserveAttachmentSection (log, "Preserve" + de::toString(preserveNdx), "Preserve " + de::toString(preserveNdx));
940 const deUint32 preserveAttachment = preserveAttachments[preserveNdx];
942 log << TestLog::Message << "Attachment: " << preserveAttachment << TestLog::EndMessage;
949 if (!renderPass.getDependencies().empty())
951 const tcu::ScopedLogSection dependenciesSection (log, "Dependencies", "Dependencies");
953 for (size_t depNdx = 0; depNdx < renderPass.getDependencies().size(); depNdx++)
955 const tcu::ScopedLogSection dependencySection (log, "Dependency" + de::toString(depNdx), "Dependency " + de::toString(depNdx));
956 const SubpassDependency& dep = renderPass.getDependencies()[depNdx];
958 log << TestLog::Message << "Source: " << dep.getSrcPass() << TestLog::EndMessage;
959 log << TestLog::Message << "Destination: " << dep.getDstPass() << TestLog::EndMessage;
961 log << TestLog::Message << "Source Stage Mask: " << dep.getSrcStageMask() << TestLog::EndMessage;
962 log << TestLog::Message << "Destination Stage Mask: " << dep.getDstStageMask() << TestLog::EndMessage;
964 log << TestLog::Message << "Input Mask: " << dep.getDstAccessMask() << TestLog::EndMessage;
965 log << TestLog::Message << "Output Mask: " << dep.getSrcAccessMask() << TestLog::EndMessage;
966 log << TestLog::Message << "Dependency Flags: " << getDependencyFlagsStr(dep.getFlags()) << TestLog::EndMessage;
971 std::string clearColorToString (VkFormat vkFormat, VkClearColorValue value, deBool useFormatCompCount)
973 const tcu::TextureFormat format = mapVkFormat(vkFormat);
974 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
975 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
976 const deUint32 componentCount = (useFormatCompCount ? (deUint32)tcu::getNumUsedChannels(format.order) : 4);
978 std::ostringstream stream;
982 switch (channelClass)
984 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
985 for (deUint32 i = 0; i < componentCount; i++)
991 stream << value.int32[i];
997 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
998 for (deUint32 i = 0; i < componentCount; i++)
1004 stream << value.uint32[i];
1010 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
1011 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
1012 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
1013 for (deUint32 i = 0; i < componentCount; i++)
1019 stream << value.float32[i];
1026 DE_FATAL("Unknown channel class");
1031 return stream.str();
1034 std::string clearValueToString (VkFormat vkFormat, VkClearValue value, deBool useFormatCompCount)
1036 const tcu::TextureFormat format = mapVkFormat(vkFormat);
1038 if (tcu::hasStencilComponent(format.order) || tcu::hasDepthComponent(format.order))
1040 std::ostringstream stream;
1044 if (tcu::hasStencilComponent(format.order))
1045 stream << "stencil: " << value.depthStencil.stencil;
1047 if (tcu::hasStencilComponent(format.order) && tcu::hasDepthComponent(format.order))
1050 if (tcu::hasDepthComponent(format.order))
1051 stream << "depth: " << value.depthStencil.depth;
1055 return stream.str();
1058 return clearColorToString(vkFormat, value.color, useFormatCompCount);
1061 VkClearColorValue randomColorClearValue (const Attachment& attachment, de::Random& rng, deBool useFormatCompCount)
1063 const float clearNan = tcu::Float32::nan().asFloat();
1064 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
1065 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
1066 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
1067 const deUint32 componentCount = (useFormatCompCount ? (deUint32)tcu::getNumUsedChannels(format.order) : 4);
1068 VkClearColorValue clearColor;
1070 switch (channelClass)
1072 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
1074 for (deUint32 ndx = 0; ndx < componentCount; ndx++)
1076 if (!channelMask[ndx])
1077 clearColor.int32[ndx] = std::numeric_limits<deInt32>::min();
1079 clearColor.uint32[ndx] = rng.getBool() ? 1u : 0u;
1084 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
1086 for (deUint32 ndx = 0; ndx < componentCount; ndx++)
1088 if (!channelMask[ndx])
1089 clearColor.uint32[ndx] = std::numeric_limits<deUint32>::max();
1091 clearColor.uint32[ndx] = rng.getBool() ? 1u : 0u;
1096 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
1097 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
1098 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
1100 for (deUint32 ndx = 0; ndx < componentCount; ndx++)
1102 if (!channelMask[ndx])
1103 clearColor.float32[ndx] = clearNan;
1105 clearColor.float32[ndx] = rng.getBool() ? 1.0f : 0.0f;
1111 DE_FATAL("Unknown channel class");
1117 template <typename AttachmentDesc>
1118 AttachmentDesc createAttachmentDescription (const Attachment& attachment)
1120 const AttachmentDesc attachmentDescription // VkAttachmentDescription || VkAttachmentDescription2KHR
1122 // || VkStructureType sType;
1123 DE_NULL, // || const void* pNext;
1124 0u, // VkAttachmentDescriptionFlags flags; || VkAttachmentDescriptionFlags flags;
1125 attachment.getFormat(), // VkFormat format; || VkFormat format;
1126 attachment.getSamples(), // VkSampleCountFlagBits samples; || VkSampleCountFlagBits samples;
1127 attachment.getLoadOp(), // VkAttachmentLoadOp loadOp; || VkAttachmentLoadOp loadOp;
1128 attachment.getStoreOp(), // VkAttachmentStoreOp storeOp; || VkAttachmentStoreOp storeOp;
1129 attachment.getStencilLoadOp(), // VkAttachmentLoadOp stencilLoadOp; || VkAttachmentLoadOp stencilLoadOp;
1130 attachment.getStencilStoreOp(), // VkAttachmentStoreOp stencilStoreOp; || VkAttachmentStoreOp stencilStoreOp;
1131 attachment.getInitialLayout(), // VkImageLayout initialLayout; || VkImageLayout initialLayout;
1132 attachment.getFinalLayout() // VkImageLayout finalLayout; || VkImageLayout finalLayout;
1135 return attachmentDescription;
1138 template <typename AttachmentRef>
1139 AttachmentRef createAttachmentReference (const AttachmentReference& referenceInfo)
1141 const AttachmentRef reference // VkAttachmentReference || VkAttachmentReference2KHR
1143 // || VkStructureType sType;
1144 DE_NULL, // || const void* pNext;
1145 referenceInfo.getAttachment(), // deUint32 attachment; || deUint32 attachment;
1146 referenceInfo.getImageLayout(), // VkImageLayout layout; || VkImageLayout layout;
1147 referenceInfo.getAspectMask() // || VkImageAspectFlags aspectMask;
1153 template <typename SubpassDesc, typename AttachmentRef>
1154 SubpassDesc createSubpassDescription (const Subpass& subpass,
1155 vector<AttachmentRef>* attachmentReferenceLists,
1156 vector<deUint32>* preserveAttachmentReferences)
1158 vector<AttachmentRef>& inputAttachmentReferences = attachmentReferenceLists[0];
1159 vector<AttachmentRef>& colorAttachmentReferences = attachmentReferenceLists[1];
1160 vector<AttachmentRef>& resolveAttachmentReferences = attachmentReferenceLists[2];
1161 vector<AttachmentRef>& depthStencilAttachmentReferences = attachmentReferenceLists[3];
1163 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
1164 colorAttachmentReferences.push_back(createAttachmentReference<AttachmentRef>(subpass.getColorAttachments()[attachmentNdx]));
1166 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
1167 inputAttachmentReferences.push_back(createAttachmentReference<AttachmentRef>(subpass.getInputAttachments()[attachmentNdx]));
1169 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getResolveAttachments().size(); attachmentNdx++)
1170 resolveAttachmentReferences.push_back(createAttachmentReference<AttachmentRef>(subpass.getResolveAttachments()[attachmentNdx]));
1172 depthStencilAttachmentReferences.push_back(createAttachmentReference<AttachmentRef>(subpass.getDepthStencilAttachment()));
1174 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getPreserveAttachments().size(); attachmentNdx++)
1175 preserveAttachmentReferences->push_back(subpass.getPreserveAttachments()[attachmentNdx]);
1177 DE_ASSERT(resolveAttachmentReferences.empty() || colorAttachmentReferences.size() == resolveAttachmentReferences.size());
1180 const SubpassDesc subpassDescription // VkSubpassDescription || VkSubpassDescription2KHR
1182 // || VkStructureType sType;
1183 DE_NULL, // || const void* pNext;
1184 subpass.getFlags(), // VkSubpassDescriptionFlags flags; || VkSubpassDescriptionFlags flags;
1185 subpass.getPipelineBindPoint(), // VkPipelineBindPoint pipelineBindPoint; || VkPipelineBindPoint pipelineBindPoint;
1186 0u, // || deUint32 viewMask;
1187 (deUint32)inputAttachmentReferences.size(), // deUint32 inputAttachmentCount; || deUint32 inputAttachmentCount;
1188 inputAttachmentReferences.empty() ? DE_NULL : &inputAttachmentReferences[0], // const VkAttachmentReference* pInputAttachments; || const VkAttachmentReference2KHR* pInputAttachments;
1189 (deUint32)colorAttachmentReferences.size(), // deUint32 colorAttachmentCount; || deUint32 colorAttachmentCount;
1190 colorAttachmentReferences.empty() ? DE_NULL : &colorAttachmentReferences[0], // const VkAttachmentReference* pColorAttachments; || const VkAttachmentReference2KHR* pColorAttachments;
1191 resolveAttachmentReferences.empty() ? DE_NULL : &resolveAttachmentReferences[0], // const VkAttachmentReference* pResolveAttachments; || const VkAttachmentReference2KHR* pResolveAttachments;
1192 &depthStencilAttachmentReferences[0], // const VkAttachmentReference* pDepthStencilAttachment; || const VkAttachmentReference2KHR* pDepthStencilAttachment;
1193 (deUint32)preserveAttachmentReferences->size(), // deUint32 preserveAttachmentCount; || deUint32 preserveAttachmentCount;
1194 preserveAttachmentReferences->empty() ? DE_NULL : &(*preserveAttachmentReferences)[0] // const deUint32* pPreserveAttachments; || const deUint32* pPreserveAttachments;
1197 return subpassDescription;
1201 template <typename SubpassDep>
1202 SubpassDep createSubpassDependency (const SubpassDependency& dependencyInfo)
1204 const SubpassDep dependency // VkSubpassDependency || VkSubpassDependency2KHR
1206 // || VkStructureType sType;
1207 DE_NULL, // || const void* pNext;
1208 dependencyInfo.getSrcPass(), // deUint32 srcSubpass; || deUint32 srcSubpass;
1209 dependencyInfo.getDstPass(), // deUint32 dstSubpass; || deUint32 dstSubpass;
1210 dependencyInfo.getSrcStageMask(), // VkPipelineStageFlags srcStageMask; || VkPipelineStageFlags srcStageMask;
1211 dependencyInfo.getDstStageMask(), // VkPipelineStageFlags dstStageMask; || VkPipelineStageFlags dstStageMask;
1212 dependencyInfo.getSrcAccessMask(), // VkAccessFlags srcAccessMask; || VkAccessFlags srcAccessMask;
1213 dependencyInfo.getDstAccessMask(), // VkAccessFlags dstAccessMask; || VkAccessFlags dstAccessMask;
1214 dependencyInfo.getFlags(), // VkDependencyFlags dependencyFlags; || VkDependencyFlags dependencyFlags;
1215 0u // || deInt32 viewOffset;
1221 de::MovePtr<VkRenderPassInputAttachmentAspectCreateInfo> createRenderPassInputAttachmentAspectCreateInfo(const RenderPass& renderPassInfo)
1223 de::MovePtr<VkRenderPassInputAttachmentAspectCreateInfo> result (DE_NULL);
1225 if (!renderPassInfo.getInputAspects().empty())
1227 const VkRenderPassInputAttachmentAspectCreateInfo inputAspectCreateInfo =
1229 VK_STRUCTURE_TYPE_RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO,
1232 (deUint32)renderPassInfo.getInputAspects().size(),
1233 renderPassInfo.getInputAspects().data(),
1236 result = de::MovePtr<VkRenderPassInputAttachmentAspectCreateInfo>(new VkRenderPassInputAttachmentAspectCreateInfo(inputAspectCreateInfo));
1242 template<typename AttachmentDesc, typename AttachmentRef, typename SubpassDesc, typename SubpassDep, typename RenderPassCreateInfo>
1243 Move<VkRenderPass> createRenderPass (const DeviceInterface& vk,
1245 const RenderPass& renderPassInfo)
1247 const size_t perSubpassAttachmentReferenceLists = 4;
1248 vector<AttachmentDesc> attachments;
1249 vector<SubpassDesc> subpasses;
1250 vector<SubpassDep> dependencies;
1251 vector<vector<AttachmentRef> > attachmentReferenceLists(renderPassInfo.getSubpasses().size() * perSubpassAttachmentReferenceLists);
1252 vector<vector<deUint32> > preserveAttachments(renderPassInfo.getSubpasses().size());
1253 de::MovePtr<VkRenderPassInputAttachmentAspectCreateInfo> inputAspectCreateInfo(createRenderPassInputAttachmentAspectCreateInfo(renderPassInfo));
1255 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
1256 attachments.push_back(createAttachmentDescription<AttachmentDesc>(renderPassInfo.getAttachments()[attachmentNdx]));
1258 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); subpassNdx++)
1259 subpasses.push_back(createSubpassDescription<SubpassDesc>(renderPassInfo.getSubpasses()[subpassNdx], &(attachmentReferenceLists[subpassNdx * perSubpassAttachmentReferenceLists]), &preserveAttachments[subpassNdx]));
1261 for (size_t depNdx = 0; depNdx < renderPassInfo.getDependencies().size(); depNdx++)
1262 dependencies.push_back(createSubpassDependency<SubpassDep>(renderPassInfo.getDependencies()[depNdx]));
1264 const RenderPassCreateInfo renderPassCreator // VkRenderPassCreateInfo || VkRenderPassCreateInfo2KHR
1266 // VkStructureType sType; || VkStructureType sType;
1267 inputAspectCreateInfo.get(), // const void* pNext; || const void* pNext;
1268 (VkRenderPassCreateFlags)0u, // VkRenderPassCreateFlags flags; || VkRenderPassCreateFlags flags;
1269 (deUint32)attachments.size(), // deUint32 attachmentCount; || deUint32 attachmentCount;
1270 (attachments.empty() ? DE_NULL : &attachments[0]), // const VkAttachmentDescription* pAttachments; || const VkAttachmentDescription2KHR* pAttachments;
1271 (deUint32)subpasses.size(), // deUint32 subpassCount; || deUint32 subpassCount;
1272 (subpasses.empty() ? DE_NULL : &subpasses[0]), // const VkSubpassDescription* pSubpasses; || const VkSubpassDescription2KHR* pSubpasses;
1273 (deUint32)dependencies.size(), // deUint32 dependencyCount; || deUint32 dependencyCount;
1274 (dependencies.empty() ? DE_NULL : &dependencies[0]), // const VkSubpassDependency* pDependencies; || const VkSubpassDependency2KHR* pDependencies;
1275 0u, // || deUint32 correlatedViewMaskCount;
1276 DE_NULL // || const deUint32* pCorrelatedViewMasks;
1279 return renderPassCreator.createRenderPass(vk, device);
1282 Move<VkRenderPass> createRenderPass (const DeviceInterface& vk,
1284 const RenderPass& renderPassInfo,
1285 const RenderingType renderPassType)
1287 switch (renderPassType)
1289 case RENDERING_TYPE_RENDERPASS_LEGACY:
1290 return createRenderPass<AttachmentDescription1, AttachmentReference1, SubpassDescription1, SubpassDependency1, RenderPassCreateInfo1>(vk, device, renderPassInfo);
1291 case RENDERING_TYPE_RENDERPASS2:
1292 return createRenderPass<AttachmentDescription2, AttachmentReference2, SubpassDescription2, SubpassDependency2, RenderPassCreateInfo2>(vk, device, renderPassInfo);
1294 TCU_THROW(InternalError, "Impossible");
1298 Move<VkFramebuffer> createFramebuffer (const DeviceInterface& vk,
1300 VkRenderPass renderPass,
1302 const vector<VkImageView>& attachments)
1304 return createFramebuffer(vk, device, 0u, renderPass, (deUint32)attachments.size(), attachments.empty() ? DE_NULL : &attachments[0], size.x(), size.y(), 1u);
1307 Move<VkImage> createAttachmentImage (const DeviceInterface& vk,
1309 deUint32 queueIndex,
1312 VkSampleCountFlagBits samples,
1313 VkImageUsageFlags usageFlags,
1314 VkImageLayout layout)
1316 VkImageUsageFlags targetUsageFlags = 0;
1317 const tcu::TextureFormat textureFormat = mapVkFormat(format);
1319 DE_ASSERT(!(tcu::hasDepthComponent(vk::mapVkFormat(format).order) || tcu::hasStencilComponent(vk::mapVkFormat(format).order))
1320 || ((usageFlags & vk::VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) == 0));
1322 DE_ASSERT((tcu::hasDepthComponent(vk::mapVkFormat(format).order) || tcu::hasStencilComponent(vk::mapVkFormat(format).order))
1323 || ((usageFlags & vk::VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0));
1325 if (tcu::hasDepthComponent(textureFormat.order) || tcu::hasStencilComponent(textureFormat.order))
1326 targetUsageFlags |= vk::VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
1328 targetUsageFlags |= vk::VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
1330 return createImage(vk, device,
1331 (VkImageCreateFlags)0,
1334 vk::makeExtent3D(size.x(), size.y(), 1u),
1338 VK_IMAGE_TILING_OPTIMAL,
1339 usageFlags | targetUsageFlags,
1340 VK_SHARING_MODE_EXCLUSIVE,
1346 de::MovePtr<Allocation> createImageMemory (const InstanceInterface& vki,
1347 const VkPhysicalDevice& vkd,
1348 const DeviceInterface& vk,
1350 Allocator& allocator,
1353 AllocationKind allocationKind)
1355 const MemoryRequirement memoryRequirement = lazy ? MemoryRequirement::LazilyAllocated : MemoryRequirement::Any;
1356 de::MovePtr<Allocation> allocation = allocateImage(vki, vk, vkd, device, image, memoryRequirement, allocator, allocationKind);
1358 bindImageMemory(vk, device, image, allocation->getMemory(), allocation->getOffset());
1363 Move<VkImageView> createImageAttachmentView (const DeviceInterface& vk,
1367 VkImageAspectFlags aspect)
1369 const VkImageSubresourceRange range =
1378 return createImageView(vk, device, 0u, image, VK_IMAGE_VIEW_TYPE_2D, format, makeComponentMappingRGBA(), range);
1381 VkClearValue randomClearValue (const Attachment& attachment, de::Random& rng, deBool useFormatCompCount, const DepthValuesArray& depthValues)
1383 const float clearNan = tcu::Float32::nan().asFloat();
1384 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
1386 if (tcu::hasStencilComponent(format.order) || tcu::hasDepthComponent(format.order))
1388 VkClearValue clearValue;
1390 clearValue.depthStencil.depth = clearNan;
1391 clearValue.depthStencil.stencil = 0xCDu;
1393 if (tcu::hasStencilComponent(format.order))
1394 clearValue.depthStencil.stencil = rng.getBool()
1398 if (tcu::hasDepthComponent(format.order))
1399 clearValue.depthStencil.depth = float(depthValues[rng.getBool() ? 1 : 0]) / 255.0f;
1405 VkClearValue clearValue;
1407 clearValue.color = randomColorClearValue(attachment, rng, useFormatCompCount);
1413 class AttachmentResources
1416 AttachmentResources (const InstanceInterface& vki,
1417 const VkPhysicalDevice& physDevice,
1418 const DeviceInterface& vk,
1420 Allocator& allocator,
1421 deUint32 queueIndex,
1423 const Attachment& attachmentInfo,
1424 VkImageUsageFlags usageFlags,
1425 const AllocationKind allocationKind)
1426 : m_image (createAttachmentImage(vk, device, queueIndex, size, attachmentInfo.getFormat(), attachmentInfo.getSamples(), usageFlags, VK_IMAGE_LAYOUT_UNDEFINED))
1427 , m_imageMemory (createImageMemory(vki, physDevice, vk, device, allocator, *m_image, ((usageFlags & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0), allocationKind))
1428 , m_attachmentView (createImageAttachmentView(vk, device, *m_image, attachmentInfo.getFormat(), getImageAspectFlags(attachmentInfo.getFormat())))
1430 const tcu::TextureFormat format = mapVkFormat(attachmentInfo.getFormat());
1431 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
1432 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
1434 if (isDepthFormat && isStencilFormat)
1436 m_depthInputAttachmentView = createImageAttachmentView(vk, device, *m_image, attachmentInfo.getFormat(), VK_IMAGE_ASPECT_DEPTH_BIT);
1437 m_stencilInputAttachmentView = createImageAttachmentView(vk, device, *m_image, attachmentInfo.getFormat(), VK_IMAGE_ASPECT_STENCIL_BIT);
1439 m_inputAttachmentViews = std::make_pair(*m_depthInputAttachmentView, *m_stencilInputAttachmentView);
1442 m_inputAttachmentViews = std::make_pair(*m_attachmentView, (vk::VkImageView)0u);
1444 if ((usageFlags & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)
1446 if (tcu::hasDepthComponent(format.order) && tcu::hasStencilComponent(format.order))
1448 const tcu::TextureFormat depthFormat = getDepthCopyFormat(attachmentInfo.getFormat());
1449 const tcu::TextureFormat stencilFormat = getStencilCopyFormat(attachmentInfo.getFormat());
1451 m_bufferSize = size.x() * size.y() * depthFormat.getPixelSize();
1452 m_secondaryBufferSize = size.x() * size.y() * stencilFormat.getPixelSize();
1454 m_buffer = createBuffer(vk, device, 0, m_bufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_SHARING_MODE_EXCLUSIVE, 1, &queueIndex);
1455 m_bufferMemory = allocateBuffer(vki, vk, physDevice, device, *m_buffer, MemoryRequirement::HostVisible, allocator, allocationKind);
1457 bindBufferMemory(vk, device, *m_buffer, m_bufferMemory->getMemory(), m_bufferMemory->getOffset());
1459 m_secondaryBuffer = createBuffer(vk, device, 0, m_secondaryBufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_SHARING_MODE_EXCLUSIVE, 1, &queueIndex);
1460 m_secondaryBufferMemory = allocateBuffer(vki, vk, physDevice, device, *m_secondaryBuffer, MemoryRequirement::HostVisible, allocator, allocationKind);
1462 bindBufferMemory(vk, device, *m_secondaryBuffer, m_secondaryBufferMemory->getMemory(), m_secondaryBufferMemory->getOffset());
1466 m_bufferSize = size.x() * size.y() * format.getPixelSize();
1468 m_buffer = createBuffer(vk, device, 0, m_bufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_SHARING_MODE_EXCLUSIVE, 1, &queueIndex);
1469 m_bufferMemory = allocateBuffer(vki, vk, physDevice, device, *m_buffer, MemoryRequirement::HostVisible, allocator, allocationKind);
1471 bindBufferMemory(vk, device, *m_buffer, m_bufferMemory->getMemory(), m_bufferMemory->getOffset());
1476 const pair<VkImageView, VkImageView>& getInputAttachmentViews (void) const
1478 return m_inputAttachmentViews;
1481 ~AttachmentResources (void)
1485 VkImageView getAttachmentView (void) const
1487 return *m_attachmentView;
1490 VkImage getImage (void) const
1495 VkBuffer getBuffer (void) const
1497 DE_ASSERT(*m_buffer != DE_NULL);
1501 VkDeviceSize getBufferSize (void) const
1503 DE_ASSERT(*m_buffer != DE_NULL);
1504 return m_bufferSize;
1507 const Allocation& getResultMemory (void) const
1509 DE_ASSERT(m_bufferMemory);
1510 return *m_bufferMemory;
1513 VkBuffer getSecondaryBuffer (void) const
1515 DE_ASSERT(*m_secondaryBuffer != DE_NULL);
1516 return *m_secondaryBuffer;
1519 VkDeviceSize getSecondaryBufferSize (void) const
1521 DE_ASSERT(*m_secondaryBuffer != DE_NULL);
1522 return m_secondaryBufferSize;
1525 const Allocation& getSecondaryResultMemory (void) const
1527 DE_ASSERT(m_secondaryBufferMemory);
1528 return *m_secondaryBufferMemory;
1532 const Unique<VkImage> m_image;
1533 const UniquePtr<Allocation> m_imageMemory;
1534 const Unique<VkImageView> m_attachmentView;
1536 Move<VkImageView> m_depthInputAttachmentView;
1537 Move<VkImageView> m_stencilInputAttachmentView;
1538 pair<VkImageView, VkImageView> m_inputAttachmentViews;
1540 Move<VkBuffer> m_buffer;
1541 VkDeviceSize m_bufferSize;
1542 de::MovePtr<Allocation> m_bufferMemory;
1544 Move<VkBuffer> m_secondaryBuffer;
1545 VkDeviceSize m_secondaryBufferSize;
1546 de::MovePtr<Allocation> m_secondaryBufferMemory;
1549 void uploadBufferData (const DeviceInterface& vk,
1551 const Allocation& memory,
1554 VkDeviceSize nonCoherentAtomSize)
1556 // Expand the range to flush to account for the nonCoherentAtomSize
1557 const VkDeviceSize roundedOffset = de::roundDown(memory.getOffset(), nonCoherentAtomSize);
1558 const VkDeviceSize roundedSize = de::roundUp(memory.getOffset() - roundedOffset + static_cast<VkDeviceSize>(size), nonCoherentAtomSize);
1560 const VkMappedMemoryRange range =
1562 VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // sType;
1564 memory.getMemory(), // mem;
1565 roundedOffset, // offset;
1566 roundedSize, // size;
1568 void* const ptr = memory.getHostPtr();
1570 deMemcpy(ptr, data, size);
1571 VK_CHECK(vk.flushMappedMemoryRanges(device, 1, &range));
1574 VkImageAspectFlagBits getPrimaryImageAspect (tcu::TextureFormat::ChannelOrder order)
1576 DE_STATIC_ASSERT(tcu::TextureFormat::CHANNELORDER_LAST == 22);
1580 case tcu::TextureFormat::D:
1581 case tcu::TextureFormat::DS:
1582 return VK_IMAGE_ASPECT_DEPTH_BIT;
1584 case tcu::TextureFormat::S:
1585 return VK_IMAGE_ASPECT_STENCIL_BIT;
1588 return VK_IMAGE_ASPECT_COLOR_BIT;
1592 deUint32 getAttachmentNdx (const vector<AttachmentReference>& colorAttachments, size_t ndx)
1594 return (colorAttachments[ndx].getAttachment() == VK_ATTACHMENT_UNUSED) ? (deUint32)ndx : colorAttachments[ndx].getAttachment();
1600 RenderQuad (const Vec2& posA, const Vec2& posB)
1603 m_vertices[0] = posA;
1604 m_vertices[1] = Vec2(posA[0], posB[1]);
1605 m_vertices[2] = posB;
1607 m_vertices[3] = posB;
1608 m_vertices[4] = Vec2(posB[0], posA[1]);
1609 m_vertices[5] = posA;
1612 const Vec2& getCornerA (void) const
1614 return m_vertices[0];
1617 const Vec2& getCornerB (void) const
1619 return m_vertices[2];
1622 const void* getVertexPointer (void) const
1624 return &m_vertices[0];
1627 size_t getVertexDataSize (void) const
1629 return sizeof(Vec2) * m_vertices.size();
1633 vector<Vec2> m_vertices;
1639 ColorClear (const UVec2& offset,
1641 const VkClearColorValue& color)
1648 const UVec2& getOffset (void) const { return m_offset; }
1649 const UVec2& getSize (void) const { return m_size; }
1650 const VkClearColorValue& getColor (void) const { return m_color; }
1655 VkClearColorValue m_color;
1658 class DepthStencilClear
1661 DepthStencilClear (const UVec2& offset,
1668 , m_stencil (stencil)
1672 const UVec2& getOffset (void) const { return m_offset; }
1673 const UVec2& getSize (void) const { return m_size; }
1674 float getDepth (void) const { return m_depth; }
1675 deUint32 getStencil (void) const { return m_stencil; }
1678 const UVec2 m_offset;
1681 const float m_depth;
1682 const deUint32 m_stencil;
1685 class SubpassRenderInfo
1688 SubpassRenderInfo (const RenderPass& renderPass,
1689 deUint32 subpassIndex,
1690 deUint32 drawStartNdx,
1693 bool omitBlendState_,
1695 const UVec2& viewportOffset,
1696 const UVec2& viewportSize,
1698 const Maybe<RenderQuad>& renderQuad,
1699 const vector<ColorClear>& colorClears,
1700 const Maybe<DepthStencilClear>& depthStencilClear)
1701 : m_viewportOffset (viewportOffset)
1702 , m_viewportSize (viewportSize)
1703 , m_subpassIndex (subpassIndex)
1704 , m_drawStartNdx (drawStartNdx)
1705 , m_isSecondary (isSecondary_)
1706 , m_omitBlendState (omitBlendState_)
1707 , m_flags (renderPass.getSubpasses()[subpassIndex].getFlags())
1708 , m_renderQuad (renderQuad)
1709 , m_colorClears (colorClears)
1710 , m_depthStencilClear (depthStencilClear)
1711 , m_colorAttachments (renderPass.getSubpasses()[subpassIndex].getColorAttachments())
1712 , m_inputAttachments (renderPass.getSubpasses()[subpassIndex].getInputAttachments())
1714 for (deUint32 attachmentNdx = 0; attachmentNdx < (deUint32)m_colorAttachments.size(); attachmentNdx++)
1715 m_colorAttachmentInfo.push_back(renderPass.getAttachments()[getAttachmentNdx(m_colorAttachments, attachmentNdx)]);
1717 if (renderPass.getSubpasses()[subpassIndex].getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
1719 m_depthStencilAttachment = tcu::just(renderPass.getSubpasses()[subpassIndex].getDepthStencilAttachment());
1720 m_depthStencilAttachmentInfo = tcu::just(renderPass.getAttachments()[renderPass.getSubpasses()[subpassIndex].getDepthStencilAttachment().getAttachment()]);
1724 const UVec2& getViewportOffset (void) const { return m_viewportOffset; }
1725 const UVec2& getViewportSize (void) const { return m_viewportSize; }
1727 deUint32 getSubpassIndex (void) const { return m_subpassIndex; }
1728 deUint32 getDrawStartNdx (void) const { return m_drawStartNdx; }
1729 bool isSecondary (void) const { return m_isSecondary; }
1730 bool getOmitBlendState (void) const { return m_omitBlendState; }
1732 const Maybe<RenderQuad>& getRenderQuad (void) const { return m_renderQuad; }
1733 const vector<ColorClear>& getColorClears (void) const { return m_colorClears; }
1734 const Maybe<DepthStencilClear>& getDepthStencilClear (void) const { return m_depthStencilClear; }
1736 deUint32 getInputAttachmentCount (void) const { return (deUint32)m_inputAttachments.size(); }
1737 deUint32 getInputAttachmentIndex (deUint32 attachmentNdx) const { return m_inputAttachments[attachmentNdx].getAttachment(); }
1738 VkImageLayout getInputAttachmentLayout (deUint32 attachmentNdx) const { return m_inputAttachments[attachmentNdx].getImageLayout(); }
1740 deUint32 getColorAttachmentCount (void) const { return (deUint32)m_colorAttachments.size(); }
1741 VkImageLayout getColorAttachmentLayout (deUint32 attachmentNdx) const { return m_colorAttachments[attachmentNdx].getImageLayout(); }
1742 deUint32 getColorAttachmentIndex (deUint32 attachmentNdx) const { return m_colorAttachments[attachmentNdx].getAttachment(); }
1743 const Attachment& getColorAttachment (deUint32 attachmentNdx) const { return m_colorAttachmentInfo[attachmentNdx]; }
1744 Maybe<VkImageLayout> getDepthStencilAttachmentLayout (void) const { return m_depthStencilAttachment ? tcu::just(m_depthStencilAttachment->getImageLayout()) : tcu::nothing<VkImageLayout>(); }
1745 Maybe<deUint32> getDepthStencilAttachmentIndex (void) const { return m_depthStencilAttachment ? tcu::just(m_depthStencilAttachment->getAttachment()) : tcu::nothing<deUint32>(); }
1746 const Maybe<Attachment>& getDepthStencilAttachment (void) const { return m_depthStencilAttachmentInfo; }
1747 VkSubpassDescriptionFlags getSubpassFlags (void) const { return m_flags; }
1750 UVec2 m_viewportOffset;
1751 UVec2 m_viewportSize;
1753 deUint32 m_subpassIndex;
1754 deUint32 m_drawStartNdx;
1756 bool m_omitBlendState;
1757 VkSubpassDescriptionFlags m_flags;
1759 Maybe<RenderQuad> m_renderQuad;
1760 vector<ColorClear> m_colorClears;
1761 Maybe<DepthStencilClear> m_depthStencilClear;
1763 vector<AttachmentReference> m_colorAttachments;
1764 vector<Attachment> m_colorAttachmentInfo;
1766 Maybe<AttachmentReference> m_depthStencilAttachment;
1767 Maybe<Attachment> m_depthStencilAttachmentInfo;
1769 vector<AttachmentReference> m_inputAttachments;
1772 void beginCommandBuffer (const DeviceInterface& vk,
1773 VkCommandBuffer cmdBuffer,
1774 VkCommandBufferUsageFlags pBeginInfo_flags,
1775 VkRenderPass pInheritanceInfo_renderPass,
1776 deUint32 pInheritanceInfo_subpass,
1777 VkFramebuffer pInheritanceInfo_framebuffer,
1778 VkBool32 pInheritanceInfo_occlusionQueryEnable,
1779 VkQueryControlFlags pInheritanceInfo_queryFlags,
1780 VkQueryPipelineStatisticFlags pInheritanceInfo_pipelineStatistics,
1781 const SubpassRenderInfo* pRenderInfo = 0,
1782 bool dynamicRenderPass = false )
1784 VkCommandBufferInheritanceInfo pInheritanceInfo =
1786 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO,
1788 pInheritanceInfo_renderPass,
1789 pInheritanceInfo_subpass,
1790 pInheritanceInfo_framebuffer,
1791 pInheritanceInfo_occlusionQueryEnable,
1792 pInheritanceInfo_queryFlags,
1793 pInheritanceInfo_pipelineStatistics,
1795 std::vector<vk::VkFormat> colorAttachmentFormats;
1796 VkCommandBufferInheritanceRenderingInfoKHR inheritanceRenderingInfo
1798 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR,
1804 VK_FORMAT_UNDEFINED,
1805 VK_FORMAT_UNDEFINED,
1806 VK_SAMPLE_COUNT_1_BIT,
1810 for (deUint32 i = 0; i < pRenderInfo->getColorAttachmentCount(); ++i)
1811 colorAttachmentFormats.push_back(pRenderInfo->getColorAttachment(i).getFormat());
1813 inheritanceRenderingInfo.colorAttachmentCount = static_cast<deUint32>(colorAttachmentFormats.size());
1814 inheritanceRenderingInfo.pColorAttachmentFormats = colorAttachmentFormats.data();
1815 if (pRenderInfo->getDepthStencilAttachment())
1817 const VkFormat dsFormat = pRenderInfo->getDepthStencilAttachment()->getFormat();
1818 inheritanceRenderingInfo.depthAttachmentFormat = tcu::hasDepthComponent(mapVkFormat(dsFormat).order) ? dsFormat : VK_FORMAT_UNDEFINED;
1819 inheritanceRenderingInfo.stencilAttachmentFormat = tcu::hasStencilComponent(mapVkFormat(dsFormat).order) ? dsFormat : VK_FORMAT_UNDEFINED;
1821 if (pRenderInfo->getColorAttachmentCount())
1822 inheritanceRenderingInfo.rasterizationSamples = pRenderInfo->getColorAttachment(0).getSamples();
1823 else if (pRenderInfo->getDepthStencilAttachment())
1824 inheritanceRenderingInfo.rasterizationSamples = pRenderInfo->getDepthStencilAttachment()->getSamples();
1826 if (dynamicRenderPass)
1827 pInheritanceInfo.pNext = &inheritanceRenderingInfo;
1829 const VkCommandBufferBeginInfo pBeginInfo =
1831 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
1836 VK_CHECK(vk.beginCommandBuffer(cmdBuffer, &pBeginInfo));
1839 Move<VkPipeline> createSubpassPipeline (const DeviceInterface& vk,
1841 VkRenderPass renderPass,
1842 VkShaderModule vertexShaderModule,
1843 VkShaderModule fragmentShaderModule,
1844 VkPipelineLayout pipelineLayout,
1845 const SubpassRenderInfo& renderInfo)
1847 Maybe<VkSampleCountFlagBits> rasterSamples;
1848 vector<VkPipelineColorBlendAttachmentState> attachmentBlendStates;
1850 for (deUint32 attachmentNdx = 0; attachmentNdx < renderInfo.getColorAttachmentCount(); attachmentNdx++)
1852 const Attachment& attachment = renderInfo.getColorAttachment(attachmentNdx);
1854 DE_ASSERT(!rasterSamples || *rasterSamples == attachment.getSamples());
1856 rasterSamples = attachment.getSamples();
1859 const VkPipelineColorBlendAttachmentState attachmentBlendState =
1861 VK_FALSE, // blendEnable
1862 VK_BLEND_FACTOR_SRC_ALPHA, // srcBlendColor
1863 VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, // destBlendColor
1864 VK_BLEND_OP_ADD, // blendOpColor
1865 VK_BLEND_FACTOR_ONE, // srcBlendAlpha
1866 VK_BLEND_FACTOR_ONE, // destBlendAlpha
1867 VK_BLEND_OP_ADD, // blendOpAlpha
1868 (attachmentNdx < renderInfo.getDrawStartNdx() ? (deUint32)0 :
1869 VK_COLOR_COMPONENT_R_BIT|VK_COLOR_COMPONENT_G_BIT|VK_COLOR_COMPONENT_B_BIT|VK_COLOR_COMPONENT_A_BIT) // channelWriteMask
1872 attachmentBlendStates.push_back(attachmentBlendState);
1876 if (renderInfo.getDepthStencilAttachment())
1878 const Attachment& attachment = *renderInfo.getDepthStencilAttachment();
1880 DE_ASSERT(!rasterSamples || *rasterSamples == attachment.getSamples());
1881 rasterSamples = attachment.getSamples();
1884 // If there are no attachment use single sample
1886 rasterSamples = VK_SAMPLE_COUNT_1_BIT;
1888 const VkVertexInputBindingDescription vertexBinding =
1891 (deUint32)sizeof(tcu::Vec2), // strideInBytes
1892 VK_VERTEX_INPUT_RATE_VERTEX, // stepRate
1895 const VkVertexInputAttributeDescription vertexAttrib =
1899 VK_FORMAT_R32G32_SFLOAT, // format
1900 0u, // offsetInBytes
1903 const VkPipelineVertexInputStateCreateInfo vertexInputState =
1905 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // sType
1907 (VkPipelineVertexInputStateCreateFlags)0u,
1909 &vertexBinding, // pVertexBindingDescriptions
1910 1u, // attributeCount
1911 &vertexAttrib, // pVertexAttributeDescriptions
1914 const VkPipelineInputAssemblyStateCreateInfo inputAssemblyState =
1916 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, // VkStructureType sType
1917 DE_NULL, // const void* pNext
1918 0u, // VkPipelineInputAssemblyStateCreateFlags flags
1919 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, // VkPrimitiveTopology topology
1920 VK_FALSE // VkBool32 primitiveRestartEnable
1923 const VkViewport viewport =
1925 (float)renderInfo.getViewportOffset().x(), (float)renderInfo.getViewportOffset().y(),
1926 (float)renderInfo.getViewportSize().x(), (float)renderInfo.getViewportSize().y(),
1930 const VkRect2D scissor =
1932 { (deInt32)renderInfo.getViewportOffset().x(), (deInt32)renderInfo.getViewportOffset().y() },
1933 { renderInfo.getViewportSize().x(), renderInfo.getViewportSize().y() }
1936 const VkPipelineViewportStateCreateInfo viewportState =
1938 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, // VkStructureType sType
1939 DE_NULL, // const void* pNext
1940 (VkPipelineViewportStateCreateFlags)0, // VkPipelineViewportStateCreateFlags flags
1941 1u, // deUint32 viewportCount
1942 &viewport, // const VkViewport* pViewports
1943 1u, // deUint32 scissorCount
1944 &scissor // const VkRect2D* pScissors
1947 const VkPipelineRasterizationStateCreateInfo rasterizationState =
1949 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, // VkStructureType sType
1950 DE_NULL, // const void* pNext
1951 0u, // VkPipelineRasterizationStateCreateFlags flags
1952 VK_FALSE, // VkBool32 depthClampEnable
1953 VK_FALSE, // VkBool32 rasterizerDiscardEnable
1954 VK_POLYGON_MODE_FILL, // VkPolygonMode polygonMode
1955 VK_CULL_MODE_NONE, // VkCullModeFlags cullMode
1956 VK_FRONT_FACE_COUNTER_CLOCKWISE, // VkFrontFace frontFace
1957 VK_FALSE, // VkBool32 depthBiasEnable
1958 0.0f, // float depthBiasConstantFactor
1959 0.0f, // float depthBiasClamp
1960 0.0f, // float depthBiasSlopeFactor
1961 1.0f // float lineWidth
1964 const VkPipelineMultisampleStateCreateInfo multisampleState =
1966 VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, // sType
1968 (VkPipelineMultisampleStateCreateFlags)0u,
1969 *rasterSamples, // rasterSamples
1970 VK_FALSE, // sampleShadingEnable
1971 0.0f, // minSampleShading
1972 DE_NULL, // pSampleMask
1973 VK_FALSE, // alphaToCoverageEnable
1974 VK_FALSE, // alphaToOneEnable
1976 const size_t stencilIndex = renderInfo.getSubpassIndex();
1978 const VkBool32 writeDepth = renderInfo.getDepthStencilAttachmentLayout()
1979 && *renderInfo.getDepthStencilAttachmentLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
1980 && *renderInfo.getDepthStencilAttachmentLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL
1984 const VkBool32 writeStencil = renderInfo.getDepthStencilAttachmentLayout()
1985 && *renderInfo.getDepthStencilAttachmentLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
1986 && *renderInfo.getDepthStencilAttachmentLayout() != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
1990 VkStencilOp stencilOp = writeStencil ? VK_STENCIL_OP_REPLACE : VK_STENCIL_OP_KEEP;
1992 const VkPipelineDepthStencilStateCreateInfo depthStencilState =
1994 VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, // sType
1996 (VkPipelineDepthStencilStateCreateFlags)0u,
1997 writeDepth, // depthTestEnable
1998 writeDepth, // depthWriteEnable
1999 VK_COMPARE_OP_ALWAYS, // depthCompareOp
2000 VK_FALSE, // depthBoundsEnable
2001 writeStencil, // stencilTestEnable
2003 stencilOp, // stencilFailOp
2004 stencilOp, // stencilPassOp
2005 stencilOp, // stencilDepthFailOp
2006 VK_COMPARE_OP_ALWAYS, // stencilCompareOp
2007 ~0u, // stencilCompareMask
2008 ~0u, // stencilWriteMask
2009 ((stencilIndex % 2) == 0) ? ~0x0u : 0x0u // stencilReference
2012 stencilOp, // stencilFailOp
2013 stencilOp, // stencilPassOp
2014 stencilOp, // stencilDepthFailOp
2015 VK_COMPARE_OP_ALWAYS, // stencilCompareOp
2016 ~0u, // stencilCompareMask
2017 ~0u, // stencilWriteMask
2018 ((stencilIndex % 2) == 0) ? ~0x0u : 0x0u // stencilReference
2021 0.0f, // minDepthBounds;
2022 1.0f // maxDepthBounds;
2025 const VkPipelineColorBlendStateCreateInfo blendState =
2027 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // sType
2029 (VkPipelineColorBlendStateCreateFlags)0u,
2030 VK_FALSE, // logicOpEnable
2031 VK_LOGIC_OP_COPY, // logicOp
2032 (deUint32)attachmentBlendStates.size(), // attachmentCount
2033 attachmentBlendStates.empty() ? DE_NULL : &attachmentBlendStates[0],// pAttachments
2034 { 0.0f, 0.0f, 0.0f, 0.0f } // blendConst
2037 std::vector<vk::VkFormat> colorAttachmentFormats;
2038 for (deUint32 i = 0; i < renderInfo.getColorAttachmentCount(); ++i)
2039 colorAttachmentFormats.push_back(renderInfo.getColorAttachment(i).getFormat());
2041 vk::VkFormat depthFormat = VK_FORMAT_UNDEFINED;
2042 vk::VkFormat stencilFormat = VK_FORMAT_UNDEFINED;
2043 if (renderInfo.getDepthStencilAttachment())
2045 const Attachment& attachment = *renderInfo.getDepthStencilAttachment();
2046 vk::VkFormat depthStencilFormat = attachment.getFormat();
2047 if (depthStencilFormat != VK_FORMAT_UNDEFINED)
2049 if (tcu::hasDepthComponent(mapVkFormat(depthStencilFormat).order))
2051 depthFormat = depthStencilFormat;
2053 if (tcu::hasStencilComponent(mapVkFormat(depthStencilFormat).order))
2055 stencilFormat = depthStencilFormat;
2061 VkPipelineRenderingCreateInfoKHR renderingCreateInfo
2063 VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR,
2066 static_cast<deUint32>(colorAttachmentFormats.size()),
2067 colorAttachmentFormats.data(),
2072 return makeGraphicsPipeline(vk, // const DeviceInterface& vk
2073 device, // const VkDevice device
2074 pipelineLayout, // const VkPipelineLayout pipelineLayout
2075 vertexShaderModule, // const VkShaderModule vertexShaderModule
2076 DE_NULL, // const VkShaderModule tessellationControlShaderModule
2077 DE_NULL, // const VkShaderModule tessellationEvalShaderModule
2078 DE_NULL, // const VkShaderModule geometryShaderModule
2079 fragmentShaderModule, // const VkShaderModule fragmentShaderModule
2080 renderPass, // const VkRenderPass renderPass
2081 renderInfo.getSubpassIndex(), // const deUint32 subpass
2082 &vertexInputState, // const VkPipelineVertexInputStateCreateInfo* vertexInputStateCreateInfo
2083 &inputAssemblyState, // const VkPipelineInputAssemblyStateCreateInfo* pInputAssemblyState;
2084 DE_NULL, // const VkPipelineRasterizationStateCreateInfo* rasterizationStateCreateInfo
2085 &viewportState, // const VkPipelineViewportStateCreateInfo* pViewportStat;
2086 &rasterizationState, // const VkPipelineRasterizationStateCreateInfo* pRasterizationState
2087 &multisampleState, // const VkPipelineMultisampleStateCreateInfo* multisampleStateCreateInfo
2088 &depthStencilState, // const VkPipelineDepthStencilStateCreateInfo* depthStencilStateCreateInfo
2089 renderInfo.getOmitBlendState()
2090 ? DE_NULL : &blendState, // const VkPipelineColorBlendStateCreateInfo* colorBlendStateCreateInfo
2091 DE_NULL, // const VkPipelineDynamicStateCreateInfo* dynamicStateCreateInfo
2092 (renderPass == DE_NULL)
2093 ? &renderingCreateInfo : DE_NULL); // const void* pNext)
2096 class SubpassRenderer
2099 SubpassRenderer (Context& context,
2100 const DeviceInterface& vk,
2102 Allocator& allocator,
2103 VkRenderPass renderPass,
2104 VkFramebuffer framebuffer,
2105 VkCommandPool commandBufferPool,
2106 deUint32 queueFamilyIndex,
2107 const vector<VkImage>& attachmentImages,
2108 const vector<pair<VkImageView, VkImageView> >& attachmentViews,
2109 const SubpassRenderInfo& renderInfo,
2110 const vector<Attachment>& attachmentInfos,
2111 const AllocationKind allocationKind,
2112 const bool dynamicRendering)
2113 : m_renderInfo (renderInfo)
2115 const InstanceInterface& vki = context.getInstanceInterface();
2116 const VkPhysicalDevice& physDevice = context.getPhysicalDevice();
2117 const deUint32 subpassIndex = renderInfo.getSubpassIndex();
2118 vector<VkDescriptorSetLayoutBinding> bindings;
2120 for (deUint32 colorAttachmentNdx = 0; colorAttachmentNdx < renderInfo.getColorAttachmentCount(); colorAttachmentNdx++)
2122 const deUint32 attachmentNdx = (renderInfo.getColorAttachmentIndex(colorAttachmentNdx) == VK_ATTACHMENT_UNUSED) ? colorAttachmentNdx
2123 : renderInfo.getColorAttachmentIndex(colorAttachmentNdx);
2125 m_colorAttachmentImages.push_back(attachmentImages[attachmentNdx]);
2128 if (renderInfo.getDepthStencilAttachmentIndex())
2129 m_depthStencilAttachmentImage = attachmentImages[*renderInfo.getDepthStencilAttachmentIndex()];
2131 if (renderInfo.getRenderQuad())
2133 const RenderQuad& renderQuad = *renderInfo.getRenderQuad();
2135 if (renderInfo.getInputAttachmentCount() > 0)
2137 deUint32 bindingIndex = 0;
2139 for (deUint32 inputAttachmentNdx = 0; inputAttachmentNdx < renderInfo.getInputAttachmentCount(); inputAttachmentNdx++)
2141 const Attachment attachmentInfo = attachmentInfos[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)];
2142 const VkImageLayout layout = renderInfo.getInputAttachmentLayout(inputAttachmentNdx);
2143 const tcu::TextureFormat format = mapVkFormat(attachmentInfo.getFormat());
2144 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
2145 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
2146 const deUint32 bindingCount = (isDepthFormat && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
2147 && (isStencilFormat && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
2151 for (deUint32 bindingNdx = 0; bindingNdx < bindingCount; bindingNdx++)
2153 const VkDescriptorSetLayoutBinding binding =
2156 vk::VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2158 vk::VK_SHADER_STAGE_FRAGMENT_BIT,
2162 bindings.push_back(binding);
2167 const VkDescriptorSetLayoutCreateInfo createInfo =
2169 vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
2173 (deUint32)bindings.size(),
2177 m_descriptorSetLayout = vk::createDescriptorSetLayout(vk, device, &createInfo);
2180 const VkDescriptorSetLayout descriptorSetLayout = *m_descriptorSetLayout;
2181 const VkPipelineLayoutCreateInfo pipelineLayoutParams =
2183 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // sType;
2185 (vk::VkPipelineLayoutCreateFlags)0,
2186 m_descriptorSetLayout ? 1u :0u , // setLayoutCount;
2187 m_descriptorSetLayout ? &descriptorSetLayout : DE_NULL, // pSetLayouts;
2188 0u, // pushConstantRangeCount;
2189 DE_NULL, // pPushConstantRanges;
2192 m_vertexShaderModule = createShaderModule(vk, device, context.getBinaryCollection().get(de::toString(subpassIndex) + "-vert"), 0u);
2193 m_fragmentShaderModule = createShaderModule(vk, device, context.getBinaryCollection().get(de::toString(subpassIndex) + "-frag"), 0u);
2194 m_pipelineLayout = createPipelineLayout(vk, device, &pipelineLayoutParams);
2195 m_pipeline = createSubpassPipeline(vk, device, renderPass, *m_vertexShaderModule, *m_fragmentShaderModule, *m_pipelineLayout, m_renderInfo);
2197 // Round up the vertex buffer size to honor nonCoherentAtomSize.
2198 const auto properties = vk::getPhysicalDeviceProperties(context.getInstanceInterface(), context.getPhysicalDevice());
2199 const auto vertexBufferSize = de::roundUp(static_cast<VkDeviceSize>(renderQuad.getVertexDataSize()), properties.limits.nonCoherentAtomSize);
2201 m_vertexBuffer = createBuffer(vk, device, 0u, vertexBufferSize, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, VK_SHARING_MODE_EXCLUSIVE, 1u, &queueFamilyIndex);
2202 m_vertexBufferMemory = allocateBuffer(vki, vk, physDevice, device, *m_vertexBuffer, MemoryRequirement::HostVisible, allocator, allocationKind);
2204 bindBufferMemory(vk, device, *m_vertexBuffer, m_vertexBufferMemory->getMemory(), m_vertexBufferMemory->getOffset());
2206 uploadBufferData(vk, device, *m_vertexBufferMemory, renderQuad.getVertexDataSize(), renderQuad.getVertexPointer(), properties.limits.nonCoherentAtomSize);
2208 if (renderInfo.getInputAttachmentCount() > 0)
2211 const VkDescriptorPoolSize poolSize =
2213 vk::VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2214 // \note Reserve 2 per input attachment since depthStencil attachments require 2.
2215 renderInfo.getInputAttachmentCount() * 2u
2217 const VkDescriptorPoolCreateInfo createInfo =
2219 vk::VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
2221 VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
2223 // \note Reserve 2 per input attachment since depthStencil attachments require 2.
2224 renderInfo.getInputAttachmentCount() * 2u,
2229 m_descriptorPool = vk::createDescriptorPool(vk, device, &createInfo);
2232 const VkDescriptorSetAllocateInfo allocateInfo =
2234 vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
2239 &descriptorSetLayout
2242 m_descriptorSet = vk::allocateDescriptorSet(vk, device, &allocateInfo);
2245 vector<VkWriteDescriptorSet> writes (bindings.size());
2246 vector<VkDescriptorImageInfo> imageInfos (bindings.size());
2247 deUint32 bindingIndex = 0;
2249 for (deUint32 inputAttachmentNdx = 0; inputAttachmentNdx < renderInfo.getInputAttachmentCount(); inputAttachmentNdx++)
2251 const Attachment attachmentInfo = attachmentInfos[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)];
2252 const tcu::TextureFormat format = mapVkFormat(attachmentInfo.getFormat());
2253 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
2254 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
2255 const VkImageLayout inputAttachmentLayout = renderInfo.getInputAttachmentLayout(inputAttachmentNdx);
2258 if (isDepthFormat && isStencilFormat)
2260 if (inputAttachmentLayout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
2262 const VkDescriptorImageInfo imageInfo =
2265 attachmentViews[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)].first,
2266 inputAttachmentLayout
2268 imageInfos[bindingIndex] = imageInfo;
2271 const VkWriteDescriptorSet write =
2273 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2280 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2281 &imageInfos[bindingIndex],
2285 writes[bindingIndex] = write;
2291 if (inputAttachmentLayout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
2293 const VkDescriptorImageInfo imageInfo =
2296 attachmentViews[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)].second,
2297 inputAttachmentLayout
2299 imageInfos[bindingIndex] = imageInfo;
2302 const VkWriteDescriptorSet write =
2304 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2311 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2312 &imageInfos[bindingIndex],
2316 writes[bindingIndex] = write;
2324 const VkDescriptorImageInfo imageInfo =
2327 attachmentViews[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)].first,
2328 inputAttachmentLayout
2330 imageInfos[bindingIndex] = imageInfo;
2333 const VkWriteDescriptorSet write =
2335 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2342 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2343 &imageInfos[bindingIndex],
2347 writes[bindingIndex] = write;
2354 vk.updateDescriptorSets(device, (deUint32)writes.size(), &writes[0], 0u, DE_NULL);
2359 if (renderInfo.isSecondary())
2361 m_commandBuffer = allocateCommandBuffer(vk, device, commandBufferPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2363 beginCommandBuffer(vk, *m_commandBuffer, vk::VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, renderPass, subpassIndex, framebuffer, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0, &renderInfo, dynamicRendering);
2364 pushRenderCommands(vk, *m_commandBuffer);
2365 endCommandBuffer(vk, *m_commandBuffer);
2369 bool isSecondary (void) const
2371 return m_commandBuffer;
2374 VkCommandBuffer getCommandBuffer (void) const
2376 DE_ASSERT(isSecondary());
2377 return *m_commandBuffer;
2380 void pushRenderCommands (const DeviceInterface& vk,
2381 VkCommandBuffer commandBuffer)
2383 if (!m_renderInfo.getColorClears().empty())
2385 const vector<ColorClear>& colorClears (m_renderInfo.getColorClears());
2387 for (deUint32 attachmentNdx = 0; attachmentNdx < m_renderInfo.getColorAttachmentCount(); attachmentNdx++)
2389 const ColorClear& colorClear = colorClears[attachmentNdx];
2390 const VkClearAttachment attachment =
2392 VK_IMAGE_ASPECT_COLOR_BIT,
2394 makeClearValue(colorClear.getColor()),
2396 const VkClearRect rect =
2399 { (deInt32)colorClear.getOffset().x(), (deInt32)colorClear.getOffset().y() },
2400 { colorClear.getSize().x(), colorClear.getSize().y() }
2402 0u, // baseArrayLayer
2406 vk.cmdClearAttachments(commandBuffer, 1u, &attachment, 1u, &rect);
2410 if (m_renderInfo.getDepthStencilClear())
2412 const DepthStencilClear& depthStencilClear = *m_renderInfo.getDepthStencilClear();
2413 const deUint32 attachmentNdx = m_renderInfo.getColorAttachmentCount();
2414 tcu::TextureFormat format = mapVkFormat(m_renderInfo.getDepthStencilAttachment()->getFormat());
2415 const VkImageLayout layout = *m_renderInfo.getDepthStencilAttachmentLayout();
2416 const VkClearAttachment attachment =
2418 (VkImageAspectFlags)((hasDepthComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL ? VK_IMAGE_ASPECT_DEPTH_BIT : 0)
2419 | (hasStencilComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL ? VK_IMAGE_ASPECT_STENCIL_BIT : 0)),
2421 makeClearValueDepthStencil(depthStencilClear.getDepth(), depthStencilClear.getStencil())
2423 const VkClearRect rect =
2426 { (deInt32)depthStencilClear.getOffset().x(), (deInt32)depthStencilClear.getOffset().y() },
2427 { depthStencilClear.getSize().x(), depthStencilClear.getSize().y() }
2429 0u, // baseArrayLayer
2433 if ((tcu::hasDepthComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
2434 || (tcu::hasStencilComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL))
2436 vk.cmdClearAttachments(commandBuffer, 1u, &attachment, 1u, &rect);
2440 vector<VkImageMemoryBarrier> selfDeps;
2441 VkPipelineStageFlags srcStages = 0;
2442 VkPipelineStageFlags dstStages = 0;
2444 for (deUint32 inputAttachmentNdx = 0; inputAttachmentNdx < m_renderInfo.getInputAttachmentCount(); inputAttachmentNdx++)
2446 for (deUint32 colorAttachmentNdx = 0; colorAttachmentNdx < m_renderInfo.getColorAttachmentCount(); colorAttachmentNdx++)
2448 if (m_renderInfo.getInputAttachmentIndex(inputAttachmentNdx) == m_renderInfo.getColorAttachmentIndex(colorAttachmentNdx))
2450 const VkImageMemoryBarrier barrier =
2452 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2455 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // srcAccessMask
2456 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT, // dstAccessMask
2458 VK_IMAGE_LAYOUT_GENERAL, // oldLayout
2459 VK_IMAGE_LAYOUT_GENERAL, // newLayout
2461 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex
2462 VK_QUEUE_FAMILY_IGNORED, // destQueueFamilyIndex
2464 m_colorAttachmentImages[colorAttachmentNdx], // image
2465 { // subresourceRange
2466 VK_IMAGE_ASPECT_COLOR_BIT, // aspect
2469 0, // baseArraySlice
2474 srcStages |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
2475 dstStages |= VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
2477 selfDeps.push_back(barrier);
2481 if (m_renderInfo.getDepthStencilAttachmentIndex() && (m_renderInfo.getInputAttachmentIndex(inputAttachmentNdx) == *m_renderInfo.getDepthStencilAttachmentIndex()))
2483 const tcu::TextureFormat format = mapVkFormat(m_renderInfo.getDepthStencilAttachment()->getFormat());
2484 const bool hasDepth = hasDepthComponent(format.order);
2485 const bool hasStencil = hasStencilComponent(format.order);
2486 const VkImageMemoryBarrier barrier =
2488 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
2491 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, // srcAccessMask
2492 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT, // dstAccessMask
2494 m_renderInfo.getInputAttachmentLayout(inputAttachmentNdx), // oldLayout
2495 m_renderInfo.getInputAttachmentLayout(inputAttachmentNdx), // newLayout;
2497 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex;
2498 VK_QUEUE_FAMILY_IGNORED, // destQueueFamilyIndex;
2500 m_depthStencilAttachmentImage, // image;
2501 { // subresourceRange;
2502 (hasDepth ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
2503 | (hasStencil ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u), // aspect;
2506 0, // baseArraySlice;
2511 srcStages |= VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT;
2512 dstStages |= VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
2514 selfDeps.push_back(barrier);
2518 if (!selfDeps.empty())
2520 DE_ASSERT(srcStages != 0);
2521 DE_ASSERT(dstStages != 0);
2522 vk.cmdPipelineBarrier(commandBuffer, srcStages, dstStages, VK_DEPENDENCY_BY_REGION_BIT, 0, DE_NULL, 0, DE_NULL, (deUint32)selfDeps.size(), &selfDeps[0]);
2525 if (m_renderInfo.getRenderQuad())
2527 const VkDeviceSize offset = 0;
2528 const VkBuffer vertexBuffer = *m_vertexBuffer;
2530 vk.cmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
2532 if (m_descriptorSet)
2534 const VkDescriptorSet descriptorSet = *m_descriptorSet;
2535 vk.cmdBindDescriptorSets(commandBuffer, vk::VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipelineLayout, 0u, 1u, &descriptorSet, 0u, NULL);
2538 vk.cmdBindVertexBuffers(commandBuffer, 0u, 1u, &vertexBuffer, &offset);
2539 vk.cmdDraw(commandBuffer, 6u, 1u, 0u, 0u);
2544 const SubpassRenderInfo m_renderInfo;
2545 Move<VkCommandBuffer> m_commandBuffer;
2546 Move<VkPipeline> m_pipeline;
2547 Move<VkDescriptorSetLayout> m_descriptorSetLayout;
2548 Move<VkPipelineLayout> m_pipelineLayout;
2550 Move<VkShaderModule> m_vertexShaderModule;
2551 Move<VkShaderModule> m_fragmentShaderModule;
2553 Move<VkDescriptorPool> m_descriptorPool;
2554 Move<VkDescriptorSet> m_descriptorSet;
2555 Move<VkBuffer> m_vertexBuffer;
2556 de::MovePtr<Allocation> m_vertexBufferMemory;
2557 vector<VkImage> m_colorAttachmentImages;
2558 VkImage m_depthStencilAttachmentImage;
2561 void pushImageInitializationCommands (const DeviceInterface& vk,
2562 VkCommandBuffer commandBuffer,
2563 const vector<Attachment>& attachmentInfo,
2564 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
2565 deUint32 queueIndex,
2566 const vector<Maybe<VkClearValue> >& clearValues)
2569 vector<VkImageMemoryBarrier> initializeLayouts;
2571 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2573 if (!clearValues[attachmentNdx])
2576 const VkImageMemoryBarrier barrier =
2578 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
2581 (VkAccessFlags)0, // srcAccessMask
2582 getAllMemoryReadFlags() | VK_ACCESS_TRANSFER_WRITE_BIT, // dstAccessMask
2584 VK_IMAGE_LAYOUT_UNDEFINED, // oldLayout
2585 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // newLayout;
2587 queueIndex, // srcQueueFamilyIndex;
2588 queueIndex, // destQueueFamilyIndex;
2590 attachmentResources[attachmentNdx]->getImage(), // image;
2591 { // subresourceRange;
2592 getImageAspectFlags(attachmentInfo[attachmentNdx].getFormat()), // aspect;
2595 0, // baseArraySlice;
2600 initializeLayouts.push_back(barrier);
2603 if (!initializeLayouts.empty())
2604 vk.cmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT,
2605 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, (VkDependencyFlags)0,
2606 0, (const VkMemoryBarrier*)DE_NULL,
2607 0, (const VkBufferMemoryBarrier*)DE_NULL,
2608 (deUint32)initializeLayouts.size(), &initializeLayouts[0]);
2611 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2613 if (!clearValues[attachmentNdx])
2616 const tcu::TextureFormat format = mapVkFormat(attachmentInfo[attachmentNdx].getFormat());
2618 if (hasStencilComponent(format.order) || hasDepthComponent(format.order))
2620 const float clearNan = tcu::Float32::nan().asFloat();
2621 const float clearDepth = hasDepthComponent(format.order) ? clearValues[attachmentNdx]->depthStencil.depth : clearNan;
2622 const deUint32 clearStencil = hasStencilComponent(format.order) ? clearValues[attachmentNdx]->depthStencil.stencil : 0xDEu;
2623 const VkClearDepthStencilValue depthStencil =
2628 const VkImageSubresourceRange range =
2630 (VkImageAspectFlags)((hasDepthComponent(format.order) ? VK_IMAGE_ASPECT_DEPTH_BIT : 0)
2631 | (hasStencilComponent(format.order) ? VK_IMAGE_ASPECT_STENCIL_BIT : 0)),
2638 vk.cmdClearDepthStencilImage(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &depthStencil, 1, &range);
2642 const VkImageSubresourceRange range =
2644 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask;
2647 0, // baseArrayLayer;
2650 const VkClearColorValue clearColor = clearValues[attachmentNdx]->color;
2652 vk.cmdClearColorImage(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clearColor, 1, &range);
2657 vector<VkImageMemoryBarrier> renderPassLayouts;
2659 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2661 const VkImageLayout oldLayout = clearValues[attachmentNdx] ? VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL : VK_IMAGE_LAYOUT_UNDEFINED;
2662 const VkImageMemoryBarrier barrier =
2664 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
2667 getMemoryFlagsForLayout(oldLayout), // srcAccessMask
2668 getAllMemoryReadFlags() | getMemoryFlagsForLayout(attachmentInfo[attachmentNdx].getInitialLayout()), // dstAccessMask
2670 oldLayout, // oldLayout
2671 attachmentInfo[attachmentNdx].getInitialLayout(), // newLayout;
2673 queueIndex, // srcQueueFamilyIndex;
2674 queueIndex, // destQueueFamilyIndex;
2676 attachmentResources[attachmentNdx]->getImage(), // image;
2677 { // subresourceRange;
2678 getImageAspectFlags(attachmentInfo[attachmentNdx].getFormat()), // aspect;
2681 0, // baseArraySlice;
2686 renderPassLayouts.push_back(barrier);
2689 if (!renderPassLayouts.empty())
2690 vk.cmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT,
2691 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, (VkDependencyFlags)0,
2692 0, (const VkMemoryBarrier*)DE_NULL,
2693 0, (const VkBufferMemoryBarrier*)DE_NULL,
2694 (deUint32)renderPassLayouts.size(), &renderPassLayouts[0]);
2698 template<typename RenderpassSubpass>
2699 void pushRenderPassCommands (const DeviceInterface& vk,
2700 VkCommandBuffer commandBuffer,
2701 VkRenderPass renderPass,
2702 VkFramebuffer framebuffer,
2703 const vector<de::SharedPtr<SubpassRenderer> >& subpassRenderers,
2704 const UVec2& renderPos,
2705 const UVec2& renderSize,
2706 const vector<Maybe<VkClearValue> >& renderPassClearValues,
2707 TestConfig::RenderTypes render)
2709 const float clearNan = tcu::Float32::nan().asFloat();
2710 vector<VkClearValue> attachmentClearValues;
2711 const typename RenderpassSubpass::SubpassEndInfo subpassEndInfo (DE_NULL);
2713 for (size_t attachmentNdx = 0; attachmentNdx < renderPassClearValues.size(); attachmentNdx++)
2715 if (renderPassClearValues[attachmentNdx])
2716 attachmentClearValues.push_back(*renderPassClearValues[attachmentNdx]);
2718 attachmentClearValues.push_back(makeClearValueColorF32(clearNan, clearNan, clearNan, clearNan));
2722 const VkRect2D renderArea =
2724 { (deInt32)renderPos.x(), (deInt32)renderPos.y() },
2725 { renderSize.x(), renderSize.y() }
2728 for (size_t subpassNdx = 0; subpassNdx < subpassRenderers.size(); subpassNdx++)
2730 const VkSubpassContents contents = subpassRenderers[subpassNdx]->isSecondary() ? VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS : VK_SUBPASS_CONTENTS_INLINE;
2731 const typename RenderpassSubpass::SubpassBeginInfo subpassBeginInfo (DE_NULL, contents);
2732 const VkRenderPassBeginInfo renderPassBeginInfo = createRenderPassBeginInfo(renderPass,
2735 (deUint32)attachmentClearValues.size(),
2736 attachmentClearValues.empty() ? DE_NULL : &attachmentClearValues[0]);
2738 if (subpassNdx == 0)
2739 RenderpassSubpass::cmdBeginRenderPass(vk, commandBuffer, &renderPassBeginInfo, &subpassBeginInfo);
2741 RenderpassSubpass::cmdNextSubpass(vk, commandBuffer, &subpassBeginInfo, &subpassEndInfo);
2745 if (contents == VK_SUBPASS_CONTENTS_INLINE)
2747 subpassRenderers[subpassNdx]->pushRenderCommands(vk, commandBuffer);
2749 else if (contents == VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS)
2751 const VkCommandBuffer cmd = subpassRenderers[subpassNdx]->getCommandBuffer();
2752 vk.cmdExecuteCommands(commandBuffer, 1, &cmd);
2755 DE_FATAL("Invalid contents");
2759 RenderpassSubpass::cmdEndRenderPass(vk, commandBuffer, &subpassEndInfo);
2763 void pushDynamicRenderingCommands (const DeviceInterface& vk,
2764 VkCommandBuffer commandBuffer,
2765 const RenderPass& renderPassInfo,
2766 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
2767 const vector<de::SharedPtr<SubpassRenderer> >& subpassRenderers,
2768 const UVec2& renderPos,
2769 const UVec2& renderSize,
2770 const vector<Maybe<VkClearValue> >& renderPassClearValues,
2771 deUint32 queueIndex,
2772 TestConfig::RenderTypes render)
2774 const float clearNan = tcu::Float32::nan().asFloat();
2775 const VkClearValue clearValueNan = makeClearValueColorF32(clearNan, clearNan, clearNan, clearNan);
2777 DE_ASSERT(subpassRenderers.size() == 1);
2779 VkRenderingFlagsKHR renderingFlags = 0u;
2780 if (subpassRenderers[0]->isSecondary())
2781 renderingFlags = VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR;
2783 const VkRect2D renderArea
2785 { (deInt32)renderPos.x(), (deInt32)renderPos.y() },
2786 { renderSize.x(), renderSize.y() }
2789 // translate structures that were prepared to construct renderpass to structures needed for dynamic rendering
2791 vector<VkImageMemoryBarrier> imageBarriersBeforeRendering;
2792 vector<VkImageMemoryBarrier> imageBarriersAfterRendering;
2793 std::vector<vk::VkRenderingAttachmentInfoKHR> colorAttachmentVect;
2794 const Subpass& subpassInfo = renderPassInfo.getSubpasses()[0];
2795 const vector<AttachmentReference>& colorAttachmentsInfo = subpassInfo.getColorAttachments();
2796 const vector<AttachmentReference>& resolveAttachmentsInfo = subpassInfo.getResolveAttachments();
2798 for (deUint32 i = 0 ; i < colorAttachmentsInfo.size() ; ++i)
2800 const AttachmentReference& colorAttachmentReference = colorAttachmentsInfo[i];
2801 const deUint32 colorAttachmentIndex = colorAttachmentReference.getAttachment();
2802 const Attachment& colorAttachmentInfo = renderPassInfo.getAttachments()[colorAttachmentIndex];
2804 VkResolveModeFlagBits resolveMode = VK_RESOLVE_MODE_NONE;
2805 VkImageView resolveImageView = DE_NULL;
2806 VkImageLayout resolveImageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
2808 // handle resolve attachments if they were specified
2809 if (!resolveAttachmentsInfo.empty())
2811 const AttachmentReference& resolveAttachmentReference = resolveAttachmentsInfo[i];
2812 const deUint32 resolveAttachmentIndex = resolveAttachmentReference.getAttachment();
2813 const Attachment& resolveAttachmentInfo = renderPassInfo.getAttachments()[resolveAttachmentIndex];
2815 resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
2816 resolveImageView = attachmentResources[resolveAttachmentIndex]->getAttachmentView();
2817 resolveImageLayout = resolveAttachmentInfo.getInitialLayout();
2820 colorAttachmentVect.push_back({
2821 vk::VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR, // VkStructureType sType
2822 DE_NULL, // const void* pNext
2823 attachmentResources[colorAttachmentIndex]->getAttachmentView(), // VkImageView imageView
2824 colorAttachmentReference.getImageLayout(), // VkImageLayout imageLayout
2825 resolveMode, // VkResolveModeFlagBits resolveMode
2826 resolveImageView, // VkImageView resolveImageView
2827 resolveImageLayout, // VkImageLayout resolveImageLayout
2828 colorAttachmentInfo.getLoadOp(), // VkAttachmentLoadOp loadOp
2829 colorAttachmentInfo.getStoreOp(), // VkAttachmentStoreOp storeOp
2830 (renderPassClearValues[colorAttachmentIndex] ?
2831 *renderPassClearValues[colorAttachmentIndex] :
2832 clearValueNan) // VkClearValue clearValue
2835 const VkImageLayout initialLayout = colorAttachmentInfo.getInitialLayout();
2836 const VkImageLayout renderingLayout = colorAttachmentReference.getImageLayout();
2837 const VkImageLayout finalLayout = colorAttachmentInfo.getFinalLayout();
2839 const VkImageMemoryBarrier barrierBeforeRendering
2841 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2844 getAllMemoryWriteFlags() | getMemoryFlagsForLayout(initialLayout), // srcAccessMask
2845 getMemoryFlagsForLayout(renderingLayout), // dstAccessMask
2847 initialLayout, // oldLayout
2848 renderingLayout, // newLayout
2850 queueIndex, // srcQueueFamilyIndex
2851 queueIndex, // destQueueFamilyIndex
2853 attachmentResources[colorAttachmentIndex]->getImage(), // image
2854 { // subresourceRange
2855 getImageAspectFlags(colorAttachmentInfo.getFormat()), // aspect;
2858 0, // baseArraySlice
2862 imageBarriersBeforeRendering.push_back(barrierBeforeRendering);
2864 const VkImageMemoryBarrier barrierAfterRendering
2866 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2869 getMemoryFlagsForLayout(renderingLayout), // srcAccessMask
2870 getAllMemoryReadFlags() | getMemoryFlagsForLayout(finalLayout), // dstAccessMask
2872 renderingLayout, // oldLayout
2873 finalLayout, // newLayout
2875 queueIndex, // srcQueueFamilyIndex
2876 queueIndex, // destQueueFamilyIndex
2878 attachmentResources[colorAttachmentIndex]->getImage(), // image
2879 { // subresourceRange
2880 getImageAspectFlags(colorAttachmentInfo.getFormat()), // aspect;
2883 0, // baseArraySlice
2887 imageBarriersAfterRendering.push_back(barrierAfterRendering);
2890 VkRenderingAttachmentInfoKHR* pDepthAttachment = DE_NULL;
2891 VkRenderingAttachmentInfoKHR* pStencilAttachment = DE_NULL;
2892 VkRenderingAttachmentInfoKHR depthAttachment
2894 vk::VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR, // VkStructureType sType;
2895 DE_NULL, // const void* pNext;
2896 DE_NULL, // VkImageView imageView;
2897 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout imageLayout;
2898 VK_RESOLVE_MODE_NONE, // VkResolveModeFlagBits resolveMode;
2899 DE_NULL, // VkImageView resolveImageView;
2900 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout resolveImageLayout;
2901 VK_ATTACHMENT_LOAD_OP_LOAD, // VkAttachmentLoadOp loadOp;
2902 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp;
2903 clearValueNan // VkClearValue clearValue;
2905 VkRenderingAttachmentInfoKHR stencilAttachment = depthAttachment;
2906 const AttachmentReference& depthStencilAttachmentReference = subpassInfo.getDepthStencilAttachment();
2907 const deUint32 dsAttachmentIndex = depthStencilAttachmentReference.getAttachment();
2909 if (dsAttachmentIndex != VK_ATTACHMENT_UNUSED)
2911 const Attachment& dsAttachmentInfo = renderPassInfo.getAttachments()[dsAttachmentIndex];
2912 const tcu::TextureFormat format = mapVkFormat(dsAttachmentInfo.getFormat());
2914 if (tcu::hasDepthComponent(format.order))
2916 depthAttachment.imageView = attachmentResources[dsAttachmentIndex]->getAttachmentView();
2917 depthAttachment.imageLayout = depthStencilAttachmentReference.getImageLayout();
2918 depthAttachment.loadOp = dsAttachmentInfo.getLoadOp();
2919 depthAttachment.storeOp = dsAttachmentInfo.getStoreOp();
2921 if (renderPassClearValues[dsAttachmentIndex])
2922 depthAttachment.clearValue = *renderPassClearValues[dsAttachmentIndex];
2924 pDepthAttachment = &depthAttachment;
2927 if (tcu::hasStencilComponent(format.order))
2929 stencilAttachment.imageView = attachmentResources[dsAttachmentIndex]->getAttachmentView();
2930 stencilAttachment.imageLayout = depthStencilAttachmentReference.getImageLayout();
2931 stencilAttachment.loadOp = dsAttachmentInfo.getStencilLoadOp();
2932 stencilAttachment.storeOp = dsAttachmentInfo.getStencilStoreOp();
2934 if (renderPassClearValues[dsAttachmentIndex])
2935 stencilAttachment.clearValue = *renderPassClearValues[dsAttachmentIndex];
2937 pStencilAttachment = &stencilAttachment;
2940 const VkImageLayout initialLayout = dsAttachmentInfo.getInitialLayout();
2941 const VkImageLayout renderingLayout = depthStencilAttachmentReference.getImageLayout();
2942 const VkImageLayout finalLayout = dsAttachmentInfo.getFinalLayout();
2944 const VkImageMemoryBarrier barrierBeforeRendering
2946 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2949 getAllMemoryWriteFlags() | getMemoryFlagsForLayout(initialLayout), // srcAccessMask
2950 getMemoryFlagsForLayout(renderingLayout), // dstAccessMask
2952 initialLayout, // oldLayout
2953 renderingLayout, // newLayout
2955 queueIndex, // srcQueueFamilyIndex
2956 queueIndex, // destQueueFamilyIndex
2958 attachmentResources[dsAttachmentIndex]->getImage(), // image
2959 { // subresourceRange
2960 getImageAspectFlags(dsAttachmentInfo.getFormat()), // aspect;
2963 0, // baseArraySlice
2967 imageBarriersBeforeRendering.push_back(barrierBeforeRendering);
2969 const VkImageMemoryBarrier barrierAfterRendering
2971 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2974 getMemoryFlagsForLayout(renderingLayout), // srcAccessMask
2975 getAllMemoryReadFlags() | getMemoryFlagsForLayout(finalLayout), // dstAccessMask
2977 renderingLayout, // oldLayout
2978 finalLayout, // newLayout
2980 queueIndex, // srcQueueFamilyIndex
2981 queueIndex, // destQueueFamilyIndex
2983 attachmentResources[dsAttachmentIndex]->getImage(), // image
2984 { // subresourceRange
2985 getImageAspectFlags(dsAttachmentInfo.getFormat()), // aspect;
2988 0, // baseArraySlice
2992 imageBarriersAfterRendering.push_back(barrierAfterRendering);
2995 if (!imageBarriersBeforeRendering.empty())
2996 vk.cmdPipelineBarrier(commandBuffer,
2997 getAllPipelineStageFlags(),
2998 getAllPipelineStageFlags(),
2999 (VkDependencyFlags)0,
3000 0, (const VkMemoryBarrier*)DE_NULL,
3001 0, (const VkBufferMemoryBarrier*)DE_NULL,
3002 (deUint32)imageBarriersBeforeRendering.size(),
3003 &imageBarriersBeforeRendering[0]);
3005 vk::VkRenderingInfoKHR renderingInfo
3007 vk::VK_STRUCTURE_TYPE_RENDERING_INFO_KHR,
3009 renderingFlags, // VkRenderingFlagsKHR flags;
3010 renderArea, // VkRect2D renderArea;
3011 1u, // deUint32 layerCount;
3012 0u, // deUint32 viewMask;
3013 static_cast<deUint32>(colorAttachmentVect.size()), // deUint32 colorAttachmentCount;
3014 colorAttachmentVect.empty() ? DE_NULL : &colorAttachmentVect[0], // const VkRenderingAttachmentInfoKHR* pColorAttachments;
3015 pDepthAttachment, // const VkRenderingAttachmentInfoKHR* pDepthAttachment;
3016 pStencilAttachment // const VkRenderingAttachmentInfoKHR* pStencilAttachment;
3019 vk.cmdBeginRenderingKHR(commandBuffer, &renderingInfo);
3023 if (subpassRenderers[0]->isSecondary())
3025 const VkCommandBuffer cmd = subpassRenderers[0]->getCommandBuffer();
3026 vk.cmdExecuteCommands(commandBuffer, 1, &cmd);
3029 subpassRenderers[0]->pushRenderCommands(vk, commandBuffer);
3032 vk.cmdEndRenderingKHR(commandBuffer);
3034 if (!imageBarriersAfterRendering.empty())
3035 vk.cmdPipelineBarrier(commandBuffer,
3036 getAllPipelineStageFlags(),
3037 getAllPipelineStageFlags(),
3038 (VkDependencyFlags)0,
3039 0, (const VkMemoryBarrier*)DE_NULL,
3040 0, (const VkBufferMemoryBarrier*)DE_NULL,
3041 (deUint32)imageBarriersAfterRendering.size(),
3042 &imageBarriersAfterRendering[0]);
3045 void pushRenderPassCommands (const DeviceInterface& vk,
3046 VkCommandBuffer commandBuffer,
3047 VkRenderPass renderPass,
3048 const RenderPass& renderPassInfo,
3049 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
3050 VkFramebuffer framebuffer,
3051 const vector<de::SharedPtr<SubpassRenderer> >& subpassRenderers,
3052 const UVec2& renderPos,
3053 const UVec2& renderSize,
3054 const vector<Maybe<VkClearValue> >& renderPassClearValues,
3055 deUint32 queueIndex,
3056 TestConfig::RenderTypes render,
3057 RenderingType renderingType)
3059 switch (renderingType)
3061 case RENDERING_TYPE_RENDERPASS_LEGACY:
3062 return pushRenderPassCommands<RenderpassSubpass1>(vk, commandBuffer, renderPass, framebuffer, subpassRenderers, renderPos, renderSize, renderPassClearValues, render);
3063 case RENDERING_TYPE_RENDERPASS2:
3064 return pushRenderPassCommands<RenderpassSubpass2>(vk, commandBuffer, renderPass, framebuffer, subpassRenderers, renderPos, renderSize, renderPassClearValues, render);
3065 case RENDERING_TYPE_DYNAMIC_RENDERING:
3066 return pushDynamicRenderingCommands(vk, commandBuffer, renderPassInfo, attachmentResources, subpassRenderers, renderPos, renderSize, renderPassClearValues, queueIndex, render);
3068 TCU_THROW(InternalError, "Impossible");
3072 void pushReadImagesToBuffers (const DeviceInterface& vk,
3073 VkCommandBuffer commandBuffer,
3074 deUint32 queueIndex,
3076 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
3077 const vector<Attachment>& attachmentInfo,
3078 const vector<bool>& isLazy,
3080 const UVec2& targetSize)
3083 vector<VkImageMemoryBarrier> imageBarriers;
3085 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
3087 if (isLazy[attachmentNdx])
3090 const VkImageLayout oldLayout = attachmentInfo[attachmentNdx].getFinalLayout();
3091 const VkImageMemoryBarrier barrier =
3093 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
3096 getAllMemoryWriteFlags() | getMemoryFlagsForLayout(oldLayout), // srcAccessMask
3097 getAllMemoryReadFlags(), // dstAccessMask
3099 oldLayout, // oldLayout
3100 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // newLayout
3102 queueIndex, // srcQueueFamilyIndex
3103 queueIndex, // destQueueFamilyIndex
3105 attachmentResources[attachmentNdx]->getImage(), // image
3106 { // subresourceRange
3107 getImageAspectFlags(attachmentInfo[attachmentNdx].getFormat()), // aspect;
3110 0, // baseArraySlice
3115 imageBarriers.push_back(barrier);
3118 if (!imageBarriers.empty())
3119 vk.cmdPipelineBarrier(commandBuffer,
3120 getAllPipelineStageFlags(),
3121 getAllPipelineStageFlags(),
3122 (VkDependencyFlags)0,
3123 0, (const VkMemoryBarrier*)DE_NULL,
3124 0, (const VkBufferMemoryBarrier*)DE_NULL,
3125 (deUint32)imageBarriers.size(), &imageBarriers[0]);
3128 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
3130 if (isLazy[attachmentNdx])
3133 const tcu::TextureFormat::ChannelOrder order = mapVkFormat(attachmentInfo[attachmentNdx].getFormat()).order;
3134 const VkBufferImageCopy rect =
3137 0, // bufferRowLength
3138 0, // bufferImageHeight
3139 { // imageSubresource
3140 (vk::VkImageAspectFlags)getPrimaryImageAspect(mapVkFormat(attachmentInfo[attachmentNdx].getFormat()).order), // aspect
3145 { 0, 0, 0 }, // imageOffset
3146 { targetSize.x(), targetSize.y(), 1u } // imageExtent
3149 vk.cmdCopyImageToBuffer(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, attachmentResources[attachmentNdx]->getBuffer(), 1, &rect);
3151 if (tcu::TextureFormat::DS == order)
3153 const VkBufferImageCopy stencilRect =
3156 0, // bufferRowLength
3157 0, // bufferImageHeight
3158 { // imageSubresource
3159 VK_IMAGE_ASPECT_STENCIL_BIT, // aspect
3164 { 0, 0, 0 }, // imageOffset
3165 { targetSize.x(), targetSize.y(), 1u } // imageExtent
3168 vk.cmdCopyImageToBuffer(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, attachmentResources[attachmentNdx]->getSecondaryBuffer(), 1, &stencilRect);
3173 vector<VkBufferMemoryBarrier> bufferBarriers;
3175 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
3177 if (isLazy[attachmentNdx])
3180 const tcu::TextureFormat::ChannelOrder order = mapVkFormat(attachmentInfo[attachmentNdx].getFormat()).order;
3181 const VkBufferMemoryBarrier bufferBarrier =
3183 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
3186 getAllMemoryWriteFlags(),
3187 getAllMemoryReadFlags(),
3192 attachmentResources[attachmentNdx]->getBuffer(),
3194 attachmentResources[attachmentNdx]->getBufferSize()
3197 bufferBarriers.push_back(bufferBarrier);
3199 if (tcu::TextureFormat::DS == order)
3201 const VkBufferMemoryBarrier secondaryBufferBarrier =
3203 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
3206 getAllMemoryWriteFlags(),
3207 getAllMemoryReadFlags(),
3212 attachmentResources[attachmentNdx]->getSecondaryBuffer(),
3214 attachmentResources[attachmentNdx]->getSecondaryBufferSize()
3217 bufferBarriers.push_back(secondaryBufferBarrier);
3221 if (!bufferBarriers.empty())
3222 vk.cmdPipelineBarrier(commandBuffer,
3223 getAllPipelineStageFlags(),
3224 getAllPipelineStageFlags(),
3225 (VkDependencyFlags)0,
3226 0, (const VkMemoryBarrier*)DE_NULL,
3227 (deUint32)bufferBarriers.size(), &bufferBarriers[0],
3228 0, (const VkImageMemoryBarrier*)DE_NULL);
3235 PixelValue (const Maybe<bool>& x = nothing<bool>(),
3236 const Maybe<bool>& y = nothing<bool>(),
3237 const Maybe<bool>& z = nothing<bool>(),
3238 const Maybe<bool>& w = nothing<bool>());
3240 void setUndefined (size_t ndx);
3241 void setValue (size_t ndx, bool value);
3242 Maybe<bool> getValue (size_t ndx) const;
3248 PixelValue::PixelValue (const Maybe<bool>& x,
3249 const Maybe<bool>& y,
3250 const Maybe<bool>& z,
3251 const Maybe<bool>& w)
3254 const Maybe<bool> values[] =
3259 for (size_t ndx = 0; ndx < DE_LENGTH_OF_ARRAY(values); ndx++)
3262 setValue(ndx, *values[ndx]);
3267 DE_ASSERT(m_status <= 0xFFu);
3270 void PixelValue::setUndefined (size_t ndx)
3273 DE_ASSERT(m_status <= 0xFFu);
3275 m_status &= (deUint16)~(0x1u << (deUint16)(ndx * 2));
3276 DE_ASSERT(m_status <= 0xFFu);
3279 void PixelValue::setValue (size_t ndx, bool value)
3282 DE_ASSERT(m_status <= 0xFFu);
3284 m_status = (deUint16)(m_status | (deUint16)(0x1u << (ndx * 2)));
3287 m_status = (deUint16)(m_status | (deUint16)(0x1u << (ndx * 2 + 1)));
3289 m_status &= (deUint16)~(0x1u << (deUint16)(ndx * 2 + 1));
3291 DE_ASSERT(m_status <= 0xFFu);
3294 Maybe<bool> PixelValue::getValue (size_t ndx) const
3297 DE_ASSERT(m_status <= 0xFFu);
3299 if ((m_status & (0x1u << (deUint16)(ndx * 2))) != 0)
3301 return just((m_status & (0x1u << (deUint32)(ndx * 2 + 1))) != 0);
3304 return nothing<bool>();
3307 void clearReferenceValues (vector<PixelValue>& values,
3308 const UVec2& targetSize,
3309 const UVec2& offset,
3312 const PixelValue& value)
3314 DE_ASSERT(targetSize.x() * targetSize.y() == (deUint32)values.size());
3315 DE_ASSERT(offset.x() + size.x() <= targetSize.x());
3316 DE_ASSERT(offset.y() + size.y() <= targetSize.y());
3318 for (deUint32 y = offset.y(); y < offset.y() + size.y(); y++)
3319 for (deUint32 x = offset.x(); x < offset.x() + size.x(); x++)
3321 for (int compNdx = 0; compNdx < 4; compNdx++)
3325 if (value.getValue(compNdx))
3326 values[x + y * targetSize.x()].setValue(compNdx, *value.getValue(compNdx));
3328 values[x + y * targetSize.x()].setUndefined(compNdx);
3334 void markUndefined (vector<PixelValue>& values,
3336 const UVec2& targetSize,
3337 const UVec2& offset,
3340 DE_ASSERT(targetSize.x() * targetSize.y() == (deUint32)values.size());
3342 for (deUint32 y = offset.y(); y < offset.y() + size.y(); y++)
3343 for (deUint32 x = offset.x(); x < offset.x() + size.x(); x++)
3345 for (int compNdx = 0; compNdx < 4; compNdx++)
3348 values[x + y * targetSize.x()].setUndefined(compNdx);
3353 PixelValue clearValueToPixelValue (const VkClearValue& value,
3354 const tcu::TextureFormat& format,
3355 const DepthValuesArray& depthValues)
3357 const bool isDepthAttachment = hasDepthComponent(format.order);
3358 const bool isStencilAttachment = hasStencilComponent(format.order);
3359 const bool isDepthOrStencilAttachment = isDepthAttachment || isStencilAttachment;
3360 PixelValue pixelValue;
3362 if (isDepthOrStencilAttachment)
3364 if (isDepthAttachment)
3366 if (value.depthStencil.depth == float(depthValues[1]) / 255.0f)
3367 pixelValue.setValue(0, true);
3368 else if (value.depthStencil.depth == float(depthValues[0]) / 255.0f)
3369 pixelValue.setValue(0, false);
3371 DE_FATAL("Unknown depth value");
3374 if (isStencilAttachment)
3376 if (value.depthStencil.stencil == 0xFFu)
3377 pixelValue.setValue(1, true);
3378 else if (value.depthStencil.stencil == 0x0u)
3379 pixelValue.setValue(1, false);
3381 DE_FATAL("Unknown stencil value");
3386 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
3387 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
3389 switch (channelClass)
3391 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
3392 for (int i = 0; i < 4; i++)
3396 if (value.color.int32[i] == 1)
3397 pixelValue.setValue(i, true);
3398 else if (value.color.int32[i] == 0)
3399 pixelValue.setValue(i, false);
3401 DE_FATAL("Unknown clear color value");
3406 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
3407 for (int i = 0; i < 4; i++)
3411 if (value.color.uint32[i] == 1u)
3412 pixelValue.setValue(i, true);
3413 else if (value.color.uint32[i] == 0u)
3414 pixelValue.setValue(i, false);
3416 DE_FATAL("Unknown clear color value");
3421 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
3422 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
3423 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
3424 for (int i = 0; i < 4; i++)
3428 if (value.color.float32[i] == 1.0f)
3429 pixelValue.setValue(i, true);
3430 else if (value.color.float32[i] == 0.0f)
3431 pixelValue.setValue(i, false);
3433 DE_FATAL("Unknown clear color value");
3439 DE_FATAL("Unknown channel class");
3446 void renderReferenceValues (vector<vector<PixelValue> >& referenceAttachments,
3447 const RenderPass& renderPassInfo,
3448 const UVec2& targetSize,
3449 const vector<Maybe<VkClearValue> >& imageClearValues,
3450 const vector<Maybe<VkClearValue> >& renderPassClearValues,
3451 const vector<SubpassRenderInfo>& subpassRenderInfo,
3452 const UVec2& renderPos,
3453 const UVec2& renderSize,
3454 const deUint32 drawStartNdx,
3455 const DepthValuesArray& depthValues)
3457 const vector<Subpass>& subpasses = renderPassInfo.getSubpasses();
3458 vector<bool> attachmentUsed (renderPassInfo.getAttachments().size(), false);
3460 referenceAttachments.resize(renderPassInfo.getAttachments().size());
3462 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
3464 const Attachment attachment = renderPassInfo.getAttachments()[attachmentNdx];
3465 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3466 vector<PixelValue>& reference = referenceAttachments[attachmentNdx];
3468 reference.resize(targetSize.x() * targetSize.y());
3470 if (imageClearValues[attachmentNdx])
3471 clearReferenceValues(reference, targetSize, UVec2(0, 0), targetSize, BVec4(true), clearValueToPixelValue(*imageClearValues[attachmentNdx], format, depthValues));
3474 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
3476 const Subpass& subpass = subpasses[subpassNdx];
3477 const SubpassRenderInfo& renderInfo = subpassRenderInfo[subpassNdx];
3478 const vector<AttachmentReference>& colorAttachments = subpass.getColorAttachments();
3480 // Apply load op if attachment was used for the first time
3481 for (size_t attachmentNdx = 0; attachmentNdx < colorAttachments.size(); attachmentNdx++)
3483 const deUint32 attachmentIndex = getAttachmentNdx(colorAttachments, attachmentNdx);
3485 if (!attachmentUsed[attachmentIndex] && colorAttachments[attachmentNdx].getAttachment() != VK_ATTACHMENT_UNUSED)
3487 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3488 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3489 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3491 DE_ASSERT(!tcu::hasDepthComponent(format.order));
3492 DE_ASSERT(!tcu::hasStencilComponent(format.order));
3494 if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
3495 clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(true), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format, depthValues));
3496 else if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
3497 markUndefined(reference, BVec4(true), targetSize, renderPos, renderSize);
3499 attachmentUsed[attachmentIndex] = true;
3503 // Apply load op to depth/stencil attachment if it was used for the first time
3504 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
3506 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3508 // Apply load op if attachment was used for the first time
3509 if (!attachmentUsed[attachmentIndex])
3511 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3512 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3513 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3515 if (tcu::hasDepthComponent(format.order))
3517 if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
3518 clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(true, false, false, false), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format, depthValues));
3519 else if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
3520 markUndefined(reference, BVec4(true, false, false, false), targetSize, renderPos, renderSize);
3523 if (tcu::hasStencilComponent(format.order))
3525 if (attachment.getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
3526 clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(false, true, false, false), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format, depthValues));
3527 else if (attachment.getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
3528 markUndefined(reference, BVec4(false, true, false, false), targetSize, renderPos, renderSize);
3531 attachmentUsed[attachmentIndex] = true;
3535 for (size_t colorClearNdx = 0; colorClearNdx < renderInfo.getColorClears().size(); colorClearNdx++)
3537 const ColorClear& colorClear = renderInfo.getColorClears()[colorClearNdx];
3538 const UVec2 offset = colorClear.getOffset();
3539 const UVec2 size = colorClear.getSize();
3540 const deUint32 attachmentIndex = subpass.getColorAttachments()[colorClearNdx].getAttachment();
3541 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3542 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3543 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3546 value.color = colorClear.getColor();
3548 clearReferenceValues(reference, targetSize, offset, size, BVec4(true), clearValueToPixelValue(value, format, depthValues));
3551 if (renderInfo.getDepthStencilClear())
3553 const DepthStencilClear& dsClear = *renderInfo.getDepthStencilClear();
3554 const UVec2 offset = dsClear.getOffset();
3555 const UVec2 size = dsClear.getSize();
3556 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3557 const VkImageLayout layout = subpass.getDepthStencilAttachment().getImageLayout();
3558 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3559 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3560 const bool hasStencil = tcu::hasStencilComponent(format.order)
3561 && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL;
3562 const bool hasDepth = tcu::hasDepthComponent(format.order)
3563 && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
3564 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3567 value.depthStencil.depth = dsClear.getDepth();
3568 value.depthStencil.stencil = dsClear.getStencil();
3570 clearReferenceValues(reference, targetSize, offset, size, BVec4(hasDepth, hasStencil, false, false), clearValueToPixelValue(value, format, depthValues));
3573 if (renderInfo.getRenderQuad())
3575 const RenderQuad& renderQuad = *renderInfo.getRenderQuad();
3576 const Vec2 posA = renderQuad.getCornerA();
3577 const Vec2 posB = renderQuad.getCornerB();
3578 const Vec2 origin = Vec2((float)renderInfo.getViewportOffset().x(), (float)renderInfo.getViewportOffset().y()) + Vec2((float)renderInfo.getViewportSize().x(), (float)renderInfo.getViewportSize().y()) / Vec2(2.0f);
3579 const Vec2 p = Vec2((float)renderInfo.getViewportSize().x(), (float)renderInfo.getViewportSize().y()) / Vec2(2.0f);
3580 const IVec2 posAI (deRoundFloatToInt32(origin.x() + (p.x() * posA.x())),
3581 deRoundFloatToInt32(origin.y() + (p.y() * posA.y())));
3582 const IVec2 posBI (deRoundFloatToInt32(origin.x() + (p.x() * posB.x())),
3583 deRoundFloatToInt32(origin.y() + (p.y() * posB.y())));
3585 DE_ASSERT(posAI.x() < posBI.x());
3586 DE_ASSERT(posAI.y() < posBI.y());
3588 if (subpass.getInputAttachments().empty())
3590 for (size_t attachmentRefNdx = drawStartNdx; attachmentRefNdx < subpass.getColorAttachments().size(); attachmentRefNdx++)
3592 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentRefNdx].getAttachment();
3594 if (attachmentIndex == VK_ATTACHMENT_UNUSED)
3597 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3598 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3599 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
3600 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3602 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3603 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3605 for (int compNdx = 0; compNdx < 4; compNdx++)
3607 const size_t index = subpassNdx + attachmentIndex + compNdx;
3608 const BoolOp op = boolOpFromIndex(index);
3609 const bool boolX = x % 2 == (int)(index % 2);
3610 const bool boolY = y % 2 == (int)((index / 2) % 2);
3612 if (channelMask[compNdx])
3613 reference[x + y * targetSize.x()].setValue(compNdx, performBoolOp(op, boolX, boolY));
3618 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
3620 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3621 const VkImageLayout layout = subpass.getDepthStencilAttachment().getImageLayout();
3622 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3623 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3624 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3626 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3627 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3629 if (tcu::hasDepthComponent(format.order)
3630 && layout != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3631 && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
3633 const size_t index = subpassNdx + 1;
3634 const BoolOp op = boolOpFromIndex(index);
3635 const bool boolX = x % 2 == (int)(index % 2);
3636 const bool boolY = y % 2 == (int)((index / 2) % 2);
3638 reference[x + y * targetSize.x()].setValue(0, performBoolOp(op, boolX, boolY));
3641 if (tcu::hasStencilComponent(format.order)
3642 && layout != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3643 && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
3645 const size_t index = subpassNdx;
3646 reference[x + y * targetSize.x()].setValue(1, (index % 2) == 0);
3653 size_t outputComponentCount = 0;
3654 vector<Maybe<bool> > inputs;
3656 DE_ASSERT(posAI.x() < posBI.x());
3657 DE_ASSERT(posAI.y() < posBI.y());
3659 for (size_t attachmentRefNdx = 0; attachmentRefNdx < subpass.getColorAttachments().size(); attachmentRefNdx++)
3661 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentRefNdx].getAttachment();
3662 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3663 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3664 const int componentCount = tcu::getNumUsedChannels(format.order);
3666 outputComponentCount += (size_t)componentCount;
3669 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3670 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3671 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
3673 const Attachment& attachment (renderPassInfo.getAttachments()[subpass.getDepthStencilAttachment().getAttachment()]);
3674 const tcu::TextureFormat format (mapVkFormat(attachment.getFormat()));
3676 if (tcu::hasDepthComponent(format.order))
3677 outputComponentCount++;
3680 if (outputComponentCount > 0)
3682 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3683 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3685 for (size_t inputAttachmentNdx = 0; inputAttachmentNdx < subpass.getInputAttachments().size(); inputAttachmentNdx++)
3687 const deUint32 attachmentIndex = subpass.getInputAttachments()[inputAttachmentNdx].getAttachment();
3688 const VkImageLayout layout = subpass.getInputAttachments()[inputAttachmentNdx].getImageLayout();
3689 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3690 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3691 const int componentCount = tcu::getNumUsedChannels(format.order);
3693 for (int compNdx = 0; compNdx < componentCount; compNdx++)
3695 if ((compNdx != 0 || layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
3696 && (compNdx != 1 || layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL))
3698 inputs.push_back(referenceAttachments[attachmentIndex][x + y * targetSize.x()].getValue(compNdx));
3703 const size_t inputsPerOutput = inputs.size() >= outputComponentCount
3704 ? ((inputs.size() / outputComponentCount)
3705 + ((inputs.size() % outputComponentCount) != 0 ? 1 : 0))
3708 size_t outputValueNdx = 0;
3710 for (size_t attachmentRefNdx = 0; attachmentRefNdx < subpass.getColorAttachments().size(); attachmentRefNdx++)
3712 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentRefNdx].getAttachment();
3713 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3714 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3715 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3716 const int componentCount = tcu::getNumUsedChannels(format.order);
3718 for (int compNdx = 0; compNdx < componentCount; compNdx++)
3720 const size_t index = subpassNdx + attachmentIndex + outputValueNdx;
3721 const BoolOp op = boolOpFromIndex(index);
3722 const bool boolX = x % 2 == (int)(index % 2);
3723 const bool boolY = y % 2 == (int)((index / 2) % 2);
3724 Maybe<bool> output = tcu::just(performBoolOp(op, boolX, boolY));
3726 for (size_t i = 0; i < inputsPerOutput; i++)
3730 else if (!inputs[((outputValueNdx + compNdx) * inputsPerOutput + i) % inputs.size()])
3731 output = tcu::nothing<bool>();
3733 output = (*output) == (*inputs[((outputValueNdx + compNdx) * inputsPerOutput + i) % inputs.size()]);
3737 reference[x + y * targetSize.x()].setValue(compNdx, *output);
3739 reference[x + y * targetSize.x()].setUndefined(compNdx);
3742 outputValueNdx += componentCount;
3745 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3746 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3747 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
3749 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3750 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3751 const size_t index = subpassNdx + attachmentIndex;
3752 const BoolOp op = boolOpFromIndex(index);
3753 const bool boolX = x % 2 == (int)(index % 2);
3754 const bool boolY = y % 2 == (int)((index / 2) % 2);
3755 Maybe<bool> output = tcu::just(performBoolOp(op, boolX, boolY));
3757 for (size_t i = 0; i < inputsPerOutput; i++)
3761 else if (inputs[(outputValueNdx * inputsPerOutput + i) % inputs.size()])
3762 output = (*output) == (*inputs[(outputValueNdx * inputsPerOutput + i) % inputs.size()]);
3764 output = tcu::nothing<bool>();
3768 reference[x + y * targetSize.x()].setValue(0, *output);
3770 reference[x + y * targetSize.x()].setUndefined(0);
3777 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3778 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3779 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
3781 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3782 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3783 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3784 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3786 if (tcu::hasStencilComponent(format.order))
3788 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3789 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3791 const size_t index = subpassNdx;
3792 reference[x + y * targetSize.x()].setValue(1, (index % 2) == 0);
3800 // Mark all attachments that were used but not stored as undefined
3801 for (size_t attachmentIndex = 0; attachmentIndex < renderPassInfo.getAttachments().size(); attachmentIndex++)
3803 const Attachment attachment = renderPassInfo.getAttachments()[attachmentIndex];
3804 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3805 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3806 const bool isStencilAttachment = hasStencilComponent(format.order);
3807 const bool isDepthOrStencilAttachment = hasDepthComponent(format.order) || isStencilAttachment;
3809 if (attachmentUsed[attachmentIndex] && renderPassInfo.getAttachments()[attachmentIndex].getStoreOp() == VK_ATTACHMENT_STORE_OP_DONT_CARE)
3811 if (isDepthOrStencilAttachment)
3812 markUndefined(reference, BVec4(true, false, false, false), targetSize, renderPos, renderSize);
3814 markUndefined(reference, BVec4(true), targetSize, renderPos, renderSize);
3817 if (attachmentUsed[attachmentIndex] && isStencilAttachment && renderPassInfo.getAttachments()[attachmentIndex].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_DONT_CARE)
3818 markUndefined(reference, BVec4(false, true, false, false), targetSize, renderPos, renderSize);
3822 void renderReferenceImagesFromValues (vector<tcu::TextureLevel>& referenceImages,
3823 const vector<vector<PixelValue> >& referenceValues,
3824 const UVec2& targetSize,
3825 const RenderPass& renderPassInfo,
3826 const DepthValuesArray& depthValues)
3828 referenceImages.resize(referenceValues.size());
3830 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
3832 const Attachment attachment = renderPassInfo.getAttachments()[attachmentNdx];
3833 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3834 const vector<PixelValue>& reference = referenceValues[attachmentNdx];
3835 const bool hasDepth = tcu::hasDepthComponent(format.order);
3836 const bool hasStencil = tcu::hasStencilComponent(format.order);
3837 const bool hasDepthOrStencil = hasDepth || hasStencil;
3838 tcu::TextureLevel& referenceImage = referenceImages[attachmentNdx];
3840 referenceImage.setStorage(format, targetSize.x(), targetSize.y());
3842 if (hasDepthOrStencil)
3846 const PixelBufferAccess depthAccess (tcu::getEffectiveDepthStencilAccess(referenceImage.getAccess(), tcu::Sampler::MODE_DEPTH));
3848 for (deUint32 y = 0; y < targetSize.y(); y++)
3849 for (deUint32 x = 0; x < targetSize.x(); x++)
3851 if (reference[x + y * targetSize.x()].getValue(0))
3853 if (*reference[x + y * targetSize.x()].getValue(0))
3854 depthAccess.setPixDepth(float(depthValues[1]) / 255.0f, x, y);
3856 depthAccess.setPixDepth(float(depthValues[0]) / 255.0f, x, y);
3858 else // Fill with 3x3 grid
3859 depthAccess.setPixDepth(((x / 3) % 2) == ((y / 3) % 2) ? 0.33f : 0.66f, x, y);
3865 const PixelBufferAccess stencilAccess (tcu::getEffectiveDepthStencilAccess(referenceImage.getAccess(), tcu::Sampler::MODE_STENCIL));
3867 for (deUint32 y = 0; y < targetSize.y(); y++)
3868 for (deUint32 x = 0; x < targetSize.x(); x++)
3870 if (reference[x + y * targetSize.x()].getValue(1))
3872 if (*reference[x + y * targetSize.x()].getValue(1))
3873 stencilAccess.setPixStencil(0xFFu, x, y);
3875 stencilAccess.setPixStencil(0x0u, x, y);
3877 else // Fill with 3x3 grid
3878 stencilAccess.setPixStencil(((x / 3) % 2) == ((y / 3) % 2) ? 85 : 170, x, y);
3884 for (deUint32 y = 0; y < targetSize.y(); y++)
3885 for (deUint32 x = 0; x < targetSize.x(); x++)
3889 for (int compNdx = 0; compNdx < 4; compNdx++)
3891 if (reference[x + y * targetSize.x()].getValue(compNdx))
3893 if (*reference[x + y * targetSize.x()].getValue(compNdx))
3894 color[compNdx] = 1.0f;
3896 color[compNdx] = 0.0f;
3898 else // Fill with 3x3 grid
3899 color[compNdx] = ((compNdx + (x / 3)) % 2) == ((y / 3) % 2) ? 0.33f : 0.66f;
3902 referenceImage.getAccess().setPixel(color, x, y);
3908 bool verifyColorAttachment (const vector<PixelValue>& reference,
3909 const ConstPixelBufferAccess& result,
3910 const PixelBufferAccess& errorImage,
3911 const deBool useFormatCompCount)
3913 const Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
3914 const Vec4 green (0.0f, 1.0f, 0.0f, 1.0f);
3917 DE_ASSERT(result.getWidth() * result.getHeight() == (int)reference.size());
3918 DE_ASSERT(result.getWidth() == errorImage.getWidth());
3919 DE_ASSERT(result.getHeight() == errorImage.getHeight());
3921 for (int y = 0; y < result.getHeight(); y++)
3922 for (int x = 0; x < result.getWidth(); x++)
3924 const Vec4 resultColor = result.getPixel(x, y);
3925 const PixelValue& referenceValue = reference[x + y * result.getWidth()];
3926 bool pixelOk = true;
3927 const deUint32 componentCount = useFormatCompCount ? (deUint32)tcu::getNumUsedChannels(result.getFormat().order) : 4;
3929 for (deUint32 compNdx = 0; compNdx < componentCount; compNdx++)
3931 const Maybe<bool> maybeValue = referenceValue.getValue(compNdx);
3935 const bool value = *maybeValue;
3937 if ((value && (resultColor[compNdx] != 1.0f))
3938 || (!value && resultColor[compNdx] != 0.0f))
3945 errorImage.setPixel(red, x, y);
3949 errorImage.setPixel(green, x, y);
3955 // Setting the alpha value to 1.0f by default helps visualization when the alpha channel is not used.
3956 const tcu::Vec4 kDefaultColorForLog {0.0f, 0.0f, 0.0f, 1.0f};
3957 const float kTrueComponent = 1.0f;
3958 const float kFalseComponent = 0.5f;
3959 const float kUnsetComponentLow = 0.0f;
3960 const float kUnsetComponentHigh = 0.25f;
3962 std::unique_ptr<tcu::TextureLevel> renderColorImageForLog (const ConstPixelBufferAccess& image, int numChannels)
3964 // Same channel order, but using UNORM_INT8 for the color format.
3965 const auto order = image.getFormat().order;
3966 const tcu::TextureFormat loggableFormat {order, tcu::TextureFormat::UNORM_INT8};
3967 const int width = image.getWidth();
3968 const int height = image.getHeight();
3969 std::unique_ptr<tcu::TextureLevel> result {new tcu::TextureLevel{loggableFormat, width, height}};
3970 auto access = result->getAccess();
3971 tcu::Vec4 outColor = kDefaultColorForLog;
3973 for (int x = 0; x < width; ++x)
3974 for (int y = 0; y < height; ++y)
3976 const auto value = image.getPixel(x, y);
3977 for (int c = 0; c < numChannels; ++c)
3979 if (value[c] == 0.0f)
3980 outColor[c] = kFalseComponent;
3981 else if (value[c] == 1.0f)
3982 outColor[c] = kTrueComponent;
3986 access.setPixel(outColor, x, y);
3992 std::unique_ptr<tcu::TextureLevel> renderColorImageForLog (const vector<PixelValue>& reference, const UVec2& targetSize, int numChannels)
3994 const tcu::TextureFormat loggableFormat {tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8};
3995 const int width = static_cast<int>(targetSize.x());
3996 const int height = static_cast<int>(targetSize.y());
3997 std::unique_ptr<tcu::TextureLevel> result {new tcu::TextureLevel{loggableFormat, width, height}};
3998 auto access = result->getAccess();
3999 tcu::Vec4 outColor = kDefaultColorForLog;
4001 for (int x = 0; x < width; ++x)
4002 for (int y = 0; y < height; ++y)
4004 const int index = x + y * width;
4005 for (int c = 0; c < numChannels; ++c)
4007 const auto maybeValue = reference[index].getValue(c);
4009 outColor[c] = ((*maybeValue) ? kTrueComponent : kFalseComponent);
4011 outColor[c] = ((((x / 3) % 2) == ((y / 3) % 2)) ? kUnsetComponentLow : kUnsetComponentHigh);
4013 access.setPixel(outColor, x, y);
4019 bool verifyDepthAttachment (const vector<PixelValue>& reference,
4020 const ConstPixelBufferAccess& result,
4021 const PixelBufferAccess& errorImage,
4022 const DepthValuesArray& depthValues,
4025 const Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
4026 const Vec4 green (0.0f, 1.0f, 0.0f, 1.0f);
4029 DE_ASSERT(result.getWidth() * result.getHeight() == (int)reference.size());
4030 DE_ASSERT(result.getWidth() == errorImage.getWidth());
4031 DE_ASSERT(result.getHeight() == errorImage.getHeight());
4033 for (int y = 0; y < result.getHeight(); y++)
4034 for (int x = 0; x < result.getWidth(); x++)
4036 bool pixelOk = true;
4038 const float resultDepth = result.getPixDepth(x, y);
4039 const PixelValue& referenceValue = reference[x + y * result.getWidth()];
4040 const Maybe<bool> maybeValue = referenceValue.getValue(0);
4044 const bool value = *maybeValue;
4046 if ((value && !depthsEqual(resultDepth, float(depthValues[1]) / 255.0f, epsilon))
4047 || (!value && !depthsEqual(resultDepth, float(depthValues[0]) / 255.0f, epsilon)))
4053 errorImage.setPixel(red, x, y);
4057 errorImage.setPixel(green, x, y);
4063 bool verifyStencilAttachment (const vector<PixelValue>& reference,
4064 const ConstPixelBufferAccess& result,
4065 const PixelBufferAccess& errorImage)
4067 const Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
4068 const Vec4 green (0.0f, 1.0f, 0.0f, 1.0f);
4071 DE_ASSERT(result.getWidth() * result.getHeight() == (int)reference.size());
4072 DE_ASSERT(result.getWidth() == errorImage.getWidth());
4073 DE_ASSERT(result.getHeight() == errorImage.getHeight());
4075 for (int y = 0; y < result.getHeight(); y++)
4076 for (int x = 0; x < result.getWidth(); x++)
4078 bool pixelOk = true;
4080 const deUint32 resultStencil = result.getPixStencil(x, y);
4081 const PixelValue& referenceValue = reference[x + y * result.getWidth()];
4082 const Maybe<bool> maybeValue = referenceValue.getValue(1);
4086 const bool value = *maybeValue;
4088 if ((value && (resultStencil != 0xFFu))
4089 || (!value && resultStencil != 0x0u))
4095 errorImage.setPixel(red, x, y);
4099 errorImage.setPixel(green, x, y);
4105 bool logAndVerifyImages (TestLog& log,
4106 const DeviceInterface& vk,
4108 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
4109 const vector<bool>& attachmentIsLazy,
4110 const RenderPass& renderPassInfo,
4111 const vector<Maybe<VkClearValue> >& renderPassClearValues,
4112 const vector<Maybe<VkClearValue> >& imageClearValues,
4113 const vector<SubpassRenderInfo>& subpassRenderInfo,
4114 const UVec2& targetSize,
4115 const TestConfig& config)
4117 vector<vector<PixelValue> > referenceValues;
4118 vector<tcu::TextureLevel> referenceAttachments;
4121 log << TestLog::Message << "Reference images fill undefined pixels with 3x3 grid pattern." << TestLog::EndMessage;
4123 renderReferenceValues(referenceValues, renderPassInfo, targetSize, imageClearValues, renderPassClearValues, subpassRenderInfo, config.renderPos, config.renderSize, config.drawStartNdx, config.depthValues);
4124 renderReferenceImagesFromValues(referenceAttachments, referenceValues, targetSize, renderPassInfo, config.depthValues);
4126 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
4128 if (!attachmentIsLazy[attachmentNdx])
4130 bool attachmentOK = true;
4131 const Attachment attachment = renderPassInfo.getAttachments()[attachmentNdx];
4132 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4134 if (tcu::hasDepthComponent(format.order) && tcu::hasStencilComponent(format.order))
4136 const tcu::TextureFormat depthFormat = getDepthCopyFormat(attachment.getFormat());
4137 void* const depthPtr = attachmentResources[attachmentNdx]->getResultMemory().getHostPtr();
4139 const tcu::TextureFormat stencilFormat = getStencilCopyFormat(attachment.getFormat());
4140 void* const stencilPtr = attachmentResources[attachmentNdx]->getSecondaryResultMemory().getHostPtr();
4142 invalidateAlloc(vk, device, attachmentResources[attachmentNdx]->getResultMemory());
4143 invalidateAlloc(vk, device, attachmentResources[attachmentNdx]->getSecondaryResultMemory());
4146 bool depthOK = true;
4147 bool stencilOK = true;
4148 const ConstPixelBufferAccess depthAccess (depthFormat, targetSize.x(), targetSize.y(), 1, depthPtr);
4149 const ConstPixelBufferAccess stencilAccess (stencilFormat, targetSize.x(), targetSize.y(), 1, stencilPtr);
4150 tcu::TextureLevel depthErrorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
4151 tcu::TextureLevel stencilErrorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
4153 if (renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE
4154 && !verifyDepthAttachment(referenceValues[attachmentNdx], depthAccess, depthErrorImage.getAccess(), config.depthValues, requiredDepthEpsilon(attachment.getFormat())))
4159 if (renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE
4160 && !verifyStencilAttachment(referenceValues[attachmentNdx], stencilAccess, stencilErrorImage.getAccess()))
4165 if (!depthOK || !stencilOK)
4167 const auto attachmentNdxStr = de::toString(attachmentNdx);
4170 log << TestLog::ImageSet("OutputAttachments" + attachmentNdxStr, "Output depth and stencil attachments " + attachmentNdxStr);
4171 log << TestLog::Image("Attachment" + attachmentNdxStr + "Depth", "Attachment " + attachmentNdxStr + " Depth", depthAccess);
4172 log << TestLog::Image("Attachment" + attachmentNdxStr + "Stencil", "Attachment " + attachmentNdxStr + " Stencil", stencilAccess);
4173 log << TestLog::EndImageSet;
4175 // Reference images. These will be logged as image sets due to having depth and stencil aspects.
4176 log << TestLog::Image("AttachmentReferences" + attachmentNdxStr, "Reference images " + attachmentNdxStr, referenceAttachments[attachmentNdx].getAccess());
4179 log << TestLog::ImageSet("ErrorMasks" + attachmentNdxStr, "Error masks " + attachmentNdxStr);
4181 log << TestLog::Image("DepthAttachmentError" + attachmentNdxStr, "Depth Attachment Error " + attachmentNdxStr, depthErrorImage.getAccess());
4183 log << TestLog::Image("StencilAttachmentError" + attachmentNdxStr, "Stencil Attachment Error " + attachmentNdxStr, stencilErrorImage.getAccess());
4184 log << TestLog::EndImageSet;
4186 attachmentOK = false;
4192 void* const ptr = attachmentResources[attachmentNdx]->getResultMemory().getHostPtr();
4194 invalidateAlloc(vk, device, attachmentResources[attachmentNdx]->getResultMemory());
4196 bool depthOK = true;
4197 bool stencilOK = true;
4198 bool colorOK = true;
4199 const ConstPixelBufferAccess access (format, targetSize.x(), targetSize.y(), 1, ptr);
4200 tcu::TextureLevel errorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
4202 if (tcu::hasDepthComponent(format.order))
4204 if ((renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE || renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE)
4205 && !verifyDepthAttachment(referenceValues[attachmentNdx], access, errorImage.getAccess(), config.depthValues, requiredDepthEpsilon(attachment.getFormat())))
4210 else if (tcu::hasStencilComponent(format.order))
4212 if ((renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE || renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE)
4213 && !verifyStencilAttachment(referenceValues[attachmentNdx], access, errorImage.getAccess()))
4220 if ((renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE || renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE)
4221 && !verifyColorAttachment(referenceValues[attachmentNdx], access, errorImage.getAccess(), config.useFormatCompCount))
4227 if (!depthOK || !stencilOK || !colorOK)
4229 log << TestLog::ImageSet("TestImages", "Output attachment, reference image and error mask");
4230 if (!depthOK || !stencilOK)
4232 // Log without conversions.
4233 log << TestLog::Image("Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx), access);
4234 log << TestLog::Image("AttachmentReference" + de::toString(attachmentNdx), "Attachment reference " + de::toString(attachmentNdx), referenceAttachments[attachmentNdx].getAccess());
4238 // Convert color images to better reflect test status and output in any format.
4239 const auto numChannels = tcu::getNumUsedChannels(access.getFormat().order);
4240 const auto attachmentForLog = renderColorImageForLog(access, numChannels);
4241 const auto referenceForLog = renderColorImageForLog(referenceValues[attachmentNdx], targetSize, numChannels);
4243 log << TestLog::Message << "Check the attachment formats and test data to verify which components affect the test result." << TestLog::EndMessage;
4244 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;
4245 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;
4247 log << TestLog::Image("Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx), attachmentForLog->getAccess());
4248 log << TestLog::Image("AttachmentReference" + de::toString(attachmentNdx), "Attachment reference " + de::toString(attachmentNdx), referenceForLog->getAccess());
4250 log << TestLog::Image("AttachmentError" + de::toString(attachmentNdx), "Attachment Error " + de::toString(attachmentNdx), errorImage.getAccess());
4251 log << TestLog::EndImageSet;
4253 attachmentOK = false;
4265 std::string getInputAttachmentType (VkFormat vkFormat)
4267 const tcu::TextureFormat format = mapVkFormat(vkFormat);
4268 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
4270 switch (channelClass)
4272 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
4273 return "isubpassInput";
4275 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
4276 return "usubpassInput";
4278 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
4279 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
4280 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
4281 return "subpassInput";
4284 DE_FATAL("Unknown channel class");
4289 std::string getAttachmentType (VkFormat vkFormat, deBool useFormatCompCount)
4291 const tcu::TextureFormat format = mapVkFormat(vkFormat);
4292 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
4293 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4295 switch (channelClass)
4297 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
4298 if (useFormatCompCount)
4299 return (componentCount == 1 ? "int" : "ivec" + de::toString(componentCount));
4303 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
4304 if (useFormatCompCount)
4305 return (componentCount == 1 ? "uint" : "uvec" + de::toString(componentCount));
4309 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
4310 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
4311 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
4312 if (useFormatCompCount)
4313 return (componentCount == 1 ? "float" : "vec" + de::toString(componentCount));
4318 DE_FATAL("Unknown channel class");
4323 void createTestShaders (SourceCollections& dst, TestConfig config)
4325 if (config.renderTypes & TestConfig::RENDERTYPES_DRAW)
4327 const vector<Subpass>& subpasses = config.renderPass.getSubpasses();
4329 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
4331 const Subpass& subpass = subpasses[subpassNdx];
4332 deUint32 inputAttachmentBinding = 0;
4333 std::ostringstream vertexShader;
4334 std::ostringstream fragmentShader;
4336 vertexShader << "#version 310 es\n"
4337 << "layout(location = 0) in highp vec2 a_position;\n"
4338 << "void main (void) {\n"
4339 << "\tgl_Position = vec4(a_position, 1.0, 1.0);\n"
4342 fragmentShader << "#version 310 es\n"
4343 << "precision highp float;\n";
4345 bool hasAnyDepthFormats = false;
4347 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
4349 const deUint32 attachmentIndex = subpass.getInputAttachments()[attachmentNdx].getAttachment();
4350 const VkImageLayout layout = subpass.getInputAttachments()[attachmentNdx].getImageLayout();
4351 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4352 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4353 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
4354 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
4356 if (isDepthFormat || isStencilFormat)
4358 if (isDepthFormat && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
4360 hasAnyDepthFormats = true;
4361 fragmentShader << "layout(input_attachment_index = " << attachmentNdx << ", set=0, binding=" << inputAttachmentBinding << ") uniform highp subpassInput i_depth" << attachmentNdx << ";\n";
4362 inputAttachmentBinding++;
4365 if (isStencilFormat && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4367 fragmentShader << "layout(input_attachment_index = " << attachmentNdx << ", set=0, binding=" << inputAttachmentBinding << ") uniform highp usubpassInput i_stencil" << attachmentNdx << ";\n";
4368 inputAttachmentBinding++;
4373 const std::string attachmentType = getInputAttachmentType(attachment.getFormat());
4375 fragmentShader << "layout(input_attachment_index = " << attachmentNdx << ", set=0, binding=" << inputAttachmentBinding << ") uniform highp " << attachmentType << " i_color" << attachmentNdx << ";\n";
4376 inputAttachmentBinding++;
4380 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
4382 const std::string attachmentType = getAttachmentType(config.renderPass.getAttachments()[getAttachmentNdx(subpass.getColorAttachments(), attachmentNdx)].getFormat(), config.useFormatCompCount);
4383 fragmentShader << "layout(location = " << attachmentNdx << ") out highp " << attachmentType << " o_color" << attachmentNdx << ";\n";
4386 if (hasAnyDepthFormats)
4387 fragmentShader << "\nbool depthsEqual(float a, float b, float epsilon) {\n"
4388 << "\treturn abs(a - b) <= epsilon;\n}\n\n";
4390 fragmentShader << "void main (void) {\n";
4392 if (subpass.getInputAttachments().empty())
4394 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
4396 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentNdx].getAttachment();
4398 if (attachmentIndex == VK_ATTACHMENT_UNUSED)
4401 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4402 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4403 const size_t componentCount = config.useFormatCompCount ? (size_t)tcu::getNumUsedChannels(format.order) : 4;
4404 const std::string attachmentType = getAttachmentType(attachment.getFormat(), config.useFormatCompCount);
4406 fragmentShader << "\to_color" << attachmentNdx << " = " << attachmentType << "(" << attachmentType + "(";
4408 for (size_t compNdx = 0; compNdx < componentCount; compNdx++)
4410 const size_t index = subpassNdx + attachmentIndex + compNdx;
4411 const BoolOp op = boolOpFromIndex(index);
4414 fragmentShader << ",\n\t\t";
4416 fragmentShader << "((int(gl_FragCoord.x) % 2 == " << (index % 2)
4417 << ") " << boolOpToString(op) << " ("
4418 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
4419 << ") ? 1.0 : 0.0)";
4422 fragmentShader << "));\n";
4425 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
4426 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
4427 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4429 const size_t index = subpassNdx + 1;
4430 const BoolOp op = boolOpFromIndex(index);
4432 fragmentShader << "\tgl_FragDepth = ((int(gl_FragCoord.x) % 2 == " << (index % 2)
4433 << ") " << boolOpToString(op) << " ("
4434 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
4435 << ") ? " << deUint32(config.depthValues[1]) << ".0f/255.0f : " << deUint32(config.depthValues[0]) << ".0f/255.0f);\n";
4440 size_t inputComponentCount = 0;
4441 size_t outputComponentCount = 0;
4443 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
4445 const deUint32 attachmentIndex = subpass.getInputAttachments()[attachmentNdx].getAttachment();
4446 const VkImageLayout layout = subpass.getInputAttachments()[attachmentNdx].getImageLayout();
4447 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4448 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4449 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4451 if (layout == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4452 inputComponentCount += 1;
4453 else if (layout == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
4454 inputComponentCount += 1;
4456 inputComponentCount += componentCount;
4459 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
4461 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentNdx].getAttachment();
4462 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4463 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4464 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4466 outputComponentCount += componentCount;
4469 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
4470 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
4471 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4473 outputComponentCount++;
4476 if (outputComponentCount > 0)
4478 const size_t inputsPerOutput = inputComponentCount >= outputComponentCount
4479 ? ((inputComponentCount / outputComponentCount)
4480 + ((inputComponentCount % outputComponentCount) != 0 ? 1 : 0))
4483 fragmentShader << "\tbool inputs[" << inputComponentCount << "];\n";
4485 if (outputComponentCount > 0)
4486 fragmentShader << "\tbool outputs[" << outputComponentCount << "];\n";
4488 size_t inputValueNdx = 0;
4490 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
4492 const char* const components[] =
4496 const deUint32 attachmentIndex = subpass.getInputAttachments()[attachmentNdx].getAttachment();
4497 const VkImageLayout layout = subpass.getInputAttachments()[attachmentNdx].getImageLayout();
4498 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4499 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4500 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4501 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
4502 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
4504 if (isDepthFormat || isStencilFormat)
4506 if (isDepthFormat && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
4508 fragmentShader << "\tinputs[" << inputValueNdx << "] = depthsEqual(" << deUint32(config.depthValues[1]) <<
4509 ".0f/255.0f, float(subpassLoad(i_depth" << attachmentNdx << ").x), " <<
4510 std::fixed << std::setprecision(12) << requiredDepthEpsilon(attachment.getFormat()) << ");\n";
4514 if (isStencilFormat && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4516 fragmentShader << "\tinputs[" << inputValueNdx << "] = 255u == subpassLoad(i_stencil" << attachmentNdx << ").x;\n";
4522 for (size_t compNdx = 0; compNdx < componentCount; compNdx++)
4524 fragmentShader << "\tinputs[" << inputValueNdx << "] = 1.0 == float(subpassLoad(i_color" << attachmentNdx << ")." << components[compNdx] << ");\n";
4530 size_t outputValueNdx = 0;
4532 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
4534 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentNdx].getAttachment();
4535 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4536 const std::string attachmentType = getAttachmentType(config.renderPass.getAttachments()[attachmentIndex].getFormat(), config.useFormatCompCount);
4537 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4538 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4540 for (size_t compNdx = 0; compNdx < componentCount; compNdx++)
4542 const size_t index = subpassNdx + attachmentIndex + outputValueNdx;
4543 const BoolOp op = boolOpFromIndex(index);
4545 fragmentShader << "\toutputs[" << outputValueNdx + compNdx << "] = "
4546 << "(int(gl_FragCoord.x) % 2 == " << (index % 2)
4547 << ") " << boolOpToString(op) << " ("
4548 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
4551 for (size_t i = 0; i < inputsPerOutput; i++)
4552 fragmentShader << "\toutputs[" << outputValueNdx + compNdx << "] = outputs[" << outputValueNdx + compNdx << "] == inputs[" << ((outputValueNdx + compNdx) * inputsPerOutput + i) % inputComponentCount << "];\n";
4555 fragmentShader << "\to_color" << attachmentNdx << " = " << attachmentType << "(";
4557 for (size_t compNdx = 0; compNdx < (config.useFormatCompCount ? componentCount : 4); compNdx++)
4560 fragmentShader << ", ";
4562 if (compNdx < componentCount)
4563 fragmentShader << "outputs[" << outputValueNdx + compNdx << "]";
4565 fragmentShader << "0";
4568 outputValueNdx += componentCount;
4570 fragmentShader << ");\n";
4573 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
4574 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
4575 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4577 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
4578 const size_t index = subpassNdx + attachmentIndex;
4579 const BoolOp op = boolOpFromIndex(index);
4581 fragmentShader << "\toutputs[" << outputValueNdx << "] = "
4582 << "(int(gl_FragCoord.x) % 2 == " << (index % 2)
4583 << ") " << boolOpToString(op) << " ("
4584 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
4587 for (size_t i = 0; i < inputsPerOutput; i++)
4588 fragmentShader << "\toutputs[" << outputValueNdx << "] = outputs[" << outputValueNdx << "] == inputs[" << (outputValueNdx * inputsPerOutput + i) % inputComponentCount << "];\n";
4590 fragmentShader << "\tgl_FragDepth = outputs[" << outputValueNdx << "] ? " << deUint32(config.depthValues[1]) << ".0f/255.0f : " << deUint32(config.depthValues[0]) << ".0f/255.0f;\n";
4595 fragmentShader << "}\n";
4597 dst.glslSources.add(de::toString(subpassNdx) + "-vert") << glu::VertexSource(vertexShader.str());
4598 dst.glslSources.add(de::toString(subpassNdx) + "-frag") << glu::FragmentSource(fragmentShader.str());
4603 void initializeAttachmentIsLazy (vector<bool>& attachmentIsLazy, const vector<Attachment>& attachments, TestConfig::ImageMemory imageMemory)
4605 bool lastAttachmentWasLazy = false;
4607 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4609 if (attachments[attachmentNdx].getLoadOp() != VK_ATTACHMENT_LOAD_OP_LOAD
4610 && attachments[attachmentNdx].getStoreOp() != VK_ATTACHMENT_STORE_OP_STORE
4611 && attachments[attachmentNdx].getStencilLoadOp() != VK_ATTACHMENT_LOAD_OP_LOAD
4612 && attachments[attachmentNdx].getStencilStoreOp() != VK_ATTACHMENT_STORE_OP_STORE)
4614 if (imageMemory == TestConfig::IMAGEMEMORY_LAZY || (imageMemory & TestConfig::IMAGEMEMORY_LAZY && !lastAttachmentWasLazy))
4616 attachmentIsLazy.push_back(true);
4618 lastAttachmentWasLazy = true;
4620 else if (imageMemory & TestConfig::IMAGEMEMORY_STRICT)
4622 attachmentIsLazy.push_back(false);
4623 lastAttachmentWasLazy = false;
4626 DE_FATAL("Unknown imageMemory");
4629 attachmentIsLazy.push_back(false);
4633 enum AttachmentRefType
4635 ATTACHMENTREFTYPE_COLOR,
4636 ATTACHMENTREFTYPE_DEPTH_STENCIL,
4637 ATTACHMENTREFTYPE_INPUT,
4638 ATTACHMENTREFTYPE_RESOLVE,
4641 VkImageUsageFlags getImageUsageFromLayout (VkImageLayout layout)
4645 case VK_IMAGE_LAYOUT_GENERAL:
4646 case VK_IMAGE_LAYOUT_PREINITIALIZED:
4649 case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
4650 return VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4652 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
4653 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL:
4654 return VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
4656 case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
4657 return VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
4659 case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
4660 return VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
4662 case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
4663 return VK_IMAGE_USAGE_TRANSFER_DST_BIT;
4666 DE_FATAL("Unexpected image layout");
4671 void getImageUsageFromAttachmentReferences(vector<VkImageUsageFlags>& attachmentImageUsage, AttachmentRefType refType, size_t count, const AttachmentReference* references)
4673 for (size_t referenceNdx = 0; referenceNdx < count; ++referenceNdx)
4675 const deUint32 attachment = references[referenceNdx].getAttachment();
4677 if (attachment != VK_ATTACHMENT_UNUSED)
4679 VkImageUsageFlags usage;
4683 case ATTACHMENTREFTYPE_COLOR:
4684 case ATTACHMENTREFTYPE_RESOLVE:
4685 usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4688 case ATTACHMENTREFTYPE_DEPTH_STENCIL:
4689 usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
4692 case ATTACHMENTREFTYPE_INPUT:
4693 usage = VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
4697 DE_FATAL("Unexpected attachment reference type");
4702 attachmentImageUsage[attachment] |= usage;
4707 void getImageUsageFromAttachmentReferences(vector<VkImageUsageFlags>& attachmentImageUsage, AttachmentRefType refType, const vector<AttachmentReference>& references)
4709 if (!references.empty())
4711 getImageUsageFromAttachmentReferences(attachmentImageUsage, refType, references.size(), &references[0]);
4715 void initializeAttachmentImageUsage (Context &context, vector<VkImageUsageFlags>& attachmentImageUsage, const RenderPass& renderPassInfo, const vector<bool>& attachmentIsLazy, const vector<Maybe<VkClearValue> >& clearValues)
4717 attachmentImageUsage.resize(renderPassInfo.getAttachments().size(), VkImageUsageFlags(0));
4719 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); ++subpassNdx)
4721 const Subpass& subpass = renderPassInfo.getSubpasses()[subpassNdx];
4723 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_COLOR, subpass.getColorAttachments());
4724 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_DEPTH_STENCIL, 1, &subpass.getDepthStencilAttachment());
4725 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_INPUT, subpass.getInputAttachments());
4726 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_RESOLVE, subpass.getResolveAttachments());
4729 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
4731 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentNdx];
4732 const VkFormatProperties formatProperties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), attachment.getFormat());
4733 const VkFormatFeatureFlags supportedFeatures = formatProperties.optimalTilingFeatures;
4735 if ((supportedFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0)
4736 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_SAMPLED_BIT;
4738 if ((supportedFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) != 0)
4739 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_STORAGE_BIT;
4741 attachmentImageUsage[attachmentNdx] |= getImageUsageFromLayout(attachment.getInitialLayout());
4742 attachmentImageUsage[attachmentNdx] |= getImageUsageFromLayout(attachment.getFinalLayout());
4744 if (!attachmentIsLazy[attachmentNdx])
4746 if (clearValues[attachmentNdx])
4747 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
4749 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
4753 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);
4755 attachmentImageUsage[attachmentNdx] &= allowedTransientBits;
4756 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4761 void initializeSubpassIsSecondary (vector<bool>& subpassIsSecondary, const vector<Subpass>& subpasses, TestConfig::CommandBufferTypes commandBuffer)
4763 bool lastSubpassWasSecondary = false;
4765 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
4767 if (commandBuffer == TestConfig::COMMANDBUFFERTYPES_SECONDARY || (commandBuffer & TestConfig::COMMANDBUFFERTYPES_SECONDARY && !lastSubpassWasSecondary))
4769 subpassIsSecondary.push_back(true);
4770 lastSubpassWasSecondary = true;
4772 else if (commandBuffer & TestConfig::COMMANDBUFFERTYPES_INLINE)
4774 subpassIsSecondary.push_back(false);
4775 lastSubpassWasSecondary = false;
4778 DE_FATAL("Unknown commandBuffer");
4782 void initializeImageClearValues (de::Random& rng, vector<Maybe<VkClearValue> >& clearValues, const vector<Attachment>& attachments, const vector<bool>& isLazy, deBool useFormatCompCount, const DepthValuesArray& depthValues)
4784 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4786 if (!isLazy[attachmentNdx])
4787 clearValues.push_back(just(randomClearValue(attachments[attachmentNdx], rng, useFormatCompCount, depthValues)));
4789 clearValues.push_back(nothing<VkClearValue>());
4793 void initializeRenderPassClearValues (de::Random& rng, vector<Maybe<VkClearValue> >& clearValues, const vector<Attachment>& attachments, deBool useFormatCompCount, const DepthValuesArray& depthValues)
4795 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4797 if (attachments[attachmentNdx].getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR
4798 || attachments[attachmentNdx].getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
4800 clearValues.push_back(just(randomClearValue(attachments[attachmentNdx], rng, useFormatCompCount, depthValues)));
4803 clearValues.push_back(nothing<VkClearValue>());
4807 void logSubpassRenderInfo (TestLog& log, const SubpassRenderInfo& info, TestConfig config)
4809 log << TestLog::Message << "Viewport, offset: " << info.getViewportOffset() << ", size: " << info.getViewportSize() << TestLog::EndMessage;
4811 if (info.isSecondary())
4812 log << TestLog::Message << "Subpass uses secondary command buffers" << TestLog::EndMessage;
4814 log << TestLog::Message << "Subpass uses inlined commands" << TestLog::EndMessage;
4816 for (deUint32 attachmentNdx = 0; attachmentNdx < info.getColorClears().size(); attachmentNdx++)
4818 const ColorClear& colorClear = info.getColorClears()[attachmentNdx];
4820 log << TestLog::Message << "Clearing color attachment " << attachmentNdx
4821 << ". Offset: " << colorClear.getOffset()
4822 << ", Size: " << colorClear.getSize()
4823 << ", Color: " << clearColorToString(info.getColorAttachment(attachmentNdx).getFormat(), colorClear.getColor(), config.useFormatCompCount) << TestLog::EndMessage;
4826 if (info.getDepthStencilClear())
4828 const DepthStencilClear& depthStencilClear = *info.getDepthStencilClear();
4830 log << TestLog::Message << "Clearing depth stencil attachment"
4831 << ". Offset: " << depthStencilClear.getOffset()
4832 << ", Size: " << depthStencilClear.getSize()
4833 << ", Depth: " << depthStencilClear.getDepth()
4834 << ", Stencil: " << depthStencilClear.getStencil() << TestLog::EndMessage;
4837 if (info.getRenderQuad())
4839 const RenderQuad& renderQuad = *info.getRenderQuad();
4841 log << TestLog::Message << "Rendering grid quad to " << renderQuad.getCornerA() << " -> " << renderQuad.getCornerB() << TestLog::EndMessage;
4845 void logTestCaseInfo (TestLog& log,
4846 const TestConfig& config,
4847 const vector<bool>& attachmentIsLazy,
4848 const vector<Maybe<VkClearValue> >& imageClearValues,
4849 const vector<Maybe<VkClearValue> >& renderPassClearValues,
4850 const vector<SubpassRenderInfo>& subpassRenderInfo)
4852 const RenderPass& renderPass = config.renderPass;
4854 logRenderPassInfo(log, renderPass);
4856 DE_ASSERT(attachmentIsLazy.size() == renderPass.getAttachments().size());
4857 DE_ASSERT(imageClearValues.size() == renderPass.getAttachments().size());
4858 DE_ASSERT(renderPassClearValues.size() == renderPass.getAttachments().size());
4860 log << TestLog::Message << "TargetSize: " << config.targetSize << TestLog::EndMessage;
4861 log << TestLog::Message << "Render area, Offset: " << config.renderPos << ", Size: " << config.renderSize << TestLog::EndMessage;
4863 for (size_t attachmentNdx = 0; attachmentNdx < attachmentIsLazy.size(); attachmentNdx++)
4865 const tcu::ScopedLogSection section (log, "Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx));
4867 if (attachmentIsLazy[attachmentNdx])
4868 log << TestLog::Message << "Is lazy." << TestLog::EndMessage;
4870 if (imageClearValues[attachmentNdx])
4871 log << TestLog::Message << "Image is cleared to " << clearValueToString(renderPass.getAttachments()[attachmentNdx].getFormat(),
4872 *imageClearValues[attachmentNdx], config.useFormatCompCount) << " before rendering." << TestLog::EndMessage;
4874 if (renderPass.getAttachments()[attachmentNdx].getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR && renderPassClearValues[attachmentNdx])
4875 log << TestLog::Message << "Attachment is cleared to " << clearValueToString(renderPass.getAttachments()[attachmentNdx].getFormat(),
4876 *renderPassClearValues[attachmentNdx], config.useFormatCompCount) << " in the beginning of the render pass." << TestLog::EndMessage;
4879 for (size_t subpassNdx = 0; subpassNdx < renderPass.getSubpasses().size(); subpassNdx++)
4881 const tcu::ScopedLogSection section (log, "Subpass" + de::toString(subpassNdx), "Subpass " + de::toString(subpassNdx));
4883 logSubpassRenderInfo(log, subpassRenderInfo[subpassNdx], config);
4887 float roundToViewport (float x, deUint32 offset, deUint32 size)
4889 const float origin = (float)(offset) + ((float(size) / 2.0f));
4890 const float p = (float)(size) / 2.0f;
4891 const deInt32 xi = deRoundFloatToInt32(origin + (p * x));
4893 return (((float)xi) - origin) / p;
4896 void initializeSubpassRenderInfo (vector<SubpassRenderInfo>& renderInfos, de::Random& rng, const RenderPass& renderPass, const TestConfig& config)
4898 const TestConfig::CommandBufferTypes commandBuffer = config.commandBufferTypes;
4899 const vector<Subpass>& subpasses = renderPass.getSubpasses();
4900 bool lastSubpassWasSecondary = false;
4902 for (deUint32 subpassNdx = 0; subpassNdx < (deUint32)subpasses.size(); subpassNdx++)
4904 const Subpass& subpass = subpasses[subpassNdx];
4905 const bool subpassIsSecondary = commandBuffer == TestConfig::COMMANDBUFFERTYPES_SECONDARY
4906 || (commandBuffer & TestConfig::COMMANDBUFFERTYPES_SECONDARY && !lastSubpassWasSecondary) ? true : false;
4907 const bool omitBlendState = subpass.getOmitBlendState();
4908 const UVec2 viewportSize ((config.renderSize * UVec2(2)) / UVec2(3));
4909 const UVec2 viewportOffset (config.renderPos.x() + (subpassNdx % 2) * (config.renderSize.x() / 3),
4910 config.renderPos.y() + ((subpassNdx / 2) % 2) * (config.renderSize.y() / 3));
4912 vector<ColorClear> colorClears;
4913 Maybe<DepthStencilClear> depthStencilClear;
4914 Maybe<RenderQuad> renderQuad;
4916 lastSubpassWasSecondary = subpassIsSecondary;
4918 if (config.renderTypes & TestConfig::RENDERTYPES_CLEAR)
4920 const vector<AttachmentReference>& colorAttachments = subpass.getColorAttachments();
4922 for (size_t attachmentRefNdx = 0; attachmentRefNdx < colorAttachments.size(); attachmentRefNdx++)
4924 const AttachmentReference& attachmentRef = colorAttachments[attachmentRefNdx];
4925 const Attachment& attachment = renderPass.getAttachments()[attachmentRef.getAttachment()];
4926 const UVec2 size ((viewportSize * UVec2(2)) / UVec2(3));
4927 const UVec2 offset (viewportOffset.x() + ((deUint32)attachmentRefNdx % 2u) * (viewportSize.x() / 3u),
4928 viewportOffset.y() + (((deUint32)attachmentRefNdx / 2u) % 2u) * (viewportSize.y() / 3u));
4929 const VkClearColorValue color = randomColorClearValue(attachment, rng, config.useFormatCompCount);
4931 colorClears.push_back(ColorClear(offset, size, color));
4934 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
4936 const Attachment& attachment = renderPass.getAttachments()[subpass.getDepthStencilAttachment().getAttachment()];
4937 const UVec2 size ((viewportSize * UVec2(2)) / UVec2(3));
4938 const UVec2 offset (viewportOffset.x() + ((deUint32)colorAttachments.size() % 2u) * (viewportSize.x() / 3u),
4939 viewportOffset.y() + (((deUint32)colorAttachments.size() / 2u) % 2u) * (viewportSize.y() / 3u));
4940 const VkClearValue value = randomClearValue(attachment, rng, config.useFormatCompCount, config.depthValues);
4942 depthStencilClear = tcu::just(DepthStencilClear(offset, size, value.depthStencil.depth, value.depthStencil.stencil));
4946 if (config.renderTypes & TestConfig::RENDERTYPES_DRAW)
4948 const float w = (subpassNdx % 2) == 0 ? 1.0f : 1.25f;
4949 const float h = (subpassNdx % 2) == 0 ? 1.25f : 1.0f;
4951 const float x0 = roundToViewport((subpassNdx % 2) == 0 ? 1.0f - w : -1.0f, viewportOffset.x(), viewportSize.x());
4952 const float x1 = roundToViewport((subpassNdx % 2) == 0 ? 1.0f : -1.0f + w, viewportOffset.x(), viewportSize.x());
4954 const float y0 = roundToViewport(((subpassNdx / 2) % 2) == 0 ? 1.0f - h : -1.0f, viewportOffset.y(), viewportSize.y());
4955 const float y1 = roundToViewport(((subpassNdx / 2) % 2) == 0 ? 1.0f : -1.0f + h, viewportOffset.y(), viewportSize.y());
4957 renderQuad = tcu::just(RenderQuad(tcu::Vec2(x0, y0), tcu::Vec2(x1, y1)));
4960 renderInfos.push_back(SubpassRenderInfo(renderPass, subpassNdx, config.drawStartNdx, subpassIsSecondary, omitBlendState, viewportOffset, viewportSize, renderQuad, colorClears, depthStencilClear));
4964 void checkTextureFormatSupport (TestLog& log,
4965 const InstanceInterface& vk,
4966 VkPhysicalDevice device,
4967 const vector<Attachment>& attachments)
4969 bool supported = true;
4971 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4973 const Attachment& attachment = attachments[attachmentNdx];
4974 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4975 const bool isDepthOrStencilAttachment = hasDepthComponent(format.order) || hasStencilComponent(format.order);
4976 const VkFormatFeatureFlags flags = isDepthOrStencilAttachment? VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT : VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
4977 VkFormatProperties properties;
4979 vk.getPhysicalDeviceFormatProperties(device, attachment.getFormat(), &properties);
4981 if ((properties.optimalTilingFeatures & flags) != flags)
4984 log << TestLog::Message << "Format: " << attachment.getFormat() << " not supported as " << (isDepthOrStencilAttachment ? "depth stencil attachment" : "color attachment") << TestLog::EndMessage;
4989 TCU_THROW(NotSupportedError, "Format not supported");
4992 tcu::TestStatus renderPassTest (Context& context, TestConfig config)
4994 const UVec2 targetSize = config.targetSize;
4995 const UVec2 renderPos = config.renderPos;
4996 const UVec2 renderSize = config.renderSize;
4997 const RenderPass& renderPassInfo = config.renderPass;
4999 TestLog& log = context.getTestContext().getLog();
5000 de::Random rng (config.seed);
5002 vector<bool> attachmentIsLazy;
5003 vector<VkImageUsageFlags> attachmentImageUsage;
5004 vector<Maybe<VkClearValue> > imageClearValues;
5005 vector<Maybe<VkClearValue> > renderPassClearValues;
5007 vector<bool> subpassIsSecondary;
5008 vector<SubpassRenderInfo> subpassRenderInfo;
5010 if (config.renderingType == RENDERING_TYPE_RENDERPASS2)
5011 context.requireDeviceFunctionality("VK_KHR_create_renderpass2");
5013 if (config.renderingType == RENDERING_TYPE_DYNAMIC_RENDERING)
5014 context.requireDeviceFunctionality("VK_KHR_dynamic_rendering");
5016 if (config.allocationKind == ALLOCATION_KIND_DEDICATED)
5018 if (!context.isDeviceFunctionalitySupported("VK_KHR_dedicated_allocation"))
5019 TCU_THROW(NotSupportedError, "VK_KHR_dedicated_allocation is not supported");
5022 if (!renderPassInfo.getInputAspects().empty())
5024 if (!context.isDeviceFunctionalitySupported("VK_KHR_maintenance2"))
5025 TCU_THROW(NotSupportedError, "Extension VK_KHR_maintenance2 not supported.");
5029 bool requireDepthStencilLayout = false;
5031 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
5033 if (renderPassInfo.getAttachments()[attachmentNdx].getInitialLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5034 || renderPassInfo.getAttachments()[attachmentNdx].getInitialLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL
5035 || renderPassInfo.getAttachments()[attachmentNdx].getFinalLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5036 || renderPassInfo.getAttachments()[attachmentNdx].getFinalLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5038 requireDepthStencilLayout = true;
5043 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size() && !requireDepthStencilLayout; subpassNdx++)
5045 const Subpass& subpass (renderPassInfo.getSubpasses()[subpassNdx]);
5047 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
5049 if (subpass.getColorAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5050 || subpass.getColorAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5052 requireDepthStencilLayout = true;
5057 for (size_t attachmentNdx = 0; !requireDepthStencilLayout && attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
5059 if (subpass.getInputAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5060 || subpass.getInputAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5062 requireDepthStencilLayout = true;
5067 for (size_t attachmentNdx = 0; !requireDepthStencilLayout && attachmentNdx < subpass.getResolveAttachments().size(); attachmentNdx++)
5069 if (subpass.getResolveAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5070 || subpass.getResolveAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5072 requireDepthStencilLayout = true;
5077 if (subpass.getDepthStencilAttachment().getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5078 || subpass.getDepthStencilAttachment().getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5080 requireDepthStencilLayout = true;
5085 if (requireDepthStencilLayout && !context.isDeviceFunctionalitySupported("VK_KHR_maintenance2"))
5086 TCU_THROW(NotSupportedError, "VK_KHR_maintenance2 is not supported");
5089 initializeAttachmentIsLazy(attachmentIsLazy, renderPassInfo.getAttachments(), config.imageMemory);
5090 initializeImageClearValues(rng, imageClearValues, renderPassInfo.getAttachments(), attachmentIsLazy, config.useFormatCompCount, config.depthValues);
5091 initializeAttachmentImageUsage(context, attachmentImageUsage, renderPassInfo, attachmentIsLazy, imageClearValues);
5092 initializeRenderPassClearValues(rng, renderPassClearValues, renderPassInfo.getAttachments(), config.useFormatCompCount, config.depthValues);
5094 initializeSubpassIsSecondary(subpassIsSecondary, renderPassInfo.getSubpasses(), config.commandBufferTypes);
5095 initializeSubpassRenderInfo(subpassRenderInfo, rng, renderPassInfo, config);
5097 logTestCaseInfo(log, config, attachmentIsLazy, imageClearValues, renderPassClearValues, subpassRenderInfo);
5099 checkTextureFormatSupport(log, context.getInstanceInterface(), context.getPhysicalDevice(), config.renderPass.getAttachments());
5102 const vk::VkPhysicalDeviceProperties properties = vk::getPhysicalDeviceProperties(context.getInstanceInterface(), context.getPhysicalDevice());
5104 log << TestLog::Message << "Max color attachments: " << properties.limits.maxColorAttachments << TestLog::EndMessage;
5106 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); subpassNdx++)
5108 if (renderPassInfo.getSubpasses()[subpassNdx].getColorAttachments().size() > (size_t)properties.limits.maxColorAttachments)
5109 TCU_THROW(NotSupportedError, "Subpass uses more than maxColorAttachments.");
5114 const InstanceInterface& vki = context.getInstanceInterface();
5115 const VkPhysicalDevice& physDevice = context.getPhysicalDevice();
5116 const VkDevice device = context.getDevice();
5117 const DeviceInterface& vk = context.getDeviceInterface();
5118 const VkQueue queue = context.getUniversalQueue();
5119 const deUint32 queueIndex = context.getUniversalQueueFamilyIndex();
5120 Allocator& allocator = context.getDefaultAllocator();
5122 const Unique<VkCommandPool> commandBufferPool (createCommandPool(vk, device, 0, queueIndex));
5123 const Unique<VkCommandBuffer> initializeImagesCommandBuffer (allocateCommandBuffer(vk, device, *commandBufferPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
5124 const Unique<VkCommandBuffer> renderCommandBuffer (allocateCommandBuffer(vk, device, *commandBufferPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
5125 const Unique<VkCommandBuffer> readImagesToBuffersCommandBuffer (allocateCommandBuffer(vk, device, *commandBufferPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
5127 vector<de::SharedPtr<AttachmentResources> > attachmentResources;
5128 vector<de::SharedPtr<SubpassRenderer> > subpassRenderers;
5129 vector<VkImage> attachmentImages;
5130 vector<VkImageView> attachmentViews;
5131 vector<pair<VkImageView, VkImageView> > inputAttachmentViews;
5133 Move<VkRenderPass> renderPass;
5134 if (config.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
5135 renderPass = createRenderPass(vk, device, renderPassInfo, config.renderingType);
5137 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
5139 const Attachment& attachmentInfo = renderPassInfo.getAttachments()[attachmentNdx];
5141 attachmentResources.push_back(de::SharedPtr<AttachmentResources>(new AttachmentResources(vki, physDevice, vk, device, allocator, queueIndex, targetSize, attachmentInfo, attachmentImageUsage[attachmentNdx], config.allocationKind)));
5142 attachmentViews.push_back(attachmentResources[attachmentNdx]->getAttachmentView());
5143 attachmentImages.push_back(attachmentResources[attachmentNdx]->getImage());
5145 inputAttachmentViews.push_back(attachmentResources[attachmentNdx]->getInputAttachmentViews());
5148 beginCommandBuffer(vk, *initializeImagesCommandBuffer, (VkCommandBufferUsageFlags)0, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0);
5149 pushImageInitializationCommands(vk, *initializeImagesCommandBuffer, renderPassInfo.getAttachments(), attachmentResources, queueIndex, imageClearValues);
5150 endCommandBuffer(vk, *initializeImagesCommandBuffer);
5153 Move<VkFramebuffer> framebuffer;
5154 if (config.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
5155 framebuffer = createFramebuffer(vk, device, *renderPass, targetSize, attachmentViews);
5157 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); subpassNdx++)
5158 subpassRenderers.push_back(de::SharedPtr<SubpassRenderer>(new SubpassRenderer(context, vk, device, allocator, *renderPass, *framebuffer, *commandBufferPool, queueIndex, attachmentImages, inputAttachmentViews, subpassRenderInfo[subpassNdx], config.renderPass.getAttachments(), config.allocationKind, config.renderingType == RENDERING_TYPE_DYNAMIC_RENDERING)));
5160 beginCommandBuffer(vk, *renderCommandBuffer, (VkCommandBufferUsageFlags)0, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0);
5161 pushRenderPassCommands(vk, *renderCommandBuffer, *renderPass, renderPassInfo, attachmentResources, *framebuffer, subpassRenderers, renderPos, renderSize, renderPassClearValues, queueIndex, config.renderTypes, config.renderingType);
5162 endCommandBuffer(vk, *renderCommandBuffer);
5164 beginCommandBuffer(vk, *readImagesToBuffersCommandBuffer, (VkCommandBufferUsageFlags)0, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0);
5165 pushReadImagesToBuffers(vk, *readImagesToBuffersCommandBuffer, queueIndex, attachmentResources, renderPassInfo.getAttachments(), attachmentIsLazy, targetSize);
5166 endCommandBuffer(vk, *readImagesToBuffersCommandBuffer);
5168 const VkCommandBuffer commandBuffers[] =
5170 *initializeImagesCommandBuffer,
5171 *renderCommandBuffer,
5172 *readImagesToBuffersCommandBuffer
5174 const Unique<VkFence> fence (createFence(vk, device, 0u));
5176 queueSubmit(vk, queue, DE_LENGTH_OF_ARRAY(commandBuffers), commandBuffers, *fence);
5177 waitForFences(vk, device, 1, &fence.get(), VK_TRUE, ~0ull);
5181 if (logAndVerifyImages(log, vk, device, attachmentResources, attachmentIsLazy, renderPassInfo, renderPassClearValues, imageClearValues, subpassRenderInfo, targetSize, config))
5182 return tcu::TestStatus::pass("Pass");
5184 return tcu::TestStatus::fail("Result verification failed");
5188 static const VkFormat s_coreColorFormats[] =
5190 VK_FORMAT_R5G6B5_UNORM_PACK16,
5195 VK_FORMAT_R8G8_UNORM,
5196 VK_FORMAT_R8G8_SNORM,
5197 VK_FORMAT_R8G8_UINT,
5198 VK_FORMAT_R8G8_SINT,
5199 VK_FORMAT_R8G8B8A8_UNORM,
5200 VK_FORMAT_R8G8B8A8_SNORM,
5201 VK_FORMAT_R8G8B8A8_UINT,
5202 VK_FORMAT_R8G8B8A8_SINT,
5203 VK_FORMAT_R8G8B8A8_SRGB,
5204 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
5205 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
5206 VK_FORMAT_A8B8G8R8_UINT_PACK32,
5207 VK_FORMAT_A8B8G8R8_SINT_PACK32,
5208 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
5209 VK_FORMAT_B8G8R8A8_UNORM,
5210 VK_FORMAT_B8G8R8A8_SRGB,
5211 VK_FORMAT_A2R10G10B10_UNORM_PACK32,
5212 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
5213 VK_FORMAT_A2B10G10R10_UINT_PACK32,
5214 VK_FORMAT_R16_UNORM,
5215 VK_FORMAT_R16_SNORM,
5218 VK_FORMAT_R16_SFLOAT,
5219 VK_FORMAT_R16G16_UNORM,
5220 VK_FORMAT_R16G16_SNORM,
5221 VK_FORMAT_R16G16_UINT,
5222 VK_FORMAT_R16G16_SINT,
5223 VK_FORMAT_R16G16_SFLOAT,
5224 VK_FORMAT_R16G16B16A16_UNORM,
5225 VK_FORMAT_R16G16B16A16_SNORM,
5226 VK_FORMAT_R16G16B16A16_UINT,
5227 VK_FORMAT_R16G16B16A16_SINT,
5228 VK_FORMAT_R16G16B16A16_SFLOAT,
5231 VK_FORMAT_R32_SFLOAT,
5232 VK_FORMAT_R32G32_UINT,
5233 VK_FORMAT_R32G32_SINT,
5234 VK_FORMAT_R32G32_SFLOAT,
5235 VK_FORMAT_R32G32B32A32_UINT,
5236 VK_FORMAT_R32G32B32A32_SINT,
5237 VK_FORMAT_R32G32B32A32_SFLOAT
5240 static const VkFormat s_coreDepthStencilFormats[] =
5242 VK_FORMAT_D16_UNORM,
5244 VK_FORMAT_X8_D24_UNORM_PACK32,
5245 VK_FORMAT_D32_SFLOAT,
5247 VK_FORMAT_D24_UNORM_S8_UINT,
5248 VK_FORMAT_D32_SFLOAT_S8_UINT
5251 void addAttachmentTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
5253 const deUint32 attachmentCounts[] = { 1, 3, 4, 8 };
5254 const VkAttachmentLoadOp loadOps[] =
5256 VK_ATTACHMENT_LOAD_OP_LOAD,
5257 VK_ATTACHMENT_LOAD_OP_CLEAR,
5258 VK_ATTACHMENT_LOAD_OP_DONT_CARE
5261 const VkAttachmentStoreOp storeOps[] =
5263 VK_ATTACHMENT_STORE_OP_STORE,
5264 VK_ATTACHMENT_STORE_OP_DONT_CARE
5267 const VkImageLayout initialAndFinalColorLayouts[] =
5269 VK_IMAGE_LAYOUT_GENERAL,
5270 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5271 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
5272 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
5273 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
5276 const VkImageLayout initialAndFinalColorLayoutsLazy[] =
5278 VK_IMAGE_LAYOUT_GENERAL,
5279 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5280 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
5283 const VkImageLayout initialAndFinalDepthStencilLayouts[] =
5285 VK_IMAGE_LAYOUT_GENERAL,
5286 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5287 VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL,
5288 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
5289 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
5290 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
5293 const VkImageLayout initialAndFinalDepthStencilLayoutsLazy[] =
5295 VK_IMAGE_LAYOUT_GENERAL,
5296 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5297 VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL,
5298 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
5301 const VkImageLayout subpassLayouts[] =
5303 VK_IMAGE_LAYOUT_GENERAL,
5304 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
5307 const VkImageLayout depthStencilLayouts[] =
5309 VK_IMAGE_LAYOUT_GENERAL,
5310 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
5313 const TestConfig::RenderTypes renderCommands[] =
5315 TestConfig::RENDERTYPES_NONE,
5316 TestConfig::RENDERTYPES_CLEAR,
5317 TestConfig::RENDERTYPES_DRAW,
5318 TestConfig::RENDERTYPES_CLEAR|TestConfig::RENDERTYPES_DRAW,
5321 const TestConfig::CommandBufferTypes commandBuffers[] =
5323 TestConfig::COMMANDBUFFERTYPES_INLINE,
5324 TestConfig::COMMANDBUFFERTYPES_SECONDARY,
5325 TestConfig::COMMANDBUFFERTYPES_INLINE|TestConfig::COMMANDBUFFERTYPES_SECONDARY
5328 const TestConfig::ImageMemory imageMemories[] =
5330 TestConfig::IMAGEMEMORY_STRICT,
5331 TestConfig::IMAGEMEMORY_LAZY,
5332 TestConfig::IMAGEMEMORY_STRICT|TestConfig::IMAGEMEMORY_LAZY
5335 const UVec2 targetSizes[] =
5341 const UVec2 renderPositions[] =
5347 const UVec2 renderSizes[] =
5353 tcu::TestContext& testCtx (group->getTestContext());
5354 bool useDynamicRendering (testConfigExternal.renderingType == RENDERING_TYPE_DYNAMIC_RENDERING);
5355 de::Random rng (1433774382u);
5357 for (size_t attachmentCountNdx = 0; attachmentCountNdx < DE_LENGTH_OF_ARRAY(attachmentCounts); attachmentCountNdx++)
5359 const deUint32 attachmentCount = attachmentCounts[attachmentCountNdx];
5360 const deUint32 testCaseCount = (attachmentCount == 1 ? 100 : 200);
5361 de::MovePtr<tcu::TestCaseGroup> attachmentCountGroup (new tcu::TestCaseGroup(testCtx, de::toString(attachmentCount).c_str(), de::toString(attachmentCount).c_str()));
5363 for (size_t testCaseNdx = 0; testCaseNdx < testCaseCount; testCaseNdx++)
5365 const bool useDepthStencil = rng.getBool();
5366 const TestConfig::ImageMemory imageMemory = rng.choose<TestConfig::ImageMemory>(DE_ARRAY_BEGIN(imageMemories), DE_ARRAY_END(imageMemories));
5367 VkImageLayout depthStencilLayout = VK_IMAGE_LAYOUT_GENERAL;
5368 vector<Attachment> attachments;
5369 vector<AttachmentReference> colorAttachmentReferences;
5371 // we want to make sure that dynamic rendering test cases have corresponding renderpass
5372 // cases as this will allow drivers to easily compare GPU batches; since configurations
5373 // for those tests are generated we need to generate configurations for all cases
5374 // even when we know earlier that for dynamic rendering we will skip it
5375 bool executeForDynamicRendering = true;
5377 for (size_t attachmentNdx = 0; attachmentNdx < attachmentCount; attachmentNdx++)
5379 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
5380 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreColorFormats), DE_ARRAY_END(s_coreColorFormats));
5381 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5382 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5384 const VkImageLayout initialLayout = (imageMemory == TestConfig::IMAGEMEMORY_STRICT)
5385 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts))
5386 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayoutsLazy), DE_ARRAY_END(initialAndFinalColorLayoutsLazy));
5387 VkImageLayout finalizeLayout = (imageMemory == TestConfig::IMAGEMEMORY_STRICT)
5388 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts))
5389 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayoutsLazy), DE_ARRAY_END(initialAndFinalColorLayoutsLazy));
5390 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayouts), DE_ARRAY_END(subpassLayouts));
5392 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5393 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5395 if (useDynamicRendering)
5397 // with renderpass we can have automatic layout transitions; to do the same with dynamic rendering cases
5398 // we would need to add addtional barries but since those tests won't add coverage we are skipping them
5399 if ((initialLayout == VK_IMAGE_LAYOUT_GENERAL) ||
5400 (initialLayout == VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL))
5401 finalizeLayout = initialLayout;
5403 executeForDynamicRendering = false;
5406 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5407 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
5410 if (useDepthStencil)
5412 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
5413 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreDepthStencilFormats), DE_ARRAY_END(s_coreDepthStencilFormats));
5414 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5415 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5417 const VkImageLayout initialLayout = (imageMemory == TestConfig::IMAGEMEMORY_STRICT)
5418 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
5419 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayoutsLazy), DE_ARRAY_END(initialAndFinalDepthStencilLayoutsLazy));
5420 VkImageLayout finalizeLayout = (imageMemory == TestConfig::IMAGEMEMORY_STRICT)
5421 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
5422 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayoutsLazy), DE_ARRAY_END(initialAndFinalDepthStencilLayoutsLazy));
5424 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5425 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5427 if (useDynamicRendering)
5429 if ((initialLayout == VK_IMAGE_LAYOUT_GENERAL) ||
5430 (initialLayout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL) ||
5431 (initialLayout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL))
5432 finalizeLayout = initialLayout;
5434 executeForDynamicRendering = false;
5437 depthStencilLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(depthStencilLayouts), DE_ARRAY_END(depthStencilLayouts));
5438 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5442 const TestConfig::RenderTypes render = rng.choose<TestConfig::RenderTypes>(DE_ARRAY_BEGIN(renderCommands), DE_ARRAY_END(renderCommands));
5443 const TestConfig::CommandBufferTypes commandBuffer = rng.choose<TestConfig::CommandBufferTypes>(DE_ARRAY_BEGIN(commandBuffers), DE_ARRAY_END(commandBuffers));
5444 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>()));
5445 const vector<SubpassDependency> deps;
5446 const string testCaseName = de::toString(attachmentCountNdx * testCaseCount + testCaseNdx);
5447 const RenderPass renderPass (attachments, subpasses, deps);
5448 const UVec2 targetSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(targetSizes), DE_ARRAY_END(targetSizes));
5449 const UVec2 renderPos = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderPositions), DE_ARRAY_END(renderPositions));
5450 const UVec2 renderSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderSizes), DE_ARRAY_END(renderSizes));
5452 // skip dynamic rendering cases (that don't add coverage)
5453 // this can be done not earlier than after grabbing all random numbers as
5454 // we need to make sure that those tests that will be created for dynamic
5455 // rendering have corresponding renderpass tests with the same name
5456 if (useDynamicRendering && !executeForDynamicRendering)
5459 const TestConfig testConfig (renderPass,
5469 testConfigExternal.allocationKind,
5470 testConfigExternal.renderingType);
5472 addFunctionCaseWithPrograms<TestConfig>(attachmentCountGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, testConfig);
5476 group->addChild(attachmentCountGroup.release());
5480 void addAttachmentWriteMaskTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
5482 const deUint32 attachmentCounts[] = { 1, 2, 3, 4, 8 };
5484 const VkFormat attachmentFormats[] =
5486 VK_FORMAT_R8G8B8A8_UINT,
5487 VK_FORMAT_R8G8B8A8_UNORM,
5488 VK_FORMAT_R5G6B5_UNORM_PACK16,
5489 VK_FORMAT_R8G8_UNORM
5492 tcu::TestContext& testCtx = group->getTestContext();
5494 for (deUint32 attachmentCountNdx = 0; attachmentCountNdx < DE_LENGTH_OF_ARRAY(attachmentCounts); attachmentCountNdx++)
5496 const deUint32 attachmentCount = attachmentCounts[attachmentCountNdx];
5497 const string groupName = "attachment_count_" + de::toString(attachmentCount);
5499 de::MovePtr<tcu::TestCaseGroup> attachmentCountGroup(new tcu::TestCaseGroup(testCtx, groupName.c_str(), de::toString(attachmentCount).c_str()));
5501 for (deUint32 drawStartNdx = 0; drawStartNdx < (attachmentCount); drawStartNdx++)
5503 deUint32 formatNdx = 0;
5504 vector<Attachment> attachments;
5505 vector<AttachmentReference> colorAttachmentReferences;
5507 for (deUint32 attachmentNdx = 0; attachmentNdx < attachmentCount; attachmentNdx++)
5509 const VkFormat format = attachmentFormats[formatNdx];
5510 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
5511 const VkAttachmentLoadOp loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
5512 const VkAttachmentStoreOp storeOp = VK_ATTACHMENT_STORE_OP_STORE;
5513 const VkAttachmentLoadOp stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
5514 const VkAttachmentStoreOp stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
5515 const VkImageLayout initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
5516 const VkImageLayout finalizeLayout = (testConfigExternal.renderingType == RENDERING_TYPE_DYNAMIC_RENDERING)
5517 ? initialLayout : VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
5518 const VkImageLayout subpassLayout = VK_IMAGE_LAYOUT_GENERAL;
5520 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5521 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
5523 if (++formatNdx == DE_LENGTH_OF_ARRAY(attachmentFormats))
5528 const VkImageLayout depthStencilLayout = VK_IMAGE_LAYOUT_GENERAL;
5529 const vector<Subpass> subpass (1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u, vector<AttachmentReference>(), colorAttachmentReferences, vector<AttachmentReference>(), AttachmentReference(VK_ATTACHMENT_UNUSED, depthStencilLayout), vector<deUint32>()));
5530 const vector<SubpassDependency> deps;
5532 const string testCaseName = "start_index_" + de::toString(drawStartNdx);
5533 const RenderPass renderPass (attachments, subpass, deps);
5535 const TestConfig::RenderTypes render = TestConfig::RENDERTYPES_DRAW;
5536 const TestConfig::CommandBufferTypes commandBuffer = TestConfig::COMMANDBUFFERTYPES_INLINE;
5537 const TestConfig::ImageMemory imageMemory = TestConfig::IMAGEMEMORY_LAZY;
5538 const UVec2 targetSize = UVec2(64, 64);
5539 const UVec2 renderPos = UVec2(0, 0);
5540 const UVec2 renderSize = UVec2(64, 64);
5541 const deBool useFormatCompCount = DE_TRUE;
5542 const vector<DeviceCoreFeature> requiredFeatures = {DEVICE_CORE_FEATURE_INDEPENDENT_BLEND};
5543 const TestConfig testConfig (renderPass,
5553 testConfigExternal.allocationKind,
5554 testConfigExternal.renderingType,
5557 addFunctionCaseWithPrograms<TestConfig>(attachmentCountGroup.get(), testCaseName.c_str(), testCaseName.c_str(), checkSupport, createTestShaders, renderPassTest, testConfig);
5561 group->addChild(attachmentCountGroup.release());
5565 template<typename T>
5566 T chooseRandom (de::Random& rng, const set<T>& values)
5568 size_t ndx = ((size_t)rng.getUint32()) % values.size();
5569 typename set<T>::const_iterator iter = values.begin();
5571 for (; ndx > 0; ndx--)
5577 void addAttachmentAllocationTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
5579 const deUint32 attachmentCounts[] = { 4, 8 };
5580 const VkAttachmentLoadOp loadOps[] =
5582 VK_ATTACHMENT_LOAD_OP_LOAD,
5583 VK_ATTACHMENT_LOAD_OP_CLEAR,
5584 VK_ATTACHMENT_LOAD_OP_DONT_CARE
5587 const VkAttachmentStoreOp storeOps[] =
5589 VK_ATTACHMENT_STORE_OP_STORE,
5590 VK_ATTACHMENT_STORE_OP_DONT_CARE
5593 const VkImageLayout initialAndFinalColorLayouts[] =
5595 VK_IMAGE_LAYOUT_GENERAL,
5596 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5597 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
5598 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
5599 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
5602 const VkImageLayout initialAndFinalDepthStencilLayouts[] =
5604 VK_IMAGE_LAYOUT_GENERAL,
5605 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5606 VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL,
5607 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
5608 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
5609 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
5612 const VkImageLayout subpassLayoutsColor[] =
5614 VK_IMAGE_LAYOUT_GENERAL,
5615 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
5618 const VkImageLayout subpassLayoutsDepthStencil[] =
5620 VK_IMAGE_LAYOUT_GENERAL,
5621 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
5624 const VkImageLayout subpassLayoutsInput[] =
5626 VK_IMAGE_LAYOUT_GENERAL,
5627 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
5632 // Each pass uses one more attachmen than previous one
5633 ALLOCATIONTYPE_GROW,
5634 // Each pass uses one less attachment than previous one
5635 ALLOCATIONTYPE_SHRINK,
5636 // Each pass drops one attachment and picks up new one
5637 ALLOCATIONTYPE_ROLL,
5638 // Start by growing and end by shrinking
5639 ALLOCATIONTYPE_GROW_SHRINK,
5640 // Each subpass has single input and single output attachment
5641 ALLOCATIONTYPE_IO_CHAIN,
5642 // Each subpass has multiple inputs and multiple outputs attachment
5643 ALLOCATIONTYPE_IO_GENERIC
5646 const AllocationType allocationTypes[] =
5648 ALLOCATIONTYPE_GROW,
5649 ALLOCATIONTYPE_SHRINK,
5650 ALLOCATIONTYPE_ROLL,
5651 ALLOCATIONTYPE_GROW_SHRINK,
5652 ALLOCATIONTYPE_IO_CHAIN,
5653 ALLOCATIONTYPE_IO_GENERIC
5656 const char* const allocationTypeStr[] =
5662 "input_output_chain",
5666 const TestConfig::RenderTypes renderCommands[] =
5668 TestConfig::RENDERTYPES_NONE,
5669 TestConfig::RENDERTYPES_CLEAR,
5670 TestConfig::RENDERTYPES_DRAW,
5671 TestConfig::RENDERTYPES_CLEAR|TestConfig::RENDERTYPES_DRAW,
5674 const TestConfig::CommandBufferTypes commandBuffers[] =
5676 TestConfig::COMMANDBUFFERTYPES_INLINE,
5677 TestConfig::COMMANDBUFFERTYPES_SECONDARY,
5678 TestConfig::COMMANDBUFFERTYPES_INLINE|TestConfig::COMMANDBUFFERTYPES_SECONDARY
5681 const TestConfig::ImageMemory imageMemories[] =
5683 TestConfig::IMAGEMEMORY_STRICT,
5684 TestConfig::IMAGEMEMORY_LAZY,
5685 TestConfig::IMAGEMEMORY_STRICT|TestConfig::IMAGEMEMORY_LAZY
5688 const UVec2 targetSizes[] =
5694 const UVec2 renderPositions[] =
5700 const UVec2 renderSizes[] =
5706 tcu::TestContext& testCtx = group->getTestContext();
5707 de::Random rng (3700649827u);
5709 for (size_t allocationTypeNdx = 0; allocationTypeNdx < DE_LENGTH_OF_ARRAY(allocationTypes); allocationTypeNdx++)
5711 const AllocationType allocationType = allocationTypes[allocationTypeNdx];
5712 const size_t testCaseCount = 100;
5713 de::MovePtr<tcu::TestCaseGroup> allocationTypeGroup (new tcu::TestCaseGroup(testCtx, allocationTypeStr[allocationTypeNdx], allocationTypeStr[allocationTypeNdx]));
5715 for (size_t testCaseNdx = 0; testCaseNdx < testCaseCount; testCaseNdx++)
5717 if (allocationType == ALLOCATIONTYPE_IO_GENERIC)
5719 const deUint32 attachmentCount = 4u + rng.getUint32() % 31u;
5720 const deUint32 subpassCount = 4u + rng.getUint32() % 31u;
5721 vector<Attachment> attachments;
5723 set<deUint32> definedAttachments;
5725 vector<Subpass> subpasses;
5726 set<deUint32> colorAttachments;
5727 set<deUint32> depthStencilAttachments;
5729 for (deUint32 attachmentIndex = 0; attachmentIndex < attachmentCount; attachmentIndex++)
5731 const bool isDepthStencilAttachment = rng.getFloat() < 0.01f;
5732 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
5733 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5734 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5736 const VkImageLayout initialLayout = isDepthStencilAttachment
5737 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
5738 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
5739 const VkImageLayout finalizeLayout = isDepthStencilAttachment
5740 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
5741 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
5743 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5744 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5746 if (isDepthStencilAttachment)
5748 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreDepthStencilFormats), DE_ARRAY_END(s_coreDepthStencilFormats));
5750 if (loadOp == VK_ATTACHMENT_LOAD_OP_LOAD || loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR
5751 || stencilLoadOp == VK_ATTACHMENT_LOAD_OP_LOAD || stencilLoadOp == VK_ATTACHMENT_LOAD_OP_CLEAR)
5752 definedAttachments.insert(attachmentIndex);
5754 depthStencilAttachments.insert(attachmentIndex);
5756 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5760 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreColorFormats), DE_ARRAY_END(s_coreColorFormats));
5762 if (loadOp == VK_ATTACHMENT_LOAD_OP_LOAD || loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR)
5763 definedAttachments.insert(attachmentIndex);
5765 colorAttachments.insert(attachmentIndex);
5767 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5770 vector<Maybe<deUint32> > lastUseOfAttachment (attachments.size(), nothing<deUint32>());
5771 vector<SubpassDependency> deps;
5773 for (deUint32 subpassIndex = 0; subpassIndex < subpassCount; subpassIndex++)
5775 const deUint32 colorAttachmentCount = depthStencilAttachments.empty()
5776 ? 1 + rng.getUint32() % de::min(4u, (deUint32)colorAttachments.size())
5777 : rng.getUint32() % (de::min(4u, (deUint32)colorAttachments.size()) + 1u);
5778 const deUint32 inputAttachmentCount = rng.getUint32() % (deUint32)(de::min<size_t>(4, definedAttachments.size()) + 1);
5779 const bool useDepthStencilAttachment = !depthStencilAttachments.empty() && (colorAttachmentCount == 0 || rng.getBool());
5780 std::vector<deUint32> subpassColorAttachments (colorAttachmentCount);
5781 std::vector<deUint32> subpassInputAttachments (inputAttachmentCount);
5782 Maybe<deUint32> depthStencilAttachment (useDepthStencilAttachment
5783 ? just(chooseRandom(rng, depthStencilAttachments))
5784 : nothing<deUint32>());
5785 std::vector<deUint32> subpassPreserveAttachments;
5787 rng.choose(colorAttachments.begin(), colorAttachments.end(), subpassColorAttachments.begin(), colorAttachmentCount);
5788 rng.choose(definedAttachments.begin(), definedAttachments.end(), subpassInputAttachments.begin(), inputAttachmentCount);
5790 for (size_t colorAttachmentNdx = 0; colorAttachmentNdx < subpassColorAttachments.size(); colorAttachmentNdx++)
5791 definedAttachments.insert(subpassColorAttachments[colorAttachmentNdx]);
5793 if (depthStencilAttachment)
5794 definedAttachments.insert(*depthStencilAttachment);
5797 std::vector<AttachmentReference> inputAttachmentReferences;
5798 std::vector<AttachmentReference> colorAttachmentReferences;
5799 AttachmentReference depthStencilAttachmentReference (VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL);
5801 for (size_t colorAttachmentNdx = 0; colorAttachmentNdx < subpassColorAttachments.size(); colorAttachmentNdx++)
5803 const deUint32 colorAttachmentIndex = subpassColorAttachments[colorAttachmentNdx];
5805 if (lastUseOfAttachment[colorAttachmentIndex])
5807 deBool foundDuplicate = false;
5809 const deUint32 srcPass = *lastUseOfAttachment[colorAttachmentIndex];
5810 const deUint32 dstPass = subpassIndex;
5811 const VkDependencyFlags dependencyFlags = rng.getBool() ? (VkDependencyFlags) VK_DEPENDENCY_BY_REGION_BIT : 0u;
5813 const SubpassDependency newDependency(srcPass, dstPass,
5814 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5815 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5816 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5817 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5819 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5820 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5821 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5822 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5824 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
5825 VK_ACCESS_COLOR_ATTACHMENT_READ_BIT,
5829 for (SubpassDependency& dependency : deps)
5831 if (dependency.getSrcPass() == srcPass && dependency.getDstPass() == dstPass)
5833 const VkAccessFlags newDstFlags = dependency.getDstAccessMask() | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT;
5834 dependency.setDstAccessMask(newDstFlags);
5835 foundDuplicate = true;
5840 if (!foundDuplicate)
5842 deps.push_back(newDependency);
5846 lastUseOfAttachment[colorAttachmentIndex] = just(subpassIndex);
5848 colorAttachmentReferences.push_back(AttachmentReference((deUint32)subpassColorAttachments[colorAttachmentNdx], VK_IMAGE_LAYOUT_GENERAL));
5851 for (size_t inputAttachmentNdx = 0; inputAttachmentNdx < subpassInputAttachments.size(); inputAttachmentNdx++)
5853 const deUint32 inputAttachmentIndex = subpassInputAttachments[inputAttachmentNdx];
5855 if(lastUseOfAttachment[inputAttachmentIndex])
5857 deBool foundDuplicate = false;
5859 const deUint32 srcPass = *lastUseOfAttachment[inputAttachmentIndex];
5860 const deUint32 dstPass = subpassIndex;
5861 const VkDependencyFlags dependencyFlags = ((srcPass == subpassIndex) || rng.getBool()) ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u;
5863 const SubpassDependency newDependency(srcPass, dstPass,
5864 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5865 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5866 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5867 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5869 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5870 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5871 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5872 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5874 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
5875 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5878 for (SubpassDependency& dependency : deps)
5880 if (dependency.getSrcPass() == srcPass && dependency.getDstPass() == dstPass)
5882 const VkAccessFlags newSrcFlags = dependency.getSrcAccessMask() | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
5883 const VkAccessFlags newDstFlags = dependency.getDstAccessMask() | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT;
5884 dependency.setDstAccessMask(newSrcFlags);
5885 dependency.setDstAccessMask(newDstFlags);
5886 foundDuplicate = true;
5891 if (!foundDuplicate)
5893 deps.push_back(newDependency);
5896 lastUseOfAttachment[inputAttachmentIndex] = just(subpassIndex);
5898 VkImageAspectFlags aspect = 0u;
5899 if (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2)
5901 bool col = colorAttachments.find(inputAttachmentIndex) != colorAttachments.end();
5902 aspect = col ? VK_IMAGE_ASPECT_COLOR_BIT : VK_IMAGE_ASPECT_DEPTH_BIT;
5904 inputAttachmentReferences.push_back(AttachmentReference((deUint32)subpassInputAttachments[inputAttachmentNdx], VK_IMAGE_LAYOUT_GENERAL, aspect));
5908 if (depthStencilAttachment)
5910 if (lastUseOfAttachment[*depthStencilAttachment])
5912 deBool foundDuplicate = false;
5914 const deUint32 srcPass = *lastUseOfAttachment[*depthStencilAttachment];
5915 const deUint32 dstPass = subpassIndex;
5916 const VkDependencyFlags dependencyFlags = ((srcPass == subpassIndex) || rng.getBool()) ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u;
5918 const SubpassDependency newDependency(srcPass, dstPass,
5919 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5920 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5921 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5922 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5924 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5925 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5926 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5927 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5929 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
5930 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT
5931 | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5934 for (SubpassDependency& dependency : deps)
5936 if (dependency.getSrcPass() == srcPass && dependency.getDstPass() == dstPass)
5938 const VkAccessFlags newSrcFlags = dependency.getSrcAccessMask() | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
5939 const VkAccessFlags newDstFlags = dependency.getDstAccessMask() | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT;
5940 dependency.setDstAccessMask(newSrcFlags);
5941 dependency.setDstAccessMask(newDstFlags);
5942 foundDuplicate = true;
5947 if (!foundDuplicate)
5949 deps.push_back(newDependency);
5953 lastUseOfAttachment[*depthStencilAttachment] = just(subpassIndex);
5955 depthStencilAttachmentReference = AttachmentReference(*depthStencilAttachment, VK_IMAGE_LAYOUT_GENERAL);
5958 depthStencilAttachmentReference = AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL);
5960 vector<deUint32> preserveAttachments;
5961 for (deUint32 attachmentIndex = 0; attachmentIndex < (deUint32)attachments.size(); attachmentIndex++)
5963 if (lastUseOfAttachment[attachmentIndex] && (*lastUseOfAttachment[attachmentIndex]) != subpassIndex)
5964 preserveAttachments.push_back(attachmentIndex);
5967 // Use random image layout when possible
5968 for (size_t colorRefIdx = 0; colorRefIdx < colorAttachmentReferences.size(); ++colorRefIdx)
5970 bool usedAsInput = false;
5971 for (size_t inputRefIdx = 0; inputRefIdx < inputAttachmentReferences.size(); ++inputRefIdx)
5972 if (colorAttachmentReferences[colorRefIdx].getAttachment() == inputAttachmentReferences[inputRefIdx].getAttachment())
5976 colorAttachmentReferences[colorRefIdx].setImageLayout(rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor)));
5978 for (size_t inputRefIdx = 0; inputRefIdx < inputAttachmentReferences.size(); ++inputRefIdx)
5980 bool usedAsDepthStencil = inputAttachmentReferences[inputRefIdx].getAttachment() == depthStencilAttachmentReference.getAttachment();
5981 bool usedAsColor = false;
5982 for (size_t colorRefIdx = 0; colorRefIdx < colorAttachmentReferences.size(); ++colorRefIdx)
5983 if (inputAttachmentReferences[inputRefIdx].getAttachment() == colorAttachmentReferences[colorRefIdx].getAttachment())
5986 if (!usedAsColor && !usedAsDepthStencil)
5987 inputAttachmentReferences[inputRefIdx].setImageLayout(rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsInput), DE_ARRAY_END(subpassLayoutsInput)));
5990 bool usedAsInput = false;
5991 for (size_t inputRefIdx = 0; inputRefIdx < inputAttachmentReferences.size(); ++inputRefIdx)
5992 if (depthStencilAttachmentReference.getAttachment() == inputAttachmentReferences[inputRefIdx].getAttachment())
5996 depthStencilAttachmentReference.setImageLayout(rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsDepthStencil), DE_ARRAY_END(subpassLayoutsDepthStencil)));
5999 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6000 inputAttachmentReferences,
6001 colorAttachmentReferences,
6002 vector<AttachmentReference>(),
6003 depthStencilAttachmentReference,
6004 preserveAttachments));
6008 const TestConfig::RenderTypes render = rng.choose<TestConfig::RenderTypes>(DE_ARRAY_BEGIN(renderCommands), DE_ARRAY_END(renderCommands));
6009 const TestConfig::CommandBufferTypes commandBuffer = rng.choose<TestConfig::CommandBufferTypes>(DE_ARRAY_BEGIN(commandBuffers), DE_ARRAY_END(commandBuffers));
6010 const TestConfig::ImageMemory imageMemory = rng.choose<TestConfig::ImageMemory>(DE_ARRAY_BEGIN(imageMemories), DE_ARRAY_END(imageMemories));
6012 const string testCaseName = de::toString(testCaseNdx);
6013 const UVec2 targetSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(targetSizes), DE_ARRAY_END(targetSizes));
6014 const UVec2 renderPos = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderPositions), DE_ARRAY_END(renderPositions));
6015 const UVec2 renderSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderSizes), DE_ARRAY_END(renderSizes));
6017 const RenderPass renderPass (attachments, subpasses, deps);
6018 const TestConfig testConfig (renderPass,
6028 testConfigExternal.allocationKind,
6029 testConfigExternal.renderingType);
6031 addFunctionCaseWithPrograms<TestConfig>(allocationTypeGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, testConfig);
6036 const deUint32 attachmentCount = rng.choose<deUint32>(DE_ARRAY_BEGIN(attachmentCounts), DE_ARRAY_END(attachmentCounts));
6037 vector<Attachment> attachments;
6038 vector<Subpass> subpasses;
6040 for (size_t attachmentNdx = 0; attachmentNdx < attachmentCount; attachmentNdx++)
6042 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
6043 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreColorFormats), DE_ARRAY_END(s_coreColorFormats));
6044 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
6045 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
6047 const VkImageLayout initialLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
6048 const VkImageLayout finalizeLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
6050 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
6051 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
6053 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
6056 if (allocationType == ALLOCATIONTYPE_GROW)
6058 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
6060 vector<AttachmentReference> colorAttachmentReferences;
6062 for (size_t attachmentNdx = 0; attachmentNdx < subpassNdx + 1; attachmentNdx++)
6064 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6066 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
6069 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6070 vector<AttachmentReference>(),
6071 colorAttachmentReferences,
6072 vector<AttachmentReference>(),
6073 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6074 vector<deUint32>()));
6077 else if (allocationType == ALLOCATIONTYPE_SHRINK)
6079 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
6081 vector<AttachmentReference> colorAttachmentReferences;
6083 for (size_t attachmentNdx = 0; attachmentNdx < (attachmentCount - subpassNdx); attachmentNdx++)
6085 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6087 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
6090 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6091 vector<AttachmentReference>(),
6092 colorAttachmentReferences,
6093 vector<AttachmentReference>(),
6094 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6095 vector<deUint32>()));
6098 else if (allocationType == ALLOCATIONTYPE_ROLL)
6100 for (size_t subpassNdx = 0; subpassNdx < attachmentCount / 2; subpassNdx++)
6102 vector<AttachmentReference> colorAttachmentReferences;
6104 for (size_t attachmentNdx = 0; attachmentNdx < attachmentCount / 2; attachmentNdx++)
6106 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6108 colorAttachmentReferences.push_back(AttachmentReference((deUint32)(subpassNdx + attachmentNdx), subpassLayout));
6111 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6112 vector<AttachmentReference>(),
6113 colorAttachmentReferences,
6114 vector<AttachmentReference>(),
6115 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6116 vector<deUint32>()));
6119 else if (allocationType == ALLOCATIONTYPE_GROW_SHRINK)
6121 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
6123 vector<AttachmentReference> colorAttachmentReferences;
6125 for (size_t attachmentNdx = 0; attachmentNdx < subpassNdx + 1; attachmentNdx++)
6127 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6129 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
6132 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6133 vector<AttachmentReference>(),
6134 colorAttachmentReferences,
6135 vector<AttachmentReference>(),
6136 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6137 vector<deUint32>()));
6139 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
6141 vector<AttachmentReference> colorAttachmentReferences;
6143 for (size_t attachmentNdx = 0; attachmentNdx < (attachmentCount - subpassNdx); attachmentNdx++)
6145 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6147 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
6150 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6151 vector<AttachmentReference>(),
6152 colorAttachmentReferences,
6153 vector<AttachmentReference>(),
6154 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6155 vector<deUint32>()));
6158 else if (allocationType == ALLOCATIONTYPE_IO_CHAIN)
6160 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6161 vector<AttachmentReference>(),
6162 vector<AttachmentReference>(1, AttachmentReference(0, rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor)))),
6163 vector<AttachmentReference>(),
6164 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6165 vector<deUint32>()));
6167 for (size_t subpassNdx = 1; subpassNdx < attachmentCount; subpassNdx++)
6169 const VkImageAspectFlags inputAttachmentAspectMask = (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2) ? VK_IMAGE_ASPECT_COLOR_BIT : static_cast<VkImageAspectFlagBits>(0);
6170 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6171 vector<AttachmentReference>(1, AttachmentReference((deUint32)(subpassNdx - 1), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
6172 vector<AttachmentReference>(1, AttachmentReference((deUint32)(subpassNdx), rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor)))),
6173 vector<AttachmentReference>(),
6174 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6175 vector<deUint32>()));
6179 DE_FATAL("Unknown allocation type");
6182 const TestConfig::RenderTypes render = rng.choose<TestConfig::RenderTypes>(DE_ARRAY_BEGIN(renderCommands), DE_ARRAY_END(renderCommands));
6183 const TestConfig::CommandBufferTypes commandBuffer = rng.choose<TestConfig::CommandBufferTypes>(DE_ARRAY_BEGIN(commandBuffers), DE_ARRAY_END(commandBuffers));
6184 const TestConfig::ImageMemory imageMemory = rng.choose<TestConfig::ImageMemory>(DE_ARRAY_BEGIN(imageMemories), DE_ARRAY_END(imageMemories));
6186 const string testCaseName = de::toString(testCaseNdx);
6187 const UVec2 targetSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(targetSizes), DE_ARRAY_END(targetSizes));
6188 const UVec2 renderPos = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderPositions), DE_ARRAY_END(renderPositions));
6189 const UVec2 renderSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderSizes), DE_ARRAY_END(renderSizes));
6191 vector<SubpassDependency> deps;
6193 for (size_t subpassNdx = 0; subpassNdx < subpasses.size() - 1; subpassNdx++)
6195 const bool byRegion = rng.getBool();
6196 deps.push_back(SubpassDependency((deUint32)subpassNdx, (deUint32)subpassNdx + 1,
6197 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
6198 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
6199 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
6200 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6202 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
6203 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
6204 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
6205 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6207 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6208 (VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT),
6210 byRegion ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u));
6213 const RenderPass renderPass (attachments, subpasses, deps);
6214 const TestConfig testConfig (renderPass,
6224 testConfigExternal.allocationKind,
6225 testConfigExternal.renderingType);
6227 addFunctionCaseWithPrograms<TestConfig>(allocationTypeGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, testConfig);
6231 group->addChild(allocationTypeGroup.release());
6235 void addSimpleTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
6237 const UVec2 targetSize (64, 64);
6238 const UVec2 renderPos (0, 0);
6239 const UVec2 renderSize (64, 64);
6243 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6244 VK_SAMPLE_COUNT_1_BIT,
6245 VK_ATTACHMENT_LOAD_OP_CLEAR,
6246 VK_ATTACHMENT_STORE_OP_STORE,
6247 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6248 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6249 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6250 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6251 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6253 vector<AttachmentReference>(),
6254 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6255 vector<AttachmentReference>(),
6256 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6257 vector<deUint32>())),
6258 vector<SubpassDependency>());
6259 const TestConfig testConfig (renderPass,
6260 TestConfig::RENDERTYPES_DRAW,
6261 TestConfig::COMMANDBUFFERTYPES_INLINE,
6262 TestConfig::IMAGEMEMORY_STRICT,
6269 testConfigExternal.allocationKind,
6270 testConfigExternal.renderingType);
6272 addFunctionCaseWithPrograms<TestConfig>(group, "color", "Single color attachment case.", createTestShaders, renderPassTest, testConfig);
6277 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_X8_D24_UNORM_PACK32,
6278 VK_SAMPLE_COUNT_1_BIT,
6279 VK_ATTACHMENT_LOAD_OP_CLEAR,
6280 VK_ATTACHMENT_STORE_OP_STORE,
6281 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6282 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6283 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6284 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6285 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6287 vector<AttachmentReference>(),
6288 vector<AttachmentReference>(),
6289 vector<AttachmentReference>(),
6290 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6291 vector<deUint32>())),
6292 vector<SubpassDependency>());
6293 const TestConfig testConfig (renderPass,
6294 TestConfig::RENDERTYPES_DRAW,
6295 TestConfig::COMMANDBUFFERTYPES_INLINE,
6296 TestConfig::IMAGEMEMORY_STRICT,
6303 testConfigExternal.allocationKind,
6304 testConfigExternal.renderingType);
6306 addFunctionCaseWithPrograms<TestConfig>(group, "depth", "Single depth attachment case.", createTestShaders, renderPassTest, testConfig);
6311 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_S8_UINT,
6312 VK_SAMPLE_COUNT_1_BIT,
6313 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6314 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6315 VK_ATTACHMENT_LOAD_OP_CLEAR,
6316 VK_ATTACHMENT_STORE_OP_STORE,
6317 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6318 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6319 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6321 vector<AttachmentReference>(),
6322 vector<AttachmentReference>(),
6323 vector<AttachmentReference>(),
6324 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6325 vector<deUint32>())),
6326 vector<SubpassDependency>());
6327 const TestConfig testConfig (renderPass,
6328 TestConfig::RENDERTYPES_DRAW,
6329 TestConfig::COMMANDBUFFERTYPES_INLINE,
6330 TestConfig::IMAGEMEMORY_STRICT,
6337 testConfigExternal.allocationKind,
6338 testConfigExternal.renderingType);
6340 addFunctionCaseWithPrograms<TestConfig>(group, "stencil", "Single stencil attachment case.", createTestShaders, renderPassTest, testConfig);
6345 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_D24_UNORM_S8_UINT,
6346 VK_SAMPLE_COUNT_1_BIT,
6347 VK_ATTACHMENT_LOAD_OP_CLEAR,
6348 VK_ATTACHMENT_STORE_OP_STORE,
6349 VK_ATTACHMENT_LOAD_OP_CLEAR,
6350 VK_ATTACHMENT_STORE_OP_STORE,
6351 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6352 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6353 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6355 vector<AttachmentReference>(),
6356 vector<AttachmentReference>(),
6357 vector<AttachmentReference>(),
6358 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6359 vector<deUint32>())),
6360 vector<SubpassDependency>());
6361 const TestConfig testConfig (renderPass,
6362 TestConfig::RENDERTYPES_DRAW,
6363 TestConfig::COMMANDBUFFERTYPES_INLINE,
6364 TestConfig::IMAGEMEMORY_STRICT,
6371 testConfigExternal.allocationKind,
6372 testConfigExternal.renderingType);
6374 addFunctionCaseWithPrograms<TestConfig>(group, "depth_stencil", "Single depth stencil attachment case.", createTestShaders, renderPassTest, testConfig);
6379 const Attachment attachments[] =
6381 Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6382 VK_SAMPLE_COUNT_1_BIT,
6383 VK_ATTACHMENT_LOAD_OP_CLEAR,
6384 VK_ATTACHMENT_STORE_OP_STORE,
6385 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6386 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6387 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6388 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL),
6389 Attachment(VK_FORMAT_X8_D24_UNORM_PACK32,
6390 VK_SAMPLE_COUNT_1_BIT,
6391 VK_ATTACHMENT_LOAD_OP_CLEAR,
6392 VK_ATTACHMENT_STORE_OP_STORE,
6393 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6394 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6395 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6396 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6399 const RenderPass renderPass (vector<Attachment>(DE_ARRAY_BEGIN(attachments), DE_ARRAY_END(attachments)),
6400 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6402 vector<AttachmentReference>(),
6403 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6404 vector<AttachmentReference>(),
6405 AttachmentReference(1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6406 vector<deUint32>())),
6407 vector<SubpassDependency>());
6408 const TestConfig testConfig (renderPass,
6409 TestConfig::RENDERTYPES_DRAW,
6410 TestConfig::COMMANDBUFFERTYPES_INLINE,
6411 TestConfig::IMAGEMEMORY_STRICT,
6418 testConfigExternal.allocationKind,
6419 testConfigExternal.renderingType);
6421 addFunctionCaseWithPrograms<TestConfig>(group, "color_depth", "Color and depth attachment case.", createTestShaders, renderPassTest, testConfig);
6426 const Attachment attachments[] =
6428 Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6429 VK_SAMPLE_COUNT_1_BIT,
6430 VK_ATTACHMENT_LOAD_OP_CLEAR,
6431 VK_ATTACHMENT_STORE_OP_STORE,
6432 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6433 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6434 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6435 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL),
6436 Attachment(VK_FORMAT_S8_UINT,
6437 VK_SAMPLE_COUNT_1_BIT,
6438 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6439 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6440 VK_ATTACHMENT_LOAD_OP_CLEAR,
6441 VK_ATTACHMENT_STORE_OP_STORE,
6442 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6443 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6446 const RenderPass renderPass (vector<Attachment>(DE_ARRAY_BEGIN(attachments), DE_ARRAY_END(attachments)),
6447 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6449 vector<AttachmentReference>(),
6450 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6451 vector<AttachmentReference>(),
6452 AttachmentReference(1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6453 vector<deUint32>())),
6454 vector<SubpassDependency>());
6455 const TestConfig testConfig (renderPass,
6456 TestConfig::RENDERTYPES_DRAW,
6457 TestConfig::COMMANDBUFFERTYPES_INLINE,
6458 TestConfig::IMAGEMEMORY_STRICT,
6465 testConfigExternal.allocationKind,
6466 testConfigExternal.renderingType);
6468 addFunctionCaseWithPrograms<TestConfig>(group, "color_stencil", "Color and stencil attachment case.", createTestShaders, renderPassTest, testConfig);
6471 // color_depth_stencil
6473 const Attachment attachments[] =
6475 Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6476 VK_SAMPLE_COUNT_1_BIT,
6477 VK_ATTACHMENT_LOAD_OP_CLEAR,
6478 VK_ATTACHMENT_STORE_OP_STORE,
6479 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6480 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6481 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6482 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL),
6483 Attachment(VK_FORMAT_D24_UNORM_S8_UINT,
6484 VK_SAMPLE_COUNT_1_BIT,
6485 VK_ATTACHMENT_LOAD_OP_CLEAR,
6486 VK_ATTACHMENT_STORE_OP_STORE,
6487 VK_ATTACHMENT_LOAD_OP_CLEAR,
6488 VK_ATTACHMENT_STORE_OP_STORE,
6489 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6490 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6493 const RenderPass renderPass (vector<Attachment>(DE_ARRAY_BEGIN(attachments), DE_ARRAY_END(attachments)),
6494 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6496 vector<AttachmentReference>(),
6497 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6498 vector<AttachmentReference>(),
6499 AttachmentReference(1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6500 vector<deUint32>())),
6501 vector<SubpassDependency>());
6502 const TestConfig testConfig (renderPass,
6503 TestConfig::RENDERTYPES_DRAW,
6504 TestConfig::COMMANDBUFFERTYPES_INLINE,
6505 TestConfig::IMAGEMEMORY_STRICT,
6512 testConfigExternal.allocationKind,
6513 testConfigExternal.renderingType);
6515 addFunctionCaseWithPrograms<TestConfig>(group, "color_depth_stencil", "Color, depth and stencil attachment case.", createTestShaders, renderPassTest, testConfig);
6520 const RenderPass renderPass (vector<Attachment>(),
6521 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6523 vector<AttachmentReference>(),
6524 vector<AttachmentReference>(),
6525 vector<AttachmentReference>(),
6526 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6527 vector<deUint32>())),
6528 vector<SubpassDependency>());
6529 const TestConfig testConfig (renderPass,
6530 TestConfig::RENDERTYPES_DRAW,
6531 TestConfig::COMMANDBUFFERTYPES_INLINE,
6532 TestConfig::IMAGEMEMORY_STRICT,
6539 testConfigExternal.allocationKind,
6540 testConfigExternal.renderingType);
6542 addFunctionCaseWithPrograms<TestConfig>(group, "no_attachments", "No attachments case.", createTestShaders, renderPassTest, testConfig);
6545 // color_unused_omit_blend_state
6546 if (testConfigExternal.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
6548 vector<Subpass> subpasses;
6550 // First subpass: use color attachment, create pipeline with color blend state
6551 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6553 vector<AttachmentReference>(),
6554 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6555 vector<AttachmentReference>(),
6556 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6560 // Second subpass: don't use color attachment, create pipeline without color blend state
6561 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6563 vector<AttachmentReference>(),
6564 vector<AttachmentReference>(1, AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6565 vector<AttachmentReference>(),
6566 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6570 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6571 VK_SAMPLE_COUNT_1_BIT,
6572 VK_ATTACHMENT_LOAD_OP_CLEAR,
6573 VK_ATTACHMENT_STORE_OP_STORE,
6574 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6575 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6576 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6577 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6579 vector<SubpassDependency>());
6581 const TestConfig testConfig (renderPass,
6582 TestConfig::RENDERTYPES_DRAW,
6583 TestConfig::COMMANDBUFFERTYPES_INLINE,
6584 TestConfig::IMAGEMEMORY_STRICT,
6591 testConfigExternal.allocationKind,
6592 testConfigExternal.renderingType);
6593 addFunctionCaseWithPrograms<TestConfig>(group, "color_unused_omit_blend_state", "Two unused color attachment case without blend state", createTestShaders, renderPassTest, testConfig);
6597 std::string formatToName (VkFormat format)
6599 const std::string formatStr = de::toString(format);
6600 const std::string prefix = "VK_FORMAT_";
6602 DE_ASSERT(formatStr.substr(0, prefix.length()) == prefix);
6604 return de::toLower(formatStr.substr(prefix.length()));
6607 void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
6609 tcu::TestContext& testCtx = group->getTestContext();
6611 const UVec2 targetSize (64, 64);
6612 const UVec2 renderPos (0, 0);
6613 const UVec2 renderSize (64, 64);
6617 const char* const str;
6618 const VkAttachmentStoreOp op;
6621 { "store", VK_ATTACHMENT_STORE_OP_STORE },
6622 { "dont_care", VK_ATTACHMENT_STORE_OP_DONT_CARE }
6627 const char* const str;
6628 const VkAttachmentLoadOp op;
6631 { "clear", VK_ATTACHMENT_LOAD_OP_CLEAR },
6632 { "load", VK_ATTACHMENT_LOAD_OP_LOAD },
6633 { "dont_care", VK_ATTACHMENT_LOAD_OP_DONT_CARE }
6638 const char* const str;
6639 const TestConfig::RenderTypes types;
6642 { "clear", TestConfig::RENDERTYPES_CLEAR },
6643 { "draw", TestConfig::RENDERTYPES_DRAW },
6644 { "clear_draw", TestConfig::RENDERTYPES_CLEAR|TestConfig::RENDERTYPES_DRAW }
6648 for (size_t formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_coreColorFormats); formatNdx++)
6650 const VkFormat format = s_coreColorFormats[formatNdx];
6651 de::MovePtr<tcu::TestCaseGroup> formatGroup (new tcu::TestCaseGroup(testCtx, formatToName(format).c_str(), de::toString(format).c_str()));
6653 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
6655 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
6656 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
6658 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
6660 const RenderPass renderPass (vector<Attachment>(1, Attachment(format,
6661 VK_SAMPLE_COUNT_1_BIT,
6663 VK_ATTACHMENT_STORE_OP_STORE,
6664 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6665 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6666 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6667 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6668 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6670 vector<AttachmentReference>(),
6671 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6672 vector<AttachmentReference>(),
6673 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6674 vector<deUint32>())),
6675 vector<SubpassDependency>());
6676 const TestConfig testConfig (renderPass,
6677 renderTypes[renderTypeNdx].types,
6678 TestConfig::COMMANDBUFFERTYPES_INLINE,
6679 TestConfig::IMAGEMEMORY_STRICT,
6686 testConfigExternal.allocationKind,
6687 testConfigExternal.renderingType);
6689 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), renderTypes[renderTypeNdx].str, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
6692 formatGroup->addChild(loadOpGroup.release());
6695 if (testConfigExternal.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
6697 de::MovePtr<tcu::TestCaseGroup> inputGroup (new tcu::TestCaseGroup(testCtx, "input", "Test attachment format as input"));
6699 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
6701 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
6702 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
6704 for (size_t storeOpNdx = 0; storeOpNdx < DE_LENGTH_OF_ARRAY(storeOps); storeOpNdx++)
6706 const VkImageAspectFlags inputAttachmentAspectMask = (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2)
6707 ? static_cast<VkImageAspectFlags>(VK_IMAGE_ASPECT_COLOR_BIT)
6708 : static_cast<VkImageAspectFlags>(0);
6709 const VkAttachmentStoreOp storeOp = storeOps[storeOpNdx].op;
6710 de::MovePtr<tcu::TestCaseGroup> storeOpGroup (new tcu::TestCaseGroup(testCtx, storeOps[storeOpNdx].str, storeOps[storeOpNdx].str));
6712 for (size_t useInputAspectNdx = 0; useInputAspectNdx < 2; useInputAspectNdx++)
6714 const bool useInputAspect = useInputAspectNdx != 0;
6716 if (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2 && useInputAspect)
6719 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
6722 vector<Attachment> attachments;
6723 vector<Subpass> subpasses;
6724 vector<SubpassDependency> deps;
6725 vector<VkInputAttachmentAspectReference> inputAspects;
6727 attachments.push_back(Attachment(format,
6728 VK_SAMPLE_COUNT_1_BIT,
6731 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6732 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6733 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6734 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
6736 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
6737 VK_SAMPLE_COUNT_1_BIT,
6738 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6739 VK_ATTACHMENT_STORE_OP_STORE,
6740 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6741 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6742 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6743 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
6745 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6747 vector<AttachmentReference>(),
6748 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6749 vector<AttachmentReference>(),
6750 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6751 vector<deUint32>()));
6752 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6754 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
6755 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6756 vector<AttachmentReference>(),
6757 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6758 vector<deUint32>()));
6760 deps.push_back(SubpassDependency(0, 1,
6762 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
6763 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6765 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6766 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6767 vk::VK_DEPENDENCY_BY_REGION_BIT));
6771 const VkInputAttachmentAspectReference inputAspect =
6775 VK_IMAGE_ASPECT_COLOR_BIT
6778 inputAspects.push_back(inputAspect);
6782 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
6783 const TestConfig testConfig (renderPass,
6784 renderTypes[renderTypeNdx].types,
6785 TestConfig::COMMANDBUFFERTYPES_INLINE,
6786 TestConfig::IMAGEMEMORY_STRICT,
6793 testConfigExternal.allocationKind,
6794 testConfigExternal.renderingType);
6795 const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : ""));
6797 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
6801 vector<Attachment> attachments;
6802 vector<Subpass> subpasses;
6803 vector<SubpassDependency> deps;
6804 vector<VkInputAttachmentAspectReference> inputAspects;
6806 attachments.push_back(Attachment(format,
6807 VK_SAMPLE_COUNT_1_BIT,
6810 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6811 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6812 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6813 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
6815 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6817 vector<AttachmentReference>(),
6818 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6819 vector<AttachmentReference>(),
6820 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6821 vector<deUint32>()));
6822 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6824 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL, inputAttachmentAspectMask)),
6825 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL)),
6826 vector<AttachmentReference>(),
6827 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6828 vector<deUint32>()));
6830 deps.push_back(SubpassDependency(0, 1,
6831 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
6832 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6834 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6835 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6836 vk::VK_DEPENDENCY_BY_REGION_BIT));
6838 deps.push_back(SubpassDependency(1, 1,
6839 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
6840 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6842 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6843 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6844 vk::VK_DEPENDENCY_BY_REGION_BIT));
6848 const VkInputAttachmentAspectReference inputAspect =
6852 VK_IMAGE_ASPECT_COLOR_BIT
6855 inputAspects.push_back(inputAspect);
6859 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
6860 const TestConfig testConfig (renderPass,
6861 renderTypes[renderTypeNdx].types,
6862 TestConfig::COMMANDBUFFERTYPES_INLINE,
6863 TestConfig::IMAGEMEMORY_STRICT,
6870 testConfigExternal.allocationKind,
6871 testConfigExternal.renderingType);
6872 const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : ""));
6874 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
6880 loadOpGroup->addChild(storeOpGroup.release());
6883 inputGroup->addChild(loadOpGroup.release());
6886 formatGroup->addChild(inputGroup.release());
6889 group->addChild(formatGroup.release());
6892 // Depth stencil formats
6893 for (size_t formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_coreDepthStencilFormats); formatNdx++)
6895 const VkFormat vkFormat = s_coreDepthStencilFormats[formatNdx];
6896 const tcu::TextureFormat format = mapVkFormat(vkFormat);
6897 const bool isStencilAttachment = hasStencilComponent(format.order);
6898 const bool isDepthAttachment = hasDepthComponent(format.order);
6899 const VkImageAspectFlags formatAspectFlags = (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
6900 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u);
6901 de::MovePtr<tcu::TestCaseGroup> formatGroup (new tcu::TestCaseGroup(testCtx, formatToName(vkFormat).c_str(), de::toString(vkFormat).c_str()));
6903 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
6905 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
6906 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
6908 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
6911 const RenderPass renderPass (vector<Attachment>(1, Attachment(vkFormat,
6912 VK_SAMPLE_COUNT_1_BIT,
6913 isDepthAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6914 isDepthAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6915 isStencilAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6916 isStencilAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6917 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6918 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6919 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6921 vector<AttachmentReference>(),
6922 vector<AttachmentReference>(),
6923 vector<AttachmentReference>(),
6924 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6925 vector<deUint32>())),
6926 vector<SubpassDependency>());
6927 const TestConfig testConfig (renderPass,
6928 renderTypes[renderTypeNdx].types,
6929 TestConfig::COMMANDBUFFERTYPES_INLINE,
6930 TestConfig::IMAGEMEMORY_STRICT,
6937 testConfigExternal.allocationKind,
6938 testConfigExternal.renderingType);
6940 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), renderTypes[renderTypeNdx].str, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
6943 if (isStencilAttachment && isDepthAttachment && loadOp != VK_ATTACHMENT_LOAD_OP_CLEAR)
6946 const RenderPass renderPass (vector<Attachment>(1, Attachment(vkFormat,
6947 VK_SAMPLE_COUNT_1_BIT,
6948 isDepthAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6949 isDepthAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6950 isStencilAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6951 isStencilAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6952 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6953 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6954 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6956 vector<AttachmentReference>(),
6957 vector<AttachmentReference>(),
6958 vector<AttachmentReference>(),
6959 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL),
6960 vector<deUint32>())),
6961 vector<SubpassDependency>());
6962 const TestConfig testConfig (renderPass,
6963 renderTypes[renderTypeNdx].types,
6964 TestConfig::COMMANDBUFFERTYPES_INLINE,
6965 TestConfig::IMAGEMEMORY_STRICT,
6972 testConfigExternal.allocationKind,
6973 testConfigExternal.renderingType);
6974 const string testName (string(renderTypes[renderTypeNdx].str) + "_depth_read_only");
6976 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
6980 const RenderPass renderPass (vector<Attachment>(1, Attachment(vkFormat,
6981 VK_SAMPLE_COUNT_1_BIT,
6982 isDepthAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6983 isDepthAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6984 isStencilAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6985 isStencilAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6986 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6987 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6988 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6990 vector<AttachmentReference>(),
6991 vector<AttachmentReference>(),
6992 vector<AttachmentReference>(),
6993 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL),
6994 vector<deUint32>())),
6995 vector<SubpassDependency>());
6996 const TestConfig testConfig (renderPass,
6997 renderTypes[renderTypeNdx].types,
6998 TestConfig::COMMANDBUFFERTYPES_INLINE,
6999 TestConfig::IMAGEMEMORY_STRICT,
7006 testConfigExternal.allocationKind,
7007 testConfigExternal.renderingType);
7008 const string testName (string(renderTypes[renderTypeNdx].str) + "_stencil_read_only");
7010 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7015 formatGroup->addChild(loadOpGroup.release());
7018 if (testConfigExternal.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
7020 de::MovePtr<tcu::TestCaseGroup> inputGroup (new tcu::TestCaseGroup(testCtx, "input", "Test attachment format as input"));
7022 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
7024 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
7025 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
7027 for (size_t storeOpNdx = 0; storeOpNdx < DE_LENGTH_OF_ARRAY(storeOps); storeOpNdx++)
7029 const VkImageAspectFlags inputAttachmentAspectMask = (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2)
7031 : static_cast<VkImageAspectFlags>(0);
7032 const VkAttachmentStoreOp storeOp = storeOps[storeOpNdx].op;
7033 de::MovePtr<tcu::TestCaseGroup> storeOpGroup (new tcu::TestCaseGroup(testCtx, storeOps[storeOpNdx].str, storeOps[storeOpNdx].str));
7035 for (size_t useInputAspectNdx = 0; useInputAspectNdx < 2; useInputAspectNdx++)
7037 const bool useInputAspect = useInputAspectNdx != 0;
7039 if (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2 && useInputAspect)
7042 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
7045 vector<Attachment> attachments;
7046 vector<Subpass> subpasses;
7047 vector<SubpassDependency> deps;
7048 vector<VkInputAttachmentAspectReference> inputAspects;
7050 attachments.push_back(Attachment(vkFormat,
7051 VK_SAMPLE_COUNT_1_BIT,
7056 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7057 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7059 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
7060 VK_SAMPLE_COUNT_1_BIT,
7061 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7062 VK_ATTACHMENT_STORE_OP_STORE,
7063 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7064 VK_ATTACHMENT_STORE_OP_DONT_CARE,
7065 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
7066 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
7068 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7070 vector<AttachmentReference>(),
7071 vector<AttachmentReference>(),
7072 vector<AttachmentReference>(),
7073 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7074 vector<deUint32>()));
7075 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7077 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
7078 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
7079 vector<AttachmentReference>(),
7080 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
7081 vector<deUint32>()));
7083 deps.push_back(SubpassDependency(0, 1,
7084 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7085 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7087 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7088 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7093 const VkInputAttachmentAspectReference inputAspect =
7097 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7098 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7101 inputAspects.push_back(inputAspect);
7105 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7106 const TestConfig testConfig (renderPass,
7107 renderTypes[renderTypeNdx].types,
7108 TestConfig::COMMANDBUFFERTYPES_INLINE,
7109 TestConfig::IMAGEMEMORY_STRICT,
7116 testConfigExternal.allocationKind,
7117 testConfigExternal.renderingType);
7118 const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : ""));
7120 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7124 vector<Attachment> attachments;
7125 vector<Subpass> subpasses;
7126 vector<SubpassDependency> deps;
7127 vector<VkInputAttachmentAspectReference> inputAspects;
7129 attachments.push_back(Attachment(vkFormat,
7130 VK_SAMPLE_COUNT_1_BIT,
7133 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7134 VK_ATTACHMENT_STORE_OP_DONT_CARE,
7135 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7136 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7138 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7140 vector<AttachmentReference>(),
7141 vector<AttachmentReference>(),
7142 vector<AttachmentReference>(),
7143 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7144 vector<deUint32>()));
7145 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7147 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL, inputAttachmentAspectMask)),
7148 vector<AttachmentReference>(),
7149 vector<AttachmentReference>(),
7150 AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL),
7151 vector<deUint32>()));
7153 deps.push_back(SubpassDependency(0, 1,
7154 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7155 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7157 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7158 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7159 vk::VK_DEPENDENCY_BY_REGION_BIT));
7161 deps.push_back(SubpassDependency(1, 1,
7162 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7163 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7164 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7165 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7166 vk::VK_DEPENDENCY_BY_REGION_BIT));
7171 const VkInputAttachmentAspectReference inputAspect =
7176 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7177 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7180 inputAspects.push_back(inputAspect);
7184 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7185 const TestConfig testConfig (renderPass,
7186 renderTypes[renderTypeNdx].types,
7187 TestConfig::COMMANDBUFFERTYPES_INLINE,
7188 TestConfig::IMAGEMEMORY_STRICT,
7195 testConfigExternal.allocationKind,
7196 testConfigExternal.renderingType);
7197 const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : ""));
7199 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7203 if (isStencilAttachment && isDepthAttachment)
7207 vector<Attachment> attachments;
7208 vector<Subpass> subpasses;
7209 vector<SubpassDependency> deps;
7210 vector<VkInputAttachmentAspectReference> inputAspects;
7212 attachments.push_back(Attachment(vkFormat,
7213 VK_SAMPLE_COUNT_1_BIT,
7218 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7219 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7221 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
7222 VK_SAMPLE_COUNT_1_BIT,
7223 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7224 VK_ATTACHMENT_STORE_OP_STORE,
7225 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7226 VK_ATTACHMENT_STORE_OP_DONT_CARE,
7227 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
7228 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
7230 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7232 vector<AttachmentReference>(),
7233 vector<AttachmentReference>(),
7234 vector<AttachmentReference>(),
7235 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7236 vector<deUint32>()));
7237 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7239 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL, inputAttachmentAspectMask)),
7240 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
7241 vector<AttachmentReference>(),
7242 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
7243 vector<deUint32>()));
7245 deps.push_back(SubpassDependency(0, 1,
7246 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7247 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7249 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7250 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7255 const VkInputAttachmentAspectReference inputAspect =
7260 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7261 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7264 inputAspects.push_back(inputAspect);
7268 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7269 const TestConfig testConfig (renderPass,
7270 renderTypes[renderTypeNdx].types,
7271 TestConfig::COMMANDBUFFERTYPES_INLINE,
7272 TestConfig::IMAGEMEMORY_STRICT,
7279 testConfigExternal.allocationKind,
7280 testConfigExternal.renderingType);
7281 const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : "") + "_depth_read_only");
7283 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7287 vector<Attachment> attachments;
7288 vector<Subpass> subpasses;
7289 vector<SubpassDependency> deps;
7290 vector<VkInputAttachmentAspectReference> inputAspects;
7292 attachments.push_back(Attachment(vkFormat,
7293 VK_SAMPLE_COUNT_1_BIT,
7298 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7299 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7301 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7303 vector<AttachmentReference>(),
7304 vector<AttachmentReference>(),
7305 vector<AttachmentReference>(),
7306 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7307 vector<deUint32>()));
7308 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7310 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL, inputAttachmentAspectMask)),
7311 vector<AttachmentReference>(),
7312 vector<AttachmentReference>(),
7313 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL),
7314 vector<deUint32>()));
7316 deps.push_back(SubpassDependency(0, 1,
7317 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7318 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7320 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7321 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7322 vk::VK_DEPENDENCY_BY_REGION_BIT));
7324 deps.push_back(SubpassDependency(1, 1,
7325 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7326 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7328 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7329 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7330 vk::VK_DEPENDENCY_BY_REGION_BIT));
7334 const VkInputAttachmentAspectReference inputAspect =
7339 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7340 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7343 inputAspects.push_back(inputAspect);
7347 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7348 const TestConfig testConfig (renderPass,
7349 renderTypes[renderTypeNdx].types,
7350 TestConfig::COMMANDBUFFERTYPES_INLINE,
7351 TestConfig::IMAGEMEMORY_STRICT,
7358 testConfigExternal.allocationKind,
7359 testConfigExternal.renderingType);
7360 const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : "") + "_depth_read_only");
7362 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7365 // Stencil read only
7367 vector<Attachment> attachments;
7368 vector<Subpass> subpasses;
7369 vector<SubpassDependency> deps;
7370 vector<VkInputAttachmentAspectReference> inputAspects;
7372 attachments.push_back(Attachment(vkFormat,
7373 VK_SAMPLE_COUNT_1_BIT,
7378 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7379 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7381 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
7382 VK_SAMPLE_COUNT_1_BIT,
7383 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7384 VK_ATTACHMENT_STORE_OP_STORE,
7385 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7386 VK_ATTACHMENT_STORE_OP_DONT_CARE,
7387 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
7388 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
7390 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7392 vector<AttachmentReference>(),
7393 vector<AttachmentReference>(),
7394 vector<AttachmentReference>(),
7395 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7396 vector<deUint32>()));
7397 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7399 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
7400 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
7401 vector<AttachmentReference>(),
7402 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
7403 vector<deUint32>()));
7405 deps.push_back(SubpassDependency(0, 1,
7406 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
7407 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7409 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7410 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7415 const VkInputAttachmentAspectReference inputAspect =
7420 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7421 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7424 inputAspects.push_back(inputAspect);
7428 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7429 const TestConfig testConfig (renderPass,
7430 renderTypes[renderTypeNdx].types,
7431 TestConfig::COMMANDBUFFERTYPES_INLINE,
7432 TestConfig::IMAGEMEMORY_STRICT,
7439 testConfigExternal.allocationKind,
7440 testConfigExternal.renderingType);
7441 const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : "") + "_stencil_read_only");
7443 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7447 vector<Attachment> attachments;
7448 vector<Subpass> subpasses;
7449 vector<SubpassDependency> deps;
7450 vector<VkInputAttachmentAspectReference> inputAspects;
7452 attachments.push_back(Attachment(vkFormat,
7453 VK_SAMPLE_COUNT_1_BIT,
7458 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7459 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7461 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7463 vector<AttachmentReference>(),
7464 vector<AttachmentReference>(),
7465 vector<AttachmentReference>(),
7466 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7467 vector<deUint32>()));
7468 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7470 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
7471 vector<AttachmentReference>(),
7472 vector<AttachmentReference>(),
7473 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL),
7474 vector<deUint32>()));
7476 deps.push_back(SubpassDependency(0, 1,
7477 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7478 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7480 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7481 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7482 vk::VK_DEPENDENCY_BY_REGION_BIT));
7484 deps.push_back(SubpassDependency(1, 1,
7485 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7486 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7488 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7489 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7490 vk::VK_DEPENDENCY_BY_REGION_BIT));
7495 const VkInputAttachmentAspectReference inputAspect =
7500 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7501 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7504 inputAspects.push_back(inputAspect);
7508 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7509 const TestConfig testConfig (renderPass,
7510 renderTypes[renderTypeNdx].types,
7511 TestConfig::COMMANDBUFFERTYPES_INLINE,
7512 TestConfig::IMAGEMEMORY_STRICT,
7519 testConfigExternal.allocationKind,
7520 testConfigExternal.renderingType);
7521 const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : "") + "_stencil_read_only");
7523 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7530 loadOpGroup->addChild(storeOpGroup.release());
7533 inputGroup->addChild(loadOpGroup.release());
7536 formatGroup->addChild(inputGroup.release());
7539 group->addChild(formatGroup.release());
7543 void addRenderPassTests (tcu::TestCaseGroup* group, const AllocationKind allocationKind, const RenderingType renderingType)
7545 const TestConfigExternal testConfigExternal (allocationKind, renderingType);
7547 addTestGroup(group, "simple", "Simple basic render pass tests", addSimpleTests, testConfigExternal);
7548 addTestGroup(group, "formats", "Tests for different image formats.", addFormatTests, testConfigExternal);
7549 addTestGroup(group, "attachment", "Attachment format and count tests with load and store ops and image layouts", addAttachmentTests, testConfigExternal);
7550 addTestGroup(group, "attachment_write_mask", "Attachment write mask tests", addAttachmentWriteMaskTests, testConfigExternal);
7552 if (renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
7553 addTestGroup(group, "attachment_allocation", "Attachment allocation tests", addAttachmentAllocationTests, testConfigExternal);
7556 de::MovePtr<tcu::TestCaseGroup> createSuballocationTests(tcu::TestContext& testCtx, RenderingType renderingType)
7558 de::MovePtr<tcu::TestCaseGroup> suballocationTestsGroup(new tcu::TestCaseGroup(testCtx, "suballocation", "Suballocation RenderPass Tests"));
7560 addRenderPassTests(suballocationTestsGroup.get(), ALLOCATION_KIND_SUBALLOCATED, renderingType);
7562 return suballocationTestsGroup;
7565 de::MovePtr<tcu::TestCaseGroup> createDedicatedAllocationTests(tcu::TestContext& testCtx, RenderingType renderingType)
7567 de::MovePtr<tcu::TestCaseGroup> dedicatedAllocationTestsGroup(new tcu::TestCaseGroup(testCtx, "dedicated_allocation", "RenderPass Tests For Dedicated Allocation"));
7569 addRenderPassTests(dedicatedAllocationTestsGroup.get(), ALLOCATION_KIND_DEDICATED, renderingType);
7571 return dedicatedAllocationTestsGroup;
7574 tcu::TestCaseGroup* createRenderPassTestsInternal (tcu::TestContext& testCtx, RenderingType renderingType)
7576 const char* renderingTestsGroupName = (renderingType == RENDERING_TYPE_RENDERPASS_LEGACY) ? "renderpass" :
7577 (renderingType == RENDERING_TYPE_RENDERPASS2) ? "renderpass2" :
7578 (renderingType == RENDERING_TYPE_DYNAMIC_RENDERING) ? "dynamic_rendering" :
7580 const char* renderingTestsGroupDescription = (renderingType == RENDERING_TYPE_RENDERPASS_LEGACY) ? "RenderPass Tests" :
7581 (renderingType == RENDERING_TYPE_RENDERPASS2) ? "RenderPass2 Tests" :
7582 (renderingType == RENDERING_TYPE_DYNAMIC_RENDERING) ? "Dynamic Rendering Tests" :
7585 de::MovePtr<tcu::TestCaseGroup> renderingTests (new tcu::TestCaseGroup(testCtx, renderingTestsGroupName, renderingTestsGroupDescription));
7586 de::MovePtr<tcu::TestCaseGroup> suballocationTestGroup = createSuballocationTests(testCtx, renderingType);
7587 de::MovePtr<tcu::TestCaseGroup> dedicatedAllocationTestGroup = createDedicatedAllocationTests(testCtx, renderingType);
7589 switch (renderingType)
7591 case RENDERING_TYPE_RENDERPASS_LEGACY:
7592 suballocationTestGroup->addChild(createRenderPassMultisampleTests(testCtx));
7593 suballocationTestGroup->addChild(createRenderPassMultisampleResolveTests(testCtx));
7594 suballocationTestGroup->addChild(createRenderPassSubpassDependencyTests(testCtx));
7595 suballocationTestGroup->addChild(createRenderPassSampleReadTests(testCtx));
7596 suballocationTestGroup->addChild(createRenderPassSparseRenderTargetTests(testCtx));
7598 renderingTests->addChild(createRenderPassMultipleSubpassesMultipleCommandBuffersTests(testCtx));
7601 case RENDERING_TYPE_RENDERPASS2:
7602 suballocationTestGroup->addChild(createRenderPass2MultisampleTests(testCtx));
7603 suballocationTestGroup->addChild(createRenderPass2MultisampleResolveTests(testCtx));
7604 suballocationTestGroup->addChild(createRenderPass2SubpassDependencyTests(testCtx));
7605 suballocationTestGroup->addChild(createRenderPass2SampleReadTests(testCtx));
7606 suballocationTestGroup->addChild(createRenderPass2SparseRenderTargetTests(testCtx));
7608 renderingTests->addChild(createRenderPass2DepthStencilResolveTests(testCtx));
7609 renderingTests->addChild(createFragmentDensityMapTests(testCtx));
7612 case RENDERING_TYPE_DYNAMIC_RENDERING:
7613 suballocationTestGroup->addChild(createDynamicRenderingMultisampleResolveTests(testCtx));
7614 suballocationTestGroup->addChild(createDynamicRenderingSparseRenderTargetTests(testCtx));
7616 renderingTests->addChild(createDynamicRenderingBasicTests(testCtx));
7620 if (renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
7622 suballocationTestGroup->addChild(createRenderPassUnusedAttachmentTests(testCtx, renderingType));
7623 suballocationTestGroup->addChild(createRenderPassUnusedAttachmentSparseFillingTests(testCtx, renderingType));
7626 suballocationTestGroup->addChild(createRenderPassUnusedClearAttachmentTests(testCtx, renderingType));
7627 suballocationTestGroup->addChild(createRenderPassLoadStoreOpNoneTests(testCtx, renderingType));
7629 renderingTests->addChild(suballocationTestGroup.release());
7630 renderingTests->addChild(dedicatedAllocationTestGroup.release());
7632 return renderingTests.release();
7637 tcu::TestCaseGroup* createRenderPassTests (tcu::TestContext& testCtx)
7639 return createRenderPassTestsInternal(testCtx, RENDERING_TYPE_RENDERPASS_LEGACY);
7642 tcu::TestCaseGroup* createRenderPass2Tests (tcu::TestContext& testCtx)
7644 return createRenderPassTestsInternal(testCtx, RENDERING_TYPE_RENDERPASS2);
7647 tcu::TestCaseGroup* createDynamicRenderingTests(tcu::TestContext& testCtx)
7649 return createRenderPassTestsInternal(testCtx, RENDERING_TYPE_DYNAMIC_RENDERING);