1#ifndef _VKTPIPELINEMULTISAMPLETESTSUTIL_HPP 2#define _VKTPIPELINEMULTISAMPLETESTSUTIL_HPP 3/*------------------------------------------------------------------------ 4 * Vulkan Conformance Tests 5 * ------------------------ 6 * 7 * Copyright (c) 2016 The Khronos Group Inc. 8 * 9 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * you may not use this file except in compliance with the License. 11 * You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 * 21 *//*! 22 * \file vktPipelineMultisampleTestsUtil.hpp 23 * \brief Multisample Tests Utility Classes 24 *//*--------------------------------------------------------------------*/ 25 26#include "vkDefs.hpp" 27#include "vkMemUtil.hpp" 28#include "vkRef.hpp" 29#include "vkRefUtil.hpp" 30#include "vkPrograms.hpp" 31#include "vkTypeUtil.hpp" 32#include "vkImageUtil.hpp" 33#include "deSharedPtr.hpp" 34 35namespace vkt 36{ 37namespace pipeline 38{ 39namespace multisample 40{ 41 42enum ImageType 43{ 44 IMAGE_TYPE_1D = 0u, 45 IMAGE_TYPE_1D_ARRAY, 46 IMAGE_TYPE_2D, 47 IMAGE_TYPE_2D_ARRAY, 48 IMAGE_TYPE_3D, 49 IMAGE_TYPE_CUBE, 50 IMAGE_TYPE_CUBE_ARRAY, 51 IMAGE_TYPE_BUFFER, 52 53 IMAGE_TYPE_LAST 54}; 55 56// Image helper functions 57vk::VkImageType mapImageType (const ImageType imageType); 58vk::VkImageViewType mapImageViewType (const ImageType imageType); 59std::string getImageTypeName (const ImageType imageType); 60std::string getShaderImageType (const tcu::TextureFormat& format, const ImageType imageType); 61std::string getShaderImageDataType (const tcu::TextureFormat& format); 62std::string getShaderImageFormatQualifier (const tcu::TextureFormat& format); 63std::string getShaderImageCoordinates (const ImageType imageType, const std::string& x, const std::string& xy, const std::string& xyz); 64//!< Size used for addresing image in a compute shader 65tcu::UVec3 getShaderGridSize (const ImageType imageType, const tcu::UVec3& imageSize, const deUint32 mipLevel = 0); 66//!< Size of a single image layer 67tcu::UVec3 getLayerSize (const ImageType imageType, const tcu::UVec3& imageSize); 68//!< Number of array layers (for array and cube types) 69deUint32 getNumLayers (const ImageType imageType, const tcu::UVec3& imageSize); 70//!< Number of texels in an image 71deUint32 getNumPixels (const ImageType imageType, const tcu::UVec3& imageSize); 72//!< Coordinate dimension used for addressing (e.g. 3 (x,y,z) for 2d array) 73deUint32 getDimensions (const ImageType imageType); 74//!< Coordinate dimension used for addressing a single layer (e.g. 2 (x,y) for 2d array) 75deUint32 getLayerDimensions (const ImageType imageType); 76deUint32 getImageMipLevelSizeInBytes (const vk::VkExtent3D& baseExtents, const deUint32 layersCount, const tcu::TextureFormat& format, const deUint32 mipmapLevel, const deUint32 numSamples = 1u); 77deUint32 getImageSizeInBytes (const vk::VkExtent3D& baseExtents, const deUint32 layersCount, const tcu::TextureFormat& format, const deUint32 mipmapLevelsCount = 1u, const deUint32 numSamples = 1u); 78deUint32 getImageMaxMipLevels (const vk::VkImageFormatProperties& imageFormatProperties, const vk::VkExtent3D& extent); 79 80enum FeatureFlagBits 81{ 82 FEATURE_TESSELLATION_SHADER = 1u << 0, 83 FEATURE_GEOMETRY_SHADER = 1u << 1, 84 FEATURE_SHADER_FLOAT_64 = 1u << 2, 85 FEATURE_VERTEX_PIPELINE_STORES_AND_ATOMICS = 1u << 3, 86 FEATURE_FRAGMENT_STORES_AND_ATOMICS = 1u << 4, 87 FEATURE_SHADER_TESSELLATION_AND_GEOMETRY_POINT_SIZE = 1u << 5, 88}; 89typedef deUint32 FeatureFlags; 90 91void requireFeatures(const vk::InstanceInterface& instanceInterface, const vk::VkPhysicalDevice physicalDevice, const FeatureFlags flags); 92 93template<typename T> 94inline de::SharedPtr<vk::Unique<T> > makeVkSharedPtr(vk::Move<T> vkMove) 95{ 96 return de::SharedPtr<vk::Unique<T> >(new vk::Unique<T>(vkMove)); 97} 98 99template<typename T> 100inline std::size_t sizeInBytes(const std::vector<T>& vec) 101{ 102 return vec.size() * sizeof(vec[0]); 103} 104 105template<typename T> 106inline const T* dataPointer(const std::vector<T>& vec) 107{ 108 return (vec.size() != 0 ? &vec[0] : DE_NULL); 109} 110 111} // multisample 112} // pipeline 113} // vkt 114 115#endif // _VKTPIPELINEMULTISAMPLETESTSUTIL_HPP 116