1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2016 The Khronos Group Inc.
6 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and/or associated documentation files (the
10 * "Materials"), to deal in the Materials without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sublicense, and/or sell copies of the Materials, and to
13 * permit persons to whom the Materials are furnished to do so, subject to
14 * the following conditions:
16 * The above copyright notice(s) and this permission notice shall be included
17 * in all copies or substantial portions of the Materials.
19 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
29 * \brief Vulkan Image Clearing Tests
30 *//*--------------------------------------------------------------------*/
32 #include "vktApiImageClearingTests.hpp"
34 #include "deRandom.hpp"
36 #include "deStringUtil.hpp"
37 #include "deUniquePtr.hpp"
38 #include "deArrayUtil.hpp"
39 #include "vkImageUtil.hpp"
40 #include "vkMemUtil.hpp"
41 #include "vktTestCase.hpp"
42 #include "vktTestCaseUtil.hpp"
43 #include "vkQueryUtil.hpp"
44 #include "vkRefUtil.hpp"
45 #include "vkTypeUtil.hpp"
46 #include "tcuImageCompare.hpp"
47 #include "tcuTexture.hpp"
48 #include "tcuTextureUtil.hpp"
49 #include "tcuVectorType.hpp"
50 #include "tcuTexture.hpp"
51 #include "tcuFloat.hpp"
52 #include "tcuTestLog.hpp"
53 #include "tcuVectorUtil.hpp"
68 // This method is copied from the vktRenderPassTests.cpp. It should be moved to a common place.
69 int calcFloatDiff (float a, float b)
71 const int asign = Float32(a).sign();
72 const int bsign = Float32(a).sign();
74 const deUint32 avalue = (Float32(a).bits() & ((0x1u << 31u) - 1u));
75 const deUint32 bvalue = (Float32(b).bits() & ((0x1u << 31u) - 1u));
78 return avalue + bvalue + 1u;
79 else if (avalue < bvalue)
80 return bvalue - avalue;
82 return avalue - bvalue;
85 // This method is copied from the vktRenderPassTests.cpp and extended with the stringResult parameter.
86 bool comparePixelToDepthClearValue (const ConstPixelBufferAccess& access,
90 std::string& stringResult)
92 const TextureFormat format = getEffectiveDepthStencilTextureFormat(access.getFormat(), Sampler::MODE_DEPTH);
93 const TextureChannelClass channelClass = getTextureChannelClass(format.type);
97 case TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
98 case TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
100 const int bitDepth = getTextureFormatBitDepth(format).x();
101 const float depth = access.getPixDepth(x, y);
102 const float threshold = 2.0f / (float)((1 << bitDepth) - 1);
103 const bool result = deFloatAbs(depth - ref) <= threshold;
108 s << "Ref:" << ref << " Threshold:" << threshold << " Depth:" << depth;
109 stringResult = s.str();
115 case TEXTURECHANNELCLASS_FLOATING_POINT:
117 const float depth = access.getPixDepth(x, y);
118 const int mantissaBits = getTextureFormatMantissaBitDepth(format).x();
119 const int threshold = 10 * 1 << (23 - mantissaBits);
121 DE_ASSERT(mantissaBits <= 23);
123 const bool result = calcFloatDiff(depth, ref) <= threshold;
127 float floatThreshold = Float32((deUint32)threshold).asFloat();
130 s << "Ref:" << ref << " Threshold:" << floatThreshold << " Depth:" << depth;
131 stringResult = s.str();
138 DE_FATAL("Invalid channel class");
143 // This method is copied from the vktRenderPassTests.cpp and extended with the stringResult parameter.
144 bool comparePixelToStencilClearValue (const ConstPixelBufferAccess& access,
148 std::string& stringResult)
150 const deUint32 stencil = access.getPixStencil(x, y);
151 const bool result = stencil == ref;
156 s << "Ref:" << ref << " Threshold:0" << " Stencil:" << stencil;
157 stringResult = s.str();
163 // This method is copied from the vktRenderPassTests.cpp and extended with the stringResult parameter.
164 bool comparePixelToColorClearValue (const ConstPixelBufferAccess& access,
168 const VkClearColorValue& ref,
169 std::string& stringResult)
171 const TextureFormat format = access.getFormat();
172 const TextureChannelClass channelClass = getTextureChannelClass(format.type);
173 const BVec4 channelMask = getTextureFormatChannelMask(format);
175 switch (channelClass)
177 case TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
178 case TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
180 const IVec4 bitDepth (getTextureFormatBitDepth(format));
181 const Vec4 resColor (access.getPixel(x, y, z));
182 Vec4 refColor (ref.float32[0],
186 const int modifier = (channelClass == TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT) ? 0 : 1;
187 const Vec4 threshold (bitDepth[0] > 0 ? 1.0f / ((float)(1 << (bitDepth[0] - modifier)) - 1.0f) : 1.0f,
188 bitDepth[1] > 0 ? 1.0f / ((float)(1 << (bitDepth[1] - modifier)) - 1.0f) : 1.0f,
189 bitDepth[2] > 0 ? 1.0f / ((float)(1 << (bitDepth[2] - modifier)) - 1.0f) : 1.0f,
190 bitDepth[3] > 0 ? 1.0f / ((float)(1 << (bitDepth[3] - modifier)) - 1.0f) : 1.0f);
192 if (isSRGB(access.getFormat()))
193 refColor = linearToSRGB(refColor);
195 const bool result = !(anyNotEqual(logicalAnd(lessThanEqual(absDiff(resColor, refColor), threshold), channelMask), channelMask));
200 s << "Ref:" << refColor << " Mask:" << channelMask << " Threshold:" << threshold << " Color:" << resColor;
201 stringResult = s.str();
207 case TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
209 const UVec4 resColor (access.getPixelUint(x, y, z));
210 const UVec4 refColor (ref.uint32[0],
214 const UVec4 threshold (1);
216 const bool result = !(anyNotEqual(logicalAnd(lessThanEqual(absDiff(resColor, refColor), threshold), channelMask), channelMask));
221 s << "Ref:" << refColor << " Mask:" << channelMask << " Threshold:" << threshold << " Color:" << resColor;
222 stringResult = s.str();
228 case TEXTURECHANNELCLASS_SIGNED_INTEGER:
230 const IVec4 resColor (access.getPixelInt(x, y, z));
231 const IVec4 refColor (ref.int32[0],
235 const IVec4 threshold (1);
237 const bool result = !(anyNotEqual(logicalAnd(lessThanEqual(absDiff(resColor, refColor), threshold), channelMask), channelMask));
242 s << "Ref:" << refColor << " Mask:" << channelMask << " Threshold:" << threshold << " Color:" << resColor;
243 stringResult = s.str();
249 case TEXTURECHANNELCLASS_FLOATING_POINT:
251 const Vec4 resColor (access.getPixel(x, y, z));
252 const Vec4 refColor (ref.float32[0],
256 const IVec4 mantissaBits (getTextureFormatMantissaBitDepth(format));
257 const IVec4 threshold (10 * IVec4(1) << (23 - mantissaBits));
259 DE_ASSERT(allEqual(greaterThanEqual(threshold, IVec4(0)), BVec4(true)));
261 for (int ndx = 0; ndx < 4; ndx++)
263 const bool result = !(calcFloatDiff(resColor[ndx], refColor[ndx]) > threshold[ndx] && channelMask[ndx]);
267 float floatThreshold = Float32((deUint32)(threshold)[0]).asFloat();
268 Vec4 thresholdVec4 (floatThreshold,
273 s << "Ref:" << refColor << " Mask:" << channelMask << " Threshold:" << thresholdVec4 << " Color:" << resColor;
274 stringResult = s.str();
284 DE_FATAL("Invalid channel class");
291 VkImageType imageType;
292 VkFormat imageFormat;
293 VkExtent3D imageExtent;
294 VkClearValue initValue;
295 VkClearValue clearValue;
298 class ImageClearingTestInstance : public vkt::TestInstance
301 ImageClearingTestInstance (Context& context,
302 const TestParams& testParams);
304 Move<VkCommandPool> createCommandPool (VkCommandPoolCreateFlags commandPoolCreateFlags) const;
305 Move<VkCommandBuffer> allocatePrimaryCommandBuffer (VkCommandPool commandPool) const;
306 Move<VkImage> createImage (VkImageType imageType, VkFormat format, VkExtent3D extent, VkImageUsageFlags usage) const;
307 Move<VkImageView> createImageView (VkImage image, VkImageViewType viewType, VkFormat format, VkImageAspectFlags aspectMask) const;
308 Move<VkRenderPass> createRenderPass (VkFormat format) const;
309 Move<VkFramebuffer> createFrameBuffer (VkImageView imageView, VkRenderPass renderPass, deUint32 imageWidth, deUint32 imageHeight) const;
311 void beginCommandBuffer (VkCommandBufferUsageFlags usageFlags) const;
312 void endCommandBuffer (void) const;
313 void submitCommandBuffer (void) const;
314 void beginRenderPass (VkSubpassContents content, VkClearValue clearValue) const;
316 void pipelineImageBarrier (VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkImageLayout oldLayout, VkImageLayout newLayout) const;
317 de::MovePtr<TextureLevel> readImage (VkImageAspectFlags aspectMask) const;
320 VkImageViewType getCorrespondingImageViewType (VkImageType imageType) const;
321 VkImageUsageFlags getImageUsageFlags (VkFormat format) const;
322 VkImageAspectFlags getImageAspectFlags (VkFormat format) const;
323 bool getIsAttachmentFormat (VkFormat format) const;
324 bool getIsStencilFormat (VkFormat format) const;
325 bool getIsDepthFormat (VkFormat format) const;
326 de::MovePtr<Allocation> allocateAndBindImageMemory (VkImage image) const;
328 const TestParams& m_params;
329 const VkDevice m_device;
330 const InstanceInterface& m_vki;
331 const DeviceInterface& m_vkd;
332 const VkQueue m_queue;
333 const deUint32 m_queueFamilyIndex;
334 Allocator& m_allocator;
336 const bool m_isAttachmentFormat;
337 const VkImageUsageFlags m_imageUsageFlags;
338 const VkImageAspectFlags m_imageAspectFlags;
340 Unique<VkCommandPool> m_commandPool;
341 Unique<VkCommandBuffer> m_commandBuffer;
343 Unique<VkImage> m_image;
344 de::MovePtr<Allocation> m_imageMemory;
345 Unique<VkImageView> m_imageView;
346 Unique<VkRenderPass> m_renderPass;
347 Unique<VkFramebuffer> m_frameBuffer;
350 ImageClearingTestInstance::ImageClearingTestInstance (Context& context, const TestParams& params)
351 : TestInstance (context)
353 , m_device (context.getDevice())
354 , m_vki (context.getInstanceInterface())
355 , m_vkd (context.getDeviceInterface())
356 , m_queue (context.getUniversalQueue())
357 , m_queueFamilyIndex (context.getUniversalQueueFamilyIndex())
358 , m_allocator (context.getDefaultAllocator())
359 , m_isAttachmentFormat (getIsAttachmentFormat(params.imageFormat))
360 , m_imageUsageFlags (getImageUsageFlags(params.imageFormat))
361 , m_imageAspectFlags (getImageAspectFlags(params.imageFormat))
362 , m_commandPool (createCommandPool(VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT))
363 , m_commandBuffer (allocatePrimaryCommandBuffer(*m_commandPool))
365 , m_image (createImage(params.imageType,
370 , m_imageMemory (allocateAndBindImageMemory(*m_image))
371 , m_imageView (m_isAttachmentFormat ? createImageView(*m_image,
372 getCorrespondingImageViewType(params.imageType),
374 m_imageAspectFlags) : vk::Move<VkImageView>())
376 , m_renderPass (m_isAttachmentFormat ? createRenderPass(params.imageFormat) : vk::Move<vk::VkRenderPass>())
377 , m_frameBuffer (m_isAttachmentFormat ? createFrameBuffer(*m_imageView, *m_renderPass, params.imageExtent.width, params.imageExtent.height) : vk::Move<vk::VkFramebuffer>())
381 VkImageViewType ImageClearingTestInstance::getCorrespondingImageViewType (VkImageType imageType) const
385 case VK_IMAGE_TYPE_1D:
386 return VK_IMAGE_VIEW_TYPE_1D;
387 case VK_IMAGE_TYPE_2D:
388 return VK_IMAGE_VIEW_TYPE_2D;
389 case VK_IMAGE_TYPE_3D:
390 return VK_IMAGE_VIEW_TYPE_3D;
392 DE_FATAL("Unknown image type!");
395 return VK_IMAGE_VIEW_TYPE_2D;
398 VkImageUsageFlags ImageClearingTestInstance::getImageUsageFlags (VkFormat format) const
400 VkImageUsageFlags commonFlags = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
402 if (m_isAttachmentFormat)
404 if (isDepthStencilFormat(format))
405 return commonFlags | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
407 return commonFlags | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
412 VkImageAspectFlags ImageClearingTestInstance::getImageAspectFlags (VkFormat format) const
414 VkImageAspectFlags imageAspectFlags = 0;
416 if (getIsDepthFormat(format))
417 imageAspectFlags |= VK_IMAGE_ASPECT_DEPTH_BIT;
419 if (getIsStencilFormat(format))
420 imageAspectFlags |= VK_IMAGE_ASPECT_STENCIL_BIT;
422 if (imageAspectFlags == 0)
423 imageAspectFlags = VK_IMAGE_ASPECT_COLOR_BIT;
425 return imageAspectFlags;
428 bool ImageClearingTestInstance::getIsAttachmentFormat (VkFormat format) const
430 const VkFormatProperties props = vk::getPhysicalDeviceFormatProperties(m_vki, m_context.getPhysicalDevice(), format);
432 return (props.optimalTilingFeatures & (vk::VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | vk::VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) != 0;
435 bool ImageClearingTestInstance::getIsStencilFormat (VkFormat format) const
437 const TextureFormat tcuFormat = mapVkFormat(format);
439 if (tcuFormat.order == TextureFormat::S || tcuFormat.order == TextureFormat::DS)
445 bool ImageClearingTestInstance::getIsDepthFormat (VkFormat format) const
447 const TextureFormat tcuFormat = mapVkFormat(format);
449 if (tcuFormat.order == TextureFormat::D || tcuFormat.order == TextureFormat::DS)
455 de::MovePtr<Allocation> ImageClearingTestInstance::allocateAndBindImageMemory (VkImage image) const
457 de::MovePtr<Allocation> imageMemory (m_allocator.allocate(getImageMemoryRequirements(m_vkd, m_device, image), MemoryRequirement::Any));
458 VK_CHECK(m_vkd.bindImageMemory(m_device, image, imageMemory->getMemory(), imageMemory->getOffset()));
462 Move<VkCommandPool> ImageClearingTestInstance::createCommandPool (VkCommandPoolCreateFlags commandPoolCreateFlags) const
464 const VkCommandPoolCreateInfo cmdPoolCreateInfo =
466 VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // VkStructureType sType;
467 DE_NULL, // const void* pNext;
468 commandPoolCreateFlags, // VkCommandPoolCreateFlags flags;
469 m_queueFamilyIndex // deUint32 queueFamilyIndex;
472 return vk::createCommandPool(m_vkd, m_device, &cmdPoolCreateInfo, DE_NULL);
475 Move<VkCommandBuffer> ImageClearingTestInstance::allocatePrimaryCommandBuffer (VkCommandPool commandPool) const
477 const VkCommandBufferAllocateInfo cmdBufferAllocateInfo =
479 VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, // VkStructureType sType;
480 DE_NULL, // const void* pNext;
481 commandPool, // VkCommandPool commandPool;
482 VK_COMMAND_BUFFER_LEVEL_PRIMARY, // VkCommandBufferLevel level;
483 1 // deUint32 commandBufferCount;
486 return vk::allocateCommandBuffer(m_vkd, m_device, &cmdBufferAllocateInfo);
489 Move<VkImage> ImageClearingTestInstance::createImage (VkImageType imageType, VkFormat format, VkExtent3D extent, VkImageUsageFlags usage) const
491 VkImageFormatProperties properties;
492 if ((m_context.getInstanceInterface().getPhysicalDeviceImageFormatProperties(m_context.getPhysicalDevice(),
495 VK_IMAGE_TILING_OPTIMAL,
497 &properties) == VK_ERROR_FORMAT_NOT_SUPPORTED))
499 TCU_THROW(NotSupportedError, "Format not supported");
502 const VkImageCreateInfo imageCreateInfo =
504 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
505 DE_NULL, // const void* pNext;
506 0u, // VkImageCreateFlags flags;
507 imageType, // VkImageType imageType;
508 format, // VkFormat format;
509 extent, // VkExtent3D extent;
510 1, // deUint32 mipLevels;
511 1, // deUint32 arrayLayers;
512 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples;
513 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
514 usage, // VkImageUsageFlags usage;
515 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
516 1, // deUint32 queueFamilyIndexCount;
517 &m_queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
518 VK_IMAGE_LAYOUT_UNDEFINED // VkImageLayout initialLayout;
521 return vk::createImage(m_vkd, m_device, &imageCreateInfo, DE_NULL);
524 Move<VkImageView> ImageClearingTestInstance::createImageView (VkImage image, VkImageViewType viewType, VkFormat format, VkImageAspectFlags aspectMask) const
526 const VkImageViewCreateInfo imageViewCreateInfo =
528 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // VkStructureType sType;
529 DE_NULL, // const void* pNext;
530 0u, // VkImageViewCreateFlags flags;
531 image, // VkImage image;
532 viewType, // VkImageViewType viewType;
533 format, // VkFormat format;
535 VK_COMPONENT_SWIZZLE_IDENTITY, // VkComponentSwizzle r;
536 VK_COMPONENT_SWIZZLE_IDENTITY, // VkComponentSwizzle g;
537 VK_COMPONENT_SWIZZLE_IDENTITY, // VkComponentSwizzle b;
538 VK_COMPONENT_SWIZZLE_IDENTITY, // VkComponentSwizzle a;
539 }, // VkComponentMapping components;
541 aspectMask, // VkImageAspectFlags aspectMask;
542 0u, // deUint32 baseMipLevel;
543 1u, // deUint32 mipLevels;
544 0u, // deUint32 baseArrayLayer;
545 1u, // deUint32 arraySize;
546 }, // VkImageSubresourceRange subresourceRange;
549 return vk::createImageView(m_vkd, m_device, &imageViewCreateInfo, DE_NULL);
552 Move<VkRenderPass> ImageClearingTestInstance::createRenderPass (VkFormat format) const
554 VkImageLayout imageLayout;
556 if (isDepthStencilFormat(format))
557 imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
559 imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
561 const VkAttachmentDescription attachmentDesc =
563 0u, // VkAttachmentDescriptionFlags flags;
564 format, // VkFormat format;
565 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples;
566 VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp;
567 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp;
568 VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp stencilLoadOp;
569 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp stencilStoreOp;
570 imageLayout, // VkImageLayout initialLayout;
571 imageLayout, // VkImageLayout finalLayout;
574 const VkAttachmentDescription attachments[1] =
579 const VkAttachmentReference attachmentRef =
581 0u, // deUint32 attachment;
582 imageLayout, // VkImageLayout layout;
585 const VkAttachmentReference* pColorAttachments = DE_NULL;
586 const VkAttachmentReference* pDepthStencilAttachment = DE_NULL;
587 deUint32 colorAttachmentCount = 1;
589 if (isDepthStencilFormat(format))
591 colorAttachmentCount = 0;
592 pDepthStencilAttachment = &attachmentRef;
596 colorAttachmentCount = 1;
597 pColorAttachments = &attachmentRef;
600 const VkSubpassDescription subpassDesc[1] =
603 0u, // VkSubpassDescriptionFlags flags;
604 VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint;
605 0u, // deUint32 inputAttachmentCount;
606 DE_NULL, // const VkAttachmentReference* pInputAttachments;
607 colorAttachmentCount, // deUint32 colorAttachmentCount;
608 pColorAttachments, // const VkAttachmentReference* pColorAttachments;
609 DE_NULL, // const VkAttachmentReference* pResolveAttachments;
610 pDepthStencilAttachment, // const VkAttachmentReference* pDepthStencilAttachment;
611 0u, // deUint32 preserveAttachmentCount;
612 DE_NULL, // const VkAttachmentReference* pPreserveAttachments;
616 const VkRenderPassCreateInfo renderPassCreateInfo =
618 VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // VkStructureType sType;
619 DE_NULL, // const void* pNext;
620 0u, // VkRenderPassCreateFlags flags;
621 1u, // deUint32 attachmentCount;
622 attachments, // const VkAttachmentDescription* pAttachments;
623 1u, // deUint32 subpassCount;
624 subpassDesc, // const VkSubpassDescription* pSubpasses;
625 0u, // deUint32 dependencyCount;
626 DE_NULL, // const VkSubpassDependency* pDependencies;
629 return vk::createRenderPass(m_vkd, m_device, &renderPassCreateInfo, DE_NULL);
632 Move<VkFramebuffer> ImageClearingTestInstance::createFrameBuffer (VkImageView imageView, VkRenderPass renderPass, deUint32 imageWidth, deUint32 imageHeight) const
634 const VkImageView attachmentViews[1] =
639 const VkFramebufferCreateInfo framebufferCreateInfo =
641 VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // VkStructureType sType;
642 DE_NULL, // const void* pNext;
643 0u, // VkFramebufferCreateFlags flags;
644 renderPass, // VkRenderPass renderPass;
645 1, // deUint32 attachmentCount;
646 attachmentViews, // const VkImageView* pAttachments;
647 imageWidth, // deUint32 width;
648 imageHeight, // deUint32 height;
649 1u, // deUint32 layers;
652 return createFramebuffer(m_vkd, m_device, &framebufferCreateInfo, DE_NULL);
655 void ImageClearingTestInstance::beginCommandBuffer (VkCommandBufferUsageFlags usageFlags) const
657 const VkCommandBufferBeginInfo commandBufferBeginInfo =
659 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
660 DE_NULL, // const void* pNext;
661 usageFlags, // VkCommandBufferUsageFlags flags;
662 DE_NULL // const VkCommandBufferInheritanceInfo* pInheritanceInfo;
665 VK_CHECK(m_vkd.beginCommandBuffer(*m_commandBuffer, &commandBufferBeginInfo));
668 void ImageClearingTestInstance::endCommandBuffer (void) const
670 VK_CHECK(m_vkd.endCommandBuffer(*m_commandBuffer));
673 void ImageClearingTestInstance::submitCommandBuffer (void) const
675 const VkFenceCreateInfo fenceCreateInfo =
677 VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, // VkStructureType sType;
678 DE_NULL, // const void* pNext;
679 0u // VkFenceCreateFlags flags;
682 const Unique<VkFence> fence (createFence(m_vkd, m_device, &fenceCreateInfo));
684 const VkSubmitInfo submitInfo =
686 VK_STRUCTURE_TYPE_SUBMIT_INFO, // VkStructureType sType;
687 DE_NULL, // const void* pNext;
688 0u, // deUint32 waitSemaphoreCount;
689 DE_NULL, // const VkSemaphore* pWaitSemaphores;
690 DE_NULL, // const VkPipelineStageFlags* pWaitDstStageMask;
691 1u, // deUint32 commandBufferCount;
692 &(*m_commandBuffer), // const VkCommandBuffer* pCommandBuffers;
693 0u, // deUint32 signalSemaphoreCount;
694 DE_NULL // const VkSemaphore* pSignalSemaphores;
697 VK_CHECK(m_vkd.queueSubmit(m_queue, 1, &submitInfo, *fence));
699 VK_CHECK(m_vkd.waitForFences(m_device, 1, &fence.get(), VK_TRUE, ~0ull));
703 void ImageClearingTestInstance::pipelineImageBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkImageLayout oldLayout, VkImageLayout newLayout) const
706 const VkImageSubresourceRange subResourcerange =
708 m_imageAspectFlags, // VkImageAspectFlags aspectMask;
709 0, // deUint32 baseMipLevel;
710 1, // deUint32 levelCount;
711 0, // deUint32 baseArrayLayer;
712 1 // deUint32 layerCount;
715 const VkImageMemoryBarrier imageBarrier =
717 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
718 DE_NULL, // const void* pNext;
719 srcAccessMask, // VkAccessFlags srcAccessMask;
720 dstAccessMask, // VkAccessFlags dstAccessMask;
721 oldLayout, // VkImageLayout oldLayout;
722 newLayout, // VkImageLayout newLayout;
723 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
724 VK_QUEUE_FAMILY_IGNORED, // deUint32 destQueueFamilyIndex;
725 *m_image, // VkImage image;
726 subResourcerange // VkImageSubresourceRange subresourceRange;
729 m_vkd.cmdPipelineBarrier(*m_commandBuffer, srcStageMask, dstStageMask, 0, 0, DE_NULL, 0, DE_NULL, 1, &imageBarrier);
733 de::MovePtr<TextureLevel> ImageClearingTestInstance::readImage (VkImageAspectFlags aspectMask) const
735 Move<VkBuffer> buffer;
736 de::MovePtr<Allocation> bufferAlloc;
738 const TextureFormat tcuFormat = aspectMask == VK_IMAGE_ASPECT_COLOR_BIT ? mapVkFormat(m_params.imageFormat) :
739 aspectMask == VK_IMAGE_ASPECT_DEPTH_BIT ? getDepthCopyFormat(m_params.imageFormat) :
740 aspectMask == VK_IMAGE_ASPECT_STENCIL_BIT ? getStencilCopyFormat(m_params.imageFormat) :
743 const VkDeviceSize pixelDataSize = m_params.imageExtent.width * m_params.imageExtent.height * m_params.imageExtent.depth * tcuFormat.getPixelSize();
744 de::MovePtr<TextureLevel> result (new TextureLevel(tcuFormat, m_params.imageExtent.width, m_params.imageExtent.height, m_params.imageExtent.depth));
746 // Create destination buffer
748 const VkBufferCreateInfo bufferParams =
750 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
751 DE_NULL, // const void* pNext;
752 0u, // VkBufferCreateFlags flags;
753 pixelDataSize, // VkDeviceSize size;
754 VK_BUFFER_USAGE_TRANSFER_DST_BIT, // VkBufferUsageFlags usage;
755 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
756 0u, // deUint32 queueFamilyIndexCount;
757 DE_NULL // const deUint32* pQueueFamilyIndices;
760 buffer = createBuffer(m_vkd, m_device, &bufferParams);
761 bufferAlloc = m_allocator.allocate(getBufferMemoryRequirements(m_vkd, m_device, *buffer), MemoryRequirement::HostVisible);
762 VK_CHECK(m_vkd.bindBufferMemory(m_device, *buffer, bufferAlloc->getMemory(), bufferAlloc->getOffset()));
765 // Barriers for copying image to buffer
767 const VkBufferMemoryBarrier bufferBarrier =
769 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
770 DE_NULL, // const void* pNext;
771 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
772 VK_ACCESS_HOST_READ_BIT, // VkAccessFlags dstAccessMask;
773 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
774 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
775 *buffer, // VkBuffer buffer;
776 0u, // VkDeviceSize offset;
777 pixelDataSize // VkDeviceSize size;
780 // Copy image to buffer
782 const VkBufferImageCopy copyRegion =
784 0u, // VkDeviceSize bufferOffset;
785 m_params.imageExtent.width, // deUint32 bufferRowLength;
786 m_params.imageExtent.height, // deUint32 bufferImageHeight;
787 { aspectMask, 0u, 0u, 1u }, // VkImageSubresourceLayers imageSubresource;
788 { 0, 0, 0 }, // VkOffset3D imageOffset;
789 m_params.imageExtent // VkExtent3D imageExtent;
792 beginCommandBuffer(0);
794 pipelineImageBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT,
795 VK_PIPELINE_STAGE_TRANSFER_BIT,
796 VK_ACCESS_TRANSFER_WRITE_BIT |
797 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
798 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
799 VK_ACCESS_TRANSFER_READ_BIT,
800 VK_IMAGE_LAYOUT_GENERAL,
801 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
803 m_vkd.cmdCopyImageToBuffer(*m_commandBuffer, *m_image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, *buffer, 1, ©Region);
804 m_vkd.cmdPipelineBarrier(*m_commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_HOST_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 1, &bufferBarrier, 0, (const VkImageMemoryBarrier*)DE_NULL);
806 pipelineImageBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT,
807 VK_PIPELINE_STAGE_TRANSFER_BIT,
809 VK_ACCESS_TRANSFER_READ_BIT |
810 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
811 VK_ACCESS_COLOR_ATTACHMENT_READ_BIT,
813 VK_ACCESS_TRANSFER_READ_BIT |
814 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
815 VK_ACCESS_COLOR_ATTACHMENT_READ_BIT,
816 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
817 VK_IMAGE_LAYOUT_GENERAL);
821 submitCommandBuffer();
823 invalidateMappedMemoryRange(m_vkd, m_device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), pixelDataSize);
825 copy(*result, ConstPixelBufferAccess(result->getFormat(), result->getSize(), bufferAlloc->getHostPtr()));
830 void ImageClearingTestInstance::beginRenderPass (VkSubpassContents content, VkClearValue clearValue) const
832 const VkRenderPassBeginInfo renderPassBeginInfo =
834 VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, // VkStructureType sType;
835 DE_NULL, // const void* pNext;
836 *m_renderPass, // VkRenderPass renderPass;
837 *m_frameBuffer, // VkFramebuffer framebuffer;
839 { 0, 0 }, // VkOffset2D offset;
841 m_params.imageExtent.width, // deUint32 width;
842 m_params.imageExtent.height // deUint32 height;
843 } // VkExtent2D extent;
844 }, // VkRect2D renderArea;
845 1u, // deUint32 clearValueCount;
846 &clearValue // const VkClearValue* pClearValues;
849 m_vkd.cmdBeginRenderPass(*m_commandBuffer, &renderPassBeginInfo, content);
852 class ClearColorImageTestInstance : public ImageClearingTestInstance
855 ClearColorImageTestInstance (Context& context,
856 const TestParams& testParams)
857 : ImageClearingTestInstance(context, testParams)
860 virtual TestStatus iterate (void);
863 TestStatus ClearColorImageTestInstance::iterate (void)
865 const VkImageSubresourceRange subResourcerange =
867 m_imageAspectFlags, // VkImageAspectFlags aspectMask;
868 0, // deUint32 baseMipLevel;
869 1, // deUint32 levelCount;
870 0, // deUint32 baseArrayLayer;
871 1 // deUint32 layerCount;
874 beginCommandBuffer(0);
876 pipelineImageBarrier(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, // VkPipelineStageFlags srcStageMask
877 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, // VkPipelineStageFlags dstStageMask
878 0, // VkAccessFlags srcAccessMask
879 (m_isAttachmentFormat
880 ? VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT
881 : VK_ACCESS_TRANSFER_WRITE_BIT), // VkAccessFlags dstAccessMask
882 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
883 (m_isAttachmentFormat
884 ? VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
885 : VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL)); // VkImageLayout newLayout;
887 if (m_isAttachmentFormat)
889 beginRenderPass(VK_SUBPASS_CONTENTS_INLINE, m_params.initValue);
890 m_vkd.cmdEndRenderPass(*m_commandBuffer);
892 pipelineImageBarrier(VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, // VkPipelineStageFlags srcStageMask
893 VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags dstStageMask
894 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // VkAccessFlags srcAccessMask
895 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask
896 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout oldLayout;
897 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); // VkImageLayout newLayout;
901 m_vkd.cmdClearColorImage(*m_commandBuffer, *m_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &m_params.clearValue.color, 1, &subResourcerange);
903 pipelineImageBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags srcStageMask
904 VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags dstStageMask
905 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask
906 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask
907 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
908 VK_IMAGE_LAYOUT_GENERAL); // VkImageLayout newLayout;
911 submitCommandBuffer();
913 de::MovePtr<TextureLevel> result = readImage(VK_IMAGE_ASPECT_COLOR_BIT);
914 std::string compareResult;
916 for (deUint32 z = 0; z < m_params.imageExtent.depth; z++)
918 for (deUint32 y = 0; y < m_params.imageExtent.height; y++)
920 for (deUint32 x = 0; x < m_params.imageExtent.width; x++)
922 if (!comparePixelToColorClearValue(result->getAccess(), x, y, z, m_params.clearValue.color, compareResult))
923 return TestStatus::fail("Color value mismatch! " + compareResult);
928 return TestStatus::pass("cmdClearColorImage passed");
931 class ClearDepthStencilImageTestInstance : public ImageClearingTestInstance
934 ClearDepthStencilImageTestInstance (Context& context,
935 const TestParams& testParams)
936 : ImageClearingTestInstance (context, testParams)
939 virtual TestStatus iterate (void);
942 TestStatus ClearDepthStencilImageTestInstance::iterate (void)
944 const VkImageSubresourceRange subResourcerange =
946 m_imageAspectFlags, // VkImageAspectFlags aspectMask;
947 0, // deUint32 baseMipLevel;
948 1, // deUint32 levelCount;
949 0, // deUint32 baseArrayLayer;
950 1 // deUint32 layerCount;
953 beginCommandBuffer(0);
955 pipelineImageBarrier(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, // VkPipelineStageFlags srcStageMask
956 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, // VkPipelineStageFlags dstStageMask
957 0, // VkAccessFlags srcAccessMask
958 (m_isAttachmentFormat
959 ? VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT
960 : VK_ACCESS_TRANSFER_WRITE_BIT), // VkAccessFlags dstAccessMask
961 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
962 (m_isAttachmentFormat
963 ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
964 : VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL)); // VkImageLayout newLayout;
966 if (m_isAttachmentFormat)
968 beginRenderPass(VK_SUBPASS_CONTENTS_INLINE, m_params.initValue);
969 m_vkd.cmdEndRenderPass(*m_commandBuffer);
971 pipelineImageBarrier(VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, // VkPipelineStageFlags srcStageMask
972 VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags dstStageMask
973 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, // VkAccessFlags srcAccessMask
974 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask
975 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, // VkImageLayout oldLayout;
976 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); // VkImageLayout newLayout;
979 m_vkd.cmdClearDepthStencilImage(*m_commandBuffer, *m_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &m_params.clearValue.depthStencil, 1, &subResourcerange);
981 pipelineImageBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags srcStageMask
982 VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags dstStageMask
983 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask
984 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask
985 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
986 VK_IMAGE_LAYOUT_GENERAL); // VkImageLayout newLayout;
989 submitCommandBuffer();
991 de::MovePtr<TextureLevel> depthResult;
992 de::MovePtr<TextureLevel> stencilResult;
993 bool isDepthFormat = getIsDepthFormat(m_params.imageFormat);
996 depthResult = readImage(VK_IMAGE_ASPECT_DEPTH_BIT);
998 const bool isStencilFormat = getIsStencilFormat(m_params.imageFormat);
1000 if (isStencilFormat)
1002 stencilResult = readImage(VK_IMAGE_ASPECT_STENCIL_BIT);
1005 std::string compareResult;
1007 for (deUint32 y = 0; y < m_params.imageExtent.height; ++y)
1009 for (deUint32 x = 0; x < m_params.imageExtent.width; ++x)
1011 if (isDepthFormat && !comparePixelToDepthClearValue(depthResult->getAccess(), x, y, m_params.clearValue.depthStencil.depth, compareResult))
1012 return TestStatus::fail("Depth value mismatch! " + compareResult);
1014 if (isStencilFormat && !comparePixelToStencilClearValue(stencilResult->getAccess(), x, y, m_params.clearValue.depthStencil.stencil, compareResult))
1015 return TestStatus::fail("Stencil value mismatch! " + compareResult);
1019 return TestStatus::pass("cmdClearDepthStencilImage passed");
1022 class ClearColorAttachmentTestInstance : public ImageClearingTestInstance
1025 ClearColorAttachmentTestInstance (Context& context,
1026 const TestParams& testParams)
1027 : ImageClearingTestInstance(context, testParams)
1029 if (!m_isAttachmentFormat)
1031 TCU_THROW(NotSupportedError, "Format not renderable");
1035 virtual TestStatus iterate (void);
1038 TestStatus ClearColorAttachmentTestInstance::iterate (void)
1040 const VkClearAttachment clearAttachment =
1042 VK_IMAGE_ASPECT_COLOR_BIT, // kImageAspectFlags aspectMask;
1043 0u, // deUint32 colorAttachment;
1044 m_params.clearValue // VkClearValue clearValue;
1047 const VkClearRect clearRect =
1051 { m_params.imageExtent.width, m_params.imageExtent.height }
1052 }, // VkRect2D rect;
1053 0u, // deUint32 baseArrayLayer;
1054 1u // deUint32 layerCount;
1057 beginCommandBuffer(0);
1059 pipelineImageBarrier(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, // VkPipelineStageFlags srcStageMask
1060 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, // VkPipelineStageFlags dstStageMask
1061 0, // VkAccessFlags srcAccessMask
1062 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
1063 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask
1064 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
1065 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); // VkImageLayout newLayout;
1067 beginRenderPass(VK_SUBPASS_CONTENTS_INLINE, m_params.initValue);
1068 m_vkd.cmdClearAttachments(*m_commandBuffer, 1, &clearAttachment, 1, &clearRect);
1069 m_vkd.cmdEndRenderPass(*m_commandBuffer);
1071 pipelineImageBarrier(VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, // VkPipelineStageFlags srcStageMask
1072 VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags dstStageMask
1073 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
1074 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask
1075 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask
1076 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout oldLayout;
1077 VK_IMAGE_LAYOUT_GENERAL); // VkImageLayout newLayout;
1080 submitCommandBuffer();
1082 de::MovePtr<TextureLevel> result = readImage(VK_IMAGE_ASPECT_COLOR_BIT);
1083 std::string compareResult;
1085 for (deUint32 y = 0; y < m_params.imageExtent.height; y++)
1087 for (deUint32 x = 0; x < m_params.imageExtent.width; x++)
1089 if (!comparePixelToColorClearValue(result->getAccess(), x, y, 0, m_params.clearValue.color, compareResult))
1090 return TestStatus::fail("Color value mismatch" + compareResult);
1094 return TestStatus::pass("cmdClearAttachments passed");
1097 class ClearDepthStencilAttachmentTestInstance : public ImageClearingTestInstance
1100 ClearDepthStencilAttachmentTestInstance (Context& context,
1101 const TestParams& testParams)
1102 : ImageClearingTestInstance(context, testParams)
1104 if (!m_isAttachmentFormat)
1106 TCU_THROW(NotSupportedError, "Format not renderable");
1110 virtual TestStatus iterate (void);
1113 TestStatus ClearDepthStencilAttachmentTestInstance::iterate (void)
1115 const VkClearAttachment clearAttachment =
1117 VK_IMAGE_ASPECT_DEPTH_BIT |
1118 VK_IMAGE_ASPECT_STENCIL_BIT, // kImageAspectFlags aspectMask;
1119 0u, // deUint32 colorAttachment;
1120 m_params.clearValue // VkClearValue clearValue;
1123 const VkClearRect clearRect =
1127 { m_params.imageExtent.width, m_params.imageExtent.height }
1128 }, // VkRect2D rect;
1129 0u, // deUint32 baseArrayLayer;
1130 1u // deUint32 layerCount;
1133 beginCommandBuffer(0);
1135 pipelineImageBarrier(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, // VkPipelineStageFlags srcStageMask
1136 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, // VkPipelineStageFlags dstStageMask
1137 0, // VkAccessFlags srcAccessMask
1138 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT |
1139 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask
1140 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
1141 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL); // VkImageLayout newLayout;
1143 beginRenderPass(VK_SUBPASS_CONTENTS_INLINE, m_params.initValue);
1144 m_vkd.cmdClearAttachments(*m_commandBuffer, 1, &clearAttachment, 1, &clearRect);
1145 m_vkd.cmdEndRenderPass(*m_commandBuffer);
1147 pipelineImageBarrier(VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, // VkPipelineStageFlags srcStageMask
1148 VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags dstStageMask
1149 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT |
1150 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask
1151 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask
1152 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, // VkImageLayout oldLayout;
1153 VK_IMAGE_LAYOUT_GENERAL); // VkImageLayout newLayout;
1156 submitCommandBuffer();
1158 de::MovePtr<TextureLevel> depthResult;
1159 de::MovePtr<TextureLevel> stencilResult;
1160 bool isDepthFormat = getIsDepthFormat(m_params.imageFormat);
1163 depthResult = readImage(VK_IMAGE_ASPECT_DEPTH_BIT);
1165 const bool isStencilFormat = getIsStencilFormat(m_params.imageFormat);
1167 if (isStencilFormat)
1169 stencilResult = readImage(VK_IMAGE_ASPECT_STENCIL_BIT);
1173 std::string compareResult;
1175 for (deUint32 y = 0; y < m_params.imageExtent.height; y++)
1177 for (deUint32 x = 0; x < m_params.imageExtent.width; x++)
1179 if (isDepthFormat && !comparePixelToDepthClearValue(depthResult->getAccess(), x, y, m_params.clearValue.depthStencil.depth, compareResult))
1180 return TestStatus::fail("Depth value mismatch! " + compareResult);
1182 if (isStencilFormat && !comparePixelToStencilClearValue(stencilResult->getAccess(), x, y, m_params.clearValue.depthStencil.stencil, compareResult))
1183 return TestStatus::fail("Stencil value mismatch! " + compareResult);
1187 return TestStatus::pass("cmdClearAttachments passed");
1190 class PartialClearColorAttachmentTestInstance : public ImageClearingTestInstance
1193 PartialClearColorAttachmentTestInstance (Context& context,
1194 const TestParams& testParams)
1195 : ImageClearingTestInstance(context, testParams)
1197 if (!m_isAttachmentFormat)
1199 TCU_THROW(NotSupportedError, "Format not renderable");
1203 virtual TestStatus iterate (void);
1206 TestStatus PartialClearColorAttachmentTestInstance::iterate (void)
1208 const VkClearAttachment clearAttachment =
1210 VK_IMAGE_ASPECT_COLOR_BIT, // kImageAspectFlags aspectMask;
1211 0u, // deUint32 colorAttachment;
1212 m_params.clearValue // VkClearValue clearValue;
1215 const VkClearRect clearRects[2] =
1219 { 0, (deInt32)(m_params.imageExtent.height / 4) },
1220 { m_params.imageExtent.width, m_params.imageExtent.height / 2}
1221 }, // VkRect2D rect;
1222 0u, // deUint32 baseArrayLayer;
1223 1u // deUint32 layerCount;
1227 { (deInt32)(m_params.imageExtent.width / 4), 0 },
1228 { m_params.imageExtent.width / 2, m_params.imageExtent.height}
1229 }, // VkRect2D rect;
1230 0u, // deUint32 baseArrayLayer;
1231 1u // deUint32 layerCount;
1235 beginCommandBuffer(0);
1237 pipelineImageBarrier(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, // VkPipelineStageFlags srcStageMask
1238 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, // VkPipelineStageFlags dstStageMask
1239 0, // VkAccessFlags srcAccessMask
1240 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // VkAccessFlags dstAccessMask
1241 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
1242 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); // VkImageLayout newLayout;
1244 beginRenderPass(VK_SUBPASS_CONTENTS_INLINE, m_params.initValue);
1245 m_vkd.cmdClearAttachments(*m_commandBuffer, 1, &clearAttachment, 2, clearRects);
1246 m_vkd.cmdEndRenderPass(*m_commandBuffer);
1248 pipelineImageBarrier(VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, // VkPipelineStageFlags srcStageMask
1249 VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags dstStageMask
1250 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
1251 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask
1252 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask
1253 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout oldLayout;
1254 VK_IMAGE_LAYOUT_GENERAL); // VkImageLayout newLayout;
1258 submitCommandBuffer();
1260 de::MovePtr<TextureLevel> result = readImage(VK_IMAGE_ASPECT_COLOR_BIT);
1261 std::string compareResult;
1263 for (deUint32 y = 0; y < m_params.imageExtent.height; y++)
1265 for (deUint32 x = 0; x < m_params.imageExtent.width; x++)
1267 if (((x < m_params.imageExtent.width / 4) && (y < m_params.imageExtent.height / 4)) ||
1268 ((x < m_params.imageExtent.width / 4) && (y >= (m_params.imageExtent.height * 3) / 4)) ||
1269 ((x >= (m_params.imageExtent.width * 3) / 4) && (y < m_params.imageExtent.height / 4)) ||
1270 ((x >= (m_params.imageExtent.width * 3) / 4) && (y >= (m_params.imageExtent.height * 3) / 4)))
1272 if (!comparePixelToColorClearValue(result->getAccess(), x, y, 0, m_params.initValue.color, compareResult))
1273 return TestStatus::fail("Color value mismatch! " + compareResult);
1275 else if (!comparePixelToColorClearValue(result->getAccess(), x, y, 0, m_params.clearValue.color, compareResult))
1276 return TestStatus::fail("Color value mismatch! " + compareResult);
1280 return TestStatus::pass("cmdClearAttachments passed");
1283 class PartialClearDepthStencilAttachmentTestInstance : public ImageClearingTestInstance
1286 PartialClearDepthStencilAttachmentTestInstance (Context& context,
1287 const TestParams& testParams)
1288 : ImageClearingTestInstance(context, testParams)
1290 if (!m_isAttachmentFormat)
1292 TCU_THROW(NotSupportedError, "Format not renderable");
1296 virtual TestStatus iterate (void);
1299 TestStatus PartialClearDepthStencilAttachmentTestInstance::iterate (void)
1301 const VkClearAttachment clearAttachment =
1303 VK_IMAGE_ASPECT_DEPTH_BIT |
1304 VK_IMAGE_ASPECT_STENCIL_BIT, // kImageAspectFlags aspectMask;
1305 0u, // deUint32 colorAttachment;
1306 m_params.clearValue // VkClearValue clearValue;
1309 const VkClearRect clearRects[2] =
1313 { 0, (deInt32)(m_params.imageExtent.height / 4) },
1314 { m_params.imageExtent.width, m_params.imageExtent.height / 2}
1315 }, // VkRect2D rect;
1316 0u, // deUint32 baseArrayLayer;
1317 1u // deUint32 layerCount;
1321 { (deInt32)(m_params.imageExtent.width / 4), 0 },
1322 { m_params.imageExtent.width / 2, m_params.imageExtent.height}
1323 }, // VkRect2D rect;
1324 0u, // deUint32 baseArrayLayer;
1325 1u // deUint32 layerCount;
1329 beginCommandBuffer(0);
1331 pipelineImageBarrier(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, // VkPipelineStageFlags srcStageMask
1332 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, // VkPipelineStageFlags dstStageMask
1333 0, // VkAccessFlags srcAccessMask
1334 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, // VkAccessFlags dstAccessMask
1335 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
1336 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL); // VkImageLayout newLayout;
1338 beginRenderPass(VK_SUBPASS_CONTENTS_INLINE, m_params.initValue);
1339 m_vkd.cmdClearAttachments(*m_commandBuffer, 1, &clearAttachment, 2, clearRects);
1340 m_vkd.cmdEndRenderPass(*m_commandBuffer);
1342 pipelineImageBarrier(VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, // VkPipelineStageFlags srcStageMask
1343 VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags dstStageMask
1344 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT |
1345 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask
1346 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask
1347 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, // VkImageLayout oldLayout;
1348 VK_IMAGE_LAYOUT_GENERAL); // VkImageLayout newLayout;
1352 submitCommandBuffer();
1354 de::MovePtr<TextureLevel> depthResult;
1355 de::MovePtr<TextureLevel> stencilResult;
1356 bool isDepthFormat = getIsDepthFormat(m_params.imageFormat);
1359 depthResult = readImage(VK_IMAGE_ASPECT_DEPTH_BIT);
1361 const bool isStencilFormat = getIsStencilFormat(m_params.imageFormat);
1363 if (isStencilFormat)
1365 stencilResult = readImage(VK_IMAGE_ASPECT_STENCIL_BIT);
1368 std::string compareResult;
1370 for (deUint32 y = 0; y < m_params.imageExtent.height; y++)
1372 for (deUint32 x = 0; x < m_params.imageExtent.width; x++)
1374 if (((x < m_params.imageExtent.width / 4) && (y < m_params.imageExtent.height / 4)) ||
1375 ((x < m_params.imageExtent.width / 4) && (y >= (m_params.imageExtent.height * 3) / 4)) ||
1376 ((x >= (m_params.imageExtent.width * 3) / 4) && (y < m_params.imageExtent.height / 4)) ||
1377 ((x >= (m_params.imageExtent.width * 3) / 4) && (y >= (m_params.imageExtent.height * 3) / 4)))
1379 if (isDepthFormat && !comparePixelToDepthClearValue(depthResult->getAccess(), x, y, m_params.initValue.depthStencil.depth, compareResult))
1380 return TestStatus::fail("Depth value mismatch! " + compareResult);
1382 if (isStencilFormat && !comparePixelToStencilClearValue(stencilResult->getAccess(), x, y, m_params.initValue.depthStencil.stencil, compareResult))
1383 return TestStatus::fail("Stencil value mismatch! " + compareResult);
1387 if (isDepthFormat && !comparePixelToDepthClearValue(depthResult->getAccess(), x, y, m_params.clearValue.depthStencil.depth, compareResult))
1388 return TestStatus::fail("Depth value mismatch! " + compareResult);
1390 if (isStencilFormat && !comparePixelToStencilClearValue(stencilResult->getAccess(), x, y, m_params.clearValue.depthStencil.stencil, compareResult))
1391 return TestStatus::fail("Stencil value mismatch! " + compareResult);
1396 return TestStatus::pass("cmdClearAttachments passed");
1399 VkClearValue makeClearColorValue (VkFormat format, float r, float g, float b, float a)
1401 const TextureFormat tcuFormat = mapVkFormat(format);
1402 VkClearValue clearValue;
1404 if (getTextureChannelClass(tcuFormat.type) == TEXTURECHANNELCLASS_FLOATING_POINT
1405 || getTextureChannelClass(tcuFormat.type) == TEXTURECHANNELCLASS_SIGNED_FIXED_POINT
1406 || getTextureChannelClass(tcuFormat.type) == TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT)
1408 clearValue.color.float32[0] = r;
1409 clearValue.color.float32[1] = g;
1410 clearValue.color.float32[2] = b;
1411 clearValue.color.float32[3] = a;
1413 else if (getTextureChannelClass(tcuFormat.type) == TEXTURECHANNELCLASS_UNSIGNED_INTEGER)
1415 UVec4 maxValues = getFormatMaxUintValue(tcuFormat);
1417 clearValue.color.uint32[0] = (deUint32)((float)maxValues[0] * r);
1418 clearValue.color.uint32[1] = (deUint32)((float)maxValues[1] * g);
1419 clearValue.color.uint32[2] = (deUint32)((float)maxValues[2] * b);
1420 clearValue.color.uint32[3] = (deUint32)((float)maxValues[3] * a);
1422 else if (getTextureChannelClass(tcuFormat.type) == TEXTURECHANNELCLASS_SIGNED_INTEGER)
1424 IVec4 maxValues = getFormatMaxIntValue(tcuFormat);
1426 clearValue.color.int32[0] = (deUint32)((float)maxValues[0] * r);
1427 clearValue.color.int32[1] = (deUint32)((float)maxValues[1] * g);
1428 clearValue.color.int32[2] = (deUint32)((float)maxValues[2] * b);
1429 clearValue.color.int32[3] = (deUint32)((float)maxValues[3] * a);
1432 DE_FATAL("Unknown channel class");
1437 std::string getFormatCaseName (VkFormat format)
1439 return de::toLower(de::toString(getFormatStr(format)).substr(10));
1442 const char* getImageTypeCaseName (VkImageType type)
1444 const char* s_names[] =
1450 return de::getSizedArrayElement<VK_IMAGE_TYPE_LAST>(s_names, type);
1455 TestCaseGroup* createImageClearingTests (TestContext& testCtx)
1458 de::MovePtr<TestCaseGroup> imageClearingTests (new TestCaseGroup(testCtx, "image_clearing", "Image Clearing Tests"));
1460 de::MovePtr<TestCaseGroup> colorImageClearTests (new TestCaseGroup(testCtx, "clear_color_image", "Color Image Clear Tests"));
1461 de::MovePtr<TestCaseGroup> depthStencilImageClearTests (new TestCaseGroup(testCtx, "clear_depth_stencil_image", "Color Depth/Stencil Image Tests"));
1462 de::MovePtr<TestCaseGroup> colorAttachmentClearTests (new TestCaseGroup(testCtx, "clear_color_attachment", "Color Color Attachment Tests"));
1463 de::MovePtr<TestCaseGroup> depthStencilAttachmentClearTests (new TestCaseGroup(testCtx, "clear_depth_stencil_attachment", "Color Depth/Stencil Attachment Tests"));
1464 de::MovePtr<TestCaseGroup> partialColorAttachmentClearTests (new TestCaseGroup(testCtx, "partial_clear_color_attachment", "Clear Partial Color Attachment Tests"));
1465 de::MovePtr<TestCaseGroup> partialDepthStencilAttachmentClearTests (new TestCaseGroup(testCtx, "partial_clear_depth_stencil_attachment", "Clear Partial Depth/Stencil Attachment Tests"));
1467 // Some formats are commented out due to the tcu::TextureFormat does not support them yet.
1468 const VkFormat colorImageFormatsToTest[] =
1470 VK_FORMAT_R4G4_UNORM_PACK8,
1471 VK_FORMAT_R4G4B4A4_UNORM_PACK16,
1472 VK_FORMAT_B4G4R4A4_UNORM_PACK16,
1473 VK_FORMAT_R5G6B5_UNORM_PACK16,
1474 VK_FORMAT_B5G6R5_UNORM_PACK16,
1475 VK_FORMAT_R5G5B5A1_UNORM_PACK16,
1476 VK_FORMAT_B5G5R5A1_UNORM_PACK16,
1477 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
1480 VK_FORMAT_R8_USCALED,
1481 VK_FORMAT_R8_SSCALED,
1485 VK_FORMAT_R8G8_UNORM,
1486 VK_FORMAT_R8G8_SNORM,
1487 VK_FORMAT_R8G8_USCALED,
1488 VK_FORMAT_R8G8_SSCALED,
1489 VK_FORMAT_R8G8_UINT,
1490 VK_FORMAT_R8G8_SINT,
1491 VK_FORMAT_R8G8_SRGB,
1492 VK_FORMAT_R8G8B8_UNORM,
1493 VK_FORMAT_R8G8B8_SNORM,
1494 VK_FORMAT_R8G8B8_USCALED,
1495 VK_FORMAT_R8G8B8_SSCALED,
1496 VK_FORMAT_R8G8B8_UINT,
1497 VK_FORMAT_R8G8B8_SINT,
1498 VK_FORMAT_R8G8B8_SRGB,
1499 VK_FORMAT_B8G8R8_UNORM,
1500 VK_FORMAT_B8G8R8_SNORM,
1501 VK_FORMAT_B8G8R8_USCALED,
1502 VK_FORMAT_B8G8R8_SSCALED,
1503 VK_FORMAT_B8G8R8_UINT,
1504 VK_FORMAT_B8G8R8_SINT,
1505 VK_FORMAT_B8G8R8_SRGB,
1506 VK_FORMAT_R8G8B8A8_UNORM,
1507 VK_FORMAT_R8G8B8A8_SNORM,
1508 VK_FORMAT_R8G8B8A8_USCALED,
1509 VK_FORMAT_R8G8B8A8_SSCALED,
1510 VK_FORMAT_R8G8B8A8_UINT,
1511 VK_FORMAT_R8G8B8A8_SINT,
1512 VK_FORMAT_R8G8B8A8_SRGB,
1513 VK_FORMAT_B8G8R8A8_UNORM,
1514 VK_FORMAT_B8G8R8A8_SNORM,
1515 VK_FORMAT_B8G8R8A8_USCALED,
1516 VK_FORMAT_B8G8R8A8_SSCALED,
1517 VK_FORMAT_B8G8R8A8_UINT,
1518 VK_FORMAT_B8G8R8A8_SINT,
1519 VK_FORMAT_B8G8R8A8_SRGB,
1520 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1521 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
1522 VK_FORMAT_A8B8G8R8_USCALED_PACK32,
1523 VK_FORMAT_A8B8G8R8_SSCALED_PACK32,
1524 VK_FORMAT_A8B8G8R8_UINT_PACK32,
1525 VK_FORMAT_A8B8G8R8_SINT_PACK32,
1526 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
1527 VK_FORMAT_A2R10G10B10_UNORM_PACK32,
1528 VK_FORMAT_A2R10G10B10_SNORM_PACK32,
1529 VK_FORMAT_A2R10G10B10_USCALED_PACK32,
1530 VK_FORMAT_A2R10G10B10_SSCALED_PACK32,
1531 VK_FORMAT_A2R10G10B10_UINT_PACK32,
1532 VK_FORMAT_A2R10G10B10_SINT_PACK32,
1533 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
1534 VK_FORMAT_A2B10G10R10_SNORM_PACK32,
1535 VK_FORMAT_A2B10G10R10_USCALED_PACK32,
1536 VK_FORMAT_A2B10G10R10_SSCALED_PACK32,
1537 VK_FORMAT_A2B10G10R10_UINT_PACK32,
1538 VK_FORMAT_A2B10G10R10_SINT_PACK32,
1539 VK_FORMAT_R16_UNORM,
1540 VK_FORMAT_R16_SNORM,
1541 VK_FORMAT_R16_USCALED,
1542 VK_FORMAT_R16_SSCALED,
1545 VK_FORMAT_R16_SFLOAT,
1546 VK_FORMAT_R16G16_UNORM,
1547 VK_FORMAT_R16G16_SNORM,
1548 VK_FORMAT_R16G16_USCALED,
1549 VK_FORMAT_R16G16_SSCALED,
1550 VK_FORMAT_R16G16_UINT,
1551 VK_FORMAT_R16G16_SINT,
1552 VK_FORMAT_R16G16_SFLOAT,
1553 VK_FORMAT_R16G16B16_UNORM,
1554 VK_FORMAT_R16G16B16_SNORM,
1555 VK_FORMAT_R16G16B16_USCALED,
1556 VK_FORMAT_R16G16B16_SSCALED,
1557 VK_FORMAT_R16G16B16_UINT,
1558 VK_FORMAT_R16G16B16_SINT,
1559 VK_FORMAT_R16G16B16_SFLOAT,
1560 VK_FORMAT_R16G16B16A16_UNORM,
1561 VK_FORMAT_R16G16B16A16_SNORM,
1562 VK_FORMAT_R16G16B16A16_USCALED,
1563 VK_FORMAT_R16G16B16A16_SSCALED,
1564 VK_FORMAT_R16G16B16A16_UINT,
1565 VK_FORMAT_R16G16B16A16_SINT,
1566 VK_FORMAT_R16G16B16A16_SFLOAT,
1569 VK_FORMAT_R32_SFLOAT,
1570 VK_FORMAT_R32G32_UINT,
1571 VK_FORMAT_R32G32_SINT,
1572 VK_FORMAT_R32G32_SFLOAT,
1573 VK_FORMAT_R32G32B32_UINT,
1574 VK_FORMAT_R32G32B32_SINT,
1575 VK_FORMAT_R32G32B32_SFLOAT,
1576 VK_FORMAT_R32G32B32A32_UINT,
1577 VK_FORMAT_R32G32B32A32_SINT,
1578 VK_FORMAT_R32G32B32A32_SFLOAT,
1579 // VK_FORMAT_R64_UINT,
1580 // VK_FORMAT_R64_SINT,
1581 // VK_FORMAT_R64_SFLOAT,
1582 // VK_FORMAT_R64G64_UINT,
1583 // VK_FORMAT_R64G64_SINT,
1584 // VK_FORMAT_R64G64_SFLOAT,
1585 // VK_FORMAT_R64G64B64_UINT,
1586 // VK_FORMAT_R64G64B64_SINT,
1587 // VK_FORMAT_R64G64B64_SFLOAT,
1588 // VK_FORMAT_R64G64B64A64_UINT,
1589 // VK_FORMAT_R64G64B64A64_SINT,
1590 // VK_FORMAT_R64G64B64A64_SFLOAT,
1591 VK_FORMAT_B10G11R11_UFLOAT_PACK32,
1592 VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
1593 // VK_FORMAT_BC1_RGB_UNORM_BLOCK,
1594 // VK_FORMAT_BC1_RGB_SRGB_BLOCK,
1595 // VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
1596 // VK_FORMAT_BC1_RGBA_SRGB_BLOCK,
1597 // VK_FORMAT_BC2_UNORM_BLOCK,
1598 // VK_FORMAT_BC2_SRGB_BLOCK,
1599 // VK_FORMAT_BC3_UNORM_BLOCK,
1600 // VK_FORMAT_BC3_SRGB_BLOCK,
1601 // VK_FORMAT_BC4_UNORM_BLOCK,
1602 // VK_FORMAT_BC4_SNORM_BLOCK,
1603 // VK_FORMAT_BC5_UNORM_BLOCK,
1604 // VK_FORMAT_BC5_SNORM_BLOCK,
1605 // VK_FORMAT_BC6H_UFLOAT_BLOCK,
1606 // VK_FORMAT_BC6H_SFLOAT_BLOCK,
1607 // VK_FORMAT_BC7_UNORM_BLOCK,
1608 // VK_FORMAT_BC7_SRGB_BLOCK,
1609 // VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,
1610 // VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
1611 // VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK,
1612 // VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,
1613 // VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK,
1614 // VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,
1615 // VK_FORMAT_EAC_R11_UNORM_BLOCK,
1616 // VK_FORMAT_EAC_R11_SNORM_BLOCK,
1617 // VK_FORMAT_EAC_R11G11_UNORM_BLOCK,
1618 // VK_FORMAT_EAC_R11G11_SNORM_BLOCK,
1619 // VK_FORMAT_ASTC_4x4_UNORM_BLOCK,
1620 // VK_FORMAT_ASTC_4x4_SRGB_BLOCK,
1621 // VK_FORMAT_ASTC_5x4_UNORM_BLOCK,
1622 // VK_FORMAT_ASTC_5x4_SRGB_BLOCK,
1623 // VK_FORMAT_ASTC_5x5_UNORM_BLOCK,
1624 // VK_FORMAT_ASTC_5x5_SRGB_BLOCK,
1625 // VK_FORMAT_ASTC_6x5_UNORM_BLOCK,
1626 // VK_FORMAT_ASTC_6x5_SRGB_BLOCK,
1627 // VK_FORMAT_ASTC_6x6_UNORM_BLOCK,
1628 // VK_FORMAT_ASTC_6x6_SRGB_BLOCK,
1629 // VK_FORMAT_ASTC_8x5_UNORM_BLOCK,
1630 // VK_FORMAT_ASTC_8x5_SRGB_BLOCK,
1631 // VK_FORMAT_ASTC_8x6_UNORM_BLOCK,
1632 // VK_FORMAT_ASTC_8x6_SRGB_BLOCK,
1633 // VK_FORMAT_ASTC_8x8_UNORM_BLOCK,
1634 // VK_FORMAT_ASTC_8x8_SRGB_BLOCK,
1635 // VK_FORMAT_ASTC_10x5_UNORM_BLOCK,
1636 // VK_FORMAT_ASTC_10x5_SRGB_BLOCK,
1637 // VK_FORMAT_ASTC_10x6_UNORM_BLOCK,
1638 // VK_FORMAT_ASTC_10x6_SRGB_BLOCK,
1639 // VK_FORMAT_ASTC_10x8_UNORM_BLOCK,
1640 // VK_FORMAT_ASTC_10x8_SRGB_BLOCK,
1641 // VK_FORMAT_ASTC_10x10_UNORM_BLOCK,
1642 // VK_FORMAT_ASTC_10x10_SRGB_BLOCK,
1643 // VK_FORMAT_ASTC_12x10_UNORM_BLOCK,
1644 // VK_FORMAT_ASTC_12x10_SRGB_BLOCK,
1645 // VK_FORMAT_ASTC_12x12_UNORM_BLOCK,
1646 // VK_FORMAT_ASTC_12x12_SRGB_BLOCK
1648 const size_t numOfColorImageFormatsToTest = DE_LENGTH_OF_ARRAY(colorImageFormatsToTest);
1650 const VkFormat depthStencilImageFormatsToTest[] =
1652 VK_FORMAT_D16_UNORM,
1653 VK_FORMAT_X8_D24_UNORM_PACK32,
1654 VK_FORMAT_D32_SFLOAT,
1656 VK_FORMAT_D16_UNORM_S8_UINT,
1657 VK_FORMAT_D24_UNORM_S8_UINT,
1658 VK_FORMAT_D32_SFLOAT_S8_UINT
1660 const size_t numOfDepthStencilImageFormatsToTest = DE_LENGTH_OF_ARRAY(depthStencilImageFormatsToTest);
1663 const VkImageType imageTypesToTest[] =
1669 const size_t numOfImageTypesToTest = DE_LENGTH_OF_ARRAY(imageTypesToTest);
1671 const VkExtent3D imageDimensionsByType[] =
1678 TestParams colorImageTestParams;
1680 for (size_t imageTypeIndex = 0; imageTypeIndex < numOfImageTypesToTest; ++imageTypeIndex)
1682 for (size_t imageFormatIndex = 0; imageFormatIndex < numOfColorImageFormatsToTest; ++imageFormatIndex)
1684 colorImageTestParams.imageType = imageTypesToTest[imageTypeIndex];
1685 colorImageTestParams.imageFormat = colorImageFormatsToTest[imageFormatIndex];
1686 colorImageTestParams.imageExtent = imageDimensionsByType[imageTypeIndex];
1687 colorImageTestParams.initValue = makeClearColorValue(colorImageTestParams.imageFormat, 0.2f, 0.1f, 0.7f, 0.8f);
1688 colorImageTestParams.clearValue = makeClearColorValue(colorImageTestParams.imageFormat, 0.1f, 0.5f, 0.3f, 0.9f);
1690 std::ostringstream testCaseName;
1691 testCaseName << getImageTypeCaseName(colorImageTestParams.imageType);
1692 testCaseName << "_" << getFormatCaseName(colorImageTestParams.imageFormat);
1694 colorImageClearTests->addChild(new InstanceFactory1<ClearColorImageTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Clear Color Image", colorImageTestParams));
1698 imageClearingTests->addChild(colorImageClearTests.release());
1702 TestParams depthStencilImageTestParams =
1704 VK_IMAGE_TYPE_2D, // VkImageType imageType;
1705 depthStencilImageFormatsToTest[0], // VkFormat format;
1706 { 256, 256, 1 }, // VkExtent3D extent;
1707 makeClearValueDepthStencil(0.5f, 0x03), // VkClearValue initValue
1708 makeClearValueDepthStencil(0.1f, 0x06) // VkClearValue clearValue
1711 for (size_t imageFormatIndex = 0; imageFormatIndex < numOfDepthStencilImageFormatsToTest; ++imageFormatIndex)
1713 depthStencilImageTestParams.imageFormat = depthStencilImageFormatsToTest[imageFormatIndex];
1715 std::ostringstream testCaseName;
1716 testCaseName << getImageTypeCaseName(depthStencilImageTestParams.imageType);
1717 testCaseName << "_" << getFormatCaseName(depthStencilImageTestParams.imageFormat);
1719 depthStencilImageClearTests->addChild(new InstanceFactory1<ClearDepthStencilImageTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Clear Depth/Stencil Image", depthStencilImageTestParams));
1722 imageClearingTests->addChild(depthStencilImageClearTests.release());
1726 TestParams colorAttachmentTestParams =
1728 VK_IMAGE_TYPE_2D, // VkImageType imageType;
1729 colorImageFormatsToTest[0], // VkFormat format;
1730 { 256, 256, 1 }, // VkExtent3D extent;
1731 makeClearValueColorU32(0, 0, 0, 0), // VkClearValue initValue
1732 makeClearValueColorU32(0, 0, 0, 0) // VkClearValue clearValue
1735 for (size_t imageFormatIndex = 0; imageFormatIndex < numOfColorImageFormatsToTest; ++imageFormatIndex)
1737 colorAttachmentTestParams.imageFormat = colorImageFormatsToTest[imageFormatIndex];
1738 colorAttachmentTestParams.initValue = makeClearColorValue(colorAttachmentTestParams.imageFormat, 0.2f, 0.1f, 0.7f, 0.8f);
1739 colorAttachmentTestParams.clearValue = makeClearColorValue(colorAttachmentTestParams.imageFormat, 0.1f, 0.5f, 0.3f, 0.9f);
1741 std::ostringstream testCaseName;
1742 testCaseName << getImageTypeCaseName(colorAttachmentTestParams.imageType);
1743 testCaseName << "_" << getFormatCaseName(colorAttachmentTestParams.imageFormat);
1745 colorAttachmentClearTests->addChild(new InstanceFactory1<ClearColorAttachmentTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Clear Color Attachment", colorAttachmentTestParams));
1748 imageClearingTests->addChild(colorAttachmentClearTests.release());
1752 TestParams depthStencilAttachmentTestParams =
1754 VK_IMAGE_TYPE_2D, // VkImageType imageType;
1755 depthStencilImageFormatsToTest[0], // VkFormat format;
1756 { 256, 256, 1 }, // VkExtent3D extent;
1757 makeClearValueDepthStencil(0.5f, 0x03), // VkClearValue initValue
1758 makeClearValueDepthStencil(0.1f, 0x06) // VkClearValue clearValue
1761 for (size_t imageFormatIndex = 0; imageFormatIndex < numOfDepthStencilImageFormatsToTest; ++imageFormatIndex)
1763 depthStencilAttachmentTestParams.imageFormat = depthStencilImageFormatsToTest[imageFormatIndex];
1765 std::ostringstream testCaseName;
1766 testCaseName << getImageTypeCaseName(depthStencilAttachmentTestParams.imageType);
1767 testCaseName << "_" << getFormatCaseName(depthStencilAttachmentTestParams.imageFormat);
1769 depthStencilAttachmentClearTests->addChild(new InstanceFactory1<ClearDepthStencilAttachmentTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Clear Depth/Stencil Attachment", depthStencilAttachmentTestParams));
1772 imageClearingTests->addChild(depthStencilAttachmentClearTests.release());
1776 TestParams colorAttachmentTestParams =
1778 VK_IMAGE_TYPE_2D, // VkImageType imageType;
1779 colorImageFormatsToTest[0], // VkFormat format;
1780 { 256, 256, 1 }, // VkExtent3D extent;
1781 makeClearValueColorU32(0, 0, 0, 0), // VkClearValue initValue
1782 makeClearValueColorU32(0, 0, 0, 0) // VkClearValue clearValue
1785 for (size_t imageFormatIndex = 0; imageFormatIndex < numOfColorImageFormatsToTest; ++imageFormatIndex)
1787 colorAttachmentTestParams.imageFormat = colorImageFormatsToTest[imageFormatIndex];
1788 colorAttachmentTestParams.initValue = makeClearColorValue(colorAttachmentTestParams.imageFormat, 0.2f, 0.1f, 0.7f, 0.8f);
1789 colorAttachmentTestParams.clearValue = makeClearColorValue(colorAttachmentTestParams.imageFormat, 0.1f, 0.5f, 0.3f, 0.9f);
1791 std::ostringstream testCaseName;
1792 testCaseName << getImageTypeCaseName(colorAttachmentTestParams.imageType);
1793 testCaseName << "_" << getFormatCaseName(colorAttachmentTestParams.imageFormat);
1795 partialColorAttachmentClearTests->addChild(new InstanceFactory1<PartialClearColorAttachmentTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Partial Clear Color Attachment", colorAttachmentTestParams));
1798 imageClearingTests->addChild(partialColorAttachmentClearTests.release());
1802 TestParams depthStencilAttachmentTestParams =
1804 VK_IMAGE_TYPE_2D, // VkImageType imageType;
1805 depthStencilImageFormatsToTest[0], // VkFormat format;
1806 { 256, 256, 1 }, // VkExtent3D extent;
1807 makeClearValueDepthStencil(0.5f, 0x03), // VkClearValue initValue
1808 makeClearValueDepthStencil(0.1f, 0x06) // VkClearValue clearValue
1811 for (size_t imageFormatIndex = 0; imageFormatIndex < numOfDepthStencilImageFormatsToTest; ++imageFormatIndex)
1813 depthStencilAttachmentTestParams.imageFormat = depthStencilImageFormatsToTest[imageFormatIndex];
1815 std::ostringstream testCaseName;
1816 testCaseName << getImageTypeCaseName(depthStencilAttachmentTestParams.imageType);
1817 testCaseName << "_" << getFormatCaseName(depthStencilAttachmentTestParams.imageFormat);
1819 partialDepthStencilAttachmentClearTests->addChild(new InstanceFactory1<PartialClearDepthStencilAttachmentTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Parital Clear Depth/Stencil Attachment", depthStencilAttachmentTestParams));
1822 imageClearingTests->addChild(partialDepthStencilAttachmentClearTests.release());
1825 return imageClearingTests.release();