Merge "Use safe glFramebufferTexture* function" am: ec5ccbe144
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / image / vktImageTexture.hpp
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 and number of layers.
35 class Texture
36 {
37 public:
38                                                 Texture                 (const ImageType imageType, const tcu::IVec3& imageLayerSize, const int layers, const int samples = 1);
39                                                 Texture                 (const Texture& other, const int samples);
40
41         ImageType                       type                    (void) const { return m_type; }                 //!< Texture type
42         tcu::IVec3                      layerSize               (void) const { return m_layerSize; }    //!< Size of a single layer
43         int                                     numLayers               (void) const { return m_numLayers; }    //!< Number of array layers (for array and cube types)
44         int                                     numSamples              (void) const { return m_numSamples; }   //!< Number of samples per texel (multisampled texture)
45
46         tcu::IVec3                      size                    (void) const;   //!< Size including number of layers in additional dimension (e.g. z in 2d texture)
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
50 private:
51         void                            checkInvariants (void) const;
52
53         const tcu::IVec3        m_layerSize;
54         const ImageType         m_type;
55         const int                       m_numLayers;
56         const int                       m_numSamples;
57 };
58
59 inline bool isCube (const Texture& texture)
60 {
61         return texture.type() == IMAGE_TYPE_CUBE || texture.type() == IMAGE_TYPE_CUBE_ARRAY;
62 }
63
64 } // image
65 } // vkt
66
67 #endif // _VKTIMAGETEXTURE_HPP