1 /*-------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2015 Google Inc.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief RenderPass tests
22 *//*--------------------------------------------------------------------*/
24 #include "vktRenderPassTests.hpp"
25 #include "vktRenderPassTestsUtil.hpp"
27 #include "vktRenderPassMultisampleTests.hpp"
28 #include "vktRenderPassMultisampleResolveTests.hpp"
29 #include "vktRenderPassSampleReadTests.hpp"
30 #include "vktRenderPassSparseRenderTargetTests.hpp"
31 #include "vktRenderPassSubpassDependencyTests.hpp"
32 #include "vktRenderPassUnusedAttachmentTests.hpp"
33 #include "vktRenderPassUnusedClearAttachmentTests.hpp"
34 #include "vktRenderPassDepthStencilResolveTests.hpp"
35 #include "vktRenderPassUnusedAttachmentSparseFillingTests.hpp"
36 #include "vktRenderPassFragmentDensityMapTests.hpp"
37 #include "vktRenderPassMultipleSubpassesMultipleCommandBuffersTests.hpp"
38 #include "vktRenderPassLoadStoreOpNoneTests.hpp"
39 #include "vktDynamicRenderingTests.hpp"
41 #include "vktTestCaseUtil.hpp"
42 #include "vktTestGroupUtil.hpp"
45 #include "vkDeviceUtil.hpp"
46 #include "vkImageUtil.hpp"
47 #include "vkMemUtil.hpp"
48 #include "vkPlatform.hpp"
49 #include "vkPrograms.hpp"
50 #include "vkQueryUtil.hpp"
52 #include "vkRefUtil.hpp"
53 #include "vkStrUtil.hpp"
54 #include "vkTypeUtil.hpp"
55 #include "vkCmdUtil.hpp"
56 #include "vkObjUtil.hpp"
58 #include "tcuFloat.hpp"
59 #include "tcuFormatUtil.hpp"
60 #include "tcuMaybe.hpp"
61 #include "tcuResultCollector.hpp"
62 #include "tcuTestLog.hpp"
63 #include "tcuTextureUtil.hpp"
64 #include "tcuVectorUtil.hpp"
66 #include "deRandom.hpp"
67 #include "deSTLUtil.hpp"
68 #include "deSharedPtr.hpp"
69 #include "deStringUtil.hpp"
70 #include "deUniquePtr.hpp"
91 using tcu::ConstPixelBufferAccess;
92 using tcu::PixelBufferAccess;
107 using namespace renderpass;
109 typedef vector<deUint8> DepthValuesArray;
111 static const deUint8 DEPTH_VALUES[] = { 0u, 255u, 1u };
115 ALLOCATION_KIND_SUBALLOCATED,
116 ALLOCATION_KIND_DEDICATED,
119 struct TestConfigExternal
121 TestConfigExternal (AllocationKind allocationKind_,
122 RenderingType renderingType_)
123 : allocationKind (allocationKind_)
124 , renderingType (renderingType_)
128 AllocationKind allocationKind;
129 RenderingType renderingType;
132 de::MovePtr<Allocation> allocateBuffer (const InstanceInterface& vki,
133 const DeviceInterface& vkd,
134 const VkPhysicalDevice& physDevice,
135 const VkDevice device,
136 const VkBuffer& buffer,
137 const MemoryRequirement requirement,
138 Allocator& allocator,
139 AllocationKind allocationKind)
141 switch (allocationKind)
143 case ALLOCATION_KIND_SUBALLOCATED:
145 const VkMemoryRequirements memoryRequirements = getBufferMemoryRequirements(vkd, device, buffer);
147 return allocator.allocate(memoryRequirements, requirement);
150 case ALLOCATION_KIND_DEDICATED:
152 return allocateDedicated(vki, vkd, physDevice, device, buffer, requirement);
157 TCU_THROW(InternalError, "Invalid allocation kind");
162 de::MovePtr<Allocation> allocateImage (const InstanceInterface& vki,
163 const DeviceInterface& vkd,
164 const VkPhysicalDevice& physDevice,
165 const VkDevice device,
166 const VkImage& image,
167 const MemoryRequirement requirement,
168 Allocator& allocator,
169 AllocationKind allocationKind)
171 switch (allocationKind)
173 case ALLOCATION_KIND_SUBALLOCATED:
175 const VkMemoryRequirements memoryRequirements = getImageMemoryRequirements(vkd, device, image);
177 return allocator.allocate(memoryRequirements, requirement);
180 case ALLOCATION_KIND_DEDICATED:
182 return allocateDedicated(vki, vkd, physDevice, device, image, requirement);
187 TCU_THROW(InternalError, "Invalid allocation kind");
200 const char* boolOpToString (BoolOp op)
217 DE_FATAL("Unknown boolean operation.");
222 bool performBoolOp (BoolOp op, bool a, bool b)
239 DE_FATAL("Unknown boolean operation.");
244 BoolOp boolOpFromIndex (size_t index)
254 return ops[index % DE_LENGTH_OF_ARRAY(ops)];
257 static float requiredDepthEpsilon(VkFormat format)
259 // Possible precision loss in the unorm depth pipeline means that we need to check depths
260 // that go in and back out of the depth buffer with an epsilon rather than an exact match
261 deUint32 unormBits = 0;
265 case VK_FORMAT_D16_UNORM:
268 case VK_FORMAT_X8_D24_UNORM_PACK32:
269 case VK_FORMAT_D24_UNORM_S8_UINT:
272 case VK_FORMAT_D32_SFLOAT:
273 case VK_FORMAT_D32_SFLOAT_S8_UINT:
280 return 1.0f / (float)((1 << unormBits) - 1);
282 return 0.0f; // Require exact match
285 static bool depthsEqual(float a, float b, float epsilon)
287 return fabs(a - b) <= epsilon;
290 Move<VkFramebuffer> createFramebuffer (const DeviceInterface& vk,
292 VkFramebufferCreateFlags pCreateInfo_flags,
293 VkRenderPass pCreateInfo_renderPass,
294 deUint32 pCreateInfo_attachmentCount,
295 const VkImageView* pCreateInfo_pAttachments,
296 deUint32 pCreateInfo_width,
297 deUint32 pCreateInfo_height,
298 deUint32 pCreateInfo_layers)
300 const VkFramebufferCreateInfo pCreateInfo =
302 VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
305 pCreateInfo_renderPass,
306 pCreateInfo_attachmentCount,
307 pCreateInfo_pAttachments,
312 return createFramebuffer(vk, device, &pCreateInfo);
315 Move<VkImage> createImage (const DeviceInterface& vk,
317 VkImageCreateFlags pCreateInfo_flags,
318 VkImageType pCreateInfo_imageType,
319 VkFormat pCreateInfo_format,
320 VkExtent3D pCreateInfo_extent,
321 deUint32 pCreateInfo_mipLevels,
322 deUint32 pCreateInfo_arrayLayers,
323 VkSampleCountFlagBits pCreateInfo_samples,
324 VkImageTiling pCreateInfo_tiling,
325 VkImageUsageFlags pCreateInfo_usage,
326 VkSharingMode pCreateInfo_sharingMode,
327 deUint32 pCreateInfo_queueFamilyCount,
328 const deUint32* pCreateInfo_pQueueFamilyIndices,
329 VkImageLayout pCreateInfo_initialLayout)
331 const VkImageCreateInfo pCreateInfo =
333 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
336 pCreateInfo_imageType,
339 pCreateInfo_mipLevels,
340 pCreateInfo_arrayLayers,
344 pCreateInfo_sharingMode,
345 pCreateInfo_queueFamilyCount,
346 pCreateInfo_pQueueFamilyIndices,
347 pCreateInfo_initialLayout
349 return createImage(vk, device, &pCreateInfo);
352 void bindBufferMemory (const DeviceInterface& vk, VkDevice device, VkBuffer buffer, VkDeviceMemory mem, VkDeviceSize memOffset)
354 VK_CHECK(vk.bindBufferMemory(device, buffer, mem, memOffset));
357 void bindImageMemory (const DeviceInterface& vk, VkDevice device, VkImage image, VkDeviceMemory mem, VkDeviceSize memOffset)
359 VK_CHECK(vk.bindImageMemory(device, image, mem, memOffset));
362 Move<VkImageView> createImageView (const DeviceInterface& vk,
364 VkImageViewCreateFlags pCreateInfo_flags,
365 VkImage pCreateInfo_image,
366 VkImageViewType pCreateInfo_viewType,
367 VkFormat pCreateInfo_format,
368 VkComponentMapping pCreateInfo_components,
369 VkImageSubresourceRange pCreateInfo_subresourceRange)
371 const VkImageViewCreateInfo pCreateInfo =
373 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
377 pCreateInfo_viewType,
379 pCreateInfo_components,
380 pCreateInfo_subresourceRange,
382 return createImageView(vk, device, &pCreateInfo);
385 Move<VkBuffer> createBuffer (const DeviceInterface& vk,
387 VkBufferCreateFlags pCreateInfo_flags,
388 VkDeviceSize pCreateInfo_size,
389 VkBufferUsageFlags pCreateInfo_usage,
390 VkSharingMode pCreateInfo_sharingMode,
391 deUint32 pCreateInfo_queueFamilyCount,
392 const deUint32* pCreateInfo_pQueueFamilyIndices)
394 const VkBufferCreateInfo pCreateInfo =
396 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
401 pCreateInfo_sharingMode,
402 pCreateInfo_queueFamilyCount,
403 pCreateInfo_pQueueFamilyIndices,
405 return createBuffer(vk, device, &pCreateInfo);
408 VkRenderPassBeginInfo createRenderPassBeginInfo (VkRenderPass pRenderPassBegin_renderPass,
409 VkFramebuffer pRenderPassBegin_framebuffer,
410 VkRect2D pRenderPassBegin_renderArea,
411 deUint32 pRenderPassBegin_clearValueCount,
412 const VkClearValue* pRenderPassBegin_pAttachmentClearValues)
414 const VkRenderPassBeginInfo renderPassBeginInfo =
416 VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
418 pRenderPassBegin_renderPass,
419 pRenderPassBegin_framebuffer,
420 pRenderPassBegin_renderArea,
421 pRenderPassBegin_clearValueCount,
422 pRenderPassBegin_pAttachmentClearValues,
425 return renderPassBeginInfo;
428 void queueSubmit (const DeviceInterface& vk, VkQueue queue, deUint32 cmdBufferCount, const VkCommandBuffer* pCmdBuffers, VkFence fence)
430 const VkSubmitInfo submitInfo =
432 VK_STRUCTURE_TYPE_SUBMIT_INFO,
434 0u, // waitSemaphoreCount
435 (const VkSemaphore*)DE_NULL, // pWaitSemaphores
436 (const VkPipelineStageFlags*)DE_NULL,
437 cmdBufferCount, // commandBufferCount
439 0u, // signalSemaphoreCount
440 (const VkSemaphore*)DE_NULL, // pSignalSemaphores
442 VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo, fence));
445 void waitForFences (const DeviceInterface& vk, VkDevice device, deUint32 fenceCount, const VkFence* pFences, VkBool32 waitAll, deUint64 timeout)
447 VK_CHECK(vk.waitForFences(device, fenceCount, pFences, waitAll, timeout));
450 VkImageAspectFlags getImageAspectFlags (VkFormat vkFormat)
452 const tcu::TextureFormat format = mapVkFormat(vkFormat);
454 DE_STATIC_ASSERT(tcu::TextureFormat::CHANNELORDER_LAST == 22);
456 switch (format.order)
458 case tcu::TextureFormat::DS:
459 return VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_DEPTH_BIT;
461 case tcu::TextureFormat::D:
462 return VK_IMAGE_ASPECT_DEPTH_BIT;
464 case tcu::TextureFormat::S:
465 return VK_IMAGE_ASPECT_STENCIL_BIT;
468 return VK_IMAGE_ASPECT_COLOR_BIT;
472 VkAccessFlags getAllMemoryReadFlags (void)
474 return VK_ACCESS_TRANSFER_READ_BIT
475 | VK_ACCESS_UNIFORM_READ_BIT
476 | VK_ACCESS_HOST_READ_BIT
477 | VK_ACCESS_INDEX_READ_BIT
478 | VK_ACCESS_SHADER_READ_BIT
479 | VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT
480 | VK_ACCESS_INDIRECT_COMMAND_READ_BIT
481 | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT
482 | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT
483 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT;
486 VkAccessFlags getAllMemoryWriteFlags (void)
488 return VK_ACCESS_TRANSFER_WRITE_BIT
489 | VK_ACCESS_HOST_WRITE_BIT
490 | VK_ACCESS_SHADER_WRITE_BIT
491 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT
492 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
495 VkAccessFlags getMemoryFlagsForLayout (const VkImageLayout layout)
499 case VK_IMAGE_LAYOUT_GENERAL: return getAllMemoryReadFlags() | getAllMemoryWriteFlags();
500 case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: return VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
501 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: return VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
502 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: return VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT;
503 case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL: return VK_ACCESS_SHADER_READ_BIT;
504 case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL: return VK_ACCESS_TRANSFER_READ_BIT;
505 case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL: return VK_ACCESS_TRANSFER_WRITE_BIT;
506 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;
507 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;
509 return (VkAccessFlags)0;
513 VkPipelineStageFlags getAllPipelineStageFlags (void)
515 /* All relevant flags for a pipeline containing VS+PS. */
516 return VK_PIPELINE_STAGE_TRANSFER_BIT
517 | VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT
518 | VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT
519 | VK_PIPELINE_STAGE_VERTEX_INPUT_BIT
520 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT
521 | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
522 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
523 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT
524 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
525 | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT
526 | VK_PIPELINE_STAGE_HOST_BIT;
529 class AttachmentReference
532 AttachmentReference (deUint32 attachment,
533 VkImageLayout layout,
534 VkImageAspectFlags aspectMask = static_cast<VkImageAspectFlags>(0u))
535 : m_attachment (attachment)
537 , m_aspectMask (aspectMask)
541 deUint32 getAttachment (void) const { return m_attachment; }
542 VkImageLayout getImageLayout (void) const { return m_layout; }
543 VkImageAspectFlags getAspectMask (void) const { return m_aspectMask; }
544 void setImageLayout (VkImageLayout layout) { m_layout = layout; }
547 deUint32 m_attachment;
548 VkImageLayout m_layout;
549 VkImageAspectFlags m_aspectMask;
555 Subpass (VkPipelineBindPoint pipelineBindPoint,
556 VkSubpassDescriptionFlags flags,
557 const vector<AttachmentReference>& inputAttachments,
558 const vector<AttachmentReference>& colorAttachments,
559 const vector<AttachmentReference>& resolveAttachments,
560 AttachmentReference depthStencilAttachment,
561 const vector<deUint32>& preserveAttachments,
562 bool omitBlendState = false)
563 : m_pipelineBindPoint (pipelineBindPoint)
565 , m_inputAttachments (inputAttachments)
566 , m_colorAttachments (colorAttachments)
567 , m_resolveAttachments (resolveAttachments)
568 , m_depthStencilAttachment (depthStencilAttachment)
569 , m_preserveAttachments (preserveAttachments)
570 , m_omitBlendState (omitBlendState)
574 VkPipelineBindPoint getPipelineBindPoint (void) const { return m_pipelineBindPoint; }
575 VkSubpassDescriptionFlags getFlags (void) const { return m_flags; }
576 const vector<AttachmentReference>& getInputAttachments (void) const { return m_inputAttachments; }
577 const vector<AttachmentReference>& getColorAttachments (void) const { return m_colorAttachments; }
578 const vector<AttachmentReference>& getResolveAttachments (void) const { return m_resolveAttachments; }
579 const AttachmentReference& getDepthStencilAttachment (void) const { return m_depthStencilAttachment; }
580 const vector<deUint32>& getPreserveAttachments (void) const { return m_preserveAttachments; }
581 bool getOmitBlendState (void) const { return m_omitBlendState; }
584 VkPipelineBindPoint m_pipelineBindPoint;
585 VkSubpassDescriptionFlags m_flags;
587 vector<AttachmentReference> m_inputAttachments;
588 vector<AttachmentReference> m_colorAttachments;
589 vector<AttachmentReference> m_resolveAttachments;
590 AttachmentReference m_depthStencilAttachment;
592 vector<deUint32> m_preserveAttachments;
593 bool m_omitBlendState;
596 class SubpassDependency
599 SubpassDependency (deUint32 srcPass,
602 VkPipelineStageFlags srcStageMask,
603 VkPipelineStageFlags dstStageMask,
605 VkAccessFlags srcAccessMask,
606 VkAccessFlags dstAccessMask,
608 VkDependencyFlags flags)
609 : m_srcPass (srcPass)
610 , m_dstPass (dstPass)
612 , m_srcStageMask (srcStageMask)
613 , m_dstStageMask (dstStageMask)
615 , m_srcAccessMask (srcAccessMask)
616 , m_dstAccessMask (dstAccessMask)
621 deUint32 getSrcPass (void) const { return m_srcPass; }
622 deUint32 getDstPass (void) const { return m_dstPass; }
624 VkPipelineStageFlags getSrcStageMask (void) const { return m_srcStageMask; }
625 VkPipelineStageFlags getDstStageMask (void) const { return m_dstStageMask; }
627 VkAccessFlags getSrcAccessMask (void) const { return m_srcAccessMask; }
628 VkAccessFlags getDstAccessMask (void) const { return m_dstAccessMask; }
630 VkDependencyFlags getFlags (void) const { return m_flags; }
632 void setSrcAccessMask (const VkAccessFlags& flags) { m_srcAccessMask = flags; }
633 void setDstAccessMask (const VkAccessFlags& flags) { m_dstAccessMask = flags; }
639 VkPipelineStageFlags m_srcStageMask;
640 VkPipelineStageFlags m_dstStageMask;
642 VkAccessFlags m_srcAccessMask;
643 VkAccessFlags m_dstAccessMask;
644 VkDependencyFlags m_flags;
650 Attachment (VkFormat format,
651 VkSampleCountFlagBits samples,
653 VkAttachmentLoadOp loadOp,
654 VkAttachmentStoreOp storeOp,
656 VkAttachmentLoadOp stencilLoadOp,
657 VkAttachmentStoreOp stencilStoreOp,
659 VkImageLayout initialLayout,
660 VkImageLayout finalLayout)
662 , m_samples (samples)
665 , m_storeOp (storeOp)
667 , m_stencilLoadOp (stencilLoadOp)
668 , m_stencilStoreOp (stencilStoreOp)
670 , m_initialLayout (initialLayout)
671 , m_finalLayout (finalLayout)
675 VkFormat getFormat (void) const { return m_format; }
676 VkSampleCountFlagBits getSamples (void) const { return m_samples; }
678 VkAttachmentLoadOp getLoadOp (void) const { return m_loadOp; }
679 VkAttachmentStoreOp getStoreOp (void) const { return m_storeOp; }
682 VkAttachmentLoadOp getStencilLoadOp (void) const { return m_stencilLoadOp; }
683 VkAttachmentStoreOp getStencilStoreOp (void) const { return m_stencilStoreOp; }
685 VkImageLayout getInitialLayout (void) const { return m_initialLayout; }
686 VkImageLayout getFinalLayout (void) const { return m_finalLayout; }
690 VkSampleCountFlagBits m_samples;
692 VkAttachmentLoadOp m_loadOp;
693 VkAttachmentStoreOp m_storeOp;
695 VkAttachmentLoadOp m_stencilLoadOp;
696 VkAttachmentStoreOp m_stencilStoreOp;
698 VkImageLayout m_initialLayout;
699 VkImageLayout m_finalLayout;
705 RenderPass (const vector<Attachment>& attachments,
706 const vector<Subpass>& subpasses,
707 const vector<SubpassDependency>& dependencies,
708 const vector<VkInputAttachmentAspectReference> inputAspects = vector<VkInputAttachmentAspectReference>())
709 : m_attachments (attachments)
710 , m_subpasses (subpasses)
711 , m_dependencies (dependencies)
712 , m_inputAspects (inputAspects)
716 const vector<Attachment>& getAttachments (void) const { return m_attachments; }
717 const vector<Subpass>& getSubpasses (void) const { return m_subpasses; }
718 const vector<SubpassDependency>& getDependencies (void) const { return m_dependencies; }
719 const vector<VkInputAttachmentAspectReference>& getInputAspects (void) const { return m_inputAspects; }
722 const vector<Attachment> m_attachments;
723 const vector<Subpass> m_subpasses;
724 const vector<SubpassDependency> m_dependencies;
725 const vector<VkInputAttachmentAspectReference> m_inputAspects;
732 RENDERTYPES_NONE = 0,
733 RENDERTYPES_CLEAR = (1<<1),
734 RENDERTYPES_DRAW = (1<<2)
737 enum CommandBufferTypes
739 COMMANDBUFFERTYPES_INLINE = (1<<0),
740 COMMANDBUFFERTYPES_SECONDARY = (1<<1)
745 IMAGEMEMORY_STRICT = (1<<0),
746 IMAGEMEMORY_LAZY = (1<<1)
749 TestConfig (const RenderPass& renderPass_,
750 RenderTypes renderTypes_,
751 CommandBufferTypes commandBufferTypes_,
752 ImageMemory imageMemory_,
753 const UVec2& targetSize_,
754 const UVec2& renderPos_,
755 const UVec2& renderSize_,
756 deBool useFormatCompCount_,
758 deUint32 drawStartNdx_,
759 AllocationKind allocationKind_,
760 RenderingType renderingType_,
761 vector<DeviceCoreFeature> requiredFeatures_ = vector<DeviceCoreFeature>())
762 : renderPass (renderPass_)
763 , renderTypes (renderTypes_)
764 , commandBufferTypes (commandBufferTypes_)
765 , imageMemory (imageMemory_)
766 , targetSize (targetSize_)
767 , renderPos (renderPos_)
768 , renderSize (renderSize_)
769 , useFormatCompCount (useFormatCompCount_)
771 , drawStartNdx (drawStartNdx_)
772 , allocationKind (allocationKind_)
773 , renderingType (renderingType_)
774 , requiredFeatures (requiredFeatures_)
776 DepthValuesArray shuffledDepthValues (&DEPTH_VALUES[0], &DEPTH_VALUES[DE_LENGTH_OF_ARRAY(DEPTH_VALUES)]);
777 de::Random rng (seed + 1);
779 rng.shuffle(shuffledDepthValues.begin(), shuffledDepthValues.end());
781 depthValues.push_back(shuffledDepthValues[0]);
782 depthValues.push_back(shuffledDepthValues[1]);
785 RenderPass renderPass;
786 RenderTypes renderTypes;
787 CommandBufferTypes commandBufferTypes;
788 ImageMemory imageMemory;
792 deBool useFormatCompCount;
794 deUint32 drawStartNdx;
795 AllocationKind allocationKind;
796 RenderingType renderingType;
797 vector<DeviceCoreFeature> requiredFeatures;
798 DepthValuesArray depthValues;
801 TestConfig::RenderTypes operator| (TestConfig::RenderTypes a, TestConfig::RenderTypes b)
803 return (TestConfig::RenderTypes)(((deUint32)a) | ((deUint32)b));
806 TestConfig::CommandBufferTypes operator| (TestConfig::CommandBufferTypes a, TestConfig::CommandBufferTypes b)
808 return (TestConfig::CommandBufferTypes)(((deUint32)a) | ((deUint32)b));
811 TestConfig::ImageMemory operator| (TestConfig::ImageMemory a, TestConfig::ImageMemory b)
813 return (TestConfig::ImageMemory)(((deUint32)a) | ((deUint32)b));
816 void checkSupport (Context& context, TestConfig config)
818 for (size_t featureNdx = 0; featureNdx < config.requiredFeatures.size(); featureNdx++)
819 context.requireDeviceCoreFeature(config.requiredFeatures[featureNdx]);
822 void logRenderPassInfo (TestLog& log,
823 const RenderPass& renderPass)
825 const bool useExternalInputAspect = !renderPass.getInputAspects().empty();
826 const tcu::ScopedLogSection section (log, "RenderPass", "RenderPass");
829 const tcu::ScopedLogSection attachmentsSection (log, "Attachments", "Attachments");
830 const vector<Attachment>& attachments = renderPass.getAttachments();
832 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
834 const tcu::ScopedLogSection attachmentSection (log, "Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx));
835 const Attachment& attachment = attachments[attachmentNdx];
837 log << TestLog::Message << "Format: " << attachment.getFormat() << TestLog::EndMessage;
838 log << TestLog::Message << "Samples: " << attachment.getSamples() << TestLog::EndMessage;
840 log << TestLog::Message << "LoadOp: " << attachment.getLoadOp() << TestLog::EndMessage;
841 log << TestLog::Message << "StoreOp: " << attachment.getStoreOp() << TestLog::EndMessage;
843 log << TestLog::Message << "StencilLoadOp: " << attachment.getStencilLoadOp() << TestLog::EndMessage;
844 log << TestLog::Message << "StencilStoreOp: " << attachment.getStencilStoreOp() << TestLog::EndMessage;
846 log << TestLog::Message << "InitialLayout: " << attachment.getInitialLayout() << TestLog::EndMessage;
847 log << TestLog::Message << "FinalLayout: " << attachment.getFinalLayout() << TestLog::EndMessage;
851 if (useExternalInputAspect)
853 const tcu::ScopedLogSection inputAspectSection (log, "InputAspects", "InputAspects");
855 for (size_t aspectNdx = 0; aspectNdx < renderPass.getInputAspects().size(); aspectNdx++)
857 const VkInputAttachmentAspectReference& inputAspect (renderPass.getInputAspects()[aspectNdx]);
859 log << TestLog::Message << "Subpass: " << inputAspect.subpass << TestLog::EndMessage;
860 log << TestLog::Message << "InputAttachmentIndex: " << inputAspect.inputAttachmentIndex << TestLog::EndMessage;
861 log << TestLog::Message << "AspectFlags: " << getImageAspectFlagsStr(inputAspect.aspectMask) << TestLog::EndMessage;
866 const tcu::ScopedLogSection subpassesSection (log, "Subpasses", "Subpasses");
867 const vector<Subpass>& subpasses = renderPass.getSubpasses();
869 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
871 const tcu::ScopedLogSection subpassSection (log, "Subpass" + de::toString(subpassNdx), "Subpass " + de::toString(subpassNdx));
872 const Subpass& subpass = subpasses[subpassNdx];
874 const vector<AttachmentReference>& inputAttachments = subpass.getInputAttachments();
875 const vector<AttachmentReference>& colorAttachments = subpass.getColorAttachments();
876 const vector<AttachmentReference>& resolveAttachments = subpass.getResolveAttachments();
877 const vector<deUint32>& preserveAttachments = subpass.getPreserveAttachments();
879 if (!inputAttachments.empty())
881 const tcu::ScopedLogSection inputAttachmentsSection (log, "Inputs", "Inputs");
883 for (size_t inputNdx = 0; inputNdx < inputAttachments.size(); inputNdx++)
885 const tcu::ScopedLogSection inputAttachmentSection (log, "Input" + de::toString(inputNdx), "Input " + de::toString(inputNdx));
886 const AttachmentReference& inputAttachment = inputAttachments[inputNdx];
888 log << TestLog::Message << "Attachment: " << inputAttachment.getAttachment() << TestLog::EndMessage;
889 log << TestLog::Message << "Layout: " << inputAttachment.getImageLayout() << TestLog::EndMessage;
890 if (!useExternalInputAspect)
891 log << TestLog::Message << "AspectMask: " << inputAttachment.getAspectMask() << TestLog::EndMessage;
895 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
897 const tcu::ScopedLogSection depthStencilAttachmentSection (log, "DepthStencil", "DepthStencil");
898 const AttachmentReference& depthStencilAttachment = subpass.getDepthStencilAttachment();
900 log << TestLog::Message << "Attachment: " << depthStencilAttachment.getAttachment() << TestLog::EndMessage;
901 log << TestLog::Message << "Layout: " << depthStencilAttachment.getImageLayout() << TestLog::EndMessage;
904 if (!colorAttachments.empty())
906 const tcu::ScopedLogSection colorAttachmentsSection (log, "Colors", "Colors");
908 for (size_t colorNdx = 0; colorNdx < colorAttachments.size(); colorNdx++)
910 const tcu::ScopedLogSection colorAttachmentSection (log, "Color" + de::toString(colorNdx), "Color " + de::toString(colorNdx));
911 const AttachmentReference& colorAttachment = colorAttachments[colorNdx];
913 log << TestLog::Message << "Attachment: " << colorAttachment.getAttachment() << TestLog::EndMessage;
914 log << TestLog::Message << "Layout: " << colorAttachment.getImageLayout() << TestLog::EndMessage;
918 if (!resolveAttachments.empty())
920 const tcu::ScopedLogSection resolveAttachmentsSection (log, "Resolves", "Resolves");
922 for (size_t resolveNdx = 0; resolveNdx < resolveAttachments.size(); resolveNdx++)
924 const tcu::ScopedLogSection resolveAttachmentSection (log, "Resolve" + de::toString(resolveNdx), "Resolve " + de::toString(resolveNdx));
925 const AttachmentReference& resolveAttachment = resolveAttachments[resolveNdx];
927 log << TestLog::Message << "Attachment: " << resolveAttachment.getAttachment() << TestLog::EndMessage;
928 log << TestLog::Message << "Layout: " << resolveAttachment.getImageLayout() << TestLog::EndMessage;
932 if (!preserveAttachments.empty())
934 const tcu::ScopedLogSection preserveAttachmentsSection (log, "Preserves", "Preserves");
936 for (size_t preserveNdx = 0; preserveNdx < preserveAttachments.size(); preserveNdx++)
938 const tcu::ScopedLogSection preserveAttachmentSection (log, "Preserve" + de::toString(preserveNdx), "Preserve " + de::toString(preserveNdx));
939 const deUint32 preserveAttachment = preserveAttachments[preserveNdx];
941 log << TestLog::Message << "Attachment: " << preserveAttachment << TestLog::EndMessage;
948 if (!renderPass.getDependencies().empty())
950 const tcu::ScopedLogSection dependenciesSection (log, "Dependencies", "Dependencies");
952 for (size_t depNdx = 0; depNdx < renderPass.getDependencies().size(); depNdx++)
954 const tcu::ScopedLogSection dependencySection (log, "Dependency" + de::toString(depNdx), "Dependency " + de::toString(depNdx));
955 const SubpassDependency& dep = renderPass.getDependencies()[depNdx];
957 log << TestLog::Message << "Source: " << dep.getSrcPass() << TestLog::EndMessage;
958 log << TestLog::Message << "Destination: " << dep.getDstPass() << TestLog::EndMessage;
960 log << TestLog::Message << "Source Stage Mask: " << dep.getSrcStageMask() << TestLog::EndMessage;
961 log << TestLog::Message << "Destination Stage Mask: " << dep.getDstStageMask() << TestLog::EndMessage;
963 log << TestLog::Message << "Input Mask: " << dep.getDstAccessMask() << TestLog::EndMessage;
964 log << TestLog::Message << "Output Mask: " << dep.getSrcAccessMask() << TestLog::EndMessage;
965 log << TestLog::Message << "Dependency Flags: " << getDependencyFlagsStr(dep.getFlags()) << TestLog::EndMessage;
970 std::string clearColorToString (VkFormat vkFormat, VkClearColorValue value, deBool useFormatCompCount)
972 const tcu::TextureFormat format = mapVkFormat(vkFormat);
973 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
974 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
975 const deUint32 componentCount = (useFormatCompCount ? (deUint32)tcu::getNumUsedChannels(format.order) : 4);
977 std::ostringstream stream;
981 switch (channelClass)
983 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
984 for (deUint32 i = 0; i < componentCount; i++)
990 stream << value.int32[i];
996 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
997 for (deUint32 i = 0; i < componentCount; i++)
1003 stream << value.uint32[i];
1009 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
1010 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
1011 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
1012 for (deUint32 i = 0; i < componentCount; i++)
1018 stream << value.float32[i];
1025 DE_FATAL("Unknown channel class");
1030 return stream.str();
1033 std::string clearValueToString (VkFormat vkFormat, VkClearValue value, deBool useFormatCompCount)
1035 const tcu::TextureFormat format = mapVkFormat(vkFormat);
1037 if (tcu::hasStencilComponent(format.order) || tcu::hasDepthComponent(format.order))
1039 std::ostringstream stream;
1043 if (tcu::hasStencilComponent(format.order))
1044 stream << "stencil: " << value.depthStencil.stencil;
1046 if (tcu::hasStencilComponent(format.order) && tcu::hasDepthComponent(format.order))
1049 if (tcu::hasDepthComponent(format.order))
1050 stream << "depth: " << value.depthStencil.depth;
1054 return stream.str();
1057 return clearColorToString(vkFormat, value.color, useFormatCompCount);
1060 VkClearColorValue randomColorClearValue (const Attachment& attachment, de::Random& rng, deBool useFormatCompCount)
1062 const float clearNan = tcu::Float32::nan().asFloat();
1063 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
1064 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
1065 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
1066 const deUint32 componentCount = (useFormatCompCount ? (deUint32)tcu::getNumUsedChannels(format.order) : 4);
1067 VkClearColorValue clearColor;
1069 switch (channelClass)
1071 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
1073 for (deUint32 ndx = 0; ndx < componentCount; ndx++)
1075 if (!channelMask[ndx])
1076 clearColor.int32[ndx] = std::numeric_limits<deInt32>::min();
1078 clearColor.uint32[ndx] = rng.getBool() ? 1u : 0u;
1083 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
1085 for (deUint32 ndx = 0; ndx < componentCount; ndx++)
1087 if (!channelMask[ndx])
1088 clearColor.uint32[ndx] = std::numeric_limits<deUint32>::max();
1090 clearColor.uint32[ndx] = rng.getBool() ? 1u : 0u;
1095 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
1096 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
1097 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
1099 for (deUint32 ndx = 0; ndx < componentCount; ndx++)
1101 if (!channelMask[ndx])
1102 clearColor.float32[ndx] = clearNan;
1104 clearColor.float32[ndx] = rng.getBool() ? 1.0f : 0.0f;
1110 DE_FATAL("Unknown channel class");
1116 template <typename AttachmentDesc>
1117 AttachmentDesc createAttachmentDescription (const Attachment& attachment)
1119 const AttachmentDesc attachmentDescription // VkAttachmentDescription || VkAttachmentDescription2KHR
1121 // || VkStructureType sType;
1122 DE_NULL, // || const void* pNext;
1123 0u, // VkAttachmentDescriptionFlags flags; || VkAttachmentDescriptionFlags flags;
1124 attachment.getFormat(), // VkFormat format; || VkFormat format;
1125 attachment.getSamples(), // VkSampleCountFlagBits samples; || VkSampleCountFlagBits samples;
1126 attachment.getLoadOp(), // VkAttachmentLoadOp loadOp; || VkAttachmentLoadOp loadOp;
1127 attachment.getStoreOp(), // VkAttachmentStoreOp storeOp; || VkAttachmentStoreOp storeOp;
1128 attachment.getStencilLoadOp(), // VkAttachmentLoadOp stencilLoadOp; || VkAttachmentLoadOp stencilLoadOp;
1129 attachment.getStencilStoreOp(), // VkAttachmentStoreOp stencilStoreOp; || VkAttachmentStoreOp stencilStoreOp;
1130 attachment.getInitialLayout(), // VkImageLayout initialLayout; || VkImageLayout initialLayout;
1131 attachment.getFinalLayout() // VkImageLayout finalLayout; || VkImageLayout finalLayout;
1134 return attachmentDescription;
1137 template <typename AttachmentRef>
1138 AttachmentRef createAttachmentReference (const AttachmentReference& referenceInfo)
1140 const AttachmentRef reference // VkAttachmentReference || VkAttachmentReference2KHR
1142 // || VkStructureType sType;
1143 DE_NULL, // || const void* pNext;
1144 referenceInfo.getAttachment(), // deUint32 attachment; || deUint32 attachment;
1145 referenceInfo.getImageLayout(), // VkImageLayout layout; || VkImageLayout layout;
1146 referenceInfo.getAspectMask() // || VkImageAspectFlags aspectMask;
1152 template <typename SubpassDesc, typename AttachmentRef>
1153 SubpassDesc createSubpassDescription (const Subpass& subpass,
1154 vector<AttachmentRef>* attachmentReferenceLists,
1155 vector<deUint32>* preserveAttachmentReferences)
1157 vector<AttachmentRef>& inputAttachmentReferences = attachmentReferenceLists[0];
1158 vector<AttachmentRef>& colorAttachmentReferences = attachmentReferenceLists[1];
1159 vector<AttachmentRef>& resolveAttachmentReferences = attachmentReferenceLists[2];
1160 vector<AttachmentRef>& depthStencilAttachmentReferences = attachmentReferenceLists[3];
1162 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
1163 colorAttachmentReferences.push_back(createAttachmentReference<AttachmentRef>(subpass.getColorAttachments()[attachmentNdx]));
1165 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
1166 inputAttachmentReferences.push_back(createAttachmentReference<AttachmentRef>(subpass.getInputAttachments()[attachmentNdx]));
1168 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getResolveAttachments().size(); attachmentNdx++)
1169 resolveAttachmentReferences.push_back(createAttachmentReference<AttachmentRef>(subpass.getResolveAttachments()[attachmentNdx]));
1171 depthStencilAttachmentReferences.push_back(createAttachmentReference<AttachmentRef>(subpass.getDepthStencilAttachment()));
1173 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getPreserveAttachments().size(); attachmentNdx++)
1174 preserveAttachmentReferences->push_back(subpass.getPreserveAttachments()[attachmentNdx]);
1176 DE_ASSERT(resolveAttachmentReferences.empty() || colorAttachmentReferences.size() == resolveAttachmentReferences.size());
1179 const SubpassDesc subpassDescription // VkSubpassDescription || VkSubpassDescription2KHR
1181 // || VkStructureType sType;
1182 DE_NULL, // || const void* pNext;
1183 subpass.getFlags(), // VkSubpassDescriptionFlags flags; || VkSubpassDescriptionFlags flags;
1184 subpass.getPipelineBindPoint(), // VkPipelineBindPoint pipelineBindPoint; || VkPipelineBindPoint pipelineBindPoint;
1185 0u, // || deUint32 viewMask;
1186 (deUint32)inputAttachmentReferences.size(), // deUint32 inputAttachmentCount; || deUint32 inputAttachmentCount;
1187 inputAttachmentReferences.empty() ? DE_NULL : &inputAttachmentReferences[0], // const VkAttachmentReference* pInputAttachments; || const VkAttachmentReference2KHR* pInputAttachments;
1188 (deUint32)colorAttachmentReferences.size(), // deUint32 colorAttachmentCount; || deUint32 colorAttachmentCount;
1189 colorAttachmentReferences.empty() ? DE_NULL : &colorAttachmentReferences[0], // const VkAttachmentReference* pColorAttachments; || const VkAttachmentReference2KHR* pColorAttachments;
1190 resolveAttachmentReferences.empty() ? DE_NULL : &resolveAttachmentReferences[0], // const VkAttachmentReference* pResolveAttachments; || const VkAttachmentReference2KHR* pResolveAttachments;
1191 &depthStencilAttachmentReferences[0], // const VkAttachmentReference* pDepthStencilAttachment; || const VkAttachmentReference2KHR* pDepthStencilAttachment;
1192 (deUint32)preserveAttachmentReferences->size(), // deUint32 preserveAttachmentCount; || deUint32 preserveAttachmentCount;
1193 preserveAttachmentReferences->empty() ? DE_NULL : &(*preserveAttachmentReferences)[0] // const deUint32* pPreserveAttachments; || const deUint32* pPreserveAttachments;
1196 return subpassDescription;
1200 template <typename SubpassDep>
1201 SubpassDep createSubpassDependency (const SubpassDependency& dependencyInfo)
1203 const SubpassDep dependency // VkSubpassDependency || VkSubpassDependency2KHR
1205 // || VkStructureType sType;
1206 DE_NULL, // || const void* pNext;
1207 dependencyInfo.getSrcPass(), // deUint32 srcSubpass; || deUint32 srcSubpass;
1208 dependencyInfo.getDstPass(), // deUint32 dstSubpass; || deUint32 dstSubpass;
1209 dependencyInfo.getSrcStageMask(), // VkPipelineStageFlags srcStageMask; || VkPipelineStageFlags srcStageMask;
1210 dependencyInfo.getDstStageMask(), // VkPipelineStageFlags dstStageMask; || VkPipelineStageFlags dstStageMask;
1211 dependencyInfo.getSrcAccessMask(), // VkAccessFlags srcAccessMask; || VkAccessFlags srcAccessMask;
1212 dependencyInfo.getDstAccessMask(), // VkAccessFlags dstAccessMask; || VkAccessFlags dstAccessMask;
1213 dependencyInfo.getFlags(), // VkDependencyFlags dependencyFlags; || VkDependencyFlags dependencyFlags;
1214 0u // || deInt32 viewOffset;
1220 de::MovePtr<VkRenderPassInputAttachmentAspectCreateInfo> createRenderPassInputAttachmentAspectCreateInfo(const RenderPass& renderPassInfo)
1222 de::MovePtr<VkRenderPassInputAttachmentAspectCreateInfo> result (DE_NULL);
1224 if (!renderPassInfo.getInputAspects().empty())
1226 const VkRenderPassInputAttachmentAspectCreateInfo inputAspectCreateInfo =
1228 VK_STRUCTURE_TYPE_RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO,
1231 (deUint32)renderPassInfo.getInputAspects().size(),
1232 renderPassInfo.getInputAspects().data(),
1235 result = de::MovePtr<VkRenderPassInputAttachmentAspectCreateInfo>(new VkRenderPassInputAttachmentAspectCreateInfo(inputAspectCreateInfo));
1241 template<typename AttachmentDesc, typename AttachmentRef, typename SubpassDesc, typename SubpassDep, typename RenderPassCreateInfo>
1242 Move<VkRenderPass> createRenderPass (const DeviceInterface& vk,
1244 const RenderPass& renderPassInfo)
1246 const size_t perSubpassAttachmentReferenceLists = 4;
1247 vector<AttachmentDesc> attachments;
1248 vector<SubpassDesc> subpasses;
1249 vector<SubpassDep> dependencies;
1250 vector<vector<AttachmentRef> > attachmentReferenceLists(renderPassInfo.getSubpasses().size() * perSubpassAttachmentReferenceLists);
1251 vector<vector<deUint32> > preserveAttachments(renderPassInfo.getSubpasses().size());
1252 de::MovePtr<VkRenderPassInputAttachmentAspectCreateInfo> inputAspectCreateInfo(createRenderPassInputAttachmentAspectCreateInfo(renderPassInfo));
1254 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
1255 attachments.push_back(createAttachmentDescription<AttachmentDesc>(renderPassInfo.getAttachments()[attachmentNdx]));
1257 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); subpassNdx++)
1258 subpasses.push_back(createSubpassDescription<SubpassDesc>(renderPassInfo.getSubpasses()[subpassNdx], &(attachmentReferenceLists[subpassNdx * perSubpassAttachmentReferenceLists]), &preserveAttachments[subpassNdx]));
1260 for (size_t depNdx = 0; depNdx < renderPassInfo.getDependencies().size(); depNdx++)
1261 dependencies.push_back(createSubpassDependency<SubpassDep>(renderPassInfo.getDependencies()[depNdx]));
1263 const RenderPassCreateInfo renderPassCreator // VkRenderPassCreateInfo || VkRenderPassCreateInfo2KHR
1265 // VkStructureType sType; || VkStructureType sType;
1266 inputAspectCreateInfo.get(), // const void* pNext; || const void* pNext;
1267 (VkRenderPassCreateFlags)0u, // VkRenderPassCreateFlags flags; || VkRenderPassCreateFlags flags;
1268 (deUint32)attachments.size(), // deUint32 attachmentCount; || deUint32 attachmentCount;
1269 (attachments.empty() ? DE_NULL : &attachments[0]), // const VkAttachmentDescription* pAttachments; || const VkAttachmentDescription2KHR* pAttachments;
1270 (deUint32)subpasses.size(), // deUint32 subpassCount; || deUint32 subpassCount;
1271 (subpasses.empty() ? DE_NULL : &subpasses[0]), // const VkSubpassDescription* pSubpasses; || const VkSubpassDescription2KHR* pSubpasses;
1272 (deUint32)dependencies.size(), // deUint32 dependencyCount; || deUint32 dependencyCount;
1273 (dependencies.empty() ? DE_NULL : &dependencies[0]), // const VkSubpassDependency* pDependencies; || const VkSubpassDependency2KHR* pDependencies;
1274 0u, // || deUint32 correlatedViewMaskCount;
1275 DE_NULL // || const deUint32* pCorrelatedViewMasks;
1278 return renderPassCreator.createRenderPass(vk, device);
1281 Move<VkRenderPass> createRenderPass (const DeviceInterface& vk,
1283 const RenderPass& renderPassInfo,
1284 const RenderingType renderPassType)
1286 switch (renderPassType)
1288 case RENDERING_TYPE_RENDERPASS_LEGACY:
1289 return createRenderPass<AttachmentDescription1, AttachmentReference1, SubpassDescription1, SubpassDependency1, RenderPassCreateInfo1>(vk, device, renderPassInfo);
1290 case RENDERING_TYPE_RENDERPASS2:
1291 return createRenderPass<AttachmentDescription2, AttachmentReference2, SubpassDescription2, SubpassDependency2, RenderPassCreateInfo2>(vk, device, renderPassInfo);
1293 TCU_THROW(InternalError, "Impossible");
1297 Move<VkFramebuffer> createFramebuffer (const DeviceInterface& vk,
1299 VkRenderPass renderPass,
1301 const vector<VkImageView>& attachments)
1303 return createFramebuffer(vk, device, 0u, renderPass, (deUint32)attachments.size(), attachments.empty() ? DE_NULL : &attachments[0], size.x(), size.y(), 1u);
1306 Move<VkImage> createAttachmentImage (const DeviceInterface& vk,
1308 deUint32 queueIndex,
1311 VkSampleCountFlagBits samples,
1312 VkImageUsageFlags usageFlags,
1313 VkImageLayout layout)
1315 VkImageUsageFlags targetUsageFlags = 0;
1316 const tcu::TextureFormat textureFormat = mapVkFormat(format);
1318 DE_ASSERT(!(tcu::hasDepthComponent(vk::mapVkFormat(format).order) || tcu::hasStencilComponent(vk::mapVkFormat(format).order))
1319 || ((usageFlags & vk::VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) == 0));
1321 DE_ASSERT((tcu::hasDepthComponent(vk::mapVkFormat(format).order) || tcu::hasStencilComponent(vk::mapVkFormat(format).order))
1322 || ((usageFlags & vk::VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0));
1324 if (tcu::hasDepthComponent(textureFormat.order) || tcu::hasStencilComponent(textureFormat.order))
1325 targetUsageFlags |= vk::VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
1327 targetUsageFlags |= vk::VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
1329 return createImage(vk, device,
1330 (VkImageCreateFlags)0,
1333 vk::makeExtent3D(size.x(), size.y(), 1u),
1337 VK_IMAGE_TILING_OPTIMAL,
1338 usageFlags | targetUsageFlags,
1339 VK_SHARING_MODE_EXCLUSIVE,
1345 de::MovePtr<Allocation> createImageMemory (const InstanceInterface& vki,
1346 const VkPhysicalDevice& vkd,
1347 const DeviceInterface& vk,
1349 Allocator& allocator,
1352 AllocationKind allocationKind)
1354 const MemoryRequirement memoryRequirement = lazy ? MemoryRequirement::LazilyAllocated : MemoryRequirement::Any;
1355 de::MovePtr<Allocation> allocation = allocateImage(vki, vk, vkd, device, image, memoryRequirement, allocator, allocationKind);
1357 bindImageMemory(vk, device, image, allocation->getMemory(), allocation->getOffset());
1362 Move<VkImageView> createImageAttachmentView (const DeviceInterface& vk,
1366 VkImageAspectFlags aspect)
1368 const VkImageSubresourceRange range =
1377 return createImageView(vk, device, 0u, image, VK_IMAGE_VIEW_TYPE_2D, format, makeComponentMappingRGBA(), range);
1380 VkClearValue randomClearValue (const Attachment& attachment, de::Random& rng, deBool useFormatCompCount, const DepthValuesArray& depthValues)
1382 const float clearNan = tcu::Float32::nan().asFloat();
1383 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
1385 if (tcu::hasStencilComponent(format.order) || tcu::hasDepthComponent(format.order))
1387 VkClearValue clearValue;
1389 clearValue.depthStencil.depth = clearNan;
1390 clearValue.depthStencil.stencil = 0xCDu;
1392 if (tcu::hasStencilComponent(format.order))
1393 clearValue.depthStencil.stencil = rng.getBool()
1397 if (tcu::hasDepthComponent(format.order))
1398 clearValue.depthStencil.depth = float(depthValues[rng.getBool() ? 1 : 0]) / 255.0f;
1404 VkClearValue clearValue;
1406 clearValue.color = randomColorClearValue(attachment, rng, useFormatCompCount);
1412 class AttachmentResources
1415 AttachmentResources (const InstanceInterface& vki,
1416 const VkPhysicalDevice& physDevice,
1417 const DeviceInterface& vk,
1419 Allocator& allocator,
1420 deUint32 queueIndex,
1422 const Attachment& attachmentInfo,
1423 VkImageUsageFlags usageFlags,
1424 const AllocationKind allocationKind)
1425 : m_image (createAttachmentImage(vk, device, queueIndex, size, attachmentInfo.getFormat(), attachmentInfo.getSamples(), usageFlags, VK_IMAGE_LAYOUT_UNDEFINED))
1426 , m_imageMemory (createImageMemory(vki, physDevice, vk, device, allocator, *m_image, ((usageFlags & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0), allocationKind))
1427 , m_attachmentView (createImageAttachmentView(vk, device, *m_image, attachmentInfo.getFormat(), getImageAspectFlags(attachmentInfo.getFormat())))
1429 const tcu::TextureFormat format = mapVkFormat(attachmentInfo.getFormat());
1430 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
1431 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
1433 if (isDepthFormat && isStencilFormat)
1435 m_depthInputAttachmentView = createImageAttachmentView(vk, device, *m_image, attachmentInfo.getFormat(), VK_IMAGE_ASPECT_DEPTH_BIT);
1436 m_stencilInputAttachmentView = createImageAttachmentView(vk, device, *m_image, attachmentInfo.getFormat(), VK_IMAGE_ASPECT_STENCIL_BIT);
1438 m_inputAttachmentViews = std::make_pair(*m_depthInputAttachmentView, *m_stencilInputAttachmentView);
1441 m_inputAttachmentViews = std::make_pair(*m_attachmentView, (vk::VkImageView)0u);
1443 if ((usageFlags & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)
1445 if (tcu::hasDepthComponent(format.order) && tcu::hasStencilComponent(format.order))
1447 const tcu::TextureFormat depthFormat = getDepthCopyFormat(attachmentInfo.getFormat());
1448 const tcu::TextureFormat stencilFormat = getStencilCopyFormat(attachmentInfo.getFormat());
1450 m_bufferSize = size.x() * size.y() * depthFormat.getPixelSize();
1451 m_secondaryBufferSize = size.x() * size.y() * stencilFormat.getPixelSize();
1453 m_buffer = createBuffer(vk, device, 0, m_bufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_SHARING_MODE_EXCLUSIVE, 1, &queueIndex);
1454 m_bufferMemory = allocateBuffer(vki, vk, physDevice, device, *m_buffer, MemoryRequirement::HostVisible, allocator, allocationKind);
1456 bindBufferMemory(vk, device, *m_buffer, m_bufferMemory->getMemory(), m_bufferMemory->getOffset());
1458 m_secondaryBuffer = createBuffer(vk, device, 0, m_secondaryBufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_SHARING_MODE_EXCLUSIVE, 1, &queueIndex);
1459 m_secondaryBufferMemory = allocateBuffer(vki, vk, physDevice, device, *m_secondaryBuffer, MemoryRequirement::HostVisible, allocator, allocationKind);
1461 bindBufferMemory(vk, device, *m_secondaryBuffer, m_secondaryBufferMemory->getMemory(), m_secondaryBufferMemory->getOffset());
1465 m_bufferSize = size.x() * size.y() * format.getPixelSize();
1467 m_buffer = createBuffer(vk, device, 0, m_bufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_SHARING_MODE_EXCLUSIVE, 1, &queueIndex);
1468 m_bufferMemory = allocateBuffer(vki, vk, physDevice, device, *m_buffer, MemoryRequirement::HostVisible, allocator, allocationKind);
1470 bindBufferMemory(vk, device, *m_buffer, m_bufferMemory->getMemory(), m_bufferMemory->getOffset());
1475 const pair<VkImageView, VkImageView>& getInputAttachmentViews (void) const
1477 return m_inputAttachmentViews;
1480 ~AttachmentResources (void)
1484 VkImageView getAttachmentView (void) const
1486 return *m_attachmentView;
1489 VkImage getImage (void) const
1494 VkBuffer getBuffer (void) const
1496 DE_ASSERT(*m_buffer != DE_NULL);
1500 VkDeviceSize getBufferSize (void) const
1502 DE_ASSERT(*m_buffer != DE_NULL);
1503 return m_bufferSize;
1506 const Allocation& getResultMemory (void) const
1508 DE_ASSERT(m_bufferMemory);
1509 return *m_bufferMemory;
1512 VkBuffer getSecondaryBuffer (void) const
1514 DE_ASSERT(*m_secondaryBuffer != DE_NULL);
1515 return *m_secondaryBuffer;
1518 VkDeviceSize getSecondaryBufferSize (void) const
1520 DE_ASSERT(*m_secondaryBuffer != DE_NULL);
1521 return m_secondaryBufferSize;
1524 const Allocation& getSecondaryResultMemory (void) const
1526 DE_ASSERT(m_secondaryBufferMemory);
1527 return *m_secondaryBufferMemory;
1531 const Unique<VkImage> m_image;
1532 const UniquePtr<Allocation> m_imageMemory;
1533 const Unique<VkImageView> m_attachmentView;
1535 Move<VkImageView> m_depthInputAttachmentView;
1536 Move<VkImageView> m_stencilInputAttachmentView;
1537 pair<VkImageView, VkImageView> m_inputAttachmentViews;
1539 Move<VkBuffer> m_buffer;
1540 VkDeviceSize m_bufferSize;
1541 de::MovePtr<Allocation> m_bufferMemory;
1543 Move<VkBuffer> m_secondaryBuffer;
1544 VkDeviceSize m_secondaryBufferSize;
1545 de::MovePtr<Allocation> m_secondaryBufferMemory;
1548 void uploadBufferData (const DeviceInterface& vk,
1550 const Allocation& memory,
1553 VkDeviceSize nonCoherentAtomSize)
1555 // Expand the range to flush to account for the nonCoherentAtomSize
1556 const VkDeviceSize roundedOffset = de::roundDown(memory.getOffset(), nonCoherentAtomSize);
1557 const VkDeviceSize roundedSize = de::roundUp(memory.getOffset() - roundedOffset + static_cast<VkDeviceSize>(size), nonCoherentAtomSize);
1559 const VkMappedMemoryRange range =
1561 VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // sType;
1563 memory.getMemory(), // mem;
1564 roundedOffset, // offset;
1565 roundedSize, // size;
1567 void* const ptr = memory.getHostPtr();
1569 deMemcpy(ptr, data, size);
1570 VK_CHECK(vk.flushMappedMemoryRanges(device, 1, &range));
1573 VkImageAspectFlagBits getPrimaryImageAspect (tcu::TextureFormat::ChannelOrder order)
1575 DE_STATIC_ASSERT(tcu::TextureFormat::CHANNELORDER_LAST == 22);
1579 case tcu::TextureFormat::D:
1580 case tcu::TextureFormat::DS:
1581 return VK_IMAGE_ASPECT_DEPTH_BIT;
1583 case tcu::TextureFormat::S:
1584 return VK_IMAGE_ASPECT_STENCIL_BIT;
1587 return VK_IMAGE_ASPECT_COLOR_BIT;
1591 deUint32 getAttachmentNdx (const vector<AttachmentReference>& colorAttachments, size_t ndx)
1593 return (colorAttachments[ndx].getAttachment() == VK_ATTACHMENT_UNUSED) ? (deUint32)ndx : colorAttachments[ndx].getAttachment();
1599 RenderQuad (const Vec2& posA, const Vec2& posB)
1602 m_vertices[0] = posA;
1603 m_vertices[1] = Vec2(posA[0], posB[1]);
1604 m_vertices[2] = posB;
1606 m_vertices[3] = posB;
1607 m_vertices[4] = Vec2(posB[0], posA[1]);
1608 m_vertices[5] = posA;
1611 const Vec2& getCornerA (void) const
1613 return m_vertices[0];
1616 const Vec2& getCornerB (void) const
1618 return m_vertices[2];
1621 const void* getVertexPointer (void) const
1623 return &m_vertices[0];
1626 size_t getVertexDataSize (void) const
1628 return sizeof(Vec2) * m_vertices.size();
1632 vector<Vec2> m_vertices;
1638 ColorClear (const UVec2& offset,
1640 const VkClearColorValue& color)
1647 const UVec2& getOffset (void) const { return m_offset; }
1648 const UVec2& getSize (void) const { return m_size; }
1649 const VkClearColorValue& getColor (void) const { return m_color; }
1654 VkClearColorValue m_color;
1657 class DepthStencilClear
1660 DepthStencilClear (const UVec2& offset,
1667 , m_stencil (stencil)
1671 const UVec2& getOffset (void) const { return m_offset; }
1672 const UVec2& getSize (void) const { return m_size; }
1673 float getDepth (void) const { return m_depth; }
1674 deUint32 getStencil (void) const { return m_stencil; }
1677 const UVec2 m_offset;
1680 const float m_depth;
1681 const deUint32 m_stencil;
1684 class SubpassRenderInfo
1687 SubpassRenderInfo (const RenderPass& renderPass,
1688 deUint32 subpassIndex,
1689 deUint32 drawStartNdx,
1692 bool omitBlendState_,
1694 const UVec2& viewportOffset,
1695 const UVec2& viewportSize,
1697 const Maybe<RenderQuad>& renderQuad,
1698 const vector<ColorClear>& colorClears,
1699 const Maybe<DepthStencilClear>& depthStencilClear)
1700 : m_viewportOffset (viewportOffset)
1701 , m_viewportSize (viewportSize)
1702 , m_subpassIndex (subpassIndex)
1703 , m_drawStartNdx (drawStartNdx)
1704 , m_isSecondary (isSecondary_)
1705 , m_omitBlendState (omitBlendState_)
1706 , m_flags (renderPass.getSubpasses()[subpassIndex].getFlags())
1707 , m_renderQuad (renderQuad)
1708 , m_colorClears (colorClears)
1709 , m_depthStencilClear (depthStencilClear)
1710 , m_colorAttachments (renderPass.getSubpasses()[subpassIndex].getColorAttachments())
1711 , m_inputAttachments (renderPass.getSubpasses()[subpassIndex].getInputAttachments())
1713 for (deUint32 attachmentNdx = 0; attachmentNdx < (deUint32)m_colorAttachments.size(); attachmentNdx++)
1714 m_colorAttachmentInfo.push_back(renderPass.getAttachments()[getAttachmentNdx(m_colorAttachments, attachmentNdx)]);
1716 if (renderPass.getSubpasses()[subpassIndex].getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
1718 m_depthStencilAttachment = tcu::just(renderPass.getSubpasses()[subpassIndex].getDepthStencilAttachment());
1719 m_depthStencilAttachmentInfo = tcu::just(renderPass.getAttachments()[renderPass.getSubpasses()[subpassIndex].getDepthStencilAttachment().getAttachment()]);
1723 const UVec2& getViewportOffset (void) const { return m_viewportOffset; }
1724 const UVec2& getViewportSize (void) const { return m_viewportSize; }
1726 deUint32 getSubpassIndex (void) const { return m_subpassIndex; }
1727 deUint32 getDrawStartNdx (void) const { return m_drawStartNdx; }
1728 bool isSecondary (void) const { return m_isSecondary; }
1729 bool getOmitBlendState (void) const { return m_omitBlendState; }
1731 const Maybe<RenderQuad>& getRenderQuad (void) const { return m_renderQuad; }
1732 const vector<ColorClear>& getColorClears (void) const { return m_colorClears; }
1733 const Maybe<DepthStencilClear>& getDepthStencilClear (void) const { return m_depthStencilClear; }
1735 deUint32 getInputAttachmentCount (void) const { return (deUint32)m_inputAttachments.size(); }
1736 deUint32 getInputAttachmentIndex (deUint32 attachmentNdx) const { return m_inputAttachments[attachmentNdx].getAttachment(); }
1737 VkImageLayout getInputAttachmentLayout (deUint32 attachmentNdx) const { return m_inputAttachments[attachmentNdx].getImageLayout(); }
1739 deUint32 getColorAttachmentCount (void) const { return (deUint32)m_colorAttachments.size(); }
1740 VkImageLayout getColorAttachmentLayout (deUint32 attachmentNdx) const { return m_colorAttachments[attachmentNdx].getImageLayout(); }
1741 deUint32 getColorAttachmentIndex (deUint32 attachmentNdx) const { return m_colorAttachments[attachmentNdx].getAttachment(); }
1742 const Attachment& getColorAttachment (deUint32 attachmentNdx) const { return m_colorAttachmentInfo[attachmentNdx]; }
1743 Maybe<VkImageLayout> getDepthStencilAttachmentLayout (void) const { return m_depthStencilAttachment ? tcu::just(m_depthStencilAttachment->getImageLayout()) : tcu::Nothing; }
1744 Maybe<deUint32> getDepthStencilAttachmentIndex (void) const { return m_depthStencilAttachment ? tcu::just(m_depthStencilAttachment->getAttachment()) : tcu::Nothing; }
1745 const Maybe<Attachment>& getDepthStencilAttachment (void) const { return m_depthStencilAttachmentInfo; }
1746 VkSubpassDescriptionFlags getSubpassFlags (void) const { return m_flags; }
1749 UVec2 m_viewportOffset;
1750 UVec2 m_viewportSize;
1752 deUint32 m_subpassIndex;
1753 deUint32 m_drawStartNdx;
1755 bool m_omitBlendState;
1756 VkSubpassDescriptionFlags m_flags;
1758 Maybe<RenderQuad> m_renderQuad;
1759 vector<ColorClear> m_colorClears;
1760 Maybe<DepthStencilClear> m_depthStencilClear;
1762 vector<AttachmentReference> m_colorAttachments;
1763 vector<Attachment> m_colorAttachmentInfo;
1765 Maybe<AttachmentReference> m_depthStencilAttachment;
1766 Maybe<Attachment> m_depthStencilAttachmentInfo;
1768 vector<AttachmentReference> m_inputAttachments;
1771 void beginCommandBuffer (const DeviceInterface& vk,
1772 VkCommandBuffer cmdBuffer,
1773 VkCommandBufferUsageFlags pBeginInfo_flags,
1774 VkRenderPass pInheritanceInfo_renderPass,
1775 deUint32 pInheritanceInfo_subpass,
1776 VkFramebuffer pInheritanceInfo_framebuffer,
1777 VkBool32 pInheritanceInfo_occlusionQueryEnable,
1778 VkQueryControlFlags pInheritanceInfo_queryFlags,
1779 VkQueryPipelineStatisticFlags pInheritanceInfo_pipelineStatistics,
1780 const SubpassRenderInfo* pRenderInfo = 0,
1781 bool dynamicRenderPass = false )
1783 VkCommandBufferInheritanceInfo pInheritanceInfo =
1785 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO,
1787 pInheritanceInfo_renderPass,
1788 pInheritanceInfo_subpass,
1789 pInheritanceInfo_framebuffer,
1790 pInheritanceInfo_occlusionQueryEnable,
1791 pInheritanceInfo_queryFlags,
1792 pInheritanceInfo_pipelineStatistics,
1794 std::vector<vk::VkFormat> colorAttachmentFormats;
1795 VkCommandBufferInheritanceRenderingInfoKHR inheritanceRenderingInfo
1797 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR,
1803 VK_FORMAT_UNDEFINED,
1804 VK_FORMAT_UNDEFINED,
1805 VK_SAMPLE_COUNT_1_BIT,
1809 for (deUint32 i = 0; i < pRenderInfo->getColorAttachmentCount(); ++i)
1810 colorAttachmentFormats.push_back(pRenderInfo->getColorAttachment(i).getFormat());
1812 inheritanceRenderingInfo.colorAttachmentCount = static_cast<deUint32>(colorAttachmentFormats.size());
1813 inheritanceRenderingInfo.pColorAttachmentFormats = colorAttachmentFormats.data();
1814 if (pRenderInfo->getDepthStencilAttachment())
1816 const VkFormat dsFormat = pRenderInfo->getDepthStencilAttachment()->getFormat();
1817 inheritanceRenderingInfo.depthAttachmentFormat = tcu::hasDepthComponent(mapVkFormat(dsFormat).order) ? dsFormat : VK_FORMAT_UNDEFINED;
1818 inheritanceRenderingInfo.stencilAttachmentFormat = tcu::hasStencilComponent(mapVkFormat(dsFormat).order) ? dsFormat : VK_FORMAT_UNDEFINED;
1820 if (pRenderInfo->getColorAttachmentCount())
1821 inheritanceRenderingInfo.rasterizationSamples = pRenderInfo->getColorAttachment(0).getSamples();
1822 else if (pRenderInfo->getDepthStencilAttachment())
1823 inheritanceRenderingInfo.rasterizationSamples = pRenderInfo->getDepthStencilAttachment()->getSamples();
1825 if (dynamicRenderPass)
1826 pInheritanceInfo.pNext = &inheritanceRenderingInfo;
1828 const VkCommandBufferBeginInfo pBeginInfo =
1830 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
1835 VK_CHECK(vk.beginCommandBuffer(cmdBuffer, &pBeginInfo));
1838 Move<VkPipeline> createSubpassPipeline (const DeviceInterface& vk,
1840 VkRenderPass renderPass,
1841 VkShaderModule vertexShaderModule,
1842 VkShaderModule fragmentShaderModule,
1843 VkPipelineLayout pipelineLayout,
1844 const SubpassRenderInfo& renderInfo)
1846 Maybe<VkSampleCountFlagBits> rasterSamples;
1847 vector<VkPipelineColorBlendAttachmentState> attachmentBlendStates;
1849 for (deUint32 attachmentNdx = 0; attachmentNdx < renderInfo.getColorAttachmentCount(); attachmentNdx++)
1851 const Attachment& attachment = renderInfo.getColorAttachment(attachmentNdx);
1853 DE_ASSERT(!rasterSamples || *rasterSamples == attachment.getSamples());
1855 rasterSamples = attachment.getSamples();
1858 const VkPipelineColorBlendAttachmentState attachmentBlendState =
1860 VK_FALSE, // blendEnable
1861 VK_BLEND_FACTOR_SRC_ALPHA, // srcBlendColor
1862 VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, // destBlendColor
1863 VK_BLEND_OP_ADD, // blendOpColor
1864 VK_BLEND_FACTOR_ONE, // srcBlendAlpha
1865 VK_BLEND_FACTOR_ONE, // destBlendAlpha
1866 VK_BLEND_OP_ADD, // blendOpAlpha
1867 (attachmentNdx < renderInfo.getDrawStartNdx() ? (deUint32)0 :
1868 VK_COLOR_COMPONENT_R_BIT|VK_COLOR_COMPONENT_G_BIT|VK_COLOR_COMPONENT_B_BIT|VK_COLOR_COMPONENT_A_BIT) // channelWriteMask
1871 attachmentBlendStates.push_back(attachmentBlendState);
1875 if (renderInfo.getDepthStencilAttachment())
1877 const Attachment& attachment = *renderInfo.getDepthStencilAttachment();
1879 DE_ASSERT(!rasterSamples || *rasterSamples == attachment.getSamples());
1880 rasterSamples = attachment.getSamples();
1883 // If there are no attachment use single sample
1885 rasterSamples = VK_SAMPLE_COUNT_1_BIT;
1887 const VkVertexInputBindingDescription vertexBinding =
1890 (deUint32)sizeof(tcu::Vec2), // strideInBytes
1891 VK_VERTEX_INPUT_RATE_VERTEX, // stepRate
1894 const VkVertexInputAttributeDescription vertexAttrib =
1898 VK_FORMAT_R32G32_SFLOAT, // format
1899 0u, // offsetInBytes
1902 const VkPipelineVertexInputStateCreateInfo vertexInputState =
1904 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // sType
1906 (VkPipelineVertexInputStateCreateFlags)0u,
1908 &vertexBinding, // pVertexBindingDescriptions
1909 1u, // attributeCount
1910 &vertexAttrib, // pVertexAttributeDescriptions
1913 const VkPipelineInputAssemblyStateCreateInfo inputAssemblyState =
1915 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, // VkStructureType sType
1916 DE_NULL, // const void* pNext
1917 0u, // VkPipelineInputAssemblyStateCreateFlags flags
1918 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, // VkPrimitiveTopology topology
1919 VK_FALSE // VkBool32 primitiveRestartEnable
1922 const VkViewport viewport =
1924 (float)renderInfo.getViewportOffset().x(), (float)renderInfo.getViewportOffset().y(),
1925 (float)renderInfo.getViewportSize().x(), (float)renderInfo.getViewportSize().y(),
1929 const VkRect2D scissor =
1931 { (deInt32)renderInfo.getViewportOffset().x(), (deInt32)renderInfo.getViewportOffset().y() },
1932 { renderInfo.getViewportSize().x(), renderInfo.getViewportSize().y() }
1935 const VkPipelineViewportStateCreateInfo viewportState =
1937 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, // VkStructureType sType
1938 DE_NULL, // const void* pNext
1939 (VkPipelineViewportStateCreateFlags)0, // VkPipelineViewportStateCreateFlags flags
1940 1u, // deUint32 viewportCount
1941 &viewport, // const VkViewport* pViewports
1942 1u, // deUint32 scissorCount
1943 &scissor // const VkRect2D* pScissors
1946 const VkPipelineRasterizationStateCreateInfo rasterizationState =
1948 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, // VkStructureType sType
1949 DE_NULL, // const void* pNext
1950 0u, // VkPipelineRasterizationStateCreateFlags flags
1951 VK_FALSE, // VkBool32 depthClampEnable
1952 VK_FALSE, // VkBool32 rasterizerDiscardEnable
1953 VK_POLYGON_MODE_FILL, // VkPolygonMode polygonMode
1954 VK_CULL_MODE_NONE, // VkCullModeFlags cullMode
1955 VK_FRONT_FACE_COUNTER_CLOCKWISE, // VkFrontFace frontFace
1956 VK_FALSE, // VkBool32 depthBiasEnable
1957 0.0f, // float depthBiasConstantFactor
1958 0.0f, // float depthBiasClamp
1959 0.0f, // float depthBiasSlopeFactor
1960 1.0f // float lineWidth
1963 const VkPipelineMultisampleStateCreateInfo multisampleState =
1965 VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, // sType
1967 (VkPipelineMultisampleStateCreateFlags)0u,
1968 *rasterSamples, // rasterSamples
1969 VK_FALSE, // sampleShadingEnable
1970 0.0f, // minSampleShading
1971 DE_NULL, // pSampleMask
1972 VK_FALSE, // alphaToCoverageEnable
1973 VK_FALSE, // alphaToOneEnable
1975 const size_t stencilIndex = renderInfo.getSubpassIndex();
1977 const VkBool32 writeDepth = renderInfo.getDepthStencilAttachmentLayout()
1978 && *renderInfo.getDepthStencilAttachmentLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
1979 && *renderInfo.getDepthStencilAttachmentLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL
1983 const VkBool32 writeStencil = renderInfo.getDepthStencilAttachmentLayout()
1984 && *renderInfo.getDepthStencilAttachmentLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
1985 && *renderInfo.getDepthStencilAttachmentLayout() != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
1989 VkStencilOp stencilOp = writeStencil ? VK_STENCIL_OP_REPLACE : VK_STENCIL_OP_KEEP;
1991 const VkPipelineDepthStencilStateCreateInfo depthStencilState =
1993 VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, // sType
1995 (VkPipelineDepthStencilStateCreateFlags)0u,
1996 writeDepth, // depthTestEnable
1997 writeDepth, // depthWriteEnable
1998 VK_COMPARE_OP_ALWAYS, // depthCompareOp
1999 VK_FALSE, // depthBoundsEnable
2000 writeStencil, // stencilTestEnable
2002 stencilOp, // stencilFailOp
2003 stencilOp, // stencilPassOp
2004 stencilOp, // stencilDepthFailOp
2005 VK_COMPARE_OP_ALWAYS, // stencilCompareOp
2006 ~0u, // stencilCompareMask
2007 ~0u, // stencilWriteMask
2008 ((stencilIndex % 2) == 0) ? ~0x0u : 0x0u // stencilReference
2011 stencilOp, // stencilFailOp
2012 stencilOp, // stencilPassOp
2013 stencilOp, // stencilDepthFailOp
2014 VK_COMPARE_OP_ALWAYS, // stencilCompareOp
2015 ~0u, // stencilCompareMask
2016 ~0u, // stencilWriteMask
2017 ((stencilIndex % 2) == 0) ? ~0x0u : 0x0u // stencilReference
2020 0.0f, // minDepthBounds;
2021 1.0f // maxDepthBounds;
2024 const VkPipelineColorBlendStateCreateInfo blendState =
2026 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // sType
2028 (VkPipelineColorBlendStateCreateFlags)0u,
2029 VK_FALSE, // logicOpEnable
2030 VK_LOGIC_OP_COPY, // logicOp
2031 (deUint32)attachmentBlendStates.size(), // attachmentCount
2032 attachmentBlendStates.empty() ? DE_NULL : &attachmentBlendStates[0],// pAttachments
2033 { 0.0f, 0.0f, 0.0f, 0.0f } // blendConst
2036 std::vector<vk::VkFormat> colorAttachmentFormats;
2037 for (deUint32 i = 0; i < renderInfo.getColorAttachmentCount(); ++i)
2038 colorAttachmentFormats.push_back(renderInfo.getColorAttachment(i).getFormat());
2040 vk::VkFormat depthFormat = VK_FORMAT_UNDEFINED;
2041 vk::VkFormat stencilFormat = VK_FORMAT_UNDEFINED;
2042 if (renderInfo.getDepthStencilAttachment())
2044 const Attachment& attachment = *renderInfo.getDepthStencilAttachment();
2045 vk::VkFormat depthStencilFormat = attachment.getFormat();
2046 if (depthStencilFormat != VK_FORMAT_UNDEFINED)
2048 if (tcu::hasDepthComponent(mapVkFormat(depthStencilFormat).order))
2050 depthFormat = depthStencilFormat;
2052 if (tcu::hasStencilComponent(mapVkFormat(depthStencilFormat).order))
2054 stencilFormat = depthStencilFormat;
2060 VkPipelineRenderingCreateInfoKHR renderingCreateInfo
2062 VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR,
2065 static_cast<deUint32>(colorAttachmentFormats.size()),
2066 colorAttachmentFormats.data(),
2071 return makeGraphicsPipeline(vk, // const DeviceInterface& vk
2072 device, // const VkDevice device
2073 pipelineLayout, // const VkPipelineLayout pipelineLayout
2074 vertexShaderModule, // const VkShaderModule vertexShaderModule
2075 DE_NULL, // const VkShaderModule tessellationControlShaderModule
2076 DE_NULL, // const VkShaderModule tessellationEvalShaderModule
2077 DE_NULL, // const VkShaderModule geometryShaderModule
2078 fragmentShaderModule, // const VkShaderModule fragmentShaderModule
2079 renderPass, // const VkRenderPass renderPass
2080 renderInfo.getSubpassIndex(), // const deUint32 subpass
2081 &vertexInputState, // const VkPipelineVertexInputStateCreateInfo* vertexInputStateCreateInfo
2082 &inputAssemblyState, // const VkPipelineInputAssemblyStateCreateInfo* pInputAssemblyState;
2083 DE_NULL, // const VkPipelineRasterizationStateCreateInfo* rasterizationStateCreateInfo
2084 &viewportState, // const VkPipelineViewportStateCreateInfo* pViewportStat;
2085 &rasterizationState, // const VkPipelineRasterizationStateCreateInfo* pRasterizationState
2086 &multisampleState, // const VkPipelineMultisampleStateCreateInfo* multisampleStateCreateInfo
2087 &depthStencilState, // const VkPipelineDepthStencilStateCreateInfo* depthStencilStateCreateInfo
2088 renderInfo.getOmitBlendState()
2089 ? DE_NULL : &blendState, // const VkPipelineColorBlendStateCreateInfo* colorBlendStateCreateInfo
2090 DE_NULL, // const VkPipelineDynamicStateCreateInfo* dynamicStateCreateInfo
2091 (renderPass == DE_NULL)
2092 ? &renderingCreateInfo : DE_NULL); // const void* pNext)
2095 class SubpassRenderer
2098 SubpassRenderer (Context& context,
2099 const DeviceInterface& vk,
2101 Allocator& allocator,
2102 VkRenderPass renderPass,
2103 VkFramebuffer framebuffer,
2104 VkCommandPool commandBufferPool,
2105 deUint32 queueFamilyIndex,
2106 const vector<VkImage>& attachmentImages,
2107 const vector<pair<VkImageView, VkImageView> >& attachmentViews,
2108 const SubpassRenderInfo& renderInfo,
2109 const vector<Attachment>& attachmentInfos,
2110 const AllocationKind allocationKind,
2111 const bool dynamicRendering)
2112 : m_renderInfo (renderInfo)
2114 const InstanceInterface& vki = context.getInstanceInterface();
2115 const VkPhysicalDevice& physDevice = context.getPhysicalDevice();
2116 const deUint32 subpassIndex = renderInfo.getSubpassIndex();
2117 vector<VkDescriptorSetLayoutBinding> bindings;
2119 for (deUint32 colorAttachmentNdx = 0; colorAttachmentNdx < renderInfo.getColorAttachmentCount(); colorAttachmentNdx++)
2121 const deUint32 attachmentNdx = (renderInfo.getColorAttachmentIndex(colorAttachmentNdx) == VK_ATTACHMENT_UNUSED) ? colorAttachmentNdx
2122 : renderInfo.getColorAttachmentIndex(colorAttachmentNdx);
2124 m_colorAttachmentImages.push_back(attachmentImages[attachmentNdx]);
2127 if (renderInfo.getDepthStencilAttachmentIndex())
2128 m_depthStencilAttachmentImage = attachmentImages[*renderInfo.getDepthStencilAttachmentIndex()];
2130 if (renderInfo.getRenderQuad())
2132 const RenderQuad& renderQuad = *renderInfo.getRenderQuad();
2134 if (renderInfo.getInputAttachmentCount() > 0)
2136 deUint32 bindingIndex = 0;
2138 for (deUint32 inputAttachmentNdx = 0; inputAttachmentNdx < renderInfo.getInputAttachmentCount(); inputAttachmentNdx++)
2140 const Attachment attachmentInfo = attachmentInfos[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)];
2141 const VkImageLayout layout = renderInfo.getInputAttachmentLayout(inputAttachmentNdx);
2142 const tcu::TextureFormat format = mapVkFormat(attachmentInfo.getFormat());
2143 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
2144 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
2145 const deUint32 bindingCount = (isDepthFormat && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
2146 && (isStencilFormat && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
2150 for (deUint32 bindingNdx = 0; bindingNdx < bindingCount; bindingNdx++)
2152 const VkDescriptorSetLayoutBinding binding =
2155 vk::VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2157 vk::VK_SHADER_STAGE_FRAGMENT_BIT,
2161 bindings.push_back(binding);
2166 const VkDescriptorSetLayoutCreateInfo createInfo =
2168 vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
2172 (deUint32)bindings.size(),
2176 m_descriptorSetLayout = vk::createDescriptorSetLayout(vk, device, &createInfo);
2179 const VkDescriptorSetLayout descriptorSetLayout = *m_descriptorSetLayout;
2180 const VkPipelineLayoutCreateInfo pipelineLayoutParams =
2182 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // sType;
2184 (vk::VkPipelineLayoutCreateFlags)0,
2185 m_descriptorSetLayout ? 1u :0u , // setLayoutCount;
2186 m_descriptorSetLayout ? &descriptorSetLayout : DE_NULL, // pSetLayouts;
2187 0u, // pushConstantRangeCount;
2188 DE_NULL, // pPushConstantRanges;
2191 m_vertexShaderModule = createShaderModule(vk, device, context.getBinaryCollection().get(de::toString(subpassIndex) + "-vert"), 0u);
2192 m_fragmentShaderModule = createShaderModule(vk, device, context.getBinaryCollection().get(de::toString(subpassIndex) + "-frag"), 0u);
2193 m_pipelineLayout = createPipelineLayout(vk, device, &pipelineLayoutParams);
2194 m_pipeline = createSubpassPipeline(vk, device, renderPass, *m_vertexShaderModule, *m_fragmentShaderModule, *m_pipelineLayout, m_renderInfo);
2196 // Round up the vertex buffer size to honor nonCoherentAtomSize.
2197 const auto properties = vk::getPhysicalDeviceProperties(context.getInstanceInterface(), context.getPhysicalDevice());
2198 const auto vertexBufferSize = de::roundUp(static_cast<VkDeviceSize>(renderQuad.getVertexDataSize()), properties.limits.nonCoherentAtomSize);
2200 m_vertexBuffer = createBuffer(vk, device, 0u, vertexBufferSize, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, VK_SHARING_MODE_EXCLUSIVE, 1u, &queueFamilyIndex);
2201 m_vertexBufferMemory = allocateBuffer(vki, vk, physDevice, device, *m_vertexBuffer, MemoryRequirement::HostVisible, allocator, allocationKind);
2203 bindBufferMemory(vk, device, *m_vertexBuffer, m_vertexBufferMemory->getMemory(), m_vertexBufferMemory->getOffset());
2205 uploadBufferData(vk, device, *m_vertexBufferMemory, renderQuad.getVertexDataSize(), renderQuad.getVertexPointer(), properties.limits.nonCoherentAtomSize);
2207 if (renderInfo.getInputAttachmentCount() > 0)
2210 const VkDescriptorPoolSize poolSize =
2212 vk::VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2213 // \note Reserve 2 per input attachment since depthStencil attachments require 2.
2214 renderInfo.getInputAttachmentCount() * 2u
2216 const VkDescriptorPoolCreateInfo createInfo =
2218 vk::VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
2220 VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
2222 // \note Reserve 2 per input attachment since depthStencil attachments require 2.
2223 renderInfo.getInputAttachmentCount() * 2u,
2228 m_descriptorPool = vk::createDescriptorPool(vk, device, &createInfo);
2231 const VkDescriptorSetAllocateInfo allocateInfo =
2233 vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
2238 &descriptorSetLayout
2241 m_descriptorSet = vk::allocateDescriptorSet(vk, device, &allocateInfo);
2244 vector<VkWriteDescriptorSet> writes (bindings.size());
2245 vector<VkDescriptorImageInfo> imageInfos (bindings.size());
2246 deUint32 bindingIndex = 0;
2248 for (deUint32 inputAttachmentNdx = 0; inputAttachmentNdx < renderInfo.getInputAttachmentCount(); inputAttachmentNdx++)
2250 const Attachment attachmentInfo = attachmentInfos[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)];
2251 const tcu::TextureFormat format = mapVkFormat(attachmentInfo.getFormat());
2252 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
2253 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
2254 const VkImageLayout inputAttachmentLayout = renderInfo.getInputAttachmentLayout(inputAttachmentNdx);
2257 if (isDepthFormat && isStencilFormat)
2259 if (inputAttachmentLayout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
2261 const VkDescriptorImageInfo imageInfo =
2264 attachmentViews[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)].first,
2265 inputAttachmentLayout
2267 imageInfos[bindingIndex] = imageInfo;
2270 const VkWriteDescriptorSet write =
2272 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2279 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2280 &imageInfos[bindingIndex],
2284 writes[bindingIndex] = write;
2290 if (inputAttachmentLayout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
2292 const VkDescriptorImageInfo imageInfo =
2295 attachmentViews[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)].second,
2296 inputAttachmentLayout
2298 imageInfos[bindingIndex] = imageInfo;
2301 const VkWriteDescriptorSet write =
2303 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2310 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2311 &imageInfos[bindingIndex],
2315 writes[bindingIndex] = write;
2323 const VkDescriptorImageInfo imageInfo =
2326 attachmentViews[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)].first,
2327 inputAttachmentLayout
2329 imageInfos[bindingIndex] = imageInfo;
2332 const VkWriteDescriptorSet write =
2334 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2341 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2342 &imageInfos[bindingIndex],
2346 writes[bindingIndex] = write;
2353 vk.updateDescriptorSets(device, (deUint32)writes.size(), &writes[0], 0u, DE_NULL);
2358 if (renderInfo.isSecondary())
2360 m_commandBuffer = allocateCommandBuffer(vk, device, commandBufferPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2362 beginCommandBuffer(vk, *m_commandBuffer, vk::VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, renderPass, subpassIndex, framebuffer, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0, &renderInfo, dynamicRendering);
2363 pushRenderCommands(vk, *m_commandBuffer);
2364 endCommandBuffer(vk, *m_commandBuffer);
2368 bool isSecondary (void) const
2370 return m_commandBuffer;
2373 VkCommandBuffer getCommandBuffer (void) const
2375 DE_ASSERT(isSecondary());
2376 return *m_commandBuffer;
2379 void pushRenderCommands (const DeviceInterface& vk,
2380 VkCommandBuffer commandBuffer)
2382 if (!m_renderInfo.getColorClears().empty())
2384 const vector<ColorClear>& colorClears (m_renderInfo.getColorClears());
2386 for (deUint32 attachmentNdx = 0; attachmentNdx < m_renderInfo.getColorAttachmentCount(); attachmentNdx++)
2388 const ColorClear& colorClear = colorClears[attachmentNdx];
2389 const VkClearAttachment attachment =
2391 VK_IMAGE_ASPECT_COLOR_BIT,
2393 makeClearValue(colorClear.getColor()),
2395 const VkClearRect rect =
2398 { (deInt32)colorClear.getOffset().x(), (deInt32)colorClear.getOffset().y() },
2399 { colorClear.getSize().x(), colorClear.getSize().y() }
2401 0u, // baseArrayLayer
2405 vk.cmdClearAttachments(commandBuffer, 1u, &attachment, 1u, &rect);
2409 if (m_renderInfo.getDepthStencilClear())
2411 const DepthStencilClear& depthStencilClear = *m_renderInfo.getDepthStencilClear();
2412 const deUint32 attachmentNdx = m_renderInfo.getColorAttachmentCount();
2413 tcu::TextureFormat format = mapVkFormat(m_renderInfo.getDepthStencilAttachment()->getFormat());
2414 const VkImageLayout layout = *m_renderInfo.getDepthStencilAttachmentLayout();
2415 const VkClearAttachment attachment =
2417 (VkImageAspectFlags)((hasDepthComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL ? VK_IMAGE_ASPECT_DEPTH_BIT : 0)
2418 | (hasStencilComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL ? VK_IMAGE_ASPECT_STENCIL_BIT : 0)),
2420 makeClearValueDepthStencil(depthStencilClear.getDepth(), depthStencilClear.getStencil())
2422 const VkClearRect rect =
2425 { (deInt32)depthStencilClear.getOffset().x(), (deInt32)depthStencilClear.getOffset().y() },
2426 { depthStencilClear.getSize().x(), depthStencilClear.getSize().y() }
2428 0u, // baseArrayLayer
2432 if ((tcu::hasDepthComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
2433 || (tcu::hasStencilComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL))
2435 vk.cmdClearAttachments(commandBuffer, 1u, &attachment, 1u, &rect);
2439 vector<VkImageMemoryBarrier> selfDeps;
2440 VkPipelineStageFlags srcStages = 0;
2441 VkPipelineStageFlags dstStages = 0;
2443 for (deUint32 inputAttachmentNdx = 0; inputAttachmentNdx < m_renderInfo.getInputAttachmentCount(); inputAttachmentNdx++)
2445 for (deUint32 colorAttachmentNdx = 0; colorAttachmentNdx < m_renderInfo.getColorAttachmentCount(); colorAttachmentNdx++)
2447 if (m_renderInfo.getInputAttachmentIndex(inputAttachmentNdx) == m_renderInfo.getColorAttachmentIndex(colorAttachmentNdx))
2449 const VkImageMemoryBarrier barrier =
2451 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2454 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // srcAccessMask
2455 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT, // dstAccessMask
2457 VK_IMAGE_LAYOUT_GENERAL, // oldLayout
2458 VK_IMAGE_LAYOUT_GENERAL, // newLayout
2460 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex
2461 VK_QUEUE_FAMILY_IGNORED, // destQueueFamilyIndex
2463 m_colorAttachmentImages[colorAttachmentNdx], // image
2464 { // subresourceRange
2465 VK_IMAGE_ASPECT_COLOR_BIT, // aspect
2468 0, // baseArraySlice
2473 srcStages |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
2474 dstStages |= VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
2476 selfDeps.push_back(barrier);
2480 if (m_renderInfo.getDepthStencilAttachmentIndex() && (m_renderInfo.getInputAttachmentIndex(inputAttachmentNdx) == *m_renderInfo.getDepthStencilAttachmentIndex()))
2482 const tcu::TextureFormat format = mapVkFormat(m_renderInfo.getDepthStencilAttachment()->getFormat());
2483 const bool hasDepth = hasDepthComponent(format.order);
2484 const bool hasStencil = hasStencilComponent(format.order);
2485 const VkImageMemoryBarrier barrier =
2487 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
2490 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, // srcAccessMask
2491 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT, // dstAccessMask
2493 m_renderInfo.getInputAttachmentLayout(inputAttachmentNdx), // oldLayout
2494 m_renderInfo.getInputAttachmentLayout(inputAttachmentNdx), // newLayout;
2496 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex;
2497 VK_QUEUE_FAMILY_IGNORED, // destQueueFamilyIndex;
2499 m_depthStencilAttachmentImage, // image;
2500 { // subresourceRange;
2501 (hasDepth ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
2502 | (hasStencil ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u), // aspect;
2505 0, // baseArraySlice;
2510 srcStages |= VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT;
2511 dstStages |= VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
2513 selfDeps.push_back(barrier);
2517 if (!selfDeps.empty())
2519 DE_ASSERT(srcStages != 0);
2520 DE_ASSERT(dstStages != 0);
2521 vk.cmdPipelineBarrier(commandBuffer, srcStages, dstStages, VK_DEPENDENCY_BY_REGION_BIT, 0, DE_NULL, 0, DE_NULL, (deUint32)selfDeps.size(), &selfDeps[0]);
2524 if (m_renderInfo.getRenderQuad())
2526 const VkDeviceSize offset = 0;
2527 const VkBuffer vertexBuffer = *m_vertexBuffer;
2529 vk.cmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
2531 if (m_descriptorSet)
2533 const VkDescriptorSet descriptorSet = *m_descriptorSet;
2534 vk.cmdBindDescriptorSets(commandBuffer, vk::VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipelineLayout, 0u, 1u, &descriptorSet, 0u, NULL);
2537 vk.cmdBindVertexBuffers(commandBuffer, 0u, 1u, &vertexBuffer, &offset);
2538 vk.cmdDraw(commandBuffer, 6u, 1u, 0u, 0u);
2543 const SubpassRenderInfo m_renderInfo;
2544 Move<VkCommandBuffer> m_commandBuffer;
2545 Move<VkPipeline> m_pipeline;
2546 Move<VkDescriptorSetLayout> m_descriptorSetLayout;
2547 Move<VkPipelineLayout> m_pipelineLayout;
2549 Move<VkShaderModule> m_vertexShaderModule;
2550 Move<VkShaderModule> m_fragmentShaderModule;
2552 Move<VkDescriptorPool> m_descriptorPool;
2553 Move<VkDescriptorSet> m_descriptorSet;
2554 Move<VkBuffer> m_vertexBuffer;
2555 de::MovePtr<Allocation> m_vertexBufferMemory;
2556 vector<VkImage> m_colorAttachmentImages;
2557 VkImage m_depthStencilAttachmentImage;
2560 void pushImageInitializationCommands (const DeviceInterface& vk,
2561 VkCommandBuffer commandBuffer,
2562 const vector<Attachment>& attachmentInfo,
2563 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
2564 deUint32 queueIndex,
2565 const vector<Maybe<VkClearValue> >& clearValues)
2568 vector<VkImageMemoryBarrier> initializeLayouts;
2570 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2572 if (!clearValues[attachmentNdx])
2575 const VkImageMemoryBarrier barrier =
2577 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
2580 (VkAccessFlags)0, // srcAccessMask
2581 getAllMemoryReadFlags() | VK_ACCESS_TRANSFER_WRITE_BIT, // dstAccessMask
2583 VK_IMAGE_LAYOUT_UNDEFINED, // oldLayout
2584 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // newLayout;
2586 queueIndex, // srcQueueFamilyIndex;
2587 queueIndex, // destQueueFamilyIndex;
2589 attachmentResources[attachmentNdx]->getImage(), // image;
2590 { // subresourceRange;
2591 getImageAspectFlags(attachmentInfo[attachmentNdx].getFormat()), // aspect;
2594 0, // baseArraySlice;
2599 initializeLayouts.push_back(barrier);
2602 if (!initializeLayouts.empty())
2603 vk.cmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT,
2604 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, (VkDependencyFlags)0,
2605 0, (const VkMemoryBarrier*)DE_NULL,
2606 0, (const VkBufferMemoryBarrier*)DE_NULL,
2607 (deUint32)initializeLayouts.size(), &initializeLayouts[0]);
2610 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2612 if (!clearValues[attachmentNdx])
2615 const tcu::TextureFormat format = mapVkFormat(attachmentInfo[attachmentNdx].getFormat());
2617 if (hasStencilComponent(format.order) || hasDepthComponent(format.order))
2619 const float clearNan = tcu::Float32::nan().asFloat();
2620 const float clearDepth = hasDepthComponent(format.order) ? clearValues[attachmentNdx]->depthStencil.depth : clearNan;
2621 const deUint32 clearStencil = hasStencilComponent(format.order) ? clearValues[attachmentNdx]->depthStencil.stencil : 0xDEu;
2622 const VkClearDepthStencilValue depthStencil =
2627 const VkImageSubresourceRange range =
2629 (VkImageAspectFlags)((hasDepthComponent(format.order) ? VK_IMAGE_ASPECT_DEPTH_BIT : 0)
2630 | (hasStencilComponent(format.order) ? VK_IMAGE_ASPECT_STENCIL_BIT : 0)),
2637 vk.cmdClearDepthStencilImage(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &depthStencil, 1, &range);
2641 const VkImageSubresourceRange range =
2643 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask;
2646 0, // baseArrayLayer;
2649 const VkClearColorValue clearColor = clearValues[attachmentNdx]->color;
2651 vk.cmdClearColorImage(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clearColor, 1, &range);
2656 vector<VkImageMemoryBarrier> renderPassLayouts;
2658 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2660 const VkImageLayout oldLayout = clearValues[attachmentNdx] ? VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL : VK_IMAGE_LAYOUT_UNDEFINED;
2661 const VkImageMemoryBarrier barrier =
2663 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
2666 getMemoryFlagsForLayout(oldLayout), // srcAccessMask
2667 getAllMemoryReadFlags() | getMemoryFlagsForLayout(attachmentInfo[attachmentNdx].getInitialLayout()), // dstAccessMask
2669 oldLayout, // oldLayout
2670 attachmentInfo[attachmentNdx].getInitialLayout(), // newLayout;
2672 queueIndex, // srcQueueFamilyIndex;
2673 queueIndex, // destQueueFamilyIndex;
2675 attachmentResources[attachmentNdx]->getImage(), // image;
2676 { // subresourceRange;
2677 getImageAspectFlags(attachmentInfo[attachmentNdx].getFormat()), // aspect;
2680 0, // baseArraySlice;
2685 renderPassLayouts.push_back(barrier);
2688 if (!renderPassLayouts.empty())
2689 vk.cmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT,
2690 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, (VkDependencyFlags)0,
2691 0, (const VkMemoryBarrier*)DE_NULL,
2692 0, (const VkBufferMemoryBarrier*)DE_NULL,
2693 (deUint32)renderPassLayouts.size(), &renderPassLayouts[0]);
2697 template<typename RenderpassSubpass>
2698 void pushRenderPassCommands (const DeviceInterface& vk,
2699 VkCommandBuffer commandBuffer,
2700 VkRenderPass renderPass,
2701 VkFramebuffer framebuffer,
2702 const vector<de::SharedPtr<SubpassRenderer> >& subpassRenderers,
2703 const UVec2& renderPos,
2704 const UVec2& renderSize,
2705 const vector<Maybe<VkClearValue> >& renderPassClearValues,
2706 TestConfig::RenderTypes render)
2708 const float clearNan = tcu::Float32::nan().asFloat();
2709 vector<VkClearValue> attachmentClearValues;
2710 const typename RenderpassSubpass::SubpassEndInfo subpassEndInfo (DE_NULL);
2712 for (size_t attachmentNdx = 0; attachmentNdx < renderPassClearValues.size(); attachmentNdx++)
2714 if (renderPassClearValues[attachmentNdx])
2715 attachmentClearValues.push_back(*renderPassClearValues[attachmentNdx]);
2717 attachmentClearValues.push_back(makeClearValueColorF32(clearNan, clearNan, clearNan, clearNan));
2721 const VkRect2D renderArea =
2723 { (deInt32)renderPos.x(), (deInt32)renderPos.y() },
2724 { renderSize.x(), renderSize.y() }
2727 for (size_t subpassNdx = 0; subpassNdx < subpassRenderers.size(); subpassNdx++)
2729 const VkSubpassContents contents = subpassRenderers[subpassNdx]->isSecondary() ? VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS : VK_SUBPASS_CONTENTS_INLINE;
2730 const typename RenderpassSubpass::SubpassBeginInfo subpassBeginInfo (DE_NULL, contents);
2731 const VkRenderPassBeginInfo renderPassBeginInfo = createRenderPassBeginInfo(renderPass,
2734 (deUint32)attachmentClearValues.size(),
2735 attachmentClearValues.empty() ? DE_NULL : &attachmentClearValues[0]);
2737 if (subpassNdx == 0)
2738 RenderpassSubpass::cmdBeginRenderPass(vk, commandBuffer, &renderPassBeginInfo, &subpassBeginInfo);
2740 RenderpassSubpass::cmdNextSubpass(vk, commandBuffer, &subpassBeginInfo, &subpassEndInfo);
2744 if (contents == VK_SUBPASS_CONTENTS_INLINE)
2746 subpassRenderers[subpassNdx]->pushRenderCommands(vk, commandBuffer);
2748 else if (contents == VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS)
2750 const VkCommandBuffer cmd = subpassRenderers[subpassNdx]->getCommandBuffer();
2751 vk.cmdExecuteCommands(commandBuffer, 1, &cmd);
2754 DE_FATAL("Invalid contents");
2758 RenderpassSubpass::cmdEndRenderPass(vk, commandBuffer, &subpassEndInfo);
2762 void pushDynamicRenderingCommands (const DeviceInterface& vk,
2763 VkCommandBuffer commandBuffer,
2764 const RenderPass& renderPassInfo,
2765 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
2766 const vector<de::SharedPtr<SubpassRenderer> >& subpassRenderers,
2767 const UVec2& renderPos,
2768 const UVec2& renderSize,
2769 const vector<Maybe<VkClearValue> >& renderPassClearValues,
2770 deUint32 queueIndex,
2771 TestConfig::RenderTypes render)
2773 const float clearNan = tcu::Float32::nan().asFloat();
2774 const VkClearValue clearValueNan = makeClearValueColorF32(clearNan, clearNan, clearNan, clearNan);
2776 DE_ASSERT(subpassRenderers.size() == 1);
2778 VkRenderingFlagsKHR renderingFlags = 0u;
2779 if (subpassRenderers[0]->isSecondary())
2780 renderingFlags = VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR;
2782 const VkRect2D renderArea
2784 { (deInt32)renderPos.x(), (deInt32)renderPos.y() },
2785 { renderSize.x(), renderSize.y() }
2788 // translate structures that were prepared to construct renderpass to structures needed for dynamic rendering
2790 vector<VkImageMemoryBarrier> imageBarriersBeforeRendering;
2791 vector<VkImageMemoryBarrier> imageBarriersAfterRendering;
2792 std::vector<vk::VkRenderingAttachmentInfoKHR> colorAttachmentVect;
2793 const Subpass& subpassInfo = renderPassInfo.getSubpasses()[0];
2794 const vector<AttachmentReference>& colorAttachmentsInfo = subpassInfo.getColorAttachments();
2795 const vector<AttachmentReference>& resolveAttachmentsInfo = subpassInfo.getResolveAttachments();
2797 for (deUint32 i = 0 ; i < colorAttachmentsInfo.size() ; ++i)
2799 const AttachmentReference& colorAttachmentReference = colorAttachmentsInfo[i];
2800 const deUint32 colorAttachmentIndex = colorAttachmentReference.getAttachment();
2801 const Attachment& colorAttachmentInfo = renderPassInfo.getAttachments()[colorAttachmentIndex];
2803 VkResolveModeFlagBits resolveMode = VK_RESOLVE_MODE_NONE;
2804 VkImageView resolveImageView = DE_NULL;
2805 VkImageLayout resolveImageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
2807 // handle resolve attachments if they were specified
2808 if (!resolveAttachmentsInfo.empty())
2810 const AttachmentReference& resolveAttachmentReference = resolveAttachmentsInfo[i];
2811 const deUint32 resolveAttachmentIndex = resolveAttachmentReference.getAttachment();
2812 const Attachment& resolveAttachmentInfo = renderPassInfo.getAttachments()[resolveAttachmentIndex];
2814 resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
2815 resolveImageView = attachmentResources[resolveAttachmentIndex]->getAttachmentView();
2816 resolveImageLayout = resolveAttachmentInfo.getInitialLayout();
2819 colorAttachmentVect.push_back({
2820 vk::VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR, // VkStructureType sType
2821 DE_NULL, // const void* pNext
2822 attachmentResources[colorAttachmentIndex]->getAttachmentView(), // VkImageView imageView
2823 colorAttachmentReference.getImageLayout(), // VkImageLayout imageLayout
2824 resolveMode, // VkResolveModeFlagBits resolveMode
2825 resolveImageView, // VkImageView resolveImageView
2826 resolveImageLayout, // VkImageLayout resolveImageLayout
2827 colorAttachmentInfo.getLoadOp(), // VkAttachmentLoadOp loadOp
2828 colorAttachmentInfo.getStoreOp(), // VkAttachmentStoreOp storeOp
2829 (renderPassClearValues[colorAttachmentIndex] ?
2830 *renderPassClearValues[colorAttachmentIndex] :
2831 clearValueNan) // VkClearValue clearValue
2834 const VkImageLayout initialLayout = colorAttachmentInfo.getInitialLayout();
2835 const VkImageLayout renderingLayout = colorAttachmentReference.getImageLayout();
2836 const VkImageLayout finalLayout = colorAttachmentInfo.getFinalLayout();
2838 const VkImageMemoryBarrier barrierBeforeRendering
2840 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2843 getAllMemoryWriteFlags() | getMemoryFlagsForLayout(initialLayout), // srcAccessMask
2844 getMemoryFlagsForLayout(renderingLayout), // dstAccessMask
2846 initialLayout, // oldLayout
2847 renderingLayout, // newLayout
2849 queueIndex, // srcQueueFamilyIndex
2850 queueIndex, // destQueueFamilyIndex
2852 attachmentResources[colorAttachmentIndex]->getImage(), // image
2853 { // subresourceRange
2854 getImageAspectFlags(colorAttachmentInfo.getFormat()), // aspect;
2857 0, // baseArraySlice
2861 imageBarriersBeforeRendering.push_back(barrierBeforeRendering);
2863 const VkImageMemoryBarrier barrierAfterRendering
2865 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2868 getMemoryFlagsForLayout(renderingLayout), // srcAccessMask
2869 getAllMemoryReadFlags() | getMemoryFlagsForLayout(finalLayout), // dstAccessMask
2871 renderingLayout, // oldLayout
2872 finalLayout, // newLayout
2874 queueIndex, // srcQueueFamilyIndex
2875 queueIndex, // destQueueFamilyIndex
2877 attachmentResources[colorAttachmentIndex]->getImage(), // image
2878 { // subresourceRange
2879 getImageAspectFlags(colorAttachmentInfo.getFormat()), // aspect;
2882 0, // baseArraySlice
2886 imageBarriersAfterRendering.push_back(barrierAfterRendering);
2889 VkRenderingAttachmentInfoKHR* pDepthAttachment = DE_NULL;
2890 VkRenderingAttachmentInfoKHR* pStencilAttachment = DE_NULL;
2891 VkRenderingAttachmentInfoKHR depthAttachment
2893 vk::VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR, // VkStructureType sType;
2894 DE_NULL, // const void* pNext;
2895 DE_NULL, // VkImageView imageView;
2896 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout imageLayout;
2897 VK_RESOLVE_MODE_NONE, // VkResolveModeFlagBits resolveMode;
2898 DE_NULL, // VkImageView resolveImageView;
2899 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout resolveImageLayout;
2900 VK_ATTACHMENT_LOAD_OP_LOAD, // VkAttachmentLoadOp loadOp;
2901 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp;
2902 clearValueNan // VkClearValue clearValue;
2904 VkRenderingAttachmentInfoKHR stencilAttachment = depthAttachment;
2905 const AttachmentReference& depthStencilAttachmentReference = subpassInfo.getDepthStencilAttachment();
2906 const deUint32 dsAttachmentIndex = depthStencilAttachmentReference.getAttachment();
2908 if (dsAttachmentIndex != VK_ATTACHMENT_UNUSED)
2910 const Attachment& dsAttachmentInfo = renderPassInfo.getAttachments()[dsAttachmentIndex];
2911 const tcu::TextureFormat format = mapVkFormat(dsAttachmentInfo.getFormat());
2913 if (tcu::hasDepthComponent(format.order))
2915 depthAttachment.imageView = attachmentResources[dsAttachmentIndex]->getAttachmentView();
2916 depthAttachment.imageLayout = depthStencilAttachmentReference.getImageLayout();
2917 depthAttachment.loadOp = dsAttachmentInfo.getLoadOp();
2918 depthAttachment.storeOp = dsAttachmentInfo.getStoreOp();
2920 if (renderPassClearValues[dsAttachmentIndex])
2921 depthAttachment.clearValue = *renderPassClearValues[dsAttachmentIndex];
2923 pDepthAttachment = &depthAttachment;
2926 if (tcu::hasStencilComponent(format.order))
2928 stencilAttachment.imageView = attachmentResources[dsAttachmentIndex]->getAttachmentView();
2929 stencilAttachment.imageLayout = depthStencilAttachmentReference.getImageLayout();
2930 stencilAttachment.loadOp = dsAttachmentInfo.getStencilLoadOp();
2931 stencilAttachment.storeOp = dsAttachmentInfo.getStencilStoreOp();
2933 if (renderPassClearValues[dsAttachmentIndex])
2934 stencilAttachment.clearValue = *renderPassClearValues[dsAttachmentIndex];
2936 pStencilAttachment = &stencilAttachment;
2939 const VkImageLayout initialLayout = dsAttachmentInfo.getInitialLayout();
2940 const VkImageLayout renderingLayout = depthStencilAttachmentReference.getImageLayout();
2941 const VkImageLayout finalLayout = dsAttachmentInfo.getFinalLayout();
2943 const VkImageMemoryBarrier barrierBeforeRendering
2945 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2948 getAllMemoryWriteFlags() | getMemoryFlagsForLayout(initialLayout), // srcAccessMask
2949 getMemoryFlagsForLayout(renderingLayout), // dstAccessMask
2951 initialLayout, // oldLayout
2952 renderingLayout, // newLayout
2954 queueIndex, // srcQueueFamilyIndex
2955 queueIndex, // destQueueFamilyIndex
2957 attachmentResources[dsAttachmentIndex]->getImage(), // image
2958 { // subresourceRange
2959 getImageAspectFlags(dsAttachmentInfo.getFormat()), // aspect;
2962 0, // baseArraySlice
2966 imageBarriersBeforeRendering.push_back(barrierBeforeRendering);
2968 const VkImageMemoryBarrier barrierAfterRendering
2970 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2973 getMemoryFlagsForLayout(renderingLayout), // srcAccessMask
2974 getAllMemoryReadFlags() | getMemoryFlagsForLayout(finalLayout), // dstAccessMask
2976 renderingLayout, // oldLayout
2977 finalLayout, // newLayout
2979 queueIndex, // srcQueueFamilyIndex
2980 queueIndex, // destQueueFamilyIndex
2982 attachmentResources[dsAttachmentIndex]->getImage(), // image
2983 { // subresourceRange
2984 getImageAspectFlags(dsAttachmentInfo.getFormat()), // aspect;
2987 0, // baseArraySlice
2991 imageBarriersAfterRendering.push_back(barrierAfterRendering);
2994 if (!imageBarriersBeforeRendering.empty())
2995 vk.cmdPipelineBarrier(commandBuffer,
2996 getAllPipelineStageFlags(),
2997 getAllPipelineStageFlags(),
2998 (VkDependencyFlags)0,
2999 0, (const VkMemoryBarrier*)DE_NULL,
3000 0, (const VkBufferMemoryBarrier*)DE_NULL,
3001 (deUint32)imageBarriersBeforeRendering.size(),
3002 &imageBarriersBeforeRendering[0]);
3004 vk::VkRenderingInfoKHR renderingInfo
3006 vk::VK_STRUCTURE_TYPE_RENDERING_INFO_KHR,
3008 renderingFlags, // VkRenderingFlagsKHR flags;
3009 renderArea, // VkRect2D renderArea;
3010 1u, // deUint32 layerCount;
3011 0u, // deUint32 viewMask;
3012 static_cast<deUint32>(colorAttachmentVect.size()), // deUint32 colorAttachmentCount;
3013 colorAttachmentVect.empty() ? DE_NULL : &colorAttachmentVect[0], // const VkRenderingAttachmentInfoKHR* pColorAttachments;
3014 pDepthAttachment, // const VkRenderingAttachmentInfoKHR* pDepthAttachment;
3015 pStencilAttachment // const VkRenderingAttachmentInfoKHR* pStencilAttachment;
3018 vk.cmdBeginRendering(commandBuffer, &renderingInfo);
3022 if (subpassRenderers[0]->isSecondary())
3024 const VkCommandBuffer cmd = subpassRenderers[0]->getCommandBuffer();
3025 vk.cmdExecuteCommands(commandBuffer, 1, &cmd);
3028 subpassRenderers[0]->pushRenderCommands(vk, commandBuffer);
3031 vk.cmdEndRendering(commandBuffer);
3033 if (!imageBarriersAfterRendering.empty())
3034 vk.cmdPipelineBarrier(commandBuffer,
3035 getAllPipelineStageFlags(),
3036 getAllPipelineStageFlags(),
3037 (VkDependencyFlags)0,
3038 0, (const VkMemoryBarrier*)DE_NULL,
3039 0, (const VkBufferMemoryBarrier*)DE_NULL,
3040 (deUint32)imageBarriersAfterRendering.size(),
3041 &imageBarriersAfterRendering[0]);
3044 void pushRenderPassCommands (const DeviceInterface& vk,
3045 VkCommandBuffer commandBuffer,
3046 VkRenderPass renderPass,
3047 const RenderPass& renderPassInfo,
3048 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
3049 VkFramebuffer framebuffer,
3050 const vector<de::SharedPtr<SubpassRenderer> >& subpassRenderers,
3051 const UVec2& renderPos,
3052 const UVec2& renderSize,
3053 const vector<Maybe<VkClearValue> >& renderPassClearValues,
3054 deUint32 queueIndex,
3055 TestConfig::RenderTypes render,
3056 RenderingType renderingType)
3058 switch (renderingType)
3060 case RENDERING_TYPE_RENDERPASS_LEGACY:
3061 return pushRenderPassCommands<RenderpassSubpass1>(vk, commandBuffer, renderPass, framebuffer, subpassRenderers, renderPos, renderSize, renderPassClearValues, render);
3062 case RENDERING_TYPE_RENDERPASS2:
3063 return pushRenderPassCommands<RenderpassSubpass2>(vk, commandBuffer, renderPass, framebuffer, subpassRenderers, renderPos, renderSize, renderPassClearValues, render);
3064 case RENDERING_TYPE_DYNAMIC_RENDERING:
3065 return pushDynamicRenderingCommands(vk, commandBuffer, renderPassInfo, attachmentResources, subpassRenderers, renderPos, renderSize, renderPassClearValues, queueIndex, render);
3067 TCU_THROW(InternalError, "Impossible");
3071 void pushReadImagesToBuffers (const DeviceInterface& vk,
3072 VkCommandBuffer commandBuffer,
3073 deUint32 queueIndex,
3075 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
3076 const vector<Attachment>& attachmentInfo,
3077 const vector<bool>& isLazy,
3079 const UVec2& targetSize)
3082 vector<VkImageMemoryBarrier> imageBarriers;
3084 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
3086 if (isLazy[attachmentNdx])
3089 const VkImageLayout oldLayout = attachmentInfo[attachmentNdx].getFinalLayout();
3090 const VkImageMemoryBarrier barrier =
3092 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
3095 getAllMemoryWriteFlags() | getMemoryFlagsForLayout(oldLayout), // srcAccessMask
3096 getAllMemoryReadFlags(), // dstAccessMask
3098 oldLayout, // oldLayout
3099 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // newLayout
3101 queueIndex, // srcQueueFamilyIndex
3102 queueIndex, // destQueueFamilyIndex
3104 attachmentResources[attachmentNdx]->getImage(), // image
3105 { // subresourceRange
3106 getImageAspectFlags(attachmentInfo[attachmentNdx].getFormat()), // aspect;
3109 0, // baseArraySlice
3114 imageBarriers.push_back(barrier);
3117 if (!imageBarriers.empty())
3118 vk.cmdPipelineBarrier(commandBuffer,
3119 getAllPipelineStageFlags(),
3120 getAllPipelineStageFlags(),
3121 (VkDependencyFlags)0,
3122 0, (const VkMemoryBarrier*)DE_NULL,
3123 0, (const VkBufferMemoryBarrier*)DE_NULL,
3124 (deUint32)imageBarriers.size(), &imageBarriers[0]);
3127 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
3129 if (isLazy[attachmentNdx])
3132 const tcu::TextureFormat::ChannelOrder order = mapVkFormat(attachmentInfo[attachmentNdx].getFormat()).order;
3133 const VkBufferImageCopy rect =
3136 0, // bufferRowLength
3137 0, // bufferImageHeight
3138 { // imageSubresource
3139 (vk::VkImageAspectFlags)getPrimaryImageAspect(mapVkFormat(attachmentInfo[attachmentNdx].getFormat()).order), // aspect
3144 { 0, 0, 0 }, // imageOffset
3145 { targetSize.x(), targetSize.y(), 1u } // imageExtent
3148 vk.cmdCopyImageToBuffer(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, attachmentResources[attachmentNdx]->getBuffer(), 1, &rect);
3150 if (tcu::TextureFormat::DS == order)
3152 const VkBufferImageCopy stencilRect =
3155 0, // bufferRowLength
3156 0, // bufferImageHeight
3157 { // imageSubresource
3158 VK_IMAGE_ASPECT_STENCIL_BIT, // aspect
3163 { 0, 0, 0 }, // imageOffset
3164 { targetSize.x(), targetSize.y(), 1u } // imageExtent
3167 vk.cmdCopyImageToBuffer(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, attachmentResources[attachmentNdx]->getSecondaryBuffer(), 1, &stencilRect);
3172 vector<VkBufferMemoryBarrier> bufferBarriers;
3174 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
3176 if (isLazy[attachmentNdx])
3179 const tcu::TextureFormat::ChannelOrder order = mapVkFormat(attachmentInfo[attachmentNdx].getFormat()).order;
3180 const VkBufferMemoryBarrier bufferBarrier =
3182 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
3185 getAllMemoryWriteFlags(),
3186 getAllMemoryReadFlags(),
3191 attachmentResources[attachmentNdx]->getBuffer(),
3193 attachmentResources[attachmentNdx]->getBufferSize()
3196 bufferBarriers.push_back(bufferBarrier);
3198 if (tcu::TextureFormat::DS == order)
3200 const VkBufferMemoryBarrier secondaryBufferBarrier =
3202 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
3205 getAllMemoryWriteFlags(),
3206 getAllMemoryReadFlags(),
3211 attachmentResources[attachmentNdx]->getSecondaryBuffer(),
3213 attachmentResources[attachmentNdx]->getSecondaryBufferSize()
3216 bufferBarriers.push_back(secondaryBufferBarrier);
3220 if (!bufferBarriers.empty())
3221 vk.cmdPipelineBarrier(commandBuffer,
3222 getAllPipelineStageFlags(),
3223 getAllPipelineStageFlags(),
3224 (VkDependencyFlags)0,
3225 0, (const VkMemoryBarrier*)DE_NULL,
3226 (deUint32)bufferBarriers.size(), &bufferBarriers[0],
3227 0, (const VkImageMemoryBarrier*)DE_NULL);
3234 PixelValue (const Maybe<bool>& x = tcu::Nothing,
3235 const Maybe<bool>& y = tcu::Nothing,
3236 const Maybe<bool>& z = tcu::Nothing,
3237 const Maybe<bool>& w = tcu::Nothing);
3239 void setUndefined (size_t ndx);
3240 void setValue (size_t ndx, bool value);
3241 Maybe<bool> getValue (size_t ndx) const;
3247 PixelValue::PixelValue (const Maybe<bool>& x,
3248 const Maybe<bool>& y,
3249 const Maybe<bool>& z,
3250 const Maybe<bool>& w)
3253 const Maybe<bool> values[] =
3258 for (size_t ndx = 0; ndx < DE_LENGTH_OF_ARRAY(values); ndx++)
3261 setValue(ndx, *values[ndx]);
3266 DE_ASSERT(m_status <= 0xFFu);
3269 void PixelValue::setUndefined (size_t ndx)
3272 DE_ASSERT(m_status <= 0xFFu);
3274 m_status &= (deUint16)~(0x1u << (deUint16)(ndx * 2));
3275 DE_ASSERT(m_status <= 0xFFu);
3278 void PixelValue::setValue (size_t ndx, bool value)
3281 DE_ASSERT(m_status <= 0xFFu);
3283 m_status = (deUint16)(m_status | (deUint16)(0x1u << (ndx * 2)));
3286 m_status = (deUint16)(m_status | (deUint16)(0x1u << (ndx * 2 + 1)));
3288 m_status &= (deUint16)~(0x1u << (deUint16)(ndx * 2 + 1));
3290 DE_ASSERT(m_status <= 0xFFu);
3293 Maybe<bool> PixelValue::getValue (size_t ndx) const
3296 DE_ASSERT(m_status <= 0xFFu);
3298 if ((m_status & (0x1u << (deUint16)(ndx * 2))) != 0)
3300 return just((m_status & (0x1u << (deUint32)(ndx * 2 + 1))) != 0);
3303 return tcu::Nothing;
3306 void clearReferenceValues (vector<PixelValue>& values,
3307 const UVec2& targetSize,
3308 const UVec2& offset,
3311 const PixelValue& value)
3313 DE_ASSERT(targetSize.x() * targetSize.y() == (deUint32)values.size());
3314 DE_ASSERT(offset.x() + size.x() <= targetSize.x());
3315 DE_ASSERT(offset.y() + size.y() <= targetSize.y());
3317 for (deUint32 y = offset.y(); y < offset.y() + size.y(); y++)
3318 for (deUint32 x = offset.x(); x < offset.x() + size.x(); x++)
3320 for (int compNdx = 0; compNdx < 4; compNdx++)
3324 if (value.getValue(compNdx))
3325 values[x + y * targetSize.x()].setValue(compNdx, *value.getValue(compNdx));
3327 values[x + y * targetSize.x()].setUndefined(compNdx);
3333 void markUndefined (vector<PixelValue>& values,
3335 const UVec2& targetSize,
3336 const UVec2& offset,
3339 DE_ASSERT(targetSize.x() * targetSize.y() == (deUint32)values.size());
3341 for (deUint32 y = offset.y(); y < offset.y() + size.y(); y++)
3342 for (deUint32 x = offset.x(); x < offset.x() + size.x(); x++)
3344 for (int compNdx = 0; compNdx < 4; compNdx++)
3347 values[x + y * targetSize.x()].setUndefined(compNdx);
3352 PixelValue clearValueToPixelValue (const VkClearValue& value,
3353 const tcu::TextureFormat& format,
3354 const DepthValuesArray& depthValues)
3356 const bool isDepthAttachment = hasDepthComponent(format.order);
3357 const bool isStencilAttachment = hasStencilComponent(format.order);
3358 const bool isDepthOrStencilAttachment = isDepthAttachment || isStencilAttachment;
3359 PixelValue pixelValue;
3361 if (isDepthOrStencilAttachment)
3363 if (isDepthAttachment)
3365 if (value.depthStencil.depth == float(depthValues[1]) / 255.0f)
3366 pixelValue.setValue(0, true);
3367 else if (value.depthStencil.depth == float(depthValues[0]) / 255.0f)
3368 pixelValue.setValue(0, false);
3370 DE_FATAL("Unknown depth value");
3373 if (isStencilAttachment)
3375 if (value.depthStencil.stencil == 0xFFu)
3376 pixelValue.setValue(1, true);
3377 else if (value.depthStencil.stencil == 0x0u)
3378 pixelValue.setValue(1, false);
3380 DE_FATAL("Unknown stencil value");
3385 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
3386 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
3388 switch (channelClass)
3390 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
3391 for (int i = 0; i < 4; i++)
3395 if (value.color.int32[i] == 1)
3396 pixelValue.setValue(i, true);
3397 else if (value.color.int32[i] == 0)
3398 pixelValue.setValue(i, false);
3400 DE_FATAL("Unknown clear color value");
3405 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
3406 for (int i = 0; i < 4; i++)
3410 if (value.color.uint32[i] == 1u)
3411 pixelValue.setValue(i, true);
3412 else if (value.color.uint32[i] == 0u)
3413 pixelValue.setValue(i, false);
3415 DE_FATAL("Unknown clear color value");
3420 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
3421 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
3422 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
3423 for (int i = 0; i < 4; i++)
3427 if (value.color.float32[i] == 1.0f)
3428 pixelValue.setValue(i, true);
3429 else if (value.color.float32[i] == 0.0f)
3430 pixelValue.setValue(i, false);
3432 DE_FATAL("Unknown clear color value");
3438 DE_FATAL("Unknown channel class");
3445 void renderReferenceValues (vector<vector<PixelValue> >& referenceAttachments,
3446 const RenderPass& renderPassInfo,
3447 const UVec2& targetSize,
3448 const vector<Maybe<VkClearValue> >& imageClearValues,
3449 const vector<Maybe<VkClearValue> >& renderPassClearValues,
3450 const vector<SubpassRenderInfo>& subpassRenderInfo,
3451 const UVec2& renderPos,
3452 const UVec2& renderSize,
3453 const deUint32 drawStartNdx,
3454 const DepthValuesArray& depthValues)
3456 const vector<Subpass>& subpasses = renderPassInfo.getSubpasses();
3457 vector<bool> attachmentUsed (renderPassInfo.getAttachments().size(), false);
3459 referenceAttachments.resize(renderPassInfo.getAttachments().size());
3461 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
3463 const Attachment attachment = renderPassInfo.getAttachments()[attachmentNdx];
3464 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3465 vector<PixelValue>& reference = referenceAttachments[attachmentNdx];
3467 reference.resize(targetSize.x() * targetSize.y());
3469 if (imageClearValues[attachmentNdx])
3470 clearReferenceValues(reference, targetSize, UVec2(0, 0), targetSize, BVec4(true), clearValueToPixelValue(*imageClearValues[attachmentNdx], format, depthValues));
3473 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
3475 const Subpass& subpass = subpasses[subpassNdx];
3476 const SubpassRenderInfo& renderInfo = subpassRenderInfo[subpassNdx];
3477 const vector<AttachmentReference>& colorAttachments = subpass.getColorAttachments();
3479 // Apply load op if attachment was used for the first time
3480 for (size_t attachmentNdx = 0; attachmentNdx < colorAttachments.size(); attachmentNdx++)
3482 const deUint32 attachmentIndex = getAttachmentNdx(colorAttachments, attachmentNdx);
3484 if (!attachmentUsed[attachmentIndex] && colorAttachments[attachmentNdx].getAttachment() != VK_ATTACHMENT_UNUSED)
3486 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3487 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3488 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3490 DE_ASSERT(!tcu::hasDepthComponent(format.order));
3491 DE_ASSERT(!tcu::hasStencilComponent(format.order));
3493 if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
3494 clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(true), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format, depthValues));
3495 else if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
3496 markUndefined(reference, BVec4(true), targetSize, renderPos, renderSize);
3498 attachmentUsed[attachmentIndex] = true;
3502 // Apply load op to depth/stencil attachment if it was used for the first time
3503 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
3505 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3507 // Apply load op if attachment was used for the first time
3508 if (!attachmentUsed[attachmentIndex])
3510 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3511 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3512 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3514 if (tcu::hasDepthComponent(format.order))
3516 if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
3517 clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(true, false, false, false), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format, depthValues));
3518 else if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
3519 markUndefined(reference, BVec4(true, false, false, false), targetSize, renderPos, renderSize);
3522 if (tcu::hasStencilComponent(format.order))
3524 if (attachment.getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
3525 clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(false, true, false, false), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format, depthValues));
3526 else if (attachment.getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
3527 markUndefined(reference, BVec4(false, true, false, false), targetSize, renderPos, renderSize);
3530 attachmentUsed[attachmentIndex] = true;
3534 for (size_t colorClearNdx = 0; colorClearNdx < renderInfo.getColorClears().size(); colorClearNdx++)
3536 const ColorClear& colorClear = renderInfo.getColorClears()[colorClearNdx];
3537 const UVec2 offset = colorClear.getOffset();
3538 const UVec2 size = colorClear.getSize();
3539 const deUint32 attachmentIndex = subpass.getColorAttachments()[colorClearNdx].getAttachment();
3540 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3541 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3542 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3545 value.color = colorClear.getColor();
3547 clearReferenceValues(reference, targetSize, offset, size, BVec4(true), clearValueToPixelValue(value, format, depthValues));
3550 if (renderInfo.getDepthStencilClear())
3552 const DepthStencilClear& dsClear = *renderInfo.getDepthStencilClear();
3553 const UVec2 offset = dsClear.getOffset();
3554 const UVec2 size = dsClear.getSize();
3555 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3556 const VkImageLayout layout = subpass.getDepthStencilAttachment().getImageLayout();
3557 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3558 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3559 const bool hasStencil = tcu::hasStencilComponent(format.order)
3560 && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL;
3561 const bool hasDepth = tcu::hasDepthComponent(format.order)
3562 && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
3563 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3566 value.depthStencil.depth = dsClear.getDepth();
3567 value.depthStencil.stencil = dsClear.getStencil();
3569 clearReferenceValues(reference, targetSize, offset, size, BVec4(hasDepth, hasStencil, false, false), clearValueToPixelValue(value, format, depthValues));
3572 if (renderInfo.getRenderQuad())
3574 const RenderQuad& renderQuad = *renderInfo.getRenderQuad();
3575 const Vec2 posA = renderQuad.getCornerA();
3576 const Vec2 posB = renderQuad.getCornerB();
3577 const Vec2 origin = Vec2((float)renderInfo.getViewportOffset().x(), (float)renderInfo.getViewportOffset().y()) + Vec2((float)renderInfo.getViewportSize().x(), (float)renderInfo.getViewportSize().y()) / Vec2(2.0f);
3578 const Vec2 p = Vec2((float)renderInfo.getViewportSize().x(), (float)renderInfo.getViewportSize().y()) / Vec2(2.0f);
3579 const IVec2 posAI (deRoundFloatToInt32(origin.x() + (p.x() * posA.x())),
3580 deRoundFloatToInt32(origin.y() + (p.y() * posA.y())));
3581 const IVec2 posBI (deRoundFloatToInt32(origin.x() + (p.x() * posB.x())),
3582 deRoundFloatToInt32(origin.y() + (p.y() * posB.y())));
3584 DE_ASSERT(posAI.x() < posBI.x());
3585 DE_ASSERT(posAI.y() < posBI.y());
3587 if (subpass.getInputAttachments().empty())
3589 for (size_t attachmentRefNdx = drawStartNdx; attachmentRefNdx < subpass.getColorAttachments().size(); attachmentRefNdx++)
3591 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentRefNdx].getAttachment();
3593 if (attachmentIndex == VK_ATTACHMENT_UNUSED)
3596 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3597 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3598 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
3599 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3601 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3602 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3604 for (int compNdx = 0; compNdx < 4; compNdx++)
3606 const size_t index = subpassNdx + attachmentIndex + compNdx;
3607 const BoolOp op = boolOpFromIndex(index);
3608 const bool boolX = x % 2 == (int)(index % 2);
3609 const bool boolY = y % 2 == (int)((index / 2) % 2);
3611 if (channelMask[compNdx])
3612 reference[x + y * targetSize.x()].setValue(compNdx, performBoolOp(op, boolX, boolY));
3617 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
3619 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3620 const VkImageLayout layout = subpass.getDepthStencilAttachment().getImageLayout();
3621 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3622 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3623 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3625 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3626 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3628 if (tcu::hasDepthComponent(format.order)
3629 && layout != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3630 && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
3632 const size_t index = subpassNdx + 1;
3633 const BoolOp op = boolOpFromIndex(index);
3634 const bool boolX = x % 2 == (int)(index % 2);
3635 const bool boolY = y % 2 == (int)((index / 2) % 2);
3637 reference[x + y * targetSize.x()].setValue(0, performBoolOp(op, boolX, boolY));
3640 if (tcu::hasStencilComponent(format.order)
3641 && layout != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3642 && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
3644 const size_t index = subpassNdx;
3645 reference[x + y * targetSize.x()].setValue(1, (index % 2) == 0);
3652 size_t outputComponentCount = 0;
3653 vector<Maybe<bool> > inputs;
3655 DE_ASSERT(posAI.x() < posBI.x());
3656 DE_ASSERT(posAI.y() < posBI.y());
3658 for (size_t attachmentRefNdx = 0; attachmentRefNdx < subpass.getColorAttachments().size(); attachmentRefNdx++)
3660 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentRefNdx].getAttachment();
3661 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3662 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3663 const int componentCount = tcu::getNumUsedChannels(format.order);
3665 outputComponentCount += (size_t)componentCount;
3668 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3669 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3670 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
3672 const Attachment& attachment (renderPassInfo.getAttachments()[subpass.getDepthStencilAttachment().getAttachment()]);
3673 const tcu::TextureFormat format (mapVkFormat(attachment.getFormat()));
3675 if (tcu::hasDepthComponent(format.order))
3676 outputComponentCount++;
3679 if (outputComponentCount > 0)
3681 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3682 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3684 for (size_t inputAttachmentNdx = 0; inputAttachmentNdx < subpass.getInputAttachments().size(); inputAttachmentNdx++)
3686 const deUint32 attachmentIndex = subpass.getInputAttachments()[inputAttachmentNdx].getAttachment();
3687 const VkImageLayout layout = subpass.getInputAttachments()[inputAttachmentNdx].getImageLayout();
3688 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3689 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3690 const int componentCount = tcu::getNumUsedChannels(format.order);
3692 for (int compNdx = 0; compNdx < componentCount; compNdx++)
3694 if ((compNdx != 0 || layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
3695 && (compNdx != 1 || layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL))
3697 inputs.push_back(referenceAttachments[attachmentIndex][x + y * targetSize.x()].getValue(compNdx));
3702 const size_t inputsPerOutput = inputs.size() >= outputComponentCount
3703 ? ((inputs.size() / outputComponentCount)
3704 + ((inputs.size() % outputComponentCount) != 0 ? 1 : 0))
3707 size_t outputValueNdx = 0;
3709 for (size_t attachmentRefNdx = 0; attachmentRefNdx < subpass.getColorAttachments().size(); attachmentRefNdx++)
3711 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentRefNdx].getAttachment();
3712 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3713 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3714 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3715 const int componentCount = tcu::getNumUsedChannels(format.order);
3717 for (int compNdx = 0; compNdx < componentCount; compNdx++)
3719 const size_t index = subpassNdx + attachmentIndex + outputValueNdx;
3720 const BoolOp op = boolOpFromIndex(index);
3721 const bool boolX = x % 2 == (int)(index % 2);
3722 const bool boolY = y % 2 == (int)((index / 2) % 2);
3723 Maybe<bool> output = tcu::just(performBoolOp(op, boolX, boolY));
3725 for (size_t i = 0; i < inputsPerOutput; i++)
3729 else if (!inputs[((outputValueNdx + compNdx) * inputsPerOutput + i) % inputs.size()])
3730 output = tcu::Nothing;
3732 output = (*output) == (*inputs[((outputValueNdx + compNdx) * inputsPerOutput + i) % inputs.size()]);
3736 reference[x + y * targetSize.x()].setValue(compNdx, *output);
3738 reference[x + y * targetSize.x()].setUndefined(compNdx);
3741 outputValueNdx += componentCount;
3744 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3745 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3746 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
3748 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3749 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3750 const size_t index = subpassNdx + attachmentIndex;
3751 const BoolOp op = boolOpFromIndex(index);
3752 const bool boolX = x % 2 == (int)(index % 2);
3753 const bool boolY = y % 2 == (int)((index / 2) % 2);
3754 Maybe<bool> output = tcu::just(performBoolOp(op, boolX, boolY));
3756 for (size_t i = 0; i < inputsPerOutput; i++)
3760 else if (inputs[(outputValueNdx * inputsPerOutput + i) % inputs.size()])
3761 output = (*output) == (*inputs[(outputValueNdx * inputsPerOutput + i) % inputs.size()]);
3763 output = tcu::Nothing;
3767 reference[x + y * targetSize.x()].setValue(0, *output);
3769 reference[x + y * targetSize.x()].setUndefined(0);
3776 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3777 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3778 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
3780 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3781 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3782 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3783 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3785 if (tcu::hasStencilComponent(format.order))
3787 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3788 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3790 const size_t index = subpassNdx;
3791 reference[x + y * targetSize.x()].setValue(1, (index % 2) == 0);
3799 // Mark all attachments that were used but not stored as undefined
3800 for (size_t attachmentIndex = 0; attachmentIndex < renderPassInfo.getAttachments().size(); attachmentIndex++)
3802 const Attachment attachment = renderPassInfo.getAttachments()[attachmentIndex];
3803 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3804 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3805 const bool isStencilAttachment = hasStencilComponent(format.order);
3806 const bool isDepthOrStencilAttachment = hasDepthComponent(format.order) || isStencilAttachment;
3808 if (attachmentUsed[attachmentIndex] && renderPassInfo.getAttachments()[attachmentIndex].getStoreOp() == VK_ATTACHMENT_STORE_OP_DONT_CARE)
3810 if (isDepthOrStencilAttachment)
3811 markUndefined(reference, BVec4(true, false, false, false), targetSize, renderPos, renderSize);
3813 markUndefined(reference, BVec4(true), targetSize, renderPos, renderSize);
3816 if (attachmentUsed[attachmentIndex] && isStencilAttachment && renderPassInfo.getAttachments()[attachmentIndex].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_DONT_CARE)
3817 markUndefined(reference, BVec4(false, true, false, false), targetSize, renderPos, renderSize);
3821 void renderReferenceImagesFromValues (vector<tcu::TextureLevel>& referenceImages,
3822 const vector<vector<PixelValue> >& referenceValues,
3823 const UVec2& targetSize,
3824 const RenderPass& renderPassInfo,
3825 const DepthValuesArray& depthValues)
3827 referenceImages.resize(referenceValues.size());
3829 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
3831 const Attachment attachment = renderPassInfo.getAttachments()[attachmentNdx];
3832 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3833 const vector<PixelValue>& reference = referenceValues[attachmentNdx];
3834 const bool hasDepth = tcu::hasDepthComponent(format.order);
3835 const bool hasStencil = tcu::hasStencilComponent(format.order);
3836 const bool hasDepthOrStencil = hasDepth || hasStencil;
3837 tcu::TextureLevel& referenceImage = referenceImages[attachmentNdx];
3839 referenceImage.setStorage(format, targetSize.x(), targetSize.y());
3841 if (hasDepthOrStencil)
3845 const PixelBufferAccess depthAccess (tcu::getEffectiveDepthStencilAccess(referenceImage.getAccess(), tcu::Sampler::MODE_DEPTH));
3847 for (deUint32 y = 0; y < targetSize.y(); y++)
3848 for (deUint32 x = 0; x < targetSize.x(); x++)
3850 if (reference[x + y * targetSize.x()].getValue(0))
3852 if (*reference[x + y * targetSize.x()].getValue(0))
3853 depthAccess.setPixDepth(float(depthValues[1]) / 255.0f, x, y);
3855 depthAccess.setPixDepth(float(depthValues[0]) / 255.0f, x, y);
3857 else // Fill with 3x3 grid
3858 depthAccess.setPixDepth(((x / 3) % 2) == ((y / 3) % 2) ? 0.33f : 0.66f, x, y);
3864 const PixelBufferAccess stencilAccess (tcu::getEffectiveDepthStencilAccess(referenceImage.getAccess(), tcu::Sampler::MODE_STENCIL));
3866 for (deUint32 y = 0; y < targetSize.y(); y++)
3867 for (deUint32 x = 0; x < targetSize.x(); x++)
3869 if (reference[x + y * targetSize.x()].getValue(1))
3871 if (*reference[x + y * targetSize.x()].getValue(1))
3872 stencilAccess.setPixStencil(0xFFu, x, y);
3874 stencilAccess.setPixStencil(0x0u, x, y);
3876 else // Fill with 3x3 grid
3877 stencilAccess.setPixStencil(((x / 3) % 2) == ((y / 3) % 2) ? 85 : 170, x, y);
3883 for (deUint32 y = 0; y < targetSize.y(); y++)
3884 for (deUint32 x = 0; x < targetSize.x(); x++)
3888 for (int compNdx = 0; compNdx < 4; compNdx++)
3890 if (reference[x + y * targetSize.x()].getValue(compNdx))
3892 if (*reference[x + y * targetSize.x()].getValue(compNdx))
3893 color[compNdx] = 1.0f;
3895 color[compNdx] = 0.0f;
3897 else // Fill with 3x3 grid
3898 color[compNdx] = ((compNdx + (x / 3)) % 2) == ((y / 3) % 2) ? 0.33f : 0.66f;
3901 referenceImage.getAccess().setPixel(color, x, y);
3907 bool verifyColorAttachment (const vector<PixelValue>& reference,
3908 const ConstPixelBufferAccess& result,
3909 const PixelBufferAccess& errorImage,
3910 const deBool useFormatCompCount)
3912 const Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
3913 const Vec4 green (0.0f, 1.0f, 0.0f, 1.0f);
3916 DE_ASSERT(result.getWidth() * result.getHeight() == (int)reference.size());
3917 DE_ASSERT(result.getWidth() == errorImage.getWidth());
3918 DE_ASSERT(result.getHeight() == errorImage.getHeight());
3920 for (int y = 0; y < result.getHeight(); y++)
3921 for (int x = 0; x < result.getWidth(); x++)
3923 const Vec4 resultColor = result.getPixel(x, y);
3924 const PixelValue& referenceValue = reference[x + y * result.getWidth()];
3925 bool pixelOk = true;
3926 const deUint32 componentCount = useFormatCompCount ? (deUint32)tcu::getNumUsedChannels(result.getFormat().order) : 4;
3928 for (deUint32 compNdx = 0; compNdx < componentCount; compNdx++)
3930 const Maybe<bool> maybeValue = referenceValue.getValue(compNdx);
3934 const bool value = *maybeValue;
3936 if ((value && (resultColor[compNdx] != 1.0f))
3937 || (!value && resultColor[compNdx] != 0.0f))
3944 errorImage.setPixel(red, x, y);
3948 errorImage.setPixel(green, x, y);
3954 // Setting the alpha value to 1.0f by default helps visualization when the alpha channel is not used.
3955 const tcu::Vec4 kDefaultColorForLog {0.0f, 0.0f, 0.0f, 1.0f};
3956 const float kTrueComponent = 1.0f;
3957 const float kFalseComponent = 0.5f;
3958 const float kUnsetComponentLow = 0.0f;
3959 const float kUnsetComponentHigh = 0.25f;
3961 std::unique_ptr<tcu::TextureLevel> renderColorImageForLog (const ConstPixelBufferAccess& image, int numChannels)
3963 // Same channel order, but using UNORM_INT8 for the color format.
3964 const auto order = image.getFormat().order;
3965 const tcu::TextureFormat loggableFormat {order, tcu::TextureFormat::UNORM_INT8};
3966 const int width = image.getWidth();
3967 const int height = image.getHeight();
3968 std::unique_ptr<tcu::TextureLevel> result {new tcu::TextureLevel{loggableFormat, width, height}};
3969 auto access = result->getAccess();
3970 tcu::Vec4 outColor = kDefaultColorForLog;
3972 for (int x = 0; x < width; ++x)
3973 for (int y = 0; y < height; ++y)
3975 const auto value = image.getPixel(x, y);
3976 for (int c = 0; c < numChannels; ++c)
3978 if (value[c] == 0.0f)
3979 outColor[c] = kFalseComponent;
3980 else if (value[c] == 1.0f)
3981 outColor[c] = kTrueComponent;
3985 access.setPixel(outColor, x, y);
3991 std::unique_ptr<tcu::TextureLevel> renderColorImageForLog (const vector<PixelValue>& reference, const UVec2& targetSize, int numChannels)
3993 const tcu::TextureFormat loggableFormat {tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8};
3994 const int width = static_cast<int>(targetSize.x());
3995 const int height = static_cast<int>(targetSize.y());
3996 std::unique_ptr<tcu::TextureLevel> result {new tcu::TextureLevel{loggableFormat, width, height}};
3997 auto access = result->getAccess();
3998 tcu::Vec4 outColor = kDefaultColorForLog;
4000 for (int x = 0; x < width; ++x)
4001 for (int y = 0; y < height; ++y)
4003 const int index = x + y * width;
4004 for (int c = 0; c < numChannels; ++c)
4006 const auto maybeValue = reference[index].getValue(c);
4008 outColor[c] = ((*maybeValue) ? kTrueComponent : kFalseComponent);
4010 outColor[c] = ((((x / 3) % 2) == ((y / 3) % 2)) ? kUnsetComponentLow : kUnsetComponentHigh);
4012 access.setPixel(outColor, x, y);
4018 bool verifyDepthAttachment (const vector<PixelValue>& reference,
4019 const ConstPixelBufferAccess& result,
4020 const PixelBufferAccess& errorImage,
4021 const DepthValuesArray& depthValues,
4024 const Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
4025 const Vec4 green (0.0f, 1.0f, 0.0f, 1.0f);
4028 DE_ASSERT(result.getWidth() * result.getHeight() == (int)reference.size());
4029 DE_ASSERT(result.getWidth() == errorImage.getWidth());
4030 DE_ASSERT(result.getHeight() == errorImage.getHeight());
4032 for (int y = 0; y < result.getHeight(); y++)
4033 for (int x = 0; x < result.getWidth(); x++)
4035 bool pixelOk = true;
4037 const float resultDepth = result.getPixDepth(x, y);
4038 const PixelValue& referenceValue = reference[x + y * result.getWidth()];
4039 const Maybe<bool> maybeValue = referenceValue.getValue(0);
4043 const bool value = *maybeValue;
4045 if ((value && !depthsEqual(resultDepth, float(depthValues[1]) / 255.0f, epsilon))
4046 || (!value && !depthsEqual(resultDepth, float(depthValues[0]) / 255.0f, epsilon)))
4052 errorImage.setPixel(red, x, y);
4056 errorImage.setPixel(green, x, y);
4062 bool verifyStencilAttachment (const vector<PixelValue>& reference,
4063 const ConstPixelBufferAccess& result,
4064 const PixelBufferAccess& errorImage)
4066 const Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
4067 const Vec4 green (0.0f, 1.0f, 0.0f, 1.0f);
4070 DE_ASSERT(result.getWidth() * result.getHeight() == (int)reference.size());
4071 DE_ASSERT(result.getWidth() == errorImage.getWidth());
4072 DE_ASSERT(result.getHeight() == errorImage.getHeight());
4074 for (int y = 0; y < result.getHeight(); y++)
4075 for (int x = 0; x < result.getWidth(); x++)
4077 bool pixelOk = true;
4079 const deUint32 resultStencil = result.getPixStencil(x, y);
4080 const PixelValue& referenceValue = reference[x + y * result.getWidth()];
4081 const Maybe<bool> maybeValue = referenceValue.getValue(1);
4085 const bool value = *maybeValue;
4087 if ((value && (resultStencil != 0xFFu))
4088 || (!value && resultStencil != 0x0u))
4094 errorImage.setPixel(red, x, y);
4098 errorImage.setPixel(green, x, y);
4104 bool logAndVerifyImages (TestLog& log,
4105 const DeviceInterface& vk,
4107 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
4108 const vector<bool>& attachmentIsLazy,
4109 const RenderPass& renderPassInfo,
4110 const vector<Maybe<VkClearValue> >& renderPassClearValues,
4111 const vector<Maybe<VkClearValue> >& imageClearValues,
4112 const vector<SubpassRenderInfo>& subpassRenderInfo,
4113 const UVec2& targetSize,
4114 const TestConfig& config)
4116 vector<vector<PixelValue> > referenceValues;
4117 vector<tcu::TextureLevel> referenceAttachments;
4120 log << TestLog::Message << "Reference images fill undefined pixels with 3x3 grid pattern." << TestLog::EndMessage;
4122 renderReferenceValues(referenceValues, renderPassInfo, targetSize, imageClearValues, renderPassClearValues, subpassRenderInfo, config.renderPos, config.renderSize, config.drawStartNdx, config.depthValues);
4123 renderReferenceImagesFromValues(referenceAttachments, referenceValues, targetSize, renderPassInfo, config.depthValues);
4125 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
4127 if (!attachmentIsLazy[attachmentNdx])
4129 bool attachmentOK = true;
4130 const Attachment attachment = renderPassInfo.getAttachments()[attachmentNdx];
4131 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4133 if (tcu::hasDepthComponent(format.order) && tcu::hasStencilComponent(format.order))
4135 const tcu::TextureFormat depthFormat = getDepthCopyFormat(attachment.getFormat());
4136 void* const depthPtr = attachmentResources[attachmentNdx]->getResultMemory().getHostPtr();
4138 const tcu::TextureFormat stencilFormat = getStencilCopyFormat(attachment.getFormat());
4139 void* const stencilPtr = attachmentResources[attachmentNdx]->getSecondaryResultMemory().getHostPtr();
4141 invalidateAlloc(vk, device, attachmentResources[attachmentNdx]->getResultMemory());
4142 invalidateAlloc(vk, device, attachmentResources[attachmentNdx]->getSecondaryResultMemory());
4145 bool depthOK = true;
4146 bool stencilOK = true;
4147 const ConstPixelBufferAccess depthAccess (depthFormat, targetSize.x(), targetSize.y(), 1, depthPtr);
4148 const ConstPixelBufferAccess stencilAccess (stencilFormat, targetSize.x(), targetSize.y(), 1, stencilPtr);
4149 tcu::TextureLevel depthErrorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
4150 tcu::TextureLevel stencilErrorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
4152 if (renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE
4153 && !verifyDepthAttachment(referenceValues[attachmentNdx], depthAccess, depthErrorImage.getAccess(), config.depthValues, requiredDepthEpsilon(attachment.getFormat())))
4158 if (renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE
4159 && !verifyStencilAttachment(referenceValues[attachmentNdx], stencilAccess, stencilErrorImage.getAccess()))
4164 if (!depthOK || !stencilOK)
4166 const auto attachmentNdxStr = de::toString(attachmentNdx);
4169 log << TestLog::ImageSet("OutputAttachments" + attachmentNdxStr, "Output depth and stencil attachments " + attachmentNdxStr);
4170 log << TestLog::Image("Attachment" + attachmentNdxStr + "Depth", "Attachment " + attachmentNdxStr + " Depth", depthAccess);
4171 log << TestLog::Image("Attachment" + attachmentNdxStr + "Stencil", "Attachment " + attachmentNdxStr + " Stencil", stencilAccess);
4172 log << TestLog::EndImageSet;
4174 // Reference images. These will be logged as image sets due to having depth and stencil aspects.
4175 log << TestLog::Image("AttachmentReferences" + attachmentNdxStr, "Reference images " + attachmentNdxStr, referenceAttachments[attachmentNdx].getAccess());
4178 log << TestLog::ImageSet("ErrorMasks" + attachmentNdxStr, "Error masks " + attachmentNdxStr);
4180 log << TestLog::Image("DepthAttachmentError" + attachmentNdxStr, "Depth Attachment Error " + attachmentNdxStr, depthErrorImage.getAccess());
4182 log << TestLog::Image("StencilAttachmentError" + attachmentNdxStr, "Stencil Attachment Error " + attachmentNdxStr, stencilErrorImage.getAccess());
4183 log << TestLog::EndImageSet;
4185 attachmentOK = false;
4191 void* const ptr = attachmentResources[attachmentNdx]->getResultMemory().getHostPtr();
4193 invalidateAlloc(vk, device, attachmentResources[attachmentNdx]->getResultMemory());
4195 bool depthOK = true;
4196 bool stencilOK = true;
4197 bool colorOK = true;
4198 const ConstPixelBufferAccess access (format, targetSize.x(), targetSize.y(), 1, ptr);
4199 tcu::TextureLevel errorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
4201 if (tcu::hasDepthComponent(format.order))
4203 if ((renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE || renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE)
4204 && !verifyDepthAttachment(referenceValues[attachmentNdx], access, errorImage.getAccess(), config.depthValues, requiredDepthEpsilon(attachment.getFormat())))
4209 else if (tcu::hasStencilComponent(format.order))
4211 if ((renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE || renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE)
4212 && !verifyStencilAttachment(referenceValues[attachmentNdx], access, errorImage.getAccess()))
4219 if ((renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE || renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE)
4220 && !verifyColorAttachment(referenceValues[attachmentNdx], access, errorImage.getAccess(), config.useFormatCompCount))
4226 if (!depthOK || !stencilOK || !colorOK)
4228 log << TestLog::ImageSet("TestImages", "Output attachment, reference image and error mask");
4229 if (!depthOK || !stencilOK)
4231 // Log without conversions.
4232 log << TestLog::Image("Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx), access);
4233 log << TestLog::Image("AttachmentReference" + de::toString(attachmentNdx), "Attachment reference " + de::toString(attachmentNdx), referenceAttachments[attachmentNdx].getAccess());
4237 // Convert color images to better reflect test status and output in any format.
4238 const auto numChannels = tcu::getNumUsedChannels(access.getFormat().order);
4239 const auto attachmentForLog = renderColorImageForLog(access, numChannels);
4240 const auto referenceForLog = renderColorImageForLog(referenceValues[attachmentNdx], targetSize, numChannels);
4242 log << TestLog::Message << "Check the attachment formats and test data to verify which components affect the test result." << TestLog::EndMessage;
4243 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;
4244 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;
4246 log << TestLog::Image("Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx), attachmentForLog->getAccess());
4247 log << TestLog::Image("AttachmentReference" + de::toString(attachmentNdx), "Attachment reference " + de::toString(attachmentNdx), referenceForLog->getAccess());
4249 log << TestLog::Image("AttachmentError" + de::toString(attachmentNdx), "Attachment Error " + de::toString(attachmentNdx), errorImage.getAccess());
4250 log << TestLog::EndImageSet;
4252 attachmentOK = false;
4264 std::string getInputAttachmentType (VkFormat vkFormat)
4266 const tcu::TextureFormat format = mapVkFormat(vkFormat);
4267 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
4269 switch (channelClass)
4271 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
4272 return "isubpassInput";
4274 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
4275 return "usubpassInput";
4277 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
4278 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
4279 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
4280 return "subpassInput";
4283 DE_FATAL("Unknown channel class");
4288 std::string getAttachmentType (VkFormat vkFormat, deBool useFormatCompCount)
4290 const tcu::TextureFormat format = mapVkFormat(vkFormat);
4291 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
4292 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4294 switch (channelClass)
4296 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
4297 if (useFormatCompCount)
4298 return (componentCount == 1 ? "int" : "ivec" + de::toString(componentCount));
4302 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
4303 if (useFormatCompCount)
4304 return (componentCount == 1 ? "uint" : "uvec" + de::toString(componentCount));
4308 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
4309 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
4310 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
4311 if (useFormatCompCount)
4312 return (componentCount == 1 ? "float" : "vec" + de::toString(componentCount));
4317 DE_FATAL("Unknown channel class");
4322 void createTestShaders (SourceCollections& dst, TestConfig config)
4324 if (config.renderTypes & TestConfig::RENDERTYPES_DRAW)
4326 const vector<Subpass>& subpasses = config.renderPass.getSubpasses();
4328 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
4330 const Subpass& subpass = subpasses[subpassNdx];
4331 deUint32 inputAttachmentBinding = 0;
4332 std::ostringstream vertexShader;
4333 std::ostringstream fragmentShader;
4335 vertexShader << "#version 310 es\n"
4336 << "layout(location = 0) in highp vec2 a_position;\n"
4337 << "void main (void) {\n"
4338 << "\tgl_Position = vec4(a_position, 1.0, 1.0);\n"
4341 fragmentShader << "#version 310 es\n"
4342 << "precision highp float;\n";
4344 bool hasAnyDepthFormats = false;
4346 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
4348 const deUint32 attachmentIndex = subpass.getInputAttachments()[attachmentNdx].getAttachment();
4349 const VkImageLayout layout = subpass.getInputAttachments()[attachmentNdx].getImageLayout();
4350 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4351 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4352 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
4353 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
4355 if (isDepthFormat || isStencilFormat)
4357 if (isDepthFormat && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
4359 hasAnyDepthFormats = true;
4360 fragmentShader << "layout(input_attachment_index = " << attachmentNdx << ", set=0, binding=" << inputAttachmentBinding << ") uniform highp subpassInput i_depth" << attachmentNdx << ";\n";
4361 inputAttachmentBinding++;
4364 if (isStencilFormat && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4366 fragmentShader << "layout(input_attachment_index = " << attachmentNdx << ", set=0, binding=" << inputAttachmentBinding << ") uniform highp usubpassInput i_stencil" << attachmentNdx << ";\n";
4367 inputAttachmentBinding++;
4372 const std::string attachmentType = getInputAttachmentType(attachment.getFormat());
4374 fragmentShader << "layout(input_attachment_index = " << attachmentNdx << ", set=0, binding=" << inputAttachmentBinding << ") uniform highp " << attachmentType << " i_color" << attachmentNdx << ";\n";
4375 inputAttachmentBinding++;
4379 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
4381 const std::string attachmentType = getAttachmentType(config.renderPass.getAttachments()[getAttachmentNdx(subpass.getColorAttachments(), attachmentNdx)].getFormat(), config.useFormatCompCount);
4382 fragmentShader << "layout(location = " << attachmentNdx << ") out highp " << attachmentType << " o_color" << attachmentNdx << ";\n";
4385 if (hasAnyDepthFormats)
4386 fragmentShader << "\nbool depthsEqual(float a, float b, float epsilon) {\n"
4387 << "\treturn abs(a - b) <= epsilon;\n}\n\n";
4389 fragmentShader << "void main (void) {\n";
4391 if (subpass.getInputAttachments().empty())
4393 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
4395 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentNdx].getAttachment();
4397 if (attachmentIndex == VK_ATTACHMENT_UNUSED)
4400 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4401 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4402 const size_t componentCount = config.useFormatCompCount ? (size_t)tcu::getNumUsedChannels(format.order) : 4;
4403 const std::string attachmentType = getAttachmentType(attachment.getFormat(), config.useFormatCompCount);
4405 fragmentShader << "\to_color" << attachmentNdx << " = " << attachmentType << "(" << attachmentType + "(";
4407 for (size_t compNdx = 0; compNdx < componentCount; compNdx++)
4409 const size_t index = subpassNdx + attachmentIndex + compNdx;
4410 const BoolOp op = boolOpFromIndex(index);
4413 fragmentShader << ",\n\t\t";
4415 fragmentShader << "((int(gl_FragCoord.x) % 2 == " << (index % 2)
4416 << ") " << boolOpToString(op) << " ("
4417 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
4418 << ") ? 1.0 : 0.0)";
4421 fragmentShader << "));\n";
4424 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
4425 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
4426 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4428 const size_t index = subpassNdx + 1;
4429 const BoolOp op = boolOpFromIndex(index);
4431 fragmentShader << "\tgl_FragDepth = ((int(gl_FragCoord.x) % 2 == " << (index % 2)
4432 << ") " << boolOpToString(op) << " ("
4433 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
4434 << ") ? " << deUint32(config.depthValues[1]) << ".0f/255.0f : " << deUint32(config.depthValues[0]) << ".0f/255.0f);\n";
4439 size_t inputComponentCount = 0;
4440 size_t outputComponentCount = 0;
4442 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
4444 const deUint32 attachmentIndex = subpass.getInputAttachments()[attachmentNdx].getAttachment();
4445 const VkImageLayout layout = subpass.getInputAttachments()[attachmentNdx].getImageLayout();
4446 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4447 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4448 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4450 if (layout == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4451 inputComponentCount += 1;
4452 else if (layout == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
4453 inputComponentCount += 1;
4455 inputComponentCount += componentCount;
4458 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
4460 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentNdx].getAttachment();
4461 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4462 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4463 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4465 outputComponentCount += componentCount;
4468 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
4469 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
4470 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4472 outputComponentCount++;
4475 if (outputComponentCount > 0)
4477 const size_t inputsPerOutput = inputComponentCount >= outputComponentCount
4478 ? ((inputComponentCount / outputComponentCount)
4479 + ((inputComponentCount % outputComponentCount) != 0 ? 1 : 0))
4482 fragmentShader << "\tbool inputs[" << inputComponentCount << "];\n";
4484 if (outputComponentCount > 0)
4485 fragmentShader << "\tbool outputs[" << outputComponentCount << "];\n";
4487 size_t inputValueNdx = 0;
4489 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
4491 const char* const components[] =
4495 const deUint32 attachmentIndex = subpass.getInputAttachments()[attachmentNdx].getAttachment();
4496 const VkImageLayout layout = subpass.getInputAttachments()[attachmentNdx].getImageLayout();
4497 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4498 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4499 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4500 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
4501 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
4503 if (isDepthFormat || isStencilFormat)
4505 if (isDepthFormat && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
4507 fragmentShader << "\tinputs[" << inputValueNdx << "] = depthsEqual(" << deUint32(config.depthValues[1]) <<
4508 ".0f/255.0f, float(subpassLoad(i_depth" << attachmentNdx << ").x), " <<
4509 std::fixed << std::setprecision(12) << requiredDepthEpsilon(attachment.getFormat()) << ");\n";
4513 if (isStencilFormat && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4515 fragmentShader << "\tinputs[" << inputValueNdx << "] = 255u == subpassLoad(i_stencil" << attachmentNdx << ").x;\n";
4521 for (size_t compNdx = 0; compNdx < componentCount; compNdx++)
4523 fragmentShader << "\tinputs[" << inputValueNdx << "] = 1.0 == float(subpassLoad(i_color" << attachmentNdx << ")." << components[compNdx] << ");\n";
4529 size_t outputValueNdx = 0;
4531 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
4533 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentNdx].getAttachment();
4534 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4535 const std::string attachmentType = getAttachmentType(config.renderPass.getAttachments()[attachmentIndex].getFormat(), config.useFormatCompCount);
4536 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4537 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4539 for (size_t compNdx = 0; compNdx < componentCount; compNdx++)
4541 const size_t index = subpassNdx + attachmentIndex + outputValueNdx;
4542 const BoolOp op = boolOpFromIndex(index);
4544 fragmentShader << "\toutputs[" << outputValueNdx + compNdx << "] = "
4545 << "(int(gl_FragCoord.x) % 2 == " << (index % 2)
4546 << ") " << boolOpToString(op) << " ("
4547 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
4550 for (size_t i = 0; i < inputsPerOutput; i++)
4551 fragmentShader << "\toutputs[" << outputValueNdx + compNdx << "] = outputs[" << outputValueNdx + compNdx << "] == inputs[" << ((outputValueNdx + compNdx) * inputsPerOutput + i) % inputComponentCount << "];\n";
4554 fragmentShader << "\to_color" << attachmentNdx << " = " << attachmentType << "(";
4556 for (size_t compNdx = 0; compNdx < (config.useFormatCompCount ? componentCount : 4); compNdx++)
4559 fragmentShader << ", ";
4561 if (compNdx < componentCount)
4562 fragmentShader << "outputs[" << outputValueNdx + compNdx << "]";
4564 fragmentShader << "0";
4567 outputValueNdx += componentCount;
4569 fragmentShader << ");\n";
4572 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
4573 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
4574 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4576 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
4577 const size_t index = subpassNdx + attachmentIndex;
4578 const BoolOp op = boolOpFromIndex(index);
4580 fragmentShader << "\toutputs[" << outputValueNdx << "] = "
4581 << "(int(gl_FragCoord.x) % 2 == " << (index % 2)
4582 << ") " << boolOpToString(op) << " ("
4583 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
4586 for (size_t i = 0; i < inputsPerOutput; i++)
4587 fragmentShader << "\toutputs[" << outputValueNdx << "] = outputs[" << outputValueNdx << "] == inputs[" << (outputValueNdx * inputsPerOutput + i) % inputComponentCount << "];\n";
4589 fragmentShader << "\tgl_FragDepth = outputs[" << outputValueNdx << "] ? " << deUint32(config.depthValues[1]) << ".0f/255.0f : " << deUint32(config.depthValues[0]) << ".0f/255.0f;\n";
4594 fragmentShader << "}\n";
4596 dst.glslSources.add(de::toString(subpassNdx) + "-vert") << glu::VertexSource(vertexShader.str());
4597 dst.glslSources.add(de::toString(subpassNdx) + "-frag") << glu::FragmentSource(fragmentShader.str());
4602 void initializeAttachmentIsLazy (vector<bool>& attachmentIsLazy, const vector<Attachment>& attachments, TestConfig::ImageMemory imageMemory)
4604 bool lastAttachmentWasLazy = false;
4606 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4608 if (attachments[attachmentNdx].getLoadOp() != VK_ATTACHMENT_LOAD_OP_LOAD
4609 && attachments[attachmentNdx].getStoreOp() != VK_ATTACHMENT_STORE_OP_STORE
4610 && attachments[attachmentNdx].getStencilLoadOp() != VK_ATTACHMENT_LOAD_OP_LOAD
4611 && attachments[attachmentNdx].getStencilStoreOp() != VK_ATTACHMENT_STORE_OP_STORE)
4613 if (imageMemory == TestConfig::IMAGEMEMORY_LAZY || (imageMemory & TestConfig::IMAGEMEMORY_LAZY && !lastAttachmentWasLazy))
4615 attachmentIsLazy.push_back(true);
4617 lastAttachmentWasLazy = true;
4619 else if (imageMemory & TestConfig::IMAGEMEMORY_STRICT)
4621 attachmentIsLazy.push_back(false);
4622 lastAttachmentWasLazy = false;
4625 DE_FATAL("Unknown imageMemory");
4628 attachmentIsLazy.push_back(false);
4632 enum AttachmentRefType
4634 ATTACHMENTREFTYPE_COLOR,
4635 ATTACHMENTREFTYPE_DEPTH_STENCIL,
4636 ATTACHMENTREFTYPE_INPUT,
4637 ATTACHMENTREFTYPE_RESOLVE,
4640 VkImageUsageFlags getImageUsageFromLayout (VkImageLayout layout)
4644 case VK_IMAGE_LAYOUT_GENERAL:
4645 case VK_IMAGE_LAYOUT_PREINITIALIZED:
4648 case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
4649 return VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4651 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
4652 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL:
4653 return VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
4655 case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
4656 return VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
4658 case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
4659 return VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
4661 case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
4662 return VK_IMAGE_USAGE_TRANSFER_DST_BIT;
4665 DE_FATAL("Unexpected image layout");
4670 void getImageUsageFromAttachmentReferences(vector<VkImageUsageFlags>& attachmentImageUsage, AttachmentRefType refType, size_t count, const AttachmentReference* references)
4672 for (size_t referenceNdx = 0; referenceNdx < count; ++referenceNdx)
4674 const deUint32 attachment = references[referenceNdx].getAttachment();
4676 if (attachment != VK_ATTACHMENT_UNUSED)
4678 VkImageUsageFlags usage;
4682 case ATTACHMENTREFTYPE_COLOR:
4683 case ATTACHMENTREFTYPE_RESOLVE:
4684 usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4687 case ATTACHMENTREFTYPE_DEPTH_STENCIL:
4688 usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
4691 case ATTACHMENTREFTYPE_INPUT:
4692 usage = VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
4696 DE_FATAL("Unexpected attachment reference type");
4701 attachmentImageUsage[attachment] |= usage;
4706 void getImageUsageFromAttachmentReferences(vector<VkImageUsageFlags>& attachmentImageUsage, AttachmentRefType refType, const vector<AttachmentReference>& references)
4708 if (!references.empty())
4710 getImageUsageFromAttachmentReferences(attachmentImageUsage, refType, references.size(), &references[0]);
4714 void initializeAttachmentImageUsage (Context &context, vector<VkImageUsageFlags>& attachmentImageUsage, const RenderPass& renderPassInfo, const vector<bool>& attachmentIsLazy, const vector<Maybe<VkClearValue> >& clearValues)
4716 attachmentImageUsage.resize(renderPassInfo.getAttachments().size(), VkImageUsageFlags(0));
4718 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); ++subpassNdx)
4720 const Subpass& subpass = renderPassInfo.getSubpasses()[subpassNdx];
4722 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_COLOR, subpass.getColorAttachments());
4723 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_DEPTH_STENCIL, 1, &subpass.getDepthStencilAttachment());
4724 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_INPUT, subpass.getInputAttachments());
4725 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_RESOLVE, subpass.getResolveAttachments());
4728 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
4730 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentNdx];
4731 const VkFormatProperties formatProperties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), attachment.getFormat());
4732 const VkFormatFeatureFlags supportedFeatures = formatProperties.optimalTilingFeatures;
4734 if ((supportedFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0)
4735 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_SAMPLED_BIT;
4737 if ((supportedFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) != 0)
4738 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_STORAGE_BIT;
4740 attachmentImageUsage[attachmentNdx] |= getImageUsageFromLayout(attachment.getInitialLayout());
4741 attachmentImageUsage[attachmentNdx] |= getImageUsageFromLayout(attachment.getFinalLayout());
4743 if (!attachmentIsLazy[attachmentNdx])
4745 if (clearValues[attachmentNdx])
4746 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
4748 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
4752 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);
4754 attachmentImageUsage[attachmentNdx] &= allowedTransientBits;
4755 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4760 void initializeSubpassIsSecondary (vector<bool>& subpassIsSecondary, const vector<Subpass>& subpasses, TestConfig::CommandBufferTypes commandBuffer)
4762 bool lastSubpassWasSecondary = false;
4764 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
4766 if (commandBuffer == TestConfig::COMMANDBUFFERTYPES_SECONDARY || (commandBuffer & TestConfig::COMMANDBUFFERTYPES_SECONDARY && !lastSubpassWasSecondary))
4768 subpassIsSecondary.push_back(true);
4769 lastSubpassWasSecondary = true;
4771 else if (commandBuffer & TestConfig::COMMANDBUFFERTYPES_INLINE)
4773 subpassIsSecondary.push_back(false);
4774 lastSubpassWasSecondary = false;
4777 DE_FATAL("Unknown commandBuffer");
4781 void initializeImageClearValues (de::Random& rng, vector<Maybe<VkClearValue> >& clearValues, const vector<Attachment>& attachments, const vector<bool>& isLazy, deBool useFormatCompCount, const DepthValuesArray& depthValues)
4783 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4785 if (!isLazy[attachmentNdx])
4786 clearValues.push_back(just(randomClearValue(attachments[attachmentNdx], rng, useFormatCompCount, depthValues)));
4788 clearValues.push_back(tcu::Nothing);
4792 void initializeRenderPassClearValues (de::Random& rng, vector<Maybe<VkClearValue> >& clearValues, const vector<Attachment>& attachments, deBool useFormatCompCount, const DepthValuesArray& depthValues)
4794 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4796 if (attachments[attachmentNdx].getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR
4797 || attachments[attachmentNdx].getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
4799 clearValues.push_back(just(randomClearValue(attachments[attachmentNdx], rng, useFormatCompCount, depthValues)));
4802 clearValues.push_back(tcu::Nothing);
4806 void logSubpassRenderInfo (TestLog& log, const SubpassRenderInfo& info, TestConfig config)
4808 log << TestLog::Message << "Viewport, offset: " << info.getViewportOffset() << ", size: " << info.getViewportSize() << TestLog::EndMessage;
4810 if (info.isSecondary())
4811 log << TestLog::Message << "Subpass uses secondary command buffers" << TestLog::EndMessage;
4813 log << TestLog::Message << "Subpass uses inlined commands" << TestLog::EndMessage;
4815 for (deUint32 attachmentNdx = 0; attachmentNdx < info.getColorClears().size(); attachmentNdx++)
4817 const ColorClear& colorClear = info.getColorClears()[attachmentNdx];
4819 log << TestLog::Message << "Clearing color attachment " << attachmentNdx
4820 << ". Offset: " << colorClear.getOffset()
4821 << ", Size: " << colorClear.getSize()
4822 << ", Color: " << clearColorToString(info.getColorAttachment(attachmentNdx).getFormat(), colorClear.getColor(), config.useFormatCompCount) << TestLog::EndMessage;
4825 if (info.getDepthStencilClear())
4827 const DepthStencilClear& depthStencilClear = *info.getDepthStencilClear();
4829 log << TestLog::Message << "Clearing depth stencil attachment"
4830 << ". Offset: " << depthStencilClear.getOffset()
4831 << ", Size: " << depthStencilClear.getSize()
4832 << ", Depth: " << depthStencilClear.getDepth()
4833 << ", Stencil: " << depthStencilClear.getStencil() << TestLog::EndMessage;
4836 if (info.getRenderQuad())
4838 const RenderQuad& renderQuad = *info.getRenderQuad();
4840 log << TestLog::Message << "Rendering grid quad to " << renderQuad.getCornerA() << " -> " << renderQuad.getCornerB() << TestLog::EndMessage;
4844 void logTestCaseInfo (TestLog& log,
4845 const TestConfig& config,
4846 const vector<bool>& attachmentIsLazy,
4847 const vector<Maybe<VkClearValue> >& imageClearValues,
4848 const vector<Maybe<VkClearValue> >& renderPassClearValues,
4849 const vector<SubpassRenderInfo>& subpassRenderInfo)
4851 const RenderPass& renderPass = config.renderPass;
4853 logRenderPassInfo(log, renderPass);
4855 DE_ASSERT(attachmentIsLazy.size() == renderPass.getAttachments().size());
4856 DE_ASSERT(imageClearValues.size() == renderPass.getAttachments().size());
4857 DE_ASSERT(renderPassClearValues.size() == renderPass.getAttachments().size());
4859 log << TestLog::Message << "TargetSize: " << config.targetSize << TestLog::EndMessage;
4860 log << TestLog::Message << "Render area, Offset: " << config.renderPos << ", Size: " << config.renderSize << TestLog::EndMessage;
4862 for (size_t attachmentNdx = 0; attachmentNdx < attachmentIsLazy.size(); attachmentNdx++)
4864 const tcu::ScopedLogSection section (log, "Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx));
4866 if (attachmentIsLazy[attachmentNdx])
4867 log << TestLog::Message << "Is lazy." << TestLog::EndMessage;
4869 if (imageClearValues[attachmentNdx])
4870 log << TestLog::Message << "Image is cleared to " << clearValueToString(renderPass.getAttachments()[attachmentNdx].getFormat(),
4871 *imageClearValues[attachmentNdx], config.useFormatCompCount) << " before rendering." << TestLog::EndMessage;
4873 if (renderPass.getAttachments()[attachmentNdx].getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR && renderPassClearValues[attachmentNdx])
4874 log << TestLog::Message << "Attachment is cleared to " << clearValueToString(renderPass.getAttachments()[attachmentNdx].getFormat(),
4875 *renderPassClearValues[attachmentNdx], config.useFormatCompCount) << " in the beginning of the render pass." << TestLog::EndMessage;
4878 for (size_t subpassNdx = 0; subpassNdx < renderPass.getSubpasses().size(); subpassNdx++)
4880 const tcu::ScopedLogSection section (log, "Subpass" + de::toString(subpassNdx), "Subpass " + de::toString(subpassNdx));
4882 logSubpassRenderInfo(log, subpassRenderInfo[subpassNdx], config);
4886 float roundToViewport (float x, deUint32 offset, deUint32 size)
4888 const float origin = (float)(offset) + ((float(size) / 2.0f));
4889 const float p = (float)(size) / 2.0f;
4890 const deInt32 xi = deRoundFloatToInt32(origin + (p * x));
4892 return (((float)xi) - origin) / p;
4895 void initializeSubpassRenderInfo (vector<SubpassRenderInfo>& renderInfos, de::Random& rng, const RenderPass& renderPass, const TestConfig& config)
4897 const TestConfig::CommandBufferTypes commandBuffer = config.commandBufferTypes;
4898 const vector<Subpass>& subpasses = renderPass.getSubpasses();
4899 bool lastSubpassWasSecondary = false;
4901 for (deUint32 subpassNdx = 0; subpassNdx < (deUint32)subpasses.size(); subpassNdx++)
4903 const Subpass& subpass = subpasses[subpassNdx];
4904 const bool subpassIsSecondary = commandBuffer == TestConfig::COMMANDBUFFERTYPES_SECONDARY
4905 || (commandBuffer & TestConfig::COMMANDBUFFERTYPES_SECONDARY && !lastSubpassWasSecondary) ? true : false;
4906 const bool omitBlendState = subpass.getOmitBlendState();
4907 const UVec2 viewportSize ((config.renderSize * UVec2(2)) / UVec2(3));
4908 const UVec2 viewportOffset (config.renderPos.x() + (subpassNdx % 2) * (config.renderSize.x() / 3),
4909 config.renderPos.y() + ((subpassNdx / 2) % 2) * (config.renderSize.y() / 3));
4911 vector<ColorClear> colorClears;
4912 Maybe<DepthStencilClear> depthStencilClear;
4913 Maybe<RenderQuad> renderQuad;
4915 lastSubpassWasSecondary = subpassIsSecondary;
4917 if (config.renderTypes & TestConfig::RENDERTYPES_CLEAR)
4919 const vector<AttachmentReference>& colorAttachments = subpass.getColorAttachments();
4921 for (size_t attachmentRefNdx = 0; attachmentRefNdx < colorAttachments.size(); attachmentRefNdx++)
4923 const AttachmentReference& attachmentRef = colorAttachments[attachmentRefNdx];
4924 const Attachment& attachment = renderPass.getAttachments()[attachmentRef.getAttachment()];
4925 const UVec2 size ((viewportSize * UVec2(2)) / UVec2(3));
4926 const UVec2 offset (viewportOffset.x() + ((deUint32)attachmentRefNdx % 2u) * (viewportSize.x() / 3u),
4927 viewportOffset.y() + (((deUint32)attachmentRefNdx / 2u) % 2u) * (viewportSize.y() / 3u));
4928 const VkClearColorValue color = randomColorClearValue(attachment, rng, config.useFormatCompCount);
4930 colorClears.push_back(ColorClear(offset, size, color));
4933 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
4935 const Attachment& attachment = renderPass.getAttachments()[subpass.getDepthStencilAttachment().getAttachment()];
4936 const UVec2 size ((viewportSize * UVec2(2)) / UVec2(3));
4937 const UVec2 offset (viewportOffset.x() + ((deUint32)colorAttachments.size() % 2u) * (viewportSize.x() / 3u),
4938 viewportOffset.y() + (((deUint32)colorAttachments.size() / 2u) % 2u) * (viewportSize.y() / 3u));
4939 const VkClearValue value = randomClearValue(attachment, rng, config.useFormatCompCount, config.depthValues);
4941 depthStencilClear = tcu::just(DepthStencilClear(offset, size, value.depthStencil.depth, value.depthStencil.stencil));
4945 if (config.renderTypes & TestConfig::RENDERTYPES_DRAW)
4947 const float w = (subpassNdx % 2) == 0 ? 1.0f : 1.25f;
4948 const float h = (subpassNdx % 2) == 0 ? 1.25f : 1.0f;
4950 const float x0 = roundToViewport((subpassNdx % 2) == 0 ? 1.0f - w : -1.0f, viewportOffset.x(), viewportSize.x());
4951 const float x1 = roundToViewport((subpassNdx % 2) == 0 ? 1.0f : -1.0f + w, viewportOffset.x(), viewportSize.x());
4953 const float y0 = roundToViewport(((subpassNdx / 2) % 2) == 0 ? 1.0f - h : -1.0f, viewportOffset.y(), viewportSize.y());
4954 const float y1 = roundToViewport(((subpassNdx / 2) % 2) == 0 ? 1.0f : -1.0f + h, viewportOffset.y(), viewportSize.y());
4956 renderQuad = tcu::just(RenderQuad(tcu::Vec2(x0, y0), tcu::Vec2(x1, y1)));
4959 renderInfos.push_back(SubpassRenderInfo(renderPass, subpassNdx, config.drawStartNdx, subpassIsSecondary, omitBlendState, viewportOffset, viewportSize, renderQuad, colorClears, depthStencilClear));
4963 void checkTextureFormatSupport (TestLog& log,
4964 const InstanceInterface& vk,
4965 VkPhysicalDevice device,
4966 const vector<Attachment>& attachments)
4968 bool supported = true;
4970 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4972 const Attachment& attachment = attachments[attachmentNdx];
4973 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4974 const bool isDepthOrStencilAttachment = hasDepthComponent(format.order) || hasStencilComponent(format.order);
4975 const VkFormatFeatureFlags flags = isDepthOrStencilAttachment? VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT : VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
4976 VkFormatProperties properties;
4978 vk.getPhysicalDeviceFormatProperties(device, attachment.getFormat(), &properties);
4980 if ((properties.optimalTilingFeatures & flags) != flags)
4983 log << TestLog::Message << "Format: " << attachment.getFormat() << " not supported as " << (isDepthOrStencilAttachment ? "depth stencil attachment" : "color attachment") << TestLog::EndMessage;
4988 TCU_THROW(NotSupportedError, "Format not supported");
4991 tcu::TestStatus renderPassTest (Context& context, TestConfig config)
4993 const UVec2 targetSize = config.targetSize;
4994 const UVec2 renderPos = config.renderPos;
4995 const UVec2 renderSize = config.renderSize;
4996 const RenderPass& renderPassInfo = config.renderPass;
4998 TestLog& log = context.getTestContext().getLog();
4999 de::Random rng (config.seed);
5001 vector<bool> attachmentIsLazy;
5002 vector<VkImageUsageFlags> attachmentImageUsage;
5003 vector<Maybe<VkClearValue> > imageClearValues;
5004 vector<Maybe<VkClearValue> > renderPassClearValues;
5006 vector<bool> subpassIsSecondary;
5007 vector<SubpassRenderInfo> subpassRenderInfo;
5009 if (config.renderingType == RENDERING_TYPE_RENDERPASS2)
5010 context.requireDeviceFunctionality("VK_KHR_create_renderpass2");
5012 if (config.renderingType == RENDERING_TYPE_DYNAMIC_RENDERING)
5013 context.requireDeviceFunctionality("VK_KHR_dynamic_rendering");
5015 if (config.allocationKind == ALLOCATION_KIND_DEDICATED)
5017 if (!context.isDeviceFunctionalitySupported("VK_KHR_dedicated_allocation"))
5018 TCU_THROW(NotSupportedError, "VK_KHR_dedicated_allocation is not supported");
5021 if (!renderPassInfo.getInputAspects().empty())
5023 if (!context.isDeviceFunctionalitySupported("VK_KHR_maintenance2"))
5024 TCU_THROW(NotSupportedError, "Extension VK_KHR_maintenance2 not supported.");
5028 bool requireDepthStencilLayout = false;
5030 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
5032 if (renderPassInfo.getAttachments()[attachmentNdx].getInitialLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5033 || renderPassInfo.getAttachments()[attachmentNdx].getInitialLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL
5034 || renderPassInfo.getAttachments()[attachmentNdx].getFinalLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5035 || renderPassInfo.getAttachments()[attachmentNdx].getFinalLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5037 requireDepthStencilLayout = true;
5042 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size() && !requireDepthStencilLayout; subpassNdx++)
5044 const Subpass& subpass (renderPassInfo.getSubpasses()[subpassNdx]);
5046 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
5048 if (subpass.getColorAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5049 || subpass.getColorAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5051 requireDepthStencilLayout = true;
5056 for (size_t attachmentNdx = 0; !requireDepthStencilLayout && attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
5058 if (subpass.getInputAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5059 || subpass.getInputAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5061 requireDepthStencilLayout = true;
5066 for (size_t attachmentNdx = 0; !requireDepthStencilLayout && attachmentNdx < subpass.getResolveAttachments().size(); attachmentNdx++)
5068 if (subpass.getResolveAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5069 || subpass.getResolveAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5071 requireDepthStencilLayout = true;
5076 if (subpass.getDepthStencilAttachment().getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5077 || subpass.getDepthStencilAttachment().getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5079 requireDepthStencilLayout = true;
5084 if (requireDepthStencilLayout && !context.isDeviceFunctionalitySupported("VK_KHR_maintenance2"))
5085 TCU_THROW(NotSupportedError, "VK_KHR_maintenance2 is not supported");
5088 initializeAttachmentIsLazy(attachmentIsLazy, renderPassInfo.getAttachments(), config.imageMemory);
5089 initializeImageClearValues(rng, imageClearValues, renderPassInfo.getAttachments(), attachmentIsLazy, config.useFormatCompCount, config.depthValues);
5090 initializeAttachmentImageUsage(context, attachmentImageUsage, renderPassInfo, attachmentIsLazy, imageClearValues);
5091 initializeRenderPassClearValues(rng, renderPassClearValues, renderPassInfo.getAttachments(), config.useFormatCompCount, config.depthValues);
5093 initializeSubpassIsSecondary(subpassIsSecondary, renderPassInfo.getSubpasses(), config.commandBufferTypes);
5094 initializeSubpassRenderInfo(subpassRenderInfo, rng, renderPassInfo, config);
5096 logTestCaseInfo(log, config, attachmentIsLazy, imageClearValues, renderPassClearValues, subpassRenderInfo);
5098 checkTextureFormatSupport(log, context.getInstanceInterface(), context.getPhysicalDevice(), config.renderPass.getAttachments());
5101 const vk::VkPhysicalDeviceProperties properties = vk::getPhysicalDeviceProperties(context.getInstanceInterface(), context.getPhysicalDevice());
5103 log << TestLog::Message << "Max color attachments: " << properties.limits.maxColorAttachments << TestLog::EndMessage;
5105 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); subpassNdx++)
5107 if (renderPassInfo.getSubpasses()[subpassNdx].getColorAttachments().size() > (size_t)properties.limits.maxColorAttachments)
5108 TCU_THROW(NotSupportedError, "Subpass uses more than maxColorAttachments.");
5113 const InstanceInterface& vki = context.getInstanceInterface();
5114 const VkPhysicalDevice& physDevice = context.getPhysicalDevice();
5115 const VkDevice device = context.getDevice();
5116 const DeviceInterface& vk = context.getDeviceInterface();
5117 const VkQueue queue = context.getUniversalQueue();
5118 const deUint32 queueIndex = context.getUniversalQueueFamilyIndex();
5119 Allocator& allocator = context.getDefaultAllocator();
5121 const Unique<VkCommandPool> commandBufferPool (createCommandPool(vk, device, 0, queueIndex));
5122 const Unique<VkCommandBuffer> initializeImagesCommandBuffer (allocateCommandBuffer(vk, device, *commandBufferPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
5123 const Unique<VkCommandBuffer> renderCommandBuffer (allocateCommandBuffer(vk, device, *commandBufferPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
5124 const Unique<VkCommandBuffer> readImagesToBuffersCommandBuffer (allocateCommandBuffer(vk, device, *commandBufferPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
5126 vector<de::SharedPtr<AttachmentResources> > attachmentResources;
5127 vector<de::SharedPtr<SubpassRenderer> > subpassRenderers;
5128 vector<VkImage> attachmentImages;
5129 vector<VkImageView> attachmentViews;
5130 vector<pair<VkImageView, VkImageView> > inputAttachmentViews;
5132 Move<VkRenderPass> renderPass;
5133 if (config.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
5134 renderPass = createRenderPass(vk, device, renderPassInfo, config.renderingType);
5136 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
5138 const Attachment& attachmentInfo = renderPassInfo.getAttachments()[attachmentNdx];
5140 attachmentResources.push_back(de::SharedPtr<AttachmentResources>(new AttachmentResources(vki, physDevice, vk, device, allocator, queueIndex, targetSize, attachmentInfo, attachmentImageUsage[attachmentNdx], config.allocationKind)));
5141 attachmentViews.push_back(attachmentResources[attachmentNdx]->getAttachmentView());
5142 attachmentImages.push_back(attachmentResources[attachmentNdx]->getImage());
5144 inputAttachmentViews.push_back(attachmentResources[attachmentNdx]->getInputAttachmentViews());
5147 beginCommandBuffer(vk, *initializeImagesCommandBuffer, (VkCommandBufferUsageFlags)0, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0);
5148 pushImageInitializationCommands(vk, *initializeImagesCommandBuffer, renderPassInfo.getAttachments(), attachmentResources, queueIndex, imageClearValues);
5149 endCommandBuffer(vk, *initializeImagesCommandBuffer);
5152 Move<VkFramebuffer> framebuffer;
5153 if (config.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
5154 framebuffer = createFramebuffer(vk, device, *renderPass, targetSize, attachmentViews);
5156 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); subpassNdx++)
5157 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)));
5159 beginCommandBuffer(vk, *renderCommandBuffer, (VkCommandBufferUsageFlags)0, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0);
5160 pushRenderPassCommands(vk, *renderCommandBuffer, *renderPass, renderPassInfo, attachmentResources, *framebuffer, subpassRenderers, renderPos, renderSize, renderPassClearValues, queueIndex, config.renderTypes, config.renderingType);
5161 endCommandBuffer(vk, *renderCommandBuffer);
5163 beginCommandBuffer(vk, *readImagesToBuffersCommandBuffer, (VkCommandBufferUsageFlags)0, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0);
5164 pushReadImagesToBuffers(vk, *readImagesToBuffersCommandBuffer, queueIndex, attachmentResources, renderPassInfo.getAttachments(), attachmentIsLazy, targetSize);
5165 endCommandBuffer(vk, *readImagesToBuffersCommandBuffer);
5167 const VkCommandBuffer commandBuffers[] =
5169 *initializeImagesCommandBuffer,
5170 *renderCommandBuffer,
5171 *readImagesToBuffersCommandBuffer
5173 const Unique<VkFence> fence (createFence(vk, device, 0u));
5175 queueSubmit(vk, queue, DE_LENGTH_OF_ARRAY(commandBuffers), commandBuffers, *fence);
5176 waitForFences(vk, device, 1, &fence.get(), VK_TRUE, ~0ull);
5180 if (logAndVerifyImages(log, vk, device, attachmentResources, attachmentIsLazy, renderPassInfo, renderPassClearValues, imageClearValues, subpassRenderInfo, targetSize, config))
5181 return tcu::TestStatus::pass("Pass");
5183 return tcu::TestStatus::fail("Result verification failed");
5187 static const VkFormat s_coreColorFormats[] =
5189 VK_FORMAT_R5G6B5_UNORM_PACK16,
5194 VK_FORMAT_R8G8_UNORM,
5195 VK_FORMAT_R8G8_SNORM,
5196 VK_FORMAT_R8G8_UINT,
5197 VK_FORMAT_R8G8_SINT,
5198 VK_FORMAT_R8G8B8A8_UNORM,
5199 VK_FORMAT_R8G8B8A8_SNORM,
5200 VK_FORMAT_R8G8B8A8_UINT,
5201 VK_FORMAT_R8G8B8A8_SINT,
5202 VK_FORMAT_R8G8B8A8_SRGB,
5203 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
5204 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
5205 VK_FORMAT_A8B8G8R8_UINT_PACK32,
5206 VK_FORMAT_A8B8G8R8_SINT_PACK32,
5207 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
5208 VK_FORMAT_B8G8R8A8_UNORM,
5209 VK_FORMAT_B8G8R8A8_SRGB,
5210 VK_FORMAT_A2R10G10B10_UNORM_PACK32,
5211 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
5212 VK_FORMAT_A2B10G10R10_UINT_PACK32,
5213 VK_FORMAT_R16_UNORM,
5214 VK_FORMAT_R16_SNORM,
5217 VK_FORMAT_R16_SFLOAT,
5218 VK_FORMAT_R16G16_UNORM,
5219 VK_FORMAT_R16G16_SNORM,
5220 VK_FORMAT_R16G16_UINT,
5221 VK_FORMAT_R16G16_SINT,
5222 VK_FORMAT_R16G16_SFLOAT,
5223 VK_FORMAT_R16G16B16A16_UNORM,
5224 VK_FORMAT_R16G16B16A16_SNORM,
5225 VK_FORMAT_R16G16B16A16_UINT,
5226 VK_FORMAT_R16G16B16A16_SINT,
5227 VK_FORMAT_R16G16B16A16_SFLOAT,
5230 VK_FORMAT_R32_SFLOAT,
5231 VK_FORMAT_R32G32_UINT,
5232 VK_FORMAT_R32G32_SINT,
5233 VK_FORMAT_R32G32_SFLOAT,
5234 VK_FORMAT_R32G32B32A32_UINT,
5235 VK_FORMAT_R32G32B32A32_SINT,
5236 VK_FORMAT_R32G32B32A32_SFLOAT
5239 static const VkFormat s_coreDepthStencilFormats[] =
5241 VK_FORMAT_D16_UNORM,
5243 VK_FORMAT_X8_D24_UNORM_PACK32,
5244 VK_FORMAT_D32_SFLOAT,
5246 VK_FORMAT_D24_UNORM_S8_UINT,
5247 VK_FORMAT_D32_SFLOAT_S8_UINT
5250 void addAttachmentTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
5252 const deUint32 attachmentCounts[] = { 1, 3, 4, 8 };
5253 const VkAttachmentLoadOp loadOps[] =
5255 VK_ATTACHMENT_LOAD_OP_LOAD,
5256 VK_ATTACHMENT_LOAD_OP_CLEAR,
5257 VK_ATTACHMENT_LOAD_OP_DONT_CARE
5260 const VkAttachmentStoreOp storeOps[] =
5262 VK_ATTACHMENT_STORE_OP_STORE,
5263 VK_ATTACHMENT_STORE_OP_DONT_CARE
5266 const VkImageLayout initialAndFinalColorLayouts[] =
5268 VK_IMAGE_LAYOUT_GENERAL,
5269 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5270 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
5271 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
5272 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
5275 const VkImageLayout initialAndFinalColorLayoutsLazy[] =
5277 VK_IMAGE_LAYOUT_GENERAL,
5278 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5279 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
5282 const VkImageLayout initialAndFinalDepthStencilLayouts[] =
5284 VK_IMAGE_LAYOUT_GENERAL,
5285 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5286 VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL,
5287 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
5288 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
5289 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
5292 const VkImageLayout initialAndFinalDepthStencilLayoutsLazy[] =
5294 VK_IMAGE_LAYOUT_GENERAL,
5295 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5296 VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL,
5297 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
5300 const VkImageLayout subpassLayouts[] =
5302 VK_IMAGE_LAYOUT_GENERAL,
5303 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
5306 const VkImageLayout depthStencilLayouts[] =
5308 VK_IMAGE_LAYOUT_GENERAL,
5309 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
5312 const TestConfig::RenderTypes renderCommands[] =
5314 TestConfig::RENDERTYPES_NONE,
5315 TestConfig::RENDERTYPES_CLEAR,
5316 TestConfig::RENDERTYPES_DRAW,
5317 TestConfig::RENDERTYPES_CLEAR|TestConfig::RENDERTYPES_DRAW,
5320 const TestConfig::CommandBufferTypes commandBuffers[] =
5322 TestConfig::COMMANDBUFFERTYPES_INLINE,
5323 TestConfig::COMMANDBUFFERTYPES_SECONDARY,
5324 TestConfig::COMMANDBUFFERTYPES_INLINE|TestConfig::COMMANDBUFFERTYPES_SECONDARY
5327 const TestConfig::ImageMemory imageMemories[] =
5329 TestConfig::IMAGEMEMORY_STRICT,
5330 TestConfig::IMAGEMEMORY_LAZY,
5331 TestConfig::IMAGEMEMORY_STRICT|TestConfig::IMAGEMEMORY_LAZY
5334 const UVec2 targetSizes[] =
5340 const UVec2 renderPositions[] =
5346 const UVec2 renderSizes[] =
5352 tcu::TestContext& testCtx (group->getTestContext());
5353 bool useDynamicRendering (testConfigExternal.renderingType == RENDERING_TYPE_DYNAMIC_RENDERING);
5354 de::Random rng (1433774382u);
5356 for (size_t attachmentCountNdx = 0; attachmentCountNdx < DE_LENGTH_OF_ARRAY(attachmentCounts); attachmentCountNdx++)
5358 const deUint32 attachmentCount = attachmentCounts[attachmentCountNdx];
5359 const deUint32 testCaseCount = (attachmentCount == 1 ? 100 : 200);
5360 de::MovePtr<tcu::TestCaseGroup> attachmentCountGroup (new tcu::TestCaseGroup(testCtx, de::toString(attachmentCount).c_str(), de::toString(attachmentCount).c_str()));
5362 for (size_t testCaseNdx = 0; testCaseNdx < testCaseCount; testCaseNdx++)
5364 const bool useDepthStencil = rng.getBool();
5365 const TestConfig::ImageMemory imageMemory = rng.choose<TestConfig::ImageMemory>(DE_ARRAY_BEGIN(imageMemories), DE_ARRAY_END(imageMemories));
5366 VkImageLayout depthStencilLayout = VK_IMAGE_LAYOUT_GENERAL;
5367 vector<Attachment> attachments;
5368 vector<AttachmentReference> colorAttachmentReferences;
5370 // we want to make sure that dynamic rendering test cases have corresponding renderpass
5371 // cases as this will allow drivers to easily compare GPU batches; since configurations
5372 // for those tests are generated we need to generate configurations for all cases
5373 // even when we know earlier that for dynamic rendering we will skip it
5374 bool executeForDynamicRendering = true;
5376 for (size_t attachmentNdx = 0; attachmentNdx < attachmentCount; attachmentNdx++)
5378 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
5379 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreColorFormats), DE_ARRAY_END(s_coreColorFormats));
5380 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5381 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5383 const VkImageLayout initialLayout = (imageMemory == TestConfig::IMAGEMEMORY_STRICT)
5384 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts))
5385 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayoutsLazy), DE_ARRAY_END(initialAndFinalColorLayoutsLazy));
5386 VkImageLayout finalizeLayout = (imageMemory == TestConfig::IMAGEMEMORY_STRICT)
5387 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts))
5388 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayoutsLazy), DE_ARRAY_END(initialAndFinalColorLayoutsLazy));
5389 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayouts), DE_ARRAY_END(subpassLayouts));
5391 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5392 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5394 if (useDynamicRendering)
5396 // with renderpass we can have automatic layout transitions; to do the same with dynamic rendering cases
5397 // we would need to add addtional barries but since those tests won't add coverage we are skipping them
5398 if ((initialLayout == VK_IMAGE_LAYOUT_GENERAL) ||
5399 (initialLayout == VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL))
5400 finalizeLayout = initialLayout;
5402 executeForDynamicRendering = false;
5405 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5406 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
5409 if (useDepthStencil)
5411 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
5412 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreDepthStencilFormats), DE_ARRAY_END(s_coreDepthStencilFormats));
5413 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5414 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5416 const VkImageLayout initialLayout = (imageMemory == TestConfig::IMAGEMEMORY_STRICT)
5417 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
5418 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayoutsLazy), DE_ARRAY_END(initialAndFinalDepthStencilLayoutsLazy));
5419 VkImageLayout finalizeLayout = (imageMemory == TestConfig::IMAGEMEMORY_STRICT)
5420 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
5421 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayoutsLazy), DE_ARRAY_END(initialAndFinalDepthStencilLayoutsLazy));
5423 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5424 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5426 if (useDynamicRendering)
5428 if ((initialLayout == VK_IMAGE_LAYOUT_GENERAL) ||
5429 (initialLayout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL) ||
5430 (initialLayout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL))
5431 finalizeLayout = initialLayout;
5433 executeForDynamicRendering = false;
5436 depthStencilLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(depthStencilLayouts), DE_ARRAY_END(depthStencilLayouts));
5437 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5441 const TestConfig::RenderTypes render = rng.choose<TestConfig::RenderTypes>(DE_ARRAY_BEGIN(renderCommands), DE_ARRAY_END(renderCommands));
5442 const TestConfig::CommandBufferTypes commandBuffer = rng.choose<TestConfig::CommandBufferTypes>(DE_ARRAY_BEGIN(commandBuffers), DE_ARRAY_END(commandBuffers));
5443 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>()));
5444 const vector<SubpassDependency> deps;
5445 const string testCaseName = de::toString(attachmentCountNdx * testCaseCount + testCaseNdx);
5446 const RenderPass renderPass (attachments, subpasses, deps);
5447 const UVec2 targetSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(targetSizes), DE_ARRAY_END(targetSizes));
5448 const UVec2 renderPos = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderPositions), DE_ARRAY_END(renderPositions));
5449 const UVec2 renderSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderSizes), DE_ARRAY_END(renderSizes));
5451 // skip dynamic rendering cases (that don't add coverage)
5452 // this can be done not earlier than after grabbing all random numbers as
5453 // we need to make sure that those tests that will be created for dynamic
5454 // rendering have corresponding renderpass tests with the same name
5455 if (useDynamicRendering && !executeForDynamicRendering)
5458 const TestConfig testConfig (renderPass,
5468 testConfigExternal.allocationKind,
5469 testConfigExternal.renderingType);
5471 addFunctionCaseWithPrograms<TestConfig>(attachmentCountGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, testConfig);
5475 group->addChild(attachmentCountGroup.release());
5479 void addAttachmentWriteMaskTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
5481 const deUint32 attachmentCounts[] = { 1, 2, 3, 4, 8 };
5483 const VkFormat attachmentFormats[] =
5485 VK_FORMAT_R8G8B8A8_UINT,
5486 VK_FORMAT_R8G8B8A8_UNORM,
5487 VK_FORMAT_R5G6B5_UNORM_PACK16,
5488 VK_FORMAT_R8G8_UNORM
5491 tcu::TestContext& testCtx = group->getTestContext();
5493 for (deUint32 attachmentCountNdx = 0; attachmentCountNdx < DE_LENGTH_OF_ARRAY(attachmentCounts); attachmentCountNdx++)
5495 const deUint32 attachmentCount = attachmentCounts[attachmentCountNdx];
5496 const string groupName = "attachment_count_" + de::toString(attachmentCount);
5498 de::MovePtr<tcu::TestCaseGroup> attachmentCountGroup(new tcu::TestCaseGroup(testCtx, groupName.c_str(), de::toString(attachmentCount).c_str()));
5500 for (deUint32 drawStartNdx = 0; drawStartNdx < (attachmentCount); drawStartNdx++)
5502 deUint32 formatNdx = 0;
5503 vector<Attachment> attachments;
5504 vector<AttachmentReference> colorAttachmentReferences;
5506 for (deUint32 attachmentNdx = 0; attachmentNdx < attachmentCount; attachmentNdx++)
5508 const VkFormat format = attachmentFormats[formatNdx];
5509 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
5510 const VkAttachmentLoadOp loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
5511 const VkAttachmentStoreOp storeOp = VK_ATTACHMENT_STORE_OP_STORE;
5512 const VkAttachmentLoadOp stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
5513 const VkAttachmentStoreOp stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
5514 const VkImageLayout initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
5515 const VkImageLayout finalizeLayout = (testConfigExternal.renderingType == RENDERING_TYPE_DYNAMIC_RENDERING)
5516 ? initialLayout : VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
5517 const VkImageLayout subpassLayout = VK_IMAGE_LAYOUT_GENERAL;
5519 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5520 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
5522 if (++formatNdx == DE_LENGTH_OF_ARRAY(attachmentFormats))
5527 const VkImageLayout depthStencilLayout = VK_IMAGE_LAYOUT_GENERAL;
5528 const vector<Subpass> subpass (1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u, vector<AttachmentReference>(), colorAttachmentReferences, vector<AttachmentReference>(), AttachmentReference(VK_ATTACHMENT_UNUSED, depthStencilLayout), vector<deUint32>()));
5529 const vector<SubpassDependency> deps;
5531 const string testCaseName = "start_index_" + de::toString(drawStartNdx);
5532 const RenderPass renderPass (attachments, subpass, deps);
5534 const TestConfig::RenderTypes render = TestConfig::RENDERTYPES_DRAW;
5535 const TestConfig::CommandBufferTypes commandBuffer = TestConfig::COMMANDBUFFERTYPES_INLINE;
5536 const TestConfig::ImageMemory imageMemory = TestConfig::IMAGEMEMORY_LAZY;
5537 const UVec2 targetSize = UVec2(64, 64);
5538 const UVec2 renderPos = UVec2(0, 0);
5539 const UVec2 renderSize = UVec2(64, 64);
5540 const deBool useFormatCompCount = DE_TRUE;
5541 const vector<DeviceCoreFeature> requiredFeatures = {DEVICE_CORE_FEATURE_INDEPENDENT_BLEND};
5542 const TestConfig testConfig (renderPass,
5552 testConfigExternal.allocationKind,
5553 testConfigExternal.renderingType,
5556 addFunctionCaseWithPrograms<TestConfig>(attachmentCountGroup.get(), testCaseName.c_str(), testCaseName.c_str(), checkSupport, createTestShaders, renderPassTest, testConfig);
5560 group->addChild(attachmentCountGroup.release());
5564 template<typename T>
5565 T chooseRandom (de::Random& rng, const set<T>& values)
5567 size_t ndx = ((size_t)rng.getUint32()) % values.size();
5568 typename set<T>::const_iterator iter = values.begin();
5570 for (; ndx > 0; ndx--)
5576 void addAttachmentAllocationTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
5578 const deUint32 attachmentCounts[] = { 4, 8 };
5579 const VkAttachmentLoadOp loadOps[] =
5581 VK_ATTACHMENT_LOAD_OP_LOAD,
5582 VK_ATTACHMENT_LOAD_OP_CLEAR,
5583 VK_ATTACHMENT_LOAD_OP_DONT_CARE
5586 const VkAttachmentStoreOp storeOps[] =
5588 VK_ATTACHMENT_STORE_OP_STORE,
5589 VK_ATTACHMENT_STORE_OP_DONT_CARE
5592 const VkImageLayout initialAndFinalColorLayouts[] =
5594 VK_IMAGE_LAYOUT_GENERAL,
5595 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5596 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
5597 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
5598 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
5601 const VkImageLayout initialAndFinalDepthStencilLayouts[] =
5603 VK_IMAGE_LAYOUT_GENERAL,
5604 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5605 VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL,
5606 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
5607 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
5608 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
5611 const VkImageLayout subpassLayoutsColor[] =
5613 VK_IMAGE_LAYOUT_GENERAL,
5614 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
5617 const VkImageLayout subpassLayoutsDepthStencil[] =
5619 VK_IMAGE_LAYOUT_GENERAL,
5620 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
5623 const VkImageLayout subpassLayoutsInput[] =
5625 VK_IMAGE_LAYOUT_GENERAL,
5626 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
5631 // Each pass uses one more attachmen than previous one
5632 ALLOCATIONTYPE_GROW,
5633 // Each pass uses one less attachment than previous one
5634 ALLOCATIONTYPE_SHRINK,
5635 // Each pass drops one attachment and picks up new one
5636 ALLOCATIONTYPE_ROLL,
5637 // Start by growing and end by shrinking
5638 ALLOCATIONTYPE_GROW_SHRINK,
5639 // Each subpass has single input and single output attachment
5640 ALLOCATIONTYPE_IO_CHAIN,
5641 // Each subpass has multiple inputs and multiple outputs attachment
5642 ALLOCATIONTYPE_IO_GENERIC
5645 const AllocationType allocationTypes[] =
5647 ALLOCATIONTYPE_GROW,
5648 ALLOCATIONTYPE_SHRINK,
5649 ALLOCATIONTYPE_ROLL,
5650 ALLOCATIONTYPE_GROW_SHRINK,
5651 ALLOCATIONTYPE_IO_CHAIN,
5652 ALLOCATIONTYPE_IO_GENERIC
5655 const char* const allocationTypeStr[] =
5661 "input_output_chain",
5665 const TestConfig::RenderTypes renderCommands[] =
5667 TestConfig::RENDERTYPES_NONE,
5668 TestConfig::RENDERTYPES_CLEAR,
5669 TestConfig::RENDERTYPES_DRAW,
5670 TestConfig::RENDERTYPES_CLEAR|TestConfig::RENDERTYPES_DRAW,
5673 const TestConfig::CommandBufferTypes commandBuffers[] =
5675 TestConfig::COMMANDBUFFERTYPES_INLINE,
5676 TestConfig::COMMANDBUFFERTYPES_SECONDARY,
5677 TestConfig::COMMANDBUFFERTYPES_INLINE|TestConfig::COMMANDBUFFERTYPES_SECONDARY
5680 const TestConfig::ImageMemory imageMemories[] =
5682 TestConfig::IMAGEMEMORY_STRICT,
5683 TestConfig::IMAGEMEMORY_LAZY,
5684 TestConfig::IMAGEMEMORY_STRICT|TestConfig::IMAGEMEMORY_LAZY
5687 const UVec2 targetSizes[] =
5693 const UVec2 renderPositions[] =
5699 const UVec2 renderSizes[] =
5705 tcu::TestContext& testCtx = group->getTestContext();
5706 de::Random rng (3700649827u);
5708 for (size_t allocationTypeNdx = 0; allocationTypeNdx < DE_LENGTH_OF_ARRAY(allocationTypes); allocationTypeNdx++)
5710 const AllocationType allocationType = allocationTypes[allocationTypeNdx];
5711 const size_t testCaseCount = 100;
5712 de::MovePtr<tcu::TestCaseGroup> allocationTypeGroup (new tcu::TestCaseGroup(testCtx, allocationTypeStr[allocationTypeNdx], allocationTypeStr[allocationTypeNdx]));
5714 for (size_t testCaseNdx = 0; testCaseNdx < testCaseCount; testCaseNdx++)
5716 if (allocationType == ALLOCATIONTYPE_IO_GENERIC)
5718 const deUint32 attachmentCount = 4u + rng.getUint32() % 31u;
5719 const deUint32 subpassCount = 4u + rng.getUint32() % 31u;
5720 vector<Attachment> attachments;
5722 set<deUint32> definedAttachments;
5724 vector<Subpass> subpasses;
5725 set<deUint32> colorAttachments;
5726 set<deUint32> depthStencilAttachments;
5728 for (deUint32 attachmentIndex = 0; attachmentIndex < attachmentCount; attachmentIndex++)
5730 const bool isDepthStencilAttachment = rng.getFloat() < 0.01f;
5731 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
5732 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5733 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5735 const VkImageLayout initialLayout = isDepthStencilAttachment
5736 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
5737 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
5738 const VkImageLayout finalizeLayout = isDepthStencilAttachment
5739 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
5740 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
5742 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5743 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5745 if (isDepthStencilAttachment)
5747 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreDepthStencilFormats), DE_ARRAY_END(s_coreDepthStencilFormats));
5749 if (loadOp == VK_ATTACHMENT_LOAD_OP_LOAD || loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR
5750 || stencilLoadOp == VK_ATTACHMENT_LOAD_OP_LOAD || stencilLoadOp == VK_ATTACHMENT_LOAD_OP_CLEAR)
5751 definedAttachments.insert(attachmentIndex);
5753 depthStencilAttachments.insert(attachmentIndex);
5755 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5759 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreColorFormats), DE_ARRAY_END(s_coreColorFormats));
5761 if (loadOp == VK_ATTACHMENT_LOAD_OP_LOAD || loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR)
5762 definedAttachments.insert(attachmentIndex);
5764 colorAttachments.insert(attachmentIndex);
5766 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5769 vector<Maybe<deUint32> > lastUseOfAttachment (attachments.size(), tcu::Nothing);
5770 vector<SubpassDependency> deps;
5772 for (deUint32 subpassIndex = 0; subpassIndex < subpassCount; subpassIndex++)
5774 const deUint32 colorAttachmentCount = depthStencilAttachments.empty()
5775 ? 1 + rng.getUint32() % de::min(4u, (deUint32)colorAttachments.size())
5776 : rng.getUint32() % (de::min(4u, (deUint32)colorAttachments.size()) + 1u);
5777 const deUint32 inputAttachmentCount = rng.getUint32() % (deUint32)(de::min<size_t>(4, definedAttachments.size()) + 1);
5778 const bool useDepthStencilAttachment = !depthStencilAttachments.empty() && (colorAttachmentCount == 0 || rng.getBool());
5779 std::vector<deUint32> subpassColorAttachments (colorAttachmentCount);
5780 std::vector<deUint32> subpassInputAttachments (inputAttachmentCount);
5781 Maybe<deUint32> depthStencilAttachment (useDepthStencilAttachment
5782 ? just(chooseRandom(rng, depthStencilAttachments))
5784 std::vector<deUint32> subpassPreserveAttachments;
5786 rng.choose(colorAttachments.begin(), colorAttachments.end(), subpassColorAttachments.begin(), colorAttachmentCount);
5787 rng.choose(definedAttachments.begin(), definedAttachments.end(), subpassInputAttachments.begin(), inputAttachmentCount);
5789 for (size_t colorAttachmentNdx = 0; colorAttachmentNdx < subpassColorAttachments.size(); colorAttachmentNdx++)
5790 definedAttachments.insert(subpassColorAttachments[colorAttachmentNdx]);
5792 if (depthStencilAttachment)
5793 definedAttachments.insert(*depthStencilAttachment);
5796 std::vector<AttachmentReference> inputAttachmentReferences;
5797 std::vector<AttachmentReference> colorAttachmentReferences;
5798 AttachmentReference depthStencilAttachmentReference (VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL);
5800 for (size_t colorAttachmentNdx = 0; colorAttachmentNdx < subpassColorAttachments.size(); colorAttachmentNdx++)
5802 const deUint32 colorAttachmentIndex = subpassColorAttachments[colorAttachmentNdx];
5804 if (lastUseOfAttachment[colorAttachmentIndex])
5806 deBool foundDuplicate = false;
5808 const deUint32 srcPass = *lastUseOfAttachment[colorAttachmentIndex];
5809 const deUint32 dstPass = subpassIndex;
5810 const VkDependencyFlags dependencyFlags = rng.getBool() ? (VkDependencyFlags) VK_DEPENDENCY_BY_REGION_BIT : 0u;
5812 const SubpassDependency newDependency(srcPass, dstPass,
5813 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5814 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5815 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5816 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5818 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5819 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5820 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5821 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5823 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
5824 VK_ACCESS_COLOR_ATTACHMENT_READ_BIT,
5828 for (SubpassDependency& dependency : deps)
5830 if (dependency.getSrcPass() == srcPass && dependency.getDstPass() == dstPass)
5832 const VkAccessFlags newDstFlags = dependency.getDstAccessMask() | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT;
5833 dependency.setDstAccessMask(newDstFlags);
5834 foundDuplicate = true;
5839 if (!foundDuplicate)
5841 deps.push_back(newDependency);
5845 lastUseOfAttachment[colorAttachmentIndex] = just(subpassIndex);
5847 colorAttachmentReferences.push_back(AttachmentReference((deUint32)subpassColorAttachments[colorAttachmentNdx], VK_IMAGE_LAYOUT_GENERAL));
5850 for (size_t inputAttachmentNdx = 0; inputAttachmentNdx < subpassInputAttachments.size(); inputAttachmentNdx++)
5852 const deUint32 inputAttachmentIndex = subpassInputAttachments[inputAttachmentNdx];
5854 if(lastUseOfAttachment[inputAttachmentIndex])
5856 deBool foundDuplicate = false;
5858 const deUint32 srcPass = *lastUseOfAttachment[inputAttachmentIndex];
5859 const deUint32 dstPass = subpassIndex;
5860 const VkDependencyFlags dependencyFlags = ((srcPass == subpassIndex) || rng.getBool()) ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u;
5862 const SubpassDependency newDependency(srcPass, dstPass,
5863 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5864 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5865 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5866 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5868 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5869 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5870 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5871 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5873 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
5874 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5877 for (SubpassDependency& dependency : deps)
5879 if (dependency.getSrcPass() == srcPass && dependency.getDstPass() == dstPass)
5881 const VkAccessFlags newSrcFlags = dependency.getSrcAccessMask() | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
5882 const VkAccessFlags newDstFlags = dependency.getDstAccessMask() | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT;
5883 dependency.setDstAccessMask(newSrcFlags);
5884 dependency.setDstAccessMask(newDstFlags);
5885 foundDuplicate = true;
5890 if (!foundDuplicate)
5892 deps.push_back(newDependency);
5895 lastUseOfAttachment[inputAttachmentIndex] = just(subpassIndex);
5897 VkImageAspectFlags aspect = 0u;
5898 if (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2)
5900 bool col = colorAttachments.find(inputAttachmentIndex) != colorAttachments.end();
5901 aspect = col ? VK_IMAGE_ASPECT_COLOR_BIT : VK_IMAGE_ASPECT_DEPTH_BIT;
5903 inputAttachmentReferences.push_back(AttachmentReference((deUint32)subpassInputAttachments[inputAttachmentNdx], VK_IMAGE_LAYOUT_GENERAL, aspect));
5907 if (depthStencilAttachment)
5909 if (lastUseOfAttachment[*depthStencilAttachment])
5911 deBool foundDuplicate = false;
5913 const deUint32 srcPass = *lastUseOfAttachment[*depthStencilAttachment];
5914 const deUint32 dstPass = subpassIndex;
5915 const VkDependencyFlags dependencyFlags = ((srcPass == subpassIndex) || rng.getBool()) ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u;
5917 const SubpassDependency newDependency(srcPass, dstPass,
5918 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5919 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5920 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5921 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5923 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5924 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5925 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5926 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5928 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
5929 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT
5930 | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5933 for (SubpassDependency& dependency : deps)
5935 if (dependency.getSrcPass() == srcPass && dependency.getDstPass() == dstPass)
5937 const VkAccessFlags newSrcFlags = dependency.getSrcAccessMask() | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
5938 const VkAccessFlags newDstFlags = dependency.getDstAccessMask() | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT;
5939 dependency.setDstAccessMask(newSrcFlags);
5940 dependency.setDstAccessMask(newDstFlags);
5941 foundDuplicate = true;
5946 if (!foundDuplicate)
5948 deps.push_back(newDependency);
5952 lastUseOfAttachment[*depthStencilAttachment] = just(subpassIndex);
5954 depthStencilAttachmentReference = AttachmentReference(*depthStencilAttachment, VK_IMAGE_LAYOUT_GENERAL);
5957 depthStencilAttachmentReference = AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL);
5959 vector<deUint32> preserveAttachments;
5960 for (deUint32 attachmentIndex = 0; attachmentIndex < (deUint32)attachments.size(); attachmentIndex++)
5962 if (lastUseOfAttachment[attachmentIndex] && (*lastUseOfAttachment[attachmentIndex]) != subpassIndex)
5963 preserveAttachments.push_back(attachmentIndex);
5966 // Use random image layout when possible
5967 for (size_t colorRefIdx = 0; colorRefIdx < colorAttachmentReferences.size(); ++colorRefIdx)
5969 bool usedAsInput = false;
5970 for (size_t inputRefIdx = 0; inputRefIdx < inputAttachmentReferences.size(); ++inputRefIdx)
5971 if (colorAttachmentReferences[colorRefIdx].getAttachment() == inputAttachmentReferences[inputRefIdx].getAttachment())
5975 colorAttachmentReferences[colorRefIdx].setImageLayout(rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor)));
5977 for (size_t inputRefIdx = 0; inputRefIdx < inputAttachmentReferences.size(); ++inputRefIdx)
5979 bool usedAsDepthStencil = inputAttachmentReferences[inputRefIdx].getAttachment() == depthStencilAttachmentReference.getAttachment();
5980 bool usedAsColor = false;
5981 for (size_t colorRefIdx = 0; colorRefIdx < colorAttachmentReferences.size(); ++colorRefIdx)
5982 if (inputAttachmentReferences[inputRefIdx].getAttachment() == colorAttachmentReferences[colorRefIdx].getAttachment())
5985 if (!usedAsColor && !usedAsDepthStencil)
5986 inputAttachmentReferences[inputRefIdx].setImageLayout(rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsInput), DE_ARRAY_END(subpassLayoutsInput)));
5989 bool usedAsInput = false;
5990 for (size_t inputRefIdx = 0; inputRefIdx < inputAttachmentReferences.size(); ++inputRefIdx)
5991 if (depthStencilAttachmentReference.getAttachment() == inputAttachmentReferences[inputRefIdx].getAttachment())
5995 depthStencilAttachmentReference.setImageLayout(rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsDepthStencil), DE_ARRAY_END(subpassLayoutsDepthStencil)));
5998 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
5999 inputAttachmentReferences,
6000 colorAttachmentReferences,
6001 vector<AttachmentReference>(),
6002 depthStencilAttachmentReference,
6003 preserveAttachments));
6007 const TestConfig::RenderTypes render = rng.choose<TestConfig::RenderTypes>(DE_ARRAY_BEGIN(renderCommands), DE_ARRAY_END(renderCommands));
6008 const TestConfig::CommandBufferTypes commandBuffer = rng.choose<TestConfig::CommandBufferTypes>(DE_ARRAY_BEGIN(commandBuffers), DE_ARRAY_END(commandBuffers));
6009 const TestConfig::ImageMemory imageMemory = rng.choose<TestConfig::ImageMemory>(DE_ARRAY_BEGIN(imageMemories), DE_ARRAY_END(imageMemories));
6011 const string testCaseName = de::toString(testCaseNdx);
6012 const UVec2 targetSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(targetSizes), DE_ARRAY_END(targetSizes));
6013 const UVec2 renderPos = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderPositions), DE_ARRAY_END(renderPositions));
6014 const UVec2 renderSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderSizes), DE_ARRAY_END(renderSizes));
6016 const RenderPass renderPass (attachments, subpasses, deps);
6017 const TestConfig testConfig (renderPass,
6027 testConfigExternal.allocationKind,
6028 testConfigExternal.renderingType);
6030 addFunctionCaseWithPrograms<TestConfig>(allocationTypeGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, testConfig);
6035 const deUint32 attachmentCount = rng.choose<deUint32>(DE_ARRAY_BEGIN(attachmentCounts), DE_ARRAY_END(attachmentCounts));
6036 vector<Attachment> attachments;
6037 vector<Subpass> subpasses;
6039 for (size_t attachmentNdx = 0; attachmentNdx < attachmentCount; attachmentNdx++)
6041 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
6042 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreColorFormats), DE_ARRAY_END(s_coreColorFormats));
6043 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
6044 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
6046 const VkImageLayout initialLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
6047 const VkImageLayout finalizeLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
6049 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
6050 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
6052 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
6055 if (allocationType == ALLOCATIONTYPE_GROW)
6057 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
6059 vector<AttachmentReference> colorAttachmentReferences;
6061 for (size_t attachmentNdx = 0; attachmentNdx < subpassNdx + 1; attachmentNdx++)
6063 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6065 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
6068 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6069 vector<AttachmentReference>(),
6070 colorAttachmentReferences,
6071 vector<AttachmentReference>(),
6072 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6073 vector<deUint32>()));
6076 else if (allocationType == ALLOCATIONTYPE_SHRINK)
6078 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
6080 vector<AttachmentReference> colorAttachmentReferences;
6082 for (size_t attachmentNdx = 0; attachmentNdx < (attachmentCount - subpassNdx); attachmentNdx++)
6084 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6086 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
6089 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6090 vector<AttachmentReference>(),
6091 colorAttachmentReferences,
6092 vector<AttachmentReference>(),
6093 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6094 vector<deUint32>()));
6097 else if (allocationType == ALLOCATIONTYPE_ROLL)
6099 for (size_t subpassNdx = 0; subpassNdx < attachmentCount / 2; subpassNdx++)
6101 vector<AttachmentReference> colorAttachmentReferences;
6103 for (size_t attachmentNdx = 0; attachmentNdx < attachmentCount / 2; attachmentNdx++)
6105 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6107 colorAttachmentReferences.push_back(AttachmentReference((deUint32)(subpassNdx + attachmentNdx), subpassLayout));
6110 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6111 vector<AttachmentReference>(),
6112 colorAttachmentReferences,
6113 vector<AttachmentReference>(),
6114 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6115 vector<deUint32>()));
6118 else if (allocationType == ALLOCATIONTYPE_GROW_SHRINK)
6120 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
6122 vector<AttachmentReference> colorAttachmentReferences;
6124 for (size_t attachmentNdx = 0; attachmentNdx < subpassNdx + 1; attachmentNdx++)
6126 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6128 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
6131 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6132 vector<AttachmentReference>(),
6133 colorAttachmentReferences,
6134 vector<AttachmentReference>(),
6135 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6136 vector<deUint32>()));
6138 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
6140 vector<AttachmentReference> colorAttachmentReferences;
6142 for (size_t attachmentNdx = 0; attachmentNdx < (attachmentCount - subpassNdx); attachmentNdx++)
6144 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6146 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
6149 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6150 vector<AttachmentReference>(),
6151 colorAttachmentReferences,
6152 vector<AttachmentReference>(),
6153 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6154 vector<deUint32>()));
6157 else if (allocationType == ALLOCATIONTYPE_IO_CHAIN)
6159 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6160 vector<AttachmentReference>(),
6161 vector<AttachmentReference>(1, AttachmentReference(0, rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor)))),
6162 vector<AttachmentReference>(),
6163 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6164 vector<deUint32>()));
6166 for (size_t subpassNdx = 1; subpassNdx < attachmentCount; subpassNdx++)
6168 const VkImageAspectFlags inputAttachmentAspectMask = (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2) ? VK_IMAGE_ASPECT_COLOR_BIT : static_cast<VkImageAspectFlagBits>(0);
6169 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6170 vector<AttachmentReference>(1, AttachmentReference((deUint32)(subpassNdx - 1), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
6171 vector<AttachmentReference>(1, AttachmentReference((deUint32)(subpassNdx), rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor)))),
6172 vector<AttachmentReference>(),
6173 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6174 vector<deUint32>()));
6178 DE_FATAL("Unknown allocation type");
6181 const TestConfig::RenderTypes render = rng.choose<TestConfig::RenderTypes>(DE_ARRAY_BEGIN(renderCommands), DE_ARRAY_END(renderCommands));
6182 const TestConfig::CommandBufferTypes commandBuffer = rng.choose<TestConfig::CommandBufferTypes>(DE_ARRAY_BEGIN(commandBuffers), DE_ARRAY_END(commandBuffers));
6183 const TestConfig::ImageMemory imageMemory = rng.choose<TestConfig::ImageMemory>(DE_ARRAY_BEGIN(imageMemories), DE_ARRAY_END(imageMemories));
6185 const string testCaseName = de::toString(testCaseNdx);
6186 const UVec2 targetSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(targetSizes), DE_ARRAY_END(targetSizes));
6187 const UVec2 renderPos = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderPositions), DE_ARRAY_END(renderPositions));
6188 const UVec2 renderSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderSizes), DE_ARRAY_END(renderSizes));
6190 vector<SubpassDependency> deps;
6192 for (size_t subpassNdx = 0; subpassNdx < subpasses.size() - 1; subpassNdx++)
6194 const bool byRegion = rng.getBool();
6195 deps.push_back(SubpassDependency((deUint32)subpassNdx, (deUint32)subpassNdx + 1,
6196 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
6197 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
6198 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
6199 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6201 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
6202 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
6203 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
6204 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6206 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6207 (VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT),
6209 byRegion ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u));
6212 const RenderPass renderPass (attachments, subpasses, deps);
6213 const TestConfig testConfig (renderPass,
6223 testConfigExternal.allocationKind,
6224 testConfigExternal.renderingType);
6226 addFunctionCaseWithPrograms<TestConfig>(allocationTypeGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, testConfig);
6230 group->addChild(allocationTypeGroup.release());
6234 void addSimpleTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
6236 const UVec2 targetSize (64, 64);
6237 const UVec2 renderPos (0, 0);
6238 const UVec2 renderSize (64, 64);
6242 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6243 VK_SAMPLE_COUNT_1_BIT,
6244 VK_ATTACHMENT_LOAD_OP_CLEAR,
6245 VK_ATTACHMENT_STORE_OP_STORE,
6246 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6247 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6248 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6249 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6250 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6252 vector<AttachmentReference>(),
6253 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6254 vector<AttachmentReference>(),
6255 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6256 vector<deUint32>())),
6257 vector<SubpassDependency>());
6258 const TestConfig testConfig (renderPass,
6259 TestConfig::RENDERTYPES_DRAW,
6260 TestConfig::COMMANDBUFFERTYPES_INLINE,
6261 TestConfig::IMAGEMEMORY_STRICT,
6268 testConfigExternal.allocationKind,
6269 testConfigExternal.renderingType);
6271 addFunctionCaseWithPrograms<TestConfig>(group, "color", "Single color attachment case.", createTestShaders, renderPassTest, testConfig);
6276 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_X8_D24_UNORM_PACK32,
6277 VK_SAMPLE_COUNT_1_BIT,
6278 VK_ATTACHMENT_LOAD_OP_CLEAR,
6279 VK_ATTACHMENT_STORE_OP_STORE,
6280 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6281 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6282 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6283 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6284 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6286 vector<AttachmentReference>(),
6287 vector<AttachmentReference>(),
6288 vector<AttachmentReference>(),
6289 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6290 vector<deUint32>())),
6291 vector<SubpassDependency>());
6292 const TestConfig testConfig (renderPass,
6293 TestConfig::RENDERTYPES_DRAW,
6294 TestConfig::COMMANDBUFFERTYPES_INLINE,
6295 TestConfig::IMAGEMEMORY_STRICT,
6302 testConfigExternal.allocationKind,
6303 testConfigExternal.renderingType);
6305 addFunctionCaseWithPrograms<TestConfig>(group, "depth", "Single depth attachment case.", createTestShaders, renderPassTest, testConfig);
6310 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_S8_UINT,
6311 VK_SAMPLE_COUNT_1_BIT,
6312 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6313 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6314 VK_ATTACHMENT_LOAD_OP_CLEAR,
6315 VK_ATTACHMENT_STORE_OP_STORE,
6316 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6317 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6318 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6320 vector<AttachmentReference>(),
6321 vector<AttachmentReference>(),
6322 vector<AttachmentReference>(),
6323 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6324 vector<deUint32>())),
6325 vector<SubpassDependency>());
6326 const TestConfig testConfig (renderPass,
6327 TestConfig::RENDERTYPES_DRAW,
6328 TestConfig::COMMANDBUFFERTYPES_INLINE,
6329 TestConfig::IMAGEMEMORY_STRICT,
6336 testConfigExternal.allocationKind,
6337 testConfigExternal.renderingType);
6339 addFunctionCaseWithPrograms<TestConfig>(group, "stencil", "Single stencil attachment case.", createTestShaders, renderPassTest, testConfig);
6344 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_D24_UNORM_S8_UINT,
6345 VK_SAMPLE_COUNT_1_BIT,
6346 VK_ATTACHMENT_LOAD_OP_CLEAR,
6347 VK_ATTACHMENT_STORE_OP_STORE,
6348 VK_ATTACHMENT_LOAD_OP_CLEAR,
6349 VK_ATTACHMENT_STORE_OP_STORE,
6350 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6351 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6352 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6354 vector<AttachmentReference>(),
6355 vector<AttachmentReference>(),
6356 vector<AttachmentReference>(),
6357 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6358 vector<deUint32>())),
6359 vector<SubpassDependency>());
6360 const TestConfig testConfig (renderPass,
6361 TestConfig::RENDERTYPES_DRAW,
6362 TestConfig::COMMANDBUFFERTYPES_INLINE,
6363 TestConfig::IMAGEMEMORY_STRICT,
6370 testConfigExternal.allocationKind,
6371 testConfigExternal.renderingType);
6373 addFunctionCaseWithPrograms<TestConfig>(group, "depth_stencil", "Single depth stencil attachment case.", createTestShaders, renderPassTest, testConfig);
6378 const Attachment attachments[] =
6380 Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6381 VK_SAMPLE_COUNT_1_BIT,
6382 VK_ATTACHMENT_LOAD_OP_CLEAR,
6383 VK_ATTACHMENT_STORE_OP_STORE,
6384 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6385 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6386 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6387 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL),
6388 Attachment(VK_FORMAT_X8_D24_UNORM_PACK32,
6389 VK_SAMPLE_COUNT_1_BIT,
6390 VK_ATTACHMENT_LOAD_OP_CLEAR,
6391 VK_ATTACHMENT_STORE_OP_STORE,
6392 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6393 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6394 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6395 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6398 const RenderPass renderPass (vector<Attachment>(DE_ARRAY_BEGIN(attachments), DE_ARRAY_END(attachments)),
6399 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6401 vector<AttachmentReference>(),
6402 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6403 vector<AttachmentReference>(),
6404 AttachmentReference(1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6405 vector<deUint32>())),
6406 vector<SubpassDependency>());
6407 const TestConfig testConfig (renderPass,
6408 TestConfig::RENDERTYPES_DRAW,
6409 TestConfig::COMMANDBUFFERTYPES_INLINE,
6410 TestConfig::IMAGEMEMORY_STRICT,
6417 testConfigExternal.allocationKind,
6418 testConfigExternal.renderingType);
6420 addFunctionCaseWithPrograms<TestConfig>(group, "color_depth", "Color and depth attachment case.", createTestShaders, renderPassTest, testConfig);
6425 const Attachment attachments[] =
6427 Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6428 VK_SAMPLE_COUNT_1_BIT,
6429 VK_ATTACHMENT_LOAD_OP_CLEAR,
6430 VK_ATTACHMENT_STORE_OP_STORE,
6431 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6432 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6433 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6434 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL),
6435 Attachment(VK_FORMAT_S8_UINT,
6436 VK_SAMPLE_COUNT_1_BIT,
6437 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6438 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6439 VK_ATTACHMENT_LOAD_OP_CLEAR,
6440 VK_ATTACHMENT_STORE_OP_STORE,
6441 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6442 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6445 const RenderPass renderPass (vector<Attachment>(DE_ARRAY_BEGIN(attachments), DE_ARRAY_END(attachments)),
6446 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6448 vector<AttachmentReference>(),
6449 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6450 vector<AttachmentReference>(),
6451 AttachmentReference(1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6452 vector<deUint32>())),
6453 vector<SubpassDependency>());
6454 const TestConfig testConfig (renderPass,
6455 TestConfig::RENDERTYPES_DRAW,
6456 TestConfig::COMMANDBUFFERTYPES_INLINE,
6457 TestConfig::IMAGEMEMORY_STRICT,
6464 testConfigExternal.allocationKind,
6465 testConfigExternal.renderingType);
6467 addFunctionCaseWithPrograms<TestConfig>(group, "color_stencil", "Color and stencil attachment case.", createTestShaders, renderPassTest, testConfig);
6470 // color_depth_stencil
6472 const Attachment attachments[] =
6474 Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6475 VK_SAMPLE_COUNT_1_BIT,
6476 VK_ATTACHMENT_LOAD_OP_CLEAR,
6477 VK_ATTACHMENT_STORE_OP_STORE,
6478 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6479 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6480 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6481 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL),
6482 Attachment(VK_FORMAT_D24_UNORM_S8_UINT,
6483 VK_SAMPLE_COUNT_1_BIT,
6484 VK_ATTACHMENT_LOAD_OP_CLEAR,
6485 VK_ATTACHMENT_STORE_OP_STORE,
6486 VK_ATTACHMENT_LOAD_OP_CLEAR,
6487 VK_ATTACHMENT_STORE_OP_STORE,
6488 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6489 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6492 const RenderPass renderPass (vector<Attachment>(DE_ARRAY_BEGIN(attachments), DE_ARRAY_END(attachments)),
6493 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6495 vector<AttachmentReference>(),
6496 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6497 vector<AttachmentReference>(),
6498 AttachmentReference(1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6499 vector<deUint32>())),
6500 vector<SubpassDependency>());
6501 const TestConfig testConfig (renderPass,
6502 TestConfig::RENDERTYPES_DRAW,
6503 TestConfig::COMMANDBUFFERTYPES_INLINE,
6504 TestConfig::IMAGEMEMORY_STRICT,
6511 testConfigExternal.allocationKind,
6512 testConfigExternal.renderingType);
6514 addFunctionCaseWithPrograms<TestConfig>(group, "color_depth_stencil", "Color, depth and stencil attachment case.", createTestShaders, renderPassTest, testConfig);
6519 const RenderPass renderPass (vector<Attachment>(),
6520 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6522 vector<AttachmentReference>(),
6523 vector<AttachmentReference>(),
6524 vector<AttachmentReference>(),
6525 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6526 vector<deUint32>())),
6527 vector<SubpassDependency>());
6528 const TestConfig testConfig (renderPass,
6529 TestConfig::RENDERTYPES_DRAW,
6530 TestConfig::COMMANDBUFFERTYPES_INLINE,
6531 TestConfig::IMAGEMEMORY_STRICT,
6538 testConfigExternal.allocationKind,
6539 testConfigExternal.renderingType);
6541 addFunctionCaseWithPrograms<TestConfig>(group, "no_attachments", "No attachments case.", createTestShaders, renderPassTest, testConfig);
6544 // color_unused_omit_blend_state
6545 if (testConfigExternal.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
6547 vector<Subpass> subpasses;
6549 // First subpass: use color attachment, create pipeline with color blend state
6550 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6552 vector<AttachmentReference>(),
6553 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6554 vector<AttachmentReference>(),
6555 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6559 // Second subpass: don't use color attachment, create pipeline without color blend state
6560 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6562 vector<AttachmentReference>(),
6563 vector<AttachmentReference>(1, AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6564 vector<AttachmentReference>(),
6565 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6569 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6570 VK_SAMPLE_COUNT_1_BIT,
6571 VK_ATTACHMENT_LOAD_OP_CLEAR,
6572 VK_ATTACHMENT_STORE_OP_STORE,
6573 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6574 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6575 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6576 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6578 vector<SubpassDependency>());
6580 const TestConfig testConfig (renderPass,
6581 TestConfig::RENDERTYPES_DRAW,
6582 TestConfig::COMMANDBUFFERTYPES_INLINE,
6583 TestConfig::IMAGEMEMORY_STRICT,
6590 testConfigExternal.allocationKind,
6591 testConfigExternal.renderingType);
6592 addFunctionCaseWithPrograms<TestConfig>(group, "color_unused_omit_blend_state", "Two unused color attachment case without blend state", createTestShaders, renderPassTest, testConfig);
6596 std::string formatToName (VkFormat format)
6598 const std::string formatStr = de::toString(format);
6599 const std::string prefix = "VK_FORMAT_";
6601 DE_ASSERT(formatStr.substr(0, prefix.length()) == prefix);
6603 return de::toLower(formatStr.substr(prefix.length()));
6606 void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
6608 tcu::TestContext& testCtx = group->getTestContext();
6610 const UVec2 targetSize (64, 64);
6611 const UVec2 renderPos (0, 0);
6612 const UVec2 renderSize (64, 64);
6616 const char* const str;
6617 const VkAttachmentStoreOp op;
6620 { "store", VK_ATTACHMENT_STORE_OP_STORE },
6621 { "dont_care", VK_ATTACHMENT_STORE_OP_DONT_CARE }
6626 const char* const str;
6627 const VkAttachmentLoadOp op;
6630 { "clear", VK_ATTACHMENT_LOAD_OP_CLEAR },
6631 { "load", VK_ATTACHMENT_LOAD_OP_LOAD },
6632 { "dont_care", VK_ATTACHMENT_LOAD_OP_DONT_CARE }
6637 const char* const str;
6638 const TestConfig::RenderTypes types;
6641 { "clear", TestConfig::RENDERTYPES_CLEAR },
6642 { "draw", TestConfig::RENDERTYPES_DRAW },
6643 { "clear_draw", TestConfig::RENDERTYPES_CLEAR|TestConfig::RENDERTYPES_DRAW }
6647 for (size_t formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_coreColorFormats); formatNdx++)
6649 const VkFormat format = s_coreColorFormats[formatNdx];
6650 de::MovePtr<tcu::TestCaseGroup> formatGroup (new tcu::TestCaseGroup(testCtx, formatToName(format).c_str(), de::toString(format).c_str()));
6652 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
6654 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
6655 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
6657 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
6659 const RenderPass renderPass (vector<Attachment>(1, Attachment(format,
6660 VK_SAMPLE_COUNT_1_BIT,
6662 VK_ATTACHMENT_STORE_OP_STORE,
6663 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6664 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6665 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6666 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6667 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6669 vector<AttachmentReference>(),
6670 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6671 vector<AttachmentReference>(),
6672 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6673 vector<deUint32>())),
6674 vector<SubpassDependency>());
6675 const TestConfig testConfig (renderPass,
6676 renderTypes[renderTypeNdx].types,
6677 TestConfig::COMMANDBUFFERTYPES_INLINE,
6678 TestConfig::IMAGEMEMORY_STRICT,
6685 testConfigExternal.allocationKind,
6686 testConfigExternal.renderingType);
6688 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), renderTypes[renderTypeNdx].str, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
6691 formatGroup->addChild(loadOpGroup.release());
6694 if (testConfigExternal.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
6696 de::MovePtr<tcu::TestCaseGroup> inputGroup (new tcu::TestCaseGroup(testCtx, "input", "Test attachment format as input"));
6698 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
6700 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
6701 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
6703 for (size_t storeOpNdx = 0; storeOpNdx < DE_LENGTH_OF_ARRAY(storeOps); storeOpNdx++)
6705 const VkImageAspectFlags inputAttachmentAspectMask = (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2)
6706 ? static_cast<VkImageAspectFlags>(VK_IMAGE_ASPECT_COLOR_BIT)
6707 : static_cast<VkImageAspectFlags>(0);
6708 const VkAttachmentStoreOp storeOp = storeOps[storeOpNdx].op;
6709 de::MovePtr<tcu::TestCaseGroup> storeOpGroup (new tcu::TestCaseGroup(testCtx, storeOps[storeOpNdx].str, storeOps[storeOpNdx].str));
6711 for (size_t useInputAspectNdx = 0; useInputAspectNdx < 2; useInputAspectNdx++)
6713 const bool useInputAspect = useInputAspectNdx != 0;
6715 if (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2 && useInputAspect)
6718 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
6721 vector<Attachment> attachments;
6722 vector<Subpass> subpasses;
6723 vector<SubpassDependency> deps;
6724 vector<VkInputAttachmentAspectReference> inputAspects;
6726 attachments.push_back(Attachment(format,
6727 VK_SAMPLE_COUNT_1_BIT,
6730 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6731 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6732 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6733 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
6735 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
6736 VK_SAMPLE_COUNT_1_BIT,
6737 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6738 VK_ATTACHMENT_STORE_OP_STORE,
6739 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6740 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6741 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6742 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
6744 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6746 vector<AttachmentReference>(),
6747 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6748 vector<AttachmentReference>(),
6749 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6750 vector<deUint32>()));
6751 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6753 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
6754 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6755 vector<AttachmentReference>(),
6756 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6757 vector<deUint32>()));
6759 deps.push_back(SubpassDependency(0, 1,
6761 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
6762 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6764 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6765 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6766 vk::VK_DEPENDENCY_BY_REGION_BIT));
6770 const VkInputAttachmentAspectReference inputAspect =
6774 VK_IMAGE_ASPECT_COLOR_BIT
6777 inputAspects.push_back(inputAspect);
6781 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
6782 const TestConfig testConfig (renderPass,
6783 renderTypes[renderTypeNdx].types,
6784 TestConfig::COMMANDBUFFERTYPES_INLINE,
6785 TestConfig::IMAGEMEMORY_STRICT,
6792 testConfigExternal.allocationKind,
6793 testConfigExternal.renderingType);
6794 const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : ""));
6796 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
6800 vector<Attachment> attachments;
6801 vector<Subpass> subpasses;
6802 vector<SubpassDependency> deps;
6803 vector<VkInputAttachmentAspectReference> inputAspects;
6805 attachments.push_back(Attachment(format,
6806 VK_SAMPLE_COUNT_1_BIT,
6809 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6810 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6811 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6812 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
6814 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6816 vector<AttachmentReference>(),
6817 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6818 vector<AttachmentReference>(),
6819 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6820 vector<deUint32>()));
6821 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6823 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL, inputAttachmentAspectMask)),
6824 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL)),
6825 vector<AttachmentReference>(),
6826 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6827 vector<deUint32>()));
6829 deps.push_back(SubpassDependency(0, 1,
6830 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
6831 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6833 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6834 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6835 vk::VK_DEPENDENCY_BY_REGION_BIT));
6837 deps.push_back(SubpassDependency(1, 1,
6838 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
6839 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6841 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6842 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6843 vk::VK_DEPENDENCY_BY_REGION_BIT));
6847 const VkInputAttachmentAspectReference inputAspect =
6851 VK_IMAGE_ASPECT_COLOR_BIT
6854 inputAspects.push_back(inputAspect);
6858 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
6859 const TestConfig testConfig (renderPass,
6860 renderTypes[renderTypeNdx].types,
6861 TestConfig::COMMANDBUFFERTYPES_INLINE,
6862 TestConfig::IMAGEMEMORY_STRICT,
6869 testConfigExternal.allocationKind,
6870 testConfigExternal.renderingType);
6871 const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : ""));
6873 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
6879 loadOpGroup->addChild(storeOpGroup.release());
6882 inputGroup->addChild(loadOpGroup.release());
6885 formatGroup->addChild(inputGroup.release());
6888 group->addChild(formatGroup.release());
6891 // Depth stencil formats
6892 for (size_t formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_coreDepthStencilFormats); formatNdx++)
6894 const VkFormat vkFormat = s_coreDepthStencilFormats[formatNdx];
6895 const tcu::TextureFormat format = mapVkFormat(vkFormat);
6896 const bool isStencilAttachment = hasStencilComponent(format.order);
6897 const bool isDepthAttachment = hasDepthComponent(format.order);
6898 const VkImageAspectFlags formatAspectFlags = (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
6899 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u);
6900 de::MovePtr<tcu::TestCaseGroup> formatGroup (new tcu::TestCaseGroup(testCtx, formatToName(vkFormat).c_str(), de::toString(vkFormat).c_str()));
6902 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
6904 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
6905 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
6907 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
6910 const RenderPass renderPass (vector<Attachment>(1, Attachment(vkFormat,
6911 VK_SAMPLE_COUNT_1_BIT,
6912 isDepthAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6913 isDepthAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6914 isStencilAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6915 isStencilAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6916 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6917 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6918 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6920 vector<AttachmentReference>(),
6921 vector<AttachmentReference>(),
6922 vector<AttachmentReference>(),
6923 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6924 vector<deUint32>())),
6925 vector<SubpassDependency>());
6926 const TestConfig testConfig (renderPass,
6927 renderTypes[renderTypeNdx].types,
6928 TestConfig::COMMANDBUFFERTYPES_INLINE,
6929 TestConfig::IMAGEMEMORY_STRICT,
6936 testConfigExternal.allocationKind,
6937 testConfigExternal.renderingType);
6939 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), renderTypes[renderTypeNdx].str, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
6942 if (isStencilAttachment && isDepthAttachment && loadOp != VK_ATTACHMENT_LOAD_OP_CLEAR)
6945 const RenderPass renderPass (vector<Attachment>(1, Attachment(vkFormat,
6946 VK_SAMPLE_COUNT_1_BIT,
6947 isDepthAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6948 isDepthAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6949 isStencilAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6950 isStencilAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6951 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6952 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6953 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6955 vector<AttachmentReference>(),
6956 vector<AttachmentReference>(),
6957 vector<AttachmentReference>(),
6958 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL),
6959 vector<deUint32>())),
6960 vector<SubpassDependency>());
6961 const TestConfig testConfig (renderPass,
6962 renderTypes[renderTypeNdx].types,
6963 TestConfig::COMMANDBUFFERTYPES_INLINE,
6964 TestConfig::IMAGEMEMORY_STRICT,
6971 testConfigExternal.allocationKind,
6972 testConfigExternal.renderingType);
6973 const string testName (string(renderTypes[renderTypeNdx].str) + "_depth_read_only");
6975 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
6979 const RenderPass renderPass (vector<Attachment>(1, Attachment(vkFormat,
6980 VK_SAMPLE_COUNT_1_BIT,
6981 isDepthAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6982 isDepthAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6983 isStencilAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6984 isStencilAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6985 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6986 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6987 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6989 vector<AttachmentReference>(),
6990 vector<AttachmentReference>(),
6991 vector<AttachmentReference>(),
6992 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL),
6993 vector<deUint32>())),
6994 vector<SubpassDependency>());
6995 const TestConfig testConfig (renderPass,
6996 renderTypes[renderTypeNdx].types,
6997 TestConfig::COMMANDBUFFERTYPES_INLINE,
6998 TestConfig::IMAGEMEMORY_STRICT,
7005 testConfigExternal.allocationKind,
7006 testConfigExternal.renderingType);
7007 const string testName (string(renderTypes[renderTypeNdx].str) + "_stencil_read_only");
7009 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7014 formatGroup->addChild(loadOpGroup.release());
7017 if (testConfigExternal.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
7019 de::MovePtr<tcu::TestCaseGroup> inputGroup (new tcu::TestCaseGroup(testCtx, "input", "Test attachment format as input"));
7021 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
7023 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
7024 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
7026 for (size_t storeOpNdx = 0; storeOpNdx < DE_LENGTH_OF_ARRAY(storeOps); storeOpNdx++)
7028 const VkImageAspectFlags inputAttachmentAspectMask = (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2)
7030 : static_cast<VkImageAspectFlags>(0);
7031 const VkAttachmentStoreOp storeOp = storeOps[storeOpNdx].op;
7032 de::MovePtr<tcu::TestCaseGroup> storeOpGroup (new tcu::TestCaseGroup(testCtx, storeOps[storeOpNdx].str, storeOps[storeOpNdx].str));
7034 for (size_t useInputAspectNdx = 0; useInputAspectNdx < 2; useInputAspectNdx++)
7036 const bool useInputAspect = useInputAspectNdx != 0;
7038 if (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2 && useInputAspect)
7041 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
7044 vector<Attachment> attachments;
7045 vector<Subpass> subpasses;
7046 vector<SubpassDependency> deps;
7047 vector<VkInputAttachmentAspectReference> inputAspects;
7049 attachments.push_back(Attachment(vkFormat,
7050 VK_SAMPLE_COUNT_1_BIT,
7055 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7056 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7058 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
7059 VK_SAMPLE_COUNT_1_BIT,
7060 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7061 VK_ATTACHMENT_STORE_OP_STORE,
7062 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7063 VK_ATTACHMENT_STORE_OP_DONT_CARE,
7064 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
7065 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
7067 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7069 vector<AttachmentReference>(),
7070 vector<AttachmentReference>(),
7071 vector<AttachmentReference>(),
7072 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7073 vector<deUint32>()));
7074 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7076 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
7077 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
7078 vector<AttachmentReference>(),
7079 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
7080 vector<deUint32>()));
7082 deps.push_back(SubpassDependency(0, 1,
7083 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7084 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7086 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7087 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7092 const VkInputAttachmentAspectReference inputAspect =
7096 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7097 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7100 inputAspects.push_back(inputAspect);
7104 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7105 const TestConfig testConfig (renderPass,
7106 renderTypes[renderTypeNdx].types,
7107 TestConfig::COMMANDBUFFERTYPES_INLINE,
7108 TestConfig::IMAGEMEMORY_STRICT,
7115 testConfigExternal.allocationKind,
7116 testConfigExternal.renderingType);
7117 const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : ""));
7119 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7123 vector<Attachment> attachments;
7124 vector<Subpass> subpasses;
7125 vector<SubpassDependency> deps;
7126 vector<VkInputAttachmentAspectReference> inputAspects;
7128 attachments.push_back(Attachment(vkFormat,
7129 VK_SAMPLE_COUNT_1_BIT,
7132 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7133 VK_ATTACHMENT_STORE_OP_DONT_CARE,
7134 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7135 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7137 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7139 vector<AttachmentReference>(),
7140 vector<AttachmentReference>(),
7141 vector<AttachmentReference>(),
7142 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7143 vector<deUint32>()));
7144 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7146 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL, inputAttachmentAspectMask)),
7147 vector<AttachmentReference>(),
7148 vector<AttachmentReference>(),
7149 AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL),
7150 vector<deUint32>()));
7152 deps.push_back(SubpassDependency(0, 1,
7153 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7154 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7156 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7157 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7158 vk::VK_DEPENDENCY_BY_REGION_BIT));
7160 deps.push_back(SubpassDependency(1, 1,
7161 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7162 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7163 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7164 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7165 vk::VK_DEPENDENCY_BY_REGION_BIT));
7170 const VkInputAttachmentAspectReference inputAspect =
7175 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7176 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7179 inputAspects.push_back(inputAspect);
7183 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7184 const TestConfig testConfig (renderPass,
7185 renderTypes[renderTypeNdx].types,
7186 TestConfig::COMMANDBUFFERTYPES_INLINE,
7187 TestConfig::IMAGEMEMORY_STRICT,
7194 testConfigExternal.allocationKind,
7195 testConfigExternal.renderingType);
7196 const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : ""));
7198 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7202 if (isStencilAttachment && isDepthAttachment)
7206 vector<Attachment> attachments;
7207 vector<Subpass> subpasses;
7208 vector<SubpassDependency> deps;
7209 vector<VkInputAttachmentAspectReference> inputAspects;
7211 attachments.push_back(Attachment(vkFormat,
7212 VK_SAMPLE_COUNT_1_BIT,
7217 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7218 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7220 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
7221 VK_SAMPLE_COUNT_1_BIT,
7222 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7223 VK_ATTACHMENT_STORE_OP_STORE,
7224 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7225 VK_ATTACHMENT_STORE_OP_DONT_CARE,
7226 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
7227 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
7229 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7231 vector<AttachmentReference>(),
7232 vector<AttachmentReference>(),
7233 vector<AttachmentReference>(),
7234 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7235 vector<deUint32>()));
7236 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7238 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL, inputAttachmentAspectMask)),
7239 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
7240 vector<AttachmentReference>(),
7241 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
7242 vector<deUint32>()));
7244 deps.push_back(SubpassDependency(0, 1,
7245 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7246 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7248 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7249 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7254 const VkInputAttachmentAspectReference inputAspect =
7259 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7260 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7263 inputAspects.push_back(inputAspect);
7267 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7268 const TestConfig testConfig (renderPass,
7269 renderTypes[renderTypeNdx].types,
7270 TestConfig::COMMANDBUFFERTYPES_INLINE,
7271 TestConfig::IMAGEMEMORY_STRICT,
7278 testConfigExternal.allocationKind,
7279 testConfigExternal.renderingType);
7280 const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : "") + "_depth_read_only");
7282 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7286 vector<Attachment> attachments;
7287 vector<Subpass> subpasses;
7288 vector<SubpassDependency> deps;
7289 vector<VkInputAttachmentAspectReference> inputAspects;
7291 attachments.push_back(Attachment(vkFormat,
7292 VK_SAMPLE_COUNT_1_BIT,
7297 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7298 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7300 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7302 vector<AttachmentReference>(),
7303 vector<AttachmentReference>(),
7304 vector<AttachmentReference>(),
7305 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7306 vector<deUint32>()));
7307 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7309 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL, inputAttachmentAspectMask)),
7310 vector<AttachmentReference>(),
7311 vector<AttachmentReference>(),
7312 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL),
7313 vector<deUint32>()));
7315 deps.push_back(SubpassDependency(0, 1,
7316 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7317 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7319 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7320 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7321 vk::VK_DEPENDENCY_BY_REGION_BIT));
7323 deps.push_back(SubpassDependency(1, 1,
7324 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7325 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7327 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7328 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7329 vk::VK_DEPENDENCY_BY_REGION_BIT));
7333 const VkInputAttachmentAspectReference inputAspect =
7338 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7339 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7342 inputAspects.push_back(inputAspect);
7346 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7347 const TestConfig testConfig (renderPass,
7348 renderTypes[renderTypeNdx].types,
7349 TestConfig::COMMANDBUFFERTYPES_INLINE,
7350 TestConfig::IMAGEMEMORY_STRICT,
7357 testConfigExternal.allocationKind,
7358 testConfigExternal.renderingType);
7359 const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : "") + "_depth_read_only");
7361 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7364 // Stencil read only
7366 vector<Attachment> attachments;
7367 vector<Subpass> subpasses;
7368 vector<SubpassDependency> deps;
7369 vector<VkInputAttachmentAspectReference> inputAspects;
7371 attachments.push_back(Attachment(vkFormat,
7372 VK_SAMPLE_COUNT_1_BIT,
7377 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7378 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7380 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
7381 VK_SAMPLE_COUNT_1_BIT,
7382 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7383 VK_ATTACHMENT_STORE_OP_STORE,
7384 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7385 VK_ATTACHMENT_STORE_OP_DONT_CARE,
7386 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
7387 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
7389 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7391 vector<AttachmentReference>(),
7392 vector<AttachmentReference>(),
7393 vector<AttachmentReference>(),
7394 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7395 vector<deUint32>()));
7396 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7398 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
7399 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
7400 vector<AttachmentReference>(),
7401 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
7402 vector<deUint32>()));
7404 deps.push_back(SubpassDependency(0, 1,
7405 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
7406 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7408 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7409 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7414 const VkInputAttachmentAspectReference inputAspect =
7419 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7420 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7423 inputAspects.push_back(inputAspect);
7427 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7428 const TestConfig testConfig (renderPass,
7429 renderTypes[renderTypeNdx].types,
7430 TestConfig::COMMANDBUFFERTYPES_INLINE,
7431 TestConfig::IMAGEMEMORY_STRICT,
7438 testConfigExternal.allocationKind,
7439 testConfigExternal.renderingType);
7440 const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : "") + "_stencil_read_only");
7442 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7446 vector<Attachment> attachments;
7447 vector<Subpass> subpasses;
7448 vector<SubpassDependency> deps;
7449 vector<VkInputAttachmentAspectReference> inputAspects;
7451 attachments.push_back(Attachment(vkFormat,
7452 VK_SAMPLE_COUNT_1_BIT,
7457 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7458 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7460 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7462 vector<AttachmentReference>(),
7463 vector<AttachmentReference>(),
7464 vector<AttachmentReference>(),
7465 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7466 vector<deUint32>()));
7467 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7469 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
7470 vector<AttachmentReference>(),
7471 vector<AttachmentReference>(),
7472 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL),
7473 vector<deUint32>()));
7475 deps.push_back(SubpassDependency(0, 1,
7476 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7477 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7479 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7480 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7481 vk::VK_DEPENDENCY_BY_REGION_BIT));
7483 deps.push_back(SubpassDependency(1, 1,
7484 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7485 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7487 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7488 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7489 vk::VK_DEPENDENCY_BY_REGION_BIT));
7494 const VkInputAttachmentAspectReference inputAspect =
7499 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7500 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7503 inputAspects.push_back(inputAspect);
7507 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7508 const TestConfig testConfig (renderPass,
7509 renderTypes[renderTypeNdx].types,
7510 TestConfig::COMMANDBUFFERTYPES_INLINE,
7511 TestConfig::IMAGEMEMORY_STRICT,
7518 testConfigExternal.allocationKind,
7519 testConfigExternal.renderingType);
7520 const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : "") + "_stencil_read_only");
7522 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7529 loadOpGroup->addChild(storeOpGroup.release());
7532 inputGroup->addChild(loadOpGroup.release());
7535 formatGroup->addChild(inputGroup.release());
7538 group->addChild(formatGroup.release());
7542 void addRenderPassTests (tcu::TestCaseGroup* group, const AllocationKind allocationKind, const RenderingType renderingType)
7544 const TestConfigExternal testConfigExternal (allocationKind, renderingType);
7546 addTestGroup(group, "simple", "Simple basic render pass tests", addSimpleTests, testConfigExternal);
7547 addTestGroup(group, "formats", "Tests for different image formats.", addFormatTests, testConfigExternal);
7548 addTestGroup(group, "attachment", "Attachment format and count tests with load and store ops and image layouts", addAttachmentTests, testConfigExternal);
7549 addTestGroup(group, "attachment_write_mask", "Attachment write mask tests", addAttachmentWriteMaskTests, testConfigExternal);
7551 if (renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
7552 addTestGroup(group, "attachment_allocation", "Attachment allocation tests", addAttachmentAllocationTests, testConfigExternal);
7555 de::MovePtr<tcu::TestCaseGroup> createSuballocationTests(tcu::TestContext& testCtx, RenderingType renderingType)
7557 de::MovePtr<tcu::TestCaseGroup> suballocationTestsGroup(new tcu::TestCaseGroup(testCtx, "suballocation", "Suballocation RenderPass Tests"));
7559 addRenderPassTests(suballocationTestsGroup.get(), ALLOCATION_KIND_SUBALLOCATED, renderingType);
7561 return suballocationTestsGroup;
7564 de::MovePtr<tcu::TestCaseGroup> createDedicatedAllocationTests(tcu::TestContext& testCtx, RenderingType renderingType)
7566 de::MovePtr<tcu::TestCaseGroup> dedicatedAllocationTestsGroup(new tcu::TestCaseGroup(testCtx, "dedicated_allocation", "RenderPass Tests For Dedicated Allocation"));
7568 addRenderPassTests(dedicatedAllocationTestsGroup.get(), ALLOCATION_KIND_DEDICATED, renderingType);
7570 return dedicatedAllocationTestsGroup;
7573 tcu::TestCaseGroup* createRenderPassTestsInternal (tcu::TestContext& testCtx, RenderingType renderingType)
7575 const char* renderingTestsGroupName = (renderingType == RENDERING_TYPE_RENDERPASS_LEGACY) ? "renderpass" :
7576 (renderingType == RENDERING_TYPE_RENDERPASS2) ? "renderpass2" :
7577 (renderingType == RENDERING_TYPE_DYNAMIC_RENDERING) ? "dynamic_rendering" :
7579 const char* renderingTestsGroupDescription = (renderingType == RENDERING_TYPE_RENDERPASS_LEGACY) ? "RenderPass Tests" :
7580 (renderingType == RENDERING_TYPE_RENDERPASS2) ? "RenderPass2 Tests" :
7581 (renderingType == RENDERING_TYPE_DYNAMIC_RENDERING) ? "Dynamic Rendering Tests" :
7584 de::MovePtr<tcu::TestCaseGroup> renderingTests (new tcu::TestCaseGroup(testCtx, renderingTestsGroupName, renderingTestsGroupDescription));
7585 de::MovePtr<tcu::TestCaseGroup> suballocationTestGroup = createSuballocationTests(testCtx, renderingType);
7586 de::MovePtr<tcu::TestCaseGroup> dedicatedAllocationTestGroup = createDedicatedAllocationTests(testCtx, renderingType);
7588 switch (renderingType)
7590 case RENDERING_TYPE_RENDERPASS_LEGACY:
7591 suballocationTestGroup->addChild(createRenderPassMultisampleTests(testCtx));
7592 suballocationTestGroup->addChild(createRenderPassMultisampleResolveTests(testCtx));
7593 suballocationTestGroup->addChild(createRenderPassSubpassDependencyTests(testCtx));
7594 suballocationTestGroup->addChild(createRenderPassSampleReadTests(testCtx));
7595 suballocationTestGroup->addChild(createRenderPassSparseRenderTargetTests(testCtx));
7597 renderingTests->addChild(createRenderPassMultipleSubpassesMultipleCommandBuffersTests(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);