xref: /aosp_15_r20/external/deqp/external/vulkancts/modules/vulkan/image/vktImageTexture.hpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 #ifndef _VKTIMAGETEXTURE_HPP
2 #define _VKTIMAGETEXTURE_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
23  * \brief Texture utility class
24  *//*--------------------------------------------------------------------*/
25 
26 #include "tcuDefs.hpp"
27 #include "vktImageTestsUtil.hpp"
28 
29 namespace vkt
30 {
31 namespace image
32 {
33 
34 //! Texture buffer/image abstraction. Helps managing size, number of layers and number of mipmap levels.
35 class Texture
36 {
37 public:
38     Texture(const ImageType imageType, const tcu::IVec3 &imageLayerSize, const int layers, const int samples = 1,
39             const int levels = 1);
40     Texture(const Texture &other, const int samples);
41 
type(void) const42     ImageType type(void) const
43     {
44         return m_type;
45     }                                                   //!< Texture type
46     tcu::IVec3 layerSize(const int mipLevel = 0) const; //!< Size of a single layer for mipmap level 0
numLayers(void) const47     int numLayers(void) const
48     {
49         return m_numLayers;
50     } //!< Number of array layers (for array and cube types)
numSamples(void) const51     int numSamples(void) const
52     {
53         return m_numSamples;
54     } //!< Number of samples per texel (multisampled texture)
55 
56     tcu::IVec3 size(const int mipLevel = 0)
57         const; //!< Size including number of layers in additional dimension (e.g. z in 2d texture) for mipmap level 0
58     int dimension(void) const; //!< Coordinate dimension used for addressing (e.g. 3 (x,y,z) for 2d array)
59     int layerDimension(
60         void) const; //!< Coordinate dimension used for addressing a single layer (e.g. 2 (x,y) for 2d array)
61 
numMipmapLevels(void) const62     int numMipmapLevels(void) const
63     {
64         return m_numMipmapLevels;
65     } //!< Number of levels of detail (mipmap texture)
66 
67 private:
68     void checkInvariants(void) const;
69 
70     const tcu::IVec3 m_layerSize;
71     const ImageType m_type;
72     const int m_numLayers;
73     const int m_numSamples;
74     const int m_numMipmapLevels;
75 };
76 
isCube(const Texture & texture)77 inline bool isCube(const Texture &texture)
78 {
79     return texture.type() == IMAGE_TYPE_CUBE || texture.type() == IMAGE_TYPE_CUBE_ARRAY;
80 }
81 
82 } // namespace image
83 } // namespace vkt
84 
85 #endif // _VKTIMAGETEXTURE_HPP
86