1 /*-------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2017 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 Tests for render passses with multisample attachments
22 *//*--------------------------------------------------------------------*/
24 #include "vktRenderPassMultisampleTests.hpp"
26 #include "vktTestCaseUtil.hpp"
27 #include "vktTestGroupUtil.hpp"
30 #include "vkDeviceUtil.hpp"
31 #include "vkImageUtil.hpp"
32 #include "vkMemUtil.hpp"
33 #include "vkPlatform.hpp"
34 #include "vkPrograms.hpp"
35 #include "vkQueryUtil.hpp"
37 #include "vkRefUtil.hpp"
38 #include "vkTypeUtil.hpp"
40 #include "tcuFloat.hpp"
41 #include "tcuImageCompare.hpp"
42 #include "tcuFormatUtil.hpp"
43 #include "tcuMaybe.hpp"
44 #include "tcuResultCollector.hpp"
45 #include "tcuTestLog.hpp"
46 #include "tcuTextureUtil.hpp"
47 #include "tcuVectorUtil.hpp"
49 #include "deUniquePtr.hpp"
50 #include "deSharedPtr.hpp"
66 using tcu::ConstPixelBufferAccess;
67 using tcu::PixelBufferAccess;
75 typedef de::SharedPtr<vk::Unique<VkImage> > VkImageSp;
76 typedef de::SharedPtr<vk::Unique<VkImageView> > VkImageViewSp;
77 typedef de::SharedPtr<vk::Unique<VkBuffer> > VkBufferSp;
78 typedef de::SharedPtr<vk::Unique<VkPipeline> > VkPipelineSp;
86 MAX_COLOR_ATTACHMENT_COUNT = 4u
90 de::SharedPtr<T> safeSharedPtr (T* ptr)
94 return de::SharedPtr<T>(ptr);
103 VkImageAspectFlags getImageAspectFlags (VkFormat vkFormat)
105 const tcu::TextureFormat format (mapVkFormat(vkFormat));
106 const bool hasDepth (tcu::hasDepthComponent(format.order));
107 const bool hasStencil (tcu::hasStencilComponent(format.order));
109 if (hasDepth || hasStencil)
111 return (hasDepth ? VK_IMAGE_ASPECT_DEPTH_BIT : (VkImageAspectFlagBits)0u)
112 | (hasStencil ? VK_IMAGE_ASPECT_STENCIL_BIT : (VkImageAspectFlagBits)0u);
115 return VK_IMAGE_ASPECT_COLOR_BIT;
118 void bindBufferMemory (const DeviceInterface& vk, VkDevice device, VkBuffer buffer, VkDeviceMemory mem, VkDeviceSize memOffset)
120 VK_CHECK(vk.bindBufferMemory(device, buffer, mem, memOffset));
123 void bindImageMemory (const DeviceInterface& vk, VkDevice device, VkImage image, VkDeviceMemory mem, VkDeviceSize memOffset)
125 VK_CHECK(vk.bindImageMemory(device, image, mem, memOffset));
128 de::MovePtr<Allocation> createBufferMemory (const DeviceInterface& vk,
130 Allocator& allocator,
133 de::MovePtr<Allocation> allocation (allocator.allocate(getBufferMemoryRequirements(vk, device, buffer), MemoryRequirement::HostVisible));
134 bindBufferMemory(vk, device, buffer, allocation->getMemory(), allocation->getOffset());
138 de::MovePtr<Allocation> createImageMemory (const DeviceInterface& vk,
140 Allocator& allocator,
143 de::MovePtr<Allocation> allocation (allocator.allocate(getImageMemoryRequirements(vk, device, image), MemoryRequirement::Any));
144 bindImageMemory(vk, device, image, allocation->getMemory(), allocation->getOffset());
148 Move<VkImage> createImage (const DeviceInterface& vk,
150 VkImageCreateFlags flags,
151 VkImageType imageType,
155 deUint32 arrayLayers,
156 VkSampleCountFlagBits samples,
157 VkImageTiling tiling,
158 VkImageUsageFlags usage,
159 VkSharingMode sharingMode,
160 deUint32 queueFamilyCount,
161 const deUint32* pQueueFamilyIndices,
162 VkImageLayout initialLayout)
164 const VkImageCreateInfo pCreateInfo =
166 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
182 return createImage(vk, device, &pCreateInfo);
185 Move<VkImageView> createImageView (const DeviceInterface& vk,
187 VkImageViewCreateFlags flags,
189 VkImageViewType viewType,
191 VkComponentMapping components,
192 VkImageSubresourceRange subresourceRange)
194 const VkImageViewCreateInfo pCreateInfo =
196 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
205 return createImageView(vk, device, &pCreateInfo);
208 Move<VkImage> createImage (const InstanceInterface& vki,
209 VkPhysicalDevice physicalDevice,
210 const DeviceInterface& vkd,
213 VkSampleCountFlagBits sampleCountBit,
214 VkImageUsageFlags usage,
220 const tcu::TextureFormat format (mapVkFormat(vkFormat));
221 const VkImageType imageType (VK_IMAGE_TYPE_2D);
222 const VkImageTiling imageTiling (VK_IMAGE_TILING_OPTIMAL);
223 const VkFormatProperties formatProperties (getPhysicalDeviceFormatProperties(vki, physicalDevice, vkFormat));
224 const VkImageFormatProperties imageFormatProperties (getPhysicalDeviceImageFormatProperties(vki, physicalDevice, vkFormat, imageType, imageTiling, usage, 0u));
225 const VkExtent3D imageExtent =
232 if ((tcu::hasDepthComponent(format.order) || tcu::hasStencilComponent(format.order))
233 && (formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)
234 TCU_THROW(NotSupportedError, "Format can't be used as depth stencil attachment");
236 if (!(tcu::hasDepthComponent(format.order) || tcu::hasStencilComponent(format.order))
237 && (formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) == 0)
238 TCU_THROW(NotSupportedError, "Format can't be used as color attachment");
240 if (imageFormatProperties.maxExtent.width < imageExtent.width
241 || imageFormatProperties.maxExtent.height < imageExtent.height
242 || ((imageFormatProperties.sampleCounts & sampleCountBit) == 0))
244 TCU_THROW(NotSupportedError, "Image type not supported");
247 return createImage(vkd, device, 0u, imageType, vkFormat, imageExtent, 1u, 1u, sampleCountBit, imageTiling, usage, VK_SHARING_MODE_EXCLUSIVE, 0u, DE_NULL, VK_IMAGE_LAYOUT_UNDEFINED);
249 catch (const vk::Error& error)
251 if (error.getError() == VK_ERROR_FORMAT_NOT_SUPPORTED)
252 TCU_THROW(NotSupportedError, "Image format not supported");
258 Move<VkImageView> createImageAttachmentView (const DeviceInterface& vkd,
262 VkImageAspectFlags aspect)
264 const VkImageSubresourceRange range =
273 return createImageView(vkd, device, 0u, image, VK_IMAGE_VIEW_TYPE_2D, format, makeComponentMappingRGBA(), range);
276 Move<VkImageView> createSrcPrimaryInputImageView (const DeviceInterface& vkd,
280 VkImageAspectFlags aspect)
282 const VkImageSubresourceRange range =
284 aspect == (VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_DEPTH_BIT)
285 ? (VkImageAspectFlags)VK_IMAGE_ASPECT_DEPTH_BIT
293 return createImageView(vkd, device, 0u, image, VK_IMAGE_VIEW_TYPE_2D, format, makeComponentMappingRGBA(), range);
296 Move<VkImageView> createSrcSecondaryInputImageView (const DeviceInterface& vkd,
300 VkImageAspectFlags aspect)
302 if (aspect == (VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_DEPTH_BIT))
304 const VkImageSubresourceRange range =
306 VK_IMAGE_ASPECT_STENCIL_BIT,
313 return createImageView(vkd, device, 0u, image, VK_IMAGE_VIEW_TYPE_2D, format, makeComponentMappingRGBA(), range);
316 return Move<VkImageView>();
319 VkDeviceSize getPixelSize (VkFormat vkFormat)
321 const tcu::TextureFormat format (mapVkFormat(vkFormat));
323 return format.getPixelSize();
326 Move<VkBuffer> createBuffer (const DeviceInterface& vkd,
332 const VkBufferUsageFlags bufferUsage (VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT);
333 const VkDeviceSize pixelSize (getPixelSize(format));
334 const VkBufferCreateInfo createInfo =
336 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
340 width * height * pixelSize,
343 VK_SHARING_MODE_EXCLUSIVE,
347 return createBuffer(vkd, device, &createInfo);
350 VkSampleCountFlagBits sampleCountBitFromomSampleCount (deUint32 count)
354 case 1: return VK_SAMPLE_COUNT_1_BIT;
355 case 2: return VK_SAMPLE_COUNT_2_BIT;
356 case 4: return VK_SAMPLE_COUNT_4_BIT;
357 case 8: return VK_SAMPLE_COUNT_8_BIT;
358 case 16: return VK_SAMPLE_COUNT_16_BIT;
359 case 32: return VK_SAMPLE_COUNT_32_BIT;
360 case 64: return VK_SAMPLE_COUNT_64_BIT;
363 DE_FATAL("Invalid sample count");
364 return (VkSampleCountFlagBits)(0x1u << count);
368 std::vector<VkImageSp> createMultisampleImages (const InstanceInterface& vki,
369 VkPhysicalDevice physicalDevice,
370 const DeviceInterface& vkd,
373 deUint32 sampleCount,
377 std::vector<VkImageSp> images (sampleCount);
379 for (size_t imageNdx = 0; imageNdx < images.size(); imageNdx++)
380 images[imageNdx] = safeSharedPtr(new vk::Unique<VkImage>(createImage(vki, physicalDevice, vkd, device, format, sampleCountBitFromomSampleCount(sampleCount), VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, width, height)));
385 std::vector<VkImageSp> createSingleSampleImages (const InstanceInterface& vki,
386 VkPhysicalDevice physicalDevice,
387 const DeviceInterface& vkd,
390 deUint32 sampleCount,
394 std::vector<VkImageSp> images (sampleCount);
396 for (size_t imageNdx = 0; imageNdx < images.size(); imageNdx++)
397 images[imageNdx] = safeSharedPtr(new vk::Unique<VkImage>(createImage(vki, physicalDevice, vkd, device, format, VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT, width, height)));
402 std::vector<de::SharedPtr<Allocation> > createImageMemory (const DeviceInterface& vkd,
404 Allocator& allocator,
405 const std::vector<VkImageSp> images)
407 std::vector<de::SharedPtr<Allocation> > memory (images.size());
409 for (size_t memoryNdx = 0; memoryNdx < memory.size(); memoryNdx++)
410 memory[memoryNdx] = safeSharedPtr(createImageMemory(vkd, device, allocator, **images[memoryNdx]).release());
415 std::vector<VkImageViewSp> createImageAttachmentViews (const DeviceInterface& vkd,
417 const std::vector<VkImageSp>& images,
419 VkImageAspectFlagBits aspect)
421 std::vector<VkImageViewSp> views (images.size());
423 for (size_t imageNdx = 0; imageNdx < images.size(); imageNdx++)
424 views[imageNdx] = safeSharedPtr(new vk::Unique<VkImageView>(createImageAttachmentView(vkd, device, **images[imageNdx], format, aspect)));
429 std::vector<VkBufferSp> createBuffers (const DeviceInterface& vkd,
432 deUint32 sampleCount,
436 std::vector<VkBufferSp> buffers (sampleCount);
438 for (size_t bufferNdx = 0; bufferNdx < buffers.size(); bufferNdx++)
439 buffers[bufferNdx] = safeSharedPtr(new vk::Unique<VkBuffer>(createBuffer(vkd, device, format, width, height)));
444 std::vector<de::SharedPtr<Allocation> > createBufferMemory (const DeviceInterface& vkd,
446 Allocator& allocator,
447 const std::vector<VkBufferSp> buffers)
449 std::vector<de::SharedPtr<Allocation> > memory (buffers.size());
451 for (size_t memoryNdx = 0; memoryNdx < memory.size(); memoryNdx++)
452 memory[memoryNdx] = safeSharedPtr(createBufferMemory(vkd, device, allocator, **buffers[memoryNdx]).release());
457 Move<VkRenderPass> createRenderPass (const DeviceInterface& vkd,
461 deUint32 sampleCount)
463 const VkSampleCountFlagBits samples (sampleCountBitFromomSampleCount(sampleCount));
464 const deUint32 splitSubpassCount (deDivRoundUp32(sampleCount, MAX_COLOR_ATTACHMENT_COUNT));
465 const tcu::TextureFormat format (mapVkFormat(srcFormat));
466 const bool isDepthStencilFormat (tcu::hasDepthComponent(format.order) || tcu::hasStencilComponent(format.order));
467 vector<VkSubpassDescription> subpasses;
468 vector<vector<VkAttachmentReference> > dstAttachmentRefs (splitSubpassCount);
469 vector<vector<VkAttachmentReference> > dstResolveAttachmentRefs (splitSubpassCount);
470 vector<VkAttachmentDescription> attachments;
471 vector<VkSubpassDependency> dependencies;
472 const VkAttachmentReference srcAttachmentRef =
476 ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
477 : VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
479 const VkAttachmentReference srcAttachmentInputRef =
482 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
486 const VkAttachmentDescription srcAttachment =
493 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
494 VK_ATTACHMENT_STORE_OP_DONT_CARE,
496 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
497 VK_ATTACHMENT_STORE_OP_DONT_CARE,
499 VK_IMAGE_LAYOUT_UNDEFINED,
500 VK_IMAGE_LAYOUT_GENERAL
503 attachments.push_back(srcAttachment);
506 for (deUint32 splitSubpassIndex = 0; splitSubpassIndex < splitSubpassCount; splitSubpassIndex++)
508 for (deUint32 sampleNdx = 0; sampleNdx < de::min((deUint32)MAX_COLOR_ATTACHMENT_COUNT, sampleCount - splitSubpassIndex * MAX_COLOR_ATTACHMENT_COUNT); sampleNdx++)
510 // Multisample color attachment
512 const VkAttachmentDescription dstAttachment =
519 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
520 VK_ATTACHMENT_STORE_OP_DONT_CARE,
522 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
523 VK_ATTACHMENT_STORE_OP_DONT_CARE,
525 VK_IMAGE_LAYOUT_UNDEFINED,
526 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
528 const VkAttachmentReference dstAttachmentRef =
530 (deUint32)attachments.size(),
531 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
534 attachments.push_back(dstAttachment);
535 dstAttachmentRefs[splitSubpassIndex].push_back(dstAttachmentRef);
537 // Resolve attachment
539 const VkAttachmentDescription dstAttachment =
544 VK_SAMPLE_COUNT_1_BIT,
546 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
547 VK_ATTACHMENT_STORE_OP_STORE,
549 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
550 VK_ATTACHMENT_STORE_OP_STORE,
552 VK_IMAGE_LAYOUT_UNDEFINED,
553 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL
555 const VkAttachmentReference dstAttachmentRef =
557 (deUint32)attachments.size(),
558 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
561 attachments.push_back(dstAttachment);
562 dstResolveAttachmentRefs[splitSubpassIndex].push_back(dstAttachmentRef);
569 const VkSubpassDescription subpass =
571 (VkSubpassDescriptionFlags)0,
572 VK_PIPELINE_BIND_POINT_GRAPHICS,
577 isDepthStencilFormat ? 0u : 1u,
578 isDepthStencilFormat ? DE_NULL : &srcAttachmentRef,
581 isDepthStencilFormat ? &srcAttachmentRef : DE_NULL,
586 subpasses.push_back(subpass);
589 for (deUint32 splitSubpassIndex = 0; splitSubpassIndex < splitSubpassCount; splitSubpassIndex++)
592 const VkSubpassDescription subpass =
594 (VkSubpassDescriptionFlags)0,
595 VK_PIPELINE_BIND_POINT_GRAPHICS,
598 &srcAttachmentInputRef,
600 (deUint32)dstAttachmentRefs[splitSubpassIndex].size(),
601 &dstAttachmentRefs[splitSubpassIndex][0],
602 &dstResolveAttachmentRefs[splitSubpassIndex][0],
608 subpasses.push_back(subpass);
611 const VkSubpassDependency dependency =
613 0u, splitSubpassIndex + 1,
614 VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
615 VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
617 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
618 VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
620 VK_DEPENDENCY_BY_REGION_BIT
623 dependencies.push_back(dependency);
626 const VkRenderPassCreateInfo createInfo =
628 VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
630 (VkRenderPassCreateFlags)0u,
632 (deUint32)attachments.size(),
635 (deUint32)subpasses.size(),
638 (deUint32)dependencies.size(),
642 return createRenderPass(vkd, device, &createInfo);
646 Move<VkFramebuffer> createFramebuffer (const DeviceInterface& vkd,
648 VkRenderPass renderPass,
649 VkImageView srcImageView,
650 const std::vector<VkImageViewSp>& dstMultisampleImageViews,
651 const std::vector<VkImageViewSp>& dstSinglesampleImageViews,
655 std::vector<VkImageView> attachments;
657 attachments.reserve(dstMultisampleImageViews.size() + dstSinglesampleImageViews.size() + 1u);
659 attachments.push_back(srcImageView);
661 DE_ASSERT(dstMultisampleImageViews.size() == dstSinglesampleImageViews.size());
663 for (size_t ndx = 0; ndx < dstMultisampleImageViews.size(); ndx++)
665 attachments.push_back(**dstMultisampleImageViews[ndx]);
666 attachments.push_back(**dstSinglesampleImageViews[ndx]);
669 const VkFramebufferCreateInfo createInfo =
671 VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
676 (deUint32)attachments.size(),
684 return createFramebuffer(vkd, device, &createInfo);
687 Move<VkPipelineLayout> createRenderPipelineLayout (const DeviceInterface& vkd,
690 const VkPushConstantRange pushConstant =
692 VK_SHADER_STAGE_FRAGMENT_BIT,
696 const VkPipelineLayoutCreateInfo createInfo =
698 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
700 (vk::VkPipelineLayoutCreateFlags)0,
709 return createPipelineLayout(vkd, device, &createInfo);
712 Move<VkPipeline> createRenderPipeline (const DeviceInterface& vkd,
715 VkRenderPass renderPass,
716 VkPipelineLayout pipelineLayout,
717 const vk::ProgramCollection<vk::ProgramBinary>& binaryCollection,
720 deUint32 sampleCount)
722 const tcu::TextureFormat format (mapVkFormat(srcFormat));
723 const bool isDepthStencilFormat (tcu::hasDepthComponent(format.order) || tcu::hasStencilComponent(format.order));
725 const Unique<VkShaderModule> vertexShaderModule (createShaderModule(vkd, device, binaryCollection.get("quad-vert"), 0u));
726 const Unique<VkShaderModule> fragmentShaderModule (createShaderModule(vkd, device, binaryCollection.get("quad-frag"), 0u));
727 const VkSpecializationInfo emptyShaderSpecializations =
736 const VkPipelineColorBlendAttachmentState attachmentBlendState =
739 VK_BLEND_FACTOR_SRC_ALPHA,
740 VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
745 VK_COLOR_COMPONENT_R_BIT|VK_COLOR_COMPONENT_G_BIT|VK_COLOR_COMPONENT_B_BIT|VK_COLOR_COMPONENT_A_BIT
747 const VkPipelineShaderStageCreateInfo shaderStages[2] =
750 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
752 (VkPipelineShaderStageCreateFlags)0u,
753 VK_SHADER_STAGE_VERTEX_BIT,
756 &emptyShaderSpecializations
759 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
761 (VkPipelineShaderStageCreateFlags)0u,
762 VK_SHADER_STAGE_FRAGMENT_BIT,
763 *fragmentShaderModule,
765 &emptyShaderSpecializations
768 const VkPipelineVertexInputStateCreateInfo vertexInputState =
770 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
772 (VkPipelineVertexInputStateCreateFlags)0u,
780 const VkPipelineInputAssemblyStateCreateInfo inputAssemblyState =
782 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
785 (VkPipelineInputAssemblyStateCreateFlags)0u,
786 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
789 const VkViewport viewport =
792 (float)width, (float)height,
796 const VkRect2D scissor =
801 const VkPipelineViewportStateCreateInfo viewportState =
803 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
805 (VkPipelineViewportStateCreateFlags)0u,
813 const VkPipelineRasterizationStateCreateInfo rasterState =
815 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
817 (VkPipelineRasterizationStateCreateFlags)0u,
820 VK_POLYGON_MODE_FILL,
822 VK_FRONT_FACE_COUNTER_CLOCKWISE,
829 const VkPipelineMultisampleStateCreateInfo multisampleState =
831 VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
833 (VkPipelineMultisampleStateCreateFlags)0u,
835 sampleCountBitFromomSampleCount(sampleCount),
842 const VkPipelineDepthStencilStateCreateInfo depthStencilState =
844 VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
846 (VkPipelineDepthStencilStateCreateFlags)0u,
850 VK_COMPARE_OP_ALWAYS,
855 VK_STENCIL_OP_INCREMENT_AND_WRAP,
857 VK_COMPARE_OP_ALWAYS,
860 0xFFu / (sampleCount + 1)
864 VK_STENCIL_OP_INCREMENT_AND_WRAP,
866 VK_COMPARE_OP_ALWAYS,
869 0xFFu / (sampleCount + 1)
875 const VkPipelineColorBlendStateCreateInfo blendState =
877 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
879 (VkPipelineColorBlendStateCreateFlags)0u,
883 (isDepthStencilFormat ? 0u : 1u),
884 (isDepthStencilFormat ? DE_NULL : &attachmentBlendState),
885 { 0.0f, 0.0f, 0.0f, 0.0f }
887 const VkGraphicsPipelineCreateInfo createInfo =
889 VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
891 (VkPipelineCreateFlags)0u,
904 (const VkPipelineDynamicStateCreateInfo*)DE_NULL,
913 return createGraphicsPipeline(vkd, device, DE_NULL, &createInfo);
916 Move<VkDescriptorSetLayout> createSplitDescriptorSetLayout (const DeviceInterface& vkd,
920 const tcu::TextureFormat format (mapVkFormat(vkFormat));
921 const bool hasDepth (tcu::hasDepthComponent(format.order));
922 const bool hasStencil (tcu::hasStencilComponent(format.order));
923 const VkDescriptorSetLayoutBinding bindings[] =
927 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
929 VK_SHADER_STAGE_FRAGMENT_BIT,
934 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
936 VK_SHADER_STAGE_FRAGMENT_BIT,
940 const VkDescriptorSetLayoutCreateInfo createInfo =
942 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
946 hasDepth && hasStencil ? 2u : 1u,
950 return createDescriptorSetLayout(vkd, device, &createInfo);
953 Move<VkPipelineLayout> createSplitPipelineLayout (const DeviceInterface& vkd,
955 VkDescriptorSetLayout descriptorSetLayout)
957 const VkPushConstantRange pushConstant =
959 VK_SHADER_STAGE_FRAGMENT_BIT,
963 const VkPipelineLayoutCreateInfo createInfo =
965 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
967 (vk::VkPipelineLayoutCreateFlags)0,
970 &descriptorSetLayout,
976 return createPipelineLayout(vkd, device, &createInfo);
979 Move<VkPipeline> createSplitPipeline (const DeviceInterface& vkd,
981 VkRenderPass renderPass,
982 deUint32 subpassIndex,
983 VkPipelineLayout pipelineLayout,
984 const vk::ProgramCollection<vk::ProgramBinary>& binaryCollection,
987 deUint32 sampleCount)
989 const Unique<VkShaderModule> vertexShaderModule (createShaderModule(vkd, device, binaryCollection.get("quad-vert"), 0u));
990 const Unique<VkShaderModule> fragmentShaderModule (createShaderModule(vkd, device, binaryCollection.get("quad-split-frag"), 0u));
991 const VkSpecializationInfo emptyShaderSpecializations =
1000 const VkPipelineColorBlendAttachmentState attachmentBlendState =
1003 VK_BLEND_FACTOR_SRC_ALPHA,
1004 VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
1006 VK_BLEND_FACTOR_ONE,
1007 VK_BLEND_FACTOR_ONE,
1009 VK_COLOR_COMPONENT_R_BIT|VK_COLOR_COMPONENT_G_BIT|VK_COLOR_COMPONENT_B_BIT|VK_COLOR_COMPONENT_A_BIT
1011 const std::vector<VkPipelineColorBlendAttachmentState> attachmentBlendStates (de::min((deUint32)MAX_COLOR_ATTACHMENT_COUNT, sampleCount), attachmentBlendState);
1012 const VkPipelineShaderStageCreateInfo shaderStages[2] =
1015 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
1017 (VkPipelineShaderStageCreateFlags)0u,
1018 VK_SHADER_STAGE_VERTEX_BIT,
1019 *vertexShaderModule,
1021 &emptyShaderSpecializations
1024 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
1026 (VkPipelineShaderStageCreateFlags)0u,
1027 VK_SHADER_STAGE_FRAGMENT_BIT,
1028 *fragmentShaderModule,
1030 &emptyShaderSpecializations
1033 const VkPipelineVertexInputStateCreateInfo vertexInputState =
1035 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
1037 (VkPipelineVertexInputStateCreateFlags)0u,
1045 const VkPipelineInputAssemblyStateCreateInfo inputAssemblyState =
1047 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
1050 (VkPipelineInputAssemblyStateCreateFlags)0u,
1051 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
1054 const VkViewport viewport =
1057 (float)width, (float)height,
1061 const VkRect2D scissor =
1066 const VkPipelineViewportStateCreateInfo viewportState =
1068 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
1070 (VkPipelineViewportStateCreateFlags)0u,
1078 const VkPipelineRasterizationStateCreateInfo rasterState =
1080 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
1082 (VkPipelineRasterizationStateCreateFlags)0u,
1085 VK_POLYGON_MODE_FILL,
1087 VK_FRONT_FACE_COUNTER_CLOCKWISE,
1094 const VkPipelineMultisampleStateCreateInfo multisampleState =
1096 VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
1098 (VkPipelineMultisampleStateCreateFlags)0u,
1100 sampleCountBitFromomSampleCount(sampleCount),
1107 const VkPipelineDepthStencilStateCreateInfo depthStencilState =
1109 VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
1111 (VkPipelineDepthStencilStateCreateFlags)0u,
1115 VK_COMPARE_OP_ALWAYS,
1119 VK_STENCIL_OP_REPLACE,
1120 VK_STENCIL_OP_REPLACE,
1121 VK_STENCIL_OP_REPLACE,
1122 VK_COMPARE_OP_ALWAYS,
1128 VK_STENCIL_OP_REPLACE,
1129 VK_STENCIL_OP_REPLACE,
1130 VK_STENCIL_OP_REPLACE,
1131 VK_COMPARE_OP_ALWAYS,
1140 const VkPipelineColorBlendStateCreateInfo blendState =
1142 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
1144 (VkPipelineColorBlendStateCreateFlags)0u,
1149 (deUint32)attachmentBlendStates.size(),
1150 &attachmentBlendStates[0],
1152 { 0.0f, 0.0f, 0.0f, 0.0f }
1154 const VkGraphicsPipelineCreateInfo createInfo =
1156 VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
1158 (VkPipelineCreateFlags)0u,
1164 &inputAssemblyState,
1171 (const VkPipelineDynamicStateCreateInfo*)DE_NULL,
1180 return createGraphicsPipeline(vkd, device, DE_NULL, &createInfo);
1183 vector<VkPipelineSp> createSplitPipelines (const DeviceInterface& vkd,
1185 VkRenderPass renderPass,
1186 VkPipelineLayout pipelineLayout,
1187 const vk::ProgramCollection<vk::ProgramBinary>& binaryCollection,
1190 deUint32 sampleCount)
1192 std::vector<VkPipelineSp> pipelines (deDivRoundUp32(sampleCount, MAX_COLOR_ATTACHMENT_COUNT), (VkPipelineSp)0u);
1194 for (size_t ndx = 0; ndx < pipelines.size(); ndx++)
1195 pipelines[ndx] = safeSharedPtr(new Unique<VkPipeline>(createSplitPipeline(vkd, device, renderPass, (deUint32)(ndx + 1), pipelineLayout, binaryCollection, width, height, sampleCount)));
1200 Move<VkDescriptorPool> createSplitDescriptorPool (const DeviceInterface& vkd,
1203 const VkDescriptorPoolSize size =
1205 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 2u
1207 const VkDescriptorPoolCreateInfo createInfo =
1209 VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
1211 VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
1219 return createDescriptorPool(vkd, device, &createInfo);
1222 Move<VkDescriptorSet> createSplitDescriptorSet (const DeviceInterface& vkd,
1224 VkDescriptorPool pool,
1225 VkDescriptorSetLayout layout,
1226 VkImageView primaryImageView,
1227 VkImageView secondaryImageView)
1229 const VkDescriptorSetAllocateInfo allocateInfo =
1231 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
1238 Move<VkDescriptorSet> set (allocateDescriptorSet(vkd, device, &allocateInfo));
1241 const VkDescriptorImageInfo imageInfos[] =
1246 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
1251 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
1254 const VkWriteDescriptorSet writes[] =
1257 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
1264 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
1270 VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
1277 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
1283 const deUint32 count = secondaryImageView != (VkImageView)0
1287 vkd.updateDescriptorSets(device, count, writes, 0u, DE_NULL);
1294 TestConfig (VkFormat format_,
1295 deUint32 sampleCount_)
1297 , sampleCount (sampleCount_)
1302 deUint32 sampleCount;
1305 VkImageUsageFlags getSrcImageUsage (VkFormat vkFormat)
1307 const tcu::TextureFormat format (mapVkFormat(vkFormat));
1308 const bool hasDepth (tcu::hasDepthComponent(format.order));
1309 const bool hasStencil (tcu::hasStencilComponent(format.order));
1311 if (hasDepth || hasStencil)
1312 return VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
1314 return VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
1317 VkFormat getDstFormat (VkFormat vkFormat)
1319 const tcu::TextureFormat format (mapVkFormat(vkFormat));
1320 const bool hasDepth (tcu::hasDepthComponent(format.order));
1321 const bool hasStencil (tcu::hasStencilComponent(format.order));
1323 if (hasDepth && hasStencil)
1324 return VK_FORMAT_R32G32_SFLOAT;
1325 else if (hasDepth || hasStencil)
1326 return VK_FORMAT_R32_SFLOAT;
1332 class MultisampleRenderPassTestInstance : public TestInstance
1335 MultisampleRenderPassTestInstance (Context& context, TestConfig config);
1336 ~MultisampleRenderPassTestInstance (void);
1338 tcu::TestStatus iterate (void);
1341 const VkFormat m_srcFormat;
1342 const VkFormat m_dstFormat;
1343 const deUint32 m_sampleCount;
1344 const deUint32 m_width;
1345 const deUint32 m_height;
1347 const VkImageAspectFlags m_srcImageAspect;
1348 const VkImageUsageFlags m_srcImageUsage;
1349 const Unique<VkImage> m_srcImage;
1350 const de::UniquePtr<Allocation> m_srcImageMemory;
1351 const Unique<VkImageView> m_srcImageView;
1352 const Unique<VkImageView> m_srcPrimaryInputImageView;
1353 const Unique<VkImageView> m_srcSecondaryInputImageView;
1355 const std::vector<VkImageSp> m_dstMultisampleImages;
1356 const std::vector<de::SharedPtr<Allocation> > m_dstMultisampleImageMemory;
1357 const std::vector<VkImageViewSp> m_dstMultisampleImageViews;
1359 const std::vector<VkImageSp> m_dstSinglesampleImages;
1360 const std::vector<de::SharedPtr<Allocation> > m_dstSinglesampleImageMemory;
1361 const std::vector<VkImageViewSp> m_dstSinglesampleImageViews;
1363 const std::vector<VkBufferSp> m_dstBuffers;
1364 const std::vector<de::SharedPtr<Allocation> > m_dstBufferMemory;
1366 const Unique<VkRenderPass> m_renderPass;
1367 const Unique<VkFramebuffer> m_framebuffer;
1369 const Unique<VkPipelineLayout> m_renderPipelineLayout;
1370 const Unique<VkPipeline> m_renderPipeline;
1372 const Unique<VkDescriptorSetLayout> m_splitDescriptorSetLayout;
1373 const Unique<VkPipelineLayout> m_splitPipelineLayout;
1374 const std::vector<VkPipelineSp> m_splitPipelines;
1375 const Unique<VkDescriptorPool> m_splitDescriptorPool;
1376 const Unique<VkDescriptorSet> m_splitDescriptorSet;
1378 const Unique<VkCommandPool> m_commandPool;
1379 tcu::ResultCollector m_resultCollector;
1382 MultisampleRenderPassTestInstance::MultisampleRenderPassTestInstance (Context& context, TestConfig config)
1383 : TestInstance (context)
1384 , m_srcFormat (config.format)
1385 , m_dstFormat (getDstFormat(config.format))
1386 , m_sampleCount (config.sampleCount)
1390 , m_srcImageAspect (getImageAspectFlags(m_srcFormat))
1391 , m_srcImageUsage (getSrcImageUsage(m_srcFormat))
1392 , m_srcImage (createImage(context.getInstanceInterface(), context.getPhysicalDevice(), context.getDeviceInterface(), context.getDevice(), m_srcFormat, sampleCountBitFromomSampleCount(m_sampleCount), m_srcImageUsage, m_width, m_height))
1393 , m_srcImageMemory (createImageMemory(context.getDeviceInterface(), context.getDevice(), context.getDefaultAllocator(), *m_srcImage))
1394 , m_srcImageView (createImageAttachmentView(context.getDeviceInterface(), context.getDevice(), *m_srcImage, m_srcFormat, m_srcImageAspect))
1395 , m_srcPrimaryInputImageView (createSrcPrimaryInputImageView(context.getDeviceInterface(), context.getDevice(), *m_srcImage, m_srcFormat, m_srcImageAspect))
1396 , m_srcSecondaryInputImageView (createSrcSecondaryInputImageView(context.getDeviceInterface(), context.getDevice(), *m_srcImage, m_srcFormat, m_srcImageAspect))
1398 , m_dstMultisampleImages (createMultisampleImages(context.getInstanceInterface(), context.getPhysicalDevice(), context.getDeviceInterface(), context.getDevice(), m_dstFormat, m_sampleCount, m_width, m_height))
1399 , m_dstMultisampleImageMemory (createImageMemory(context.getDeviceInterface(), context.getDevice(), context.getDefaultAllocator(), m_dstMultisampleImages))
1400 , m_dstMultisampleImageViews (createImageAttachmentViews(context.getDeviceInterface(), context.getDevice(), m_dstMultisampleImages, m_dstFormat, VK_IMAGE_ASPECT_COLOR_BIT))
1402 , m_dstSinglesampleImages (createSingleSampleImages(context.getInstanceInterface(), context.getPhysicalDevice(), context.getDeviceInterface(), context.getDevice(), m_dstFormat, m_sampleCount, m_width, m_height))
1403 , m_dstSinglesampleImageMemory (createImageMemory(context.getDeviceInterface(), context.getDevice(), context.getDefaultAllocator(), m_dstSinglesampleImages))
1404 , m_dstSinglesampleImageViews (createImageAttachmentViews(context.getDeviceInterface(), context.getDevice(), m_dstSinglesampleImages, m_dstFormat, VK_IMAGE_ASPECT_COLOR_BIT))
1406 , m_dstBuffers (createBuffers(context.getDeviceInterface(), context.getDevice(), m_dstFormat, m_sampleCount, m_width, m_height))
1407 , m_dstBufferMemory (createBufferMemory(context.getDeviceInterface(), context.getDevice(), context.getDefaultAllocator(), m_dstBuffers))
1409 , m_renderPass (createRenderPass(context.getDeviceInterface(), context.getDevice(), m_srcFormat, m_dstFormat, m_sampleCount))
1410 , m_framebuffer (createFramebuffer(context.getDeviceInterface(), context.getDevice(), *m_renderPass, *m_srcImageView, m_dstMultisampleImageViews, m_dstSinglesampleImageViews, m_width, m_height))
1412 , m_renderPipelineLayout (createRenderPipelineLayout(context.getDeviceInterface(), context.getDevice()))
1413 , m_renderPipeline (createRenderPipeline(context.getDeviceInterface(), context.getDevice(), m_srcFormat, *m_renderPass, *m_renderPipelineLayout, context.getBinaryCollection(), m_width, m_height, m_sampleCount))
1415 , m_splitDescriptorSetLayout (createSplitDescriptorSetLayout(context.getDeviceInterface(), context.getDevice(), m_srcFormat))
1416 , m_splitPipelineLayout (createSplitPipelineLayout(context.getDeviceInterface(), context.getDevice(), *m_splitDescriptorSetLayout))
1417 , m_splitPipelines (createSplitPipelines(context.getDeviceInterface(), context.getDevice(), *m_renderPass, *m_splitPipelineLayout, context.getBinaryCollection(), m_width, m_height, m_sampleCount))
1418 , m_splitDescriptorPool (createSplitDescriptorPool(context.getDeviceInterface(), context.getDevice()))
1419 , m_splitDescriptorSet (createSplitDescriptorSet(context.getDeviceInterface(), context.getDevice(), *m_splitDescriptorPool, *m_splitDescriptorSetLayout, *m_srcPrimaryInputImageView, *m_srcSecondaryInputImageView))
1420 , m_commandPool (createCommandPool(context.getDeviceInterface(), context.getDevice(), VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, context.getUniversalQueueFamilyIndex()))
1424 MultisampleRenderPassTestInstance::~MultisampleRenderPassTestInstance (void)
1428 tcu::TestStatus MultisampleRenderPassTestInstance::iterate (void)
1430 const DeviceInterface& vkd (m_context.getDeviceInterface());
1431 const VkDevice device (m_context.getDevice());
1432 const Unique<VkCommandBuffer> commandBuffer (allocateCommandBuffer(vkd, device, *m_commandPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
1435 const VkCommandBufferBeginInfo beginInfo =
1437 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
1440 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
1444 VK_CHECK(vkd.beginCommandBuffer(*commandBuffer, &beginInfo));
1448 const VkRenderPassBeginInfo beginInfo =
1450 VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
1458 { m_width, m_height }
1464 vkd.cmdBeginRenderPass(*commandBuffer, &beginInfo, VK_SUBPASS_CONTENTS_INLINE);
1467 vkd.cmdBindPipeline(*commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_renderPipeline);
1469 for (deUint32 sampleNdx = 0; sampleNdx < m_sampleCount; sampleNdx++)
1471 vkd.cmdPushConstants(*commandBuffer, *m_renderPipelineLayout, VK_SHADER_STAGE_FRAGMENT_BIT, 0u, sizeof(sampleNdx), &sampleNdx);
1472 vkd.cmdDraw(*commandBuffer, 6u, 1u, 0u, 0u);
1475 for (deUint32 splitPipelineNdx = 0; splitPipelineNdx < m_splitPipelines.size(); splitPipelineNdx++)
1477 vkd.cmdNextSubpass(*commandBuffer, VK_SUBPASS_CONTENTS_INLINE);
1479 vkd.cmdBindPipeline(*commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, **m_splitPipelines[splitPipelineNdx]);
1480 vkd.cmdBindDescriptorSets(*commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_splitPipelineLayout, 0u, 1u, &*m_splitDescriptorSet, 0u, DE_NULL);
1481 vkd.cmdPushConstants(*commandBuffer, *m_splitPipelineLayout, VK_SHADER_STAGE_FRAGMENT_BIT, 0u, sizeof(splitPipelineNdx), &splitPipelineNdx);
1482 vkd.cmdDraw(*commandBuffer, 6u, 1u, 0u, 0u);
1485 vkd.cmdEndRenderPass(*commandBuffer);
1487 // Memory barriers between rendering and copies
1489 std::vector<VkImageMemoryBarrier> barriers;
1491 for (size_t dstNdx = 0; dstNdx < m_dstSinglesampleImages.size(); dstNdx++)
1493 const VkImageMemoryBarrier barrier =
1495 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
1498 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
1499 VK_ACCESS_TRANSFER_READ_BIT,
1501 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
1502 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
1504 VK_QUEUE_FAMILY_IGNORED,
1505 VK_QUEUE_FAMILY_IGNORED,
1507 **m_dstSinglesampleImages[dstNdx],
1509 VK_IMAGE_ASPECT_COLOR_BIT,
1517 barriers.push_back(barrier);
1520 vkd.cmdPipelineBarrier(*commandBuffer, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0u, 0u, DE_NULL, 0u, DE_NULL, (deUint32)barriers.size(), &barriers[0]);
1523 // Copy image memory to buffers
1524 for (size_t dstNdx = 0; dstNdx < m_dstSinglesampleImages.size(); dstNdx++)
1526 const VkBufferImageCopy region =
1532 VK_IMAGE_ASPECT_COLOR_BIT,
1538 { m_width, m_height, 1u }
1541 vkd.cmdCopyImageToBuffer(*commandBuffer, **m_dstSinglesampleImages[dstNdx], VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, **m_dstBuffers[dstNdx], 1u, ®ion);
1544 // Memory barriers between copies and host access
1546 std::vector<VkBufferMemoryBarrier> barriers;
1548 for (size_t dstNdx = 0; dstNdx < m_dstBuffers.size(); dstNdx++)
1550 const VkBufferMemoryBarrier barrier =
1552 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
1555 VK_ACCESS_TRANSFER_WRITE_BIT,
1556 VK_ACCESS_HOST_READ_BIT,
1558 VK_QUEUE_FAMILY_IGNORED,
1559 VK_QUEUE_FAMILY_IGNORED,
1561 **m_dstBuffers[dstNdx],
1566 barriers.push_back(barrier);
1569 vkd.cmdPipelineBarrier(*commandBuffer, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0u, 0u, DE_NULL, (deUint32)barriers.size(), &barriers[0], 0u, DE_NULL);
1572 VK_CHECK(vkd.endCommandBuffer(*commandBuffer));
1575 const VkSubmitInfo submitInfo =
1577 VK_STRUCTURE_TYPE_SUBMIT_INFO,
1591 VK_CHECK(vkd.queueSubmit(m_context.getUniversalQueue(), 1u, &submitInfo, (VkFence)0u));
1593 VK_CHECK(vkd.queueWaitIdle(m_context.getUniversalQueue()));
1597 const tcu::TextureFormat format (mapVkFormat(m_dstFormat));
1598 const tcu::TextureFormat srcFormat (mapVkFormat(m_srcFormat));
1599 const bool hasDepth (tcu::hasDepthComponent(srcFormat.order));
1600 const bool hasStencil (tcu::hasStencilComponent(srcFormat.order));
1602 for (deUint32 sampleNdx = 0; sampleNdx < m_sampleCount; sampleNdx++)
1604 const std::string name ("Sample" + de::toString(sampleNdx));
1605 const void* const ptr (m_dstBufferMemory[sampleNdx]->getHostPtr());
1606 const tcu::ConstPixelBufferAccess access (format, m_width, m_height, 1, ptr);
1607 tcu::TextureLevel reference (format, m_width, m_height);
1609 if (hasDepth || hasStencil)
1613 for (deUint32 y = 0; y < m_height; y++)
1614 for (deUint32 x = 0; x < m_width; x++)
1616 const deUint32 x1 = x ^ sampleNdx;
1617 const deUint32 y1 = y ^ sampleNdx;
1618 const float range = 1.0f;
1620 deUint32 divider = 2;
1622 // \note Limited to ten bits since the target is 32x32, so there are 10 input bits
1623 for (size_t bitNdx = 0; bitNdx < 10; bitNdx++)
1625 depth += (range / (float)divider)
1626 * (((bitNdx % 2 == 0 ? x1 : y1) & (0x1u << (bitNdx / 2u))) == 0u ? 0u : 1u);
1630 reference.getAccess().setPixel(Vec4(depth, 0.0f, 0.0f, 0.0f), x, y);
1635 for (deUint32 y = 0; y < m_height; y++)
1636 for (deUint32 x = 0; x < m_width; x++)
1638 const deUint32 stencil = sampleNdx + 1u;
1642 const Vec4 src (reference.getAccess().getPixel(x, y));
1644 reference.getAccess().setPixel(Vec4(src.x(), (float)stencil, 0.0f, 0.0f), x, y);
1647 reference.getAccess().setPixel(Vec4((float)stencil, 0.0f, 0.0f, 0.0f), x, y);
1651 const Vec4 threshold (hasDepth ? (1.0f / 1024.0f) : 0.0f, 0.0f, 0.0f, 0.0f);
1653 if (!tcu::floatThresholdCompare(m_context.getTestContext().getLog(), name.c_str(), name.c_str(), reference.getAccess(), access, threshold, tcu::COMPARE_LOG_ON_ERROR))
1654 m_resultCollector.fail("Compare failed for sample " + de::toString(sampleNdx));
1659 const tcu::TextureChannelClass channelClass (tcu::getTextureChannelClass(format.type));
1661 switch (channelClass)
1663 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
1665 const UVec4 bits (tcu::getTextureFormatBitDepth(format).cast<deUint32>());
1666 const UVec4 minValue (0);
1667 const UVec4 range (UVec4(1u) << tcu::min(bits, UVec4(31)));
1668 const int componentCount (tcu::getNumUsedChannels(format.order));
1669 const deUint32 bitSize (bits[0] + bits[1] + bits[2] + bits[3]);
1671 for (deUint32 y = 0; y < m_height; y++)
1672 for (deUint32 x = 0; x < m_width; x++)
1674 const deUint32 x1 = x ^ sampleNdx;
1675 const deUint32 y1 = y ^ sampleNdx;
1676 UVec4 color (minValue);
1677 deUint32 dstBitsUsed[4] = { 0u, 0u, 0u, 0u };
1678 deUint32 nextSrcBit = 0;
1679 deUint32 divider = 2;
1681 // \note Limited to ten bits since the target is 32x32, so there are 10 input bits
1682 while (nextSrcBit < de::min(bitSize, 10u))
1684 for (int compNdx = 0; compNdx < componentCount; compNdx++)
1686 if (dstBitsUsed[compNdx] > bits[compNdx])
1689 color[compNdx] += (range[compNdx] / divider)
1690 * (((nextSrcBit % 2 == 0 ? x1 : y1) & (0x1u << (nextSrcBit / 2u))) == 0u ? 0u : 1u);
1693 dstBitsUsed[compNdx]++;
1699 reference.getAccess().setPixel(color, x, y);
1702 if (!tcu::intThresholdCompare(m_context.getTestContext().getLog(), name.c_str(), name.c_str(), reference.getAccess(), access, UVec4(0u), tcu::COMPARE_LOG_ON_ERROR))
1703 m_resultCollector.fail("Compare failed for sample " + de::toString(sampleNdx));
1708 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
1710 const UVec4 bits (tcu::getTextureFormatBitDepth(format).cast<deUint32>());
1711 const IVec4 minValue (0);
1712 const IVec4 range ((UVec4(1u) << tcu::min(bits, UVec4(30))).cast<deInt32>());
1713 const int componentCount (tcu::getNumUsedChannels(format.order));
1714 const deUint32 bitSize (bits[0] + bits[1] + bits[2] + bits[3]);
1716 for (deUint32 y = 0; y < m_height; y++)
1717 for (deUint32 x = 0; x < m_width; x++)
1719 const deUint32 x1 = x ^ sampleNdx;
1720 const deUint32 y1 = y ^ sampleNdx;
1721 IVec4 color (minValue);
1722 deUint32 dstBitsUsed[4] = { 0u, 0u, 0u, 0u };
1723 deUint32 nextSrcBit = 0;
1724 deUint32 divider = 2;
1726 // \note Limited to ten bits since the target is 32x32, so there are 10 input bits
1727 while (nextSrcBit < de::min(bitSize, 10u))
1729 for (int compNdx = 0; compNdx < componentCount; compNdx++)
1731 if (dstBitsUsed[compNdx] > bits[compNdx])
1734 color[compNdx] += (range[compNdx] / divider)
1735 * (((nextSrcBit % 2 == 0 ? x1 : y1) & (0x1u << (nextSrcBit / 2u))) == 0u ? 0u : 1u);
1738 dstBitsUsed[compNdx]++;
1744 reference.getAccess().setPixel(color, x, y);
1747 if (!tcu::intThresholdCompare(m_context.getTestContext().getLog(), name.c_str(), name.c_str(), reference.getAccess(), access, UVec4(0u), tcu::COMPARE_LOG_ON_ERROR))
1748 m_resultCollector.fail("Compare failed for sample " + de::toString(sampleNdx));
1753 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
1754 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
1755 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
1757 const tcu::TextureFormatInfo info (tcu::getTextureFormatInfo(format));
1758 const UVec4 bits (tcu::getTextureFormatBitDepth(format).cast<deUint32>());
1759 const Vec4 minLimit (-65536.0);
1760 const Vec4 maxLimit (65536.0);
1761 const Vec4 minValue (tcu::max(info.valueMin, minLimit));
1762 const Vec4 range (tcu::min(info.valueMax, maxLimit) - minValue);
1763 const int componentCount (tcu::getNumUsedChannels(format.order));
1764 const deUint32 bitSize (bits[0] + bits[1] + bits[2] + bits[3]);
1766 for (deUint32 y = 0; y < m_height; y++)
1767 for (deUint32 x = 0; x < m_width; x++)
1769 const deUint32 x1 = x ^ sampleNdx;
1770 const deUint32 y1 = y ^ sampleNdx;
1771 Vec4 color (minValue);
1772 deUint32 dstBitsUsed[4] = { 0u, 0u, 0u, 0u };
1773 deUint32 nextSrcBit = 0;
1774 deUint32 divider = 2;
1776 // \note Limited to ten bits since the target is 32x32, so there are 10 input bits
1777 while (nextSrcBit < de::min(bitSize, 10u))
1779 for (int compNdx = 0; compNdx < componentCount; compNdx++)
1781 if (dstBitsUsed[compNdx] > bits[compNdx])
1784 color[compNdx] += (range[compNdx] / (float)divider)
1785 * (((nextSrcBit % 2 == 0 ? x1 : y1) & (0x1u << (nextSrcBit / 2u))) == 0u ? 0u : 1u);
1788 dstBitsUsed[compNdx]++;
1794 if (tcu::isSRGB(format))
1795 reference.getAccess().setPixel(tcu::linearToSRGB(color), x, y);
1797 reference.getAccess().setPixel(color, x, y);
1800 if (channelClass == tcu::TEXTURECHANNELCLASS_FLOATING_POINT)
1802 // Convert target format ulps to float ulps and allow 64ulp differences
1803 const UVec4 threshold (64u * (UVec4(1u) << (UVec4(23) - tcu::getTextureFormatMantissaBitDepth(format).cast<deUint32>())));
1805 if (!tcu::floatUlpThresholdCompare(m_context.getTestContext().getLog(), name.c_str(), name.c_str(), reference.getAccess(), access, threshold, tcu::COMPARE_LOG_ON_ERROR))
1806 m_resultCollector.fail("Compare failed for sample " + de::toString(sampleNdx));
1810 // Allow error of 4 times the minimum presentable difference
1811 const Vec4 threshold (4.0f * 1.0f / ((UVec4(1u) << tcu::getTextureFormatMantissaBitDepth(format).cast<deUint32>()) - 1u).cast<float>());
1813 if (!tcu::floatThresholdCompare(m_context.getTestContext().getLog(), name.c_str(), name.c_str(), reference.getAccess(), access, threshold, tcu::COMPARE_LOG_ON_ERROR))
1814 m_resultCollector.fail("Compare failed for sample " + de::toString(sampleNdx));
1821 DE_FATAL("Unknown channel class");
1827 return tcu::TestStatus(m_resultCollector.getResult(), m_resultCollector.getMessage());
1832 void init (vk::SourceCollections& dst, TestConfig config) const
1834 const tcu::TextureFormat format (mapVkFormat(config.format));
1835 const tcu::TextureChannelClass channelClass (tcu::getTextureChannelClass(format.type));
1837 dst.glslSources.add("quad-vert") << glu::VertexSource(
1839 "out gl_PerVertex {\n"
1840 "\tvec4 gl_Position;\n"
1843 "void main (void) {\n"
1844 "\tgl_Position = vec4(((gl_VertexIndex + 2) / 3) % 2 == 0 ? -1.0 : 1.0,\n"
1845 "\t ((gl_VertexIndex + 1) / 3) % 2 == 0 ? -1.0 : 1.0, 0.0, 1.0);\n"
1848 if (tcu::hasDepthComponent(format.order))
1850 const Vec4 minValue (0.0f);
1851 const Vec4 range (1.0f);
1852 std::ostringstream fragmentShader;
1856 "layout(push_constant) uniform PushConstant {\n"
1857 "\thighp uint sampleIndex;\n"
1858 "} pushConstants;\n"
1859 "void main (void)\n"
1861 "\thighp uint sampleIndex = pushConstants.sampleIndex;\n"
1862 "\tgl_SampleMask[0] = int((~0x0u) << sampleIndex);\n"
1863 "\thighp float depth;\n"
1864 "\thighp uint x = sampleIndex ^ uint(gl_FragCoord.x);\n"
1865 "\thighp uint y = sampleIndex ^ uint(gl_FragCoord.y);\n";
1867 fragmentShader << "\tdepth = " << minValue[0] << ";\n";
1870 deUint32 divider = 2;
1872 // \note Limited to ten bits since the target is 32x32, so there are 10 input bits
1873 for (size_t bitNdx = 0; bitNdx < 10; bitNdx++)
1876 "\tdepth += " << (range[0] / (float)divider)
1877 << " * float(bitfieldExtract(" << (bitNdx % 2 == 0 ? "x" : "y") << ", " << (bitNdx / 2) << ", 1));\n";
1884 "\tgl_FragDepth = depth;\n"
1887 dst.glslSources.add("quad-frag") << glu::FragmentSource(fragmentShader.str());
1889 else if (tcu::hasStencilComponent(format.order))
1891 dst.glslSources.add("quad-frag") << glu::FragmentSource(
1893 "layout(push_constant) uniform PushConstant {\n"
1894 "\thighp uint sampleIndex;\n"
1895 "} pushConstants;\n"
1896 "void main (void)\n"
1898 "\thighp uint sampleIndex = pushConstants.sampleIndex;\n"
1899 "\tgl_SampleMask[0] = int((~0x0u) << sampleIndex);\n"
1904 switch (channelClass)
1906 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
1908 const UVec4 bits (tcu::getTextureFormatBitDepth(format).cast<deUint32>());
1909 const UVec4 minValue (0);
1910 const UVec4 range (UVec4(1u) << tcu::min(bits, UVec4(31)));
1911 std::ostringstream fragmentShader;
1915 "layout(location = 0) out highp uvec4 o_color;\n"
1916 "layout(push_constant) uniform PushConstant {\n"
1917 "\thighp uint sampleIndex;\n"
1918 "} pushConstants;\n"
1919 "void main (void)\n"
1921 "\thighp uint sampleIndex = pushConstants.sampleIndex;\n"
1922 "\tgl_SampleMask[0] = int(0x1u << sampleIndex);\n"
1923 "\thighp uint color[4];\n"
1924 "\thighp uint x = sampleIndex ^ uint(gl_FragCoord.x);\n"
1925 "\thighp uint y = sampleIndex ^ uint(gl_FragCoord.y);\n";
1927 for (int ndx = 0; ndx < 4; ndx++)
1928 fragmentShader << "\tcolor[" << ndx << "] = " << minValue[ndx] << ";\n";
1931 const int componentCount = tcu::getNumUsedChannels(format.order);
1932 const deUint32 bitSize (bits[0] + bits[1] + bits[2] + bits[3]);
1933 deUint32 dstBitsUsed[4] = { 0u, 0u, 0u, 0u };
1934 deUint32 nextSrcBit = 0;
1935 deUint32 divider = 2;
1937 // \note Limited to ten bits since the target is 32x32, so there are 10 input bits
1938 while (nextSrcBit < de::min(bitSize, 10u))
1940 for (int compNdx = 0; compNdx < componentCount; compNdx++)
1942 if (dstBitsUsed[compNdx] > bits[compNdx])
1946 "\tcolor[" << compNdx << "] += " << (range[compNdx] / divider)
1947 << " * bitfieldExtract(" << (nextSrcBit % 2 == 0 ? "x" : "y") << ", " << (nextSrcBit / 2) << ", 1);\n";
1950 dstBitsUsed[compNdx]++;
1958 "\to_color = uvec4(color[0], color[1], color[2], color[3]);\n"
1961 dst.glslSources.add("quad-frag") << glu::FragmentSource(fragmentShader.str());
1965 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
1967 const UVec4 bits (tcu::getTextureFormatBitDepth(format).cast<deUint32>());
1968 const IVec4 minValue (0);
1969 const IVec4 range ((UVec4(1u) << tcu::min(bits, UVec4(30))).cast<deInt32>());
1970 const IVec4 maxV ((UVec4(1u) << (bits - UVec4(1u))).cast<deInt32>());
1971 const IVec4 clampMax (maxV - 1);
1972 const IVec4 clampMin (-maxV);
1973 std::ostringstream fragmentShader;
1977 "layout(location = 0) out highp ivec4 o_color;\n"
1978 "layout(push_constant) uniform PushConstant {\n"
1979 "\thighp uint sampleIndex;\n"
1980 "} pushConstants;\n"
1981 "void main (void)\n"
1983 "\thighp uint sampleIndex = pushConstants.sampleIndex;\n"
1984 "\tgl_SampleMask[0] = int(0x1u << sampleIndex);\n"
1985 "\thighp int color[4];\n"
1986 "\thighp uint x = sampleIndex ^ uint(gl_FragCoord.x);\n"
1987 "\thighp uint y = sampleIndex ^ uint(gl_FragCoord.y);\n";
1989 for (int ndx = 0; ndx < 4; ndx++)
1990 fragmentShader << "\tcolor[" << ndx << "] = " << minValue[ndx] << ";\n";
1993 const int componentCount = tcu::getNumUsedChannels(format.order);
1994 const deUint32 bitSize (bits[0] + bits[1] + bits[2] + bits[3]);
1995 deUint32 dstBitsUsed[4] = { 0u, 0u, 0u, 0u };
1996 deUint32 nextSrcBit = 0;
1997 deUint32 divider = 2;
1999 // \note Limited to ten bits since the target is 32x32, so there are 10 input bits
2000 while (nextSrcBit < de::min(bitSize, 10u))
2002 for (int compNdx = 0; compNdx < componentCount; compNdx++)
2004 if (dstBitsUsed[compNdx] > bits[compNdx])
2008 "\tcolor[" << compNdx << "] += " << (range[compNdx] / divider)
2009 << " * int(bitfieldExtract(" << (nextSrcBit % 2 == 0 ? "x" : "y") << ", " << (nextSrcBit / 2) << ", 1));\n";
2012 dstBitsUsed[compNdx]++;
2019 // The spec doesn't define whether signed-integers are clamped on output,
2020 // so we'll clamp them explicitly to have well-defined outputs.
2022 "\to_color = clamp(ivec4(color[0], color[1], color[2], color[3]), " <<
2023 "ivec4" << clampMin << ", ivec4" << clampMax << ");\n" <<
2026 dst.glslSources.add("quad-frag") << glu::FragmentSource(fragmentShader.str());
2030 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
2031 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
2032 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
2034 const tcu::TextureFormatInfo info (tcu::getTextureFormatInfo(format));
2035 const UVec4 bits (tcu::getTextureFormatMantissaBitDepth(format).cast<deUint32>());
2036 const Vec4 minLimit (-65536.0);
2037 const Vec4 maxLimit (65536.0);
2038 const Vec4 minValue (tcu::max(info.valueMin, minLimit));
2039 const Vec4 range (tcu::min(info.valueMax, maxLimit) - minValue);
2040 std::ostringstream fragmentShader;
2044 "layout(location = 0) out highp vec4 o_color;\n"
2045 "layout(push_constant) uniform PushConstant {\n"
2046 "\thighp uint sampleIndex;\n"
2047 "} pushConstants;\n"
2048 "void main (void)\n"
2050 "\thighp uint sampleIndex = pushConstants.sampleIndex;\n"
2051 "\tgl_SampleMask[0] = int(0x1u << sampleIndex);\n"
2052 "\thighp float color[4];\n"
2053 "\thighp uint x = sampleIndex ^ uint(gl_FragCoord.x);\n"
2054 "\thighp uint y = sampleIndex ^ uint(gl_FragCoord.y);\n";
2056 for (int ndx = 0; ndx < 4; ndx++)
2057 fragmentShader << "\tcolor[" << ndx << "] = " << minValue[ndx] << ";\n";
2060 const int componentCount = tcu::getNumUsedChannels(format.order);
2061 const deUint32 bitSize (bits[0] + bits[1] + bits[2] + bits[3]);
2062 deUint32 dstBitsUsed[4] = { 0u, 0u, 0u, 0u };
2063 deUint32 nextSrcBit = 0;
2064 deUint32 divider = 2;
2066 // \note Limited to ten bits since the target is 32x32, so there are 10 input bits
2067 while (nextSrcBit < de::min(bitSize, 10u))
2069 for (int compNdx = 0; compNdx < componentCount; compNdx++)
2071 if (dstBitsUsed[compNdx] > bits[compNdx])
2075 "\tcolor[" << compNdx << "] += " << (range[compNdx] / (float)divider)
2076 << " * float(bitfieldExtract(" << (nextSrcBit % 2 == 0 ? "x" : "y") << ", " << (nextSrcBit / 2) << ", 1));\n";
2079 dstBitsUsed[compNdx]++;
2087 "\to_color = vec4(color[0], color[1], color[2], color[3]);\n"
2090 dst.glslSources.add("quad-frag") << glu::FragmentSource(fragmentShader.str());
2095 DE_FATAL("Unknown channel class");
2099 if (tcu::hasDepthComponent(format.order) || tcu::hasStencilComponent(format.order))
2101 std::ostringstream splitShader;
2106 if (tcu::hasDepthComponent(format.order) && tcu::hasStencilComponent(format.order))
2108 splitShader << "layout(input_attachment_index = 0, set = 0, binding = 0) uniform highp subpassInputMS i_depth;\n"
2109 << "layout(input_attachment_index = 0, set = 0, binding = 1) uniform highp usubpassInputMS i_stencil;\n";
2111 else if (tcu::hasDepthComponent(format.order))
2112 splitShader << "layout(input_attachment_index = 0, set = 0, binding = 0) uniform highp subpassInputMS i_depth;\n";
2113 else if (tcu::hasStencilComponent(format.order))
2114 splitShader << "layout(input_attachment_index = 0, set = 0, binding = 0) uniform highp usubpassInputMS i_stencil;\n";
2117 "layout(push_constant) uniform PushConstant {\n"
2118 "\thighp uint splitSubpassIndex;\n"
2119 "} pushConstants;\n";
2121 for (deUint32 attachmentNdx = 0; attachmentNdx < de::min((deUint32)MAX_COLOR_ATTACHMENT_COUNT, config.sampleCount); attachmentNdx++)
2123 if (tcu::hasDepthComponent(format.order) && tcu::hasStencilComponent(format.order))
2124 splitShader << "layout(location = " << attachmentNdx << ") out highp vec2 o_color" << attachmentNdx << ";\n";
2126 splitShader << "layout(location = " << attachmentNdx << ") out highp float o_color" << attachmentNdx << ";\n";
2130 "void main (void)\n"
2133 for (deUint32 attachmentNdx = 0; attachmentNdx < de::min((deUint32)MAX_COLOR_ATTACHMENT_COUNT, config.sampleCount); attachmentNdx++)
2135 if (tcu::hasDepthComponent(format.order))
2136 splitShader << "\thighp float depth" << attachmentNdx << " = subpassLoad(i_depth, int(" << MAX_COLOR_ATTACHMENT_COUNT << " * pushConstants.splitSubpassIndex + " << attachmentNdx << "u)).x;\n";
2138 if (tcu::hasStencilComponent(format.order))
2139 splitShader << "\thighp uint stencil" << attachmentNdx << " = subpassLoad(i_stencil, int(" << MAX_COLOR_ATTACHMENT_COUNT << " * pushConstants.splitSubpassIndex + " << attachmentNdx << "u)).x;\n";
2141 if (tcu::hasDepthComponent(format.order) && tcu::hasStencilComponent(format.order))
2142 splitShader << "\to_color" << attachmentNdx << " = vec2(depth" << attachmentNdx << ", float(stencil" << attachmentNdx << "));\n";
2143 else if (tcu::hasDepthComponent(format.order))
2144 splitShader << "\to_color" << attachmentNdx << " = float(depth" << attachmentNdx << ");\n";
2145 else if (tcu::hasStencilComponent(format.order))
2146 splitShader << "\to_color" << attachmentNdx << " = float(stencil" << attachmentNdx << ");\n";
2152 dst.glslSources.add("quad-split-frag") << glu::FragmentSource(splitShader.str());
2156 std::string subpassType;
2157 std::string outputType;
2159 switch (channelClass)
2161 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
2162 subpassType = "usubpassInputMS";
2163 outputType = "uvec4";
2166 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
2167 subpassType = "isubpassInputMS";
2168 outputType = "ivec4";
2171 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
2172 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
2173 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
2174 subpassType = "subpassInputMS";
2175 outputType = "vec4";
2179 DE_FATAL("Unknown channel class");
2182 std::ostringstream splitShader;
2185 "layout(input_attachment_index = 0, set = 0, binding = 0) uniform highp " << subpassType << " i_color;\n"
2186 "layout(push_constant) uniform PushConstant {\n"
2187 "\thighp uint splitSubpassIndex;\n"
2188 "} pushConstants;\n";
2190 for (deUint32 attachmentNdx = 0; attachmentNdx < de::min((deUint32)MAX_COLOR_ATTACHMENT_COUNT, config.sampleCount); attachmentNdx++)
2191 splitShader << "layout(location = " << attachmentNdx << ") out highp " << outputType << " o_color" << attachmentNdx << ";\n";
2194 "void main (void)\n"
2197 for (deUint32 attachmentNdx = 0; attachmentNdx < de::min((deUint32)MAX_COLOR_ATTACHMENT_COUNT, config.sampleCount); attachmentNdx++)
2198 splitShader << "\to_color" << attachmentNdx << " = subpassLoad(i_color, int(" << MAX_COLOR_ATTACHMENT_COUNT << " * pushConstants.splitSubpassIndex + " << attachmentNdx << "u));\n";
2203 dst.glslSources.add("quad-split-frag") << glu::FragmentSource(splitShader.str());
2208 std::string formatToName (VkFormat format)
2210 const std::string formatStr = de::toString(format);
2211 const std::string prefix = "VK_FORMAT_";
2213 DE_ASSERT(formatStr.substr(0, prefix.length()) == prefix);
2215 return de::toLower(formatStr.substr(prefix.length()));
2218 void initTests (tcu::TestCaseGroup* group)
2220 static const VkFormat formats[] =
2222 VK_FORMAT_R5G6B5_UNORM_PACK16,
2227 VK_FORMAT_R8G8_UNORM,
2228 VK_FORMAT_R8G8_SNORM,
2229 VK_FORMAT_R8G8_UINT,
2230 VK_FORMAT_R8G8_SINT,
2231 VK_FORMAT_R8G8B8A8_UNORM,
2232 VK_FORMAT_R8G8B8A8_SNORM,
2233 VK_FORMAT_R8G8B8A8_UINT,
2234 VK_FORMAT_R8G8B8A8_SINT,
2235 VK_FORMAT_R8G8B8A8_SRGB,
2236 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
2237 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
2238 VK_FORMAT_A8B8G8R8_UINT_PACK32,
2239 VK_FORMAT_A8B8G8R8_SINT_PACK32,
2240 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
2241 VK_FORMAT_B8G8R8A8_UNORM,
2242 VK_FORMAT_B8G8R8A8_SRGB,
2243 VK_FORMAT_A2R10G10B10_UNORM_PACK32,
2244 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
2245 VK_FORMAT_A2B10G10R10_UINT_PACK32,
2246 VK_FORMAT_R16_UNORM,
2247 VK_FORMAT_R16_SNORM,
2250 VK_FORMAT_R16_SFLOAT,
2251 VK_FORMAT_R16G16_UNORM,
2252 VK_FORMAT_R16G16_SNORM,
2253 VK_FORMAT_R16G16_UINT,
2254 VK_FORMAT_R16G16_SINT,
2255 VK_FORMAT_R16G16_SFLOAT,
2256 VK_FORMAT_R16G16B16A16_UNORM,
2257 VK_FORMAT_R16G16B16A16_SNORM,
2258 VK_FORMAT_R16G16B16A16_UINT,
2259 VK_FORMAT_R16G16B16A16_SINT,
2260 VK_FORMAT_R16G16B16A16_SFLOAT,
2263 VK_FORMAT_R32_SFLOAT,
2264 VK_FORMAT_R32G32_UINT,
2265 VK_FORMAT_R32G32_SINT,
2266 VK_FORMAT_R32G32_SFLOAT,
2267 VK_FORMAT_R32G32B32A32_UINT,
2268 VK_FORMAT_R32G32B32A32_SINT,
2269 VK_FORMAT_R32G32B32A32_SFLOAT,
2271 VK_FORMAT_D16_UNORM,
2272 VK_FORMAT_X8_D24_UNORM_PACK32,
2273 VK_FORMAT_D32_SFLOAT,
2275 VK_FORMAT_D16_UNORM_S8_UINT,
2276 VK_FORMAT_D24_UNORM_S8_UINT,
2277 VK_FORMAT_D32_SFLOAT_S8_UINT
2279 const deUint32 sampleCounts[] =
2281 2u, 4u, 8u, 16u, 32u
2283 tcu::TestContext& testCtx (group->getTestContext());
2285 for (size_t formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(formats); formatNdx++)
2287 const VkFormat format (formats[formatNdx]);
2288 const std::string formatName (formatToName(format));
2289 de::MovePtr<tcu::TestCaseGroup> formatGroup (new tcu::TestCaseGroup(testCtx, formatName.c_str(), formatName.c_str()));
2291 for (size_t sampleCountNdx = 0; sampleCountNdx < DE_LENGTH_OF_ARRAY(sampleCounts); sampleCountNdx++)
2293 const deUint32 sampleCount (sampleCounts[sampleCountNdx]);
2294 const std::string testName ("samples_" + de::toString(sampleCount));
2296 formatGroup->addChild(new InstanceFactory1<MultisampleRenderPassTestInstance, TestConfig, Programs>(testCtx, tcu::NODETYPE_SELF_VALIDATE, testName.c_str(), testName.c_str(), TestConfig(format, sampleCount)));
2299 group->addChild(formatGroup.release());
2305 tcu::TestCaseGroup* createRenderPassMultisampleTests (tcu::TestContext& testCtx)
2307 return createTestGroup(testCtx, "multisample", "Multisample render pass tests", initTests);