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