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"
26 #include "vktRenderPassMultisampleTests.hpp"
27 #include "vktRenderPassMultisampleResolveTests.hpp"
29 #include "vktTestCaseUtil.hpp"
30 #include "vktTestGroupUtil.hpp"
33 #include "vkDeviceUtil.hpp"
34 #include "vkImageUtil.hpp"
35 #include "vkMemUtil.hpp"
36 #include "vkPlatform.hpp"
37 #include "vkPrograms.hpp"
38 #include "vkQueryUtil.hpp"
40 #include "vkRefUtil.hpp"
41 #include "vkStrUtil.hpp"
42 #include "vkTypeUtil.hpp"
44 #include "tcuFloat.hpp"
45 #include "tcuFormatUtil.hpp"
46 #include "tcuMaybe.hpp"
47 #include "tcuResultCollector.hpp"
48 #include "tcuTestLog.hpp"
49 #include "tcuTextureUtil.hpp"
50 #include "tcuVectorUtil.hpp"
52 #include "deRandom.hpp"
53 #include "deSTLUtil.hpp"
54 #include "deSharedPtr.hpp"
55 #include "deStringUtil.hpp"
56 #include "deUniquePtr.hpp"
77 using tcu::ConstPixelBufferAccess;
78 using tcu::PixelBufferAccess;
95 ALLOCATION_KIND_SUBALLOCATED,
96 ALLOCATION_KIND_DEDICATED,
99 de::MovePtr<Allocation> allocateBuffer (const InstanceInterface& vki,
100 const DeviceInterface& vkd,
101 const VkPhysicalDevice& physDevice,
102 const VkDevice device,
103 const VkBuffer& buffer,
104 const MemoryRequirement requirement,
105 Allocator& allocator,
106 AllocationKind allocationKind)
108 switch (allocationKind)
110 case ALLOCATION_KIND_SUBALLOCATED:
112 const VkMemoryRequirements memoryRequirements = getBufferMemoryRequirements(vkd, device, buffer);
114 return allocator.allocate(memoryRequirements, requirement);
117 case ALLOCATION_KIND_DEDICATED:
119 return allocateDedicated(vki, vkd, physDevice, device, buffer, requirement);
124 TCU_THROW(InternalError, "Invalid allocation kind");
129 de::MovePtr<Allocation> allocateImage (const InstanceInterface& vki,
130 const DeviceInterface& vkd,
131 const VkPhysicalDevice& physDevice,
132 const VkDevice device,
133 const VkImage& image,
134 const MemoryRequirement requirement,
135 Allocator& allocator,
136 AllocationKind allocationKind)
138 switch (allocationKind)
140 case ALLOCATION_KIND_SUBALLOCATED:
142 const VkMemoryRequirements memoryRequirements = getImageMemoryRequirements(vkd, device, image);
144 return allocator.allocate(memoryRequirements, requirement);
147 case ALLOCATION_KIND_DEDICATED:
149 return allocateDedicated(vki, vkd, physDevice, device, image, requirement);
154 TCU_THROW(InternalError, "Invalid allocation kind");
167 const char* boolOpToString (BoolOp op)
184 DE_FATAL("Unknown boolean operation.");
189 bool performBoolOp (BoolOp op, bool a, bool b)
206 DE_FATAL("Unknown boolean operation.");
211 BoolOp boolOpFromIndex (size_t index)
221 return ops[index % DE_LENGTH_OF_ARRAY(ops)];
224 Move<VkFramebuffer> createFramebuffer (const DeviceInterface& vk,
226 VkFramebufferCreateFlags pCreateInfo_flags,
227 VkRenderPass pCreateInfo_renderPass,
228 deUint32 pCreateInfo_attachmentCount,
229 const VkImageView* pCreateInfo_pAttachments,
230 deUint32 pCreateInfo_width,
231 deUint32 pCreateInfo_height,
232 deUint32 pCreateInfo_layers)
234 const VkFramebufferCreateInfo pCreateInfo =
236 VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
239 pCreateInfo_renderPass,
240 pCreateInfo_attachmentCount,
241 pCreateInfo_pAttachments,
246 return createFramebuffer(vk, device, &pCreateInfo);
249 Move<VkImage> createImage (const DeviceInterface& vk,
251 VkImageCreateFlags pCreateInfo_flags,
252 VkImageType pCreateInfo_imageType,
253 VkFormat pCreateInfo_format,
254 VkExtent3D pCreateInfo_extent,
255 deUint32 pCreateInfo_mipLevels,
256 deUint32 pCreateInfo_arrayLayers,
257 VkSampleCountFlagBits pCreateInfo_samples,
258 VkImageTiling pCreateInfo_tiling,
259 VkImageUsageFlags pCreateInfo_usage,
260 VkSharingMode pCreateInfo_sharingMode,
261 deUint32 pCreateInfo_queueFamilyCount,
262 const deUint32* pCreateInfo_pQueueFamilyIndices,
263 VkImageLayout pCreateInfo_initialLayout)
265 const VkImageCreateInfo pCreateInfo =
267 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
270 pCreateInfo_imageType,
273 pCreateInfo_mipLevels,
274 pCreateInfo_arrayLayers,
278 pCreateInfo_sharingMode,
279 pCreateInfo_queueFamilyCount,
280 pCreateInfo_pQueueFamilyIndices,
281 pCreateInfo_initialLayout
283 return createImage(vk, device, &pCreateInfo);
286 void bindBufferMemory (const DeviceInterface& vk, VkDevice device, VkBuffer buffer, VkDeviceMemory mem, VkDeviceSize memOffset)
288 VK_CHECK(vk.bindBufferMemory(device, buffer, mem, memOffset));
291 void bindImageMemory (const DeviceInterface& vk, VkDevice device, VkImage image, VkDeviceMemory mem, VkDeviceSize memOffset)
293 VK_CHECK(vk.bindImageMemory(device, image, mem, memOffset));
296 Move<VkImageView> createImageView (const DeviceInterface& vk,
298 VkImageViewCreateFlags pCreateInfo_flags,
299 VkImage pCreateInfo_image,
300 VkImageViewType pCreateInfo_viewType,
301 VkFormat pCreateInfo_format,
302 VkComponentMapping pCreateInfo_components,
303 VkImageSubresourceRange pCreateInfo_subresourceRange)
305 const VkImageViewCreateInfo pCreateInfo =
307 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
311 pCreateInfo_viewType,
313 pCreateInfo_components,
314 pCreateInfo_subresourceRange,
316 return createImageView(vk, device, &pCreateInfo);
319 Move<VkBuffer> createBuffer (const DeviceInterface& vk,
321 VkBufferCreateFlags pCreateInfo_flags,
322 VkDeviceSize pCreateInfo_size,
323 VkBufferUsageFlags pCreateInfo_usage,
324 VkSharingMode pCreateInfo_sharingMode,
325 deUint32 pCreateInfo_queueFamilyCount,
326 const deUint32* pCreateInfo_pQueueFamilyIndices)
328 const VkBufferCreateInfo pCreateInfo =
330 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
335 pCreateInfo_sharingMode,
336 pCreateInfo_queueFamilyCount,
337 pCreateInfo_pQueueFamilyIndices,
339 return createBuffer(vk, device, &pCreateInfo);
342 void cmdBeginRenderPass (const DeviceInterface& vk,
343 VkCommandBuffer cmdBuffer,
344 VkRenderPass pRenderPassBegin_renderPass,
345 VkFramebuffer pRenderPassBegin_framebuffer,
346 VkRect2D pRenderPassBegin_renderArea,
347 deUint32 pRenderPassBegin_clearValueCount,
348 const VkClearValue* pRenderPassBegin_pAttachmentClearValues,
349 VkSubpassContents contents)
351 const VkRenderPassBeginInfo pRenderPassBegin =
353 VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
355 pRenderPassBegin_renderPass,
356 pRenderPassBegin_framebuffer,
357 pRenderPassBegin_renderArea,
358 pRenderPassBegin_clearValueCount,
359 pRenderPassBegin_pAttachmentClearValues,
361 vk.cmdBeginRenderPass(cmdBuffer, &pRenderPassBegin, contents);
364 void beginCommandBuffer (const DeviceInterface& vk,
365 VkCommandBuffer cmdBuffer,
366 VkCommandBufferUsageFlags pBeginInfo_flags,
367 VkRenderPass pInheritanceInfo_renderPass,
368 deUint32 pInheritanceInfo_subpass,
369 VkFramebuffer pInheritanceInfo_framebuffer,
370 VkBool32 pInheritanceInfo_occlusionQueryEnable,
371 VkQueryControlFlags pInheritanceInfo_queryFlags,
372 VkQueryPipelineStatisticFlags pInheritanceInfo_pipelineStatistics)
374 const VkCommandBufferInheritanceInfo pInheritanceInfo =
376 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO,
378 pInheritanceInfo_renderPass,
379 pInheritanceInfo_subpass,
380 pInheritanceInfo_framebuffer,
381 pInheritanceInfo_occlusionQueryEnable,
382 pInheritanceInfo_queryFlags,
383 pInheritanceInfo_pipelineStatistics,
385 const VkCommandBufferBeginInfo pBeginInfo =
387 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
392 VK_CHECK(vk.beginCommandBuffer(cmdBuffer, &pBeginInfo));
395 void endCommandBuffer (const DeviceInterface& vk, VkCommandBuffer cmdBuffer)
397 VK_CHECK(vk.endCommandBuffer(cmdBuffer));
400 void queueSubmit (const DeviceInterface& vk, VkQueue queue, deUint32 cmdBufferCount, const VkCommandBuffer* pCmdBuffers, VkFence fence)
402 const VkSubmitInfo submitInfo =
404 VK_STRUCTURE_TYPE_SUBMIT_INFO,
406 0u, // waitSemaphoreCount
407 (const VkSemaphore*)DE_NULL, // pWaitSemaphores
408 (const VkPipelineStageFlags*)DE_NULL,
409 cmdBufferCount, // commandBufferCount
411 0u, // signalSemaphoreCount
412 (const VkSemaphore*)DE_NULL, // pSignalSemaphores
414 VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo, fence));
417 void waitForFences (const DeviceInterface& vk, VkDevice device, deUint32 fenceCount, const VkFence* pFences, VkBool32 waitAll, deUint64 timeout)
419 VK_CHECK(vk.waitForFences(device, fenceCount, pFences, waitAll, timeout));
422 VkImageAspectFlags getImageAspectFlags (VkFormat vkFormat)
424 const tcu::TextureFormat format = mapVkFormat(vkFormat);
426 DE_STATIC_ASSERT(tcu::TextureFormat::CHANNELORDER_LAST == 21);
428 switch (format.order)
430 case tcu::TextureFormat::DS:
431 return VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_DEPTH_BIT;
433 case tcu::TextureFormat::D:
434 return VK_IMAGE_ASPECT_DEPTH_BIT;
436 case tcu::TextureFormat::S:
437 return VK_IMAGE_ASPECT_STENCIL_BIT;
440 return VK_IMAGE_ASPECT_COLOR_BIT;
444 VkAccessFlags getAllMemoryReadFlags (void)
446 return VK_ACCESS_TRANSFER_READ_BIT
447 | VK_ACCESS_UNIFORM_READ_BIT
448 | VK_ACCESS_HOST_READ_BIT
449 | VK_ACCESS_INDEX_READ_BIT
450 | VK_ACCESS_SHADER_READ_BIT
451 | VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT
452 | VK_ACCESS_INDIRECT_COMMAND_READ_BIT
453 | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT
454 | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT
455 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT;
458 VkAccessFlags getAllMemoryWriteFlags (void)
460 return VK_ACCESS_TRANSFER_WRITE_BIT
461 | VK_ACCESS_HOST_WRITE_BIT
462 | VK_ACCESS_SHADER_WRITE_BIT
463 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT
464 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
467 VkAccessFlags getMemoryFlagsForLayout (const VkImageLayout layout)
471 case VK_IMAGE_LAYOUT_GENERAL: return getAllMemoryReadFlags() | getAllMemoryWriteFlags();
472 case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: return VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
473 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: return VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
474 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: return VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT;
475 case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL: return VK_ACCESS_SHADER_READ_BIT;
476 case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL: return VK_ACCESS_TRANSFER_READ_BIT;
477 case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL: return VK_ACCESS_TRANSFER_WRITE_BIT;
478 case VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR: return VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | VK_ACCESS_SHADER_READ_BIT;
479 case VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR: return VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | VK_ACCESS_SHADER_READ_BIT;
481 return (VkAccessFlags)0;
485 VkPipelineStageFlags getAllPipelineStageFlags (void)
487 return VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT
488 | VK_PIPELINE_STAGE_TRANSFER_BIT
489 | VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT
490 | VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT
491 | VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT
492 | VK_PIPELINE_STAGE_VERTEX_INPUT_BIT
493 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT
494 | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
495 | VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT
496 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
497 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT
498 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
499 | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
502 class AttachmentReference
505 AttachmentReference (deUint32 attachment,
506 VkImageLayout layout)
507 : m_attachment (attachment)
512 deUint32 getAttachment (void) const { return m_attachment; }
513 VkImageLayout getImageLayout (void) const { return m_layout; }
516 deUint32 m_attachment;
517 VkImageLayout m_layout;
523 Subpass (VkPipelineBindPoint pipelineBindPoint,
524 VkSubpassDescriptionFlags flags,
525 const vector<AttachmentReference>& inputAttachments,
526 const vector<AttachmentReference>& colorAttachments,
527 const vector<AttachmentReference>& resolveAttachments,
528 AttachmentReference depthStencilAttachment,
529 const vector<deUint32>& preserveAttachments)
530 : m_pipelineBindPoint (pipelineBindPoint)
532 , m_inputAttachments (inputAttachments)
533 , m_colorAttachments (colorAttachments)
534 , m_resolveAttachments (resolveAttachments)
535 , m_depthStencilAttachment (depthStencilAttachment)
536 , m_preserveAttachments (preserveAttachments)
540 VkPipelineBindPoint getPipelineBindPoint (void) const { return m_pipelineBindPoint; }
541 VkSubpassDescriptionFlags getFlags (void) const { return m_flags; }
542 const vector<AttachmentReference>& getInputAttachments (void) const { return m_inputAttachments; }
543 const vector<AttachmentReference>& getColorAttachments (void) const { return m_colorAttachments; }
544 const vector<AttachmentReference>& getResolveAttachments (void) const { return m_resolveAttachments; }
545 const AttachmentReference& getDepthStencilAttachment (void) const { return m_depthStencilAttachment; }
546 const vector<deUint32>& getPreserveAttachments (void) const { return m_preserveAttachments; }
549 VkPipelineBindPoint m_pipelineBindPoint;
550 VkSubpassDescriptionFlags m_flags;
552 vector<AttachmentReference> m_inputAttachments;
553 vector<AttachmentReference> m_colorAttachments;
554 vector<AttachmentReference> m_resolveAttachments;
555 AttachmentReference m_depthStencilAttachment;
557 vector<deUint32> m_preserveAttachments;
560 class SubpassDependency
563 SubpassDependency (deUint32 srcPass,
566 VkPipelineStageFlags srcStageMask,
567 VkPipelineStageFlags dstStageMask,
569 VkAccessFlags outputMask,
570 VkAccessFlags inputMask,
572 VkDependencyFlags flags)
573 : m_srcPass (srcPass)
574 , m_dstPass (dstPass)
576 , m_srcStageMask (srcStageMask)
577 , m_dstStageMask (dstStageMask)
579 , m_outputMask (outputMask)
580 , m_inputMask (inputMask)
585 deUint32 getSrcPass (void) const { return m_srcPass; }
586 deUint32 getDstPass (void) const { return m_dstPass; }
588 VkPipelineStageFlags getSrcStageMask (void) const { return m_srcStageMask; }
589 VkPipelineStageFlags getDstStageMask (void) const { return m_dstStageMask; }
591 VkAccessFlags getOutputMask (void) const { return m_outputMask; }
592 VkAccessFlags getInputMask (void) const { return m_inputMask; }
594 VkDependencyFlags getFlags (void) const { return m_flags; }
600 VkPipelineStageFlags m_srcStageMask;
601 VkPipelineStageFlags m_dstStageMask;
603 VkAccessFlags m_outputMask;
604 VkAccessFlags m_inputMask;
605 VkDependencyFlags m_flags;
611 Attachment (VkFormat format,
612 VkSampleCountFlagBits samples,
614 VkAttachmentLoadOp loadOp,
615 VkAttachmentStoreOp storeOp,
617 VkAttachmentLoadOp stencilLoadOp,
618 VkAttachmentStoreOp stencilStoreOp,
620 VkImageLayout initialLayout,
621 VkImageLayout finalLayout)
623 , m_samples (samples)
626 , m_storeOp (storeOp)
628 , m_stencilLoadOp (stencilLoadOp)
629 , m_stencilStoreOp (stencilStoreOp)
631 , m_initialLayout (initialLayout)
632 , m_finalLayout (finalLayout)
636 VkFormat getFormat (void) const { return m_format; }
637 VkSampleCountFlagBits getSamples (void) const { return m_samples; }
639 VkAttachmentLoadOp getLoadOp (void) const { return m_loadOp; }
640 VkAttachmentStoreOp getStoreOp (void) const { return m_storeOp; }
643 VkAttachmentLoadOp getStencilLoadOp (void) const { return m_stencilLoadOp; }
644 VkAttachmentStoreOp getStencilStoreOp (void) const { return m_stencilStoreOp; }
646 VkImageLayout getInitialLayout (void) const { return m_initialLayout; }
647 VkImageLayout getFinalLayout (void) const { return m_finalLayout; }
651 VkSampleCountFlagBits m_samples;
653 VkAttachmentLoadOp m_loadOp;
654 VkAttachmentStoreOp m_storeOp;
656 VkAttachmentLoadOp m_stencilLoadOp;
657 VkAttachmentStoreOp m_stencilStoreOp;
659 VkImageLayout m_initialLayout;
660 VkImageLayout m_finalLayout;
666 RenderPass (const vector<Attachment>& attachments,
667 const vector<Subpass>& subpasses,
668 const vector<SubpassDependency>& dependencies,
669 const vector<VkInputAttachmentAspectReferenceKHR> inputAspects = vector<VkInputAttachmentAspectReferenceKHR>())
670 : m_attachments (attachments)
671 , m_subpasses (subpasses)
672 , m_dependencies (dependencies)
673 , m_inputAspects (inputAspects)
677 const vector<Attachment>& getAttachments (void) const { return m_attachments; }
678 const vector<Subpass>& getSubpasses (void) const { return m_subpasses; }
679 const vector<SubpassDependency>& getDependencies (void) const { return m_dependencies; }
680 const vector<VkInputAttachmentAspectReferenceKHR> getInputAspects (void) const { return m_inputAspects; }
683 const vector<Attachment> m_attachments;
684 const vector<Subpass> m_subpasses;
685 const vector<SubpassDependency> m_dependencies;
686 const vector<VkInputAttachmentAspectReferenceKHR> m_inputAspects;
693 RENDERTYPES_NONE = 0,
694 RENDERTYPES_CLEAR = (1<<1),
695 RENDERTYPES_DRAW = (1<<2)
698 enum CommandBufferTypes
700 COMMANDBUFFERTYPES_INLINE = (1<<0),
701 COMMANDBUFFERTYPES_SECONDARY = (1<<1)
706 IMAGEMEMORY_STRICT = (1<<0),
707 IMAGEMEMORY_LAZY = (1<<1)
710 TestConfig (const RenderPass& renderPass_,
711 RenderTypes renderTypes_,
712 CommandBufferTypes commandBufferTypes_,
713 ImageMemory imageMemory_,
714 const UVec2& targetSize_,
715 const UVec2& renderPos_,
716 const UVec2& renderSize_,
718 AllocationKind allocationKind_)
719 : renderPass (renderPass_)
720 , renderTypes (renderTypes_)
721 , commandBufferTypes (commandBufferTypes_)
722 , imageMemory (imageMemory_)
723 , targetSize (targetSize_)
724 , renderPos (renderPos_)
725 , renderSize (renderSize_)
727 , allocationKind (allocationKind_)
731 RenderPass renderPass;
732 RenderTypes renderTypes;
733 CommandBufferTypes commandBufferTypes;
734 ImageMemory imageMemory;
739 AllocationKind allocationKind;
742 TestConfig::RenderTypes operator| (TestConfig::RenderTypes a, TestConfig::RenderTypes b)
744 return (TestConfig::RenderTypes)(((deUint32)a) | ((deUint32)b));
747 TestConfig::CommandBufferTypes operator| (TestConfig::CommandBufferTypes a, TestConfig::CommandBufferTypes b)
749 return (TestConfig::CommandBufferTypes)(((deUint32)a) | ((deUint32)b));
752 TestConfig::ImageMemory operator| (TestConfig::ImageMemory a, TestConfig::ImageMemory b)
754 return (TestConfig::ImageMemory)(((deUint32)a) | ((deUint32)b));
757 void logRenderPassInfo (TestLog& log,
758 const RenderPass& renderPass)
760 const tcu::ScopedLogSection section (log, "RenderPass", "RenderPass");
763 const tcu::ScopedLogSection attachmentsSection (log, "Attachments", "Attachments");
764 const vector<Attachment>& attachments = renderPass.getAttachments();
766 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
768 const tcu::ScopedLogSection attachmentSection (log, "Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx));
769 const Attachment& attachment = attachments[attachmentNdx];
771 log << TestLog::Message << "Format: " << attachment.getFormat() << TestLog::EndMessage;
772 log << TestLog::Message << "Samples: " << attachment.getSamples() << TestLog::EndMessage;
774 log << TestLog::Message << "LoadOp: " << attachment.getLoadOp() << TestLog::EndMessage;
775 log << TestLog::Message << "StoreOp: " << attachment.getStoreOp() << TestLog::EndMessage;
777 log << TestLog::Message << "StencilLoadOp: " << attachment.getStencilLoadOp() << TestLog::EndMessage;
778 log << TestLog::Message << "StencilStoreOp: " << attachment.getStencilStoreOp() << TestLog::EndMessage;
780 log << TestLog::Message << "InitialLayout: " << attachment.getInitialLayout() << TestLog::EndMessage;
781 log << TestLog::Message << "FinalLayout: " << attachment.getFinalLayout() << TestLog::EndMessage;
785 if (!renderPass.getInputAspects().empty())
787 const tcu::ScopedLogSection inputAspectSection (log, "InputAspects", "InputAspects");
789 for (size_t aspectNdx = 0; aspectNdx < renderPass.getInputAspects().size(); aspectNdx++)
791 const VkInputAttachmentAspectReferenceKHR& inputAspect (renderPass.getInputAspects()[aspectNdx]);
793 log << TestLog::Message << "Subpass: " << inputAspect.subpass << TestLog::EndMessage;
794 log << TestLog::Message << "InputAttachmentIndex: " << inputAspect.inputAttachmentIndex << TestLog::EndMessage;
795 log << TestLog::Message << "AspectFlags: " << getImageAspectFlagsStr(inputAspect.aspectMask) << TestLog::EndMessage;
800 const tcu::ScopedLogSection subpassesSection (log, "Subpasses", "Subpasses");
801 const vector<Subpass>& subpasses = renderPass.getSubpasses();
803 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
805 const tcu::ScopedLogSection subpassSection (log, "Subpass" + de::toString(subpassNdx), "Subpass " + de::toString(subpassNdx));
806 const Subpass& subpass = subpasses[subpassNdx];
808 const vector<AttachmentReference>& inputAttachments = subpass.getInputAttachments();
809 const vector<AttachmentReference>& colorAttachments = subpass.getColorAttachments();
810 const vector<AttachmentReference>& resolveAttachments = subpass.getResolveAttachments();
811 const vector<deUint32>& preserveAttachments = subpass.getPreserveAttachments();
813 if (!inputAttachments.empty())
815 const tcu::ScopedLogSection inputAttachmentsSection (log, "Inputs", "Inputs");
817 for (size_t inputNdx = 0; inputNdx < inputAttachments.size(); inputNdx++)
819 const tcu::ScopedLogSection inputAttachmentSection (log, "Input" + de::toString(inputNdx), "Input " + de::toString(inputNdx));
820 const AttachmentReference& inputAttachment = inputAttachments[inputNdx];
822 log << TestLog::Message << "Attachment: " << inputAttachment.getAttachment() << TestLog::EndMessage;
823 log << TestLog::Message << "Layout: " << inputAttachment.getImageLayout() << TestLog::EndMessage;
827 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
829 const tcu::ScopedLogSection depthStencilAttachmentSection (log, "DepthStencil", "DepthStencil");
830 const AttachmentReference& depthStencilAttachment = subpass.getDepthStencilAttachment();
832 log << TestLog::Message << "Attachment: " << depthStencilAttachment.getAttachment() << TestLog::EndMessage;
833 log << TestLog::Message << "Layout: " << depthStencilAttachment.getImageLayout() << TestLog::EndMessage;
836 if (!colorAttachments.empty())
838 const tcu::ScopedLogSection colorAttachmentsSection (log, "Colors", "Colors");
840 for (size_t colorNdx = 0; colorNdx < colorAttachments.size(); colorNdx++)
842 const tcu::ScopedLogSection colorAttachmentSection (log, "Color" + de::toString(colorNdx), "Color " + de::toString(colorNdx));
843 const AttachmentReference& colorAttachment = colorAttachments[colorNdx];
845 log << TestLog::Message << "Attachment: " << colorAttachment.getAttachment() << TestLog::EndMessage;
846 log << TestLog::Message << "Layout: " << colorAttachment.getImageLayout() << TestLog::EndMessage;
850 if (!resolveAttachments.empty())
852 const tcu::ScopedLogSection resolveAttachmentsSection (log, "Resolves", "Resolves");
854 for (size_t resolveNdx = 0; resolveNdx < resolveAttachments.size(); resolveNdx++)
856 const tcu::ScopedLogSection resolveAttachmentSection (log, "Resolve" + de::toString(resolveNdx), "Resolve " + de::toString(resolveNdx));
857 const AttachmentReference& resolveAttachment = resolveAttachments[resolveNdx];
859 log << TestLog::Message << "Attachment: " << resolveAttachment.getAttachment() << TestLog::EndMessage;
860 log << TestLog::Message << "Layout: " << resolveAttachment.getImageLayout() << TestLog::EndMessage;
864 if (!preserveAttachments.empty())
866 const tcu::ScopedLogSection preserveAttachmentsSection (log, "Preserves", "Preserves");
868 for (size_t preserveNdx = 0; preserveNdx < preserveAttachments.size(); preserveNdx++)
870 const tcu::ScopedLogSection preserveAttachmentSection (log, "Preserve" + de::toString(preserveNdx), "Preserve " + de::toString(preserveNdx));
871 const deUint32 preserveAttachment = preserveAttachments[preserveNdx];
873 log << TestLog::Message << "Attachment: " << preserveAttachment << TestLog::EndMessage;
880 if (!renderPass.getDependencies().empty())
882 const tcu::ScopedLogSection dependenciesSection (log, "Dependencies", "Dependencies");
884 for (size_t depNdx = 0; depNdx < renderPass.getDependencies().size(); depNdx++)
886 const tcu::ScopedLogSection dependencySection (log, "Dependency" + de::toString(depNdx), "Dependency " + de::toString(depNdx));
887 const SubpassDependency& dep = renderPass.getDependencies()[depNdx];
889 log << TestLog::Message << "Source: " << dep.getSrcPass() << TestLog::EndMessage;
890 log << TestLog::Message << "Destination: " << dep.getDstPass() << TestLog::EndMessage;
892 log << TestLog::Message << "Source Stage Mask: " << dep.getSrcStageMask() << TestLog::EndMessage;
893 log << TestLog::Message << "Destination Stage Mask: " << dep.getDstStageMask() << TestLog::EndMessage;
895 log << TestLog::Message << "Input Mask: " << dep.getInputMask() << TestLog::EndMessage;
896 log << TestLog::Message << "Output Mask: " << dep.getOutputMask() << TestLog::EndMessage;
897 log << TestLog::Message << "Dependency Flags: " << getDependencyFlagsStr(dep.getFlags()) << TestLog::EndMessage;
902 std::string clearColorToString (VkFormat vkFormat, VkClearColorValue value)
904 const tcu::TextureFormat format = mapVkFormat(vkFormat);
905 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
906 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
908 std::ostringstream stream;
912 switch (channelClass)
914 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
915 for (int i = 0; i < 4; i++)
921 stream << value.int32[i];
927 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
928 for (int i = 0; i < 4; i++)
934 stream << value.uint32[i];
940 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
941 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
942 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
943 for (int i = 0; i < 4; i++)
949 stream << value.float32[i];
956 DE_FATAL("Unknown channel class");
964 std::string clearValueToString (VkFormat vkFormat, VkClearValue value)
966 const tcu::TextureFormat format = mapVkFormat(vkFormat);
968 if (tcu::hasStencilComponent(format.order) || tcu::hasDepthComponent(format.order))
970 std::ostringstream stream;
974 if (tcu::hasStencilComponent(format.order))
975 stream << "stencil: " << value.depthStencil.stencil;
977 if (tcu::hasStencilComponent(format.order) && tcu::hasDepthComponent(format.order))
980 if (tcu::hasDepthComponent(format.order))
981 stream << "depth: " << value.depthStencil.depth;
988 return clearColorToString(vkFormat, value.color);
991 VkClearColorValue randomColorClearValue (const Attachment& attachment, de::Random& rng)
993 const float clearNan = tcu::Float32::nan().asFloat();
994 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
995 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
996 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
997 VkClearColorValue clearColor;
999 switch (channelClass)
1001 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
1003 for (int ndx = 0; ndx < 4; ndx++)
1005 if (!channelMask[ndx])
1006 clearColor.int32[ndx] = std::numeric_limits<deInt32>::min();
1008 clearColor.uint32[ndx] = rng.getBool() ? 1u : 0u;
1013 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
1015 for (int ndx = 0; ndx < 4; ndx++)
1017 if (!channelMask[ndx])
1018 clearColor.uint32[ndx] = std::numeric_limits<deUint32>::max();
1020 clearColor.uint32[ndx] = rng.getBool() ? 1u : 0u;
1025 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
1026 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
1027 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
1029 for (int ndx = 0; ndx < 4; ndx++)
1031 if (!channelMask[ndx])
1032 clearColor.float32[ndx] = clearNan;
1034 clearColor.float32[ndx] = rng.getBool() ? 1.0f : 0.0f;
1040 DE_FATAL("Unknown channel class");
1046 VkAttachmentDescription createAttachmentDescription (const Attachment& attachment)
1048 const VkAttachmentDescription attachmentDescription =
1052 attachment.getFormat(), // format
1053 attachment.getSamples(), // samples
1055 attachment.getLoadOp(), // loadOp
1056 attachment.getStoreOp(), // storeOp
1058 attachment.getStencilLoadOp(), // stencilLoadOp
1059 attachment.getStencilStoreOp(), // stencilStoreOp
1061 attachment.getInitialLayout(), // initialLayout
1062 attachment.getFinalLayout(), // finalLayout
1065 return attachmentDescription;
1068 VkAttachmentReference createAttachmentReference (const AttachmentReference& referenceInfo)
1070 const VkAttachmentReference reference =
1072 referenceInfo.getAttachment(), // attachment;
1073 referenceInfo.getImageLayout() // layout;
1079 VkSubpassDescription createSubpassDescription (const Subpass& subpass,
1080 vector<VkAttachmentReference>* attachmentReferenceLists,
1081 vector<deUint32>* preserveAttachmentReferences)
1083 vector<VkAttachmentReference>& inputAttachmentReferences = attachmentReferenceLists[0];
1084 vector<VkAttachmentReference>& colorAttachmentReferences = attachmentReferenceLists[1];
1085 vector<VkAttachmentReference>& resolveAttachmentReferences = attachmentReferenceLists[2];
1086 vector<VkAttachmentReference>& depthStencilAttachmentReferences = attachmentReferenceLists[3];
1088 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
1089 colorAttachmentReferences.push_back(createAttachmentReference(subpass.getColorAttachments()[attachmentNdx]));
1091 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
1092 inputAttachmentReferences.push_back(createAttachmentReference(subpass.getInputAttachments()[attachmentNdx]));
1094 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getResolveAttachments().size(); attachmentNdx++)
1095 resolveAttachmentReferences.push_back(createAttachmentReference(subpass.getResolveAttachments()[attachmentNdx]));
1097 depthStencilAttachmentReferences.push_back(createAttachmentReference(subpass.getDepthStencilAttachment()));
1099 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getPreserveAttachments().size(); attachmentNdx++)
1100 preserveAttachmentReferences->push_back(subpass.getPreserveAttachments()[attachmentNdx]);
1102 DE_ASSERT(resolveAttachmentReferences.empty() || colorAttachmentReferences.size() == resolveAttachmentReferences.size());
1105 const VkSubpassDescription subpassDescription =
1107 subpass.getFlags(), // flags;
1108 subpass.getPipelineBindPoint(), // pipelineBindPoint;
1110 (deUint32)inputAttachmentReferences.size(), // inputCount;
1111 inputAttachmentReferences.empty() ? DE_NULL : &inputAttachmentReferences[0], // inputAttachments;
1113 (deUint32)colorAttachmentReferences.size(), // colorCount;
1114 colorAttachmentReferences.empty() ? DE_NULL : &colorAttachmentReferences[0], // colorAttachments;
1115 resolveAttachmentReferences.empty() ? DE_NULL : &resolveAttachmentReferences[0], // resolveAttachments;
1117 &depthStencilAttachmentReferences[0], // pDepthStencilAttachment;
1118 (deUint32)preserveAttachmentReferences->size(), // preserveCount;
1119 preserveAttachmentReferences->empty() ? DE_NULL : &(*preserveAttachmentReferences)[0] // preserveAttachments;
1122 return subpassDescription;
1126 VkSubpassDependency createSubpassDependency (const SubpassDependency& dependencyInfo)
1128 const VkSubpassDependency dependency =
1130 dependencyInfo.getSrcPass(), // srcSubpass;
1131 dependencyInfo.getDstPass(), // destSubpass;
1133 dependencyInfo.getSrcStageMask(), // srcStageMask;
1134 dependencyInfo.getDstStageMask(), // destStageMask;
1136 dependencyInfo.getOutputMask(), // outputMask;
1137 dependencyInfo.getInputMask(), // inputMask;
1139 dependencyInfo.getFlags() // dependencyFlags;
1145 Move<VkRenderPass> createRenderPass (const DeviceInterface& vk,
1147 const RenderPass& renderPassInfo)
1149 const size_t perSubpassAttachmentReferenceLists = 4;
1150 vector<VkAttachmentDescription> attachments;
1151 vector<VkSubpassDescription> subpasses;
1152 vector<VkSubpassDependency> dependencies;
1153 vector<vector<VkAttachmentReference> > attachmentReferenceLists(renderPassInfo.getSubpasses().size() * perSubpassAttachmentReferenceLists);
1154 vector<vector<deUint32> > preserveAttachments(renderPassInfo.getSubpasses().size());
1156 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
1157 attachments.push_back(createAttachmentDescription(renderPassInfo.getAttachments()[attachmentNdx]));
1159 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); subpassNdx++)
1160 subpasses.push_back(createSubpassDescription(renderPassInfo.getSubpasses()[subpassNdx], &(attachmentReferenceLists[subpassNdx * perSubpassAttachmentReferenceLists]), &preserveAttachments[subpassNdx]));
1162 for (size_t depNdx = 0; depNdx < renderPassInfo.getDependencies().size(); depNdx++)
1163 dependencies.push_back(createSubpassDependency(renderPassInfo.getDependencies()[depNdx]));
1165 if (renderPassInfo.getInputAspects().empty())
1167 const VkRenderPassCreateInfo createInfo =
1169 VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
1171 (VkRenderPassCreateFlags)0u,
1172 (deUint32)attachments.size(),
1173 (attachments.empty() ? DE_NULL : &attachments[0]),
1174 (deUint32)subpasses.size(),
1175 (subpasses.empty() ? DE_NULL : &subpasses[0]),
1176 (deUint32)dependencies.size(),
1177 (dependencies.empty() ? DE_NULL : &dependencies[0])
1180 return createRenderPass(vk, device, &createInfo);
1184 const VkRenderPassInputAttachmentAspectCreateInfoKHR inputAspectCreateInfo =
1186 VK_STRUCTURE_TYPE_RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO_KHR,
1189 (deUint32)renderPassInfo.getInputAspects().size(),
1190 renderPassInfo.getInputAspects().data(),
1192 const VkRenderPassCreateInfo createInfo =
1194 VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
1195 &inputAspectCreateInfo,
1196 (VkRenderPassCreateFlags)0u,
1197 (deUint32)attachments.size(),
1198 (attachments.empty() ? DE_NULL : &attachments[0]),
1199 (deUint32)subpasses.size(),
1200 (subpasses.empty() ? DE_NULL : &subpasses[0]),
1201 (deUint32)dependencies.size(),
1202 (dependencies.empty() ? DE_NULL : &dependencies[0])
1205 return createRenderPass(vk, device, &createInfo);
1209 Move<VkFramebuffer> createFramebuffer (const DeviceInterface& vk,
1211 VkRenderPass renderPass,
1213 const vector<VkImageView>& attachments)
1215 return createFramebuffer(vk, device, 0u, renderPass, (deUint32)attachments.size(), attachments.empty() ? DE_NULL : &attachments[0], size.x(), size.y(), 1u);
1218 Move<VkImage> createAttachmentImage (const DeviceInterface& vk,
1220 deUint32 queueIndex,
1223 VkSampleCountFlagBits samples,
1224 VkImageUsageFlags usageFlags,
1225 VkImageLayout layout)
1227 VkImageUsageFlags targetUsageFlags = 0;
1228 const tcu::TextureFormat textureFormat = mapVkFormat(format);
1230 DE_ASSERT(!(tcu::hasDepthComponent(vk::mapVkFormat(format).order) || tcu::hasStencilComponent(vk::mapVkFormat(format).order))
1231 || ((usageFlags & vk::VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) == 0));
1233 DE_ASSERT((tcu::hasDepthComponent(vk::mapVkFormat(format).order) || tcu::hasStencilComponent(vk::mapVkFormat(format).order))
1234 || ((usageFlags & vk::VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0));
1236 if (tcu::hasDepthComponent(textureFormat.order) || tcu::hasStencilComponent(textureFormat.order))
1237 targetUsageFlags |= vk::VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
1239 targetUsageFlags |= vk::VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
1241 return createImage(vk, device,
1242 (VkImageCreateFlags)0,
1245 vk::makeExtent3D(size.x(), size.y(), 1u),
1249 VK_IMAGE_TILING_OPTIMAL,
1250 usageFlags | targetUsageFlags,
1251 VK_SHARING_MODE_EXCLUSIVE,
1257 de::MovePtr<Allocation> createImageMemory (const InstanceInterface& vki,
1258 const VkPhysicalDevice& vkd,
1259 const DeviceInterface& vk,
1261 Allocator& allocator,
1264 AllocationKind allocationKind)
1266 const MemoryRequirement memoryRequirement = lazy ? MemoryRequirement::LazilyAllocated : MemoryRequirement::Any;
1267 de::MovePtr<Allocation> allocation = allocateImage(vki, vk, vkd, device, image, memoryRequirement, allocator, allocationKind);
1269 bindImageMemory(vk, device, image, allocation->getMemory(), allocation->getOffset());
1274 Move<VkImageView> createImageAttachmentView (const DeviceInterface& vk,
1278 VkImageAspectFlags aspect)
1280 const VkImageSubresourceRange range =
1289 return createImageView(vk, device, 0u, image, VK_IMAGE_VIEW_TYPE_2D, format, makeComponentMappingRGBA(), range);
1292 VkClearValue randomClearValue (const Attachment& attachment, de::Random& rng)
1294 const float clearNan = tcu::Float32::nan().asFloat();
1295 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
1297 if (tcu::hasStencilComponent(format.order) || tcu::hasDepthComponent(format.order))
1299 VkClearValue clearValue;
1301 clearValue.depthStencil.depth = clearNan;
1302 clearValue.depthStencil.stencil = 0xCDu;
1304 if (tcu::hasStencilComponent(format.order))
1305 clearValue.depthStencil.stencil = rng.getBool()
1309 if (tcu::hasDepthComponent(format.order))
1310 clearValue.depthStencil.depth = rng.getBool()
1318 VkClearValue clearValue;
1320 clearValue.color = randomColorClearValue(attachment, rng);
1326 class AttachmentResources
1329 AttachmentResources (const InstanceInterface& vki,
1330 const VkPhysicalDevice& physDevice,
1331 const DeviceInterface& vk,
1333 Allocator& allocator,
1334 deUint32 queueIndex,
1336 const Attachment& attachmentInfo,
1337 VkImageUsageFlags usageFlags,
1338 const AllocationKind allocationKind)
1339 : m_image (createAttachmentImage(vk, device, queueIndex, size, attachmentInfo.getFormat(), attachmentInfo.getSamples(), usageFlags, VK_IMAGE_LAYOUT_UNDEFINED))
1340 , m_imageMemory (createImageMemory(vki, physDevice, vk, device, allocator, *m_image, ((usageFlags & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0), allocationKind))
1341 , m_attachmentView (createImageAttachmentView(vk, device, *m_image, attachmentInfo.getFormat(), getImageAspectFlags(attachmentInfo.getFormat())))
1343 const tcu::TextureFormat format = mapVkFormat(attachmentInfo.getFormat());
1344 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
1345 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
1347 if (isDepthFormat && isStencilFormat)
1349 m_depthInputAttachmentView = createImageAttachmentView(vk, device, *m_image, attachmentInfo.getFormat(), VK_IMAGE_ASPECT_DEPTH_BIT);
1350 m_stencilInputAttachmentView = createImageAttachmentView(vk, device, *m_image, attachmentInfo.getFormat(), VK_IMAGE_ASPECT_STENCIL_BIT);
1352 m_inputAttachmentViews = std::make_pair(*m_depthInputAttachmentView, *m_stencilInputAttachmentView);
1355 m_inputAttachmentViews = std::make_pair(*m_attachmentView, (vk::VkImageView)0u);
1357 if ((usageFlags & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)
1359 if (tcu::hasDepthComponent(format.order) && tcu::hasStencilComponent(format.order))
1361 const tcu::TextureFormat depthFormat = getDepthCopyFormat(attachmentInfo.getFormat());
1362 const tcu::TextureFormat stencilFormat = getStencilCopyFormat(attachmentInfo.getFormat());
1364 m_bufferSize = size.x() * size.y() * depthFormat.getPixelSize();
1365 m_secondaryBufferSize = size.x() * size.y() * stencilFormat.getPixelSize();
1367 m_buffer = createBuffer(vk, device, 0, m_bufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_SHARING_MODE_EXCLUSIVE, 1, &queueIndex);
1368 m_bufferMemory = allocateBuffer(vki, vk, physDevice, device, *m_buffer, MemoryRequirement::HostVisible, allocator, allocationKind);
1370 bindBufferMemory(vk, device, *m_buffer, m_bufferMemory->getMemory(), m_bufferMemory->getOffset());
1372 m_secondaryBuffer = createBuffer(vk, device, 0, m_secondaryBufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_SHARING_MODE_EXCLUSIVE, 1, &queueIndex);
1373 m_secondaryBufferMemory = allocateBuffer(vki, vk, physDevice, device, *m_secondaryBuffer, MemoryRequirement::HostVisible, allocator, allocationKind);
1375 bindBufferMemory(vk, device, *m_secondaryBuffer, m_secondaryBufferMemory->getMemory(), m_secondaryBufferMemory->getOffset());
1379 m_bufferSize = size.x() * size.y() * format.getPixelSize();
1381 m_buffer = createBuffer(vk, device, 0, m_bufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_SHARING_MODE_EXCLUSIVE, 1, &queueIndex);
1382 m_bufferMemory = allocateBuffer(vki, vk, physDevice, device, *m_buffer, MemoryRequirement::HostVisible, allocator, allocationKind);
1384 bindBufferMemory(vk, device, *m_buffer, m_bufferMemory->getMemory(), m_bufferMemory->getOffset());
1389 const pair<VkImageView, VkImageView>& getInputAttachmentViews (void) const
1391 return m_inputAttachmentViews;
1394 ~AttachmentResources (void)
1398 VkImageView getAttachmentView (void) const
1400 return *m_attachmentView;
1403 VkImage getImage (void) const
1408 VkBuffer getBuffer (void) const
1410 DE_ASSERT(*m_buffer != DE_NULL);
1414 VkDeviceSize getBufferSize (void) const
1416 DE_ASSERT(*m_buffer != DE_NULL);
1417 return m_bufferSize;
1420 const Allocation& getResultMemory (void) const
1422 DE_ASSERT(m_bufferMemory);
1423 return *m_bufferMemory;
1426 VkBuffer getSecondaryBuffer (void) const
1428 DE_ASSERT(*m_secondaryBuffer != DE_NULL);
1429 return *m_secondaryBuffer;
1432 VkDeviceSize getSecondaryBufferSize (void) const
1434 DE_ASSERT(*m_secondaryBuffer != DE_NULL);
1435 return m_secondaryBufferSize;
1438 const Allocation& getSecondaryResultMemory (void) const
1440 DE_ASSERT(m_secondaryBufferMemory);
1441 return *m_secondaryBufferMemory;
1445 const Unique<VkImage> m_image;
1446 const UniquePtr<Allocation> m_imageMemory;
1447 const Unique<VkImageView> m_attachmentView;
1449 Move<VkImageView> m_depthInputAttachmentView;
1450 Move<VkImageView> m_stencilInputAttachmentView;
1451 pair<VkImageView, VkImageView> m_inputAttachmentViews;
1453 Move<VkBuffer> m_buffer;
1454 VkDeviceSize m_bufferSize;
1455 de::MovePtr<Allocation> m_bufferMemory;
1457 Move<VkBuffer> m_secondaryBuffer;
1458 VkDeviceSize m_secondaryBufferSize;
1459 de::MovePtr<Allocation> m_secondaryBufferMemory;
1462 void uploadBufferData (const DeviceInterface& vk,
1464 const Allocation& memory,
1468 const VkMappedMemoryRange range =
1470 VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // sType;
1472 memory.getMemory(), // mem;
1473 memory.getOffset(), // offset;
1474 (VkDeviceSize)size // size;
1476 void* const ptr = memory.getHostPtr();
1478 deMemcpy(ptr, data, size);
1479 VK_CHECK(vk.flushMappedMemoryRanges(device, 1, &range));
1482 VkImageAspectFlagBits getPrimaryImageAspect (tcu::TextureFormat::ChannelOrder order)
1484 DE_STATIC_ASSERT(tcu::TextureFormat::CHANNELORDER_LAST == 21);
1488 case tcu::TextureFormat::D:
1489 case tcu::TextureFormat::DS:
1490 return VK_IMAGE_ASPECT_DEPTH_BIT;
1492 case tcu::TextureFormat::S:
1493 return VK_IMAGE_ASPECT_STENCIL_BIT;
1496 return VK_IMAGE_ASPECT_COLOR_BIT;
1503 RenderQuad (const Vec2& posA, const Vec2& posB)
1506 m_vertices[0] = posA;
1507 m_vertices[1] = Vec2(posA[0], posB[1]);
1508 m_vertices[2] = posB;
1510 m_vertices[3] = posB;
1511 m_vertices[4] = Vec2(posB[0], posA[1]);
1512 m_vertices[5] = posA;
1515 const Vec2& getCornerA (void) const
1517 return m_vertices[0];
1520 const Vec2& getCornerB (void) const
1522 return m_vertices[2];
1525 const void* getVertexPointer (void) const
1527 return &m_vertices[0];
1530 size_t getVertexDataSize (void) const
1532 return sizeof(Vec2) * m_vertices.size();
1536 vector<Vec2> m_vertices;
1542 ColorClear (const UVec2& offset,
1544 const VkClearColorValue& color)
1551 const UVec2& getOffset (void) const { return m_offset; }
1552 const UVec2& getSize (void) const { return m_size; }
1553 const VkClearColorValue& getColor (void) const { return m_color; }
1558 VkClearColorValue m_color;
1561 class DepthStencilClear
1564 DepthStencilClear (const UVec2& offset,
1571 , m_stencil (stencil)
1575 const UVec2& getOffset (void) const { return m_offset; }
1576 const UVec2& getSize (void) const { return m_size; }
1577 float getDepth (void) const { return m_depth; }
1578 deUint32 getStencil (void) const { return m_stencil; }
1581 const UVec2 m_offset;
1584 const float m_depth;
1585 const deUint32 m_stencil;
1588 class SubpassRenderInfo
1591 SubpassRenderInfo (const RenderPass& renderPass,
1592 deUint32 subpassIndex,
1596 const UVec2& viewportOffset,
1597 const UVec2& viewportSize,
1599 const Maybe<RenderQuad>& renderQuad,
1600 const vector<ColorClear>& colorClears,
1601 const Maybe<DepthStencilClear>& depthStencilClear)
1602 : m_viewportOffset (viewportOffset)
1603 , m_viewportSize (viewportSize)
1604 , m_subpassIndex (subpassIndex)
1605 , m_isSecondary (isSecondary_)
1606 , m_flags (renderPass.getSubpasses()[subpassIndex].getFlags())
1607 , m_renderQuad (renderQuad)
1608 , m_colorClears (colorClears)
1609 , m_depthStencilClear (depthStencilClear)
1610 , m_colorAttachments (renderPass.getSubpasses()[subpassIndex].getColorAttachments())
1611 , m_inputAttachments (renderPass.getSubpasses()[subpassIndex].getInputAttachments())
1613 for (deUint32 attachmentNdx = 0; attachmentNdx < (deUint32)m_colorAttachments.size(); attachmentNdx++)
1614 m_colorAttachmentInfo.push_back(renderPass.getAttachments()[m_colorAttachments[attachmentNdx].getAttachment()]);
1616 if (renderPass.getSubpasses()[subpassIndex].getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
1618 m_depthStencilAttachment = tcu::just(renderPass.getSubpasses()[subpassIndex].getDepthStencilAttachment());
1619 m_depthStencilAttachmentInfo = tcu::just(renderPass.getAttachments()[renderPass.getSubpasses()[subpassIndex].getDepthStencilAttachment().getAttachment()]);
1623 const UVec2& getViewportOffset (void) const { return m_viewportOffset; }
1624 const UVec2& getViewportSize (void) const { return m_viewportSize; }
1626 deUint32 getSubpassIndex (void) const { return m_subpassIndex; }
1627 bool isSecondary (void) const { return m_isSecondary; }
1629 const Maybe<RenderQuad>& getRenderQuad (void) const { return m_renderQuad; }
1630 const vector<ColorClear>& getColorClears (void) const { return m_colorClears; }
1631 const Maybe<DepthStencilClear>& getDepthStencilClear (void) const { return m_depthStencilClear; }
1633 deUint32 getInputAttachmentCount (void) const { return (deUint32)m_inputAttachments.size(); }
1634 deUint32 getInputAttachmentIndex (deUint32 attachmentNdx) const { return m_inputAttachments[attachmentNdx].getAttachment(); }
1635 VkImageLayout getInputAttachmentLayout (deUint32 attachmentNdx) const { return m_inputAttachments[attachmentNdx].getImageLayout(); }
1637 deUint32 getColorAttachmentCount (void) const { return (deUint32)m_colorAttachments.size(); }
1638 VkImageLayout getColorAttachmentLayout (deUint32 attachmentNdx) const { return m_colorAttachments[attachmentNdx].getImageLayout(); }
1639 deUint32 getColorAttachmentIndex (deUint32 attachmentNdx) const { return m_colorAttachments[attachmentNdx].getAttachment(); }
1640 const Attachment& getColorAttachment (deUint32 attachmentNdx) const { return m_colorAttachmentInfo[attachmentNdx]; }
1641 Maybe<VkImageLayout> getDepthStencilAttachmentLayout (void) const { return m_depthStencilAttachment ? tcu::just(m_depthStencilAttachment->getImageLayout()) : tcu::nothing<VkImageLayout>(); }
1642 Maybe<deUint32> getDepthStencilAttachmentIndex (void) const { return m_depthStencilAttachment ? tcu::just(m_depthStencilAttachment->getAttachment()) : tcu::nothing<deUint32>(); };
1643 const Maybe<Attachment>& getDepthStencilAttachment (void) const { return m_depthStencilAttachmentInfo; }
1644 VkSubpassDescriptionFlags getSubpassFlags (void) const { return m_flags; }
1647 UVec2 m_viewportOffset;
1648 UVec2 m_viewportSize;
1650 deUint32 m_subpassIndex;
1652 VkSubpassDescriptionFlags m_flags;
1654 Maybe<RenderQuad> m_renderQuad;
1655 vector<ColorClear> m_colorClears;
1656 Maybe<DepthStencilClear> m_depthStencilClear;
1658 vector<AttachmentReference> m_colorAttachments;
1659 vector<Attachment> m_colorAttachmentInfo;
1661 Maybe<AttachmentReference> m_depthStencilAttachment;
1662 Maybe<Attachment> m_depthStencilAttachmentInfo;
1664 vector<AttachmentReference> m_inputAttachments;
1667 Move<VkPipeline> createSubpassPipeline (const DeviceInterface& vk,
1669 VkRenderPass renderPass,
1670 VkShaderModule vertexShaderModule,
1671 VkShaderModule fragmentShaderModule,
1672 VkPipelineLayout pipelineLayout,
1673 const SubpassRenderInfo& renderInfo)
1675 const VkSpecializationInfo emptyShaderSpecializations =
1677 0u, // mapEntryCount
1683 Maybe<VkSampleCountFlagBits> rasterSamples;
1684 vector<VkPipelineColorBlendAttachmentState> attachmentBlendStates;
1686 for (deUint32 attachmentNdx = 0; attachmentNdx < renderInfo.getColorAttachmentCount(); attachmentNdx++)
1688 const Attachment& attachment = renderInfo.getColorAttachment(attachmentNdx);
1690 DE_ASSERT(!rasterSamples || *rasterSamples == attachment.getSamples());
1692 rasterSamples = attachment.getSamples();
1695 const VkPipelineColorBlendAttachmentState attachmentBlendState =
1697 VK_FALSE, // blendEnable
1698 VK_BLEND_FACTOR_SRC_ALPHA, // srcBlendColor
1699 VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, // destBlendColor
1700 VK_BLEND_OP_ADD, // blendOpColor
1701 VK_BLEND_FACTOR_ONE, // srcBlendAlpha
1702 VK_BLEND_FACTOR_ONE, // destBlendAlpha
1703 VK_BLEND_OP_ADD, // blendOpAlpha
1704 VK_COLOR_COMPONENT_R_BIT|VK_COLOR_COMPONENT_G_BIT|VK_COLOR_COMPONENT_B_BIT|VK_COLOR_COMPONENT_A_BIT, // channelWriteMask
1707 attachmentBlendStates.push_back(attachmentBlendState);
1711 if (renderInfo.getDepthStencilAttachment())
1713 const Attachment& attachment = *renderInfo.getDepthStencilAttachment();
1715 DE_ASSERT(!rasterSamples || *rasterSamples == attachment.getSamples());
1716 rasterSamples = attachment.getSamples();
1719 // If there are no attachment use single sample
1721 rasterSamples = VK_SAMPLE_COUNT_1_BIT;
1723 const VkPipelineShaderStageCreateInfo shaderStages[2] =
1726 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // sType
1728 (VkPipelineShaderStageCreateFlags)0u,
1729 VK_SHADER_STAGE_VERTEX_BIT, // stage
1730 vertexShaderModule, // shader
1732 &emptyShaderSpecializations
1735 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // sType
1737 (VkPipelineShaderStageCreateFlags)0u,
1738 VK_SHADER_STAGE_FRAGMENT_BIT, // stage
1739 fragmentShaderModule, // shader
1741 &emptyShaderSpecializations
1744 const VkVertexInputBindingDescription vertexBinding =
1747 (deUint32)sizeof(tcu::Vec2), // strideInBytes
1748 VK_VERTEX_INPUT_RATE_VERTEX, // stepRate
1750 const VkVertexInputAttributeDescription vertexAttrib =
1754 VK_FORMAT_R32G32_SFLOAT, // format
1755 0u, // offsetInBytes
1757 const VkPipelineVertexInputStateCreateInfo vertexInputState =
1759 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // sType
1761 (VkPipelineVertexInputStateCreateFlags)0u,
1763 &vertexBinding, // pVertexBindingDescriptions
1764 1u, // attributeCount
1765 &vertexAttrib, // pVertexAttributeDescriptions
1767 const VkPipelineInputAssemblyStateCreateInfo inputAssemblyState =
1769 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, // sType
1771 (VkPipelineInputAssemblyStateCreateFlags)0u,
1772 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, // topology
1773 VK_FALSE, // primitiveRestartEnable
1775 const VkViewport viewport =
1777 (float)renderInfo.getViewportOffset().x(), (float)renderInfo.getViewportOffset().y(),
1778 (float)renderInfo.getViewportSize().x(), (float)renderInfo.getViewportSize().y(),
1781 const VkRect2D scissor =
1783 { (deInt32)renderInfo.getViewportOffset().x(), (deInt32)renderInfo.getViewportOffset().y() },
1784 { renderInfo.getViewportSize().x(), renderInfo.getViewportSize().y() }
1786 const VkPipelineViewportStateCreateInfo viewportState =
1788 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
1790 (VkPipelineViewportStateCreateFlags)0u,
1796 const VkPipelineRasterizationStateCreateInfo rasterState =
1798 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, // sType
1800 (VkPipelineRasterizationStateCreateFlags)0u,
1801 VK_TRUE, // depthClipEnable
1802 VK_FALSE, // rasterizerDiscardEnable
1803 VK_POLYGON_MODE_FILL, // fillMode
1804 VK_CULL_MODE_NONE, // cullMode
1805 VK_FRONT_FACE_COUNTER_CLOCKWISE, // frontFace
1806 VK_FALSE, // depthBiasEnable
1808 0.0f, // depthBiasClamp
1809 0.0f, // slopeScaledDepthBias
1812 const VkPipelineMultisampleStateCreateInfo multisampleState =
1814 VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, // sType
1816 (VkPipelineMultisampleStateCreateFlags)0u,
1817 *rasterSamples, // rasterSamples
1818 VK_FALSE, // sampleShadingEnable
1819 0.0f, // minSampleShading
1820 DE_NULL, // pSampleMask
1821 VK_FALSE, // alphaToCoverageEnable
1822 VK_FALSE, // alphaToOneEnable
1824 const size_t stencilIndex = renderInfo.getSubpassIndex();
1825 const VkBool32 writeDepth = renderInfo.getDepthStencilAttachmentLayout()
1826 && *renderInfo.getDepthStencilAttachmentLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
1827 && *renderInfo.getDepthStencilAttachmentLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR
1830 const VkBool32 writeStencil = renderInfo.getDepthStencilAttachmentLayout()
1831 && *renderInfo.getDepthStencilAttachmentLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
1832 && *renderInfo.getDepthStencilAttachmentLayout() != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR
1835 const VkPipelineDepthStencilStateCreateInfo depthStencilState =
1837 VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, // sType
1839 (VkPipelineDepthStencilStateCreateFlags)0u,
1840 writeDepth, // depthTestEnable
1841 writeDepth, // depthWriteEnable
1842 VK_COMPARE_OP_ALWAYS, // depthCompareOp
1843 VK_FALSE, // depthBoundsEnable
1844 writeStencil, // stencilTestEnable
1846 VK_STENCIL_OP_REPLACE, // stencilFailOp
1847 VK_STENCIL_OP_REPLACE, // stencilPassOp
1848 VK_STENCIL_OP_REPLACE, // stencilDepthFailOp
1849 VK_COMPARE_OP_ALWAYS, // stencilCompareOp
1850 ~0u, // stencilCompareMask
1851 ~0u, // stencilWriteMask
1852 ((stencilIndex % 2) == 0) ? ~0x0u : 0x0u // stencilReference
1855 VK_STENCIL_OP_REPLACE, // stencilFailOp
1856 VK_STENCIL_OP_REPLACE, // stencilPassOp
1857 VK_STENCIL_OP_REPLACE, // stencilDepthFailOp
1858 VK_COMPARE_OP_ALWAYS, // stencilCompareOp
1859 ~0u, // stencilCompareMask
1860 ~0u, // stencilWriteMask
1861 ((stencilIndex % 2) == 0) ? ~0x0u : 0x0u // stencilReference
1864 0.0f, // minDepthBounds;
1865 1.0f // maxDepthBounds;
1867 const VkPipelineColorBlendStateCreateInfo blendState =
1869 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // sType
1871 (VkPipelineColorBlendStateCreateFlags)0u,
1872 VK_FALSE, // logicOpEnable
1873 VK_LOGIC_OP_COPY, // logicOp
1874 (deUint32)attachmentBlendStates.size(), // attachmentCount
1875 attachmentBlendStates.empty() ? DE_NULL : &attachmentBlendStates[0],// pAttachments
1876 { 0.0f, 0.0f, 0.0f, 0.0f } // blendConst
1878 const VkGraphicsPipelineCreateInfo createInfo =
1880 VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, // sType
1882 (VkPipelineCreateFlags)0u,
1885 shaderStages, // pStages
1887 &vertexInputState, // pVertexInputState
1888 &inputAssemblyState, // pInputAssemblyState
1889 DE_NULL, // pTessellationState
1890 &viewportState, // pViewportState
1891 &rasterState, // pRasterState
1892 &multisampleState, // pMultisampleState
1893 &depthStencilState, // pDepthStencilState
1894 &blendState, // pColorBlendState
1895 (const VkPipelineDynamicStateCreateInfo*)DE_NULL, // pDynamicState
1896 pipelineLayout, // layout
1898 renderPass, // renderPass
1899 renderInfo.getSubpassIndex(), // subpass
1900 DE_NULL, // basePipelineHandle
1901 0u // basePipelineIndex
1904 return createGraphicsPipeline(vk, device, DE_NULL, &createInfo);
1907 class SubpassRenderer
1910 SubpassRenderer (Context& context,
1911 const DeviceInterface& vk,
1913 Allocator& allocator,
1914 VkRenderPass renderPass,
1915 VkFramebuffer framebuffer,
1916 VkCommandPool commandBufferPool,
1917 deUint32 queueFamilyIndex,
1918 const vector<VkImage>& attachmentImages,
1919 const vector<pair<VkImageView, VkImageView> >& attachmentViews,
1920 const SubpassRenderInfo& renderInfo,
1921 const vector<Attachment>& attachmentInfos,
1922 const AllocationKind allocationKind)
1923 : m_renderInfo (renderInfo)
1925 const InstanceInterface& vki = context.getInstanceInterface();
1926 const VkPhysicalDevice& physDevice = context.getPhysicalDevice();
1927 const deUint32 subpassIndex = renderInfo.getSubpassIndex();
1928 vector<VkDescriptorSetLayoutBinding> bindings;
1930 for (deUint32 colorAttachmentNdx = 0; colorAttachmentNdx < renderInfo.getColorAttachmentCount(); colorAttachmentNdx++)
1931 m_colorAttachmentImages.push_back(attachmentImages[renderInfo.getColorAttachmentIndex(colorAttachmentNdx)]);
1933 if (renderInfo.getDepthStencilAttachmentIndex())
1934 m_depthStencilAttachmentImage = attachmentImages[*renderInfo.getDepthStencilAttachmentIndex()];
1936 if (renderInfo.getRenderQuad())
1938 const RenderQuad& renderQuad = *renderInfo.getRenderQuad();
1940 if (renderInfo.getInputAttachmentCount() > 0)
1942 deUint32 bindingIndex = 0;
1944 for (deUint32 inputAttachmentNdx = 0; inputAttachmentNdx < renderInfo.getInputAttachmentCount(); inputAttachmentNdx++)
1946 const Attachment attachmentInfo = attachmentInfos[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)];
1947 const VkImageLayout layout = renderInfo.getInputAttachmentLayout(inputAttachmentNdx);
1948 const tcu::TextureFormat format = mapVkFormat(attachmentInfo.getFormat());
1949 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
1950 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
1951 const deUint32 bindingCount = (isDepthFormat && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
1952 && (isStencilFormat && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR)
1956 for (deUint32 bindingNdx = 0; bindingNdx < bindingCount; bindingNdx++)
1958 const VkDescriptorSetLayoutBinding binding =
1961 vk::VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
1963 vk::VK_SHADER_STAGE_FRAGMENT_BIT,
1967 bindings.push_back(binding);
1972 const VkDescriptorSetLayoutCreateInfo createInfo =
1974 vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
1978 (deUint32)bindings.size(),
1982 m_descriptorSetLayout = vk::createDescriptorSetLayout(vk, device, &createInfo);
1985 const VkDescriptorSetLayout descriptorSetLayout = *m_descriptorSetLayout;
1986 const VkPipelineLayoutCreateInfo pipelineLayoutParams =
1988 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // sType;
1990 (vk::VkPipelineLayoutCreateFlags)0,
1991 m_descriptorSetLayout ? 1u :0u , // setLayoutCount;
1992 m_descriptorSetLayout ? &descriptorSetLayout : DE_NULL, // pSetLayouts;
1993 0u, // pushConstantRangeCount;
1994 DE_NULL, // pPushConstantRanges;
1997 m_vertexShaderModule = createShaderModule(vk, device, context.getBinaryCollection().get(de::toString(subpassIndex) + "-vert"), 0u);
1998 m_fragmentShaderModule = createShaderModule(vk, device, context.getBinaryCollection().get(de::toString(subpassIndex) + "-frag"), 0u);
1999 m_pipelineLayout = createPipelineLayout(vk, device, &pipelineLayoutParams);
2000 m_pipeline = createSubpassPipeline(vk, device, renderPass, *m_vertexShaderModule, *m_fragmentShaderModule, *m_pipelineLayout, m_renderInfo);
2002 m_vertexBuffer = createBuffer(vk, device, 0u, (VkDeviceSize)renderQuad.getVertexDataSize(), VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, VK_SHARING_MODE_EXCLUSIVE, 1u, &queueFamilyIndex);
2003 m_vertexBufferMemory = allocateBuffer(vki, vk, physDevice, device, *m_vertexBuffer, MemoryRequirement::HostVisible, allocator, allocationKind);
2005 bindBufferMemory(vk, device, *m_vertexBuffer, m_vertexBufferMemory->getMemory(), m_vertexBufferMemory->getOffset());
2006 uploadBufferData(vk, device, *m_vertexBufferMemory, renderQuad.getVertexDataSize(), renderQuad.getVertexPointer());
2008 if (renderInfo.getInputAttachmentCount() > 0)
2011 const VkDescriptorPoolSize poolSize =
2013 vk::VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2014 // \note Reserve 2 per input attachment since depthStencil attachments require 2.
2015 renderInfo.getInputAttachmentCount() * 2u
2017 const VkDescriptorPoolCreateInfo createInfo =
2019 vk::VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
2021 VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
2023 // \note Reserve 2 per input attachment since depthStencil attachments require 2.
2024 renderInfo.getInputAttachmentCount() * 2u,
2029 m_descriptorPool = vk::createDescriptorPool(vk, device, &createInfo);
2032 const VkDescriptorSetAllocateInfo allocateInfo =
2034 vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
2039 &descriptorSetLayout
2042 m_descriptorSet = vk::allocateDescriptorSet(vk, device, &allocateInfo);
2045 vector<VkWriteDescriptorSet> writes (bindings.size());
2046 vector<VkDescriptorImageInfo> imageInfos (bindings.size());
2047 deUint32 bindingIndex = 0;
2049 for (deUint32 inputAttachmentNdx = 0; inputAttachmentNdx < renderInfo.getInputAttachmentCount(); inputAttachmentNdx++)
2051 const Attachment attachmentInfo = attachmentInfos[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)];
2052 const tcu::TextureFormat format = mapVkFormat(attachmentInfo.getFormat());
2053 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
2054 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
2055 const VkImageLayout inputAttachmentLayout = renderInfo.getInputAttachmentLayout(inputAttachmentNdx);
2058 if (isDepthFormat && isStencilFormat)
2060 if (inputAttachmentLayout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR)
2062 const VkDescriptorImageInfo imageInfo =
2065 attachmentViews[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)].first,
2066 inputAttachmentLayout
2068 imageInfos[bindingIndex] = imageInfo;
2071 const VkWriteDescriptorSet write =
2073 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2080 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2081 &imageInfos[bindingIndex],
2085 writes[bindingIndex] = write;
2091 if (inputAttachmentLayout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
2093 const VkDescriptorImageInfo imageInfo =
2096 attachmentViews[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)].second,
2097 inputAttachmentLayout
2099 imageInfos[bindingIndex] = imageInfo;
2102 const VkWriteDescriptorSet write =
2104 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2111 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2112 &imageInfos[bindingIndex],
2116 writes[bindingIndex] = write;
2124 const VkDescriptorImageInfo imageInfo =
2127 attachmentViews[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)].first,
2128 inputAttachmentLayout
2130 imageInfos[bindingIndex] = imageInfo;
2133 const VkWriteDescriptorSet write =
2135 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2142 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2143 &imageInfos[bindingIndex],
2147 writes[bindingIndex] = write;
2154 vk.updateDescriptorSets(device, (deUint32)writes.size(), &writes[0], 0u, DE_NULL);
2159 if (renderInfo.isSecondary())
2161 m_commandBuffer = allocateCommandBuffer(vk, device, commandBufferPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2163 beginCommandBuffer(vk, *m_commandBuffer, vk::VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, renderPass, subpassIndex, framebuffer, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0);
2164 pushRenderCommands(vk, *m_commandBuffer);
2165 endCommandBuffer(vk, *m_commandBuffer);
2169 bool isSecondary (void) const
2171 return m_commandBuffer;
2174 VkCommandBuffer getCommandBuffer (void) const
2176 DE_ASSERT(isSecondary());
2177 return *m_commandBuffer;
2180 void pushRenderCommands (const DeviceInterface& vk,
2181 VkCommandBuffer commandBuffer)
2183 if (!m_renderInfo.getColorClears().empty())
2185 const vector<ColorClear>& colorClears (m_renderInfo.getColorClears());
2187 for (deUint32 attachmentNdx = 0; attachmentNdx < m_renderInfo.getColorAttachmentCount(); attachmentNdx++)
2189 const ColorClear& colorClear = colorClears[attachmentNdx];
2190 const VkClearAttachment attachment =
2192 VK_IMAGE_ASPECT_COLOR_BIT,
2194 makeClearValue(colorClear.getColor()),
2196 const VkClearRect rect =
2199 { (deInt32)colorClear.getOffset().x(), (deInt32)colorClear.getOffset().y() },
2200 { colorClear.getSize().x(), colorClear.getSize().y() }
2202 0u, // baseArrayLayer
2206 vk.cmdClearAttachments(commandBuffer, 1u, &attachment, 1u, &rect);
2210 if (m_renderInfo.getDepthStencilClear())
2212 const DepthStencilClear& depthStencilClear = *m_renderInfo.getDepthStencilClear();
2213 const deUint32 attachmentNdx = m_renderInfo.getColorAttachmentCount();
2214 tcu::TextureFormat format = mapVkFormat(m_renderInfo.getDepthStencilAttachment()->getFormat());
2215 const VkImageLayout layout = *m_renderInfo.getDepthStencilAttachmentLayout();
2216 const VkClearAttachment attachment =
2218 (VkImageAspectFlags)((hasDepthComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR ? VK_IMAGE_ASPECT_DEPTH_BIT : 0)
2219 | (hasStencilComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR ? VK_IMAGE_ASPECT_STENCIL_BIT : 0)),
2221 makeClearValueDepthStencil(depthStencilClear.getDepth(), depthStencilClear.getStencil())
2223 const VkClearRect rect =
2226 { (deInt32)depthStencilClear.getOffset().x(), (deInt32)depthStencilClear.getOffset().y() },
2227 { depthStencilClear.getSize().x(), depthStencilClear.getSize().y() }
2229 0u, // baseArrayLayer
2233 if ((tcu::hasDepthComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
2234 || (tcu::hasStencilComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR))
2236 vk.cmdClearAttachments(commandBuffer, 1u, &attachment, 1u, &rect);
2240 vector<VkImageMemoryBarrier> selfDeps;
2241 VkPipelineStageFlags srcStages = 0;
2242 VkPipelineStageFlags dstStages = 0;
2244 for (deUint32 inputAttachmentNdx = 0; inputAttachmentNdx < m_renderInfo.getInputAttachmentCount(); inputAttachmentNdx++)
2246 for (deUint32 colorAttachmentNdx = 0; colorAttachmentNdx < m_renderInfo.getColorAttachmentCount(); colorAttachmentNdx++)
2248 if (m_renderInfo.getInputAttachmentIndex(inputAttachmentNdx) == m_renderInfo.getColorAttachmentIndex(colorAttachmentNdx))
2250 const VkImageMemoryBarrier barrier =
2252 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2255 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // srcAccessMask
2256 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT, // dstAccessMask
2258 VK_IMAGE_LAYOUT_GENERAL, // oldLayout
2259 VK_IMAGE_LAYOUT_GENERAL, // newLayout
2261 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex
2262 VK_QUEUE_FAMILY_IGNORED, // destQueueFamilyIndex
2264 m_colorAttachmentImages[colorAttachmentNdx], // image
2265 { // subresourceRange
2266 VK_IMAGE_ASPECT_COLOR_BIT, // aspect
2269 0, // baseArraySlice
2274 srcStages |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
2275 dstStages |= VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
2277 selfDeps.push_back(barrier);
2281 if (m_renderInfo.getDepthStencilAttachmentIndex() && (m_renderInfo.getInputAttachmentIndex(inputAttachmentNdx) == *m_renderInfo.getDepthStencilAttachmentIndex()))
2283 const tcu::TextureFormat format = mapVkFormat(m_renderInfo.getDepthStencilAttachment()->getFormat());
2284 const bool hasDepth = hasDepthComponent(format.order);
2285 const bool hasStencil = hasStencilComponent(format.order);
2286 const VkImageMemoryBarrier barrier =
2288 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
2291 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, // srcAccessMask
2292 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT, // dstAccessMask
2294 VK_IMAGE_LAYOUT_GENERAL, // oldLayout
2295 VK_IMAGE_LAYOUT_GENERAL, // newLayout;
2297 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex;
2298 VK_QUEUE_FAMILY_IGNORED, // destQueueFamilyIndex;
2300 m_depthStencilAttachmentImage, // image;
2301 { // subresourceRange;
2302 (hasDepth ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
2303 | (hasStencil ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u), // aspect;
2306 0, // baseArraySlice;
2311 srcStages |= VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT;
2312 dstStages |= VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
2314 selfDeps.push_back(barrier);
2318 if (!selfDeps.empty())
2320 DE_ASSERT(srcStages != 0);
2321 DE_ASSERT(dstStages != 0);
2322 vk.cmdPipelineBarrier(commandBuffer, srcStages, dstStages, VK_DEPENDENCY_BY_REGION_BIT, 0, DE_NULL, 0, DE_NULL, (deUint32)selfDeps.size(), &selfDeps[0]);
2325 if (m_renderInfo.getRenderQuad())
2327 const VkDeviceSize offset = 0;
2328 const VkBuffer vertexBuffer = *m_vertexBuffer;
2330 vk.cmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
2332 if (m_descriptorSet)
2334 const VkDescriptorSet descriptorSet = *m_descriptorSet;
2335 vk.cmdBindDescriptorSets(commandBuffer, vk::VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipelineLayout, 0u, 1u, &descriptorSet, 0u, NULL);
2338 vk.cmdBindVertexBuffers(commandBuffer, 0u, 1u, &vertexBuffer, &offset);
2339 vk.cmdDraw(commandBuffer, 6u, 1u, 0u, 0u);
2344 const SubpassRenderInfo m_renderInfo;
2345 Move<VkCommandBuffer> m_commandBuffer;
2346 Move<VkPipeline> m_pipeline;
2347 Move<VkDescriptorSetLayout> m_descriptorSetLayout;
2348 Move<VkPipelineLayout> m_pipelineLayout;
2350 Move<VkShaderModule> m_vertexShaderModule;
2351 Move<VkShaderModule> m_fragmentShaderModule;
2353 Move<VkDescriptorPool> m_descriptorPool;
2354 Move<VkDescriptorSet> m_descriptorSet;
2355 Move<VkBuffer> m_vertexBuffer;
2356 de::MovePtr<Allocation> m_vertexBufferMemory;
2357 vector<VkImage> m_colorAttachmentImages;
2358 VkImage m_depthStencilAttachmentImage;
2361 void pushImageInitializationCommands (const DeviceInterface& vk,
2362 VkCommandBuffer commandBuffer,
2363 const vector<Attachment>& attachmentInfo,
2364 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
2365 deUint32 queueIndex,
2366 const vector<Maybe<VkClearValue> >& clearValues)
2369 vector<VkImageMemoryBarrier> initializeLayouts;
2371 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2373 if (!clearValues[attachmentNdx])
2376 const VkImageMemoryBarrier barrier =
2378 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
2381 (VkAccessFlags)0, // srcAccessMask
2382 getAllMemoryReadFlags() | VK_ACCESS_TRANSFER_WRITE_BIT, // dstAccessMask
2384 VK_IMAGE_LAYOUT_UNDEFINED, // oldLayout
2385 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // newLayout;
2387 queueIndex, // srcQueueFamilyIndex;
2388 queueIndex, // destQueueFamilyIndex;
2390 attachmentResources[attachmentNdx]->getImage(), // image;
2391 { // subresourceRange;
2392 getImageAspectFlags(attachmentInfo[attachmentNdx].getFormat()), // aspect;
2395 0, // baseArraySlice;
2400 initializeLayouts.push_back(barrier);
2403 if (!initializeLayouts.empty())
2404 vk.cmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT,
2405 VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, (VkDependencyFlags)0,
2406 0, (const VkMemoryBarrier*)DE_NULL,
2407 0, (const VkBufferMemoryBarrier*)DE_NULL,
2408 (deUint32)initializeLayouts.size(), &initializeLayouts[0]);
2411 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2413 if (!clearValues[attachmentNdx])
2416 const tcu::TextureFormat format = mapVkFormat(attachmentInfo[attachmentNdx].getFormat());
2418 if (hasStencilComponent(format.order) || hasDepthComponent(format.order))
2420 const float clearNan = tcu::Float32::nan().asFloat();
2421 const float clearDepth = hasDepthComponent(format.order) ? clearValues[attachmentNdx]->depthStencil.depth : clearNan;
2422 const deUint32 clearStencil = hasStencilComponent(format.order) ? clearValues[attachmentNdx]->depthStencil.stencil : 0xDEu;
2423 const VkClearDepthStencilValue depthStencil =
2428 const VkImageSubresourceRange range =
2430 (VkImageAspectFlags)((hasDepthComponent(format.order) ? VK_IMAGE_ASPECT_DEPTH_BIT : 0)
2431 | (hasStencilComponent(format.order) ? VK_IMAGE_ASPECT_STENCIL_BIT : 0)),
2438 vk.cmdClearDepthStencilImage(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &depthStencil, 1, &range);
2442 const VkImageSubresourceRange range =
2444 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask;
2447 0, // baseArrayLayer;
2450 const VkClearColorValue clearColor = clearValues[attachmentNdx]->color;
2452 vk.cmdClearColorImage(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clearColor, 1, &range);
2457 vector<VkImageMemoryBarrier> renderPassLayouts;
2459 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2461 const VkImageLayout oldLayout = clearValues[attachmentNdx] ? VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL : VK_IMAGE_LAYOUT_UNDEFINED;
2462 const VkImageMemoryBarrier barrier =
2464 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
2467 (oldLayout != VK_IMAGE_LAYOUT_UNDEFINED ? getAllMemoryWriteFlags() : (VkAccessFlags)0), // srcAccessMask
2468 getAllMemoryReadFlags() | getMemoryFlagsForLayout(attachmentInfo[attachmentNdx].getInitialLayout()), // dstAccessMask
2470 oldLayout, // oldLayout
2471 attachmentInfo[attachmentNdx].getInitialLayout(), // newLayout;
2473 queueIndex, // srcQueueFamilyIndex;
2474 queueIndex, // destQueueFamilyIndex;
2476 attachmentResources[attachmentNdx]->getImage(), // image;
2477 { // subresourceRange;
2478 getImageAspectFlags(attachmentInfo[attachmentNdx].getFormat()), // aspect;
2481 0, // baseArraySlice;
2486 renderPassLayouts.push_back(barrier);
2489 if (!renderPassLayouts.empty())
2490 vk.cmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT,
2491 VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, (VkDependencyFlags)0,
2492 0, (const VkMemoryBarrier*)DE_NULL,
2493 0, (const VkBufferMemoryBarrier*)DE_NULL,
2494 (deUint32)renderPassLayouts.size(), &renderPassLayouts[0]);
2498 void pushRenderPassCommands (const DeviceInterface& vk,
2499 VkCommandBuffer commandBuffer,
2500 VkRenderPass renderPass,
2501 VkFramebuffer framebuffer,
2502 const vector<de::SharedPtr<SubpassRenderer> >& subpassRenderers,
2503 const UVec2& renderPos,
2504 const UVec2& renderSize,
2505 const vector<Maybe<VkClearValue> >& renderPassClearValues,
2506 TestConfig::RenderTypes render)
2508 const float clearNan = tcu::Float32::nan().asFloat();
2509 vector<VkClearValue> attachmentClearValues;
2511 for (size_t attachmentNdx = 0; attachmentNdx < renderPassClearValues.size(); attachmentNdx++)
2513 if (renderPassClearValues[attachmentNdx])
2514 attachmentClearValues.push_back(*renderPassClearValues[attachmentNdx]);
2516 attachmentClearValues.push_back(makeClearValueColorF32(clearNan, clearNan, clearNan, clearNan));
2520 const VkRect2D renderArea =
2522 { (deInt32)renderPos.x(), (deInt32)renderPos.y() },
2523 { renderSize.x(), renderSize.y() }
2526 for (size_t subpassNdx = 0; subpassNdx < subpassRenderers.size(); subpassNdx++)
2528 const VkSubpassContents contents = subpassRenderers[subpassNdx]->isSecondary() ? VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS : VK_SUBPASS_CONTENTS_INLINE;
2530 if (subpassNdx == 0)
2531 cmdBeginRenderPass(vk, commandBuffer, renderPass, framebuffer, renderArea, (deUint32)attachmentClearValues.size(), attachmentClearValues.empty() ? DE_NULL : &attachmentClearValues[0], contents);
2533 vk.cmdNextSubpass(commandBuffer, contents);
2537 if (contents == VK_SUBPASS_CONTENTS_INLINE)
2539 subpassRenderers[subpassNdx]->pushRenderCommands(vk, commandBuffer);
2541 else if (contents == VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS)
2543 const VkCommandBuffer cmd = subpassRenderers[subpassNdx]->getCommandBuffer();
2544 vk.cmdExecuteCommands(commandBuffer, 1, &cmd);
2547 DE_FATAL("Invalid contents");
2551 vk.cmdEndRenderPass(commandBuffer);
2555 void pushReadImagesToBuffers (const DeviceInterface& vk,
2556 VkCommandBuffer commandBuffer,
2557 deUint32 queueIndex,
2559 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
2560 const vector<Attachment>& attachmentInfo,
2561 const vector<bool>& isLazy,
2563 const UVec2& targetSize)
2566 vector<VkImageMemoryBarrier> imageBarriers;
2568 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2570 if (isLazy[attachmentNdx])
2573 const VkImageLayout oldLayout = attachmentInfo[attachmentNdx].getFinalLayout();
2574 const VkImageMemoryBarrier barrier =
2576 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2579 getAllMemoryWriteFlags() | getMemoryFlagsForLayout(oldLayout), // srcAccessMask
2580 getAllMemoryReadFlags(), // dstAccessMask
2582 oldLayout, // oldLayout
2583 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // newLayout
2585 queueIndex, // srcQueueFamilyIndex
2586 queueIndex, // destQueueFamilyIndex
2588 attachmentResources[attachmentNdx]->getImage(), // image
2589 { // subresourceRange
2590 getImageAspectFlags(attachmentInfo[attachmentNdx].getFormat()), // aspect;
2593 0, // baseArraySlice
2598 imageBarriers.push_back(barrier);
2601 if (!imageBarriers.empty())
2602 vk.cmdPipelineBarrier(commandBuffer,
2603 getAllPipelineStageFlags(),
2604 getAllPipelineStageFlags(),
2605 (VkDependencyFlags)0,
2606 0, (const VkMemoryBarrier*)DE_NULL,
2607 0, (const VkBufferMemoryBarrier*)DE_NULL,
2608 (deUint32)imageBarriers.size(), &imageBarriers[0]);
2611 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2613 if (isLazy[attachmentNdx])
2616 const tcu::TextureFormat::ChannelOrder order = mapVkFormat(attachmentInfo[attachmentNdx].getFormat()).order;
2617 const VkBufferImageCopy rect =
2620 0, // bufferRowLength
2621 0, // bufferImageHeight
2622 { // imageSubresource
2623 (vk::VkImageAspectFlags)getPrimaryImageAspect(mapVkFormat(attachmentInfo[attachmentNdx].getFormat()).order), // aspect
2628 { 0, 0, 0 }, // imageOffset
2629 { targetSize.x(), targetSize.y(), 1u } // imageExtent
2632 vk.cmdCopyImageToBuffer(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, attachmentResources[attachmentNdx]->getBuffer(), 1, &rect);
2634 if (tcu::TextureFormat::DS == order)
2636 const VkBufferImageCopy stencilRect =
2639 0, // bufferRowLength
2640 0, // bufferImageHeight
2641 { // imageSubresource
2642 VK_IMAGE_ASPECT_STENCIL_BIT, // aspect
2647 { 0, 0, 0 }, // imageOffset
2648 { targetSize.x(), targetSize.y(), 1u } // imageExtent
2651 vk.cmdCopyImageToBuffer(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, attachmentResources[attachmentNdx]->getSecondaryBuffer(), 1, &stencilRect);
2656 vector<VkBufferMemoryBarrier> bufferBarriers;
2658 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2660 if (isLazy[attachmentNdx])
2663 const tcu::TextureFormat::ChannelOrder order = mapVkFormat(attachmentInfo[attachmentNdx].getFormat()).order;
2664 const VkBufferMemoryBarrier bufferBarrier =
2666 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
2669 getAllMemoryWriteFlags(),
2670 getAllMemoryReadFlags(),
2675 attachmentResources[attachmentNdx]->getBuffer(),
2677 attachmentResources[attachmentNdx]->getBufferSize()
2680 bufferBarriers.push_back(bufferBarrier);
2682 if (tcu::TextureFormat::DS == order)
2684 const VkBufferMemoryBarrier secondaryBufferBarrier =
2686 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
2689 getAllMemoryWriteFlags(),
2690 getAllMemoryReadFlags(),
2695 attachmentResources[attachmentNdx]->getSecondaryBuffer(),
2697 attachmentResources[attachmentNdx]->getSecondaryBufferSize()
2700 bufferBarriers.push_back(secondaryBufferBarrier);
2704 if (!bufferBarriers.empty())
2705 vk.cmdPipelineBarrier(commandBuffer,
2706 getAllPipelineStageFlags(),
2707 getAllPipelineStageFlags(),
2708 (VkDependencyFlags)0,
2709 0, (const VkMemoryBarrier*)DE_NULL,
2710 (deUint32)bufferBarriers.size(), &bufferBarriers[0],
2711 0, (const VkImageMemoryBarrier*)DE_NULL);
2718 PixelValue (const Maybe<bool>& x = nothing<bool>(),
2719 const Maybe<bool>& y = nothing<bool>(),
2720 const Maybe<bool>& z = nothing<bool>(),
2721 const Maybe<bool>& w = nothing<bool>());
2723 void setUndefined (size_t ndx);
2724 void setValue (size_t ndx, bool value);
2725 Maybe<bool> getValue (size_t ndx) const;
2731 PixelValue::PixelValue (const Maybe<bool>& x,
2732 const Maybe<bool>& y,
2733 const Maybe<bool>& z,
2734 const Maybe<bool>& w)
2737 const Maybe<bool> values[] =
2742 for (size_t ndx = 0; ndx < DE_LENGTH_OF_ARRAY(values); ndx++)
2745 setValue(ndx, *values[ndx]);
2750 DE_ASSERT(m_status <= 0xFFu);
2753 void PixelValue::setUndefined (size_t ndx)
2756 DE_ASSERT(m_status <= 0xFFu);
2758 m_status &= (deUint16)~(0x1u << (deUint16)(ndx * 2));
2759 DE_ASSERT(m_status <= 0xFFu);
2762 void PixelValue::setValue (size_t ndx, bool value)
2765 DE_ASSERT(m_status <= 0xFFu);
2767 m_status = (deUint16)(m_status | (deUint16)(0x1u << (ndx * 2)));
2770 m_status = (deUint16)(m_status | (deUint16)(0x1u << (ndx * 2 + 1)));
2772 m_status &= (deUint16)~(0x1u << (deUint16)(ndx * 2 + 1));
2774 DE_ASSERT(m_status <= 0xFFu);
2777 Maybe<bool> PixelValue::getValue (size_t ndx) const
2780 DE_ASSERT(m_status <= 0xFFu);
2782 if ((m_status & (0x1u << (deUint16)(ndx * 2))) != 0)
2784 return just((m_status & (0x1u << (deUint32)(ndx * 2 + 1))) != 0);
2787 return nothing<bool>();
2790 void clearReferenceValues (vector<PixelValue>& values,
2791 const UVec2& targetSize,
2792 const UVec2& offset,
2795 const PixelValue& value)
2797 DE_ASSERT(targetSize.x() * targetSize.y() == (deUint32)values.size());
2798 DE_ASSERT(offset.x() + size.x() <= targetSize.x());
2799 DE_ASSERT(offset.y() + size.y() <= targetSize.y());
2801 for (deUint32 y = offset.y(); y < offset.y() + size.y(); y++)
2802 for (deUint32 x = offset.x(); x < offset.x() + size.x(); x++)
2804 for (int compNdx = 0; compNdx < 4; compNdx++)
2808 if (value.getValue(compNdx))
2809 values[x + y * targetSize.x()].setValue(compNdx, *value.getValue(compNdx));
2811 values[x + y * targetSize.x()].setUndefined(compNdx);
2817 void markUndefined (vector<PixelValue>& values,
2819 const UVec2& targetSize,
2820 const UVec2& offset,
2823 DE_ASSERT(targetSize.x() * targetSize.y() == (deUint32)values.size());
2825 for (deUint32 y = offset.y(); y < offset.y() + size.y(); y++)
2826 for (deUint32 x = offset.x(); x < offset.x() + size.x(); x++)
2828 for (int compNdx = 0; compNdx < 4; compNdx++)
2831 values[x + y * targetSize.x()].setUndefined(compNdx);
2836 PixelValue clearValueToPixelValue (const VkClearValue& value,
2837 const tcu::TextureFormat& format)
2839 const bool isDepthAttachment = hasDepthComponent(format.order);
2840 const bool isStencilAttachment = hasStencilComponent(format.order);
2841 const bool isDepthOrStencilAttachment = isDepthAttachment || isStencilAttachment;
2842 PixelValue pixelValue;
2844 if (isDepthOrStencilAttachment)
2846 if (isDepthAttachment)
2848 if (value.depthStencil.depth == 1.0f)
2849 pixelValue.setValue(0, true);
2850 else if (value.depthStencil.depth == 0.0f)
2851 pixelValue.setValue(0, false);
2853 DE_FATAL("Unknown depth value");
2856 if (isStencilAttachment)
2858 if (value.depthStencil.stencil == 0xFFu)
2859 pixelValue.setValue(1, true);
2860 else if (value.depthStencil.stencil == 0x0u)
2861 pixelValue.setValue(1, false);
2863 DE_FATAL("Unknown stencil value");
2868 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
2869 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
2871 switch (channelClass)
2873 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
2874 for (int i = 0; i < 4; i++)
2878 if (value.color.int32[i] == 1)
2879 pixelValue.setValue(i, true);
2880 else if (value.color.int32[i] == 0)
2881 pixelValue.setValue(i, false);
2883 DE_FATAL("Unknown clear color value");
2888 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
2889 for (int i = 0; i < 4; i++)
2893 if (value.color.uint32[i] == 1u)
2894 pixelValue.setValue(i, true);
2895 else if (value.color.uint32[i] == 0u)
2896 pixelValue.setValue(i, false);
2898 DE_FATAL("Unknown clear color value");
2903 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
2904 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
2905 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
2906 for (int i = 0; i < 4; i++)
2910 if (value.color.float32[i] == 1.0f)
2911 pixelValue.setValue(i, true);
2912 else if (value.color.float32[i] == 0.0f)
2913 pixelValue.setValue(i, false);
2915 DE_FATAL("Unknown clear color value");
2921 DE_FATAL("Unknown channel class");
2928 void renderReferenceValues (vector<vector<PixelValue> >& referenceAttachments,
2929 const RenderPass& renderPassInfo,
2930 const UVec2& targetSize,
2931 const vector<Maybe<VkClearValue> >& imageClearValues,
2932 const vector<Maybe<VkClearValue> >& renderPassClearValues,
2933 const vector<SubpassRenderInfo>& subpassRenderInfo,
2934 const UVec2& renderPos,
2935 const UVec2& renderSize)
2937 const vector<Subpass>& subpasses = renderPassInfo.getSubpasses();
2938 vector<bool> attachmentUsed (renderPassInfo.getAttachments().size(), false);
2940 referenceAttachments.resize(renderPassInfo.getAttachments().size());
2942 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
2944 const Attachment attachment = renderPassInfo.getAttachments()[attachmentNdx];
2945 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
2946 vector<PixelValue>& reference = referenceAttachments[attachmentNdx];
2948 reference.resize(targetSize.x() * targetSize.y());
2950 if (imageClearValues[attachmentNdx])
2951 clearReferenceValues(reference, targetSize, UVec2(0, 0), targetSize, BVec4(true), clearValueToPixelValue(*imageClearValues[attachmentNdx], format));
2954 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
2956 const Subpass& subpass = subpasses[subpassNdx];
2957 const SubpassRenderInfo& renderInfo = subpassRenderInfo[subpassNdx];
2958 const vector<AttachmentReference>& colorAttachments = subpass.getColorAttachments();
2960 // Apply load op if attachment was used for the first time
2961 for (size_t attachmentNdx = 0; attachmentNdx < colorAttachments.size(); attachmentNdx++)
2963 const deUint32 attachmentIndex = colorAttachments[attachmentNdx].getAttachment();
2965 if (!attachmentUsed[attachmentIndex])
2967 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
2968 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
2969 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
2971 DE_ASSERT(!tcu::hasDepthComponent(format.order));
2972 DE_ASSERT(!tcu::hasStencilComponent(format.order));
2974 if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
2975 clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(true), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format));
2976 else if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
2977 markUndefined(reference, BVec4(true), targetSize, renderPos, renderSize);
2979 attachmentUsed[attachmentIndex] = true;
2983 // Apply load op to depth/stencil attachment if it was used for the first time
2984 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
2986 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
2988 // Apply load op if attachment was used for the first time
2989 if (!attachmentUsed[attachmentIndex])
2991 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
2992 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
2993 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
2995 if (tcu::hasDepthComponent(format.order))
2997 if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
2998 clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(true, false, false, false), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format));
2999 else if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
3000 markUndefined(reference, BVec4(true, false, false, false), targetSize, renderPos, renderSize);
3003 if (tcu::hasStencilComponent(format.order))
3005 if (attachment.getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
3006 clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(false, true, false, false), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format));
3007 else if (attachment.getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
3008 markUndefined(reference, BVec4(false, true, false, false), targetSize, renderPos, renderSize);
3011 attachmentUsed[attachmentIndex] = true;
3015 for (size_t colorClearNdx = 0; colorClearNdx < renderInfo.getColorClears().size(); colorClearNdx++)
3017 const ColorClear& colorClear = renderInfo.getColorClears()[colorClearNdx];
3018 const UVec2 offset = colorClear.getOffset();
3019 const UVec2 size = colorClear.getSize();
3020 const deUint32 attachmentIndex = subpass.getColorAttachments()[colorClearNdx].getAttachment();
3021 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3022 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3023 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3026 value.color = colorClear.getColor();
3028 clearReferenceValues(reference, targetSize, offset, size, BVec4(true), clearValueToPixelValue(value, format));
3031 if (renderInfo.getDepthStencilClear())
3033 const DepthStencilClear& dsClear = *renderInfo.getDepthStencilClear();
3034 const UVec2 offset = dsClear.getOffset();
3035 const UVec2 size = dsClear.getSize();
3036 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3037 const VkImageLayout layout = subpass.getDepthStencilAttachment().getImageLayout();
3038 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3039 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3040 const bool hasStencil = tcu::hasStencilComponent(format.order)
3041 && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR;
3042 const bool hasDepth = tcu::hasDepthComponent(format.order)
3043 && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR;
3044 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3047 value.depthStencil.depth = dsClear.getDepth();
3048 value.depthStencil.stencil = dsClear.getStencil();
3050 clearReferenceValues(reference, targetSize, offset, size, BVec4(hasDepth, hasStencil, false, false), clearValueToPixelValue(value, format));
3053 if (renderInfo.getRenderQuad())
3055 const RenderQuad& renderQuad = *renderInfo.getRenderQuad();
3056 const Vec2 posA = renderQuad.getCornerA();
3057 const Vec2 posB = renderQuad.getCornerB();
3058 const Vec2 origin = Vec2((float)renderInfo.getViewportOffset().x(), (float)renderInfo.getViewportOffset().y()) + Vec2((float)renderInfo.getViewportSize().x(), (float)renderInfo.getViewportSize().y()) / Vec2(2.0f);
3059 const Vec2 p = Vec2((float)renderInfo.getViewportSize().x(), (float)renderInfo.getViewportSize().y()) / Vec2(2.0f);
3060 const IVec2 posAI (deRoundFloatToInt32(origin.x() + (p.x() * posA.x())),
3061 deRoundFloatToInt32(origin.y() + (p.y() * posA.y())));
3062 const IVec2 posBI (deRoundFloatToInt32(origin.x() + (p.x() * posB.x())),
3063 deRoundFloatToInt32(origin.y() + (p.y() * posB.y())));
3065 DE_ASSERT(posAI.x() < posBI.x());
3066 DE_ASSERT(posAI.y() < posBI.y());
3068 if (subpass.getInputAttachments().empty())
3070 for (size_t attachmentRefNdx = 0; attachmentRefNdx < subpass.getColorAttachments().size(); attachmentRefNdx++)
3072 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentRefNdx].getAttachment();
3073 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3074 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3075 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
3076 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3078 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3079 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3081 for (int compNdx = 0; compNdx < 4; compNdx++)
3083 const size_t index = subpassNdx + attachmentIndex + compNdx;
3084 const BoolOp op = boolOpFromIndex(index);
3085 const bool boolX = x % 2 == (int)(index % 2);
3086 const bool boolY = y % 2 == (int)((index / 2) % 2);
3088 if (channelMask[compNdx])
3089 reference[x + y * targetSize.x()].setValue(compNdx, performBoolOp(op, boolX, boolY));
3094 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
3096 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3097 const VkImageLayout layout = subpass.getDepthStencilAttachment().getImageLayout();
3098 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3099 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3100 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3102 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3103 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3105 if (tcu::hasDepthComponent(format.order)
3106 && layout != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3107 && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
3109 const size_t index = subpassNdx + 1;
3110 const BoolOp op = boolOpFromIndex(index);
3111 const bool boolX = x % 2 == (int)(index % 2);
3112 const bool boolY = y % 2 == (int)((index / 2) % 2);
3114 reference[x + y * targetSize.x()].setValue(0, performBoolOp(op, boolX, boolY));
3117 if (tcu::hasStencilComponent(format.order)
3118 && layout != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3119 && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR)
3121 const size_t index = subpassNdx;
3122 reference[x + y * targetSize.x()].setValue(1, (index % 2) == 0);
3129 size_t outputComponentCount = 0;
3130 vector<Maybe<bool> > inputs;
3132 DE_ASSERT(posAI.x() < posBI.x());
3133 DE_ASSERT(posAI.y() < posBI.y());
3135 for (size_t attachmentRefNdx = 0; attachmentRefNdx < subpass.getColorAttachments().size(); attachmentRefNdx++)
3137 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentRefNdx].getAttachment();
3138 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3139 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3140 const int componentCount = tcu::getNumUsedChannels(format.order);
3142 outputComponentCount += (size_t)componentCount;
3145 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3146 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3147 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
3149 const Attachment& attachment (renderPassInfo.getAttachments()[subpass.getDepthStencilAttachment().getAttachment()]);
3150 const tcu::TextureFormat format (mapVkFormat(attachment.getFormat()));
3152 if (tcu::hasDepthComponent(format.order))
3153 outputComponentCount++;
3156 if (outputComponentCount > 0)
3158 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3159 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3161 for (size_t inputAttachmentNdx = 0; inputAttachmentNdx < subpass.getInputAttachments().size(); inputAttachmentNdx++)
3163 const deUint32 attachmentIndex = subpass.getInputAttachments()[inputAttachmentNdx].getAttachment();
3164 const VkImageLayout layout = subpass.getInputAttachments()[inputAttachmentNdx].getImageLayout();
3165 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3166 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3167 const int componentCount = tcu::getNumUsedChannels(format.order);
3169 for (int compNdx = 0; compNdx < componentCount; compNdx++)
3171 if ((compNdx != 0 || layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR)
3172 && (compNdx != 1 || layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR))
3174 inputs.push_back(referenceAttachments[attachmentIndex][x + y * targetSize.x()].getValue(compNdx));
3179 const size_t inputsPerOutput = inputs.size() >= outputComponentCount
3180 ? ((inputs.size() / outputComponentCount)
3181 + ((inputs.size() % outputComponentCount) != 0 ? 1 : 0))
3184 size_t outputValueNdx = 0;
3186 for (size_t attachmentRefNdx = 0; attachmentRefNdx < subpass.getColorAttachments().size(); attachmentRefNdx++)
3188 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentRefNdx].getAttachment();
3189 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3190 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3191 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3192 const int componentCount = tcu::getNumUsedChannels(format.order);
3194 for (int compNdx = 0; compNdx < componentCount; compNdx++)
3196 const size_t index = subpassNdx + attachmentIndex + outputValueNdx;
3197 const BoolOp op = boolOpFromIndex(index);
3198 const bool boolX = x % 2 == (int)(index % 2);
3199 const bool boolY = y % 2 == (int)((index / 2) % 2);
3200 Maybe<bool> output = tcu::just(performBoolOp(op, boolX, boolY));
3202 for (size_t i = 0; i < inputsPerOutput; i++)
3206 else if (!inputs[((outputValueNdx + compNdx) * inputsPerOutput + i) % inputs.size()])
3207 output = tcu::nothing<bool>();
3209 output = (*output) == (*inputs[((outputValueNdx + compNdx) * inputsPerOutput + i) % inputs.size()]);
3213 reference[x + y * targetSize.x()].setValue(compNdx, *output);
3215 reference[x + y * targetSize.x()].setUndefined(compNdx);
3218 outputValueNdx += componentCount;
3221 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3222 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3223 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
3225 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3226 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3227 const size_t index = subpassNdx + attachmentIndex;
3228 const BoolOp op = boolOpFromIndex(index);
3229 const bool boolX = x % 2 == (int)(index % 2);
3230 const bool boolY = y % 2 == (int)((index / 2) % 2);
3231 Maybe<bool> output = tcu::just(performBoolOp(op, boolX, boolY));
3233 for (size_t i = 0; i < inputsPerOutput; i++)
3237 else if (inputs[(outputValueNdx * inputsPerOutput + i) % inputs.size()])
3238 output = (*output) == (*inputs[(outputValueNdx * inputsPerOutput + i) % inputs.size()]);
3240 output = tcu::nothing<bool>();
3244 reference[x + y * targetSize.x()].setValue(0, *output);
3246 reference[x + y * targetSize.x()].setUndefined(0);
3253 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3254 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3255 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR)
3257 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3258 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3259 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3260 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3262 if (tcu::hasStencilComponent(format.order))
3264 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3265 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3267 const size_t index = subpassNdx;
3268 reference[x + y * targetSize.x()].setValue(1, (index % 2) == 0);
3276 // Mark all attachments that were used but not stored as undefined
3277 for (size_t attachmentIndex = 0; attachmentIndex < renderPassInfo.getAttachments().size(); attachmentIndex++)
3279 const Attachment attachment = renderPassInfo.getAttachments()[attachmentIndex];
3280 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3281 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3282 const bool isStencilAttachment = hasStencilComponent(format.order);
3283 const bool isDepthOrStencilAttachment = hasDepthComponent(format.order) || isStencilAttachment;
3285 if (attachmentUsed[attachmentIndex] && renderPassInfo.getAttachments()[attachmentIndex].getStoreOp() == VK_ATTACHMENT_STORE_OP_DONT_CARE)
3287 if (isDepthOrStencilAttachment)
3288 markUndefined(reference, BVec4(true, false, false, false), targetSize, renderPos, renderSize);
3290 markUndefined(reference, BVec4(true), targetSize, renderPos, renderSize);
3293 if (attachmentUsed[attachmentIndex] && isStencilAttachment && renderPassInfo.getAttachments()[attachmentIndex].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_DONT_CARE)
3294 markUndefined(reference, BVec4(false, true, false, false), targetSize, renderPos, renderSize);
3298 void renderReferenceImagesFromValues (vector<tcu::TextureLevel>& referenceImages,
3299 const vector<vector<PixelValue> >& referenceValues,
3300 const UVec2& targetSize,
3301 const RenderPass& renderPassInfo)
3303 referenceImages.resize(referenceValues.size());
3305 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
3307 const Attachment attachment = renderPassInfo.getAttachments()[attachmentNdx];
3308 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3309 const vector<PixelValue>& reference = referenceValues[attachmentNdx];
3310 const bool hasDepth = tcu::hasDepthComponent(format.order);
3311 const bool hasStencil = tcu::hasStencilComponent(format.order);
3312 const bool hasDepthOrStencil = hasDepth || hasStencil;
3313 tcu::TextureLevel& referenceImage = referenceImages[attachmentNdx];
3315 referenceImage.setStorage(format, targetSize.x(), targetSize.y());
3317 if (hasDepthOrStencil)
3321 const PixelBufferAccess depthAccess (tcu::getEffectiveDepthStencilAccess(referenceImage.getAccess(), tcu::Sampler::MODE_DEPTH));
3323 for (deUint32 y = 0; y < targetSize.y(); y++)
3324 for (deUint32 x = 0; x < targetSize.x(); x++)
3326 if (reference[x + y * targetSize.x()].getValue(0))
3328 if (*reference[x + y * targetSize.x()].getValue(0))
3329 depthAccess.setPixDepth(1.0f, x, y);
3331 depthAccess.setPixDepth(0.0f, x, y);
3333 else // Fill with 3x3 grid
3334 depthAccess.setPixDepth(((x / 3) % 2) == ((y / 3) % 2) ? 0.33f : 0.66f, x, y);
3340 const PixelBufferAccess stencilAccess (tcu::getEffectiveDepthStencilAccess(referenceImage.getAccess(), tcu::Sampler::MODE_STENCIL));
3342 for (deUint32 y = 0; y < targetSize.y(); y++)
3343 for (deUint32 x = 0; x < targetSize.x(); x++)
3345 if (reference[x + y * targetSize.x()].getValue(1))
3347 if (*reference[x + y * targetSize.x()].getValue(1))
3348 stencilAccess.setPixStencil(0xFFu, x, y);
3350 stencilAccess.setPixStencil(0x0u, x, y);
3352 else // Fill with 3x3 grid
3353 stencilAccess.setPixStencil(((x / 3) % 2) == ((y / 3) % 2) ? 85 : 170, x, y);
3359 for (deUint32 y = 0; y < targetSize.y(); y++)
3360 for (deUint32 x = 0; x < targetSize.x(); x++)
3364 for (int compNdx = 0; compNdx < 4; compNdx++)
3366 if (reference[x + y * targetSize.x()].getValue(compNdx))
3368 if (*reference[x + y * targetSize.x()].getValue(compNdx))
3369 color[compNdx] = 1.0f;
3371 color[compNdx] = 0.0f;
3373 else // Fill with 3x3 grid
3374 color[compNdx] = ((compNdx + (x / 3)) % 2) == ((y / 3) % 2) ? 0.33f : 0.66f;
3377 referenceImage.getAccess().setPixel(color, x, y);
3383 bool verifyColorAttachment (const vector<PixelValue>& reference,
3384 const ConstPixelBufferAccess& result,
3385 const PixelBufferAccess& errorImage)
3387 const Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
3388 const Vec4 green (0.0f, 1.0f, 0.0f, 1.0f);
3391 DE_ASSERT(result.getWidth() * result.getHeight() == (int)reference.size());
3392 DE_ASSERT(result.getWidth() == errorImage.getWidth());
3393 DE_ASSERT(result.getHeight() == errorImage.getHeight());
3395 for (int y = 0; y < result.getHeight(); y++)
3396 for (int x = 0; x < result.getWidth(); x++)
3398 const Vec4 resultColor = result.getPixel(x, y);
3399 const PixelValue& referenceValue = reference[x + y * result.getWidth()];
3400 bool pixelOk = true;
3402 for (int compNdx = 0; compNdx < 4; compNdx++)
3404 const Maybe<bool> maybeValue = referenceValue.getValue(compNdx);
3408 const bool value = *maybeValue;
3410 if ((value && (resultColor[compNdx] != 1.0f))
3411 || (!value && resultColor[compNdx] != 0.0f))
3418 errorImage.setPixel(red, x, y);
3422 errorImage.setPixel(green, x, y);
3428 bool verifyDepthAttachment (const vector<PixelValue>& reference,
3429 const ConstPixelBufferAccess& result,
3430 const PixelBufferAccess& errorImage)
3432 const Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
3433 const Vec4 green (0.0f, 1.0f, 0.0f, 1.0f);
3436 DE_ASSERT(result.getWidth() * result.getHeight() == (int)reference.size());
3437 DE_ASSERT(result.getWidth() == errorImage.getWidth());
3438 DE_ASSERT(result.getHeight() == errorImage.getHeight());
3440 for (int y = 0; y < result.getHeight(); y++)
3441 for (int x = 0; x < result.getWidth(); x++)
3443 bool pixelOk = true;
3445 const float resultDepth = result.getPixDepth(x, y);
3446 const PixelValue& referenceValue = reference[x + y * result.getWidth()];
3447 const Maybe<bool> maybeValue = referenceValue.getValue(0);
3451 const bool value = *maybeValue;
3453 if ((value && (resultDepth != 1.0f))
3454 || (!value && resultDepth != 0.0f))
3460 errorImage.setPixel(red, x, y);
3464 errorImage.setPixel(green, x, y);
3470 bool verifyStencilAttachment (const vector<PixelValue>& reference,
3471 const ConstPixelBufferAccess& result,
3472 const PixelBufferAccess& errorImage)
3474 const Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
3475 const Vec4 green (0.0f, 1.0f, 0.0f, 1.0f);
3478 DE_ASSERT(result.getWidth() * result.getHeight() == (int)reference.size());
3479 DE_ASSERT(result.getWidth() == errorImage.getWidth());
3480 DE_ASSERT(result.getHeight() == errorImage.getHeight());
3482 for (int y = 0; y < result.getHeight(); y++)
3483 for (int x = 0; x < result.getWidth(); x++)
3485 bool pixelOk = true;
3487 const deUint32 resultStencil = result.getPixStencil(x, y);
3488 const PixelValue& referenceValue = reference[x + y * result.getWidth()];
3489 const Maybe<bool> maybeValue = referenceValue.getValue(1);
3493 const bool value = *maybeValue;
3495 if ((value && (resultStencil != 0xFFu))
3496 || (!value && resultStencil != 0x0u))
3502 errorImage.setPixel(red, x, y);
3506 errorImage.setPixel(green, x, y);
3512 bool logAndVerifyImages (TestLog& log,
3513 const DeviceInterface& vk,
3515 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
3516 const vector<bool>& attachmentIsLazy,
3517 const RenderPass& renderPassInfo,
3518 const vector<Maybe<VkClearValue> >& renderPassClearValues,
3519 const vector<Maybe<VkClearValue> >& imageClearValues,
3520 const vector<SubpassRenderInfo>& subpassRenderInfo,
3521 const UVec2& targetSize,
3522 const TestConfig& config)
3524 vector<vector<PixelValue> > referenceValues;
3525 vector<tcu::TextureLevel> referenceAttachments;
3528 log << TestLog::Message << "Reference images fill undefined pixels with 3x3 grid pattern." << TestLog::EndMessage;
3530 renderReferenceValues(referenceValues, renderPassInfo, targetSize, imageClearValues, renderPassClearValues, subpassRenderInfo, config.renderPos, config.renderSize);
3531 renderReferenceImagesFromValues(referenceAttachments, referenceValues, targetSize, renderPassInfo);
3533 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
3535 if (!attachmentIsLazy[attachmentNdx])
3537 const Attachment attachment = renderPassInfo.getAttachments()[attachmentNdx];
3538 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3540 if (tcu::hasDepthComponent(format.order) && tcu::hasStencilComponent(format.order))
3542 const tcu::TextureFormat depthFormat = getDepthCopyFormat(attachment.getFormat());
3543 const VkDeviceSize depthBufferSize = targetSize.x() * targetSize.y() * depthFormat.getPixelSize();
3544 void* const depthPtr = attachmentResources[attachmentNdx]->getResultMemory().getHostPtr();
3546 const tcu::TextureFormat stencilFormat = getStencilCopyFormat(attachment.getFormat());
3547 const VkDeviceSize stencilBufferSize = targetSize.x() * targetSize.y() * stencilFormat.getPixelSize();
3548 void* const stencilPtr = attachmentResources[attachmentNdx]->getSecondaryResultMemory().getHostPtr();
3550 const VkMappedMemoryRange ranges[] =
3553 VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // sType;
3555 attachmentResources[attachmentNdx]->getResultMemory().getMemory(), // mem;
3556 attachmentResources[attachmentNdx]->getResultMemory().getOffset(), // offset;
3557 depthBufferSize // size;
3560 VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // sType;
3562 attachmentResources[attachmentNdx]->getSecondaryResultMemory().getMemory(), // mem;
3563 attachmentResources[attachmentNdx]->getSecondaryResultMemory().getOffset(), // offset;
3564 stencilBufferSize // size;
3567 VK_CHECK(vk.invalidateMappedMemoryRanges(device, 2u, ranges));
3570 const ConstPixelBufferAccess depthAccess (depthFormat, targetSize.x(), targetSize.y(), 1, depthPtr);
3571 const ConstPixelBufferAccess stencilAccess (stencilFormat, targetSize.x(), targetSize.y(), 1, stencilPtr);
3572 tcu::TextureLevel depthErrorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
3573 tcu::TextureLevel stencilErrorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
3575 log << TestLog::Image("Attachment" + de::toString(attachmentNdx) + "Depth", "Attachment " + de::toString(attachmentNdx) + " Depth", depthAccess);
3576 log << TestLog::Image("Attachment" + de::toString(attachmentNdx) + "Stencil", "Attachment " + de::toString(attachmentNdx) + " Stencil", stencilAccess);
3578 log << TestLog::Image("AttachmentReference" + de::toString(attachmentNdx), "Attachment reference " + de::toString(attachmentNdx), referenceAttachments[attachmentNdx].getAccess());
3580 if (renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE
3581 && !verifyDepthAttachment(referenceValues[attachmentNdx], depthAccess, depthErrorImage.getAccess()))
3583 log << TestLog::Image("DepthAttachmentError" + de::toString(attachmentNdx), "Depth Attachment Error " + de::toString(attachmentNdx), depthErrorImage.getAccess());
3587 if (renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE
3588 && !verifyStencilAttachment(referenceValues[attachmentNdx], stencilAccess, stencilErrorImage.getAccess()))
3590 log << TestLog::Image("StencilAttachmentError" + de::toString(attachmentNdx), "Stencil Attachment Error " + de::toString(attachmentNdx), stencilErrorImage.getAccess());
3597 const VkDeviceSize bufferSize = targetSize.x() * targetSize.y() * format.getPixelSize();
3598 void* const ptr = attachmentResources[attachmentNdx]->getResultMemory().getHostPtr();
3600 const VkMappedMemoryRange range =
3602 VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // sType;
3604 attachmentResources[attachmentNdx]->getResultMemory().getMemory(), // mem;
3605 attachmentResources[attachmentNdx]->getResultMemory().getOffset(), // offset;
3608 VK_CHECK(vk.invalidateMappedMemoryRanges(device, 1u, &range));
3610 if (tcu::hasDepthComponent(format.order))
3612 const ConstPixelBufferAccess access (format, targetSize.x(), targetSize.y(), 1, ptr);
3613 tcu::TextureLevel errorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
3615 log << TestLog::Image("Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx), access);
3616 log << TestLog::Image("AttachmentReference" + de::toString(attachmentNdx), "Attachment reference " + de::toString(attachmentNdx), referenceAttachments[attachmentNdx].getAccess());
3618 if ((renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE || renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE)
3619 && !verifyDepthAttachment(referenceValues[attachmentNdx], access, errorImage.getAccess()))
3621 log << TestLog::Image("AttachmentError" + de::toString(attachmentNdx), "Attachment Error " + de::toString(attachmentNdx), errorImage.getAccess());
3625 else if (tcu::hasStencilComponent(format.order))
3627 const ConstPixelBufferAccess access (format, targetSize.x(), targetSize.y(), 1, ptr);
3628 tcu::TextureLevel errorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
3630 log << TestLog::Image("Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx), access);
3631 log << TestLog::Image("AttachmentReference" + de::toString(attachmentNdx), "Attachment reference " + de::toString(attachmentNdx), referenceAttachments[attachmentNdx].getAccess());
3633 if ((renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE || renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE)
3634 && !verifyStencilAttachment(referenceValues[attachmentNdx], access, errorImage.getAccess()))
3636 log << TestLog::Image("AttachmentError" + de::toString(attachmentNdx), "Attachment Error " + de::toString(attachmentNdx), errorImage.getAccess());
3642 const ConstPixelBufferAccess access (format, targetSize.x(), targetSize.y(), 1, ptr);
3643 tcu::TextureLevel errorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
3645 log << TestLog::Image("Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx), access);
3646 log << TestLog::Image("AttachmentReference" + de::toString(attachmentNdx), "Attachment reference " + de::toString(attachmentNdx), referenceAttachments[attachmentNdx].getAccess());
3648 if ((renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE || renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE)
3649 && !verifyColorAttachment(referenceValues[attachmentNdx], access, errorImage.getAccess()))
3651 log << TestLog::Image("AttachmentError" + de::toString(attachmentNdx), "Attachment Error " + de::toString(attachmentNdx), errorImage.getAccess());
3662 std::string getInputAttachmentType (VkFormat vkFormat)
3664 const tcu::TextureFormat format = mapVkFormat(vkFormat);
3665 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
3667 switch (channelClass)
3669 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
3670 return "isubpassInput";
3672 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
3673 return "usubpassInput";
3675 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
3676 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
3677 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
3678 return "subpassInput";
3681 DE_FATAL("Unknown channel class");
3686 std::string getAttachmentType (VkFormat vkFormat)
3688 const tcu::TextureFormat format = mapVkFormat(vkFormat);
3689 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
3691 switch (channelClass)
3693 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
3696 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
3699 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
3700 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
3701 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
3705 DE_FATAL("Unknown channel class");
3710 void createTestShaders (SourceCollections& dst, TestConfig config)
3712 if (config.renderTypes & TestConfig::RENDERTYPES_DRAW)
3714 const vector<Subpass>& subpasses = config.renderPass.getSubpasses();
3716 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
3718 const Subpass& subpass = subpasses[subpassNdx];
3719 deUint32 inputAttachmentBinding = 0;
3720 std::ostringstream vertexShader;
3721 std::ostringstream fragmentShader;
3723 vertexShader << "#version 310 es\n"
3724 << "layout(location = 0) in highp vec2 a_position;\n"
3725 << "void main (void) {\n"
3726 << "\tgl_Position = vec4(a_position, 1.0, 1.0);\n"
3729 fragmentShader << "#version 310 es\n"
3730 << "precision highp float;\n";
3732 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
3734 const deUint32 attachmentIndex = subpass.getInputAttachments()[attachmentNdx].getAttachment();
3735 const VkImageLayout layout = subpass.getInputAttachments()[attachmentNdx].getImageLayout();
3736 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
3737 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3738 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
3739 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
3741 if (isDepthFormat || isStencilFormat)
3743 if (isDepthFormat && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR)
3745 fragmentShader << "layout(input_attachment_index = " << attachmentNdx << ", set=0, binding=" << inputAttachmentBinding << ") uniform highp subpassInput i_depth" << attachmentNdx << ";\n";
3746 inputAttachmentBinding++;
3749 if (isStencilFormat && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
3751 fragmentShader << "layout(input_attachment_index = " << attachmentNdx << ", set=0, binding=" << inputAttachmentBinding << ") uniform highp usubpassInput i_stencil" << attachmentNdx << ";\n";
3752 inputAttachmentBinding++;
3757 const std::string attachmentType = getInputAttachmentType(attachment.getFormat());
3759 fragmentShader << "layout(input_attachment_index = " << attachmentNdx << ", set=0, binding=" << inputAttachmentBinding << ") uniform highp " << attachmentType << " i_color" << attachmentNdx << ";\n";
3760 inputAttachmentBinding++;
3764 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
3766 const std::string attachmentType = getAttachmentType(config.renderPass.getAttachments()[subpass.getColorAttachments()[attachmentNdx].getAttachment()].getFormat());
3767 fragmentShader << "layout(location = " << attachmentNdx << ") out highp " << attachmentType << " o_color" << attachmentNdx << ";\n";
3770 fragmentShader << "void main (void) {\n";
3772 if (subpass.getInputAttachments().empty())
3774 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
3776 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentNdx].getAttachment();
3777 const std::string attachmentType = getAttachmentType(config.renderPass.getAttachments()[attachmentIndex].getFormat());
3779 fragmentShader << "\to_color" << attachmentNdx << " = " << attachmentType << "(vec4(";
3781 for (size_t compNdx = 0; compNdx < 4; compNdx++)
3783 const size_t index = subpassNdx + attachmentIndex + compNdx;
3784 const BoolOp op = boolOpFromIndex(index);
3787 fragmentShader << ",\n\t\t";
3789 fragmentShader << "((int(gl_FragCoord.x) % 2 == " << (index % 2)
3790 << ") " << boolOpToString(op) << " ("
3791 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
3792 << ") ? 1.0 : 0.0)";
3795 fragmentShader << "));\n";
3798 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3799 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3800 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
3802 const size_t index = subpassNdx + 1;
3803 const BoolOp op = boolOpFromIndex(index);
3805 fragmentShader << "\tgl_FragDepth = ((int(gl_FragCoord.x) % 2 == " << (index % 2)
3806 << ") " << boolOpToString(op) << " ("
3807 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
3808 << ") ? 1.0 : 0.0);\n";
3813 size_t inputComponentCount = 0;
3814 size_t outputComponentCount = 0;
3816 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
3818 const deUint32 attachmentIndex = subpass.getInputAttachments()[attachmentNdx].getAttachment();
3819 const VkImageLayout layout = subpass.getInputAttachments()[attachmentNdx].getImageLayout();
3820 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
3821 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3822 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
3824 if (layout == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
3825 inputComponentCount += 1;
3826 else if (layout == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR)
3827 inputComponentCount += 1;
3829 inputComponentCount += componentCount;
3832 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
3834 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentNdx].getAttachment();
3835 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
3836 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3837 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
3839 outputComponentCount += componentCount;
3842 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3843 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3844 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
3846 outputComponentCount++;
3849 if (outputComponentCount > 0)
3851 const size_t inputsPerOutput = inputComponentCount >= outputComponentCount
3852 ? ((inputComponentCount / outputComponentCount)
3853 + ((inputComponentCount % outputComponentCount) != 0 ? 1 : 0))
3856 fragmentShader << "\tbool inputs[" << inputComponentCount << "];\n";
3858 if (outputComponentCount > 0)
3859 fragmentShader << "\tbool outputs[" << outputComponentCount << "];\n";
3861 size_t inputValueNdx = 0;
3863 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
3865 const char* const components[] =
3869 const deUint32 attachmentIndex = subpass.getInputAttachments()[attachmentNdx].getAttachment();
3870 const VkImageLayout layout = subpass.getInputAttachments()[attachmentNdx].getImageLayout();
3871 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
3872 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3873 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
3874 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
3875 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
3877 if (isDepthFormat || isStencilFormat)
3879 if (isDepthFormat && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR)
3881 fragmentShader << "\tinputs[" << inputValueNdx << "] = 1.0 == float(subpassLoad(i_depth" << attachmentNdx << ").x);\n";
3885 if (isStencilFormat && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
3887 fragmentShader << "\tinputs[" << inputValueNdx << "] = 255u == subpassLoad(i_stencil" << attachmentNdx << ").x;\n";
3893 for (size_t compNdx = 0; compNdx < componentCount; compNdx++)
3895 fragmentShader << "\tinputs[" << inputValueNdx << "] = 1.0 == float(subpassLoad(i_color" << attachmentNdx << ")." << components[compNdx] << ");\n";
3901 size_t outputValueNdx = 0;
3903 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
3905 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentNdx].getAttachment();
3906 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
3907 const std::string attachmentType = getAttachmentType(config.renderPass.getAttachments()[attachmentIndex].getFormat());
3908 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3909 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
3911 for (size_t compNdx = 0; compNdx < componentCount; compNdx++)
3913 const size_t index = subpassNdx + attachmentIndex + outputValueNdx;
3914 const BoolOp op = boolOpFromIndex(index);
3916 fragmentShader << "\toutputs[" << outputValueNdx + compNdx << "] = "
3917 << "(int(gl_FragCoord.x) % 2 == " << (index % 2)
3918 << ") " << boolOpToString(op) << " ("
3919 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
3922 for (size_t i = 0; i < inputsPerOutput; i++)
3923 fragmentShader << "\toutputs[" << outputValueNdx + compNdx << "] = outputs[" << outputValueNdx + compNdx << "] == inputs[" << ((outputValueNdx + compNdx) * inputsPerOutput + i) % inputComponentCount << "];\n";
3926 fragmentShader << "\to_color" << attachmentNdx << " = " << attachmentType << "(";
3928 for (size_t compNdx = 0; compNdx < 4; compNdx++)
3931 fragmentShader << ", ";
3933 if (compNdx < componentCount)
3934 fragmentShader << "outputs[" << outputValueNdx + compNdx << "]";
3936 fragmentShader << "0";
3939 outputValueNdx += componentCount;
3941 fragmentShader << ");\n";
3944 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3945 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3946 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
3948 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3949 const size_t index = subpassNdx + attachmentIndex;
3950 const BoolOp op = boolOpFromIndex(index);
3952 fragmentShader << "\toutputs[" << outputValueNdx << "] = "
3953 << "(int(gl_FragCoord.x) % 2 == " << (index % 2)
3954 << ") " << boolOpToString(op) << " ("
3955 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
3958 for (size_t i = 0; i < inputsPerOutput; i++)
3959 fragmentShader << "\toutputs[" << outputValueNdx << "] = outputs[" << outputValueNdx << "] == inputs[" << (outputValueNdx * inputsPerOutput + i) % inputComponentCount << "];\n";
3961 fragmentShader << "\tgl_FragDepth = outputs[" << outputValueNdx << "] ? 1.0 : 0.0;";
3966 fragmentShader << "}\n";
3968 dst.glslSources.add(de::toString(subpassNdx) + "-vert") << glu::VertexSource(vertexShader.str());
3969 dst.glslSources.add(de::toString(subpassNdx) + "-frag") << glu::FragmentSource(fragmentShader.str());
3974 void initializeAttachmentIsLazy (vector<bool>& attachmentIsLazy, const vector<Attachment>& attachments, TestConfig::ImageMemory imageMemory)
3976 bool lastAttachmentWasLazy = false;
3978 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
3980 if (attachments[attachmentNdx].getLoadOp() != VK_ATTACHMENT_LOAD_OP_LOAD
3981 && attachments[attachmentNdx].getStoreOp() != VK_ATTACHMENT_STORE_OP_STORE
3982 && attachments[attachmentNdx].getStencilLoadOp() != VK_ATTACHMENT_LOAD_OP_LOAD
3983 && attachments[attachmentNdx].getStencilStoreOp() != VK_ATTACHMENT_STORE_OP_STORE)
3985 if (imageMemory == TestConfig::IMAGEMEMORY_LAZY || (imageMemory & TestConfig::IMAGEMEMORY_LAZY && !lastAttachmentWasLazy))
3987 attachmentIsLazy.push_back(true);
3989 lastAttachmentWasLazy = true;
3991 else if (imageMemory & TestConfig::IMAGEMEMORY_STRICT)
3993 attachmentIsLazy.push_back(false);
3994 lastAttachmentWasLazy = false;
3997 DE_FATAL("Unknown imageMemory");
4000 attachmentIsLazy.push_back(false);
4004 enum AttachmentRefType
4006 ATTACHMENTREFTYPE_COLOR,
4007 ATTACHMENTREFTYPE_DEPTH_STENCIL,
4008 ATTACHMENTREFTYPE_INPUT,
4009 ATTACHMENTREFTYPE_RESOLVE,
4012 VkImageUsageFlags getImageUsageFromLayout (VkImageLayout layout)
4016 case VK_IMAGE_LAYOUT_GENERAL:
4017 case VK_IMAGE_LAYOUT_PREINITIALIZED:
4020 case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
4021 return VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4023 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
4024 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL:
4025 return VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
4027 case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
4028 return VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
4030 case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
4031 return VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
4033 case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
4034 return VK_IMAGE_USAGE_TRANSFER_DST_BIT;
4037 DE_FATAL("Unexpected image layout");
4042 void getImageUsageFromAttachmentReferences(vector<VkImageUsageFlags>& attachmentImageUsage, AttachmentRefType refType, size_t count, const AttachmentReference* references)
4044 for (size_t referenceNdx = 0; referenceNdx < count; ++referenceNdx)
4046 const deUint32 attachment = references[referenceNdx].getAttachment();
4048 if (attachment != VK_ATTACHMENT_UNUSED)
4050 VkImageUsageFlags usage;
4054 case ATTACHMENTREFTYPE_COLOR:
4055 case ATTACHMENTREFTYPE_RESOLVE:
4056 usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4059 case ATTACHMENTREFTYPE_DEPTH_STENCIL:
4060 usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
4063 case ATTACHMENTREFTYPE_INPUT:
4064 usage = VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
4068 DE_FATAL("Unexpected attachment reference type");
4073 attachmentImageUsage[attachment] |= usage;
4078 void getImageUsageFromAttachmentReferences(vector<VkImageUsageFlags>& attachmentImageUsage, AttachmentRefType refType, const vector<AttachmentReference>& references)
4080 if (!references.empty())
4082 getImageUsageFromAttachmentReferences(attachmentImageUsage, refType, references.size(), &references[0]);
4086 void initializeAttachmentImageUsage (Context &context, vector<VkImageUsageFlags>& attachmentImageUsage, const RenderPass& renderPassInfo, const vector<bool>& attachmentIsLazy, const vector<Maybe<VkClearValue> >& clearValues)
4088 attachmentImageUsage.resize(renderPassInfo.getAttachments().size(), VkImageUsageFlags(0));
4090 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); ++subpassNdx)
4092 const Subpass& subpass = renderPassInfo.getSubpasses()[subpassNdx];
4094 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_COLOR, subpass.getColorAttachments());
4095 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_DEPTH_STENCIL, 1, &subpass.getDepthStencilAttachment());
4096 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_INPUT, subpass.getInputAttachments());
4097 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_RESOLVE, subpass.getResolveAttachments());
4100 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
4102 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentNdx];
4103 const VkFormatProperties formatProperties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), attachment.getFormat());
4104 const VkFormatFeatureFlags supportedFeatures = formatProperties.optimalTilingFeatures;
4106 if ((supportedFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0)
4107 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_SAMPLED_BIT;
4109 if ((supportedFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) != 0)
4110 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_STORAGE_BIT;
4112 attachmentImageUsage[attachmentNdx] |= getImageUsageFromLayout(attachment.getInitialLayout());
4113 attachmentImageUsage[attachmentNdx] |= getImageUsageFromLayout(attachment.getFinalLayout());
4115 if (!attachmentIsLazy[attachmentNdx])
4117 if (clearValues[attachmentNdx])
4118 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
4120 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
4124 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);
4126 attachmentImageUsage[attachmentNdx] &= allowedTransientBits;
4127 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4132 void initializeSubpassIsSecondary (vector<bool>& subpassIsSecondary, const vector<Subpass>& subpasses, TestConfig::CommandBufferTypes commandBuffer)
4134 bool lastSubpassWasSecondary = false;
4136 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
4138 if (commandBuffer == TestConfig::COMMANDBUFFERTYPES_SECONDARY || (commandBuffer & TestConfig::COMMANDBUFFERTYPES_SECONDARY && !lastSubpassWasSecondary))
4140 subpassIsSecondary.push_back(true);
4141 lastSubpassWasSecondary = true;
4143 else if (commandBuffer & TestConfig::COMMANDBUFFERTYPES_INLINE)
4145 subpassIsSecondary.push_back(false);
4146 lastSubpassWasSecondary = false;
4149 DE_FATAL("Unknown commandBuffer");
4153 void initializeImageClearValues (de::Random& rng, vector<Maybe<VkClearValue> >& clearValues, const vector<Attachment>& attachments, const vector<bool>& isLazy)
4155 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4157 if (!isLazy[attachmentNdx])
4158 clearValues.push_back(just(randomClearValue(attachments[attachmentNdx], rng)));
4160 clearValues.push_back(nothing<VkClearValue>());
4164 void initializeRenderPassClearValues (de::Random& rng, vector<Maybe<VkClearValue> >& clearValues, const vector<Attachment>& attachments)
4166 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4168 if (attachments[attachmentNdx].getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR
4169 || attachments[attachmentNdx].getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
4171 clearValues.push_back(just(randomClearValue(attachments[attachmentNdx], rng)));
4174 clearValues.push_back(nothing<VkClearValue>());
4178 void initializeSubpassClearValues (de::Random& rng, vector<vector<VkClearColorValue> >& clearValues, const RenderPass& renderPass)
4180 clearValues.resize(renderPass.getSubpasses().size());
4182 for (size_t subpassNdx = 0; subpassNdx < renderPass.getSubpasses().size(); subpassNdx++)
4184 const Subpass& subpass = renderPass.getSubpasses()[subpassNdx];
4185 const vector<AttachmentReference>& colorAttachments = subpass.getColorAttachments();
4187 clearValues[subpassNdx].resize(colorAttachments.size());
4189 for (size_t attachmentRefNdx = 0; attachmentRefNdx < colorAttachments.size(); attachmentRefNdx++)
4191 const AttachmentReference& attachmentRef = colorAttachments[attachmentRefNdx];
4192 const Attachment& attachment = renderPass.getAttachments()[attachmentRef.getAttachment()];
4194 clearValues[subpassNdx][attachmentRefNdx] = randomColorClearValue(attachment, rng);
4199 void logSubpassRenderInfo (TestLog& log,
4200 const SubpassRenderInfo& info)
4202 log << TestLog::Message << "Viewport, offset: " << info.getViewportOffset() << ", size: " << info.getViewportSize() << TestLog::EndMessage;
4204 if (info.isSecondary())
4205 log << TestLog::Message << "Subpass uses secondary command buffers" << TestLog::EndMessage;
4207 log << TestLog::Message << "Subpass uses inlined commands" << TestLog::EndMessage;
4209 for (deUint32 attachmentNdx = 0; attachmentNdx < info.getColorClears().size(); attachmentNdx++)
4211 const ColorClear& colorClear = info.getColorClears()[attachmentNdx];
4213 log << TestLog::Message << "Clearing color attachment " << attachmentNdx
4214 << ". Offset: " << colorClear.getOffset()
4215 << ", Size: " << colorClear.getSize()
4216 << ", Color: " << clearColorToString(info.getColorAttachment(attachmentNdx).getFormat(), colorClear.getColor()) << TestLog::EndMessage;
4219 if (info.getDepthStencilClear())
4221 const DepthStencilClear& depthStencilClear = *info.getDepthStencilClear();
4223 log << TestLog::Message << "Clearing depth stencil attachment"
4224 << ". Offset: " << depthStencilClear.getOffset()
4225 << ", Size: " << depthStencilClear.getSize()
4226 << ", Depth: " << depthStencilClear.getDepth()
4227 << ", Stencil: " << depthStencilClear.getStencil() << TestLog::EndMessage;
4230 if (info.getRenderQuad())
4232 const RenderQuad& renderQuad = *info.getRenderQuad();
4234 log << TestLog::Message << "Rendering grid quad to " << renderQuad.getCornerA() << " -> " << renderQuad.getCornerB() << TestLog::EndMessage;
4238 void logTestCaseInfo (TestLog& log,
4239 const TestConfig& config,
4240 const vector<bool>& attachmentIsLazy,
4241 const vector<Maybe<VkClearValue> >& imageClearValues,
4242 const vector<Maybe<VkClearValue> >& renderPassClearValues,
4243 const vector<SubpassRenderInfo>& subpassRenderInfo)
4245 const RenderPass& renderPass = config.renderPass;
4247 logRenderPassInfo(log, renderPass);
4249 DE_ASSERT(attachmentIsLazy.size() == renderPass.getAttachments().size());
4250 DE_ASSERT(imageClearValues.size() == renderPass.getAttachments().size());
4251 DE_ASSERT(renderPassClearValues.size() == renderPass.getAttachments().size());
4253 log << TestLog::Message << "TargetSize: " << config.targetSize << TestLog::EndMessage;
4254 log << TestLog::Message << "Render area, Offset: " << config.renderPos << ", Size: " << config.renderSize << TestLog::EndMessage;
4256 for (size_t attachmentNdx = 0; attachmentNdx < attachmentIsLazy.size(); attachmentNdx++)
4258 const tcu::ScopedLogSection section (log, "Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx));
4260 if (attachmentIsLazy[attachmentNdx])
4261 log << TestLog::Message << "Is lazy." << TestLog::EndMessage;
4263 if (imageClearValues[attachmentNdx])
4264 log << TestLog::Message << "Image is cleared to " << clearValueToString(renderPass.getAttachments()[attachmentNdx].getFormat(), *imageClearValues[attachmentNdx]) << " before rendering." << TestLog::EndMessage;
4266 if (renderPass.getAttachments()[attachmentNdx].getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR && renderPassClearValues[attachmentNdx])
4267 log << TestLog::Message << "Attachment is cleared to " << clearValueToString(renderPass.getAttachments()[attachmentNdx].getFormat(), *renderPassClearValues[attachmentNdx]) << " in the beginning of the render pass." << TestLog::EndMessage;
4270 for (size_t subpassNdx = 0; subpassNdx < renderPass.getSubpasses().size(); subpassNdx++)
4272 const tcu::ScopedLogSection section (log, "Subpass" + de::toString(subpassNdx), "Subpass " + de::toString(subpassNdx));
4274 logSubpassRenderInfo(log, subpassRenderInfo[subpassNdx]);
4278 float roundToViewport (float x, deUint32 offset, deUint32 size)
4280 const float origin = (float)(offset) + ((float(size) / 2.0f));
4281 const float p = (float)(size) / 2.0f;
4282 const deInt32 xi = deRoundFloatToInt32(origin + (p * x));
4284 return (((float)xi) - origin) / p;
4287 void initializeSubpassRenderInfo (vector<SubpassRenderInfo>& renderInfos, de::Random& rng, const RenderPass& renderPass, const TestConfig& config)
4289 const TestConfig::CommandBufferTypes commandBuffer = config.commandBufferTypes;
4290 const vector<Subpass>& subpasses = renderPass.getSubpasses();
4291 bool lastSubpassWasSecondary = false;
4293 for (deUint32 subpassNdx = 0; subpassNdx < (deUint32)subpasses.size(); subpassNdx++)
4295 const Subpass& subpass = subpasses[subpassNdx];
4296 const bool subpassIsSecondary = commandBuffer == TestConfig::COMMANDBUFFERTYPES_SECONDARY
4297 || (commandBuffer & TestConfig::COMMANDBUFFERTYPES_SECONDARY && !lastSubpassWasSecondary) ? true : false;
4298 const UVec2 viewportSize ((config.renderSize * UVec2(2)) / UVec2(3));
4299 const UVec2 viewportOffset (config.renderPos.x() + (subpassNdx % 2) * (config.renderSize.x() / 3),
4300 config.renderPos.y() + ((subpassNdx / 2) % 2) * (config.renderSize.y() / 3));
4302 vector<ColorClear> colorClears;
4303 Maybe<DepthStencilClear> depthStencilClear;
4304 Maybe<RenderQuad> renderQuad;
4306 lastSubpassWasSecondary = subpassIsSecondary;
4308 if (config.renderTypes & TestConfig::RENDERTYPES_CLEAR)
4310 const vector<AttachmentReference>& colorAttachments = subpass.getColorAttachments();
4312 for (size_t attachmentRefNdx = 0; attachmentRefNdx < colorAttachments.size(); attachmentRefNdx++)
4314 const AttachmentReference& attachmentRef = colorAttachments[attachmentRefNdx];
4315 const Attachment& attachment = renderPass.getAttachments()[attachmentRef.getAttachment()];
4316 const UVec2 size ((viewportSize * UVec2(2)) / UVec2(3));
4317 const UVec2 offset (viewportOffset.x() + ((deUint32)attachmentRefNdx % 2u) * (viewportSize.x() / 3u),
4318 viewportOffset.y() + (((deUint32)attachmentRefNdx / 2u) % 2u) * (viewportSize.y() / 3u));
4319 const VkClearColorValue color = randomColorClearValue(attachment, rng);
4321 colorClears.push_back(ColorClear(offset, size, color));
4324 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
4326 const Attachment& attachment = renderPass.getAttachments()[subpass.getDepthStencilAttachment().getAttachment()];
4327 const UVec2 size ((viewportSize * UVec2(2)) / UVec2(3));
4328 const UVec2 offset (viewportOffset.x() + ((deUint32)colorAttachments.size() % 2u) * (viewportSize.x() / 3u),
4329 viewportOffset.y() + (((deUint32)colorAttachments.size() / 2u) % 2u) * (viewportSize.y() / 3u));
4330 const VkClearValue value = randomClearValue(attachment, rng);
4332 depthStencilClear = tcu::just(DepthStencilClear(offset, size, value.depthStencil.depth, value.depthStencil.stencil));
4336 if (config.renderTypes & TestConfig::RENDERTYPES_DRAW)
4338 const float w = (subpassNdx % 2) == 0 ? 1.0f : 1.25f;
4339 const float h = (subpassNdx % 2) == 0 ? 1.25f : 1.0f;
4341 const float x0 = roundToViewport((subpassNdx % 2) == 0 ? 1.0f - w : -1.0f, viewportOffset.x(), viewportSize.x());
4342 const float x1 = roundToViewport((subpassNdx % 2) == 0 ? 1.0f : -1.0f + w, viewportOffset.x(), viewportSize.x());
4344 const float y0 = roundToViewport(((subpassNdx / 2) % 2) == 0 ? 1.0f - h : -1.0f, viewportOffset.y(), viewportSize.y());
4345 const float y1 = roundToViewport(((subpassNdx / 2) % 2) == 0 ? 1.0f : -1.0f + h, viewportOffset.y(), viewportSize.y());
4347 renderQuad = tcu::just(RenderQuad(tcu::Vec2(x0, y0), tcu::Vec2(x1, y1)));
4350 renderInfos.push_back(SubpassRenderInfo(renderPass, subpassNdx, subpassIsSecondary, viewportOffset, viewportSize, renderQuad, colorClears, depthStencilClear));
4354 void checkTextureFormatSupport (TestLog& log,
4355 const InstanceInterface& vk,
4356 VkPhysicalDevice device,
4357 const vector<Attachment>& attachments)
4359 bool supported = true;
4361 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4363 const Attachment& attachment = attachments[attachmentNdx];
4364 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4365 const bool isDepthOrStencilAttachment = hasDepthComponent(format.order) || hasStencilComponent(format.order);
4366 const VkFormatFeatureFlags flags = isDepthOrStencilAttachment? VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT : VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
4367 VkFormatProperties properties;
4369 vk.getPhysicalDeviceFormatProperties(device, attachment.getFormat(), &properties);
4371 if ((properties.optimalTilingFeatures & flags) != flags)
4374 log << TestLog::Message << "Format: " << attachment.getFormat() << " not supported as " << (isDepthOrStencilAttachment ? "depth stencil attachment" : "color attachment") << TestLog::EndMessage;
4379 TCU_THROW(NotSupportedError, "Format not supported");
4382 tcu::TestStatus renderPassTest (Context& context, TestConfig config)
4384 const UVec2 targetSize = config.targetSize;
4385 const UVec2 renderPos = config.renderPos;
4386 const UVec2 renderSize = config.renderSize;
4387 const RenderPass& renderPassInfo = config.renderPass;
4389 TestLog& log = context.getTestContext().getLog();
4390 de::Random rng (config.seed);
4392 vector<bool> attachmentIsLazy;
4393 vector<VkImageUsageFlags> attachmentImageUsage;
4394 vector<Maybe<VkClearValue> > imageClearValues;
4395 vector<Maybe<VkClearValue> > renderPassClearValues;
4397 vector<bool> subpassIsSecondary;
4398 vector<SubpassRenderInfo> subpassRenderInfo;
4399 vector<vector<VkClearColorValue> > subpassColorClearValues;
4401 if (config.allocationKind == ALLOCATION_KIND_DEDICATED)
4403 const std::string extensionName("VK_KHR_dedicated_allocation");
4405 if (!de::contains(context.getDeviceExtensions().begin(), context.getDeviceExtensions().end(), extensionName))
4406 TCU_THROW(NotSupportedError, std::string(extensionName + " is not supported").c_str());
4409 if (!renderPassInfo.getInputAspects().empty())
4411 if (!de::contains(context.getDeviceExtensions().begin(), context.getDeviceExtensions().end(), string("VK_KHR_maintenance2")))
4412 TCU_THROW(NotSupportedError, "Extension VK_KHR_maintenance2 not supported.");
4416 bool requireDepthStencilLayout = false;
4418 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
4420 if (renderPassInfo.getAttachments()[attachmentNdx].getInitialLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR
4421 || renderPassInfo.getAttachments()[attachmentNdx].getInitialLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR
4422 || renderPassInfo.getAttachments()[attachmentNdx].getFinalLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR
4423 || renderPassInfo.getAttachments()[attachmentNdx].getFinalLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
4425 requireDepthStencilLayout = true;
4430 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size() && !requireDepthStencilLayout; subpassNdx++)
4432 const Subpass& subpass (renderPassInfo.getSubpasses()[subpassNdx]);
4434 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
4436 if (subpass.getColorAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR
4437 || subpass.getColorAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
4439 requireDepthStencilLayout = true;
4444 for (size_t attachmentNdx = 0; !requireDepthStencilLayout && attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
4446 if (subpass.getInputAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR
4447 || subpass.getInputAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
4449 requireDepthStencilLayout = true;
4454 for (size_t attachmentNdx = 0; !requireDepthStencilLayout && attachmentNdx < subpass.getResolveAttachments().size(); attachmentNdx++)
4456 if (subpass.getResolveAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR
4457 || subpass.getResolveAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
4459 requireDepthStencilLayout = true;
4464 if (subpass.getDepthStencilAttachment().getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR
4465 || subpass.getDepthStencilAttachment().getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
4467 requireDepthStencilLayout = true;
4472 if (requireDepthStencilLayout && !de::contains(context.getDeviceExtensions().begin(), context.getDeviceExtensions().end(), string("VK_KHR_maintenance2")))
4473 TCU_THROW(NotSupportedError, "VK_KHR_maintenance2 is not supported");
4476 initializeAttachmentIsLazy(attachmentIsLazy, renderPassInfo.getAttachments(), config.imageMemory);
4477 initializeImageClearValues(rng, imageClearValues, renderPassInfo.getAttachments(), attachmentIsLazy);
4478 initializeAttachmentImageUsage(context, attachmentImageUsage, renderPassInfo, attachmentIsLazy, imageClearValues);
4479 initializeRenderPassClearValues(rng, renderPassClearValues, renderPassInfo.getAttachments());
4481 initializeSubpassIsSecondary(subpassIsSecondary, renderPassInfo.getSubpasses(), config.commandBufferTypes);
4482 initializeSubpassClearValues(rng, subpassColorClearValues, renderPassInfo);
4483 initializeSubpassRenderInfo(subpassRenderInfo, rng, renderPassInfo, config);
4485 logTestCaseInfo(log, config, attachmentIsLazy, imageClearValues, renderPassClearValues, subpassRenderInfo);
4487 checkTextureFormatSupport(log, context.getInstanceInterface(), context.getPhysicalDevice(), config.renderPass.getAttachments());
4490 const vk::VkPhysicalDeviceProperties properties = vk::getPhysicalDeviceProperties(context.getInstanceInterface(), context.getPhysicalDevice());
4492 log << TestLog::Message << "Max color attachments: " << properties.limits.maxColorAttachments << TestLog::EndMessage;
4494 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); subpassNdx++)
4496 if (renderPassInfo.getSubpasses()[subpassNdx].getColorAttachments().size() > (size_t)properties.limits.maxColorAttachments)
4497 TCU_THROW(NotSupportedError, "Subpass uses more than maxColorAttachments.");
4502 const InstanceInterface& vki = context.getInstanceInterface();
4503 const VkPhysicalDevice& physDevice = context.getPhysicalDevice();
4504 const VkDevice device = context.getDevice();
4505 const DeviceInterface& vk = context.getDeviceInterface();
4506 const VkQueue queue = context.getUniversalQueue();
4507 const deUint32 queueIndex = context.getUniversalQueueFamilyIndex();
4508 Allocator& allocator = context.getDefaultAllocator();
4510 const Unique<VkRenderPass> renderPass (createRenderPass(vk, device, renderPassInfo));
4511 const Unique<VkCommandPool> commandBufferPool (createCommandPool(vk, device, queueIndex, 0));
4512 const Unique<VkCommandBuffer> initializeImagesCommandBuffer (allocateCommandBuffer(vk, device, *commandBufferPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
4513 const Unique<VkCommandBuffer> renderCommandBuffer (allocateCommandBuffer(vk, device, *commandBufferPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
4514 const Unique<VkCommandBuffer> readImagesToBuffersCommandBuffer (allocateCommandBuffer(vk, device, *commandBufferPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
4516 vector<de::SharedPtr<AttachmentResources> > attachmentResources;
4517 vector<de::SharedPtr<SubpassRenderer> > subpassRenderers;
4518 vector<VkImage> attachmentImages;
4519 vector<VkImageView> attachmentViews;
4520 vector<pair<VkImageView, VkImageView> > inputAttachmentViews;
4522 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
4524 const Attachment& attachmentInfo = renderPassInfo.getAttachments()[attachmentNdx];
4526 attachmentResources.push_back(de::SharedPtr<AttachmentResources>(new AttachmentResources(vki, physDevice, vk, device, allocator, queueIndex, targetSize, attachmentInfo, attachmentImageUsage[attachmentNdx], config.allocationKind)));
4527 attachmentViews.push_back(attachmentResources[attachmentNdx]->getAttachmentView());
4528 attachmentImages.push_back(attachmentResources[attachmentNdx]->getImage());
4530 inputAttachmentViews.push_back(attachmentResources[attachmentNdx]->getInputAttachmentViews());
4533 beginCommandBuffer(vk, *initializeImagesCommandBuffer, (VkCommandBufferUsageFlags)0, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0);
4534 pushImageInitializationCommands(vk, *initializeImagesCommandBuffer, renderPassInfo.getAttachments(), attachmentResources, queueIndex, imageClearValues);
4535 endCommandBuffer(vk, *initializeImagesCommandBuffer);
4538 const Unique<VkFramebuffer> framebuffer (createFramebuffer(vk, device, *renderPass, targetSize, attachmentViews));
4540 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); subpassNdx++)
4541 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)));
4543 beginCommandBuffer(vk, *renderCommandBuffer, (VkCommandBufferUsageFlags)0, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0);
4544 pushRenderPassCommands(vk, *renderCommandBuffer, *renderPass, *framebuffer, subpassRenderers, renderPos, renderSize, renderPassClearValues, config.renderTypes);
4545 endCommandBuffer(vk, *renderCommandBuffer);
4547 beginCommandBuffer(vk, *readImagesToBuffersCommandBuffer, (VkCommandBufferUsageFlags)0, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0);
4548 pushReadImagesToBuffers(vk, *readImagesToBuffersCommandBuffer, queueIndex, attachmentResources, renderPassInfo.getAttachments(), attachmentIsLazy, targetSize);
4549 endCommandBuffer(vk, *readImagesToBuffersCommandBuffer);
4551 const VkCommandBuffer commandBuffers[] =
4553 *initializeImagesCommandBuffer,
4554 *renderCommandBuffer,
4555 *readImagesToBuffersCommandBuffer
4557 const Unique<VkFence> fence (createFence(vk, device, 0u));
4559 queueSubmit(vk, queue, DE_LENGTH_OF_ARRAY(commandBuffers), commandBuffers, *fence);
4560 waitForFences(vk, device, 1, &fence.get(), VK_TRUE, ~0ull);
4564 if (logAndVerifyImages(log, vk, device, attachmentResources, attachmentIsLazy, renderPassInfo, renderPassClearValues, imageClearValues, subpassRenderInfo, targetSize, config))
4565 return tcu::TestStatus::pass("Pass");
4567 return tcu::TestStatus::fail("Result verification failed");
4571 static const VkFormat s_coreColorFormats[] =
4573 VK_FORMAT_R5G6B5_UNORM_PACK16,
4578 VK_FORMAT_R8G8_UNORM,
4579 VK_FORMAT_R8G8_SNORM,
4580 VK_FORMAT_R8G8_UINT,
4581 VK_FORMAT_R8G8_SINT,
4582 VK_FORMAT_R8G8B8A8_UNORM,
4583 VK_FORMAT_R8G8B8A8_SNORM,
4584 VK_FORMAT_R8G8B8A8_UINT,
4585 VK_FORMAT_R8G8B8A8_SINT,
4586 VK_FORMAT_R8G8B8A8_SRGB,
4587 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
4588 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
4589 VK_FORMAT_A8B8G8R8_UINT_PACK32,
4590 VK_FORMAT_A8B8G8R8_SINT_PACK32,
4591 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
4592 VK_FORMAT_B8G8R8A8_UNORM,
4593 VK_FORMAT_B8G8R8A8_SRGB,
4594 VK_FORMAT_A2R10G10B10_UNORM_PACK32,
4595 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
4596 VK_FORMAT_A2B10G10R10_UINT_PACK32,
4597 VK_FORMAT_R16_UNORM,
4598 VK_FORMAT_R16_SNORM,
4601 VK_FORMAT_R16_SFLOAT,
4602 VK_FORMAT_R16G16_UNORM,
4603 VK_FORMAT_R16G16_SNORM,
4604 VK_FORMAT_R16G16_UINT,
4605 VK_FORMAT_R16G16_SINT,
4606 VK_FORMAT_R16G16_SFLOAT,
4607 VK_FORMAT_R16G16B16A16_UNORM,
4608 VK_FORMAT_R16G16B16A16_SNORM,
4609 VK_FORMAT_R16G16B16A16_UINT,
4610 VK_FORMAT_R16G16B16A16_SINT,
4611 VK_FORMAT_R16G16B16A16_SFLOAT,
4614 VK_FORMAT_R32_SFLOAT,
4615 VK_FORMAT_R32G32_UINT,
4616 VK_FORMAT_R32G32_SINT,
4617 VK_FORMAT_R32G32_SFLOAT,
4618 VK_FORMAT_R32G32B32A32_UINT,
4619 VK_FORMAT_R32G32B32A32_SINT,
4620 VK_FORMAT_R32G32B32A32_SFLOAT
4623 static const VkFormat s_coreDepthStencilFormats[] =
4625 VK_FORMAT_D16_UNORM,
4627 VK_FORMAT_X8_D24_UNORM_PACK32,
4628 VK_FORMAT_D32_SFLOAT,
4630 VK_FORMAT_D24_UNORM_S8_UINT,
4631 VK_FORMAT_D32_SFLOAT_S8_UINT
4634 void addAttachmentTests (tcu::TestCaseGroup* group, AllocationKind allocationKind)
4636 const deUint32 attachmentCounts[] = { 1, 3, 4, 8 };
4637 const VkAttachmentLoadOp loadOps[] =
4639 VK_ATTACHMENT_LOAD_OP_LOAD,
4640 VK_ATTACHMENT_LOAD_OP_CLEAR,
4641 VK_ATTACHMENT_LOAD_OP_DONT_CARE
4644 const VkAttachmentStoreOp storeOps[] =
4646 VK_ATTACHMENT_STORE_OP_STORE,
4647 VK_ATTACHMENT_STORE_OP_DONT_CARE
4650 const VkImageLayout initialAndFinalColorLayouts[] =
4652 VK_IMAGE_LAYOUT_GENERAL,
4653 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
4654 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
4655 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
4656 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
4659 const VkImageLayout initialAndFinalDepthStencilLayouts[] =
4661 VK_IMAGE_LAYOUT_GENERAL,
4662 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
4663 VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL,
4664 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
4665 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
4666 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
4669 const VkImageLayout subpassLayouts[] =
4671 VK_IMAGE_LAYOUT_GENERAL,
4672 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
4675 const VkImageLayout depthStencilLayouts[] =
4677 VK_IMAGE_LAYOUT_GENERAL,
4678 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
4681 const TestConfig::RenderTypes renderCommands[] =
4683 TestConfig::RENDERTYPES_NONE,
4684 TestConfig::RENDERTYPES_CLEAR,
4685 TestConfig::RENDERTYPES_DRAW,
4686 TestConfig::RENDERTYPES_CLEAR|TestConfig::RENDERTYPES_DRAW,
4689 const TestConfig::CommandBufferTypes commandBuffers[] =
4691 TestConfig::COMMANDBUFFERTYPES_INLINE,
4692 TestConfig::COMMANDBUFFERTYPES_SECONDARY,
4693 TestConfig::COMMANDBUFFERTYPES_INLINE|TestConfig::COMMANDBUFFERTYPES_SECONDARY
4696 const TestConfig::ImageMemory imageMemories[] =
4698 TestConfig::IMAGEMEMORY_STRICT,
4699 TestConfig::IMAGEMEMORY_LAZY,
4700 TestConfig::IMAGEMEMORY_STRICT|TestConfig::IMAGEMEMORY_LAZY
4703 const UVec2 targetSizes[] =
4709 const UVec2 renderPositions[] =
4715 const UVec2 renderSizes[] =
4721 tcu::TestContext& testCtx = group->getTestContext();
4722 de::Random rng (1433774382u);
4724 for (size_t attachmentCountNdx = 0; attachmentCountNdx < DE_LENGTH_OF_ARRAY(attachmentCounts); attachmentCountNdx++)
4726 const deUint32 attachmentCount = attachmentCounts[attachmentCountNdx];
4727 const deUint32 testCaseCount = (attachmentCount == 1 ? 100 : 200);
4728 de::MovePtr<tcu::TestCaseGroup> attachmentCountGroup (new tcu::TestCaseGroup(testCtx, de::toString(attachmentCount).c_str(), de::toString(attachmentCount).c_str()));
4730 for (size_t testCaseNdx = 0; testCaseNdx < testCaseCount; testCaseNdx++)
4732 const bool useDepthStencil = rng.getBool();
4733 VkImageLayout depthStencilLayout = VK_IMAGE_LAYOUT_GENERAL;
4734 vector<Attachment> attachments;
4735 vector<AttachmentReference> colorAttachmentReferences;
4737 for (size_t attachmentNdx = 0; attachmentNdx < attachmentCount; attachmentNdx++)
4739 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
4740 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreColorFormats), DE_ARRAY_END(s_coreColorFormats));
4741 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
4742 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
4744 const VkImageLayout initialLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
4745 const VkImageLayout finalizeLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
4746 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayouts), DE_ARRAY_END(subpassLayouts));
4748 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
4749 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
4751 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
4752 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
4755 if (useDepthStencil)
4757 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
4758 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreDepthStencilFormats), DE_ARRAY_END(s_coreDepthStencilFormats));
4759 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
4760 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
4762 const VkImageLayout initialLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts));
4763 const VkImageLayout finalizeLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts));
4765 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
4766 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
4768 depthStencilLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(depthStencilLayouts), DE_ARRAY_END(depthStencilLayouts));
4769 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
4773 const TestConfig::RenderTypes render = rng.choose<TestConfig::RenderTypes>(DE_ARRAY_BEGIN(renderCommands), DE_ARRAY_END(renderCommands));
4774 const TestConfig::CommandBufferTypes commandBuffer = rng.choose<TestConfig::CommandBufferTypes>(DE_ARRAY_BEGIN(commandBuffers), DE_ARRAY_END(commandBuffers));
4775 const TestConfig::ImageMemory imageMemory = rng.choose<TestConfig::ImageMemory>(DE_ARRAY_BEGIN(imageMemories), DE_ARRAY_END(imageMemories));
4776 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>()));
4777 const vector<SubpassDependency> deps;
4779 const string testCaseName = de::toString(attachmentCountNdx * testCaseCount + testCaseNdx);
4780 const RenderPass renderPass (attachments, subpasses, deps);
4781 const UVec2 targetSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(targetSizes), DE_ARRAY_END(targetSizes));
4782 const UVec2 renderPos = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderPositions), DE_ARRAY_END(renderPositions));
4783 const UVec2 renderSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderSizes), DE_ARRAY_END(renderSizes));
4785 addFunctionCaseWithPrograms<TestConfig>(attachmentCountGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, TestConfig(renderPass, render, commandBuffer, imageMemory, targetSize, renderPos, renderSize, 1293809, allocationKind));
4789 group->addChild(attachmentCountGroup.release());
4793 template<typename T>
4794 T chooseRandom (de::Random& rng, const set<T>& values)
4796 size_t ndx = ((size_t)rng.getUint32()) % values.size();
4797 typename set<T>::const_iterator iter = values.begin();
4799 for (; ndx > 0; ndx--)
4805 void addAttachmentAllocationTests (tcu::TestCaseGroup* group, AllocationKind allocationKind)
4807 const deUint32 attachmentCounts[] = { 4, 8 };
4808 const VkAttachmentLoadOp loadOps[] =
4810 VK_ATTACHMENT_LOAD_OP_LOAD,
4811 VK_ATTACHMENT_LOAD_OP_CLEAR,
4812 VK_ATTACHMENT_LOAD_OP_DONT_CARE
4815 const VkAttachmentStoreOp storeOps[] =
4817 VK_ATTACHMENT_STORE_OP_STORE,
4818 VK_ATTACHMENT_STORE_OP_DONT_CARE
4821 const VkImageLayout initialAndFinalColorLayouts[] =
4823 VK_IMAGE_LAYOUT_GENERAL,
4824 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
4825 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
4826 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
4827 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
4830 const VkImageLayout initialAndFinalDepthStencilLayouts[] =
4832 VK_IMAGE_LAYOUT_GENERAL,
4833 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
4834 VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL,
4835 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
4836 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
4837 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
4840 const VkImageLayout subpassLayouts[] =
4842 VK_IMAGE_LAYOUT_GENERAL,
4843 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
4848 // Each pass uses one more attachmen than previous one
4849 ALLOCATIONTYPE_GROW,
4850 // Each pass uses one less attachment than previous one
4851 ALLOCATIONTYPE_SHRINK,
4852 // Each pass drops one attachment and picks up new one
4853 ALLOCATIONTYPE_ROLL,
4854 // Start by growing and end by shrinking
4855 ALLOCATIONTYPE_GROW_SHRINK,
4856 // Each subpass has single input and single output attachment
4857 ALLOCATIONTYPE_IO_CHAIN,
4858 // Each subpass has multiple inputs and multiple outputs attachment
4859 ALLOCATIONTYPE_IO_GENERIC
4862 const AllocationType allocationTypes[] =
4864 ALLOCATIONTYPE_GROW,
4865 ALLOCATIONTYPE_SHRINK,
4866 ALLOCATIONTYPE_ROLL,
4867 ALLOCATIONTYPE_GROW_SHRINK,
4868 ALLOCATIONTYPE_IO_CHAIN,
4869 ALLOCATIONTYPE_IO_GENERIC
4872 const char* const allocationTypeStr[] =
4878 "input_output_chain",
4882 const TestConfig::RenderTypes renderCommands[] =
4884 TestConfig::RENDERTYPES_NONE,
4885 TestConfig::RENDERTYPES_CLEAR,
4886 TestConfig::RENDERTYPES_DRAW,
4887 TestConfig::RENDERTYPES_CLEAR|TestConfig::RENDERTYPES_DRAW,
4890 const TestConfig::CommandBufferTypes commandBuffers[] =
4892 TestConfig::COMMANDBUFFERTYPES_INLINE,
4893 TestConfig::COMMANDBUFFERTYPES_SECONDARY,
4894 TestConfig::COMMANDBUFFERTYPES_INLINE|TestConfig::COMMANDBUFFERTYPES_SECONDARY
4897 const TestConfig::ImageMemory imageMemories[] =
4899 TestConfig::IMAGEMEMORY_STRICT,
4900 TestConfig::IMAGEMEMORY_LAZY,
4901 TestConfig::IMAGEMEMORY_STRICT|TestConfig::IMAGEMEMORY_LAZY
4904 const UVec2 targetSizes[] =
4910 const UVec2 renderPositions[] =
4916 const UVec2 renderSizes[] =
4922 tcu::TestContext& testCtx = group->getTestContext();
4923 de::Random rng (3700649827u);
4925 for (size_t allocationTypeNdx = 0; allocationTypeNdx < DE_LENGTH_OF_ARRAY(allocationTypes); allocationTypeNdx++)
4927 const AllocationType allocationType = allocationTypes[allocationTypeNdx];
4928 const size_t testCaseCount = 100;
4929 de::MovePtr<tcu::TestCaseGroup> allocationTypeGroup (new tcu::TestCaseGroup(testCtx, allocationTypeStr[allocationTypeNdx], allocationTypeStr[allocationTypeNdx]));
4931 for (size_t testCaseNdx = 0; testCaseNdx < testCaseCount; testCaseNdx++)
4933 if (allocationType == ALLOCATIONTYPE_IO_GENERIC)
4935 const deUint32 attachmentCount = 4u + rng.getUint32() % 31u;
4936 const deUint32 subpassCount = 4u + rng.getUint32() % 31u;
4937 vector<Attachment> attachments;
4939 set<deUint32> definedAttachments;
4941 vector<Subpass> subpasses;
4942 set<deUint32> colorAttachments;
4943 set<deUint32> depthStencilAttachments;
4945 for (deUint32 attachmentIndex = 0; attachmentIndex < attachmentCount; attachmentIndex++)
4947 const bool isDepthStencilAttachment = rng.getFloat() < 0.01f;
4948 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
4949 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
4950 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
4952 const VkImageLayout initialLayout = isDepthStencilAttachment
4953 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
4954 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
4955 const VkImageLayout finalizeLayout = isDepthStencilAttachment
4956 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
4957 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
4959 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
4960 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
4962 if (isDepthStencilAttachment)
4964 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreDepthStencilFormats), DE_ARRAY_END(s_coreDepthStencilFormats));
4966 if (loadOp == VK_ATTACHMENT_LOAD_OP_LOAD || loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR
4967 || stencilLoadOp == VK_ATTACHMENT_LOAD_OP_LOAD || stencilLoadOp == VK_ATTACHMENT_LOAD_OP_CLEAR)
4968 definedAttachments.insert(attachmentIndex);
4970 depthStencilAttachments.insert(attachmentIndex);
4972 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
4976 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreColorFormats), DE_ARRAY_END(s_coreColorFormats));
4978 if (loadOp == VK_ATTACHMENT_LOAD_OP_LOAD || loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR)
4979 definedAttachments.insert(attachmentIndex);
4981 colorAttachments.insert(attachmentIndex);
4983 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
4986 vector<Maybe<deUint32> > lastUseOfAttachment (attachments.size(), nothing<deUint32>());
4987 vector<SubpassDependency> deps;
4989 for (deUint32 subpassIndex = 0; subpassIndex < subpassCount; subpassIndex++)
4991 const deUint32 colorAttachmentCount = depthStencilAttachments.empty()
4992 ? 1 + rng.getUint32() % de::min(4u, (deUint32)colorAttachments.size())
4993 : rng.getUint32() % (de::min(4u, (deUint32)colorAttachments.size()) + 1u);
4994 const deUint32 inputAttachmentCount = rng.getUint32() % (deUint32)(de::min<size_t>(4, definedAttachments.size()) + 1);
4995 const bool useDepthStencilAttachment = !depthStencilAttachments.empty() && (colorAttachmentCount == 0 || rng.getBool());
4996 std::vector<deUint32> subpassColorAttachments (colorAttachmentCount);
4997 std::vector<deUint32> subpassInputAttachments (inputAttachmentCount);
4998 Maybe<deUint32> depthStencilAttachment (useDepthStencilAttachment
4999 ? just(chooseRandom(rng, depthStencilAttachments))
5000 : nothing<deUint32>());
5001 std::vector<deUint32> subpassPreserveAttachments;
5003 rng.choose(colorAttachments.begin(), colorAttachments.end(), subpassColorAttachments.begin(), colorAttachmentCount);
5004 rng.choose(definedAttachments.begin(), definedAttachments.end(), subpassInputAttachments.begin(), inputAttachmentCount);
5006 for (size_t colorAttachmentNdx = 0; colorAttachmentNdx < subpassColorAttachments.size(); colorAttachmentNdx++)
5007 definedAttachments.insert(subpassColorAttachments[colorAttachmentNdx]);
5009 if (depthStencilAttachment)
5010 definedAttachments.insert(*depthStencilAttachment);
5013 std::vector<AttachmentReference> inputAttachmentReferences;
5014 std::vector<AttachmentReference> colorAttachmentReferences;
5015 AttachmentReference depthStencilAttachmentReference (VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL);
5017 for (size_t colorAttachmentNdx = 0; colorAttachmentNdx < subpassColorAttachments.size(); colorAttachmentNdx++)
5019 const deUint32 colorAttachmentIndex = subpassColorAttachments[colorAttachmentNdx];
5020 // \todo [mika 2016-08-25] Check if attachment is not used as input attachment and use other image layouts
5021 const VkImageLayout subpassLayout = VK_IMAGE_LAYOUT_GENERAL;
5023 if (lastUseOfAttachment[colorAttachmentIndex])
5025 const bool byRegion = rng.getBool();
5027 deps.push_back(SubpassDependency(*lastUseOfAttachment[colorAttachmentIndex], subpassIndex,
5028 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5029 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5030 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5031 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5033 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5034 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5035 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5036 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5038 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
5039 VK_ACCESS_COLOR_ATTACHMENT_READ_BIT,
5041 byRegion ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u));
5044 lastUseOfAttachment[colorAttachmentIndex] = just(subpassIndex);
5046 colorAttachmentReferences.push_back(AttachmentReference((deUint32)subpassColorAttachments[colorAttachmentNdx], subpassLayout));
5049 for (size_t inputAttachmentNdx = 0; inputAttachmentNdx < subpassInputAttachments.size(); inputAttachmentNdx++)
5051 const deUint32 inputAttachmentIndex = subpassInputAttachments[inputAttachmentNdx];
5052 // \todo [mika 2016-08-25] Check if attachment is not used as color attachment and use other image layouts
5053 const VkImageLayout subpassLayout = VK_IMAGE_LAYOUT_GENERAL;
5055 if(lastUseOfAttachment[inputAttachmentIndex])
5057 if(*lastUseOfAttachment[inputAttachmentIndex] == subpassIndex)
5059 deps.push_back(SubpassDependency(subpassIndex, subpassIndex,
5060 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5061 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5062 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5063 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5065 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5066 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5067 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5068 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5070 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
5071 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5073 VK_DEPENDENCY_BY_REGION_BIT));
5077 const bool byRegion = rng.getBool();
5079 deps.push_back(SubpassDependency(*lastUseOfAttachment[inputAttachmentIndex], subpassIndex,
5080 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5081 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5082 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5083 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5085 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5086 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5087 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5088 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5090 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
5091 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5093 byRegion ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u));
5096 lastUseOfAttachment[inputAttachmentIndex] = just(subpassIndex);
5098 inputAttachmentReferences.push_back(AttachmentReference((deUint32)subpassInputAttachments[inputAttachmentNdx], subpassLayout));
5102 if (depthStencilAttachment)
5104 // \todo [mika 2016-08-25] Check if attachment is not used as input attachment and use other image layouts
5105 if (lastUseOfAttachment[*depthStencilAttachment])
5107 if(*lastUseOfAttachment[*depthStencilAttachment] == subpassIndex)
5109 deps.push_back(SubpassDependency(subpassIndex, subpassIndex,
5110 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5111 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5112 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5113 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5115 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5116 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5117 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5118 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5120 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
5121 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5123 VK_DEPENDENCY_BY_REGION_BIT));
5127 const bool byRegion = rng.getBool();
5129 deps.push_back(SubpassDependency(*lastUseOfAttachment[*depthStencilAttachment], subpassIndex,
5130 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5131 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5132 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5133 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5135 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5136 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5137 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5138 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5140 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
5141 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5143 byRegion ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u));
5147 lastUseOfAttachment[*depthStencilAttachment] = just(subpassIndex);
5148 depthStencilAttachmentReference = AttachmentReference(*depthStencilAttachment, VK_IMAGE_LAYOUT_GENERAL);
5151 depthStencilAttachmentReference = AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL);
5153 vector<deUint32> preserveAttachments;
5154 for (deUint32 attachmentIndex = 0; attachmentIndex < (deUint32)attachments.size(); attachmentIndex++)
5156 if (lastUseOfAttachment[attachmentIndex] && (*lastUseOfAttachment[attachmentIndex]) != subpassIndex)
5157 preserveAttachments.push_back(attachmentIndex);
5160 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
5161 inputAttachmentReferences,
5162 colorAttachmentReferences,
5163 vector<AttachmentReference>(),
5164 depthStencilAttachmentReference,
5165 preserveAttachments));
5169 const TestConfig::RenderTypes render = rng.choose<TestConfig::RenderTypes>(DE_ARRAY_BEGIN(renderCommands), DE_ARRAY_END(renderCommands));
5170 const TestConfig::CommandBufferTypes commandBuffer = rng.choose<TestConfig::CommandBufferTypes>(DE_ARRAY_BEGIN(commandBuffers), DE_ARRAY_END(commandBuffers));
5171 const TestConfig::ImageMemory imageMemory = rng.choose<TestConfig::ImageMemory>(DE_ARRAY_BEGIN(imageMemories), DE_ARRAY_END(imageMemories));
5173 const string testCaseName = de::toString(testCaseNdx);
5174 const UVec2 targetSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(targetSizes), DE_ARRAY_END(targetSizes));
5175 const UVec2 renderPos = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderPositions), DE_ARRAY_END(renderPositions));
5176 const UVec2 renderSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderSizes), DE_ARRAY_END(renderSizes));
5178 const RenderPass renderPass (attachments, subpasses, deps);
5180 addFunctionCaseWithPrograms<TestConfig>(allocationTypeGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, TestConfig(renderPass, render, commandBuffer, imageMemory, targetSize, renderPos, renderSize, 80329, allocationKind));
5185 const deUint32 attachmentCount = rng.choose<deUint32>(DE_ARRAY_BEGIN(attachmentCounts), DE_ARRAY_END(attachmentCounts));
5186 vector<Attachment> attachments;
5187 vector<Subpass> subpasses;
5189 for (size_t attachmentNdx = 0; attachmentNdx < attachmentCount; attachmentNdx++)
5191 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
5192 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreColorFormats), DE_ARRAY_END(s_coreColorFormats));
5193 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5194 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5196 const VkImageLayout initialLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
5197 const VkImageLayout finalizeLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
5199 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5200 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5202 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5205 if (allocationType == ALLOCATIONTYPE_GROW)
5207 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
5209 vector<AttachmentReference> colorAttachmentReferences;
5211 for (size_t attachmentNdx = 0; attachmentNdx < subpassNdx + 1; attachmentNdx++)
5213 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayouts), DE_ARRAY_END(subpassLayouts));
5215 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
5218 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
5219 vector<AttachmentReference>(),
5220 colorAttachmentReferences,
5221 vector<AttachmentReference>(),
5222 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5223 vector<deUint32>()));
5226 else if (allocationType == ALLOCATIONTYPE_SHRINK)
5228 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
5230 vector<AttachmentReference> colorAttachmentReferences;
5232 for (size_t attachmentNdx = 0; attachmentNdx < (attachmentCount - subpassNdx); attachmentNdx++)
5234 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayouts), DE_ARRAY_END(subpassLayouts));
5236 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
5239 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
5240 vector<AttachmentReference>(),
5241 colorAttachmentReferences,
5242 vector<AttachmentReference>(),
5243 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5244 vector<deUint32>()));
5247 else if (allocationType == ALLOCATIONTYPE_ROLL)
5249 for (size_t subpassNdx = 0; subpassNdx < attachmentCount / 2; subpassNdx++)
5251 vector<AttachmentReference> colorAttachmentReferences;
5253 for (size_t attachmentNdx = 0; attachmentNdx < attachmentCount / 2; attachmentNdx++)
5255 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayouts), DE_ARRAY_END(subpassLayouts));
5257 colorAttachmentReferences.push_back(AttachmentReference((deUint32)(subpassNdx + attachmentNdx), subpassLayout));
5260 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
5261 vector<AttachmentReference>(),
5262 colorAttachmentReferences,
5263 vector<AttachmentReference>(),
5264 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5265 vector<deUint32>()));
5268 else if (allocationType == ALLOCATIONTYPE_GROW_SHRINK)
5270 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
5272 vector<AttachmentReference> colorAttachmentReferences;
5274 for (size_t attachmentNdx = 0; attachmentNdx < subpassNdx + 1; attachmentNdx++)
5276 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayouts), DE_ARRAY_END(subpassLayouts));
5278 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
5281 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
5282 vector<AttachmentReference>(),
5283 colorAttachmentReferences,
5284 vector<AttachmentReference>(),
5285 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5286 vector<deUint32>()));
5289 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
5291 vector<AttachmentReference> colorAttachmentReferences;
5293 for (size_t attachmentNdx = 0; attachmentNdx < (attachmentCount - subpassNdx); attachmentNdx++)
5295 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayouts), DE_ARRAY_END(subpassLayouts));
5297 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
5300 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
5301 vector<AttachmentReference>(),
5302 colorAttachmentReferences,
5303 vector<AttachmentReference>(),
5304 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5305 vector<deUint32>()));
5308 else if (allocationType == ALLOCATIONTYPE_IO_CHAIN)
5310 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
5311 vector<AttachmentReference>(),
5312 vector<AttachmentReference>(1, AttachmentReference(0, rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayouts), DE_ARRAY_END(subpassLayouts)))),
5313 vector<AttachmentReference>(),
5314 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5315 vector<deUint32>()));
5317 for (size_t subpassNdx = 1; subpassNdx < attachmentCount; subpassNdx++)
5319 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
5320 vector<AttachmentReference>(1, AttachmentReference((deUint32)(subpassNdx - 1), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL)),
5321 vector<AttachmentReference>(1, AttachmentReference((deUint32)(subpassNdx), rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayouts), DE_ARRAY_END(subpassLayouts)))),
5322 vector<AttachmentReference>(),
5323 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5324 vector<deUint32>()));
5328 DE_FATAL("Unknown allocation type");
5331 const TestConfig::RenderTypes render = rng.choose<TestConfig::RenderTypes>(DE_ARRAY_BEGIN(renderCommands), DE_ARRAY_END(renderCommands));
5332 const TestConfig::CommandBufferTypes commandBuffer = rng.choose<TestConfig::CommandBufferTypes>(DE_ARRAY_BEGIN(commandBuffers), DE_ARRAY_END(commandBuffers));
5333 const TestConfig::ImageMemory imageMemory = rng.choose<TestConfig::ImageMemory>(DE_ARRAY_BEGIN(imageMemories), DE_ARRAY_END(imageMemories));
5335 const string testCaseName = de::toString(testCaseNdx);
5336 const UVec2 targetSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(targetSizes), DE_ARRAY_END(targetSizes));
5337 const UVec2 renderPos = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderPositions), DE_ARRAY_END(renderPositions));
5338 const UVec2 renderSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderSizes), DE_ARRAY_END(renderSizes));
5340 vector<SubpassDependency> deps;
5342 for (size_t subpassNdx = 0; subpassNdx < subpasses.size() - 1; subpassNdx++)
5344 const bool byRegion = rng.getBool();
5345 deps.push_back(SubpassDependency((deUint32)subpassNdx, (deUint32)subpassNdx + 1,
5346 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5347 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5348 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5349 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5351 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5352 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5353 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5354 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5356 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
5357 VK_ACCESS_COLOR_ATTACHMENT_READ_BIT,
5359 byRegion ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u));
5362 const RenderPass renderPass (attachments, subpasses, deps);
5364 addFunctionCaseWithPrograms<TestConfig>(allocationTypeGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, TestConfig(renderPass, render, commandBuffer, imageMemory, targetSize, renderPos, renderSize, 80329, allocationKind));
5368 group->addChild(allocationTypeGroup.release());
5372 void addSimpleTests (tcu::TestCaseGroup* group, AllocationKind allocationKind)
5374 const UVec2 targetSize (64, 64);
5375 const UVec2 renderPos (0, 0);
5376 const UVec2 renderSize (64, 64);
5380 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_R8G8B8A8_UNORM,
5381 VK_SAMPLE_COUNT_1_BIT,
5382 VK_ATTACHMENT_LOAD_OP_CLEAR,
5383 VK_ATTACHMENT_STORE_OP_STORE,
5384 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5385 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5386 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5387 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
5388 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5390 vector<AttachmentReference>(),
5391 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
5392 vector<AttachmentReference>(),
5393 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5394 vector<deUint32>())),
5395 vector<SubpassDependency>());
5397 addFunctionCaseWithPrograms<TestConfig>(group, "color", "Single color attachment case.", createTestShaders, renderPassTest, TestConfig(renderPass, TestConfig::RENDERTYPES_DRAW, TestConfig::COMMANDBUFFERTYPES_INLINE, TestConfig::IMAGEMEMORY_STRICT, targetSize, renderPos, renderSize, 90239, allocationKind));
5402 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_X8_D24_UNORM_PACK32,
5403 VK_SAMPLE_COUNT_1_BIT,
5404 VK_ATTACHMENT_LOAD_OP_CLEAR,
5405 VK_ATTACHMENT_STORE_OP_STORE,
5406 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5407 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5408 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5409 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
5410 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5412 vector<AttachmentReference>(),
5413 vector<AttachmentReference>(),
5414 vector<AttachmentReference>(),
5415 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
5416 vector<deUint32>())),
5417 vector<SubpassDependency>());
5419 addFunctionCaseWithPrograms<TestConfig>(group, "depth", "Single depth attachment case.", createTestShaders, renderPassTest, TestConfig(renderPass, TestConfig::RENDERTYPES_DRAW, TestConfig::COMMANDBUFFERTYPES_INLINE, TestConfig::IMAGEMEMORY_STRICT, targetSize, renderPos, renderSize, 90239, allocationKind));
5424 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_S8_UINT,
5425 VK_SAMPLE_COUNT_1_BIT,
5426 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5427 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5428 VK_ATTACHMENT_LOAD_OP_CLEAR,
5429 VK_ATTACHMENT_STORE_OP_STORE,
5430 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5431 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
5432 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5434 vector<AttachmentReference>(),
5435 vector<AttachmentReference>(),
5436 vector<AttachmentReference>(),
5437 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
5438 vector<deUint32>())),
5439 vector<SubpassDependency>());
5441 addFunctionCaseWithPrograms<TestConfig>(group, "stencil", "Single stencil attachment case.", createTestShaders, renderPassTest, TestConfig(renderPass, TestConfig::RENDERTYPES_DRAW, TestConfig::COMMANDBUFFERTYPES_INLINE, TestConfig::IMAGEMEMORY_STRICT, targetSize, renderPos, renderSize, 90239, allocationKind));
5446 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_D24_UNORM_S8_UINT,
5447 VK_SAMPLE_COUNT_1_BIT,
5448 VK_ATTACHMENT_LOAD_OP_CLEAR,
5449 VK_ATTACHMENT_STORE_OP_STORE,
5450 VK_ATTACHMENT_LOAD_OP_CLEAR,
5451 VK_ATTACHMENT_STORE_OP_STORE,
5452 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5453 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
5454 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5456 vector<AttachmentReference>(),
5457 vector<AttachmentReference>(),
5458 vector<AttachmentReference>(),
5459 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
5460 vector<deUint32>())),
5461 vector<SubpassDependency>());
5463 addFunctionCaseWithPrograms<TestConfig>(group, "depth_stencil", "Single depth stencil attachment case.", createTestShaders, renderPassTest, TestConfig(renderPass, TestConfig::RENDERTYPES_DRAW, TestConfig::COMMANDBUFFERTYPES_INLINE, TestConfig::IMAGEMEMORY_STRICT, targetSize, renderPos, renderSize, 90239, allocationKind));
5468 const Attachment attachments[] =
5470 Attachment(VK_FORMAT_R8G8B8A8_UNORM,
5471 VK_SAMPLE_COUNT_1_BIT,
5472 VK_ATTACHMENT_LOAD_OP_CLEAR,
5473 VK_ATTACHMENT_STORE_OP_STORE,
5474 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5475 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5476 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5477 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL),
5478 Attachment(VK_FORMAT_X8_D24_UNORM_PACK32,
5479 VK_SAMPLE_COUNT_1_BIT,
5480 VK_ATTACHMENT_LOAD_OP_CLEAR,
5481 VK_ATTACHMENT_STORE_OP_STORE,
5482 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5483 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5484 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5485 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
5488 const RenderPass renderPass (vector<Attachment>(DE_ARRAY_BEGIN(attachments), DE_ARRAY_END(attachments)),
5489 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5491 vector<AttachmentReference>(),
5492 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
5493 vector<AttachmentReference>(),
5494 AttachmentReference(1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
5495 vector<deUint32>())),
5496 vector<SubpassDependency>());
5498 addFunctionCaseWithPrograms<TestConfig>(group, "color_depth", "Color and depth attachment case.", createTestShaders, renderPassTest, TestConfig(renderPass, TestConfig::RENDERTYPES_DRAW, TestConfig::COMMANDBUFFERTYPES_INLINE, TestConfig::IMAGEMEMORY_STRICT, targetSize, renderPos, renderSize, 90239, allocationKind));
5503 const Attachment attachments[] =
5505 Attachment(VK_FORMAT_R8G8B8A8_UNORM,
5506 VK_SAMPLE_COUNT_1_BIT,
5507 VK_ATTACHMENT_LOAD_OP_CLEAR,
5508 VK_ATTACHMENT_STORE_OP_STORE,
5509 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5510 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5511 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5512 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL),
5513 Attachment(VK_FORMAT_S8_UINT,
5514 VK_SAMPLE_COUNT_1_BIT,
5515 VK_ATTACHMENT_LOAD_OP_CLEAR,
5516 VK_ATTACHMENT_STORE_OP_STORE,
5517 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5518 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5519 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5520 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
5523 const RenderPass renderPass (vector<Attachment>(DE_ARRAY_BEGIN(attachments), DE_ARRAY_END(attachments)),
5524 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5526 vector<AttachmentReference>(),
5527 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
5528 vector<AttachmentReference>(),
5529 AttachmentReference(1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
5530 vector<deUint32>())),
5531 vector<SubpassDependency>());
5534 addFunctionCaseWithPrograms<TestConfig>(group, "color_stencil", "Color and stencil attachment case.", createTestShaders, renderPassTest, TestConfig(renderPass, TestConfig::RENDERTYPES_DRAW, TestConfig::COMMANDBUFFERTYPES_INLINE, TestConfig::IMAGEMEMORY_STRICT, targetSize, renderPos, renderSize, 90239, allocationKind));
5537 // color_depth_stencil
5539 const Attachment attachments[] =
5541 Attachment(VK_FORMAT_R8G8B8A8_UNORM,
5542 VK_SAMPLE_COUNT_1_BIT,
5543 VK_ATTACHMENT_LOAD_OP_CLEAR,
5544 VK_ATTACHMENT_STORE_OP_STORE,
5545 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5546 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5547 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5548 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL),
5549 Attachment(VK_FORMAT_D24_UNORM_S8_UINT,
5550 VK_SAMPLE_COUNT_1_BIT,
5551 VK_ATTACHMENT_LOAD_OP_CLEAR,
5552 VK_ATTACHMENT_STORE_OP_STORE,
5553 VK_ATTACHMENT_LOAD_OP_CLEAR,
5554 VK_ATTACHMENT_STORE_OP_STORE,
5555 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5556 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
5559 const RenderPass renderPass (vector<Attachment>(DE_ARRAY_BEGIN(attachments), DE_ARRAY_END(attachments)),
5560 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5562 vector<AttachmentReference>(),
5563 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
5564 vector<AttachmentReference>(),
5565 AttachmentReference(1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
5566 vector<deUint32>())),
5567 vector<SubpassDependency>());
5569 addFunctionCaseWithPrograms<TestConfig>(group, "color_depth_stencil", "Color, depth and stencil attachment case.", createTestShaders, renderPassTest, TestConfig(renderPass, TestConfig::RENDERTYPES_DRAW, TestConfig::COMMANDBUFFERTYPES_INLINE, TestConfig::IMAGEMEMORY_STRICT, targetSize, renderPos, renderSize, 90239, allocationKind));
5573 std::string formatToName (VkFormat format)
5575 const std::string formatStr = de::toString(format);
5576 const std::string prefix = "VK_FORMAT_";
5578 DE_ASSERT(formatStr.substr(0, prefix.length()) == prefix);
5580 return de::toLower(formatStr.substr(prefix.length()));
5583 void addFormatTests (tcu::TestCaseGroup* group, AllocationKind allocationKind)
5585 tcu::TestContext& testCtx = group->getTestContext();
5587 const UVec2 targetSize (64, 64);
5588 const UVec2 renderPos (0, 0);
5589 const UVec2 renderSize (64, 64);
5593 const char* const str;
5594 const VkAttachmentStoreOp op;
5597 { "store", VK_ATTACHMENT_STORE_OP_STORE },
5598 { "dont_care", VK_ATTACHMENT_STORE_OP_DONT_CARE }
5603 const char* const str;
5604 const VkAttachmentLoadOp op;
5607 { "clear", VK_ATTACHMENT_LOAD_OP_CLEAR },
5608 { "load", VK_ATTACHMENT_LOAD_OP_LOAD },
5609 { "dont_care", VK_ATTACHMENT_LOAD_OP_DONT_CARE }
5614 const char* const str;
5615 const TestConfig::RenderTypes types;
5618 { "clear", TestConfig::RENDERTYPES_CLEAR },
5619 { "draw", TestConfig::RENDERTYPES_DRAW },
5620 { "clear_draw", TestConfig::RENDERTYPES_CLEAR|TestConfig::RENDERTYPES_DRAW }
5624 for (size_t formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_coreColorFormats); formatNdx++)
5626 const VkFormat format = s_coreColorFormats[formatNdx];
5627 de::MovePtr<tcu::TestCaseGroup> formatGroup (new tcu::TestCaseGroup(testCtx, formatToName(format).c_str(), de::toString(format).c_str()));
5629 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
5631 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
5632 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
5634 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
5636 const RenderPass renderPass (vector<Attachment>(1, Attachment(format,
5637 VK_SAMPLE_COUNT_1_BIT,
5639 VK_ATTACHMENT_STORE_OP_STORE,
5640 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5641 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5642 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5643 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
5644 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5646 vector<AttachmentReference>(),
5647 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
5648 vector<AttachmentReference>(),
5649 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5650 vector<deUint32>())),
5651 vector<SubpassDependency>());
5653 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), renderTypes[renderTypeNdx].str, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, TestConfig(renderPass, renderTypes[renderTypeNdx].types, TestConfig::COMMANDBUFFERTYPES_INLINE, TestConfig::IMAGEMEMORY_STRICT, targetSize, renderPos, renderSize, 90239, allocationKind));
5656 formatGroup->addChild(loadOpGroup.release());
5660 de::MovePtr<tcu::TestCaseGroup> inputGroup (new tcu::TestCaseGroup(testCtx, "input", "Test attachment format as input"));
5662 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
5664 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
5665 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
5667 for (size_t storeOpNdx = 0; storeOpNdx < DE_LENGTH_OF_ARRAY(storeOps); storeOpNdx++)
5669 const VkAttachmentStoreOp storeOp = storeOps[storeOpNdx].op;
5670 de::MovePtr<tcu::TestCaseGroup> storeOpGroup (new tcu::TestCaseGroup(testCtx, storeOps[storeOpNdx].str, storeOps[storeOpNdx].str));
5672 for (size_t useInputAspectNdx = 0; useInputAspectNdx < 2; useInputAspectNdx++)
5674 const bool useInputAspect = useInputAspectNdx != 0;
5676 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
5679 vector<Attachment> attachments;
5680 vector<Subpass> subpasses;
5681 vector<SubpassDependency> deps;
5682 vector<VkInputAttachmentAspectReferenceKHR> inputAspects;
5684 attachments.push_back(Attachment(format,
5685 VK_SAMPLE_COUNT_1_BIT,
5688 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5689 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5690 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5691 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
5693 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
5694 VK_SAMPLE_COUNT_1_BIT,
5695 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5696 VK_ATTACHMENT_STORE_OP_STORE,
5697 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5698 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5699 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5700 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
5702 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5704 vector<AttachmentReference>(),
5705 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
5706 vector<AttachmentReference>(),
5707 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5708 vector<deUint32>()));
5709 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5711 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL)),
5712 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
5713 vector<AttachmentReference>(),
5714 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5715 vector<deUint32>()));
5717 deps.push_back(SubpassDependency(0, 1,
5719 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
5720 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
5722 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
5723 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5724 vk::VK_DEPENDENCY_BY_REGION_BIT));
5728 const VkInputAttachmentAspectReferenceKHR inputAspect =
5732 VK_IMAGE_ASPECT_COLOR_BIT
5735 inputAspects.push_back(inputAspect);
5739 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
5741 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : ""), renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, TestConfig(renderPass, renderTypes[renderTypeNdx].types, TestConfig::COMMANDBUFFERTYPES_INLINE, TestConfig::IMAGEMEMORY_STRICT, targetSize, renderPos, renderSize, 89246, allocationKind));
5745 vector<Attachment> attachments;
5746 vector<Subpass> subpasses;
5747 vector<SubpassDependency> deps;
5748 vector<VkInputAttachmentAspectReferenceKHR> inputAspects;
5750 attachments.push_back(Attachment(format,
5751 VK_SAMPLE_COUNT_1_BIT,
5754 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5755 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5756 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5757 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
5759 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5761 vector<AttachmentReference>(),
5762 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
5763 vector<AttachmentReference>(),
5764 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5765 vector<deUint32>()));
5766 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5768 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL)),
5769 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL)),
5770 vector<AttachmentReference>(),
5771 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5772 vector<deUint32>()));
5774 deps.push_back(SubpassDependency(0, 1,
5775 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
5776 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
5778 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
5779 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5780 vk::VK_DEPENDENCY_BY_REGION_BIT));
5784 const VkInputAttachmentAspectReferenceKHR inputAspect =
5788 VK_IMAGE_ASPECT_COLOR_BIT
5791 inputAspects.push_back(inputAspect);
5795 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
5797 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : ""), string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, TestConfig(renderPass, renderTypes[renderTypeNdx].types, TestConfig::COMMANDBUFFERTYPES_INLINE, TestConfig::IMAGEMEMORY_STRICT, targetSize, renderPos, renderSize, 89246, allocationKind));
5803 loadOpGroup->addChild(storeOpGroup.release());
5806 inputGroup->addChild(loadOpGroup.release());
5809 formatGroup->addChild(inputGroup.release());
5812 group->addChild(formatGroup.release());
5815 // Depth stencil formats
5816 for (size_t formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_coreDepthStencilFormats); formatNdx++)
5818 const VkFormat vkFormat = s_coreDepthStencilFormats[formatNdx];
5819 const tcu::TextureFormat format = mapVkFormat(vkFormat);
5820 const bool isStencilAttachment = hasStencilComponent(format.order);
5821 const bool isDepthAttachment = hasDepthComponent(format.order);
5822 de::MovePtr<tcu::TestCaseGroup> formatGroup (new tcu::TestCaseGroup(testCtx, formatToName(vkFormat).c_str(), de::toString(vkFormat).c_str()));
5824 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
5826 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
5827 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
5829 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
5832 const RenderPass renderPass (vector<Attachment>(1, Attachment(vkFormat,
5833 VK_SAMPLE_COUNT_1_BIT,
5834 isDepthAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5835 isDepthAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
5836 isStencilAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5837 isStencilAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
5838 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5839 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
5840 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5842 vector<AttachmentReference>(),
5843 vector<AttachmentReference>(),
5844 vector<AttachmentReference>(),
5845 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
5846 vector<deUint32>())),
5847 vector<SubpassDependency>());
5849 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), renderTypes[renderTypeNdx].str, renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, TestConfig(renderPass, renderTypes[renderTypeNdx].types, TestConfig::COMMANDBUFFERTYPES_INLINE, TestConfig::IMAGEMEMORY_STRICT, targetSize, renderPos, renderSize, 90239, allocationKind));
5852 if (isStencilAttachment && isDepthAttachment)
5855 const RenderPass renderPass (vector<Attachment>(1, Attachment(vkFormat,
5856 VK_SAMPLE_COUNT_1_BIT,
5857 isDepthAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5858 isDepthAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
5859 isStencilAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5860 isStencilAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
5861 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5862 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
5863 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5865 vector<AttachmentReference>(),
5866 vector<AttachmentReference>(),
5867 vector<AttachmentReference>(),
5868 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR),
5869 vector<deUint32>())),
5870 vector<SubpassDependency>());
5872 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), string(renderTypes[renderTypeNdx].str) + "_depth_read_only", renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, TestConfig(renderPass, renderTypes[renderTypeNdx].types, TestConfig::COMMANDBUFFERTYPES_INLINE, TestConfig::IMAGEMEMORY_STRICT, targetSize, renderPos, renderSize, 90239, allocationKind));
5876 const RenderPass renderPass (vector<Attachment>(1, Attachment(vkFormat,
5877 VK_SAMPLE_COUNT_1_BIT,
5878 isDepthAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5879 isDepthAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
5880 isStencilAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5881 isStencilAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
5882 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5883 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
5884 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5886 vector<AttachmentReference>(),
5887 vector<AttachmentReference>(),
5888 vector<AttachmentReference>(),
5889 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR),
5890 vector<deUint32>())),
5891 vector<SubpassDependency>());
5893 addFunctionCaseWithPrograms<TestConfig>(loadOpGroup.get(), string(renderTypes[renderTypeNdx].str) + "_stencil_read_only", renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, TestConfig(renderPass, renderTypes[renderTypeNdx].types, TestConfig::COMMANDBUFFERTYPES_INLINE, TestConfig::IMAGEMEMORY_STRICT, targetSize, renderPos, renderSize, 90239, allocationKind));
5898 formatGroup->addChild(loadOpGroup.release());
5902 de::MovePtr<tcu::TestCaseGroup> inputGroup (new tcu::TestCaseGroup(testCtx, "input", "Test attachment format as input"));
5904 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
5906 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
5907 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
5909 for (size_t storeOpNdx = 0; storeOpNdx < DE_LENGTH_OF_ARRAY(storeOps); storeOpNdx++)
5911 const VkAttachmentStoreOp storeOp = storeOps[storeOpNdx].op;
5912 de::MovePtr<tcu::TestCaseGroup> storeOpGroup (new tcu::TestCaseGroup(testCtx, storeOps[storeOpNdx].str, storeOps[storeOpNdx].str));
5914 for (size_t useInputAspectNdx = 0; useInputAspectNdx < 2; useInputAspectNdx++)
5916 const bool useInputAspect = useInputAspectNdx != 0;
5918 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
5921 vector<Attachment> attachments;
5922 vector<Subpass> subpasses;
5923 vector<SubpassDependency> deps;
5924 vector<VkInputAttachmentAspectReferenceKHR> inputAspects;
5926 attachments.push_back(Attachment(vkFormat,
5927 VK_SAMPLE_COUNT_1_BIT,
5932 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5933 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
5935 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
5936 VK_SAMPLE_COUNT_1_BIT,
5937 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5938 VK_ATTACHMENT_STORE_OP_STORE,
5939 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5940 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5941 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5942 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
5944 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5946 vector<AttachmentReference>(),
5947 vector<AttachmentReference>(),
5948 vector<AttachmentReference>(),
5949 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
5950 vector<deUint32>()));
5951 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5953 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL)),
5954 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
5955 vector<AttachmentReference>(),
5956 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5957 vector<deUint32>()));
5959 deps.push_back(SubpassDependency(0, 1,
5960 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
5961 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
5963 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
5964 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5967 deps.push_back(SubpassDependency(1, 1,
5968 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
5969 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
5971 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
5972 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5973 vk::VK_DEPENDENCY_BY_REGION_BIT));
5977 const VkInputAttachmentAspectReferenceKHR inputAspect =
5981 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
5982 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
5985 inputAspects.push_back(inputAspect);
5989 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
5991 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : ""), renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, TestConfig(renderPass, renderTypes[renderTypeNdx].types, TestConfig::COMMANDBUFFERTYPES_INLINE, TestConfig::IMAGEMEMORY_STRICT, targetSize, renderPos, renderSize, 89246, allocationKind));
5995 vector<Attachment> attachments;
5996 vector<Subpass> subpasses;
5997 vector<SubpassDependency> deps;
5998 vector<VkInputAttachmentAspectReferenceKHR> inputAspects;
6000 attachments.push_back(Attachment(vkFormat,
6001 VK_SAMPLE_COUNT_1_BIT,
6004 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6005 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6006 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6007 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
6009 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6011 vector<AttachmentReference>(),
6012 vector<AttachmentReference>(),
6013 vector<AttachmentReference>(),
6014 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6015 vector<deUint32>()));
6016 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6018 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL)),
6019 vector<AttachmentReference>(),
6020 vector<AttachmentReference>(),
6021 AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL),
6022 vector<deUint32>()));
6024 deps.push_back(SubpassDependency(0, 1,
6025 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6026 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6028 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
6029 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6030 vk::VK_DEPENDENCY_BY_REGION_BIT));
6035 const VkInputAttachmentAspectReferenceKHR inputAspect =
6040 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
6041 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
6044 inputAspects.push_back(inputAspect);
6048 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
6050 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : ""), string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, TestConfig(renderPass, renderTypes[renderTypeNdx].types, TestConfig::COMMANDBUFFERTYPES_INLINE, TestConfig::IMAGEMEMORY_STRICT, targetSize, renderPos, renderSize, 89246, allocationKind));
6054 if (isStencilAttachment && isDepthAttachment)
6058 vector<Attachment> attachments;
6059 vector<Subpass> subpasses;
6060 vector<SubpassDependency> deps;
6061 vector<VkInputAttachmentAspectReferenceKHR> inputAspects;
6063 attachments.push_back(Attachment(vkFormat,
6064 VK_SAMPLE_COUNT_1_BIT,
6069 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6070 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
6072 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
6073 VK_SAMPLE_COUNT_1_BIT,
6074 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6075 VK_ATTACHMENT_STORE_OP_STORE,
6076 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6077 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6078 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6079 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
6081 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6083 vector<AttachmentReference>(),
6084 vector<AttachmentReference>(),
6085 vector<AttachmentReference>(),
6086 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6087 vector<deUint32>()));
6088 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6090 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)),
6091 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6092 vector<AttachmentReference>(),
6093 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6094 vector<deUint32>()));
6096 deps.push_back(SubpassDependency(0, 1,
6097 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
6098 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6100 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6101 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6106 const VkInputAttachmentAspectReferenceKHR inputAspect =
6111 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
6112 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
6115 inputAspects.push_back(inputAspect);
6119 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
6121 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : "") + "_depth_read_only", renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, TestConfig(renderPass, renderTypes[renderTypeNdx].types, TestConfig::COMMANDBUFFERTYPES_INLINE, TestConfig::IMAGEMEMORY_STRICT, targetSize, renderPos, renderSize, 89246, allocationKind));
6125 vector<Attachment> attachments;
6126 vector<Subpass> subpasses;
6127 vector<SubpassDependency> deps;
6128 vector<VkInputAttachmentAspectReferenceKHR> inputAspects;
6130 attachments.push_back(Attachment(vkFormat,
6131 VK_SAMPLE_COUNT_1_BIT,
6136 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6137 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
6139 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6141 vector<AttachmentReference>(),
6142 vector<AttachmentReference>(),
6143 vector<AttachmentReference>(),
6144 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6145 vector<deUint32>()));
6146 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6148 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)),
6149 vector<AttachmentReference>(),
6150 vector<AttachmentReference>(),
6151 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR),
6152 vector<deUint32>()));
6154 deps.push_back(SubpassDependency(0, 1,
6155 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6156 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6158 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
6159 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6160 vk::VK_DEPENDENCY_BY_REGION_BIT));
6162 deps.push_back(SubpassDependency(1, 1,
6163 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
6164 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6166 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6167 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6168 vk::VK_DEPENDENCY_BY_REGION_BIT));
6173 const VkInputAttachmentAspectReferenceKHR inputAspect =
6178 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
6179 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
6182 inputAspects.push_back(inputAspect);
6186 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
6188 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : "") + "_depth_read_only", string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, TestConfig(renderPass, renderTypes[renderTypeNdx].types, TestConfig::COMMANDBUFFERTYPES_INLINE, TestConfig::IMAGEMEMORY_STRICT, targetSize, renderPos, renderSize, 89246, allocationKind));
6191 // Stencil read only
6193 vector<Attachment> attachments;
6194 vector<Subpass> subpasses;
6195 vector<SubpassDependency> deps;
6196 vector<VkInputAttachmentAspectReferenceKHR> inputAspects;
6198 attachments.push_back(Attachment(vkFormat,
6199 VK_SAMPLE_COUNT_1_BIT,
6204 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6205 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
6207 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
6208 VK_SAMPLE_COUNT_1_BIT,
6209 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6210 VK_ATTACHMENT_STORE_OP_STORE,
6211 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6212 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6213 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6214 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
6216 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6218 vector<AttachmentReference>(),
6219 vector<AttachmentReference>(),
6220 vector<AttachmentReference>(),
6221 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6222 vector<deUint32>()));
6223 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6225 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR)),
6226 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6227 vector<AttachmentReference>(),
6228 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6229 vector<deUint32>()));
6231 deps.push_back(SubpassDependency(0, 1,
6232 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6233 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6235 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
6236 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6241 const VkInputAttachmentAspectReferenceKHR inputAspect =
6246 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
6247 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
6250 inputAspects.push_back(inputAspect);
6254 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
6256 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), renderTypes[renderTypeNdx].str + string(useInputAspect ? "_use_input_aspect" : "") + "_stencil_read_only", renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, TestConfig(renderPass, renderTypes[renderTypeNdx].types, TestConfig::COMMANDBUFFERTYPES_INLINE, TestConfig::IMAGEMEMORY_STRICT, targetSize, renderPos, renderSize, 89246, allocationKind));
6260 vector<Attachment> attachments;
6261 vector<Subpass> subpasses;
6262 vector<SubpassDependency> deps;
6263 vector<VkInputAttachmentAspectReferenceKHR> inputAspects;
6265 attachments.push_back(Attachment(vkFormat,
6266 VK_SAMPLE_COUNT_1_BIT,
6271 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6272 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
6274 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6276 vector<AttachmentReference>(),
6277 vector<AttachmentReference>(),
6278 vector<AttachmentReference>(),
6279 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6280 vector<deUint32>()));
6281 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6283 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR)),
6284 vector<AttachmentReference>(),
6285 vector<AttachmentReference>(),
6286 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR),
6287 vector<deUint32>()));
6289 deps.push_back(SubpassDependency(0, 1,
6290 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6291 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6293 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
6294 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6295 vk::VK_DEPENDENCY_BY_REGION_BIT));
6297 deps.push_back(SubpassDependency(1, 1,
6298 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
6299 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6301 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6302 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6303 vk::VK_DEPENDENCY_BY_REGION_BIT));
6308 const VkInputAttachmentAspectReferenceKHR inputAspect =
6313 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
6314 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
6317 inputAspects.push_back(inputAspect);
6321 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
6323 addFunctionCaseWithPrograms<TestConfig>(storeOpGroup.get(), string("self_dep_") + renderTypes[renderTypeNdx].str + (useInputAspect ? "_use_input_aspect" : "") + "_stencil_read_only", string("self_dep_") + renderTypes[renderTypeNdx].str, createTestShaders, renderPassTest, TestConfig(renderPass, renderTypes[renderTypeNdx].types, TestConfig::COMMANDBUFFERTYPES_INLINE, TestConfig::IMAGEMEMORY_STRICT, targetSize, renderPos, renderSize, 89246, allocationKind));
6330 loadOpGroup->addChild(storeOpGroup.release());
6333 inputGroup->addChild(loadOpGroup.release());
6336 formatGroup->addChild(inputGroup.release());
6339 group->addChild(formatGroup.release());
6343 void addRenderPassTests (tcu::TestCaseGroup* group, AllocationKind allocationKind)
6345 addTestGroup(group, "simple", "Simple basic render pass tests", addSimpleTests, allocationKind);
6346 addTestGroup(group, "formats", "Tests for different image formats.", addFormatTests, allocationKind);
6347 addTestGroup(group, "attachment", "Attachment format and count tests with load and store ops and image layouts", addAttachmentTests, allocationKind);
6348 addTestGroup(group, "attachment_allocation", "Attachment allocation tests", addAttachmentAllocationTests, allocationKind);
6351 de::MovePtr<tcu::TestCaseGroup> createSuballocationTests(tcu::TestContext& testCtx)
6353 de::MovePtr<tcu::TestCaseGroup> suballocationTestsGroup(new tcu::TestCaseGroup(testCtx, "suballocation", "Suballocation RenderPass Tests"));
6355 addRenderPassTests(suballocationTestsGroup.get(), ALLOCATION_KIND_SUBALLOCATED);
6357 return suballocationTestsGroup;
6360 de::MovePtr<tcu::TestCaseGroup> createDedicatedAllocationTests(tcu::TestContext& testCtx)
6362 de::MovePtr<tcu::TestCaseGroup> dedicatedAllocationTestsGroup(new tcu::TestCaseGroup(testCtx, "dedicated_allocation", "RenderPass Tests For Dedicated Allocation"));
6364 addRenderPassTests(dedicatedAllocationTestsGroup.get(), ALLOCATION_KIND_DEDICATED);
6366 return dedicatedAllocationTestsGroup;
6371 tcu::TestCaseGroup* createRenderPassTests (tcu::TestContext& testCtx)
6373 de::MovePtr<tcu::TestCaseGroup> renderpassTests (new tcu::TestCaseGroup(testCtx, "renderpass", "RenderPass Tests"));
6374 de::MovePtr<tcu::TestCaseGroup> suballocationTestGroup = createSuballocationTests(testCtx);
6375 de::MovePtr<tcu::TestCaseGroup> dedicatedAllocationTestGroup = createDedicatedAllocationTests(testCtx);
6377 suballocationTestGroup->addChild(createRenderPassMultisampleTests(testCtx));
6378 suballocationTestGroup->addChild(createRenderPassMultisampleResolveTests(testCtx));
6380 renderpassTests->addChild(suballocationTestGroup.release());
6381 renderpassTests->addChild(dedicatedAllocationTestGroup.release());
6383 renderpassTests->addChild(createRenderPassMultisampleTests(testCtx));
6384 renderpassTests->addChild(createRenderPassMultisampleResolveTests(testCtx));
6386 return renderpassTests.release();