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 deUint32 greatestCommonDivisor (const deUint32 a, const deUint32 b)
93 deUint32 lowestCommonMultiple (const deUint32 a, const deUint32 b)
95 return (a*b)/greatestCommonDivisor(a,b);
98 std::vector<deUint32> getImageMipLevelSizes (const deUint32 pixelSize, const VkExtent3D& baseExtent, const deUint32 numMipLevels, const deUint32 perLevelAlignment = 1u)
100 std::vector<deUint32> results(numMipLevels);
102 for (deUint32 mipLevel = 0; mipLevel < numMipLevels; ++mipLevel)
104 const VkExtent3D extent = getMipLevelExtent(baseExtent, mipLevel);
105 results[mipLevel] = static_cast<deUint32>(extent.width * extent.height * extent.depth * pixelSize);
106 results[mipLevel] = ((results[mipLevel] + perLevelAlignment-1) / perLevelAlignment) * perLevelAlignment;
112 //! Check if a point lies in a cross-like area.
113 inline bool isInClearRange (const UVec4& clearCoords, const deUint32 x, const deUint32 y)
115 return !((x < clearCoords[0] && y < clearCoords[1]) ||
116 (x < clearCoords[0] && y >= clearCoords[3]) ||
117 (x >= clearCoords[2] && y < clearCoords[1]) ||
118 (x >= clearCoords[2] && y >= clearCoords[3]));
121 // This method is copied from the vktRenderPassTests.cpp. It should be moved to a common place.
122 int calcFloatDiff (float a, float b)
124 const int asign = Float32(a).sign();
125 const int bsign = Float32(a).sign();
127 const deUint32 avalue = (Float32(a).bits() & ((0x1u << 31u) - 1u));
128 const deUint32 bvalue = (Float32(b).bits() & ((0x1u << 31u) - 1u));
131 return avalue + bvalue + 1u;
132 else if (avalue < bvalue)
133 return bvalue - avalue;
135 return avalue - bvalue;
138 // This method is copied from the vktRenderPassTests.cpp and extended with the stringResult parameter.
139 bool comparePixelToDepthClearValue (const ConstPixelBufferAccess& access,
143 std::string& stringResult)
145 const TextureFormat format = getEffectiveDepthStencilTextureFormat(access.getFormat(), Sampler::MODE_DEPTH);
146 const TextureChannelClass channelClass = getTextureChannelClass(format.type);
148 switch (channelClass)
150 case TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
151 case TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
153 const int bitDepth = getTextureFormatBitDepth(format).x();
154 const float depth = access.getPixDepth(x, y);
155 const float threshold = 2.0f / (float)((1 << bitDepth) - 1);
156 const bool result = deFloatAbs(depth - ref) <= threshold;
161 s << "Ref:" << ref << " Threshold:" << threshold << " Depth:" << depth;
162 stringResult = s.str();
168 case TEXTURECHANNELCLASS_FLOATING_POINT:
170 const float depth = access.getPixDepth(x, y);
171 const int mantissaBits = getTextureFormatMantissaBitDepth(format).x();
172 const int threshold = 10 * 1 << (23 - mantissaBits);
174 DE_ASSERT(mantissaBits <= 23);
176 const bool result = calcFloatDiff(depth, ref) <= threshold;
180 float floatThreshold = Float32((deUint32)threshold).asFloat();
183 s << "Ref:" << ref << " Threshold:" << floatThreshold << " Depth:" << depth;
184 stringResult = s.str();
191 DE_FATAL("Invalid channel class");
196 // This method is copied from the vktRenderPassTests.cpp and extended with the stringResult parameter.
197 bool comparePixelToStencilClearValue (const ConstPixelBufferAccess& access,
201 std::string& stringResult)
203 const deUint32 stencil = access.getPixStencil(x, y);
204 const bool result = stencil == ref;
209 s << "Ref:" << ref << " Threshold:0" << " Stencil:" << stencil;
210 stringResult = s.str();
216 // This method is copied from the vktRenderPassTests.cpp and extended with the stringResult parameter.
217 bool comparePixelToColorClearValue (const ConstPixelBufferAccess& access,
221 const VkClearColorValue& ref,
222 std::string& stringResult)
224 const TextureFormat format = access.getFormat();
225 const TextureChannelClass channelClass = getTextureChannelClass(format.type);
226 const BVec4 channelMask = getTextureFormatChannelMask(format);
228 switch (channelClass)
230 case TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
231 case TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
233 const IVec4 bitDepth (getTextureFormatBitDepth(format));
234 const Vec4 resColor (access.getPixel(x, y, z));
235 Vec4 refColor (ref.float32[0],
239 const int modifier = (channelClass == TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT) ? 0 : 1;
240 const Vec4 threshold (bitDepth[0] > 0 ? 1.0f / ((float)(1 << (bitDepth[0] - modifier)) - 1.0f) : 1.0f,
241 bitDepth[1] > 0 ? 1.0f / ((float)(1 << (bitDepth[1] - modifier)) - 1.0f) : 1.0f,
242 bitDepth[2] > 0 ? 1.0f / ((float)(1 << (bitDepth[2] - modifier)) - 1.0f) : 1.0f,
243 bitDepth[3] > 0 ? 1.0f / ((float)(1 << (bitDepth[3] - modifier)) - 1.0f) : 1.0f);
245 if (isSRGB(access.getFormat()))
246 refColor = linearToSRGB(refColor);
248 const bool result = !(anyNotEqual(logicalAnd(lessThanEqual(absDiff(resColor, refColor), threshold), channelMask), channelMask));
253 s << "Ref:" << refColor << " Mask:" << channelMask << " Threshold:" << threshold << " Color:" << resColor;
254 stringResult = s.str();
260 case TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
262 const UVec4 resColor (access.getPixelUint(x, y, z));
263 const UVec4 refColor (ref.uint32[0],
267 const UVec4 threshold (1);
269 const bool result = !(anyNotEqual(logicalAnd(lessThanEqual(absDiff(resColor, refColor), threshold), channelMask), channelMask));
274 s << "Ref:" << refColor << " Mask:" << channelMask << " Threshold:" << threshold << " Color:" << resColor;
275 stringResult = s.str();
281 case TEXTURECHANNELCLASS_SIGNED_INTEGER:
283 const IVec4 resColor (access.getPixelInt(x, y, z));
284 const IVec4 refColor (ref.int32[0],
288 const IVec4 threshold (1);
290 const bool result = !(anyNotEqual(logicalAnd(lessThanEqual(absDiff(resColor, refColor), threshold), channelMask), channelMask));
295 s << "Ref:" << refColor << " Mask:" << channelMask << " Threshold:" << threshold << " Color:" << resColor;
296 stringResult = s.str();
302 case TEXTURECHANNELCLASS_FLOATING_POINT:
304 const Vec4 resColor (access.getPixel(x, y, z));
305 const Vec4 refColor (ref.float32[0],
309 const IVec4 mantissaBits (getTextureFormatMantissaBitDepth(format));
310 const IVec4 threshold (10 * IVec4(1) << (23 - mantissaBits));
312 DE_ASSERT(allEqual(greaterThanEqual(threshold, IVec4(0)), BVec4(true)));
314 for (int ndx = 0; ndx < 4; ndx++)
316 const bool result = !(calcFloatDiff(resColor[ndx], refColor[ndx]) > threshold[ndx] && channelMask[ndx]);
320 float floatThreshold = Float32((deUint32)(threshold)[0]).asFloat();
321 Vec4 thresholdVec4 (floatThreshold,
326 s << "Ref:" << refColor << " Mask:" << channelMask << " Threshold:" << thresholdVec4 << " Color:" << resColor;
327 stringResult = s.str();
337 DE_FATAL("Invalid channel class");
344 bool useSingleMipLevel; //!< only mip level 0, otherwise up to maxMipLevels
345 VkImageType imageType;
346 VkFormat imageFormat;
347 VkExtent3D imageExtent;
348 VkClearValue initValue;
349 VkClearValue clearValue[2]; //!< the second value is used with more than one mip map
352 class ImageClearingTestInstance : public vkt::TestInstance
355 ImageClearingTestInstance (Context& context,
356 const TestParams& testParams);
358 Move<VkCommandPool> createCommandPool (VkCommandPoolCreateFlags commandPoolCreateFlags) const;
359 Move<VkCommandBuffer> allocatePrimaryCommandBuffer (VkCommandPool commandPool) const;
360 Move<VkImage> createImage (VkImageType imageType, VkFormat format, VkExtent3D extent, VkImageUsageFlags usage) const;
361 Move<VkImageView> createImageView (VkImage image, VkImageViewType viewType, VkFormat format, VkImageAspectFlags aspectMask) const;
362 Move<VkRenderPass> createRenderPass (VkFormat format) const;
363 Move<VkFramebuffer> createFrameBuffer (VkImageView imageView, VkRenderPass renderPass, deUint32 imageWidth, deUint32 imageHeight) const;
365 void beginCommandBuffer (VkCommandBufferUsageFlags usageFlags) const;
366 void endCommandBuffer (void) const;
367 void submitCommandBuffer (void) const;
368 void beginRenderPass (VkSubpassContents content, VkClearValue clearValue) const;
370 void pipelineImageBarrier (VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkImageLayout oldLayout, VkImageLayout newLayout) const;
371 de::MovePtr<TextureLevelPyramid> readImage (VkImageAspectFlags aspectMask) const;
372 tcu::TestStatus verifyResultImage (const std::string& successMessage, const UVec4& clearCoords = UVec4()) const;
375 VkImageViewType getCorrespondingImageViewType (VkImageType imageType) const;
376 VkImageUsageFlags getImageUsageFlags (VkFormat format) const;
377 VkImageAspectFlags getImageAspectFlags (VkFormat format) const;
378 bool getIsAttachmentFormat (VkFormat format) const;
379 bool getIsStencilFormat (VkFormat format) const;
380 bool getIsDepthFormat (VkFormat format) const;
381 VkImageFormatProperties getImageFormatProperties (void) const;
382 de::MovePtr<Allocation> allocateAndBindImageMemory (VkImage image) const;
384 const TestParams& m_params;
385 const VkDevice m_device;
386 const InstanceInterface& m_vki;
387 const DeviceInterface& m_vkd;
388 const VkQueue m_queue;
389 const deUint32 m_queueFamilyIndex;
390 Allocator& m_allocator;
392 const bool m_isAttachmentFormat;
393 const VkImageUsageFlags m_imageUsageFlags;
394 const VkImageAspectFlags m_imageAspectFlags;
395 const VkImageFormatProperties m_imageFormatProperties;
396 const deUint32 m_imageMipLevels;
397 const deUint32 m_thresholdMipLevel;
399 Unique<VkCommandPool> m_commandPool;
400 Unique<VkCommandBuffer> m_commandBuffer;
402 Unique<VkImage> m_image;
403 de::MovePtr<Allocation> m_imageMemory;
404 Unique<VkImageView> m_imageView;
405 Unique<VkRenderPass> m_renderPass;
406 Unique<VkFramebuffer> m_frameBuffer;
409 ImageClearingTestInstance::ImageClearingTestInstance (Context& context, const TestParams& params)
410 : TestInstance (context)
412 , m_device (context.getDevice())
413 , m_vki (context.getInstanceInterface())
414 , m_vkd (context.getDeviceInterface())
415 , m_queue (context.getUniversalQueue())
416 , m_queueFamilyIndex (context.getUniversalQueueFamilyIndex())
417 , m_allocator (context.getDefaultAllocator())
418 , m_isAttachmentFormat (getIsAttachmentFormat(params.imageFormat))
419 , m_imageUsageFlags (getImageUsageFlags(params.imageFormat))
420 , m_imageAspectFlags (getImageAspectFlags(params.imageFormat))
421 , m_imageFormatProperties (getImageFormatProperties())
422 , m_imageMipLevels (params.useSingleMipLevel ? 1u : getNumMipLevels(params.imageExtent, m_imageFormatProperties.maxMipLevels))
423 , m_thresholdMipLevel (std::max(m_imageMipLevels / 2u, 1u))
424 , m_commandPool (createCommandPool(VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT))
425 , m_commandBuffer (allocatePrimaryCommandBuffer(*m_commandPool))
427 , m_image (createImage(params.imageType,
432 , m_imageMemory (allocateAndBindImageMemory(*m_image))
433 , m_imageView (m_isAttachmentFormat ? createImageView(*m_image,
434 getCorrespondingImageViewType(params.imageType),
436 m_imageAspectFlags) : vk::Move<VkImageView>())
438 , m_renderPass (m_isAttachmentFormat ? createRenderPass(params.imageFormat) : vk::Move<vk::VkRenderPass>())
439 , m_frameBuffer (m_isAttachmentFormat ? createFrameBuffer(*m_imageView, *m_renderPass, params.imageExtent.width, params.imageExtent.height) : vk::Move<vk::VkFramebuffer>())
443 VkImageViewType ImageClearingTestInstance::getCorrespondingImageViewType (VkImageType imageType) const
447 case VK_IMAGE_TYPE_1D:
448 return VK_IMAGE_VIEW_TYPE_1D;
449 case VK_IMAGE_TYPE_2D:
450 return VK_IMAGE_VIEW_TYPE_2D;
451 case VK_IMAGE_TYPE_3D:
452 return VK_IMAGE_VIEW_TYPE_3D;
454 DE_FATAL("Unknown image type!");
457 return VK_IMAGE_VIEW_TYPE_2D;
460 VkImageUsageFlags ImageClearingTestInstance::getImageUsageFlags (VkFormat format) const
462 VkImageUsageFlags commonFlags = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
464 if (m_isAttachmentFormat)
466 if (isDepthStencilFormat(format))
467 return commonFlags | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
469 return commonFlags | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
474 VkImageAspectFlags ImageClearingTestInstance::getImageAspectFlags (VkFormat format) const
476 VkImageAspectFlags imageAspectFlags = 0;
478 if (getIsDepthFormat(format))
479 imageAspectFlags |= VK_IMAGE_ASPECT_DEPTH_BIT;
481 if (getIsStencilFormat(format))
482 imageAspectFlags |= VK_IMAGE_ASPECT_STENCIL_BIT;
484 if (imageAspectFlags == 0)
485 imageAspectFlags = VK_IMAGE_ASPECT_COLOR_BIT;
487 return imageAspectFlags;
490 bool ImageClearingTestInstance::getIsAttachmentFormat (VkFormat format) const
492 const VkFormatProperties props = vk::getPhysicalDeviceFormatProperties(m_vki, m_context.getPhysicalDevice(), format);
494 return (props.optimalTilingFeatures & (vk::VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | vk::VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) != 0;
497 bool ImageClearingTestInstance::getIsStencilFormat (VkFormat format) const
499 const TextureFormat tcuFormat = mapVkFormat(format);
501 if (tcuFormat.order == TextureFormat::S || tcuFormat.order == TextureFormat::DS)
507 bool ImageClearingTestInstance::getIsDepthFormat (VkFormat format) const
509 const TextureFormat tcuFormat = mapVkFormat(format);
511 if (tcuFormat.order == TextureFormat::D || tcuFormat.order == TextureFormat::DS)
517 VkImageFormatProperties ImageClearingTestInstance::getImageFormatProperties (void) const
519 VkImageFormatProperties properties;
520 const VkResult result = m_vki.getPhysicalDeviceImageFormatProperties(m_context.getPhysicalDevice(), m_params.imageFormat, m_params.imageType,
521 VK_IMAGE_TILING_OPTIMAL, m_imageUsageFlags, (VkImageCreateFlags)0, &properties);
523 if (result == VK_ERROR_FORMAT_NOT_SUPPORTED)
524 TCU_THROW(NotSupportedError, "Format not supported");
529 de::MovePtr<Allocation> ImageClearingTestInstance::allocateAndBindImageMemory (VkImage image) const
531 de::MovePtr<Allocation> imageMemory (m_allocator.allocate(getImageMemoryRequirements(m_vkd, m_device, image), MemoryRequirement::Any));
532 VK_CHECK(m_vkd.bindImageMemory(m_device, image, imageMemory->getMemory(), imageMemory->getOffset()));
536 Move<VkCommandPool> ImageClearingTestInstance::createCommandPool (VkCommandPoolCreateFlags commandPoolCreateFlags) const
538 return vk::createCommandPool(m_vkd, m_device, commandPoolCreateFlags, m_queueFamilyIndex);
541 Move<VkCommandBuffer> ImageClearingTestInstance::allocatePrimaryCommandBuffer (VkCommandPool commandPool) const
543 return vk::allocateCommandBuffer(m_vkd, m_device, commandPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY);
546 Move<VkImage> ImageClearingTestInstance::createImage (VkImageType imageType, VkFormat format, VkExtent3D extent, VkImageUsageFlags usage) const
548 const VkImageCreateInfo imageCreateInfo =
550 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
551 DE_NULL, // const void* pNext;
552 0u, // VkImageCreateFlags flags;
553 imageType, // VkImageType imageType;
554 format, // VkFormat format;
555 extent, // VkExtent3D extent;
556 m_imageMipLevels, // deUint32 mipLevels;
557 1u, // deUint32 arrayLayers;
558 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples;
559 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
560 usage, // VkImageUsageFlags usage;
561 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
562 1u, // deUint32 queueFamilyIndexCount;
563 &m_queueFamilyIndex, // const deUint32* pQueueFamilyIndices;
564 VK_IMAGE_LAYOUT_UNDEFINED // VkImageLayout initialLayout;
567 return vk::createImage(m_vkd, m_device, &imageCreateInfo, DE_NULL);
570 Move<VkImageView> ImageClearingTestInstance::createImageView (VkImage image, VkImageViewType viewType, VkFormat format, VkImageAspectFlags aspectMask) const
572 const VkImageViewCreateInfo imageViewCreateInfo =
574 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // VkStructureType sType;
575 DE_NULL, // const void* pNext;
576 0u, // VkImageViewCreateFlags flags;
577 image, // VkImage image;
578 viewType, // VkImageViewType viewType;
579 format, // VkFormat format;
581 VK_COMPONENT_SWIZZLE_IDENTITY, // VkComponentSwizzle r;
582 VK_COMPONENT_SWIZZLE_IDENTITY, // VkComponentSwizzle g;
583 VK_COMPONENT_SWIZZLE_IDENTITY, // VkComponentSwizzle b;
584 VK_COMPONENT_SWIZZLE_IDENTITY, // VkComponentSwizzle a;
585 }, // VkComponentMapping components;
587 aspectMask, // VkImageAspectFlags aspectMask;
588 0u, // deUint32 baseMipLevel;
589 1u, // deUint32 mipLevels;
590 0u, // deUint32 baseArrayLayer;
591 1u, // deUint32 arraySize;
592 }, // VkImageSubresourceRange subresourceRange;
595 return vk::createImageView(m_vkd, m_device, &imageViewCreateInfo, DE_NULL);
598 Move<VkRenderPass> ImageClearingTestInstance::createRenderPass (VkFormat format) const
600 VkImageLayout imageLayout;
602 if (isDepthStencilFormat(format))
603 imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
605 imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
607 const VkAttachmentDescription attachmentDesc =
609 0u, // VkAttachmentDescriptionFlags flags;
610 format, // VkFormat format;
611 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples;
612 VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp;
613 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp;
614 VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp stencilLoadOp;
615 VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp stencilStoreOp;
616 imageLayout, // VkImageLayout initialLayout;
617 imageLayout, // VkImageLayout finalLayout;
620 const VkAttachmentDescription attachments[1] =
625 const VkAttachmentReference attachmentRef =
627 0u, // deUint32 attachment;
628 imageLayout, // VkImageLayout layout;
631 const VkAttachmentReference* pColorAttachments = DE_NULL;
632 const VkAttachmentReference* pDepthStencilAttachment = DE_NULL;
633 deUint32 colorAttachmentCount = 1;
635 if (isDepthStencilFormat(format))
637 colorAttachmentCount = 0;
638 pDepthStencilAttachment = &attachmentRef;
642 colorAttachmentCount = 1;
643 pColorAttachments = &attachmentRef;
646 const VkSubpassDescription subpassDesc[1] =
649 0u, // VkSubpassDescriptionFlags flags;
650 VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint;
651 0u, // deUint32 inputAttachmentCount;
652 DE_NULL, // const VkAttachmentReference* pInputAttachments;
653 colorAttachmentCount, // deUint32 colorAttachmentCount;
654 pColorAttachments, // const VkAttachmentReference* pColorAttachments;
655 DE_NULL, // const VkAttachmentReference* pResolveAttachments;
656 pDepthStencilAttachment, // const VkAttachmentReference* pDepthStencilAttachment;
657 0u, // deUint32 preserveAttachmentCount;
658 DE_NULL, // const VkAttachmentReference* pPreserveAttachments;
662 const VkRenderPassCreateInfo renderPassCreateInfo =
664 VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // VkStructureType sType;
665 DE_NULL, // const void* pNext;
666 0u, // VkRenderPassCreateFlags flags;
667 1u, // deUint32 attachmentCount;
668 attachments, // const VkAttachmentDescription* pAttachments;
669 1u, // deUint32 subpassCount;
670 subpassDesc, // const VkSubpassDescription* pSubpasses;
671 0u, // deUint32 dependencyCount;
672 DE_NULL, // const VkSubpassDependency* pDependencies;
675 return vk::createRenderPass(m_vkd, m_device, &renderPassCreateInfo, DE_NULL);
678 Move<VkFramebuffer> ImageClearingTestInstance::createFrameBuffer (VkImageView imageView, VkRenderPass renderPass, deUint32 imageWidth, deUint32 imageHeight) const
680 const VkImageView attachmentViews[1] =
685 const VkFramebufferCreateInfo framebufferCreateInfo =
687 VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // VkStructureType sType;
688 DE_NULL, // const void* pNext;
689 0u, // VkFramebufferCreateFlags flags;
690 renderPass, // VkRenderPass renderPass;
691 1, // deUint32 attachmentCount;
692 attachmentViews, // const VkImageView* pAttachments;
693 imageWidth, // deUint32 width;
694 imageHeight, // deUint32 height;
695 1u, // deUint32 layers;
698 return createFramebuffer(m_vkd, m_device, &framebufferCreateInfo, DE_NULL);
701 void ImageClearingTestInstance::beginCommandBuffer (VkCommandBufferUsageFlags usageFlags) const
703 const VkCommandBufferBeginInfo commandBufferBeginInfo =
705 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
706 DE_NULL, // const void* pNext;
707 usageFlags, // VkCommandBufferUsageFlags flags;
708 DE_NULL // const VkCommandBufferInheritanceInfo* pInheritanceInfo;
711 VK_CHECK(m_vkd.beginCommandBuffer(*m_commandBuffer, &commandBufferBeginInfo));
714 void ImageClearingTestInstance::endCommandBuffer (void) const
716 VK_CHECK(m_vkd.endCommandBuffer(*m_commandBuffer));
719 void ImageClearingTestInstance::submitCommandBuffer (void) const
721 const Unique<VkFence> fence (createFence(m_vkd, m_device));
723 const VkSubmitInfo submitInfo =
725 VK_STRUCTURE_TYPE_SUBMIT_INFO, // VkStructureType sType;
726 DE_NULL, // const void* pNext;
727 0u, // deUint32 waitSemaphoreCount;
728 DE_NULL, // const VkSemaphore* pWaitSemaphores;
729 DE_NULL, // const VkPipelineStageFlags* pWaitDstStageMask;
730 1u, // deUint32 commandBufferCount;
731 &(*m_commandBuffer), // const VkCommandBuffer* pCommandBuffers;
732 0u, // deUint32 signalSemaphoreCount;
733 DE_NULL // const VkSemaphore* pSignalSemaphores;
736 VK_CHECK(m_vkd.queueSubmit(m_queue, 1, &submitInfo, *fence));
738 VK_CHECK(m_vkd.waitForFences(m_device, 1, &fence.get(), VK_TRUE, ~0ull));
741 void ImageClearingTestInstance::pipelineImageBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkImageLayout oldLayout, VkImageLayout newLayout) const
743 const VkImageMemoryBarrier imageBarrier =
745 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
746 DE_NULL, // const void* pNext;
747 srcAccessMask, // VkAccessFlags srcAccessMask;
748 dstAccessMask, // VkAccessFlags dstAccessMask;
749 oldLayout, // VkImageLayout oldLayout;
750 newLayout, // VkImageLayout newLayout;
751 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
752 VK_QUEUE_FAMILY_IGNORED, // deUint32 destQueueFamilyIndex;
753 *m_image, // VkImage image;
755 m_imageAspectFlags, // VkImageAspectFlags aspectMask;
756 0u, // deUint32 baseMipLevel;
757 VK_REMAINING_MIP_LEVELS, // deUint32 levelCount;
758 0u, // deUint32 baseArrayLayer;
759 1u, // deUint32 layerCount;
760 }, // VkImageSubresourceRange subresourceRange;
763 m_vkd.cmdPipelineBarrier(*m_commandBuffer, srcStageMask, dstStageMask, 0, 0, DE_NULL, 0, DE_NULL, 1, &imageBarrier);
766 de::MovePtr<TextureLevelPyramid> ImageClearingTestInstance::readImage (VkImageAspectFlags aspectMask) const
768 const TextureFormat tcuFormat = aspectMask == VK_IMAGE_ASPECT_COLOR_BIT ? mapVkFormat(m_params.imageFormat) :
769 aspectMask == VK_IMAGE_ASPECT_DEPTH_BIT ? getDepthCopyFormat(m_params.imageFormat) :
770 aspectMask == VK_IMAGE_ASPECT_STENCIL_BIT ? getStencilCopyFormat(m_params.imageFormat) :
772 const deUint32 pixelSize = getPixelSize(tcuFormat);
773 deUint32 alignment = 4; // subsequent mip levels aligned to 4 bytes
775 if (!getIsDepthFormat(m_params.imageFormat) && !getIsStencilFormat(m_params.imageFormat))
776 alignment = lowestCommonMultiple(pixelSize, alignment); // alignment must be multiple of pixel size, if not D/S.
778 const std::vector<deUint32> mipLevelSizes = getImageMipLevelSizes(pixelSize, m_params.imageExtent, m_imageMipLevels, alignment);
779 const VkDeviceSize imageTotalSize = std::accumulate(mipLevelSizes.begin(), mipLevelSizes.end(), 0u);
781 de::MovePtr<TextureLevelPyramid> result (new TextureLevelPyramid(tcuFormat, m_imageMipLevels));
782 Move<VkBuffer> buffer;
783 de::MovePtr<Allocation> bufferAlloc;
785 // Create destination buffer
787 const VkBufferCreateInfo bufferParams =
789 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType;
790 DE_NULL, // const void* pNext;
791 0u, // VkBufferCreateFlags flags;
792 imageTotalSize, // VkDeviceSize size;
793 VK_BUFFER_USAGE_TRANSFER_DST_BIT, // VkBufferUsageFlags usage;
794 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
795 0u, // deUint32 queueFamilyIndexCount;
796 DE_NULL // const deUint32* pQueueFamilyIndices;
799 buffer = createBuffer(m_vkd, m_device, &bufferParams);
800 bufferAlloc = m_allocator.allocate(getBufferMemoryRequirements(m_vkd, m_device, *buffer), MemoryRequirement::HostVisible);
801 VK_CHECK(m_vkd.bindBufferMemory(m_device, *buffer, bufferAlloc->getMemory(), bufferAlloc->getOffset()));
804 // Barriers for copying image to buffer
806 const VkBufferMemoryBarrier bufferBarrier =
808 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, // VkStructureType sType;
809 DE_NULL, // const void* pNext;
810 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask;
811 VK_ACCESS_HOST_READ_BIT, // VkAccessFlags dstAccessMask;
812 VK_QUEUE_FAMILY_IGNORED, // deUint32 srcQueueFamilyIndex;
813 VK_QUEUE_FAMILY_IGNORED, // deUint32 dstQueueFamilyIndex;
814 *buffer, // VkBuffer buffer;
815 0u, // VkDeviceSize offset;
816 imageTotalSize, // VkDeviceSize size;
819 // Copy image to buffer
820 std::vector<VkBufferImageCopy> copyRegions;
822 deUint32 offset = 0u;
823 for (deUint32 mipLevel = 0; mipLevel < m_imageMipLevels; ++mipLevel)
825 const VkExtent3D extent = getMipLevelExtent(m_params.imageExtent, mipLevel);
826 const VkBufferImageCopy region =
828 offset, // VkDeviceSize bufferOffset;
829 0u, // deUint32 bufferRowLength;
830 0u, // deUint32 bufferImageHeight;
831 { aspectMask, mipLevel, 0u, 1u }, // VkImageSubresourceLayers imageSubresource;
832 { 0, 0, 0 }, // VkOffset3D imageOffset;
833 extent // VkExtent3D imageExtent;
835 copyRegions.push_back(region);
836 offset += mipLevelSizes[mipLevel];
840 beginCommandBuffer(0);
842 pipelineImageBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT,
843 VK_PIPELINE_STAGE_TRANSFER_BIT,
844 VK_ACCESS_TRANSFER_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
845 VK_ACCESS_TRANSFER_READ_BIT,
846 VK_IMAGE_LAYOUT_GENERAL,
847 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
849 m_vkd.cmdCopyImageToBuffer(*m_commandBuffer, *m_image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, *buffer, static_cast<deUint32>(copyRegions.size()), ©Regions[0]);
850 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);
852 pipelineImageBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT,
853 VK_PIPELINE_STAGE_TRANSFER_BIT,
854 VK_ACCESS_TRANSFER_READ_BIT,
855 VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT,
856 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
857 VK_IMAGE_LAYOUT_GENERAL);
860 submitCommandBuffer();
862 invalidateMappedMemoryRange(m_vkd, m_device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), imageTotalSize);
865 deUint32 offset = 0u;
866 for (deUint32 mipLevel = 0; mipLevel < m_imageMipLevels; ++mipLevel)
868 const VkExtent3D extent = getMipLevelExtent(m_params.imageExtent, mipLevel);
869 const void* pLevelData = static_cast<const void*>(reinterpret_cast<deUint8*>(bufferAlloc->getHostPtr()) + offset);
871 result->allocLevel(mipLevel, extent.width, extent.height, extent.depth);
872 copy(result->getLevel(mipLevel), ConstPixelBufferAccess(result->getFormat(), result->getLevel(mipLevel).getSize(), pLevelData));
874 offset += mipLevelSizes[mipLevel];
881 tcu::TestStatus ImageClearingTestInstance::verifyResultImage (const std::string& successMessage, const UVec4& clearCoords) const
883 const bool useClearRange = clearCoords != UVec4();
884 DE_ASSERT(!useClearRange || m_params.imageExtent.depth == 1u);
886 if (getIsDepthFormat(m_params.imageFormat))
888 DE_ASSERT(m_imageMipLevels == 1u);
890 de::MovePtr<TextureLevelPyramid> image = readImage(VK_IMAGE_ASPECT_DEPTH_BIT);
894 for (deUint32 y = 0; y < m_params.imageExtent.height; ++y)
895 for (deUint32 x = 0; x < m_params.imageExtent.width; ++x)
897 if (!useClearRange || isInClearRange(clearCoords, x, y))
898 depthValue = m_params.clearValue[0].depthStencil.depth;
900 depthValue = m_params.initValue.depthStencil.depth;
902 if (!comparePixelToDepthClearValue(image->getLevel(0), x, y, depthValue, message))
903 return TestStatus::fail("Depth value mismatch! " + message);
907 if (getIsStencilFormat(m_params.imageFormat))
909 DE_ASSERT(m_imageMipLevels == 1u);
911 de::MovePtr<TextureLevelPyramid> image = readImage(VK_IMAGE_ASPECT_STENCIL_BIT);
913 deUint32 stencilValue;
915 for (deUint32 y = 0; y < m_params.imageExtent.height; ++y)
916 for (deUint32 x = 0; x < m_params.imageExtent.width; ++x)
918 if (!useClearRange || isInClearRange(clearCoords, x, y))
919 stencilValue = m_params.clearValue[0].depthStencil.stencil;
921 stencilValue = m_params.initValue.depthStencil.stencil;
923 if (!comparePixelToStencilClearValue(image->getLevel(0), x, y, stencilValue, message))
924 return TestStatus::fail("Stencil value mismatch! " + message);
928 if (!isDepthStencilFormat(m_params.imageFormat))
930 de::MovePtr<TextureLevelPyramid> image = readImage(VK_IMAGE_ASPECT_COLOR_BIT);
932 const VkClearColorValue* pColorValue;
934 for (deUint32 mipLevel = 0; mipLevel < m_imageMipLevels; ++mipLevel)
936 const int clearColorNdx = (mipLevel < m_thresholdMipLevel ? 0 : 1);
937 const VkExtent3D extent = getMipLevelExtent(m_params.imageExtent, mipLevel);
939 for (deUint32 z = 0; z < extent.depth; ++z)
940 for (deUint32 y = 0; y < extent.height; ++y)
941 for (deUint32 x = 0; x < extent.width; ++x)
943 if (!useClearRange || isInClearRange(clearCoords, x, y))
944 pColorValue = &m_params.clearValue[clearColorNdx].color;
946 pColorValue = &m_params.initValue.color;
948 if (!comparePixelToColorClearValue(image->getLevel(mipLevel), x, y, z, *pColorValue, message))
949 return TestStatus::fail("Color value mismatch! " + message);
954 return TestStatus::pass(successMessage);
957 void ImageClearingTestInstance::beginRenderPass (VkSubpassContents content, VkClearValue clearValue) const
959 const VkRenderPassBeginInfo renderPassBeginInfo =
961 VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, // VkStructureType sType;
962 DE_NULL, // const void* pNext;
963 *m_renderPass, // VkRenderPass renderPass;
964 *m_frameBuffer, // VkFramebuffer framebuffer;
966 { 0, 0 }, // VkOffset2D offset;
968 m_params.imageExtent.width, // deUint32 width;
969 m_params.imageExtent.height // deUint32 height;
970 } // VkExtent2D extent;
971 }, // VkRect2D renderArea;
972 1u, // deUint32 clearValueCount;
973 &clearValue // const VkClearValue* pClearValues;
976 m_vkd.cmdBeginRenderPass(*m_commandBuffer, &renderPassBeginInfo, content);
979 class ClearColorImageTestInstance : public ImageClearingTestInstance
982 ClearColorImageTestInstance (Context& context, const TestParams& testParams) : ImageClearingTestInstance (context, testParams) {}
983 TestStatus iterate (void);
986 TestStatus ClearColorImageTestInstance::iterate (void)
988 std::vector<VkImageSubresourceRange> subresourceRanges;
990 if (m_imageMipLevels == 1)
991 subresourceRanges.push_back(makeImageSubresourceRange(m_imageAspectFlags, 0u, 1u, 0u, 1u));
994 subresourceRanges.push_back(makeImageSubresourceRange(m_imageAspectFlags, 0u, m_thresholdMipLevel, 0u, 1u));
995 subresourceRanges.push_back(makeImageSubresourceRange(m_imageAspectFlags, m_thresholdMipLevel, VK_REMAINING_MIP_LEVELS, 0u, 1u));
998 beginCommandBuffer(0);
1000 pipelineImageBarrier(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, // VkPipelineStageFlags srcStageMask
1001 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, // VkPipelineStageFlags dstStageMask
1002 0, // VkAccessFlags srcAccessMask
1003 (m_isAttachmentFormat
1004 ? VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT
1005 : VK_ACCESS_TRANSFER_WRITE_BIT), // VkAccessFlags dstAccessMask
1006 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
1007 (m_isAttachmentFormat
1008 ? VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
1009 : VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL)); // VkImageLayout newLayout;
1011 if (m_isAttachmentFormat)
1013 beginRenderPass(VK_SUBPASS_CONTENTS_INLINE, m_params.initValue);
1014 m_vkd.cmdEndRenderPass(*m_commandBuffer);
1016 pipelineImageBarrier(VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, // VkPipelineStageFlags srcStageMask
1017 VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags dstStageMask
1018 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // VkAccessFlags srcAccessMask
1019 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask
1020 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout oldLayout;
1021 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); // VkImageLayout newLayout;
1024 // Different clear color per range
1025 for (std::size_t i = 0u; i < subresourceRanges.size(); ++i)
1026 m_vkd.cmdClearColorImage(*m_commandBuffer, *m_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &m_params.clearValue[i].color, 1, &subresourceRanges[i]);
1028 pipelineImageBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags srcStageMask
1029 VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags dstStageMask
1030 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask
1031 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask
1032 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
1033 VK_IMAGE_LAYOUT_GENERAL); // VkImageLayout newLayout;
1036 submitCommandBuffer();
1038 return verifyResultImage("cmdClearColorImage passed");
1041 class ClearDepthStencilImageTestInstance : public ImageClearingTestInstance
1044 ClearDepthStencilImageTestInstance (Context& context, const TestParams& testParams) : ImageClearingTestInstance (context, testParams) {}
1045 TestStatus iterate (void);
1048 TestStatus ClearDepthStencilImageTestInstance::iterate (void)
1050 const VkImageSubresourceRange subresourceRange = makeImageSubresourceRange(m_imageAspectFlags, 0u, 1u, 0u, 1u);
1052 beginCommandBuffer(0);
1054 pipelineImageBarrier(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, // VkPipelineStageFlags srcStageMask
1055 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, // VkPipelineStageFlags dstStageMask
1056 0, // VkAccessFlags srcAccessMask
1057 (m_isAttachmentFormat
1058 ? VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT
1059 : VK_ACCESS_TRANSFER_WRITE_BIT), // VkAccessFlags dstAccessMask
1060 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
1061 (m_isAttachmentFormat
1062 ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
1063 : VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL)); // VkImageLayout newLayout;
1065 if (m_isAttachmentFormat)
1067 beginRenderPass(VK_SUBPASS_CONTENTS_INLINE, m_params.initValue);
1068 m_vkd.cmdEndRenderPass(*m_commandBuffer);
1070 pipelineImageBarrier(VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, // VkPipelineStageFlags srcStageMask
1071 VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags dstStageMask
1072 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, // VkAccessFlags srcAccessMask
1073 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask
1074 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, // VkImageLayout oldLayout;
1075 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); // VkImageLayout newLayout;
1078 m_vkd.cmdClearDepthStencilImage(*m_commandBuffer, *m_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &m_params.clearValue[0].depthStencil, 1, &subresourceRange);
1080 pipelineImageBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags srcStageMask
1081 VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags dstStageMask
1082 VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask
1083 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask
1084 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout;
1085 VK_IMAGE_LAYOUT_GENERAL); // VkImageLayout newLayout;
1088 submitCommandBuffer();
1090 return verifyResultImage("cmdClearDepthStencilImage passed");
1093 class ClearAttachmentTestInstance : public ImageClearingTestInstance
1102 ClearAttachmentTestInstance (Context& context, const TestParams& testParams, const ClearType clearType = FULL_CLEAR)
1103 : ImageClearingTestInstance (context, testParams)
1104 , m_clearType (clearType)
1106 if (!m_isAttachmentFormat)
1107 TCU_THROW(NotSupportedError, "Format not renderable");
1110 TestStatus iterate (void)
1112 const VkClearAttachment clearAttachment =
1114 m_imageAspectFlags, // VkImageAspectFlags aspectMask;
1115 0u, // deUint32 colorAttachment;
1116 m_params.clearValue[0] // VkClearValue clearValue;
1120 std::vector<VkClearRect> clearRects;
1122 if (m_clearType == FULL_CLEAR)
1124 const VkClearRect rect =
1127 { 0, 0 }, // VkOffset2D offset;
1128 { m_params.imageExtent.width, m_params.imageExtent.height } // VkExtent2D extent;
1129 }, // VkRect2D rect;
1130 0u, // deUint32 baseArrayLayer;
1131 1u // deUint32 layerCount;
1134 clearRects.push_back(rect);
1138 const deUint32 clearX = m_params.imageExtent.width / 4u;
1139 const deUint32 clearY = m_params.imageExtent.height / 4u;
1140 const deUint32 clearWidth = m_params.imageExtent.width / 2u;
1141 const deUint32 clearHeight = m_params.imageExtent.height / 2u;
1143 clearCoords = UVec4(clearX, clearY,
1144 clearX + clearWidth, clearY + clearHeight);
1146 const VkClearRect rects[2] =
1150 { 0, static_cast<deInt32>(clearY) }, // VkOffset2D offset;
1151 { m_params.imageExtent.width, clearHeight } // VkExtent2D extent;
1152 }, // VkRect2D rect;
1153 0u, // deUint32 baseArrayLayer;
1154 1u // deUint32 layerCount;
1158 { static_cast<deInt32>(clearX), 0 }, // VkOffset2D offset;
1159 { clearWidth, m_params.imageExtent.height } // VkExtent2D extent;
1160 }, // VkRect2D rect;
1161 0u, // deUint32 baseArrayLayer;
1162 1u // deUint32 layerCount;
1166 clearRects.push_back(rects[0]);
1167 clearRects.push_back(rects[1]);
1170 const bool isDepthStencil = isDepthStencilFormat(m_params.imageFormat);
1171 const VkAccessFlags accessMask = (isDepthStencil ? VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT : VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
1172 const VkImageLayout attachmentLayout = (isDepthStencil ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
1174 beginCommandBuffer(0);
1176 pipelineImageBarrier(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, // VkPipelineStageFlags srcStageMask
1177 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, // VkPipelineStageFlags dstStageMask
1178 0, // VkAccessFlags srcAccessMask
1179 accessMask, // VkAccessFlags dstAccessMask
1180 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout;
1181 attachmentLayout); // VkImageLayout newLayout;
1183 beginRenderPass(VK_SUBPASS_CONTENTS_INLINE, m_params.initValue);
1184 m_vkd.cmdClearAttachments(*m_commandBuffer, 1, &clearAttachment, static_cast<deUint32>(clearRects.size()), &clearRects[0]);
1185 m_vkd.cmdEndRenderPass(*m_commandBuffer);
1187 pipelineImageBarrier(VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, // VkPipelineStageFlags srcStageMask
1188 VK_PIPELINE_STAGE_TRANSFER_BIT, // VkPipelineStageFlags dstStageMask
1189 accessMask, // VkAccessFlags srcAccessMask
1190 VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask
1191 attachmentLayout, // VkImageLayout oldLayout;
1192 VK_IMAGE_LAYOUT_GENERAL); // VkImageLayout newLayout;
1195 submitCommandBuffer();
1197 return verifyResultImage("cmdClearAttachments passed", clearCoords);
1201 const ClearType m_clearType;
1204 class PartialClearAttachmentTestInstance : public ClearAttachmentTestInstance
1207 PartialClearAttachmentTestInstance (Context& context, const TestParams& testParams) : ClearAttachmentTestInstance (context, testParams, PARTIAL_CLEAR) {}
1210 VkClearValue makeClearColorValue (VkFormat format, float r, float g, float b, float a)
1212 const TextureFormat tcuFormat = mapVkFormat(format);
1213 VkClearValue clearValue;
1215 if (getTextureChannelClass(tcuFormat.type) == TEXTURECHANNELCLASS_FLOATING_POINT
1216 || getTextureChannelClass(tcuFormat.type) == TEXTURECHANNELCLASS_SIGNED_FIXED_POINT
1217 || getTextureChannelClass(tcuFormat.type) == TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT)
1219 clearValue.color.float32[0] = r;
1220 clearValue.color.float32[1] = g;
1221 clearValue.color.float32[2] = b;
1222 clearValue.color.float32[3] = a;
1224 else if (getTextureChannelClass(tcuFormat.type) == TEXTURECHANNELCLASS_UNSIGNED_INTEGER)
1226 UVec4 maxValues = getFormatMaxUintValue(tcuFormat);
1228 clearValue.color.uint32[0] = (deUint32)((float)maxValues[0] * r);
1229 clearValue.color.uint32[1] = (deUint32)((float)maxValues[1] * g);
1230 clearValue.color.uint32[2] = (deUint32)((float)maxValues[2] * b);
1231 clearValue.color.uint32[3] = (deUint32)((float)maxValues[3] * a);
1233 else if (getTextureChannelClass(tcuFormat.type) == TEXTURECHANNELCLASS_SIGNED_INTEGER)
1235 IVec4 maxValues = getFormatMaxIntValue(tcuFormat);
1237 clearValue.color.int32[0] = (deUint32)((float)maxValues[0] * r);
1238 clearValue.color.int32[1] = (deUint32)((float)maxValues[1] * g);
1239 clearValue.color.int32[2] = (deUint32)((float)maxValues[2] * b);
1240 clearValue.color.int32[3] = (deUint32)((float)maxValues[3] * a);
1243 DE_FATAL("Unknown channel class");
1248 std::string getFormatCaseName (VkFormat format)
1250 return de::toLower(de::toString(getFormatStr(format)).substr(10));
1253 const char* getImageTypeCaseName (VkImageType type)
1255 const char* s_names[] =
1261 return de::getSizedArrayElement<VK_IMAGE_TYPE_LAST>(s_names, type);
1266 TestCaseGroup* createImageClearingTests (TestContext& testCtx)
1269 de::MovePtr<TestCaseGroup> imageClearingTests (new TestCaseGroup(testCtx, "image_clearing", "Image Clearing Tests"));
1271 de::MovePtr<TestCaseGroup> colorImageClearTests (new TestCaseGroup(testCtx, "clear_color_image", "Color Image Clear Tests"));
1272 de::MovePtr<TestCaseGroup> depthStencilImageClearTests (new TestCaseGroup(testCtx, "clear_depth_stencil_image", "Color Depth/Stencil Image Tests"));
1273 de::MovePtr<TestCaseGroup> colorAttachmentClearTests (new TestCaseGroup(testCtx, "clear_color_attachment", "Color Color Attachment Tests"));
1274 de::MovePtr<TestCaseGroup> depthStencilAttachmentClearTests (new TestCaseGroup(testCtx, "clear_depth_stencil_attachment", "Color Depth/Stencil Attachment Tests"));
1275 de::MovePtr<TestCaseGroup> partialColorAttachmentClearTests (new TestCaseGroup(testCtx, "partial_clear_color_attachment", "Clear Partial Color Attachment Tests"));
1276 de::MovePtr<TestCaseGroup> partialDepthStencilAttachmentClearTests (new TestCaseGroup(testCtx, "partial_clear_depth_stencil_attachment", "Clear Partial Depth/Stencil Attachment Tests"));
1278 // Some formats are commented out due to the tcu::TextureFormat does not support them yet.
1279 const VkFormat colorImageFormatsToTest[] =
1281 VK_FORMAT_R4G4_UNORM_PACK8,
1282 VK_FORMAT_R4G4B4A4_UNORM_PACK16,
1283 VK_FORMAT_B4G4R4A4_UNORM_PACK16,
1284 VK_FORMAT_R5G6B5_UNORM_PACK16,
1285 VK_FORMAT_B5G6R5_UNORM_PACK16,
1286 VK_FORMAT_R5G5B5A1_UNORM_PACK16,
1287 VK_FORMAT_B5G5R5A1_UNORM_PACK16,
1288 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
1291 VK_FORMAT_R8_USCALED,
1292 VK_FORMAT_R8_SSCALED,
1296 VK_FORMAT_R8G8_UNORM,
1297 VK_FORMAT_R8G8_SNORM,
1298 VK_FORMAT_R8G8_USCALED,
1299 VK_FORMAT_R8G8_SSCALED,
1300 VK_FORMAT_R8G8_UINT,
1301 VK_FORMAT_R8G8_SINT,
1302 VK_FORMAT_R8G8_SRGB,
1303 VK_FORMAT_R8G8B8_UNORM,
1304 VK_FORMAT_R8G8B8_SNORM,
1305 VK_FORMAT_R8G8B8_USCALED,
1306 VK_FORMAT_R8G8B8_SSCALED,
1307 VK_FORMAT_R8G8B8_UINT,
1308 VK_FORMAT_R8G8B8_SINT,
1309 VK_FORMAT_R8G8B8_SRGB,
1310 VK_FORMAT_B8G8R8_UNORM,
1311 VK_FORMAT_B8G8R8_SNORM,
1312 VK_FORMAT_B8G8R8_USCALED,
1313 VK_FORMAT_B8G8R8_SSCALED,
1314 VK_FORMAT_B8G8R8_UINT,
1315 VK_FORMAT_B8G8R8_SINT,
1316 VK_FORMAT_B8G8R8_SRGB,
1317 VK_FORMAT_R8G8B8A8_UNORM,
1318 VK_FORMAT_R8G8B8A8_SNORM,
1319 VK_FORMAT_R8G8B8A8_USCALED,
1320 VK_FORMAT_R8G8B8A8_SSCALED,
1321 VK_FORMAT_R8G8B8A8_UINT,
1322 VK_FORMAT_R8G8B8A8_SINT,
1323 VK_FORMAT_R8G8B8A8_SRGB,
1324 VK_FORMAT_B8G8R8A8_UNORM,
1325 VK_FORMAT_B8G8R8A8_SNORM,
1326 VK_FORMAT_B8G8R8A8_USCALED,
1327 VK_FORMAT_B8G8R8A8_SSCALED,
1328 VK_FORMAT_B8G8R8A8_UINT,
1329 VK_FORMAT_B8G8R8A8_SINT,
1330 VK_FORMAT_B8G8R8A8_SRGB,
1331 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1332 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
1333 VK_FORMAT_A8B8G8R8_USCALED_PACK32,
1334 VK_FORMAT_A8B8G8R8_SSCALED_PACK32,
1335 VK_FORMAT_A8B8G8R8_UINT_PACK32,
1336 VK_FORMAT_A8B8G8R8_SINT_PACK32,
1337 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
1338 VK_FORMAT_A2R10G10B10_UNORM_PACK32,
1339 VK_FORMAT_A2R10G10B10_SNORM_PACK32,
1340 VK_FORMAT_A2R10G10B10_USCALED_PACK32,
1341 VK_FORMAT_A2R10G10B10_SSCALED_PACK32,
1342 VK_FORMAT_A2R10G10B10_UINT_PACK32,
1343 VK_FORMAT_A2R10G10B10_SINT_PACK32,
1344 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
1345 VK_FORMAT_A2B10G10R10_SNORM_PACK32,
1346 VK_FORMAT_A2B10G10R10_USCALED_PACK32,
1347 VK_FORMAT_A2B10G10R10_SSCALED_PACK32,
1348 VK_FORMAT_A2B10G10R10_UINT_PACK32,
1349 VK_FORMAT_A2B10G10R10_SINT_PACK32,
1350 VK_FORMAT_R16_UNORM,
1351 VK_FORMAT_R16_SNORM,
1352 VK_FORMAT_R16_USCALED,
1353 VK_FORMAT_R16_SSCALED,
1356 VK_FORMAT_R16_SFLOAT,
1357 VK_FORMAT_R16G16_UNORM,
1358 VK_FORMAT_R16G16_SNORM,
1359 VK_FORMAT_R16G16_USCALED,
1360 VK_FORMAT_R16G16_SSCALED,
1361 VK_FORMAT_R16G16_UINT,
1362 VK_FORMAT_R16G16_SINT,
1363 VK_FORMAT_R16G16_SFLOAT,
1364 VK_FORMAT_R16G16B16_UNORM,
1365 VK_FORMAT_R16G16B16_SNORM,
1366 VK_FORMAT_R16G16B16_USCALED,
1367 VK_FORMAT_R16G16B16_SSCALED,
1368 VK_FORMAT_R16G16B16_UINT,
1369 VK_FORMAT_R16G16B16_SINT,
1370 VK_FORMAT_R16G16B16_SFLOAT,
1371 VK_FORMAT_R16G16B16A16_UNORM,
1372 VK_FORMAT_R16G16B16A16_SNORM,
1373 VK_FORMAT_R16G16B16A16_USCALED,
1374 VK_FORMAT_R16G16B16A16_SSCALED,
1375 VK_FORMAT_R16G16B16A16_UINT,
1376 VK_FORMAT_R16G16B16A16_SINT,
1377 VK_FORMAT_R16G16B16A16_SFLOAT,
1380 VK_FORMAT_R32_SFLOAT,
1381 VK_FORMAT_R32G32_UINT,
1382 VK_FORMAT_R32G32_SINT,
1383 VK_FORMAT_R32G32_SFLOAT,
1384 VK_FORMAT_R32G32B32_UINT,
1385 VK_FORMAT_R32G32B32_SINT,
1386 VK_FORMAT_R32G32B32_SFLOAT,
1387 VK_FORMAT_R32G32B32A32_UINT,
1388 VK_FORMAT_R32G32B32A32_SINT,
1389 VK_FORMAT_R32G32B32A32_SFLOAT,
1390 // VK_FORMAT_R64_UINT,
1391 // VK_FORMAT_R64_SINT,
1392 // VK_FORMAT_R64_SFLOAT,
1393 // VK_FORMAT_R64G64_UINT,
1394 // VK_FORMAT_R64G64_SINT,
1395 // VK_FORMAT_R64G64_SFLOAT,
1396 // VK_FORMAT_R64G64B64_UINT,
1397 // VK_FORMAT_R64G64B64_SINT,
1398 // VK_FORMAT_R64G64B64_SFLOAT,
1399 // VK_FORMAT_R64G64B64A64_UINT,
1400 // VK_FORMAT_R64G64B64A64_SINT,
1401 // VK_FORMAT_R64G64B64A64_SFLOAT,
1402 VK_FORMAT_B10G11R11_UFLOAT_PACK32,
1403 VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
1404 // VK_FORMAT_BC1_RGB_UNORM_BLOCK,
1405 // VK_FORMAT_BC1_RGB_SRGB_BLOCK,
1406 // VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
1407 // VK_FORMAT_BC1_RGBA_SRGB_BLOCK,
1408 // VK_FORMAT_BC2_UNORM_BLOCK,
1409 // VK_FORMAT_BC2_SRGB_BLOCK,
1410 // VK_FORMAT_BC3_UNORM_BLOCK,
1411 // VK_FORMAT_BC3_SRGB_BLOCK,
1412 // VK_FORMAT_BC4_UNORM_BLOCK,
1413 // VK_FORMAT_BC4_SNORM_BLOCK,
1414 // VK_FORMAT_BC5_UNORM_BLOCK,
1415 // VK_FORMAT_BC5_SNORM_BLOCK,
1416 // VK_FORMAT_BC6H_UFLOAT_BLOCK,
1417 // VK_FORMAT_BC6H_SFLOAT_BLOCK,
1418 // VK_FORMAT_BC7_UNORM_BLOCK,
1419 // VK_FORMAT_BC7_SRGB_BLOCK,
1420 // VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,
1421 // VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
1422 // VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK,
1423 // VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,
1424 // VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK,
1425 // VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,
1426 // VK_FORMAT_EAC_R11_UNORM_BLOCK,
1427 // VK_FORMAT_EAC_R11_SNORM_BLOCK,
1428 // VK_FORMAT_EAC_R11G11_UNORM_BLOCK,
1429 // VK_FORMAT_EAC_R11G11_SNORM_BLOCK,
1430 // VK_FORMAT_ASTC_4x4_UNORM_BLOCK,
1431 // VK_FORMAT_ASTC_4x4_SRGB_BLOCK,
1432 // VK_FORMAT_ASTC_5x4_UNORM_BLOCK,
1433 // VK_FORMAT_ASTC_5x4_SRGB_BLOCK,
1434 // VK_FORMAT_ASTC_5x5_UNORM_BLOCK,
1435 // VK_FORMAT_ASTC_5x5_SRGB_BLOCK,
1436 // VK_FORMAT_ASTC_6x5_UNORM_BLOCK,
1437 // VK_FORMAT_ASTC_6x5_SRGB_BLOCK,
1438 // VK_FORMAT_ASTC_6x6_UNORM_BLOCK,
1439 // VK_FORMAT_ASTC_6x6_SRGB_BLOCK,
1440 // VK_FORMAT_ASTC_8x5_UNORM_BLOCK,
1441 // VK_FORMAT_ASTC_8x5_SRGB_BLOCK,
1442 // VK_FORMAT_ASTC_8x6_UNORM_BLOCK,
1443 // VK_FORMAT_ASTC_8x6_SRGB_BLOCK,
1444 // VK_FORMAT_ASTC_8x8_UNORM_BLOCK,
1445 // VK_FORMAT_ASTC_8x8_SRGB_BLOCK,
1446 // VK_FORMAT_ASTC_10x5_UNORM_BLOCK,
1447 // VK_FORMAT_ASTC_10x5_SRGB_BLOCK,
1448 // VK_FORMAT_ASTC_10x6_UNORM_BLOCK,
1449 // VK_FORMAT_ASTC_10x6_SRGB_BLOCK,
1450 // VK_FORMAT_ASTC_10x8_UNORM_BLOCK,
1451 // VK_FORMAT_ASTC_10x8_SRGB_BLOCK,
1452 // VK_FORMAT_ASTC_10x10_UNORM_BLOCK,
1453 // VK_FORMAT_ASTC_10x10_SRGB_BLOCK,
1454 // VK_FORMAT_ASTC_12x10_UNORM_BLOCK,
1455 // VK_FORMAT_ASTC_12x10_SRGB_BLOCK,
1456 // VK_FORMAT_ASTC_12x12_UNORM_BLOCK,
1457 // VK_FORMAT_ASTC_12x12_SRGB_BLOCK
1459 const size_t numOfColorImageFormatsToTest = DE_LENGTH_OF_ARRAY(colorImageFormatsToTest);
1461 const VkFormat depthStencilImageFormatsToTest[] =
1463 VK_FORMAT_D16_UNORM,
1464 VK_FORMAT_X8_D24_UNORM_PACK32,
1465 VK_FORMAT_D32_SFLOAT,
1467 VK_FORMAT_D16_UNORM_S8_UINT,
1468 VK_FORMAT_D24_UNORM_S8_UINT,
1469 VK_FORMAT_D32_SFLOAT_S8_UINT
1471 const size_t numOfDepthStencilImageFormatsToTest = DE_LENGTH_OF_ARRAY(depthStencilImageFormatsToTest);
1473 // Clear color image
1475 const VkImageType imageTypesToTest[] =
1481 const size_t numOfImageTypesToTest = DE_LENGTH_OF_ARRAY(imageTypesToTest);
1483 const VkExtent3D imageDimensionsByType[] =
1490 for (size_t imageTypeIndex = 0; imageTypeIndex < numOfImageTypesToTest; ++imageTypeIndex)
1491 for (size_t imageFormatIndex = 0; imageFormatIndex < numOfColorImageFormatsToTest; ++imageFormatIndex)
1493 const VkFormat format = colorImageFormatsToTest[imageFormatIndex];
1494 const TestParams testParams =
1496 false, // bool useSingleMipLevel;
1497 imageTypesToTest[imageTypeIndex], // VkImageType imageType;
1498 format, // VkFormat imageFormat;
1499 imageDimensionsByType[imageTypeIndex], // VkExtent3D imageExtent;
1500 makeClearColorValue(format, 0.2f, 0.1f, 0.7f, 0.8f), // VkClearValue initValue;
1502 makeClearColorValue(format, 0.1f, 0.5f, 0.3f, 0.9f), // VkClearValue clearValue[0];
1503 makeClearColorValue(format, 0.3f, 0.6f, 0.2f, 0.7f), // VkClearValue clearValue[1];
1507 std::ostringstream testCaseName;
1508 testCaseName << getImageTypeCaseName(testParams.imageType) << "_" << getFormatCaseName(format);
1510 colorImageClearTests->addChild(new InstanceFactory1<ClearColorImageTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Clear Color Image", testParams));
1513 imageClearingTests->addChild(colorImageClearTests.release());
1516 // Clear depth/stencil image
1518 TestParams testParams =
1520 true, // bool useSingleMipLevel;
1521 VK_IMAGE_TYPE_2D, // VkImageType imageType;
1522 VK_FORMAT_UNDEFINED, // VkFormat format;
1523 { 256, 256, 1 }, // VkExtent3D extent;
1524 makeClearValueDepthStencil(0.5f, 0x03), // VkClearValue initValue
1526 makeClearValueDepthStencil(0.1f, 0x06), // VkClearValue clearValue[0];
1527 makeClearValueDepthStencil(0.3f, 0x04), // VkClearValue clearValue[1];
1531 for (size_t imageFormatIndex = 0; imageFormatIndex < numOfDepthStencilImageFormatsToTest; ++imageFormatIndex)
1533 testParams.imageFormat = depthStencilImageFormatsToTest[imageFormatIndex];
1535 std::ostringstream testCaseName;
1536 testCaseName << getImageTypeCaseName(testParams.imageType) << "_" << getFormatCaseName(testParams.imageFormat);
1538 depthStencilImageClearTests->addChild(new InstanceFactory1<ClearDepthStencilImageTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Clear Depth/Stencil Image", testParams));
1541 imageClearingTests->addChild(depthStencilImageClearTests.release());
1544 // Clear color attachment
1546 for (size_t imageFormatIndex = 0; imageFormatIndex < numOfColorImageFormatsToTest; ++imageFormatIndex)
1548 const VkFormat format = colorImageFormatsToTest[imageFormatIndex];
1549 const TestParams testParams =
1551 true, // bool useSingleMipLevel;
1552 VK_IMAGE_TYPE_2D, // VkImageType imageType;
1553 format, // VkFormat format;
1554 { 256, 256, 1 }, // VkExtent3D extent;
1555 makeClearColorValue(format, 0.2f, 0.1f, 0.7f, 0.8f), // VkClearValue initValue
1557 makeClearColorValue(format, 0.1f, 0.5f, 0.3f, 0.9f), // VkClearValue clearValue[0];
1558 makeClearColorValue(format, 0.3f, 0.6f, 0.2f, 0.7f), // VkClearValue clearValue[1];
1562 std::ostringstream testCaseName;
1563 testCaseName << getImageTypeCaseName(testParams.imageType) << "_" << getFormatCaseName(format);
1565 colorAttachmentClearTests->addChild(new InstanceFactory1<ClearAttachmentTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Clear Color Attachment", testParams));
1566 partialColorAttachmentClearTests->addChild(new InstanceFactory1<PartialClearAttachmentTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Partial Clear Color Attachment", testParams));
1569 imageClearingTests->addChild(colorAttachmentClearTests.release());
1570 imageClearingTests->addChild(partialColorAttachmentClearTests.release());
1573 // Clear depth/stencil attachment
1575 TestParams testParams =
1577 true, // bool useSingleMipLevel;
1578 VK_IMAGE_TYPE_2D, // VkImageType imageType;
1579 VK_FORMAT_UNDEFINED, // VkFormat format;
1580 { 256, 256, 1 }, // VkExtent3D extent;
1581 makeClearValueDepthStencil(0.5f, 0x03), // VkClearValue initValue
1583 makeClearValueDepthStencil(0.1f, 0x06), // VkClearValue clearValue[0];
1584 makeClearValueDepthStencil(0.3f, 0x04), // VkClearValue clearValue[1];
1588 for (size_t imageFormatIndex = 0; imageFormatIndex < numOfDepthStencilImageFormatsToTest; ++imageFormatIndex)
1590 testParams.imageFormat = depthStencilImageFormatsToTest[imageFormatIndex];
1592 std::ostringstream testCaseName;
1593 testCaseName << getImageTypeCaseName(testParams.imageType) << "_" << getFormatCaseName(testParams.imageFormat);
1595 depthStencilAttachmentClearTests->addChild(new InstanceFactory1<ClearAttachmentTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Clear Depth/Stencil Attachment", testParams));
1596 partialDepthStencilAttachmentClearTests->addChild(new InstanceFactory1<PartialClearAttachmentTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Parital Clear Depth/Stencil Attachment", testParams));
1599 imageClearingTests->addChild(depthStencilAttachmentClearTests.release());
1600 imageClearingTests->addChild(partialDepthStencilAttachmentClearTests.release());
1603 return imageClearingTests.release();