1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2016 The Khronos Group Inc.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief Texture utility class
22 *//*--------------------------------------------------------------------*/
24 #include "vktImageTexture.hpp"
31 void Texture::checkInvariants (void) const
33 DE_ASSERT((m_numSamples == 1) || (m_numSamples == 2) || (m_numSamples == 4) || (m_numSamples == 8) ||
34 (m_numSamples == 16) || (m_numSamples == 32) || (m_numSamples == 64));
35 DE_ASSERT(m_numLayers >= 1);
36 DE_ASSERT(m_layerSize.x() >= 1 && m_layerSize.y() >= 1 && m_layerSize.z() >= 1);
41 case IMAGE_TYPE_BUFFER:
42 DE_ASSERT(m_numLayers == 1);
43 DE_ASSERT(m_numSamples == 1);
44 DE_ASSERT(m_layerSize.y() == 1 && m_layerSize.z() == 1);
47 case IMAGE_TYPE_1D_ARRAY:
48 DE_ASSERT(m_numSamples == 1);
49 DE_ASSERT(m_layerSize.y() == 1 && m_layerSize.z() == 1);
53 DE_ASSERT(m_numLayers == 1);
54 DE_ASSERT(m_layerSize.z() == 1);
57 case IMAGE_TYPE_2D_ARRAY:
58 DE_ASSERT(m_layerSize.z() == 1);
62 DE_ASSERT(m_numSamples == 1);
63 DE_ASSERT(m_numLayers == 6);
64 DE_ASSERT(m_layerSize.z() == 1);
67 case IMAGE_TYPE_CUBE_ARRAY:
68 DE_ASSERT(m_numSamples == 1);
69 DE_ASSERT(m_numLayers >= 6 && m_numLayers % 6 == 0);
70 DE_ASSERT(m_layerSize.z() == 1);
74 DE_ASSERT(m_numSamples == 1);
75 DE_ASSERT(m_numLayers == 1);
79 DE_FATAL("Internal error");
84 Texture::Texture (const ImageType imageType, const tcu::IVec3& imageLayerSize, const int layers, const int samples)
85 : m_layerSize (imageLayerSize)
87 , m_numLayers (layers)
88 , m_numSamples (samples)
93 Texture::Texture (const Texture& other, const int samples)
94 : m_layerSize (other.m_layerSize)
95 , m_type (other.m_type)
96 , m_numLayers (other.m_numLayers)
97 , m_numSamples (samples)
102 tcu::IVec3 Texture::size (void) const
107 case IMAGE_TYPE_BUFFER:
112 case IMAGE_TYPE_1D_ARRAY:
113 return tcu::IVec3(m_layerSize.x(), m_numLayers, 1);
115 case IMAGE_TYPE_2D_ARRAY:
116 case IMAGE_TYPE_CUBE:
117 case IMAGE_TYPE_CUBE_ARRAY:
118 return tcu::IVec3(m_layerSize.x(), m_layerSize.y(), m_numLayers);
121 DE_FATAL("Internal error");
126 int Texture::dimension (void) const
131 case IMAGE_TYPE_BUFFER:
134 case IMAGE_TYPE_1D_ARRAY:
138 case IMAGE_TYPE_2D_ARRAY:
139 case IMAGE_TYPE_CUBE:
140 case IMAGE_TYPE_CUBE_ARRAY:
145 DE_FATAL("Internal error");
150 int Texture::layerDimension (void) const
155 case IMAGE_TYPE_BUFFER:
156 case IMAGE_TYPE_1D_ARRAY:
160 case IMAGE_TYPE_2D_ARRAY:
161 case IMAGE_TYPE_CUBE:
162 case IMAGE_TYPE_CUBE_ARRAY:
169 DE_FATAL("Internal error");