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"
40 #include "vktRenderPassDepthStencilWriteConditionsTests.hpp"
42 #include "vktTestCaseUtil.hpp"
43 #include "vktTestGroupUtil.hpp"
46 #include "vkDeviceUtil.hpp"
47 #include "vkImageUtil.hpp"
48 #include "vkMemUtil.hpp"
49 #include "vkPlatform.hpp"
50 #include "vkPrograms.hpp"
51 #include "vkQueryUtil.hpp"
53 #include "vkRefUtil.hpp"
54 #include "vkStrUtil.hpp"
55 #include "vkTypeUtil.hpp"
56 #include "vkCmdUtil.hpp"
57 #include "vkObjUtil.hpp"
59 #include "tcuFloat.hpp"
60 #include "tcuFormatUtil.hpp"
61 #include "tcuMaybe.hpp"
62 #include "tcuResultCollector.hpp"
63 #include "tcuTestLog.hpp"
64 #include "tcuTextureUtil.hpp"
65 #include "tcuVectorUtil.hpp"
67 #include "deRandom.hpp"
68 #include "deSTLUtil.hpp"
69 #include "deSharedPtr.hpp"
70 #include "deStringUtil.hpp"
71 #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; }
1745 Maybe<deUint32> getDepthStencilAttachmentIndex (void) const { return m_depthStencilAttachment ? tcu::just(m_depthStencilAttachment->getAttachment()) : tcu::Nothing; }
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 const VkPipelineDepthStencilStateCreateInfo depthStencilState =
1992 VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, // sType
1994 (VkPipelineDepthStencilStateCreateFlags)0u,
1995 writeDepth, // depthTestEnable
1996 writeDepth, // depthWriteEnable
1997 VK_COMPARE_OP_ALWAYS, // depthCompareOp
1998 VK_FALSE, // depthBoundsEnable
1999 writeStencil, // stencilTestEnable
2001 VK_STENCIL_OP_REPLACE, // stencilFailOp
2002 VK_STENCIL_OP_REPLACE, // stencilPassOp
2003 VK_STENCIL_OP_REPLACE, // stencilDepthFailOp
2004 VK_COMPARE_OP_ALWAYS, // stencilCompareOp
2005 ~0u, // stencilCompareMask
2006 ~0u, // stencilWriteMask
2007 ((stencilIndex % 2) == 0) ? ~0x0u : 0x0u // stencilReference
2010 VK_STENCIL_OP_REPLACE, // stencilFailOp
2011 VK_STENCIL_OP_REPLACE, // stencilPassOp
2012 VK_STENCIL_OP_REPLACE, // stencilDepthFailOp
2013 VK_COMPARE_OP_ALWAYS, // stencilCompareOp
2014 ~0u, // stencilCompareMask
2015 ~0u, // stencilWriteMask
2016 ((stencilIndex % 2) == 0) ? ~0x0u : 0x0u // stencilReference
2019 0.0f, // minDepthBounds;
2020 1.0f // maxDepthBounds;
2023 const VkPipelineColorBlendStateCreateInfo blendState =
2025 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // sType
2027 (VkPipelineColorBlendStateCreateFlags)0u,
2028 VK_FALSE, // logicOpEnable
2029 VK_LOGIC_OP_COPY, // logicOp
2030 (deUint32)attachmentBlendStates.size(), // attachmentCount
2031 attachmentBlendStates.empty() ? DE_NULL : &attachmentBlendStates[0],// pAttachments
2032 { 0.0f, 0.0f, 0.0f, 0.0f } // blendConst
2035 std::vector<vk::VkFormat> colorAttachmentFormats;
2036 for (deUint32 i = 0; i < renderInfo.getColorAttachmentCount(); ++i)
2037 colorAttachmentFormats.push_back(renderInfo.getColorAttachment(i).getFormat());
2039 vk::VkFormat depthFormat = VK_FORMAT_UNDEFINED;
2040 vk::VkFormat stencilFormat = VK_FORMAT_UNDEFINED;
2041 if (renderInfo.getDepthStencilAttachment())
2043 const Attachment& attachment = *renderInfo.getDepthStencilAttachment();
2044 vk::VkFormat depthStencilFormat = attachment.getFormat();
2045 if (depthStencilFormat != VK_FORMAT_UNDEFINED)
2047 if (tcu::hasDepthComponent(mapVkFormat(depthStencilFormat).order))
2049 depthFormat = depthStencilFormat;
2051 if (tcu::hasStencilComponent(mapVkFormat(depthStencilFormat).order))
2053 stencilFormat = depthStencilFormat;
2059 VkPipelineRenderingCreateInfoKHR renderingCreateInfo
2061 VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR,
2064 static_cast<deUint32>(colorAttachmentFormats.size()),
2065 colorAttachmentFormats.data(),
2070 return makeGraphicsPipeline(vk, // const DeviceInterface& vk
2071 device, // const VkDevice device
2072 pipelineLayout, // const VkPipelineLayout pipelineLayout
2073 vertexShaderModule, // const VkShaderModule vertexShaderModule
2074 DE_NULL, // const VkShaderModule tessellationControlShaderModule
2075 DE_NULL, // const VkShaderModule tessellationEvalShaderModule
2076 DE_NULL, // const VkShaderModule geometryShaderModule
2077 fragmentShaderModule, // const VkShaderModule fragmentShaderModule
2078 renderPass, // const VkRenderPass renderPass
2079 renderInfo.getSubpassIndex(), // const deUint32 subpass
2080 &vertexInputState, // const VkPipelineVertexInputStateCreateInfo* vertexInputStateCreateInfo
2081 &inputAssemblyState, // const VkPipelineInputAssemblyStateCreateInfo* pInputAssemblyState;
2082 DE_NULL, // const VkPipelineRasterizationStateCreateInfo* rasterizationStateCreateInfo
2083 &viewportState, // const VkPipelineViewportStateCreateInfo* pViewportStat;
2084 &rasterizationState, // const VkPipelineRasterizationStateCreateInfo* pRasterizationState
2085 &multisampleState, // const VkPipelineMultisampleStateCreateInfo* multisampleStateCreateInfo
2086 &depthStencilState, // const VkPipelineDepthStencilStateCreateInfo* depthStencilStateCreateInfo
2087 renderInfo.getOmitBlendState()
2088 ? DE_NULL : &blendState, // const VkPipelineColorBlendStateCreateInfo* colorBlendStateCreateInfo
2089 DE_NULL, // const VkPipelineDynamicStateCreateInfo* dynamicStateCreateInfo
2090 (renderPass == DE_NULL)
2091 ? &renderingCreateInfo : DE_NULL); // const void* pNext)
2094 class SubpassRenderer
2097 SubpassRenderer (Context& context,
2098 const DeviceInterface& vk,
2100 Allocator& allocator,
2101 VkRenderPass renderPass,
2102 VkFramebuffer framebuffer,
2103 VkCommandPool commandBufferPool,
2104 deUint32 queueFamilyIndex,
2105 const vector<VkImage>& attachmentImages,
2106 const vector<pair<VkImageView, VkImageView> >& attachmentViews,
2107 const SubpassRenderInfo& renderInfo,
2108 const vector<Attachment>& attachmentInfos,
2109 const AllocationKind allocationKind,
2110 const bool dynamicRendering)
2111 : m_renderInfo (renderInfo)
2113 const InstanceInterface& vki = context.getInstanceInterface();
2114 const VkPhysicalDevice& physDevice = context.getPhysicalDevice();
2115 const deUint32 subpassIndex = renderInfo.getSubpassIndex();
2116 vector<VkDescriptorSetLayoutBinding> bindings;
2118 for (deUint32 colorAttachmentNdx = 0; colorAttachmentNdx < renderInfo.getColorAttachmentCount(); colorAttachmentNdx++)
2120 const deUint32 attachmentNdx = (renderInfo.getColorAttachmentIndex(colorAttachmentNdx) == VK_ATTACHMENT_UNUSED) ? colorAttachmentNdx
2121 : renderInfo.getColorAttachmentIndex(colorAttachmentNdx);
2123 m_colorAttachmentImages.push_back(attachmentImages[attachmentNdx]);
2126 if (renderInfo.getDepthStencilAttachmentIndex())
2127 m_depthStencilAttachmentImage = attachmentImages[*renderInfo.getDepthStencilAttachmentIndex()];
2129 if (renderInfo.getRenderQuad())
2131 const RenderQuad& renderQuad = *renderInfo.getRenderQuad();
2133 if (renderInfo.getInputAttachmentCount() > 0)
2135 deUint32 bindingIndex = 0;
2137 for (deUint32 inputAttachmentNdx = 0; inputAttachmentNdx < renderInfo.getInputAttachmentCount(); inputAttachmentNdx++)
2139 const Attachment attachmentInfo = attachmentInfos[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)];
2140 const VkImageLayout layout = renderInfo.getInputAttachmentLayout(inputAttachmentNdx);
2141 const tcu::TextureFormat format = mapVkFormat(attachmentInfo.getFormat());
2142 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
2143 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
2144 const deUint32 bindingCount = (isDepthFormat && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
2145 && (isStencilFormat && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
2149 for (deUint32 bindingNdx = 0; bindingNdx < bindingCount; bindingNdx++)
2151 const VkDescriptorSetLayoutBinding binding =
2154 vk::VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2156 vk::VK_SHADER_STAGE_FRAGMENT_BIT,
2160 bindings.push_back(binding);
2165 const VkDescriptorSetLayoutCreateInfo createInfo =
2167 vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
2171 (deUint32)bindings.size(),
2175 m_descriptorSetLayout = vk::createDescriptorSetLayout(vk, device, &createInfo);
2178 const VkDescriptorSetLayout descriptorSetLayout = *m_descriptorSetLayout;
2179 const VkPipelineLayoutCreateInfo pipelineLayoutParams =
2181 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // sType;
2183 (vk::VkPipelineLayoutCreateFlags)0,
2184 m_descriptorSetLayout ? 1u :0u , // setLayoutCount;
2185 m_descriptorSetLayout ? &descriptorSetLayout : DE_NULL, // pSetLayouts;
2186 0u, // pushConstantRangeCount;
2187 DE_NULL, // pPushConstantRanges;
2190 m_vertexShaderModule = createShaderModule(vk, device, context.getBinaryCollection().get(de::toString(subpassIndex) + "-vert"), 0u);
2191 m_fragmentShaderModule = createShaderModule(vk, device, context.getBinaryCollection().get(de::toString(subpassIndex) + "-frag"), 0u);
2192 m_pipelineLayout = createPipelineLayout(vk, device, &pipelineLayoutParams);
2193 m_pipeline = createSubpassPipeline(vk, device, renderPass, *m_vertexShaderModule, *m_fragmentShaderModule, *m_pipelineLayout, m_renderInfo);
2195 // Round up the vertex buffer size to honor nonCoherentAtomSize.
2196 const auto properties = vk::getPhysicalDeviceProperties(context.getInstanceInterface(), context.getPhysicalDevice());
2197 const auto vertexBufferSize = de::roundUp(static_cast<VkDeviceSize>(renderQuad.getVertexDataSize()), properties.limits.nonCoherentAtomSize);
2199 m_vertexBuffer = createBuffer(vk, device, 0u, vertexBufferSize, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, VK_SHARING_MODE_EXCLUSIVE, 1u, &queueFamilyIndex);
2200 m_vertexBufferMemory = allocateBuffer(vki, vk, physDevice, device, *m_vertexBuffer, MemoryRequirement::HostVisible, allocator, allocationKind);
2202 bindBufferMemory(vk, device, *m_vertexBuffer, m_vertexBufferMemory->getMemory(), m_vertexBufferMemory->getOffset());
2204 uploadBufferData(vk, device, *m_vertexBufferMemory, renderQuad.getVertexDataSize(), renderQuad.getVertexPointer(), properties.limits.nonCoherentAtomSize);
2206 if (renderInfo.getInputAttachmentCount() > 0)
2209 const VkDescriptorPoolSize poolSize =
2211 vk::VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2212 // \note Reserve 2 per input attachment since depthStencil attachments require 2.
2213 renderInfo.getInputAttachmentCount() * 2u
2215 const VkDescriptorPoolCreateInfo createInfo =
2217 vk::VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
2219 VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
2221 // \note Reserve 2 per input attachment since depthStencil attachments require 2.
2222 renderInfo.getInputAttachmentCount() * 2u,
2227 m_descriptorPool = vk::createDescriptorPool(vk, device, &createInfo);
2230 const VkDescriptorSetAllocateInfo allocateInfo =
2232 vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
2237 &descriptorSetLayout
2240 m_descriptorSet = vk::allocateDescriptorSet(vk, device, &allocateInfo);
2243 vector<VkWriteDescriptorSet> writes (bindings.size());
2244 vector<VkDescriptorImageInfo> imageInfos (bindings.size());
2245 deUint32 bindingIndex = 0;
2247 for (deUint32 inputAttachmentNdx = 0; inputAttachmentNdx < renderInfo.getInputAttachmentCount(); inputAttachmentNdx++)
2249 const Attachment attachmentInfo = attachmentInfos[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)];
2250 const tcu::TextureFormat format = mapVkFormat(attachmentInfo.getFormat());
2251 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
2252 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
2253 const VkImageLayout inputAttachmentLayout = renderInfo.getInputAttachmentLayout(inputAttachmentNdx);
2256 if (isDepthFormat && isStencilFormat)
2258 if (inputAttachmentLayout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
2260 const VkDescriptorImageInfo imageInfo =
2263 attachmentViews[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)].first,
2264 inputAttachmentLayout
2266 imageInfos[bindingIndex] = imageInfo;
2269 const VkWriteDescriptorSet write =
2271 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2278 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2279 &imageInfos[bindingIndex],
2283 writes[bindingIndex] = write;
2289 if (inputAttachmentLayout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
2291 const VkDescriptorImageInfo imageInfo =
2294 attachmentViews[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)].second,
2295 inputAttachmentLayout
2297 imageInfos[bindingIndex] = imageInfo;
2300 const VkWriteDescriptorSet write =
2302 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2309 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2310 &imageInfos[bindingIndex],
2314 writes[bindingIndex] = write;
2322 const VkDescriptorImageInfo imageInfo =
2325 attachmentViews[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)].first,
2326 inputAttachmentLayout
2328 imageInfos[bindingIndex] = imageInfo;
2331 const VkWriteDescriptorSet write =
2333 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2340 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2341 &imageInfos[bindingIndex],
2345 writes[bindingIndex] = write;
2352 vk.updateDescriptorSets(device, (deUint32)writes.size(), &writes[0], 0u, DE_NULL);
2357 if (renderInfo.isSecondary())
2359 m_commandBuffer = allocateCommandBuffer(vk, device, commandBufferPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2361 beginCommandBuffer(vk, *m_commandBuffer, vk::VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, renderPass, subpassIndex, framebuffer, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0, &renderInfo, dynamicRendering);
2362 pushRenderCommands(vk, *m_commandBuffer);
2363 endCommandBuffer(vk, *m_commandBuffer);
2367 bool isSecondary (void) const
2369 return !!m_commandBuffer;
2372 VkCommandBuffer getCommandBuffer (void) const
2374 DE_ASSERT(isSecondary());
2375 return *m_commandBuffer;
2378 void pushRenderCommands (const DeviceInterface& vk,
2379 VkCommandBuffer commandBuffer)
2381 if (!m_renderInfo.getColorClears().empty())
2383 const vector<ColorClear>& colorClears (m_renderInfo.getColorClears());
2385 for (deUint32 attachmentNdx = 0; attachmentNdx < m_renderInfo.getColorAttachmentCount(); attachmentNdx++)
2387 const ColorClear& colorClear = colorClears[attachmentNdx];
2388 const VkClearAttachment attachment =
2390 VK_IMAGE_ASPECT_COLOR_BIT,
2392 makeClearValue(colorClear.getColor()),
2394 const VkClearRect rect =
2397 { (deInt32)colorClear.getOffset().x(), (deInt32)colorClear.getOffset().y() },
2398 { colorClear.getSize().x(), colorClear.getSize().y() }
2400 0u, // baseArrayLayer
2404 vk.cmdClearAttachments(commandBuffer, 1u, &attachment, 1u, &rect);
2408 if (m_renderInfo.getDepthStencilClear())
2410 const DepthStencilClear& depthStencilClear = *m_renderInfo.getDepthStencilClear();
2411 const deUint32 attachmentNdx = m_renderInfo.getColorAttachmentCount();
2412 tcu::TextureFormat format = mapVkFormat(m_renderInfo.getDepthStencilAttachment()->getFormat());
2413 const VkImageLayout layout = *m_renderInfo.getDepthStencilAttachmentLayout();
2414 const VkClearAttachment attachment =
2416 (VkImageAspectFlags)((hasDepthComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL ? VK_IMAGE_ASPECT_DEPTH_BIT : 0)
2417 | (hasStencilComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL ? VK_IMAGE_ASPECT_STENCIL_BIT : 0)),
2419 makeClearValueDepthStencil(depthStencilClear.getDepth(), depthStencilClear.getStencil())
2421 const VkClearRect rect =
2424 { (deInt32)depthStencilClear.getOffset().x(), (deInt32)depthStencilClear.getOffset().y() },
2425 { depthStencilClear.getSize().x(), depthStencilClear.getSize().y() }
2427 0u, // baseArrayLayer
2431 if ((tcu::hasDepthComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
2432 || (tcu::hasStencilComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL))
2434 vk.cmdClearAttachments(commandBuffer, 1u, &attachment, 1u, &rect);
2438 vector<VkImageMemoryBarrier> selfDeps;
2439 VkPipelineStageFlags srcStages = 0;
2440 VkPipelineStageFlags dstStages = 0;
2442 for (deUint32 inputAttachmentNdx = 0; inputAttachmentNdx < m_renderInfo.getInputAttachmentCount(); inputAttachmentNdx++)
2444 for (deUint32 colorAttachmentNdx = 0; colorAttachmentNdx < m_renderInfo.getColorAttachmentCount(); colorAttachmentNdx++)
2446 if (m_renderInfo.getInputAttachmentIndex(inputAttachmentNdx) == m_renderInfo.getColorAttachmentIndex(colorAttachmentNdx))
2448 const VkImageMemoryBarrier barrier =
2450 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2453 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // srcAccessMask
2454 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT, // dstAccessMask
2456 VK_IMAGE_LAYOUT_GENERAL, // oldLayout
2457 VK_IMAGE_LAYOUT_GENERAL, // newLayout
2459 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex
2460 VK_QUEUE_FAMILY_IGNORED, // destQueueFamilyIndex
2462 m_colorAttachmentImages[colorAttachmentNdx], // image
2463 { // subresourceRange
2464 VK_IMAGE_ASPECT_COLOR_BIT, // aspect
2467 0, // baseArraySlice
2472 srcStages |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
2473 dstStages |= VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
2475 selfDeps.push_back(barrier);
2479 if (m_renderInfo.getDepthStencilAttachmentIndex() && (m_renderInfo.getInputAttachmentIndex(inputAttachmentNdx) == *m_renderInfo.getDepthStencilAttachmentIndex()))
2481 const tcu::TextureFormat format = mapVkFormat(m_renderInfo.getDepthStencilAttachment()->getFormat());
2482 const bool hasDepth = hasDepthComponent(format.order);
2483 const bool hasStencil = hasStencilComponent(format.order);
2484 const VkImageMemoryBarrier barrier =
2486 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
2489 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, // srcAccessMask
2490 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT, // dstAccessMask
2492 m_renderInfo.getInputAttachmentLayout(inputAttachmentNdx), // oldLayout
2493 m_renderInfo.getInputAttachmentLayout(inputAttachmentNdx), // newLayout;
2495 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex;
2496 VK_QUEUE_FAMILY_IGNORED, // destQueueFamilyIndex;
2498 m_depthStencilAttachmentImage, // image;
2499 { // subresourceRange;
2500 (hasDepth ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
2501 | (hasStencil ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u), // aspect;
2504 0, // baseArraySlice;
2509 srcStages |= VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT;
2510 dstStages |= VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
2512 selfDeps.push_back(barrier);
2516 if (!selfDeps.empty())
2518 DE_ASSERT(srcStages != 0);
2519 DE_ASSERT(dstStages != 0);
2520 vk.cmdPipelineBarrier(commandBuffer, srcStages, dstStages, VK_DEPENDENCY_BY_REGION_BIT, 0, DE_NULL, 0, DE_NULL, (deUint32)selfDeps.size(), &selfDeps[0]);
2523 if (m_renderInfo.getRenderQuad())
2525 const VkDeviceSize offset = 0;
2526 const VkBuffer vertexBuffer = *m_vertexBuffer;
2528 vk.cmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
2530 if (m_descriptorSet)
2532 const VkDescriptorSet descriptorSet = *m_descriptorSet;
2533 vk.cmdBindDescriptorSets(commandBuffer, vk::VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipelineLayout, 0u, 1u, &descriptorSet, 0u, NULL);
2536 vk.cmdBindVertexBuffers(commandBuffer, 0u, 1u, &vertexBuffer, &offset);
2537 vk.cmdDraw(commandBuffer, 6u, 1u, 0u, 0u);
2542 const SubpassRenderInfo m_renderInfo;
2543 Move<VkCommandBuffer> m_commandBuffer;
2544 Move<VkPipeline> m_pipeline;
2545 Move<VkDescriptorSetLayout> m_descriptorSetLayout;
2546 Move<VkPipelineLayout> m_pipelineLayout;
2548 Move<VkShaderModule> m_vertexShaderModule;
2549 Move<VkShaderModule> m_fragmentShaderModule;
2551 Move<VkDescriptorPool> m_descriptorPool;
2552 Move<VkDescriptorSet> m_descriptorSet;
2553 Move<VkBuffer> m_vertexBuffer;
2554 de::MovePtr<Allocation> m_vertexBufferMemory;
2555 vector<VkImage> m_colorAttachmentImages;
2556 VkImage m_depthStencilAttachmentImage;
2559 void pushImageInitializationCommands (const DeviceInterface& vk,
2560 VkCommandBuffer commandBuffer,
2561 const vector<Attachment>& attachmentInfo,
2562 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
2563 deUint32 queueIndex,
2564 const vector<Maybe<VkClearValue> >& clearValues)
2567 vector<VkImageMemoryBarrier> initializeLayouts;
2569 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2571 if (!clearValues[attachmentNdx])
2574 const VkImageMemoryBarrier barrier =
2576 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
2579 (VkAccessFlags)0, // srcAccessMask
2580 getAllMemoryReadFlags() | VK_ACCESS_TRANSFER_WRITE_BIT, // dstAccessMask
2582 VK_IMAGE_LAYOUT_UNDEFINED, // oldLayout
2583 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // newLayout;
2585 queueIndex, // srcQueueFamilyIndex;
2586 queueIndex, // destQueueFamilyIndex;
2588 attachmentResources[attachmentNdx]->getImage(), // image;
2589 { // subresourceRange;
2590 getImageAspectFlags(attachmentInfo[attachmentNdx].getFormat()), // aspect;
2593 0, // baseArraySlice;
2598 initializeLayouts.push_back(barrier);
2601 if (!initializeLayouts.empty())
2602 vk.cmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT,
2603 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, (VkDependencyFlags)0,
2604 0, (const VkMemoryBarrier*)DE_NULL,
2605 0, (const VkBufferMemoryBarrier*)DE_NULL,
2606 (deUint32)initializeLayouts.size(), &initializeLayouts[0]);
2609 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2611 if (!clearValues[attachmentNdx])
2614 const tcu::TextureFormat format = mapVkFormat(attachmentInfo[attachmentNdx].getFormat());
2616 if (hasStencilComponent(format.order) || hasDepthComponent(format.order))
2618 const float clearNan = tcu::Float32::nan().asFloat();
2619 const float clearDepth = hasDepthComponent(format.order) ? clearValues[attachmentNdx]->depthStencil.depth : clearNan;
2620 const deUint32 clearStencil = hasStencilComponent(format.order) ? clearValues[attachmentNdx]->depthStencil.stencil : 0xDEu;
2621 const VkClearDepthStencilValue depthStencil =
2626 const VkImageSubresourceRange range =
2628 (VkImageAspectFlags)((hasDepthComponent(format.order) ? VK_IMAGE_ASPECT_DEPTH_BIT : 0)
2629 | (hasStencilComponent(format.order) ? VK_IMAGE_ASPECT_STENCIL_BIT : 0)),
2636 vk.cmdClearDepthStencilImage(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &depthStencil, 1, &range);
2640 const VkImageSubresourceRange range =
2642 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask;
2645 0, // baseArrayLayer;
2648 const VkClearColorValue clearColor = clearValues[attachmentNdx]->color;
2650 vk.cmdClearColorImage(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clearColor, 1, &range);
2655 vector<VkImageMemoryBarrier> renderPassLayouts;
2657 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2659 const VkImageLayout oldLayout = clearValues[attachmentNdx] ? VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL : VK_IMAGE_LAYOUT_UNDEFINED;
2660 const VkImageMemoryBarrier barrier =
2662 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
2665 getMemoryFlagsForLayout(oldLayout), // srcAccessMask
2666 getAllMemoryReadFlags() | getMemoryFlagsForLayout(attachmentInfo[attachmentNdx].getInitialLayout()), // dstAccessMask
2668 oldLayout, // oldLayout
2669 attachmentInfo[attachmentNdx].getInitialLayout(), // newLayout;
2671 queueIndex, // srcQueueFamilyIndex;
2672 queueIndex, // destQueueFamilyIndex;
2674 attachmentResources[attachmentNdx]->getImage(), // image;
2675 { // subresourceRange;
2676 getImageAspectFlags(attachmentInfo[attachmentNdx].getFormat()), // aspect;
2679 0, // baseArraySlice;
2684 renderPassLayouts.push_back(barrier);
2687 if (!renderPassLayouts.empty())
2688 vk.cmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT,
2689 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, (VkDependencyFlags)0,
2690 0, (const VkMemoryBarrier*)DE_NULL,
2691 0, (const VkBufferMemoryBarrier*)DE_NULL,
2692 (deUint32)renderPassLayouts.size(), &renderPassLayouts[0]);
2696 template<typename RenderpassSubpass>
2697 void pushRenderPassCommands (const DeviceInterface& vk,
2698 VkCommandBuffer commandBuffer,
2699 VkRenderPass renderPass,
2700 VkFramebuffer framebuffer,
2701 const vector<de::SharedPtr<SubpassRenderer> >& subpassRenderers,
2702 const UVec2& renderPos,
2703 const UVec2& renderSize,
2704 const vector<Maybe<VkClearValue> >& renderPassClearValues,
2705 TestConfig::RenderTypes render)
2707 const float clearNan = tcu::Float32::nan().asFloat();
2708 vector<VkClearValue> attachmentClearValues;
2709 const typename RenderpassSubpass::SubpassEndInfo subpassEndInfo (DE_NULL);
2711 for (size_t attachmentNdx = 0; attachmentNdx < renderPassClearValues.size(); attachmentNdx++)
2713 if (renderPassClearValues[attachmentNdx])
2714 attachmentClearValues.push_back(*renderPassClearValues[attachmentNdx]);
2716 attachmentClearValues.push_back(makeClearValueColorF32(clearNan, clearNan, clearNan, clearNan));
2720 const VkRect2D renderArea =
2722 { (deInt32)renderPos.x(), (deInt32)renderPos.y() },
2723 { renderSize.x(), renderSize.y() }
2726 for (size_t subpassNdx = 0; subpassNdx < subpassRenderers.size(); subpassNdx++)
2728 const VkSubpassContents contents = subpassRenderers[subpassNdx]->isSecondary() ? VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS : VK_SUBPASS_CONTENTS_INLINE;
2729 const typename RenderpassSubpass::SubpassBeginInfo subpassBeginInfo (DE_NULL, contents);
2730 const VkRenderPassBeginInfo renderPassBeginInfo = createRenderPassBeginInfo(renderPass,
2733 (deUint32)attachmentClearValues.size(),
2734 attachmentClearValues.empty() ? DE_NULL : &attachmentClearValues[0]);
2736 if (subpassNdx == 0)
2737 RenderpassSubpass::cmdBeginRenderPass(vk, commandBuffer, &renderPassBeginInfo, &subpassBeginInfo);
2739 RenderpassSubpass::cmdNextSubpass(vk, commandBuffer, &subpassBeginInfo, &subpassEndInfo);
2743 if (contents == VK_SUBPASS_CONTENTS_INLINE)
2745 subpassRenderers[subpassNdx]->pushRenderCommands(vk, commandBuffer);
2747 else if (contents == VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS)
2749 const VkCommandBuffer cmd = subpassRenderers[subpassNdx]->getCommandBuffer();
2750 vk.cmdExecuteCommands(commandBuffer, 1, &cmd);
2753 DE_FATAL("Invalid contents");
2757 RenderpassSubpass::cmdEndRenderPass(vk, commandBuffer, &subpassEndInfo);
2761 void pushDynamicRenderingCommands (const DeviceInterface& vk,
2762 VkCommandBuffer commandBuffer,
2763 const RenderPass& renderPassInfo,
2764 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
2765 const vector<de::SharedPtr<SubpassRenderer> >& subpassRenderers,
2766 const UVec2& renderPos,
2767 const UVec2& renderSize,
2768 const vector<Maybe<VkClearValue> >& renderPassClearValues,
2769 deUint32 queueIndex,
2770 TestConfig::RenderTypes render)
2772 const float clearNan = tcu::Float32::nan().asFloat();
2773 const VkClearValue clearValueNan = makeClearValueColorF32(clearNan, clearNan, clearNan, clearNan);
2775 DE_ASSERT(subpassRenderers.size() == 1);
2777 VkRenderingFlagsKHR renderingFlags = 0u;
2778 if (subpassRenderers[0]->isSecondary())
2779 renderingFlags = VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR;
2781 const VkRect2D renderArea
2783 { (deInt32)renderPos.x(), (deInt32)renderPos.y() },
2784 { renderSize.x(), renderSize.y() }
2787 // translate structures that were prepared to construct renderpass to structures needed for dynamic rendering
2789 vector<VkImageMemoryBarrier> imageBarriersBeforeRendering;
2790 vector<VkImageMemoryBarrier> imageBarriersAfterRendering;
2791 std::vector<vk::VkRenderingAttachmentInfoKHR> colorAttachmentVect;
2792 const Subpass& subpassInfo = renderPassInfo.getSubpasses()[0];
2793 const vector<AttachmentReference>& colorAttachmentsInfo = subpassInfo.getColorAttachments();
2794 const vector<AttachmentReference>& resolveAttachmentsInfo = subpassInfo.getResolveAttachments();
2796 for (deUint32 i = 0 ; i < colorAttachmentsInfo.size() ; ++i)
2798 const AttachmentReference& colorAttachmentReference = colorAttachmentsInfo[i];
2799 const deUint32 colorAttachmentIndex = colorAttachmentReference.getAttachment();
2800 const Attachment& colorAttachmentInfo = renderPassInfo.getAttachments()[colorAttachmentIndex];
2802 VkResolveModeFlagBits resolveMode = VK_RESOLVE_MODE_NONE;
2803 VkImageView resolveImageView = DE_NULL;
2804 VkImageLayout resolveImageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
2806 // handle resolve attachments if they were specified
2807 if (!resolveAttachmentsInfo.empty())
2809 const AttachmentReference& resolveAttachmentReference = resolveAttachmentsInfo[i];
2810 const deUint32 resolveAttachmentIndex = resolveAttachmentReference.getAttachment();
2811 const Attachment& resolveAttachmentInfo = renderPassInfo.getAttachments()[resolveAttachmentIndex];
2813 resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
2814 resolveImageView = attachmentResources[resolveAttachmentIndex]->getAttachmentView();
2815 resolveImageLayout = resolveAttachmentInfo.getInitialLayout();
2818 colorAttachmentVect.push_back({
2819 vk::VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR, // VkStructureType sType
2820 DE_NULL, // const void* pNext
2821 attachmentResources[colorAttachmentIndex]->getAttachmentView(), // VkImageView imageView
2822 colorAttachmentReference.getImageLayout(), // VkImageLayout imageLayout
2823 resolveMode, // VkResolveModeFlagBits resolveMode
2824 resolveImageView, // VkImageView resolveImageView
2825 resolveImageLayout, // VkImageLayout resolveImageLayout
2826 colorAttachmentInfo.getLoadOp(), // VkAttachmentLoadOp loadOp
2827 colorAttachmentInfo.getStoreOp(), // VkAttachmentStoreOp storeOp
2828 (renderPassClearValues[colorAttachmentIndex] ?
2829 *renderPassClearValues[colorAttachmentIndex] :
2830 clearValueNan) // VkClearValue clearValue
2833 const VkImageLayout initialLayout = colorAttachmentInfo.getInitialLayout();
2834 const VkImageLayout renderingLayout = colorAttachmentReference.getImageLayout();
2835 const VkImageLayout finalLayout = colorAttachmentInfo.getFinalLayout();
2837 const VkImageMemoryBarrier barrierBeforeRendering
2839 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2842 getAllMemoryWriteFlags() | getMemoryFlagsForLayout(initialLayout), // srcAccessMask
2843 getMemoryFlagsForLayout(renderingLayout), // dstAccessMask
2845 initialLayout, // oldLayout
2846 renderingLayout, // newLayout
2848 queueIndex, // srcQueueFamilyIndex
2849 queueIndex, // destQueueFamilyIndex
2851 attachmentResources[colorAttachmentIndex]->getImage(), // image
2852 { // subresourceRange
2853 getImageAspectFlags(colorAttachmentInfo.getFormat()), // aspect;
2856 0, // baseArraySlice
2860 imageBarriersBeforeRendering.push_back(barrierBeforeRendering);
2862 const VkImageMemoryBarrier barrierAfterRendering
2864 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2867 getMemoryFlagsForLayout(renderingLayout), // srcAccessMask
2868 getAllMemoryReadFlags() | getMemoryFlagsForLayout(finalLayout), // dstAccessMask
2870 renderingLayout, // oldLayout
2871 finalLayout, // newLayout
2873 queueIndex, // srcQueueFamilyIndex
2874 queueIndex, // destQueueFamilyIndex
2876 attachmentResources[colorAttachmentIndex]->getImage(), // image
2877 { // subresourceRange
2878 getImageAspectFlags(colorAttachmentInfo.getFormat()), // aspect;
2881 0, // baseArraySlice
2885 imageBarriersAfterRendering.push_back(barrierAfterRendering);
2888 VkRenderingAttachmentInfoKHR* pDepthAttachment = DE_NULL;
2889 VkRenderingAttachmentInfoKHR* pStencilAttachment = DE_NULL;
2890 VkRenderingAttachmentInfoKHR depthAttachment
2892 vk::VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR, // VkStructureType sType;
2893 DE_NULL, // const void* pNext;
2894 DE_NULL, // VkImageView imageView;
2895 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout imageLayout;
2896 VK_RESOLVE_MODE_NONE, // VkResolveModeFlagBits resolveMode;
2897 DE_NULL, // VkImageView resolveImageView;
2898 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout resolveImageLayout;
2899 VK_ATTACHMENT_LOAD_OP_LOAD, // VkAttachmentLoadOp loadOp;
2900 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp;
2901 clearValueNan // VkClearValue clearValue;
2903 VkRenderingAttachmentInfoKHR stencilAttachment = depthAttachment;
2904 const AttachmentReference& depthStencilAttachmentReference = subpassInfo.getDepthStencilAttachment();
2905 const deUint32 dsAttachmentIndex = depthStencilAttachmentReference.getAttachment();
2907 if (dsAttachmentIndex != VK_ATTACHMENT_UNUSED)
2909 const Attachment& dsAttachmentInfo = renderPassInfo.getAttachments()[dsAttachmentIndex];
2910 const tcu::TextureFormat format = mapVkFormat(dsAttachmentInfo.getFormat());
2912 if (tcu::hasDepthComponent(format.order))
2914 depthAttachment.imageView = attachmentResources[dsAttachmentIndex]->getAttachmentView();
2915 depthAttachment.imageLayout = depthStencilAttachmentReference.getImageLayout();
2916 depthAttachment.loadOp = dsAttachmentInfo.getLoadOp();
2917 depthAttachment.storeOp = dsAttachmentInfo.getStoreOp();
2919 if (renderPassClearValues[dsAttachmentIndex])
2920 depthAttachment.clearValue = *renderPassClearValues[dsAttachmentIndex];
2922 pDepthAttachment = &depthAttachment;
2925 if (tcu::hasStencilComponent(format.order))
2927 stencilAttachment.imageView = attachmentResources[dsAttachmentIndex]->getAttachmentView();
2928 stencilAttachment.imageLayout = depthStencilAttachmentReference.getImageLayout();
2929 stencilAttachment.loadOp = dsAttachmentInfo.getStencilLoadOp();
2930 stencilAttachment.storeOp = dsAttachmentInfo.getStencilStoreOp();
2932 if (renderPassClearValues[dsAttachmentIndex])
2933 stencilAttachment.clearValue = *renderPassClearValues[dsAttachmentIndex];
2935 pStencilAttachment = &stencilAttachment;
2938 const VkImageLayout initialLayout = dsAttachmentInfo.getInitialLayout();
2939 const VkImageLayout renderingLayout = depthStencilAttachmentReference.getImageLayout();
2940 const VkImageLayout finalLayout = dsAttachmentInfo.getFinalLayout();
2942 const VkImageMemoryBarrier barrierBeforeRendering
2944 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2947 getAllMemoryWriteFlags() | getMemoryFlagsForLayout(initialLayout), // srcAccessMask
2948 getMemoryFlagsForLayout(renderingLayout), // dstAccessMask
2950 initialLayout, // oldLayout
2951 renderingLayout, // newLayout
2953 queueIndex, // srcQueueFamilyIndex
2954 queueIndex, // destQueueFamilyIndex
2956 attachmentResources[dsAttachmentIndex]->getImage(), // image
2957 { // subresourceRange
2958 getImageAspectFlags(dsAttachmentInfo.getFormat()), // aspect;
2961 0, // baseArraySlice
2965 imageBarriersBeforeRendering.push_back(barrierBeforeRendering);
2967 const VkImageMemoryBarrier barrierAfterRendering
2969 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2972 getMemoryFlagsForLayout(renderingLayout), // srcAccessMask
2973 getAllMemoryReadFlags() | getMemoryFlagsForLayout(finalLayout), // dstAccessMask
2975 renderingLayout, // oldLayout
2976 finalLayout, // newLayout
2978 queueIndex, // srcQueueFamilyIndex
2979 queueIndex, // destQueueFamilyIndex
2981 attachmentResources[dsAttachmentIndex]->getImage(), // image
2982 { // subresourceRange
2983 getImageAspectFlags(dsAttachmentInfo.getFormat()), // aspect;
2986 0, // baseArraySlice
2990 imageBarriersAfterRendering.push_back(barrierAfterRendering);
2993 if (!imageBarriersBeforeRendering.empty())
2994 vk.cmdPipelineBarrier(commandBuffer,
2995 getAllPipelineStageFlags(),
2996 getAllPipelineStageFlags(),
2997 (VkDependencyFlags)0,
2998 0, (const VkMemoryBarrier*)DE_NULL,
2999 0, (const VkBufferMemoryBarrier*)DE_NULL,
3000 (deUint32)imageBarriersBeforeRendering.size(),
3001 &imageBarriersBeforeRendering[0]);
3003 vk::VkRenderingInfoKHR renderingInfo
3005 vk::VK_STRUCTURE_TYPE_RENDERING_INFO_KHR,
3007 renderingFlags, // VkRenderingFlagsKHR flags;
3008 renderArea, // VkRect2D renderArea;
3009 1u, // deUint32 layerCount;
3010 0u, // deUint32 viewMask;
3011 static_cast<deUint32>(colorAttachmentVect.size()), // deUint32 colorAttachmentCount;
3012 colorAttachmentVect.empty() ? DE_NULL : &colorAttachmentVect[0], // const VkRenderingAttachmentInfoKHR* pColorAttachments;
3013 pDepthAttachment, // const VkRenderingAttachmentInfoKHR* pDepthAttachment;
3014 pStencilAttachment // const VkRenderingAttachmentInfoKHR* pStencilAttachment;
3017 vk.cmdBeginRendering(commandBuffer, &renderingInfo);
3021 if (subpassRenderers[0]->isSecondary())
3023 const VkCommandBuffer cmd = subpassRenderers[0]->getCommandBuffer();
3024 vk.cmdExecuteCommands(commandBuffer, 1, &cmd);
3027 subpassRenderers[0]->pushRenderCommands(vk, commandBuffer);
3030 vk.cmdEndRendering(commandBuffer);
3032 if (!imageBarriersAfterRendering.empty())
3033 vk.cmdPipelineBarrier(commandBuffer,
3034 getAllPipelineStageFlags(),
3035 getAllPipelineStageFlags(),
3036 (VkDependencyFlags)0,
3037 0, (const VkMemoryBarrier*)DE_NULL,
3038 0, (const VkBufferMemoryBarrier*)DE_NULL,
3039 (deUint32)imageBarriersAfterRendering.size(),
3040 &imageBarriersAfterRendering[0]);
3043 void pushRenderPassCommands (const DeviceInterface& vk,
3044 VkCommandBuffer commandBuffer,
3045 VkRenderPass renderPass,
3046 const RenderPass& renderPassInfo,
3047 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
3048 VkFramebuffer framebuffer,
3049 const vector<de::SharedPtr<SubpassRenderer> >& subpassRenderers,
3050 const UVec2& renderPos,
3051 const UVec2& renderSize,
3052 const vector<Maybe<VkClearValue> >& renderPassClearValues,
3053 deUint32 queueIndex,
3054 TestConfig::RenderTypes render,
3055 RenderingType renderingType)
3057 switch (renderingType)
3059 case RENDERING_TYPE_RENDERPASS_LEGACY:
3060 return pushRenderPassCommands<RenderpassSubpass1>(vk, commandBuffer, renderPass, framebuffer, subpassRenderers, renderPos, renderSize, renderPassClearValues, render);
3061 case RENDERING_TYPE_RENDERPASS2:
3062 return pushRenderPassCommands<RenderpassSubpass2>(vk, commandBuffer, renderPass, framebuffer, subpassRenderers, renderPos, renderSize, renderPassClearValues, render);
3063 case RENDERING_TYPE_DYNAMIC_RENDERING:
3064 return pushDynamicRenderingCommands(vk, commandBuffer, renderPassInfo, attachmentResources, subpassRenderers, renderPos, renderSize, renderPassClearValues, queueIndex, render);
3066 TCU_THROW(InternalError, "Impossible");
3070 void pushReadImagesToBuffers (const DeviceInterface& vk,
3071 VkCommandBuffer commandBuffer,
3072 deUint32 queueIndex,
3074 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
3075 const vector<Attachment>& attachmentInfo,
3076 const vector<bool>& isLazy,
3078 const UVec2& targetSize)
3081 vector<VkImageMemoryBarrier> imageBarriers;
3083 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
3085 if (isLazy[attachmentNdx])
3088 const VkImageLayout oldLayout = attachmentInfo[attachmentNdx].getFinalLayout();
3089 const VkImageMemoryBarrier barrier =
3091 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
3094 getAllMemoryWriteFlags() | getMemoryFlagsForLayout(oldLayout), // srcAccessMask
3095 getAllMemoryReadFlags(), // dstAccessMask
3097 oldLayout, // oldLayout
3098 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // newLayout
3100 queueIndex, // srcQueueFamilyIndex
3101 queueIndex, // destQueueFamilyIndex
3103 attachmentResources[attachmentNdx]->getImage(), // image
3104 { // subresourceRange
3105 getImageAspectFlags(attachmentInfo[attachmentNdx].getFormat()), // aspect;
3108 0, // baseArraySlice
3113 imageBarriers.push_back(barrier);
3116 if (!imageBarriers.empty())
3117 vk.cmdPipelineBarrier(commandBuffer,
3118 getAllPipelineStageFlags(),
3119 getAllPipelineStageFlags(),
3120 (VkDependencyFlags)0,
3121 0, (const VkMemoryBarrier*)DE_NULL,
3122 0, (const VkBufferMemoryBarrier*)DE_NULL,
3123 (deUint32)imageBarriers.size(), &imageBarriers[0]);
3126 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
3128 if (isLazy[attachmentNdx])
3131 const tcu::TextureFormat::ChannelOrder order = mapVkFormat(attachmentInfo[attachmentNdx].getFormat()).order;
3132 const VkBufferImageCopy rect =
3135 0, // bufferRowLength
3136 0, // bufferImageHeight
3137 { // imageSubresource
3138 (vk::VkImageAspectFlags)getPrimaryImageAspect(mapVkFormat(attachmentInfo[attachmentNdx].getFormat()).order), // aspect
3143 { 0, 0, 0 }, // imageOffset
3144 { targetSize.x(), targetSize.y(), 1u } // imageExtent
3147 vk.cmdCopyImageToBuffer(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, attachmentResources[attachmentNdx]->getBuffer(), 1, &rect);
3149 if (tcu::TextureFormat::DS == order)
3151 const VkBufferImageCopy stencilRect =
3154 0, // bufferRowLength
3155 0, // bufferImageHeight
3156 { // imageSubresource
3157 VK_IMAGE_ASPECT_STENCIL_BIT, // aspect
3162 { 0, 0, 0 }, // imageOffset
3163 { targetSize.x(), targetSize.y(), 1u } // imageExtent
3166 vk.cmdCopyImageToBuffer(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, attachmentResources[attachmentNdx]->getSecondaryBuffer(), 1, &stencilRect);
3171 vector<VkBufferMemoryBarrier> bufferBarriers;
3173 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
3175 if (isLazy[attachmentNdx])
3178 const tcu::TextureFormat::ChannelOrder order = mapVkFormat(attachmentInfo[attachmentNdx].getFormat()).order;
3179 const VkBufferMemoryBarrier bufferBarrier =
3181 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
3184 getAllMemoryWriteFlags(),
3185 getAllMemoryReadFlags(),
3190 attachmentResources[attachmentNdx]->getBuffer(),
3192 attachmentResources[attachmentNdx]->getBufferSize()
3195 bufferBarriers.push_back(bufferBarrier);
3197 if (tcu::TextureFormat::DS == order)
3199 const VkBufferMemoryBarrier secondaryBufferBarrier =
3201 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
3204 getAllMemoryWriteFlags(),
3205 getAllMemoryReadFlags(),
3210 attachmentResources[attachmentNdx]->getSecondaryBuffer(),
3212 attachmentResources[attachmentNdx]->getSecondaryBufferSize()
3215 bufferBarriers.push_back(secondaryBufferBarrier);
3219 if (!bufferBarriers.empty())
3220 vk.cmdPipelineBarrier(commandBuffer,
3221 getAllPipelineStageFlags(),
3222 getAllPipelineStageFlags(),
3223 (VkDependencyFlags)0,
3224 0, (const VkMemoryBarrier*)DE_NULL,
3225 (deUint32)bufferBarriers.size(), &bufferBarriers[0],
3226 0, (const VkImageMemoryBarrier*)DE_NULL);
3233 PixelValue (const Maybe<bool>& x = tcu::Nothing,
3234 const Maybe<bool>& y = tcu::Nothing,
3235 const Maybe<bool>& z = tcu::Nothing,
3236 const Maybe<bool>& w = tcu::Nothing);
3238 void setUndefined (size_t ndx);
3239 void setValue (size_t ndx, bool value);
3240 Maybe<bool> getValue (size_t ndx) const;
3246 PixelValue::PixelValue (const Maybe<bool>& x,
3247 const Maybe<bool>& y,
3248 const Maybe<bool>& z,
3249 const Maybe<bool>& w)
3252 const Maybe<bool> values[] =
3257 for (size_t ndx = 0; ndx < DE_LENGTH_OF_ARRAY(values); ndx++)
3260 setValue(ndx, *values[ndx]);
3265 DE_ASSERT(m_status <= 0xFFu);
3268 void PixelValue::setUndefined (size_t ndx)
3271 DE_ASSERT(m_status <= 0xFFu);
3273 m_status &= (deUint16)~(0x1u << (deUint16)(ndx * 2));
3274 DE_ASSERT(m_status <= 0xFFu);
3277 void PixelValue::setValue (size_t ndx, bool value)
3280 DE_ASSERT(m_status <= 0xFFu);
3282 m_status = (deUint16)(m_status | (deUint16)(0x1u << (ndx * 2)));
3285 m_status = (deUint16)(m_status | (deUint16)(0x1u << (ndx * 2 + 1)));
3287 m_status &= (deUint16)~(0x1u << (deUint16)(ndx * 2 + 1));
3289 DE_ASSERT(m_status <= 0xFFu);
3292 Maybe<bool> PixelValue::getValue (size_t ndx) const
3295 DE_ASSERT(m_status <= 0xFFu);
3297 if ((m_status & (0x1u << (deUint16)(ndx * 2))) != 0)
3299 return just((m_status & (0x1u << (deUint32)(ndx * 2 + 1))) != 0);
3302 return tcu::Nothing;
3305 void clearReferenceValues (vector<PixelValue>& values,
3306 const UVec2& targetSize,
3307 const UVec2& offset,
3310 const PixelValue& value)
3312 DE_ASSERT(targetSize.x() * targetSize.y() == (deUint32)values.size());
3313 DE_ASSERT(offset.x() + size.x() <= targetSize.x());
3314 DE_ASSERT(offset.y() + size.y() <= targetSize.y());
3316 for (deUint32 y = offset.y(); y < offset.y() + size.y(); y++)
3317 for (deUint32 x = offset.x(); x < offset.x() + size.x(); x++)
3319 for (int compNdx = 0; compNdx < 4; compNdx++)
3323 if (value.getValue(compNdx))
3324 values[x + y * targetSize.x()].setValue(compNdx, *value.getValue(compNdx));
3326 values[x + y * targetSize.x()].setUndefined(compNdx);
3332 void markUndefined (vector<PixelValue>& values,
3334 const UVec2& targetSize,
3335 const UVec2& offset,
3338 DE_ASSERT(targetSize.x() * targetSize.y() == (deUint32)values.size());
3340 for (deUint32 y = offset.y(); y < offset.y() + size.y(); y++)
3341 for (deUint32 x = offset.x(); x < offset.x() + size.x(); x++)
3343 for (int compNdx = 0; compNdx < 4; compNdx++)
3346 values[x + y * targetSize.x()].setUndefined(compNdx);
3351 PixelValue clearValueToPixelValue (const VkClearValue& value,
3352 const tcu::TextureFormat& format,
3353 const DepthValuesArray& depthValues)
3355 const bool isDepthAttachment = hasDepthComponent(format.order);
3356 const bool isStencilAttachment = hasStencilComponent(format.order);
3357 const bool isDepthOrStencilAttachment = isDepthAttachment || isStencilAttachment;
3358 PixelValue pixelValue;
3360 if (isDepthOrStencilAttachment)
3362 if (isDepthAttachment)
3364 if (value.depthStencil.depth == float(depthValues[1]) / 255.0f)
3365 pixelValue.setValue(0, true);
3366 else if (value.depthStencil.depth == float(depthValues[0]) / 255.0f)
3367 pixelValue.setValue(0, false);
3369 DE_FATAL("Unknown depth value");
3372 if (isStencilAttachment)
3374 if (value.depthStencil.stencil == 0xFFu)
3375 pixelValue.setValue(1, true);
3376 else if (value.depthStencil.stencil == 0x0u)
3377 pixelValue.setValue(1, false);
3379 DE_FATAL("Unknown stencil value");
3384 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
3385 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
3387 switch (channelClass)
3389 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
3390 for (int i = 0; i < 4; i++)
3394 if (value.color.int32[i] == 1)
3395 pixelValue.setValue(i, true);
3396 else if (value.color.int32[i] == 0)
3397 pixelValue.setValue(i, false);
3399 DE_FATAL("Unknown clear color value");
3404 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
3405 for (int i = 0; i < 4; i++)
3409 if (value.color.uint32[i] == 1u)
3410 pixelValue.setValue(i, true);
3411 else if (value.color.uint32[i] == 0u)
3412 pixelValue.setValue(i, false);
3414 DE_FATAL("Unknown clear color value");
3419 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
3420 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
3421 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
3422 for (int i = 0; i < 4; i++)
3426 if (value.color.float32[i] == 1.0f)
3427 pixelValue.setValue(i, true);
3428 else if (value.color.float32[i] == 0.0f)
3429 pixelValue.setValue(i, false);
3431 DE_FATAL("Unknown clear color value");
3437 DE_FATAL("Unknown channel class");
3444 void renderReferenceValues (vector<vector<PixelValue> >& referenceAttachments,
3445 const RenderPass& renderPassInfo,
3446 const UVec2& targetSize,
3447 const vector<Maybe<VkClearValue> >& imageClearValues,
3448 const vector<Maybe<VkClearValue> >& renderPassClearValues,
3449 const vector<SubpassRenderInfo>& subpassRenderInfo,
3450 const UVec2& renderPos,
3451 const UVec2& renderSize,
3452 const deUint32 drawStartNdx,
3453 const DepthValuesArray& depthValues)
3455 const vector<Subpass>& subpasses = renderPassInfo.getSubpasses();
3456 vector<bool> attachmentUsed (renderPassInfo.getAttachments().size(), false);
3458 referenceAttachments.resize(renderPassInfo.getAttachments().size());
3460 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
3462 const Attachment attachment = renderPassInfo.getAttachments()[attachmentNdx];
3463 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3464 vector<PixelValue>& reference = referenceAttachments[attachmentNdx];
3466 reference.resize(targetSize.x() * targetSize.y());
3468 if (imageClearValues[attachmentNdx])
3469 clearReferenceValues(reference, targetSize, UVec2(0, 0), targetSize, BVec4(true), clearValueToPixelValue(*imageClearValues[attachmentNdx], format, depthValues));
3472 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
3474 const Subpass& subpass = subpasses[subpassNdx];
3475 const SubpassRenderInfo& renderInfo = subpassRenderInfo[subpassNdx];
3476 const vector<AttachmentReference>& colorAttachments = subpass.getColorAttachments();
3478 // Apply load op if attachment was used for the first time
3479 for (size_t attachmentNdx = 0; attachmentNdx < colorAttachments.size(); attachmentNdx++)
3481 const deUint32 attachmentIndex = getAttachmentNdx(colorAttachments, attachmentNdx);
3483 if (!attachmentUsed[attachmentIndex] && colorAttachments[attachmentNdx].getAttachment() != VK_ATTACHMENT_UNUSED)
3485 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3486 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3487 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3489 DE_ASSERT(!tcu::hasDepthComponent(format.order));
3490 DE_ASSERT(!tcu::hasStencilComponent(format.order));
3492 if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
3493 clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(true), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format, depthValues));
3494 else if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
3495 markUndefined(reference, BVec4(true), targetSize, renderPos, renderSize);
3497 attachmentUsed[attachmentIndex] = true;
3501 // Apply load op to depth/stencil attachment if it was used for the first time
3502 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
3504 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3506 // Apply load op if attachment was used for the first time
3507 if (!attachmentUsed[attachmentIndex])
3509 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3510 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3511 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3513 if (tcu::hasDepthComponent(format.order))
3515 if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
3516 clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(true, false, false, false), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format, depthValues));
3517 else if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
3518 markUndefined(reference, BVec4(true, false, false, false), targetSize, renderPos, renderSize);
3521 if (tcu::hasStencilComponent(format.order))
3523 if (attachment.getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
3524 clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(false, true, false, false), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format, depthValues));
3525 else if (attachment.getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
3526 markUndefined(reference, BVec4(false, true, false, false), targetSize, renderPos, renderSize);
3529 attachmentUsed[attachmentIndex] = true;
3533 for (size_t colorClearNdx = 0; colorClearNdx < renderInfo.getColorClears().size(); colorClearNdx++)
3535 const ColorClear& colorClear = renderInfo.getColorClears()[colorClearNdx];
3536 const UVec2 offset = colorClear.getOffset();
3537 const UVec2 size = colorClear.getSize();
3538 const deUint32 attachmentIndex = subpass.getColorAttachments()[colorClearNdx].getAttachment();
3539 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3540 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3541 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3544 value.color = colorClear.getColor();
3546 clearReferenceValues(reference, targetSize, offset, size, BVec4(true), clearValueToPixelValue(value, format, depthValues));
3549 if (renderInfo.getDepthStencilClear())
3551 const DepthStencilClear& dsClear = *renderInfo.getDepthStencilClear();
3552 const UVec2 offset = dsClear.getOffset();
3553 const UVec2 size = dsClear.getSize();
3554 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3555 const VkImageLayout layout = subpass.getDepthStencilAttachment().getImageLayout();
3556 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3557 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3558 const bool hasStencil = tcu::hasStencilComponent(format.order)
3559 && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL;
3560 const bool hasDepth = tcu::hasDepthComponent(format.order)
3561 && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
3562 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3565 value.depthStencil.depth = dsClear.getDepth();
3566 value.depthStencil.stencil = dsClear.getStencil();
3568 clearReferenceValues(reference, targetSize, offset, size, BVec4(hasDepth, hasStencil, false, false), clearValueToPixelValue(value, format, depthValues));
3571 if (renderInfo.getRenderQuad())
3573 const RenderQuad& renderQuad = *renderInfo.getRenderQuad();
3574 const Vec2 posA = renderQuad.getCornerA();
3575 const Vec2 posB = renderQuad.getCornerB();
3576 const Vec2 origin = Vec2((float)renderInfo.getViewportOffset().x(), (float)renderInfo.getViewportOffset().y()) + Vec2((float)renderInfo.getViewportSize().x(), (float)renderInfo.getViewportSize().y()) / Vec2(2.0f);
3577 const Vec2 p = Vec2((float)renderInfo.getViewportSize().x(), (float)renderInfo.getViewportSize().y()) / Vec2(2.0f);
3578 const IVec2 posAI (deRoundFloatToInt32(origin.x() + (p.x() * posA.x())),
3579 deRoundFloatToInt32(origin.y() + (p.y() * posA.y())));
3580 const IVec2 posBI (deRoundFloatToInt32(origin.x() + (p.x() * posB.x())),
3581 deRoundFloatToInt32(origin.y() + (p.y() * posB.y())));
3583 DE_ASSERT(posAI.x() < posBI.x());
3584 DE_ASSERT(posAI.y() < posBI.y());
3586 if (subpass.getInputAttachments().empty())
3588 for (size_t attachmentRefNdx = drawStartNdx; attachmentRefNdx < subpass.getColorAttachments().size(); attachmentRefNdx++)
3590 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentRefNdx].getAttachment();
3592 if (attachmentIndex == VK_ATTACHMENT_UNUSED)
3595 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3596 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3597 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
3598 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3600 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3601 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3603 for (int compNdx = 0; compNdx < 4; compNdx++)
3605 const size_t index = subpassNdx + attachmentIndex + compNdx;
3606 const BoolOp op = boolOpFromIndex(index);
3607 const bool boolX = x % 2 == (int)(index % 2);
3608 const bool boolY = y % 2 == (int)((index / 2) % 2);
3610 if (channelMask[compNdx])
3611 reference[x + y * targetSize.x()].setValue(compNdx, performBoolOp(op, boolX, boolY));
3616 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
3618 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3619 const VkImageLayout layout = subpass.getDepthStencilAttachment().getImageLayout();
3620 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3621 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3622 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3624 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3625 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3627 if (tcu::hasDepthComponent(format.order)
3628 && layout != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3629 && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
3631 const size_t index = subpassNdx + 1;
3632 const BoolOp op = boolOpFromIndex(index);
3633 const bool boolX = x % 2 == (int)(index % 2);
3634 const bool boolY = y % 2 == (int)((index / 2) % 2);
3636 reference[x + y * targetSize.x()].setValue(0, performBoolOp(op, boolX, boolY));
3639 if (tcu::hasStencilComponent(format.order)
3640 && layout != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3641 && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
3643 const size_t index = subpassNdx;
3644 reference[x + y * targetSize.x()].setValue(1, (index % 2) == 0);
3651 size_t outputComponentCount = 0;
3652 vector<Maybe<bool> > inputs;
3654 DE_ASSERT(posAI.x() < posBI.x());
3655 DE_ASSERT(posAI.y() < posBI.y());
3657 for (size_t attachmentRefNdx = 0; attachmentRefNdx < subpass.getColorAttachments().size(); attachmentRefNdx++)
3659 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentRefNdx].getAttachment();
3660 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3661 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3662 const int componentCount = tcu::getNumUsedChannels(format.order);
3664 outputComponentCount += (size_t)componentCount;
3667 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3668 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3669 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
3671 const Attachment& attachment (renderPassInfo.getAttachments()[subpass.getDepthStencilAttachment().getAttachment()]);
3672 const tcu::TextureFormat format (mapVkFormat(attachment.getFormat()));
3674 if (tcu::hasDepthComponent(format.order))
3675 outputComponentCount++;
3678 if (outputComponentCount > 0)
3680 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3681 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3683 for (size_t inputAttachmentNdx = 0; inputAttachmentNdx < subpass.getInputAttachments().size(); inputAttachmentNdx++)
3685 const deUint32 attachmentIndex = subpass.getInputAttachments()[inputAttachmentNdx].getAttachment();
3686 const VkImageLayout layout = subpass.getInputAttachments()[inputAttachmentNdx].getImageLayout();
3687 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3688 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3689 const int componentCount = tcu::getNumUsedChannels(format.order);
3691 for (int compNdx = 0; compNdx < componentCount; compNdx++)
3693 if ((compNdx != 0 || layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
3694 && (compNdx != 1 || layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL))
3696 inputs.push_back(referenceAttachments[attachmentIndex][x + y * targetSize.x()].getValue(compNdx));
3701 const size_t inputsPerOutput = inputs.size() >= outputComponentCount
3702 ? ((inputs.size() / outputComponentCount)
3703 + ((inputs.size() % outputComponentCount) != 0 ? 1 : 0))
3706 size_t outputValueNdx = 0;
3708 for (size_t attachmentRefNdx = 0; attachmentRefNdx < subpass.getColorAttachments().size(); attachmentRefNdx++)
3710 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentRefNdx].getAttachment();
3711 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3712 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3713 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3714 const int componentCount = tcu::getNumUsedChannels(format.order);
3716 for (int compNdx = 0; compNdx < componentCount; compNdx++)
3718 const size_t index = subpassNdx + attachmentIndex + outputValueNdx;
3719 const BoolOp op = boolOpFromIndex(index);
3720 const bool boolX = x % 2 == (int)(index % 2);
3721 const bool boolY = y % 2 == (int)((index / 2) % 2);
3722 Maybe<bool> output = tcu::just(performBoolOp(op, boolX, boolY));
3724 for (size_t i = 0; i < inputsPerOutput; i++)
3728 else if (!inputs[((outputValueNdx + compNdx) * inputsPerOutput + i) % inputs.size()])
3729 output = tcu::Nothing;
3731 output = (*output) == (*inputs[((outputValueNdx + compNdx) * inputsPerOutput + i) % inputs.size()]);
3735 reference[x + y * targetSize.x()].setValue(compNdx, *output);
3737 reference[x + y * targetSize.x()].setUndefined(compNdx);
3740 outputValueNdx += componentCount;
3743 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3744 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3745 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
3747 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3748 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3749 const size_t index = subpassNdx + attachmentIndex;
3750 const BoolOp op = boolOpFromIndex(index);
3751 const bool boolX = x % 2 == (int)(index % 2);
3752 const bool boolY = y % 2 == (int)((index / 2) % 2);
3753 Maybe<bool> output = tcu::just(performBoolOp(op, boolX, boolY));
3755 for (size_t i = 0; i < inputsPerOutput; i++)
3759 else if (inputs[(outputValueNdx * inputsPerOutput + i) % inputs.size()])
3760 output = (*output) == (*inputs[(outputValueNdx * inputsPerOutput + i) % inputs.size()]);
3762 output = tcu::Nothing;
3766 reference[x + y * targetSize.x()].setValue(0, *output);
3768 reference[x + y * targetSize.x()].setUndefined(0);
3775 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3776 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3777 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
3779 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3780 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3781 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3782 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3784 if (tcu::hasStencilComponent(format.order))
3786 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3787 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3789 const size_t index = subpassNdx;
3790 reference[x + y * targetSize.x()].setValue(1, (index % 2) == 0);
3798 // Mark all attachments that were used but not stored as undefined
3799 for (size_t attachmentIndex = 0; attachmentIndex < renderPassInfo.getAttachments().size(); attachmentIndex++)
3801 const Attachment attachment = renderPassInfo.getAttachments()[attachmentIndex];
3802 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3803 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3804 const bool isStencilAttachment = hasStencilComponent(format.order);
3805 const bool isDepthOrStencilAttachment = hasDepthComponent(format.order) || isStencilAttachment;
3807 if (attachmentUsed[attachmentIndex] && renderPassInfo.getAttachments()[attachmentIndex].getStoreOp() == VK_ATTACHMENT_STORE_OP_DONT_CARE)
3809 if (isDepthOrStencilAttachment)
3810 markUndefined(reference, BVec4(true, false, false, false), targetSize, renderPos, renderSize);
3812 markUndefined(reference, BVec4(true), targetSize, renderPos, renderSize);
3815 if (attachmentUsed[attachmentIndex] && isStencilAttachment && renderPassInfo.getAttachments()[attachmentIndex].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_DONT_CARE)
3816 markUndefined(reference, BVec4(false, true, false, false), targetSize, renderPos, renderSize);
3820 void renderReferenceImagesFromValues (vector<tcu::TextureLevel>& referenceImages,
3821 const vector<vector<PixelValue> >& referenceValues,
3822 const UVec2& targetSize,
3823 const RenderPass& renderPassInfo,
3824 const DepthValuesArray& depthValues)
3826 referenceImages.resize(referenceValues.size());
3828 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
3830 const Attachment attachment = renderPassInfo.getAttachments()[attachmentNdx];
3831 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3832 const vector<PixelValue>& reference = referenceValues[attachmentNdx];
3833 const bool hasDepth = tcu::hasDepthComponent(format.order);
3834 const bool hasStencil = tcu::hasStencilComponent(format.order);
3835 const bool hasDepthOrStencil = hasDepth || hasStencil;
3836 tcu::TextureLevel& referenceImage = referenceImages[attachmentNdx];
3838 referenceImage.setStorage(format, targetSize.x(), targetSize.y());
3840 if (hasDepthOrStencil)
3844 const PixelBufferAccess depthAccess (tcu::getEffectiveDepthStencilAccess(referenceImage.getAccess(), tcu::Sampler::MODE_DEPTH));
3846 for (deUint32 y = 0; y < targetSize.y(); y++)
3847 for (deUint32 x = 0; x < targetSize.x(); x++)
3849 if (reference[x + y * targetSize.x()].getValue(0))
3851 if (*reference[x + y * targetSize.x()].getValue(0))
3852 depthAccess.setPixDepth(float(depthValues[1]) / 255.0f, x, y);
3854 depthAccess.setPixDepth(float(depthValues[0]) / 255.0f, x, y);
3856 else // Fill with 3x3 grid
3857 depthAccess.setPixDepth(((x / 3) % 2) == ((y / 3) % 2) ? 0.33f : 0.66f, x, y);
3863 const PixelBufferAccess stencilAccess (tcu::getEffectiveDepthStencilAccess(referenceImage.getAccess(), tcu::Sampler::MODE_STENCIL));
3865 for (deUint32 y = 0; y < targetSize.y(); y++)
3866 for (deUint32 x = 0; x < targetSize.x(); x++)
3868 if (reference[x + y * targetSize.x()].getValue(1))
3870 if (*reference[x + y * targetSize.x()].getValue(1))
3871 stencilAccess.setPixStencil(0xFFu, x, y);
3873 stencilAccess.setPixStencil(0x0u, x, y);
3875 else // Fill with 3x3 grid
3876 stencilAccess.setPixStencil(((x / 3) % 2) == ((y / 3) % 2) ? 85 : 170, x, y);
3882 for (deUint32 y = 0; y < targetSize.y(); y++)
3883 for (deUint32 x = 0; x < targetSize.x(); x++)
3887 for (int compNdx = 0; compNdx < 4; compNdx++)
3889 if (reference[x + y * targetSize.x()].getValue(compNdx))
3891 if (*reference[x + y * targetSize.x()].getValue(compNdx))
3892 color[compNdx] = 1.0f;
3894 color[compNdx] = 0.0f;
3896 else // Fill with 3x3 grid
3897 color[compNdx] = ((compNdx + (x / 3)) % 2) == ((y / 3) % 2) ? 0.33f : 0.66f;
3900 referenceImage.getAccess().setPixel(color, x, y);
3906 bool verifyColorAttachment (const vector<PixelValue>& reference,
3907 const ConstPixelBufferAccess& result,
3908 const PixelBufferAccess& errorImage,
3909 const deBool useFormatCompCount)
3911 const Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
3912 const Vec4 green (0.0f, 1.0f, 0.0f, 1.0f);
3915 DE_ASSERT(result.getWidth() * result.getHeight() == (int)reference.size());
3916 DE_ASSERT(result.getWidth() == errorImage.getWidth());
3917 DE_ASSERT(result.getHeight() == errorImage.getHeight());
3919 for (int y = 0; y < result.getHeight(); y++)
3920 for (int x = 0; x < result.getWidth(); x++)
3922 const Vec4 resultColor = result.getPixel(x, y);
3923 const PixelValue& referenceValue = reference[x + y * result.getWidth()];
3924 bool pixelOk = true;
3925 const deUint32 componentCount = useFormatCompCount ? (deUint32)tcu::getNumUsedChannels(result.getFormat().order) : 4;
3927 for (deUint32 compNdx = 0; compNdx < componentCount; compNdx++)
3929 const Maybe<bool> maybeValue = referenceValue.getValue(compNdx);
3933 const bool value = *maybeValue;
3935 if ((value && (resultColor[compNdx] != 1.0f))
3936 || (!value && resultColor[compNdx] != 0.0f))
3943 errorImage.setPixel(red, x, y);
3947 errorImage.setPixel(green, x, y);
3953 // Setting the alpha value to 1.0f by default helps visualization when the alpha channel is not used.
3954 const tcu::Vec4 kDefaultColorForLog {0.0f, 0.0f, 0.0f, 1.0f};
3955 const float kTrueComponent = 1.0f;
3956 const float kFalseComponent = 0.5f;
3957 const float kUnsetComponentLow = 0.0f;
3958 const float kUnsetComponentHigh = 0.25f;
3960 std::unique_ptr<tcu::TextureLevel> renderColorImageForLog (const ConstPixelBufferAccess& image, int numChannels)
3962 // Same channel order, but using UNORM_INT8 for the color format.
3963 const auto order = image.getFormat().order;
3964 const tcu::TextureFormat loggableFormat {order, tcu::TextureFormat::UNORM_INT8};
3965 const int width = image.getWidth();
3966 const int height = image.getHeight();
3967 std::unique_ptr<tcu::TextureLevel> result {new tcu::TextureLevel{loggableFormat, width, height}};
3968 auto access = result->getAccess();
3969 tcu::Vec4 outColor = kDefaultColorForLog;
3971 for (int x = 0; x < width; ++x)
3972 for (int y = 0; y < height; ++y)
3974 const auto value = image.getPixel(x, y);
3975 for (int c = 0; c < numChannels; ++c)
3977 if (value[c] == 0.0f)
3978 outColor[c] = kFalseComponent;
3979 else if (value[c] == 1.0f)
3980 outColor[c] = kTrueComponent;
3984 access.setPixel(outColor, x, y);
3990 std::unique_ptr<tcu::TextureLevel> renderColorImageForLog (const vector<PixelValue>& reference, const UVec2& targetSize, int numChannels)
3992 const tcu::TextureFormat loggableFormat {tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8};
3993 const int width = static_cast<int>(targetSize.x());
3994 const int height = static_cast<int>(targetSize.y());
3995 std::unique_ptr<tcu::TextureLevel> result {new tcu::TextureLevel{loggableFormat, width, height}};
3996 auto access = result->getAccess();
3997 tcu::Vec4 outColor = kDefaultColorForLog;
3999 for (int x = 0; x < width; ++x)
4000 for (int y = 0; y < height; ++y)
4002 const int index = x + y * width;
4003 for (int c = 0; c < numChannels; ++c)
4005 const auto maybeValue = reference[index].getValue(c);
4007 outColor[c] = ((*maybeValue) ? kTrueComponent : kFalseComponent);
4009 outColor[c] = ((((x / 3) % 2) == ((y / 3) % 2)) ? kUnsetComponentLow : kUnsetComponentHigh);
4011 access.setPixel(outColor, x, y);
4017 bool verifyDepthAttachment (const vector<PixelValue>& reference,
4018 const ConstPixelBufferAccess& result,
4019 const PixelBufferAccess& errorImage,
4020 const DepthValuesArray& depthValues,
4023 const Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
4024 const Vec4 green (0.0f, 1.0f, 0.0f, 1.0f);
4027 DE_ASSERT(result.getWidth() * result.getHeight() == (int)reference.size());
4028 DE_ASSERT(result.getWidth() == errorImage.getWidth());
4029 DE_ASSERT(result.getHeight() == errorImage.getHeight());
4031 for (int y = 0; y < result.getHeight(); y++)
4032 for (int x = 0; x < result.getWidth(); x++)
4034 bool pixelOk = true;
4036 const float resultDepth = result.getPixDepth(x, y);
4037 const PixelValue& referenceValue = reference[x + y * result.getWidth()];
4038 const Maybe<bool> maybeValue = referenceValue.getValue(0);
4042 const bool value = *maybeValue;
4044 if ((value && !depthsEqual(resultDepth, float(depthValues[1]) / 255.0f, epsilon))
4045 || (!value && !depthsEqual(resultDepth, float(depthValues[0]) / 255.0f, epsilon)))
4051 errorImage.setPixel(red, x, y);
4055 errorImage.setPixel(green, x, y);
4061 bool verifyStencilAttachment (const vector<PixelValue>& reference,
4062 const ConstPixelBufferAccess& result,
4063 const PixelBufferAccess& errorImage)
4065 const Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
4066 const Vec4 green (0.0f, 1.0f, 0.0f, 1.0f);
4069 DE_ASSERT(result.getWidth() * result.getHeight() == (int)reference.size());
4070 DE_ASSERT(result.getWidth() == errorImage.getWidth());
4071 DE_ASSERT(result.getHeight() == errorImage.getHeight());
4073 for (int y = 0; y < result.getHeight(); y++)
4074 for (int x = 0; x < result.getWidth(); x++)
4076 bool pixelOk = true;
4078 const deUint32 resultStencil = result.getPixStencil(x, y);
4079 const PixelValue& referenceValue = reference[x + y * result.getWidth()];
4080 const Maybe<bool> maybeValue = referenceValue.getValue(1);
4084 const bool value = *maybeValue;
4086 if ((value && (resultStencil != 0xFFu))
4087 || (!value && resultStencil != 0x0u))
4093 errorImage.setPixel(red, x, y);
4097 errorImage.setPixel(green, x, y);
4103 bool logAndVerifyImages (TestLog& log,
4104 const DeviceInterface& vk,
4106 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
4107 const vector<bool>& attachmentIsLazy,
4108 const RenderPass& renderPassInfo,
4109 const vector<Maybe<VkClearValue> >& renderPassClearValues,
4110 const vector<Maybe<VkClearValue> >& imageClearValues,
4111 const vector<SubpassRenderInfo>& subpassRenderInfo,
4112 const UVec2& targetSize,
4113 const TestConfig& config)
4115 vector<vector<PixelValue> > referenceValues;
4116 vector<tcu::TextureLevel> referenceAttachments;
4119 log << TestLog::Message << "Reference images fill undefined pixels with 3x3 grid pattern." << TestLog::EndMessage;
4121 renderReferenceValues(referenceValues, renderPassInfo, targetSize, imageClearValues, renderPassClearValues, subpassRenderInfo, config.renderPos, config.renderSize, config.drawStartNdx, config.depthValues);
4122 renderReferenceImagesFromValues(referenceAttachments, referenceValues, targetSize, renderPassInfo, config.depthValues);
4124 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
4126 if (!attachmentIsLazy[attachmentNdx])
4128 bool attachmentOK = true;
4129 const Attachment attachment = renderPassInfo.getAttachments()[attachmentNdx];
4130 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4132 if (tcu::hasDepthComponent(format.order) && tcu::hasStencilComponent(format.order))
4134 const tcu::TextureFormat depthFormat = getDepthCopyFormat(attachment.getFormat());
4135 void* const depthPtr = attachmentResources[attachmentNdx]->getResultMemory().getHostPtr();
4137 const tcu::TextureFormat stencilFormat = getStencilCopyFormat(attachment.getFormat());
4138 void* const stencilPtr = attachmentResources[attachmentNdx]->getSecondaryResultMemory().getHostPtr();
4140 invalidateAlloc(vk, device, attachmentResources[attachmentNdx]->getResultMemory());
4141 invalidateAlloc(vk, device, attachmentResources[attachmentNdx]->getSecondaryResultMemory());
4144 bool depthOK = true;
4145 bool stencilOK = true;
4146 const ConstPixelBufferAccess depthAccess (depthFormat, targetSize.x(), targetSize.y(), 1, depthPtr);
4147 const ConstPixelBufferAccess stencilAccess (stencilFormat, targetSize.x(), targetSize.y(), 1, stencilPtr);
4148 tcu::TextureLevel depthErrorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
4149 tcu::TextureLevel stencilErrorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
4151 if (renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE
4152 && !verifyDepthAttachment(referenceValues[attachmentNdx], depthAccess, depthErrorImage.getAccess(), config.depthValues, requiredDepthEpsilon(attachment.getFormat())))
4157 if (renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE
4158 && !verifyStencilAttachment(referenceValues[attachmentNdx], stencilAccess, stencilErrorImage.getAccess()))
4163 if (!depthOK || !stencilOK)
4165 const auto attachmentNdxStr = de::toString(attachmentNdx);
4168 log << TestLog::ImageSet("OutputAttachments" + attachmentNdxStr, "Output depth and stencil attachments " + attachmentNdxStr);
4169 log << TestLog::Image("Attachment" + attachmentNdxStr + "Depth", "Attachment " + attachmentNdxStr + " Depth", depthAccess);
4170 log << TestLog::Image("Attachment" + attachmentNdxStr + "Stencil", "Attachment " + attachmentNdxStr + " Stencil", stencilAccess);
4171 log << TestLog::EndImageSet;
4173 // Reference images. These will be logged as image sets due to having depth and stencil aspects.
4174 log << TestLog::Image("AttachmentReferences" + attachmentNdxStr, "Reference images " + attachmentNdxStr, referenceAttachments[attachmentNdx].getAccess());
4177 log << TestLog::ImageSet("ErrorMasks" + attachmentNdxStr, "Error masks " + attachmentNdxStr);
4179 log << TestLog::Image("DepthAttachmentError" + attachmentNdxStr, "Depth Attachment Error " + attachmentNdxStr, depthErrorImage.getAccess());
4181 log << TestLog::Image("StencilAttachmentError" + attachmentNdxStr, "Stencil Attachment Error " + attachmentNdxStr, stencilErrorImage.getAccess());
4182 log << TestLog::EndImageSet;
4184 attachmentOK = false;
4190 void* const ptr = attachmentResources[attachmentNdx]->getResultMemory().getHostPtr();
4192 invalidateAlloc(vk, device, attachmentResources[attachmentNdx]->getResultMemory());
4194 bool depthOK = true;
4195 bool stencilOK = true;
4196 bool colorOK = true;
4197 const ConstPixelBufferAccess access (format, targetSize.x(), targetSize.y(), 1, ptr);
4198 tcu::TextureLevel errorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
4200 if (tcu::hasDepthComponent(format.order))
4202 if ((renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE || renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE)
4203 && !verifyDepthAttachment(referenceValues[attachmentNdx], access, errorImage.getAccess(), config.depthValues, requiredDepthEpsilon(attachment.getFormat())))
4208 else if (tcu::hasStencilComponent(format.order))
4210 if ((renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE || renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE)
4211 && !verifyStencilAttachment(referenceValues[attachmentNdx], access, errorImage.getAccess()))
4218 if ((renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE || renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE)
4219 && !verifyColorAttachment(referenceValues[attachmentNdx], access, errorImage.getAccess(), config.useFormatCompCount))
4225 if (!depthOK || !stencilOK || !colorOK)
4227 log << TestLog::ImageSet("TestImages", "Output attachment, reference image and error mask");
4228 if (!depthOK || !stencilOK)
4230 // Log without conversions.
4231 log << TestLog::Image("Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx), access);
4232 log << TestLog::Image("AttachmentReference" + de::toString(attachmentNdx), "Attachment reference " + de::toString(attachmentNdx), referenceAttachments[attachmentNdx].getAccess());
4236 // Convert color images to better reflect test status and output in any format.
4237 const auto numChannels = tcu::getNumUsedChannels(access.getFormat().order);
4238 const auto attachmentForLog = renderColorImageForLog(access, numChannels);
4239 const auto referenceForLog = renderColorImageForLog(referenceValues[attachmentNdx], targetSize, numChannels);
4241 log << TestLog::Message << "Check the attachment formats and test data to verify which components affect the test result." << TestLog::EndMessage;
4242 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;
4243 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;
4245 log << TestLog::Image("Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx), attachmentForLog->getAccess());
4246 log << TestLog::Image("AttachmentReference" + de::toString(attachmentNdx), "Attachment reference " + de::toString(attachmentNdx), referenceForLog->getAccess());
4248 log << TestLog::Image("AttachmentError" + de::toString(attachmentNdx), "Attachment Error " + de::toString(attachmentNdx), errorImage.getAccess());
4249 log << TestLog::EndImageSet;
4251 attachmentOK = false;
4263 std::string getInputAttachmentType (VkFormat vkFormat)
4265 const tcu::TextureFormat format = mapVkFormat(vkFormat);
4266 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
4268 switch (channelClass)
4270 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
4271 return "isubpassInput";
4273 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
4274 return "usubpassInput";
4276 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
4277 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
4278 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
4279 return "subpassInput";
4282 DE_FATAL("Unknown channel class");
4287 std::string getAttachmentType (VkFormat vkFormat, deBool useFormatCompCount)
4289 const tcu::TextureFormat format = mapVkFormat(vkFormat);
4290 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
4291 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4293 switch (channelClass)
4295 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
4296 if (useFormatCompCount)
4297 return (componentCount == 1 ? "int" : "ivec" + de::toString(componentCount));
4301 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
4302 if (useFormatCompCount)
4303 return (componentCount == 1 ? "uint" : "uvec" + de::toString(componentCount));
4307 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
4308 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
4309 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
4310 if (useFormatCompCount)
4311 return (componentCount == 1 ? "float" : "vec" + de::toString(componentCount));
4316 DE_FATAL("Unknown channel class");
4321 void createTestShaders (SourceCollections& dst, TestConfig config)
4323 if (config.renderTypes & TestConfig::RENDERTYPES_DRAW)
4325 const vector<Subpass>& subpasses = config.renderPass.getSubpasses();
4327 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
4329 const Subpass& subpass = subpasses[subpassNdx];
4330 deUint32 inputAttachmentBinding = 0;
4331 std::ostringstream vertexShader;
4332 std::ostringstream fragmentShader;
4334 vertexShader << "#version 310 es\n"
4335 << "layout(location = 0) in highp vec2 a_position;\n"
4336 << "void main (void) {\n"
4337 << "\tgl_Position = vec4(a_position, 1.0, 1.0);\n"
4340 fragmentShader << "#version 310 es\n"
4341 << "precision highp float;\n";
4343 bool hasAnyDepthFormats = false;
4345 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
4347 const deUint32 attachmentIndex = subpass.getInputAttachments()[attachmentNdx].getAttachment();
4348 const VkImageLayout layout = subpass.getInputAttachments()[attachmentNdx].getImageLayout();
4349 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4350 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4351 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
4352 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
4354 if (isDepthFormat || isStencilFormat)
4356 if (isDepthFormat && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
4358 hasAnyDepthFormats = true;
4359 fragmentShader << "layout(input_attachment_index = " << attachmentNdx << ", set=0, binding=" << inputAttachmentBinding << ") uniform highp subpassInput i_depth" << attachmentNdx << ";\n";
4360 inputAttachmentBinding++;
4363 if (isStencilFormat && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4365 fragmentShader << "layout(input_attachment_index = " << attachmentNdx << ", set=0, binding=" << inputAttachmentBinding << ") uniform highp usubpassInput i_stencil" << attachmentNdx << ";\n";
4366 inputAttachmentBinding++;
4371 const std::string attachmentType = getInputAttachmentType(attachment.getFormat());
4373 fragmentShader << "layout(input_attachment_index = " << attachmentNdx << ", set=0, binding=" << inputAttachmentBinding << ") uniform highp " << attachmentType << " i_color" << attachmentNdx << ";\n";
4374 inputAttachmentBinding++;
4378 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
4380 const std::string attachmentType = getAttachmentType(config.renderPass.getAttachments()[getAttachmentNdx(subpass.getColorAttachments(), attachmentNdx)].getFormat(), config.useFormatCompCount);
4381 fragmentShader << "layout(location = " << attachmentNdx << ") out highp " << attachmentType << " o_color" << attachmentNdx << ";\n";
4384 if (hasAnyDepthFormats)
4385 fragmentShader << "\nbool depthsEqual(float a, float b, float epsilon) {\n"
4386 << "\treturn abs(a - b) <= epsilon;\n}\n\n";
4388 fragmentShader << "void main (void) {\n";
4390 if (subpass.getInputAttachments().empty())
4392 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
4394 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentNdx].getAttachment();
4396 if (attachmentIndex == VK_ATTACHMENT_UNUSED)
4399 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4400 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4401 const size_t componentCount = config.useFormatCompCount ? (size_t)tcu::getNumUsedChannels(format.order) : 4;
4402 const std::string attachmentType = getAttachmentType(attachment.getFormat(), config.useFormatCompCount);
4404 fragmentShader << "\to_color" << attachmentNdx << " = " << attachmentType << "(" << attachmentType + "(";
4406 for (size_t compNdx = 0; compNdx < componentCount; compNdx++)
4408 const size_t index = subpassNdx + attachmentIndex + compNdx;
4409 const BoolOp op = boolOpFromIndex(index);
4412 fragmentShader << ",\n\t\t";
4414 fragmentShader << "((int(gl_FragCoord.x) % 2 == " << (index % 2)
4415 << ") " << boolOpToString(op) << " ("
4416 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
4417 << ") ? 1.0 : 0.0)";
4420 fragmentShader << "));\n";
4423 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
4424 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
4425 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4427 const size_t index = subpassNdx + 1;
4428 const BoolOp op = boolOpFromIndex(index);
4430 fragmentShader << "\tgl_FragDepth = ((int(gl_FragCoord.x) % 2 == " << (index % 2)
4431 << ") " << boolOpToString(op) << " ("
4432 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
4433 << ") ? " << deUint32(config.depthValues[1]) << ".0f/255.0f : " << deUint32(config.depthValues[0]) << ".0f/255.0f);\n";
4438 size_t inputComponentCount = 0;
4439 size_t outputComponentCount = 0;
4441 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
4443 const deUint32 attachmentIndex = subpass.getInputAttachments()[attachmentNdx].getAttachment();
4444 const VkImageLayout layout = subpass.getInputAttachments()[attachmentNdx].getImageLayout();
4445 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4446 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4447 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4449 if (layout == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4450 inputComponentCount += 1;
4451 else if (layout == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
4452 inputComponentCount += 1;
4454 inputComponentCount += componentCount;
4457 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
4459 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentNdx].getAttachment();
4460 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4461 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4462 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4464 outputComponentCount += componentCount;
4467 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
4468 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
4469 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4471 outputComponentCount++;
4474 if (outputComponentCount > 0)
4476 const size_t inputsPerOutput = inputComponentCount >= outputComponentCount
4477 ? ((inputComponentCount / outputComponentCount)
4478 + ((inputComponentCount % outputComponentCount) != 0 ? 1 : 0))
4481 fragmentShader << "\tbool inputs[" << inputComponentCount << "];\n";
4483 if (outputComponentCount > 0)
4484 fragmentShader << "\tbool outputs[" << outputComponentCount << "];\n";
4486 size_t inputValueNdx = 0;
4488 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
4490 const char* const components[] =
4494 const deUint32 attachmentIndex = subpass.getInputAttachments()[attachmentNdx].getAttachment();
4495 const VkImageLayout layout = subpass.getInputAttachments()[attachmentNdx].getImageLayout();
4496 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4497 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4498 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4499 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
4500 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
4502 if (isDepthFormat || isStencilFormat)
4504 if (isDepthFormat && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
4506 fragmentShader << "\tinputs[" << inputValueNdx << "] = depthsEqual(" << deUint32(config.depthValues[1]) <<
4507 ".0f/255.0f, float(subpassLoad(i_depth" << attachmentNdx << ").x), " <<
4508 std::fixed << std::setprecision(12) << requiredDepthEpsilon(attachment.getFormat()) << ");\n";
4512 if (isStencilFormat && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4514 fragmentShader << "\tinputs[" << inputValueNdx << "] = 255u == subpassLoad(i_stencil" << attachmentNdx << ").x;\n";
4520 for (size_t compNdx = 0; compNdx < componentCount; compNdx++)
4522 fragmentShader << "\tinputs[" << inputValueNdx << "] = 1.0 == float(subpassLoad(i_color" << attachmentNdx << ")." << components[compNdx] << ");\n";
4528 size_t outputValueNdx = 0;
4530 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
4532 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentNdx].getAttachment();
4533 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4534 const std::string attachmentType = getAttachmentType(config.renderPass.getAttachments()[attachmentIndex].getFormat(), config.useFormatCompCount);
4535 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4536 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4538 for (size_t compNdx = 0; compNdx < componentCount; compNdx++)
4540 const size_t index = subpassNdx + attachmentIndex + outputValueNdx;
4541 const BoolOp op = boolOpFromIndex(index);
4543 fragmentShader << "\toutputs[" << outputValueNdx + compNdx << "] = "
4544 << "(int(gl_FragCoord.x) % 2 == " << (index % 2)
4545 << ") " << boolOpToString(op) << " ("
4546 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
4549 for (size_t i = 0; i < inputsPerOutput; i++)
4550 fragmentShader << "\toutputs[" << outputValueNdx + compNdx << "] = outputs[" << outputValueNdx + compNdx << "] == inputs[" << ((outputValueNdx + compNdx) * inputsPerOutput + i) % inputComponentCount << "];\n";
4553 fragmentShader << "\to_color" << attachmentNdx << " = " << attachmentType << "(";
4555 for (size_t compNdx = 0; compNdx < (config.useFormatCompCount ? componentCount : 4); compNdx++)
4558 fragmentShader << ", ";
4560 if (compNdx < componentCount)
4561 fragmentShader << "outputs[" << outputValueNdx + compNdx << "]";
4563 fragmentShader << "0";
4566 outputValueNdx += componentCount;
4568 fragmentShader << ");\n";
4571 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
4572 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
4573 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4575 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
4576 const size_t index = subpassNdx + attachmentIndex;
4577 const BoolOp op = boolOpFromIndex(index);
4579 fragmentShader << "\toutputs[" << outputValueNdx << "] = "
4580 << "(int(gl_FragCoord.x) % 2 == " << (index % 2)
4581 << ") " << boolOpToString(op) << " ("
4582 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
4585 for (size_t i = 0; i < inputsPerOutput; i++)
4586 fragmentShader << "\toutputs[" << outputValueNdx << "] = outputs[" << outputValueNdx << "] == inputs[" << (outputValueNdx * inputsPerOutput + i) % inputComponentCount << "];\n";
4588 fragmentShader << "\tgl_FragDepth = outputs[" << outputValueNdx << "] ? " << deUint32(config.depthValues[1]) << ".0f/255.0f : " << deUint32(config.depthValues[0]) << ".0f/255.0f;\n";
4593 fragmentShader << "}\n";
4595 dst.glslSources.add(de::toString(subpassNdx) + "-vert") << glu::VertexSource(vertexShader.str());
4596 dst.glslSources.add(de::toString(subpassNdx) + "-frag") << glu::FragmentSource(fragmentShader.str());
4601 void initializeAttachmentIsLazy (vector<bool>& attachmentIsLazy, const vector<Attachment>& attachments, TestConfig::ImageMemory imageMemory)
4603 bool lastAttachmentWasLazy = false;
4605 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4607 if (attachments[attachmentNdx].getLoadOp() != VK_ATTACHMENT_LOAD_OP_LOAD
4608 && attachments[attachmentNdx].getStoreOp() != VK_ATTACHMENT_STORE_OP_STORE
4609 && attachments[attachmentNdx].getStencilLoadOp() != VK_ATTACHMENT_LOAD_OP_LOAD
4610 && attachments[attachmentNdx].getStencilStoreOp() != VK_ATTACHMENT_STORE_OP_STORE)
4612 if (imageMemory == TestConfig::IMAGEMEMORY_LAZY || (imageMemory & TestConfig::IMAGEMEMORY_LAZY && !lastAttachmentWasLazy))
4614 attachmentIsLazy.push_back(true);
4616 lastAttachmentWasLazy = true;
4618 else if (imageMemory & TestConfig::IMAGEMEMORY_STRICT)
4620 attachmentIsLazy.push_back(false);
4621 lastAttachmentWasLazy = false;
4624 DE_FATAL("Unknown imageMemory");
4627 attachmentIsLazy.push_back(false);
4631 enum AttachmentRefType
4633 ATTACHMENTREFTYPE_COLOR,
4634 ATTACHMENTREFTYPE_DEPTH_STENCIL,
4635 ATTACHMENTREFTYPE_INPUT,
4636 ATTACHMENTREFTYPE_RESOLVE,
4639 VkImageUsageFlags getImageUsageFromLayout (VkImageLayout layout)
4643 case VK_IMAGE_LAYOUT_GENERAL:
4644 case VK_IMAGE_LAYOUT_PREINITIALIZED:
4647 case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
4648 return VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4650 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
4651 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL:
4652 return VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
4654 case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
4655 return VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
4657 case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
4658 return VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
4660 case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
4661 return VK_IMAGE_USAGE_TRANSFER_DST_BIT;
4664 DE_FATAL("Unexpected image layout");
4669 void getImageUsageFromAttachmentReferences(vector<VkImageUsageFlags>& attachmentImageUsage, AttachmentRefType refType, size_t count, const AttachmentReference* references)
4671 for (size_t referenceNdx = 0; referenceNdx < count; ++referenceNdx)
4673 const deUint32 attachment = references[referenceNdx].getAttachment();
4675 if (attachment != VK_ATTACHMENT_UNUSED)
4677 VkImageUsageFlags usage;
4681 case ATTACHMENTREFTYPE_COLOR:
4682 case ATTACHMENTREFTYPE_RESOLVE:
4683 usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4686 case ATTACHMENTREFTYPE_DEPTH_STENCIL:
4687 usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
4690 case ATTACHMENTREFTYPE_INPUT:
4691 usage = VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
4695 DE_FATAL("Unexpected attachment reference type");
4700 attachmentImageUsage[attachment] |= usage;
4705 void getImageUsageFromAttachmentReferences(vector<VkImageUsageFlags>& attachmentImageUsage, AttachmentRefType refType, const vector<AttachmentReference>& references)
4707 if (!references.empty())
4709 getImageUsageFromAttachmentReferences(attachmentImageUsage, refType, references.size(), &references[0]);
4713 void initializeAttachmentImageUsage (Context &context, vector<VkImageUsageFlags>& attachmentImageUsage, const RenderPass& renderPassInfo, const vector<bool>& attachmentIsLazy, const vector<Maybe<VkClearValue> >& clearValues)
4715 attachmentImageUsage.resize(renderPassInfo.getAttachments().size(), VkImageUsageFlags(0));
4717 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); ++subpassNdx)
4719 const Subpass& subpass = renderPassInfo.getSubpasses()[subpassNdx];
4721 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_COLOR, subpass.getColorAttachments());
4722 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_DEPTH_STENCIL, 1, &subpass.getDepthStencilAttachment());
4723 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_INPUT, subpass.getInputAttachments());
4724 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_RESOLVE, subpass.getResolveAttachments());
4727 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
4729 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentNdx];
4730 const VkFormatProperties formatProperties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), attachment.getFormat());
4731 const VkFormatFeatureFlags supportedFeatures = formatProperties.optimalTilingFeatures;
4733 if ((supportedFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0)
4734 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_SAMPLED_BIT;
4736 if ((supportedFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) != 0)
4737 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_STORAGE_BIT;
4739 attachmentImageUsage[attachmentNdx] |= getImageUsageFromLayout(attachment.getInitialLayout());
4740 attachmentImageUsage[attachmentNdx] |= getImageUsageFromLayout(attachment.getFinalLayout());
4742 if (!attachmentIsLazy[attachmentNdx])
4744 if (clearValues[attachmentNdx])
4745 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
4747 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
4751 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);
4753 attachmentImageUsage[attachmentNdx] &= allowedTransientBits;
4754 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4759 void initializeSubpassIsSecondary (vector<bool>& subpassIsSecondary, const vector<Subpass>& subpasses, TestConfig::CommandBufferTypes commandBuffer)
4761 bool lastSubpassWasSecondary = false;
4763 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
4765 if (commandBuffer == TestConfig::COMMANDBUFFERTYPES_SECONDARY || (commandBuffer & TestConfig::COMMANDBUFFERTYPES_SECONDARY && !lastSubpassWasSecondary))
4767 subpassIsSecondary.push_back(true);
4768 lastSubpassWasSecondary = true;
4770 else if (commandBuffer & TestConfig::COMMANDBUFFERTYPES_INLINE)
4772 subpassIsSecondary.push_back(false);
4773 lastSubpassWasSecondary = false;
4776 DE_FATAL("Unknown commandBuffer");
4780 void initializeImageClearValues (de::Random& rng, vector<Maybe<VkClearValue> >& clearValues, const vector<Attachment>& attachments, const vector<bool>& isLazy, deBool useFormatCompCount, const DepthValuesArray& depthValues)
4782 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4784 if (!isLazy[attachmentNdx])
4785 clearValues.push_back(just(randomClearValue(attachments[attachmentNdx], rng, useFormatCompCount, depthValues)));
4787 clearValues.push_back(tcu::Nothing);
4791 void initializeRenderPassClearValues (de::Random& rng, vector<Maybe<VkClearValue> >& clearValues, const vector<Attachment>& attachments, deBool useFormatCompCount, const DepthValuesArray& depthValues)
4793 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4795 if (attachments[attachmentNdx].getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR
4796 || attachments[attachmentNdx].getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
4798 clearValues.push_back(just(randomClearValue(attachments[attachmentNdx], rng, useFormatCompCount, depthValues)));
4801 clearValues.push_back(tcu::Nothing);
4805 void logSubpassRenderInfo (TestLog& log, const SubpassRenderInfo& info, TestConfig config)
4807 log << TestLog::Message << "Viewport, offset: " << info.getViewportOffset() << ", size: " << info.getViewportSize() << TestLog::EndMessage;
4809 if (info.isSecondary())
4810 log << TestLog::Message << "Subpass uses secondary command buffers" << TestLog::EndMessage;
4812 log << TestLog::Message << "Subpass uses inlined commands" << TestLog::EndMessage;
4814 for (deUint32 attachmentNdx = 0; attachmentNdx < info.getColorClears().size(); attachmentNdx++)
4816 const ColorClear& colorClear = info.getColorClears()[attachmentNdx];
4818 log << TestLog::Message << "Clearing color attachment " << attachmentNdx
4819 << ". Offset: " << colorClear.getOffset()
4820 << ", Size: " << colorClear.getSize()
4821 << ", Color: " << clearColorToString(info.getColorAttachment(attachmentNdx).getFormat(), colorClear.getColor(), config.useFormatCompCount) << TestLog::EndMessage;
4824 if (info.getDepthStencilClear())
4826 const DepthStencilClear& depthStencilClear = *info.getDepthStencilClear();
4828 log << TestLog::Message << "Clearing depth stencil attachment"
4829 << ". Offset: " << depthStencilClear.getOffset()
4830 << ", Size: " << depthStencilClear.getSize()
4831 << ", Depth: " << depthStencilClear.getDepth()
4832 << ", Stencil: " << depthStencilClear.getStencil() << TestLog::EndMessage;
4835 if (info.getRenderQuad())
4837 const RenderQuad& renderQuad = *info.getRenderQuad();
4839 log << TestLog::Message << "Rendering grid quad to " << renderQuad.getCornerA() << " -> " << renderQuad.getCornerB() << TestLog::EndMessage;
4843 void logTestCaseInfo (TestLog& log,
4844 const TestConfig& config,
4845 const vector<bool>& attachmentIsLazy,
4846 const vector<Maybe<VkClearValue> >& imageClearValues,
4847 const vector<Maybe<VkClearValue> >& renderPassClearValues,
4848 const vector<SubpassRenderInfo>& subpassRenderInfo)
4850 const RenderPass& renderPass = config.renderPass;
4852 logRenderPassInfo(log, renderPass);
4854 DE_ASSERT(attachmentIsLazy.size() == renderPass.getAttachments().size());
4855 DE_ASSERT(imageClearValues.size() == renderPass.getAttachments().size());
4856 DE_ASSERT(renderPassClearValues.size() == renderPass.getAttachments().size());
4858 log << TestLog::Message << "TargetSize: " << config.targetSize << TestLog::EndMessage;
4859 log << TestLog::Message << "Render area, Offset: " << config.renderPos << ", Size: " << config.renderSize << TestLog::EndMessage;
4861 for (size_t attachmentNdx = 0; attachmentNdx < attachmentIsLazy.size(); attachmentNdx++)
4863 const tcu::ScopedLogSection section (log, "Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx));
4865 if (attachmentIsLazy[attachmentNdx])
4866 log << TestLog::Message << "Is lazy." << TestLog::EndMessage;
4868 if (imageClearValues[attachmentNdx])
4869 log << TestLog::Message << "Image is cleared to " << clearValueToString(renderPass.getAttachments()[attachmentNdx].getFormat(),
4870 *imageClearValues[attachmentNdx], config.useFormatCompCount) << " before rendering." << TestLog::EndMessage;
4872 if (renderPass.getAttachments()[attachmentNdx].getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR && renderPassClearValues[attachmentNdx])
4873 log << TestLog::Message << "Attachment is cleared to " << clearValueToString(renderPass.getAttachments()[attachmentNdx].getFormat(),
4874 *renderPassClearValues[attachmentNdx], config.useFormatCompCount) << " in the beginning of the render pass." << TestLog::EndMessage;
4877 for (size_t subpassNdx = 0; subpassNdx < renderPass.getSubpasses().size(); subpassNdx++)
4879 const tcu::ScopedLogSection section (log, "Subpass" + de::toString(subpassNdx), "Subpass " + de::toString(subpassNdx));
4881 logSubpassRenderInfo(log, subpassRenderInfo[subpassNdx], config);
4885 float roundToViewport (float x, deUint32 offset, deUint32 size)
4887 const float origin = (float)(offset) + ((float(size) / 2.0f));
4888 const float p = (float)(size) / 2.0f;
4889 const deInt32 xi = deRoundFloatToInt32(origin + (p * x));
4891 return (((float)xi) - origin) / p;
4894 void initializeSubpassRenderInfo (vector<SubpassRenderInfo>& renderInfos, de::Random& rng, const RenderPass& renderPass, const TestConfig& config)
4896 const TestConfig::CommandBufferTypes commandBuffer = config.commandBufferTypes;
4897 const vector<Subpass>& subpasses = renderPass.getSubpasses();
4898 bool lastSubpassWasSecondary = false;
4900 for (deUint32 subpassNdx = 0; subpassNdx < (deUint32)subpasses.size(); subpassNdx++)
4902 const Subpass& subpass = subpasses[subpassNdx];
4903 const bool subpassIsSecondary = commandBuffer == TestConfig::COMMANDBUFFERTYPES_SECONDARY
4904 || (commandBuffer & TestConfig::COMMANDBUFFERTYPES_SECONDARY && !lastSubpassWasSecondary) ? true : false;
4905 const bool omitBlendState = subpass.getOmitBlendState();
4906 const UVec2 viewportSize ((config.renderSize * UVec2(2)) / UVec2(3));
4907 const UVec2 viewportOffset (config.renderPos.x() + (subpassNdx % 2) * (config.renderSize.x() / 3),
4908 config.renderPos.y() + ((subpassNdx / 2) % 2) * (config.renderSize.y() / 3));
4910 vector<ColorClear> colorClears;
4911 Maybe<DepthStencilClear> depthStencilClear;
4912 Maybe<RenderQuad> renderQuad;
4914 lastSubpassWasSecondary = subpassIsSecondary;
4916 if (config.renderTypes & TestConfig::RENDERTYPES_CLEAR)
4918 const vector<AttachmentReference>& colorAttachments = subpass.getColorAttachments();
4920 for (size_t attachmentRefNdx = 0; attachmentRefNdx < colorAttachments.size(); attachmentRefNdx++)
4922 const AttachmentReference& attachmentRef = colorAttachments[attachmentRefNdx];
4923 const Attachment& attachment = renderPass.getAttachments()[attachmentRef.getAttachment()];
4924 const UVec2 size ((viewportSize * UVec2(2)) / UVec2(3));
4925 const UVec2 offset (viewportOffset.x() + ((deUint32)attachmentRefNdx % 2u) * (viewportSize.x() / 3u),
4926 viewportOffset.y() + (((deUint32)attachmentRefNdx / 2u) % 2u) * (viewportSize.y() / 3u));
4927 const VkClearColorValue color = randomColorClearValue(attachment, rng, config.useFormatCompCount);
4929 colorClears.push_back(ColorClear(offset, size, color));
4932 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
4934 const Attachment& attachment = renderPass.getAttachments()[subpass.getDepthStencilAttachment().getAttachment()];
4935 const UVec2 size ((viewportSize * UVec2(2)) / UVec2(3));
4936 const UVec2 offset (viewportOffset.x() + ((deUint32)colorAttachments.size() % 2u) * (viewportSize.x() / 3u),
4937 viewportOffset.y() + (((deUint32)colorAttachments.size() / 2u) % 2u) * (viewportSize.y() / 3u));
4938 const VkClearValue value = randomClearValue(attachment, rng, config.useFormatCompCount, config.depthValues);
4940 depthStencilClear = tcu::just(DepthStencilClear(offset, size, value.depthStencil.depth, value.depthStencil.stencil));
4944 if (config.renderTypes & TestConfig::RENDERTYPES_DRAW)
4946 const float w = (subpassNdx % 2) == 0 ? 1.0f : 1.25f;
4947 const float h = (subpassNdx % 2) == 0 ? 1.25f : 1.0f;
4949 const float x0 = roundToViewport((subpassNdx % 2) == 0 ? 1.0f - w : -1.0f, viewportOffset.x(), viewportSize.x());
4950 const float x1 = roundToViewport((subpassNdx % 2) == 0 ? 1.0f : -1.0f + w, viewportOffset.x(), viewportSize.x());
4952 const float y0 = roundToViewport(((subpassNdx / 2) % 2) == 0 ? 1.0f - h : -1.0f, viewportOffset.y(), viewportSize.y());
4953 const float y1 = roundToViewport(((subpassNdx / 2) % 2) == 0 ? 1.0f : -1.0f + h, viewportOffset.y(), viewportSize.y());
4955 renderQuad = tcu::just(RenderQuad(tcu::Vec2(x0, y0), tcu::Vec2(x1, y1)));
4958 renderInfos.push_back(SubpassRenderInfo(renderPass, subpassNdx, config.drawStartNdx, subpassIsSecondary, omitBlendState, viewportOffset, viewportSize, renderQuad, colorClears, depthStencilClear));
4962 void checkTextureFormatSupport (TestLog& log,
4963 const InstanceInterface& vk,
4964 VkPhysicalDevice device,
4965 const vector<Attachment>& attachments)
4967 bool supported = true;
4969 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4971 const Attachment& attachment = attachments[attachmentNdx];
4972 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4973 const bool isDepthOrStencilAttachment = hasDepthComponent(format.order) || hasStencilComponent(format.order);
4974 const VkFormatFeatureFlags flags = isDepthOrStencilAttachment? VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT : VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
4975 VkFormatProperties properties;
4977 vk.getPhysicalDeviceFormatProperties(device, attachment.getFormat(), &properties);
4979 if ((properties.optimalTilingFeatures & flags) != flags)
4982 log << TestLog::Message << "Format: " << attachment.getFormat() << " not supported as " << (isDepthOrStencilAttachment ? "depth stencil attachment" : "color attachment") << TestLog::EndMessage;
4987 TCU_THROW(NotSupportedError, "Format not supported");
4990 tcu::TestStatus renderPassTest (Context& context, TestConfig config)
4992 const UVec2 targetSize = config.targetSize;
4993 const UVec2 renderPos = config.renderPos;
4994 const UVec2 renderSize = config.renderSize;
4995 const RenderPass& renderPassInfo = config.renderPass;
4997 TestLog& log = context.getTestContext().getLog();
4998 de::Random rng (config.seed);
5000 vector<bool> attachmentIsLazy;
5001 vector<VkImageUsageFlags> attachmentImageUsage;
5002 vector<Maybe<VkClearValue> > imageClearValues;
5003 vector<Maybe<VkClearValue> > renderPassClearValues;
5005 vector<bool> subpassIsSecondary;
5006 vector<SubpassRenderInfo> subpassRenderInfo;
5008 if (config.renderingType == RENDERING_TYPE_RENDERPASS2)
5009 context.requireDeviceFunctionality("VK_KHR_create_renderpass2");
5011 if (config.renderingType == RENDERING_TYPE_DYNAMIC_RENDERING)
5012 context.requireDeviceFunctionality("VK_KHR_dynamic_rendering");
5014 if (config.allocationKind == ALLOCATION_KIND_DEDICATED)
5016 if (!context.isDeviceFunctionalitySupported("VK_KHR_dedicated_allocation"))
5017 TCU_THROW(NotSupportedError, "VK_KHR_dedicated_allocation is not supported");
5020 if (!renderPassInfo.getInputAspects().empty())
5022 if (!context.isDeviceFunctionalitySupported("VK_KHR_maintenance2"))
5023 TCU_THROW(NotSupportedError, "Extension VK_KHR_maintenance2 not supported.");
5027 bool requireDepthStencilLayout = false;
5029 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
5031 if (renderPassInfo.getAttachments()[attachmentNdx].getInitialLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5032 || renderPassInfo.getAttachments()[attachmentNdx].getInitialLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL
5033 || renderPassInfo.getAttachments()[attachmentNdx].getFinalLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5034 || renderPassInfo.getAttachments()[attachmentNdx].getFinalLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5036 requireDepthStencilLayout = true;
5041 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size() && !requireDepthStencilLayout; subpassNdx++)
5043 const Subpass& subpass (renderPassInfo.getSubpasses()[subpassNdx]);
5045 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
5047 if (subpass.getColorAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5048 || subpass.getColorAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5050 requireDepthStencilLayout = true;
5055 for (size_t attachmentNdx = 0; !requireDepthStencilLayout && attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
5057 if (subpass.getInputAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5058 || subpass.getInputAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5060 requireDepthStencilLayout = true;
5065 for (size_t attachmentNdx = 0; !requireDepthStencilLayout && attachmentNdx < subpass.getResolveAttachments().size(); attachmentNdx++)
5067 if (subpass.getResolveAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5068 || subpass.getResolveAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5070 requireDepthStencilLayout = true;
5075 if (subpass.getDepthStencilAttachment().getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5076 || subpass.getDepthStencilAttachment().getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5078 requireDepthStencilLayout = true;
5083 if (requireDepthStencilLayout && !context.isDeviceFunctionalitySupported("VK_KHR_maintenance2"))
5084 TCU_THROW(NotSupportedError, "VK_KHR_maintenance2 is not supported");
5087 initializeAttachmentIsLazy(attachmentIsLazy, renderPassInfo.getAttachments(), config.imageMemory);
5088 initializeImageClearValues(rng, imageClearValues, renderPassInfo.getAttachments(), attachmentIsLazy, config.useFormatCompCount, config.depthValues);
5089 initializeAttachmentImageUsage(context, attachmentImageUsage, renderPassInfo, attachmentIsLazy, imageClearValues);
5090 initializeRenderPassClearValues(rng, renderPassClearValues, renderPassInfo.getAttachments(), config.useFormatCompCount, config.depthValues);
5092 initializeSubpassIsSecondary(subpassIsSecondary, renderPassInfo.getSubpasses(), config.commandBufferTypes);
5093 initializeSubpassRenderInfo(subpassRenderInfo, rng, renderPassInfo, config);
5095 logTestCaseInfo(log, config, attachmentIsLazy, imageClearValues, renderPassClearValues, subpassRenderInfo);
5097 checkTextureFormatSupport(log, context.getInstanceInterface(), context.getPhysicalDevice(), config.renderPass.getAttachments());
5100 const vk::VkPhysicalDeviceProperties properties = vk::getPhysicalDeviceProperties(context.getInstanceInterface(), context.getPhysicalDevice());
5102 log << TestLog::Message << "Max color attachments: " << properties.limits.maxColorAttachments << TestLog::EndMessage;
5104 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); subpassNdx++)
5106 if (renderPassInfo.getSubpasses()[subpassNdx].getColorAttachments().size() > (size_t)properties.limits.maxColorAttachments)
5107 TCU_THROW(NotSupportedError, "Subpass uses more than maxColorAttachments.");
5112 const InstanceInterface& vki = context.getInstanceInterface();
5113 const VkPhysicalDevice& physDevice = context.getPhysicalDevice();
5114 const VkDevice device = context.getDevice();
5115 const DeviceInterface& vk = context.getDeviceInterface();
5116 const VkQueue queue = context.getUniversalQueue();
5117 const deUint32 queueIndex = context.getUniversalQueueFamilyIndex();
5118 Allocator& allocator = context.getDefaultAllocator();
5120 const Unique<VkCommandPool> commandBufferPool (createCommandPool(vk, device, 0, queueIndex));
5121 const Unique<VkCommandBuffer> initializeImagesCommandBuffer (allocateCommandBuffer(vk, device, *commandBufferPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
5122 const Unique<VkCommandBuffer> renderCommandBuffer (allocateCommandBuffer(vk, device, *commandBufferPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
5123 const Unique<VkCommandBuffer> readImagesToBuffersCommandBuffer (allocateCommandBuffer(vk, device, *commandBufferPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
5125 vector<de::SharedPtr<AttachmentResources> > attachmentResources;
5126 vector<de::SharedPtr<SubpassRenderer> > subpassRenderers;
5127 vector<VkImage> attachmentImages;
5128 vector<VkImageView> attachmentViews;
5129 vector<pair<VkImageView, VkImageView> > inputAttachmentViews;
5131 Move<VkRenderPass> renderPass;
5132 if (config.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
5133 renderPass = createRenderPass(vk, device, renderPassInfo, config.renderingType);
5135 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
5137 const Attachment& attachmentInfo = renderPassInfo.getAttachments()[attachmentNdx];
5139 attachmentResources.push_back(de::SharedPtr<AttachmentResources>(new AttachmentResources(vki, physDevice, vk, device, allocator, queueIndex, targetSize, attachmentInfo, attachmentImageUsage[attachmentNdx], config.allocationKind)));
5140 attachmentViews.push_back(attachmentResources[attachmentNdx]->getAttachmentView());
5141 attachmentImages.push_back(attachmentResources[attachmentNdx]->getImage());
5143 inputAttachmentViews.push_back(attachmentResources[attachmentNdx]->getInputAttachmentViews());
5146 beginCommandBuffer(vk, *initializeImagesCommandBuffer, (VkCommandBufferUsageFlags)0, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0);
5147 pushImageInitializationCommands(vk, *initializeImagesCommandBuffer, renderPassInfo.getAttachments(), attachmentResources, queueIndex, imageClearValues);
5148 endCommandBuffer(vk, *initializeImagesCommandBuffer);
5151 Move<VkFramebuffer> framebuffer;
5152 if (config.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
5153 framebuffer = createFramebuffer(vk, device, *renderPass, targetSize, attachmentViews);
5155 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); subpassNdx++)
5156 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)));
5158 beginCommandBuffer(vk, *renderCommandBuffer, (VkCommandBufferUsageFlags)0, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0);
5159 pushRenderPassCommands(vk, *renderCommandBuffer, *renderPass, renderPassInfo, attachmentResources, *framebuffer, subpassRenderers, renderPos, renderSize, renderPassClearValues, queueIndex, config.renderTypes, config.renderingType);
5160 endCommandBuffer(vk, *renderCommandBuffer);
5162 beginCommandBuffer(vk, *readImagesToBuffersCommandBuffer, (VkCommandBufferUsageFlags)0, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0);
5163 pushReadImagesToBuffers(vk, *readImagesToBuffersCommandBuffer, queueIndex, attachmentResources, renderPassInfo.getAttachments(), attachmentIsLazy, targetSize);
5164 endCommandBuffer(vk, *readImagesToBuffersCommandBuffer);
5166 const VkCommandBuffer commandBuffers[] =
5168 *initializeImagesCommandBuffer,
5169 *renderCommandBuffer,
5170 *readImagesToBuffersCommandBuffer
5172 const Unique<VkFence> fence (createFence(vk, device, 0u));
5174 queueSubmit(vk, queue, DE_LENGTH_OF_ARRAY(commandBuffers), commandBuffers, *fence);
5175 waitForFences(vk, device, 1, &fence.get(), VK_TRUE, ~0ull);
5179 if (logAndVerifyImages(log, vk, device, attachmentResources, attachmentIsLazy, renderPassInfo, renderPassClearValues, imageClearValues, subpassRenderInfo, targetSize, config))
5180 return tcu::TestStatus::pass("Pass");
5182 return tcu::TestStatus::fail("Result verification failed");
5186 static const VkFormat s_coreColorFormats[] =
5188 VK_FORMAT_R5G6B5_UNORM_PACK16,
5193 VK_FORMAT_R8G8_UNORM,
5194 VK_FORMAT_R8G8_SNORM,
5195 VK_FORMAT_R8G8_UINT,
5196 VK_FORMAT_R8G8_SINT,
5197 VK_FORMAT_R8G8B8A8_UNORM,
5198 VK_FORMAT_R8G8B8A8_SNORM,
5199 VK_FORMAT_R8G8B8A8_UINT,
5200 VK_FORMAT_R8G8B8A8_SINT,
5201 VK_FORMAT_R8G8B8A8_SRGB,
5202 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
5203 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
5204 VK_FORMAT_A8B8G8R8_UINT_PACK32,
5205 VK_FORMAT_A8B8G8R8_SINT_PACK32,
5206 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
5207 VK_FORMAT_B8G8R8A8_UNORM,
5208 VK_FORMAT_B8G8R8A8_SRGB,
5209 VK_FORMAT_A2R10G10B10_UNORM_PACK32,
5210 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
5211 VK_FORMAT_A2B10G10R10_UINT_PACK32,
5212 VK_FORMAT_R16_UNORM,
5213 VK_FORMAT_R16_SNORM,
5216 VK_FORMAT_R16_SFLOAT,
5217 VK_FORMAT_R16G16_UNORM,
5218 VK_FORMAT_R16G16_SNORM,
5219 VK_FORMAT_R16G16_UINT,
5220 VK_FORMAT_R16G16_SINT,
5221 VK_FORMAT_R16G16_SFLOAT,
5222 VK_FORMAT_R16G16B16A16_UNORM,
5223 VK_FORMAT_R16G16B16A16_SNORM,
5224 VK_FORMAT_R16G16B16A16_UINT,
5225 VK_FORMAT_R16G16B16A16_SINT,
5226 VK_FORMAT_R16G16B16A16_SFLOAT,
5229 VK_FORMAT_R32_SFLOAT,
5230 VK_FORMAT_R32G32_UINT,
5231 VK_FORMAT_R32G32_SINT,
5232 VK_FORMAT_R32G32_SFLOAT,
5233 VK_FORMAT_R32G32B32A32_UINT,
5234 VK_FORMAT_R32G32B32A32_SINT,
5235 VK_FORMAT_R32G32B32A32_SFLOAT
5238 static const VkFormat s_coreDepthStencilFormats[] =
5240 VK_FORMAT_D16_UNORM,
5242 VK_FORMAT_X8_D24_UNORM_PACK32,
5243 VK_FORMAT_D32_SFLOAT,
5245 VK_FORMAT_D24_UNORM_S8_UINT,
5246 VK_FORMAT_D32_SFLOAT_S8_UINT
5249 void addAttachmentTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
5251 const deUint32 attachmentCounts[] = { 1, 3, 4, 8 };
5252 const VkAttachmentLoadOp loadOps[] =
5254 VK_ATTACHMENT_LOAD_OP_LOAD,
5255 VK_ATTACHMENT_LOAD_OP_CLEAR,
5256 VK_ATTACHMENT_LOAD_OP_DONT_CARE
5259 const VkAttachmentStoreOp storeOps[] =
5261 VK_ATTACHMENT_STORE_OP_STORE,
5262 VK_ATTACHMENT_STORE_OP_DONT_CARE
5265 const VkImageLayout initialAndFinalColorLayouts[] =
5267 VK_IMAGE_LAYOUT_GENERAL,
5268 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5269 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
5270 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
5271 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
5274 const VkImageLayout initialAndFinalColorLayoutsLazy[] =
5276 VK_IMAGE_LAYOUT_GENERAL,
5277 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5278 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
5281 const VkImageLayout initialAndFinalDepthStencilLayouts[] =
5283 VK_IMAGE_LAYOUT_GENERAL,
5284 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5285 VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL,
5286 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
5287 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
5288 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
5291 const VkImageLayout initialAndFinalDepthStencilLayoutsLazy[] =
5293 VK_IMAGE_LAYOUT_GENERAL,
5294 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5295 VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL,
5296 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
5299 const VkImageLayout subpassLayouts[] =
5301 VK_IMAGE_LAYOUT_GENERAL,
5302 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
5305 const VkImageLayout depthStencilLayouts[] =
5307 VK_IMAGE_LAYOUT_GENERAL,
5308 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
5311 const TestConfig::RenderTypes renderCommands[] =
5313 TestConfig::RENDERTYPES_NONE,
5314 TestConfig::RENDERTYPES_CLEAR,
5315 TestConfig::RENDERTYPES_DRAW,
5316 TestConfig::RENDERTYPES_CLEAR|TestConfig::RENDERTYPES_DRAW,
5319 const TestConfig::CommandBufferTypes commandBuffers[] =
5321 TestConfig::COMMANDBUFFERTYPES_INLINE,
5322 TestConfig::COMMANDBUFFERTYPES_SECONDARY,
5323 TestConfig::COMMANDBUFFERTYPES_INLINE|TestConfig::COMMANDBUFFERTYPES_SECONDARY
5326 const TestConfig::ImageMemory imageMemories[] =
5328 TestConfig::IMAGEMEMORY_STRICT,
5329 TestConfig::IMAGEMEMORY_LAZY,
5330 TestConfig::IMAGEMEMORY_STRICT|TestConfig::IMAGEMEMORY_LAZY
5333 const UVec2 targetSizes[] =
5339 const UVec2 renderPositions[] =
5345 const UVec2 renderSizes[] =
5351 tcu::TestContext& testCtx (group->getTestContext());
5352 bool useDynamicRendering (testConfigExternal.renderingType == RENDERING_TYPE_DYNAMIC_RENDERING);
5353 de::Random rng (1433774382u);
5355 for (size_t attachmentCountNdx = 0; attachmentCountNdx < DE_LENGTH_OF_ARRAY(attachmentCounts); attachmentCountNdx++)
5357 const deUint32 attachmentCount = attachmentCounts[attachmentCountNdx];
5358 const deUint32 testCaseCount = (attachmentCount == 1 ? 100 : 200);
5359 de::MovePtr<tcu::TestCaseGroup> attachmentCountGroup (new tcu::TestCaseGroup(testCtx, de::toString(attachmentCount).c_str(), de::toString(attachmentCount).c_str()));
5361 for (size_t testCaseNdx = 0; testCaseNdx < testCaseCount; testCaseNdx++)
5363 const bool useDepthStencil = rng.getBool();
5364 const TestConfig::ImageMemory imageMemory = rng.choose<TestConfig::ImageMemory>(DE_ARRAY_BEGIN(imageMemories), DE_ARRAY_END(imageMemories));
5365 VkImageLayout depthStencilLayout = VK_IMAGE_LAYOUT_GENERAL;
5366 vector<Attachment> attachments;
5367 vector<AttachmentReference> colorAttachmentReferences;
5369 // we want to make sure that dynamic rendering test cases have corresponding renderpass
5370 // cases as this will allow drivers to easily compare GPU batches; since configurations
5371 // for those tests are generated we need to generate configurations for all cases
5372 // even when we know earlier that for dynamic rendering we will skip it
5373 bool executeForDynamicRendering = true;
5375 for (size_t attachmentNdx = 0; attachmentNdx < attachmentCount; attachmentNdx++)
5377 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
5378 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreColorFormats), DE_ARRAY_END(s_coreColorFormats));
5379 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5380 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5382 const VkImageLayout initialLayout = (imageMemory == TestConfig::IMAGEMEMORY_STRICT)
5383 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts))
5384 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayoutsLazy), DE_ARRAY_END(initialAndFinalColorLayoutsLazy));
5385 VkImageLayout finalizeLayout = (imageMemory == TestConfig::IMAGEMEMORY_STRICT)
5386 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts))
5387 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayoutsLazy), DE_ARRAY_END(initialAndFinalColorLayoutsLazy));
5388 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayouts), DE_ARRAY_END(subpassLayouts));
5390 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5391 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5393 if (useDynamicRendering)
5395 // with renderpass we can have automatic layout transitions; to do the same with dynamic rendering cases
5396 // we would need to add addtional barries but since those tests won't add coverage we are skipping them
5397 if ((initialLayout == VK_IMAGE_LAYOUT_GENERAL) ||
5398 (initialLayout == VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL))
5399 finalizeLayout = initialLayout;
5401 executeForDynamicRendering = false;
5404 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5405 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
5408 if (useDepthStencil)
5410 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
5411 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreDepthStencilFormats), DE_ARRAY_END(s_coreDepthStencilFormats));
5412 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5413 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5415 const VkImageLayout initialLayout = (imageMemory == TestConfig::IMAGEMEMORY_STRICT)
5416 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
5417 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayoutsLazy), DE_ARRAY_END(initialAndFinalDepthStencilLayoutsLazy));
5418 VkImageLayout finalizeLayout = (imageMemory == TestConfig::IMAGEMEMORY_STRICT)
5419 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
5420 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayoutsLazy), DE_ARRAY_END(initialAndFinalDepthStencilLayoutsLazy));
5422 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5423 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5425 if (useDynamicRendering)
5427 if ((initialLayout == VK_IMAGE_LAYOUT_GENERAL) ||
5428 (initialLayout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL) ||
5429 (initialLayout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL))
5430 finalizeLayout = initialLayout;
5432 executeForDynamicRendering = false;
5435 depthStencilLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(depthStencilLayouts), DE_ARRAY_END(depthStencilLayouts));
5436 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5440 const TestConfig::RenderTypes render = rng.choose<TestConfig::RenderTypes>(DE_ARRAY_BEGIN(renderCommands), DE_ARRAY_END(renderCommands));
5441 const TestConfig::CommandBufferTypes commandBuffer = rng.choose<TestConfig::CommandBufferTypes>(DE_ARRAY_BEGIN(commandBuffers), DE_ARRAY_END(commandBuffers));
5442 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>()));
5443 const vector<SubpassDependency> deps;
5444 const string testCaseName = de::toString(attachmentCountNdx * testCaseCount + testCaseNdx);
5445 const RenderPass renderPass (attachments, subpasses, deps);
5446 const UVec2 targetSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(targetSizes), DE_ARRAY_END(targetSizes));
5447 const UVec2 renderPos = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderPositions), DE_ARRAY_END(renderPositions));
5448 const UVec2 renderSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderSizes), DE_ARRAY_END(renderSizes));
5450 // skip dynamic rendering cases (that don't add coverage)
5451 // this can be done not earlier than after grabbing all random numbers as
5452 // we need to make sure that those tests that will be created for dynamic
5453 // rendering have corresponding renderpass tests with the same name
5454 if (useDynamicRendering && !executeForDynamicRendering)
5457 const TestConfig testConfig (renderPass,
5467 testConfigExternal.allocationKind,
5468 testConfigExternal.renderingType);
5470 addFunctionCaseWithPrograms<TestConfig>(attachmentCountGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, testConfig);
5474 group->addChild(attachmentCountGroup.release());
5478 void addAttachmentWriteMaskTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
5480 const deUint32 attachmentCounts[] = { 1, 2, 3, 4, 8 };
5482 const VkFormat attachmentFormats[] =
5484 VK_FORMAT_R8G8B8A8_UINT,
5485 VK_FORMAT_R8G8B8A8_UNORM,
5486 VK_FORMAT_R5G6B5_UNORM_PACK16,
5487 VK_FORMAT_R8G8_UNORM
5490 tcu::TestContext& testCtx = group->getTestContext();
5492 for (deUint32 attachmentCountNdx = 0; attachmentCountNdx < DE_LENGTH_OF_ARRAY(attachmentCounts); attachmentCountNdx++)
5494 const deUint32 attachmentCount = attachmentCounts[attachmentCountNdx];
5495 const string groupName = "attachment_count_" + de::toString(attachmentCount);
5497 de::MovePtr<tcu::TestCaseGroup> attachmentCountGroup(new tcu::TestCaseGroup(testCtx, groupName.c_str(), de::toString(attachmentCount).c_str()));
5499 for (deUint32 drawStartNdx = 0; drawStartNdx < (attachmentCount); drawStartNdx++)
5501 deUint32 formatNdx = 0;
5502 vector<Attachment> attachments;
5503 vector<AttachmentReference> colorAttachmentReferences;
5505 for (deUint32 attachmentNdx = 0; attachmentNdx < attachmentCount; attachmentNdx++)
5507 const VkFormat format = attachmentFormats[formatNdx];
5508 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
5509 const VkAttachmentLoadOp loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
5510 const VkAttachmentStoreOp storeOp = VK_ATTACHMENT_STORE_OP_STORE;
5511 const VkAttachmentLoadOp stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
5512 const VkAttachmentStoreOp stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
5513 const VkImageLayout initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
5514 const VkImageLayout finalizeLayout = (testConfigExternal.renderingType == RENDERING_TYPE_DYNAMIC_RENDERING)
5515 ? initialLayout : VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
5516 const VkImageLayout subpassLayout = VK_IMAGE_LAYOUT_GENERAL;
5518 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5519 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
5521 if (++formatNdx == DE_LENGTH_OF_ARRAY(attachmentFormats))
5526 const VkImageLayout depthStencilLayout = VK_IMAGE_LAYOUT_GENERAL;
5527 const vector<Subpass> subpass (1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u, vector<AttachmentReference>(), colorAttachmentReferences, vector<AttachmentReference>(), AttachmentReference(VK_ATTACHMENT_UNUSED, depthStencilLayout), vector<deUint32>()));
5528 const vector<SubpassDependency> deps;
5530 const string testCaseName = "start_index_" + de::toString(drawStartNdx);
5531 const RenderPass renderPass (attachments, subpass, deps);
5533 const TestConfig::RenderTypes render = TestConfig::RENDERTYPES_DRAW;
5534 const TestConfig::CommandBufferTypes commandBuffer = TestConfig::COMMANDBUFFERTYPES_INLINE;
5535 const TestConfig::ImageMemory imageMemory = TestConfig::IMAGEMEMORY_LAZY;
5536 const UVec2 targetSize = UVec2(64, 64);
5537 const UVec2 renderPos = UVec2(0, 0);
5538 const UVec2 renderSize = UVec2(64, 64);
5539 const deBool useFormatCompCount = DE_TRUE;
5540 const vector<DeviceCoreFeature> requiredFeatures = {DEVICE_CORE_FEATURE_INDEPENDENT_BLEND};
5541 const TestConfig testConfig (renderPass,
5551 testConfigExternal.allocationKind,
5552 testConfigExternal.renderingType,
5555 addFunctionCaseWithPrograms<TestConfig>(attachmentCountGroup.get(), testCaseName.c_str(), testCaseName.c_str(), checkSupport, createTestShaders, renderPassTest, testConfig);
5559 group->addChild(attachmentCountGroup.release());
5563 template<typename T>
5564 T chooseRandom (de::Random& rng, const set<T>& values)
5566 size_t ndx = ((size_t)rng.getUint32()) % values.size();
5567 typename set<T>::const_iterator iter = values.begin();
5569 for (; ndx > 0; ndx--)
5575 void addAttachmentAllocationTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
5577 const deUint32 attachmentCounts[] = { 4, 8 };
5578 const VkAttachmentLoadOp loadOps[] =
5580 VK_ATTACHMENT_LOAD_OP_LOAD,
5581 VK_ATTACHMENT_LOAD_OP_CLEAR,
5582 VK_ATTACHMENT_LOAD_OP_DONT_CARE
5585 const VkAttachmentStoreOp storeOps[] =
5587 VK_ATTACHMENT_STORE_OP_STORE,
5588 VK_ATTACHMENT_STORE_OP_DONT_CARE
5591 const VkImageLayout initialAndFinalColorLayouts[] =
5593 VK_IMAGE_LAYOUT_GENERAL,
5594 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5595 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
5596 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
5597 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
5600 const VkImageLayout initialAndFinalDepthStencilLayouts[] =
5602 VK_IMAGE_LAYOUT_GENERAL,
5603 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5604 VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL,
5605 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
5606 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
5607 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
5610 const VkImageLayout subpassLayoutsColor[] =
5612 VK_IMAGE_LAYOUT_GENERAL,
5613 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
5616 const VkImageLayout subpassLayoutsDepthStencil[] =
5618 VK_IMAGE_LAYOUT_GENERAL,
5619 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
5622 const VkImageLayout subpassLayoutsInput[] =
5624 VK_IMAGE_LAYOUT_GENERAL,
5625 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
5630 // Each pass uses one more attachmen than previous one
5631 ALLOCATIONTYPE_GROW,
5632 // Each pass uses one less attachment than previous one
5633 ALLOCATIONTYPE_SHRINK,
5634 // Each pass drops one attachment and picks up new one
5635 ALLOCATIONTYPE_ROLL,
5636 // Start by growing and end by shrinking
5637 ALLOCATIONTYPE_GROW_SHRINK,
5638 // Each subpass has single input and single output attachment
5639 ALLOCATIONTYPE_IO_CHAIN,
5640 // Each subpass has multiple inputs and multiple outputs attachment
5641 ALLOCATIONTYPE_IO_GENERIC
5644 const AllocationType allocationTypes[] =
5646 ALLOCATIONTYPE_GROW,
5647 ALLOCATIONTYPE_SHRINK,
5648 ALLOCATIONTYPE_ROLL,
5649 ALLOCATIONTYPE_GROW_SHRINK,
5650 ALLOCATIONTYPE_IO_CHAIN,
5651 ALLOCATIONTYPE_IO_GENERIC
5654 const char* const allocationTypeStr[] =
5660 "input_output_chain",
5664 const TestConfig::RenderTypes renderCommands[] =
5666 TestConfig::RENDERTYPES_NONE,
5667 TestConfig::RENDERTYPES_CLEAR,
5668 TestConfig::RENDERTYPES_DRAW,
5669 TestConfig::RENDERTYPES_CLEAR|TestConfig::RENDERTYPES_DRAW,
5672 const TestConfig::CommandBufferTypes commandBuffers[] =
5674 TestConfig::COMMANDBUFFERTYPES_INLINE,
5675 TestConfig::COMMANDBUFFERTYPES_SECONDARY,
5676 TestConfig::COMMANDBUFFERTYPES_INLINE|TestConfig::COMMANDBUFFERTYPES_SECONDARY
5679 const TestConfig::ImageMemory imageMemories[] =
5681 TestConfig::IMAGEMEMORY_STRICT,
5682 TestConfig::IMAGEMEMORY_LAZY,
5683 TestConfig::IMAGEMEMORY_STRICT|TestConfig::IMAGEMEMORY_LAZY
5686 const UVec2 targetSizes[] =
5692 const UVec2 renderPositions[] =
5698 const UVec2 renderSizes[] =
5704 tcu::TestContext& testCtx = group->getTestContext();
5705 de::Random rng (3700649827u);
5707 for (size_t allocationTypeNdx = 0; allocationTypeNdx < DE_LENGTH_OF_ARRAY(allocationTypes); allocationTypeNdx++)
5709 const AllocationType allocationType = allocationTypes[allocationTypeNdx];
5710 const size_t testCaseCount = 100;
5711 de::MovePtr<tcu::TestCaseGroup> allocationTypeGroup (new tcu::TestCaseGroup(testCtx, allocationTypeStr[allocationTypeNdx], allocationTypeStr[allocationTypeNdx]));
5713 for (size_t testCaseNdx = 0; testCaseNdx < testCaseCount; testCaseNdx++)
5715 if (allocationType == ALLOCATIONTYPE_IO_GENERIC)
5717 const deUint32 attachmentCount = 4u + rng.getUint32() % 31u;
5718 const deUint32 subpassCount = 4u + rng.getUint32() % 31u;
5719 vector<Attachment> attachments;
5721 set<deUint32> definedAttachments;
5723 vector<Subpass> subpasses;
5724 set<deUint32> colorAttachments;
5725 set<deUint32> depthStencilAttachments;
5727 for (deUint32 attachmentIndex = 0; attachmentIndex < attachmentCount; attachmentIndex++)
5729 const bool isDepthStencilAttachment = rng.getFloat() < 0.01f;
5730 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
5731 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5732 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5734 const VkImageLayout initialLayout = isDepthStencilAttachment
5735 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
5736 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
5737 const VkImageLayout finalizeLayout = isDepthStencilAttachment
5738 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
5739 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
5741 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5742 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5744 if (isDepthStencilAttachment)
5746 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreDepthStencilFormats), DE_ARRAY_END(s_coreDepthStencilFormats));
5748 if (loadOp == VK_ATTACHMENT_LOAD_OP_LOAD || loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR
5749 || stencilLoadOp == VK_ATTACHMENT_LOAD_OP_LOAD || stencilLoadOp == VK_ATTACHMENT_LOAD_OP_CLEAR)
5750 definedAttachments.insert(attachmentIndex);
5752 depthStencilAttachments.insert(attachmentIndex);
5754 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5758 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreColorFormats), DE_ARRAY_END(s_coreColorFormats));
5760 if (loadOp == VK_ATTACHMENT_LOAD_OP_LOAD || loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR)
5761 definedAttachments.insert(attachmentIndex);
5763 colorAttachments.insert(attachmentIndex);
5765 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5768 vector<Maybe<deUint32> > lastUseOfAttachment (attachments.size(), tcu::Nothing);
5769 vector<SubpassDependency> deps;
5771 for (deUint32 subpassIndex = 0; subpassIndex < subpassCount; subpassIndex++)
5773 const deUint32 colorAttachmentCount = depthStencilAttachments.empty()
5774 ? 1 + rng.getUint32() % de::min(4u, (deUint32)colorAttachments.size())
5775 : rng.getUint32() % (de::min(4u, (deUint32)colorAttachments.size()) + 1u);
5776 const deUint32 inputAttachmentCount = rng.getUint32() % (deUint32)(de::min<size_t>(4, definedAttachments.size()) + 1);
5777 const bool useDepthStencilAttachment = !depthStencilAttachments.empty() && (colorAttachmentCount == 0 || rng.getBool());
5778 std::vector<deUint32> subpassColorAttachments (colorAttachmentCount);
5779 std::vector<deUint32> subpassInputAttachments (inputAttachmentCount);
5780 Maybe<deUint32> depthStencilAttachment (useDepthStencilAttachment
5781 ? just(chooseRandom(rng, depthStencilAttachments))
5783 std::vector<deUint32> subpassPreserveAttachments;
5785 rng.choose(colorAttachments.begin(), colorAttachments.end(), subpassColorAttachments.begin(), colorAttachmentCount);
5786 rng.choose(definedAttachments.begin(), definedAttachments.end(), subpassInputAttachments.begin(), inputAttachmentCount);
5788 for (size_t colorAttachmentNdx = 0; colorAttachmentNdx < subpassColorAttachments.size(); colorAttachmentNdx++)
5789 definedAttachments.insert(subpassColorAttachments[colorAttachmentNdx]);
5791 if (depthStencilAttachment)
5792 definedAttachments.insert(*depthStencilAttachment);
5795 std::vector<AttachmentReference> inputAttachmentReferences;
5796 std::vector<AttachmentReference> colorAttachmentReferences;
5797 AttachmentReference depthStencilAttachmentReference (VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL);
5799 for (size_t colorAttachmentNdx = 0; colorAttachmentNdx < subpassColorAttachments.size(); colorAttachmentNdx++)
5801 const deUint32 colorAttachmentIndex = subpassColorAttachments[colorAttachmentNdx];
5803 if (lastUseOfAttachment[colorAttachmentIndex])
5805 deBool foundDuplicate = false;
5807 const deUint32 srcPass = *lastUseOfAttachment[colorAttachmentIndex];
5808 const deUint32 dstPass = subpassIndex;
5809 const VkDependencyFlags dependencyFlags = rng.getBool() ? (VkDependencyFlags) VK_DEPENDENCY_BY_REGION_BIT : 0u;
5811 const SubpassDependency newDependency(srcPass, dstPass,
5812 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5813 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5814 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5815 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5817 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5818 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5819 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5820 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5822 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
5823 VK_ACCESS_COLOR_ATTACHMENT_READ_BIT,
5827 for (SubpassDependency& dependency : deps)
5829 if (dependency.getSrcPass() == srcPass && dependency.getDstPass() == dstPass)
5831 const VkAccessFlags newDstFlags = dependency.getDstAccessMask() | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT;
5832 dependency.setDstAccessMask(newDstFlags);
5833 foundDuplicate = true;
5838 if (!foundDuplicate)
5840 deps.push_back(newDependency);
5844 lastUseOfAttachment[colorAttachmentIndex] = just(subpassIndex);
5846 colorAttachmentReferences.push_back(AttachmentReference((deUint32)subpassColorAttachments[colorAttachmentNdx], VK_IMAGE_LAYOUT_GENERAL));
5849 for (size_t inputAttachmentNdx = 0; inputAttachmentNdx < subpassInputAttachments.size(); inputAttachmentNdx++)
5851 const deUint32 inputAttachmentIndex = subpassInputAttachments[inputAttachmentNdx];
5853 if(lastUseOfAttachment[inputAttachmentIndex])
5855 deBool foundDuplicate = false;
5857 const deUint32 srcPass = *lastUseOfAttachment[inputAttachmentIndex];
5858 const deUint32 dstPass = subpassIndex;
5859 const VkDependencyFlags dependencyFlags = ((srcPass == subpassIndex) || rng.getBool()) ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u;
5861 const SubpassDependency newDependency(srcPass, dstPass,
5862 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5863 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5864 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5865 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5867 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5868 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5869 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5870 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5872 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
5873 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5876 for (SubpassDependency& dependency : deps)
5878 if (dependency.getSrcPass() == srcPass && dependency.getDstPass() == dstPass)
5880 const VkAccessFlags newSrcFlags = dependency.getSrcAccessMask() | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
5881 const VkAccessFlags newDstFlags = dependency.getDstAccessMask() | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT;
5882 dependency.setDstAccessMask(newSrcFlags);
5883 dependency.setDstAccessMask(newDstFlags);
5884 foundDuplicate = true;
5889 if (!foundDuplicate)
5891 deps.push_back(newDependency);
5894 lastUseOfAttachment[inputAttachmentIndex] = just(subpassIndex);
5896 VkImageAspectFlags aspect = 0u;
5897 if (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2)
5899 bool col = colorAttachments.find(inputAttachmentIndex) != colorAttachments.end();
5900 aspect = col ? VK_IMAGE_ASPECT_COLOR_BIT : VK_IMAGE_ASPECT_DEPTH_BIT;
5902 inputAttachmentReferences.push_back(AttachmentReference((deUint32)subpassInputAttachments[inputAttachmentNdx], VK_IMAGE_LAYOUT_GENERAL, aspect));
5906 if (depthStencilAttachment)
5908 if (lastUseOfAttachment[*depthStencilAttachment])
5910 deBool foundDuplicate = false;
5912 const deUint32 srcPass = *lastUseOfAttachment[*depthStencilAttachment];
5913 const deUint32 dstPass = subpassIndex;
5914 const VkDependencyFlags dependencyFlags = ((srcPass == subpassIndex) || rng.getBool()) ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u;
5916 const SubpassDependency newDependency(srcPass, dstPass,
5917 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5918 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5919 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5920 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5922 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5923 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5924 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5925 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5927 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
5928 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT
5929 | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5932 for (SubpassDependency& dependency : deps)
5934 if (dependency.getSrcPass() == srcPass && dependency.getDstPass() == dstPass)
5936 const VkAccessFlags newSrcFlags = dependency.getSrcAccessMask() | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
5937 const VkAccessFlags newDstFlags = dependency.getDstAccessMask() | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT;
5938 dependency.setDstAccessMask(newSrcFlags);
5939 dependency.setDstAccessMask(newDstFlags);
5940 foundDuplicate = true;
5945 if (!foundDuplicate)
5947 deps.push_back(newDependency);
5951 lastUseOfAttachment[*depthStencilAttachment] = just(subpassIndex);
5953 depthStencilAttachmentReference = AttachmentReference(*depthStencilAttachment, VK_IMAGE_LAYOUT_GENERAL);
5956 depthStencilAttachmentReference = AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL);
5958 vector<deUint32> preserveAttachments;
5959 for (deUint32 attachmentIndex = 0; attachmentIndex < (deUint32)attachments.size(); attachmentIndex++)
5961 if (lastUseOfAttachment[attachmentIndex] && (*lastUseOfAttachment[attachmentIndex]) != subpassIndex)
5962 preserveAttachments.push_back(attachmentIndex);
5965 // Use random image layout when possible
5966 for (size_t colorRefIdx = 0; colorRefIdx < colorAttachmentReferences.size(); ++colorRefIdx)
5968 bool usedAsInput = false;
5969 for (size_t inputRefIdx = 0; inputRefIdx < inputAttachmentReferences.size(); ++inputRefIdx)
5970 if (colorAttachmentReferences[colorRefIdx].getAttachment() == inputAttachmentReferences[inputRefIdx].getAttachment())
5974 colorAttachmentReferences[colorRefIdx].setImageLayout(rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor)));
5976 for (size_t inputRefIdx = 0; inputRefIdx < inputAttachmentReferences.size(); ++inputRefIdx)
5978 bool usedAsDepthStencil = inputAttachmentReferences[inputRefIdx].getAttachment() == depthStencilAttachmentReference.getAttachment();
5979 bool usedAsColor = false;
5980 for (size_t colorRefIdx = 0; colorRefIdx < colorAttachmentReferences.size(); ++colorRefIdx)
5981 if (inputAttachmentReferences[inputRefIdx].getAttachment() == colorAttachmentReferences[colorRefIdx].getAttachment())
5984 if (!usedAsColor && !usedAsDepthStencil)
5985 inputAttachmentReferences[inputRefIdx].setImageLayout(rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsInput), DE_ARRAY_END(subpassLayoutsInput)));
5988 bool usedAsInput = false;
5989 for (size_t inputRefIdx = 0; inputRefIdx < inputAttachmentReferences.size(); ++inputRefIdx)
5990 if (depthStencilAttachmentReference.getAttachment() == inputAttachmentReferences[inputRefIdx].getAttachment())
5994 depthStencilAttachmentReference.setImageLayout(rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsDepthStencil), DE_ARRAY_END(subpassLayoutsDepthStencil)));
5997 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
5998 inputAttachmentReferences,
5999 colorAttachmentReferences,
6000 vector<AttachmentReference>(),
6001 depthStencilAttachmentReference,
6002 preserveAttachments));
6006 const TestConfig::RenderTypes render = rng.choose<TestConfig::RenderTypes>(DE_ARRAY_BEGIN(renderCommands), DE_ARRAY_END(renderCommands));
6007 const TestConfig::CommandBufferTypes commandBuffer = rng.choose<TestConfig::CommandBufferTypes>(DE_ARRAY_BEGIN(commandBuffers), DE_ARRAY_END(commandBuffers));
6008 const TestConfig::ImageMemory imageMemory = rng.choose<TestConfig::ImageMemory>(DE_ARRAY_BEGIN(imageMemories), DE_ARRAY_END(imageMemories));
6010 const string testCaseName = de::toString(testCaseNdx);
6011 const UVec2 targetSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(targetSizes), DE_ARRAY_END(targetSizes));
6012 const UVec2 renderPos = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderPositions), DE_ARRAY_END(renderPositions));
6013 const UVec2 renderSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderSizes), DE_ARRAY_END(renderSizes));
6015 const RenderPass renderPass (attachments, subpasses, deps);
6016 const TestConfig testConfig (renderPass,
6026 testConfigExternal.allocationKind,
6027 testConfigExternal.renderingType);
6029 addFunctionCaseWithPrograms<TestConfig>(allocationTypeGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, testConfig);
6034 const deUint32 attachmentCount = rng.choose<deUint32>(DE_ARRAY_BEGIN(attachmentCounts), DE_ARRAY_END(attachmentCounts));
6035 vector<Attachment> attachments;
6036 vector<Subpass> subpasses;
6038 for (size_t attachmentNdx = 0; attachmentNdx < attachmentCount; attachmentNdx++)
6040 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
6041 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreColorFormats), DE_ARRAY_END(s_coreColorFormats));
6042 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
6043 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
6045 const VkImageLayout initialLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
6046 const VkImageLayout finalizeLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
6048 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
6049 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
6051 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
6054 if (allocationType == ALLOCATIONTYPE_GROW)
6056 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
6058 vector<AttachmentReference> colorAttachmentReferences;
6060 for (size_t attachmentNdx = 0; attachmentNdx < subpassNdx + 1; attachmentNdx++)
6062 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6064 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
6067 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6068 vector<AttachmentReference>(),
6069 colorAttachmentReferences,
6070 vector<AttachmentReference>(),
6071 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6072 vector<deUint32>()));
6075 else if (allocationType == ALLOCATIONTYPE_SHRINK)
6077 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
6079 vector<AttachmentReference> colorAttachmentReferences;
6081 for (size_t attachmentNdx = 0; attachmentNdx < (attachmentCount - subpassNdx); attachmentNdx++)
6083 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6085 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
6088 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6089 vector<AttachmentReference>(),
6090 colorAttachmentReferences,
6091 vector<AttachmentReference>(),
6092 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6093 vector<deUint32>()));
6096 else if (allocationType == ALLOCATIONTYPE_ROLL)
6098 for (size_t subpassNdx = 0; subpassNdx < attachmentCount / 2; subpassNdx++)
6100 vector<AttachmentReference> colorAttachmentReferences;
6102 for (size_t attachmentNdx = 0; attachmentNdx < attachmentCount / 2; attachmentNdx++)
6104 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6106 colorAttachmentReferences.push_back(AttachmentReference((deUint32)(subpassNdx + attachmentNdx), subpassLayout));
6109 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6110 vector<AttachmentReference>(),
6111 colorAttachmentReferences,
6112 vector<AttachmentReference>(),
6113 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6114 vector<deUint32>()));
6117 else if (allocationType == ALLOCATIONTYPE_GROW_SHRINK)
6119 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
6121 vector<AttachmentReference> colorAttachmentReferences;
6123 for (size_t attachmentNdx = 0; attachmentNdx < subpassNdx + 1; attachmentNdx++)
6125 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6127 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
6130 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6131 vector<AttachmentReference>(),
6132 colorAttachmentReferences,
6133 vector<AttachmentReference>(),
6134 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6135 vector<deUint32>()));
6137 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
6139 vector<AttachmentReference> colorAttachmentReferences;
6141 for (size_t attachmentNdx = 0; attachmentNdx < (attachmentCount - subpassNdx); attachmentNdx++)
6143 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6145 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
6148 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6149 vector<AttachmentReference>(),
6150 colorAttachmentReferences,
6151 vector<AttachmentReference>(),
6152 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6153 vector<deUint32>()));
6156 else if (allocationType == ALLOCATIONTYPE_IO_CHAIN)
6158 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6159 vector<AttachmentReference>(),
6160 vector<AttachmentReference>(1, AttachmentReference(0, rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor)))),
6161 vector<AttachmentReference>(),
6162 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6163 vector<deUint32>()));
6165 for (size_t subpassNdx = 1; subpassNdx < attachmentCount; subpassNdx++)
6167 const VkImageAspectFlags inputAttachmentAspectMask = (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2) ? VK_IMAGE_ASPECT_COLOR_BIT : static_cast<VkImageAspectFlagBits>(0);
6168 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6169 vector<AttachmentReference>(1, AttachmentReference((deUint32)(subpassNdx - 1), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
6170 vector<AttachmentReference>(1, AttachmentReference((deUint32)(subpassNdx), rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor)))),
6171 vector<AttachmentReference>(),
6172 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6173 vector<deUint32>()));
6177 DE_FATAL("Unknown allocation type");
6180 const TestConfig::RenderTypes render = rng.choose<TestConfig::RenderTypes>(DE_ARRAY_BEGIN(renderCommands), DE_ARRAY_END(renderCommands));
6181 const TestConfig::CommandBufferTypes commandBuffer = rng.choose<TestConfig::CommandBufferTypes>(DE_ARRAY_BEGIN(commandBuffers), DE_ARRAY_END(commandBuffers));
6182 const TestConfig::ImageMemory imageMemory = rng.choose<TestConfig::ImageMemory>(DE_ARRAY_BEGIN(imageMemories), DE_ARRAY_END(imageMemories));
6184 const string testCaseName = de::toString(testCaseNdx);
6185 const UVec2 targetSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(targetSizes), DE_ARRAY_END(targetSizes));
6186 const UVec2 renderPos = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderPositions), DE_ARRAY_END(renderPositions));
6187 const UVec2 renderSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderSizes), DE_ARRAY_END(renderSizes));
6189 vector<SubpassDependency> deps;
6191 for (size_t subpassNdx = 0; subpassNdx < subpasses.size() - 1; subpassNdx++)
6193 const bool byRegion = rng.getBool();
6194 deps.push_back(SubpassDependency((deUint32)subpassNdx, (deUint32)subpassNdx + 1,
6195 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
6196 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
6197 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
6198 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6200 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
6201 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
6202 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
6203 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6205 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6206 (VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT),
6208 byRegion ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u));
6211 const RenderPass renderPass (attachments, subpasses, deps);
6212 const TestConfig testConfig (renderPass,
6222 testConfigExternal.allocationKind,
6223 testConfigExternal.renderingType);
6225 addFunctionCaseWithPrograms<TestConfig>(allocationTypeGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, testConfig);
6229 group->addChild(allocationTypeGroup.release());
6233 void addSimpleTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
6235 const UVec2 targetSize (64, 64);
6236 const UVec2 renderPos (0, 0);
6237 const UVec2 renderSize (64, 64);
6241 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6242 VK_SAMPLE_COUNT_1_BIT,
6243 VK_ATTACHMENT_LOAD_OP_CLEAR,
6244 VK_ATTACHMENT_STORE_OP_STORE,
6245 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6246 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6247 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6248 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6249 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6251 vector<AttachmentReference>(),
6252 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6253 vector<AttachmentReference>(),
6254 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6255 vector<deUint32>())),
6256 vector<SubpassDependency>());
6257 const TestConfig testConfig (renderPass,
6258 TestConfig::RENDERTYPES_DRAW,
6259 TestConfig::COMMANDBUFFERTYPES_INLINE,
6260 TestConfig::IMAGEMEMORY_STRICT,
6267 testConfigExternal.allocationKind,
6268 testConfigExternal.renderingType);
6270 addFunctionCaseWithPrograms<TestConfig>(group, "color", "Single color attachment case.", createTestShaders, renderPassTest, testConfig);
6275 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_X8_D24_UNORM_PACK32,
6276 VK_SAMPLE_COUNT_1_BIT,
6277 VK_ATTACHMENT_LOAD_OP_CLEAR,
6278 VK_ATTACHMENT_STORE_OP_STORE,
6279 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6280 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6281 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6282 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6283 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6285 vector<AttachmentReference>(),
6286 vector<AttachmentReference>(),
6287 vector<AttachmentReference>(),
6288 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6289 vector<deUint32>())),
6290 vector<SubpassDependency>());
6291 const TestConfig testConfig (renderPass,
6292 TestConfig::RENDERTYPES_DRAW,
6293 TestConfig::COMMANDBUFFERTYPES_INLINE,
6294 TestConfig::IMAGEMEMORY_STRICT,
6301 testConfigExternal.allocationKind,
6302 testConfigExternal.renderingType);
6304 addFunctionCaseWithPrograms<TestConfig>(group, "depth", "Single depth attachment case.", createTestShaders, renderPassTest, testConfig);
6309 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_S8_UINT,
6310 VK_SAMPLE_COUNT_1_BIT,
6311 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6312 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6313 VK_ATTACHMENT_LOAD_OP_CLEAR,
6314 VK_ATTACHMENT_STORE_OP_STORE,
6315 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6316 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6317 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6319 vector<AttachmentReference>(),
6320 vector<AttachmentReference>(),
6321 vector<AttachmentReference>(),
6322 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6323 vector<deUint32>())),
6324 vector<SubpassDependency>());
6325 const TestConfig testConfig (renderPass,
6326 TestConfig::RENDERTYPES_DRAW,
6327 TestConfig::COMMANDBUFFERTYPES_INLINE,
6328 TestConfig::IMAGEMEMORY_STRICT,
6335 testConfigExternal.allocationKind,
6336 testConfigExternal.renderingType);
6338 addFunctionCaseWithPrograms<TestConfig>(group, "stencil", "Single stencil attachment case.", createTestShaders, renderPassTest, testConfig);
6343 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_D24_UNORM_S8_UINT,
6344 VK_SAMPLE_COUNT_1_BIT,
6345 VK_ATTACHMENT_LOAD_OP_CLEAR,
6346 VK_ATTACHMENT_STORE_OP_STORE,
6347 VK_ATTACHMENT_LOAD_OP_CLEAR,
6348 VK_ATTACHMENT_STORE_OP_STORE,
6349 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6350 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6351 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6353 vector<AttachmentReference>(),
6354 vector<AttachmentReference>(),
6355 vector<AttachmentReference>(),
6356 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6357 vector<deUint32>())),
6358 vector<SubpassDependency>());
6359 const TestConfig testConfig (renderPass,
6360 TestConfig::RENDERTYPES_DRAW,
6361 TestConfig::COMMANDBUFFERTYPES_INLINE,
6362 TestConfig::IMAGEMEMORY_STRICT,
6369 testConfigExternal.allocationKind,
6370 testConfigExternal.renderingType);
6372 addFunctionCaseWithPrograms<TestConfig>(group, "depth_stencil", "Single depth stencil attachment case.", createTestShaders, renderPassTest, testConfig);
6377 const Attachment attachments[] =
6379 Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6380 VK_SAMPLE_COUNT_1_BIT,
6381 VK_ATTACHMENT_LOAD_OP_CLEAR,
6382 VK_ATTACHMENT_STORE_OP_STORE,
6383 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6384 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6385 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6386 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL),
6387 Attachment(VK_FORMAT_X8_D24_UNORM_PACK32,
6388 VK_SAMPLE_COUNT_1_BIT,
6389 VK_ATTACHMENT_LOAD_OP_CLEAR,
6390 VK_ATTACHMENT_STORE_OP_STORE,
6391 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6392 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6393 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6394 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6397 const RenderPass renderPass (vector<Attachment>(DE_ARRAY_BEGIN(attachments), DE_ARRAY_END(attachments)),
6398 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6400 vector<AttachmentReference>(),
6401 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6402 vector<AttachmentReference>(),
6403 AttachmentReference(1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6404 vector<deUint32>())),
6405 vector<SubpassDependency>());
6406 const TestConfig testConfig (renderPass,
6407 TestConfig::RENDERTYPES_DRAW,
6408 TestConfig::COMMANDBUFFERTYPES_INLINE,
6409 TestConfig::IMAGEMEMORY_STRICT,
6416 testConfigExternal.allocationKind,
6417 testConfigExternal.renderingType);
6419 addFunctionCaseWithPrograms<TestConfig>(group, "color_depth", "Color and depth attachment case.", createTestShaders, renderPassTest, testConfig);
6424 const Attachment attachments[] =
6426 Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6427 VK_SAMPLE_COUNT_1_BIT,
6428 VK_ATTACHMENT_LOAD_OP_CLEAR,
6429 VK_ATTACHMENT_STORE_OP_STORE,
6430 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6431 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6432 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6433 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL),
6434 Attachment(VK_FORMAT_S8_UINT,
6435 VK_SAMPLE_COUNT_1_BIT,
6436 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6437 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6438 VK_ATTACHMENT_LOAD_OP_CLEAR,
6439 VK_ATTACHMENT_STORE_OP_STORE,
6440 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6441 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6444 const RenderPass renderPass (vector<Attachment>(DE_ARRAY_BEGIN(attachments), DE_ARRAY_END(attachments)),
6445 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6447 vector<AttachmentReference>(),
6448 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6449 vector<AttachmentReference>(),
6450 AttachmentReference(1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6451 vector<deUint32>())),
6452 vector<SubpassDependency>());
6453 const TestConfig testConfig (renderPass,
6454 TestConfig::RENDERTYPES_DRAW,
6455 TestConfig::COMMANDBUFFERTYPES_INLINE,
6456 TestConfig::IMAGEMEMORY_STRICT,
6463 testConfigExternal.allocationKind,
6464 testConfigExternal.renderingType);
6466 addFunctionCaseWithPrograms<TestConfig>(group, "color_stencil", "Color and stencil attachment case.", createTestShaders, renderPassTest, testConfig);
6469 // color_depth_stencil
6471 const Attachment attachments[] =
6473 Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6474 VK_SAMPLE_COUNT_1_BIT,
6475 VK_ATTACHMENT_LOAD_OP_CLEAR,
6476 VK_ATTACHMENT_STORE_OP_STORE,
6477 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6478 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6479 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6480 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL),
6481 Attachment(VK_FORMAT_D24_UNORM_S8_UINT,
6482 VK_SAMPLE_COUNT_1_BIT,
6483 VK_ATTACHMENT_LOAD_OP_CLEAR,
6484 VK_ATTACHMENT_STORE_OP_STORE,
6485 VK_ATTACHMENT_LOAD_OP_CLEAR,
6486 VK_ATTACHMENT_STORE_OP_STORE,
6487 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6488 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6491 const RenderPass renderPass (vector<Attachment>(DE_ARRAY_BEGIN(attachments), DE_ARRAY_END(attachments)),
6492 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6494 vector<AttachmentReference>(),
6495 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6496 vector<AttachmentReference>(),
6497 AttachmentReference(1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6498 vector<deUint32>())),
6499 vector<SubpassDependency>());
6500 const TestConfig testConfig (renderPass,
6501 TestConfig::RENDERTYPES_DRAW,
6502 TestConfig::COMMANDBUFFERTYPES_INLINE,
6503 TestConfig::IMAGEMEMORY_STRICT,
6510 testConfigExternal.allocationKind,
6511 testConfigExternal.renderingType);
6513 addFunctionCaseWithPrograms<TestConfig>(group, "color_depth_stencil", "Color, depth and stencil attachment case.", createTestShaders, renderPassTest, testConfig);
6518 const RenderPass renderPass (vector<Attachment>(),
6519 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6521 vector<AttachmentReference>(),
6522 vector<AttachmentReference>(),
6523 vector<AttachmentReference>(),
6524 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6525 vector<deUint32>())),
6526 vector<SubpassDependency>());
6527 const TestConfig testConfig (renderPass,
6528 TestConfig::RENDERTYPES_DRAW,
6529 TestConfig::COMMANDBUFFERTYPES_INLINE,
6530 TestConfig::IMAGEMEMORY_STRICT,
6537 testConfigExternal.allocationKind,
6538 testConfigExternal.renderingType);
6540 addFunctionCaseWithPrograms<TestConfig>(group, "no_attachments", "No attachments case.", createTestShaders, renderPassTest, testConfig);
6543 // color_unused_omit_blend_state
6544 if (testConfigExternal.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
6546 vector<Subpass> subpasses;
6548 // First subpass: use color attachment, create pipeline with color blend state
6549 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6551 vector<AttachmentReference>(),
6552 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6553 vector<AttachmentReference>(),
6554 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6558 // Second subpass: don't use color attachment, create pipeline without color blend state
6559 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6561 vector<AttachmentReference>(),
6562 vector<AttachmentReference>(1, AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6563 vector<AttachmentReference>(),
6564 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6568 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6569 VK_SAMPLE_COUNT_1_BIT,
6570 VK_ATTACHMENT_LOAD_OP_CLEAR,
6571 VK_ATTACHMENT_STORE_OP_STORE,
6572 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6573 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6574 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6575 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6577 vector<SubpassDependency>());
6579 const TestConfig testConfig (renderPass,
6580 TestConfig::RENDERTYPES_DRAW,
6581 TestConfig::COMMANDBUFFERTYPES_INLINE,
6582 TestConfig::IMAGEMEMORY_STRICT,
6589 testConfigExternal.allocationKind,
6590 testConfigExternal.renderingType);
6591 addFunctionCaseWithPrograms<TestConfig>(group, "color_unused_omit_blend_state", "Two unused color attachment case without blend state", createTestShaders, renderPassTest, testConfig);
6595 std::string formatToName (VkFormat format)
6597 const std::string formatStr = de::toString(format);
6598 const std::string prefix = "VK_FORMAT_";
6600 DE_ASSERT(formatStr.substr(0, prefix.length()) == prefix);
6602 return de::toLower(formatStr.substr(prefix.length()));
6605 void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
6607 tcu::TestContext& testCtx = group->getTestContext();
6609 const UVec2 targetSize (64, 64);
6610 const UVec2 renderPos (0, 0);
6611 const UVec2 renderSize (64, 64);
6615 const char* const str;
6616 const VkAttachmentStoreOp op;
6619 { "store", VK_ATTACHMENT_STORE_OP_STORE },
6620 { "dont_care", VK_ATTACHMENT_STORE_OP_DONT_CARE }
6625 const char* const str;
6626 const VkAttachmentLoadOp op;
6629 { "clear", VK_ATTACHMENT_LOAD_OP_CLEAR },
6630 { "load", VK_ATTACHMENT_LOAD_OP_LOAD },
6631 { "dont_care", VK_ATTACHMENT_LOAD_OP_DONT_CARE }
6636 const char* const str;
6637 const TestConfig::RenderTypes types;
6640 { "clear", TestConfig::RENDERTYPES_CLEAR },
6641 { "draw", TestConfig::RENDERTYPES_DRAW },
6642 { "clear_draw", TestConfig::RENDERTYPES_CLEAR|TestConfig::RENDERTYPES_DRAW }
6646 for (size_t formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_coreColorFormats); formatNdx++)
6648 const VkFormat format = s_coreColorFormats[formatNdx];
6649 de::MovePtr<tcu::TestCaseGroup> formatGroup (new tcu::TestCaseGroup(testCtx, formatToName(format).c_str(), de::toString(format).c_str()));
6651 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
6653 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
6654 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
6656 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
6658 const RenderPass renderPass (vector<Attachment>(1, Attachment(format,
6659 VK_SAMPLE_COUNT_1_BIT,
6661 VK_ATTACHMENT_STORE_OP_STORE,
6662 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6663 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6664 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6665 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6666 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6668 vector<AttachmentReference>(),
6669 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6670 vector<AttachmentReference>(),
6671 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6672 vector<deUint32>())),
6673 vector<SubpassDependency>());
6674 const TestConfig testConfig (renderPass,
6675 renderTypes[renderTypeNdx].types,
6676 TestConfig::COMMANDBUFFERTYPES_INLINE,
6677 TestConfig::IMAGEMEMORY_STRICT,
6684 testConfigExternal.allocationKind,
6685 testConfigExternal.renderingType);
6687 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), renderTypes[renderTypeNdx].str, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
6690 formatGroup->addChild(loadOpGroup.release());
6693 if (testConfigExternal.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
6695 de::MovePtr<tcu::TestCaseGroup> inputGroup (new tcu::TestCaseGroup(testCtx, "input", "Test attachment format as input"));
6697 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
6699 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
6700 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
6702 for (size_t storeOpNdx = 0; storeOpNdx < DE_LENGTH_OF_ARRAY(storeOps); storeOpNdx++)
6704 const VkImageAspectFlags inputAttachmentAspectMask = (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2)
6705 ? static_cast<VkImageAspectFlags>(VK_IMAGE_ASPECT_COLOR_BIT)
6706 : static_cast<VkImageAspectFlags>(0);
6707 const VkAttachmentStoreOp storeOp = storeOps[storeOpNdx].op;
6708 de::MovePtr<tcu::TestCaseGroup> storeOpGroup (new tcu::TestCaseGroup(testCtx, storeOps[storeOpNdx].str, storeOps[storeOpNdx].str));
6710 for (size_t useInputAspectNdx = 0; useInputAspectNdx < 2; useInputAspectNdx++)
6712 const bool useInputAspect = useInputAspectNdx != 0;
6714 if (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2 && useInputAspect)
6717 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
6720 vector<Attachment> attachments;
6721 vector<Subpass> subpasses;
6722 vector<SubpassDependency> deps;
6723 vector<VkInputAttachmentAspectReference> inputAspects;
6725 attachments.push_back(Attachment(format,
6726 VK_SAMPLE_COUNT_1_BIT,
6729 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6730 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6731 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6732 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
6734 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
6735 VK_SAMPLE_COUNT_1_BIT,
6736 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6737 VK_ATTACHMENT_STORE_OP_STORE,
6738 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6739 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6740 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6741 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
6743 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6745 vector<AttachmentReference>(),
6746 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6747 vector<AttachmentReference>(),
6748 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6749 vector<deUint32>()));
6750 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6752 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
6753 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6754 vector<AttachmentReference>(),
6755 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6756 vector<deUint32>()));
6758 deps.push_back(SubpassDependency(0, 1,
6760 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
6761 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6763 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6764 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6765 vk::VK_DEPENDENCY_BY_REGION_BIT));
6769 const VkInputAttachmentAspectReference inputAspect =
6773 VK_IMAGE_ASPECT_COLOR_BIT
6776 inputAspects.push_back(inputAspect);
6780 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
6781 const TestConfig testConfig (renderPass,
6782 renderTypes[renderTypeNdx].types,
6783 TestConfig::COMMANDBUFFERTYPES_INLINE,
6784 TestConfig::IMAGEMEMORY_STRICT,
6791 testConfigExternal.allocationKind,
6792 testConfigExternal.renderingType);
6793 const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : ""));
6795 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
6799 vector<Attachment> attachments;
6800 vector<Subpass> subpasses;
6801 vector<SubpassDependency> deps;
6802 vector<VkInputAttachmentAspectReference> inputAspects;
6804 attachments.push_back(Attachment(format,
6805 VK_SAMPLE_COUNT_1_BIT,
6808 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6809 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6810 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6811 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
6813 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6815 vector<AttachmentReference>(),
6816 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6817 vector<AttachmentReference>(),
6818 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6819 vector<deUint32>()));
6820 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6822 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL, inputAttachmentAspectMask)),
6823 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL)),
6824 vector<AttachmentReference>(),
6825 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6826 vector<deUint32>()));
6828 deps.push_back(SubpassDependency(0, 1,
6829 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
6830 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6832 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6833 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6834 vk::VK_DEPENDENCY_BY_REGION_BIT));
6836 deps.push_back(SubpassDependency(1, 1,
6837 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
6838 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6840 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6841 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6842 vk::VK_DEPENDENCY_BY_REGION_BIT));
6846 const VkInputAttachmentAspectReference inputAspect =
6850 VK_IMAGE_ASPECT_COLOR_BIT
6853 inputAspects.push_back(inputAspect);
6857 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
6858 const TestConfig testConfig (renderPass,
6859 renderTypes[renderTypeNdx].types,
6860 TestConfig::COMMANDBUFFERTYPES_INLINE,
6861 TestConfig::IMAGEMEMORY_STRICT,
6868 testConfigExternal.allocationKind,
6869 testConfigExternal.renderingType);
6870 const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : ""));
6872 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
6878 loadOpGroup->addChild(storeOpGroup.release());
6881 inputGroup->addChild(loadOpGroup.release());
6884 formatGroup->addChild(inputGroup.release());
6887 group->addChild(formatGroup.release());
6890 // Depth stencil formats
6891 for (size_t formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_coreDepthStencilFormats); formatNdx++)
6893 const VkFormat vkFormat = s_coreDepthStencilFormats[formatNdx];
6894 const tcu::TextureFormat format = mapVkFormat(vkFormat);
6895 const bool isStencilAttachment = hasStencilComponent(format.order);
6896 const bool isDepthAttachment = hasDepthComponent(format.order);
6897 const VkImageAspectFlags formatAspectFlags = (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
6898 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u);
6899 de::MovePtr<tcu::TestCaseGroup> formatGroup (new tcu::TestCaseGroup(testCtx, formatToName(vkFormat).c_str(), de::toString(vkFormat).c_str()));
6901 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
6903 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
6904 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
6906 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
6909 const RenderPass renderPass (vector<Attachment>(1, Attachment(vkFormat,
6910 VK_SAMPLE_COUNT_1_BIT,
6911 isDepthAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6912 isDepthAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6913 isStencilAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6914 isStencilAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6915 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6916 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6917 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6919 vector<AttachmentReference>(),
6920 vector<AttachmentReference>(),
6921 vector<AttachmentReference>(),
6922 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6923 vector<deUint32>())),
6924 vector<SubpassDependency>());
6925 const TestConfig testConfig (renderPass,
6926 renderTypes[renderTypeNdx].types,
6927 TestConfig::COMMANDBUFFERTYPES_INLINE,
6928 TestConfig::IMAGEMEMORY_STRICT,
6935 testConfigExternal.allocationKind,
6936 testConfigExternal.renderingType);
6938 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), renderTypes[renderTypeNdx].str, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
6941 if (isStencilAttachment && isDepthAttachment && loadOp != VK_ATTACHMENT_LOAD_OP_CLEAR)
6944 const RenderPass renderPass (vector<Attachment>(1, Attachment(vkFormat,
6945 VK_SAMPLE_COUNT_1_BIT,
6946 isDepthAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6947 isDepthAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6948 isStencilAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6949 isStencilAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6950 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6951 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6952 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6954 vector<AttachmentReference>(),
6955 vector<AttachmentReference>(),
6956 vector<AttachmentReference>(),
6957 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL),
6958 vector<deUint32>())),
6959 vector<SubpassDependency>());
6960 const TestConfig testConfig (renderPass,
6961 renderTypes[renderTypeNdx].types,
6962 TestConfig::COMMANDBUFFERTYPES_INLINE,
6963 TestConfig::IMAGEMEMORY_STRICT,
6970 testConfigExternal.allocationKind,
6971 testConfigExternal.renderingType);
6972 const string testName (string(renderTypes[renderTypeNdx].str) + "_depth_read_only");
6974 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
6978 const RenderPass renderPass (vector<Attachment>(1, Attachment(vkFormat,
6979 VK_SAMPLE_COUNT_1_BIT,
6980 isDepthAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6981 isDepthAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6982 isStencilAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6983 isStencilAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6984 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6985 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6986 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6988 vector<AttachmentReference>(),
6989 vector<AttachmentReference>(),
6990 vector<AttachmentReference>(),
6991 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL),
6992 vector<deUint32>())),
6993 vector<SubpassDependency>());
6994 const TestConfig testConfig (renderPass,
6995 renderTypes[renderTypeNdx].types,
6996 TestConfig::COMMANDBUFFERTYPES_INLINE,
6997 TestConfig::IMAGEMEMORY_STRICT,
7004 testConfigExternal.allocationKind,
7005 testConfigExternal.renderingType);
7006 const string testName (string(renderTypes[renderTypeNdx].str) + "_stencil_read_only");
7008 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7013 formatGroup->addChild(loadOpGroup.release());
7016 if (testConfigExternal.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
7018 de::MovePtr<tcu::TestCaseGroup> inputGroup (new tcu::TestCaseGroup(testCtx, "input", "Test attachment format as input"));
7020 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
7022 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
7023 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
7025 for (size_t storeOpNdx = 0; storeOpNdx < DE_LENGTH_OF_ARRAY(storeOps); storeOpNdx++)
7027 const VkImageAspectFlags inputAttachmentAspectMask = (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2)
7029 : static_cast<VkImageAspectFlags>(0);
7030 const VkAttachmentStoreOp storeOp = storeOps[storeOpNdx].op;
7031 de::MovePtr<tcu::TestCaseGroup> storeOpGroup (new tcu::TestCaseGroup(testCtx, storeOps[storeOpNdx].str, storeOps[storeOpNdx].str));
7033 for (size_t useInputAspectNdx = 0; useInputAspectNdx < 2; useInputAspectNdx++)
7035 const bool useInputAspect = useInputAspectNdx != 0;
7037 if (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2 && useInputAspect)
7040 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
7043 vector<Attachment> attachments;
7044 vector<Subpass> subpasses;
7045 vector<SubpassDependency> deps;
7046 vector<VkInputAttachmentAspectReference> inputAspects;
7048 attachments.push_back(Attachment(vkFormat,
7049 VK_SAMPLE_COUNT_1_BIT,
7054 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7055 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7057 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
7058 VK_SAMPLE_COUNT_1_BIT,
7059 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7060 VK_ATTACHMENT_STORE_OP_STORE,
7061 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7062 VK_ATTACHMENT_STORE_OP_DONT_CARE,
7063 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
7064 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
7066 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7068 vector<AttachmentReference>(),
7069 vector<AttachmentReference>(),
7070 vector<AttachmentReference>(),
7071 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7072 vector<deUint32>()));
7073 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7075 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
7076 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
7077 vector<AttachmentReference>(),
7078 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
7079 vector<deUint32>()));
7081 deps.push_back(SubpassDependency(0, 1,
7082 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7083 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7085 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7086 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7091 const VkInputAttachmentAspectReference inputAspect =
7095 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7096 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7099 inputAspects.push_back(inputAspect);
7103 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7104 const TestConfig testConfig (renderPass,
7105 renderTypes[renderTypeNdx].types,
7106 TestConfig::COMMANDBUFFERTYPES_INLINE,
7107 TestConfig::IMAGEMEMORY_STRICT,
7114 testConfigExternal.allocationKind,
7115 testConfigExternal.renderingType);
7116 const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : ""));
7118 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7122 vector<Attachment> attachments;
7123 vector<Subpass> subpasses;
7124 vector<SubpassDependency> deps;
7125 vector<VkInputAttachmentAspectReference> inputAspects;
7127 attachments.push_back(Attachment(vkFormat,
7128 VK_SAMPLE_COUNT_1_BIT,
7131 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7132 VK_ATTACHMENT_STORE_OP_DONT_CARE,
7133 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7134 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7136 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7138 vector<AttachmentReference>(),
7139 vector<AttachmentReference>(),
7140 vector<AttachmentReference>(),
7141 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7142 vector<deUint32>()));
7143 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7145 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL, inputAttachmentAspectMask)),
7146 vector<AttachmentReference>(),
7147 vector<AttachmentReference>(),
7148 AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL),
7149 vector<deUint32>()));
7151 deps.push_back(SubpassDependency(0, 1,
7152 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7153 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7155 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7156 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7157 vk::VK_DEPENDENCY_BY_REGION_BIT));
7159 deps.push_back(SubpassDependency(1, 1,
7160 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7161 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7162 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7163 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7164 vk::VK_DEPENDENCY_BY_REGION_BIT));
7169 const VkInputAttachmentAspectReference inputAspect =
7174 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7175 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7178 inputAspects.push_back(inputAspect);
7182 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7183 const TestConfig testConfig (renderPass,
7184 renderTypes[renderTypeNdx].types,
7185 TestConfig::COMMANDBUFFERTYPES_INLINE,
7186 TestConfig::IMAGEMEMORY_STRICT,
7193 testConfigExternal.allocationKind,
7194 testConfigExternal.renderingType);
7195 const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : ""));
7197 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7201 if (isStencilAttachment && isDepthAttachment)
7205 vector<Attachment> attachments;
7206 vector<Subpass> subpasses;
7207 vector<SubpassDependency> deps;
7208 vector<VkInputAttachmentAspectReference> inputAspects;
7210 attachments.push_back(Attachment(vkFormat,
7211 VK_SAMPLE_COUNT_1_BIT,
7216 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7217 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7219 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
7220 VK_SAMPLE_COUNT_1_BIT,
7221 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7222 VK_ATTACHMENT_STORE_OP_STORE,
7223 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7224 VK_ATTACHMENT_STORE_OP_DONT_CARE,
7225 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
7226 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
7228 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7230 vector<AttachmentReference>(),
7231 vector<AttachmentReference>(),
7232 vector<AttachmentReference>(),
7233 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7234 vector<deUint32>()));
7235 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7237 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL, inputAttachmentAspectMask)),
7238 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
7239 vector<AttachmentReference>(),
7240 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
7241 vector<deUint32>()));
7243 deps.push_back(SubpassDependency(0, 1,
7244 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7245 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7247 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7248 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7253 const VkInputAttachmentAspectReference inputAspect =
7258 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7259 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7262 inputAspects.push_back(inputAspect);
7266 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7267 const TestConfig testConfig (renderPass,
7268 renderTypes[renderTypeNdx].types,
7269 TestConfig::COMMANDBUFFERTYPES_INLINE,
7270 TestConfig::IMAGEMEMORY_STRICT,
7277 testConfigExternal.allocationKind,
7278 testConfigExternal.renderingType);
7279 const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : "") + "_depth_read_only");
7281 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7285 vector<Attachment> attachments;
7286 vector<Subpass> subpasses;
7287 vector<SubpassDependency> deps;
7288 vector<VkInputAttachmentAspectReference> inputAspects;
7290 attachments.push_back(Attachment(vkFormat,
7291 VK_SAMPLE_COUNT_1_BIT,
7296 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7297 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7299 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7301 vector<AttachmentReference>(),
7302 vector<AttachmentReference>(),
7303 vector<AttachmentReference>(),
7304 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7305 vector<deUint32>()));
7306 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7308 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL, inputAttachmentAspectMask)),
7309 vector<AttachmentReference>(),
7310 vector<AttachmentReference>(),
7311 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL),
7312 vector<deUint32>()));
7314 deps.push_back(SubpassDependency(0, 1,
7315 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7316 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7318 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7319 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7320 vk::VK_DEPENDENCY_BY_REGION_BIT));
7322 deps.push_back(SubpassDependency(1, 1,
7323 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7324 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7326 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7327 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7328 vk::VK_DEPENDENCY_BY_REGION_BIT));
7332 const VkInputAttachmentAspectReference inputAspect =
7337 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7338 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7341 inputAspects.push_back(inputAspect);
7345 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7346 const TestConfig testConfig (renderPass,
7347 renderTypes[renderTypeNdx].types,
7348 TestConfig::COMMANDBUFFERTYPES_INLINE,
7349 TestConfig::IMAGEMEMORY_STRICT,
7356 testConfigExternal.allocationKind,
7357 testConfigExternal.renderingType);
7358 const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : "") + "_depth_read_only");
7360 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7363 // Stencil read only
7365 vector<Attachment> attachments;
7366 vector<Subpass> subpasses;
7367 vector<SubpassDependency> deps;
7368 vector<VkInputAttachmentAspectReference> inputAspects;
7370 attachments.push_back(Attachment(vkFormat,
7371 VK_SAMPLE_COUNT_1_BIT,
7376 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7377 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7379 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
7380 VK_SAMPLE_COUNT_1_BIT,
7381 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7382 VK_ATTACHMENT_STORE_OP_STORE,
7383 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7384 VK_ATTACHMENT_STORE_OP_DONT_CARE,
7385 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
7386 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
7388 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7390 vector<AttachmentReference>(),
7391 vector<AttachmentReference>(),
7392 vector<AttachmentReference>(),
7393 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7394 vector<deUint32>()));
7395 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7397 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
7398 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
7399 vector<AttachmentReference>(),
7400 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
7401 vector<deUint32>()));
7403 deps.push_back(SubpassDependency(0, 1,
7404 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
7405 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7407 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7408 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7413 const VkInputAttachmentAspectReference inputAspect =
7418 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7419 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7422 inputAspects.push_back(inputAspect);
7426 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7427 const TestConfig testConfig (renderPass,
7428 renderTypes[renderTypeNdx].types,
7429 TestConfig::COMMANDBUFFERTYPES_INLINE,
7430 TestConfig::IMAGEMEMORY_STRICT,
7437 testConfigExternal.allocationKind,
7438 testConfigExternal.renderingType);
7439 const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : "") + "_stencil_read_only");
7441 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7445 vector<Attachment> attachments;
7446 vector<Subpass> subpasses;
7447 vector<SubpassDependency> deps;
7448 vector<VkInputAttachmentAspectReference> inputAspects;
7450 attachments.push_back(Attachment(vkFormat,
7451 VK_SAMPLE_COUNT_1_BIT,
7456 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7457 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7459 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7461 vector<AttachmentReference>(),
7462 vector<AttachmentReference>(),
7463 vector<AttachmentReference>(),
7464 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7465 vector<deUint32>()));
7466 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7468 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
7469 vector<AttachmentReference>(),
7470 vector<AttachmentReference>(),
7471 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL),
7472 vector<deUint32>()));
7474 deps.push_back(SubpassDependency(0, 1,
7475 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7476 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7478 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7479 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7480 vk::VK_DEPENDENCY_BY_REGION_BIT));
7482 deps.push_back(SubpassDependency(1, 1,
7483 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7484 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7486 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7487 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7488 vk::VK_DEPENDENCY_BY_REGION_BIT));
7493 const VkInputAttachmentAspectReference inputAspect =
7498 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7499 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7502 inputAspects.push_back(inputAspect);
7506 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7507 const TestConfig testConfig (renderPass,
7508 renderTypes[renderTypeNdx].types,
7509 TestConfig::COMMANDBUFFERTYPES_INLINE,
7510 TestConfig::IMAGEMEMORY_STRICT,
7517 testConfigExternal.allocationKind,
7518 testConfigExternal.renderingType);
7519 const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : "") + "_stencil_read_only");
7521 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7528 loadOpGroup->addChild(storeOpGroup.release());
7531 inputGroup->addChild(loadOpGroup.release());
7534 formatGroup->addChild(inputGroup.release());
7537 group->addChild(formatGroup.release());
7541 void addRenderPassTests (tcu::TestCaseGroup* group, const AllocationKind allocationKind, const RenderingType renderingType)
7543 const TestConfigExternal testConfigExternal (allocationKind, renderingType);
7545 addTestGroup(group, "simple", "Simple basic render pass tests", addSimpleTests, testConfigExternal);
7546 addTestGroup(group, "formats", "Tests for different image formats.", addFormatTests, testConfigExternal);
7547 addTestGroup(group, "attachment", "Attachment format and count tests with load and store ops and image layouts", addAttachmentTests, testConfigExternal);
7548 addTestGroup(group, "attachment_write_mask", "Attachment write mask tests", addAttachmentWriteMaskTests, testConfigExternal);
7550 if (renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
7551 addTestGroup(group, "attachment_allocation", "Attachment allocation tests", addAttachmentAllocationTests, testConfigExternal);
7554 de::MovePtr<tcu::TestCaseGroup> createSuballocationTests(tcu::TestContext& testCtx, RenderingType renderingType)
7556 de::MovePtr<tcu::TestCaseGroup> suballocationTestsGroup(new tcu::TestCaseGroup(testCtx, "suballocation", "Suballocation RenderPass Tests"));
7558 addRenderPassTests(suballocationTestsGroup.get(), ALLOCATION_KIND_SUBALLOCATED, renderingType);
7560 return suballocationTestsGroup;
7563 de::MovePtr<tcu::TestCaseGroup> createDedicatedAllocationTests(tcu::TestContext& testCtx, RenderingType renderingType)
7565 de::MovePtr<tcu::TestCaseGroup> dedicatedAllocationTestsGroup(new tcu::TestCaseGroup(testCtx, "dedicated_allocation", "RenderPass Tests For Dedicated Allocation"));
7567 addRenderPassTests(dedicatedAllocationTestsGroup.get(), ALLOCATION_KIND_DEDICATED, renderingType);
7569 return dedicatedAllocationTestsGroup;
7572 tcu::TestCaseGroup* createRenderPassTestsInternal (tcu::TestContext& testCtx, RenderingType renderingType)
7574 const char* renderingTestsGroupName = (renderingType == RENDERING_TYPE_RENDERPASS_LEGACY) ? "renderpass" :
7575 (renderingType == RENDERING_TYPE_RENDERPASS2) ? "renderpass2" :
7576 (renderingType == RENDERING_TYPE_DYNAMIC_RENDERING) ? "dynamic_rendering" :
7578 const char* renderingTestsGroupDescription = (renderingType == RENDERING_TYPE_RENDERPASS_LEGACY) ? "RenderPass Tests" :
7579 (renderingType == RENDERING_TYPE_RENDERPASS2) ? "RenderPass2 Tests" :
7580 (renderingType == RENDERING_TYPE_DYNAMIC_RENDERING) ? "Dynamic Rendering Tests" :
7583 de::MovePtr<tcu::TestCaseGroup> renderingTests (new tcu::TestCaseGroup(testCtx, renderingTestsGroupName, renderingTestsGroupDescription));
7584 de::MovePtr<tcu::TestCaseGroup> suballocationTestGroup = createSuballocationTests(testCtx, renderingType);
7585 de::MovePtr<tcu::TestCaseGroup> dedicatedAllocationTestGroup = createDedicatedAllocationTests(testCtx, renderingType);
7587 switch (renderingType)
7589 case RENDERING_TYPE_RENDERPASS_LEGACY:
7590 suballocationTestGroup->addChild(createRenderPassMultisampleTests(testCtx));
7591 suballocationTestGroup->addChild(createRenderPassMultisampleResolveTests(testCtx));
7592 suballocationTestGroup->addChild(createRenderPassSubpassDependencyTests(testCtx));
7593 suballocationTestGroup->addChild(createRenderPassSampleReadTests(testCtx));
7594 suballocationTestGroup->addChild(createRenderPassSparseRenderTargetTests(testCtx));
7596 renderingTests->addChild(createRenderPassMultipleSubpassesMultipleCommandBuffersTests(testCtx));
7597 renderingTests->addChild(createDepthStencilWriteConditionsTests(testCtx));
7600 case RENDERING_TYPE_RENDERPASS2:
7601 suballocationTestGroup->addChild(createRenderPass2MultisampleTests(testCtx));
7602 suballocationTestGroup->addChild(createRenderPass2MultisampleResolveTests(testCtx));
7603 suballocationTestGroup->addChild(createRenderPass2SubpassDependencyTests(testCtx));
7604 suballocationTestGroup->addChild(createRenderPass2SampleReadTests(testCtx));
7605 suballocationTestGroup->addChild(createRenderPass2SparseRenderTargetTests(testCtx));
7607 renderingTests->addChild(createRenderPass2DepthStencilResolveTests(testCtx));
7610 case RENDERING_TYPE_DYNAMIC_RENDERING:
7611 suballocationTestGroup->addChild(createDynamicRenderingMultisampleResolveTests(testCtx));
7612 suballocationTestGroup->addChild(createDynamicRenderingSparseRenderTargetTests(testCtx));
7614 renderingTests->addChild(createDynamicRenderingBasicTests(testCtx));
7618 if (renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
7620 suballocationTestGroup->addChild(createRenderPassUnusedAttachmentTests(testCtx, renderingType));
7621 suballocationTestGroup->addChild(createRenderPassUnusedAttachmentSparseFillingTests(testCtx, renderingType));
7624 suballocationTestGroup->addChild(createRenderPassUnusedClearAttachmentTests(testCtx, renderingType));
7625 suballocationTestGroup->addChild(createRenderPassLoadStoreOpNoneTests(testCtx, renderingType));
7627 renderingTests->addChild(suballocationTestGroup.release());
7628 renderingTests->addChild(dedicatedAllocationTestGroup.release());
7629 renderingTests->addChild(createFragmentDensityMapTests(testCtx, renderingType));
7631 return renderingTests.release();
7636 tcu::TestCaseGroup* createRenderPassTests (tcu::TestContext& testCtx)
7638 return createRenderPassTestsInternal(testCtx, RENDERING_TYPE_RENDERPASS_LEGACY);
7641 tcu::TestCaseGroup* createRenderPass2Tests (tcu::TestContext& testCtx)
7643 return createRenderPassTestsInternal(testCtx, RENDERING_TYPE_RENDERPASS2);
7646 tcu::TestCaseGroup* createDynamicRenderingTests(tcu::TestContext& testCtx)
7648 return createRenderPassTestsInternal(testCtx, RENDERING_TYPE_DYNAMIC_RENDERING);