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"
28 #include "vktRenderPassSampleReadTests.hpp"
30 #include "vktTestCaseUtil.hpp"
31 #include "vktTestGroupUtil.hpp"
34 #include "vkDeviceUtil.hpp"
35 #include "vkImageUtil.hpp"
36 #include "vkMemUtil.hpp"
37 #include "vkPlatform.hpp"
38 #include "vkPrograms.hpp"
39 #include "vkQueryUtil.hpp"
41 #include "vkRefUtil.hpp"
42 #include "vkStrUtil.hpp"
43 #include "vkTypeUtil.hpp"
45 #include "tcuFloat.hpp"
46 #include "tcuFormatUtil.hpp"
47 #include "tcuMaybe.hpp"
48 #include "tcuResultCollector.hpp"
49 #include "tcuTestLog.hpp"
50 #include "tcuTextureUtil.hpp"
51 #include "tcuVectorUtil.hpp"
53 #include "deRandom.hpp"
54 #include "deSTLUtil.hpp"
55 #include "deSharedPtr.hpp"
56 #include "deStringUtil.hpp"
57 #include "deUniquePtr.hpp"
78 using tcu::ConstPixelBufferAccess;
79 using tcu::PixelBufferAccess;
96 ALLOCATION_KIND_SUBALLOCATED,
97 ALLOCATION_KIND_DEDICATED,
100 de::MovePtr<Allocation> allocateBuffer (const InstanceInterface& vki,
101 const DeviceInterface& vkd,
102 const VkPhysicalDevice& physDevice,
103 const VkDevice device,
104 const VkBuffer& buffer,
105 const MemoryRequirement requirement,
106 Allocator& allocator,
107 AllocationKind allocationKind)
109 switch (allocationKind)
111 case ALLOCATION_KIND_SUBALLOCATED:
113 const VkMemoryRequirements memoryRequirements = getBufferMemoryRequirements(vkd, device, buffer);
115 return allocator.allocate(memoryRequirements, requirement);
118 case ALLOCATION_KIND_DEDICATED:
120 return allocateDedicated(vki, vkd, physDevice, device, buffer, requirement);
125 TCU_THROW(InternalError, "Invalid allocation kind");
130 de::MovePtr<Allocation> allocateImage (const InstanceInterface& vki,
131 const DeviceInterface& vkd,
132 const VkPhysicalDevice& physDevice,
133 const VkDevice device,
134 const VkImage& image,
135 const MemoryRequirement requirement,
136 Allocator& allocator,
137 AllocationKind allocationKind)
139 switch (allocationKind)
141 case ALLOCATION_KIND_SUBALLOCATED:
143 const VkMemoryRequirements memoryRequirements = getImageMemoryRequirements(vkd, device, image);
145 return allocator.allocate(memoryRequirements, requirement);
148 case ALLOCATION_KIND_DEDICATED:
150 return allocateDedicated(vki, vkd, physDevice, device, image, requirement);
155 TCU_THROW(InternalError, "Invalid allocation kind");
168 const char* boolOpToString (BoolOp op)
185 DE_FATAL("Unknown boolean operation.");
190 bool performBoolOp (BoolOp op, bool a, bool b)
207 DE_FATAL("Unknown boolean operation.");
212 BoolOp boolOpFromIndex (size_t index)
222 return ops[index % DE_LENGTH_OF_ARRAY(ops)];
225 Move<VkFramebuffer> createFramebuffer (const DeviceInterface& vk,
227 VkFramebufferCreateFlags pCreateInfo_flags,
228 VkRenderPass pCreateInfo_renderPass,
229 deUint32 pCreateInfo_attachmentCount,
230 const VkImageView* pCreateInfo_pAttachments,
231 deUint32 pCreateInfo_width,
232 deUint32 pCreateInfo_height,
233 deUint32 pCreateInfo_layers)
235 const VkFramebufferCreateInfo pCreateInfo =
237 VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
240 pCreateInfo_renderPass,
241 pCreateInfo_attachmentCount,
242 pCreateInfo_pAttachments,
247 return createFramebuffer(vk, device, &pCreateInfo);
250 Move<VkImage> createImage (const DeviceInterface& vk,
252 VkImageCreateFlags pCreateInfo_flags,
253 VkImageType pCreateInfo_imageType,
254 VkFormat pCreateInfo_format,
255 VkExtent3D pCreateInfo_extent,
256 deUint32 pCreateInfo_mipLevels,
257 deUint32 pCreateInfo_arrayLayers,
258 VkSampleCountFlagBits pCreateInfo_samples,
259 VkImageTiling pCreateInfo_tiling,
260 VkImageUsageFlags pCreateInfo_usage,
261 VkSharingMode pCreateInfo_sharingMode,
262 deUint32 pCreateInfo_queueFamilyCount,
263 const deUint32* pCreateInfo_pQueueFamilyIndices,
264 VkImageLayout pCreateInfo_initialLayout)
266 const VkImageCreateInfo pCreateInfo =
268 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
271 pCreateInfo_imageType,
274 pCreateInfo_mipLevels,
275 pCreateInfo_arrayLayers,
279 pCreateInfo_sharingMode,
280 pCreateInfo_queueFamilyCount,
281 pCreateInfo_pQueueFamilyIndices,
282 pCreateInfo_initialLayout
284 return createImage(vk, device, &pCreateInfo);
287 void bindBufferMemory (const DeviceInterface& vk, VkDevice device, VkBuffer buffer, VkDeviceMemory mem, VkDeviceSize memOffset)
289 VK_CHECK(vk.bindBufferMemory(device, buffer, mem, memOffset));
292 void bindImageMemory (const DeviceInterface& vk, VkDevice device, VkImage image, VkDeviceMemory mem, VkDeviceSize memOffset)
294 VK_CHECK(vk.bindImageMemory(device, image, mem, memOffset));
297 Move<VkImageView> createImageView (const DeviceInterface& vk,
299 VkImageViewCreateFlags pCreateInfo_flags,
300 VkImage pCreateInfo_image,
301 VkImageViewType pCreateInfo_viewType,
302 VkFormat pCreateInfo_format,
303 VkComponentMapping pCreateInfo_components,
304 VkImageSubresourceRange pCreateInfo_subresourceRange)
306 const VkImageViewCreateInfo pCreateInfo =
308 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
312 pCreateInfo_viewType,
314 pCreateInfo_components,
315 pCreateInfo_subresourceRange,
317 return createImageView(vk, device, &pCreateInfo);
320 Move<VkBuffer> createBuffer (const DeviceInterface& vk,
322 VkBufferCreateFlags pCreateInfo_flags,
323 VkDeviceSize pCreateInfo_size,
324 VkBufferUsageFlags pCreateInfo_usage,
325 VkSharingMode pCreateInfo_sharingMode,
326 deUint32 pCreateInfo_queueFamilyCount,
327 const deUint32* pCreateInfo_pQueueFamilyIndices)
329 const VkBufferCreateInfo pCreateInfo =
331 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
336 pCreateInfo_sharingMode,
337 pCreateInfo_queueFamilyCount,
338 pCreateInfo_pQueueFamilyIndices,
340 return createBuffer(vk, device, &pCreateInfo);
343 void cmdBeginRenderPass (const DeviceInterface& vk,
344 VkCommandBuffer cmdBuffer,
345 VkRenderPass pRenderPassBegin_renderPass,
346 VkFramebuffer pRenderPassBegin_framebuffer,
347 VkRect2D pRenderPassBegin_renderArea,
348 deUint32 pRenderPassBegin_clearValueCount,
349 const VkClearValue* pRenderPassBegin_pAttachmentClearValues,
350 VkSubpassContents contents)
352 const VkRenderPassBeginInfo pRenderPassBegin =
354 VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
356 pRenderPassBegin_renderPass,
357 pRenderPassBegin_framebuffer,
358 pRenderPassBegin_renderArea,
359 pRenderPassBegin_clearValueCount,
360 pRenderPassBegin_pAttachmentClearValues,
362 vk.cmdBeginRenderPass(cmdBuffer, &pRenderPassBegin, contents);
365 void beginCommandBuffer (const DeviceInterface& vk,
366 VkCommandBuffer cmdBuffer,
367 VkCommandBufferUsageFlags pBeginInfo_flags,
368 VkRenderPass pInheritanceInfo_renderPass,
369 deUint32 pInheritanceInfo_subpass,
370 VkFramebuffer pInheritanceInfo_framebuffer,
371 VkBool32 pInheritanceInfo_occlusionQueryEnable,
372 VkQueryControlFlags pInheritanceInfo_queryFlags,
373 VkQueryPipelineStatisticFlags pInheritanceInfo_pipelineStatistics)
375 const VkCommandBufferInheritanceInfo pInheritanceInfo =
377 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO,
379 pInheritanceInfo_renderPass,
380 pInheritanceInfo_subpass,
381 pInheritanceInfo_framebuffer,
382 pInheritanceInfo_occlusionQueryEnable,
383 pInheritanceInfo_queryFlags,
384 pInheritanceInfo_pipelineStatistics,
386 const VkCommandBufferBeginInfo pBeginInfo =
388 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
393 VK_CHECK(vk.beginCommandBuffer(cmdBuffer, &pBeginInfo));
396 void endCommandBuffer (const DeviceInterface& vk, VkCommandBuffer cmdBuffer)
398 VK_CHECK(vk.endCommandBuffer(cmdBuffer));
401 void queueSubmit (const DeviceInterface& vk, VkQueue queue, deUint32 cmdBufferCount, const VkCommandBuffer* pCmdBuffers, VkFence fence)
403 const VkSubmitInfo submitInfo =
405 VK_STRUCTURE_TYPE_SUBMIT_INFO,
407 0u, // waitSemaphoreCount
408 (const VkSemaphore*)DE_NULL, // pWaitSemaphores
409 (const VkPipelineStageFlags*)DE_NULL,
410 cmdBufferCount, // commandBufferCount
412 0u, // signalSemaphoreCount
413 (const VkSemaphore*)DE_NULL, // pSignalSemaphores
415 VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo, fence));
418 void waitForFences (const DeviceInterface& vk, VkDevice device, deUint32 fenceCount, const VkFence* pFences, VkBool32 waitAll, deUint64 timeout)
420 VK_CHECK(vk.waitForFences(device, fenceCount, pFences, waitAll, timeout));
423 VkImageAspectFlags getImageAspectFlags (VkFormat vkFormat)
425 const tcu::TextureFormat format = mapVkFormat(vkFormat);
427 DE_STATIC_ASSERT(tcu::TextureFormat::CHANNELORDER_LAST == 21);
429 switch (format.order)
431 case tcu::TextureFormat::DS:
432 return VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_DEPTH_BIT;
434 case tcu::TextureFormat::D:
435 return VK_IMAGE_ASPECT_DEPTH_BIT;
437 case tcu::TextureFormat::S:
438 return VK_IMAGE_ASPECT_STENCIL_BIT;
441 return VK_IMAGE_ASPECT_COLOR_BIT;
445 VkAccessFlags getAllMemoryReadFlags (void)
447 return VK_ACCESS_TRANSFER_READ_BIT
448 | VK_ACCESS_UNIFORM_READ_BIT
449 | VK_ACCESS_HOST_READ_BIT
450 | VK_ACCESS_INDEX_READ_BIT
451 | VK_ACCESS_SHADER_READ_BIT
452 | VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT
453 | VK_ACCESS_INDIRECT_COMMAND_READ_BIT
454 | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT
455 | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT
456 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT;
459 VkAccessFlags getAllMemoryWriteFlags (void)
461 return VK_ACCESS_TRANSFER_WRITE_BIT
462 | VK_ACCESS_HOST_WRITE_BIT
463 | VK_ACCESS_SHADER_WRITE_BIT
464 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT
465 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
468 VkAccessFlags getMemoryFlagsForLayout (const VkImageLayout layout)
472 case VK_IMAGE_LAYOUT_GENERAL: return getAllMemoryReadFlags() | getAllMemoryWriteFlags();
473 case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: return VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
474 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: return VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
475 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: return VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT;
476 case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL: return VK_ACCESS_SHADER_READ_BIT;
477 case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL: return VK_ACCESS_TRANSFER_READ_BIT;
478 case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL: return VK_ACCESS_TRANSFER_WRITE_BIT;
479 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;
480 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;
482 return (VkAccessFlags)0;
486 VkPipelineStageFlags getAllPipelineStageFlags (void)
488 return VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT
489 | VK_PIPELINE_STAGE_TRANSFER_BIT
490 | VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT
491 | VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT
492 | VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT
493 | VK_PIPELINE_STAGE_VERTEX_INPUT_BIT
494 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT
495 | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
496 | VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT
497 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
498 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT
499 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
500 | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
503 class AttachmentReference
506 AttachmentReference (deUint32 attachment,
507 VkImageLayout layout)
508 : m_attachment (attachment)
513 deUint32 getAttachment (void) const { return m_attachment; }
514 VkImageLayout getImageLayout (void) const { return m_layout; }
517 deUint32 m_attachment;
518 VkImageLayout m_layout;
524 Subpass (VkPipelineBindPoint pipelineBindPoint,
525 VkSubpassDescriptionFlags flags,
526 const vector<AttachmentReference>& inputAttachments,
527 const vector<AttachmentReference>& colorAttachments,
528 const vector<AttachmentReference>& resolveAttachments,
529 AttachmentReference depthStencilAttachment,
530 const vector<deUint32>& preserveAttachments)
531 : m_pipelineBindPoint (pipelineBindPoint)
533 , m_inputAttachments (inputAttachments)
534 , m_colorAttachments (colorAttachments)
535 , m_resolveAttachments (resolveAttachments)
536 , m_depthStencilAttachment (depthStencilAttachment)
537 , m_preserveAttachments (preserveAttachments)
541 VkPipelineBindPoint getPipelineBindPoint (void) const { return m_pipelineBindPoint; }
542 VkSubpassDescriptionFlags getFlags (void) const { return m_flags; }
543 const vector<AttachmentReference>& getInputAttachments (void) const { return m_inputAttachments; }
544 const vector<AttachmentReference>& getColorAttachments (void) const { return m_colorAttachments; }
545 const vector<AttachmentReference>& getResolveAttachments (void) const { return m_resolveAttachments; }
546 const AttachmentReference& getDepthStencilAttachment (void) const { return m_depthStencilAttachment; }
547 const vector<deUint32>& getPreserveAttachments (void) const { return m_preserveAttachments; }
550 VkPipelineBindPoint m_pipelineBindPoint;
551 VkSubpassDescriptionFlags m_flags;
553 vector<AttachmentReference> m_inputAttachments;
554 vector<AttachmentReference> m_colorAttachments;
555 vector<AttachmentReference> m_resolveAttachments;
556 AttachmentReference m_depthStencilAttachment;
558 vector<deUint32> m_preserveAttachments;
561 class SubpassDependency
564 SubpassDependency (deUint32 srcPass,
567 VkPipelineStageFlags srcStageMask,
568 VkPipelineStageFlags dstStageMask,
570 VkAccessFlags srcAccessMask,
571 VkAccessFlags dstAccessMask,
573 VkDependencyFlags flags)
574 : m_srcPass (srcPass)
575 , m_dstPass (dstPass)
577 , m_srcStageMask (srcStageMask)
578 , m_dstStageMask (dstStageMask)
580 , m_srcAccessMask (srcAccessMask)
581 , m_dstAccessMask (dstAccessMask)
586 deUint32 getSrcPass (void) const { return m_srcPass; }
587 deUint32 getDstPass (void) const { return m_dstPass; }
589 VkPipelineStageFlags getSrcStageMask (void) const { return m_srcStageMask; }
590 VkPipelineStageFlags getDstStageMask (void) const { return m_dstStageMask; }
592 VkAccessFlags getSrcAccessMask (void) const { return m_srcAccessMask; }
593 VkAccessFlags getDstAccessMask (void) const { return m_dstAccessMask; }
595 VkDependencyFlags getFlags (void) const { return m_flags; }
601 VkPipelineStageFlags m_srcStageMask;
602 VkPipelineStageFlags m_dstStageMask;
604 VkAccessFlags m_srcAccessMask;
605 VkAccessFlags m_dstAccessMask;
606 VkDependencyFlags m_flags;
612 Attachment (VkFormat format,
613 VkSampleCountFlagBits samples,
615 VkAttachmentLoadOp loadOp,
616 VkAttachmentStoreOp storeOp,
618 VkAttachmentLoadOp stencilLoadOp,
619 VkAttachmentStoreOp stencilStoreOp,
621 VkImageLayout initialLayout,
622 VkImageLayout finalLayout)
624 , m_samples (samples)
627 , m_storeOp (storeOp)
629 , m_stencilLoadOp (stencilLoadOp)
630 , m_stencilStoreOp (stencilStoreOp)
632 , m_initialLayout (initialLayout)
633 , m_finalLayout (finalLayout)
637 VkFormat getFormat (void) const { return m_format; }
638 VkSampleCountFlagBits getSamples (void) const { return m_samples; }
640 VkAttachmentLoadOp getLoadOp (void) const { return m_loadOp; }
641 VkAttachmentStoreOp getStoreOp (void) const { return m_storeOp; }
644 VkAttachmentLoadOp getStencilLoadOp (void) const { return m_stencilLoadOp; }
645 VkAttachmentStoreOp getStencilStoreOp (void) const { return m_stencilStoreOp; }
647 VkImageLayout getInitialLayout (void) const { return m_initialLayout; }
648 VkImageLayout getFinalLayout (void) const { return m_finalLayout; }
652 VkSampleCountFlagBits m_samples;
654 VkAttachmentLoadOp m_loadOp;
655 VkAttachmentStoreOp m_storeOp;
657 VkAttachmentLoadOp m_stencilLoadOp;
658 VkAttachmentStoreOp m_stencilStoreOp;
660 VkImageLayout m_initialLayout;
661 VkImageLayout m_finalLayout;
667 RenderPass (const vector<Attachment>& attachments,
668 const vector<Subpass>& subpasses,
669 const vector<SubpassDependency>& dependencies,
670 const vector<VkInputAttachmentAspectReferenceKHR> inputAspects = vector<VkInputAttachmentAspectReferenceKHR>())
671 : m_attachments (attachments)
672 , m_subpasses (subpasses)
673 , m_dependencies (dependencies)
674 , m_inputAspects (inputAspects)
678 const vector<Attachment>& getAttachments (void) const { return m_attachments; }
679 const vector<Subpass>& getSubpasses (void) const { return m_subpasses; }
680 const vector<SubpassDependency>& getDependencies (void) const { return m_dependencies; }
681 const vector<VkInputAttachmentAspectReferenceKHR> getInputAspects (void) const { return m_inputAspects; }
684 const vector<Attachment> m_attachments;
685 const vector<Subpass> m_subpasses;
686 const vector<SubpassDependency> m_dependencies;
687 const vector<VkInputAttachmentAspectReferenceKHR> m_inputAspects;
694 RENDERTYPES_NONE = 0,
695 RENDERTYPES_CLEAR = (1<<1),
696 RENDERTYPES_DRAW = (1<<2)
699 enum CommandBufferTypes
701 COMMANDBUFFERTYPES_INLINE = (1<<0),
702 COMMANDBUFFERTYPES_SECONDARY = (1<<1)
707 IMAGEMEMORY_STRICT = (1<<0),
708 IMAGEMEMORY_LAZY = (1<<1)
711 TestConfig (const RenderPass& renderPass_,
712 RenderTypes renderTypes_,
713 CommandBufferTypes commandBufferTypes_,
714 ImageMemory imageMemory_,
715 const UVec2& targetSize_,
716 const UVec2& renderPos_,
717 const UVec2& renderSize_,
719 AllocationKind allocationKind_)
720 : renderPass (renderPass_)
721 , renderTypes (renderTypes_)
722 , commandBufferTypes (commandBufferTypes_)
723 , imageMemory (imageMemory_)
724 , targetSize (targetSize_)
725 , renderPos (renderPos_)
726 , renderSize (renderSize_)
728 , allocationKind (allocationKind_)
732 RenderPass renderPass;
733 RenderTypes renderTypes;
734 CommandBufferTypes commandBufferTypes;
735 ImageMemory imageMemory;
740 AllocationKind allocationKind;
743 TestConfig::RenderTypes operator| (TestConfig::RenderTypes a, TestConfig::RenderTypes b)
745 return (TestConfig::RenderTypes)(((deUint32)a) | ((deUint32)b));
748 TestConfig::CommandBufferTypes operator| (TestConfig::CommandBufferTypes a, TestConfig::CommandBufferTypes b)
750 return (TestConfig::CommandBufferTypes)(((deUint32)a) | ((deUint32)b));
753 TestConfig::ImageMemory operator| (TestConfig::ImageMemory a, TestConfig::ImageMemory b)
755 return (TestConfig::ImageMemory)(((deUint32)a) | ((deUint32)b));
758 void logRenderPassInfo (TestLog& log,
759 const RenderPass& renderPass)
761 const tcu::ScopedLogSection section (log, "RenderPass", "RenderPass");
764 const tcu::ScopedLogSection attachmentsSection (log, "Attachments", "Attachments");
765 const vector<Attachment>& attachments = renderPass.getAttachments();
767 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
769 const tcu::ScopedLogSection attachmentSection (log, "Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx));
770 const Attachment& attachment = attachments[attachmentNdx];
772 log << TestLog::Message << "Format: " << attachment.getFormat() << TestLog::EndMessage;
773 log << TestLog::Message << "Samples: " << attachment.getSamples() << TestLog::EndMessage;
775 log << TestLog::Message << "LoadOp: " << attachment.getLoadOp() << TestLog::EndMessage;
776 log << TestLog::Message << "StoreOp: " << attachment.getStoreOp() << TestLog::EndMessage;
778 log << TestLog::Message << "StencilLoadOp: " << attachment.getStencilLoadOp() << TestLog::EndMessage;
779 log << TestLog::Message << "StencilStoreOp: " << attachment.getStencilStoreOp() << TestLog::EndMessage;
781 log << TestLog::Message << "InitialLayout: " << attachment.getInitialLayout() << TestLog::EndMessage;
782 log << TestLog::Message << "FinalLayout: " << attachment.getFinalLayout() << TestLog::EndMessage;
786 if (!renderPass.getInputAspects().empty())
788 const tcu::ScopedLogSection inputAspectSection (log, "InputAspects", "InputAspects");
790 for (size_t aspectNdx = 0; aspectNdx < renderPass.getInputAspects().size(); aspectNdx++)
792 const VkInputAttachmentAspectReferenceKHR& inputAspect (renderPass.getInputAspects()[aspectNdx]);
794 log << TestLog::Message << "Subpass: " << inputAspect.subpass << TestLog::EndMessage;
795 log << TestLog::Message << "InputAttachmentIndex: " << inputAspect.inputAttachmentIndex << TestLog::EndMessage;
796 log << TestLog::Message << "AspectFlags: " << getImageAspectFlagsStr(inputAspect.aspectMask) << TestLog::EndMessage;
801 const tcu::ScopedLogSection subpassesSection (log, "Subpasses", "Subpasses");
802 const vector<Subpass>& subpasses = renderPass.getSubpasses();
804 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
806 const tcu::ScopedLogSection subpassSection (log, "Subpass" + de::toString(subpassNdx), "Subpass " + de::toString(subpassNdx));
807 const Subpass& subpass = subpasses[subpassNdx];
809 const vector<AttachmentReference>& inputAttachments = subpass.getInputAttachments();
810 const vector<AttachmentReference>& colorAttachments = subpass.getColorAttachments();
811 const vector<AttachmentReference>& resolveAttachments = subpass.getResolveAttachments();
812 const vector<deUint32>& preserveAttachments = subpass.getPreserveAttachments();
814 if (!inputAttachments.empty())
816 const tcu::ScopedLogSection inputAttachmentsSection (log, "Inputs", "Inputs");
818 for (size_t inputNdx = 0; inputNdx < inputAttachments.size(); inputNdx++)
820 const tcu::ScopedLogSection inputAttachmentSection (log, "Input" + de::toString(inputNdx), "Input " + de::toString(inputNdx));
821 const AttachmentReference& inputAttachment = inputAttachments[inputNdx];
823 log << TestLog::Message << "Attachment: " << inputAttachment.getAttachment() << TestLog::EndMessage;
824 log << TestLog::Message << "Layout: " << inputAttachment.getImageLayout() << TestLog::EndMessage;
828 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
830 const tcu::ScopedLogSection depthStencilAttachmentSection (log, "DepthStencil", "DepthStencil");
831 const AttachmentReference& depthStencilAttachment = subpass.getDepthStencilAttachment();
833 log << TestLog::Message << "Attachment: " << depthStencilAttachment.getAttachment() << TestLog::EndMessage;
834 log << TestLog::Message << "Layout: " << depthStencilAttachment.getImageLayout() << TestLog::EndMessage;
837 if (!colorAttachments.empty())
839 const tcu::ScopedLogSection colorAttachmentsSection (log, "Colors", "Colors");
841 for (size_t colorNdx = 0; colorNdx < colorAttachments.size(); colorNdx++)
843 const tcu::ScopedLogSection colorAttachmentSection (log, "Color" + de::toString(colorNdx), "Color " + de::toString(colorNdx));
844 const AttachmentReference& colorAttachment = colorAttachments[colorNdx];
846 log << TestLog::Message << "Attachment: " << colorAttachment.getAttachment() << TestLog::EndMessage;
847 log << TestLog::Message << "Layout: " << colorAttachment.getImageLayout() << TestLog::EndMessage;
851 if (!resolveAttachments.empty())
853 const tcu::ScopedLogSection resolveAttachmentsSection (log, "Resolves", "Resolves");
855 for (size_t resolveNdx = 0; resolveNdx < resolveAttachments.size(); resolveNdx++)
857 const tcu::ScopedLogSection resolveAttachmentSection (log, "Resolve" + de::toString(resolveNdx), "Resolve " + de::toString(resolveNdx));
858 const AttachmentReference& resolveAttachment = resolveAttachments[resolveNdx];
860 log << TestLog::Message << "Attachment: " << resolveAttachment.getAttachment() << TestLog::EndMessage;
861 log << TestLog::Message << "Layout: " << resolveAttachment.getImageLayout() << TestLog::EndMessage;
865 if (!preserveAttachments.empty())
867 const tcu::ScopedLogSection preserveAttachmentsSection (log, "Preserves", "Preserves");
869 for (size_t preserveNdx = 0; preserveNdx < preserveAttachments.size(); preserveNdx++)
871 const tcu::ScopedLogSection preserveAttachmentSection (log, "Preserve" + de::toString(preserveNdx), "Preserve " + de::toString(preserveNdx));
872 const deUint32 preserveAttachment = preserveAttachments[preserveNdx];
874 log << TestLog::Message << "Attachment: " << preserveAttachment << TestLog::EndMessage;
881 if (!renderPass.getDependencies().empty())
883 const tcu::ScopedLogSection dependenciesSection (log, "Dependencies", "Dependencies");
885 for (size_t depNdx = 0; depNdx < renderPass.getDependencies().size(); depNdx++)
887 const tcu::ScopedLogSection dependencySection (log, "Dependency" + de::toString(depNdx), "Dependency " + de::toString(depNdx));
888 const SubpassDependency& dep = renderPass.getDependencies()[depNdx];
890 log << TestLog::Message << "Source: " << dep.getSrcPass() << TestLog::EndMessage;
891 log << TestLog::Message << "Destination: " << dep.getDstPass() << TestLog::EndMessage;
893 log << TestLog::Message << "Source Stage Mask: " << dep.getSrcStageMask() << TestLog::EndMessage;
894 log << TestLog::Message << "Destination Stage Mask: " << dep.getDstStageMask() << TestLog::EndMessage;
896 log << TestLog::Message << "Input Mask: " << dep.getDstAccessMask() << TestLog::EndMessage;
897 log << TestLog::Message << "Output Mask: " << dep.getSrcAccessMask() << TestLog::EndMessage;
898 log << TestLog::Message << "Dependency Flags: " << getDependencyFlagsStr(dep.getFlags()) << TestLog::EndMessage;
903 std::string clearColorToString (VkFormat vkFormat, VkClearColorValue value)
905 const tcu::TextureFormat format = mapVkFormat(vkFormat);
906 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
907 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
909 std::ostringstream stream;
913 switch (channelClass)
915 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
916 for (int i = 0; i < 4; i++)
922 stream << value.int32[i];
928 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
929 for (int i = 0; i < 4; i++)
935 stream << value.uint32[i];
941 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
942 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
943 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
944 for (int i = 0; i < 4; i++)
950 stream << value.float32[i];
957 DE_FATAL("Unknown channel class");
965 std::string clearValueToString (VkFormat vkFormat, VkClearValue value)
967 const tcu::TextureFormat format = mapVkFormat(vkFormat);
969 if (tcu::hasStencilComponent(format.order) || tcu::hasDepthComponent(format.order))
971 std::ostringstream stream;
975 if (tcu::hasStencilComponent(format.order))
976 stream << "stencil: " << value.depthStencil.stencil;
978 if (tcu::hasStencilComponent(format.order) && tcu::hasDepthComponent(format.order))
981 if (tcu::hasDepthComponent(format.order))
982 stream << "depth: " << value.depthStencil.depth;
989 return clearColorToString(vkFormat, value.color);
992 VkClearColorValue randomColorClearValue (const Attachment& attachment, de::Random& rng)
994 const float clearNan = tcu::Float32::nan().asFloat();
995 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
996 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
997 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
998 VkClearColorValue clearColor;
1000 switch (channelClass)
1002 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
1004 for (int ndx = 0; ndx < 4; ndx++)
1006 if (!channelMask[ndx])
1007 clearColor.int32[ndx] = std::numeric_limits<deInt32>::min();
1009 clearColor.uint32[ndx] = rng.getBool() ? 1u : 0u;
1014 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
1016 for (int ndx = 0; ndx < 4; ndx++)
1018 if (!channelMask[ndx])
1019 clearColor.uint32[ndx] = std::numeric_limits<deUint32>::max();
1021 clearColor.uint32[ndx] = rng.getBool() ? 1u : 0u;
1026 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
1027 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
1028 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
1030 for (int ndx = 0; ndx < 4; ndx++)
1032 if (!channelMask[ndx])
1033 clearColor.float32[ndx] = clearNan;
1035 clearColor.float32[ndx] = rng.getBool() ? 1.0f : 0.0f;
1041 DE_FATAL("Unknown channel class");
1047 VkAttachmentDescription createAttachmentDescription (const Attachment& attachment)
1049 const VkAttachmentDescription attachmentDescription =
1053 attachment.getFormat(), // format
1054 attachment.getSamples(), // samples
1056 attachment.getLoadOp(), // loadOp
1057 attachment.getStoreOp(), // storeOp
1059 attachment.getStencilLoadOp(), // stencilLoadOp
1060 attachment.getStencilStoreOp(), // stencilStoreOp
1062 attachment.getInitialLayout(), // initialLayout
1063 attachment.getFinalLayout(), // finalLayout
1066 return attachmentDescription;
1069 VkAttachmentReference createAttachmentReference (const AttachmentReference& referenceInfo)
1071 const VkAttachmentReference reference =
1073 referenceInfo.getAttachment(), // attachment;
1074 referenceInfo.getImageLayout() // layout;
1080 VkSubpassDescription createSubpassDescription (const Subpass& subpass,
1081 vector<VkAttachmentReference>* attachmentReferenceLists,
1082 vector<deUint32>* preserveAttachmentReferences)
1084 vector<VkAttachmentReference>& inputAttachmentReferences = attachmentReferenceLists[0];
1085 vector<VkAttachmentReference>& colorAttachmentReferences = attachmentReferenceLists[1];
1086 vector<VkAttachmentReference>& resolveAttachmentReferences = attachmentReferenceLists[2];
1087 vector<VkAttachmentReference>& depthStencilAttachmentReferences = attachmentReferenceLists[3];
1089 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
1090 colorAttachmentReferences.push_back(createAttachmentReference(subpass.getColorAttachments()[attachmentNdx]));
1092 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
1093 inputAttachmentReferences.push_back(createAttachmentReference(subpass.getInputAttachments()[attachmentNdx]));
1095 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getResolveAttachments().size(); attachmentNdx++)
1096 resolveAttachmentReferences.push_back(createAttachmentReference(subpass.getResolveAttachments()[attachmentNdx]));
1098 depthStencilAttachmentReferences.push_back(createAttachmentReference(subpass.getDepthStencilAttachment()));
1100 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getPreserveAttachments().size(); attachmentNdx++)
1101 preserveAttachmentReferences->push_back(subpass.getPreserveAttachments()[attachmentNdx]);
1103 DE_ASSERT(resolveAttachmentReferences.empty() || colorAttachmentReferences.size() == resolveAttachmentReferences.size());
1106 const VkSubpassDescription subpassDescription =
1108 subpass.getFlags(), // flags;
1109 subpass.getPipelineBindPoint(), // pipelineBindPoint;
1111 (deUint32)inputAttachmentReferences.size(), // inputCount;
1112 inputAttachmentReferences.empty() ? DE_NULL : &inputAttachmentReferences[0], // inputAttachments;
1114 (deUint32)colorAttachmentReferences.size(), // colorCount;
1115 colorAttachmentReferences.empty() ? DE_NULL : &colorAttachmentReferences[0], // colorAttachments;
1116 resolveAttachmentReferences.empty() ? DE_NULL : &resolveAttachmentReferences[0], // resolveAttachments;
1118 &depthStencilAttachmentReferences[0], // pDepthStencilAttachment;
1119 (deUint32)preserveAttachmentReferences->size(), // preserveCount;
1120 preserveAttachmentReferences->empty() ? DE_NULL : &(*preserveAttachmentReferences)[0] // preserveAttachments;
1123 return subpassDescription;
1127 VkSubpassDependency createSubpassDependency (const SubpassDependency& dependencyInfo)
1129 const VkSubpassDependency dependency =
1131 dependencyInfo.getSrcPass(), // srcSubpass;
1132 dependencyInfo.getDstPass(), // destSubpass;
1134 dependencyInfo.getSrcStageMask(), // srcStageMask;
1135 dependencyInfo.getDstStageMask(), // destStageMask;
1137 dependencyInfo.getSrcAccessMask(), // srcAccessMask;
1138 dependencyInfo.getDstAccessMask(), // dstAccessMask;
1140 dependencyInfo.getFlags() // dependencyFlags;
1146 Move<VkRenderPass> createRenderPass (const DeviceInterface& vk,
1148 const RenderPass& renderPassInfo)
1150 const size_t perSubpassAttachmentReferenceLists = 4;
1151 vector<VkAttachmentDescription> attachments;
1152 vector<VkSubpassDescription> subpasses;
1153 vector<VkSubpassDependency> dependencies;
1154 vector<vector<VkAttachmentReference> > attachmentReferenceLists(renderPassInfo.getSubpasses().size() * perSubpassAttachmentReferenceLists);
1155 vector<vector<deUint32> > preserveAttachments(renderPassInfo.getSubpasses().size());
1157 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
1158 attachments.push_back(createAttachmentDescription(renderPassInfo.getAttachments()[attachmentNdx]));
1160 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); subpassNdx++)
1161 subpasses.push_back(createSubpassDescription(renderPassInfo.getSubpasses()[subpassNdx], &(attachmentReferenceLists[subpassNdx * perSubpassAttachmentReferenceLists]), &preserveAttachments[subpassNdx]));
1163 for (size_t depNdx = 0; depNdx < renderPassInfo.getDependencies().size(); depNdx++)
1164 dependencies.push_back(createSubpassDependency(renderPassInfo.getDependencies()[depNdx]));
1166 if (renderPassInfo.getInputAspects().empty())
1168 const VkRenderPassCreateInfo createInfo =
1170 VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
1172 (VkRenderPassCreateFlags)0u,
1173 (deUint32)attachments.size(),
1174 (attachments.empty() ? DE_NULL : &attachments[0]),
1175 (deUint32)subpasses.size(),
1176 (subpasses.empty() ? DE_NULL : &subpasses[0]),
1177 (deUint32)dependencies.size(),
1178 (dependencies.empty() ? DE_NULL : &dependencies[0])
1181 return createRenderPass(vk, device, &createInfo);
1185 const VkRenderPassInputAttachmentAspectCreateInfoKHR inputAspectCreateInfo =
1187 VK_STRUCTURE_TYPE_RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO_KHR,
1190 (deUint32)renderPassInfo.getInputAspects().size(),
1191 renderPassInfo.getInputAspects().data(),
1193 const VkRenderPassCreateInfo createInfo =
1195 VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
1196 &inputAspectCreateInfo,
1197 (VkRenderPassCreateFlags)0u,
1198 (deUint32)attachments.size(),
1199 (attachments.empty() ? DE_NULL : &attachments[0]),
1200 (deUint32)subpasses.size(),
1201 (subpasses.empty() ? DE_NULL : &subpasses[0]),
1202 (deUint32)dependencies.size(),
1203 (dependencies.empty() ? DE_NULL : &dependencies[0])
1206 return createRenderPass(vk, device, &createInfo);
1210 Move<VkFramebuffer> createFramebuffer (const DeviceInterface& vk,
1212 VkRenderPass renderPass,
1214 const vector<VkImageView>& attachments)
1216 return createFramebuffer(vk, device, 0u, renderPass, (deUint32)attachments.size(), attachments.empty() ? DE_NULL : &attachments[0], size.x(), size.y(), 1u);
1219 Move<VkImage> createAttachmentImage (const DeviceInterface& vk,
1221 deUint32 queueIndex,
1224 VkSampleCountFlagBits samples,
1225 VkImageUsageFlags usageFlags,
1226 VkImageLayout layout)
1228 VkImageUsageFlags targetUsageFlags = 0;
1229 const tcu::TextureFormat textureFormat = mapVkFormat(format);
1231 DE_ASSERT(!(tcu::hasDepthComponent(vk::mapVkFormat(format).order) || tcu::hasStencilComponent(vk::mapVkFormat(format).order))
1232 || ((usageFlags & vk::VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) == 0));
1234 DE_ASSERT((tcu::hasDepthComponent(vk::mapVkFormat(format).order) || tcu::hasStencilComponent(vk::mapVkFormat(format).order))
1235 || ((usageFlags & vk::VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0));
1237 if (tcu::hasDepthComponent(textureFormat.order) || tcu::hasStencilComponent(textureFormat.order))
1238 targetUsageFlags |= vk::VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
1240 targetUsageFlags |= vk::VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
1242 return createImage(vk, device,
1243 (VkImageCreateFlags)0,
1246 vk::makeExtent3D(size.x(), size.y(), 1u),
1250 VK_IMAGE_TILING_OPTIMAL,
1251 usageFlags | targetUsageFlags,
1252 VK_SHARING_MODE_EXCLUSIVE,
1258 de::MovePtr<Allocation> createImageMemory (const InstanceInterface& vki,
1259 const VkPhysicalDevice& vkd,
1260 const DeviceInterface& vk,
1262 Allocator& allocator,
1265 AllocationKind allocationKind)
1267 const MemoryRequirement memoryRequirement = lazy ? MemoryRequirement::LazilyAllocated : MemoryRequirement::Any;
1268 de::MovePtr<Allocation> allocation = allocateImage(vki, vk, vkd, device, image, memoryRequirement, allocator, allocationKind);
1270 bindImageMemory(vk, device, image, allocation->getMemory(), allocation->getOffset());
1275 Move<VkImageView> createImageAttachmentView (const DeviceInterface& vk,
1279 VkImageAspectFlags aspect)
1281 const VkImageSubresourceRange range =
1290 return createImageView(vk, device, 0u, image, VK_IMAGE_VIEW_TYPE_2D, format, makeComponentMappingRGBA(), range);
1293 VkClearValue randomClearValue (const Attachment& attachment, de::Random& rng)
1295 const float clearNan = tcu::Float32::nan().asFloat();
1296 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
1298 if (tcu::hasStencilComponent(format.order) || tcu::hasDepthComponent(format.order))
1300 VkClearValue clearValue;
1302 clearValue.depthStencil.depth = clearNan;
1303 clearValue.depthStencil.stencil = 0xCDu;
1305 if (tcu::hasStencilComponent(format.order))
1306 clearValue.depthStencil.stencil = rng.getBool()
1310 if (tcu::hasDepthComponent(format.order))
1311 clearValue.depthStencil.depth = rng.getBool()
1319 VkClearValue clearValue;
1321 clearValue.color = randomColorClearValue(attachment, rng);
1327 class AttachmentResources
1330 AttachmentResources (const InstanceInterface& vki,
1331 const VkPhysicalDevice& physDevice,
1332 const DeviceInterface& vk,
1334 Allocator& allocator,
1335 deUint32 queueIndex,
1337 const Attachment& attachmentInfo,
1338 VkImageUsageFlags usageFlags,
1339 const AllocationKind allocationKind)
1340 : m_image (createAttachmentImage(vk, device, queueIndex, size, attachmentInfo.getFormat(), attachmentInfo.getSamples(), usageFlags, VK_IMAGE_LAYOUT_UNDEFINED))
1341 , m_imageMemory (createImageMemory(vki, physDevice, vk, device, allocator, *m_image, ((usageFlags & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0), allocationKind))
1342 , m_attachmentView (createImageAttachmentView(vk, device, *m_image, attachmentInfo.getFormat(), getImageAspectFlags(attachmentInfo.getFormat())))
1344 const tcu::TextureFormat format = mapVkFormat(attachmentInfo.getFormat());
1345 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
1346 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
1348 if (isDepthFormat && isStencilFormat)
1350 m_depthInputAttachmentView = createImageAttachmentView(vk, device, *m_image, attachmentInfo.getFormat(), VK_IMAGE_ASPECT_DEPTH_BIT);
1351 m_stencilInputAttachmentView = createImageAttachmentView(vk, device, *m_image, attachmentInfo.getFormat(), VK_IMAGE_ASPECT_STENCIL_BIT);
1353 m_inputAttachmentViews = std::make_pair(*m_depthInputAttachmentView, *m_stencilInputAttachmentView);
1356 m_inputAttachmentViews = std::make_pair(*m_attachmentView, (vk::VkImageView)0u);
1358 if ((usageFlags & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)
1360 if (tcu::hasDepthComponent(format.order) && tcu::hasStencilComponent(format.order))
1362 const tcu::TextureFormat depthFormat = getDepthCopyFormat(attachmentInfo.getFormat());
1363 const tcu::TextureFormat stencilFormat = getStencilCopyFormat(attachmentInfo.getFormat());
1365 m_bufferSize = size.x() * size.y() * depthFormat.getPixelSize();
1366 m_secondaryBufferSize = size.x() * size.y() * stencilFormat.getPixelSize();
1368 m_buffer = createBuffer(vk, device, 0, m_bufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_SHARING_MODE_EXCLUSIVE, 1, &queueIndex);
1369 m_bufferMemory = allocateBuffer(vki, vk, physDevice, device, *m_buffer, MemoryRequirement::HostVisible, allocator, allocationKind);
1371 bindBufferMemory(vk, device, *m_buffer, m_bufferMemory->getMemory(), m_bufferMemory->getOffset());
1373 m_secondaryBuffer = createBuffer(vk, device, 0, m_secondaryBufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_SHARING_MODE_EXCLUSIVE, 1, &queueIndex);
1374 m_secondaryBufferMemory = allocateBuffer(vki, vk, physDevice, device, *m_secondaryBuffer, MemoryRequirement::HostVisible, allocator, allocationKind);
1376 bindBufferMemory(vk, device, *m_secondaryBuffer, m_secondaryBufferMemory->getMemory(), m_secondaryBufferMemory->getOffset());
1380 m_bufferSize = size.x() * size.y() * format.getPixelSize();
1382 m_buffer = createBuffer(vk, device, 0, m_bufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_SHARING_MODE_EXCLUSIVE, 1, &queueIndex);
1383 m_bufferMemory = allocateBuffer(vki, vk, physDevice, device, *m_buffer, MemoryRequirement::HostVisible, allocator, allocationKind);
1385 bindBufferMemory(vk, device, *m_buffer, m_bufferMemory->getMemory(), m_bufferMemory->getOffset());
1390 const pair<VkImageView, VkImageView>& getInputAttachmentViews (void) const
1392 return m_inputAttachmentViews;
1395 ~AttachmentResources (void)
1399 VkImageView getAttachmentView (void) const
1401 return *m_attachmentView;
1404 VkImage getImage (void) const
1409 VkBuffer getBuffer (void) const
1411 DE_ASSERT(*m_buffer != DE_NULL);
1415 VkDeviceSize getBufferSize (void) const
1417 DE_ASSERT(*m_buffer != DE_NULL);
1418 return m_bufferSize;
1421 const Allocation& getResultMemory (void) const
1423 DE_ASSERT(m_bufferMemory);
1424 return *m_bufferMemory;
1427 VkBuffer getSecondaryBuffer (void) const
1429 DE_ASSERT(*m_secondaryBuffer != DE_NULL);
1430 return *m_secondaryBuffer;
1433 VkDeviceSize getSecondaryBufferSize (void) const
1435 DE_ASSERT(*m_secondaryBuffer != DE_NULL);
1436 return m_secondaryBufferSize;
1439 const Allocation& getSecondaryResultMemory (void) const
1441 DE_ASSERT(m_secondaryBufferMemory);
1442 return *m_secondaryBufferMemory;
1446 const Unique<VkImage> m_image;
1447 const UniquePtr<Allocation> m_imageMemory;
1448 const Unique<VkImageView> m_attachmentView;
1450 Move<VkImageView> m_depthInputAttachmentView;
1451 Move<VkImageView> m_stencilInputAttachmentView;
1452 pair<VkImageView, VkImageView> m_inputAttachmentViews;
1454 Move<VkBuffer> m_buffer;
1455 VkDeviceSize m_bufferSize;
1456 de::MovePtr<Allocation> m_bufferMemory;
1458 Move<VkBuffer> m_secondaryBuffer;
1459 VkDeviceSize m_secondaryBufferSize;
1460 de::MovePtr<Allocation> m_secondaryBufferMemory;
1463 void uploadBufferData (const DeviceInterface& vk,
1465 const Allocation& memory,
1469 const VkMappedMemoryRange range =
1471 VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // sType;
1473 memory.getMemory(), // mem;
1474 memory.getOffset(), // offset;
1475 (VkDeviceSize)size // size;
1477 void* const ptr = memory.getHostPtr();
1479 deMemcpy(ptr, data, size);
1480 VK_CHECK(vk.flushMappedMemoryRanges(device, 1, &range));
1483 VkImageAspectFlagBits getPrimaryImageAspect (tcu::TextureFormat::ChannelOrder order)
1485 DE_STATIC_ASSERT(tcu::TextureFormat::CHANNELORDER_LAST == 21);
1489 case tcu::TextureFormat::D:
1490 case tcu::TextureFormat::DS:
1491 return VK_IMAGE_ASPECT_DEPTH_BIT;
1493 case tcu::TextureFormat::S:
1494 return VK_IMAGE_ASPECT_STENCIL_BIT;
1497 return VK_IMAGE_ASPECT_COLOR_BIT;
1504 RenderQuad (const Vec2& posA, const Vec2& posB)
1507 m_vertices[0] = posA;
1508 m_vertices[1] = Vec2(posA[0], posB[1]);
1509 m_vertices[2] = posB;
1511 m_vertices[3] = posB;
1512 m_vertices[4] = Vec2(posB[0], posA[1]);
1513 m_vertices[5] = posA;
1516 const Vec2& getCornerA (void) const
1518 return m_vertices[0];
1521 const Vec2& getCornerB (void) const
1523 return m_vertices[2];
1526 const void* getVertexPointer (void) const
1528 return &m_vertices[0];
1531 size_t getVertexDataSize (void) const
1533 return sizeof(Vec2) * m_vertices.size();
1537 vector<Vec2> m_vertices;
1543 ColorClear (const UVec2& offset,
1545 const VkClearColorValue& color)
1552 const UVec2& getOffset (void) const { return m_offset; }
1553 const UVec2& getSize (void) const { return m_size; }
1554 const VkClearColorValue& getColor (void) const { return m_color; }
1559 VkClearColorValue m_color;
1562 class DepthStencilClear
1565 DepthStencilClear (const UVec2& offset,
1572 , m_stencil (stencil)
1576 const UVec2& getOffset (void) const { return m_offset; }
1577 const UVec2& getSize (void) const { return m_size; }
1578 float getDepth (void) const { return m_depth; }
1579 deUint32 getStencil (void) const { return m_stencil; }
1582 const UVec2 m_offset;
1585 const float m_depth;
1586 const deUint32 m_stencil;
1589 class SubpassRenderInfo
1592 SubpassRenderInfo (const RenderPass& renderPass,
1593 deUint32 subpassIndex,
1597 const UVec2& viewportOffset,
1598 const UVec2& viewportSize,
1600 const Maybe<RenderQuad>& renderQuad,
1601 const vector<ColorClear>& colorClears,
1602 const Maybe<DepthStencilClear>& depthStencilClear)
1603 : m_viewportOffset (viewportOffset)
1604 , m_viewportSize (viewportSize)
1605 , m_subpassIndex (subpassIndex)
1606 , m_isSecondary (isSecondary_)
1607 , m_flags (renderPass.getSubpasses()[subpassIndex].getFlags())
1608 , m_renderQuad (renderQuad)
1609 , m_colorClears (colorClears)
1610 , m_depthStencilClear (depthStencilClear)
1611 , m_colorAttachments (renderPass.getSubpasses()[subpassIndex].getColorAttachments())
1612 , m_inputAttachments (renderPass.getSubpasses()[subpassIndex].getInputAttachments())
1614 for (deUint32 attachmentNdx = 0; attachmentNdx < (deUint32)m_colorAttachments.size(); attachmentNdx++)
1615 m_colorAttachmentInfo.push_back(renderPass.getAttachments()[m_colorAttachments[attachmentNdx].getAttachment()]);
1617 if (renderPass.getSubpasses()[subpassIndex].getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
1619 m_depthStencilAttachment = tcu::just(renderPass.getSubpasses()[subpassIndex].getDepthStencilAttachment());
1620 m_depthStencilAttachmentInfo = tcu::just(renderPass.getAttachments()[renderPass.getSubpasses()[subpassIndex].getDepthStencilAttachment().getAttachment()]);
1624 const UVec2& getViewportOffset (void) const { return m_viewportOffset; }
1625 const UVec2& getViewportSize (void) const { return m_viewportSize; }
1627 deUint32 getSubpassIndex (void) const { return m_subpassIndex; }
1628 bool isSecondary (void) const { return m_isSecondary; }
1630 const Maybe<RenderQuad>& getRenderQuad (void) const { return m_renderQuad; }
1631 const vector<ColorClear>& getColorClears (void) const { return m_colorClears; }
1632 const Maybe<DepthStencilClear>& getDepthStencilClear (void) const { return m_depthStencilClear; }
1634 deUint32 getInputAttachmentCount (void) const { return (deUint32)m_inputAttachments.size(); }
1635 deUint32 getInputAttachmentIndex (deUint32 attachmentNdx) const { return m_inputAttachments[attachmentNdx].getAttachment(); }
1636 VkImageLayout getInputAttachmentLayout (deUint32 attachmentNdx) const { return m_inputAttachments[attachmentNdx].getImageLayout(); }
1638 deUint32 getColorAttachmentCount (void) const { return (deUint32)m_colorAttachments.size(); }
1639 VkImageLayout getColorAttachmentLayout (deUint32 attachmentNdx) const { return m_colorAttachments[attachmentNdx].getImageLayout(); }
1640 deUint32 getColorAttachmentIndex (deUint32 attachmentNdx) const { return m_colorAttachments[attachmentNdx].getAttachment(); }
1641 const Attachment& getColorAttachment (deUint32 attachmentNdx) const { return m_colorAttachmentInfo[attachmentNdx]; }
1642 Maybe<VkImageLayout> getDepthStencilAttachmentLayout (void) const { return m_depthStencilAttachment ? tcu::just(m_depthStencilAttachment->getImageLayout()) : tcu::nothing<VkImageLayout>(); }
1643 Maybe<deUint32> getDepthStencilAttachmentIndex (void) const { return m_depthStencilAttachment ? tcu::just(m_depthStencilAttachment->getAttachment()) : tcu::nothing<deUint32>(); };
1644 const Maybe<Attachment>& getDepthStencilAttachment (void) const { return m_depthStencilAttachmentInfo; }
1645 VkSubpassDescriptionFlags getSubpassFlags (void) const { return m_flags; }
1648 UVec2 m_viewportOffset;
1649 UVec2 m_viewportSize;
1651 deUint32 m_subpassIndex;
1653 VkSubpassDescriptionFlags m_flags;
1655 Maybe<RenderQuad> m_renderQuad;
1656 vector<ColorClear> m_colorClears;
1657 Maybe<DepthStencilClear> m_depthStencilClear;
1659 vector<AttachmentReference> m_colorAttachments;
1660 vector<Attachment> m_colorAttachmentInfo;
1662 Maybe<AttachmentReference> m_depthStencilAttachment;
1663 Maybe<Attachment> m_depthStencilAttachmentInfo;
1665 vector<AttachmentReference> m_inputAttachments;
1668 Move<VkPipeline> createSubpassPipeline (const DeviceInterface& vk,
1670 VkRenderPass renderPass,
1671 VkShaderModule vertexShaderModule,
1672 VkShaderModule fragmentShaderModule,
1673 VkPipelineLayout pipelineLayout,
1674 const SubpassRenderInfo& renderInfo)
1676 const VkSpecializationInfo emptyShaderSpecializations =
1678 0u, // mapEntryCount
1684 Maybe<VkSampleCountFlagBits> rasterSamples;
1685 vector<VkPipelineColorBlendAttachmentState> attachmentBlendStates;
1687 for (deUint32 attachmentNdx = 0; attachmentNdx < renderInfo.getColorAttachmentCount(); attachmentNdx++)
1689 const Attachment& attachment = renderInfo.getColorAttachment(attachmentNdx);
1691 DE_ASSERT(!rasterSamples || *rasterSamples == attachment.getSamples());
1693 rasterSamples = attachment.getSamples();
1696 const VkPipelineColorBlendAttachmentState attachmentBlendState =
1698 VK_FALSE, // blendEnable
1699 VK_BLEND_FACTOR_SRC_ALPHA, // srcBlendColor
1700 VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, // destBlendColor
1701 VK_BLEND_OP_ADD, // blendOpColor
1702 VK_BLEND_FACTOR_ONE, // srcBlendAlpha
1703 VK_BLEND_FACTOR_ONE, // destBlendAlpha
1704 VK_BLEND_OP_ADD, // blendOpAlpha
1705 VK_COLOR_COMPONENT_R_BIT|VK_COLOR_COMPONENT_G_BIT|VK_COLOR_COMPONENT_B_BIT|VK_COLOR_COMPONENT_A_BIT, // channelWriteMask
1708 attachmentBlendStates.push_back(attachmentBlendState);
1712 if (renderInfo.getDepthStencilAttachment())
1714 const Attachment& attachment = *renderInfo.getDepthStencilAttachment();
1716 DE_ASSERT(!rasterSamples || *rasterSamples == attachment.getSamples());
1717 rasterSamples = attachment.getSamples();
1720 // If there are no attachment use single sample
1722 rasterSamples = VK_SAMPLE_COUNT_1_BIT;
1724 const VkPipelineShaderStageCreateInfo shaderStages[2] =
1727 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // sType
1729 (VkPipelineShaderStageCreateFlags)0u,
1730 VK_SHADER_STAGE_VERTEX_BIT, // stage
1731 vertexShaderModule, // shader
1733 &emptyShaderSpecializations
1736 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // sType
1738 (VkPipelineShaderStageCreateFlags)0u,
1739 VK_SHADER_STAGE_FRAGMENT_BIT, // stage
1740 fragmentShaderModule, // shader
1742 &emptyShaderSpecializations
1745 const VkVertexInputBindingDescription vertexBinding =
1748 (deUint32)sizeof(tcu::Vec2), // strideInBytes
1749 VK_VERTEX_INPUT_RATE_VERTEX, // stepRate
1751 const VkVertexInputAttributeDescription vertexAttrib =
1755 VK_FORMAT_R32G32_SFLOAT, // format
1756 0u, // offsetInBytes
1758 const VkPipelineVertexInputStateCreateInfo vertexInputState =
1760 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // sType
1762 (VkPipelineVertexInputStateCreateFlags)0u,
1764 &vertexBinding, // pVertexBindingDescriptions
1765 1u, // attributeCount
1766 &vertexAttrib, // pVertexAttributeDescriptions
1768 const VkPipelineInputAssemblyStateCreateInfo inputAssemblyState =
1770 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, // sType
1772 (VkPipelineInputAssemblyStateCreateFlags)0u,
1773 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, // topology
1774 VK_FALSE, // primitiveRestartEnable
1776 const VkViewport viewport =
1778 (float)renderInfo.getViewportOffset().x(), (float)renderInfo.getViewportOffset().y(),
1779 (float)renderInfo.getViewportSize().x(), (float)renderInfo.getViewportSize().y(),
1782 const VkRect2D scissor =
1784 { (deInt32)renderInfo.getViewportOffset().x(), (deInt32)renderInfo.getViewportOffset().y() },
1785 { renderInfo.getViewportSize().x(), renderInfo.getViewportSize().y() }
1787 const VkPipelineViewportStateCreateInfo viewportState =
1789 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
1791 (VkPipelineViewportStateCreateFlags)0u,
1797 const VkPipelineRasterizationStateCreateInfo rasterState =
1799 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, // sType
1801 (VkPipelineRasterizationStateCreateFlags)0u,
1802 VK_TRUE, // depthClipEnable
1803 VK_FALSE, // rasterizerDiscardEnable
1804 VK_POLYGON_MODE_FILL, // fillMode
1805 VK_CULL_MODE_NONE, // cullMode
1806 VK_FRONT_FACE_COUNTER_CLOCKWISE, // frontFace
1807 VK_FALSE, // depthBiasEnable
1809 0.0f, // depthBiasClamp
1810 0.0f, // slopeScaledDepthBias
1813 const VkPipelineMultisampleStateCreateInfo multisampleState =
1815 VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, // sType
1817 (VkPipelineMultisampleStateCreateFlags)0u,
1818 *rasterSamples, // rasterSamples
1819 VK_FALSE, // sampleShadingEnable
1820 0.0f, // minSampleShading
1821 DE_NULL, // pSampleMask
1822 VK_FALSE, // alphaToCoverageEnable
1823 VK_FALSE, // alphaToOneEnable
1825 const size_t stencilIndex = renderInfo.getSubpassIndex();
1826 const VkBool32 writeDepth = renderInfo.getDepthStencilAttachmentLayout()
1827 && *renderInfo.getDepthStencilAttachmentLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
1828 && *renderInfo.getDepthStencilAttachmentLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR
1831 const VkBool32 writeStencil = renderInfo.getDepthStencilAttachmentLayout()
1832 && *renderInfo.getDepthStencilAttachmentLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
1833 && *renderInfo.getDepthStencilAttachmentLayout() != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR
1836 const VkPipelineDepthStencilStateCreateInfo depthStencilState =
1838 VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, // sType
1840 (VkPipelineDepthStencilStateCreateFlags)0u,
1841 writeDepth, // depthTestEnable
1842 writeDepth, // depthWriteEnable
1843 VK_COMPARE_OP_ALWAYS, // depthCompareOp
1844 VK_FALSE, // depthBoundsEnable
1845 writeStencil, // stencilTestEnable
1847 VK_STENCIL_OP_REPLACE, // stencilFailOp
1848 VK_STENCIL_OP_REPLACE, // stencilPassOp
1849 VK_STENCIL_OP_REPLACE, // stencilDepthFailOp
1850 VK_COMPARE_OP_ALWAYS, // stencilCompareOp
1851 ~0u, // stencilCompareMask
1852 ~0u, // stencilWriteMask
1853 ((stencilIndex % 2) == 0) ? ~0x0u : 0x0u // stencilReference
1856 VK_STENCIL_OP_REPLACE, // stencilFailOp
1857 VK_STENCIL_OP_REPLACE, // stencilPassOp
1858 VK_STENCIL_OP_REPLACE, // stencilDepthFailOp
1859 VK_COMPARE_OP_ALWAYS, // stencilCompareOp
1860 ~0u, // stencilCompareMask
1861 ~0u, // stencilWriteMask
1862 ((stencilIndex % 2) == 0) ? ~0x0u : 0x0u // stencilReference
1865 0.0f, // minDepthBounds;
1866 1.0f // maxDepthBounds;
1868 const VkPipelineColorBlendStateCreateInfo blendState =
1870 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // sType
1872 (VkPipelineColorBlendStateCreateFlags)0u,
1873 VK_FALSE, // logicOpEnable
1874 VK_LOGIC_OP_COPY, // logicOp
1875 (deUint32)attachmentBlendStates.size(), // attachmentCount
1876 attachmentBlendStates.empty() ? DE_NULL : &attachmentBlendStates[0],// pAttachments
1877 { 0.0f, 0.0f, 0.0f, 0.0f } // blendConst
1879 const VkGraphicsPipelineCreateInfo createInfo =
1881 VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, // sType
1883 (VkPipelineCreateFlags)0u,
1886 shaderStages, // pStages
1888 &vertexInputState, // pVertexInputState
1889 &inputAssemblyState, // pInputAssemblyState
1890 DE_NULL, // pTessellationState
1891 &viewportState, // pViewportState
1892 &rasterState, // pRasterState
1893 &multisampleState, // pMultisampleState
1894 &depthStencilState, // pDepthStencilState
1895 &blendState, // pColorBlendState
1896 (const VkPipelineDynamicStateCreateInfo*)DE_NULL, // pDynamicState
1897 pipelineLayout, // layout
1899 renderPass, // renderPass
1900 renderInfo.getSubpassIndex(), // subpass
1901 DE_NULL, // basePipelineHandle
1902 0u // basePipelineIndex
1905 return createGraphicsPipeline(vk, device, DE_NULL, &createInfo);
1908 class SubpassRenderer
1911 SubpassRenderer (Context& context,
1912 const DeviceInterface& vk,
1914 Allocator& allocator,
1915 VkRenderPass renderPass,
1916 VkFramebuffer framebuffer,
1917 VkCommandPool commandBufferPool,
1918 deUint32 queueFamilyIndex,
1919 const vector<VkImage>& attachmentImages,
1920 const vector<pair<VkImageView, VkImageView> >& attachmentViews,
1921 const SubpassRenderInfo& renderInfo,
1922 const vector<Attachment>& attachmentInfos,
1923 const AllocationKind allocationKind)
1924 : m_renderInfo (renderInfo)
1926 const InstanceInterface& vki = context.getInstanceInterface();
1927 const VkPhysicalDevice& physDevice = context.getPhysicalDevice();
1928 const deUint32 subpassIndex = renderInfo.getSubpassIndex();
1929 vector<VkDescriptorSetLayoutBinding> bindings;
1931 for (deUint32 colorAttachmentNdx = 0; colorAttachmentNdx < renderInfo.getColorAttachmentCount(); colorAttachmentNdx++)
1932 m_colorAttachmentImages.push_back(attachmentImages[renderInfo.getColorAttachmentIndex(colorAttachmentNdx)]);
1934 if (renderInfo.getDepthStencilAttachmentIndex())
1935 m_depthStencilAttachmentImage = attachmentImages[*renderInfo.getDepthStencilAttachmentIndex()];
1937 if (renderInfo.getRenderQuad())
1939 const RenderQuad& renderQuad = *renderInfo.getRenderQuad();
1941 if (renderInfo.getInputAttachmentCount() > 0)
1943 deUint32 bindingIndex = 0;
1945 for (deUint32 inputAttachmentNdx = 0; inputAttachmentNdx < renderInfo.getInputAttachmentCount(); inputAttachmentNdx++)
1947 const Attachment attachmentInfo = attachmentInfos[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)];
1948 const VkImageLayout layout = renderInfo.getInputAttachmentLayout(inputAttachmentNdx);
1949 const tcu::TextureFormat format = mapVkFormat(attachmentInfo.getFormat());
1950 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
1951 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
1952 const deUint32 bindingCount = (isDepthFormat && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
1953 && (isStencilFormat && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR)
1957 for (deUint32 bindingNdx = 0; bindingNdx < bindingCount; bindingNdx++)
1959 const VkDescriptorSetLayoutBinding binding =
1962 vk::VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
1964 vk::VK_SHADER_STAGE_FRAGMENT_BIT,
1968 bindings.push_back(binding);
1973 const VkDescriptorSetLayoutCreateInfo createInfo =
1975 vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
1979 (deUint32)bindings.size(),
1983 m_descriptorSetLayout = vk::createDescriptorSetLayout(vk, device, &createInfo);
1986 const VkDescriptorSetLayout descriptorSetLayout = *m_descriptorSetLayout;
1987 const VkPipelineLayoutCreateInfo pipelineLayoutParams =
1989 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // sType;
1991 (vk::VkPipelineLayoutCreateFlags)0,
1992 m_descriptorSetLayout ? 1u :0u , // setLayoutCount;
1993 m_descriptorSetLayout ? &descriptorSetLayout : DE_NULL, // pSetLayouts;
1994 0u, // pushConstantRangeCount;
1995 DE_NULL, // pPushConstantRanges;
1998 m_vertexShaderModule = createShaderModule(vk, device, context.getBinaryCollection().get(de::toString(subpassIndex) + "-vert"), 0u);
1999 m_fragmentShaderModule = createShaderModule(vk, device, context.getBinaryCollection().get(de::toString(subpassIndex) + "-frag"), 0u);
2000 m_pipelineLayout = createPipelineLayout(vk, device, &pipelineLayoutParams);
2001 m_pipeline = createSubpassPipeline(vk, device, renderPass, *m_vertexShaderModule, *m_fragmentShaderModule, *m_pipelineLayout, m_renderInfo);
2003 m_vertexBuffer = createBuffer(vk, device, 0u, (VkDeviceSize)renderQuad.getVertexDataSize(), VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, VK_SHARING_MODE_EXCLUSIVE, 1u, &queueFamilyIndex);
2004 m_vertexBufferMemory = allocateBuffer(vki, vk, physDevice, device, *m_vertexBuffer, MemoryRequirement::HostVisible, allocator, allocationKind);
2006 bindBufferMemory(vk, device, *m_vertexBuffer, m_vertexBufferMemory->getMemory(), m_vertexBufferMemory->getOffset());
2007 uploadBufferData(vk, device, *m_vertexBufferMemory, renderQuad.getVertexDataSize(), renderQuad.getVertexPointer());
2009 if (renderInfo.getInputAttachmentCount() > 0)
2012 const VkDescriptorPoolSize poolSize =
2014 vk::VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2015 // \note Reserve 2 per input attachment since depthStencil attachments require 2.
2016 renderInfo.getInputAttachmentCount() * 2u
2018 const VkDescriptorPoolCreateInfo createInfo =
2020 vk::VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
2022 VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
2024 // \note Reserve 2 per input attachment since depthStencil attachments require 2.
2025 renderInfo.getInputAttachmentCount() * 2u,
2030 m_descriptorPool = vk::createDescriptorPool(vk, device, &createInfo);
2033 const VkDescriptorSetAllocateInfo allocateInfo =
2035 vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
2040 &descriptorSetLayout
2043 m_descriptorSet = vk::allocateDescriptorSet(vk, device, &allocateInfo);
2046 vector<VkWriteDescriptorSet> writes (bindings.size());
2047 vector<VkDescriptorImageInfo> imageInfos (bindings.size());
2048 deUint32 bindingIndex = 0;
2050 for (deUint32 inputAttachmentNdx = 0; inputAttachmentNdx < renderInfo.getInputAttachmentCount(); inputAttachmentNdx++)
2052 const Attachment attachmentInfo = attachmentInfos[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)];
2053 const tcu::TextureFormat format = mapVkFormat(attachmentInfo.getFormat());
2054 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
2055 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
2056 const VkImageLayout inputAttachmentLayout = renderInfo.getInputAttachmentLayout(inputAttachmentNdx);
2059 if (isDepthFormat && isStencilFormat)
2061 if (inputAttachmentLayout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR)
2063 const VkDescriptorImageInfo imageInfo =
2066 attachmentViews[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)].first,
2067 inputAttachmentLayout
2069 imageInfos[bindingIndex] = imageInfo;
2072 const VkWriteDescriptorSet write =
2074 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2081 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2082 &imageInfos[bindingIndex],
2086 writes[bindingIndex] = write;
2092 if (inputAttachmentLayout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
2094 const VkDescriptorImageInfo imageInfo =
2097 attachmentViews[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)].second,
2098 inputAttachmentLayout
2100 imageInfos[bindingIndex] = imageInfo;
2103 const VkWriteDescriptorSet write =
2105 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2112 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2113 &imageInfos[bindingIndex],
2117 writes[bindingIndex] = write;
2125 const VkDescriptorImageInfo imageInfo =
2128 attachmentViews[renderInfo.getInputAttachmentIndex(inputAttachmentNdx)].first,
2129 inputAttachmentLayout
2131 imageInfos[bindingIndex] = imageInfo;
2134 const VkWriteDescriptorSet write =
2136 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2143 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2144 &imageInfos[bindingIndex],
2148 writes[bindingIndex] = write;
2155 vk.updateDescriptorSets(device, (deUint32)writes.size(), &writes[0], 0u, DE_NULL);
2160 if (renderInfo.isSecondary())
2162 m_commandBuffer = allocateCommandBuffer(vk, device, commandBufferPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
2164 beginCommandBuffer(vk, *m_commandBuffer, vk::VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, renderPass, subpassIndex, framebuffer, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0);
2165 pushRenderCommands(vk, *m_commandBuffer);
2166 endCommandBuffer(vk, *m_commandBuffer);
2170 bool isSecondary (void) const
2172 return m_commandBuffer;
2175 VkCommandBuffer getCommandBuffer (void) const
2177 DE_ASSERT(isSecondary());
2178 return *m_commandBuffer;
2181 void pushRenderCommands (const DeviceInterface& vk,
2182 VkCommandBuffer commandBuffer)
2184 if (!m_renderInfo.getColorClears().empty())
2186 const vector<ColorClear>& colorClears (m_renderInfo.getColorClears());
2188 for (deUint32 attachmentNdx = 0; attachmentNdx < m_renderInfo.getColorAttachmentCount(); attachmentNdx++)
2190 const ColorClear& colorClear = colorClears[attachmentNdx];
2191 const VkClearAttachment attachment =
2193 VK_IMAGE_ASPECT_COLOR_BIT,
2195 makeClearValue(colorClear.getColor()),
2197 const VkClearRect rect =
2200 { (deInt32)colorClear.getOffset().x(), (deInt32)colorClear.getOffset().y() },
2201 { colorClear.getSize().x(), colorClear.getSize().y() }
2203 0u, // baseArrayLayer
2207 vk.cmdClearAttachments(commandBuffer, 1u, &attachment, 1u, &rect);
2211 if (m_renderInfo.getDepthStencilClear())
2213 const DepthStencilClear& depthStencilClear = *m_renderInfo.getDepthStencilClear();
2214 const deUint32 attachmentNdx = m_renderInfo.getColorAttachmentCount();
2215 tcu::TextureFormat format = mapVkFormat(m_renderInfo.getDepthStencilAttachment()->getFormat());
2216 const VkImageLayout layout = *m_renderInfo.getDepthStencilAttachmentLayout();
2217 const VkClearAttachment attachment =
2219 (VkImageAspectFlags)((hasDepthComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR ? VK_IMAGE_ASPECT_DEPTH_BIT : 0)
2220 | (hasStencilComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR ? VK_IMAGE_ASPECT_STENCIL_BIT : 0)),
2222 makeClearValueDepthStencil(depthStencilClear.getDepth(), depthStencilClear.getStencil())
2224 const VkClearRect rect =
2227 { (deInt32)depthStencilClear.getOffset().x(), (deInt32)depthStencilClear.getOffset().y() },
2228 { depthStencilClear.getSize().x(), depthStencilClear.getSize().y() }
2230 0u, // baseArrayLayer
2234 if ((tcu::hasDepthComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
2235 || (tcu::hasStencilComponent(format.order) && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR))
2237 vk.cmdClearAttachments(commandBuffer, 1u, &attachment, 1u, &rect);
2241 vector<VkImageMemoryBarrier> selfDeps;
2242 VkPipelineStageFlags srcStages = 0;
2243 VkPipelineStageFlags dstStages = 0;
2245 for (deUint32 inputAttachmentNdx = 0; inputAttachmentNdx < m_renderInfo.getInputAttachmentCount(); inputAttachmentNdx++)
2247 for (deUint32 colorAttachmentNdx = 0; colorAttachmentNdx < m_renderInfo.getColorAttachmentCount(); colorAttachmentNdx++)
2249 if (m_renderInfo.getInputAttachmentIndex(inputAttachmentNdx) == m_renderInfo.getColorAttachmentIndex(colorAttachmentNdx))
2251 const VkImageMemoryBarrier barrier =
2253 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2256 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // srcAccessMask
2257 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT, // dstAccessMask
2259 VK_IMAGE_LAYOUT_GENERAL, // oldLayout
2260 VK_IMAGE_LAYOUT_GENERAL, // newLayout
2262 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex
2263 VK_QUEUE_FAMILY_IGNORED, // destQueueFamilyIndex
2265 m_colorAttachmentImages[colorAttachmentNdx], // image
2266 { // subresourceRange
2267 VK_IMAGE_ASPECT_COLOR_BIT, // aspect
2270 0, // baseArraySlice
2275 srcStages |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
2276 dstStages |= VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
2278 selfDeps.push_back(barrier);
2282 if (m_renderInfo.getDepthStencilAttachmentIndex() && (m_renderInfo.getInputAttachmentIndex(inputAttachmentNdx) == *m_renderInfo.getDepthStencilAttachmentIndex()))
2284 const tcu::TextureFormat format = mapVkFormat(m_renderInfo.getDepthStencilAttachment()->getFormat());
2285 const bool hasDepth = hasDepthComponent(format.order);
2286 const bool hasStencil = hasStencilComponent(format.order);
2287 const VkImageMemoryBarrier barrier =
2289 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
2292 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, // srcAccessMask
2293 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT, // dstAccessMask
2295 VK_IMAGE_LAYOUT_GENERAL, // oldLayout
2296 VK_IMAGE_LAYOUT_GENERAL, // newLayout;
2298 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex;
2299 VK_QUEUE_FAMILY_IGNORED, // destQueueFamilyIndex;
2301 m_depthStencilAttachmentImage, // image;
2302 { // subresourceRange;
2303 (hasDepth ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
2304 | (hasStencil ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u), // aspect;
2307 0, // baseArraySlice;
2312 srcStages |= VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT;
2313 dstStages |= VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
2315 selfDeps.push_back(barrier);
2319 if (!selfDeps.empty())
2321 DE_ASSERT(srcStages != 0);
2322 DE_ASSERT(dstStages != 0);
2323 vk.cmdPipelineBarrier(commandBuffer, srcStages, dstStages, VK_DEPENDENCY_BY_REGION_BIT, 0, DE_NULL, 0, DE_NULL, (deUint32)selfDeps.size(), &selfDeps[0]);
2326 if (m_renderInfo.getRenderQuad())
2328 const VkDeviceSize offset = 0;
2329 const VkBuffer vertexBuffer = *m_vertexBuffer;
2331 vk.cmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline);
2333 if (m_descriptorSet)
2335 const VkDescriptorSet descriptorSet = *m_descriptorSet;
2336 vk.cmdBindDescriptorSets(commandBuffer, vk::VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipelineLayout, 0u, 1u, &descriptorSet, 0u, NULL);
2339 vk.cmdBindVertexBuffers(commandBuffer, 0u, 1u, &vertexBuffer, &offset);
2340 vk.cmdDraw(commandBuffer, 6u, 1u, 0u, 0u);
2345 const SubpassRenderInfo m_renderInfo;
2346 Move<VkCommandBuffer> m_commandBuffer;
2347 Move<VkPipeline> m_pipeline;
2348 Move<VkDescriptorSetLayout> m_descriptorSetLayout;
2349 Move<VkPipelineLayout> m_pipelineLayout;
2351 Move<VkShaderModule> m_vertexShaderModule;
2352 Move<VkShaderModule> m_fragmentShaderModule;
2354 Move<VkDescriptorPool> m_descriptorPool;
2355 Move<VkDescriptorSet> m_descriptorSet;
2356 Move<VkBuffer> m_vertexBuffer;
2357 de::MovePtr<Allocation> m_vertexBufferMemory;
2358 vector<VkImage> m_colorAttachmentImages;
2359 VkImage m_depthStencilAttachmentImage;
2362 void pushImageInitializationCommands (const DeviceInterface& vk,
2363 VkCommandBuffer commandBuffer,
2364 const vector<Attachment>& attachmentInfo,
2365 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
2366 deUint32 queueIndex,
2367 const vector<Maybe<VkClearValue> >& clearValues)
2370 vector<VkImageMemoryBarrier> initializeLayouts;
2372 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2374 if (!clearValues[attachmentNdx])
2377 const VkImageMemoryBarrier barrier =
2379 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
2382 (VkAccessFlags)0, // srcAccessMask
2383 getAllMemoryReadFlags() | VK_ACCESS_TRANSFER_WRITE_BIT, // dstAccessMask
2385 VK_IMAGE_LAYOUT_UNDEFINED, // oldLayout
2386 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // newLayout;
2388 queueIndex, // srcQueueFamilyIndex;
2389 queueIndex, // destQueueFamilyIndex;
2391 attachmentResources[attachmentNdx]->getImage(), // image;
2392 { // subresourceRange;
2393 getImageAspectFlags(attachmentInfo[attachmentNdx].getFormat()), // aspect;
2396 0, // baseArraySlice;
2401 initializeLayouts.push_back(barrier);
2404 if (!initializeLayouts.empty())
2405 vk.cmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT,
2406 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, (VkDependencyFlags)0,
2407 0, (const VkMemoryBarrier*)DE_NULL,
2408 0, (const VkBufferMemoryBarrier*)DE_NULL,
2409 (deUint32)initializeLayouts.size(), &initializeLayouts[0]);
2412 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2414 if (!clearValues[attachmentNdx])
2417 const tcu::TextureFormat format = mapVkFormat(attachmentInfo[attachmentNdx].getFormat());
2419 if (hasStencilComponent(format.order) || hasDepthComponent(format.order))
2421 const float clearNan = tcu::Float32::nan().asFloat();
2422 const float clearDepth = hasDepthComponent(format.order) ? clearValues[attachmentNdx]->depthStencil.depth : clearNan;
2423 const deUint32 clearStencil = hasStencilComponent(format.order) ? clearValues[attachmentNdx]->depthStencil.stencil : 0xDEu;
2424 const VkClearDepthStencilValue depthStencil =
2429 const VkImageSubresourceRange range =
2431 (VkImageAspectFlags)((hasDepthComponent(format.order) ? VK_IMAGE_ASPECT_DEPTH_BIT : 0)
2432 | (hasStencilComponent(format.order) ? VK_IMAGE_ASPECT_STENCIL_BIT : 0)),
2439 vk.cmdClearDepthStencilImage(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &depthStencil, 1, &range);
2443 const VkImageSubresourceRange range =
2445 VK_IMAGE_ASPECT_COLOR_BIT, // aspectMask;
2448 0, // baseArrayLayer;
2451 const VkClearColorValue clearColor = clearValues[attachmentNdx]->color;
2453 vk.cmdClearColorImage(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clearColor, 1, &range);
2458 vector<VkImageMemoryBarrier> renderPassLayouts;
2460 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2462 const VkImageLayout oldLayout = clearValues[attachmentNdx] ? VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL : VK_IMAGE_LAYOUT_UNDEFINED;
2463 const VkImageMemoryBarrier barrier =
2465 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType;
2468 (oldLayout != VK_IMAGE_LAYOUT_UNDEFINED ? getAllMemoryWriteFlags() : (VkAccessFlags)0), // srcAccessMask
2469 getAllMemoryReadFlags() | getMemoryFlagsForLayout(attachmentInfo[attachmentNdx].getInitialLayout()), // dstAccessMask
2471 oldLayout, // oldLayout
2472 attachmentInfo[attachmentNdx].getInitialLayout(), // newLayout;
2474 queueIndex, // srcQueueFamilyIndex;
2475 queueIndex, // destQueueFamilyIndex;
2477 attachmentResources[attachmentNdx]->getImage(), // image;
2478 { // subresourceRange;
2479 getImageAspectFlags(attachmentInfo[attachmentNdx].getFormat()), // aspect;
2482 0, // baseArraySlice;
2487 renderPassLayouts.push_back(barrier);
2490 if (!renderPassLayouts.empty())
2491 vk.cmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT,
2492 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, (VkDependencyFlags)0,
2493 0, (const VkMemoryBarrier*)DE_NULL,
2494 0, (const VkBufferMemoryBarrier*)DE_NULL,
2495 (deUint32)renderPassLayouts.size(), &renderPassLayouts[0]);
2499 void pushRenderPassCommands (const DeviceInterface& vk,
2500 VkCommandBuffer commandBuffer,
2501 VkRenderPass renderPass,
2502 VkFramebuffer framebuffer,
2503 const vector<de::SharedPtr<SubpassRenderer> >& subpassRenderers,
2504 const UVec2& renderPos,
2505 const UVec2& renderSize,
2506 const vector<Maybe<VkClearValue> >& renderPassClearValues,
2507 TestConfig::RenderTypes render)
2509 const float clearNan = tcu::Float32::nan().asFloat();
2510 vector<VkClearValue> attachmentClearValues;
2512 for (size_t attachmentNdx = 0; attachmentNdx < renderPassClearValues.size(); attachmentNdx++)
2514 if (renderPassClearValues[attachmentNdx])
2515 attachmentClearValues.push_back(*renderPassClearValues[attachmentNdx]);
2517 attachmentClearValues.push_back(makeClearValueColorF32(clearNan, clearNan, clearNan, clearNan));
2521 const VkRect2D renderArea =
2523 { (deInt32)renderPos.x(), (deInt32)renderPos.y() },
2524 { renderSize.x(), renderSize.y() }
2527 for (size_t subpassNdx = 0; subpassNdx < subpassRenderers.size(); subpassNdx++)
2529 const VkSubpassContents contents = subpassRenderers[subpassNdx]->isSecondary() ? VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS : VK_SUBPASS_CONTENTS_INLINE;
2531 if (subpassNdx == 0)
2532 cmdBeginRenderPass(vk, commandBuffer, renderPass, framebuffer, renderArea, (deUint32)attachmentClearValues.size(), attachmentClearValues.empty() ? DE_NULL : &attachmentClearValues[0], contents);
2534 vk.cmdNextSubpass(commandBuffer, contents);
2538 if (contents == VK_SUBPASS_CONTENTS_INLINE)
2540 subpassRenderers[subpassNdx]->pushRenderCommands(vk, commandBuffer);
2542 else if (contents == VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS)
2544 const VkCommandBuffer cmd = subpassRenderers[subpassNdx]->getCommandBuffer();
2545 vk.cmdExecuteCommands(commandBuffer, 1, &cmd);
2548 DE_FATAL("Invalid contents");
2552 vk.cmdEndRenderPass(commandBuffer);
2556 void pushReadImagesToBuffers (const DeviceInterface& vk,
2557 VkCommandBuffer commandBuffer,
2558 deUint32 queueIndex,
2560 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
2561 const vector<Attachment>& attachmentInfo,
2562 const vector<bool>& isLazy,
2564 const UVec2& targetSize)
2567 vector<VkImageMemoryBarrier> imageBarriers;
2569 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2571 if (isLazy[attachmentNdx])
2574 const VkImageLayout oldLayout = attachmentInfo[attachmentNdx].getFinalLayout();
2575 const VkImageMemoryBarrier barrier =
2577 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
2580 getAllMemoryWriteFlags() | getMemoryFlagsForLayout(oldLayout), // srcAccessMask
2581 getAllMemoryReadFlags(), // dstAccessMask
2583 oldLayout, // oldLayout
2584 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, // newLayout
2586 queueIndex, // srcQueueFamilyIndex
2587 queueIndex, // destQueueFamilyIndex
2589 attachmentResources[attachmentNdx]->getImage(), // image
2590 { // subresourceRange
2591 getImageAspectFlags(attachmentInfo[attachmentNdx].getFormat()), // aspect;
2594 0, // baseArraySlice
2599 imageBarriers.push_back(barrier);
2602 if (!imageBarriers.empty())
2603 vk.cmdPipelineBarrier(commandBuffer,
2604 getAllPipelineStageFlags(),
2605 getAllPipelineStageFlags(),
2606 (VkDependencyFlags)0,
2607 0, (const VkMemoryBarrier*)DE_NULL,
2608 0, (const VkBufferMemoryBarrier*)DE_NULL,
2609 (deUint32)imageBarriers.size(), &imageBarriers[0]);
2612 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2614 if (isLazy[attachmentNdx])
2617 const tcu::TextureFormat::ChannelOrder order = mapVkFormat(attachmentInfo[attachmentNdx].getFormat()).order;
2618 const VkBufferImageCopy rect =
2621 0, // bufferRowLength
2622 0, // bufferImageHeight
2623 { // imageSubresource
2624 (vk::VkImageAspectFlags)getPrimaryImageAspect(mapVkFormat(attachmentInfo[attachmentNdx].getFormat()).order), // aspect
2629 { 0, 0, 0 }, // imageOffset
2630 { targetSize.x(), targetSize.y(), 1u } // imageExtent
2633 vk.cmdCopyImageToBuffer(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, attachmentResources[attachmentNdx]->getBuffer(), 1, &rect);
2635 if (tcu::TextureFormat::DS == order)
2637 const VkBufferImageCopy stencilRect =
2640 0, // bufferRowLength
2641 0, // bufferImageHeight
2642 { // imageSubresource
2643 VK_IMAGE_ASPECT_STENCIL_BIT, // aspect
2648 { 0, 0, 0 }, // imageOffset
2649 { targetSize.x(), targetSize.y(), 1u } // imageExtent
2652 vk.cmdCopyImageToBuffer(commandBuffer, attachmentResources[attachmentNdx]->getImage(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, attachmentResources[attachmentNdx]->getSecondaryBuffer(), 1, &stencilRect);
2657 vector<VkBufferMemoryBarrier> bufferBarriers;
2659 for (size_t attachmentNdx = 0; attachmentNdx < attachmentInfo.size(); attachmentNdx++)
2661 if (isLazy[attachmentNdx])
2664 const tcu::TextureFormat::ChannelOrder order = mapVkFormat(attachmentInfo[attachmentNdx].getFormat()).order;
2665 const VkBufferMemoryBarrier bufferBarrier =
2667 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
2670 getAllMemoryWriteFlags(),
2671 getAllMemoryReadFlags(),
2676 attachmentResources[attachmentNdx]->getBuffer(),
2678 attachmentResources[attachmentNdx]->getBufferSize()
2681 bufferBarriers.push_back(bufferBarrier);
2683 if (tcu::TextureFormat::DS == order)
2685 const VkBufferMemoryBarrier secondaryBufferBarrier =
2687 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
2690 getAllMemoryWriteFlags(),
2691 getAllMemoryReadFlags(),
2696 attachmentResources[attachmentNdx]->getSecondaryBuffer(),
2698 attachmentResources[attachmentNdx]->getSecondaryBufferSize()
2701 bufferBarriers.push_back(secondaryBufferBarrier);
2705 if (!bufferBarriers.empty())
2706 vk.cmdPipelineBarrier(commandBuffer,
2707 getAllPipelineStageFlags(),
2708 getAllPipelineStageFlags(),
2709 (VkDependencyFlags)0,
2710 0, (const VkMemoryBarrier*)DE_NULL,
2711 (deUint32)bufferBarriers.size(), &bufferBarriers[0],
2712 0, (const VkImageMemoryBarrier*)DE_NULL);
2719 PixelValue (const Maybe<bool>& x = nothing<bool>(),
2720 const Maybe<bool>& y = nothing<bool>(),
2721 const Maybe<bool>& z = nothing<bool>(),
2722 const Maybe<bool>& w = nothing<bool>());
2724 void setUndefined (size_t ndx);
2725 void setValue (size_t ndx, bool value);
2726 Maybe<bool> getValue (size_t ndx) const;
2732 PixelValue::PixelValue (const Maybe<bool>& x,
2733 const Maybe<bool>& y,
2734 const Maybe<bool>& z,
2735 const Maybe<bool>& w)
2738 const Maybe<bool> values[] =
2743 for (size_t ndx = 0; ndx < DE_LENGTH_OF_ARRAY(values); ndx++)
2746 setValue(ndx, *values[ndx]);
2751 DE_ASSERT(m_status <= 0xFFu);
2754 void PixelValue::setUndefined (size_t ndx)
2757 DE_ASSERT(m_status <= 0xFFu);
2759 m_status &= (deUint16)~(0x1u << (deUint16)(ndx * 2));
2760 DE_ASSERT(m_status <= 0xFFu);
2763 void PixelValue::setValue (size_t ndx, bool value)
2766 DE_ASSERT(m_status <= 0xFFu);
2768 m_status = (deUint16)(m_status | (deUint16)(0x1u << (ndx * 2)));
2771 m_status = (deUint16)(m_status | (deUint16)(0x1u << (ndx * 2 + 1)));
2773 m_status &= (deUint16)~(0x1u << (deUint16)(ndx * 2 + 1));
2775 DE_ASSERT(m_status <= 0xFFu);
2778 Maybe<bool> PixelValue::getValue (size_t ndx) const
2781 DE_ASSERT(m_status <= 0xFFu);
2783 if ((m_status & (0x1u << (deUint16)(ndx * 2))) != 0)
2785 return just((m_status & (0x1u << (deUint32)(ndx * 2 + 1))) != 0);
2788 return nothing<bool>();
2791 void clearReferenceValues (vector<PixelValue>& values,
2792 const UVec2& targetSize,
2793 const UVec2& offset,
2796 const PixelValue& value)
2798 DE_ASSERT(targetSize.x() * targetSize.y() == (deUint32)values.size());
2799 DE_ASSERT(offset.x() + size.x() <= targetSize.x());
2800 DE_ASSERT(offset.y() + size.y() <= targetSize.y());
2802 for (deUint32 y = offset.y(); y < offset.y() + size.y(); y++)
2803 for (deUint32 x = offset.x(); x < offset.x() + size.x(); x++)
2805 for (int compNdx = 0; compNdx < 4; compNdx++)
2809 if (value.getValue(compNdx))
2810 values[x + y * targetSize.x()].setValue(compNdx, *value.getValue(compNdx));
2812 values[x + y * targetSize.x()].setUndefined(compNdx);
2818 void markUndefined (vector<PixelValue>& values,
2820 const UVec2& targetSize,
2821 const UVec2& offset,
2824 DE_ASSERT(targetSize.x() * targetSize.y() == (deUint32)values.size());
2826 for (deUint32 y = offset.y(); y < offset.y() + size.y(); y++)
2827 for (deUint32 x = offset.x(); x < offset.x() + size.x(); x++)
2829 for (int compNdx = 0; compNdx < 4; compNdx++)
2832 values[x + y * targetSize.x()].setUndefined(compNdx);
2837 PixelValue clearValueToPixelValue (const VkClearValue& value,
2838 const tcu::TextureFormat& format)
2840 const bool isDepthAttachment = hasDepthComponent(format.order);
2841 const bool isStencilAttachment = hasStencilComponent(format.order);
2842 const bool isDepthOrStencilAttachment = isDepthAttachment || isStencilAttachment;
2843 PixelValue pixelValue;
2845 if (isDepthOrStencilAttachment)
2847 if (isDepthAttachment)
2849 if (value.depthStencil.depth == 1.0f)
2850 pixelValue.setValue(0, true);
2851 else if (value.depthStencil.depth == 0.0f)
2852 pixelValue.setValue(0, false);
2854 DE_FATAL("Unknown depth value");
2857 if (isStencilAttachment)
2859 if (value.depthStencil.stencil == 0xFFu)
2860 pixelValue.setValue(1, true);
2861 else if (value.depthStencil.stencil == 0x0u)
2862 pixelValue.setValue(1, false);
2864 DE_FATAL("Unknown stencil value");
2869 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
2870 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
2872 switch (channelClass)
2874 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
2875 for (int i = 0; i < 4; i++)
2879 if (value.color.int32[i] == 1)
2880 pixelValue.setValue(i, true);
2881 else if (value.color.int32[i] == 0)
2882 pixelValue.setValue(i, false);
2884 DE_FATAL("Unknown clear color value");
2889 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
2890 for (int i = 0; i < 4; i++)
2894 if (value.color.uint32[i] == 1u)
2895 pixelValue.setValue(i, true);
2896 else if (value.color.uint32[i] == 0u)
2897 pixelValue.setValue(i, false);
2899 DE_FATAL("Unknown clear color value");
2904 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
2905 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
2906 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
2907 for (int i = 0; i < 4; i++)
2911 if (value.color.float32[i] == 1.0f)
2912 pixelValue.setValue(i, true);
2913 else if (value.color.float32[i] == 0.0f)
2914 pixelValue.setValue(i, false);
2916 DE_FATAL("Unknown clear color value");
2922 DE_FATAL("Unknown channel class");
2929 void renderReferenceValues (vector<vector<PixelValue> >& referenceAttachments,
2930 const RenderPass& renderPassInfo,
2931 const UVec2& targetSize,
2932 const vector<Maybe<VkClearValue> >& imageClearValues,
2933 const vector<Maybe<VkClearValue> >& renderPassClearValues,
2934 const vector<SubpassRenderInfo>& subpassRenderInfo,
2935 const UVec2& renderPos,
2936 const UVec2& renderSize)
2938 const vector<Subpass>& subpasses = renderPassInfo.getSubpasses();
2939 vector<bool> attachmentUsed (renderPassInfo.getAttachments().size(), false);
2941 referenceAttachments.resize(renderPassInfo.getAttachments().size());
2943 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
2945 const Attachment attachment = renderPassInfo.getAttachments()[attachmentNdx];
2946 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
2947 vector<PixelValue>& reference = referenceAttachments[attachmentNdx];
2949 reference.resize(targetSize.x() * targetSize.y());
2951 if (imageClearValues[attachmentNdx])
2952 clearReferenceValues(reference, targetSize, UVec2(0, 0), targetSize, BVec4(true), clearValueToPixelValue(*imageClearValues[attachmentNdx], format));
2955 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
2957 const Subpass& subpass = subpasses[subpassNdx];
2958 const SubpassRenderInfo& renderInfo = subpassRenderInfo[subpassNdx];
2959 const vector<AttachmentReference>& colorAttachments = subpass.getColorAttachments();
2961 // Apply load op if attachment was used for the first time
2962 for (size_t attachmentNdx = 0; attachmentNdx < colorAttachments.size(); attachmentNdx++)
2964 const deUint32 attachmentIndex = colorAttachments[attachmentNdx].getAttachment();
2966 if (!attachmentUsed[attachmentIndex])
2968 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
2969 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
2970 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
2972 DE_ASSERT(!tcu::hasDepthComponent(format.order));
2973 DE_ASSERT(!tcu::hasStencilComponent(format.order));
2975 if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
2976 clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(true), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format));
2977 else if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
2978 markUndefined(reference, BVec4(true), targetSize, renderPos, renderSize);
2980 attachmentUsed[attachmentIndex] = true;
2984 // Apply load op to depth/stencil attachment if it was used for the first time
2985 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
2987 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
2989 // Apply load op if attachment was used for the first time
2990 if (!attachmentUsed[attachmentIndex])
2992 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
2993 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
2994 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
2996 if (tcu::hasDepthComponent(format.order))
2998 if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
2999 clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(true, false, false, false), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format));
3000 else if (attachment.getLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
3001 markUndefined(reference, BVec4(true, false, false, false), targetSize, renderPos, renderSize);
3004 if (tcu::hasStencilComponent(format.order))
3006 if (attachment.getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
3007 clearReferenceValues(reference, targetSize, renderPos, renderSize, BVec4(false, true, false, false), clearValueToPixelValue(*renderPassClearValues[attachmentIndex], format));
3008 else if (attachment.getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_DONT_CARE)
3009 markUndefined(reference, BVec4(false, true, false, false), targetSize, renderPos, renderSize);
3012 attachmentUsed[attachmentIndex] = true;
3016 for (size_t colorClearNdx = 0; colorClearNdx < renderInfo.getColorClears().size(); colorClearNdx++)
3018 const ColorClear& colorClear = renderInfo.getColorClears()[colorClearNdx];
3019 const UVec2 offset = colorClear.getOffset();
3020 const UVec2 size = colorClear.getSize();
3021 const deUint32 attachmentIndex = subpass.getColorAttachments()[colorClearNdx].getAttachment();
3022 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3023 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3024 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3027 value.color = colorClear.getColor();
3029 clearReferenceValues(reference, targetSize, offset, size, BVec4(true), clearValueToPixelValue(value, format));
3032 if (renderInfo.getDepthStencilClear())
3034 const DepthStencilClear& dsClear = *renderInfo.getDepthStencilClear();
3035 const UVec2 offset = dsClear.getOffset();
3036 const UVec2 size = dsClear.getSize();
3037 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3038 const VkImageLayout layout = subpass.getDepthStencilAttachment().getImageLayout();
3039 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3040 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3041 const bool hasStencil = tcu::hasStencilComponent(format.order)
3042 && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR;
3043 const bool hasDepth = tcu::hasDepthComponent(format.order)
3044 && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR;
3045 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3048 value.depthStencil.depth = dsClear.getDepth();
3049 value.depthStencil.stencil = dsClear.getStencil();
3051 clearReferenceValues(reference, targetSize, offset, size, BVec4(hasDepth, hasStencil, false, false), clearValueToPixelValue(value, format));
3054 if (renderInfo.getRenderQuad())
3056 const RenderQuad& renderQuad = *renderInfo.getRenderQuad();
3057 const Vec2 posA = renderQuad.getCornerA();
3058 const Vec2 posB = renderQuad.getCornerB();
3059 const Vec2 origin = Vec2((float)renderInfo.getViewportOffset().x(), (float)renderInfo.getViewportOffset().y()) + Vec2((float)renderInfo.getViewportSize().x(), (float)renderInfo.getViewportSize().y()) / Vec2(2.0f);
3060 const Vec2 p = Vec2((float)renderInfo.getViewportSize().x(), (float)renderInfo.getViewportSize().y()) / Vec2(2.0f);
3061 const IVec2 posAI (deRoundFloatToInt32(origin.x() + (p.x() * posA.x())),
3062 deRoundFloatToInt32(origin.y() + (p.y() * posA.y())));
3063 const IVec2 posBI (deRoundFloatToInt32(origin.x() + (p.x() * posB.x())),
3064 deRoundFloatToInt32(origin.y() + (p.y() * posB.y())));
3066 DE_ASSERT(posAI.x() < posBI.x());
3067 DE_ASSERT(posAI.y() < posBI.y());
3069 if (subpass.getInputAttachments().empty())
3071 for (size_t attachmentRefNdx = 0; attachmentRefNdx < subpass.getColorAttachments().size(); attachmentRefNdx++)
3073 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentRefNdx].getAttachment();
3074 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3075 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3076 const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(format);
3077 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3079 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3080 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3082 for (int compNdx = 0; compNdx < 4; compNdx++)
3084 const size_t index = subpassNdx + attachmentIndex + compNdx;
3085 const BoolOp op = boolOpFromIndex(index);
3086 const bool boolX = x % 2 == (int)(index % 2);
3087 const bool boolY = y % 2 == (int)((index / 2) % 2);
3089 if (channelMask[compNdx])
3090 reference[x + y * targetSize.x()].setValue(compNdx, performBoolOp(op, boolX, boolY));
3095 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
3097 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3098 const VkImageLayout layout = subpass.getDepthStencilAttachment().getImageLayout();
3099 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3100 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3101 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3103 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3104 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3106 if (tcu::hasDepthComponent(format.order)
3107 && layout != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3108 && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
3110 const size_t index = subpassNdx + 1;
3111 const BoolOp op = boolOpFromIndex(index);
3112 const bool boolX = x % 2 == (int)(index % 2);
3113 const bool boolY = y % 2 == (int)((index / 2) % 2);
3115 reference[x + y * targetSize.x()].setValue(0, performBoolOp(op, boolX, boolY));
3118 if (tcu::hasStencilComponent(format.order)
3119 && layout != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3120 && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR)
3122 const size_t index = subpassNdx;
3123 reference[x + y * targetSize.x()].setValue(1, (index % 2) == 0);
3130 size_t outputComponentCount = 0;
3131 vector<Maybe<bool> > inputs;
3133 DE_ASSERT(posAI.x() < posBI.x());
3134 DE_ASSERT(posAI.y() < posBI.y());
3136 for (size_t attachmentRefNdx = 0; attachmentRefNdx < subpass.getColorAttachments().size(); attachmentRefNdx++)
3138 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentRefNdx].getAttachment();
3139 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3140 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3141 const int componentCount = tcu::getNumUsedChannels(format.order);
3143 outputComponentCount += (size_t)componentCount;
3146 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3147 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3148 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
3150 const Attachment& attachment (renderPassInfo.getAttachments()[subpass.getDepthStencilAttachment().getAttachment()]);
3151 const tcu::TextureFormat format (mapVkFormat(attachment.getFormat()));
3153 if (tcu::hasDepthComponent(format.order))
3154 outputComponentCount++;
3157 if (outputComponentCount > 0)
3159 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3160 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3162 for (size_t inputAttachmentNdx = 0; inputAttachmentNdx < subpass.getInputAttachments().size(); inputAttachmentNdx++)
3164 const deUint32 attachmentIndex = subpass.getInputAttachments()[inputAttachmentNdx].getAttachment();
3165 const VkImageLayout layout = subpass.getInputAttachments()[inputAttachmentNdx].getImageLayout();
3166 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3167 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3168 const int componentCount = tcu::getNumUsedChannels(format.order);
3170 for (int compNdx = 0; compNdx < componentCount; compNdx++)
3172 if ((compNdx != 0 || layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR)
3173 && (compNdx != 1 || layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR))
3175 inputs.push_back(referenceAttachments[attachmentIndex][x + y * targetSize.x()].getValue(compNdx));
3180 const size_t inputsPerOutput = inputs.size() >= outputComponentCount
3181 ? ((inputs.size() / outputComponentCount)
3182 + ((inputs.size() % outputComponentCount) != 0 ? 1 : 0))
3185 size_t outputValueNdx = 0;
3187 for (size_t attachmentRefNdx = 0; attachmentRefNdx < subpass.getColorAttachments().size(); attachmentRefNdx++)
3189 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentRefNdx].getAttachment();
3190 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3191 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3192 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3193 const int componentCount = tcu::getNumUsedChannels(format.order);
3195 for (int compNdx = 0; compNdx < componentCount; compNdx++)
3197 const size_t index = subpassNdx + attachmentIndex + outputValueNdx;
3198 const BoolOp op = boolOpFromIndex(index);
3199 const bool boolX = x % 2 == (int)(index % 2);
3200 const bool boolY = y % 2 == (int)((index / 2) % 2);
3201 Maybe<bool> output = tcu::just(performBoolOp(op, boolX, boolY));
3203 for (size_t i = 0; i < inputsPerOutput; i++)
3207 else if (!inputs[((outputValueNdx + compNdx) * inputsPerOutput + i) % inputs.size()])
3208 output = tcu::nothing<bool>();
3210 output = (*output) == (*inputs[((outputValueNdx + compNdx) * inputsPerOutput + i) % inputs.size()]);
3214 reference[x + y * targetSize.x()].setValue(compNdx, *output);
3216 reference[x + y * targetSize.x()].setUndefined(compNdx);
3219 outputValueNdx += componentCount;
3222 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3223 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3224 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
3226 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3227 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3228 const size_t index = subpassNdx + attachmentIndex;
3229 const BoolOp op = boolOpFromIndex(index);
3230 const bool boolX = x % 2 == (int)(index % 2);
3231 const bool boolY = y % 2 == (int)((index / 2) % 2);
3232 Maybe<bool> output = tcu::just(performBoolOp(op, boolX, boolY));
3234 for (size_t i = 0; i < inputsPerOutput; i++)
3238 else if (inputs[(outputValueNdx * inputsPerOutput + i) % inputs.size()])
3239 output = (*output) == (*inputs[(outputValueNdx * inputsPerOutput + i) % inputs.size()]);
3241 output = tcu::nothing<bool>();
3245 reference[x + y * targetSize.x()].setValue(0, *output);
3247 reference[x + y * targetSize.x()].setUndefined(0);
3254 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3255 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3256 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR)
3258 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3259 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentIndex];
3260 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3261 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3263 if (tcu::hasStencilComponent(format.order))
3265 for (int y = posAI.y(); y < (int)posBI.y(); y++)
3266 for (int x = posAI.x(); x < (int)posBI.x(); x++)
3268 const size_t index = subpassNdx;
3269 reference[x + y * targetSize.x()].setValue(1, (index % 2) == 0);
3277 // Mark all attachments that were used but not stored as undefined
3278 for (size_t attachmentIndex = 0; attachmentIndex < renderPassInfo.getAttachments().size(); attachmentIndex++)
3280 const Attachment attachment = renderPassInfo.getAttachments()[attachmentIndex];
3281 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3282 vector<PixelValue>& reference = referenceAttachments[attachmentIndex];
3283 const bool isStencilAttachment = hasStencilComponent(format.order);
3284 const bool isDepthOrStencilAttachment = hasDepthComponent(format.order) || isStencilAttachment;
3286 if (attachmentUsed[attachmentIndex] && renderPassInfo.getAttachments()[attachmentIndex].getStoreOp() == VK_ATTACHMENT_STORE_OP_DONT_CARE)
3288 if (isDepthOrStencilAttachment)
3289 markUndefined(reference, BVec4(true, false, false, false), targetSize, renderPos, renderSize);
3291 markUndefined(reference, BVec4(true), targetSize, renderPos, renderSize);
3294 if (attachmentUsed[attachmentIndex] && isStencilAttachment && renderPassInfo.getAttachments()[attachmentIndex].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_DONT_CARE)
3295 markUndefined(reference, BVec4(false, true, false, false), targetSize, renderPos, renderSize);
3299 void renderReferenceImagesFromValues (vector<tcu::TextureLevel>& referenceImages,
3300 const vector<vector<PixelValue> >& referenceValues,
3301 const UVec2& targetSize,
3302 const RenderPass& renderPassInfo)
3304 referenceImages.resize(referenceValues.size());
3306 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
3308 const Attachment attachment = renderPassInfo.getAttachments()[attachmentNdx];
3309 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3310 const vector<PixelValue>& reference = referenceValues[attachmentNdx];
3311 const bool hasDepth = tcu::hasDepthComponent(format.order);
3312 const bool hasStencil = tcu::hasStencilComponent(format.order);
3313 const bool hasDepthOrStencil = hasDepth || hasStencil;
3314 tcu::TextureLevel& referenceImage = referenceImages[attachmentNdx];
3316 referenceImage.setStorage(format, targetSize.x(), targetSize.y());
3318 if (hasDepthOrStencil)
3322 const PixelBufferAccess depthAccess (tcu::getEffectiveDepthStencilAccess(referenceImage.getAccess(), tcu::Sampler::MODE_DEPTH));
3324 for (deUint32 y = 0; y < targetSize.y(); y++)
3325 for (deUint32 x = 0; x < targetSize.x(); x++)
3327 if (reference[x + y * targetSize.x()].getValue(0))
3329 if (*reference[x + y * targetSize.x()].getValue(0))
3330 depthAccess.setPixDepth(1.0f, x, y);
3332 depthAccess.setPixDepth(0.0f, x, y);
3334 else // Fill with 3x3 grid
3335 depthAccess.setPixDepth(((x / 3) % 2) == ((y / 3) % 2) ? 0.33f : 0.66f, x, y);
3341 const PixelBufferAccess stencilAccess (tcu::getEffectiveDepthStencilAccess(referenceImage.getAccess(), tcu::Sampler::MODE_STENCIL));
3343 for (deUint32 y = 0; y < targetSize.y(); y++)
3344 for (deUint32 x = 0; x < targetSize.x(); x++)
3346 if (reference[x + y * targetSize.x()].getValue(1))
3348 if (*reference[x + y * targetSize.x()].getValue(1))
3349 stencilAccess.setPixStencil(0xFFu, x, y);
3351 stencilAccess.setPixStencil(0x0u, x, y);
3353 else // Fill with 3x3 grid
3354 stencilAccess.setPixStencil(((x / 3) % 2) == ((y / 3) % 2) ? 85 : 170, x, y);
3360 for (deUint32 y = 0; y < targetSize.y(); y++)
3361 for (deUint32 x = 0; x < targetSize.x(); x++)
3365 for (int compNdx = 0; compNdx < 4; compNdx++)
3367 if (reference[x + y * targetSize.x()].getValue(compNdx))
3369 if (*reference[x + y * targetSize.x()].getValue(compNdx))
3370 color[compNdx] = 1.0f;
3372 color[compNdx] = 0.0f;
3374 else // Fill with 3x3 grid
3375 color[compNdx] = ((compNdx + (x / 3)) % 2) == ((y / 3) % 2) ? 0.33f : 0.66f;
3378 referenceImage.getAccess().setPixel(color, x, y);
3384 bool verifyColorAttachment (const vector<PixelValue>& reference,
3385 const ConstPixelBufferAccess& result,
3386 const PixelBufferAccess& errorImage)
3388 const Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
3389 const Vec4 green (0.0f, 1.0f, 0.0f, 1.0f);
3392 DE_ASSERT(result.getWidth() * result.getHeight() == (int)reference.size());
3393 DE_ASSERT(result.getWidth() == errorImage.getWidth());
3394 DE_ASSERT(result.getHeight() == errorImage.getHeight());
3396 for (int y = 0; y < result.getHeight(); y++)
3397 for (int x = 0; x < result.getWidth(); x++)
3399 const Vec4 resultColor = result.getPixel(x, y);
3400 const PixelValue& referenceValue = reference[x + y * result.getWidth()];
3401 bool pixelOk = true;
3403 for (int compNdx = 0; compNdx < 4; compNdx++)
3405 const Maybe<bool> maybeValue = referenceValue.getValue(compNdx);
3409 const bool value = *maybeValue;
3411 if ((value && (resultColor[compNdx] != 1.0f))
3412 || (!value && resultColor[compNdx] != 0.0f))
3419 errorImage.setPixel(red, x, y);
3423 errorImage.setPixel(green, x, y);
3429 bool verifyDepthAttachment (const vector<PixelValue>& reference,
3430 const ConstPixelBufferAccess& result,
3431 const PixelBufferAccess& errorImage)
3433 const Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
3434 const Vec4 green (0.0f, 1.0f, 0.0f, 1.0f);
3437 DE_ASSERT(result.getWidth() * result.getHeight() == (int)reference.size());
3438 DE_ASSERT(result.getWidth() == errorImage.getWidth());
3439 DE_ASSERT(result.getHeight() == errorImage.getHeight());
3441 for (int y = 0; y < result.getHeight(); y++)
3442 for (int x = 0; x < result.getWidth(); x++)
3444 bool pixelOk = true;
3446 const float resultDepth = result.getPixDepth(x, y);
3447 const PixelValue& referenceValue = reference[x + y * result.getWidth()];
3448 const Maybe<bool> maybeValue = referenceValue.getValue(0);
3452 const bool value = *maybeValue;
3454 if ((value && (resultDepth != 1.0f))
3455 || (!value && resultDepth != 0.0f))
3461 errorImage.setPixel(red, x, y);
3465 errorImage.setPixel(green, x, y);
3471 bool verifyStencilAttachment (const vector<PixelValue>& reference,
3472 const ConstPixelBufferAccess& result,
3473 const PixelBufferAccess& errorImage)
3475 const Vec4 red (1.0f, 0.0f, 0.0f, 1.0f);
3476 const Vec4 green (0.0f, 1.0f, 0.0f, 1.0f);
3479 DE_ASSERT(result.getWidth() * result.getHeight() == (int)reference.size());
3480 DE_ASSERT(result.getWidth() == errorImage.getWidth());
3481 DE_ASSERT(result.getHeight() == errorImage.getHeight());
3483 for (int y = 0; y < result.getHeight(); y++)
3484 for (int x = 0; x < result.getWidth(); x++)
3486 bool pixelOk = true;
3488 const deUint32 resultStencil = result.getPixStencil(x, y);
3489 const PixelValue& referenceValue = reference[x + y * result.getWidth()];
3490 const Maybe<bool> maybeValue = referenceValue.getValue(1);
3494 const bool value = *maybeValue;
3496 if ((value && (resultStencil != 0xFFu))
3497 || (!value && resultStencil != 0x0u))
3503 errorImage.setPixel(red, x, y);
3507 errorImage.setPixel(green, x, y);
3513 bool logAndVerifyImages (TestLog& log,
3514 const DeviceInterface& vk,
3516 const vector<de::SharedPtr<AttachmentResources> >& attachmentResources,
3517 const vector<bool>& attachmentIsLazy,
3518 const RenderPass& renderPassInfo,
3519 const vector<Maybe<VkClearValue> >& renderPassClearValues,
3520 const vector<Maybe<VkClearValue> >& imageClearValues,
3521 const vector<SubpassRenderInfo>& subpassRenderInfo,
3522 const UVec2& targetSize,
3523 const TestConfig& config)
3525 vector<vector<PixelValue> > referenceValues;
3526 vector<tcu::TextureLevel> referenceAttachments;
3529 log << TestLog::Message << "Reference images fill undefined pixels with 3x3 grid pattern." << TestLog::EndMessage;
3531 renderReferenceValues(referenceValues, renderPassInfo, targetSize, imageClearValues, renderPassClearValues, subpassRenderInfo, config.renderPos, config.renderSize);
3532 renderReferenceImagesFromValues(referenceAttachments, referenceValues, targetSize, renderPassInfo);
3534 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
3536 if (!attachmentIsLazy[attachmentNdx])
3538 const Attachment attachment = renderPassInfo.getAttachments()[attachmentNdx];
3539 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3541 if (tcu::hasDepthComponent(format.order) && tcu::hasStencilComponent(format.order))
3543 const tcu::TextureFormat depthFormat = getDepthCopyFormat(attachment.getFormat());
3544 const VkDeviceSize depthBufferSize = targetSize.x() * targetSize.y() * depthFormat.getPixelSize();
3545 void* const depthPtr = attachmentResources[attachmentNdx]->getResultMemory().getHostPtr();
3547 const tcu::TextureFormat stencilFormat = getStencilCopyFormat(attachment.getFormat());
3548 const VkDeviceSize stencilBufferSize = targetSize.x() * targetSize.y() * stencilFormat.getPixelSize();
3549 void* const stencilPtr = attachmentResources[attachmentNdx]->getSecondaryResultMemory().getHostPtr();
3551 const VkMappedMemoryRange ranges[] =
3554 VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // sType;
3556 attachmentResources[attachmentNdx]->getResultMemory().getMemory(), // mem;
3557 attachmentResources[attachmentNdx]->getResultMemory().getOffset(), // offset;
3558 depthBufferSize // size;
3561 VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // sType;
3563 attachmentResources[attachmentNdx]->getSecondaryResultMemory().getMemory(), // mem;
3564 attachmentResources[attachmentNdx]->getSecondaryResultMemory().getOffset(), // offset;
3565 stencilBufferSize // size;
3568 VK_CHECK(vk.invalidateMappedMemoryRanges(device, 2u, ranges));
3571 const ConstPixelBufferAccess depthAccess (depthFormat, targetSize.x(), targetSize.y(), 1, depthPtr);
3572 const ConstPixelBufferAccess stencilAccess (stencilFormat, targetSize.x(), targetSize.y(), 1, stencilPtr);
3573 tcu::TextureLevel depthErrorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
3574 tcu::TextureLevel stencilErrorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
3576 log << TestLog::Image("Attachment" + de::toString(attachmentNdx) + "Depth", "Attachment " + de::toString(attachmentNdx) + " Depth", depthAccess);
3577 log << TestLog::Image("Attachment" + de::toString(attachmentNdx) + "Stencil", "Attachment " + de::toString(attachmentNdx) + " Stencil", stencilAccess);
3579 log << TestLog::Image("AttachmentReference" + de::toString(attachmentNdx), "Attachment reference " + de::toString(attachmentNdx), referenceAttachments[attachmentNdx].getAccess());
3581 if (renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE
3582 && !verifyDepthAttachment(referenceValues[attachmentNdx], depthAccess, depthErrorImage.getAccess()))
3584 log << TestLog::Image("DepthAttachmentError" + de::toString(attachmentNdx), "Depth Attachment Error " + de::toString(attachmentNdx), depthErrorImage.getAccess());
3588 if (renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE
3589 && !verifyStencilAttachment(referenceValues[attachmentNdx], stencilAccess, stencilErrorImage.getAccess()))
3591 log << TestLog::Image("StencilAttachmentError" + de::toString(attachmentNdx), "Stencil Attachment Error " + de::toString(attachmentNdx), stencilErrorImage.getAccess());
3598 const VkDeviceSize bufferSize = targetSize.x() * targetSize.y() * format.getPixelSize();
3599 void* const ptr = attachmentResources[attachmentNdx]->getResultMemory().getHostPtr();
3601 const VkMappedMemoryRange range =
3603 VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // sType;
3605 attachmentResources[attachmentNdx]->getResultMemory().getMemory(), // mem;
3606 attachmentResources[attachmentNdx]->getResultMemory().getOffset(), // offset;
3609 VK_CHECK(vk.invalidateMappedMemoryRanges(device, 1u, &range));
3611 if (tcu::hasDepthComponent(format.order))
3613 const ConstPixelBufferAccess access (format, targetSize.x(), targetSize.y(), 1, ptr);
3614 tcu::TextureLevel errorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
3616 log << TestLog::Image("Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx), access);
3617 log << TestLog::Image("AttachmentReference" + de::toString(attachmentNdx), "Attachment reference " + de::toString(attachmentNdx), referenceAttachments[attachmentNdx].getAccess());
3619 if ((renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE || renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE)
3620 && !verifyDepthAttachment(referenceValues[attachmentNdx], access, errorImage.getAccess()))
3622 log << TestLog::Image("AttachmentError" + de::toString(attachmentNdx), "Attachment Error " + de::toString(attachmentNdx), errorImage.getAccess());
3626 else if (tcu::hasStencilComponent(format.order))
3628 const ConstPixelBufferAccess access (format, targetSize.x(), targetSize.y(), 1, ptr);
3629 tcu::TextureLevel errorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
3631 log << TestLog::Image("Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx), access);
3632 log << TestLog::Image("AttachmentReference" + de::toString(attachmentNdx), "Attachment reference " + de::toString(attachmentNdx), referenceAttachments[attachmentNdx].getAccess());
3634 if ((renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE || renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE)
3635 && !verifyStencilAttachment(referenceValues[attachmentNdx], access, errorImage.getAccess()))
3637 log << TestLog::Image("AttachmentError" + de::toString(attachmentNdx), "Attachment Error " + de::toString(attachmentNdx), errorImage.getAccess());
3643 const ConstPixelBufferAccess access (format, targetSize.x(), targetSize.y(), 1, ptr);
3644 tcu::TextureLevel errorImage (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), targetSize.x(), targetSize.y());
3646 log << TestLog::Image("Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx), access);
3647 log << TestLog::Image("AttachmentReference" + de::toString(attachmentNdx), "Attachment reference " + de::toString(attachmentNdx), referenceAttachments[attachmentNdx].getAccess());
3649 if ((renderPassInfo.getAttachments()[attachmentNdx].getStoreOp() == VK_ATTACHMENT_STORE_OP_STORE || renderPassInfo.getAttachments()[attachmentNdx].getStencilStoreOp() == VK_ATTACHMENT_STORE_OP_STORE)
3650 && !verifyColorAttachment(referenceValues[attachmentNdx], access, errorImage.getAccess()))
3652 log << TestLog::Image("AttachmentError" + de::toString(attachmentNdx), "Attachment Error " + de::toString(attachmentNdx), errorImage.getAccess());
3663 std::string getInputAttachmentType (VkFormat vkFormat)
3665 const tcu::TextureFormat format = mapVkFormat(vkFormat);
3666 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
3668 switch (channelClass)
3670 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
3671 return "isubpassInput";
3673 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
3674 return "usubpassInput";
3676 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
3677 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
3678 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
3679 return "subpassInput";
3682 DE_FATAL("Unknown channel class");
3687 std::string getAttachmentType (VkFormat vkFormat)
3689 const tcu::TextureFormat format = mapVkFormat(vkFormat);
3690 const tcu::TextureChannelClass channelClass = tcu::getTextureChannelClass(format.type);
3692 switch (channelClass)
3694 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
3697 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
3700 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
3701 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
3702 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
3706 DE_FATAL("Unknown channel class");
3711 void createTestShaders (SourceCollections& dst, TestConfig config)
3713 if (config.renderTypes & TestConfig::RENDERTYPES_DRAW)
3715 const vector<Subpass>& subpasses = config.renderPass.getSubpasses();
3717 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
3719 const Subpass& subpass = subpasses[subpassNdx];
3720 deUint32 inputAttachmentBinding = 0;
3721 std::ostringstream vertexShader;
3722 std::ostringstream fragmentShader;
3724 vertexShader << "#version 310 es\n"
3725 << "layout(location = 0) in highp vec2 a_position;\n"
3726 << "void main (void) {\n"
3727 << "\tgl_Position = vec4(a_position, 1.0, 1.0);\n"
3730 fragmentShader << "#version 310 es\n"
3731 << "precision highp float;\n";
3733 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
3735 const deUint32 attachmentIndex = subpass.getInputAttachments()[attachmentNdx].getAttachment();
3736 const VkImageLayout layout = subpass.getInputAttachments()[attachmentNdx].getImageLayout();
3737 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
3738 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3739 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
3740 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
3742 if (isDepthFormat || isStencilFormat)
3744 if (isDepthFormat && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR)
3746 fragmentShader << "layout(input_attachment_index = " << attachmentNdx << ", set=0, binding=" << inputAttachmentBinding << ") uniform highp subpassInput i_depth" << attachmentNdx << ";\n";
3747 inputAttachmentBinding++;
3750 if (isStencilFormat && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
3752 fragmentShader << "layout(input_attachment_index = " << attachmentNdx << ", set=0, binding=" << inputAttachmentBinding << ") uniform highp usubpassInput i_stencil" << attachmentNdx << ";\n";
3753 inputAttachmentBinding++;
3758 const std::string attachmentType = getInputAttachmentType(attachment.getFormat());
3760 fragmentShader << "layout(input_attachment_index = " << attachmentNdx << ", set=0, binding=" << inputAttachmentBinding << ") uniform highp " << attachmentType << " i_color" << attachmentNdx << ";\n";
3761 inputAttachmentBinding++;
3765 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
3767 const std::string attachmentType = getAttachmentType(config.renderPass.getAttachments()[subpass.getColorAttachments()[attachmentNdx].getAttachment()].getFormat());
3768 fragmentShader << "layout(location = " << attachmentNdx << ") out highp " << attachmentType << " o_color" << attachmentNdx << ";\n";
3771 fragmentShader << "void main (void) {\n";
3773 if (subpass.getInputAttachments().empty())
3775 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
3777 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentNdx].getAttachment();
3778 const std::string attachmentType = getAttachmentType(config.renderPass.getAttachments()[attachmentIndex].getFormat());
3780 fragmentShader << "\to_color" << attachmentNdx << " = " << attachmentType << "(vec4(";
3782 for (size_t compNdx = 0; compNdx < 4; compNdx++)
3784 const size_t index = subpassNdx + attachmentIndex + compNdx;
3785 const BoolOp op = boolOpFromIndex(index);
3788 fragmentShader << ",\n\t\t";
3790 fragmentShader << "((int(gl_FragCoord.x) % 2 == " << (index % 2)
3791 << ") " << boolOpToString(op) << " ("
3792 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
3793 << ") ? 1.0 : 0.0)";
3796 fragmentShader << "));\n";
3799 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3800 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3801 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
3803 const size_t index = subpassNdx + 1;
3804 const BoolOp op = boolOpFromIndex(index);
3806 fragmentShader << "\tgl_FragDepth = ((int(gl_FragCoord.x) % 2 == " << (index % 2)
3807 << ") " << boolOpToString(op) << " ("
3808 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
3809 << ") ? 1.0 : 0.0);\n";
3814 size_t inputComponentCount = 0;
3815 size_t outputComponentCount = 0;
3817 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
3819 const deUint32 attachmentIndex = subpass.getInputAttachments()[attachmentNdx].getAttachment();
3820 const VkImageLayout layout = subpass.getInputAttachments()[attachmentNdx].getImageLayout();
3821 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
3822 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3823 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
3825 if (layout == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
3826 inputComponentCount += 1;
3827 else if (layout == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR)
3828 inputComponentCount += 1;
3830 inputComponentCount += componentCount;
3833 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
3835 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentNdx].getAttachment();
3836 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
3837 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3838 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
3840 outputComponentCount += componentCount;
3843 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3844 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3845 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
3847 outputComponentCount++;
3850 if (outputComponentCount > 0)
3852 const size_t inputsPerOutput = inputComponentCount >= outputComponentCount
3853 ? ((inputComponentCount / outputComponentCount)
3854 + ((inputComponentCount % outputComponentCount) != 0 ? 1 : 0))
3857 fragmentShader << "\tbool inputs[" << inputComponentCount << "];\n";
3859 if (outputComponentCount > 0)
3860 fragmentShader << "\tbool outputs[" << outputComponentCount << "];\n";
3862 size_t inputValueNdx = 0;
3864 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
3866 const char* const components[] =
3870 const deUint32 attachmentIndex = subpass.getInputAttachments()[attachmentNdx].getAttachment();
3871 const VkImageLayout layout = subpass.getInputAttachments()[attachmentNdx].getImageLayout();
3872 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
3873 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3874 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
3875 const bool isDepthFormat = tcu::hasDepthComponent(format.order);
3876 const bool isStencilFormat = tcu::hasStencilComponent(format.order);
3878 if (isDepthFormat || isStencilFormat)
3880 if (isDepthFormat && layout != VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR)
3882 fragmentShader << "\tinputs[" << inputValueNdx << "] = 1.0 == float(subpassLoad(i_depth" << attachmentNdx << ").x);\n";
3886 if (isStencilFormat && layout != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
3888 fragmentShader << "\tinputs[" << inputValueNdx << "] = 255u == subpassLoad(i_stencil" << attachmentNdx << ").x;\n";
3894 for (size_t compNdx = 0; compNdx < componentCount; compNdx++)
3896 fragmentShader << "\tinputs[" << inputValueNdx << "] = 1.0 == float(subpassLoad(i_color" << attachmentNdx << ")." << components[compNdx] << ");\n";
3902 size_t outputValueNdx = 0;
3904 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
3906 const deUint32 attachmentIndex = subpass.getColorAttachments()[attachmentNdx].getAttachment();
3907 const Attachment attachment = config.renderPass.getAttachments()[attachmentIndex];
3908 const std::string attachmentType = getAttachmentType(config.renderPass.getAttachments()[attachmentIndex].getFormat());
3909 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
3910 const size_t componentCount = (size_t)tcu::getNumUsedChannels(format.order);
3912 for (size_t compNdx = 0; compNdx < componentCount; compNdx++)
3914 const size_t index = subpassNdx + attachmentIndex + outputValueNdx;
3915 const BoolOp op = boolOpFromIndex(index);
3917 fragmentShader << "\toutputs[" << outputValueNdx + compNdx << "] = "
3918 << "(int(gl_FragCoord.x) % 2 == " << (index % 2)
3919 << ") " << boolOpToString(op) << " ("
3920 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
3923 for (size_t i = 0; i < inputsPerOutput; i++)
3924 fragmentShader << "\toutputs[" << outputValueNdx + compNdx << "] = outputs[" << outputValueNdx + compNdx << "] == inputs[" << ((outputValueNdx + compNdx) * inputsPerOutput + i) % inputComponentCount << "];\n";
3927 fragmentShader << "\to_color" << attachmentNdx << " = " << attachmentType << "(";
3929 for (size_t compNdx = 0; compNdx < 4; compNdx++)
3932 fragmentShader << ", ";
3934 if (compNdx < componentCount)
3935 fragmentShader << "outputs[" << outputValueNdx + compNdx << "]";
3937 fragmentShader << "0";
3940 outputValueNdx += componentCount;
3942 fragmentShader << ");\n";
3945 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED
3946 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
3947 && subpass.getDepthStencilAttachment().getImageLayout() != VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
3949 const deUint32 attachmentIndex = subpass.getDepthStencilAttachment().getAttachment();
3950 const size_t index = subpassNdx + attachmentIndex;
3951 const BoolOp op = boolOpFromIndex(index);
3953 fragmentShader << "\toutputs[" << outputValueNdx << "] = "
3954 << "(int(gl_FragCoord.x) % 2 == " << (index % 2)
3955 << ") " << boolOpToString(op) << " ("
3956 << "int(gl_FragCoord.y) % 2 == " << ((index / 2) % 2)
3959 for (size_t i = 0; i < inputsPerOutput; i++)
3960 fragmentShader << "\toutputs[" << outputValueNdx << "] = outputs[" << outputValueNdx << "] == inputs[" << (outputValueNdx * inputsPerOutput + i) % inputComponentCount << "];\n";
3962 fragmentShader << "\tgl_FragDepth = outputs[" << outputValueNdx << "] ? 1.0 : 0.0;";
3967 fragmentShader << "}\n";
3969 dst.glslSources.add(de::toString(subpassNdx) + "-vert") << glu::VertexSource(vertexShader.str());
3970 dst.glslSources.add(de::toString(subpassNdx) + "-frag") << glu::FragmentSource(fragmentShader.str());
3975 void initializeAttachmentIsLazy (vector<bool>& attachmentIsLazy, const vector<Attachment>& attachments, TestConfig::ImageMemory imageMemory)
3977 bool lastAttachmentWasLazy = false;
3979 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
3981 if (attachments[attachmentNdx].getLoadOp() != VK_ATTACHMENT_LOAD_OP_LOAD
3982 && attachments[attachmentNdx].getStoreOp() != VK_ATTACHMENT_STORE_OP_STORE
3983 && attachments[attachmentNdx].getStencilLoadOp() != VK_ATTACHMENT_LOAD_OP_LOAD
3984 && attachments[attachmentNdx].getStencilStoreOp() != VK_ATTACHMENT_STORE_OP_STORE)
3986 if (imageMemory == TestConfig::IMAGEMEMORY_LAZY || (imageMemory & TestConfig::IMAGEMEMORY_LAZY && !lastAttachmentWasLazy))
3988 attachmentIsLazy.push_back(true);
3990 lastAttachmentWasLazy = true;
3992 else if (imageMemory & TestConfig::IMAGEMEMORY_STRICT)
3994 attachmentIsLazy.push_back(false);
3995 lastAttachmentWasLazy = false;
3998 DE_FATAL("Unknown imageMemory");
4001 attachmentIsLazy.push_back(false);
4005 enum AttachmentRefType
4007 ATTACHMENTREFTYPE_COLOR,
4008 ATTACHMENTREFTYPE_DEPTH_STENCIL,
4009 ATTACHMENTREFTYPE_INPUT,
4010 ATTACHMENTREFTYPE_RESOLVE,
4013 VkImageUsageFlags getImageUsageFromLayout (VkImageLayout layout)
4017 case VK_IMAGE_LAYOUT_GENERAL:
4018 case VK_IMAGE_LAYOUT_PREINITIALIZED:
4021 case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
4022 return VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4024 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
4025 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL:
4026 return VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
4028 case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
4029 return VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
4031 case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
4032 return VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
4034 case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
4035 return VK_IMAGE_USAGE_TRANSFER_DST_BIT;
4038 DE_FATAL("Unexpected image layout");
4043 void getImageUsageFromAttachmentReferences(vector<VkImageUsageFlags>& attachmentImageUsage, AttachmentRefType refType, size_t count, const AttachmentReference* references)
4045 for (size_t referenceNdx = 0; referenceNdx < count; ++referenceNdx)
4047 const deUint32 attachment = references[referenceNdx].getAttachment();
4049 if (attachment != VK_ATTACHMENT_UNUSED)
4051 VkImageUsageFlags usage;
4055 case ATTACHMENTREFTYPE_COLOR:
4056 case ATTACHMENTREFTYPE_RESOLVE:
4057 usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
4060 case ATTACHMENTREFTYPE_DEPTH_STENCIL:
4061 usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
4064 case ATTACHMENTREFTYPE_INPUT:
4065 usage = VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
4069 DE_FATAL("Unexpected attachment reference type");
4074 attachmentImageUsage[attachment] |= usage;
4079 void getImageUsageFromAttachmentReferences(vector<VkImageUsageFlags>& attachmentImageUsage, AttachmentRefType refType, const vector<AttachmentReference>& references)
4081 if (!references.empty())
4083 getImageUsageFromAttachmentReferences(attachmentImageUsage, refType, references.size(), &references[0]);
4087 void initializeAttachmentImageUsage (Context &context, vector<VkImageUsageFlags>& attachmentImageUsage, const RenderPass& renderPassInfo, const vector<bool>& attachmentIsLazy, const vector<Maybe<VkClearValue> >& clearValues)
4089 attachmentImageUsage.resize(renderPassInfo.getAttachments().size(), VkImageUsageFlags(0));
4091 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); ++subpassNdx)
4093 const Subpass& subpass = renderPassInfo.getSubpasses()[subpassNdx];
4095 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_COLOR, subpass.getColorAttachments());
4096 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_DEPTH_STENCIL, 1, &subpass.getDepthStencilAttachment());
4097 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_INPUT, subpass.getInputAttachments());
4098 getImageUsageFromAttachmentReferences(attachmentImageUsage, ATTACHMENTREFTYPE_RESOLVE, subpass.getResolveAttachments());
4101 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
4103 const Attachment& attachment = renderPassInfo.getAttachments()[attachmentNdx];
4104 const VkFormatProperties formatProperties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), attachment.getFormat());
4105 const VkFormatFeatureFlags supportedFeatures = formatProperties.optimalTilingFeatures;
4107 if ((supportedFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0)
4108 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_SAMPLED_BIT;
4110 if ((supportedFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) != 0)
4111 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_STORAGE_BIT;
4113 attachmentImageUsage[attachmentNdx] |= getImageUsageFromLayout(attachment.getInitialLayout());
4114 attachmentImageUsage[attachmentNdx] |= getImageUsageFromLayout(attachment.getFinalLayout());
4116 if (!attachmentIsLazy[attachmentNdx])
4118 if (clearValues[attachmentNdx])
4119 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
4121 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
4125 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);
4127 attachmentImageUsage[attachmentNdx] &= allowedTransientBits;
4128 attachmentImageUsage[attachmentNdx] |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4133 void initializeSubpassIsSecondary (vector<bool>& subpassIsSecondary, const vector<Subpass>& subpasses, TestConfig::CommandBufferTypes commandBuffer)
4135 bool lastSubpassWasSecondary = false;
4137 for (size_t subpassNdx = 0; subpassNdx < subpasses.size(); subpassNdx++)
4139 if (commandBuffer == TestConfig::COMMANDBUFFERTYPES_SECONDARY || (commandBuffer & TestConfig::COMMANDBUFFERTYPES_SECONDARY && !lastSubpassWasSecondary))
4141 subpassIsSecondary.push_back(true);
4142 lastSubpassWasSecondary = true;
4144 else if (commandBuffer & TestConfig::COMMANDBUFFERTYPES_INLINE)
4146 subpassIsSecondary.push_back(false);
4147 lastSubpassWasSecondary = false;
4150 DE_FATAL("Unknown commandBuffer");
4154 void initializeImageClearValues (de::Random& rng, vector<Maybe<VkClearValue> >& clearValues, const vector<Attachment>& attachments, const vector<bool>& isLazy)
4156 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4158 if (!isLazy[attachmentNdx])
4159 clearValues.push_back(just(randomClearValue(attachments[attachmentNdx], rng)));
4161 clearValues.push_back(nothing<VkClearValue>());
4165 void initializeRenderPassClearValues (de::Random& rng, vector<Maybe<VkClearValue> >& clearValues, const vector<Attachment>& attachments)
4167 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4169 if (attachments[attachmentNdx].getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR
4170 || attachments[attachmentNdx].getStencilLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR)
4172 clearValues.push_back(just(randomClearValue(attachments[attachmentNdx], rng)));
4175 clearValues.push_back(nothing<VkClearValue>());
4179 void initializeSubpassClearValues (de::Random& rng, vector<vector<VkClearColorValue> >& clearValues, const RenderPass& renderPass)
4181 clearValues.resize(renderPass.getSubpasses().size());
4183 for (size_t subpassNdx = 0; subpassNdx < renderPass.getSubpasses().size(); subpassNdx++)
4185 const Subpass& subpass = renderPass.getSubpasses()[subpassNdx];
4186 const vector<AttachmentReference>& colorAttachments = subpass.getColorAttachments();
4188 clearValues[subpassNdx].resize(colorAttachments.size());
4190 for (size_t attachmentRefNdx = 0; attachmentRefNdx < colorAttachments.size(); attachmentRefNdx++)
4192 const AttachmentReference& attachmentRef = colorAttachments[attachmentRefNdx];
4193 const Attachment& attachment = renderPass.getAttachments()[attachmentRef.getAttachment()];
4195 clearValues[subpassNdx][attachmentRefNdx] = randomColorClearValue(attachment, rng);
4200 void logSubpassRenderInfo (TestLog& log,
4201 const SubpassRenderInfo& info)
4203 log << TestLog::Message << "Viewport, offset: " << info.getViewportOffset() << ", size: " << info.getViewportSize() << TestLog::EndMessage;
4205 if (info.isSecondary())
4206 log << TestLog::Message << "Subpass uses secondary command buffers" << TestLog::EndMessage;
4208 log << TestLog::Message << "Subpass uses inlined commands" << TestLog::EndMessage;
4210 for (deUint32 attachmentNdx = 0; attachmentNdx < info.getColorClears().size(); attachmentNdx++)
4212 const ColorClear& colorClear = info.getColorClears()[attachmentNdx];
4214 log << TestLog::Message << "Clearing color attachment " << attachmentNdx
4215 << ". Offset: " << colorClear.getOffset()
4216 << ", Size: " << colorClear.getSize()
4217 << ", Color: " << clearColorToString(info.getColorAttachment(attachmentNdx).getFormat(), colorClear.getColor()) << TestLog::EndMessage;
4220 if (info.getDepthStencilClear())
4222 const DepthStencilClear& depthStencilClear = *info.getDepthStencilClear();
4224 log << TestLog::Message << "Clearing depth stencil attachment"
4225 << ". Offset: " << depthStencilClear.getOffset()
4226 << ", Size: " << depthStencilClear.getSize()
4227 << ", Depth: " << depthStencilClear.getDepth()
4228 << ", Stencil: " << depthStencilClear.getStencil() << TestLog::EndMessage;
4231 if (info.getRenderQuad())
4233 const RenderQuad& renderQuad = *info.getRenderQuad();
4235 log << TestLog::Message << "Rendering grid quad to " << renderQuad.getCornerA() << " -> " << renderQuad.getCornerB() << TestLog::EndMessage;
4239 void logTestCaseInfo (TestLog& log,
4240 const TestConfig& config,
4241 const vector<bool>& attachmentIsLazy,
4242 const vector<Maybe<VkClearValue> >& imageClearValues,
4243 const vector<Maybe<VkClearValue> >& renderPassClearValues,
4244 const vector<SubpassRenderInfo>& subpassRenderInfo)
4246 const RenderPass& renderPass = config.renderPass;
4248 logRenderPassInfo(log, renderPass);
4250 DE_ASSERT(attachmentIsLazy.size() == renderPass.getAttachments().size());
4251 DE_ASSERT(imageClearValues.size() == renderPass.getAttachments().size());
4252 DE_ASSERT(renderPassClearValues.size() == renderPass.getAttachments().size());
4254 log << TestLog::Message << "TargetSize: " << config.targetSize << TestLog::EndMessage;
4255 log << TestLog::Message << "Render area, Offset: " << config.renderPos << ", Size: " << config.renderSize << TestLog::EndMessage;
4257 for (size_t attachmentNdx = 0; attachmentNdx < attachmentIsLazy.size(); attachmentNdx++)
4259 const tcu::ScopedLogSection section (log, "Attachment" + de::toString(attachmentNdx), "Attachment " + de::toString(attachmentNdx));
4261 if (attachmentIsLazy[attachmentNdx])
4262 log << TestLog::Message << "Is lazy." << TestLog::EndMessage;
4264 if (imageClearValues[attachmentNdx])
4265 log << TestLog::Message << "Image is cleared to " << clearValueToString(renderPass.getAttachments()[attachmentNdx].getFormat(), *imageClearValues[attachmentNdx]) << " before rendering." << TestLog::EndMessage;
4267 if (renderPass.getAttachments()[attachmentNdx].getLoadOp() == VK_ATTACHMENT_LOAD_OP_CLEAR && renderPassClearValues[attachmentNdx])
4268 log << TestLog::Message << "Attachment is cleared to " << clearValueToString(renderPass.getAttachments()[attachmentNdx].getFormat(), *renderPassClearValues[attachmentNdx]) << " in the beginning of the render pass." << TestLog::EndMessage;
4271 for (size_t subpassNdx = 0; subpassNdx < renderPass.getSubpasses().size(); subpassNdx++)
4273 const tcu::ScopedLogSection section (log, "Subpass" + de::toString(subpassNdx), "Subpass " + de::toString(subpassNdx));
4275 logSubpassRenderInfo(log, subpassRenderInfo[subpassNdx]);
4279 float roundToViewport (float x, deUint32 offset, deUint32 size)
4281 const float origin = (float)(offset) + ((float(size) / 2.0f));
4282 const float p = (float)(size) / 2.0f;
4283 const deInt32 xi = deRoundFloatToInt32(origin + (p * x));
4285 return (((float)xi) - origin) / p;
4288 void initializeSubpassRenderInfo (vector<SubpassRenderInfo>& renderInfos, de::Random& rng, const RenderPass& renderPass, const TestConfig& config)
4290 const TestConfig::CommandBufferTypes commandBuffer = config.commandBufferTypes;
4291 const vector<Subpass>& subpasses = renderPass.getSubpasses();
4292 bool lastSubpassWasSecondary = false;
4294 for (deUint32 subpassNdx = 0; subpassNdx < (deUint32)subpasses.size(); subpassNdx++)
4296 const Subpass& subpass = subpasses[subpassNdx];
4297 const bool subpassIsSecondary = commandBuffer == TestConfig::COMMANDBUFFERTYPES_SECONDARY
4298 || (commandBuffer & TestConfig::COMMANDBUFFERTYPES_SECONDARY && !lastSubpassWasSecondary) ? true : false;
4299 const UVec2 viewportSize ((config.renderSize * UVec2(2)) / UVec2(3));
4300 const UVec2 viewportOffset (config.renderPos.x() + (subpassNdx % 2) * (config.renderSize.x() / 3),
4301 config.renderPos.y() + ((subpassNdx / 2) % 2) * (config.renderSize.y() / 3));
4303 vector<ColorClear> colorClears;
4304 Maybe<DepthStencilClear> depthStencilClear;
4305 Maybe<RenderQuad> renderQuad;
4307 lastSubpassWasSecondary = subpassIsSecondary;
4309 if (config.renderTypes & TestConfig::RENDERTYPES_CLEAR)
4311 const vector<AttachmentReference>& colorAttachments = subpass.getColorAttachments();
4313 for (size_t attachmentRefNdx = 0; attachmentRefNdx < colorAttachments.size(); attachmentRefNdx++)
4315 const AttachmentReference& attachmentRef = colorAttachments[attachmentRefNdx];
4316 const Attachment& attachment = renderPass.getAttachments()[attachmentRef.getAttachment()];
4317 const UVec2 size ((viewportSize * UVec2(2)) / UVec2(3));
4318 const UVec2 offset (viewportOffset.x() + ((deUint32)attachmentRefNdx % 2u) * (viewportSize.x() / 3u),
4319 viewportOffset.y() + (((deUint32)attachmentRefNdx / 2u) % 2u) * (viewportSize.y() / 3u));
4320 const VkClearColorValue color = randomColorClearValue(attachment, rng);
4322 colorClears.push_back(ColorClear(offset, size, color));
4325 if (subpass.getDepthStencilAttachment().getAttachment() != VK_ATTACHMENT_UNUSED)
4327 const Attachment& attachment = renderPass.getAttachments()[subpass.getDepthStencilAttachment().getAttachment()];
4328 const UVec2 size ((viewportSize * UVec2(2)) / UVec2(3));
4329 const UVec2 offset (viewportOffset.x() + ((deUint32)colorAttachments.size() % 2u) * (viewportSize.x() / 3u),
4330 viewportOffset.y() + (((deUint32)colorAttachments.size() / 2u) % 2u) * (viewportSize.y() / 3u));
4331 const VkClearValue value = randomClearValue(attachment, rng);
4333 depthStencilClear = tcu::just(DepthStencilClear(offset, size, value.depthStencil.depth, value.depthStencil.stencil));
4337 if (config.renderTypes & TestConfig::RENDERTYPES_DRAW)
4339 const float w = (subpassNdx % 2) == 0 ? 1.0f : 1.25f;
4340 const float h = (subpassNdx % 2) == 0 ? 1.25f : 1.0f;
4342 const float x0 = roundToViewport((subpassNdx % 2) == 0 ? 1.0f - w : -1.0f, viewportOffset.x(), viewportSize.x());
4343 const float x1 = roundToViewport((subpassNdx % 2) == 0 ? 1.0f : -1.0f + w, viewportOffset.x(), viewportSize.x());
4345 const float y0 = roundToViewport(((subpassNdx / 2) % 2) == 0 ? 1.0f - h : -1.0f, viewportOffset.y(), viewportSize.y());
4346 const float y1 = roundToViewport(((subpassNdx / 2) % 2) == 0 ? 1.0f : -1.0f + h, viewportOffset.y(), viewportSize.y());
4348 renderQuad = tcu::just(RenderQuad(tcu::Vec2(x0, y0), tcu::Vec2(x1, y1)));
4351 renderInfos.push_back(SubpassRenderInfo(renderPass, subpassNdx, subpassIsSecondary, viewportOffset, viewportSize, renderQuad, colorClears, depthStencilClear));
4355 void checkTextureFormatSupport (TestLog& log,
4356 const InstanceInterface& vk,
4357 VkPhysicalDevice device,
4358 const vector<Attachment>& attachments)
4360 bool supported = true;
4362 for (size_t attachmentNdx = 0; attachmentNdx < attachments.size(); attachmentNdx++)
4364 const Attachment& attachment = attachments[attachmentNdx];
4365 const tcu::TextureFormat format = mapVkFormat(attachment.getFormat());
4366 const bool isDepthOrStencilAttachment = hasDepthComponent(format.order) || hasStencilComponent(format.order);
4367 const VkFormatFeatureFlags flags = isDepthOrStencilAttachment? VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT : VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
4368 VkFormatProperties properties;
4370 vk.getPhysicalDeviceFormatProperties(device, attachment.getFormat(), &properties);
4372 if ((properties.optimalTilingFeatures & flags) != flags)
4375 log << TestLog::Message << "Format: " << attachment.getFormat() << " not supported as " << (isDepthOrStencilAttachment ? "depth stencil attachment" : "color attachment") << TestLog::EndMessage;
4380 TCU_THROW(NotSupportedError, "Format not supported");
4383 tcu::TestStatus renderPassTest (Context& context, TestConfig config)
4385 const UVec2 targetSize = config.targetSize;
4386 const UVec2 renderPos = config.renderPos;
4387 const UVec2 renderSize = config.renderSize;
4388 const RenderPass& renderPassInfo = config.renderPass;
4390 TestLog& log = context.getTestContext().getLog();
4391 de::Random rng (config.seed);
4393 vector<bool> attachmentIsLazy;
4394 vector<VkImageUsageFlags> attachmentImageUsage;
4395 vector<Maybe<VkClearValue> > imageClearValues;
4396 vector<Maybe<VkClearValue> > renderPassClearValues;
4398 vector<bool> subpassIsSecondary;
4399 vector<SubpassRenderInfo> subpassRenderInfo;
4400 vector<vector<VkClearColorValue> > subpassColorClearValues;
4402 if (config.allocationKind == ALLOCATION_KIND_DEDICATED)
4404 const std::string extensionName("VK_KHR_dedicated_allocation");
4406 if (!de::contains(context.getDeviceExtensions().begin(), context.getDeviceExtensions().end(), extensionName))
4407 TCU_THROW(NotSupportedError, std::string(extensionName + " is not supported").c_str());
4410 if (!renderPassInfo.getInputAspects().empty())
4412 if (!de::contains(context.getDeviceExtensions().begin(), context.getDeviceExtensions().end(), string("VK_KHR_maintenance2")))
4413 TCU_THROW(NotSupportedError, "Extension VK_KHR_maintenance2 not supported.");
4417 bool requireDepthStencilLayout = false;
4419 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
4421 if (renderPassInfo.getAttachments()[attachmentNdx].getInitialLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR
4422 || renderPassInfo.getAttachments()[attachmentNdx].getInitialLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR
4423 || renderPassInfo.getAttachments()[attachmentNdx].getFinalLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR
4424 || renderPassInfo.getAttachments()[attachmentNdx].getFinalLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
4426 requireDepthStencilLayout = true;
4431 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size() && !requireDepthStencilLayout; subpassNdx++)
4433 const Subpass& subpass (renderPassInfo.getSubpasses()[subpassNdx]);
4435 for (size_t attachmentNdx = 0; attachmentNdx < subpass.getColorAttachments().size(); attachmentNdx++)
4437 if (subpass.getColorAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR
4438 || subpass.getColorAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
4440 requireDepthStencilLayout = true;
4445 for (size_t attachmentNdx = 0; !requireDepthStencilLayout && attachmentNdx < subpass.getInputAttachments().size(); attachmentNdx++)
4447 if (subpass.getInputAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR
4448 || subpass.getInputAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
4450 requireDepthStencilLayout = true;
4455 for (size_t attachmentNdx = 0; !requireDepthStencilLayout && attachmentNdx < subpass.getResolveAttachments().size(); attachmentNdx++)
4457 if (subpass.getResolveAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR
4458 || subpass.getResolveAttachments()[attachmentNdx].getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
4460 requireDepthStencilLayout = true;
4465 if (subpass.getDepthStencilAttachment().getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR
4466 || subpass.getDepthStencilAttachment().getImageLayout() == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)
4468 requireDepthStencilLayout = true;
4473 if (requireDepthStencilLayout && !de::contains(context.getDeviceExtensions().begin(), context.getDeviceExtensions().end(), string("VK_KHR_maintenance2")))
4474 TCU_THROW(NotSupportedError, "VK_KHR_maintenance2 is not supported");
4477 initializeAttachmentIsLazy(attachmentIsLazy, renderPassInfo.getAttachments(), config.imageMemory);
4478 initializeImageClearValues(rng, imageClearValues, renderPassInfo.getAttachments(), attachmentIsLazy);
4479 initializeAttachmentImageUsage(context, attachmentImageUsage, renderPassInfo, attachmentIsLazy, imageClearValues);
4480 initializeRenderPassClearValues(rng, renderPassClearValues, renderPassInfo.getAttachments());
4482 initializeSubpassIsSecondary(subpassIsSecondary, renderPassInfo.getSubpasses(), config.commandBufferTypes);
4483 initializeSubpassClearValues(rng, subpassColorClearValues, renderPassInfo);
4484 initializeSubpassRenderInfo(subpassRenderInfo, rng, renderPassInfo, config);
4486 logTestCaseInfo(log, config, attachmentIsLazy, imageClearValues, renderPassClearValues, subpassRenderInfo);
4488 checkTextureFormatSupport(log, context.getInstanceInterface(), context.getPhysicalDevice(), config.renderPass.getAttachments());
4491 const vk::VkPhysicalDeviceProperties properties = vk::getPhysicalDeviceProperties(context.getInstanceInterface(), context.getPhysicalDevice());
4493 log << TestLog::Message << "Max color attachments: " << properties.limits.maxColorAttachments << TestLog::EndMessage;
4495 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); subpassNdx++)
4497 if (renderPassInfo.getSubpasses()[subpassNdx].getColorAttachments().size() > (size_t)properties.limits.maxColorAttachments)
4498 TCU_THROW(NotSupportedError, "Subpass uses more than maxColorAttachments.");
4503 const InstanceInterface& vki = context.getInstanceInterface();
4504 const VkPhysicalDevice& physDevice = context.getPhysicalDevice();
4505 const VkDevice device = context.getDevice();
4506 const DeviceInterface& vk = context.getDeviceInterface();
4507 const VkQueue queue = context.getUniversalQueue();
4508 const deUint32 queueIndex = context.getUniversalQueueFamilyIndex();
4509 Allocator& allocator = context.getDefaultAllocator();
4511 const Unique<VkRenderPass> renderPass (createRenderPass(vk, device, renderPassInfo));
4512 const Unique<VkCommandPool> commandBufferPool (createCommandPool(vk, device, queueIndex, 0));
4513 const Unique<VkCommandBuffer> initializeImagesCommandBuffer (allocateCommandBuffer(vk, device, *commandBufferPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
4514 const Unique<VkCommandBuffer> renderCommandBuffer (allocateCommandBuffer(vk, device, *commandBufferPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
4515 const Unique<VkCommandBuffer> readImagesToBuffersCommandBuffer (allocateCommandBuffer(vk, device, *commandBufferPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
4517 vector<de::SharedPtr<AttachmentResources> > attachmentResources;
4518 vector<de::SharedPtr<SubpassRenderer> > subpassRenderers;
4519 vector<VkImage> attachmentImages;
4520 vector<VkImageView> attachmentViews;
4521 vector<pair<VkImageView, VkImageView> > inputAttachmentViews;
4523 for (size_t attachmentNdx = 0; attachmentNdx < renderPassInfo.getAttachments().size(); attachmentNdx++)
4525 const Attachment& attachmentInfo = renderPassInfo.getAttachments()[attachmentNdx];
4527 attachmentResources.push_back(de::SharedPtr<AttachmentResources>(new AttachmentResources(vki, physDevice, vk, device, allocator, queueIndex, targetSize, attachmentInfo, attachmentImageUsage[attachmentNdx], config.allocationKind)));
4528 attachmentViews.push_back(attachmentResources[attachmentNdx]->getAttachmentView());
4529 attachmentImages.push_back(attachmentResources[attachmentNdx]->getImage());
4531 inputAttachmentViews.push_back(attachmentResources[attachmentNdx]->getInputAttachmentViews());
4534 beginCommandBuffer(vk, *initializeImagesCommandBuffer, (VkCommandBufferUsageFlags)0, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0);
4535 pushImageInitializationCommands(vk, *initializeImagesCommandBuffer, renderPassInfo.getAttachments(), attachmentResources, queueIndex, imageClearValues);
4536 endCommandBuffer(vk, *initializeImagesCommandBuffer);
4539 const Unique<VkFramebuffer> framebuffer (createFramebuffer(vk, device, *renderPass, targetSize, attachmentViews));
4541 for (size_t subpassNdx = 0; subpassNdx < renderPassInfo.getSubpasses().size(); subpassNdx++)
4542 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)));
4544 beginCommandBuffer(vk, *renderCommandBuffer, (VkCommandBufferUsageFlags)0, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0);
4545 pushRenderPassCommands(vk, *renderCommandBuffer, *renderPass, *framebuffer, subpassRenderers, renderPos, renderSize, renderPassClearValues, config.renderTypes);
4546 endCommandBuffer(vk, *renderCommandBuffer);
4548 beginCommandBuffer(vk, *readImagesToBuffersCommandBuffer, (VkCommandBufferUsageFlags)0, DE_NULL, 0, DE_NULL, VK_FALSE, (VkQueryControlFlags)0, (VkQueryPipelineStatisticFlags)0);
4549 pushReadImagesToBuffers(vk, *readImagesToBuffersCommandBuffer, queueIndex, attachmentResources, renderPassInfo.getAttachments(), attachmentIsLazy, targetSize);
4550 endCommandBuffer(vk, *readImagesToBuffersCommandBuffer);
4552 const VkCommandBuffer commandBuffers[] =
4554 *initializeImagesCommandBuffer,
4555 *renderCommandBuffer,
4556 *readImagesToBuffersCommandBuffer
4558 const Unique<VkFence> fence (createFence(vk, device, 0u));
4560 queueSubmit(vk, queue, DE_LENGTH_OF_ARRAY(commandBuffers), commandBuffers, *fence);
4561 waitForFences(vk, device, 1, &fence.get(), VK_TRUE, ~0ull);
4565 if (logAndVerifyImages(log, vk, device, attachmentResources, attachmentIsLazy, renderPassInfo, renderPassClearValues, imageClearValues, subpassRenderInfo, targetSize, config))
4566 return tcu::TestStatus::pass("Pass");
4568 return tcu::TestStatus::fail("Result verification failed");
4572 static const VkFormat s_coreColorFormats[] =
4574 VK_FORMAT_R5G6B5_UNORM_PACK16,
4579 VK_FORMAT_R8G8_UNORM,
4580 VK_FORMAT_R8G8_SNORM,
4581 VK_FORMAT_R8G8_UINT,
4582 VK_FORMAT_R8G8_SINT,
4583 VK_FORMAT_R8G8B8A8_UNORM,
4584 VK_FORMAT_R8G8B8A8_SNORM,
4585 VK_FORMAT_R8G8B8A8_UINT,
4586 VK_FORMAT_R8G8B8A8_SINT,
4587 VK_FORMAT_R8G8B8A8_SRGB,
4588 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
4589 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
4590 VK_FORMAT_A8B8G8R8_UINT_PACK32,
4591 VK_FORMAT_A8B8G8R8_SINT_PACK32,
4592 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
4593 VK_FORMAT_B8G8R8A8_UNORM,
4594 VK_FORMAT_B8G8R8A8_SRGB,
4595 VK_FORMAT_A2R10G10B10_UNORM_PACK32,
4596 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
4597 VK_FORMAT_A2B10G10R10_UINT_PACK32,
4598 VK_FORMAT_R16_UNORM,
4599 VK_FORMAT_R16_SNORM,
4602 VK_FORMAT_R16_SFLOAT,
4603 VK_FORMAT_R16G16_UNORM,
4604 VK_FORMAT_R16G16_SNORM,
4605 VK_FORMAT_R16G16_UINT,
4606 VK_FORMAT_R16G16_SINT,
4607 VK_FORMAT_R16G16_SFLOAT,
4608 VK_FORMAT_R16G16B16A16_UNORM,
4609 VK_FORMAT_R16G16B16A16_SNORM,
4610 VK_FORMAT_R16G16B16A16_UINT,
4611 VK_FORMAT_R16G16B16A16_SINT,
4612 VK_FORMAT_R16G16B16A16_SFLOAT,
4615 VK_FORMAT_R32_SFLOAT,
4616 VK_FORMAT_R32G32_UINT,
4617 VK_FORMAT_R32G32_SINT,
4618 VK_FORMAT_R32G32_SFLOAT,
4619 VK_FORMAT_R32G32B32A32_UINT,
4620 VK_FORMAT_R32G32B32A32_SINT,
4621 VK_FORMAT_R32G32B32A32_SFLOAT
4624 static const VkFormat s_coreDepthStencilFormats[] =
4626 VK_FORMAT_D16_UNORM,
4628 VK_FORMAT_X8_D24_UNORM_PACK32,
4629 VK_FORMAT_D32_SFLOAT,
4631 VK_FORMAT_D24_UNORM_S8_UINT,
4632 VK_FORMAT_D32_SFLOAT_S8_UINT
4635 void addAttachmentTests (tcu::TestCaseGroup* group, AllocationKind allocationKind)
4637 const deUint32 attachmentCounts[] = { 1, 3, 4, 8 };
4638 const VkAttachmentLoadOp loadOps[] =
4640 VK_ATTACHMENT_LOAD_OP_LOAD,
4641 VK_ATTACHMENT_LOAD_OP_CLEAR,
4642 VK_ATTACHMENT_LOAD_OP_DONT_CARE
4645 const VkAttachmentStoreOp storeOps[] =
4647 VK_ATTACHMENT_STORE_OP_STORE,
4648 VK_ATTACHMENT_STORE_OP_DONT_CARE
4651 const VkImageLayout initialAndFinalColorLayouts[] =
4653 VK_IMAGE_LAYOUT_GENERAL,
4654 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
4655 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
4656 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
4657 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
4660 const VkImageLayout initialAndFinalDepthStencilLayouts[] =
4662 VK_IMAGE_LAYOUT_GENERAL,
4663 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
4664 VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL,
4665 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
4666 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
4667 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
4670 const VkImageLayout subpassLayouts[] =
4672 VK_IMAGE_LAYOUT_GENERAL,
4673 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
4676 const VkImageLayout depthStencilLayouts[] =
4678 VK_IMAGE_LAYOUT_GENERAL,
4679 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
4682 const TestConfig::RenderTypes renderCommands[] =
4684 TestConfig::RENDERTYPES_NONE,
4685 TestConfig::RENDERTYPES_CLEAR,
4686 TestConfig::RENDERTYPES_DRAW,
4687 TestConfig::RENDERTYPES_CLEAR|TestConfig::RENDERTYPES_DRAW,
4690 const TestConfig::CommandBufferTypes commandBuffers[] =
4692 TestConfig::COMMANDBUFFERTYPES_INLINE,
4693 TestConfig::COMMANDBUFFERTYPES_SECONDARY,
4694 TestConfig::COMMANDBUFFERTYPES_INLINE|TestConfig::COMMANDBUFFERTYPES_SECONDARY
4697 const TestConfig::ImageMemory imageMemories[] =
4699 TestConfig::IMAGEMEMORY_STRICT,
4700 TestConfig::IMAGEMEMORY_LAZY,
4701 TestConfig::IMAGEMEMORY_STRICT|TestConfig::IMAGEMEMORY_LAZY
4704 const UVec2 targetSizes[] =
4710 const UVec2 renderPositions[] =
4716 const UVec2 renderSizes[] =
4722 tcu::TestContext& testCtx = group->getTestContext();
4723 de::Random rng (1433774382u);
4725 for (size_t attachmentCountNdx = 0; attachmentCountNdx < DE_LENGTH_OF_ARRAY(attachmentCounts); attachmentCountNdx++)
4727 const deUint32 attachmentCount = attachmentCounts[attachmentCountNdx];
4728 const deUint32 testCaseCount = (attachmentCount == 1 ? 100 : 200);
4729 de::MovePtr<tcu::TestCaseGroup> attachmentCountGroup (new tcu::TestCaseGroup(testCtx, de::toString(attachmentCount).c_str(), de::toString(attachmentCount).c_str()));
4731 for (size_t testCaseNdx = 0; testCaseNdx < testCaseCount; testCaseNdx++)
4733 const bool useDepthStencil = rng.getBool();
4734 VkImageLayout depthStencilLayout = VK_IMAGE_LAYOUT_GENERAL;
4735 vector<Attachment> attachments;
4736 vector<AttachmentReference> colorAttachmentReferences;
4738 for (size_t attachmentNdx = 0; attachmentNdx < attachmentCount; attachmentNdx++)
4740 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
4741 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreColorFormats), DE_ARRAY_END(s_coreColorFormats));
4742 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
4743 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
4745 const VkImageLayout initialLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
4746 const VkImageLayout finalizeLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
4747 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayouts), DE_ARRAY_END(subpassLayouts));
4749 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
4750 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
4752 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
4753 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
4756 if (useDepthStencil)
4758 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
4759 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreDepthStencilFormats), DE_ARRAY_END(s_coreDepthStencilFormats));
4760 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
4761 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
4763 const VkImageLayout initialLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts));
4764 const VkImageLayout finalizeLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts));
4766 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
4767 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
4769 depthStencilLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(depthStencilLayouts), DE_ARRAY_END(depthStencilLayouts));
4770 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
4774 const TestConfig::RenderTypes render = rng.choose<TestConfig::RenderTypes>(DE_ARRAY_BEGIN(renderCommands), DE_ARRAY_END(renderCommands));
4775 const TestConfig::CommandBufferTypes commandBuffer = rng.choose<TestConfig::CommandBufferTypes>(DE_ARRAY_BEGIN(commandBuffers), DE_ARRAY_END(commandBuffers));
4776 const TestConfig::ImageMemory imageMemory = rng.choose<TestConfig::ImageMemory>(DE_ARRAY_BEGIN(imageMemories), DE_ARRAY_END(imageMemories));
4777 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>()));
4778 const vector<SubpassDependency> deps;
4780 const string testCaseName = de::toString(attachmentCountNdx * testCaseCount + testCaseNdx);
4781 const RenderPass renderPass (attachments, subpasses, deps);
4782 const UVec2 targetSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(targetSizes), DE_ARRAY_END(targetSizes));
4783 const UVec2 renderPos = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderPositions), DE_ARRAY_END(renderPositions));
4784 const UVec2 renderSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderSizes), DE_ARRAY_END(renderSizes));
4786 addFunctionCaseWithPrograms<TestConfig>(attachmentCountGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, TestConfig(renderPass, render, commandBuffer, imageMemory, targetSize, renderPos, renderSize, 1293809, allocationKind));
4790 group->addChild(attachmentCountGroup.release());
4794 template<typename T>
4795 T chooseRandom (de::Random& rng, const set<T>& values)
4797 size_t ndx = ((size_t)rng.getUint32()) % values.size();
4798 typename set<T>::const_iterator iter = values.begin();
4800 for (; ndx > 0; ndx--)
4806 void addAttachmentAllocationTests (tcu::TestCaseGroup* group, AllocationKind allocationKind)
4808 const deUint32 attachmentCounts[] = { 4, 8 };
4809 const VkAttachmentLoadOp loadOps[] =
4811 VK_ATTACHMENT_LOAD_OP_LOAD,
4812 VK_ATTACHMENT_LOAD_OP_CLEAR,
4813 VK_ATTACHMENT_LOAD_OP_DONT_CARE
4816 const VkAttachmentStoreOp storeOps[] =
4818 VK_ATTACHMENT_STORE_OP_STORE,
4819 VK_ATTACHMENT_STORE_OP_DONT_CARE
4822 const VkImageLayout initialAndFinalColorLayouts[] =
4824 VK_IMAGE_LAYOUT_GENERAL,
4825 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
4826 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
4827 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
4828 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
4831 const VkImageLayout initialAndFinalDepthStencilLayouts[] =
4833 VK_IMAGE_LAYOUT_GENERAL,
4834 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
4835 VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL,
4836 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
4837 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
4838 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
4841 const VkImageLayout subpassLayouts[] =
4843 VK_IMAGE_LAYOUT_GENERAL,
4844 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
4849 // Each pass uses one more attachmen than previous one
4850 ALLOCATIONTYPE_GROW,
4851 // Each pass uses one less attachment than previous one
4852 ALLOCATIONTYPE_SHRINK,
4853 // Each pass drops one attachment and picks up new one
4854 ALLOCATIONTYPE_ROLL,
4855 // Start by growing and end by shrinking
4856 ALLOCATIONTYPE_GROW_SHRINK,
4857 // Each subpass has single input and single output attachment
4858 ALLOCATIONTYPE_IO_CHAIN,
4859 // Each subpass has multiple inputs and multiple outputs attachment
4860 ALLOCATIONTYPE_IO_GENERIC
4863 const AllocationType allocationTypes[] =
4865 ALLOCATIONTYPE_GROW,
4866 ALLOCATIONTYPE_SHRINK,
4867 ALLOCATIONTYPE_ROLL,
4868 ALLOCATIONTYPE_GROW_SHRINK,
4869 ALLOCATIONTYPE_IO_CHAIN,
4870 ALLOCATIONTYPE_IO_GENERIC
4873 const char* const allocationTypeStr[] =
4879 "input_output_chain",
4883 const TestConfig::RenderTypes renderCommands[] =
4885 TestConfig::RENDERTYPES_NONE,
4886 TestConfig::RENDERTYPES_CLEAR,
4887 TestConfig::RENDERTYPES_DRAW,
4888 TestConfig::RENDERTYPES_CLEAR|TestConfig::RENDERTYPES_DRAW,
4891 const TestConfig::CommandBufferTypes commandBuffers[] =
4893 TestConfig::COMMANDBUFFERTYPES_INLINE,
4894 TestConfig::COMMANDBUFFERTYPES_SECONDARY,
4895 TestConfig::COMMANDBUFFERTYPES_INLINE|TestConfig::COMMANDBUFFERTYPES_SECONDARY
4898 const TestConfig::ImageMemory imageMemories[] =
4900 TestConfig::IMAGEMEMORY_STRICT,
4901 TestConfig::IMAGEMEMORY_LAZY,
4902 TestConfig::IMAGEMEMORY_STRICT|TestConfig::IMAGEMEMORY_LAZY
4905 const UVec2 targetSizes[] =
4911 const UVec2 renderPositions[] =
4917 const UVec2 renderSizes[] =
4923 tcu::TestContext& testCtx = group->getTestContext();
4924 de::Random rng (3700649827u);
4926 for (size_t allocationTypeNdx = 0; allocationTypeNdx < DE_LENGTH_OF_ARRAY(allocationTypes); allocationTypeNdx++)
4928 const AllocationType allocationType = allocationTypes[allocationTypeNdx];
4929 const size_t testCaseCount = 100;
4930 de::MovePtr<tcu::TestCaseGroup> allocationTypeGroup (new tcu::TestCaseGroup(testCtx, allocationTypeStr[allocationTypeNdx], allocationTypeStr[allocationTypeNdx]));
4932 for (size_t testCaseNdx = 0; testCaseNdx < testCaseCount; testCaseNdx++)
4934 if (allocationType == ALLOCATIONTYPE_IO_GENERIC)
4936 const deUint32 attachmentCount = 4u + rng.getUint32() % 31u;
4937 const deUint32 subpassCount = 4u + rng.getUint32() % 31u;
4938 vector<Attachment> attachments;
4940 set<deUint32> definedAttachments;
4942 vector<Subpass> subpasses;
4943 set<deUint32> colorAttachments;
4944 set<deUint32> depthStencilAttachments;
4946 for (deUint32 attachmentIndex = 0; attachmentIndex < attachmentCount; attachmentIndex++)
4948 const bool isDepthStencilAttachment = rng.getFloat() < 0.01f;
4949 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
4950 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
4951 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
4953 const VkImageLayout initialLayout = isDepthStencilAttachment
4954 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
4955 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
4956 const VkImageLayout finalizeLayout = isDepthStencilAttachment
4957 ? rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalDepthStencilLayouts), DE_ARRAY_END(initialAndFinalDepthStencilLayouts))
4958 : rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
4960 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
4961 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
4963 if (isDepthStencilAttachment)
4965 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreDepthStencilFormats), DE_ARRAY_END(s_coreDepthStencilFormats));
4967 if (loadOp == VK_ATTACHMENT_LOAD_OP_LOAD || loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR
4968 || stencilLoadOp == VK_ATTACHMENT_LOAD_OP_LOAD || stencilLoadOp == VK_ATTACHMENT_LOAD_OP_CLEAR)
4969 definedAttachments.insert(attachmentIndex);
4971 depthStencilAttachments.insert(attachmentIndex);
4973 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
4977 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreColorFormats), DE_ARRAY_END(s_coreColorFormats));
4979 if (loadOp == VK_ATTACHMENT_LOAD_OP_LOAD || loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR)
4980 definedAttachments.insert(attachmentIndex);
4982 colorAttachments.insert(attachmentIndex);
4984 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
4987 vector<Maybe<deUint32> > lastUseOfAttachment (attachments.size(), nothing<deUint32>());
4988 vector<SubpassDependency> deps;
4990 for (deUint32 subpassIndex = 0; subpassIndex < subpassCount; subpassIndex++)
4992 const deUint32 colorAttachmentCount = depthStencilAttachments.empty()
4993 ? 1 + rng.getUint32() % de::min(4u, (deUint32)colorAttachments.size())
4994 : rng.getUint32() % (de::min(4u, (deUint32)colorAttachments.size()) + 1u);
4995 const deUint32 inputAttachmentCount = rng.getUint32() % (deUint32)(de::min<size_t>(4, definedAttachments.size()) + 1);
4996 const bool useDepthStencilAttachment = !depthStencilAttachments.empty() && (colorAttachmentCount == 0 || rng.getBool());
4997 std::vector<deUint32> subpassColorAttachments (colorAttachmentCount);
4998 std::vector<deUint32> subpassInputAttachments (inputAttachmentCount);
4999 Maybe<deUint32> depthStencilAttachment (useDepthStencilAttachment
5000 ? just(chooseRandom(rng, depthStencilAttachments))
5001 : nothing<deUint32>());
5002 std::vector<deUint32> subpassPreserveAttachments;
5004 rng.choose(colorAttachments.begin(), colorAttachments.end(), subpassColorAttachments.begin(), colorAttachmentCount);
5005 rng.choose(definedAttachments.begin(), definedAttachments.end(), subpassInputAttachments.begin(), inputAttachmentCount);
5007 for (size_t colorAttachmentNdx = 0; colorAttachmentNdx < subpassColorAttachments.size(); colorAttachmentNdx++)
5008 definedAttachments.insert(subpassColorAttachments[colorAttachmentNdx]);
5010 if (depthStencilAttachment)
5011 definedAttachments.insert(*depthStencilAttachment);
5014 std::vector<AttachmentReference> inputAttachmentReferences;
5015 std::vector<AttachmentReference> colorAttachmentReferences;
5016 AttachmentReference depthStencilAttachmentReference (VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL);
5018 for (size_t colorAttachmentNdx = 0; colorAttachmentNdx < subpassColorAttachments.size(); colorAttachmentNdx++)
5020 const deUint32 colorAttachmentIndex = subpassColorAttachments[colorAttachmentNdx];
5021 // \todo [mika 2016-08-25] Check if attachment is not used as input attachment and use other image layouts
5022 const VkImageLayout subpassLayout = VK_IMAGE_LAYOUT_GENERAL;
5024 if (lastUseOfAttachment[colorAttachmentIndex])
5026 const bool byRegion = rng.getBool();
5028 deps.push_back(SubpassDependency(*lastUseOfAttachment[colorAttachmentIndex], subpassIndex,
5029 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5030 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5031 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5032 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5034 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5035 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5036 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5037 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5039 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
5040 VK_ACCESS_COLOR_ATTACHMENT_READ_BIT,
5042 byRegion ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u));
5045 lastUseOfAttachment[colorAttachmentIndex] = just(subpassIndex);
5047 colorAttachmentReferences.push_back(AttachmentReference((deUint32)subpassColorAttachments[colorAttachmentNdx], subpassLayout));
5050 for (size_t inputAttachmentNdx = 0; inputAttachmentNdx < subpassInputAttachments.size(); inputAttachmentNdx++)
5052 const deUint32 inputAttachmentIndex = subpassInputAttachments[inputAttachmentNdx];
5053 // \todo [mika 2016-08-25] Check if attachment is not used as color attachment and use other image layouts
5054 const VkImageLayout subpassLayout = VK_IMAGE_LAYOUT_GENERAL;
5056 if(lastUseOfAttachment[inputAttachmentIndex])
5058 if(*lastUseOfAttachment[inputAttachmentIndex] == subpassIndex)
5060 deps.push_back(SubpassDependency(subpassIndex, subpassIndex,
5061 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5062 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5063 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5064 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5066 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5067 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5068 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5069 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5071 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
5072 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5074 VK_DEPENDENCY_BY_REGION_BIT));
5078 const bool byRegion = rng.getBool();
5080 deps.push_back(SubpassDependency(*lastUseOfAttachment[inputAttachmentIndex], subpassIndex,
5081 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5082 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5083 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5084 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5086 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5087 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5088 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5089 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5091 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
5092 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5094 byRegion ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u));
5097 lastUseOfAttachment[inputAttachmentIndex] = just(subpassIndex);
5099 inputAttachmentReferences.push_back(AttachmentReference((deUint32)subpassInputAttachments[inputAttachmentNdx], subpassLayout));
5103 if (depthStencilAttachment)
5105 // \todo [mika 2016-08-25] Check if attachment is not used as input attachment and use other image layouts
5106 if (lastUseOfAttachment[*depthStencilAttachment])
5108 if(*lastUseOfAttachment[*depthStencilAttachment] == subpassIndex)
5110 deps.push_back(SubpassDependency(subpassIndex, subpassIndex,
5111 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5112 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5113 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5114 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5116 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5117 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5118 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5119 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5121 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
5122 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5124 VK_DEPENDENCY_BY_REGION_BIT));
5128 const bool byRegion = rng.getBool();
5130 deps.push_back(SubpassDependency(*lastUseOfAttachment[*depthStencilAttachment], subpassIndex,
5131 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5132 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5133 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5134 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5136 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5137 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5138 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5139 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5141 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
5142 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5144 byRegion ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u));
5148 lastUseOfAttachment[*depthStencilAttachment] = just(subpassIndex);
5149 depthStencilAttachmentReference = AttachmentReference(*depthStencilAttachment, VK_IMAGE_LAYOUT_GENERAL);
5152 depthStencilAttachmentReference = AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL);
5154 vector<deUint32> preserveAttachments;
5155 for (deUint32 attachmentIndex = 0; attachmentIndex < (deUint32)attachments.size(); attachmentIndex++)
5157 if (lastUseOfAttachment[attachmentIndex] && (*lastUseOfAttachment[attachmentIndex]) != subpassIndex)
5158 preserveAttachments.push_back(attachmentIndex);
5161 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
5162 inputAttachmentReferences,
5163 colorAttachmentReferences,
5164 vector<AttachmentReference>(),
5165 depthStencilAttachmentReference,
5166 preserveAttachments));
5170 const TestConfig::RenderTypes render = rng.choose<TestConfig::RenderTypes>(DE_ARRAY_BEGIN(renderCommands), DE_ARRAY_END(renderCommands));
5171 const TestConfig::CommandBufferTypes commandBuffer = rng.choose<TestConfig::CommandBufferTypes>(DE_ARRAY_BEGIN(commandBuffers), DE_ARRAY_END(commandBuffers));
5172 const TestConfig::ImageMemory imageMemory = rng.choose<TestConfig::ImageMemory>(DE_ARRAY_BEGIN(imageMemories), DE_ARRAY_END(imageMemories));
5174 const string testCaseName = de::toString(testCaseNdx);
5175 const UVec2 targetSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(targetSizes), DE_ARRAY_END(targetSizes));
5176 const UVec2 renderPos = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderPositions), DE_ARRAY_END(renderPositions));
5177 const UVec2 renderSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderSizes), DE_ARRAY_END(renderSizes));
5179 const RenderPass renderPass (attachments, subpasses, deps);
5181 addFunctionCaseWithPrograms<TestConfig>(allocationTypeGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, TestConfig(renderPass, render, commandBuffer, imageMemory, targetSize, renderPos, renderSize, 80329, allocationKind));
5186 const deUint32 attachmentCount = rng.choose<deUint32>(DE_ARRAY_BEGIN(attachmentCounts), DE_ARRAY_END(attachmentCounts));
5187 vector<Attachment> attachments;
5188 vector<Subpass> subpasses;
5190 for (size_t attachmentNdx = 0; attachmentNdx < attachmentCount; attachmentNdx++)
5192 const VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT;
5193 const VkFormat format = rng.choose<VkFormat>(DE_ARRAY_BEGIN(s_coreColorFormats), DE_ARRAY_END(s_coreColorFormats));
5194 const VkAttachmentLoadOp loadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5195 const VkAttachmentStoreOp storeOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5197 const VkImageLayout initialLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
5198 const VkImageLayout finalizeLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(initialAndFinalColorLayouts), DE_ARRAY_END(initialAndFinalColorLayouts));
5200 const VkAttachmentLoadOp stencilLoadOp = rng.choose<VkAttachmentLoadOp>(DE_ARRAY_BEGIN(loadOps), DE_ARRAY_END(loadOps));
5201 const VkAttachmentStoreOp stencilStoreOp = rng.choose<VkAttachmentStoreOp>(DE_ARRAY_BEGIN(storeOps), DE_ARRAY_END(storeOps));
5203 attachments.push_back(Attachment(format, sampleCount, loadOp, storeOp, stencilLoadOp, stencilStoreOp, initialLayout, finalizeLayout));
5206 if (allocationType == ALLOCATIONTYPE_GROW)
5208 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
5210 vector<AttachmentReference> colorAttachmentReferences;
5212 for (size_t attachmentNdx = 0; attachmentNdx < subpassNdx + 1; attachmentNdx++)
5214 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayouts), DE_ARRAY_END(subpassLayouts));
5216 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
5219 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
5220 vector<AttachmentReference>(),
5221 colorAttachmentReferences,
5222 vector<AttachmentReference>(),
5223 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5224 vector<deUint32>()));
5227 else if (allocationType == ALLOCATIONTYPE_SHRINK)
5229 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
5231 vector<AttachmentReference> colorAttachmentReferences;
5233 for (size_t attachmentNdx = 0; attachmentNdx < (attachmentCount - subpassNdx); attachmentNdx++)
5235 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayouts), DE_ARRAY_END(subpassLayouts));
5237 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
5240 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
5241 vector<AttachmentReference>(),
5242 colorAttachmentReferences,
5243 vector<AttachmentReference>(),
5244 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5245 vector<deUint32>()));
5248 else if (allocationType == ALLOCATIONTYPE_ROLL)
5250 for (size_t subpassNdx = 0; subpassNdx < attachmentCount / 2; subpassNdx++)
5252 vector<AttachmentReference> colorAttachmentReferences;
5254 for (size_t attachmentNdx = 0; attachmentNdx < attachmentCount / 2; attachmentNdx++)
5256 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayouts), DE_ARRAY_END(subpassLayouts));
5258 colorAttachmentReferences.push_back(AttachmentReference((deUint32)(subpassNdx + attachmentNdx), subpassLayout));
5261 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
5262 vector<AttachmentReference>(),
5263 colorAttachmentReferences,
5264 vector<AttachmentReference>(),
5265 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5266 vector<deUint32>()));
5269 else if (allocationType == ALLOCATIONTYPE_GROW_SHRINK)
5271 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
5273 vector<AttachmentReference> colorAttachmentReferences;
5275 for (size_t attachmentNdx = 0; attachmentNdx < subpassNdx + 1; attachmentNdx++)
5277 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayouts), DE_ARRAY_END(subpassLayouts));
5279 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
5282 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
5283 vector<AttachmentReference>(),
5284 colorAttachmentReferences,
5285 vector<AttachmentReference>(),
5286 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5287 vector<deUint32>()));
5290 for (size_t subpassNdx = 0; subpassNdx < attachmentCount; subpassNdx++)
5292 vector<AttachmentReference> colorAttachmentReferences;
5294 for (size_t attachmentNdx = 0; attachmentNdx < (attachmentCount - subpassNdx); attachmentNdx++)
5296 const VkImageLayout subpassLayout = rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayouts), DE_ARRAY_END(subpassLayouts));
5298 colorAttachmentReferences.push_back(AttachmentReference((deUint32)attachmentNdx, subpassLayout));
5301 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
5302 vector<AttachmentReference>(),
5303 colorAttachmentReferences,
5304 vector<AttachmentReference>(),
5305 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5306 vector<deUint32>()));
5309 else if (allocationType == ALLOCATIONTYPE_IO_CHAIN)
5311 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
5312 vector<AttachmentReference>(),
5313 vector<AttachmentReference>(1, AttachmentReference(0, rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayouts), DE_ARRAY_END(subpassLayouts)))),
5314 vector<AttachmentReference>(),
5315 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5316 vector<deUint32>()));
5318 for (size_t subpassNdx = 1; subpassNdx < attachmentCount; subpassNdx++)
5320 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS, 0u,
5321 vector<AttachmentReference>(1, AttachmentReference((deUint32)(subpassNdx - 1), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL)),
5322 vector<AttachmentReference>(1, AttachmentReference((deUint32)(subpassNdx), rng.choose<VkImageLayout>(DE_ARRAY_BEGIN(subpassLayouts), DE_ARRAY_END(subpassLayouts)))),
5323 vector<AttachmentReference>(),
5324 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5325 vector<deUint32>()));
5329 DE_FATAL("Unknown allocation type");
5332 const TestConfig::RenderTypes render = rng.choose<TestConfig::RenderTypes>(DE_ARRAY_BEGIN(renderCommands), DE_ARRAY_END(renderCommands));
5333 const TestConfig::CommandBufferTypes commandBuffer = rng.choose<TestConfig::CommandBufferTypes>(DE_ARRAY_BEGIN(commandBuffers), DE_ARRAY_END(commandBuffers));
5334 const TestConfig::ImageMemory imageMemory = rng.choose<TestConfig::ImageMemory>(DE_ARRAY_BEGIN(imageMemories), DE_ARRAY_END(imageMemories));
5336 const string testCaseName = de::toString(testCaseNdx);
5337 const UVec2 targetSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(targetSizes), DE_ARRAY_END(targetSizes));
5338 const UVec2 renderPos = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderPositions), DE_ARRAY_END(renderPositions));
5339 const UVec2 renderSize = rng.choose<UVec2>(DE_ARRAY_BEGIN(renderSizes), DE_ARRAY_END(renderSizes));
5341 vector<SubpassDependency> deps;
5343 for (size_t subpassNdx = 0; subpassNdx < subpasses.size() - 1; subpassNdx++)
5345 const bool byRegion = rng.getBool();
5346 deps.push_back(SubpassDependency((deUint32)subpassNdx, (deUint32)subpassNdx + 1,
5347 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5348 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5349 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5350 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5352 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
5353 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
5354 | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
5355 | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
5357 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
5358 VK_ACCESS_COLOR_ATTACHMENT_READ_BIT,
5360 byRegion ? (VkDependencyFlags)VK_DEPENDENCY_BY_REGION_BIT : 0u));
5363 const RenderPass renderPass (attachments, subpasses, deps);
5365 addFunctionCaseWithPrograms<TestConfig>(allocationTypeGroup.get(), testCaseName.c_str(), testCaseName.c_str(), createTestShaders, renderPassTest, TestConfig(renderPass, render, commandBuffer, imageMemory, targetSize, renderPos, renderSize, 80329, allocationKind));
5369 group->addChild(allocationTypeGroup.release());
5373 void addSimpleTests (tcu::TestCaseGroup* group, AllocationKind allocationKind)
5375 const UVec2 targetSize (64, 64);
5376 const UVec2 renderPos (0, 0);
5377 const UVec2 renderSize (64, 64);
5381 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_R8G8B8A8_UNORM,
5382 VK_SAMPLE_COUNT_1_BIT,
5383 VK_ATTACHMENT_LOAD_OP_CLEAR,
5384 VK_ATTACHMENT_STORE_OP_STORE,
5385 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5386 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5387 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5388 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
5389 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5391 vector<AttachmentReference>(),
5392 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
5393 vector<AttachmentReference>(),
5394 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5395 vector<deUint32>())),
5396 vector<SubpassDependency>());
5398 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));
5403 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_X8_D24_UNORM_PACK32,
5404 VK_SAMPLE_COUNT_1_BIT,
5405 VK_ATTACHMENT_LOAD_OP_CLEAR,
5406 VK_ATTACHMENT_STORE_OP_STORE,
5407 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5408 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5409 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5410 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
5411 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5413 vector<AttachmentReference>(),
5414 vector<AttachmentReference>(),
5415 vector<AttachmentReference>(),
5416 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
5417 vector<deUint32>())),
5418 vector<SubpassDependency>());
5420 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));
5425 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_S8_UINT,
5426 VK_SAMPLE_COUNT_1_BIT,
5427 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5428 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5429 VK_ATTACHMENT_LOAD_OP_CLEAR,
5430 VK_ATTACHMENT_STORE_OP_STORE,
5431 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5432 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
5433 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5435 vector<AttachmentReference>(),
5436 vector<AttachmentReference>(),
5437 vector<AttachmentReference>(),
5438 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
5439 vector<deUint32>())),
5440 vector<SubpassDependency>());
5442 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));
5447 const RenderPass renderPass (vector<Attachment>(1, Attachment(VK_FORMAT_D24_UNORM_S8_UINT,
5448 VK_SAMPLE_COUNT_1_BIT,
5449 VK_ATTACHMENT_LOAD_OP_CLEAR,
5450 VK_ATTACHMENT_STORE_OP_STORE,
5451 VK_ATTACHMENT_LOAD_OP_CLEAR,
5452 VK_ATTACHMENT_STORE_OP_STORE,
5453 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5454 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
5455 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5457 vector<AttachmentReference>(),
5458 vector<AttachmentReference>(),
5459 vector<AttachmentReference>(),
5460 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
5461 vector<deUint32>())),
5462 vector<SubpassDependency>());
5464 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));
5469 const Attachment attachments[] =
5471 Attachment(VK_FORMAT_R8G8B8A8_UNORM,
5472 VK_SAMPLE_COUNT_1_BIT,
5473 VK_ATTACHMENT_LOAD_OP_CLEAR,
5474 VK_ATTACHMENT_STORE_OP_STORE,
5475 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5476 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5477 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5478 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL),
5479 Attachment(VK_FORMAT_X8_D24_UNORM_PACK32,
5480 VK_SAMPLE_COUNT_1_BIT,
5481 VK_ATTACHMENT_LOAD_OP_CLEAR,
5482 VK_ATTACHMENT_STORE_OP_STORE,
5483 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5484 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5485 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5486 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
5489 const RenderPass renderPass (vector<Attachment>(DE_ARRAY_BEGIN(attachments), DE_ARRAY_END(attachments)),
5490 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5492 vector<AttachmentReference>(),
5493 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
5494 vector<AttachmentReference>(),
5495 AttachmentReference(1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
5496 vector<deUint32>())),
5497 vector<SubpassDependency>());
5499 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));
5504 const Attachment attachments[] =
5506 Attachment(VK_FORMAT_R8G8B8A8_UNORM,
5507 VK_SAMPLE_COUNT_1_BIT,
5508 VK_ATTACHMENT_LOAD_OP_CLEAR,
5509 VK_ATTACHMENT_STORE_OP_STORE,
5510 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5511 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5512 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5513 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL),
5514 Attachment(VK_FORMAT_S8_UINT,
5515 VK_SAMPLE_COUNT_1_BIT,
5516 VK_ATTACHMENT_LOAD_OP_CLEAR,
5517 VK_ATTACHMENT_STORE_OP_STORE,
5518 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5519 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5520 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5521 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
5524 const RenderPass renderPass (vector<Attachment>(DE_ARRAY_BEGIN(attachments), DE_ARRAY_END(attachments)),
5525 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5527 vector<AttachmentReference>(),
5528 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
5529 vector<AttachmentReference>(),
5530 AttachmentReference(1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
5531 vector<deUint32>())),
5532 vector<SubpassDependency>());
5535 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));
5538 // color_depth_stencil
5540 const Attachment attachments[] =
5542 Attachment(VK_FORMAT_R8G8B8A8_UNORM,
5543 VK_SAMPLE_COUNT_1_BIT,
5544 VK_ATTACHMENT_LOAD_OP_CLEAR,
5545 VK_ATTACHMENT_STORE_OP_STORE,
5546 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5547 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5548 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5549 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL),
5550 Attachment(VK_FORMAT_D24_UNORM_S8_UINT,
5551 VK_SAMPLE_COUNT_1_BIT,
5552 VK_ATTACHMENT_LOAD_OP_CLEAR,
5553 VK_ATTACHMENT_STORE_OP_STORE,
5554 VK_ATTACHMENT_LOAD_OP_CLEAR,
5555 VK_ATTACHMENT_STORE_OP_STORE,
5556 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5557 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
5560 const RenderPass renderPass (vector<Attachment>(DE_ARRAY_BEGIN(attachments), DE_ARRAY_END(attachments)),
5561 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5563 vector<AttachmentReference>(),
5564 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
5565 vector<AttachmentReference>(),
5566 AttachmentReference(1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
5567 vector<deUint32>())),
5568 vector<SubpassDependency>());
5570 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));
5575 const RenderPass renderPass (vector<Attachment>(),
5576 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5578 vector<AttachmentReference>(),
5579 vector<AttachmentReference>(),
5580 vector<AttachmentReference>(),
5581 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5582 vector<deUint32>())),
5583 vector<SubpassDependency>());
5585 addFunctionCaseWithPrograms<TestConfig>(group, "no_attachments", "No attachments case.", createTestShaders, renderPassTest, TestConfig(renderPass, TestConfig::RENDERTYPES_DRAW, TestConfig::COMMANDBUFFERTYPES_INLINE, TestConfig::IMAGEMEMORY_STRICT, targetSize, renderPos, renderSize, 90239, allocationKind));
5589 std::string formatToName (VkFormat format)
5591 const std::string formatStr = de::toString(format);
5592 const std::string prefix = "VK_FORMAT_";
5594 DE_ASSERT(formatStr.substr(0, prefix.length()) == prefix);
5596 return de::toLower(formatStr.substr(prefix.length()));
5599 void addFormatTests (tcu::TestCaseGroup* group, AllocationKind allocationKind)
5601 tcu::TestContext& testCtx = group->getTestContext();
5603 const UVec2 targetSize (64, 64);
5604 const UVec2 renderPos (0, 0);
5605 const UVec2 renderSize (64, 64);
5609 const char* const str;
5610 const VkAttachmentStoreOp op;
5613 { "store", VK_ATTACHMENT_STORE_OP_STORE },
5614 { "dont_care", VK_ATTACHMENT_STORE_OP_DONT_CARE }
5619 const char* const str;
5620 const VkAttachmentLoadOp op;
5623 { "clear", VK_ATTACHMENT_LOAD_OP_CLEAR },
5624 { "load", VK_ATTACHMENT_LOAD_OP_LOAD },
5625 { "dont_care", VK_ATTACHMENT_LOAD_OP_DONT_CARE }
5630 const char* const str;
5631 const TestConfig::RenderTypes types;
5634 { "clear", TestConfig::RENDERTYPES_CLEAR },
5635 { "draw", TestConfig::RENDERTYPES_DRAW },
5636 { "clear_draw", TestConfig::RENDERTYPES_CLEAR|TestConfig::RENDERTYPES_DRAW }
5640 for (size_t formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_coreColorFormats); formatNdx++)
5642 const VkFormat format = s_coreColorFormats[formatNdx];
5643 de::MovePtr<tcu::TestCaseGroup> formatGroup (new tcu::TestCaseGroup(testCtx, formatToName(format).c_str(), de::toString(format).c_str()));
5645 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
5647 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
5648 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
5650 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
5652 const RenderPass renderPass (vector<Attachment>(1, Attachment(format,
5653 VK_SAMPLE_COUNT_1_BIT,
5655 VK_ATTACHMENT_STORE_OP_STORE,
5656 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5657 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5658 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5659 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
5660 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5662 vector<AttachmentReference>(),
5663 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
5664 vector<AttachmentReference>(),
5665 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5666 vector<deUint32>())),
5667 vector<SubpassDependency>());
5669 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));
5672 formatGroup->addChild(loadOpGroup.release());
5676 de::MovePtr<tcu::TestCaseGroup> inputGroup (new tcu::TestCaseGroup(testCtx, "input", "Test attachment format as input"));
5678 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
5680 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
5681 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
5683 for (size_t storeOpNdx = 0; storeOpNdx < DE_LENGTH_OF_ARRAY(storeOps); storeOpNdx++)
5685 const VkAttachmentStoreOp storeOp = storeOps[storeOpNdx].op;
5686 de::MovePtr<tcu::TestCaseGroup> storeOpGroup (new tcu::TestCaseGroup(testCtx, storeOps[storeOpNdx].str, storeOps[storeOpNdx].str));
5688 for (size_t useInputAspectNdx = 0; useInputAspectNdx < 2; useInputAspectNdx++)
5690 const bool useInputAspect = useInputAspectNdx != 0;
5692 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
5695 vector<Attachment> attachments;
5696 vector<Subpass> subpasses;
5697 vector<SubpassDependency> deps;
5698 vector<VkInputAttachmentAspectReferenceKHR> inputAspects;
5700 attachments.push_back(Attachment(format,
5701 VK_SAMPLE_COUNT_1_BIT,
5704 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5705 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5706 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5707 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
5709 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
5710 VK_SAMPLE_COUNT_1_BIT,
5711 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5712 VK_ATTACHMENT_STORE_OP_STORE,
5713 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5714 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5715 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5716 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
5718 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5720 vector<AttachmentReference>(),
5721 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
5722 vector<AttachmentReference>(),
5723 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5724 vector<deUint32>()));
5725 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5727 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL)),
5728 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
5729 vector<AttachmentReference>(),
5730 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5731 vector<deUint32>()));
5733 deps.push_back(SubpassDependency(0, 1,
5735 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
5736 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
5738 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
5739 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5740 vk::VK_DEPENDENCY_BY_REGION_BIT));
5744 const VkInputAttachmentAspectReferenceKHR inputAspect =
5748 VK_IMAGE_ASPECT_COLOR_BIT
5751 inputAspects.push_back(inputAspect);
5755 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
5757 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));
5761 vector<Attachment> attachments;
5762 vector<Subpass> subpasses;
5763 vector<SubpassDependency> deps;
5764 vector<VkInputAttachmentAspectReferenceKHR> inputAspects;
5766 attachments.push_back(Attachment(format,
5767 VK_SAMPLE_COUNT_1_BIT,
5770 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5771 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5772 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5773 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
5775 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5777 vector<AttachmentReference>(),
5778 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
5779 vector<AttachmentReference>(),
5780 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5781 vector<deUint32>()));
5782 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5784 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL)),
5785 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL)),
5786 vector<AttachmentReference>(),
5787 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5788 vector<deUint32>()));
5790 deps.push_back(SubpassDependency(0, 1,
5791 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
5792 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
5794 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
5795 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5796 vk::VK_DEPENDENCY_BY_REGION_BIT));
5800 const VkInputAttachmentAspectReferenceKHR inputAspect =
5804 VK_IMAGE_ASPECT_COLOR_BIT
5807 inputAspects.push_back(inputAspect);
5811 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
5813 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));
5819 loadOpGroup->addChild(storeOpGroup.release());
5822 inputGroup->addChild(loadOpGroup.release());
5825 formatGroup->addChild(inputGroup.release());
5828 group->addChild(formatGroup.release());
5831 // Depth stencil formats
5832 for (size_t formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(s_coreDepthStencilFormats); formatNdx++)
5834 const VkFormat vkFormat = s_coreDepthStencilFormats[formatNdx];
5835 const tcu::TextureFormat format = mapVkFormat(vkFormat);
5836 const bool isStencilAttachment = hasStencilComponent(format.order);
5837 const bool isDepthAttachment = hasDepthComponent(format.order);
5838 de::MovePtr<tcu::TestCaseGroup> formatGroup (new tcu::TestCaseGroup(testCtx, formatToName(vkFormat).c_str(), de::toString(vkFormat).c_str()));
5840 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
5842 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
5843 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
5845 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
5848 const RenderPass renderPass (vector<Attachment>(1, Attachment(vkFormat,
5849 VK_SAMPLE_COUNT_1_BIT,
5850 isDepthAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5851 isDepthAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
5852 isStencilAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5853 isStencilAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
5854 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5855 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
5856 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5858 vector<AttachmentReference>(),
5859 vector<AttachmentReference>(),
5860 vector<AttachmentReference>(),
5861 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
5862 vector<deUint32>())),
5863 vector<SubpassDependency>());
5865 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));
5868 if (isStencilAttachment && isDepthAttachment)
5871 const RenderPass renderPass (vector<Attachment>(1, Attachment(vkFormat,
5872 VK_SAMPLE_COUNT_1_BIT,
5873 isDepthAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5874 isDepthAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
5875 isStencilAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5876 isStencilAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
5877 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5878 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
5879 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5881 vector<AttachmentReference>(),
5882 vector<AttachmentReference>(),
5883 vector<AttachmentReference>(),
5884 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR),
5885 vector<deUint32>())),
5886 vector<SubpassDependency>());
5888 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));
5892 const RenderPass renderPass (vector<Attachment>(1, Attachment(vkFormat,
5893 VK_SAMPLE_COUNT_1_BIT,
5894 isDepthAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5895 isDepthAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
5896 isStencilAttachment ? loadOp : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5897 isStencilAttachment ? VK_ATTACHMENT_STORE_OP_STORE :VK_ATTACHMENT_STORE_OP_DONT_CARE,
5898 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5899 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)),
5900 vector<Subpass>(1, Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5902 vector<AttachmentReference>(),
5903 vector<AttachmentReference>(),
5904 vector<AttachmentReference>(),
5905 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR),
5906 vector<deUint32>())),
5907 vector<SubpassDependency>());
5909 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));
5914 formatGroup->addChild(loadOpGroup.release());
5918 de::MovePtr<tcu::TestCaseGroup> inputGroup (new tcu::TestCaseGroup(testCtx, "input", "Test attachment format as input"));
5920 for (size_t loadOpNdx = 0; loadOpNdx < DE_LENGTH_OF_ARRAY(loadOps); loadOpNdx++)
5922 const VkAttachmentLoadOp loadOp = loadOps[loadOpNdx].op;
5923 de::MovePtr<tcu::TestCaseGroup> loadOpGroup (new tcu::TestCaseGroup(testCtx, loadOps[loadOpNdx].str, loadOps[loadOpNdx].str));
5925 for (size_t storeOpNdx = 0; storeOpNdx < DE_LENGTH_OF_ARRAY(storeOps); storeOpNdx++)
5927 const VkAttachmentStoreOp storeOp = storeOps[storeOpNdx].op;
5928 de::MovePtr<tcu::TestCaseGroup> storeOpGroup (new tcu::TestCaseGroup(testCtx, storeOps[storeOpNdx].str, storeOps[storeOpNdx].str));
5930 for (size_t useInputAspectNdx = 0; useInputAspectNdx < 2; useInputAspectNdx++)
5932 const bool useInputAspect = useInputAspectNdx != 0;
5934 for (size_t renderTypeNdx = 0; renderTypeNdx < DE_LENGTH_OF_ARRAY(renderTypes); renderTypeNdx++)
5937 vector<Attachment> attachments;
5938 vector<Subpass> subpasses;
5939 vector<SubpassDependency> deps;
5940 vector<VkInputAttachmentAspectReferenceKHR> inputAspects;
5942 attachments.push_back(Attachment(vkFormat,
5943 VK_SAMPLE_COUNT_1_BIT,
5948 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
5949 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
5951 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
5952 VK_SAMPLE_COUNT_1_BIT,
5953 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5954 VK_ATTACHMENT_STORE_OP_STORE,
5955 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
5956 VK_ATTACHMENT_STORE_OP_DONT_CARE,
5957 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
5958 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
5960 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5962 vector<AttachmentReference>(),
5963 vector<AttachmentReference>(),
5964 vector<AttachmentReference>(),
5965 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
5966 vector<deUint32>()));
5967 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
5969 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL)),
5970 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
5971 vector<AttachmentReference>(),
5972 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
5973 vector<deUint32>()));
5975 deps.push_back(SubpassDependency(0, 1,
5976 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
5977 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
5979 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
5980 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5983 deps.push_back(SubpassDependency(1, 1,
5984 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
5985 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
5987 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
5988 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
5989 vk::VK_DEPENDENCY_BY_REGION_BIT));
5993 const VkInputAttachmentAspectReferenceKHR inputAspect =
5997 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
5998 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
6001 inputAspects.push_back(inputAspect);
6005 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
6007 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));
6011 vector<Attachment> attachments;
6012 vector<Subpass> subpasses;
6013 vector<SubpassDependency> deps;
6014 vector<VkInputAttachmentAspectReferenceKHR> inputAspects;
6016 attachments.push_back(Attachment(vkFormat,
6017 VK_SAMPLE_COUNT_1_BIT,
6020 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6021 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6022 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6023 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
6025 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6027 vector<AttachmentReference>(),
6028 vector<AttachmentReference>(),
6029 vector<AttachmentReference>(),
6030 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6031 vector<deUint32>()));
6032 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6034 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL)),
6035 vector<AttachmentReference>(),
6036 vector<AttachmentReference>(),
6037 AttachmentReference(0, VK_IMAGE_LAYOUT_GENERAL),
6038 vector<deUint32>()));
6040 deps.push_back(SubpassDependency(0, 1,
6041 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6042 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6044 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
6045 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6046 vk::VK_DEPENDENCY_BY_REGION_BIT));
6051 const VkInputAttachmentAspectReferenceKHR inputAspect =
6056 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
6057 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
6060 inputAspects.push_back(inputAspect);
6064 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
6066 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));
6070 if (isStencilAttachment && isDepthAttachment)
6074 vector<Attachment> attachments;
6075 vector<Subpass> subpasses;
6076 vector<SubpassDependency> deps;
6077 vector<VkInputAttachmentAspectReferenceKHR> inputAspects;
6079 attachments.push_back(Attachment(vkFormat,
6080 VK_SAMPLE_COUNT_1_BIT,
6085 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6086 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
6088 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
6089 VK_SAMPLE_COUNT_1_BIT,
6090 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6091 VK_ATTACHMENT_STORE_OP_STORE,
6092 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6093 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6094 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6095 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
6097 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6099 vector<AttachmentReference>(),
6100 vector<AttachmentReference>(),
6101 vector<AttachmentReference>(),
6102 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6103 vector<deUint32>()));
6104 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6106 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)),
6107 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6108 vector<AttachmentReference>(),
6109 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6110 vector<deUint32>()));
6112 deps.push_back(SubpassDependency(0, 1,
6113 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
6114 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6116 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6117 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6122 const VkInputAttachmentAspectReferenceKHR inputAspect =
6127 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
6128 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
6131 inputAspects.push_back(inputAspect);
6135 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
6137 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));
6141 vector<Attachment> attachments;
6142 vector<Subpass> subpasses;
6143 vector<SubpassDependency> deps;
6144 vector<VkInputAttachmentAspectReferenceKHR> inputAspects;
6146 attachments.push_back(Attachment(vkFormat,
6147 VK_SAMPLE_COUNT_1_BIT,
6152 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6153 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
6155 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6157 vector<AttachmentReference>(),
6158 vector<AttachmentReference>(),
6159 vector<AttachmentReference>(),
6160 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6161 vector<deUint32>()));
6162 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6164 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR)),
6165 vector<AttachmentReference>(),
6166 vector<AttachmentReference>(),
6167 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR),
6168 vector<deUint32>()));
6170 deps.push_back(SubpassDependency(0, 1,
6171 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6172 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6174 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
6175 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6176 vk::VK_DEPENDENCY_BY_REGION_BIT));
6178 deps.push_back(SubpassDependency(1, 1,
6179 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
6180 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6182 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6183 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6184 vk::VK_DEPENDENCY_BY_REGION_BIT));
6189 const VkInputAttachmentAspectReferenceKHR inputAspect =
6194 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
6195 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
6198 inputAspects.push_back(inputAspect);
6202 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
6204 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));
6207 // Stencil read only
6209 vector<Attachment> attachments;
6210 vector<Subpass> subpasses;
6211 vector<SubpassDependency> deps;
6212 vector<VkInputAttachmentAspectReferenceKHR> inputAspects;
6214 attachments.push_back(Attachment(vkFormat,
6215 VK_SAMPLE_COUNT_1_BIT,
6220 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6221 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
6223 attachments.push_back(Attachment(vk::VK_FORMAT_R8G8B8A8_UNORM,
6224 VK_SAMPLE_COUNT_1_BIT,
6225 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6226 VK_ATTACHMENT_STORE_OP_STORE,
6227 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
6228 VK_ATTACHMENT_STORE_OP_DONT_CARE,
6229 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
6230 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
6232 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6234 vector<AttachmentReference>(),
6235 vector<AttachmentReference>(),
6236 vector<AttachmentReference>(),
6237 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6238 vector<deUint32>()));
6239 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6241 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR)),
6242 vector<AttachmentReference>(1, AttachmentReference(1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)),
6243 vector<AttachmentReference>(),
6244 AttachmentReference(VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL),
6245 vector<deUint32>()));
6247 deps.push_back(SubpassDependency(0, 1,
6248 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6249 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6251 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
6252 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6257 const VkInputAttachmentAspectReferenceKHR inputAspect =
6262 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
6263 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
6266 inputAspects.push_back(inputAspect);
6270 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
6272 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));
6276 vector<Attachment> attachments;
6277 vector<Subpass> subpasses;
6278 vector<SubpassDependency> deps;
6279 vector<VkInputAttachmentAspectReferenceKHR> inputAspects;
6281 attachments.push_back(Attachment(vkFormat,
6282 VK_SAMPLE_COUNT_1_BIT,
6287 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
6288 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL));
6290 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6292 vector<AttachmentReference>(),
6293 vector<AttachmentReference>(),
6294 vector<AttachmentReference>(),
6295 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL),
6296 vector<deUint32>()));
6297 subpasses.push_back(Subpass(VK_PIPELINE_BIND_POINT_GRAPHICS,
6299 vector<AttachmentReference>(1, AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR)),
6300 vector<AttachmentReference>(),
6301 vector<AttachmentReference>(),
6302 AttachmentReference(0, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR),
6303 vector<deUint32>()));
6305 deps.push_back(SubpassDependency(0, 1,
6306 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
6307 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6309 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
6310 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6311 vk::VK_DEPENDENCY_BY_REGION_BIT));
6313 deps.push_back(SubpassDependency(1, 1,
6314 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
6315 vk::VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
6317 vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
6318 vk::VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
6319 vk::VK_DEPENDENCY_BY_REGION_BIT));
6324 const VkInputAttachmentAspectReferenceKHR inputAspect =
6329 (isDepthAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT : 0u)
6330 | (isStencilAttachment ? (VkImageAspectFlags)VK_IMAGE_ASPECT_STENCIL_BIT : 0u)
6333 inputAspects.push_back(inputAspect);
6337 const RenderPass renderPass (attachments, subpasses, deps, inputAspects);
6339 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));
6346 loadOpGroup->addChild(storeOpGroup.release());
6349 inputGroup->addChild(loadOpGroup.release());
6352 formatGroup->addChild(inputGroup.release());
6355 group->addChild(formatGroup.release());
6359 void addRenderPassTests (tcu::TestCaseGroup* group, AllocationKind allocationKind)
6361 addTestGroup(group, "simple", "Simple basic render pass tests", addSimpleTests, allocationKind);
6362 addTestGroup(group, "formats", "Tests for different image formats.", addFormatTests, allocationKind);
6363 addTestGroup(group, "attachment", "Attachment format and count tests with load and store ops and image layouts", addAttachmentTests, allocationKind);
6364 addTestGroup(group, "attachment_allocation", "Attachment allocation tests", addAttachmentAllocationTests, allocationKind);
6367 de::MovePtr<tcu::TestCaseGroup> createSuballocationTests(tcu::TestContext& testCtx)
6369 de::MovePtr<tcu::TestCaseGroup> suballocationTestsGroup(new tcu::TestCaseGroup(testCtx, "suballocation", "Suballocation RenderPass Tests"));
6371 addRenderPassTests(suballocationTestsGroup.get(), ALLOCATION_KIND_SUBALLOCATED);
6373 return suballocationTestsGroup;
6376 de::MovePtr<tcu::TestCaseGroup> createDedicatedAllocationTests(tcu::TestContext& testCtx)
6378 de::MovePtr<tcu::TestCaseGroup> dedicatedAllocationTestsGroup(new tcu::TestCaseGroup(testCtx, "dedicated_allocation", "RenderPass Tests For Dedicated Allocation"));
6380 addRenderPassTests(dedicatedAllocationTestsGroup.get(), ALLOCATION_KIND_DEDICATED);
6382 return dedicatedAllocationTestsGroup;
6387 tcu::TestCaseGroup* createRenderPassTests (tcu::TestContext& testCtx)
6389 de::MovePtr<tcu::TestCaseGroup> renderpassTests (new tcu::TestCaseGroup(testCtx, "renderpass", "RenderPass Tests"));
6390 de::MovePtr<tcu::TestCaseGroup> suballocationTestGroup = createSuballocationTests(testCtx);
6391 de::MovePtr<tcu::TestCaseGroup> dedicatedAllocationTestGroup = createDedicatedAllocationTests(testCtx);
6393 suballocationTestGroup->addChild(createRenderPassMultisampleTests(testCtx));
6394 suballocationTestGroup->addChild(createRenderPassMultisampleResolveTests(testCtx));
6396 renderpassTests->addChild(suballocationTestGroup.release());
6397 renderpassTests->addChild(dedicatedAllocationTestGroup.release());
6399 renderpassTests->addChild(createRenderPassMultisampleTests(testCtx));
6400 renderpassTests->addChild(createRenderPassMultisampleResolveTests(testCtx));
6401 renderpassTests->addChild(createRenderPassSampleReadTests(testCtx));
6403 return renderpassTests.release();