Home | History | Annotate | Download | only in pipeline
      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 
     35 namespace vkt
     36 {
     37 namespace pipeline
     38 {
     39 namespace multisample
     40 {
     41 
     42 enum 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
     57 vk::VkImageType		mapImageType					(const ImageType imageType);
     58 vk::VkImageViewType	mapImageViewType				(const ImageType imageType);
     59 std::string			getImageTypeName				(const ImageType imageType);
     60 std::string			getShaderImageType				(const tcu::TextureFormat& format, const ImageType imageType);
     61 std::string			getShaderImageDataType			(const tcu::TextureFormat& format);
     62 std::string			getShaderImageFormatQualifier	(const tcu::TextureFormat& format);
     63 std::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
     65 tcu::UVec3			getShaderGridSize				(const ImageType imageType, const tcu::UVec3& imageSize, const deUint32	mipLevel = 0);
     66 //!< Size of a single image layer
     67 tcu::UVec3			getLayerSize					(const ImageType imageType, const tcu::UVec3& imageSize);
     68 //!< Number of array layers (for array and cube types)
     69 deUint32			getNumLayers					(const ImageType imageType, const tcu::UVec3& imageSize);
     70 //!< Number of texels in an image
     71 deUint32			getNumPixels					(const ImageType imageType, const tcu::UVec3& imageSize);
     72 //!< Coordinate dimension used for addressing (e.g. 3 (x,y,z) for 2d array)
     73 deUint32			getDimensions					(const ImageType imageType);
     74 //!< Coordinate dimension used for addressing a single layer (e.g. 2 (x,y) for 2d array)
     75 deUint32			getLayerDimensions				(const ImageType imageType);
     76 vk::VkExtent3D		mipLevelExtents					(const vk::VkExtent3D& baseExtents, const deUint32 mipLevel);
     77 tcu::UVec3			mipLevelExtents					(const tcu::UVec3&	   baseExtents, const deUint32 mipLevel);
     78 deUint32			getImageMipLevelSizeInBytes		(const vk::VkExtent3D& baseExtents, const deUint32 layersCount, const tcu::TextureFormat& format, const deUint32 mipmapLevel);
     79 deUint32			getImageSizeInBytes				(const vk::VkExtent3D& baseExtents, const deUint32 layersCount, const tcu::TextureFormat& format, const deUint32 mipmapLevelsCount = 1u);
     80 deUint32			getImageMaxMipLevels			(const vk::VkImageFormatProperties& imageFormatProperties, const vk::VkExtent3D& extent);
     81 
     82 enum FeatureFlagBits
     83 {
     84 	FEATURE_TESSELLATION_SHADER = 1u << 0,
     85 	FEATURE_GEOMETRY_SHADER = 1u << 1,
     86 	FEATURE_SHADER_FLOAT_64 = 1u << 2,
     87 	FEATURE_VERTEX_PIPELINE_STORES_AND_ATOMICS = 1u << 3,
     88 	FEATURE_FRAGMENT_STORES_AND_ATOMICS = 1u << 4,
     89 	FEATURE_SHADER_TESSELLATION_AND_GEOMETRY_POINT_SIZE = 1u << 5,
     90 };
     91 typedef deUint32 FeatureFlags;
     92 
     93 void requireFeatures(const vk::InstanceInterface& instanceInterface, const vk::VkPhysicalDevice physicalDevice, const FeatureFlags flags);
     94 
     95 template<typename T>
     96 inline de::SharedPtr<vk::Unique<T> > makeVkSharedPtr(vk::Move<T> vkMove)
     97 {
     98 	return de::SharedPtr<vk::Unique<T> >(new vk::Unique<T>(vkMove));
     99 }
    100 
    101 template<typename T>
    102 inline std::size_t sizeInBytes(const std::vector<T>& vec)
    103 {
    104 	return vec.size() * sizeof(vec[0]);
    105 }
    106 
    107 template<typename T>
    108 inline const T* dataPointer(const std::vector<T>& vec)
    109 {
    110 	return (vec.size() != 0 ? &vec[0] : DE_NULL);
    111 }
    112 
    113 } // multisample
    114 } // pipeline
    115 } // vkt
    116 
    117 #endif // _VKTPIPELINEMULTISAMPLETESTSUTIL_HPP
    118