blob: ba1a3515f6ffba26e3eb76666d0372d178808d52 [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:
Geoff Lang4907f2c2013-07-25 12:53:57 -040062 Texture(rx::Renderer *renderer, GLuint id, GLenum target);
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
Geoff Lang4907f2c2013-07-25 12:53:57 -040069 GLenum getTarget() const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000070
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;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +000090 virtual int levelCount() = 0;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000091
Jamie Madillf8989902013-07-19 16:36:58 -040092 virtual bool isSamplerComplete(const SamplerState &samplerState) const = 0;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000093
daniel@transgaming.com87705f82012-12-20 21:10:45 +000094 rx::TextureStorageInterface *getNativeTexture();
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000095 virtual Renderbuffer *getRenderbuffer(GLenum target) = 0;
96
97 virtual void generateMipmaps() = 0;
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +000098 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 +000099
100 bool hasDirtyParameters() const;
101 bool hasDirtyImages() const;
102 void resetDirty();
103 unsigned int getTextureSerial();
104 unsigned int getRenderTargetSerial(GLenum target);
105
106 bool isImmutable() const;
107
108 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.
109
110 protected:
shannonwoods@chromium.org557aab02013-05-30 00:08:27 +0000111 void setImage(GLint unpackAlignment, GLenum type, const void *pixels, rx::Image *image);
shannon.woods%transgaming.com@gtempaccount.com4760c562013-04-13 03:42:30 +0000112 bool subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
113 GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, rx::Image *image);
daniel@transgaming.com31b13e12012-11-28 19:34:30 +0000114 void setCompressedImage(GLsizei imageSize, const void *pixels, rx::Image *image);
shannon.woods%transgaming.com@gtempaccount.com4760c562013-04-13 03:42:30 +0000115 bool subImageCompressed(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
116 GLenum format, GLsizei imageSize, const void *pixels, rx::Image *image);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000117
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000118 GLint creationLevels(GLsizei width, GLsizei height, GLsizei depth) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000119 GLint creationLevels(GLsizei width, GLsizei height) const;
120 GLint creationLevels(GLsizei size) const;
121
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000122 virtual void createTexture() = 0;
123 virtual void updateTexture() = 0;
124 virtual void convertToRenderTarget() = 0;
daniel@transgaming.comd186dc72012-11-28 19:40:16 +0000125 virtual rx::RenderTarget *getRenderTarget(GLenum target) = 0;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000126
daniel@transgaming.com370482e2012-11-28 19:32:13 +0000127 rx::Renderer *mRenderer;
128
daniel@transgaming.comebf139f2012-10-31 18:07:32 +0000129 SamplerState mSamplerState;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000130 GLenum mUsage;
131
132 bool mDirtyImages;
133
134 bool mImmutable;
135
Geoff Lang4907f2c2013-07-25 12:53:57 -0400136 GLenum mTarget;
137
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000138 private:
139 DISALLOW_COPY_AND_ASSIGN(Texture);
140
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000141 virtual rx::TextureStorageInterface *getStorage(bool renderTarget) = 0;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000142};
143
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000144class Texture2D : public Texture
145{
146 public:
daniel@transgaming.com370482e2012-11-28 19:32:13 +0000147 Texture2D(rx::Renderer *renderer, GLuint id);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000148
149 ~Texture2D();
150
151 void addProxyRef(const Renderbuffer *proxy);
152 void releaseProxy(const Renderbuffer *proxy);
153
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000154 GLsizei getWidth(GLint level) const;
155 GLsizei getHeight(GLint level) const;
156 GLenum getInternalFormat(GLint level) const;
daniel@transgaming.com20d36662012-10-31 19:51:43 +0000157 GLenum getActualFormat(GLint level) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000158 bool isCompressed(GLint level) const;
159 bool isDepth(GLint level) const;
160
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +0000161 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 +0000162 void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
163 void subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
164 void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
165 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 +0000166 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 +0000167 void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
168
Jamie Madillf8989902013-07-19 16:36:58 -0400169 virtual bool isSamplerComplete(const SamplerState &samplerState) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000170 virtual void bindTexImage(egl::Surface *surface);
171 virtual void releaseTexImage();
172
173 virtual void generateMipmaps();
174
175 virtual Renderbuffer *getRenderbuffer(GLenum target);
176
177 protected:
178 friend class RenderbufferTexture2D;
daniel@transgaming.comd186dc72012-11-28 19:40:16 +0000179 virtual rx::RenderTarget *getRenderTarget(GLenum target);
180 virtual rx::RenderTarget *getDepthStencil(GLenum target);
daniel@transgaming.com690d8ae2012-10-31 19:52:08 +0000181 virtual int levelCount();
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000182
183 private:
184 DISALLOW_COPY_AND_ASSIGN(Texture2D);
185
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000186 virtual void createTexture();
187 virtual void updateTexture();
188 virtual void convertToRenderTarget();
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000189 virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000190
191 bool isMipmapComplete() const;
Jamie Madill07edd442013-07-19 16:36:58 -0400192 bool isLevelComplete(int level) const;
193 void updateTextureLevel(int level);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000194
shannon.woods@transgaming.come2e97982013-02-28 23:18:50 +0000195 void redefineImage(GLint level, GLint internalformat, GLsizei width, GLsizei height);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000196 void commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
197
daniel@transgaming.comd9ec9022012-12-20 20:52:16 +0000198 rx::Image *mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000199
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000200 rx::TextureStorageInterface2D *mTexStorage;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000201 egl::Surface *mSurface;
202
203 // A specific internal reference count is kept for colorbuffer proxy references,
204 // because, as the renderbuffer acting as proxy will maintain a binding pointer
205 // back to this texture, there would be a circular reference if we used a binding
206 // pointer here. This reference count will cause the pointer to be set to NULL if
207 // the count drops to zero, but will not cause deletion of the Renderbuffer.
208 Renderbuffer *mColorbufferProxy;
209 unsigned int mProxyRefs;
210};
211
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000212class TextureCubeMap : public Texture
213{
214 public:
daniel@transgaming.com370482e2012-11-28 19:32:13 +0000215 TextureCubeMap(rx::Renderer *renderer, GLuint id);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000216
217 ~TextureCubeMap();
218
219 void addProxyRef(const Renderbuffer *proxy);
220 void releaseProxy(const Renderbuffer *proxy);
221
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000222 GLsizei getWidth(GLenum target, GLint level) const;
223 GLsizei getHeight(GLenum target, GLint level) const;
224 GLenum getInternalFormat(GLenum target, GLint level) const;
daniel@transgaming.com20d36662012-10-31 19:51:43 +0000225 GLenum getActualFormat(GLenum target, GLint level) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000226 bool isCompressed(GLenum target, GLint level) const;
227
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +0000228 void setImagePosX(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
229 void setImageNegX(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
230 void setImagePosY(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
231 void setImageNegY(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
232 void setImagePosZ(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
233 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 +0000234
235 void setCompressedImage(GLenum face, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
236
237 void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
238 void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
239 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 +0000240 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 +0000241 void storage(GLsizei levels, GLenum internalformat, GLsizei size);
242
Jamie Madillf8989902013-07-19 16:36:58 -0400243 virtual bool isSamplerComplete(const SamplerState &samplerState) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000244
245 virtual void generateMipmaps();
246
247 virtual Renderbuffer *getRenderbuffer(GLenum target);
248
249 static unsigned int faceIndex(GLenum face);
250
251 protected:
252 friend class RenderbufferTextureCubeMap;
daniel@transgaming.comd186dc72012-11-28 19:40:16 +0000253 virtual rx::RenderTarget *getRenderTarget(GLenum target);
daniel@transgaming.com690d8ae2012-10-31 19:52:08 +0000254 virtual int levelCount();
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000255
256 private:
257 DISALLOW_COPY_AND_ASSIGN(TextureCubeMap);
258
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000259 virtual void createTexture();
260 virtual void updateTexture();
261 virtual void convertToRenderTarget();
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000262 virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000263
264 bool isCubeComplete() const;
265 bool isMipmapCubeComplete() const;
Jamie Madill07edd442013-07-19 16:36:58 -0400266 bool isFaceLevelComplete(int face, int level) const;
267 void updateTextureFaceLevel(int face, int level);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000268
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +0000269 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 +0000270 void commitRect(int faceIndex, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
shannon.woods@transgaming.come2e97982013-02-28 23:18:50 +0000271 void redefineImage(int faceIndex, GLint level, GLint internalformat, GLsizei width, GLsizei height);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000272
daniel@transgaming.comd9ec9022012-12-20 20:52:16 +0000273 rx::Image *mImageArray[6][IMPLEMENTATION_MAX_TEXTURE_LEVELS];
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000274
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000275 rx::TextureStorageInterfaceCube *mTexStorage;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000276
277 // A specific internal reference count is kept for colorbuffer proxy references,
278 // because, as the renderbuffer acting as proxy will maintain a binding pointer
279 // back to this texture, there would be a circular reference if we used a binding
280 // pointer here. This reference count will cause the pointer to be set to NULL if
281 // the count drops to zero, but will not cause deletion of the Renderbuffer.
282 Renderbuffer *mFaceProxies[6];
283 unsigned int *mFaceProxyRefs[6];
284};
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000285
286class Texture3D : public Texture
287{
288 public:
289 Texture3D(rx::Renderer *renderer, GLuint id);
290
291 ~Texture3D();
292
293 void addProxyRef(const Renderbuffer *proxy);
294 void releaseProxy(const Renderbuffer *proxy);
295
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000296 GLsizei getWidth(GLint level) const;
297 GLsizei getHeight(GLint level) const;
298 GLsizei getDepth(GLint level) const;
299 GLenum getInternalFormat(GLint level) const;
300 GLenum getActualFormat(GLint level) const;
301 bool isCompressed(GLint level) const;
302 bool isDepth(GLint level) const;
303
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +0000304 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 +0000305 void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
306 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);
307 void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
308 void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
309
310 virtual void generateMipmaps();
311 virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
312
Jamie Madillf8989902013-07-19 16:36:58 -0400313 virtual bool isSamplerComplete(const SamplerState &samplerState) const;
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000314 virtual bool isMipmapComplete() const;
315
316 virtual Renderbuffer *getRenderbuffer(GLenum target);
317
318 protected:
319 virtual int levelCount();
320
321 private:
322 DISALLOW_COPY_AND_ASSIGN(Texture3D);
323
324 virtual void createTexture();
325 virtual void updateTexture();
326 virtual void convertToRenderTarget();
327 virtual rx::RenderTarget *getRenderTarget(GLenum target);
328
329 virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
330
331 void redefineImage(GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth);
332 void commitRect(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);
333
Jamie Madill07edd442013-07-19 16:36:58 -0400334 bool isLevelComplete(int level) const;
335 void updateTextureLevel(int level);
336
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000337 rx::Image *mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
338
339 rx::TextureStorageInterface3D *mTexStorage;
340
341 // A specific internal reference count is kept for colorbuffer proxy references,
342 // because, as the renderbuffer acting as proxy will maintain a binding pointer
343 // back to this texture, there would be a circular reference if we used a binding
344 // pointer here. This reference count will cause the pointer to be set to NULL if
345 // the count drops to zero, but will not cause deletion of the Renderbuffer.
346 Renderbuffer *mColorbufferProxy;
347 unsigned int mProxyRefs;
348};
349
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000350class Texture2DArray : public Texture
351{
352 public:
353 Texture2DArray(rx::Renderer *renderer, GLuint id);
354
355 ~Texture2DArray();
356
357 void addProxyRef(const Renderbuffer *proxy);
358 void releaseProxy(const Renderbuffer *proxy);
359
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000360 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
Jamie Madillf8989902013-07-19 16:36:58 -0400377 virtual bool isSamplerComplete(const SamplerState &samplerState) const;
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000378 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
Jamie Madill07edd442013-07-19 16:36:58 -0400398 bool isLevelComplete(int level) const;
399 void updateTextureLevel(int level);
400
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000401 // Storing images as an array of single depth textures since D3D11 treats each array level of a
402 // Texture2D object as a separate subresource. Each layer would have to be looped over
403 // to update all the texture layers since they cannot all be updated at once and it makes the most
404 // 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 +0000405 GLsizei mLayerCounts[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
shannonwoods@chromium.org644f7662013-05-30 00:02:07 +0000406 rx::Image **mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000407
408 rx::TextureStorageInterface2DArray *mTexStorage;
409
410 // A specific internal reference count is kept for colorbuffer proxy references,
411 // because, as the renderbuffer acting as proxy will maintain a binding pointer
412 // back to this texture, there would be a circular reference if we used a binding
413 // pointer here. This reference count will cause the pointer to be set to NULL if
414 // the count drops to zero, but will not cause deletion of the Renderbuffer.
415 Renderbuffer *mColorbufferProxy;
416 unsigned int mProxyRefs;
417};
418
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000419}
420
jbauman@chromium.org68715282012-07-12 23:28:41 +0000421#endif // LIBGLESV2_TEXTURE_H_