1 #ifndef _GLUTEXTURE_HPP
2 #define _GLUTEXTURE_HPP
3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program OpenGL ES Utilities
5 * ------------------------------------------------
7 * Copyright 2014 The Android Open Source Project
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 * \brief Texture classes.
24 *//*--------------------------------------------------------------------*/
26 #include "gluDefs.hpp"
27 #include "tcuTexture.hpp"
28 #include "tcuCompressedTexture.hpp"
29 #include "tcuResource.hpp"
30 #include "gluRenderContext.hpp"
31 #include "gluContextInfo.hpp"
32 #include "deArrayBuffer.hpp"
40 /*--------------------------------------------------------------------*//*!
41 * \brief 1D Texture only supported on OpenGL
42 *//*--------------------------------------------------------------------*/
46 Texture1D (const RenderContext& context, deUint32 format, deUint32 dataType, int width);
47 Texture1D (const RenderContext& context, deUint32 internalFormat, int width);
50 tcu::Texture1D& getRefTexture (void) { return m_refTexture; }
51 const tcu::Texture1D& getRefTexture (void) const { return m_refTexture; }
52 deUint32 getGLTexture (void) const { return m_glTexture; }
57 Texture1D (const Texture1D& other); // Not allowed!
58 Texture1D& operator= (const Texture1D& other); // Not allowed!
60 const RenderContext& m_context;
61 deUint32 m_format; //!< Internal format.
62 tcu::Texture1D m_refTexture;
64 } DE_WARN_UNUSED_TYPE;
66 /*--------------------------------------------------------------------*//*!
68 *//*--------------------------------------------------------------------*/
72 Texture2D (const RenderContext& context, const ContextInfo& contextInfo, int numLevels, const tcu::CompressedTexture* levels, const tcu::TexDecompressionParams& decompressionParams = tcu::TexDecompressionParams());
73 Texture2D (const RenderContext& context, deUint32 format, deUint32 dataType, int width, int height);
74 Texture2D (const RenderContext& context, deUint32 internalFormat, int width, int height);
77 void upload (void); // Not supported on compressed textures.
79 tcu::Texture2D& getRefTexture (void) { return m_refTexture; }
80 const tcu::Texture2D& getRefTexture (void) const { return m_refTexture; }
81 deUint32 getGLTexture (void) const { return m_glTexture; }
83 static Texture2D* create (const RenderContext& context, const ContextInfo& contextInfo, const tcu::Archive& archive, int numLevels, const std::vector<std::string>& filenames);
84 static Texture2D* create (const RenderContext& context, const ContextInfo& contextInfo, const tcu::Archive& archive, int numLevels, const char* const* filenames);
85 static Texture2D* create (const RenderContext& context, const ContextInfo& contextInfo, const tcu::Archive& archive, const char* filename) { return create(context, contextInfo, archive, 1, &filename); }
88 Texture2D (const Texture2D& other); // Not allowed!
89 Texture2D& operator= (const Texture2D& other); // Not allowed!
91 void loadCompressed (int numLevels, const tcu::CompressedTexture* levels, const tcu::TexDecompressionParams& decompressionParams);
93 const RenderContext& m_context;
96 deUint32 m_format; //!< Internal format.
98 tcu::Texture2D m_refTexture;
100 } DE_WARN_UNUSED_TYPE;
102 /*--------------------------------------------------------------------*//*!
103 * \brief Cube Map Texture
104 *//*--------------------------------------------------------------------*/
108 // For compressed cubemap constructor and create() function input level pointers / filenames are expected
109 // to laid out to array in following order:
110 // { l0_neg_x, l0_pos_x, l0_neg_y, l0_pos_y, l0_neg_z, l0_pos_z, l1_neg_x, l1_pos_x, ... }
112 TextureCube (const RenderContext& context, const ContextInfo& contextInfo, int numLevels, const tcu::CompressedTexture* levels, const tcu::TexDecompressionParams& decompressionParams = tcu::TexDecompressionParams());
113 TextureCube (const RenderContext& context, deUint32 format, deUint32 dataType, int size);
114 TextureCube (const RenderContext& context, deUint32 internalFormat, int size);
117 void upload (void); // Not supported on compressed textures.
119 tcu::TextureCube& getRefTexture (void) { return m_refTexture; }
120 const tcu::TextureCube& getRefTexture (void) const { return m_refTexture; }
121 deUint32 getGLTexture (void) const { return m_glTexture; }
123 static TextureCube* create (const RenderContext& context, const ContextInfo& contextInfo, const tcu::Archive& archive, int numLevels, const std::vector<std::string>& filenames);
124 static TextureCube* create (const RenderContext& context, const ContextInfo& contextInfo, const tcu::Archive& archive, int numLevels, const char* const* filenames);
127 TextureCube (const TextureCube& other); // Not allowed!
128 TextureCube& operator= (const TextureCube& other); // Not allowed!
130 void loadCompressed (int numLevels, const tcu::CompressedTexture* levels, const tcu::TexDecompressionParams& decompressionParams);
132 const RenderContext& m_context;
135 deUint32 m_format; //!< Internal format.
137 tcu::TextureCube m_refTexture;
138 deUint32 m_glTexture;
139 } DE_WARN_UNUSED_TYPE;
141 /*--------------------------------------------------------------------*//*!
142 * \brief 2D Array Texture
143 * \note Not supported on OpenGL ES 2
144 *//*--------------------------------------------------------------------*/
148 Texture2DArray (const RenderContext& context, deUint32 format, deUint32 dataType, int width, int height, int numLayers);
149 Texture2DArray (const RenderContext& context, deUint32 internalFormat, int width, int height, int numLayers);
150 Texture2DArray (const RenderContext& context, const ContextInfo& contextInfo, int numLevels, const tcu::CompressedTexture* levels, const tcu::TexDecompressionParams& decompressionParams = tcu::TexDecompressionParams());
151 ~Texture2DArray (void);
155 tcu::Texture2DArray& getRefTexture (void) { return m_refTexture; }
156 const tcu::Texture2DArray& getRefTexture (void) const { return m_refTexture; }
157 deUint32 getGLTexture (void) const { return m_glTexture; }
160 Texture2DArray (const Texture2DArray& other); // Not allowed!
161 Texture2DArray& operator= (const Texture2DArray& other); // Not allowed!
163 void loadCompressed (int numLevels, const tcu::CompressedTexture* levels, const tcu::TexDecompressionParams& decompressionParams);
166 const RenderContext& m_context;
169 deUint32 m_format; //!< Internal format.
171 tcu::Texture2DArray m_refTexture;
172 deUint32 m_glTexture;
173 } DE_WARN_UNUSED_TYPE;
175 /*--------------------------------------------------------------------*//*!
176 * \brief 1D Array Texture
177 * \note Only supported on OpenGL
178 *//*--------------------------------------------------------------------*/
182 Texture1DArray (const RenderContext& context, deUint32 format, deUint32 dataType, int width, int numLayers);
183 Texture1DArray (const RenderContext& context, deUint32 internalFormat, int width, int numLayers);
184 ~Texture1DArray (void);
188 tcu::Texture1DArray& getRefTexture (void) { return m_refTexture; }
189 const tcu::Texture1DArray& getRefTexture (void) const { return m_refTexture; }
190 deUint32 getGLTexture (void) const { return m_glTexture; }
193 Texture1DArray (const Texture1DArray& other); // Not allowed!
194 Texture1DArray& operator= (const Texture1DArray& other); // Not allowed!
196 const RenderContext& m_context;
198 deUint32 m_format; //!< Internal format.
200 tcu::Texture1DArray m_refTexture;
201 deUint32 m_glTexture;
202 } DE_WARN_UNUSED_TYPE;
204 /*--------------------------------------------------------------------*//*!
206 * \note Not supported on OpenGL ES 2
207 *//*--------------------------------------------------------------------*/
211 Texture3D (const RenderContext& context, deUint32 format, deUint32 dataType, int width, int height, int depth);
212 Texture3D (const RenderContext& context, deUint32 internalFormat, int width, int height, int depth);
213 Texture3D (const RenderContext& context, const ContextInfo& contextInfo, int numLevels, const tcu::CompressedTexture* levels, const tcu::TexDecompressionParams& decompressionParams = tcu::TexDecompressionParams());
218 tcu::Texture3D& getRefTexture (void) { return m_refTexture; }
219 const tcu::Texture3D& getRefTexture (void) const { return m_refTexture; }
220 deUint32 getGLTexture (void) const { return m_glTexture; }
223 Texture3D (const Texture3D& other); // Not allowed!
224 Texture3D& operator= (const Texture3D& other); // Not allowed!
226 void loadCompressed (int numLevels, const tcu::CompressedTexture* levels, const tcu::TexDecompressionParams& decompressionParams);
228 const RenderContext& m_context;
231 deUint32 m_format; //!< Internal format.
233 tcu::Texture3D m_refTexture;
234 deUint32 m_glTexture;
235 } DE_WARN_UNUSED_TYPE;
237 /*--------------------------------------------------------------------*//*!
238 * \brief Cube Map Array Texture
239 * \note Not supported on OpenGL ES 3.0 or lower
240 *//*--------------------------------------------------------------------*/
241 class TextureCubeArray
244 TextureCubeArray (const RenderContext& context, deUint32 format, deUint32 dataType, int size, int numLayers);
245 TextureCubeArray (const RenderContext& context, deUint32 internalFormat, int size, int numLayers);
247 ~TextureCubeArray (void);
251 tcu::TextureCubeArray& getRefTexture (void) { return m_refTexture; }
252 const tcu::TextureCubeArray& getRefTexture (void) const { return m_refTexture; }
253 deUint32 getGLTexture (void) const { return m_glTexture; }
256 TextureCubeArray (const TextureCubeArray& other); // Not allowed!
257 TextureCubeArray& operator= (const TextureCubeArray& other); // Not allowed!
259 const RenderContext& m_context;
262 deUint32 m_format; //!< Internal format.
264 tcu::TextureCubeArray m_refTexture;
265 deUint32 m_glTexture;
266 } DE_WARN_UNUSED_TYPE;
268 /*--------------------------------------------------------------------*//*!
269 * \brief 1D Texture Buffer only supported on OpenGL
270 *//*--------------------------------------------------------------------*/
274 TextureBuffer (const RenderContext& context, deUint32 internalFormat, size_t bufferSize);
275 TextureBuffer (const RenderContext& context, deUint32 internalFormat, size_t bufferSize, size_t offset, size_t size, const void* data = DE_NULL);
277 ~TextureBuffer (void);
279 // \note Effective pixel buffer access must be limited to w <= GL_MAX_TEXTURE_BUFFER_SIZE
280 const tcu::PixelBufferAccess getFullRefTexture (void);
281 const tcu::ConstPixelBufferAccess getFullRefTexture (void) const;
283 // \note mutating buffer storage will invalidate existing pixel buffer accesses
284 de::ArrayBuffer<deUint8>& getRefBuffer (void) { return m_refBuffer; }
285 const de::ArrayBuffer<deUint8>& getRefBuffer (void) const { return m_refBuffer; }
287 size_t getSize (void) const { return m_size; }
288 size_t getOffset (void) const { return m_offset; }
289 size_t getBufferSize (void) const { return m_refBuffer.size(); }
291 deUint32 getGLTexture (void) const { return m_glTexture; }
292 deUint32 getGLBuffer (void) const { return m_glBuffer; }
297 void init (deUint32 internalFormat, size_t bufferSize, size_t offset, size_t size, const void* data);
298 TextureBuffer (const TextureBuffer& other); // Not allowed!
299 TextureBuffer& operator= (const TextureBuffer& other); // Not allowed!
301 const RenderContext& m_context;
302 deUint32 m_format; //!< Internal format.
303 de::ArrayBuffer<deUint8> m_refBuffer;
307 deUint32 m_glTexture;
309 } DE_WARN_UNUSED_TYPE;
313 #endif // _GLUTEXTURE_HPP