blob: 2d729f647f29850833de3e82e6cec1d1b705384a [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:
Jamie Madill88f18f42013-09-18 14:36:19 -0400110 void setImage(const PixelUnpackState &unpack, 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,
Jamie Madill88f18f42013-09-18 14:36:19 -0400112 GLenum format, GLenum type, const PixelUnpackState &unpack, 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);
Jamie Madill1beb1db2013-09-18 14:36:28 -0400116 bool fastUnpackPixels(const PixelUnpackState &unpack, const void *pixels, const Box &destArea,
117 GLenum sizedInternalFormat, GLenum type, GLint level);
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.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
Geoff Lang8040f572013-07-25 16:49:54 -0400138 // A specific internal reference count is kept for colorbuffer proxy references,
139 // because, as the renderbuffer acting as proxy will maintain a binding pointer
140 // back to this texture, there would be a circular reference if we used a binding
141 // pointer here. This reference count will cause the pointer to be set to NULL if
142 // the count drops to zero, but will not cause deletion of the Renderbuffer.
143 RenderbufferProxySet mRenderbufferProxies;
144
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000145 private:
146 DISALLOW_COPY_AND_ASSIGN(Texture);
147
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000148 virtual rx::TextureStorageInterface *getStorage(bool renderTarget) = 0;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000149};
150
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000151class Texture2D : public Texture
152{
153 public:
daniel@transgaming.com370482e2012-11-28 19:32:13 +0000154 Texture2D(rx::Renderer *renderer, GLuint id);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000155
156 ~Texture2D();
157
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000158 GLsizei getWidth(GLint level) const;
159 GLsizei getHeight(GLint level) const;
160 GLenum getInternalFormat(GLint level) const;
daniel@transgaming.com20d36662012-10-31 19:51:43 +0000161 GLenum getActualFormat(GLint level) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000162 bool isCompressed(GLint level) const;
163 bool isDepth(GLint level) const;
164
Jamie Madill88f18f42013-09-18 14:36:19 -0400165 void setImage(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000166 void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
Jamie Madill88f18f42013-09-18 14:36:19 -0400167 void subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000168 void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
169 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 +0000170 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 +0000171 void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
172
Jamie Madillf8989902013-07-19 16:36:58 -0400173 virtual bool isSamplerComplete(const SamplerState &samplerState) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000174 virtual void bindTexImage(egl::Surface *surface);
175 virtual void releaseTexImage();
176
177 virtual void generateMipmaps();
178
Geoff Lang8040f572013-07-25 16:49:54 -0400179 Renderbuffer *getRenderbuffer(GLint level);
180 unsigned int getRenderTargetSerial(GLint level);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000181
182 protected:
183 friend class RenderbufferTexture2D;
Geoff Lang8040f572013-07-25 16:49:54 -0400184 rx::RenderTarget *getRenderTarget(GLint level);
185 rx::RenderTarget *getDepthSencil(GLint level);
daniel@transgaming.com690d8ae2012-10-31 19:52:08 +0000186 virtual int levelCount();
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000187
188 private:
189 DISALLOW_COPY_AND_ASSIGN(Texture2D);
190
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000191 virtual void createTexture();
192 virtual void updateTexture();
193 virtual void convertToRenderTarget();
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000194 virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000195
196 bool isMipmapComplete() const;
Jamie Madill07edd442013-07-19 16:36:58 -0400197 bool isLevelComplete(int level) const;
198 void updateTextureLevel(int level);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000199
shannon.woods@transgaming.come2e97982013-02-28 23:18:50 +0000200 void redefineImage(GLint level, GLint internalformat, GLsizei width, GLsizei height);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000201 void commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
202
daniel@transgaming.comd9ec9022012-12-20 20:52:16 +0000203 rx::Image *mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000204
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000205 rx::TextureStorageInterface2D *mTexStorage;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000206 egl::Surface *mSurface;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000207};
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
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000216 GLsizei getWidth(GLenum target, GLint level) const;
217 GLsizei getHeight(GLenum target, GLint level) const;
218 GLenum getInternalFormat(GLenum target, GLint level) const;
daniel@transgaming.com20d36662012-10-31 19:51:43 +0000219 GLenum getActualFormat(GLenum target, GLint level) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000220 bool isCompressed(GLenum target, GLint level) const;
Geoff Lang8040f572013-07-25 16:49:54 -0400221 bool isDepth(GLenum target, GLint level) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000222
Jamie Madill88f18f42013-09-18 14:36:19 -0400223 void setImagePosX(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
224 void setImageNegX(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
225 void setImagePosY(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
226 void setImageNegY(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
227 void setImagePosZ(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
228 void setImageNegZ(GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000229
230 void setCompressedImage(GLenum face, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
231
Jamie Madill88f18f42013-09-18 14:36:19 -0400232 void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000233 void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
234 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 +0000235 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 +0000236 void storage(GLsizei levels, GLenum internalformat, GLsizei size);
237
Jamie Madillf8989902013-07-19 16:36:58 -0400238 virtual bool isSamplerComplete(const SamplerState &samplerState) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000239
240 virtual void generateMipmaps();
241
Geoff Lang8040f572013-07-25 16:49:54 -0400242 Renderbuffer *getRenderbuffer(GLenum target, GLint level);
243 unsigned int getRenderTargetSerial(GLenum faceTarget, GLint level);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000244
245 static unsigned int faceIndex(GLenum face);
246
247 protected:
248 friend class RenderbufferTextureCubeMap;
Geoff Lang8040f572013-07-25 16:49:54 -0400249 rx::RenderTarget *getRenderTarget(GLenum target, GLint level);
250 rx::RenderTarget *getDepthStencil(GLenum target, GLint level);
daniel@transgaming.com690d8ae2012-10-31 19:52:08 +0000251 virtual int levelCount();
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000252
253 private:
254 DISALLOW_COPY_AND_ASSIGN(TextureCubeMap);
255
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000256 virtual void createTexture();
257 virtual void updateTexture();
258 virtual void convertToRenderTarget();
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000259 virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000260
261 bool isCubeComplete() const;
262 bool isMipmapCubeComplete() const;
Jamie Madill07edd442013-07-19 16:36:58 -0400263 bool isFaceLevelComplete(int face, int level) const;
264 void updateTextureFaceLevel(int face, int level);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000265
Jamie Madill88f18f42013-09-18 14:36:19 -0400266 void setImage(int faceIndex, GLint level, GLsizei width, GLsizei height, GLint internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, 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};
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000274
275class Texture3D : public Texture
276{
277 public:
278 Texture3D(rx::Renderer *renderer, GLuint id);
279
280 ~Texture3D();
281
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000282 GLsizei getWidth(GLint level) const;
283 GLsizei getHeight(GLint level) const;
284 GLsizei getDepth(GLint level) const;
285 GLenum getInternalFormat(GLint level) const;
286 GLenum getActualFormat(GLint level) const;
287 bool isCompressed(GLint level) const;
288 bool isDepth(GLint level) const;
289
Jamie Madill88f18f42013-09-18 14:36:19 -0400290 void setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLint internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000291 void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
Jamie Madill88f18f42013-09-18 14:36:19 -0400292 void subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000293 void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
294 void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
295
296 virtual void generateMipmaps();
297 virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
298
Jamie Madillf8989902013-07-19 16:36:58 -0400299 virtual bool isSamplerComplete(const SamplerState &samplerState) const;
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000300 virtual bool isMipmapComplete() const;
301
Geoff Lang8040f572013-07-25 16:49:54 -0400302 Renderbuffer *getRenderbuffer(GLint level, GLint layer);
303 unsigned int getRenderTargetSerial(GLint level, GLint layer);
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000304
305 protected:
Geoff Langd5d8e392013-07-25 16:53:03 -0400306 friend class RenderbufferTexture3DLayer;
Geoff Lang8040f572013-07-25 16:49:54 -0400307 rx::RenderTarget *getRenderTarget(GLint level, GLint layer);
308 rx::RenderTarget *getDepthStencil(GLint level, GLint layer);
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000309 virtual int levelCount();
310
311 private:
312 DISALLOW_COPY_AND_ASSIGN(Texture3D);
313
314 virtual void createTexture();
315 virtual void updateTexture();
316 virtual void convertToRenderTarget();
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000317
318 virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
319
320 void redefineImage(GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth);
321 void commitRect(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);
322
Jamie Madill07edd442013-07-19 16:36:58 -0400323 bool isLevelComplete(int level) const;
324 void updateTextureLevel(int level);
325
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000326 rx::Image *mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
327
328 rx::TextureStorageInterface3D *mTexStorage;
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000329};
330
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000331class Texture2DArray : public Texture
332{
333 public:
334 Texture2DArray(rx::Renderer *renderer, GLuint id);
335
336 ~Texture2DArray();
337
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000338 GLsizei getWidth(GLint level) const;
339 GLsizei getHeight(GLint level) const;
340 GLsizei getDepth(GLint level) const;
341 GLenum getInternalFormat(GLint level) const;
342 GLenum getActualFormat(GLint level) const;
343 bool isCompressed(GLint level) const;
344 bool isDepth(GLint level) const;
345
Jamie Madill88f18f42013-09-18 14:36:19 -0400346 void setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLint internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000347 void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
Jamie Madill88f18f42013-09-18 14:36:19 -0400348 void subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000349 void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
350 void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
351
352 virtual void generateMipmaps();
353 virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
354
Jamie Madillf8989902013-07-19 16:36:58 -0400355 virtual bool isSamplerComplete(const SamplerState &samplerState) const;
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000356 virtual bool isMipmapComplete() const;
357
Geoff Lang8040f572013-07-25 16:49:54 -0400358 Renderbuffer *getRenderbuffer(GLint level, GLint layer);
359 unsigned int getRenderTargetSerial(GLint level, GLint layer);
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000360
361 protected:
Geoff Langd5d8e392013-07-25 16:53:03 -0400362 friend class RenderbufferTexture2DArrayLayer;
Geoff Lang8040f572013-07-25 16:49:54 -0400363 rx::RenderTarget *getRenderTarget(GLint level, GLint layer);
364 rx::RenderTarget *getDepthStencil(GLint level, GLint layer);
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000365 virtual int levelCount();
366
367 private:
368 DISALLOW_COPY_AND_ASSIGN(Texture2DArray);
369
370 virtual void createTexture();
371 virtual void updateTexture();
372 virtual void convertToRenderTarget();
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000373
374 virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
375
376 void redefineImage(GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth);
377 void commitRect(GLint level, GLint xoffset, GLint yoffset, GLint layerTarget, GLsizei width, GLsizei height);
378
Jamie Madill07edd442013-07-19 16:36:58 -0400379 bool isLevelComplete(int level) const;
380 void updateTextureLevel(int level);
381
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000382 // Storing images as an array of single depth textures since D3D11 treats each array level of a
383 // Texture2D object as a separate subresource. Each layer would have to be looped over
384 // to update all the texture layers since they cannot all be updated at once and it makes the most
385 // 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 +0000386 GLsizei mLayerCounts[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
shannonwoods@chromium.org644f7662013-05-30 00:02:07 +0000387 rx::Image **mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000388
389 rx::TextureStorageInterface2DArray *mTexStorage;
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000390};
391
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000392}
393
jbauman@chromium.org68715282012-07-12 23:28:41 +0000394#endif // LIBGLESV2_TEXTURE_H_