blob: b3a43d8541c0c10ec4e9c2750a1ee003a63027ab [file] [log] [blame]
daniel@transgaming.com95a758f2012-07-12 15:17:06 +00001//
shannon.woods@transgaming.come2e97982013-02-28 23:18:50 +00002// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com95a758f2012-07-12 15:17:06 +00003// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7// Texture.h: Defines the abstract gl::Texture class and its concrete derived
8// classes Texture2D and TextureCubeMap. Implements GL texture objects and
9// related functionality. [OpenGL ES 2.0.24] section 3.7 page 63.
10
11#ifndef LIBGLESV2_TEXTURE_H_
12#define LIBGLESV2_TEXTURE_H_
13
14#include <vector>
15
16#define GL_APICALL
shannon.woods%transgaming.com@gtempaccount.comf26ddae2013-04-13 03:29:13 +000017#include <GLES3/gl3.h>
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000018#include <GLES2/gl2.h>
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000019
20#include "common/debug.h"
21#include "common/RefCountObject.h"
daniel@transgaming.com8bc304a2013-01-11 04:07:42 +000022#include "libGLESv2/angletypes.h"
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000023
24namespace egl
25{
26class Surface;
27}
28
daniel@transgaming.com370482e2012-11-28 19:32:13 +000029namespace rx
30{
31class Renderer;
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000032class TextureStorageInterface;
33class TextureStorageInterface2D;
34class TextureStorageInterfaceCube;
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +000035class TextureStorageInterface3D;
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +000036class TextureStorageInterface2DArray;
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000037class RenderTarget;
38class Image;
daniel@transgaming.com370482e2012-11-28 19:32:13 +000039}
40
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000041namespace gl
42{
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000043class Framebuffer;
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000044class Renderbuffer;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000045
46enum
47{
48 // These are the maximums the implementation can support
49 // The actual GL caps are limited by the device caps
50 // and should be queried from the Context
shannon.woods%transgaming.com@gtempaccount.comc1fdf6b2013-04-13 03:44:41 +000051 IMPLEMENTATION_MAX_2D_TEXTURE_SIZE = 16384,
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000052 IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE = 16384,
shannon.woods%transgaming.com@gtempaccount.comc1fdf6b2013-04-13 03:44:41 +000053 IMPLEMENTATION_MAX_3D_TEXTURE_SIZE = 2048,
shannon.woods%transgaming.com@gtempaccount.coma98a8112013-04-13 03:45:57 +000054 IMPLEMENTATION_MAX_2D_ARRAY_TEXTURE_LAYERS = 2048,
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000055
56 IMPLEMENTATION_MAX_TEXTURE_LEVELS = 15 // 1+log2 of MAX_TEXTURE_SIZE
57};
58
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000059class Texture : public RefCountObject
60{
61 public:
daniel@transgaming.com370482e2012-11-28 19:32:13 +000062 Texture(rx::Renderer *renderer, GLuint id);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000063
64 virtual ~Texture();
65
66 virtual void addProxyRef(const Renderbuffer *proxy) = 0;
67 virtual void releaseProxy(const Renderbuffer *proxy) = 0;
68
69 virtual GLenum getTarget() const = 0;
70
71 bool setMinFilter(GLenum filter);
72 bool setMagFilter(GLenum filter);
73 bool setWrapS(GLenum wrap);
74 bool setWrapT(GLenum wrap);
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +000075 bool setWrapR(GLenum wrap);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +000076 bool setMaxAnisotropy(float textureMaxAnisotropy, float contextMaxAnisotropy);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000077 bool setUsage(GLenum usage);
78
79 GLenum getMinFilter() const;
80 GLenum getMagFilter() const;
81 GLenum getWrapS() const;
82 GLenum getWrapT() const;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +000083 GLenum getWrapR() const;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +000084 float getMaxAnisotropy() const;
daniel@transgaming.comebf139f2012-10-31 18:07:32 +000085 int getLodOffset();
86 void getSamplerState(SamplerState *sampler);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000087 GLenum getUsage() const;
daniel@transgaming.comca9a3c82012-10-26 18:55:07 +000088 bool isMipmapFiltered() const;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +000089 virtual int levelCount() = 0;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000090
91 virtual bool isSamplerComplete() const = 0;
92
daniel@transgaming.com87705f82012-12-20 21:10:45 +000093 rx::TextureStorageInterface *getNativeTexture();
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000094 virtual Renderbuffer *getRenderbuffer(GLenum target) = 0;
95
96 virtual void generateMipmaps() = 0;
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +000097 virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source) = 0;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000098
99 bool hasDirtyParameters() const;
100 bool hasDirtyImages() const;
101 void resetDirty();
102 unsigned int getTextureSerial();
103 unsigned int getRenderTargetSerial(GLenum target);
104
105 bool isImmutable() const;
106
107 static const GLuint INCOMPLETE_TEXTURE_ID = static_cast<GLuint>(-1); // Every texture takes an id at creation time. The value is arbitrary because it is never registered with the resource manager.
108
109 protected:
shannonwoods@chromium.org557aab02013-05-30 00:08:27 +0000110 void setImage(GLint unpackAlignment, GLenum type, const void *pixels, rx::Image *image);
shannon.woods%transgaming.com@gtempaccount.com4760c562013-04-13 03:42:30 +0000111 bool subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
112 GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, rx::Image *image);
daniel@transgaming.com31b13e12012-11-28 19:34:30 +0000113 void setCompressedImage(GLsizei imageSize, const void *pixels, rx::Image *image);
shannon.woods%transgaming.com@gtempaccount.com4760c562013-04-13 03:42:30 +0000114 bool subImageCompressed(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
115 GLenum format, GLsizei imageSize, const void *pixels, rx::Image *image);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000116
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000117 GLint creationLevels(GLsizei width, GLsizei height, GLsizei depth) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000118 GLint creationLevels(GLsizei width, GLsizei height) const;
119 GLint creationLevels(GLsizei size) const;
120
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000121 virtual void createTexture() = 0;
122 virtual void updateTexture() = 0;
123 virtual void convertToRenderTarget() = 0;
daniel@transgaming.comd186dc72012-11-28 19:40:16 +0000124 virtual rx::RenderTarget *getRenderTarget(GLenum target) = 0;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000125
daniel@transgaming.com370482e2012-11-28 19:32:13 +0000126 rx::Renderer *mRenderer;
127
daniel@transgaming.comebf139f2012-10-31 18:07:32 +0000128 SamplerState mSamplerState;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000129 GLenum mUsage;
130
131 bool mDirtyImages;
132
133 bool mImmutable;
134
135 private:
136 DISALLOW_COPY_AND_ASSIGN(Texture);
137
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000138 virtual rx::TextureStorageInterface *getStorage(bool renderTarget) = 0;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000139};
140
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000141class Texture2D : public Texture
142{
143 public:
daniel@transgaming.com370482e2012-11-28 19:32:13 +0000144 Texture2D(rx::Renderer *renderer, GLuint id);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000145
146 ~Texture2D();
147
148 void addProxyRef(const Renderbuffer *proxy);
149 void releaseProxy(const Renderbuffer *proxy);
150
151 virtual GLenum getTarget() const;
152
153 GLsizei getWidth(GLint level) const;
154 GLsizei getHeight(GLint level) const;
155 GLenum getInternalFormat(GLint level) const;
daniel@transgaming.com20d36662012-10-31 19:51:43 +0000156 GLenum getActualFormat(GLint level) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000157 bool isCompressed(GLint level) const;
158 bool isDepth(GLint level) const;
159
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +0000160 void setImage(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000161 void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
162 void subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
163 void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
164 void copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000165 virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000166 void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
167
168 virtual bool isSamplerComplete() const;
169 virtual void bindTexImage(egl::Surface *surface);
170 virtual void releaseTexImage();
171
172 virtual void generateMipmaps();
173
174 virtual Renderbuffer *getRenderbuffer(GLenum target);
175
176 protected:
177 friend class RenderbufferTexture2D;
daniel@transgaming.comd186dc72012-11-28 19:40:16 +0000178 virtual rx::RenderTarget *getRenderTarget(GLenum target);
179 virtual rx::RenderTarget *getDepthStencil(GLenum target);
daniel@transgaming.com690d8ae2012-10-31 19:52:08 +0000180 virtual int levelCount();
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000181
182 private:
183 DISALLOW_COPY_AND_ASSIGN(Texture2D);
184
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000185 virtual void createTexture();
186 virtual void updateTexture();
187 virtual void convertToRenderTarget();
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000188 virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000189
190 bool isMipmapComplete() const;
191
shannon.woods@transgaming.come2e97982013-02-28 23:18:50 +0000192 void redefineImage(GLint level, GLint internalformat, GLsizei width, GLsizei height);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000193 void commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
194
daniel@transgaming.comd9ec9022012-12-20 20:52:16 +0000195 rx::Image *mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000196
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000197 rx::TextureStorageInterface2D *mTexStorage;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000198 egl::Surface *mSurface;
199
200 // A specific internal reference count is kept for colorbuffer proxy references,
201 // because, as the renderbuffer acting as proxy will maintain a binding pointer
202 // back to this texture, there would be a circular reference if we used a binding
203 // pointer here. This reference count will cause the pointer to be set to NULL if
204 // the count drops to zero, but will not cause deletion of the Renderbuffer.
205 Renderbuffer *mColorbufferProxy;
206 unsigned int mProxyRefs;
207};
208
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000209class TextureCubeMap : public Texture
210{
211 public:
daniel@transgaming.com370482e2012-11-28 19:32:13 +0000212 TextureCubeMap(rx::Renderer *renderer, GLuint id);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000213
214 ~TextureCubeMap();
215
216 void addProxyRef(const Renderbuffer *proxy);
217 void releaseProxy(const Renderbuffer *proxy);
218
219 virtual GLenum getTarget() const;
220
221 GLsizei getWidth(GLenum target, GLint level) const;
222 GLsizei getHeight(GLenum target, GLint level) const;
223 GLenum getInternalFormat(GLenum target, GLint level) const;
daniel@transgaming.com20d36662012-10-31 19:51:43 +0000224 GLenum getActualFormat(GLenum target, GLint level) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000225 bool isCompressed(GLenum target, GLint level) const;
226
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +0000227 void setImagePosX(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
228 void setImageNegX(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
229 void setImagePosY(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
230 void setImageNegY(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
231 void setImagePosZ(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
232 void setImageNegZ(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000233
234 void setCompressedImage(GLenum face, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
235
236 void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
237 void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
238 void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000239 virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000240 void storage(GLsizei levels, GLenum internalformat, GLsizei size);
241
242 virtual bool isSamplerComplete() const;
243
244 virtual void generateMipmaps();
245
246 virtual Renderbuffer *getRenderbuffer(GLenum target);
247
248 static unsigned int faceIndex(GLenum face);
249
250 protected:
251 friend class RenderbufferTextureCubeMap;
daniel@transgaming.comd186dc72012-11-28 19:40:16 +0000252 virtual rx::RenderTarget *getRenderTarget(GLenum target);
daniel@transgaming.com690d8ae2012-10-31 19:52:08 +0000253 virtual int levelCount();
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000254
255 private:
256 DISALLOW_COPY_AND_ASSIGN(TextureCubeMap);
257
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000258 virtual void createTexture();
259 virtual void updateTexture();
260 virtual void convertToRenderTarget();
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000261 virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000262
263 bool isCubeComplete() const;
264 bool isMipmapCubeComplete() const;
265
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +0000266 void setImage(int faceIndex, GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000267 void commitRect(int faceIndex, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
shannon.woods@transgaming.come2e97982013-02-28 23:18:50 +0000268 void redefineImage(int faceIndex, GLint level, GLint internalformat, GLsizei width, GLsizei height);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000269
daniel@transgaming.comd9ec9022012-12-20 20:52:16 +0000270 rx::Image *mImageArray[6][IMPLEMENTATION_MAX_TEXTURE_LEVELS];
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000271
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000272 rx::TextureStorageInterfaceCube *mTexStorage;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000273
274 // A specific internal reference count is kept for colorbuffer proxy references,
275 // because, as the renderbuffer acting as proxy will maintain a binding pointer
276 // back to this texture, there would be a circular reference if we used a binding
277 // pointer here. This reference count will cause the pointer to be set to NULL if
278 // the count drops to zero, but will not cause deletion of the Renderbuffer.
279 Renderbuffer *mFaceProxies[6];
280 unsigned int *mFaceProxyRefs[6];
281};
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000282
283class Texture3D : public Texture
284{
285 public:
286 Texture3D(rx::Renderer *renderer, GLuint id);
287
288 ~Texture3D();
289
290 void addProxyRef(const Renderbuffer *proxy);
291 void releaseProxy(const Renderbuffer *proxy);
292
293 virtual GLenum getTarget() const;
294
295 GLsizei getWidth(GLint level) const;
296 GLsizei getHeight(GLint level) const;
297 GLsizei getDepth(GLint level) const;
298 GLenum getInternalFormat(GLint level) const;
299 GLenum getActualFormat(GLint level) const;
300 bool isCompressed(GLint level) const;
301 bool isDepth(GLint level) const;
302
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +0000303 void setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000304 void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
305 void subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
306 void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
307 void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
308
309 virtual void generateMipmaps();
310 virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
311
312 virtual bool isSamplerComplete() const;
313 virtual bool isMipmapComplete() const;
314
315 virtual Renderbuffer *getRenderbuffer(GLenum target);
316
317 protected:
318 virtual int levelCount();
319
320 private:
321 DISALLOW_COPY_AND_ASSIGN(Texture3D);
322
323 virtual void createTexture();
324 virtual void updateTexture();
325 virtual void convertToRenderTarget();
326 virtual rx::RenderTarget *getRenderTarget(GLenum target);
327
328 virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
329
330 void redefineImage(GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth);
331 void commitRect(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);
332
333 rx::Image *mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
334
335 rx::TextureStorageInterface3D *mTexStorage;
336
337 // A specific internal reference count is kept for colorbuffer proxy references,
338 // because, as the renderbuffer acting as proxy will maintain a binding pointer
339 // back to this texture, there would be a circular reference if we used a binding
340 // pointer here. This reference count will cause the pointer to be set to NULL if
341 // the count drops to zero, but will not cause deletion of the Renderbuffer.
342 Renderbuffer *mColorbufferProxy;
343 unsigned int mProxyRefs;
344};
345
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000346class Texture2DArray : public Texture
347{
348 public:
349 Texture2DArray(rx::Renderer *renderer, GLuint id);
350
351 ~Texture2DArray();
352
353 void addProxyRef(const Renderbuffer *proxy);
354 void releaseProxy(const Renderbuffer *proxy);
355
356 virtual GLenum getTarget() const;
357
358 GLsizei getWidth(GLint level) const;
359 GLsizei getHeight(GLint level) const;
360 GLsizei getDepth(GLint level) const;
361 GLenum getInternalFormat(GLint level) const;
362 GLenum getActualFormat(GLint level) const;
363 bool isCompressed(GLint level) const;
364 bool isDepth(GLint level) const;
365
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +0000366 void setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000367 void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
368 void subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
369 void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
370 void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
371
372 virtual void generateMipmaps();
373 virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
374
375 virtual bool isSamplerComplete() const;
376 virtual bool isMipmapComplete() const;
377
378 virtual Renderbuffer *getRenderbuffer(GLenum target);
379
380 protected:
381 virtual int levelCount();
382
383 private:
384 DISALLOW_COPY_AND_ASSIGN(Texture2DArray);
385
386 virtual void createTexture();
387 virtual void updateTexture();
388 virtual void convertToRenderTarget();
389 virtual rx::RenderTarget *getRenderTarget(GLenum target);
390
391 virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
392
393 void redefineImage(GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth);
394 void commitRect(GLint level, GLint xoffset, GLint yoffset, GLint layerTarget, GLsizei width, GLsizei height);
395
396 // Storing images as an array of single depth textures since D3D11 treats each array level of a
397 // Texture2D object as a separate subresource. Each layer would have to be looped over
398 // to update all the texture layers since they cannot all be updated at once and it makes the most
399 // sense for the Image class to not have to worry about layer subresource as well as mip subresources.
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000400 GLsizei mLayerCounts[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
shannonwoods@chromium.org644f7662013-05-30 00:02:07 +0000401 rx::Image **mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000402
403 rx::TextureStorageInterface2DArray *mTexStorage;
404
405 // A specific internal reference count is kept for colorbuffer proxy references,
406 // because, as the renderbuffer acting as proxy will maintain a binding pointer
407 // back to this texture, there would be a circular reference if we used a binding
408 // pointer here. This reference count will cause the pointer to be set to NULL if
409 // the count drops to zero, but will not cause deletion of the Renderbuffer.
410 Renderbuffer *mColorbufferProxy;
411 unsigned int mProxyRefs;
412};
413
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000414}
415
jbauman@chromium.org68715282012-07-12 23:28:41 +0000416#endif // LIBGLESV2_TEXTURE_H_