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 const VkPipelineDepthStencilStateCreateInfo depthStencilState =
1991 VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, // sType
1993 (VkPipelineDepthStencilStateCreateFlags)0u,
1994 writeDepth, // depthTestEnable
1995 writeDepth, // depthWriteEnable
1996 VK_COMPARE_OP_ALWAYS, // depthCompareOp
1997 VK_FALSE, // depthBoundsEnable
1998 writeStencil, // stencilTestEnable
2000 VK_STENCIL_OP_REPLACE, // stencilFailOp
2001 VK_STENCIL_OP_REPLACE, // stencilPassOp
2002 VK_STENCIL_OP_REPLACE, // stencilDepthFailOp
2003 VK_COMPARE_OP_ALWAYS, // stencilCompareOp
2004 ~0u, // stencilCompareMask
2005 ~0u, // stencilWriteMask
2006 ((stencilIndex % 2) == 0) ? ~0x0u : 0x0u // stencilReference
2009 VK_STENCIL_OP_REPLACE, // stencilFailOp
2010 VK_STENCIL_OP_REPLACE, // stencilPassOp
2011 VK_STENCIL_OP_REPLACE, // stencilDepthFailOp
2012 VK_COMPARE_OP_ALWAYS, // stencilCompareOp
2013 ~0u, // stencilCompareMask
2014 ~0u, // stencilWriteMask
2015 ((stencilIndex % 2) == 0) ? ~0x0u : 0x0u // stencilReference
2018 0.0f, // minDepthBounds;
2019 1.0f // maxDepthBounds;
2022 const VkPipelineColorBlendStateCreateInfo blendState =
2024 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // sType
2026 (VkPipelineColorBlendStateCreateFlags)0u,
2027 VK_FALSE, // logicOpEnable
2028 VK_LOGIC_OP_COPY, // logicOp
2029 (deUint32)attachmentBlendStates.size(), // attachmentCount
2030 attachmentBlendStates.empty() ? DE_NULL : &attachmentBlendStates[0],// pAttachments
2031 { 0.0f, 0.0f, 0.0f, 0.0f } // blendConst
2034 std::vector<vk::VkFormat> colorAttachmentFormats;
2035 for (deUint32 i = 0; i < renderInfo.getColorAttachmentCount(); ++i)
2036 colorAttachmentFormats.push_back(renderInfo.getColorAttachment(i).getFormat());
2038 vk::VkFormat depthFormat = VK_FORMAT_UNDEFINED;
2039 vk::VkFormat stencilFormat = VK_FORMAT_UNDEFINED;
2040 if (renderInfo.getDepthStencilAttachment())
2042 const Attachment& attachment = *renderInfo.getDepthStencilAttachment();
2043 vk::VkFormat depthStencilFormat = attachment.getFormat();
2044 if (depthStencilFormat != VK_FORMAT_UNDEFINED)
2046 if (tcu::hasDepthComponent(mapVkFormat(depthStencilFormat).order))
2048 depthFormat = depthStencilFormat;
2050 if (tcu::hasStencilComponent(mapVkFormat(depthStencilFormat).order))
2052 stencilFormat = depthStencilFormat;
2058 VkPipelineRenderingCreateInfoKHR renderingCreateInfo
2060 VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR,
2063 static_cast<deUint32>(colorAttachmentFormats.size()),
2064 colorAttachmentFormats.data(),
2069 return makeGraphicsPipeline(vk, // const DeviceInterface& vk
2070 device, // const VkDevice device
2071 pipelineLayout, // const VkPipelineLayout pipelineLayout
2072 vertexShaderModule, // const VkShaderModule vertexShaderModule
2073 DE_NULL, // const VkShaderModule tessellationControlShaderModule
2074 DE_NULL, // const VkShaderModule tessellationEvalShaderModule
2075 DE_NULL, // const VkShaderModule geometryShaderModule
2076 fragmentShaderModule, // const VkShaderModule fragmentShaderModule
2077 renderPass, // const VkRenderPass renderPass
2078 renderInfo.getSubpassIndex(), // const deUint32 subpass
2079 &vertexInputState, // const VkPipelineVertexInputStateCreateInfo* vertexInputStateCreateInfo
2080 &inputAssemblyState, // const VkPipelineInputAssemblyStateCreateInfo* pInputAssemblyState;
2081 DE_NULL, // const VkPipelineRasterizationStateCreateInfo* rasterizationStateCreateInfo
2082 &viewportState, // const VkPipelineViewportStateCreateInfo* pViewportStat;
2083 &rasterizationState, // const VkPipelineRasterizationStateCreateInfo* pRasterizationState
2084 &multisampleState, // const VkPipelineMultisampleStateCreateInfo* multisampleStateCreateInfo
2085 &depthStencilState, // const VkPipelineDepthStencilStateCreateInfo* depthStencilStateCreateInfo
2086 renderInfo.getOmitBlendState()
2087 ? DE_NULL : &blendState, // const VkPipelineColorBlendStateCreateInfo* colorBlendStateCreateInfo
2088 DE_NULL, // const VkPipelineDynamicStateCreateInfo* dynamicStateCreateInfo
2089 (renderPass == DE_NULL)
2090 ? &renderingCreateInfo : DE_NULL); // const void* pNext)
2093 class SubpassRenderer
2096 SubpassRenderer (Context& context,
2097 const DeviceInterface& vk,
2099 Allocator& allocator,
2100 VkRenderPass renderPass,
2101 VkFramebuffer framebuffer,
2102 VkCommandPool commandBufferPool,
2103 deUint32 queueFamilyIndex,
2104 const vector<VkImage>& attachmentImages,
2105 const vector<pair<VkImageView, VkImageView> >& attachmentViews,
2106 const SubpassRenderInfo& renderInfo,
2107 const vector<Attachment>& attachmentInfos,
2108 const AllocationKind allocationKind,
2109 const bool dynamicRendering)
2110 : m_renderInfo (renderInfo)
2112 const InstanceInterface& vki = context.getInstanceInterface();
2113 const VkPhysicalDevice& physDevice = context.getPhysicalDevice();
2114 const deUint32 subpassIndex = renderInfo.getSubpassIndex();
2115 vector<VkDescriptorSetLayoutBinding> bindings;
2117 for (deUint32 colorAttachmentNdx = 0; colorAttachmentNdx < renderInfo.getColorAttachmentCount(); colorAttachmentNdx++)
2119 const deUint32 attachmentNdx = (renderInfo.getColorAttachmentIndex(colorAttachmentNdx) == VK_ATTACHMENT_UNUSED) ? colorAttachmentNdx
2120 : renderInfo.getColorAttachmentIndex(colorAttachmentNdx);
2122 m_colorAttachmentImages.push_back(attachmentImages[attachmentNdx]);
2125 if (renderInfo.getDepthStencilAttachmentIndex())
2126 m_depthStencilAttachmentImage = attachmentImages[*renderInfo.getDepthStencilAttachmentIndex()];
2128 if (renderInfo.getRenderQuad())
2130 const RenderQuad& renderQuad = *renderInfo.getRenderQuad();
2132 if (renderInfo.getInputAttachmentCount() > 0)
2134 deUint32 bindingIndex = 0;
2136 for (deUint32 inputAttachmentNdx = 0; inputAttachmentNdx < renderInfo.getInputAttachmentCount(); inputAttachmentNdx++)
2138 const Attachment attachmentInfo = attachmentInfos[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)];
2139 const VkImageLayout layout = renderInfo.getInputAttachmentLayout(inputAttachmentNdx);
2140 const tcu::TextureFormat format = mapVkFormat(attachmentInfo.getFormat());
2141 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
2142 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
2143 const deUint32 bindingCount = (isDepthFormat && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
2144 && (isStencilFormat && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
2148 for (deUint32 bindingNdx = 0; bindingNdx < bindingCount; bindingNdx++)
2150 const VkDescriptorSetLayoutBinding binding =
2153 vk::VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2155 vk::VK_SHADER_STAGE_FRAGMENT_BIT,
2159 bindings.push_back(binding);
2164 const VkDescriptorSetLayoutCreateInfo createInfo =
2166 vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
2170 (deUint32)bindings.size(),
2174 m_descriptorSetLayout = vk::createDescriptorSetLayout(vk, device, &createInfo);
2177 const VkDescriptorSetLayout descriptorSetLayout = *m_descriptorSetLayout;
2178 const VkPipelineLayoutCreateInfo pipelineLayoutParams =
2180 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // sType;
2182 (vk::VkPipelineLayoutCreateFlags)0,
2183 m_descriptorSetLayout ? 1u :0u , // setLayoutCount;
2184 m_descriptorSetLayout ? &descriptorSetLayout : DE_NULL, // pSetLayouts;
2185 0u, // pushConstantRangeCount;
2186 DE_NULL, // pPushConstantRanges;
2189 m_vertexShaderModule = createShaderModule(vk, device, context.getBinaryCollection().get(de::toString(subpassIndex) + "-vert"), 0u);
2190 m_fragmentShaderModule = createShaderModule(vk, device, context.getBinaryCollection().get(de::toString(subpassIndex) + "-frag"), 0u);
2191 m_pipelineLayout = createPipelineLayout(vk, device, &pipelineLayoutParams);
2192 m_pipeline = createSubpassPipeline(vk, device, renderPass, *m_vertexShaderModule, *m_fragmentShaderModule, *m_pipelineLayout, m_renderInfo);
2194 // Round up the vertex buffer size to honor nonCoherentAtomSize.
2195 const auto properties = vk::getPhysicalDeviceProperties(context.getInstanceInterface(), context.getPhysicalDevice());
2196 const auto vertexBufferSize = de::roundUp(static_cast<VkDeviceSize>(renderQuad.getVertexDataSize()), properties.limits.nonCoherentAtomSize);
2198 m_vertexBuffer = createBuffer(vk, device, 0u, vertexBufferSize, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, VK_SHARING_MODE_EXCLUSIVE, 1u, &queueFamilyIndex);
2199 m_vertexBufferMemory = allocateBuffer(vki, vk, physDevice, device, *m_vertexBuffer, MemoryRequirement::HostVisible, allocator, allocationKind);
2201 bindBufferMemory(vk, device, *m_vertexBuffer, m_vertexBufferMemory->getMemory(), m_vertexBufferMemory->getOffset());
2203 uploadBufferData(vk, device, *m_vertexBufferMemory, renderQuad.getVertexDataSize(), renderQuad.getVertexPointer(), properties.limits.nonCoherentAtomSize);
2205 if (renderInfo.getInputAttachmentCount() > 0)
2208 const VkDescriptorPoolSize poolSize =
2210 vk::VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2211 // \note Reserve 2 per input attachment since depthStencil attachments require 2.
2212 renderInfo.getInputAttachmentCount() * 2u
2214 const VkDescriptorPoolCreateInfo createInfo =
2216 vk::VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
2218 VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
2220 // \note Reserve 2 per input attachment since depthStencil attachments require 2.
2221 renderInfo.getInputAttachmentCount() * 2u,
2226 m_descriptorPool = vk::createDescriptorPool(vk, device, &createInfo);
2229 const VkDescriptorSetAllocateInfo allocateInfo =
2231 vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
2236 &descriptorSetLayout
2239 m_descriptorSet = vk::allocateDescriptorSet(vk, device, &allocateInfo);
2242 vector<VkWriteDescriptorSet> writes (bindings.size());
2243 vector<VkDescriptorImageInfo> imageInfos (bindings.size());
2244 deUint32 bindingIndex = 0;
2246 for (deUint32 inputAttachmentNdx = 0; inputAttachmentNdx < renderInfo.getInputAttachmentCount(); inputAttachmentNdx++)
2248 const Attachment attachmentInfo = attachmentInfos[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)];
2249 const tcu::TextureFormat format = mapVkFormat(attachmentInfo.getFormat());
2250 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
2251 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
2252 const VkImageLayout inputAttachmentLayout = renderInfo.getInputAttachmentLayout(inputAttachmentNdx);
2255 if (isDepthFormat && isStencilFormat)
2257 if (inputAttachmentLayout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
2259 const VkDescriptorImageInfo imageInfo =
2262 attachmentViews[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)].first,
2263 inputAttachmentLayout
2265 imageInfos[bindingIndex] = imageInfo;
2268 const VkWriteDescriptorSet write =
2270 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2277 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2278 &imageInfos[bindingIndex],
2282 writes[bindingIndex] = write;
2288 if (inputAttachmentLayout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
2290 const VkDescriptorImageInfo imageInfo =
2293 attachmentViews[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)].second,
2294 inputAttachmentLayout
2296 imageInfos[bindingIndex] = imageInfo;
2299 const VkWriteDescriptorSet write =
2301 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2308 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2309 &imageInfos[bindingIndex],
2313 writes[bindingIndex] = write;
2321 const VkDescriptorImageInfo imageInfo =
2324 attachmentViews[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)].first,
2325 inputAttachmentLayout
2327 imageInfos[bindingIndex] = imageInfo;
2330 const VkWriteDescriptorSet write =
2332 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2339 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2340 &imageInfos[bindingIndex],
2344 writes[bindingIndex] = write;
2351 vk.updateDescriptorSets(device, (deUint32)writes.size(), &writes[0], 0u, DE_NULL);
2356 if (renderInfo.isSecondary())
2358 m_commandBuffer = allocateCommandBuffer(vk, device, commandBufferPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2360 beginCommandBuffer(vk, *m_commandBuffer, vk::VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, renderPass, subpassIndex, framebuffer, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0, &renderInfo, dynamicRendering);
2361 pushRenderCommands(vk, *m_commandBuffer);
2362 endCommandBuffer(vk, *m_commandBuffer);
2366 bool isSecondary (void) const
2368 return m_commandBuffer;
2371 VkCommandBuffer getCommandBuffer (void) const
2373 DE_ASSERT(isSecondary());
2374 return *m_commandBuffer;
2377 void pushRenderCommands (const DeviceInterface& vk,
2378 VkCommandBuffer commandBuffer)
2380 if (!m_renderInfo.getColorClears().empty())
2382 const vector<ColorClear>& colorClears (m_renderInfo.getColorClears());
2384 for (deUint32 attachmentNdx = 0; attachmentNdx < m_renderInfo.getColorAttachmentCount(); attachmentNdx++)
2386 const ColorClear& colorClear = colorClears[attachmentNdx];
2387 const VkClearAttachment attachment =
2389 VK_IMAGE_ASPECT_COLOR_BIT,
2391 makeClearValue(colorClear.getColor()),
2393 const VkClearRect rect =
2396 { (deInt32)colorClear.getOffset().x(), (deInt32)colorClear.getOffset().y() },
2397 { colorClear.getSize().x(), colorClear.getSize().y() }
2399 0u, // baseArrayLayer
2403 vk.cmdClearAttachments(commandBuffer, 1u, &attachment, 1u, &rect);
2407 if (m_renderInfo.getDepthStencilClear())
2409 const DepthStencilClear& depthStencilClear = *m_renderInfo.getDepthStencilClear();
2410 const deUint32 attachmentNdx = m_renderInfo.getColorAttachmentCount();
2411 tcu::TextureFormat format = mapVkFormat(m_renderInfo.getDepthStencilAttachment()->getFormat());
2412 const VkImageLayout layout = *m_renderInfo.getDepthStencilAttachmentLayout();
2413 const VkClearAttachment attachment =
2415 (VkImageAspectFlags)((hasDepthComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL ? VK_IMAGE_ASPECT_DEPTH_BIT : 0)
2416 | (hasStencilComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL ? VK_IMAGE_ASPECT_STENCIL_BIT : 0)),
2418 makeClearValueDepthStencil(depthStencilClear.getDepth(), depthStencilClear.getStencil())
2420 const VkClearRect rect =
2423 { (deInt32)depthStencilClear.getOffset().x(), (deInt32)depthStencilClear.getOffset().y() },
2424 { depthStencilClear.getSize().x(), depthStencilClear.getSize().y() }
2426 0u, // baseArrayLayer
2430 if ((tcu::hasDepthComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
2431 || (tcu::hasStencilComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL))
2433 vk.cmdClearAttachments(commandBuffer, 1u, &attachment, 1u, &rect);
2437 vector<VkImageMemoryBarrier> selfDeps;
2438 VkPipelineStageFlags srcStages = 0;
2439 VkPipelineStageFlags dstStages = 0;
2441 for (deUint32 inputAttachmentNdx = 0; inputAttachmentNdx < m_renderInfo.getInputAttachmentCount(); inputAttachmentNdx++)
2443 for (deUint32 colorAttachmentNdx = 0; colorAttachmentNdx < m_renderInfo.getColorAttachmentCount(); colorAttachmentNdx++)
2445 if (m_renderInfo.getInputAttachmentIndex(inputAttachmentNdx) == m_renderInfo.getColorAttachmentIndex(colorAttachmentNdx))
2447 const VkImageMemoryBarrier barrier =
2449 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2452 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // srcAccessMask
2453 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT, // dstAccessMask
2455 VK_IMAGE_LAYOUT_GENERAL, // oldLayout
2456 VK_IMAGE_LAYOUT_GENERAL, // newLayout
2458 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex
2459 VK_QUEUE_FAMILY_IGNORED, // destQueueFamilyIndex
2461 m_colorAttachmentImages[colorAttachmentNdx], // image
2462 { // subresourceRange
2463 VK_IMAGE_ASPECT_COLOR_BIT, // aspect
2466 0, // baseArraySlice
2471 srcStages |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
2472 dstStages |= VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
2474 selfDeps.push_back(barrier);
2478 if (m_renderInfo.getDepthStencilAttachmentIndex() && (m_renderInfo.getInputAttachmentIndex(inputAttachmentNdx) == *m_renderInfo.getDepthStencilAttachmentIndex()))
2480 const tcu::TextureFormat format = mapVkFormat(m_renderInfo.getDepthStencilAttachment()->getFormat());
2481 const bool hasDepth = hasDepthComponent(format.order);
2482 const bool hasStencil = hasStencilComponent(format.order);
2483 const VkImageMemoryBarrier barrier =
2485 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
2488 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, // srcAccessMask
2489 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT, // dstAccessMask
2491 m_renderInfo.getInputAttachmentLayout(inputAttachmentNdx), // oldLayout
2492 m_renderInfo.getInputAttachmentLayout(inputAttachmentNdx), // newLayout;
2494 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex;
2495 VK_QUEUE_FAMILY_IGNORED, // destQueueFamilyIndex;
2497 m_depthStencilAttachmentImage, // image;
2498 { // subresourceRange;
2499 (hasDepth ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
2500 | (hasStencil ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u), // aspect;
2503 0, // baseArraySlice;
2508 srcStages |= VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT;
2509 dstStages |= VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
2511 selfDeps.push_back(barrier);
2515 if (!selfDeps.empty())
2517 DE_ASSERT(srcStages != 0);
2518 DE_ASSERT(dstStages != 0);
2519 vk.cmdPipelineBarrier(commandBuffer, srcStages, dstStages, VK_DEPENDENCY_BY_REGION_BIT, 0, DE_NULL, 0, DE_NULL, (deUint32)selfDeps.size(), &selfDeps[0]);
2522 if (m_renderInfo.getRenderQuad())
2524 const VkDeviceSize offset = 0;
2525 const VkBuffer vertexBuffer = *m_vertexBuffer;
2527 vk.cmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
2529 if (m_descriptorSet)
2531 const VkDescriptorSet descriptorSet = *m_descriptorSet;
2532 vk.cmdBindDescriptorSets(commandBuffer, vk::VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipelineLayout, 0u, 1u, &descriptorSet, 0u, NULL);
2535 vk.cmdBindVertexBuffers(commandBuffer, 0u, 1u, &vertexBuffer, &offset);
2536 vk.cmdDraw(commandBuffer, 6u, 1u, 0u, 0u);
2541 const SubpassRenderInfo m_renderInfo;
2542 Move<VkCommandBuffer> m_commandBuffer;
2543 Move<VkPipeline> m_pipeline;
2544 Move<VkDescriptorSetLayout> m_descriptorSetLayout;
2545 Move<VkPipelineLayout> m_pipelineLayout;
2547 Move<VkShaderModule> m_vertexShaderModule;
2548 Move<VkShaderModule> m_fragmentShaderModule;
2550 Move<VkDescriptorPool> m_descriptorPool;
2551 Move<VkDescriptorSet> m_descriptorSet;
2552 Move<VkBuffer> m_vertexBuffer;
2553 de::MovePtr<Allocation> m_vertexBufferMemory;
2554 vector<VkImage> m_colorAttachmentImages;
2555 VkImage m_depthStencilAttachmentImage;
2558 void pushImageInitializationCommands (const DeviceInterface& vk,
2559 VkCommandBuffer commandBuffer,
2560 const vector<Attachment>& attachmentInfo,
2561 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
2562 deUint32 queueIndex,
2563 const vector<Maybe<VkClearValue> >& clearValues)
2566 vector<VkImageMemoryBarrier> initializeLayouts;
2568 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2570 if (!clearValues[attachmentNdx])
2573 const VkImageMemoryBarrier barrier =
2575 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
2578 (VkAccessFlags)0, // srcAccessMask
2579 getAllMemoryReadFlags() | VK_ACCESS_TRANSFER_WRITE_BIT, // dstAccessMask
2581 VK_IMAGE_LAYOUT_UNDEFINED, // oldLayout
2582 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // newLayout;
2584 queueIndex, // srcQueueFamilyIndex;
2585 queueIndex, // destQueueFamilyIndex;
2587 attachmentResources[attachmentNdx]->getImage(), // image;
2588 { // subresourceRange;
2589 getImageAspectFlags(attachmentInfo[attachmentNdx].getFormat()), // aspect;
2592 0, // baseArraySlice;
2597 initializeLayouts.push_back(barrier);
2600 if (!initializeLayouts.empty())
2601 vk.cmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT,
2602 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, (VkDependencyFlags)0,
2603 0, (const VkMemoryBarrier*)DE_NULL,
2604 0, (const VkBufferMemoryBarrier*)DE_NULL,
2605 (deUint32)initializeLayouts.size(), &initializeLayouts[0]);
2608 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2610 if (!clearValues[attachmentNdx])
2613 const tcu::TextureFormat format = mapVkFormat(attachmentInfo[attachmentNdx].getFormat());
2615 if (hasStencilComponent(format.order) || hasDepthComponent(format.order))
2617 const float clearNan = tcu::Float32::nan().asFloat();
2618 const float clearDepth = hasDepthComponent(format.order) ? clearValues[attachmentNdx]->depthStencil.depth : clearNan;
2619 const deUint32 clearStencil = hasStencilComponent(format.order) ? clearValues[attachmentNdx]->depthStencil.stencil : 0xDEu;
2620 const VkClearDepthStencilValue depthStencil =
2625 const VkImageSubresourceRange range =
2627 (VkImageAspectFlags)((hasDepthComponent(format.order) ? VK_IMAGE_ASPECT_DEPTH_BIT : 0)
2628 | (hasStencilComponent(format.order) ? VK_IMAGE_ASPECT_STENCIL_BIT : 0)),
2635 vk.cmdClearDepthStencilImage(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &depthStencil, 1, &range);
2639 const VkImageSubresourceRange range =
2641 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask;
2644 0, // baseArrayLayer;
2647 const VkClearColorValue clearColor = clearValues[attachmentNdx]->color;
2649 vk.cmdClearColorImage(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clearColor, 1, &range);
2654 vector<VkImageMemoryBarrier> renderPassLayouts;
2656 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2658 const VkImageLayout oldLayout = clearValues[attachmentNdx] ? VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL : VK_IMAGE_LAYOUT_UNDEFINED;
2659 const VkImageMemoryBarrier barrier =
2661 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
2664 getMemoryFlagsForLayout(oldLayout), // srcAccessMask
2665 getAllMemoryReadFlags() | getMemoryFlagsForLayout(attachmentInfo[attachmentNdx].getInitialLayout()), // dstAccessMask
2667 oldLayout, // oldLayout
2668 attachmentInfo[attachmentNdx].getInitialLayout(), // newLayout;
2670 queueIndex, // srcQueueFamilyIndex;
2671 queueIndex, // destQueueFamilyIndex;
2673 attachmentResources[attachmentNdx]->getImage(), // image;
2674 { // subresourceRange;
2675 getImageAspectFlags(attachmentInfo[attachmentNdx].getFormat()), // aspect;
2678 0, // baseArraySlice;
2683 renderPassLayouts.push_back(barrier);
2686 if (!renderPassLayouts.empty())
2687 vk.cmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT,
2688 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, (VkDependencyFlags)0,
2689 0, (const VkMemoryBarrier*)DE_NULL,
2690 0, (const VkBufferMemoryBarrier*)DE_NULL,
2691 (deUint32)renderPassLayouts.size(), &renderPassLayouts[0]);
2695 template<typename RenderpassSubpass>
2696 void pushRenderPassCommands (const DeviceInterface& vk,
2697 VkCommandBuffer commandBuffer,
2698 VkRenderPass renderPass,
2699 VkFramebuffer framebuffer,
2700 const vector<de::SharedPtr<SubpassRenderer> >& subpassRenderers,
2701 const UVec2& renderPos,
2702 const UVec2& renderSize,
2703 const vector<Maybe<VkClearValue> >& renderPassClearValues,
2704 TestConfig::RenderTypes render)
2706 const float clearNan = tcu::Float32::nan().asFloat();
2707 vector<VkClearValue> attachmentClearValues;
2708 const typename RenderpassSubpass::SubpassEndInfo subpassEndInfo (DE_NULL);
2710 for (size_t attachmentNdx = 0; attachmentNdx < renderPassClearValues.size(); attachmentNdx++)
2712 if (renderPassClearValues[attachmentNdx])
2713 attachmentClearValues.push_back(*renderPassClearValues[attachmentNdx]);
2715 attachmentClearValues.push_back(makeClearValueColorF32(clearNan, clearNan, clearNan, clearNan));
2719 const VkRect2D renderArea =
2721 { (deInt32)renderPos.x(), (deInt32)renderPos.y() },
2722 { renderSize.x(), renderSize.y() }
2725 for (size_t subpassNdx = 0; subpassNdx < subpassRenderers.size(); subpassNdx++)
2727 const VkSubpassContents contents = subpassRenderers[subpassNdx]->isSecondary() ? VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS : VK_SUBPASS_CONTENTS_INLINE;
2728 const typename RenderpassSubpass::SubpassBeginInfo subpassBeginInfo (DE_NULL, contents);
2729 const VkRenderPassBeginInfo renderPassBeginInfo = createRenderPassBeginInfo(renderPass,
2732 (deUint32)attachmentClearValues.size(),
2733 attachmentClearValues.empty() ? DE_NULL : &attachmentClearValues[0]);
2735 if (subpassNdx == 0)
2736 RenderpassSubpass::cmdBeginRenderPass(vk, commandBuffer, &renderPassBeginInfo, &subpassBeginInfo);
2738 RenderpassSubpass::cmdNextSubpass(vk, commandBuffer, &subpassBeginInfo, &subpassEndInfo);
2742 if (contents == VK_SUBPASS_CONTENTS_INLINE)
2744 subpassRenderers[subpassNdx]->pushRenderCommands(vk, commandBuffer);
2746 else if (contents == VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS)
2748 const VkCommandBuffer cmd = subpassRenderers[subpassNdx]->getCommandBuffer();
2749 vk.cmdExecuteCommands(commandBuffer, 1, &cmd);
2752 DE_FATAL("Invalid contents");
2756 RenderpassSubpass::cmdEndRenderPass(vk, commandBuffer, &subpassEndInfo);
2760 void pushDynamicRenderingCommands (const DeviceInterface& vk,
2761 VkCommandBuffer commandBuffer,
2762 const RenderPass& renderPassInfo,
2763 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
2764 const vector<de::SharedPtr<SubpassRenderer> >& subpassRenderers,
2765 const UVec2& renderPos,
2766 const UVec2& renderSize,
2767 const vector<Maybe<VkClearValue> >& renderPassClearValues,
2768 deUint32 queueIndex,
2769 TestConfig::RenderTypes render)
2771 const float clearNan = tcu::Float32::nan().asFloat();
2772 const VkClearValue clearValueNan = makeClearValueColorF32(clearNan, clearNan, clearNan, clearNan);
2774 DE_ASSERT(subpassRenderers.size() == 1);
2776 VkRenderingFlagsKHR renderingFlags = 0u;
2777 if (subpassRenderers[0]->isSecondary())
2778 renderingFlags = VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR;
2780 const VkRect2D renderArea
2782 { (deInt32)renderPos.x(), (deInt32)renderPos.y() },
2783 { renderSize.x(), renderSize.y() }
2786 // translate structures that were prepared to construct renderpass to structures needed for dynamic rendering
2788 vector<VkImageMemoryBarrier> imageBarriersBeforeRendering;
2789 vector<VkImageMemoryBarrier> imageBarriersAfterRendering;
2790 std::vector<vk::VkRenderingAttachmentInfoKHR> colorAttachmentVect;
2791 const Subpass& subpassInfo = renderPassInfo.getSubpasses()[0];
2792 const vector<AttachmentReference>& colorAttachmentsInfo = subpassInfo.getColorAttachments();
2793 const vector<AttachmentReference>& resolveAttachmentsInfo = subpassInfo.getResolveAttachments();
2795 for (deUint32 i = 0 ; i < colorAttachmentsInfo.size() ; ++i)
2797 const AttachmentReference& colorAttachmentReference = colorAttachmentsInfo[i];
2798 const deUint32 colorAttachmentIndex = colorAttachmentReference.getAttachment();
2799 const Attachment& colorAttachmentInfo = renderPassInfo.getAttachments()[colorAttachmentIndex];
2801 VkResolveModeFlagBits resolveMode = VK_RESOLVE_MODE_NONE;
2802 VkImageView resolveImageView = DE_NULL;
2803 VkImageLayout resolveImageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
2805 // handle resolve attachments if they were specified
2806 if (!resolveAttachmentsInfo.empty())
2808 const AttachmentReference& resolveAttachmentReference = resolveAttachmentsInfo[i];
2809 const deUint32 resolveAttachmentIndex = resolveAttachmentReference.getAttachment();
2810 const Attachment& resolveAttachmentInfo = renderPassInfo.getAttachments()[resolveAttachmentIndex];
2812 resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
2813 resolveImageView = attachmentResources[resolveAttachmentIndex]->getAttachmentView();
2814 resolveImageLayout = resolveAttachmentInfo.getInitialLayout();
2817 colorAttachmentVect.push_back({
2818 vk::VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR, // VkStructureType sType
2819 DE_NULL, // const void* pNext
2820 attachmentResources[colorAttachmentIndex]->getAttachmentView(), // VkImageView imageView
2821 colorAttachmentReference.getImageLayout(), // VkImageLayout imageLayout
2822 resolveMode, // VkResolveModeFlagBits resolveMode
2823 resolveImageView, // VkImageView resolveImageView
2824 resolveImageLayout, // VkImageLayout resolveImageLayout
2825 colorAttachmentInfo.getLoadOp(), // VkAttachmentLoadOp loadOp
2826 colorAttachmentInfo.getStoreOp(), // VkAttachmentStoreOp storeOp
2827 (renderPassClearValues[colorAttachmentIndex] ?
2828 *renderPassClearValues[colorAttachmentIndex] :
2829 clearValueNan) // VkClearValue clearValue
2832 const VkImageLayout initialLayout = colorAttachmentInfo.getInitialLayout();
2833 const VkImageLayout renderingLayout = colorAttachmentReference.getImageLayout();
2834 const VkImageLayout finalLayout = colorAttachmentInfo.getFinalLayout();
2836 const VkImageMemoryBarrier barrierBeforeRendering
2838 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2841 getAllMemoryWriteFlags() | getMemoryFlagsForLayout(initialLayout), // srcAccessMask
2842 getMemoryFlagsForLayout(renderingLayout), // dstAccessMask
2844 initialLayout, // oldLayout
2845 renderingLayout, // newLayout
2847 queueIndex, // srcQueueFamilyIndex
2848 queueIndex, // destQueueFamilyIndex
2850 attachmentResources[colorAttachmentIndex]->getImage(), // image
2851 { // subresourceRange
2852 getImageAspectFlags(colorAttachmentInfo.getFormat()), // aspect;
2855 0, // baseArraySlice
2859 imageBarriersBeforeRendering.push_back(barrierBeforeRendering);
2861 const VkImageMemoryBarrier barrierAfterRendering
2863 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2866 getMemoryFlagsForLayout(renderingLayout), // srcAccessMask
2867 getAllMemoryReadFlags() | getMemoryFlagsForLayout(finalLayout), // dstAccessMask
2869 renderingLayout, // oldLayout
2870 finalLayout, // newLayout
2872 queueIndex, // srcQueueFamilyIndex
2873 queueIndex, // destQueueFamilyIndex
2875 attachmentResources[colorAttachmentIndex]->getImage(), // image
2876 { // subresourceRange
2877 getImageAspectFlags(colorAttachmentInfo.getFormat()), // aspect;
2880 0, // baseArraySlice
2884 imageBarriersAfterRendering.push_back(barrierAfterRendering);
2887 VkRenderingAttachmentInfoKHR* pDepthAttachment = DE_NULL;
2888 VkRenderingAttachmentInfoKHR* pStencilAttachment = DE_NULL;
2889 VkRenderingAttachmentInfoKHR depthAttachment
2891 vk::VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR, // VkStructureType sType;
2892 DE_NULL, // const void* pNext;
2893 DE_NULL, // VkImageView imageView;
2894 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout imageLayout;
2895 VK_RESOLVE_MODE_NONE, // VkResolveModeFlagBits resolveMode;
2896 DE_NULL, // VkImageView resolveImageView;
2897 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout resolveImageLayout;
2898 VK_ATTACHMENT_LOAD_OP_LOAD, // VkAttachmentLoadOp loadOp;
2899 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp;
2900 clearValueNan // VkClearValue clearValue;
2902 VkRenderingAttachmentInfoKHR stencilAttachment = depthAttachment;
2903 const AttachmentReference& depthStencilAttachmentReference = subpassInfo.getDepthStencilAttachment();
2904 const deUint32 dsAttachmentIndex = depthStencilAttachmentReference.getAttachment();
2906 if (dsAttachmentIndex != VK_ATTACHMENT_UNUSED)
2908 const Attachment& dsAttachmentInfo = renderPassInfo.getAttachments()[dsAttachmentIndex];
2909 const tcu::TextureFormat format = mapVkFormat(dsAttachmentInfo.getFormat());
2911 if (tcu::hasDepthComponent(format.order))
2913 depthAttachment.imageView = attachmentResources[dsAttachmentIndex]->getAttachmentView();
2914 depthAttachment.imageLayout = depthStencilAttachmentReference.getImageLayout();
2915 depthAttachment.loadOp = dsAttachmentInfo.getLoadOp();
2916 depthAttachment.storeOp = dsAttachmentInfo.getStoreOp();
2918 if (renderPassClearValues[dsAttachmentIndex])
2919 depthAttachment.clearValue = *renderPassClearValues[dsAttachmentIndex];
2921 pDepthAttachment = &depthAttachment;
2924 if (tcu::hasStencilComponent(format.order))
2926 stencilAttachment.imageView = attachmentResources[dsAttachmentIndex]->getAttachmentView();
2927 stencilAttachment.imageLayout = depthStencilAttachmentReference.getImageLayout();
2928 stencilAttachment.loadOp = dsAttachmentInfo.getStencilLoadOp();
2929 stencilAttachment.storeOp = dsAttachmentInfo.getStencilStoreOp();
2931 if (renderPassClearValues[dsAttachmentIndex])
2932 stencilAttachment.clearValue = *renderPassClearValues[dsAttachmentIndex];
2934 pStencilAttachment = &stencilAttachment;
2937 const VkImageLayout initialLayout = dsAttachmentInfo.getInitialLayout();
2938 const VkImageLayout renderingLayout = depthStencilAttachmentReference.getImageLayout();
2939 const VkImageLayout finalLayout = dsAttachmentInfo.getFinalLayout();
2941 const VkImageMemoryBarrier barrierBeforeRendering
2943 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2946 getAllMemoryWriteFlags() | getMemoryFlagsForLayout(initialLayout), // srcAccessMask
2947 getMemoryFlagsForLayout(renderingLayout), // dstAccessMask
2949 initialLayout, // oldLayout
2950 renderingLayout, // newLayout
2952 queueIndex, // srcQueueFamilyIndex
2953 queueIndex, // destQueueFamilyIndex
2955 attachmentResources[dsAttachmentIndex]->getImage(), // image
2956 { // subresourceRange
2957 getImageAspectFlags(dsAttachmentInfo.getFormat()), // aspect;
2960 0, // baseArraySlice
2964 imageBarriersBeforeRendering.push_back(barrierBeforeRendering);
2966 const VkImageMemoryBarrier barrierAfterRendering
2968 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2971 getMemoryFlagsForLayout(renderingLayout), // srcAccessMask
2972 getAllMemoryReadFlags() | getMemoryFlagsForLayout(finalLayout), // dstAccessMask
2974 renderingLayout, // oldLayout
2975 finalLayout, // newLayout
2977 queueIndex, // srcQueueFamilyIndex
2978 queueIndex, // destQueueFamilyIndex
2980 attachmentResources[dsAttachmentIndex]->getImage(), // image
2981 { // subresourceRange
2982 getImageAspectFlags(dsAttachmentInfo.getFormat()), // aspect;
2985 0, // baseArraySlice
2989 imageBarriersAfterRendering.push_back(barrierAfterRendering);
2992 if (!imageBarriersBeforeRendering.empty())
2993 vk.cmdPipelineBarrier(commandBuffer,
2994 getAllPipelineStageFlags(),
2995 getAllPipelineStageFlags(),
2996 (VkDependencyFlags)0,
2997 0, (const VkMemoryBarrier*)DE_NULL,
2998 0, (const VkBufferMemoryBarrier*)DE_NULL,
2999 (deUint32)imageBarriersBeforeRendering.size(),
3000 &imageBarriersBeforeRendering[0]);
3002 vk::VkRenderingInfoKHR renderingInfo
3004 vk::VK_STRUCTURE_TYPE_RENDERING_INFO_KHR,
3006 renderingFlags, // VkRenderingFlagsKHR flags;
3007 renderArea, // VkRect2D renderArea;
3008 1u, // deUint32 layerCount;
3009 0u, // deUint32 viewMask;
3010 static_cast<deUint32>(colorAttachmentVect.size()), // deUint32 colorAttachmentCount;
3011 colorAttachmentVect.empty() ? DE_NULL : &colorAttachmentVect[0], // const VkRenderingAttachmentInfoKHR* pColorAttachments;
3012 pDepthAttachment, // const VkRenderingAttachmentInfoKHR* pDepthAttachment;
3013 pStencilAttachment // const VkRenderingAttachmentInfoKHR* pStencilAttachment;
3016 vk.cmdBeginRendering(commandBuffer, &renderingInfo);
3020 if (subpassRenderers[0]->isSecondary())
3022 const VkCommandBuffer cmd = subpassRenderers[0]->getCommandBuffer();
3023 vk.cmdExecuteCommands(commandBuffer, 1, &cmd);
3026 subpassRenderers[0]->pushRenderCommands(vk, commandBuffer);
3029 vk.cmdEndRendering(commandBuffer);
3031 if (!imageBarriersAfterRendering.empty())
3032 vk.cmdPipelineBarrier(commandBuffer,
3033 getAllPipelineStageFlags(),
3034 getAllPipelineStageFlags(),
3035 (VkDependencyFlags)0,
3036 0, (const VkMemoryBarrier*)DE_NULL,
3037 0, (const VkBufferMemoryBarrier*)DE_NULL,
3038 (deUint32)imageBarriersAfterRendering.size(),
3039 &imageBarriersAfterRendering[0]);
3042 void pushRenderPassCommands (const DeviceInterface& vk,
3043 VkCommandBuffer commandBuffer,
3044 VkRenderPass renderPass,
3045 const RenderPass& renderPassInfo,
3046 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
3047 VkFramebuffer framebuffer,
3048 const vector<de::SharedPtr<SubpassRenderer> >& subpassRenderers,
3049 const UVec2& renderPos,
3050 const UVec2& renderSize,
3051 const vector<Maybe<VkClearValue> >& renderPassClearValues,
3052 deUint32 queueIndex,
3053 TestConfig::RenderTypes render,
3054 RenderingType renderingType)
3056 switch (renderingType)
3058 case RENDERING_TYPE_RENDERPASS_LEGACY:
3059 return pushRenderPassCommands<RenderpassSubpass1>(vk, commandBuffer, renderPass, framebuffer, subpassRenderers, renderPos, renderSize, renderPassClearValues, render);
3060 case RENDERING_TYPE_RENDERPASS2:
3061 return pushRenderPassCommands<RenderpassSubpass2>(vk, commandBuffer, renderPass, framebuffer, subpassRenderers, renderPos, renderSize, renderPassClearValues, render);
3062 case RENDERING_TYPE_DYNAMIC_RENDERING:
3063 return pushDynamicRenderingCommands(vk, commandBuffer, renderPassInfo, attachmentResources, subpassRenderers, renderPos, renderSize, renderPassClearValues, queueIndex, render);
3065 TCU_THROW(InternalError, "Impossible");
3069 void pushReadImagesToBuffers (const DeviceInterface& vk,
3070 VkCommandBuffer commandBuffer,
3071 deUint32 queueIndex,
3073 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
3074 const vector<Attachment>& attachmentInfo,
3075 const vector<bool>& isLazy,
3077 const UVec2& targetSize)
3080 vector<VkImageMemoryBarrier> imageBarriers;
3082 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
3084 if (isLazy[attachmentNdx])
3087 const VkImageLayout oldLayout = attachmentInfo[attachmentNdx].getFinalLayout();
3088 const VkImageMemoryBarrier barrier =
3090 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
3093 getAllMemoryWriteFlags() | getMemoryFlagsForLayout(oldLayout), // srcAccessMask
3094 getAllMemoryReadFlags(), // dstAccessMask
3096 oldLayout, // oldLayout
3097 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // newLayout
3099 queueIndex, // srcQueueFamilyIndex
3100 queueIndex, // destQueueFamilyIndex
3102 attachmentResources[attachmentNdx]->getImage(), // image
3103 { // subresourceRange
3104 getImageAspectFlags(attachmentInfo[attachmentNdx].getFormat()), // aspect;
3107 0, // baseArraySlice
3112 imageBarriers.push_back(barrier);
3115 if (!imageBarriers.empty())
3116 vk.cmdPipelineBarrier(commandBuffer,
3117 getAllPipelineStageFlags(),
3118 getAllPipelineStageFlags(),
3119 (VkDependencyFlags)0,
3120 0, (const VkMemoryBarrier*)DE_NULL,
3121 0, (const VkBufferMemoryBarrier*)DE_NULL,
3122 (deUint32)imageBarriers.size(), &imageBarriers[0]);
3125 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
3127 if (isLazy[attachmentNdx])
3130 const tcu::TextureFormat::ChannelOrder order = mapVkFormat(attachmentInfo[attachmentNdx].getFormat()).order;
3131 const VkBufferImageCopy rect =
3134 0, // bufferRowLength
3135 0, // bufferImageHeight
3136 { // imageSubresource
3137 (vk::VkImageAspectFlags)getPrimaryImageAspect(mapVkFormat(attachmentInfo[attachmentNdx].getFormat()).order), // aspect
3142 { 0, 0, 0 }, // imageOffset
3143 { targetSize.x(), targetSize.y(), 1u } // imageExtent
3146 vk.cmdCopyImageToBuffer(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, attachmentResources[attachmentNdx]->getBuffer(), 1, &rect);
3148 if (tcu::TextureFormat::DS == order)
3150 const VkBufferImageCopy stencilRect =
3153 0, // bufferRowLength
3154 0, // bufferImageHeight
3155 { // imageSubresource
3156 VK_IMAGE_ASPECT_STENCIL_BIT, // aspect
3161 { 0, 0, 0 }, // imageOffset
3162 { targetSize.x(), targetSize.y(), 1u } // imageExtent
3165 vk.cmdCopyImageToBuffer(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, attachmentResources[attachmentNdx]->getSecondaryBuffer(), 1, &stencilRect);
3170 vector<VkBufferMemoryBarrier> bufferBarriers;
3172 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
3174 if (isLazy[attachmentNdx])
3177 const tcu::TextureFormat::ChannelOrder order = mapVkFormat(attachmentInfo[attachmentNdx].getFormat()).order;
3178 const VkBufferMemoryBarrier bufferBarrier =
3180 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
3183 getAllMemoryWriteFlags(),
3184 getAllMemoryReadFlags(),
3189 attachmentResources[attachmentNdx]->getBuffer(),
3191 attachmentResources[attachmentNdx]->getBufferSize()
3194 bufferBarriers.push_back(bufferBarrier);
3196 if (tcu::TextureFormat::DS == order)
3198 const VkBufferMemoryBarrier secondaryBufferBarrier =
3200 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
3203 getAllMemoryWriteFlags(),
3204 getAllMemoryReadFlags(),
3209 attachmentResources[attachmentNdx]->getSecondaryBuffer(),
3211 attachmentResources[attachmentNdx]->getSecondaryBufferSize()
3214 bufferBarriers.push_back(secondaryBufferBarrier);
3218 if (!bufferBarriers.empty())
3219 vk.cmdPipelineBarrier(commandBuffer,
3220 getAllPipelineStageFlags(),
3221 getAllPipelineStageFlags(),
3222 (VkDependencyFlags)0,
3223 0, (const VkMemoryBarrier*)DE_NULL,
3224 (deUint32)bufferBarriers.size(), &bufferBarriers[0],
3225 0, (const VkImageMemoryBarrier*)DE_NULL);
3232 PixelValue (const Maybe<bool>& x = tcu::Nothing,
3233 const Maybe<bool>& y = tcu::Nothing,
3234 const Maybe<bool>& z = tcu::Nothing,
3235 const Maybe<bool>& w = tcu::Nothing);
3237 void setUndefined (size_t ndx);
3238 void setValue (size_t ndx, bool value);
3239 Maybe<bool> getValue (size_t ndx) const;
3245 PixelValue::PixelValue (const Maybe<bool>& x,
3246 const Maybe<bool>& y,
3247 const Maybe<bool>& z,
3248 const Maybe<bool>& w)
3251 const Maybe<bool> values[] =
3256 for (size_t ndx = 0; ndx < DE_LENGTH_OF_ARRAY(values); ndx++)
3259 setValue(ndx, *values[ndx]);
3264 DE_ASSERT(m_status <= 0xFFu);
3267 void PixelValue::setUndefined (size_t ndx)
3270 DE_ASSERT(m_status <= 0xFFu);
3272 m_status &= (deUint16)~(0x1u << (deUint16)(ndx * 2));
3273 DE_ASSERT(m_status <= 0xFFu);
3276 void PixelValue::setValue (size_t ndx, bool value)
3279 DE_ASSERT(m_status <= 0xFFu);
3281 m_status = (deUint16)(m_status | (deUint16)(0x1u << (ndx * 2)));
3284 m_status = (deUint16)(m_status | (deUint16)(0x1u << (ndx * 2 + 1)));
3286 m_status &= (deUint16)~(0x1u << (deUint16)(ndx * 2 + 1));
3288 DE_ASSERT(m_status <= 0xFFu);
3291 Maybe<bool> PixelValue::getValue (size_t ndx) const
3294 DE_ASSERT(m_status <= 0xFFu);
3296 if ((m_status & (0x1u << (deUint16)(ndx * 2))) != 0)
3298 return just((m_status & (0x1u << (deUint32)(ndx * 2 + 1))) != 0);
3301 return tcu::Nothing;
3304 void clearReferenceValues (vector<PixelValue>& values,
3305 const UVec2& targetSize,
3306 const UVec2& offset,
3309 const PixelValue& value)
3311 DE_ASSERT(targetSize.x() * targetSize.y() == (deUint32)values.size());
3312 DE_ASSERT(offset.x() + size.x() <= targetSize.x());
3313 DE_ASSERT(offset.y() + size.y() <= targetSize.y());
3315 for (deUint32 y = offset.y(); y < offset.y() + size.y(); y++)
3316 for (deUint32 x = offset.x(); x < offset.x() + size.x(); x++)
3318 for (int compNdx = 0; compNdx < 4; compNdx++)
3322 if (value.getValue(compNdx))
3323 values[x + y * targetSize.x()].setValue(compNdx, *value.getValue(compNdx));
3325 values[x + y * targetSize.x()].setUndefined(compNdx);
3331 void markUndefined (vector<PixelValue>& values,
3333 const UVec2& targetSize,
3334 const UVec2& offset,
3337 DE_ASSERT(targetSize.x() * targetSize.y() == (deUint32)values.size());
3339 for (deUint32 y = offset.y(); y < offset.y() + size.y(); y++)
3340 for (deUint32 x = offset.x(); x < offset.x() + size.x(); x++)
3342 for (int compNdx = 0; compNdx < 4; compNdx++)
3345 values[x + y * targetSize.x()].setUndefined(compNdx);
3350 PixelValue clearValueToPixelValue (const VkClearValue& value,
3351 const tcu::TextureFormat& format,
3352 const DepthValuesArray& depthValues)
3354 const bool isDepthAttachment = hasDepthComponent(format.order);
3355 const bool isStencilAttachment = hasStencilComponent(format.order);
3356 const bool isDepthOrStencilAttachment = isDepthAttachment || isStencilAttachment;
3357 PixelValue pixelValue;
3359 if (isDepthOrStencilAttachment)
3361 if (isDepthAttachment)
3363 if (value.depthStencil.depth == float(depthValues[1]) / 255.0f)
3364 pixelValue.setValue(0, true);
3365 else if (value.depthStencil.depth == float(depthValues[0]) / 255.0f)
3366 pixelValue.setValue(0, false);
3368 DE_FATAL("Unknown depth value");
3371 if (isStencilAttachment)
3373 if (value.depthStencil.stencil == 0xFFu)
3374 pixelValue.setValue(1, true);
3375 else if (value.depthStencil.stencil == 0x0u)
3376 pixelValue.setValue(1, false);
3378 DE_FATAL("Unknown stencil value");
3383 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
3384 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
3386 switch (channelClass)
3388 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
3389 for (int i = 0; i < 4; i++)
3393 if (value.color.int32[i] == 1)
3394 pixelValue.setValue(i, true);
3395 else if (value.color.int32[i] == 0)
3396 pixelValue.setValue(i, false);
3398 DE_FATAL("Unknown clear color value");
3403 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
3404 for (int i = 0; i < 4; i++)
3408 if (value.color.uint32[i] == 1u)
3409 pixelValue.setValue(i, true);
3410 else if (value.color.uint32[i] == 0u)
3411 pixelValue.setValue(i, false);
3413 DE_FATAL("Unknown clear color value");
3418 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
3419 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
3420 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
3421 for (int i = 0; i < 4; i++)
3425 if (value.color.float32[i] == 1.0f)
3426 pixelValue.setValue(i, true);
3427 else if (value.color.float32[i] == 0.0f)
3428 pixelValue.setValue(i, false);
3430 DE_FATAL("Unknown clear color value");
3436 DE_FATAL("Unknown channel class");
3443 void renderReferenceValues (vector<vector<PixelValue> >& referenceAttachments,
3444 const RenderPass& renderPassInfo,
3445 const UVec2& targetSize,
3446 const vector<Maybe<VkClearValue> >& imageClearValues,
3447 const vector<Maybe<VkClearValue> >& renderPassClearValues,
3448 const vector<SubpassRenderInfo>& subpassRenderInfo,
3449 const UVec2& renderPos,
3450 const UVec2& renderSize,
3451 const deUint32 drawStartNdx,
3452 const DepthValuesArray& depthValues)
3454 const vector<Subpass>& subpasses = renderPassInfo.getSubpasses();
3455 vector<bool> attachmentUsed (renderPassInfo.getAttachments().size(), false);
3457 referenceAttachments.resize(renderPassInfo.getAttachments().size());
3459 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
3461 const Attachment attachment = renderPassInfo.getAttachments()[attachmentNdx];
3462 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3463 vector<PixelValue>& reference = referenceAttachments[attachmentNdx];
3465 reference.resize(targetSize.x() * targetSize.y());
3467 if (imageClearValues[attachmentNdx])
3468 clearReferenceValues(reference, targetSize, UVec2(0, 0), targetSize, BVec4(true), clearValueToPixelValue(*imageClearValues[attachmentNdx], format, depthValues));
3471 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
3473 const Subpass& subpass = subpasses[subpassNdx];
3474 const SubpassRenderInfo& renderInfo = subpassRenderInfo[subpassNdx];
3475 const vector<AttachmentReference>& colorAttachments = subpass.getColorAttachments();
3477 // Apply load op if attachment was used for the first time
3478 for (size_t attachmentNdx = 0; attachmentNdx < colorAttachments.size(); attachmentNdx++)
3480 const deUint32 attachmentIndex = getAttachmentNdx(colorAttachments, attachmentNdx);
3482 if (!attachmentUsed[attachmentIndex] && colorAttachments[attachmentNdx].getAttachment() != VK_ATTACHMENT_UNUSED)
3484 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3485 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3486 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3488 DE_ASSERT(!tcu::hasDepthComponent(format.order));
3489 DE_ASSERT(!tcu::hasStencilComponent(format.order));
3491 if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
3492 clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(true), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format, depthValues));
3493 else if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
3494 markUndefined(reference, BVec4(true), targetSize, renderPos, renderSize);
3496 attachmentUsed[attachmentIndex] = true;
3500 // Apply load op to depth/stencil attachment if it was used for the first time
3501 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
3503 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3505 // Apply load op if attachment was used for the first time
3506 if (!attachmentUsed[attachmentIndex])
3508 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3509 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3510 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3512 if (tcu::hasDepthComponent(format.order))
3514 if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
3515 clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(true, false, false, false), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format, depthValues));
3516 else if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
3517 markUndefined(reference, BVec4(true, false, false, false), targetSize, renderPos, renderSize);
3520 if (tcu::hasStencilComponent(format.order))
3522 if (attachment.getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
3523 clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(false, true, false, false), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format, depthValues));
3524 else if (attachment.getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
3525 markUndefined(reference, BVec4(false, true, false, false), targetSize, renderPos, renderSize);
3528 attachmentUsed[attachmentIndex] = true;
3532 for (size_t colorClearNdx = 0; colorClearNdx < renderInfo.getColorClears().size(); colorClearNdx++)
3534 const ColorClear& colorClear = renderInfo.getColorClears()[colorClearNdx];
3535 const UVec2 offset = colorClear.getOffset();
3536 const UVec2 size = colorClear.getSize();
3537 const deUint32 attachmentIndex = subpass.getColorAttachments()[colorClearNdx].getAttachment();
3538 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3539 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3540 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3543 value.color = colorClear.getColor();
3545 clearReferenceValues(reference, targetSize, offset, size, BVec4(true), clearValueToPixelValue(value, format, depthValues));
3548 if (renderInfo.getDepthStencilClear())
3550 const DepthStencilClear& dsClear = *renderInfo.getDepthStencilClear();
3551 const UVec2 offset = dsClear.getOffset();
3552 const UVec2 size = dsClear.getSize();
3553 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3554 const VkImageLayout layout = subpass.getDepthStencilAttachment().getImageLayout();
3555 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3556 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3557 const bool hasStencil = tcu::hasStencilComponent(format.order)
3558 && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL;
3559 const bool hasDepth = tcu::hasDepthComponent(format.order)
3560 && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
3561 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3564 value.depthStencil.depth = dsClear.getDepth();
3565 value.depthStencil.stencil = dsClear.getStencil();
3567 clearReferenceValues(reference, targetSize, offset, size, BVec4(hasDepth, hasStencil, false, false), clearValueToPixelValue(value, format, depthValues));
3570 if (renderInfo.getRenderQuad())
3572 const RenderQuad& renderQuad = *renderInfo.getRenderQuad();
3573 const Vec2 posA = renderQuad.getCornerA();
3574 const Vec2 posB = renderQuad.getCornerB();
3575 const Vec2 origin = Vec2((float)renderInfo.getViewportOffset().x(), (float)renderInfo.getViewportOffset().y()) + Vec2((float)renderInfo.getViewportSize().x(), (float)renderInfo.getViewportSize().y()) / Vec2(2.0f);
3576 const Vec2 p = Vec2((float)renderInfo.getViewportSize().x(), (float)renderInfo.getViewportSize().y()) / Vec2(2.0f);
3577 const IVec2 posAI (deRoundFloatToInt32(origin.x() + (p.x() * posA.x())),
3578 deRoundFloatToInt32(origin.y() + (p.y() * posA.y())));
3579 const IVec2 posBI (deRoundFloatToInt32(origin.x() + (p.x() * posB.x())),
3580 deRoundFloatToInt32(origin.y() + (p.y() * posB.y())));
3582 DE_ASSERT(posAI.x() < posBI.x());
3583 DE_ASSERT(posAI.y() < posBI.y());
3585 if (subpass.getInputAttachments().empty())
3587 for (size_t attachmentRefNdx = drawStartNdx; attachmentRefNdx < subpass.getColorAttachments().size(); attachmentRefNdx++)
3589 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentRefNdx].getAttachment();
3591 if (attachmentIndex == VK_ATTACHMENT_UNUSED)
3594 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3595 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3596 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
3597 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3599 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3600 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3602 for (int compNdx = 0; compNdx < 4; compNdx++)
3604 const size_t index = subpassNdx + attachmentIndex + compNdx;
3605 const BoolOp op = boolOpFromIndex(index);
3606 const bool boolX = x % 2 == (int)(index % 2);
3607 const bool boolY = y % 2 == (int)((index / 2) % 2);
3609 if (channelMask[compNdx])
3610 reference[x + y * targetSize.x()].setValue(compNdx, performBoolOp(op, boolX, boolY));
3615 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
3617 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3618 const VkImageLayout layout = subpass.getDepthStencilAttachment().getImageLayout();
3619 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3620 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3621 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3623 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3624 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3626 if (tcu::hasDepthComponent(format.order)
3627 && layout != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3628 && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
3630 const size_t index = subpassNdx + 1;
3631 const BoolOp op = boolOpFromIndex(index);
3632 const bool boolX = x % 2 == (int)(index % 2);
3633 const bool boolY = y % 2 == (int)((index / 2) % 2);
3635 reference[x + y * targetSize.x()].setValue(0, performBoolOp(op, boolX, boolY));
3638 if (tcu::hasStencilComponent(format.order)
3639 && layout != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3640 && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
3642 const size_t index = subpassNdx;
3643 reference[x + y * targetSize.x()].setValue(1, (index % 2) == 0);
3650 size_t outputComponentCount = 0;
3651 vector<Maybe<bool> > inputs;
3653 DE_ASSERT(posAI.x() < posBI.x());
3654 DE_ASSERT(posAI.y() < posBI.y());
3656 for (size_t attachmentRefNdx = 0; attachmentRefNdx < subpass.getColorAttachments().size(); attachmentRefNdx++)
3658 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentRefNdx].getAttachment();
3659 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3660 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3661 const int componentCount = tcu::getNumUsedChannels(format.order);
3663 outputComponentCount += (size_t)componentCount;
3666 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3667 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3668 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
3670 const Attachment& attachment (renderPassInfo.getAttachments()[subpass.getDepthStencilAttachment().getAttachment()]);
3671 const tcu::TextureFormat format (mapVkFormat(attachment.getFormat()));
3673 if (tcu::hasDepthComponent(format.order))
3674 outputComponentCount++;
3677 if (outputComponentCount > 0)
3679 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3680 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3682 for (size_t inputAttachmentNdx = 0; inputAttachmentNdx < subpass.getInputAttachments().size(); inputAttachmentNdx++)
3684 const deUint32 attachmentIndex = subpass.getInputAttachments()[inputAttachmentNdx].getAttachment();
3685 const VkImageLayout layout = subpass.getInputAttachments()[inputAttachmentNdx].getImageLayout();
3686 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3687 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3688 const int componentCount = tcu::getNumUsedChannels(format.order);
3690 for (int compNdx = 0; compNdx < componentCount; compNdx++)
3692 if ((compNdx != 0 || layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
3693 && (compNdx != 1 || layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL))
3695 inputs.push_back(referenceAttachments[attachmentIndex][x + y * targetSize.x()].getValue(compNdx));
3700 const size_t inputsPerOutput = inputs.size() >= outputComponentCount
3701 ? ((inputs.size() / outputComponentCount)
3702 + ((inputs.size() % outputComponentCount) != 0 ? 1 : 0))
3705 size_t outputValueNdx = 0;
3707 for (size_t attachmentRefNdx = 0; attachmentRefNdx < subpass.getColorAttachments().size(); attachmentRefNdx++)
3709 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentRefNdx].getAttachment();
3710 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3711 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3712 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3713 const int componentCount = tcu::getNumUsedChannels(format.order);
3715 for (int compNdx = 0; compNdx < componentCount; compNdx++)
3717 const size_t index = subpassNdx + attachmentIndex + outputValueNdx;
3718 const BoolOp op = boolOpFromIndex(index);
3719 const bool boolX = x % 2 == (int)(index % 2);
3720 const bool boolY = y % 2 == (int)((index / 2) % 2);
3721 Maybe<bool> output = tcu::just(performBoolOp(op, boolX, boolY));
3723 for (size_t i = 0; i < inputsPerOutput; i++)
3727 else if (!inputs[((outputValueNdx + compNdx) * inputsPerOutput + i) % inputs.size()])
3728 output = tcu::Nothing;
3730 output = (*output) == (*inputs[((outputValueNdx + compNdx) * inputsPerOutput + i) % inputs.size()]);
3734 reference[x + y * targetSize.x()].setValue(compNdx, *output);
3736 reference[x + y * targetSize.x()].setUndefined(compNdx);
3739 outputValueNdx += componentCount;
3742 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3743 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3744 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
3746 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3747 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3748 const size_t index = subpassNdx + attachmentIndex;
3749 const BoolOp op = boolOpFromIndex(index);
3750 const bool boolX = x % 2 == (int)(index % 2);
3751 const bool boolY = y % 2 == (int)((index / 2) % 2);
3752 Maybe<bool> output = tcu::just(performBoolOp(op, boolX, boolY));
3754 for (size_t i = 0; i < inputsPerOutput; i++)
3758 else if (inputs[(outputValueNdx * inputsPerOutput + i) % inputs.size()])
3759 output = (*output) == (*inputs[(outputValueNdx * inputsPerOutput + i) % inputs.size()]);
3761 output = tcu::Nothing;
3765 reference[x + y * targetSize.x()].setValue(0, *output);
3767 reference[x + y * targetSize.x()].setUndefined(0);
3774 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3775 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3776 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
3778 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3779 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3780 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3781 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3783 if (tcu::hasStencilComponent(format.order))
3785 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3786 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3788 const size_t index = subpassNdx;
3789 reference[x + y * targetSize.x()].setValue(1, (index % 2) == 0);
3797 // Mark all attachments that were used but not stored as undefined
3798 for (size_t attachmentIndex = 0; attachmentIndex < renderPassInfo.getAttachments().size(); attachmentIndex++)
3800 const Attachment attachment = renderPassInfo.getAttachments()[attachmentIndex];
3801 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3802 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3803 const bool isStencilAttachment = hasStencilComponent(format.order);
3804 const bool isDepthOrStencilAttachment = hasDepthComponent(format.order) || isStencilAttachment;
3806 if (attachmentUsed[attachmentIndex] && renderPassInfo.getAttachments()[attachmentIndex].getStoreOp() == VK_ATTACHMENT_STORE_OP_DONT_CARE)
3808 if (isDepthOrStencilAttachment)
3809 markUndefined(reference, BVec4(true, false, false, false), targetSize, renderPos, renderSize);
3811 markUndefined(reference, BVec4(true), targetSize, renderPos, renderSize);
3814 if (attachmentUsed[attachmentIndex] && isStencilAttachment && renderPassInfo.getAttachments()[attachmentIndex].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_DONT_CARE)
3815 markUndefined(reference, BVec4(false, true, false, false), targetSize, renderPos, renderSize);
3819 void renderReferenceImagesFromValues (vector<tcu::TextureLevel>& referenceImages,
3820 const vector<vector<PixelValue> >& referenceValues,
3821 const UVec2& targetSize,
3822 const RenderPass& renderPassInfo,
3823 const DepthValuesArray& depthValues)
3825 referenceImages.resize(referenceValues.size());
3827 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
3829 const Attachment attachment = renderPassInfo.getAttachments()[attachmentNdx];
3830 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3831 const vector<PixelValue>& reference = referenceValues[attachmentNdx];
3832 const bool hasDepth = tcu::hasDepthComponent(format.order);
3833 const bool hasStencil = tcu::hasStencilComponent(format.order);
3834 const bool hasDepthOrStencil = hasDepth || hasStencil;
3835 tcu::TextureLevel& referenceImage = referenceImages[attachmentNdx];
3837 referenceImage.setStorage(format, targetSize.x(), targetSize.y());
3839 if (hasDepthOrStencil)
3843 const PixelBufferAccess depthAccess (tcu::getEffectiveDepthStencilAccess(referenceImage.getAccess(), tcu::Sampler::MODE_DEPTH));
3845 for (deUint32 y = 0; y < targetSize.y(); y++)
3846 for (deUint32 x = 0; x < targetSize.x(); x++)
3848 if (reference[x + y * targetSize.x()].getValue(0))
3850 if (*reference[x + y * targetSize.x()].getValue(0))
3851 depthAccess.setPixDepth(float(depthValues[1]) / 255.0f, x, y);
3853 depthAccess.setPixDepth(float(depthValues[0]) / 255.0f, x, y);
3855 else // Fill with 3x3 grid
3856 depthAccess.setPixDepth(((x / 3) % 2) == ((y / 3) % 2) ? 0.33f : 0.66f, x, y);
3862 const PixelBufferAccess stencilAccess (tcu::getEffectiveDepthStencilAccess(referenceImage.getAccess(), tcu::Sampler::MODE_STENCIL));
3864 for (deUint32 y = 0; y < targetSize.y(); y++)
3865 for (deUint32 x = 0; x < targetSize.x(); x++)
3867 if (reference[x + y * targetSize.x()].getValue(1))
3869 if (*reference[x + y * targetSize.x()].getValue(1))
3870 stencilAccess.setPixStencil(0xFFu, x, y);
3872 stencilAccess.setPixStencil(0x0u, x, y);
3874 else // Fill with 3x3 grid
3875 stencilAccess.setPixStencil(((x / 3) % 2) == ((y / 3) % 2) ? 85 : 170, x, y);
3881 for (deUint32 y = 0; y < targetSize.y(); y++)
3882 for (deUint32 x = 0; x < targetSize.x(); x++)
3886 for (int compNdx = 0; compNdx < 4; compNdx++)
3888 if (reference[x + y * targetSize.x()].getValue(compNdx))
3890 if (*reference[x + y * targetSize.x()].getValue(compNdx))
3891 color[compNdx] = 1.0f;
3893 color[compNdx] = 0.0f;
3895 else // Fill with 3x3 grid
3896 color[compNdx] = ((compNdx + (x / 3)) % 2) == ((y / 3) % 2) ? 0.33f : 0.66f;
3899 referenceImage.getAccess().setPixel(color, x, y);
3905 bool verifyColorAttachment (const vector<PixelValue>& reference,
3906 const ConstPixelBufferAccess& result,
3907 const PixelBufferAccess& errorImage,
3908 const deBool useFormatCompCount)
3910 const Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
3911 const Vec4 green (0.0f, 1.0f, 0.0f, 1.0f);
3914 DE_ASSERT(result.getWidth() * result.getHeight() == (int)reference.size());
3915 DE_ASSERT(result.getWidth() == errorImage.getWidth());
3916 DE_ASSERT(result.getHeight() == errorImage.getHeight());
3918 for (int y = 0; y < result.getHeight(); y++)
3919 for (int x = 0; x < result.getWidth(); x++)
3921 const Vec4 resultColor = result.getPixel(x, y);
3922 const PixelValue& referenceValue = reference[x + y * result.getWidth()];
3923 bool pixelOk = true;
3924 const deUint32 componentCount = useFormatCompCount ? (deUint32)tcu::getNumUsedChannels(result.getFormat().order) : 4;
3926 for (deUint32 compNdx = 0; compNdx < componentCount; compNdx++)
3928 const Maybe<bool> maybeValue = referenceValue.getValue(compNdx);
3932 const bool value = *maybeValue;
3934 if ((value && (resultColor[compNdx] != 1.0f))
3935 || (!value && resultColor[compNdx] != 0.0f))
3942 errorImage.setPixel(red, x, y);
3946 errorImage.setPixel(green, x, y);
3952 // Setting the alpha value to 1.0f by default helps visualization when the alpha channel is not used.
3953 const tcu::Vec4 kDefaultColorForLog {0.0f, 0.0f, 0.0f, 1.0f};
3954 const float kTrueComponent = 1.0f;
3955 const float kFalseComponent = 0.5f;
3956 const float kUnsetComponentLow = 0.0f;
3957 const float kUnsetComponentHigh = 0.25f;
3959 std::unique_ptr<tcu::TextureLevel> renderColorImageForLog (const ConstPixelBufferAccess& image, int numChannels)
3961 // Same channel order, but using UNORM_INT8 for the color format.
3962 const auto order = image.getFormat().order;
3963 const tcu::TextureFormat loggableFormat {order, tcu::TextureFormat::UNORM_INT8};
3964 const int width = image.getWidth();
3965 const int height = image.getHeight();
3966 std::unique_ptr<tcu::TextureLevel> result {new tcu::TextureLevel{loggableFormat, width, height}};
3967 auto access = result->getAccess();
3968 tcu::Vec4 outColor = kDefaultColorForLog;
3970 for (int x = 0; x < width; ++x)
3971 for (int y = 0; y < height; ++y)
3973 const auto value = image.getPixel(x, y);
3974 for (int c = 0; c < numChannels; ++c)
3976 if (value[c] == 0.0f)
3977 outColor[c] = kFalseComponent;
3978 else if (value[c] == 1.0f)
3979 outColor[c] = kTrueComponent;
3983 access.setPixel(outColor, x, y);
3989 std::unique_ptr<tcu::TextureLevel> renderColorImageForLog (const vector<PixelValue>& reference, const UVec2& targetSize, int numChannels)
3991 const tcu::TextureFormat loggableFormat {tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8};
3992 const int width = static_cast<int>(targetSize.x());
3993 const int height = static_cast<int>(targetSize.y());
3994 std::unique_ptr<tcu::TextureLevel> result {new tcu::TextureLevel{loggableFormat, width, height}};
3995 auto access = result->getAccess();
3996 tcu::Vec4 outColor = kDefaultColorForLog;
3998 for (int x = 0; x < width; ++x)
3999 for (int y = 0; y < height; ++y)
4001 const int index = x + y * width;
4002 for (int c = 0; c < numChannels; ++c)
4004 const auto maybeValue = reference[index].getValue(c);
4006 outColor[c] = ((*maybeValue) ? kTrueComponent : kFalseComponent);
4008 outColor[c] = ((((x / 3) % 2) == ((y / 3) % 2)) ? kUnsetComponentLow : kUnsetComponentHigh);
4010 access.setPixel(outColor, x, y);
4016 bool verifyDepthAttachment (const vector<PixelValue>& reference,
4017 const ConstPixelBufferAccess& result,
4018 const PixelBufferAccess& errorImage,
4019 const DepthValuesArray& depthValues,
4022 const Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
4023 const Vec4 green (0.0f, 1.0f, 0.0f, 1.0f);
4026 DE_ASSERT(result.getWidth() * result.getHeight() == (int)reference.size());
4027 DE_ASSERT(result.getWidth() == errorImage.getWidth());
4028 DE_ASSERT(result.getHeight() == errorImage.getHeight());
4030 for (int y = 0; y < result.getHeight(); y++)
4031 for (int x = 0; x < result.getWidth(); x++)
4033 bool pixelOk = true;
4035 const float resultDepth = result.getPixDepth(x, y);
4036 const PixelValue& referenceValue = reference[x + y * result.getWidth()];
4037 const Maybe<bool> maybeValue = referenceValue.getValue(0);
4041 const bool value = *maybeValue;
4043 if ((value && !depthsEqual(resultDepth, float(depthValues[1]) / 255.0f, epsilon))
4044 || (!value && !depthsEqual(resultDepth, float(depthValues[0]) / 255.0f, epsilon)))
4050 errorImage.setPixel(red, x, y);
4054 errorImage.setPixel(green, x, y);
4060 bool verifyStencilAttachment (const vector<PixelValue>& reference,
4061 const ConstPixelBufferAccess& result,
4062 const PixelBufferAccess& errorImage)
4064 const Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
4065 const Vec4 green (0.0f, 1.0f, 0.0f, 1.0f);
4068 DE_ASSERT(result.getWidth() * result.getHeight() == (int)reference.size());
4069 DE_ASSERT(result.getWidth() == errorImage.getWidth());
4070 DE_ASSERT(result.getHeight() == errorImage.getHeight());
4072 for (int y = 0; y < result.getHeight(); y++)
4073 for (int x = 0; x < result.getWidth(); x++)
4075 bool pixelOk = true;
4077 const deUint32 resultStencil = result.getPixStencil(x, y);
4078 const PixelValue& referenceValue = reference[x + y * result.getWidth()];
4079 const Maybe<bool> maybeValue = referenceValue.getValue(1);
4083 const bool value = *maybeValue;
4085 if ((value && (resultStencil != 0xFFu))
4086 || (!value && resultStencil != 0x0u))
4092 errorImage.setPixel(red, x, y);
4096 errorImage.setPixel(green, x, y);
4102 bool logAndVerifyImages (TestLog& log,
4103 const DeviceInterface& vk,
4105 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
4106 const vector<bool>& attachmentIsLazy,
4107 const RenderPass& renderPassInfo,
4108 const vector<Maybe<VkClearValue> >& renderPassClearValues,
4109 const vector<Maybe<VkClearValue> >& imageClearValues,
4110 const vector<SubpassRenderInfo>& subpassRenderInfo,
4111 const UVec2& targetSize,
4112 const TestConfig& config)
4114 vector<vector<PixelValue> > referenceValues;
4115 vector<tcu::TextureLevel> referenceAttachments;
4118 log << TestLog::Message << "Reference images fill undefined pixels with 3x3 grid pattern." << TestLog::EndMessage;
4120 renderReferenceValues(referenceValues, renderPassInfo, targetSize, imageClearValues, renderPassClearValues, subpassRenderInfo, config.renderPos, config.renderSize, config.drawStartNdx, config.depthValues);
4121 renderReferenceImagesFromValues(referenceAttachments, referenceValues, targetSize, renderPassInfo, config.depthValues);
4123 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
4125 if (!attachmentIsLazy[attachmentNdx])
4127 bool attachmentOK = true;
4128 const Attachment attachment = renderPassInfo.getAttachments()[attachmentNdx];
4129 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4131 if (tcu::hasDepthComponent(format.order) && tcu::hasStencilComponent(format.order))
4133 const tcu::TextureFormat depthFormat = getDepthCopyFormat(attachment.getFormat());
4134 void* const depthPtr = attachmentResources[attachmentNdx]->getResultMemory().getHostPtr();
4136 const tcu::TextureFormat stencilFormat = getStencilCopyFormat(attachment.getFormat());
4137 void* const stencilPtr = attachmentResources[attachmentNdx]->getSecondaryResultMemory().getHostPtr();
4139 invalidateAlloc(vk, device, attachmentResources[attachmentNdx]->getResultMemory());
4140 invalidateAlloc(vk, device, attachmentResources[attachmentNdx]->getSecondaryResultMemory());
4143 bool depthOK = true;
4144 bool stencilOK = true;
4145 const ConstPixelBufferAccess depthAccess (depthFormat, targetSize.x(), targetSize.y(), 1, depthPtr);
4146 const ConstPixelBufferAccess stencilAccess (stencilFormat, targetSize.x(), targetSize.y(), 1, stencilPtr);
4147 tcu::TextureLevel depthErrorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
4148 tcu::TextureLevel stencilErrorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
4150 if (renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE
4151 && !verifyDepthAttachment(referenceValues[attachmentNdx], depthAccess, depthErrorImage.getAccess(), config.depthValues, requiredDepthEpsilon(attachment.getFormat())))
4156 if (renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE
4157 && !verifyStencilAttachment(referenceValues[attachmentNdx], stencilAccess, stencilErrorImage.getAccess()))
4162 if (!depthOK || !stencilOK)
4164 const auto attachmentNdxStr = de::toString(attachmentNdx);
4167 log << TestLog::ImageSet("OutputAttachments" + attachmentNdxStr, "Output depth and stencil attachments " + attachmentNdxStr);
4168 log << TestLog::Image("Attachment" + attachmentNdxStr + "Depth", "Attachment " + attachmentNdxStr + " Depth", depthAccess);
4169 log << TestLog::Image("Attachment" + attachmentNdxStr + "Stencil", "Attachment " + attachmentNdxStr + " Stencil", stencilAccess);
4170 log << TestLog::EndImageSet;
4172 // Reference images. These will be logged as image sets due to having depth and stencil aspects.
4173 log << TestLog::Image("AttachmentReferences" + attachmentNdxStr, "Reference images " + attachmentNdxStr, referenceAttachments[attachmentNdx].getAccess());
4176 log << TestLog::ImageSet("ErrorMasks" + attachmentNdxStr, "Error masks " + attachmentNdxStr);
4178 log << TestLog::Image("DepthAttachmentError" + attachmentNdxStr, "Depth Attachment Error " + attachmentNdxStr, depthErrorImage.getAccess());
4180 log << TestLog::Image("StencilAttachmentError" + attachmentNdxStr, "Stencil Attachment Error " + attachmentNdxStr, stencilErrorImage.getAccess());
4181 log << TestLog::EndImageSet;
4183 attachmentOK = false;
4189 void* const ptr = attachmentResources[attachmentNdx]->getResultMemory().getHostPtr();
4191 invalidateAlloc(vk, device, attachmentResources[attachmentNdx]->getResultMemory());
4193 bool depthOK = true;
4194 bool stencilOK = true;
4195 bool colorOK = true;
4196 const ConstPixelBufferAccess access (format, targetSize.x(), targetSize.y(), 1, ptr);
4197 tcu::TextureLevel errorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
4199 if (tcu::hasDepthComponent(format.order))
4201 if ((renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE || renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE)
4202 && !verifyDepthAttachment(referenceValues[attachmentNdx], access, errorImage.getAccess(), config.depthValues, requiredDepthEpsilon(attachment.getFormat())))
4207 else if (tcu::hasStencilComponent(format.order))
4209 if ((renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE || renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE)
4210 && !verifyStencilAttachment(referenceValues[attachmentNdx], access, errorImage.getAccess()))
4217 if ((renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE || renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE)
4218 && !verifyColorAttachment(referenceValues[attachmentNdx], access, errorImage.getAccess(), config.useFormatCompCount))
4224 if (!depthOK || !stencilOK || !colorOK)
4226 log << TestLog::ImageSet("TestImages", "Output attachment, reference image and error mask");
4227 if (!depthOK || !stencilOK)
4229 // Log without conversions.
4230 log << TestLog::Image("Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx), access);
4231 log << TestLog::Image("AttachmentReference" + de::toString(attachmentNdx), "Attachment reference " + de::toString(attachmentNdx), referenceAttachments[attachmentNdx].getAccess());
4235 // Convert color images to better reflect test status and output in any format.
4236 const auto numChannels = tcu::getNumUsedChannels(access.getFormat().order);
4237 const auto attachmentForLog = renderColorImageForLog(access, numChannels);
4238 const auto referenceForLog = renderColorImageForLog(referenceValues[attachmentNdx], targetSize, numChannels);
4240 log << TestLog::Message << "Check the attachment formats and test data to verify which components affect the test result." << TestLog::EndMessage;
4241 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;
4242 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;
4244 log << TestLog::Image("Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx), attachmentForLog->getAccess());
4245 log << TestLog::Image("AttachmentReference" + de::toString(attachmentNdx), "Attachment reference " + de::toString(attachmentNdx), referenceForLog->getAccess());
4247 log << TestLog::Image("AttachmentError" + de::toString(attachmentNdx), "Attachment Error " + de::toString(attachmentNdx), errorImage.getAccess());
4248 log << TestLog::EndImageSet;
4250 attachmentOK = false;
4262 std::string getInputAttachmentType (VkFormat vkFormat)
4264 const tcu::TextureFormat format = mapVkFormat(vkFormat);
4265 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
4267 switch (channelClass)
4269 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
4270 return "isubpassInput";
4272 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
4273 return "usubpassInput";
4275 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
4276 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
4277 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
4278 return "subpassInput";
4281 DE_FATAL("Unknown channel class");
4286 std::string getAttachmentType (VkFormat vkFormat, deBool useFormatCompCount)
4288 const tcu::TextureFormat format = mapVkFormat(vkFormat);
4289 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
4290 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4292 switch (channelClass)
4294 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
4295 if (useFormatCompCount)
4296 return (componentCount == 1 ? "int" : "ivec" + de::toString(componentCount));
4300 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
4301 if (useFormatCompCount)
4302 return (componentCount == 1 ? "uint" : "uvec" + de::toString(componentCount));
4306 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
4307 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
4308 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
4309 if (useFormatCompCount)
4310 return (componentCount == 1 ? "float" : "vec" + de::toString(componentCount));
4315 DE_FATAL("Unknown channel class");
4320 void createTestShaders (SourceCollections& dst, TestConfig config)
4322 if (config.renderTypes & TestConfig::RENDERTYPES_DRAW)
4324 const vector<Subpass>& subpasses = config.renderPass.getSubpasses();
4326 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
4328 const Subpass& subpass = subpasses[subpassNdx];
4329 deUint32 inputAttachmentBinding = 0;
4330 std::ostringstream vertexShader;
4331 std::ostringstream fragmentShader;
4333 vertexShader << "#version 310 es\n"
4334 << "layout(location = 0) in highp vec2 a_position;\n"
4335 << "void main (void) {\n"
4336 << "\tgl_Position = vec4(a_position, 1.0, 1.0);\n"
4339 fragmentShader << "#version 310 es\n"
4340 << "precision highp float;\n";
4342 bool hasAnyDepthFormats = false;
4344 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
4346 const deUint32 attachmentIndex = subpass.getInputAttachments()[attachmentNdx].getAttachment();
4347 const VkImageLayout layout = subpass.getInputAttachments()[attachmentNdx].getImageLayout();
4348 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4349 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4350 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
4351 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
4353 if (isDepthFormat || isStencilFormat)
4355 if (isDepthFormat && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
4357 hasAnyDepthFormats = true;
4358 fragmentShader << "layout(input_attachment_index = " << attachmentNdx << ", set=0, binding=" << inputAttachmentBinding << ") uniform highp subpassInput i_depth" << attachmentNdx << ";\n";
4359 inputAttachmentBinding++;
4362 if (isStencilFormat && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4364 fragmentShader << "layout(input_attachment_index = " << attachmentNdx << ", set=0, binding=" << inputAttachmentBinding << ") uniform highp usubpassInput i_stencil" << attachmentNdx << ";\n";
4365 inputAttachmentBinding++;
4370 const std::string attachmentType = getInputAttachmentType(attachment.getFormat());
4372 fragmentShader << "layout(input_attachment_index = " << attachmentNdx << ", set=0, binding=" << inputAttachmentBinding << ") uniform highp " << attachmentType << " i_color" << attachmentNdx << ";\n";
4373 inputAttachmentBinding++;
4377 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
4379 const std::string attachmentType = getAttachmentType(config.renderPass.getAttachments()[getAttachmentNdx(subpass.getColorAttachments(), attachmentNdx)].getFormat(), config.useFormatCompCount);
4380 fragmentShader << "layout(location = " << attachmentNdx << ") out highp " << attachmentType << " o_color" << attachmentNdx << ";\n";
4383 if (hasAnyDepthFormats)
4384 fragmentShader << "\nbool depthsEqual(float a, float b, float epsilon) {\n"
4385 << "\treturn abs(a - b) <= epsilon;\n}\n\n";
4387 fragmentShader << "void main (void) {\n";
4389 if (subpass.getInputAttachments().empty())
4391 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
4393 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentNdx].getAttachment();
4395 if (attachmentIndex == VK_ATTACHMENT_UNUSED)
4398 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4399 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4400 const size_t componentCount = config.useFormatCompCount ? (size_t)tcu::getNumUsedChannels(format.order) : 4;
4401 const std::string attachmentType = getAttachmentType(attachment.getFormat(), config.useFormatCompCount);
4403 fragmentShader << "\to_color" << attachmentNdx << " = " << attachmentType << "(" << attachmentType + "(";
4405 for (size_t compNdx = 0; compNdx < componentCount; compNdx++)
4407 const size_t index = subpassNdx + attachmentIndex + compNdx;
4408 const BoolOp op = boolOpFromIndex(index);
4411 fragmentShader << ",\n\t\t";
4413 fragmentShader << "((int(gl_FragCoord.x) % 2 == " << (index % 2)
4414 << ") " << boolOpToString(op) << " ("
4415 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
4416 << ") ? 1.0 : 0.0)";
4419 fragmentShader << "));\n";
4422 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
4423 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
4424 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4426 const size_t index = subpassNdx + 1;
4427 const BoolOp op = boolOpFromIndex(index);
4429 fragmentShader << "\tgl_FragDepth = ((int(gl_FragCoord.x) % 2 == " << (index % 2)
4430 << ") " << boolOpToString(op) << " ("
4431 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
4432 << ") ? " << deUint32(config.depthValues[1]) << ".0f/255.0f : " << deUint32(config.depthValues[0]) << ".0f/255.0f);\n";
4437 size_t inputComponentCount = 0;
4438 size_t outputComponentCount = 0;
4440 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
4442 const deUint32 attachmentIndex = subpass.getInputAttachments()[attachmentNdx].getAttachment();
4443 const VkImageLayout layout = subpass.getInputAttachments()[attachmentNdx].getImageLayout();
4444 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4445 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4446 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4448 if (layout == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4449 inputComponentCount += 1;
4450 else if (layout == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
4451 inputComponentCount += 1;
4453 inputComponentCount += componentCount;
4456 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
4458 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentNdx].getAttachment();
4459 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4460 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4461 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4463 outputComponentCount += componentCount;
4466 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
4467 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
4468 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4470 outputComponentCount++;
4473 if (outputComponentCount > 0)
4475 const size_t inputsPerOutput = inputComponentCount >= outputComponentCount
4476 ? ((inputComponentCount / outputComponentCount)
4477 + ((inputComponentCount % outputComponentCount) != 0 ? 1 : 0))
4480 fragmentShader << "\tbool inputs[" << inputComponentCount << "];\n";
4482 if (outputComponentCount > 0)
4483 fragmentShader << "\tbool outputs[" << outputComponentCount << "];\n";
4485 size_t inputValueNdx = 0;
4487 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
4489 const char* const components[] =
4493 const deUint32 attachmentIndex = subpass.getInputAttachments()[attachmentNdx].getAttachment();
4494 const VkImageLayout layout = subpass.getInputAttachments()[attachmentNdx].getImageLayout();
4495 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4496 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4497 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4498 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
4499 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
4501 if (isDepthFormat || isStencilFormat)
4503 if (isDepthFormat && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL)
4505 fragmentShader << "\tinputs[" << inputValueNdx << "] = depthsEqual(" << deUint32(config.depthValues[1]) <<
4506 ".0f/255.0f, float(subpassLoad(i_depth" << attachmentNdx << ").x), " <<
4507 std::fixed << std::setprecision(12) << requiredDepthEpsilon(attachment.getFormat()) << ");\n";
4511 if (isStencilFormat && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4513 fragmentShader << "\tinputs[" << inputValueNdx << "] = 255u == subpassLoad(i_stencil" << attachmentNdx << ").x;\n";
4519 for (size_t compNdx = 0; compNdx < componentCount; compNdx++)
4521 fragmentShader << "\tinputs[" << inputValueNdx << "] = 1.0 == float(subpassLoad(i_color" << attachmentNdx << ")." << components[compNdx] << ");\n";
4527 size_t outputValueNdx = 0;
4529 for (size_t attachmentNdx = config.drawStartNdx; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
4531 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentNdx].getAttachment();
4532 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
4533 const std::string attachmentType = getAttachmentType(config.renderPass.getAttachments()[attachmentIndex].getFormat(), config.useFormatCompCount);
4534 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4535 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
4537 for (size_t compNdx = 0; compNdx < componentCount; compNdx++)
4539 const size_t index = subpassNdx + attachmentIndex + outputValueNdx;
4540 const BoolOp op = boolOpFromIndex(index);
4542 fragmentShader << "\toutputs[" << outputValueNdx + compNdx << "] = "
4543 << "(int(gl_FragCoord.x) % 2 == " << (index % 2)
4544 << ") " << boolOpToString(op) << " ("
4545 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
4548 for (size_t i = 0; i < inputsPerOutput; i++)
4549 fragmentShader << "\toutputs[" << outputValueNdx + compNdx << "] = outputs[" << outputValueNdx + compNdx << "] == inputs[" << ((outputValueNdx + compNdx) * inputsPerOutput + i) % inputComponentCount << "];\n";
4552 fragmentShader << "\to_color" << attachmentNdx << " = " << attachmentType << "(";
4554 for (size_t compNdx = 0; compNdx < (config.useFormatCompCount ? componentCount : 4); compNdx++)
4557 fragmentShader << ", ";
4559 if (compNdx < componentCount)
4560 fragmentShader << "outputs[" << outputValueNdx + compNdx << "]";
4562 fragmentShader << "0";
4565 outputValueNdx += componentCount;
4567 fragmentShader << ");\n";
4570 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
4571 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
4572 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
4574 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
4575 const size_t index = subpassNdx + attachmentIndex;
4576 const BoolOp op = boolOpFromIndex(index);
4578 fragmentShader << "\toutputs[" << outputValueNdx << "] = "
4579 << "(int(gl_FragCoord.x) % 2 == " << (index % 2)
4580 << ") " << boolOpToString(op) << " ("
4581 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
4584 for (size_t i = 0; i < inputsPerOutput; i++)
4585 fragmentShader << "\toutputs[" << outputValueNdx << "] = outputs[" << outputValueNdx << "] == inputs[" << (outputValueNdx * inputsPerOutput + i) % inputComponentCount << "];\n";
4587 fragmentShader << "\tgl_FragDepth = outputs[" << outputValueNdx << "] ? " << deUint32(config.depthValues[1]) << ".0f/255.0f : " << deUint32(config.depthValues[0]) << ".0f/255.0f;\n";
4592 fragmentShader << "}\n";
4594 dst.glslSources.add(de::toString(subpassNdx) + "-vert") << glu::VertexSource(vertexShader.str());
4595 dst.glslSources.add(de::toString(subpassNdx) + "-frag") << glu::FragmentSource(fragmentShader.str());
4600 void initializeAttachmentIsLazy (vector<bool>& attachmentIsLazy, const vector<Attachment>& attachments, TestConfig::ImageMemory imageMemory)
4602 bool lastAttachmentWasLazy = false;
4604 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4606 if (attachments[attachmentNdx].getLoadOp() != VK_ATTACHMENT_LOAD_OP_LOAD
4607 && attachments[attachmentNdx].getStoreOp() != VK_ATTACHMENT_STORE_OP_STORE
4608 && attachments[attachmentNdx].getStencilLoadOp() != VK_ATTACHMENT_LOAD_OP_LOAD
4609 && attachments[attachmentNdx].getStencilStoreOp() != VK_ATTACHMENT_STORE_OP_STORE)
4611 if (imageMemory == TestConfig::IMAGEMEMORY_LAZY || (imageMemory & TestConfig::IMAGEMEMORY_LAZY && !lastAttachmentWasLazy))
4613 attachmentIsLazy.push_back(true);
4615 lastAttachmentWasLazy = true;
4617 else if (imageMemory & TestConfig::IMAGEMEMORY_STRICT)
4619 attachmentIsLazy.push_back(false);
4620 lastAttachmentWasLazy = false;
4623 DE_FATAL("Unknown imageMemory");
4626 attachmentIsLazy.push_back(false);
4630 enum AttachmentRefType
4632 ATTACHMENTREFTYPE_COLOR,
4633 ATTACHMENTREFTYPE_DEPTH_STENCIL,
4634 ATTACHMENTREFTYPE_INPUT,
4635 ATTACHMENTREFTYPE_RESOLVE,
4638 VkImageUsageFlags getImageUsageFromLayout (VkImageLayout layout)
4642 case VK_IMAGE_LAYOUT_GENERAL:
4643 case VK_IMAGE_LAYOUT_PREINITIALIZED:
4646 case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
4647 return VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4649 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
4650 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL:
4651 return VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
4653 case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
4654 return VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
4656 case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
4657 return VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
4659 case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
4660 return VK_IMAGE_USAGE_TRANSFER_DST_BIT;
4663 DE_FATAL("Unexpected image layout");
4668 void getImageUsageFromAttachmentReferences(vector<VkImageUsageFlags>& attachmentImageUsage, AttachmentRefType refType, size_t count, const AttachmentReference* references)
4670 for (size_t referenceNdx = 0; referenceNdx < count; ++referenceNdx)
4672 const deUint32 attachment = references[referenceNdx].getAttachment();
4674 if (attachment != VK_ATTACHMENT_UNUSED)
4676 VkImageUsageFlags usage;
4680 case ATTACHMENTREFTYPE_COLOR:
4681 case ATTACHMENTREFTYPE_RESOLVE:
4682 usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4685 case ATTACHMENTREFTYPE_DEPTH_STENCIL:
4686 usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
4689 case ATTACHMENTREFTYPE_INPUT:
4690 usage = VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
4694 DE_FATAL("Unexpected attachment reference type");
4699 attachmentImageUsage[attachment] |= usage;
4704 void getImageUsageFromAttachmentReferences(vector<VkImageUsageFlags>& attachmentImageUsage, AttachmentRefType refType, const vector<AttachmentReference>& references)
4706 if (!references.empty())
4708 getImageUsageFromAttachmentReferences(attachmentImageUsage, refType, references.size(), &references[0]);
4712 void initializeAttachmentImageUsage (Context &context, vector<VkImageUsageFlags>& attachmentImageUsage, const RenderPass& renderPassInfo, const vector<bool>& attachmentIsLazy, const vector<Maybe<VkClearValue> >& clearValues)
4714 attachmentImageUsage.resize(renderPassInfo.getAttachments().size(), VkImageUsageFlags(0));
4716 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); ++subpassNdx)
4718 const Subpass& subpass = renderPassInfo.getSubpasses()[subpassNdx];
4720 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_COLOR, subpass.getColorAttachments());
4721 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_DEPTH_STENCIL, 1, &subpass.getDepthStencilAttachment());
4722 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_INPUT, subpass.getInputAttachments());
4723 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_RESOLVE, subpass.getResolveAttachments());
4726 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
4728 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentNdx];
4729 const VkFormatProperties formatProperties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), attachment.getFormat());
4730 const VkFormatFeatureFlags supportedFeatures = formatProperties.optimalTilingFeatures;
4732 if ((supportedFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0)
4733 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_SAMPLED_BIT;
4735 if ((supportedFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) != 0)
4736 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_STORAGE_BIT;
4738 attachmentImageUsage[attachmentNdx] |= getImageUsageFromLayout(attachment.getInitialLayout());
4739 attachmentImageUsage[attachmentNdx] |= getImageUsageFromLayout(attachment.getFinalLayout());
4741 if (!attachmentIsLazy[attachmentNdx])
4743 if (clearValues[attachmentNdx])
4744 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
4746 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
4750 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);
4752 attachmentImageUsage[attachmentNdx] &= allowedTransientBits;
4753 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4758 void initializeSubpassIsSecondary (vector<bool>& subpassIsSecondary, const vector<Subpass>& subpasses, TestConfig::CommandBufferTypes commandBuffer)
4760 bool lastSubpassWasSecondary = false;
4762 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
4764 if (commandBuffer == TestConfig::COMMANDBUFFERTYPES_SECONDARY || (commandBuffer & TestConfig::COMMANDBUFFERTYPES_SECONDARY && !lastSubpassWasSecondary))
4766 subpassIsSecondary.push_back(true);
4767 lastSubpassWasSecondary = true;
4769 else if (commandBuffer & TestConfig::COMMANDBUFFERTYPES_INLINE)
4771 subpassIsSecondary.push_back(false);
4772 lastSubpassWasSecondary = false;
4775 DE_FATAL("Unknown commandBuffer");
4779 void initializeImageClearValues (de::Random& rng, vector<Maybe<VkClearValue> >& clearValues, const vector<Attachment>& attachments, const vector<bool>& isLazy, deBool useFormatCompCount, const DepthValuesArray& depthValues)
4781 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4783 if (!isLazy[attachmentNdx])
4784 clearValues.push_back(just(randomClearValue(attachments[attachmentNdx], rng, useFormatCompCount, depthValues)));
4786 clearValues.push_back(tcu::Nothing);
4790 void initializeRenderPassClearValues (de::Random& rng, vector<Maybe<VkClearValue> >& clearValues, const vector<Attachment>& attachments, deBool useFormatCompCount, const DepthValuesArray& depthValues)
4792 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4794 if (attachments[attachmentNdx].getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR
4795 || attachments[attachmentNdx].getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
4797 clearValues.push_back(just(randomClearValue(attachments[attachmentNdx], rng, useFormatCompCount, depthValues)));
4800 clearValues.push_back(tcu::Nothing);
4804 void logSubpassRenderInfo (TestLog& log, const SubpassRenderInfo& info, TestConfig config)
4806 log << TestLog::Message << "Viewport, offset: " << info.getViewportOffset() << ", size: " << info.getViewportSize() << TestLog::EndMessage;
4808 if (info.isSecondary())
4809 log << TestLog::Message << "Subpass uses secondary command buffers" << TestLog::EndMessage;
4811 log << TestLog::Message << "Subpass uses inlined commands" << TestLog::EndMessage;
4813 for (deUint32 attachmentNdx = 0; attachmentNdx < info.getColorClears().size(); attachmentNdx++)
4815 const ColorClear& colorClear = info.getColorClears()[attachmentNdx];
4817 log << TestLog::Message << "Clearing color attachment " << attachmentNdx
4818 << ". Offset: " << colorClear.getOffset()
4819 << ", Size: " << colorClear.getSize()
4820 << ", Color: " << clearColorToString(info.getColorAttachment(attachmentNdx).getFormat(), colorClear.getColor(), config.useFormatCompCount) << TestLog::EndMessage;
4823 if (info.getDepthStencilClear())
4825 const DepthStencilClear& depthStencilClear = *info.getDepthStencilClear();
4827 log << TestLog::Message << "Clearing depth stencil attachment"
4828 << ". Offset: " << depthStencilClear.getOffset()
4829 << ", Size: " << depthStencilClear.getSize()
4830 << ", Depth: " << depthStencilClear.getDepth()
4831 << ", Stencil: " << depthStencilClear.getStencil() << TestLog::EndMessage;
4834 if (info.getRenderQuad())
4836 const RenderQuad& renderQuad = *info.getRenderQuad();
4838 log << TestLog::Message << "Rendering grid quad to " << renderQuad.getCornerA() << " -> " << renderQuad.getCornerB() << TestLog::EndMessage;
4842 void logTestCaseInfo (TestLog& log,
4843 const TestConfig& config,
4844 const vector<bool>& attachmentIsLazy,
4845 const vector<Maybe<VkClearValue> >& imageClearValues,
4846 const vector<Maybe<VkClearValue> >& renderPassClearValues,
4847 const vector<SubpassRenderInfo>& subpassRenderInfo)
4849 const RenderPass& renderPass = config.renderPass;
4851 logRenderPassInfo(log, renderPass);
4853 DE_ASSERT(attachmentIsLazy.size() == renderPass.getAttachments().size());
4854 DE_ASSERT(imageClearValues.size() == renderPass.getAttachments().size());
4855 DE_ASSERT(renderPassClearValues.size() == renderPass.getAttachments().size());
4857 log << TestLog::Message << "TargetSize: " << config.targetSize << TestLog::EndMessage;
4858 log << TestLog::Message << "Render area, Offset: " << config.renderPos << ", Size: " << config.renderSize << TestLog::EndMessage;
4860 for (size_t attachmentNdx = 0; attachmentNdx < attachmentIsLazy.size(); attachmentNdx++)
4862 const tcu::ScopedLogSection section (log, "Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx));
4864 if (attachmentIsLazy[attachmentNdx])
4865 log << TestLog::Message << "Is lazy." << TestLog::EndMessage;
4867 if (imageClearValues[attachmentNdx])
4868 log << TestLog::Message << "Image is cleared to " << clearValueToString(renderPass.getAttachments()[attachmentNdx].getFormat(),
4869 *imageClearValues[attachmentNdx], config.useFormatCompCount) << " before rendering." << TestLog::EndMessage;
4871 if (renderPass.getAttachments()[attachmentNdx].getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR && renderPassClearValues[attachmentNdx])
4872 log << TestLog::Message << "Attachment is cleared to " << clearValueToString(renderPass.getAttachments()[attachmentNdx].getFormat(),
4873 *renderPassClearValues[attachmentNdx], config.useFormatCompCount) << " in the beginning of the render pass." << TestLog::EndMessage;
4876 for (size_t subpassNdx = 0; subpassNdx < renderPass.getSubpasses().size(); subpassNdx++)
4878 const tcu::ScopedLogSection section (log, "Subpass" + de::toString(subpassNdx), "Subpass " + de::toString(subpassNdx));
4880 logSubpassRenderInfo(log, subpassRenderInfo[subpassNdx], config);
4884 float roundToViewport (float x, deUint32 offset, deUint32 size)
4886 const float origin = (float)(offset) + ((float(size) / 2.0f));
4887 const float p = (float)(size) / 2.0f;
4888 const deInt32 xi = deRoundFloatToInt32(origin + (p * x));
4890 return (((float)xi) - origin) / p;
4893 void initializeSubpassRenderInfo (vector<SubpassRenderInfo>& renderInfos, de::Random& rng, const RenderPass& renderPass, const TestConfig& config)
4895 const TestConfig::CommandBufferTypes commandBuffer = config.commandBufferTypes;
4896 const vector<Subpass>& subpasses = renderPass.getSubpasses();
4897 bool lastSubpassWasSecondary = false;
4899 for (deUint32 subpassNdx = 0; subpassNdx < (deUint32)subpasses.size(); subpassNdx++)
4901 const Subpass& subpass = subpasses[subpassNdx];
4902 const bool subpassIsSecondary = commandBuffer == TestConfig::COMMANDBUFFERTYPES_SECONDARY
4903 || (commandBuffer & TestConfig::COMMANDBUFFERTYPES_SECONDARY && !lastSubpassWasSecondary) ? true : false;
4904 const bool omitBlendState = subpass.getOmitBlendState();
4905 const UVec2 viewportSize ((config.renderSize * UVec2(2)) / UVec2(3));
4906 const UVec2 viewportOffset (config.renderPos.x() + (subpassNdx % 2) * (config.renderSize.x() / 3),
4907 config.renderPos.y() + ((subpassNdx / 2) % 2) * (config.renderSize.y() / 3));
4909 vector<ColorClear> colorClears;
4910 Maybe<DepthStencilClear> depthStencilClear;
4911 Maybe<RenderQuad> renderQuad;
4913 lastSubpassWasSecondary = subpassIsSecondary;
4915 if (config.renderTypes & TestConfig::RENDERTYPES_CLEAR)
4917 const vector<AttachmentReference>& colorAttachments = subpass.getColorAttachments();
4919 for (size_t attachmentRefNdx = 0; attachmentRefNdx < colorAttachments.size(); attachmentRefNdx++)
4921 const AttachmentReference& attachmentRef = colorAttachments[attachmentRefNdx];
4922 const Attachment& attachment = renderPass.getAttachments()[attachmentRef.getAttachment()];
4923 const UVec2 size ((viewportSize * UVec2(2)) / UVec2(3));
4924 const UVec2 offset (viewportOffset.x() + ((deUint32)attachmentRefNdx % 2u) * (viewportSize.x() / 3u),
4925 viewportOffset.y() + (((deUint32)attachmentRefNdx / 2u) % 2u) * (viewportSize.y() / 3u));
4926 const VkClearColorValue color = randomColorClearValue(attachment, rng, config.useFormatCompCount);
4928 colorClears.push_back(ColorClear(offset, size, color));
4931 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
4933 const Attachment& attachment = renderPass.getAttachments()[subpass.getDepthStencilAttachment().getAttachment()];
4934 const UVec2 size ((viewportSize * UVec2(2)) / UVec2(3));
4935 const UVec2 offset (viewportOffset.x() + ((deUint32)colorAttachments.size() % 2u) * (viewportSize.x() / 3u),
4936 viewportOffset.y() + (((deUint32)colorAttachments.size() / 2u) % 2u) * (viewportSize.y() / 3u));
4937 const VkClearValue value = randomClearValue(attachment, rng, config.useFormatCompCount, config.depthValues);
4939 depthStencilClear = tcu::just(DepthStencilClear(offset, size, value.depthStencil.depth, value.depthStencil.stencil));
4943 if (config.renderTypes & TestConfig::RENDERTYPES_DRAW)
4945 const float w = (subpassNdx % 2) == 0 ? 1.0f : 1.25f;
4946 const float h = (subpassNdx % 2) == 0 ? 1.25f : 1.0f;
4948 const float x0 = roundToViewport((subpassNdx % 2) == 0 ? 1.0f - w : -1.0f, viewportOffset.x(), viewportSize.x());
4949 const float x1 = roundToViewport((subpassNdx % 2) == 0 ? 1.0f : -1.0f + w, viewportOffset.x(), viewportSize.x());
4951 const float y0 = roundToViewport(((subpassNdx / 2) % 2) == 0 ? 1.0f - h : -1.0f, viewportOffset.y(), viewportSize.y());
4952 const float y1 = roundToViewport(((subpassNdx / 2) % 2) == 0 ? 1.0f : -1.0f + h, viewportOffset.y(), viewportSize.y());
4954 renderQuad = tcu::just(RenderQuad(tcu::Vec2(x0, y0), tcu::Vec2(x1, y1)));
4957 renderInfos.push_back(SubpassRenderInfo(renderPass, subpassNdx, config.drawStartNdx, subpassIsSecondary, omitBlendState, viewportOffset, viewportSize, renderQuad, colorClears, depthStencilClear));
4961 void checkTextureFormatSupport (TestLog& log,
4962 const InstanceInterface& vk,
4963 VkPhysicalDevice device,
4964 const vector<Attachment>& attachments)
4966 bool supported = true;
4968 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4970 const Attachment& attachment = attachments[attachmentNdx];
4971 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4972 const bool isDepthOrStencilAttachment = hasDepthComponent(format.order) || hasStencilComponent(format.order);
4973 const VkFormatFeatureFlags flags = isDepthOrStencilAttachment? VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT : VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
4974 VkFormatProperties properties;
4976 vk.getPhysicalDeviceFormatProperties(device, attachment.getFormat(), &properties);
4978 if ((properties.optimalTilingFeatures & flags) != flags)
4981 log << TestLog::Message << "Format: " << attachment.getFormat() << " not supported as " << (isDepthOrStencilAttachment ? "depth stencil attachment" : "color attachment") << TestLog::EndMessage;
4986 TCU_THROW(NotSupportedError, "Format not supported");
4989 tcu::TestStatus renderPassTest (Context& context, TestConfig config)
4991 const UVec2 targetSize = config.targetSize;
4992 const UVec2 renderPos = config.renderPos;
4993 const UVec2 renderSize = config.renderSize;
4994 const RenderPass& renderPassInfo = config.renderPass;
4996 TestLog& log = context.getTestContext().getLog();
4997 de::Random rng (config.seed);
4999 vector<bool> attachmentIsLazy;
5000 vector<VkImageUsageFlags> attachmentImageUsage;
5001 vector<Maybe<VkClearValue> > imageClearValues;
5002 vector<Maybe<VkClearValue> > renderPassClearValues;
5004 vector<bool> subpassIsSecondary;
5005 vector<SubpassRenderInfo> subpassRenderInfo;
5007 if (config.renderingType == RENDERING_TYPE_RENDERPASS2)
5008 context.requireDeviceFunctionality("VK_KHR_create_renderpass2");
5010 if (config.renderingType == RENDERING_TYPE_DYNAMIC_RENDERING)
5011 context.requireDeviceFunctionality("VK_KHR_dynamic_rendering");
5013 if (config.allocationKind == ALLOCATION_KIND_DEDICATED)
5015 if (!context.isDeviceFunctionalitySupported("VK_KHR_dedicated_allocation"))
5016 TCU_THROW(NotSupportedError, "VK_KHR_dedicated_allocation is not supported");
5019 if (!renderPassInfo.getInputAspects().empty())
5021 if (!context.isDeviceFunctionalitySupported("VK_KHR_maintenance2"))
5022 TCU_THROW(NotSupportedError, "Extension VK_KHR_maintenance2 not supported.");
5026 bool requireDepthStencilLayout = false;
5028 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
5030 if (renderPassInfo.getAttachments()[attachmentNdx].getInitialLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5031 || renderPassInfo.getAttachments()[attachmentNdx].getInitialLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL
5032 || renderPassInfo.getAttachments()[attachmentNdx].getFinalLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5033 || renderPassInfo.getAttachments()[attachmentNdx].getFinalLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5035 requireDepthStencilLayout = true;
5040 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size() && !requireDepthStencilLayout; subpassNdx++)
5042 const Subpass& subpass (renderPassInfo.getSubpasses()[subpassNdx]);
5044 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
5046 if (subpass.getColorAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5047 || subpass.getColorAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5049 requireDepthStencilLayout = true;
5054 for (size_t attachmentNdx = 0; !requireDepthStencilLayout && attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
5056 if (subpass.getInputAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5057 || subpass.getInputAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5059 requireDepthStencilLayout = true;
5064 for (size_t attachmentNdx = 0; !requireDepthStencilLayout && attachmentNdx < subpass.getResolveAttachments().size(); attachmentNdx++)
5066 if (subpass.getResolveAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5067 || subpass.getResolveAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5069 requireDepthStencilLayout = true;
5074 if (subpass.getDepthStencilAttachment().getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
5075 || subpass.getDepthStencilAttachment().getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL)
5077 requireDepthStencilLayout = true;
5082 if (requireDepthStencilLayout && !context.isDeviceFunctionalitySupported("VK_KHR_maintenance2"))
5083 TCU_THROW(NotSupportedError, "VK_KHR_maintenance2 is not supported");
5086 initializeAttachmentIsLazy(attachmentIsLazy, renderPassInfo.getAttachments(), config.imageMemory);
5087 initializeImageClearValues(rng, imageClearValues, renderPassInfo.getAttachments(), attachmentIsLazy, config.useFormatCompCount, config.depthValues);
5088 initializeAttachmentImageUsage(context, attachmentImageUsage, renderPassInfo, attachmentIsLazy, imageClearValues);
5089 initializeRenderPassClearValues(rng, renderPassClearValues, renderPassInfo.getAttachments(), config.useFormatCompCount, config.depthValues);
5091 initializeSubpassIsSecondary(subpassIsSecondary, renderPassInfo.getSubpasses(), config.commandBufferTypes);
5092 initializeSubpassRenderInfo(subpassRenderInfo, rng, renderPassInfo, config);
5094 logTestCaseInfo(log, config, attachmentIsLazy, imageClearValues, renderPassClearValues, subpassRenderInfo);
5096 checkTextureFormatSupport(log, context.getInstanceInterface(), context.getPhysicalDevice(), config.renderPass.getAttachments());
5099 const vk::VkPhysicalDeviceProperties properties = vk::getPhysicalDeviceProperties(context.getInstanceInterface(), context.getPhysicalDevice());
5101 log << TestLog::Message << "Max color attachments: " << properties.limits.maxColorAttachments << TestLog::EndMessage;
5103 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); subpassNdx++)
5105 if (renderPassInfo.getSubpasses()[subpassNdx].getColorAttachments().size() > (size_t)properties.limits.maxColorAttachments)
5106 TCU_THROW(NotSupportedError, "Subpass uses more than maxColorAttachments.");
5111 const InstanceInterface& vki = context.getInstanceInterface();
5112 const VkPhysicalDevice& physDevice = context.getPhysicalDevice();
5113 const VkDevice device = context.getDevice();
5114 const DeviceInterface& vk = context.getDeviceInterface();
5115 const VkQueue queue = context.getUniversalQueue();
5116 const deUint32 queueIndex = context.getUniversalQueueFamilyIndex();
5117 Allocator& allocator = context.getDefaultAllocator();
5119 const Unique<VkCommandPool> commandBufferPool (createCommandPool(vk, device, 0, queueIndex));
5120 const Unique<VkCommandBuffer> initializeImagesCommandBuffer (allocateCommandBuffer(vk, device, *commandBufferPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
5121 const Unique<VkCommandBuffer> renderCommandBuffer (allocateCommandBuffer(vk, device, *commandBufferPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
5122 const Unique<VkCommandBuffer> readImagesToBuffersCommandBuffer (allocateCommandBuffer(vk, device, *commandBufferPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
5124 vector<de::SharedPtr<AttachmentResources> > attachmentResources;
5125 vector<de::SharedPtr<SubpassRenderer> > subpassRenderers;
5126 vector<VkImage> attachmentImages;
5127 vector<VkImageView> attachmentViews;
5128 vector<pair<VkImageView, VkImageView> > inputAttachmentViews;
5130 Move<VkRenderPass> renderPass;
5131 if (config.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
5132 renderPass = createRenderPass(vk, device, renderPassInfo, config.renderingType);
5134 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
5136 const Attachment& attachmentInfo = renderPassInfo.getAttachments()[attachmentNdx];
5138 attachmentResources.push_back(de::SharedPtr<AttachmentResources>(new AttachmentResources(vki, physDevice, vk, device, allocator, queueIndex, targetSize, attachmentInfo, attachmentImageUsage[attachmentNdx], config.allocationKind)));
5139 attachmentViews.push_back(attachmentResources[attachmentNdx]->getAttachmentView());
5140 attachmentImages.push_back(attachmentResources[attachmentNdx]->getImage());
5142 inputAttachmentViews.push_back(attachmentResources[attachmentNdx]->getInputAttachmentViews());
5145 beginCommandBuffer(vk, *initializeImagesCommandBuffer, (VkCommandBufferUsageFlags)0, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0);
5146 pushImageInitializationCommands(vk, *initializeImagesCommandBuffer, renderPassInfo.getAttachments(), attachmentResources, queueIndex, imageClearValues);
5147 endCommandBuffer(vk, *initializeImagesCommandBuffer);
5150 Move<VkFramebuffer> framebuffer;
5151 if (config.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
5152 framebuffer = createFramebuffer(vk, device, *renderPass, targetSize, attachmentViews);
5154 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); subpassNdx++)
5155 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)));
5157 beginCommandBuffer(vk, *renderCommandBuffer, (VkCommandBufferUsageFlags)0, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0);
5158 pushRenderPassCommands(vk, *renderCommandBuffer, *renderPass, renderPassInfo, attachmentResources, *framebuffer, subpassRenderers, renderPos, renderSize, renderPassClearValues, queueIndex, config.renderTypes, config.renderingType);
5159 endCommandBuffer(vk, *renderCommandBuffer);
5161 beginCommandBuffer(vk, *readImagesToBuffersCommandBuffer, (VkCommandBufferUsageFlags)0, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0);
5162 pushReadImagesToBuffers(vk, *readImagesToBuffersCommandBuffer, queueIndex, attachmentResources, renderPassInfo.getAttachments(), attachmentIsLazy, targetSize);
5163 endCommandBuffer(vk, *readImagesToBuffersCommandBuffer);
5165 const VkCommandBuffer commandBuffers[] =
5167 *initializeImagesCommandBuffer,
5168 *renderCommandBuffer,
5169 *readImagesToBuffersCommandBuffer
5171 const Unique<VkFence> fence (createFence(vk, device, 0u));
5173 queueSubmit(vk, queue, DE_LENGTH_OF_ARRAY(commandBuffers), commandBuffers, *fence);
5174 waitForFences(vk, device, 1, &fence.get(), VK_TRUE, ~0ull);
5178 if (logAndVerifyImages(log, vk, device, attachmentResources, attachmentIsLazy, renderPassInfo, renderPassClearValues, imageClearValues, subpassRenderInfo, targetSize, config))
5179 return tcu::TestStatus::pass("Pass");
5181 return tcu::TestStatus::fail("Result verification failed");
5185 static const VkFormat s_coreColorFormats[] =
5187 VK_FORMAT_R5G6B5_UNORM_PACK16,
5192 VK_FORMAT_R8G8_UNORM,
5193 VK_FORMAT_R8G8_SNORM,
5194 VK_FORMAT_R8G8_UINT,
5195 VK_FORMAT_R8G8_SINT,
5196 VK_FORMAT_R8G8B8A8_UNORM,
5197 VK_FORMAT_R8G8B8A8_SNORM,
5198 VK_FORMAT_R8G8B8A8_UINT,
5199 VK_FORMAT_R8G8B8A8_SINT,
5200 VK_FORMAT_R8G8B8A8_SRGB,
5201 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
5202 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
5203 VK_FORMAT_A8B8G8R8_UINT_PACK32,
5204 VK_FORMAT_A8B8G8R8_SINT_PACK32,
5205 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
5206 VK_FORMAT_B8G8R8A8_UNORM,
5207 VK_FORMAT_B8G8R8A8_SRGB,
5208 VK_FORMAT_A2R10G10B10_UNORM_PACK32,
5209 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
5210 VK_FORMAT_A2B10G10R10_UINT_PACK32,
5211 VK_FORMAT_R16_UNORM,
5212 VK_FORMAT_R16_SNORM,
5215 VK_FORMAT_R16_SFLOAT,
5216 VK_FORMAT_R16G16_UNORM,
5217 VK_FORMAT_R16G16_SNORM,
5218 VK_FORMAT_R16G16_UINT,
5219 VK_FORMAT_R16G16_SINT,
5220 VK_FORMAT_R16G16_SFLOAT,
5221 VK_FORMAT_R16G16B16A16_UNORM,
5222 VK_FORMAT_R16G16B16A16_SNORM,
5223 VK_FORMAT_R16G16B16A16_UINT,
5224 VK_FORMAT_R16G16B16A16_SINT,
5225 VK_FORMAT_R16G16B16A16_SFLOAT,
5228 VK_FORMAT_R32_SFLOAT,
5229 VK_FORMAT_R32G32_UINT,
5230 VK_FORMAT_R32G32_SINT,
5231 VK_FORMAT_R32G32_SFLOAT,
5232 VK_FORMAT_R32G32B32A32_UINT,
5233 VK_FORMAT_R32G32B32A32_SINT,
5234 VK_FORMAT_R32G32B32A32_SFLOAT
5237 static const VkFormat s_coreDepthStencilFormats[] =
5239 VK_FORMAT_D16_UNORM,
5241 VK_FORMAT_X8_D24_UNORM_PACK32,
5242 VK_FORMAT_D32_SFLOAT,
5244 VK_FORMAT_D24_UNORM_S8_UINT,
5245 VK_FORMAT_D32_SFLOAT_S8_UINT
5248 void addAttachmentTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
5250 const deUint32 attachmentCounts[] = { 1, 3, 4, 8 };
5251 const VkAttachmentLoadOp loadOps[] =
5253 VK_ATTACHMENT_LOAD_OP_LOAD,
5254 VK_ATTACHMENT_LOAD_OP_CLEAR,
5255 VK_ATTACHMENT_LOAD_OP_DONT_CARE
5258 const VkAttachmentStoreOp storeOps[] =
5260 VK_ATTACHMENT_STORE_OP_STORE,
5261 VK_ATTACHMENT_STORE_OP_DONT_CARE
5264 const VkImageLayout initialAndFinalColorLayouts[] =
5266 VK_IMAGE_LAYOUT_GENERAL,
5267 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5268 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
5269 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
5270 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
5273 const VkImageLayout initialAndFinalColorLayoutsLazy[] =
5275 VK_IMAGE_LAYOUT_GENERAL,
5276 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5277 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
5280 const VkImageLayout initialAndFinalDepthStencilLayouts[] =
5282 VK_IMAGE_LAYOUT_GENERAL,
5283 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5284 VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL,
5285 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
5286 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
5287 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
5290 const VkImageLayout initialAndFinalDepthStencilLayoutsLazy[] =
5292 VK_IMAGE_LAYOUT_GENERAL,
5293 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5294 VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL,
5295 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
5298 const VkImageLayout subpassLayouts[] =
5300 VK_IMAGE_LAYOUT_GENERAL,
5301 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
5304 const VkImageLayout depthStencilLayouts[] =
5306 VK_IMAGE_LAYOUT_GENERAL,
5307 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
5310 const TestConfig::RenderTypes renderCommands[] =
5312 TestConfig::RENDERTYPES_NONE,
5313 TestConfig::RENDERTYPES_CLEAR,
5314 TestConfig::RENDERTYPES_DRAW,
5315 TestConfig::RENDERTYPES_CLEAR|TestConfig::RENDERTYPES_DRAW,
5318 const TestConfig::CommandBufferTypes commandBuffers[] =
5320 TestConfig::COMMANDBUFFERTYPES_INLINE,
5321 TestConfig::COMMANDBUFFERTYPES_SECONDARY,
5322 TestConfig::COMMANDBUFFERTYPES_INLINE|TestConfig::COMMANDBUFFERTYPES_SECONDARY
5325 const TestConfig::ImageMemory imageMemories[] =
5327 TestConfig::IMAGEMEMORY_STRICT,
5328 TestConfig::IMAGEMEMORY_LAZY,
5329 TestConfig::IMAGEMEMORY_STRICT|TestConfig::IMAGEMEMORY_LAZY
5332 const UVec2 targetSizes[] =
5338 const UVec2 renderPositions[] =
5344 const UVec2 renderSizes[] =
5350 tcu::TestContext& testCtx (group->getTestContext());
5351 bool useDynamicRendering (testConfigExternal.renderingType == RENDERING_TYPE_DYNAMIC_RENDERING);
5352 de::Random rng (1433774382u);
5354 for (size_t attachmentCountNdx = 0; attachmentCountNdx < DE_LENGTH_OF_ARRAY(attachmentCounts); attachmentCountNdx++)
5356 const deUint32 attachmentCount = attachmentCounts[attachmentCountNdx];
5357 const deUint32 testCaseCount = (attachmentCount == 1 ? 100 : 200);
5358 de::MovePtr<tcu::TestCaseGroup> attachmentCountGroup (new tcu::TestCaseGroup(testCtx, de::toString(attachmentCount).c_str(), de::toString(attachmentCount).c_str()));
5360 for (size_t testCaseNdx = 0; testCaseNdx < testCaseCount; testCaseNdx++)
5362 const bool useDepthStencil = rng.getBool();
5363 const TestConfig::ImageMemory imageMemory = rng.choose<TestConfig::ImageMemory>(DE_ARRAY_BEGIN(imageMemories), DE_ARRAY_END(imageMemories));
5364 VkImageLayout depthStencilLayout = VK_IMAGE_LAYOUT_GENERAL;
5365 vector<Attachment> attachments;
5366 vector<AttachmentReference> colorAttachmentReferences;
5368 // we want to make sure that dynamic rendering test cases have corresponding renderpass
5369 // cases as this will allow drivers to easily compare GPU batches; since configurations
5370 // for those tests are generated we need to generate configurations for all cases
5371 // even when we know earlier that for dynamic rendering we will skip it
5372 bool executeForDynamicRendering = true;
5374 for (size_t attachmentNdx = 0; attachmentNdx < attachmentCount; attachmentNdx++)
5376 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
5377 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreColorFormats), DE_ARRAY_END(s_coreColorFormats));
5378 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5379 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5381 const VkImageLayout initialLayout = (imageMemory == TestConfig::IMAGEMEMORY_STRICT)
5382 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts))
5383 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayoutsLazy), DE_ARRAY_END(initialAndFinalColorLayoutsLazy));
5384 VkImageLayout finalizeLayout = (imageMemory == TestConfig::IMAGEMEMORY_STRICT)
5385 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts))
5386 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayoutsLazy), DE_ARRAY_END(initialAndFinalColorLayoutsLazy));
5387 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayouts), DE_ARRAY_END(subpassLayouts));
5389 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5390 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5392 if (useDynamicRendering)
5394 // with renderpass we can have automatic layout transitions; to do the same with dynamic rendering cases
5395 // we would need to add addtional barries but since those tests won't add coverage we are skipping them
5396 if ((initialLayout == VK_IMAGE_LAYOUT_GENERAL) ||
5397 (initialLayout == VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL))
5398 finalizeLayout = initialLayout;
5400 executeForDynamicRendering = false;
5403 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5404 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
5407 if (useDepthStencil)
5409 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
5410 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreDepthStencilFormats), DE_ARRAY_END(s_coreDepthStencilFormats));
5411 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5412 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5414 const VkImageLayout initialLayout = (imageMemory == TestConfig::IMAGEMEMORY_STRICT)
5415 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
5416 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayoutsLazy), DE_ARRAY_END(initialAndFinalDepthStencilLayoutsLazy));
5417 VkImageLayout finalizeLayout = (imageMemory == TestConfig::IMAGEMEMORY_STRICT)
5418 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
5419 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayoutsLazy), DE_ARRAY_END(initialAndFinalDepthStencilLayoutsLazy));
5421 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5422 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5424 if (useDynamicRendering)
5426 if ((initialLayout == VK_IMAGE_LAYOUT_GENERAL) ||
5427 (initialLayout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL) ||
5428 (initialLayout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL))
5429 finalizeLayout = initialLayout;
5431 executeForDynamicRendering = false;
5434 depthStencilLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(depthStencilLayouts), DE_ARRAY_END(depthStencilLayouts));
5435 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5439 const TestConfig::RenderTypes render = rng.choose<TestConfig::RenderTypes>(DE_ARRAY_BEGIN(renderCommands), DE_ARRAY_END(renderCommands));
5440 const TestConfig::CommandBufferTypes commandBuffer = rng.choose<TestConfig::CommandBufferTypes>(DE_ARRAY_BEGIN(commandBuffers), DE_ARRAY_END(commandBuffers));
5441 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>()));
5442 const vector<SubpassDependency> deps;
5443 const string testCaseName = de::toString(attachmentCountNdx * testCaseCount + testCaseNdx);
5444 const RenderPass renderPass (attachments, subpasses, deps);
5445 const UVec2 targetSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(targetSizes), DE_ARRAY_END(targetSizes));
5446 const UVec2 renderPos = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderPositions), DE_ARRAY_END(renderPositions));
5447 const UVec2 renderSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderSizes), DE_ARRAY_END(renderSizes));
5449 // skip dynamic rendering cases (that don't add coverage)
5450 // this can be done not earlier than after grabbing all random numbers as
5451 // we need to make sure that those tests that will be created for dynamic
5452 // rendering have corresponding renderpass tests with the same name
5453 if (useDynamicRendering && !executeForDynamicRendering)
5456 const TestConfig testConfig (renderPass,
5466 testConfigExternal.allocationKind,
5467 testConfigExternal.renderingType);
5469 addFunctionCaseWithPrograms<TestConfig>(attachmentCountGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, testConfig);
5473 group->addChild(attachmentCountGroup.release());
5477 void addAttachmentWriteMaskTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
5479 const deUint32 attachmentCounts[] = { 1, 2, 3, 4, 8 };
5481 const VkFormat attachmentFormats[] =
5483 VK_FORMAT_R8G8B8A8_UINT,
5484 VK_FORMAT_R8G8B8A8_UNORM,
5485 VK_FORMAT_R5G6B5_UNORM_PACK16,
5486 VK_FORMAT_R8G8_UNORM
5489 tcu::TestContext& testCtx = group->getTestContext();
5491 for (deUint32 attachmentCountNdx = 0; attachmentCountNdx < DE_LENGTH_OF_ARRAY(attachmentCounts); attachmentCountNdx++)
5493 const deUint32 attachmentCount = attachmentCounts[attachmentCountNdx];
5494 const string groupName = "attachment_count_" + de::toString(attachmentCount);
5496 de::MovePtr<tcu::TestCaseGroup> attachmentCountGroup(new tcu::TestCaseGroup(testCtx, groupName.c_str(), de::toString(attachmentCount).c_str()));
5498 for (deUint32 drawStartNdx = 0; drawStartNdx < (attachmentCount); drawStartNdx++)
5500 deUint32 formatNdx = 0;
5501 vector<Attachment> attachments;
5502 vector<AttachmentReference> colorAttachmentReferences;
5504 for (deUint32 attachmentNdx = 0; attachmentNdx < attachmentCount; attachmentNdx++)
5506 const VkFormat format = attachmentFormats[formatNdx];
5507 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
5508 const VkAttachmentLoadOp loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
5509 const VkAttachmentStoreOp storeOp = VK_ATTACHMENT_STORE_OP_STORE;
5510 const VkAttachmentLoadOp stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
5511 const VkAttachmentStoreOp stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
5512 const VkImageLayout initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
5513 const VkImageLayout finalizeLayout = (testConfigExternal.renderingType == RENDERING_TYPE_DYNAMIC_RENDERING)
5514 ? initialLayout : VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
5515 const VkImageLayout subpassLayout = VK_IMAGE_LAYOUT_GENERAL;
5517 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5518 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
5520 if (++formatNdx == DE_LENGTH_OF_ARRAY(attachmentFormats))
5525 const VkImageLayout depthStencilLayout = VK_IMAGE_LAYOUT_GENERAL;
5526 const vector<Subpass> subpass (1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u, vector<AttachmentReference>(), colorAttachmentReferences, vector<AttachmentReference>(), AttachmentReference(VK_ATTACHMENT_UNUSED, depthStencilLayout), vector<deUint32>()));
5527 const vector<SubpassDependency> deps;
5529 const string testCaseName = "start_index_" + de::toString(drawStartNdx);
5530 const RenderPass renderPass (attachments, subpass, deps);
5532 const TestConfig::RenderTypes render = TestConfig::RENDERTYPES_DRAW;
5533 const TestConfig::CommandBufferTypes commandBuffer = TestConfig::COMMANDBUFFERTYPES_INLINE;
5534 const TestConfig::ImageMemory imageMemory = TestConfig::IMAGEMEMORY_LAZY;
5535 const UVec2 targetSize = UVec2(64, 64);
5536 const UVec2 renderPos = UVec2(0, 0);
5537 const UVec2 renderSize = UVec2(64, 64);
5538 const deBool useFormatCompCount = DE_TRUE;
5539 const vector<DeviceCoreFeature> requiredFeatures = {DEVICE_CORE_FEATURE_INDEPENDENT_BLEND};
5540 const TestConfig testConfig (renderPass,
5550 testConfigExternal.allocationKind,
5551 testConfigExternal.renderingType,
5554 addFunctionCaseWithPrograms<TestConfig>(attachmentCountGroup.get(), testCaseName.c_str(), testCaseName.c_str(), checkSupport, createTestShaders, renderPassTest, testConfig);
5558 group->addChild(attachmentCountGroup.release());
5562 template<typename T>
5563 T chooseRandom (de::Random& rng, const set<T>& values)
5565 size_t ndx = ((size_t)rng.getUint32()) % values.size();
5566 typename set<T>::const_iterator iter = values.begin();
5568 for (; ndx > 0; ndx--)
5574 void addAttachmentAllocationTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
5576 const deUint32 attachmentCounts[] = { 4, 8 };
5577 const VkAttachmentLoadOp loadOps[] =
5579 VK_ATTACHMENT_LOAD_OP_LOAD,
5580 VK_ATTACHMENT_LOAD_OP_CLEAR,
5581 VK_ATTACHMENT_LOAD_OP_DONT_CARE
5584 const VkAttachmentStoreOp storeOps[] =
5586 VK_ATTACHMENT_STORE_OP_STORE,
5587 VK_ATTACHMENT_STORE_OP_DONT_CARE
5590 const VkImageLayout initialAndFinalColorLayouts[] =
5592 VK_IMAGE_LAYOUT_GENERAL,
5593 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5594 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
5595 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
5596 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
5599 const VkImageLayout initialAndFinalDepthStencilLayouts[] =
5601 VK_IMAGE_LAYOUT_GENERAL,
5602 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5603 VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL,
5604 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
5605 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
5606 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
5609 const VkImageLayout subpassLayoutsColor[] =
5611 VK_IMAGE_LAYOUT_GENERAL,
5612 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
5615 const VkImageLayout subpassLayoutsDepthStencil[] =
5617 VK_IMAGE_LAYOUT_GENERAL,
5618 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
5621 const VkImageLayout subpassLayoutsInput[] =
5623 VK_IMAGE_LAYOUT_GENERAL,
5624 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
5629 // Each pass uses one more attachmen than previous one
5630 ALLOCATIONTYPE_GROW,
5631 // Each pass uses one less attachment than previous one
5632 ALLOCATIONTYPE_SHRINK,
5633 // Each pass drops one attachment and picks up new one
5634 ALLOCATIONTYPE_ROLL,
5635 // Start by growing and end by shrinking
5636 ALLOCATIONTYPE_GROW_SHRINK,
5637 // Each subpass has single input and single output attachment
5638 ALLOCATIONTYPE_IO_CHAIN,
5639 // Each subpass has multiple inputs and multiple outputs attachment
5640 ALLOCATIONTYPE_IO_GENERIC
5643 const AllocationType allocationTypes[] =
5645 ALLOCATIONTYPE_GROW,
5646 ALLOCATIONTYPE_SHRINK,
5647 ALLOCATIONTYPE_ROLL,
5648 ALLOCATIONTYPE_GROW_SHRINK,
5649 ALLOCATIONTYPE_IO_CHAIN,
5650 ALLOCATIONTYPE_IO_GENERIC
5653 const char* const allocationTypeStr[] =
5659 "input_output_chain",
5663 const TestConfig::RenderTypes renderCommands[] =
5665 TestConfig::RENDERTYPES_NONE,
5666 TestConfig::RENDERTYPES_CLEAR,
5667 TestConfig::RENDERTYPES_DRAW,
5668 TestConfig::RENDERTYPES_CLEAR|TestConfig::RENDERTYPES_DRAW,
5671 const TestConfig::CommandBufferTypes commandBuffers[] =
5673 TestConfig::COMMANDBUFFERTYPES_INLINE,
5674 TestConfig::COMMANDBUFFERTYPES_SECONDARY,
5675 TestConfig::COMMANDBUFFERTYPES_INLINE|TestConfig::COMMANDBUFFERTYPES_SECONDARY
5678 const TestConfig::ImageMemory imageMemories[] =
5680 TestConfig::IMAGEMEMORY_STRICT,
5681 TestConfig::IMAGEMEMORY_LAZY,
5682 TestConfig::IMAGEMEMORY_STRICT|TestConfig::IMAGEMEMORY_LAZY
5685 const UVec2 targetSizes[] =
5691 const UVec2 renderPositions[] =
5697 const UVec2 renderSizes[] =
5703 tcu::TestContext& testCtx = group->getTestContext();
5704 de::Random rng (3700649827u);
5706 for (size_t allocationTypeNdx = 0; allocationTypeNdx < DE_LENGTH_OF_ARRAY(allocationTypes); allocationTypeNdx++)
5708 const AllocationType allocationType = allocationTypes[allocationTypeNdx];
5709 const size_t testCaseCount = 100;
5710 de::MovePtr<tcu::TestCaseGroup> allocationTypeGroup (new tcu::TestCaseGroup(testCtx, allocationTypeStr[allocationTypeNdx], allocationTypeStr[allocationTypeNdx]));
5712 for (size_t testCaseNdx = 0; testCaseNdx < testCaseCount; testCaseNdx++)
5714 if (allocationType == ALLOCATIONTYPE_IO_GENERIC)
5716 const deUint32 attachmentCount = 4u + rng.getUint32() % 31u;
5717 const deUint32 subpassCount = 4u + rng.getUint32() % 31u;
5718 vector<Attachment> attachments;
5720 set<deUint32> definedAttachments;
5722 vector<Subpass> subpasses;
5723 set<deUint32> colorAttachments;
5724 set<deUint32> depthStencilAttachments;
5726 for (deUint32 attachmentIndex = 0; attachmentIndex < attachmentCount; attachmentIndex++)
5728 const bool isDepthStencilAttachment = rng.getFloat() < 0.01f;
5729 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
5730 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5731 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5733 const VkImageLayout initialLayout = isDepthStencilAttachment
5734 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
5735 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
5736 const VkImageLayout finalizeLayout = isDepthStencilAttachment
5737 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
5738 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
5740 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5741 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5743 if (isDepthStencilAttachment)
5745 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreDepthStencilFormats), DE_ARRAY_END(s_coreDepthStencilFormats));
5747 if (loadOp == VK_ATTACHMENT_LOAD_OP_LOAD || loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR
5748 || stencilLoadOp == VK_ATTACHMENT_LOAD_OP_LOAD || stencilLoadOp == VK_ATTACHMENT_LOAD_OP_CLEAR)
5749 definedAttachments.insert(attachmentIndex);
5751 depthStencilAttachments.insert(attachmentIndex);
5753 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5757 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreColorFormats), DE_ARRAY_END(s_coreColorFormats));
5759 if (loadOp == VK_ATTACHMENT_LOAD_OP_LOAD || loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR)
5760 definedAttachments.insert(attachmentIndex);
5762 colorAttachments.insert(attachmentIndex);
5764 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5767 vector<Maybe<deUint32> > lastUseOfAttachment (attachments.size(), tcu::Nothing);
5768 vector<SubpassDependency> deps;
5770 for (deUint32 subpassIndex = 0; subpassIndex < subpassCount; subpassIndex++)
5772 const deUint32 colorAttachmentCount = depthStencilAttachments.empty()
5773 ? 1 + rng.getUint32() % de::min(4u, (deUint32)colorAttachments.size())
5774 : rng.getUint32() % (de::min(4u, (deUint32)colorAttachments.size()) + 1u);
5775 const deUint32 inputAttachmentCount = rng.getUint32() % (deUint32)(de::min<size_t>(4, definedAttachments.size()) + 1);
5776 const bool useDepthStencilAttachment = !depthStencilAttachments.empty() && (colorAttachmentCount == 0 || rng.getBool());
5777 std::vector<deUint32> subpassColorAttachments (colorAttachmentCount);
5778 std::vector<deUint32> subpassInputAttachments (inputAttachmentCount);
5779 Maybe<deUint32> depthStencilAttachment (useDepthStencilAttachment
5780 ? just(chooseRandom(rng, depthStencilAttachments))
5782 std::vector<deUint32> subpassPreserveAttachments;
5784 rng.choose(colorAttachments.begin(), colorAttachments.end(), subpassColorAttachments.begin(), colorAttachmentCount);
5785 rng.choose(definedAttachments.begin(), definedAttachments.end(), subpassInputAttachments.begin(), inputAttachmentCount);
5787 for (size_t colorAttachmentNdx = 0; colorAttachmentNdx < subpassColorAttachments.size(); colorAttachmentNdx++)
5788 definedAttachments.insert(subpassColorAttachments[colorAttachmentNdx]);
5790 if (depthStencilAttachment)
5791 definedAttachments.insert(*depthStencilAttachment);
5794 std::vector<AttachmentReference> inputAttachmentReferences;
5795 std::vector<AttachmentReference> colorAttachmentReferences;
5796 AttachmentReference depthStencilAttachmentReference (VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL);
5798 for (size_t colorAttachmentNdx = 0; colorAttachmentNdx < subpassColorAttachments.size(); colorAttachmentNdx++)
5800 const deUint32 colorAttachmentIndex = subpassColorAttachments[colorAttachmentNdx];
5802 if (lastUseOfAttachment[colorAttachmentIndex])
5804 deBool foundDuplicate = false;
5806 const deUint32 srcPass = *lastUseOfAttachment[colorAttachmentIndex];
5807 const deUint32 dstPass = subpassIndex;
5808 const VkDependencyFlags dependencyFlags = rng.getBool() ? (VkDependencyFlags) VK_DEPENDENCY_BY_REGION_BIT : 0u;
5810 const SubpassDependency newDependency(srcPass, dstPass,
5811 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5812 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5813 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5814 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5816 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5817 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5818 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5819 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5821 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
5822 VK_ACCESS_COLOR_ATTACHMENT_READ_BIT,
5826 for (SubpassDependency& dependency : deps)
5828 if (dependency.getSrcPass() == srcPass && dependency.getDstPass() == dstPass)
5830 const VkAccessFlags newDstFlags = dependency.getDstAccessMask() | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT;
5831 dependency.setDstAccessMask(newDstFlags);
5832 foundDuplicate = true;
5837 if (!foundDuplicate)
5839 deps.push_back(newDependency);
5843 lastUseOfAttachment[colorAttachmentIndex] = just(subpassIndex);
5845 colorAttachmentReferences.push_back(AttachmentReference((deUint32)subpassColorAttachments[colorAttachmentNdx], VK_IMAGE_LAYOUT_GENERAL));
5848 for (size_t inputAttachmentNdx = 0; inputAttachmentNdx < subpassInputAttachments.size(); inputAttachmentNdx++)
5850 const deUint32 inputAttachmentIndex = subpassInputAttachments[inputAttachmentNdx];
5852 if(lastUseOfAttachment[inputAttachmentIndex])
5854 deBool foundDuplicate = false;
5856 const deUint32 srcPass = *lastUseOfAttachment[inputAttachmentIndex];
5857 const deUint32 dstPass = subpassIndex;
5858 const VkDependencyFlags dependencyFlags = ((srcPass == subpassIndex) || rng.getBool()) ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u;
5860 const SubpassDependency newDependency(srcPass, dstPass,
5861 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5862 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5863 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5864 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5866 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5867 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5868 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5869 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5871 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
5872 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5875 for (SubpassDependency& dependency : deps)
5877 if (dependency.getSrcPass() == srcPass && dependency.getDstPass() == dstPass)
5879 const VkAccessFlags newSrcFlags = dependency.getSrcAccessMask() | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
5880 const VkAccessFlags newDstFlags = dependency.getDstAccessMask() | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT;
5881 dependency.setDstAccessMask(newSrcFlags);
5882 dependency.setDstAccessMask(newDstFlags);
5883 foundDuplicate = true;
5888 if (!foundDuplicate)
5890 deps.push_back(newDependency);
5893 lastUseOfAttachment[inputAttachmentIndex] = just(subpassIndex);
5895 VkImageAspectFlags aspect = 0u;
5896 if (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2)
5898 bool col = colorAttachments.find(inputAttachmentIndex) != colorAttachments.end();
5899 aspect = col ? VK_IMAGE_ASPECT_COLOR_BIT : VK_IMAGE_ASPECT_DEPTH_BIT;
5901 inputAttachmentReferences.push_back(AttachmentReference((deUint32)subpassInputAttachments[inputAttachmentNdx], VK_IMAGE_LAYOUT_GENERAL, aspect));
5905 if (depthStencilAttachment)
5907 if (lastUseOfAttachment[*depthStencilAttachment])
5909 deBool foundDuplicate = false;
5911 const deUint32 srcPass = *lastUseOfAttachment[*depthStencilAttachment];
5912 const deUint32 dstPass = subpassIndex;
5913 const VkDependencyFlags dependencyFlags = ((srcPass == subpassIndex) || rng.getBool()) ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u;
5915 const SubpassDependency newDependency(srcPass, dstPass,
5916 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5917 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5918 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5919 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5921 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5922 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5923 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5924 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5926 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
5927 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT
5928 | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5931 for (SubpassDependency& dependency : deps)
5933 if (dependency.getSrcPass() == srcPass && dependency.getDstPass() == dstPass)
5935 const VkAccessFlags newSrcFlags = dependency.getSrcAccessMask() | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
5936 const VkAccessFlags newDstFlags = dependency.getDstAccessMask() | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT;
5937 dependency.setDstAccessMask(newSrcFlags);
5938 dependency.setDstAccessMask(newDstFlags);
5939 foundDuplicate = true;
5944 if (!foundDuplicate)
5946 deps.push_back(newDependency);
5950 lastUseOfAttachment[*depthStencilAttachment] = just(subpassIndex);
5952 depthStencilAttachmentReference = AttachmentReference(*depthStencilAttachment, VK_IMAGE_LAYOUT_GENERAL);
5955 depthStencilAttachmentReference = AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL);
5957 vector<deUint32> preserveAttachments;
5958 for (deUint32 attachmentIndex = 0; attachmentIndex < (deUint32)attachments.size(); attachmentIndex++)
5960 if (lastUseOfAttachment[attachmentIndex] && (*lastUseOfAttachment[attachmentIndex]) != subpassIndex)
5961 preserveAttachments.push_back(attachmentIndex);
5964 // Use random image layout when possible
5965 for (size_t colorRefIdx = 0; colorRefIdx < colorAttachmentReferences.size(); ++colorRefIdx)
5967 bool usedAsInput = false;
5968 for (size_t inputRefIdx = 0; inputRefIdx < inputAttachmentReferences.size(); ++inputRefIdx)
5969 if (colorAttachmentReferences[colorRefIdx].getAttachment() == inputAttachmentReferences[inputRefIdx].getAttachment())
5973 colorAttachmentReferences[colorRefIdx].setImageLayout(rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor)));
5975 for (size_t inputRefIdx = 0; inputRefIdx < inputAttachmentReferences.size(); ++inputRefIdx)
5977 bool usedAsDepthStencil = inputAttachmentReferences[inputRefIdx].getAttachment() == depthStencilAttachmentReference.getAttachment();
5978 bool usedAsColor = false;
5979 for (size_t colorRefIdx = 0; colorRefIdx < colorAttachmentReferences.size(); ++colorRefIdx)
5980 if (inputAttachmentReferences[inputRefIdx].getAttachment() == colorAttachmentReferences[colorRefIdx].getAttachment())
5983 if (!usedAsColor && !usedAsDepthStencil)
5984 inputAttachmentReferences[inputRefIdx].setImageLayout(rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsInput), DE_ARRAY_END(subpassLayoutsInput)));
5987 bool usedAsInput = false;
5988 for (size_t inputRefIdx = 0; inputRefIdx < inputAttachmentReferences.size(); ++inputRefIdx)
5989 if (depthStencilAttachmentReference.getAttachment() == inputAttachmentReferences[inputRefIdx].getAttachment())
5993 depthStencilAttachmentReference.setImageLayout(rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsDepthStencil), DE_ARRAY_END(subpassLayoutsDepthStencil)));
5996 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
5997 inputAttachmentReferences,
5998 colorAttachmentReferences,
5999 vector<AttachmentReference>(),
6000 depthStencilAttachmentReference,
6001 preserveAttachments));
6005 const TestConfig::RenderTypes render = rng.choose<TestConfig::RenderTypes>(DE_ARRAY_BEGIN(renderCommands), DE_ARRAY_END(renderCommands));
6006 const TestConfig::CommandBufferTypes commandBuffer = rng.choose<TestConfig::CommandBufferTypes>(DE_ARRAY_BEGIN(commandBuffers), DE_ARRAY_END(commandBuffers));
6007 const TestConfig::ImageMemory imageMemory = rng.choose<TestConfig::ImageMemory>(DE_ARRAY_BEGIN(imageMemories), DE_ARRAY_END(imageMemories));
6009 const string testCaseName = de::toString(testCaseNdx);
6010 const UVec2 targetSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(targetSizes), DE_ARRAY_END(targetSizes));
6011 const UVec2 renderPos = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderPositions), DE_ARRAY_END(renderPositions));
6012 const UVec2 renderSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderSizes), DE_ARRAY_END(renderSizes));
6014 const RenderPass renderPass (attachments, subpasses, deps);
6015 const TestConfig testConfig (renderPass,
6025 testConfigExternal.allocationKind,
6026 testConfigExternal.renderingType);
6028 addFunctionCaseWithPrograms<TestConfig>(allocationTypeGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, testConfig);
6033 const deUint32 attachmentCount = rng.choose<deUint32>(DE_ARRAY_BEGIN(attachmentCounts), DE_ARRAY_END(attachmentCounts));
6034 vector<Attachment> attachments;
6035 vector<Subpass> subpasses;
6037 for (size_t attachmentNdx = 0; attachmentNdx < attachmentCount; attachmentNdx++)
6039 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
6040 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreColorFormats), DE_ARRAY_END(s_coreColorFormats));
6041 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
6042 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
6044 const VkImageLayout initialLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
6045 const VkImageLayout finalizeLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
6047 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
6048 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
6050 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
6053 if (allocationType == ALLOCATIONTYPE_GROW)
6055 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
6057 vector<AttachmentReference> colorAttachmentReferences;
6059 for (size_t attachmentNdx = 0; attachmentNdx < subpassNdx + 1; attachmentNdx++)
6061 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6063 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
6066 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6067 vector<AttachmentReference>(),
6068 colorAttachmentReferences,
6069 vector<AttachmentReference>(),
6070 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6071 vector<deUint32>()));
6074 else if (allocationType == ALLOCATIONTYPE_SHRINK)
6076 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
6078 vector<AttachmentReference> colorAttachmentReferences;
6080 for (size_t attachmentNdx = 0; attachmentNdx < (attachmentCount - subpassNdx); attachmentNdx++)
6082 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6084 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
6087 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6088 vector<AttachmentReference>(),
6089 colorAttachmentReferences,
6090 vector<AttachmentReference>(),
6091 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6092 vector<deUint32>()));
6095 else if (allocationType == ALLOCATIONTYPE_ROLL)
6097 for (size_t subpassNdx = 0; subpassNdx < attachmentCount / 2; subpassNdx++)
6099 vector<AttachmentReference> colorAttachmentReferences;
6101 for (size_t attachmentNdx = 0; attachmentNdx < attachmentCount / 2; attachmentNdx++)
6103 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6105 colorAttachmentReferences.push_back(AttachmentReference((deUint32)(subpassNdx + attachmentNdx), subpassLayout));
6108 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6109 vector<AttachmentReference>(),
6110 colorAttachmentReferences,
6111 vector<AttachmentReference>(),
6112 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6113 vector<deUint32>()));
6116 else if (allocationType == ALLOCATIONTYPE_GROW_SHRINK)
6118 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
6120 vector<AttachmentReference> colorAttachmentReferences;
6122 for (size_t attachmentNdx = 0; attachmentNdx < subpassNdx + 1; attachmentNdx++)
6124 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6126 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
6129 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6130 vector<AttachmentReference>(),
6131 colorAttachmentReferences,
6132 vector<AttachmentReference>(),
6133 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6134 vector<deUint32>()));
6136 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
6138 vector<AttachmentReference> colorAttachmentReferences;
6140 for (size_t attachmentNdx = 0; attachmentNdx < (attachmentCount - subpassNdx); attachmentNdx++)
6142 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor));
6144 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
6147 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6148 vector<AttachmentReference>(),
6149 colorAttachmentReferences,
6150 vector<AttachmentReference>(),
6151 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6152 vector<deUint32>()));
6155 else if (allocationType == ALLOCATIONTYPE_IO_CHAIN)
6157 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6158 vector<AttachmentReference>(),
6159 vector<AttachmentReference>(1, AttachmentReference(0, rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor)))),
6160 vector<AttachmentReference>(),
6161 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6162 vector<deUint32>()));
6164 for (size_t subpassNdx = 1; subpassNdx < attachmentCount; subpassNdx++)
6166 const VkImageAspectFlags inputAttachmentAspectMask = (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2) ? VK_IMAGE_ASPECT_COLOR_BIT : static_cast<VkImageAspectFlagBits>(0);
6167 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
6168 vector<AttachmentReference>(1, AttachmentReference((deUint32)(subpassNdx - 1), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
6169 vector<AttachmentReference>(1, AttachmentReference((deUint32)(subpassNdx), rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayoutsColor), DE_ARRAY_END(subpassLayoutsColor)))),
6170 vector<AttachmentReference>(),
6171 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6172 vector<deUint32>()));
6176 DE_FATAL("Unknown allocation type");
6179 const TestConfig::RenderTypes render = rng.choose<TestConfig::RenderTypes>(DE_ARRAY_BEGIN(renderCommands), DE_ARRAY_END(renderCommands));
6180 const TestConfig::CommandBufferTypes commandBuffer = rng.choose<TestConfig::CommandBufferTypes>(DE_ARRAY_BEGIN(commandBuffers), DE_ARRAY_END(commandBuffers));
6181 const TestConfig::ImageMemory imageMemory = rng.choose<TestConfig::ImageMemory>(DE_ARRAY_BEGIN(imageMemories), DE_ARRAY_END(imageMemories));
6183 const string testCaseName = de::toString(testCaseNdx);
6184 const UVec2 targetSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(targetSizes), DE_ARRAY_END(targetSizes));
6185 const UVec2 renderPos = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderPositions), DE_ARRAY_END(renderPositions));
6186 const UVec2 renderSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderSizes), DE_ARRAY_END(renderSizes));
6188 vector<SubpassDependency> deps;
6190 for (size_t subpassNdx = 0; subpassNdx < subpasses.size() - 1; subpassNdx++)
6192 const bool byRegion = rng.getBool();
6193 deps.push_back(SubpassDependency((deUint32)subpassNdx, (deUint32)subpassNdx + 1,
6194 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
6195 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
6196 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
6197 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6199 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
6200 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
6201 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
6202 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6204 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6205 (VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT),
6207 byRegion ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u));
6210 const RenderPass renderPass (attachments, subpasses, deps);
6211 const TestConfig testConfig (renderPass,
6221 testConfigExternal.allocationKind,
6222 testConfigExternal.renderingType);
6224 addFunctionCaseWithPrograms<TestConfig>(allocationTypeGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, testConfig);
6228 group->addChild(allocationTypeGroup.release());
6232 void addSimpleTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
6234 const UVec2 targetSize (64, 64);
6235 const UVec2 renderPos (0, 0);
6236 const UVec2 renderSize (64, 64);
6240 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6241 VK_SAMPLE_COUNT_1_BIT,
6242 VK_ATTACHMENT_LOAD_OP_CLEAR,
6243 VK_ATTACHMENT_STORE_OP_STORE,
6244 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6245 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6246 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6247 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6248 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6250 vector<AttachmentReference>(),
6251 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6252 vector<AttachmentReference>(),
6253 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6254 vector<deUint32>())),
6255 vector<SubpassDependency>());
6256 const TestConfig testConfig (renderPass,
6257 TestConfig::RENDERTYPES_DRAW,
6258 TestConfig::COMMANDBUFFERTYPES_INLINE,
6259 TestConfig::IMAGEMEMORY_STRICT,
6266 testConfigExternal.allocationKind,
6267 testConfigExternal.renderingType);
6269 addFunctionCaseWithPrograms<TestConfig>(group, "color", "Single color attachment case.", createTestShaders, renderPassTest, testConfig);
6274 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_X8_D24_UNORM_PACK32,
6275 VK_SAMPLE_COUNT_1_BIT,
6276 VK_ATTACHMENT_LOAD_OP_CLEAR,
6277 VK_ATTACHMENT_STORE_OP_STORE,
6278 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6279 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6280 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6281 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6282 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6284 vector<AttachmentReference>(),
6285 vector<AttachmentReference>(),
6286 vector<AttachmentReference>(),
6287 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6288 vector<deUint32>())),
6289 vector<SubpassDependency>());
6290 const TestConfig testConfig (renderPass,
6291 TestConfig::RENDERTYPES_DRAW,
6292 TestConfig::COMMANDBUFFERTYPES_INLINE,
6293 TestConfig::IMAGEMEMORY_STRICT,
6300 testConfigExternal.allocationKind,
6301 testConfigExternal.renderingType);
6303 addFunctionCaseWithPrograms<TestConfig>(group, "depth", "Single depth attachment case.", createTestShaders, renderPassTest, testConfig);
6308 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_S8_UINT,
6309 VK_SAMPLE_COUNT_1_BIT,
6310 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6311 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6312 VK_ATTACHMENT_LOAD_OP_CLEAR,
6313 VK_ATTACHMENT_STORE_OP_STORE,
6314 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6315 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6316 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6318 vector<AttachmentReference>(),
6319 vector<AttachmentReference>(),
6320 vector<AttachmentReference>(),
6321 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6322 vector<deUint32>())),
6323 vector<SubpassDependency>());
6324 const TestConfig testConfig (renderPass,
6325 TestConfig::RENDERTYPES_DRAW,
6326 TestConfig::COMMANDBUFFERTYPES_INLINE,
6327 TestConfig::IMAGEMEMORY_STRICT,
6334 testConfigExternal.allocationKind,
6335 testConfigExternal.renderingType);
6337 addFunctionCaseWithPrograms<TestConfig>(group, "stencil", "Single stencil attachment case.", createTestShaders, renderPassTest, testConfig);
6342 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_D24_UNORM_S8_UINT,
6343 VK_SAMPLE_COUNT_1_BIT,
6344 VK_ATTACHMENT_LOAD_OP_CLEAR,
6345 VK_ATTACHMENT_STORE_OP_STORE,
6346 VK_ATTACHMENT_LOAD_OP_CLEAR,
6347 VK_ATTACHMENT_STORE_OP_STORE,
6348 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6349 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6350 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6352 vector<AttachmentReference>(),
6353 vector<AttachmentReference>(),
6354 vector<AttachmentReference>(),
6355 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6356 vector<deUint32>())),
6357 vector<SubpassDependency>());
6358 const TestConfig testConfig (renderPass,
6359 TestConfig::RENDERTYPES_DRAW,
6360 TestConfig::COMMANDBUFFERTYPES_INLINE,
6361 TestConfig::IMAGEMEMORY_STRICT,
6368 testConfigExternal.allocationKind,
6369 testConfigExternal.renderingType);
6371 addFunctionCaseWithPrograms<TestConfig>(group, "depth_stencil", "Single depth stencil attachment case.", createTestShaders, renderPassTest, testConfig);
6376 const Attachment attachments[] =
6378 Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6379 VK_SAMPLE_COUNT_1_BIT,
6380 VK_ATTACHMENT_LOAD_OP_CLEAR,
6381 VK_ATTACHMENT_STORE_OP_STORE,
6382 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6383 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6384 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6385 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL),
6386 Attachment(VK_FORMAT_X8_D24_UNORM_PACK32,
6387 VK_SAMPLE_COUNT_1_BIT,
6388 VK_ATTACHMENT_LOAD_OP_CLEAR,
6389 VK_ATTACHMENT_STORE_OP_STORE,
6390 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6391 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6392 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6393 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6396 const RenderPass renderPass (vector<Attachment>(DE_ARRAY_BEGIN(attachments), DE_ARRAY_END(attachments)),
6397 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6399 vector<AttachmentReference>(),
6400 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6401 vector<AttachmentReference>(),
6402 AttachmentReference(1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6403 vector<deUint32>())),
6404 vector<SubpassDependency>());
6405 const TestConfig testConfig (renderPass,
6406 TestConfig::RENDERTYPES_DRAW,
6407 TestConfig::COMMANDBUFFERTYPES_INLINE,
6408 TestConfig::IMAGEMEMORY_STRICT,
6415 testConfigExternal.allocationKind,
6416 testConfigExternal.renderingType);
6418 addFunctionCaseWithPrograms<TestConfig>(group, "color_depth", "Color and depth attachment case.", createTestShaders, renderPassTest, testConfig);
6423 const Attachment attachments[] =
6425 Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6426 VK_SAMPLE_COUNT_1_BIT,
6427 VK_ATTACHMENT_LOAD_OP_CLEAR,
6428 VK_ATTACHMENT_STORE_OP_STORE,
6429 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6430 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6431 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6432 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL),
6433 Attachment(VK_FORMAT_S8_UINT,
6434 VK_SAMPLE_COUNT_1_BIT,
6435 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6436 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6437 VK_ATTACHMENT_LOAD_OP_CLEAR,
6438 VK_ATTACHMENT_STORE_OP_STORE,
6439 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6440 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6443 const RenderPass renderPass (vector<Attachment>(DE_ARRAY_BEGIN(attachments), DE_ARRAY_END(attachments)),
6444 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6446 vector<AttachmentReference>(),
6447 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6448 vector<AttachmentReference>(),
6449 AttachmentReference(1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6450 vector<deUint32>())),
6451 vector<SubpassDependency>());
6452 const TestConfig testConfig (renderPass,
6453 TestConfig::RENDERTYPES_DRAW,
6454 TestConfig::COMMANDBUFFERTYPES_INLINE,
6455 TestConfig::IMAGEMEMORY_STRICT,
6462 testConfigExternal.allocationKind,
6463 testConfigExternal.renderingType);
6465 addFunctionCaseWithPrograms<TestConfig>(group, "color_stencil", "Color and stencil attachment case.", createTestShaders, renderPassTest, testConfig);
6468 // color_depth_stencil
6470 const Attachment attachments[] =
6472 Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6473 VK_SAMPLE_COUNT_1_BIT,
6474 VK_ATTACHMENT_LOAD_OP_CLEAR,
6475 VK_ATTACHMENT_STORE_OP_STORE,
6476 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6477 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6478 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6479 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL),
6480 Attachment(VK_FORMAT_D24_UNORM_S8_UINT,
6481 VK_SAMPLE_COUNT_1_BIT,
6482 VK_ATTACHMENT_LOAD_OP_CLEAR,
6483 VK_ATTACHMENT_STORE_OP_STORE,
6484 VK_ATTACHMENT_LOAD_OP_CLEAR,
6485 VK_ATTACHMENT_STORE_OP_STORE,
6486 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6487 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6490 const RenderPass renderPass (vector<Attachment>(DE_ARRAY_BEGIN(attachments), DE_ARRAY_END(attachments)),
6491 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6493 vector<AttachmentReference>(),
6494 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6495 vector<AttachmentReference>(),
6496 AttachmentReference(1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6497 vector<deUint32>())),
6498 vector<SubpassDependency>());
6499 const TestConfig testConfig (renderPass,
6500 TestConfig::RENDERTYPES_DRAW,
6501 TestConfig::COMMANDBUFFERTYPES_INLINE,
6502 TestConfig::IMAGEMEMORY_STRICT,
6509 testConfigExternal.allocationKind,
6510 testConfigExternal.renderingType);
6512 addFunctionCaseWithPrograms<TestConfig>(group, "color_depth_stencil", "Color, depth and stencil attachment case.", createTestShaders, renderPassTest, testConfig);
6517 const RenderPass renderPass (vector<Attachment>(),
6518 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6520 vector<AttachmentReference>(),
6521 vector<AttachmentReference>(),
6522 vector<AttachmentReference>(),
6523 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6524 vector<deUint32>())),
6525 vector<SubpassDependency>());
6526 const TestConfig testConfig (renderPass,
6527 TestConfig::RENDERTYPES_DRAW,
6528 TestConfig::COMMANDBUFFERTYPES_INLINE,
6529 TestConfig::IMAGEMEMORY_STRICT,
6536 testConfigExternal.allocationKind,
6537 testConfigExternal.renderingType);
6539 addFunctionCaseWithPrograms<TestConfig>(group, "no_attachments", "No attachments case.", createTestShaders, renderPassTest, testConfig);
6542 // color_unused_omit_blend_state
6543 if (testConfigExternal.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
6545 vector<Subpass> subpasses;
6547 // First subpass: use color attachment, create pipeline with color blend state
6548 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6550 vector<AttachmentReference>(),
6551 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6552 vector<AttachmentReference>(),
6553 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6557 // Second subpass: don't use color attachment, create pipeline without color blend state
6558 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6560 vector<AttachmentReference>(),
6561 vector<AttachmentReference>(1, AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6562 vector<AttachmentReference>(),
6563 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6567 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_R8G8B8A8_UNORM,
6568 VK_SAMPLE_COUNT_1_BIT,
6569 VK_ATTACHMENT_LOAD_OP_CLEAR,
6570 VK_ATTACHMENT_STORE_OP_STORE,
6571 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6572 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6573 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6574 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6576 vector<SubpassDependency>());
6578 const TestConfig testConfig (renderPass,
6579 TestConfig::RENDERTYPES_DRAW,
6580 TestConfig::COMMANDBUFFERTYPES_INLINE,
6581 TestConfig::IMAGEMEMORY_STRICT,
6588 testConfigExternal.allocationKind,
6589 testConfigExternal.renderingType);
6590 addFunctionCaseWithPrograms<TestConfig>(group, "color_unused_omit_blend_state", "Two unused color attachment case without blend state", createTestShaders, renderPassTest, testConfig);
6594 std::string formatToName (VkFormat format)
6596 const std::string formatStr = de::toString(format);
6597 const std::string prefix = "VK_FORMAT_";
6599 DE_ASSERT(formatStr.substr(0, prefix.length()) == prefix);
6601 return de::toLower(formatStr.substr(prefix.length()));
6604 void addFormatTests (tcu::TestCaseGroup* group, const TestConfigExternal testConfigExternal)
6606 tcu::TestContext& testCtx = group->getTestContext();
6608 const UVec2 targetSize (64, 64);
6609 const UVec2 renderPos (0, 0);
6610 const UVec2 renderSize (64, 64);
6614 const char* const str;
6615 const VkAttachmentStoreOp op;
6618 { "store", VK_ATTACHMENT_STORE_OP_STORE },
6619 { "dont_care", VK_ATTACHMENT_STORE_OP_DONT_CARE }
6624 const char* const str;
6625 const VkAttachmentLoadOp op;
6628 { "clear", VK_ATTACHMENT_LOAD_OP_CLEAR },
6629 { "load", VK_ATTACHMENT_LOAD_OP_LOAD },
6630 { "dont_care", VK_ATTACHMENT_LOAD_OP_DONT_CARE }
6635 const char* const str;
6636 const TestConfig::RenderTypes types;
6639 { "clear", TestConfig::RENDERTYPES_CLEAR },
6640 { "draw", TestConfig::RENDERTYPES_DRAW },
6641 { "clear_draw", TestConfig::RENDERTYPES_CLEAR|TestConfig::RENDERTYPES_DRAW }
6645 for (size_t formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_coreColorFormats); formatNdx++)
6647 const VkFormat format = s_coreColorFormats[formatNdx];
6648 de::MovePtr<tcu::TestCaseGroup> formatGroup (new tcu::TestCaseGroup(testCtx, formatToName(format).c_str(), de::toString(format).c_str()));
6650 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
6652 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
6653 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
6655 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
6657 const RenderPass renderPass (vector<Attachment>(1, Attachment(format,
6658 VK_SAMPLE_COUNT_1_BIT,
6660 VK_ATTACHMENT_STORE_OP_STORE,
6661 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6662 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6663 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6664 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6665 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6667 vector<AttachmentReference>(),
6668 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6669 vector<AttachmentReference>(),
6670 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6671 vector<deUint32>())),
6672 vector<SubpassDependency>());
6673 const TestConfig testConfig (renderPass,
6674 renderTypes[renderTypeNdx].types,
6675 TestConfig::COMMANDBUFFERTYPES_INLINE,
6676 TestConfig::IMAGEMEMORY_STRICT,
6683 testConfigExternal.allocationKind,
6684 testConfigExternal.renderingType);
6686 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), renderTypes[renderTypeNdx].str, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
6689 formatGroup->addChild(loadOpGroup.release());
6692 if (testConfigExternal.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
6694 de::MovePtr<tcu::TestCaseGroup> inputGroup (new tcu::TestCaseGroup(testCtx, "input", "Test attachment format as input"));
6696 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
6698 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
6699 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
6701 for (size_t storeOpNdx = 0; storeOpNdx < DE_LENGTH_OF_ARRAY(storeOps); storeOpNdx++)
6703 const VkImageAspectFlags inputAttachmentAspectMask = (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2)
6704 ? static_cast<VkImageAspectFlags>(VK_IMAGE_ASPECT_COLOR_BIT)
6705 : static_cast<VkImageAspectFlags>(0);
6706 const VkAttachmentStoreOp storeOp = storeOps[storeOpNdx].op;
6707 de::MovePtr<tcu::TestCaseGroup> storeOpGroup (new tcu::TestCaseGroup(testCtx, storeOps[storeOpNdx].str, storeOps[storeOpNdx].str));
6709 for (size_t useInputAspectNdx = 0; useInputAspectNdx < 2; useInputAspectNdx++)
6711 const bool useInputAspect = useInputAspectNdx != 0;
6713 if (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2 && useInputAspect)
6716 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
6719 vector<Attachment> attachments;
6720 vector<Subpass> subpasses;
6721 vector<SubpassDependency> deps;
6722 vector<VkInputAttachmentAspectReference> inputAspects;
6724 attachments.push_back(Attachment(format,
6725 VK_SAMPLE_COUNT_1_BIT,
6728 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6729 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6730 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6731 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
6733 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
6734 VK_SAMPLE_COUNT_1_BIT,
6735 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6736 VK_ATTACHMENT_STORE_OP_STORE,
6737 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6738 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6739 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6740 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
6742 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6744 vector<AttachmentReference>(),
6745 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6746 vector<AttachmentReference>(),
6747 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6748 vector<deUint32>()));
6749 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6751 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
6752 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6753 vector<AttachmentReference>(),
6754 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6755 vector<deUint32>()));
6757 deps.push_back(SubpassDependency(0, 1,
6759 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
6760 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6762 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6763 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6764 vk::VK_DEPENDENCY_BY_REGION_BIT));
6768 const VkInputAttachmentAspectReference inputAspect =
6772 VK_IMAGE_ASPECT_COLOR_BIT
6775 inputAspects.push_back(inputAspect);
6779 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
6780 const TestConfig testConfig (renderPass,
6781 renderTypes[renderTypeNdx].types,
6782 TestConfig::COMMANDBUFFERTYPES_INLINE,
6783 TestConfig::IMAGEMEMORY_STRICT,
6790 testConfigExternal.allocationKind,
6791 testConfigExternal.renderingType);
6792 const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : ""));
6794 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
6798 vector<Attachment> attachments;
6799 vector<Subpass> subpasses;
6800 vector<SubpassDependency> deps;
6801 vector<VkInputAttachmentAspectReference> inputAspects;
6803 attachments.push_back(Attachment(format,
6804 VK_SAMPLE_COUNT_1_BIT,
6807 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6808 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6809 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6810 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
6812 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6814 vector<AttachmentReference>(),
6815 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6816 vector<AttachmentReference>(),
6817 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6818 vector<deUint32>()));
6819 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6821 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL, inputAttachmentAspectMask)),
6822 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL)),
6823 vector<AttachmentReference>(),
6824 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6825 vector<deUint32>()));
6827 deps.push_back(SubpassDependency(0, 1,
6828 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
6829 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6831 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6832 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6833 vk::VK_DEPENDENCY_BY_REGION_BIT));
6835 deps.push_back(SubpassDependency(1, 1,
6836 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
6837 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6839 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6840 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6841 vk::VK_DEPENDENCY_BY_REGION_BIT));
6845 const VkInputAttachmentAspectReference inputAspect =
6849 VK_IMAGE_ASPECT_COLOR_BIT
6852 inputAspects.push_back(inputAspect);
6856 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
6857 const TestConfig testConfig (renderPass,
6858 renderTypes[renderTypeNdx].types,
6859 TestConfig::COMMANDBUFFERTYPES_INLINE,
6860 TestConfig::IMAGEMEMORY_STRICT,
6867 testConfigExternal.allocationKind,
6868 testConfigExternal.renderingType);
6869 const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : ""));
6871 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
6877 loadOpGroup->addChild(storeOpGroup.release());
6880 inputGroup->addChild(loadOpGroup.release());
6883 formatGroup->addChild(inputGroup.release());
6886 group->addChild(formatGroup.release());
6889 // Depth stencil formats
6890 for (size_t formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_coreDepthStencilFormats); formatNdx++)
6892 const VkFormat vkFormat = s_coreDepthStencilFormats[formatNdx];
6893 const tcu::TextureFormat format = mapVkFormat(vkFormat);
6894 const bool isStencilAttachment = hasStencilComponent(format.order);
6895 const bool isDepthAttachment = hasDepthComponent(format.order);
6896 const VkImageAspectFlags formatAspectFlags = (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
6897 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u);
6898 de::MovePtr<tcu::TestCaseGroup> formatGroup (new tcu::TestCaseGroup(testCtx, formatToName(vkFormat).c_str(), de::toString(vkFormat).c_str()));
6900 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
6902 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
6903 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
6905 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
6908 const RenderPass renderPass (vector<Attachment>(1, Attachment(vkFormat,
6909 VK_SAMPLE_COUNT_1_BIT,
6910 isDepthAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6911 isDepthAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6912 isStencilAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6913 isStencilAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6914 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6915 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6916 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6918 vector<AttachmentReference>(),
6919 vector<AttachmentReference>(),
6920 vector<AttachmentReference>(),
6921 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6922 vector<deUint32>())),
6923 vector<SubpassDependency>());
6924 const TestConfig testConfig (renderPass,
6925 renderTypes[renderTypeNdx].types,
6926 TestConfig::COMMANDBUFFERTYPES_INLINE,
6927 TestConfig::IMAGEMEMORY_STRICT,
6934 testConfigExternal.allocationKind,
6935 testConfigExternal.renderingType);
6937 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), renderTypes[renderTypeNdx].str, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
6940 if (isStencilAttachment && isDepthAttachment && loadOp != VK_ATTACHMENT_LOAD_OP_CLEAR)
6943 const RenderPass renderPass (vector<Attachment>(1, Attachment(vkFormat,
6944 VK_SAMPLE_COUNT_1_BIT,
6945 isDepthAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6946 isDepthAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6947 isStencilAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6948 isStencilAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6949 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6950 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6951 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6953 vector<AttachmentReference>(),
6954 vector<AttachmentReference>(),
6955 vector<AttachmentReference>(),
6956 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL),
6957 vector<deUint32>())),
6958 vector<SubpassDependency>());
6959 const TestConfig testConfig (renderPass,
6960 renderTypes[renderTypeNdx].types,
6961 TestConfig::COMMANDBUFFERTYPES_INLINE,
6962 TestConfig::IMAGEMEMORY_STRICT,
6969 testConfigExternal.allocationKind,
6970 testConfigExternal.renderingType);
6971 const string testName (string(renderTypes[renderTypeNdx].str) + "_depth_read_only");
6973 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
6977 const RenderPass renderPass (vector<Attachment>(1, Attachment(vkFormat,
6978 VK_SAMPLE_COUNT_1_BIT,
6979 isDepthAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6980 isDepthAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6981 isStencilAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6982 isStencilAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
6983 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6984 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
6985 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6987 vector<AttachmentReference>(),
6988 vector<AttachmentReference>(),
6989 vector<AttachmentReference>(),
6990 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL),
6991 vector<deUint32>())),
6992 vector<SubpassDependency>());
6993 const TestConfig testConfig (renderPass,
6994 renderTypes[renderTypeNdx].types,
6995 TestConfig::COMMANDBUFFERTYPES_INLINE,
6996 TestConfig::IMAGEMEMORY_STRICT,
7003 testConfigExternal.allocationKind,
7004 testConfigExternal.renderingType);
7005 const string testName (string(renderTypes[renderTypeNdx].str) + "_stencil_read_only");
7007 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7012 formatGroup->addChild(loadOpGroup.release());
7015 if (testConfigExternal.renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
7017 de::MovePtr<tcu::TestCaseGroup> inputGroup (new tcu::TestCaseGroup(testCtx, "input", "Test attachment format as input"));
7019 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
7021 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
7022 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
7024 for (size_t storeOpNdx = 0; storeOpNdx < DE_LENGTH_OF_ARRAY(storeOps); storeOpNdx++)
7026 const VkImageAspectFlags inputAttachmentAspectMask = (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2)
7028 : static_cast<VkImageAspectFlags>(0);
7029 const VkAttachmentStoreOp storeOp = storeOps[storeOpNdx].op;
7030 de::MovePtr<tcu::TestCaseGroup> storeOpGroup (new tcu::TestCaseGroup(testCtx, storeOps[storeOpNdx].str, storeOps[storeOpNdx].str));
7032 for (size_t useInputAspectNdx = 0; useInputAspectNdx < 2; useInputAspectNdx++)
7034 const bool useInputAspect = useInputAspectNdx != 0;
7036 if (testConfigExternal.renderingType == RENDERING_TYPE_RENDERPASS2 && useInputAspect)
7039 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
7042 vector<Attachment> attachments;
7043 vector<Subpass> subpasses;
7044 vector<SubpassDependency> deps;
7045 vector<VkInputAttachmentAspectReference> inputAspects;
7047 attachments.push_back(Attachment(vkFormat,
7048 VK_SAMPLE_COUNT_1_BIT,
7053 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7054 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7056 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
7057 VK_SAMPLE_COUNT_1_BIT,
7058 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7059 VK_ATTACHMENT_STORE_OP_STORE,
7060 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7061 VK_ATTACHMENT_STORE_OP_DONT_CARE,
7062 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
7063 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
7065 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7067 vector<AttachmentReference>(),
7068 vector<AttachmentReference>(),
7069 vector<AttachmentReference>(),
7070 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7071 vector<deUint32>()));
7072 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7074 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
7075 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
7076 vector<AttachmentReference>(),
7077 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
7078 vector<deUint32>()));
7080 deps.push_back(SubpassDependency(0, 1,
7081 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7082 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7084 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7085 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7090 const VkInputAttachmentAspectReference inputAspect =
7094 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7095 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7098 inputAspects.push_back(inputAspect);
7102 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7103 const TestConfig testConfig (renderPass,
7104 renderTypes[renderTypeNdx].types,
7105 TestConfig::COMMANDBUFFERTYPES_INLINE,
7106 TestConfig::IMAGEMEMORY_STRICT,
7113 testConfigExternal.allocationKind,
7114 testConfigExternal.renderingType);
7115 const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : ""));
7117 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7121 vector<Attachment> attachments;
7122 vector<Subpass> subpasses;
7123 vector<SubpassDependency> deps;
7124 vector<VkInputAttachmentAspectReference> inputAspects;
7126 attachments.push_back(Attachment(vkFormat,
7127 VK_SAMPLE_COUNT_1_BIT,
7130 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7131 VK_ATTACHMENT_STORE_OP_DONT_CARE,
7132 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7133 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7135 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7137 vector<AttachmentReference>(),
7138 vector<AttachmentReference>(),
7139 vector<AttachmentReference>(),
7140 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7141 vector<deUint32>()));
7142 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7144 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL, inputAttachmentAspectMask)),
7145 vector<AttachmentReference>(),
7146 vector<AttachmentReference>(),
7147 AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL),
7148 vector<deUint32>()));
7150 deps.push_back(SubpassDependency(0, 1,
7151 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7152 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7154 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7155 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7156 vk::VK_DEPENDENCY_BY_REGION_BIT));
7158 deps.push_back(SubpassDependency(1, 1,
7159 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7160 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7161 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7162 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7163 vk::VK_DEPENDENCY_BY_REGION_BIT));
7168 const VkInputAttachmentAspectReference inputAspect =
7173 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7174 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7177 inputAspects.push_back(inputAspect);
7181 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7182 const TestConfig testConfig (renderPass,
7183 renderTypes[renderTypeNdx].types,
7184 TestConfig::COMMANDBUFFERTYPES_INLINE,
7185 TestConfig::IMAGEMEMORY_STRICT,
7192 testConfigExternal.allocationKind,
7193 testConfigExternal.renderingType);
7194 const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : ""));
7196 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7200 if (isStencilAttachment && isDepthAttachment)
7204 vector<Attachment> attachments;
7205 vector<Subpass> subpasses;
7206 vector<SubpassDependency> deps;
7207 vector<VkInputAttachmentAspectReference> inputAspects;
7209 attachments.push_back(Attachment(vkFormat,
7210 VK_SAMPLE_COUNT_1_BIT,
7215 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7216 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7218 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
7219 VK_SAMPLE_COUNT_1_BIT,
7220 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7221 VK_ATTACHMENT_STORE_OP_STORE,
7222 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7223 VK_ATTACHMENT_STORE_OP_DONT_CARE,
7224 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
7225 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
7227 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7229 vector<AttachmentReference>(),
7230 vector<AttachmentReference>(),
7231 vector<AttachmentReference>(),
7232 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7233 vector<deUint32>()));
7234 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7236 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL, inputAttachmentAspectMask)),
7237 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
7238 vector<AttachmentReference>(),
7239 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
7240 vector<deUint32>()));
7242 deps.push_back(SubpassDependency(0, 1,
7243 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7244 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7246 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7247 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7252 const VkInputAttachmentAspectReference inputAspect =
7257 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7258 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7261 inputAspects.push_back(inputAspect);
7265 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7266 const TestConfig testConfig (renderPass,
7267 renderTypes[renderTypeNdx].types,
7268 TestConfig::COMMANDBUFFERTYPES_INLINE,
7269 TestConfig::IMAGEMEMORY_STRICT,
7276 testConfigExternal.allocationKind,
7277 testConfigExternal.renderingType);
7278 const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : "") + "_depth_read_only");
7280 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7284 vector<Attachment> attachments;
7285 vector<Subpass> subpasses;
7286 vector<SubpassDependency> deps;
7287 vector<VkInputAttachmentAspectReference> inputAspects;
7289 attachments.push_back(Attachment(vkFormat,
7290 VK_SAMPLE_COUNT_1_BIT,
7295 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7296 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7298 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7300 vector<AttachmentReference>(),
7301 vector<AttachmentReference>(),
7302 vector<AttachmentReference>(),
7303 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7304 vector<deUint32>()));
7305 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7307 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL, inputAttachmentAspectMask)),
7308 vector<AttachmentReference>(),
7309 vector<AttachmentReference>(),
7310 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL),
7311 vector<deUint32>()));
7313 deps.push_back(SubpassDependency(0, 1,
7314 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7315 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7317 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7318 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7319 vk::VK_DEPENDENCY_BY_REGION_BIT));
7321 deps.push_back(SubpassDependency(1, 1,
7322 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7323 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7325 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7326 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7327 vk::VK_DEPENDENCY_BY_REGION_BIT));
7331 const VkInputAttachmentAspectReference inputAspect =
7336 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7337 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7340 inputAspects.push_back(inputAspect);
7344 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7345 const TestConfig testConfig (renderPass,
7346 renderTypes[renderTypeNdx].types,
7347 TestConfig::COMMANDBUFFERTYPES_INLINE,
7348 TestConfig::IMAGEMEMORY_STRICT,
7355 testConfigExternal.allocationKind,
7356 testConfigExternal.renderingType);
7357 const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : "") + "_depth_read_only");
7359 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7362 // Stencil read only
7364 vector<Attachment> attachments;
7365 vector<Subpass> subpasses;
7366 vector<SubpassDependency> deps;
7367 vector<VkInputAttachmentAspectReference> inputAspects;
7369 attachments.push_back(Attachment(vkFormat,
7370 VK_SAMPLE_COUNT_1_BIT,
7375 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7376 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7378 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
7379 VK_SAMPLE_COUNT_1_BIT,
7380 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7381 VK_ATTACHMENT_STORE_OP_STORE,
7382 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
7383 VK_ATTACHMENT_STORE_OP_DONT_CARE,
7384 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
7385 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
7387 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7389 vector<AttachmentReference>(),
7390 vector<AttachmentReference>(),
7391 vector<AttachmentReference>(),
7392 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7393 vector<deUint32>()));
7394 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7396 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
7397 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
7398 vector<AttachmentReference>(),
7399 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
7400 vector<deUint32>()));
7402 deps.push_back(SubpassDependency(0, 1,
7403 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
7404 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7406 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7407 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7412 const VkInputAttachmentAspectReference inputAspect =
7417 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7418 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7421 inputAspects.push_back(inputAspect);
7425 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7426 const TestConfig testConfig (renderPass,
7427 renderTypes[renderTypeNdx].types,
7428 TestConfig::COMMANDBUFFERTYPES_INLINE,
7429 TestConfig::IMAGEMEMORY_STRICT,
7436 testConfigExternal.allocationKind,
7437 testConfigExternal.renderingType);
7438 const string testName (renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : "") + "_stencil_read_only");
7440 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7444 vector<Attachment> attachments;
7445 vector<Subpass> subpasses;
7446 vector<SubpassDependency> deps;
7447 vector<VkInputAttachmentAspectReference> inputAspects;
7449 attachments.push_back(Attachment(vkFormat,
7450 VK_SAMPLE_COUNT_1_BIT,
7455 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
7456 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
7458 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7460 vector<AttachmentReference>(),
7461 vector<AttachmentReference>(),
7462 vector<AttachmentReference>(),
7463 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
7464 vector<deUint32>()));
7465 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
7467 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL, inputAttachmentAspectMask)),
7468 vector<AttachmentReference>(),
7469 vector<AttachmentReference>(),
7470 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL),
7471 vector<deUint32>()));
7473 deps.push_back(SubpassDependency(0, 1,
7474 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7475 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7477 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7478 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7479 vk::VK_DEPENDENCY_BY_REGION_BIT));
7481 deps.push_back(SubpassDependency(1, 1,
7482 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
7483 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
7485 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
7486 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
7487 vk::VK_DEPENDENCY_BY_REGION_BIT));
7492 const VkInputAttachmentAspectReference inputAspect =
7497 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
7498 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
7501 inputAspects.push_back(inputAspect);
7505 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
7506 const TestConfig testConfig (renderPass,
7507 renderTypes[renderTypeNdx].types,
7508 TestConfig::COMMANDBUFFERTYPES_INLINE,
7509 TestConfig::IMAGEMEMORY_STRICT,
7516 testConfigExternal.allocationKind,
7517 testConfigExternal.renderingType);
7518 const string testName (string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : "") + "_stencil_read_only");
7520 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), testName, string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, testConfig);
7527 loadOpGroup->addChild(storeOpGroup.release());
7530 inputGroup->addChild(loadOpGroup.release());
7533 formatGroup->addChild(inputGroup.release());
7536 group->addChild(formatGroup.release());
7540 void addRenderPassTests (tcu::TestCaseGroup* group, const AllocationKind allocationKind, const RenderingType renderingType)
7542 const TestConfigExternal testConfigExternal (allocationKind, renderingType);
7544 addTestGroup(group, "simple", "Simple basic render pass tests", addSimpleTests, testConfigExternal);
7545 addTestGroup(group, "formats", "Tests for different image formats.", addFormatTests, testConfigExternal);
7546 addTestGroup(group, "attachment", "Attachment format and count tests with load and store ops and image layouts", addAttachmentTests, testConfigExternal);
7547 addTestGroup(group, "attachment_write_mask", "Attachment write mask tests", addAttachmentWriteMaskTests, testConfigExternal);
7549 if (renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
7550 addTestGroup(group, "attachment_allocation", "Attachment allocation tests", addAttachmentAllocationTests, testConfigExternal);
7553 de::MovePtr<tcu::TestCaseGroup> createSuballocationTests(tcu::TestContext& testCtx, RenderingType renderingType)
7555 de::MovePtr<tcu::TestCaseGroup> suballocationTestsGroup(new tcu::TestCaseGroup(testCtx, "suballocation", "Suballocation RenderPass Tests"));
7557 addRenderPassTests(suballocationTestsGroup.get(), ALLOCATION_KIND_SUBALLOCATED, renderingType);
7559 return suballocationTestsGroup;
7562 de::MovePtr<tcu::TestCaseGroup> createDedicatedAllocationTests(tcu::TestContext& testCtx, RenderingType renderingType)
7564 de::MovePtr<tcu::TestCaseGroup> dedicatedAllocationTestsGroup(new tcu::TestCaseGroup(testCtx, "dedicated_allocation", "RenderPass Tests For Dedicated Allocation"));
7566 addRenderPassTests(dedicatedAllocationTestsGroup.get(), ALLOCATION_KIND_DEDICATED, renderingType);
7568 return dedicatedAllocationTestsGroup;
7571 tcu::TestCaseGroup* createRenderPassTestsInternal (tcu::TestContext& testCtx, RenderingType renderingType)
7573 const char* renderingTestsGroupName = (renderingType == RENDERING_TYPE_RENDERPASS_LEGACY) ? "renderpass" :
7574 (renderingType == RENDERING_TYPE_RENDERPASS2) ? "renderpass2" :
7575 (renderingType == RENDERING_TYPE_DYNAMIC_RENDERING) ? "dynamic_rendering" :
7577 const char* renderingTestsGroupDescription = (renderingType == RENDERING_TYPE_RENDERPASS_LEGACY) ? "RenderPass Tests" :
7578 (renderingType == RENDERING_TYPE_RENDERPASS2) ? "RenderPass2 Tests" :
7579 (renderingType == RENDERING_TYPE_DYNAMIC_RENDERING) ? "Dynamic Rendering Tests" :
7582 de::MovePtr<tcu::TestCaseGroup> renderingTests (new tcu::TestCaseGroup(testCtx, renderingTestsGroupName, renderingTestsGroupDescription));
7583 de::MovePtr<tcu::TestCaseGroup> suballocationTestGroup = createSuballocationTests(testCtx, renderingType);
7584 de::MovePtr<tcu::TestCaseGroup> dedicatedAllocationTestGroup = createDedicatedAllocationTests(testCtx, renderingType);
7586 switch (renderingType)
7588 case RENDERING_TYPE_RENDERPASS_LEGACY:
7589 suballocationTestGroup->addChild(createRenderPassMultisampleTests(testCtx));
7590 suballocationTestGroup->addChild(createRenderPassMultisampleResolveTests(testCtx));
7591 suballocationTestGroup->addChild(createRenderPassSubpassDependencyTests(testCtx));
7592 suballocationTestGroup->addChild(createRenderPassSampleReadTests(testCtx));
7593 suballocationTestGroup->addChild(createRenderPassSparseRenderTargetTests(testCtx));
7595 renderingTests->addChild(createRenderPassMultipleSubpassesMultipleCommandBuffersTests(testCtx));
7598 case RENDERING_TYPE_RENDERPASS2:
7599 suballocationTestGroup->addChild(createRenderPass2MultisampleTests(testCtx));
7600 suballocationTestGroup->addChild(createRenderPass2MultisampleResolveTests(testCtx));
7601 suballocationTestGroup->addChild(createRenderPass2SubpassDependencyTests(testCtx));
7602 suballocationTestGroup->addChild(createRenderPass2SampleReadTests(testCtx));
7603 suballocationTestGroup->addChild(createRenderPass2SparseRenderTargetTests(testCtx));
7605 renderingTests->addChild(createRenderPass2DepthStencilResolveTests(testCtx));
7608 case RENDERING_TYPE_DYNAMIC_RENDERING:
7609 suballocationTestGroup->addChild(createDynamicRenderingMultisampleResolveTests(testCtx));
7610 suballocationTestGroup->addChild(createDynamicRenderingSparseRenderTargetTests(testCtx));
7612 renderingTests->addChild(createDynamicRenderingBasicTests(testCtx));
7616 if (renderingType != RENDERING_TYPE_DYNAMIC_RENDERING)
7618 suballocationTestGroup->addChild(createRenderPassUnusedAttachmentTests(testCtx, renderingType));
7619 suballocationTestGroup->addChild(createRenderPassUnusedAttachmentSparseFillingTests(testCtx, renderingType));
7622 suballocationTestGroup->addChild(createRenderPassUnusedClearAttachmentTests(testCtx, renderingType));
7623 suballocationTestGroup->addChild(createRenderPassLoadStoreOpNoneTests(testCtx, renderingType));
7625 renderingTests->addChild(suballocationTestGroup.release());
7626 renderingTests->addChild(dedicatedAllocationTestGroup.release());
7627 renderingTests->addChild(createFragmentDensityMapTests(testCtx, renderingType));
7629 return renderingTests.release();
7634 tcu::TestCaseGroup* createRenderPassTests (tcu::TestContext& testCtx)
7636 return createRenderPassTestsInternal(testCtx, RENDERING_TYPE_RENDERPASS_LEGACY);
7639 tcu::TestCaseGroup* createRenderPass2Tests (tcu::TestContext& testCtx)
7641 return createRenderPassTestsInternal(testCtx, RENDERING_TYPE_RENDERPASS2);
7644 tcu::TestCaseGroup* createDynamicRenderingTests(tcu::TestContext& testCtx)
7646 return createRenderPassTestsInternal(testCtx, RENDERING_TYPE_DYNAMIC_RENDERING);