blob: 28ce1515b740184025fe3dc1d8bcf94d27b3baa1 [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);
Geoff Langc82fc412013-07-10 14:43:42 -040077 bool setCompareMode(GLenum mode);
78 bool setCompareFunc(GLenum func);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000079 bool setUsage(GLenum usage);
80
81 GLenum getMinFilter() const;
82 GLenum getMagFilter() const;
83 GLenum getWrapS() const;
84 GLenum getWrapT() const;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +000085 GLenum getWrapR() const;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +000086 float getMaxAnisotropy() const;
daniel@transgaming.comebf139f2012-10-31 18:07:32 +000087 int getLodOffset();
88 void getSamplerState(SamplerState *sampler);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000089 GLenum getUsage() const;
daniel@transgaming.comca9a3c82012-10-26 18:55:07 +000090 bool isMipmapFiltered() const;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +000091 virtual int levelCount() = 0;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000092
93 virtual bool isSamplerComplete() const = 0;
94
daniel@transgaming.com87705f82012-12-20 21:10:45 +000095 rx::TextureStorageInterface *getNativeTexture();
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000096 virtual Renderbuffer *getRenderbuffer(GLenum target) = 0;
97
98 virtual void generateMipmaps() = 0;
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +000099 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 +0000100
101 bool hasDirtyParameters() const;
102 bool hasDirtyImages() const;
103 void resetDirty();
104 unsigned int getTextureSerial();
105 unsigned int getRenderTargetSerial(GLenum target);
106
107 bool isImmutable() const;
108
109 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.
110
111 protected:
shannonwoods@chromium.org557aab02013-05-30 00:08:27 +0000112 void setImage(GLint unpackAlignment, GLenum type, const void *pixels, rx::Image *image);
shannon.woods%transgaming.com@gtempaccount.com4760c562013-04-13 03:42:30 +0000113 bool subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
114 GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, rx::Image *image);
daniel@transgaming.com31b13e12012-11-28 19:34:30 +0000115 void setCompressedImage(GLsizei imageSize, const void *pixels, rx::Image *image);
shannon.woods%transgaming.com@gtempaccount.com4760c562013-04-13 03:42:30 +0000116 bool subImageCompressed(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
117 GLenum format, GLsizei imageSize, const void *pixels, rx::Image *image);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000118
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000119 GLint creationLevels(GLsizei width, GLsizei height, GLsizei depth) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000120 GLint creationLevels(GLsizei width, GLsizei height) const;
121 GLint creationLevels(GLsizei size) const;
122
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000123 virtual void createTexture() = 0;
124 virtual void updateTexture() = 0;
125 virtual void convertToRenderTarget() = 0;
daniel@transgaming.comd186dc72012-11-28 19:40:16 +0000126 virtual rx::RenderTarget *getRenderTarget(GLenum target) = 0;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000127
daniel@transgaming.com370482e2012-11-28 19:32:13 +0000128 rx::Renderer *mRenderer;
129
daniel@transgaming.comebf139f2012-10-31 18:07:32 +0000130 SamplerState mSamplerState;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000131 GLenum mUsage;
132
133 bool mDirtyImages;
134
135 bool mImmutable;
136
137 private:
138 DISALLOW_COPY_AND_ASSIGN(Texture);
139
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000140 virtual rx::TextureStorageInterface *getStorage(bool renderTarget) = 0;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000141};
142
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000143class Texture2D : public Texture
144{
145 public:
daniel@transgaming.com370482e2012-11-28 19:32:13 +0000146 Texture2D(rx::Renderer *renderer, GLuint id);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000147
148 ~Texture2D();
149
150 void addProxyRef(const Renderbuffer *proxy);
151 void releaseProxy(const Renderbuffer *proxy);
152
153 virtual GLenum getTarget() const;
154
155 GLsizei getWidth(GLint level) const;
156 GLsizei getHeight(GLint level) const;
157 GLenum getInternalFormat(GLint level) const;
daniel@transgaming.com20d36662012-10-31 19:51:43 +0000158 GLenum getActualFormat(GLint level) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000159 bool isCompressed(GLint level) const;
160 bool isDepth(GLint level) const;
161
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +0000162 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 +0000163 void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
164 void subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
165 void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
166 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 +0000167 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 +0000168 void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
169
170 virtual bool isSamplerComplete() const;
171 virtual void bindTexImage(egl::Surface *surface);
172 virtual void releaseTexImage();
173
174 virtual void generateMipmaps();
175
176 virtual Renderbuffer *getRenderbuffer(GLenum target);
177
178 protected:
179 friend class RenderbufferTexture2D;
daniel@transgaming.comd186dc72012-11-28 19:40:16 +0000180 virtual rx::RenderTarget *getRenderTarget(GLenum target);
181 virtual rx::RenderTarget *getDepthStencil(GLenum target);
daniel@transgaming.com690d8ae2012-10-31 19:52:08 +0000182 virtual int levelCount();
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000183
184 private:
185 DISALLOW_COPY_AND_ASSIGN(Texture2D);
186
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000187 virtual void createTexture();
188 virtual void updateTexture();
189 virtual void convertToRenderTarget();
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000190 virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000191
192 bool isMipmapComplete() const;
193
shannon.woods@transgaming.come2e97982013-02-28 23:18:50 +0000194 void redefineImage(GLint level, GLint internalformat, GLsizei width, GLsizei height);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000195 void commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
196
daniel@transgaming.comd9ec9022012-12-20 20:52:16 +0000197 rx::Image *mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000198
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000199 rx::TextureStorageInterface2D *mTexStorage;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000200 egl::Surface *mSurface;
201
202 // A specific internal reference count is kept for colorbuffer proxy references,
203 // because, as the renderbuffer acting as proxy will maintain a binding pointer
204 // back to this texture, there would be a circular reference if we used a binding
205 // pointer here. This reference count will cause the pointer to be set to NULL if
206 // the count drops to zero, but will not cause deletion of the Renderbuffer.
207 Renderbuffer *mColorbufferProxy;
208 unsigned int mProxyRefs;
209};
210
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000211class TextureCubeMap : public Texture
212{
213 public:
daniel@transgaming.com370482e2012-11-28 19:32:13 +0000214 TextureCubeMap(rx::Renderer *renderer, GLuint id);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000215
216 ~TextureCubeMap();
217
218 void addProxyRef(const Renderbuffer *proxy);
219 void releaseProxy(const Renderbuffer *proxy);
220
221 virtual GLenum getTarget() const;
222
223 GLsizei getWidth(GLenum target, GLint level) const;
224 GLsizei getHeight(GLenum target, GLint level) const;
225 GLenum getInternalFormat(GLenum target, GLint level) const;
daniel@transgaming.com20d36662012-10-31 19:51:43 +0000226 GLenum getActualFormat(GLenum target, GLint level) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000227 bool isCompressed(GLenum target, GLint level) const;
228
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +0000229 void setImagePosX(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
230 void setImageNegX(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
231 void setImagePosY(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
232 void setImageNegY(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
233 void setImagePosZ(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
234 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 +0000235
236 void setCompressedImage(GLenum face, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
237
238 void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
239 void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
240 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 +0000241 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 +0000242 void storage(GLsizei levels, GLenum internalformat, GLsizei size);
243
244 virtual bool isSamplerComplete() const;
245
246 virtual void generateMipmaps();
247
248 virtual Renderbuffer *getRenderbuffer(GLenum target);
249
250 static unsigned int faceIndex(GLenum face);
251
252 protected:
253 friend class RenderbufferTextureCubeMap;
daniel@transgaming.comd186dc72012-11-28 19:40:16 +0000254 virtual rx::RenderTarget *getRenderTarget(GLenum target);
daniel@transgaming.com690d8ae2012-10-31 19:52:08 +0000255 virtual int levelCount();
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000256
257 private:
258 DISALLOW_COPY_AND_ASSIGN(TextureCubeMap);
259
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000260 virtual void createTexture();
261 virtual void updateTexture();
262 virtual void convertToRenderTarget();
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000263 virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000264
265 bool isCubeComplete() const;
266 bool isMipmapCubeComplete() const;
267
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +0000268 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 +0000269 void commitRect(int faceIndex, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
shannon.woods@transgaming.come2e97982013-02-28 23:18:50 +0000270 void redefineImage(int faceIndex, GLint level, GLint internalformat, GLsizei width, GLsizei height);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000271
daniel@transgaming.comd9ec9022012-12-20 20:52:16 +0000272 rx::Image *mImageArray[6][IMPLEMENTATION_MAX_TEXTURE_LEVELS];
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000273
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000274 rx::TextureStorageInterfaceCube *mTexStorage;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000275
276 // A specific internal reference count is kept for colorbuffer proxy references,
277 // because, as the renderbuffer acting as proxy will maintain a binding pointer
278 // back to this texture, there would be a circular reference if we used a binding
279 // pointer here. This reference count will cause the pointer to be set to NULL if
280 // the count drops to zero, but will not cause deletion of the Renderbuffer.
281 Renderbuffer *mFaceProxies[6];
282 unsigned int *mFaceProxyRefs[6];
283};
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000284
285class Texture3D : public Texture
286{
287 public:
288 Texture3D(rx::Renderer *renderer, GLuint id);
289
290 ~Texture3D();
291
292 void addProxyRef(const Renderbuffer *proxy);
293 void releaseProxy(const Renderbuffer *proxy);
294
295 virtual GLenum getTarget() const;
296
297 GLsizei getWidth(GLint level) const;
298 GLsizei getHeight(GLint level) const;
299 GLsizei getDepth(GLint level) const;
300 GLenum getInternalFormat(GLint level) const;
301 GLenum getActualFormat(GLint level) const;
302 bool isCompressed(GLint level) const;
303 bool isDepth(GLint level) const;
304
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +0000305 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 +0000306 void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
307 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);
308 void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
309 void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
310
311 virtual void generateMipmaps();
312 virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
313
314 virtual bool isSamplerComplete() const;
315 virtual bool isMipmapComplete() const;
316
317 virtual Renderbuffer *getRenderbuffer(GLenum target);
318
319 protected:
320 virtual int levelCount();
321
322 private:
323 DISALLOW_COPY_AND_ASSIGN(Texture3D);
324
325 virtual void createTexture();
326 virtual void updateTexture();
327 virtual void convertToRenderTarget();
328 virtual rx::RenderTarget *getRenderTarget(GLenum target);
329
330 virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
331
332 void redefineImage(GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth);
333 void commitRect(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);
334
335 rx::Image *mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
336
337 rx::TextureStorageInterface3D *mTexStorage;
338
339 // A specific internal reference count is kept for colorbuffer proxy references,
340 // because, as the renderbuffer acting as proxy will maintain a binding pointer
341 // back to this texture, there would be a circular reference if we used a binding
342 // pointer here. This reference count will cause the pointer to be set to NULL if
343 // the count drops to zero, but will not cause deletion of the Renderbuffer.
344 Renderbuffer *mColorbufferProxy;
345 unsigned int mProxyRefs;
346};
347
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000348class Texture2DArray : public Texture
349{
350 public:
351 Texture2DArray(rx::Renderer *renderer, GLuint id);
352
353 ~Texture2DArray();
354
355 void addProxyRef(const Renderbuffer *proxy);
356 void releaseProxy(const Renderbuffer *proxy);
357
358 virtual GLenum getTarget() const;
359
360 GLsizei getWidth(GLint level) const;
361 GLsizei getHeight(GLint level) const;
362 GLsizei getDepth(GLint level) const;
363 GLenum getInternalFormat(GLint level) const;
364 GLenum getActualFormat(GLint level) const;
365 bool isCompressed(GLint level) const;
366 bool isDepth(GLint level) const;
367
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +0000368 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 +0000369 void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
370 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);
371 void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
372 void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
373
374 virtual void generateMipmaps();
375 virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
376
377 virtual bool isSamplerComplete() const;
378 virtual bool isMipmapComplete() const;
379
380 virtual Renderbuffer *getRenderbuffer(GLenum target);
381
382 protected:
383 virtual int levelCount();
384
385 private:
386 DISALLOW_COPY_AND_ASSIGN(Texture2DArray);
387
388 virtual void createTexture();
389 virtual void updateTexture();
390 virtual void convertToRenderTarget();
391 virtual rx::RenderTarget *getRenderTarget(GLenum target);
392
393 virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
394
395 void redefineImage(GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth);
396 void commitRect(GLint level, GLint xoffset, GLint yoffset, GLint layerTarget, GLsizei width, GLsizei height);
397
398 // Storing images as an array of single depth textures since D3D11 treats each array level of a
399 // Texture2D object as a separate subresource. Each layer would have to be looped over
400 // to update all the texture layers since they cannot all be updated at once and it makes the most
401 // 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 +0000402 GLsizei mLayerCounts[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
shannonwoods@chromium.org644f7662013-05-30 00:02:07 +0000403 rx::Image **mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000404
405 rx::TextureStorageInterface2DArray *mTexStorage;
406
407 // A specific internal reference count is kept for colorbuffer proxy references,
408 // because, as the renderbuffer acting as proxy will maintain a binding pointer
409 // back to this texture, there would be a circular reference if we used a binding
410 // pointer here. This reference count will cause the pointer to be set to NULL if
411 // the count drops to zero, but will not cause deletion of the Renderbuffer.
412 Renderbuffer *mColorbufferProxy;
413 unsigned int mProxyRefs;
414};
415
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000416}
417
jbauman@chromium.org68715282012-07-12 23:28:41 +0000418#endif // LIBGLESV2_TEXTURE_H_