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, const int levels = 1);
39 Texture (const Texture& other, const int samples);
40
type(void) const41 ImageType type (void) const { return m_type; } //!< Texture type
42 tcu::IVec3 layerSize (const int mipLevel = 0) const; //!< Size of a single layer for mipmap level 0
numLayers(void) const43 int numLayers (void) const { return m_numLayers; } //!< Number of array layers (for array and cube types)
numSamples(void) const44 int numSamples (void) const { return m_numSamples; } //!< Number of samples per texel (multisampled texture)
45
46 tcu::IVec3 size (const int mipLevel = 0) const; //!< Size including number of layers in additional dimension (e.g. z in 2d texture) for mipmap level 0
47 int dimension (void) const; //!< Coordinate dimension used for addressing (e.g. 3 (x,y,z) for 2d array)
48 int layerDimension (void) const; //!< Coordinate dimension used for addressing a single layer (e.g. 2 (x,y) for 2d array)
49
numMipmapLevels(void) const50 int numMipmapLevels (void) const { return m_numMipmapLevels; } //!< Number of levels of detail (mipmap texture)
51
52 private:
53 void checkInvariants (void) const;
54
55 const tcu::IVec3 m_layerSize;
56 const ImageType m_type;
57 const int m_numLayers;
58 const int m_numSamples;
59 const int m_numMipmapLevels;
60 };
61
isCube(const Texture & texture)62 inline bool isCube (const Texture& texture)
63 {
64 return texture.type() == IMAGE_TYPE_CUBE || texture.type() == IMAGE_TYPE_CUBE_ARRAY;
65 }
66
67 } // image
68 } // vkt
69
70 #endif // _VKTIMAGETEXTURE_HPP
71