1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2016 The Khronos Group Inc.
6 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 * \brief Vulkan Image Clearing Tests
23 *//*--------------------------------------------------------------------*/
25 #include "vktApiImageClearingTests.hpp"
27 #include "deRandom.hpp"
29 #include "deStringUtil.hpp"
30 #include "deUniquePtr.hpp"
31 #include "deArrayUtil.hpp"
33 #include "vkImageUtil.hpp"
34 #include "vkMemUtil.hpp"
35 #include "vktTestCase.hpp"
36 #include "vktTestCaseUtil.hpp"
37 #include "vkQueryUtil.hpp"
38 #include "vkRefUtil.hpp"
39 #include "vkTypeUtil.hpp"
40 #include "tcuImageCompare.hpp"
41 #include "tcuTexture.hpp"
42 #include "tcuTextureUtil.hpp"
43 #include "tcuVectorType.hpp"
44 #include "tcuTexture.hpp"
45 #include "tcuFloat.hpp"
46 #include "tcuTestLog.hpp"
47 #include "tcuVectorUtil.hpp"
63 VkExtent3D getMipLevelExtent (VkExtent3D baseExtent, const deUint32 mipLevel)
65 baseExtent.width = std::max(baseExtent.width >> mipLevel, 1u);
66 baseExtent.height = std::max(baseExtent.height >> mipLevel, 1u);
67 baseExtent.depth = std::max(baseExtent.depth >> mipLevel, 1u);
71 deUint32 getNumMipLevels (const VkExtent3D& baseExtent, const deUint32 maxMipLevels)
73 const deUint32 widestEdge = std::max(std::max(baseExtent.width, baseExtent.height), baseExtent.depth);
74 return std::min(static_cast<deUint32>(deFloatLog2(static_cast<float>(widestEdge))) + 1u, maxMipLevels);
77 std::vector<deUint32> getImageMipLevelSizes (const deUint32 pixelSize, const VkExtent3D& baseExtent, const deUint32 numMipLevels, const deUint32 perLevelAlignment = 1u)
79 std::vector<deUint32> results(numMipLevels);
81 for (deUint32 mipLevel = 0; mipLevel < numMipLevels; ++mipLevel)
83 const VkExtent3D extent = getMipLevelExtent(baseExtent, mipLevel);
84 results[mipLevel] = static_cast<deUint32>(deAlignSize(extent.width * extent.height * extent.depth * pixelSize, perLevelAlignment));
90 //! Check if a point lies in a cross-like area.
91 inline bool isInClearRange (const UVec4& clearCoords, const deUint32 x, const deUint32 y)
93 return !((x < clearCoords[0] && y < clearCoords[1]) ||
94 (x < clearCoords[0] && y >= clearCoords[3]) ||
95 (x >= clearCoords[2] && y < clearCoords[1]) ||
96 (x >= clearCoords[2] && y >= clearCoords[3]));
99 // This method is copied from the vktRenderPassTests.cpp. It should be moved to a common place.
100 int calcFloatDiff (float a, float b)
102 const int asign = Float32(a).sign();
103 const int bsign = Float32(a).sign();
105 const deUint32 avalue = (Float32(a).bits() & ((0x1u << 31u) - 1u));
106 const deUint32 bvalue = (Float32(b).bits() & ((0x1u << 31u) - 1u));
109 return avalue + bvalue + 1u;
110 else if (avalue < bvalue)
111 return bvalue - avalue;
113 return avalue - bvalue;
116 // This method is copied from the vktRenderPassTests.cpp and extended with the stringResult parameter.
117 bool comparePixelToDepthClearValue (const ConstPixelBufferAccess& access,
121 std::string& stringResult)
123 const TextureFormat format = getEffectiveDepthStencilTextureFormat(access.getFormat(), Sampler::MODE_DEPTH);
124 const TextureChannelClass channelClass = getTextureChannelClass(format.type);
126 switch (channelClass)
128 case TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
129 case TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
131 const int bitDepth = getTextureFormatBitDepth(format).x();
132 const float depth = access.getPixDepth(x, y);
133 const float threshold = 2.0f / (float)((1 << bitDepth) - 1);
134 const bool result = deFloatAbs(depth - ref) <= threshold;
139 s << "Ref:" << ref << " Threshold:" << threshold << " Depth:" << depth;
140 stringResult = s.str();
146 case TEXTURECHANNELCLASS_FLOATING_POINT:
148 const float depth = access.getPixDepth(x, y);
149 const int mantissaBits = getTextureFormatMantissaBitDepth(format).x();
150 const int threshold = 10 * 1 << (23 - mantissaBits);
152 DE_ASSERT(mantissaBits <= 23);
154 const bool result = calcFloatDiff(depth, ref) <= threshold;
158 float floatThreshold = Float32((deUint32)threshold).asFloat();
161 s << "Ref:" << ref << " Threshold:" << floatThreshold << " Depth:" << depth;
162 stringResult = s.str();
169 DE_FATAL("Invalid channel class");
174 // This method is copied from the vktRenderPassTests.cpp and extended with the stringResult parameter.
175 bool comparePixelToStencilClearValue (const ConstPixelBufferAccess& access,
179 std::string& stringResult)
181 const deUint32 stencil = access.getPixStencil(x, y);
182 const bool result = stencil == ref;
187 s << "Ref:" << ref << " Threshold:0" << " Stencil:" << stencil;
188 stringResult = s.str();
194 // This method is copied from the vktRenderPassTests.cpp and extended with the stringResult parameter.
195 bool comparePixelToColorClearValue (const ConstPixelBufferAccess& access,
199 const VkClearColorValue& ref,
200 std::string& stringResult)
202 const TextureFormat format = access.getFormat();
203 const TextureChannelClass channelClass = getTextureChannelClass(format.type);
204 const BVec4 channelMask = getTextureFormatChannelMask(format);
206 switch (channelClass)
208 case TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
209 case TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
211 const IVec4 bitDepth (getTextureFormatBitDepth(format));
212 const Vec4 resColor (access.getPixel(x, y, z));
213 Vec4 refColor (ref.float32[0],
217 const int modifier = (channelClass == TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT) ? 0 : 1;
218 const Vec4 threshold (bitDepth[0] > 0 ? 1.0f / ((float)(1 << (bitDepth[0] - modifier)) - 1.0f) : 1.0f,
219 bitDepth[1] > 0 ? 1.0f / ((float)(1 << (bitDepth[1] - modifier)) - 1.0f) : 1.0f,
220 bitDepth[2] > 0 ? 1.0f / ((float)(1 << (bitDepth[2] - modifier)) - 1.0f) : 1.0f,
221 bitDepth[3] > 0 ? 1.0f / ((float)(1 << (bitDepth[3] - modifier)) - 1.0f) : 1.0f);
223 if (isSRGB(access.getFormat()))
224 refColor = linearToSRGB(refColor);
226 const bool result = !(anyNotEqual(logicalAnd(lessThanEqual(absDiff(resColor, refColor), threshold), channelMask), channelMask));
231 s << "Ref:" << refColor << " Mask:" << channelMask << " Threshold:" << threshold << " Color:" << resColor;
232 stringResult = s.str();
238 case TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
240 const UVec4 resColor (access.getPixelUint(x, y, z));
241 const UVec4 refColor (ref.uint32[0],
245 const UVec4 threshold (1);
247 const bool result = !(anyNotEqual(logicalAnd(lessThanEqual(absDiff(resColor, refColor), threshold), channelMask), channelMask));
252 s << "Ref:" << refColor << " Mask:" << channelMask << " Threshold:" << threshold << " Color:" << resColor;
253 stringResult = s.str();
259 case TEXTURECHANNELCLASS_SIGNED_INTEGER:
261 const IVec4 resColor (access.getPixelInt(x, y, z));
262 const IVec4 refColor (ref.int32[0],
266 const IVec4 threshold (1);
268 const bool result = !(anyNotEqual(logicalAnd(lessThanEqual(absDiff(resColor, refColor), threshold), channelMask), channelMask));
273 s << "Ref:" << refColor << " Mask:" << channelMask << " Threshold:" << threshold << " Color:" << resColor;
274 stringResult = s.str();
280 case TEXTURECHANNELCLASS_FLOATING_POINT:
282 const Vec4 resColor (access.getPixel(x, y, z));
283 const Vec4 refColor (ref.float32[0],
287 const IVec4 mantissaBits (getTextureFormatMantissaBitDepth(format));
288 const IVec4 threshold (10 * IVec4(1) << (23 - mantissaBits));
290 DE_ASSERT(allEqual(greaterThanEqual(threshold, IVec4(0)), BVec4(true)));
292 for (int ndx = 0; ndx < 4; ndx++)
294 const bool result = !(calcFloatDiff(resColor[ndx], refColor[ndx]) > threshold[ndx] && channelMask[ndx]);
298 float floatThreshold = Float32((deUint32)(threshold)[0]).asFloat();
299 Vec4 thresholdVec4 (floatThreshold,
304 s << "Ref:" << refColor << " Mask:" << channelMask << " Threshold:" << thresholdVec4 << " Color:" << resColor;
305 stringResult = s.str();
315 DE_FATAL("Invalid channel class");
322 bool useSingleMipLevel; //!< only mip level 0, otherwise up to maxMipLevels
323 VkImageType imageType;
324 VkFormat imageFormat;
325 VkExtent3D imageExtent;
326 VkClearValue initValue;
327 VkClearValue clearValue[2]; //!< the second value is used with more than one mip map
330 class ImageClearingTestInstance : public vkt::TestInstance
333 ImageClearingTestInstance (Context& context,
334 const TestParams& testParams);
336 Move<VkCommandPool> createCommandPool (VkCommandPoolCreateFlags commandPoolCreateFlags) const;
337 Move<VkCommandBuffer> allocatePrimaryCommandBuffer (VkCommandPool commandPool) const;
338 Move<VkImage> createImage (VkImageType imageType, VkFormat format, VkExtent3D extent, VkImageUsageFlags usage) const;
339 Move<VkImageView> createImageView (VkImage image, VkImageViewType viewType, VkFormat format, VkImageAspectFlags aspectMask) const;
340 Move<VkRenderPass> createRenderPass (VkFormat format) const;
341 Move<VkFramebuffer> createFrameBuffer (VkImageView imageView, VkRenderPass renderPass, deUint32 imageWidth, deUint32 imageHeight) const;
343 void beginCommandBuffer (VkCommandBufferUsageFlags usageFlags) const;
344 void endCommandBuffer (void) const;
345 void submitCommandBuffer (void) const;
346 void beginRenderPass (VkSubpassContents content, VkClearValue clearValue) const;
348 void pipelineImageBarrier (VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkImageLayout oldLayout, VkImageLayout newLayout) const;
349 de::MovePtr<TextureLevelPyramid> readImage (VkImageAspectFlags aspectMask) const;
350 tcu::TestStatus verifyResultImage (const std::string& successMessage, const UVec4& clearCoords = UVec4()) const;
353 VkImageViewType getCorrespondingImageViewType (VkImageType imageType) const;
354 VkImageUsageFlags getImageUsageFlags (VkFormat format) const;
355 VkImageAspectFlags getImageAspectFlags (VkFormat format) const;
356 bool getIsAttachmentFormat (VkFormat format) const;
357 bool getIsStencilFormat (VkFormat format) const;
358 bool getIsDepthFormat (VkFormat format) const;
359 VkImageFormatProperties getImageFormatProperties (void) const;
360 de::MovePtr<Allocation> allocateAndBindImageMemory (VkImage image) const;
362 const TestParams& m_params;
363 const VkDevice m_device;
364 const InstanceInterface& m_vki;
365 const DeviceInterface& m_vkd;
366 const VkQueue m_queue;
367 const deUint32 m_queueFamilyIndex;
368 Allocator& m_allocator;
370 const bool m_isAttachmentFormat;
371 const VkImageUsageFlags m_imageUsageFlags;
372 const VkImageAspectFlags m_imageAspectFlags;
373 const VkImageFormatProperties m_imageFormatProperties;
374 const deUint32 m_imageMipLevels;
375 const deUint32 m_thresholdMipLevel;
377 Unique<VkCommandPool> m_commandPool;
378 Unique<VkCommandBuffer> m_commandBuffer;
380 Unique<VkImage> m_image;
381 de::MovePtr<Allocation> m_imageMemory;
382 Unique<VkImageView> m_imageView;
383 Unique<VkRenderPass> m_renderPass;
384 Unique<VkFramebuffer> m_frameBuffer;
387 ImageClearingTestInstance::ImageClearingTestInstance (Context& context, const TestParams& params)
388 : TestInstance (context)
390 , m_device (context.getDevice())
391 , m_vki (context.getInstanceInterface())
392 , m_vkd (context.getDeviceInterface())
393 , m_queue (context.getUniversalQueue())
394 , m_queueFamilyIndex (context.getUniversalQueueFamilyIndex())
395 , m_allocator (context.getDefaultAllocator())
396 , m_isAttachmentFormat (getIsAttachmentFormat(params.imageFormat))
397 , m_imageUsageFlags (getImageUsageFlags(params.imageFormat))
398 , m_imageAspectFlags (getImageAspectFlags(params.imageFormat))
399 , m_imageFormatProperties (getImageFormatProperties())
400 , m_imageMipLevels (params.useSingleMipLevel ? 1u : getNumMipLevels(params.imageExtent, m_imageFormatProperties.maxMipLevels))
401 , m_thresholdMipLevel (std::max(m_imageMipLevels / 2u, 1u))
402 , m_commandPool (createCommandPool(VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT))
403 , m_commandBuffer (allocatePrimaryCommandBuffer(*m_commandPool))
405 , m_image (createImage(params.imageType,
410 , m_imageMemory (allocateAndBindImageMemory(*m_image))
411 , m_imageView (m_isAttachmentFormat ? createImageView(*m_image,
412 getCorrespondingImageViewType(params.imageType),
414 m_imageAspectFlags) : vk::Move<VkImageView>())
416 , m_renderPass (m_isAttachmentFormat ? createRenderPass(params.imageFormat) : vk::Move<vk::VkRenderPass>())
417 , m_frameBuffer (m_isAttachmentFormat ? createFrameBuffer(*m_imageView, *m_renderPass, params.imageExtent.width, params.imageExtent.height) : vk::Move<vk::VkFramebuffer>())
421 VkImageViewType ImageClearingTestInstance::getCorrespondingImageViewType (VkImageType imageType) const
425 case VK_IMAGE_TYPE_1D:
426 return VK_IMAGE_VIEW_TYPE_1D;
427 case VK_IMAGE_TYPE_2D:
428 return VK_IMAGE_VIEW_TYPE_2D;
429 case VK_IMAGE_TYPE_3D:
430 return VK_IMAGE_VIEW_TYPE_3D;
432 DE_FATAL("Unknown image type!");
435 return VK_IMAGE_VIEW_TYPE_2D;
438 VkImageUsageFlags ImageClearingTestInstance::getImageUsageFlags (VkFormat format) const
440 VkImageUsageFlags commonFlags = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
442 if (m_isAttachmentFormat)
444 if (isDepthStencilFormat(format))
445 return commonFlags | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
447 return commonFlags | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
452 VkImageAspectFlags ImageClearingTestInstance::getImageAspectFlags (VkFormat format) const
454 VkImageAspectFlags imageAspectFlags = 0;
456 if (getIsDepthFormat(format))
457 imageAspectFlags |= VK_IMAGE_ASPECT_DEPTH_BIT;
459 if (getIsStencilFormat(format))
460 imageAspectFlags |= VK_IMAGE_ASPECT_STENCIL_BIT;
462 if (imageAspectFlags == 0)
463 imageAspectFlags = VK_IMAGE_ASPECT_COLOR_BIT;
465 return imageAspectFlags;
468 bool ImageClearingTestInstance::getIsAttachmentFormat (VkFormat format) const
470 const VkFormatProperties props = vk::getPhysicalDeviceFormatProperties(m_vki, m_context.getPhysicalDevice(), format);
472 return (props.optimalTilingFeatures & (vk::VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | vk::VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) != 0;
475 bool ImageClearingTestInstance::getIsStencilFormat (VkFormat format) const
477 const TextureFormat tcuFormat = mapVkFormat(format);
479 if (tcuFormat.order == TextureFormat::S || tcuFormat.order == TextureFormat::DS)
485 bool ImageClearingTestInstance::getIsDepthFormat (VkFormat format) const
487 const TextureFormat tcuFormat = mapVkFormat(format);
489 if (tcuFormat.order == TextureFormat::D || tcuFormat.order == TextureFormat::DS)
495 VkImageFormatProperties ImageClearingTestInstance::getImageFormatProperties (void) const
497 VkImageFormatProperties properties;
498 const VkResult result = m_vki.getPhysicalDeviceImageFormatProperties(m_context.getPhysicalDevice(), m_params.imageFormat, m_params.imageType,
499 VK_IMAGE_TILING_OPTIMAL, m_imageUsageFlags, (VkImageCreateFlags)0, &properties);
501 if (result == VK_ERROR_FORMAT_NOT_SUPPORTED)
502 TCU_THROW(NotSupportedError, "Format not supported");
507 de::MovePtr<Allocation> ImageClearingTestInstance::allocateAndBindImageMemory (VkImage image) const
509 de::MovePtr<Allocation> imageMemory (m_allocator.allocate(getImageMemoryRequirements(m_vkd, m_device, image), MemoryRequirement::Any));
510 VK_CHECK(m_vkd.bindImageMemory(m_device, image, imageMemory->getMemory(), imageMemory->getOffset()));
514 Move<VkCommandPool> ImageClearingTestInstance::createCommandPool (VkCommandPoolCreateFlags commandPoolCreateFlags) const
516 const VkCommandPoolCreateInfo cmdPoolCreateInfo =
518 VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // VkStructureType sType;
519 DE_NULL, // const void* pNext;
520 commandPoolCreateFlags, // VkCommandPoolCreateFlags flags;
521 m_queueFamilyIndex // deUint32 queueFamilyIndex;
524 return vk::createCommandPool(m_vkd, m_device, &cmdPoolCreateInfo, DE_NULL);
527 Move<VkCommandBuffer> ImageClearingTestInstance::allocatePrimaryCommandBuffer (VkCommandPool commandPool) const
529 const VkCommandBufferAllocateInfo cmdBufferAllocateInfo =
531 VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, // VkStructureType sType;
532 DE_NULL, // const void* pNext;
533 commandPool, // VkCommandPool commandPool;
534 VK_COMMAND_BUFFER_LEVEL_PRIMARY, // VkCommandBufferLevel level;
535 1 // deUint32 commandBufferCount;
538 return vk::allocateCommandBuffer(m_vkd, m_device, &cmdBufferAllocateInfo);
541 Move<VkImage> ImageClearingTestInstance::createImage (VkImageType imageType, VkFormat format, VkExtent3D extent, VkImageUsageFlags usage) const
543 const VkImageCreateInfo imageCreateInfo =
545 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
546 DE_NULL, // const void* pNext;
547 0u, // VkImageCreateFlags flags;
548 imageType, // VkImageType imageType;
549 format, // VkFormat format;
550 extent, // VkExtent3D extent;
551 m_imageMipLevels, // deUint32 mipLevels;
552 1u, // deUint32 arrayLayers;
553 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples;
554 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
555 usage, // VkImageUsageFlags usage;
556 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
557 1u, // deUint32 queueFamilyIndexCount;
558 &m_queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
559 VK_IMAGE_LAYOUT_UNDEFINED // VkImageLayout initialLayout;
562 return vk::createImage(m_vkd, m_device, &imageCreateInfo, DE_NULL);
565 Move<VkImageView> ImageClearingTestInstance::createImageView (VkImage image, VkImageViewType viewType, VkFormat format, VkImageAspectFlags aspectMask) const
567 const VkImageViewCreateInfo imageViewCreateInfo =
569 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // VkStructureType sType;
570 DE_NULL, // const void* pNext;
571 0u, // VkImageViewCreateFlags flags;
572 image, // VkImage image;
573 viewType, // VkImageViewType viewType;
574 format, // VkFormat format;
576 VK_COMPONENT_SWIZZLE_IDENTITY, // VkComponentSwizzle r;
577 VK_COMPONENT_SWIZZLE_IDENTITY, // VkComponentSwizzle g;
578 VK_COMPONENT_SWIZZLE_IDENTITY, // VkComponentSwizzle b;
579 VK_COMPONENT_SWIZZLE_IDENTITY, // VkComponentSwizzle a;
580 }, // VkComponentMapping components;
582 aspectMask, // VkImageAspectFlags aspectMask;
583 0u, // deUint32 baseMipLevel;
584 1u, // deUint32 mipLevels;
585 0u, // deUint32 baseArrayLayer;
586 1u, // deUint32 arraySize;
587 }, // VkImageSubresourceRange subresourceRange;
590 return vk::createImageView(m_vkd, m_device, &imageViewCreateInfo, DE_NULL);
593 Move<VkRenderPass> ImageClearingTestInstance::createRenderPass (VkFormat format) const
595 VkImageLayout imageLayout;
597 if (isDepthStencilFormat(format))
598 imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
600 imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
602 const VkAttachmentDescription attachmentDesc =
604 0u, // VkAttachmentDescriptionFlags flags;
605 format, // VkFormat format;
606 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples;
607 VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp;
608 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp;
609 VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp stencilLoadOp;
610 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp stencilStoreOp;
611 imageLayout, // VkImageLayout initialLayout;
612 imageLayout, // VkImageLayout finalLayout;
615 const VkAttachmentDescription attachments[1] =
620 const VkAttachmentReference attachmentRef =
622 0u, // deUint32 attachment;
623 imageLayout, // VkImageLayout layout;
626 const VkAttachmentReference* pColorAttachments = DE_NULL;
627 const VkAttachmentReference* pDepthStencilAttachment = DE_NULL;
628 deUint32 colorAttachmentCount = 1;
630 if (isDepthStencilFormat(format))
632 colorAttachmentCount = 0;
633 pDepthStencilAttachment = &attachmentRef;
637 colorAttachmentCount = 1;
638 pColorAttachments = &attachmentRef;
641 const VkSubpassDescription subpassDesc[1] =
644 0u, // VkSubpassDescriptionFlags flags;
645 VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint;
646 0u, // deUint32 inputAttachmentCount;
647 DE_NULL, // const VkAttachmentReference* pInputAttachments;
648 colorAttachmentCount, // deUint32 colorAttachmentCount;
649 pColorAttachments, // const VkAttachmentReference* pColorAttachments;
650 DE_NULL, // const VkAttachmentReference* pResolveAttachments;
651 pDepthStencilAttachment, // const VkAttachmentReference* pDepthStencilAttachment;
652 0u, // deUint32 preserveAttachmentCount;
653 DE_NULL, // const VkAttachmentReference* pPreserveAttachments;
657 const VkRenderPassCreateInfo renderPassCreateInfo =
659 VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // VkStructureType sType;
660 DE_NULL, // const void* pNext;
661 0u, // VkRenderPassCreateFlags flags;
662 1u, // deUint32 attachmentCount;
663 attachments, // const VkAttachmentDescription* pAttachments;
664 1u, // deUint32 subpassCount;
665 subpassDesc, // const VkSubpassDescription* pSubpasses;
666 0u, // deUint32 dependencyCount;
667 DE_NULL, // const VkSubpassDependency* pDependencies;
670 return vk::createRenderPass(m_vkd, m_device, &renderPassCreateInfo, DE_NULL);
673 Move<VkFramebuffer> ImageClearingTestInstance::createFrameBuffer (VkImageView imageView, VkRenderPass renderPass, deUint32 imageWidth, deUint32 imageHeight) const
675 const VkImageView attachmentViews[1] =
680 const VkFramebufferCreateInfo framebufferCreateInfo =
682 VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // VkStructureType sType;
683 DE_NULL, // const void* pNext;
684 0u, // VkFramebufferCreateFlags flags;
685 renderPass, // VkRenderPass renderPass;
686 1, // deUint32 attachmentCount;
687 attachmentViews, // const VkImageView* pAttachments;
688 imageWidth, // deUint32 width;
689 imageHeight, // deUint32 height;
690 1u, // deUint32 layers;
693 return createFramebuffer(m_vkd, m_device, &framebufferCreateInfo, DE_NULL);
696 void ImageClearingTestInstance::beginCommandBuffer (VkCommandBufferUsageFlags usageFlags) const
698 const VkCommandBufferBeginInfo commandBufferBeginInfo =
700 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
701 DE_NULL, // const void* pNext;
702 usageFlags, // VkCommandBufferUsageFlags flags;
703 DE_NULL // const VkCommandBufferInheritanceInfo* pInheritanceInfo;
706 VK_CHECK(m_vkd.beginCommandBuffer(*m_commandBuffer, &commandBufferBeginInfo));
709 void ImageClearingTestInstance::endCommandBuffer (void) const
711 VK_CHECK(m_vkd.endCommandBuffer(*m_commandBuffer));
714 void ImageClearingTestInstance::submitCommandBuffer (void) const
716 const VkFenceCreateInfo fenceCreateInfo =
718 VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, // VkStructureType sType;
719 DE_NULL, // const void* pNext;
720 0u // VkFenceCreateFlags flags;
723 const Unique<VkFence> fence (createFence(m_vkd, m_device, &fenceCreateInfo));
725 const VkSubmitInfo submitInfo =
727 VK_STRUCTURE_TYPE_SUBMIT_INFO, // VkStructureType sType;
728 DE_NULL, // const void* pNext;
729 0u, // deUint32 waitSemaphoreCount;
730 DE_NULL, // const VkSemaphore* pWaitSemaphores;
731 DE_NULL, // const VkPipelineStageFlags* pWaitDstStageMask;
732 1u, // deUint32 commandBufferCount;
733 &(*m_commandBuffer), // const VkCommandBuffer* pCommandBuffers;
734 0u, // deUint32 signalSemaphoreCount;
735 DE_NULL // const VkSemaphore* pSignalSemaphores;
738 VK_CHECK(m_vkd.queueSubmit(m_queue, 1, &submitInfo, *fence));
740 VK_CHECK(m_vkd.waitForFences(m_device, 1, &fence.get(), VK_TRUE, ~0ull));
743 void ImageClearingTestInstance::pipelineImageBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkImageLayout oldLayout, VkImageLayout newLayout) const
745 const VkImageMemoryBarrier imageBarrier =
747 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
748 DE_NULL, // const void* pNext;
749 srcAccessMask, // VkAccessFlags srcAccessMask;
750 dstAccessMask, // VkAccessFlags dstAccessMask;
751 oldLayout, // VkImageLayout oldLayout;
752 newLayout, // VkImageLayout newLayout;
753 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
754 VK_QUEUE_FAMILY_IGNORED, // deUint32 destQueueFamilyIndex;
755 *m_image, // VkImage image;
757 m_imageAspectFlags, // VkImageAspectFlags aspectMask;
758 0u, // deUint32 baseMipLevel;
759 VK_REMAINING_MIP_LEVELS, // deUint32 levelCount;
760 0u, // deUint32 baseArrayLayer;
761 1u, // deUint32 layerCount;
762 }, // VkImageSubresourceRange subresourceRange;
765 m_vkd.cmdPipelineBarrier(*m_commandBuffer, srcStageMask, dstStageMask, 0, 0, DE_NULL, 0, DE_NULL, 1, &imageBarrier);
768 de::MovePtr<TextureLevelPyramid> ImageClearingTestInstance::readImage (VkImageAspectFlags aspectMask) const
770 const TextureFormat tcuFormat = aspectMask == VK_IMAGE_ASPECT_COLOR_BIT ? mapVkFormat(m_params.imageFormat) :
771 aspectMask == VK_IMAGE_ASPECT_DEPTH_BIT ? getDepthCopyFormat(m_params.imageFormat) :
772 aspectMask == VK_IMAGE_ASPECT_STENCIL_BIT ? getStencilCopyFormat(m_params.imageFormat) :
774 const deUint32 pixelSize = getPixelSize(tcuFormat);
775 const deUint32 alignment = 4; // subsequent mip levels aligned to 4 bytes
776 const std::vector<deUint32> mipLevelSizes = getImageMipLevelSizes(pixelSize, m_params.imageExtent, m_imageMipLevels, alignment);
777 const VkDeviceSize imageTotalSize = std::accumulate(mipLevelSizes.begin(), mipLevelSizes.end(), 0u);
779 de::MovePtr<TextureLevelPyramid> result (new TextureLevelPyramid(tcuFormat, m_imageMipLevels));
780 Move<VkBuffer> buffer;
781 de::MovePtr<Allocation> bufferAlloc;
783 // Create destination buffer
785 const VkBufferCreateInfo bufferParams =
787 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
788 DE_NULL, // const void* pNext;
789 0u, // VkBufferCreateFlags flags;
790 imageTotalSize, // VkDeviceSize size;
791 VK_BUFFER_USAGE_TRANSFER_DST_BIT, // VkBufferUsageFlags usage;
792 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
793 0u, // deUint32 queueFamilyIndexCount;
794 DE_NULL // const deUint32* pQueueFamilyIndices;
797 buffer = createBuffer(m_vkd, m_device, &bufferParams);
798 bufferAlloc = m_allocator.allocate(getBufferMemoryRequirements(m_vkd, m_device, *buffer), MemoryRequirement::HostVisible);
799 VK_CHECK(m_vkd.bindBufferMemory(m_device, *buffer, bufferAlloc->getMemory(), bufferAlloc->getOffset()));
802 // Barriers for copying image to buffer
804 const VkBufferMemoryBarrier bufferBarrier =
806 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
807 DE_NULL, // const void* pNext;
808 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
809 VK_ACCESS_HOST_READ_BIT, // VkAccessFlags dstAccessMask;
810 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
811 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
812 *buffer, // VkBuffer buffer;
813 0u, // VkDeviceSize offset;
814 imageTotalSize, // VkDeviceSize size;
817 // Copy image to buffer
818 std::vector<VkBufferImageCopy> copyRegions;
820 deUint32 offset = 0u;
821 for (deUint32 mipLevel = 0; mipLevel < m_imageMipLevels; ++mipLevel)
823 const VkExtent3D extent = getMipLevelExtent(m_params.imageExtent, mipLevel);
824 const VkBufferImageCopy region =
826 offset, // VkDeviceSize bufferOffset;
827 0u, // deUint32 bufferRowLength;
828 0u, // deUint32 bufferImageHeight;
829 { aspectMask, mipLevel, 0u, 1u }, // VkImageSubresourceLayers imageSubresource;
830 { 0, 0, 0 }, // VkOffset3D imageOffset;
831 extent // VkExtent3D imageExtent;
833 copyRegions.push_back(region);
834 offset += mipLevelSizes[mipLevel];
838 beginCommandBuffer(0);
840 pipelineImageBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT,
841 VK_PIPELINE_STAGE_TRANSFER_BIT,
842 VK_ACCESS_TRANSFER_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
843 VK_ACCESS_TRANSFER_READ_BIT,
844 VK_IMAGE_LAYOUT_GENERAL,
845 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
847 m_vkd.cmdCopyImageToBuffer(*m_commandBuffer, *m_image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, *buffer, static_cast<deUint32>(copyRegions.size()), ©Regions[0]);
848 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);
850 pipelineImageBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT,
851 VK_PIPELINE_STAGE_TRANSFER_BIT,
852 VK_ACCESS_TRANSFER_READ_BIT,
853 VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT,
854 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
855 VK_IMAGE_LAYOUT_GENERAL);
858 submitCommandBuffer();
860 invalidateMappedMemoryRange(m_vkd, m_device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), imageTotalSize);
863 deUint32 offset = 0u;
864 for (deUint32 mipLevel = 0; mipLevel < m_imageMipLevels; ++mipLevel)
866 const VkExtent3D extent = getMipLevelExtent(m_params.imageExtent, mipLevel);
867 const void* pLevelData = static_cast<const void*>(reinterpret_cast<deUint8*>(bufferAlloc->getHostPtr()) + offset);
869 result->allocLevel(mipLevel, extent.width, extent.height, extent.depth);
870 copy(result->getLevel(mipLevel), ConstPixelBufferAccess(result->getFormat(), result->getLevel(mipLevel).getSize(), pLevelData));
872 offset += mipLevelSizes[mipLevel];
879 tcu::TestStatus ImageClearingTestInstance::verifyResultImage (const std::string& successMessage, const UVec4& clearCoords) const
881 const bool useClearRange = clearCoords != UVec4();
882 DE_ASSERT(!useClearRange || m_params.imageExtent.depth == 1u);
884 if (getIsDepthFormat(m_params.imageFormat))
886 DE_ASSERT(m_imageMipLevels == 1u);
888 de::MovePtr<TextureLevelPyramid> image = readImage(VK_IMAGE_ASPECT_DEPTH_BIT);
892 for (deUint32 y = 0; y < m_params.imageExtent.height; ++y)
893 for (deUint32 x = 0; x < m_params.imageExtent.width; ++x)
895 if (!useClearRange || isInClearRange(clearCoords, x, y))
896 depthValue = m_params.clearValue[0].depthStencil.depth;
898 depthValue = m_params.initValue.depthStencil.depth;
900 if (!comparePixelToDepthClearValue(image->getLevel(0), x, y, depthValue, message))
901 return TestStatus::fail("Depth value mismatch! " + message);
905 if (getIsStencilFormat(m_params.imageFormat))
907 DE_ASSERT(m_imageMipLevels == 1u);
909 de::MovePtr<TextureLevelPyramid> image = readImage(VK_IMAGE_ASPECT_STENCIL_BIT);
911 deUint32 stencilValue;
913 for (deUint32 y = 0; y < m_params.imageExtent.height; ++y)
914 for (deUint32 x = 0; x < m_params.imageExtent.width; ++x)
916 if (!useClearRange || isInClearRange(clearCoords, x, y))
917 stencilValue = m_params.clearValue[0].depthStencil.stencil;
919 stencilValue = m_params.initValue.depthStencil.stencil;
921 if (!comparePixelToStencilClearValue(image->getLevel(0), x, y, stencilValue, message))
922 return TestStatus::fail("Stencil value mismatch! " + message);
926 if (!isDepthStencilFormat(m_params.imageFormat))
928 de::MovePtr<TextureLevelPyramid> image = readImage(VK_IMAGE_ASPECT_COLOR_BIT);
930 const VkClearColorValue* pColorValue;
932 for (deUint32 mipLevel = 0; mipLevel < m_imageMipLevels; ++mipLevel)
934 const int clearColorNdx = (mipLevel < m_thresholdMipLevel ? 0 : 1);
935 const VkExtent3D extent = getMipLevelExtent(m_params.imageExtent, mipLevel);
937 for (deUint32 z = 0; z < extent.depth; ++z)
938 for (deUint32 y = 0; y < extent.height; ++y)
939 for (deUint32 x = 0; x < extent.width; ++x)
941 if (!useClearRange || isInClearRange(clearCoords, x, y))
942 pColorValue = &m_params.clearValue[clearColorNdx].color;
944 pColorValue = &m_params.initValue.color;
946 if (!comparePixelToColorClearValue(image->getLevel(mipLevel), x, y, z, *pColorValue, message))
947 return TestStatus::fail("Color value mismatch! " + message);
952 return TestStatus::pass(successMessage);
955 void ImageClearingTestInstance::beginRenderPass (VkSubpassContents content, VkClearValue clearValue) const
957 const VkRenderPassBeginInfo renderPassBeginInfo =
959 VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, // VkStructureType sType;
960 DE_NULL, // const void* pNext;
961 *m_renderPass, // VkRenderPass renderPass;
962 *m_frameBuffer, // VkFramebuffer framebuffer;
964 { 0, 0 }, // VkOffset2D offset;
966 m_params.imageExtent.width, // deUint32 width;
967 m_params.imageExtent.height // deUint32 height;
968 } // VkExtent2D extent;
969 }, // VkRect2D renderArea;
970 1u, // deUint32 clearValueCount;
971 &clearValue // const VkClearValue* pClearValues;
974 m_vkd.cmdBeginRenderPass(*m_commandBuffer, &renderPassBeginInfo, content);
977 class ClearColorImageTestInstance : public ImageClearingTestInstance
980 ClearColorImageTestInstance (Context& context, const TestParams& testParams) : ImageClearingTestInstance (context, testParams) {}
981 TestStatus iterate (void);
984 TestStatus ClearColorImageTestInstance::iterate (void)
986 std::vector<VkImageSubresourceRange> subresourceRanges;
988 if (m_imageMipLevels == 1)
989 subresourceRanges.push_back(makeImageSubresourceRange(m_imageAspectFlags, 0u, 1u, 0u, 1u));
992 subresourceRanges.push_back(makeImageSubresourceRange(m_imageAspectFlags, 0u, m_thresholdMipLevel, 0u, 1u));
993 subresourceRanges.push_back(makeImageSubresourceRange(m_imageAspectFlags, m_thresholdMipLevel, VK_REMAINING_MIP_LEVELS, 0u, 1u));
996 beginCommandBuffer(0);
998 pipelineImageBarrier(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, // VkPipelineStageFlags srcStageMask
999 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, // VkPipelineStageFlags dstStageMask
1000 0, // VkAccessFlags srcAccessMask
1001 (m_isAttachmentFormat
1002 ? VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT
1003 : VK_ACCESS_TRANSFER_WRITE_BIT), // VkAccessFlags dstAccessMask
1004 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
1005 (m_isAttachmentFormat
1006 ? VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
1007 : VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL)); // VkImageLayout newLayout;
1009 if (m_isAttachmentFormat)
1011 beginRenderPass(VK_SUBPASS_CONTENTS_INLINE, m_params.initValue);
1012 m_vkd.cmdEndRenderPass(*m_commandBuffer);
1014 pipelineImageBarrier(VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, // VkPipelineStageFlags srcStageMask
1015 VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags dstStageMask
1016 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // VkAccessFlags srcAccessMask
1017 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask
1018 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout oldLayout;
1019 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); // VkImageLayout newLayout;
1022 // Different clear color per range
1023 for (std::size_t i = 0u; i < subresourceRanges.size(); ++i)
1024 m_vkd.cmdClearColorImage(*m_commandBuffer, *m_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &m_params.clearValue[i].color, 1, &subresourceRanges[i]);
1026 pipelineImageBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags srcStageMask
1027 VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags dstStageMask
1028 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask
1029 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask
1030 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
1031 VK_IMAGE_LAYOUT_GENERAL); // VkImageLayout newLayout;
1034 submitCommandBuffer();
1036 return verifyResultImage("cmdClearColorImage passed");
1039 class ClearDepthStencilImageTestInstance : public ImageClearingTestInstance
1042 ClearDepthStencilImageTestInstance (Context& context, const TestParams& testParams) : ImageClearingTestInstance (context, testParams) {}
1043 TestStatus iterate (void);
1046 TestStatus ClearDepthStencilImageTestInstance::iterate (void)
1048 const VkImageSubresourceRange subresourceRange = makeImageSubresourceRange(m_imageAspectFlags, 0u, 1u, 0u, 1u);
1050 beginCommandBuffer(0);
1052 pipelineImageBarrier(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, // VkPipelineStageFlags srcStageMask
1053 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, // VkPipelineStageFlags dstStageMask
1054 0, // VkAccessFlags srcAccessMask
1055 (m_isAttachmentFormat
1056 ? VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT
1057 : VK_ACCESS_TRANSFER_WRITE_BIT), // VkAccessFlags dstAccessMask
1058 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
1059 (m_isAttachmentFormat
1060 ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
1061 : VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL)); // VkImageLayout newLayout;
1063 if (m_isAttachmentFormat)
1065 beginRenderPass(VK_SUBPASS_CONTENTS_INLINE, m_params.initValue);
1066 m_vkd.cmdEndRenderPass(*m_commandBuffer);
1068 pipelineImageBarrier(VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, // VkPipelineStageFlags srcStageMask
1069 VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags dstStageMask
1070 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, // VkAccessFlags srcAccessMask
1071 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask
1072 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, // VkImageLayout oldLayout;
1073 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); // VkImageLayout newLayout;
1076 m_vkd.cmdClearDepthStencilImage(*m_commandBuffer, *m_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &m_params.clearValue[0].depthStencil, 1, &subresourceRange);
1078 pipelineImageBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags srcStageMask
1079 VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags dstStageMask
1080 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask
1081 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask
1082 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
1083 VK_IMAGE_LAYOUT_GENERAL); // VkImageLayout newLayout;
1086 submitCommandBuffer();
1088 return verifyResultImage("cmdClearDepthStencilImage passed");
1091 class ClearAttachmentTestInstance : public ImageClearingTestInstance
1100 ClearAttachmentTestInstance (Context& context, const TestParams& testParams, const ClearType clearType = FULL_CLEAR)
1101 : ImageClearingTestInstance (context, testParams)
1102 , m_clearType (clearType)
1104 if (!m_isAttachmentFormat)
1105 TCU_THROW(NotSupportedError, "Format not renderable");
1108 TestStatus iterate (void)
1110 const VkClearAttachment clearAttachment =
1112 m_imageAspectFlags, // VkImageAspectFlags aspectMask;
1113 0u, // deUint32 colorAttachment;
1114 m_params.clearValue[0] // VkClearValue clearValue;
1118 std::vector<VkClearRect> clearRects;
1120 if (m_clearType == FULL_CLEAR)
1122 const VkClearRect rect =
1125 { 0, 0 }, // VkOffset2D offset;
1126 { m_params.imageExtent.width, m_params.imageExtent.height } // VkExtent2D extent;
1127 }, // VkRect2D rect;
1128 0u, // deUint32 baseArrayLayer;
1129 1u // deUint32 layerCount;
1132 clearRects.push_back(rect);
1136 const deUint32 clearX = m_params.imageExtent.width / 4u;
1137 const deUint32 clearY = m_params.imageExtent.height / 4u;
1138 const deUint32 clearWidth = m_params.imageExtent.width / 2u;
1139 const deUint32 clearHeight = m_params.imageExtent.height / 2u;
1141 clearCoords = UVec4(clearX, clearY,
1142 clearX + clearWidth, clearY + clearHeight);
1144 const VkClearRect rects[2] =
1148 { 0, static_cast<deInt32>(clearY) }, // VkOffset2D offset;
1149 { m_params.imageExtent.width, clearHeight } // VkExtent2D extent;
1150 }, // VkRect2D rect;
1151 0u, // deUint32 baseArrayLayer;
1152 1u // deUint32 layerCount;
1156 { static_cast<deInt32>(clearX), 0 }, // VkOffset2D offset;
1157 { clearWidth, m_params.imageExtent.height } // VkExtent2D extent;
1158 }, // VkRect2D rect;
1159 0u, // deUint32 baseArrayLayer;
1160 1u // deUint32 layerCount;
1164 clearRects.push_back(rects[0]);
1165 clearRects.push_back(rects[1]);
1168 const bool isDepthStencil = isDepthStencilFormat(m_params.imageFormat);
1169 const VkAccessFlags accessMask = (isDepthStencil ? VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT : VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
1170 const VkImageLayout attachmentLayout = (isDepthStencil ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
1172 beginCommandBuffer(0);
1174 pipelineImageBarrier(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, // VkPipelineStageFlags srcStageMask
1175 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, // VkPipelineStageFlags dstStageMask
1176 0, // VkAccessFlags srcAccessMask
1177 accessMask, // VkAccessFlags dstAccessMask
1178 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
1179 attachmentLayout); // VkImageLayout newLayout;
1181 beginRenderPass(VK_SUBPASS_CONTENTS_INLINE, m_params.initValue);
1182 m_vkd.cmdClearAttachments(*m_commandBuffer, 1, &clearAttachment, static_cast<deUint32>(clearRects.size()), &clearRects[0]);
1183 m_vkd.cmdEndRenderPass(*m_commandBuffer);
1185 pipelineImageBarrier(VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, // VkPipelineStageFlags srcStageMask
1186 VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags dstStageMask
1187 accessMask, // VkAccessFlags srcAccessMask
1188 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask
1189 attachmentLayout, // VkImageLayout oldLayout;
1190 VK_IMAGE_LAYOUT_GENERAL); // VkImageLayout newLayout;
1193 submitCommandBuffer();
1195 return verifyResultImage("cmdClearAttachments passed", clearCoords);
1199 const ClearType m_clearType;
1202 class PartialClearAttachmentTestInstance : public ClearAttachmentTestInstance
1205 PartialClearAttachmentTestInstance (Context& context, const TestParams& testParams) : ClearAttachmentTestInstance (context, testParams, PARTIAL_CLEAR) {}
1208 VkClearValue makeClearColorValue (VkFormat format, float r, float g, float b, float a)
1210 const TextureFormat tcuFormat = mapVkFormat(format);
1211 VkClearValue clearValue;
1213 if (getTextureChannelClass(tcuFormat.type) == TEXTURECHANNELCLASS_FLOATING_POINT
1214 || getTextureChannelClass(tcuFormat.type) == TEXTURECHANNELCLASS_SIGNED_FIXED_POINT
1215 || getTextureChannelClass(tcuFormat.type) == TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT)
1217 clearValue.color.float32[0] = r;
1218 clearValue.color.float32[1] = g;
1219 clearValue.color.float32[2] = b;
1220 clearValue.color.float32[3] = a;
1222 else if (getTextureChannelClass(tcuFormat.type) == TEXTURECHANNELCLASS_UNSIGNED_INTEGER)
1224 UVec4 maxValues = getFormatMaxUintValue(tcuFormat);
1226 clearValue.color.uint32[0] = (deUint32)((float)maxValues[0] * r);
1227 clearValue.color.uint32[1] = (deUint32)((float)maxValues[1] * g);
1228 clearValue.color.uint32[2] = (deUint32)((float)maxValues[2] * b);
1229 clearValue.color.uint32[3] = (deUint32)((float)maxValues[3] * a);
1231 else if (getTextureChannelClass(tcuFormat.type) == TEXTURECHANNELCLASS_SIGNED_INTEGER)
1233 IVec4 maxValues = getFormatMaxIntValue(tcuFormat);
1235 clearValue.color.int32[0] = (deUint32)((float)maxValues[0] * r);
1236 clearValue.color.int32[1] = (deUint32)((float)maxValues[1] * g);
1237 clearValue.color.int32[2] = (deUint32)((float)maxValues[2] * b);
1238 clearValue.color.int32[3] = (deUint32)((float)maxValues[3] * a);
1241 DE_FATAL("Unknown channel class");
1246 std::string getFormatCaseName (VkFormat format)
1248 return de::toLower(de::toString(getFormatStr(format)).substr(10));
1251 const char* getImageTypeCaseName (VkImageType type)
1253 const char* s_names[] =
1259 return de::getSizedArrayElement<VK_IMAGE_TYPE_LAST>(s_names, type);
1264 TestCaseGroup* createImageClearingTests (TestContext& testCtx)
1267 de::MovePtr<TestCaseGroup> imageClearingTests (new TestCaseGroup(testCtx, "image_clearing", "Image Clearing Tests"));
1269 de::MovePtr<TestCaseGroup> colorImageClearTests (new TestCaseGroup(testCtx, "clear_color_image", "Color Image Clear Tests"));
1270 de::MovePtr<TestCaseGroup> depthStencilImageClearTests (new TestCaseGroup(testCtx, "clear_depth_stencil_image", "Color Depth/Stencil Image Tests"));
1271 de::MovePtr<TestCaseGroup> colorAttachmentClearTests (new TestCaseGroup(testCtx, "clear_color_attachment", "Color Color Attachment Tests"));
1272 de::MovePtr<TestCaseGroup> depthStencilAttachmentClearTests (new TestCaseGroup(testCtx, "clear_depth_stencil_attachment", "Color Depth/Stencil Attachment Tests"));
1273 de::MovePtr<TestCaseGroup> partialColorAttachmentClearTests (new TestCaseGroup(testCtx, "partial_clear_color_attachment", "Clear Partial Color Attachment Tests"));
1274 de::MovePtr<TestCaseGroup> partialDepthStencilAttachmentClearTests (new TestCaseGroup(testCtx, "partial_clear_depth_stencil_attachment", "Clear Partial Depth/Stencil Attachment Tests"));
1276 // Some formats are commented out due to the tcu::TextureFormat does not support them yet.
1277 const VkFormat colorImageFormatsToTest[] =
1279 VK_FORMAT_R4G4_UNORM_PACK8,
1280 VK_FORMAT_R4G4B4A4_UNORM_PACK16,
1281 VK_FORMAT_B4G4R4A4_UNORM_PACK16,
1282 VK_FORMAT_R5G6B5_UNORM_PACK16,
1283 VK_FORMAT_B5G6R5_UNORM_PACK16,
1284 VK_FORMAT_R5G5B5A1_UNORM_PACK16,
1285 VK_FORMAT_B5G5R5A1_UNORM_PACK16,
1286 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
1289 VK_FORMAT_R8_USCALED,
1290 VK_FORMAT_R8_SSCALED,
1294 VK_FORMAT_R8G8_UNORM,
1295 VK_FORMAT_R8G8_SNORM,
1296 VK_FORMAT_R8G8_USCALED,
1297 VK_FORMAT_R8G8_SSCALED,
1298 VK_FORMAT_R8G8_UINT,
1299 VK_FORMAT_R8G8_SINT,
1300 VK_FORMAT_R8G8_SRGB,
1301 VK_FORMAT_R8G8B8_UNORM,
1302 VK_FORMAT_R8G8B8_SNORM,
1303 VK_FORMAT_R8G8B8_USCALED,
1304 VK_FORMAT_R8G8B8_SSCALED,
1305 VK_FORMAT_R8G8B8_UINT,
1306 VK_FORMAT_R8G8B8_SINT,
1307 VK_FORMAT_R8G8B8_SRGB,
1308 VK_FORMAT_B8G8R8_UNORM,
1309 VK_FORMAT_B8G8R8_SNORM,
1310 VK_FORMAT_B8G8R8_USCALED,
1311 VK_FORMAT_B8G8R8_SSCALED,
1312 VK_FORMAT_B8G8R8_UINT,
1313 VK_FORMAT_B8G8R8_SINT,
1314 VK_FORMAT_B8G8R8_SRGB,
1315 VK_FORMAT_R8G8B8A8_UNORM,
1316 VK_FORMAT_R8G8B8A8_SNORM,
1317 VK_FORMAT_R8G8B8A8_USCALED,
1318 VK_FORMAT_R8G8B8A8_SSCALED,
1319 VK_FORMAT_R8G8B8A8_UINT,
1320 VK_FORMAT_R8G8B8A8_SINT,
1321 VK_FORMAT_R8G8B8A8_SRGB,
1322 VK_FORMAT_B8G8R8A8_UNORM,
1323 VK_FORMAT_B8G8R8A8_SNORM,
1324 VK_FORMAT_B8G8R8A8_USCALED,
1325 VK_FORMAT_B8G8R8A8_SSCALED,
1326 VK_FORMAT_B8G8R8A8_UINT,
1327 VK_FORMAT_B8G8R8A8_SINT,
1328 VK_FORMAT_B8G8R8A8_SRGB,
1329 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1330 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
1331 VK_FORMAT_A8B8G8R8_USCALED_PACK32,
1332 VK_FORMAT_A8B8G8R8_SSCALED_PACK32,
1333 VK_FORMAT_A8B8G8R8_UINT_PACK32,
1334 VK_FORMAT_A8B8G8R8_SINT_PACK32,
1335 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
1336 VK_FORMAT_A2R10G10B10_UNORM_PACK32,
1337 VK_FORMAT_A2R10G10B10_SNORM_PACK32,
1338 VK_FORMAT_A2R10G10B10_USCALED_PACK32,
1339 VK_FORMAT_A2R10G10B10_SSCALED_PACK32,
1340 VK_FORMAT_A2R10G10B10_UINT_PACK32,
1341 VK_FORMAT_A2R10G10B10_SINT_PACK32,
1342 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
1343 VK_FORMAT_A2B10G10R10_SNORM_PACK32,
1344 VK_FORMAT_A2B10G10R10_USCALED_PACK32,
1345 VK_FORMAT_A2B10G10R10_SSCALED_PACK32,
1346 VK_FORMAT_A2B10G10R10_UINT_PACK32,
1347 VK_FORMAT_A2B10G10R10_SINT_PACK32,
1348 VK_FORMAT_R16_UNORM,
1349 VK_FORMAT_R16_SNORM,
1350 VK_FORMAT_R16_USCALED,
1351 VK_FORMAT_R16_SSCALED,
1354 VK_FORMAT_R16_SFLOAT,
1355 VK_FORMAT_R16G16_UNORM,
1356 VK_FORMAT_R16G16_SNORM,
1357 VK_FORMAT_R16G16_USCALED,
1358 VK_FORMAT_R16G16_SSCALED,
1359 VK_FORMAT_R16G16_UINT,
1360 VK_FORMAT_R16G16_SINT,
1361 VK_FORMAT_R16G16_SFLOAT,
1362 VK_FORMAT_R16G16B16_UNORM,
1363 VK_FORMAT_R16G16B16_SNORM,
1364 VK_FORMAT_R16G16B16_USCALED,
1365 VK_FORMAT_R16G16B16_SSCALED,
1366 VK_FORMAT_R16G16B16_UINT,
1367 VK_FORMAT_R16G16B16_SINT,
1368 VK_FORMAT_R16G16B16_SFLOAT,
1369 VK_FORMAT_R16G16B16A16_UNORM,
1370 VK_FORMAT_R16G16B16A16_SNORM,
1371 VK_FORMAT_R16G16B16A16_USCALED,
1372 VK_FORMAT_R16G16B16A16_SSCALED,
1373 VK_FORMAT_R16G16B16A16_UINT,
1374 VK_FORMAT_R16G16B16A16_SINT,
1375 VK_FORMAT_R16G16B16A16_SFLOAT,
1378 VK_FORMAT_R32_SFLOAT,
1379 VK_FORMAT_R32G32_UINT,
1380 VK_FORMAT_R32G32_SINT,
1381 VK_FORMAT_R32G32_SFLOAT,
1382 VK_FORMAT_R32G32B32_UINT,
1383 VK_FORMAT_R32G32B32_SINT,
1384 VK_FORMAT_R32G32B32_SFLOAT,
1385 VK_FORMAT_R32G32B32A32_UINT,
1386 VK_FORMAT_R32G32B32A32_SINT,
1387 VK_FORMAT_R32G32B32A32_SFLOAT,
1388 // VK_FORMAT_R64_UINT,
1389 // VK_FORMAT_R64_SINT,
1390 // VK_FORMAT_R64_SFLOAT,
1391 // VK_FORMAT_R64G64_UINT,
1392 // VK_FORMAT_R64G64_SINT,
1393 // VK_FORMAT_R64G64_SFLOAT,
1394 // VK_FORMAT_R64G64B64_UINT,
1395 // VK_FORMAT_R64G64B64_SINT,
1396 // VK_FORMAT_R64G64B64_SFLOAT,
1397 // VK_FORMAT_R64G64B64A64_UINT,
1398 // VK_FORMAT_R64G64B64A64_SINT,
1399 // VK_FORMAT_R64G64B64A64_SFLOAT,
1400 VK_FORMAT_B10G11R11_UFLOAT_PACK32,
1401 VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
1402 // VK_FORMAT_BC1_RGB_UNORM_BLOCK,
1403 // VK_FORMAT_BC1_RGB_SRGB_BLOCK,
1404 // VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
1405 // VK_FORMAT_BC1_RGBA_SRGB_BLOCK,
1406 // VK_FORMAT_BC2_UNORM_BLOCK,
1407 // VK_FORMAT_BC2_SRGB_BLOCK,
1408 // VK_FORMAT_BC3_UNORM_BLOCK,
1409 // VK_FORMAT_BC3_SRGB_BLOCK,
1410 // VK_FORMAT_BC4_UNORM_BLOCK,
1411 // VK_FORMAT_BC4_SNORM_BLOCK,
1412 // VK_FORMAT_BC5_UNORM_BLOCK,
1413 // VK_FORMAT_BC5_SNORM_BLOCK,
1414 // VK_FORMAT_BC6H_UFLOAT_BLOCK,
1415 // VK_FORMAT_BC6H_SFLOAT_BLOCK,
1416 // VK_FORMAT_BC7_UNORM_BLOCK,
1417 // VK_FORMAT_BC7_SRGB_BLOCK,
1418 // VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,
1419 // VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
1420 // VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK,
1421 // VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,
1422 // VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK,
1423 // VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,
1424 // VK_FORMAT_EAC_R11_UNORM_BLOCK,
1425 // VK_FORMAT_EAC_R11_SNORM_BLOCK,
1426 // VK_FORMAT_EAC_R11G11_UNORM_BLOCK,
1427 // VK_FORMAT_EAC_R11G11_SNORM_BLOCK,
1428 // VK_FORMAT_ASTC_4x4_UNORM_BLOCK,
1429 // VK_FORMAT_ASTC_4x4_SRGB_BLOCK,
1430 // VK_FORMAT_ASTC_5x4_UNORM_BLOCK,
1431 // VK_FORMAT_ASTC_5x4_SRGB_BLOCK,
1432 // VK_FORMAT_ASTC_5x5_UNORM_BLOCK,
1433 // VK_FORMAT_ASTC_5x5_SRGB_BLOCK,
1434 // VK_FORMAT_ASTC_6x5_UNORM_BLOCK,
1435 // VK_FORMAT_ASTC_6x5_SRGB_BLOCK,
1436 // VK_FORMAT_ASTC_6x6_UNORM_BLOCK,
1437 // VK_FORMAT_ASTC_6x6_SRGB_BLOCK,
1438 // VK_FORMAT_ASTC_8x5_UNORM_BLOCK,
1439 // VK_FORMAT_ASTC_8x5_SRGB_BLOCK,
1440 // VK_FORMAT_ASTC_8x6_UNORM_BLOCK,
1441 // VK_FORMAT_ASTC_8x6_SRGB_BLOCK,
1442 // VK_FORMAT_ASTC_8x8_UNORM_BLOCK,
1443 // VK_FORMAT_ASTC_8x8_SRGB_BLOCK,
1444 // VK_FORMAT_ASTC_10x5_UNORM_BLOCK,
1445 // VK_FORMAT_ASTC_10x5_SRGB_BLOCK,
1446 // VK_FORMAT_ASTC_10x6_UNORM_BLOCK,
1447 // VK_FORMAT_ASTC_10x6_SRGB_BLOCK,
1448 // VK_FORMAT_ASTC_10x8_UNORM_BLOCK,
1449 // VK_FORMAT_ASTC_10x8_SRGB_BLOCK,
1450 // VK_FORMAT_ASTC_10x10_UNORM_BLOCK,
1451 // VK_FORMAT_ASTC_10x10_SRGB_BLOCK,
1452 // VK_FORMAT_ASTC_12x10_UNORM_BLOCK,
1453 // VK_FORMAT_ASTC_12x10_SRGB_BLOCK,
1454 // VK_FORMAT_ASTC_12x12_UNORM_BLOCK,
1455 // VK_FORMAT_ASTC_12x12_SRGB_BLOCK
1457 const size_t numOfColorImageFormatsToTest = DE_LENGTH_OF_ARRAY(colorImageFormatsToTest);
1459 const VkFormat depthStencilImageFormatsToTest[] =
1461 VK_FORMAT_D16_UNORM,
1462 VK_FORMAT_X8_D24_UNORM_PACK32,
1463 VK_FORMAT_D32_SFLOAT,
1465 VK_FORMAT_D16_UNORM_S8_UINT,
1466 VK_FORMAT_D24_UNORM_S8_UINT,
1467 VK_FORMAT_D32_SFLOAT_S8_UINT
1469 const size_t numOfDepthStencilImageFormatsToTest = DE_LENGTH_OF_ARRAY(depthStencilImageFormatsToTest);
1471 // Clear color image
1473 const VkImageType imageTypesToTest[] =
1479 const size_t numOfImageTypesToTest = DE_LENGTH_OF_ARRAY(imageTypesToTest);
1481 const VkExtent3D imageDimensionsByType[] =
1488 for (size_t imageTypeIndex = 0; imageTypeIndex < numOfImageTypesToTest; ++imageTypeIndex)
1489 for (size_t imageFormatIndex = 0; imageFormatIndex < numOfColorImageFormatsToTest; ++imageFormatIndex)
1491 const VkFormat format = colorImageFormatsToTest[imageFormatIndex];
1492 const TestParams testParams =
1494 false, // bool useSingleMipLevel;
1495 imageTypesToTest[imageTypeIndex], // VkImageType imageType;
1496 format, // VkFormat imageFormat;
1497 imageDimensionsByType[imageTypeIndex], // VkExtent3D imageExtent;
1498 makeClearColorValue(format, 0.2f, 0.1f, 0.7f, 0.8f), // VkClearValue initValue;
1500 makeClearColorValue(format, 0.1f, 0.5f, 0.3f, 0.9f), // VkClearValue clearValue[0];
1501 makeClearColorValue(format, 0.3f, 0.6f, 0.2f, 0.7f), // VkClearValue clearValue[1];
1505 std::ostringstream testCaseName;
1506 testCaseName << getImageTypeCaseName(testParams.imageType) << "_" << getFormatCaseName(format);
1508 colorImageClearTests->addChild(new InstanceFactory1<ClearColorImageTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Clear Color Image", testParams));
1511 imageClearingTests->addChild(colorImageClearTests.release());
1514 // Clear depth/stencil image
1516 TestParams testParams =
1518 true, // bool useSingleMipLevel;
1519 VK_IMAGE_TYPE_2D, // VkImageType imageType;
1520 VK_FORMAT_UNDEFINED, // VkFormat format;
1521 { 256, 256, 1 }, // VkExtent3D extent;
1522 makeClearValueDepthStencil(0.5f, 0x03), // VkClearValue initValue
1524 makeClearValueDepthStencil(0.1f, 0x06), // VkClearValue clearValue[0];
1525 makeClearValueDepthStencil(0.3f, 0x04), // VkClearValue clearValue[1];
1529 for (size_t imageFormatIndex = 0; imageFormatIndex < numOfDepthStencilImageFormatsToTest; ++imageFormatIndex)
1531 testParams.imageFormat = depthStencilImageFormatsToTest[imageFormatIndex];
1533 std::ostringstream testCaseName;
1534 testCaseName << getImageTypeCaseName(testParams.imageType) << "_" << getFormatCaseName(testParams.imageFormat);
1536 depthStencilImageClearTests->addChild(new InstanceFactory1<ClearDepthStencilImageTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Clear Depth/Stencil Image", testParams));
1539 imageClearingTests->addChild(depthStencilImageClearTests.release());
1542 // Clear color attachment
1544 for (size_t imageFormatIndex = 0; imageFormatIndex < numOfColorImageFormatsToTest; ++imageFormatIndex)
1546 const VkFormat format = colorImageFormatsToTest[imageFormatIndex];
1547 const TestParams testParams =
1549 true, // bool useSingleMipLevel;
1550 VK_IMAGE_TYPE_2D, // VkImageType imageType;
1551 format, // VkFormat format;
1552 { 256, 256, 1 }, // VkExtent3D extent;
1553 makeClearColorValue(format, 0.2f, 0.1f, 0.7f, 0.8f), // VkClearValue initValue
1555 makeClearColorValue(format, 0.1f, 0.5f, 0.3f, 0.9f), // VkClearValue clearValue[0];
1556 makeClearColorValue(format, 0.3f, 0.6f, 0.2f, 0.7f), // VkClearValue clearValue[1];
1560 std::ostringstream testCaseName;
1561 testCaseName << getImageTypeCaseName(testParams.imageType) << "_" << getFormatCaseName(format);
1563 colorAttachmentClearTests->addChild(new InstanceFactory1<ClearAttachmentTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Clear Color Attachment", testParams));
1564 partialColorAttachmentClearTests->addChild(new InstanceFactory1<PartialClearAttachmentTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Partial Clear Color Attachment", testParams));
1567 imageClearingTests->addChild(colorAttachmentClearTests.release());
1568 imageClearingTests->addChild(partialColorAttachmentClearTests.release());
1571 // Clear depth/stencil attachment
1573 TestParams testParams =
1575 true, // bool useSingleMipLevel;
1576 VK_IMAGE_TYPE_2D, // VkImageType imageType;
1577 VK_FORMAT_UNDEFINED, // VkFormat format;
1578 { 256, 256, 1 }, // VkExtent3D extent;
1579 makeClearValueDepthStencil(0.5f, 0x03), // VkClearValue initValue
1581 makeClearValueDepthStencil(0.1f, 0x06), // VkClearValue clearValue[0];
1582 makeClearValueDepthStencil(0.3f, 0x04), // VkClearValue clearValue[1];
1586 for (size_t imageFormatIndex = 0; imageFormatIndex < numOfDepthStencilImageFormatsToTest; ++imageFormatIndex)
1588 testParams.imageFormat = depthStencilImageFormatsToTest[imageFormatIndex];
1590 std::ostringstream testCaseName;
1591 testCaseName << getImageTypeCaseName(testParams.imageType) << "_" << getFormatCaseName(testParams.imageFormat);
1593 depthStencilAttachmentClearTests->addChild(new InstanceFactory1<ClearAttachmentTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Clear Depth/Stencil Attachment", testParams));
1594 partialDepthStencilAttachmentClearTests->addChild(new InstanceFactory1<PartialClearAttachmentTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Parital Clear Depth/Stencil Attachment", testParams));
1597 imageClearingTests->addChild(depthStencilAttachmentClearTests.release());
1598 imageClearingTests->addChild(partialDepthStencilAttachmentClearTests.release());
1601 return imageClearingTests.release();