1e5c31af7Sopenharmony_ci#ifndef _VKIMAGEUTIL_HPP 2e5c31af7Sopenharmony_ci#define _VKIMAGEUTIL_HPP 3e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------- 4e5c31af7Sopenharmony_ci * Vulkan CTS Framework 5e5c31af7Sopenharmony_ci * -------------------- 6e5c31af7Sopenharmony_ci * 7e5c31af7Sopenharmony_ci * Copyright (c) 2015 The Khronos Group Inc. 8e5c31af7Sopenharmony_ci * Copyright (c) 2015 Imagination Technologies Ltd. 9e5c31af7Sopenharmony_ci * Copyright (c) 2015 Google Inc. 10e5c31af7Sopenharmony_ci * 11e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 12e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License. 13e5c31af7Sopenharmony_ci * You may obtain a copy of the License at 14e5c31af7Sopenharmony_ci * 15e5c31af7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 16e5c31af7Sopenharmony_ci * 17e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 18e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 19e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and 21e5c31af7Sopenharmony_ci * limitations under the License. 22e5c31af7Sopenharmony_ci * 23e5c31af7Sopenharmony_ci *//*! 24e5c31af7Sopenharmony_ci * \file 25e5c31af7Sopenharmony_ci * \brief Utilities for images. 26e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 27e5c31af7Sopenharmony_ci 28e5c31af7Sopenharmony_ci#include "vkDefs.hpp" 29e5c31af7Sopenharmony_ci#include "tcuTexture.hpp" 30e5c31af7Sopenharmony_ci#include "tcuCompressedTexture.hpp" 31e5c31af7Sopenharmony_ci#include "deSharedPtr.hpp" 32e5c31af7Sopenharmony_ci#include "vkImageWithMemory.hpp" 33e5c31af7Sopenharmony_ci#include "vkBufferWithMemory.hpp" 34e5c31af7Sopenharmony_ci#include "vkMemUtil.hpp" 35e5c31af7Sopenharmony_ci#include "vkTypeUtil.hpp" 36e5c31af7Sopenharmony_ci#include <memory> 37e5c31af7Sopenharmony_ci 38e5c31af7Sopenharmony_cinamespace vk 39e5c31af7Sopenharmony_ci{ 40e5c31af7Sopenharmony_ci 41e5c31af7Sopenharmony_cibool isFloatFormat (VkFormat format); 42e5c31af7Sopenharmony_cibool isUfloatFormat (VkFormat format); 43e5c31af7Sopenharmony_cibool isSfloatFormat (VkFormat format); 44e5c31af7Sopenharmony_cibool isUnormFormat (VkFormat format); 45e5c31af7Sopenharmony_cibool isSnormFormat (VkFormat format); 46e5c31af7Sopenharmony_cibool isIntFormat (VkFormat format); 47e5c31af7Sopenharmony_cibool isUintFormat (VkFormat format); 48e5c31af7Sopenharmony_cibool isScaledFormat (VkFormat format); 49e5c31af7Sopenharmony_cibool isDepthStencilFormat (VkFormat format); 50e5c31af7Sopenharmony_cibool isCompressedFormat (VkFormat format); 51e5c31af7Sopenharmony_cibool isSrgbFormat (VkFormat format); 52e5c31af7Sopenharmony_cibool isPaddedFormat (VkFormat format); 53e5c31af7Sopenharmony_cibool isAlphaOnlyFormat (VkFormat format); 54e5c31af7Sopenharmony_ci 55e5c31af7Sopenharmony_cibool is64BitIntegerFormat (VkFormat format); 56e5c31af7Sopenharmony_ci 57e5c31af7Sopenharmony_cibool isSupportedByFramework (VkFormat format); 58e5c31af7Sopenharmony_civoid checkImageSupport (const InstanceInterface& vki, VkPhysicalDevice physicalDevice, const VkImageCreateInfo& imageCreateInfo); 59e5c31af7Sopenharmony_ci 60e5c31af7Sopenharmony_citcu::TextureFormat mapVkFormat (VkFormat format); 61e5c31af7Sopenharmony_citcu::CompressedTexFormat mapVkCompressedFormat (VkFormat format); 62e5c31af7Sopenharmony_citcu::TextureFormat getDepthCopyFormat (VkFormat combinedFormat); 63e5c31af7Sopenharmony_citcu::TextureFormat getStencilCopyFormat (VkFormat combinedFormat); 64e5c31af7Sopenharmony_ci 65e5c31af7Sopenharmony_citcu::Sampler mapVkSampler (const VkSamplerCreateInfo& samplerCreateInfo); 66e5c31af7Sopenharmony_citcu::Sampler::CompareMode mapVkSamplerCompareOp (VkCompareOp compareOp); 67e5c31af7Sopenharmony_citcu::Sampler::WrapMode mapVkSamplerAddressMode (VkSamplerAddressMode addressMode); 68e5c31af7Sopenharmony_citcu::Sampler::ReductionMode mapVkSamplerReductionMode (VkSamplerReductionMode reductionMode); 69e5c31af7Sopenharmony_citcu::Sampler::FilterMode mapVkMinTexFilter (VkFilter filter, VkSamplerMipmapMode mipMode); 70e5c31af7Sopenharmony_citcu::Sampler::FilterMode mapVkMagTexFilter (VkFilter filter); 71e5c31af7Sopenharmony_ci 72e5c31af7Sopenharmony_ciVkFilter mapFilterMode (tcu::Sampler::FilterMode filterMode); 73e5c31af7Sopenharmony_ciVkSamplerMipmapMode mapMipmapMode (tcu::Sampler::FilterMode filterMode); 74e5c31af7Sopenharmony_ciVkSamplerAddressMode mapWrapMode (tcu::Sampler::WrapMode wrapMode); 75e5c31af7Sopenharmony_ciVkCompareOp mapCompareMode (tcu::Sampler::CompareMode mode); 76e5c31af7Sopenharmony_ciVkFormat mapTextureFormat (const tcu::TextureFormat& format); 77e5c31af7Sopenharmony_ciVkFormat mapCompressedTextureFormat (const tcu::CompressedTexFormat format); 78e5c31af7Sopenharmony_ciVkSamplerCreateInfo mapSampler (const tcu::Sampler& sampler, const tcu::TextureFormat& format, float minLod = 0.0f, float maxLod = 1000.0f, bool unnormal = false); 79e5c31af7Sopenharmony_cirr::GenericVec4 mapVkColor (const VkClearColorValue& color); 80e5c31af7Sopenharmony_ciVkClearColorValue mapVkColor (const rr::GenericVec4& color); 81e5c31af7Sopenharmony_ci 82e5c31af7Sopenharmony_civoid imageUtilSelfTest (void); 83e5c31af7Sopenharmony_ci 84e5c31af7Sopenharmony_cifloat getRepresentableDiffUnorm (const VkFormat format, const deUint32 componentNdx); 85e5c31af7Sopenharmony_cifloat getRepresentableDiffSnorm (const VkFormat format, const deUint32 componentNdx); 86e5c31af7Sopenharmony_cideUint32 getFormatComponentWidth (const VkFormat format, const deUint32 componentNdx); 87e5c31af7Sopenharmony_cideUint32 getBlockSizeInBytes (const VkFormat compressedFormat); 88e5c31af7Sopenharmony_cideUint32 getBlockWidth (const VkFormat compressedFormat); 89e5c31af7Sopenharmony_cideUint32 getBlockHeight (const VkFormat compressedFormat); 90e5c31af7Sopenharmony_ci 91e5c31af7Sopenharmony_cibool hasSpirvFormat (VkFormat fmt); 92e5c31af7Sopenharmony_ciconst std::string getSpirvFormat (VkFormat fmt); 93e5c31af7Sopenharmony_ci 94e5c31af7Sopenharmony_ciconst deUint32 BUFFER_IMAGE_COPY_OFFSET_GRANULARITY = 4u; 95e5c31af7Sopenharmony_ci 96e5c31af7Sopenharmony_ci// \todo [2017-05-18 pyry] Consider moving this to tcu 97e5c31af7Sopenharmony_cistruct PlanarFormatDescription 98e5c31af7Sopenharmony_ci{ 99e5c31af7Sopenharmony_ci enum 100e5c31af7Sopenharmony_ci { 101e5c31af7Sopenharmony_ci MAX_CHANNELS = 4, 102e5c31af7Sopenharmony_ci MAX_PLANES = 3 103e5c31af7Sopenharmony_ci }; 104e5c31af7Sopenharmony_ci 105e5c31af7Sopenharmony_ci enum ChannelFlags 106e5c31af7Sopenharmony_ci { 107e5c31af7Sopenharmony_ci CHANNEL_R = (1u<<0), // Has "R" (0) channel 108e5c31af7Sopenharmony_ci CHANNEL_G = (1u<<1), // Has "G" (1) channel 109e5c31af7Sopenharmony_ci CHANNEL_B = (1u<<2), // Has "B" (2) channel 110e5c31af7Sopenharmony_ci CHANNEL_A = (1u<<3), // Has "A" (3) channel 111e5c31af7Sopenharmony_ci }; 112e5c31af7Sopenharmony_ci 113e5c31af7Sopenharmony_ci struct Plane 114e5c31af7Sopenharmony_ci { 115e5c31af7Sopenharmony_ci deUint8 elementSizeBytes; 116e5c31af7Sopenharmony_ci deUint8 widthDivisor; 117e5c31af7Sopenharmony_ci deUint8 heightDivisor; 118e5c31af7Sopenharmony_ci VkFormat planeCompatibleFormat; 119e5c31af7Sopenharmony_ci }; 120e5c31af7Sopenharmony_ci 121e5c31af7Sopenharmony_ci struct Channel 122e5c31af7Sopenharmony_ci { 123e5c31af7Sopenharmony_ci deUint8 planeNdx; 124e5c31af7Sopenharmony_ci deUint8 type; // tcu::TextureChannelClass value 125e5c31af7Sopenharmony_ci deUint8 offsetBits; // Offset in element in bits 126e5c31af7Sopenharmony_ci deUint8 sizeBits; // Value size in bits 127e5c31af7Sopenharmony_ci deUint8 strideBytes; // Pixel stride (in bytes), usually plane elementSize 128e5c31af7Sopenharmony_ci }; 129e5c31af7Sopenharmony_ci 130e5c31af7Sopenharmony_ci deUint8 numPlanes; 131e5c31af7Sopenharmony_ci deUint8 presentChannels; 132e5c31af7Sopenharmony_ci deUint8 blockWidth; 133e5c31af7Sopenharmony_ci deUint8 blockHeight; 134e5c31af7Sopenharmony_ci Plane planes[MAX_PLANES]; 135e5c31af7Sopenharmony_ci Channel channels[MAX_CHANNELS]; 136e5c31af7Sopenharmony_ci 137e5c31af7Sopenharmony_ci inline bool hasChannelNdx (deUint32 ndx) const 138e5c31af7Sopenharmony_ci { 139e5c31af7Sopenharmony_ci DE_ASSERT(de::inBounds(ndx, 0u, 4u)); 140e5c31af7Sopenharmony_ci return (presentChannels & (1u<<ndx)) != 0; 141e5c31af7Sopenharmony_ci } 142e5c31af7Sopenharmony_ci}; 143e5c31af7Sopenharmony_ci 144e5c31af7Sopenharmony_ciclass ImageWithBuffer 145e5c31af7Sopenharmony_ci{ 146e5c31af7Sopenharmony_ci std::unique_ptr<ImageWithMemory> image; 147e5c31af7Sopenharmony_ci Move<vk::VkImageView> imageView; 148e5c31af7Sopenharmony_ci std::unique_ptr<BufferWithMemory> buffer; 149e5c31af7Sopenharmony_ci VkDeviceSize size; 150e5c31af7Sopenharmony_ci 151e5c31af7Sopenharmony_cipublic: 152e5c31af7Sopenharmony_ci ImageWithBuffer( 153e5c31af7Sopenharmony_ci const DeviceInterface& vkd, 154e5c31af7Sopenharmony_ci const VkDevice device, 155e5c31af7Sopenharmony_ci Allocator& alloc, 156e5c31af7Sopenharmony_ci vk::VkExtent3D extent, 157e5c31af7Sopenharmony_ci vk::VkFormat imageFormat, 158e5c31af7Sopenharmony_ci vk::VkImageUsageFlags usage, 159e5c31af7Sopenharmony_ci vk::VkImageType imageType, 160e5c31af7Sopenharmony_ci vk::VkImageSubresourceRange ssr = makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u), 161e5c31af7Sopenharmony_ci uint32_t arrayLayers = 1, 162e5c31af7Sopenharmony_ci vk::VkSampleCountFlagBits samples = VK_SAMPLE_COUNT_1_BIT, 163e5c31af7Sopenharmony_ci vk::VkImageTiling tiling = VK_IMAGE_TILING_OPTIMAL, 164e5c31af7Sopenharmony_ci uint32_t mipLevels = 1, 165e5c31af7Sopenharmony_ci vk::VkSharingMode sharingMode = VK_SHARING_MODE_EXCLUSIVE); 166e5c31af7Sopenharmony_ci 167e5c31af7Sopenharmony_ci VkImage getImage(); 168e5c31af7Sopenharmony_ci VkImageView getImageView(); 169e5c31af7Sopenharmony_ci VkBuffer getBuffer(); 170e5c31af7Sopenharmony_ci VkDeviceSize getBufferSize(); 171e5c31af7Sopenharmony_ci Allocation& getImageAllocation(); 172e5c31af7Sopenharmony_ci Allocation& getBufferAllocation(); 173e5c31af7Sopenharmony_ci}; 174e5c31af7Sopenharmony_ci 175e5c31af7Sopenharmony_cibool isYCbCrFormat (VkFormat format); 176e5c31af7Sopenharmony_cibool isYCbCrExtensionFormat (VkFormat format); 177e5c31af7Sopenharmony_cibool isYCbCrConversionFormat (VkFormat format); 178e5c31af7Sopenharmony_cibool isPvrtcFormat (VkFormat format); 179e5c31af7Sopenharmony_ciPlanarFormatDescription getPlanarFormatDescription (VkFormat format); 180e5c31af7Sopenharmony_ciint getPlaneCount (VkFormat format); 181e5c31af7Sopenharmony_cideUint32 getMipmapCount (VkFormat format, 182e5c31af7Sopenharmony_ci const vk::PlanarFormatDescription& formatDescription, 183e5c31af7Sopenharmony_ci const vk::VkImageFormatProperties& imageFormatProperties, 184e5c31af7Sopenharmony_ci const vk::VkExtent3D& extent); 185e5c31af7Sopenharmony_ci 186e5c31af7Sopenharmony_cideUint32 getPlaneSizeInBytes (const PlanarFormatDescription& formatInfo, 187e5c31af7Sopenharmony_ci const VkExtent3D& baseExtents, 188e5c31af7Sopenharmony_ci const deUint32 planeNdx, 189e5c31af7Sopenharmony_ci const deUint32 mipmapLevel, 190e5c31af7Sopenharmony_ci const deUint32 mipmapMemoryAlignment); 191e5c31af7Sopenharmony_cideUint32 getPlaneSizeInBytes (const PlanarFormatDescription& formatInfo, 192e5c31af7Sopenharmony_ci const tcu::UVec2& baseExtents, 193e5c31af7Sopenharmony_ci const deUint32 planeNdx, 194e5c31af7Sopenharmony_ci const deUint32 mipmapLevel, 195e5c31af7Sopenharmony_ci const deUint32 mipmapMemoryAlignment); 196e5c31af7Sopenharmony_ciVkExtent3D getPlaneExtent (const PlanarFormatDescription& formatInfo, 197e5c31af7Sopenharmony_ci const VkExtent3D& baseExtents, 198e5c31af7Sopenharmony_ci const deUint32 planeNdx, 199e5c31af7Sopenharmony_ci const deUint32 mipmapLevel); 200e5c31af7Sopenharmony_citcu::UVec2 getPlaneExtent (const PlanarFormatDescription& formatInfo, 201e5c31af7Sopenharmony_ci const tcu::UVec2& baseExtents, 202e5c31af7Sopenharmony_ci const deUint32 planeNdx, 203e5c31af7Sopenharmony_ci const deUint32 mipmapLevel); 204e5c31af7Sopenharmony_citcu::UVec3 getImageSizeAlignment (VkFormat format); 205e5c31af7Sopenharmony_citcu::UVec3 getImageSizeAlignment (const PlanarFormatDescription& formatInfo); 206e5c31af7Sopenharmony_citcu::UVec2 getBlockExtent (VkFormat format); 207e5c31af7Sopenharmony_citcu::UVec2 getBlockExtent (const PlanarFormatDescription& formatInfo); 208e5c31af7Sopenharmony_ciVkFormat getPlaneCompatibleFormat (VkFormat format, 209e5c31af7Sopenharmony_ci deUint32 planeNdx); 210e5c31af7Sopenharmony_ciVkFormat getPlaneCompatibleFormat (const PlanarFormatDescription& formatInfo, 211e5c31af7Sopenharmony_ci deUint32 planeNdx); 212e5c31af7Sopenharmony_ci 213e5c31af7Sopenharmony_ciVkImageAspectFlagBits getPlaneAspect (deUint32 planeNdx); 214e5c31af7Sopenharmony_cideUint32 getAspectPlaneNdx (VkImageAspectFlagBits planeAspect); 215e5c31af7Sopenharmony_cibool isChromaSubsampled (VkFormat format); 216e5c31af7Sopenharmony_cibool isYCbCr422Format (VkFormat format); 217e5c31af7Sopenharmony_cibool isYCbCr420Format (VkFormat format); 218e5c31af7Sopenharmony_ci 219e5c31af7Sopenharmony_citcu::PixelBufferAccess getChannelAccess (const PlanarFormatDescription& formatInfo, 220e5c31af7Sopenharmony_ci const tcu::UVec2& size, 221e5c31af7Sopenharmony_ci const deUint32* planeRowPitches, 222e5c31af7Sopenharmony_ci void* const* planePtrs, 223e5c31af7Sopenharmony_ci deUint32 channelNdx); 224e5c31af7Sopenharmony_citcu::ConstPixelBufferAccess getChannelAccess (const PlanarFormatDescription& formatInfo, 225e5c31af7Sopenharmony_ci const tcu::UVec2& size, 226e5c31af7Sopenharmony_ci const deUint32* planeRowPitches, 227e5c31af7Sopenharmony_ci const void* const* planePtrs, 228e5c31af7Sopenharmony_ci deUint32 channelNdx); 229e5c31af7Sopenharmony_citcu::PixelBufferAccess getChannelAccess (const PlanarFormatDescription& formatInfo, 230e5c31af7Sopenharmony_ci const tcu::UVec3& size, 231e5c31af7Sopenharmony_ci const deUint32* planeRowPitches, 232e5c31af7Sopenharmony_ci void* const* planePtrs, 233e5c31af7Sopenharmony_ci deUint32 channelNdx); 234e5c31af7Sopenharmony_citcu::ConstPixelBufferAccess getChannelAccess (const PlanarFormatDescription& formatInfo, 235e5c31af7Sopenharmony_ci const tcu::UVec3& size, 236e5c31af7Sopenharmony_ci const deUint32* planeRowPitches, 237e5c31af7Sopenharmony_ci const void* const* planePtrs, 238e5c31af7Sopenharmony_ci deUint32 channelNdx); 239e5c31af7Sopenharmony_ciVkImageAspectFlags getImageAspectFlags (const tcu::TextureFormat textureFormat); 240e5c31af7Sopenharmony_ciVkExtent3D mipLevelExtents (const VkExtent3D& baseExtents, 241e5c31af7Sopenharmony_ci const deUint32 mipLevel); 242e5c31af7Sopenharmony_citcu::UVec3 alignedDivide (const VkExtent3D& extent, 243e5c31af7Sopenharmony_ci const VkExtent3D& divisor); 244e5c31af7Sopenharmony_ci 245e5c31af7Sopenharmony_ci/*--------------------------------------------------------------------*//*! 246e5c31af7Sopenharmony_ci * Copies buffer data into an image. The buffer is expected to be 247e5c31af7Sopenharmony_ci * in a state after host write. 248e5c31af7Sopenharmony_ci*//*--------------------------------------------------------------------*/ 249e5c31af7Sopenharmony_civoid copyBufferToImage (const DeviceInterface& vk, 250e5c31af7Sopenharmony_ci vk::VkDevice device, 251e5c31af7Sopenharmony_ci vk::VkQueue queue, 252e5c31af7Sopenharmony_ci deUint32 queueFamilyIndex, 253e5c31af7Sopenharmony_ci const vk::VkBuffer& buffer, 254e5c31af7Sopenharmony_ci vk::VkDeviceSize bufferSize, 255e5c31af7Sopenharmony_ci const std::vector<vk::VkBufferImageCopy>& copyRegions, 256e5c31af7Sopenharmony_ci const vk::VkSemaphore* waitSemaphore, 257e5c31af7Sopenharmony_ci vk::VkImageAspectFlags imageAspectFlags, 258e5c31af7Sopenharmony_ci deUint32 mipLevels, 259e5c31af7Sopenharmony_ci deUint32 arrayLayers, 260e5c31af7Sopenharmony_ci vk::VkImage destImage, 261e5c31af7Sopenharmony_ci VkImageLayout destImageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, 262e5c31af7Sopenharmony_ci VkPipelineStageFlags destImageDstStageFlags = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 263e5c31af7Sopenharmony_ci VkAccessFlags destImageDstAccessMask = VK_ACCESS_SHADER_READ_BIT, 264e5c31af7Sopenharmony_ci const VkCommandPool* externalCommandPool = DE_NULL, 265e5c31af7Sopenharmony_ci deUint32 baseMipLevel = 0); 266e5c31af7Sopenharmony_ci 267e5c31af7Sopenharmony_civoid copyBufferToImage (const DeviceInterface& vk, 268e5c31af7Sopenharmony_ci const VkCommandBuffer& cmdBuffer, 269e5c31af7Sopenharmony_ci const VkBuffer& buffer, 270e5c31af7Sopenharmony_ci vk::VkDeviceSize bufferSize, 271e5c31af7Sopenharmony_ci const std::vector<VkBufferImageCopy>& copyRegions, 272e5c31af7Sopenharmony_ci VkImageAspectFlags imageAspectFlags, 273e5c31af7Sopenharmony_ci deUint32 mipLevels, 274e5c31af7Sopenharmony_ci deUint32 arrayLayers, 275e5c31af7Sopenharmony_ci VkImage destImage, 276e5c31af7Sopenharmony_ci VkImageLayout destImageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, 277e5c31af7Sopenharmony_ci VkPipelineStageFlags destImageDstStageFlags = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 278e5c31af7Sopenharmony_ci VkAccessFlags destImageDstAccessMask = VK_ACCESS_SHADER_READ_BIT, 279e5c31af7Sopenharmony_ci deUint32 baseMipLevel = 0); 280e5c31af7Sopenharmony_ci 281e5c31af7Sopenharmony_ci/*--------------------------------------------------------------------*//*! 282e5c31af7Sopenharmony_ci * Copies image data into a buffer. The buffer is expected to be 283e5c31af7Sopenharmony_ci * read by the host. 284e5c31af7Sopenharmony_ci*//*--------------------------------------------------------------------*/ 285e5c31af7Sopenharmony_civoid copyImageToBuffer (const DeviceInterface& vk, 286e5c31af7Sopenharmony_ci vk::VkCommandBuffer cmdBuffer, 287e5c31af7Sopenharmony_ci vk::VkImage image, 288e5c31af7Sopenharmony_ci vk::VkBuffer buffer, 289e5c31af7Sopenharmony_ci tcu::IVec2 size, 290e5c31af7Sopenharmony_ci vk::VkAccessFlags srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, 291e5c31af7Sopenharmony_ci vk::VkImageLayout oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, 292e5c31af7Sopenharmony_ci deUint32 numLayers = 1u, 293e5c31af7Sopenharmony_ci VkImageAspectFlags barrierAspect = VK_IMAGE_ASPECT_COLOR_BIT, 294e5c31af7Sopenharmony_ci VkImageAspectFlags copyAspect = VK_IMAGE_ASPECT_COLOR_BIT, 295e5c31af7Sopenharmony_ci VkPipelineStageFlags srcStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); 296e5c31af7Sopenharmony_ci 297e5c31af7Sopenharmony_civoid copyImageToBuffer (const DeviceInterface& vk, 298e5c31af7Sopenharmony_ci vk::VkCommandBuffer cmdBuffer, 299e5c31af7Sopenharmony_ci vk::VkImage image, 300e5c31af7Sopenharmony_ci vk::VkBuffer buffer, 301e5c31af7Sopenharmony_ci vk::VkFormat format, 302e5c31af7Sopenharmony_ci tcu::IVec2 size, 303e5c31af7Sopenharmony_ci deUint32 mipLevel = 0u, 304e5c31af7Sopenharmony_ci vk::VkAccessFlags srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, 305e5c31af7Sopenharmony_ci vk::VkImageLayout oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, 306e5c31af7Sopenharmony_ci deUint32 numLayers = 1u, 307e5c31af7Sopenharmony_ci VkImageAspectFlags barrierAspect = VK_IMAGE_ASPECT_COLOR_BIT, 308e5c31af7Sopenharmony_ci VkImageAspectFlags copyAspect = VK_IMAGE_ASPECT_COLOR_BIT); 309e5c31af7Sopenharmony_ci 310e5c31af7Sopenharmony_ci/*--------------------------------------------------------------------*//*! 311e5c31af7Sopenharmony_ci * Clear a color image 312e5c31af7Sopenharmony_ci*//*--------------------------------------------------------------------*/ 313e5c31af7Sopenharmony_civoid clearColorImage (const DeviceInterface& vk, 314e5c31af7Sopenharmony_ci const vk::VkDevice device, 315e5c31af7Sopenharmony_ci const vk::VkQueue queue, 316e5c31af7Sopenharmony_ci deUint32 queueFamilyIndex, 317e5c31af7Sopenharmony_ci vk::VkImage image, 318e5c31af7Sopenharmony_ci tcu::Vec4 clearColor, 319e5c31af7Sopenharmony_ci vk::VkImageLayout oldLayout, 320e5c31af7Sopenharmony_ci vk::VkImageLayout newLayout, 321e5c31af7Sopenharmony_ci vk::VkPipelineStageFlags dstStageFlags, 322e5c31af7Sopenharmony_ci deUint32 baseArrayLayer = 0u, 323e5c31af7Sopenharmony_ci deUint32 layerCount = 1u, 324e5c31af7Sopenharmony_ci deUint32 baseMipLevel = 0u, 325e5c31af7Sopenharmony_ci deUint32 levelCount = 1u); 326e5c31af7Sopenharmony_ci 327e5c31af7Sopenharmony_civoid clearColorImage (const DeviceInterface& vk, 328e5c31af7Sopenharmony_ci const vk::VkDevice device, 329e5c31af7Sopenharmony_ci const vk::VkQueue queue, 330e5c31af7Sopenharmony_ci deUint32 queueFamilyIndex, 331e5c31af7Sopenharmony_ci vk::VkImage image, 332e5c31af7Sopenharmony_ci vk::VkClearColorValue clearColor, 333e5c31af7Sopenharmony_ci vk::VkImageLayout oldLayout, 334e5c31af7Sopenharmony_ci vk::VkImageLayout newLayout, 335e5c31af7Sopenharmony_ci vk::VkAccessFlags dstAccessFlags, 336e5c31af7Sopenharmony_ci vk::VkPipelineStageFlags dstStageFlags, 337e5c31af7Sopenharmony_ci deUint32 baseArrayLayer = 0u, 338e5c31af7Sopenharmony_ci deUint32 layerCount = 1u, 339e5c31af7Sopenharmony_ci deUint32 baseMipLevel = 0u, 340e5c31af7Sopenharmony_ci deUint32 levelCount = 1u); 341e5c31af7Sopenharmony_ci 342e5c31af7Sopenharmony_ci/*--------------------------------------------------------------------*//*! 343e5c31af7Sopenharmony_ci * Initialize color image with a chessboard pattern 344e5c31af7Sopenharmony_ci*//*--------------------------------------------------------------------*/ 345e5c31af7Sopenharmony_civoid initColorImageChessboardPattern (const DeviceInterface& vk, 346e5c31af7Sopenharmony_ci const vk::VkDevice device, 347e5c31af7Sopenharmony_ci const vk::VkQueue queue, 348e5c31af7Sopenharmony_ci deUint32 queueFamilyIndex, 349e5c31af7Sopenharmony_ci Allocator& allocator, 350e5c31af7Sopenharmony_ci vk::VkImage image, 351e5c31af7Sopenharmony_ci vk::VkFormat format, 352e5c31af7Sopenharmony_ci tcu::Vec4 colorValue0, 353e5c31af7Sopenharmony_ci tcu::Vec4 colorValue1, 354e5c31af7Sopenharmony_ci deUint32 imageWidth, 355e5c31af7Sopenharmony_ci deUint32 imageHeight, 356e5c31af7Sopenharmony_ci deUint32 tileSize, 357e5c31af7Sopenharmony_ci vk::VkImageLayout oldLayout, 358e5c31af7Sopenharmony_ci vk::VkImageLayout newLayout, 359e5c31af7Sopenharmony_ci vk::VkPipelineStageFlags dstStageFlags); 360e5c31af7Sopenharmony_ci 361e5c31af7Sopenharmony_ci/*--------------------------------------------------------------------*//*! 362e5c31af7Sopenharmony_ci * Copies depth/stencil image data into two separate buffers. 363e5c31af7Sopenharmony_ci * The buffers are expected to be read by the host. 364e5c31af7Sopenharmony_ci*//*--------------------------------------------------------------------*/ 365e5c31af7Sopenharmony_civoid copyDepthStencilImageToBuffers (const DeviceInterface& vk, 366e5c31af7Sopenharmony_ci vk::VkCommandBuffer cmdBuffer, 367e5c31af7Sopenharmony_ci vk::VkImage image, 368e5c31af7Sopenharmony_ci vk::VkBuffer depthBuffer, 369e5c31af7Sopenharmony_ci vk::VkBuffer stencilBuffer, 370e5c31af7Sopenharmony_ci tcu::IVec2 size, 371e5c31af7Sopenharmony_ci vk::VkAccessFlags srcAccessMask, 372e5c31af7Sopenharmony_ci vk::VkImageLayout oldLayout, 373e5c31af7Sopenharmony_ci deUint32 numLayers = 1u); 374e5c31af7Sopenharmony_ci 375e5c31af7Sopenharmony_ci/*--------------------------------------------------------------------*//*! 376e5c31af7Sopenharmony_ci * Clear a depth/stencil image 377e5c31af7Sopenharmony_ci*//*--------------------------------------------------------------------*/ 378e5c31af7Sopenharmony_civoid clearDepthStencilImage (const DeviceInterface& vk, 379e5c31af7Sopenharmony_ci const vk::VkDevice device, 380e5c31af7Sopenharmony_ci const vk::VkQueue queue, 381e5c31af7Sopenharmony_ci deUint32 queueFamilyIndex, 382e5c31af7Sopenharmony_ci vk::VkImage image, 383e5c31af7Sopenharmony_ci vk::VkFormat format, 384e5c31af7Sopenharmony_ci float depthValue, 385e5c31af7Sopenharmony_ci deUint32 stencilValue, 386e5c31af7Sopenharmony_ci vk::VkImageLayout oldLayout, 387e5c31af7Sopenharmony_ci vk::VkImageLayout newLayout, 388e5c31af7Sopenharmony_ci vk::VkAccessFlags dstAccessFlags, 389e5c31af7Sopenharmony_ci vk::VkPipelineStageFlags dstStageFlags); 390e5c31af7Sopenharmony_ci 391e5c31af7Sopenharmony_ci/*--------------------------------------------------------------------*//*! 392e5c31af7Sopenharmony_ci * Initialize depth and stencil channels with a chessboard pattern 393e5c31af7Sopenharmony_ci*//*--------------------------------------------------------------------*/ 394e5c31af7Sopenharmony_civoid initDepthStencilImageChessboardPattern (const DeviceInterface& vk, 395e5c31af7Sopenharmony_ci const vk::VkDevice device, 396e5c31af7Sopenharmony_ci const vk::VkQueue queue, 397e5c31af7Sopenharmony_ci deUint32 queueFamilyIndex, 398e5c31af7Sopenharmony_ci Allocator& allocator, 399e5c31af7Sopenharmony_ci vk::VkImage image, 400e5c31af7Sopenharmony_ci vk::VkFormat format, 401e5c31af7Sopenharmony_ci float depthValue0, 402e5c31af7Sopenharmony_ci float depthValue1, 403e5c31af7Sopenharmony_ci deUint32 stencilValue0, 404e5c31af7Sopenharmony_ci deUint32 stencilValue1, 405e5c31af7Sopenharmony_ci deUint32 imageWidth, 406e5c31af7Sopenharmony_ci deUint32 imageHeight, 407e5c31af7Sopenharmony_ci deUint32 tileSize, 408e5c31af7Sopenharmony_ci vk::VkImageLayout oldLayout, 409e5c31af7Sopenharmony_ci vk::VkImageLayout newLayout, 410e5c31af7Sopenharmony_ci vk::VkPipelineStageFlags dstStageFlags); 411e5c31af7Sopenharmony_ci 412e5c31af7Sopenharmony_ci/*--------------------------------------------------------------------*//*! 413e5c31af7Sopenharmony_ci * Makes common image subresource structures with common defaults 414e5c31af7Sopenharmony_ci*//*--------------------------------------------------------------------*/ 415e5c31af7Sopenharmony_civk::VkImageSubresourceRange makeDefaultImageSubresourceRange(); 416e5c31af7Sopenharmony_ci 417e5c31af7Sopenharmony_civk::VkImageSubresourceLayers makeDefaultImageSubresourceLayers(); 418e5c31af7Sopenharmony_ci 419e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC 420e5c31af7Sopenharmony_ci/*--------------------------------------------------------------------*//*! 421e5c31af7Sopenharmony_ci * Checks if the physical device supports creation of the specified 422e5c31af7Sopenharmony_ci * image format. 423e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 424e5c31af7Sopenharmony_cibool checkSparseImageFormatSupport (const VkPhysicalDevice physicalDevice, 425e5c31af7Sopenharmony_ci const InstanceInterface& instance, 426e5c31af7Sopenharmony_ci const VkFormat format, 427e5c31af7Sopenharmony_ci const VkImageType imageType, 428e5c31af7Sopenharmony_ci const VkSampleCountFlagBits sampleCount, 429e5c31af7Sopenharmony_ci const VkImageUsageFlags usageFlags, 430e5c31af7Sopenharmony_ci const VkImageTiling imageTiling); 431e5c31af7Sopenharmony_ci 432e5c31af7Sopenharmony_cibool checkSparseImageFormatSupport (const vk::VkPhysicalDevice physicalDevice, 433e5c31af7Sopenharmony_ci const vk::InstanceInterface& instance, 434e5c31af7Sopenharmony_ci const vk::VkImageCreateInfo& imageCreateInfo); 435e5c31af7Sopenharmony_ci 436e5c31af7Sopenharmony_ci/*--------------------------------------------------------------------*//*! 437e5c31af7Sopenharmony_ci * Allocates memory for a sparse image and handles the memory binding. 438e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 439e5c31af7Sopenharmony_civoid allocateAndBindSparseImage (const vk::DeviceInterface& vk, 440e5c31af7Sopenharmony_ci vk::VkDevice device, 441e5c31af7Sopenharmony_ci const vk::VkPhysicalDevice physicalDevice, 442e5c31af7Sopenharmony_ci const vk::InstanceInterface& instance, 443e5c31af7Sopenharmony_ci const vk::VkImageCreateInfo& imageCreateInfo, 444e5c31af7Sopenharmony_ci const vk::VkSemaphore& signalSemaphore, 445e5c31af7Sopenharmony_ci vk::VkQueue queue, 446e5c31af7Sopenharmony_ci vk::Allocator& allocator, 447e5c31af7Sopenharmony_ci std::vector<de::SharedPtr<vk::Allocation> >& allocations, 448e5c31af7Sopenharmony_ci tcu::TextureFormat format, 449e5c31af7Sopenharmony_ci vk::VkImage destImage); 450e5c31af7Sopenharmony_ci#endif // CTS_USES_VULKANSC 451e5c31af7Sopenharmony_ci} // vk 452e5c31af7Sopenharmony_ci 453e5c31af7Sopenharmony_ci#endif // _VKIMAGEUTIL_HPP 454