blob: ed7533e5b13756e51eaba2c94240df1db2e88504 [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"
Geoff Lang8040f572013-07-25 16:49:54 -040023#include "libGLESv2/RenderbufferProxySet.h"
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000024
25namespace egl
26{
27class Surface;
28}
29
daniel@transgaming.com370482e2012-11-28 19:32:13 +000030namespace rx
31{
32class Renderer;
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000033class TextureStorageInterface;
34class TextureStorageInterface2D;
35class TextureStorageInterfaceCube;
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +000036class TextureStorageInterface3D;
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +000037class TextureStorageInterface2DArray;
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000038class RenderTarget;
39class Image;
daniel@transgaming.com370482e2012-11-28 19:32:13 +000040}
41
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000042namespace gl
43{
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000044class Framebuffer;
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000045class Renderbuffer;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000046
47enum
48{
49 // These are the maximums the implementation can support
50 // The actual GL caps are limited by the device caps
51 // and should be queried from the Context
shannon.woods%transgaming.com@gtempaccount.comc1fdf6b2013-04-13 03:44:41 +000052 IMPLEMENTATION_MAX_2D_TEXTURE_SIZE = 16384,
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000053 IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE = 16384,
shannon.woods%transgaming.com@gtempaccount.comc1fdf6b2013-04-13 03:44:41 +000054 IMPLEMENTATION_MAX_3D_TEXTURE_SIZE = 2048,
shannon.woods%transgaming.com@gtempaccount.coma98a8112013-04-13 03:45:57 +000055 IMPLEMENTATION_MAX_2D_ARRAY_TEXTURE_LAYERS = 2048,
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000056
57 IMPLEMENTATION_MAX_TEXTURE_LEVELS = 15 // 1+log2 of MAX_TEXTURE_SIZE
58};
59
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000060class Texture : public RefCountObject
61{
62 public:
Geoff Lang4907f2c2013-07-25 12:53:57 -040063 Texture(rx::Renderer *renderer, GLuint id, GLenum target);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000064
65 virtual ~Texture();
66
Geoff Lang8040f572013-07-25 16:49:54 -040067 void addProxyRef(const Renderbuffer *proxy);
68 void releaseProxy(const Renderbuffer *proxy);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000069
Geoff Lang4907f2c2013-07-25 12:53:57 -040070 GLenum getTarget() const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000071
72 bool setMinFilter(GLenum filter);
73 bool setMagFilter(GLenum filter);
74 bool setWrapS(GLenum wrap);
75 bool setWrapT(GLenum wrap);
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +000076 bool setWrapR(GLenum wrap);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +000077 bool setMaxAnisotropy(float textureMaxAnisotropy, float contextMaxAnisotropy);
Geoff Langc82fc412013-07-10 14:43:42 -040078 bool setCompareMode(GLenum mode);
79 bool setCompareFunc(GLenum func);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000080 bool setUsage(GLenum usage);
81
82 GLenum getMinFilter() const;
83 GLenum getMagFilter() const;
84 GLenum getWrapS() const;
85 GLenum getWrapT() const;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +000086 GLenum getWrapR() const;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +000087 float getMaxAnisotropy() const;
daniel@transgaming.comebf139f2012-10-31 18:07:32 +000088 int getLodOffset();
89 void getSamplerState(SamplerState *sampler);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000090 GLenum getUsage() const;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +000091 virtual int levelCount() = 0;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000092
Jamie Madillf8989902013-07-19 16:36:58 -040093 virtual bool isSamplerComplete(const SamplerState &samplerState) const = 0;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000094
daniel@transgaming.com87705f82012-12-20 21:10:45 +000095 rx::TextureStorageInterface *getNativeTexture();
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000096
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();
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000104
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.com95a758f2012-07-12 15:17:06 +0000124
daniel@transgaming.com370482e2012-11-28 19:32:13 +0000125 rx::Renderer *mRenderer;
126
daniel@transgaming.comebf139f2012-10-31 18:07:32 +0000127 SamplerState mSamplerState;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000128 GLenum mUsage;
129
130 bool mDirtyImages;
131
132 bool mImmutable;
133
Geoff Lang4907f2c2013-07-25 12:53:57 -0400134 GLenum mTarget;
135
Geoff Lang8040f572013-07-25 16:49:54 -0400136 // A specific internal reference count is kept for colorbuffer proxy references,
137 // because, as the renderbuffer acting as proxy will maintain a binding pointer
138 // back to this texture, there would be a circular reference if we used a binding
139 // pointer here. This reference count will cause the pointer to be set to NULL if
140 // the count drops to zero, but will not cause deletion of the Renderbuffer.
141 RenderbufferProxySet mRenderbufferProxies;
142
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000143 private:
144 DISALLOW_COPY_AND_ASSIGN(Texture);
145
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000146 virtual rx::TextureStorageInterface *getStorage(bool renderTarget) = 0;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000147};
148
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000149class Texture2D : public Texture
150{
151 public:
daniel@transgaming.com370482e2012-11-28 19:32:13 +0000152 Texture2D(rx::Renderer *renderer, GLuint id);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000153
154 ~Texture2D();
155
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000156 GLsizei getWidth(GLint level) const;
157 GLsizei getHeight(GLint level) const;
158 GLenum getInternalFormat(GLint level) const;
daniel@transgaming.com20d36662012-10-31 19:51:43 +0000159 GLenum getActualFormat(GLint level) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000160 bool isCompressed(GLint level) const;
161 bool isDepth(GLint level) const;
162
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +0000163 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 +0000164 void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
165 void subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
166 void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
167 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 +0000168 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 +0000169 void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
170
Jamie Madillf8989902013-07-19 16:36:58 -0400171 virtual bool isSamplerComplete(const SamplerState &samplerState) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000172 virtual void bindTexImage(egl::Surface *surface);
173 virtual void releaseTexImage();
174
175 virtual void generateMipmaps();
176
Geoff Lang8040f572013-07-25 16:49:54 -0400177 Renderbuffer *getRenderbuffer(GLint level);
178 unsigned int getRenderTargetSerial(GLint level);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000179
180 protected:
181 friend class RenderbufferTexture2D;
Geoff Lang8040f572013-07-25 16:49:54 -0400182 rx::RenderTarget *getRenderTarget(GLint level);
183 rx::RenderTarget *getDepthSencil(GLint level);
daniel@transgaming.com690d8ae2012-10-31 19:52:08 +0000184 virtual int levelCount();
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000185
186 private:
187 DISALLOW_COPY_AND_ASSIGN(Texture2D);
188
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000189 virtual void createTexture();
190 virtual void updateTexture();
191 virtual void convertToRenderTarget();
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000192 virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000193
194 bool isMipmapComplete() const;
Jamie Madill07edd442013-07-19 16:36:58 -0400195 bool isLevelComplete(int level) const;
196 void updateTextureLevel(int level);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000197
shannon.woods@transgaming.come2e97982013-02-28 23:18:50 +0000198 void redefineImage(GLint level, GLint internalformat, GLsizei width, GLsizei height);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000199 void commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
200
daniel@transgaming.comd9ec9022012-12-20 20:52:16 +0000201 rx::Image *mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000202
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000203 rx::TextureStorageInterface2D *mTexStorage;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000204 egl::Surface *mSurface;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000205};
206
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000207class TextureCubeMap : public Texture
208{
209 public:
daniel@transgaming.com370482e2012-11-28 19:32:13 +0000210 TextureCubeMap(rx::Renderer *renderer, GLuint id);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000211
212 ~TextureCubeMap();
213
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000214 GLsizei getWidth(GLenum target, GLint level) const;
215 GLsizei getHeight(GLenum target, GLint level) const;
216 GLenum getInternalFormat(GLenum target, GLint level) const;
daniel@transgaming.com20d36662012-10-31 19:51:43 +0000217 GLenum getActualFormat(GLenum target, GLint level) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000218 bool isCompressed(GLenum target, GLint level) const;
Geoff Lang8040f572013-07-25 16:49:54 -0400219 bool isDepth(GLenum target, GLint level) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000220
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +0000221 void setImagePosX(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
222 void setImageNegX(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
223 void setImagePosY(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
224 void setImageNegY(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
225 void setImagePosZ(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
226 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 +0000227
228 void setCompressedImage(GLenum face, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
229
230 void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
231 void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
232 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 +0000233 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 +0000234 void storage(GLsizei levels, GLenum internalformat, GLsizei size);
235
Jamie Madillf8989902013-07-19 16:36:58 -0400236 virtual bool isSamplerComplete(const SamplerState &samplerState) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000237
238 virtual void generateMipmaps();
239
Geoff Lang8040f572013-07-25 16:49:54 -0400240 Renderbuffer *getRenderbuffer(GLenum target, GLint level);
241 unsigned int getRenderTargetSerial(GLenum faceTarget, GLint level);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000242
243 static unsigned int faceIndex(GLenum face);
244
245 protected:
246 friend class RenderbufferTextureCubeMap;
Geoff Lang8040f572013-07-25 16:49:54 -0400247 rx::RenderTarget *getRenderTarget(GLenum target, GLint level);
248 rx::RenderTarget *getDepthStencil(GLenum target, GLint level);
daniel@transgaming.com690d8ae2012-10-31 19:52:08 +0000249 virtual int levelCount();
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000250
251 private:
252 DISALLOW_COPY_AND_ASSIGN(TextureCubeMap);
253
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000254 virtual void createTexture();
255 virtual void updateTexture();
256 virtual void convertToRenderTarget();
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000257 virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000258
259 bool isCubeComplete() const;
260 bool isMipmapCubeComplete() const;
Jamie Madill07edd442013-07-19 16:36:58 -0400261 bool isFaceLevelComplete(int face, int level) const;
262 void updateTextureFaceLevel(int face, int level);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000263
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +0000264 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 +0000265 void commitRect(int faceIndex, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
shannon.woods@transgaming.come2e97982013-02-28 23:18:50 +0000266 void redefineImage(int faceIndex, GLint level, GLint internalformat, GLsizei width, GLsizei height);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000267
daniel@transgaming.comd9ec9022012-12-20 20:52:16 +0000268 rx::Image *mImageArray[6][IMPLEMENTATION_MAX_TEXTURE_LEVELS];
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000269
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000270 rx::TextureStorageInterfaceCube *mTexStorage;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000271};
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000272
273class Texture3D : public Texture
274{
275 public:
276 Texture3D(rx::Renderer *renderer, GLuint id);
277
278 ~Texture3D();
279
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000280 GLsizei getWidth(GLint level) const;
281 GLsizei getHeight(GLint level) const;
282 GLsizei getDepth(GLint level) const;
283 GLenum getInternalFormat(GLint level) const;
284 GLenum getActualFormat(GLint level) const;
285 bool isCompressed(GLint level) const;
286 bool isDepth(GLint level) const;
287
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +0000288 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 +0000289 void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
290 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);
291 void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
292 void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
293
294 virtual void generateMipmaps();
295 virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
296
Jamie Madillf8989902013-07-19 16:36:58 -0400297 virtual bool isSamplerComplete(const SamplerState &samplerState) const;
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000298 virtual bool isMipmapComplete() const;
299
Geoff Lang8040f572013-07-25 16:49:54 -0400300 Renderbuffer *getRenderbuffer(GLint level, GLint layer);
301 unsigned int getRenderTargetSerial(GLint level, GLint layer);
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000302
303 protected:
Geoff Lang8040f572013-07-25 16:49:54 -0400304 rx::RenderTarget *getRenderTarget(GLint level, GLint layer);
305 rx::RenderTarget *getDepthStencil(GLint level, GLint layer);
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000306 virtual int levelCount();
307
308 private:
309 DISALLOW_COPY_AND_ASSIGN(Texture3D);
310
311 virtual void createTexture();
312 virtual void updateTexture();
313 virtual void convertToRenderTarget();
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000314
315 virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
316
317 void redefineImage(GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth);
318 void commitRect(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);
319
Jamie Madill07edd442013-07-19 16:36:58 -0400320 bool isLevelComplete(int level) const;
321 void updateTextureLevel(int level);
322
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000323 rx::Image *mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
324
325 rx::TextureStorageInterface3D *mTexStorage;
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000326};
327
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000328class Texture2DArray : public Texture
329{
330 public:
331 Texture2DArray(rx::Renderer *renderer, GLuint id);
332
333 ~Texture2DArray();
334
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000335 GLsizei getWidth(GLint level) const;
336 GLsizei getHeight(GLint level) const;
337 GLsizei getDepth(GLint level) const;
338 GLenum getInternalFormat(GLint level) const;
339 GLenum getActualFormat(GLint level) const;
340 bool isCompressed(GLint level) const;
341 bool isDepth(GLint level) const;
342
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +0000343 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 +0000344 void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
345 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);
346 void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
347 void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
348
349 virtual void generateMipmaps();
350 virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
351
Jamie Madillf8989902013-07-19 16:36:58 -0400352 virtual bool isSamplerComplete(const SamplerState &samplerState) const;
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000353 virtual bool isMipmapComplete() const;
354
Geoff Lang8040f572013-07-25 16:49:54 -0400355 Renderbuffer *getRenderbuffer(GLint level, GLint layer);
356 unsigned int getRenderTargetSerial(GLint level, GLint layer);
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000357
358 protected:
Geoff Lang8040f572013-07-25 16:49:54 -0400359 rx::RenderTarget *getRenderTarget(GLint level, GLint layer);
360 rx::RenderTarget *getDepthStencil(GLint level, GLint layer);
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000361 virtual int levelCount();
362
363 private:
364 DISALLOW_COPY_AND_ASSIGN(Texture2DArray);
365
366 virtual void createTexture();
367 virtual void updateTexture();
368 virtual void convertToRenderTarget();
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000369
370 virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
371
372 void redefineImage(GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth);
373 void commitRect(GLint level, GLint xoffset, GLint yoffset, GLint layerTarget, GLsizei width, GLsizei height);
374
Jamie Madill07edd442013-07-19 16:36:58 -0400375 bool isLevelComplete(int level) const;
376 void updateTextureLevel(int level);
377
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000378 // Storing images as an array of single depth textures since D3D11 treats each array level of a
379 // Texture2D object as a separate subresource. Each layer would have to be looped over
380 // to update all the texture layers since they cannot all be updated at once and it makes the most
381 // 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 +0000382 GLsizei mLayerCounts[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
shannonwoods@chromium.org644f7662013-05-30 00:02:07 +0000383 rx::Image **mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000384
385 rx::TextureStorageInterface2DArray *mTexStorage;
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000386};
387
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000388}
389
jbauman@chromium.org68715282012-07-12 23:28:41 +0000390#endif // LIBGLESV2_TEXTURE_H_