blob: 8efa7b250cacf89cbf16c96f608276427f991967 [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
Jamie Madillf51639a2014-06-25 16:04:57 -040016#include "angle_gl.h"
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000017
18#include "common/debug.h"
19#include "common/RefCountObject.h"
daniel@transgaming.com8bc304a2013-01-11 04:07:42 +000020#include "libGLESv2/angletypes.h"
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000021
22namespace egl
23{
24class Surface;
25}
26
daniel@transgaming.com370482e2012-11-28 19:32:13 +000027namespace rx
28{
29class Renderer;
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000030class TextureStorageInterface;
31class TextureStorageInterface2D;
32class TextureStorageInterfaceCube;
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +000033class TextureStorageInterface3D;
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +000034class TextureStorageInterface2DArray;
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000035class RenderTarget;
36class Image;
daniel@transgaming.com370482e2012-11-28 19:32:13 +000037}
38
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000039namespace gl
40{
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000041class Framebuffer;
Jamie Madill3c7fa222014-06-05 13:08:51 -040042class FramebufferAttachment;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000043
44enum
45{
46 // These are the maximums the implementation can support
47 // The actual GL caps are limited by the device caps
48 // and should be queried from the Context
shannon.woods%transgaming.com@gtempaccount.comc1fdf6b2013-04-13 03:44:41 +000049 IMPLEMENTATION_MAX_2D_TEXTURE_SIZE = 16384,
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000050 IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE = 16384,
shannon.woods%transgaming.com@gtempaccount.comc1fdf6b2013-04-13 03:44:41 +000051 IMPLEMENTATION_MAX_3D_TEXTURE_SIZE = 2048,
shannon.woods%transgaming.com@gtempaccount.coma98a8112013-04-13 03:45:57 +000052 IMPLEMENTATION_MAX_2D_ARRAY_TEXTURE_LAYERS = 2048,
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000053
54 IMPLEMENTATION_MAX_TEXTURE_LEVELS = 15 // 1+log2 of MAX_TEXTURE_SIZE
55};
56
Nicolas Capense47e7362014-03-27 13:34:56 -040057bool IsMipmapFiltered(const SamplerState &samplerState);
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
Geoff Lang4907f2c2013-07-25 12:53:57 -040066 GLenum getTarget() const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000067
Geoff Lang63b5f1f2013-09-23 14:52:14 -040068 void setMinFilter(GLenum filter);
69 void setMagFilter(GLenum filter);
70 void setWrapS(GLenum wrap);
71 void setWrapT(GLenum wrap);
72 void setWrapR(GLenum wrap);
73 void setMaxAnisotropy(float textureMaxAnisotropy, float contextMaxAnisotropy);
74 void setCompareMode(GLenum mode);
75 void setCompareFunc(GLenum func);
Geoff Langbc90a482013-09-17 16:51:27 -040076 void setSwizzleRed(GLenum swizzle);
77 void setSwizzleGreen(GLenum swizzle);
78 void setSwizzleBlue(GLenum swizzle);
79 void setSwizzleAlpha(GLenum swizzle);
Nicolas Capens8de68282014-04-04 11:10:27 -040080 void setBaseLevel(GLint baseLevel);
81 void setMaxLevel(GLint maxLevel);
82 void setMinLod(GLfloat minLod);
83 void setMaxLod(GLfloat maxLod);
Geoff Lang63b5f1f2013-09-23 14:52:14 -040084 void setUsage(GLenum usage);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +000085
86 GLenum getMinFilter() const;
87 GLenum getMagFilter() const;
88 GLenum getWrapS() const;
89 GLenum getWrapT() const;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +000090 GLenum getWrapR() const;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +000091 float getMaxAnisotropy() const;
Geoff Langbc90a482013-09-17 16:51:27 -040092 GLenum getSwizzleRed() const;
93 GLenum getSwizzleGreen() const;
94 GLenum getSwizzleBlue() const;
95 GLenum getSwizzleAlpha() const;
Nicolas Capens8de68282014-04-04 11:10:27 -040096 GLint getBaseLevel() const;
97 GLint getMaxLevel() const;
98 GLfloat getMinLod() const;
99 GLfloat getMaxLod() const;
Geoff Langbc90a482013-09-17 16:51:27 -0400100 bool isSwizzled() const;
daniel@transgaming.comebf139f2012-10-31 18:07:32 +0000101 void getSamplerState(SamplerState *sampler);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000102 GLenum getUsage() const;
103
Jamie Madilld3d2a342013-10-07 10:46:35 -0400104 GLint getBaseLevelWidth() const;
105 GLint getBaseLevelHeight() const;
106 GLint getBaseLevelDepth() const;
107 GLenum getBaseLevelInternalFormat() const;
108
Jamie Madillf8989902013-07-19 16:36:58 -0400109 virtual bool isSamplerComplete(const SamplerState &samplerState) const = 0;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000110
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000111 rx::TextureStorageInterface *getNativeTexture();
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000112
113 virtual void generateMipmaps() = 0;
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000114 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 +0000115
116 bool hasDirtyParameters() const;
117 bool hasDirtyImages() const;
118 void resetDirty();
119 unsigned int getTextureSerial();
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000120
121 bool isImmutable() const;
Jamie Madill51a94372013-10-24 17:49:43 -0400122 int immutableLevelCount();
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000123
124 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.
125
126 protected:
Jamie Madill88f18f42013-09-18 14:36:19 -0400127 void setImage(const PixelUnpackState &unpack, GLenum type, const void *pixels, rx::Image *image);
shannon.woods%transgaming.com@gtempaccount.com4760c562013-04-13 03:42:30 +0000128 bool subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
Jamie Madill88f18f42013-09-18 14:36:19 -0400129 GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels, rx::Image *image);
daniel@transgaming.com31b13e12012-11-28 19:34:30 +0000130 void setCompressedImage(GLsizei imageSize, const void *pixels, rx::Image *image);
shannon.woods%transgaming.com@gtempaccount.com4760c562013-04-13 03:42:30 +0000131 bool subImageCompressed(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
132 GLenum format, GLsizei imageSize, const void *pixels, rx::Image *image);
Geoff Lang005df412013-10-16 14:12:50 -0400133 bool isFastUnpackable(const PixelUnpackState &unpack, GLenum sizedInternalFormat);
Jamie Madill1beb1db2013-09-18 14:36:28 -0400134 bool fastUnpackPixels(const PixelUnpackState &unpack, const void *pixels, const Box &destArea,
Jamie Madill8cc7d972013-10-10 15:51:55 -0400135 GLenum sizedInternalFormat, GLenum type, rx::RenderTarget *destRenderTarget);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000136
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000137 GLint creationLevels(GLsizei width, GLsizei height, GLsizei depth) const;
Jamie Madill22f843a2013-10-24 17:49:36 -0400138 int mipLevels() const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000139
Jamie Madill73b5d062013-10-24 17:49:38 -0400140 virtual void initializeStorage(bool renderTarget) = 0;
Jamie Madill169d1112013-10-24 17:49:37 -0400141 virtual void updateStorage() = 0;
Jamie Madille83d1a92013-10-24 17:49:33 -0400142 virtual bool ensureRenderTarget() = 0;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000143
daniel@transgaming.com370482e2012-11-28 19:32:13 +0000144 rx::Renderer *mRenderer;
145
daniel@transgaming.comebf139f2012-10-31 18:07:32 +0000146 SamplerState mSamplerState;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000147 GLenum mUsage;
148
149 bool mDirtyImages;
150
151 bool mImmutable;
152
Geoff Lang4907f2c2013-07-25 12:53:57 -0400153 GLenum mTarget;
154
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000155 private:
156 DISALLOW_COPY_AND_ASSIGN(Texture);
157
Jamie Madill2ebab852013-10-24 17:49:42 -0400158 virtual rx::TextureStorageInterface *getBaseLevelStorage() = 0;
Jamie Madilld3d2a342013-10-07 10:46:35 -0400159 virtual const rx::Image *getBaseLevelImage() const = 0;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000160};
161
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000162class Texture2D : public Texture
163{
164 public:
daniel@transgaming.com370482e2012-11-28 19:32:13 +0000165 Texture2D(rx::Renderer *renderer, GLuint id);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000166
167 ~Texture2D();
168
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000169 GLsizei getWidth(GLint level) const;
170 GLsizei getHeight(GLint level) const;
171 GLenum getInternalFormat(GLint level) const;
daniel@transgaming.com20d36662012-10-31 19:51:43 +0000172 GLenum getActualFormat(GLint level) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000173 bool isCompressed(GLint level) const;
174 bool isDepth(GLint level) const;
175
Geoff Lang005df412013-10-16 14:12:50 -0400176 void setImage(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000177 void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
Jamie Madill88f18f42013-09-18 14:36:19 -0400178 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 +0000179 void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
180 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 +0000181 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 +0000182 void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
183
Jamie Madillf8989902013-07-19 16:36:58 -0400184 virtual bool isSamplerComplete(const SamplerState &samplerState) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000185 virtual void bindTexImage(egl::Surface *surface);
186 virtual void releaseTexImage();
187
188 virtual void generateMipmaps();
189
Geoff Lang8040f572013-07-25 16:49:54 -0400190 unsigned int getRenderTargetSerial(GLint level);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000191
192 protected:
Jamie Madill3c7fa222014-06-05 13:08:51 -0400193 friend class Texture2DAttachment;
Geoff Lang8040f572013-07-25 16:49:54 -0400194 rx::RenderTarget *getRenderTarget(GLint level);
195 rx::RenderTarget *getDepthSencil(GLint level);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000196
197 private:
198 DISALLOW_COPY_AND_ASSIGN(Texture2D);
199
Jamie Madill73b5d062013-10-24 17:49:38 -0400200 virtual void initializeStorage(bool renderTarget);
201 rx::TextureStorageInterface2D *createCompleteStorage(bool renderTarget) const;
202 void setCompleteTexStorage(rx::TextureStorageInterface2D *newCompleteTexStorage);
203
Jamie Madill169d1112013-10-24 17:49:37 -0400204 virtual void updateStorage();
Jamie Madille83d1a92013-10-24 17:49:33 -0400205 virtual bool ensureRenderTarget();
Jamie Madill2ebab852013-10-24 17:49:42 -0400206 virtual rx::TextureStorageInterface *getBaseLevelStorage();
Jamie Madilld3d2a342013-10-07 10:46:35 -0400207 virtual const rx::Image *getBaseLevelImage() const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000208
209 bool isMipmapComplete() const;
Jamie Madill07bb8cf2013-10-24 17:49:44 -0400210 bool isValidLevel(int level) const;
Jamie Madill07edd442013-07-19 16:36:58 -0400211 bool isLevelComplete(int level) const;
Jamie Madill169d1112013-10-24 17:49:37 -0400212 void updateStorageLevel(int level);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000213
Geoff Lang005df412013-10-16 14:12:50 -0400214 void redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000215 void commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
216
daniel@transgaming.comd9ec9022012-12-20 20:52:16 +0000217 rx::Image *mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000218
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000219 rx::TextureStorageInterface2D *mTexStorage;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000220 egl::Surface *mSurface;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000221};
222
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000223class TextureCubeMap : public Texture
224{
225 public:
daniel@transgaming.com370482e2012-11-28 19:32:13 +0000226 TextureCubeMap(rx::Renderer *renderer, GLuint id);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000227
228 ~TextureCubeMap();
229
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000230 GLsizei getWidth(GLenum target, GLint level) const;
231 GLsizei getHeight(GLenum target, GLint level) const;
232 GLenum getInternalFormat(GLenum target, GLint level) const;
daniel@transgaming.com20d36662012-10-31 19:51:43 +0000233 GLenum getActualFormat(GLenum target, GLint level) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000234 bool isCompressed(GLenum target, GLint level) const;
Geoff Lang8040f572013-07-25 16:49:54 -0400235 bool isDepth(GLenum target, GLint level) const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000236
Geoff Lang005df412013-10-16 14:12:50 -0400237 void setImagePosX(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
238 void setImageNegX(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
239 void setImagePosY(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
240 void setImageNegY(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
241 void setImagePosZ(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
242 void setImageNegZ(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000243
Jamie Madill2db197c2013-10-24 17:49:35 -0400244 void setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000245
Jamie Madill88f18f42013-09-18 14:36:19 -0400246 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 +0000247 void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
248 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 +0000249 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 +0000250 void storage(GLsizei levels, GLenum internalformat, GLsizei size);
251
Jamie Madillf8989902013-07-19 16:36:58 -0400252 virtual bool isSamplerComplete(const SamplerState &samplerState) const;
Jamie Madillc1f8b162013-10-07 10:46:38 -0400253 bool isCubeComplete() const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000254
255 virtual void generateMipmaps();
256
Jamie Madill2db197c2013-10-24 17:49:35 -0400257 unsigned int getRenderTargetSerial(GLenum target, GLint level);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000258
Jamie Madill2db197c2013-10-24 17:49:35 -0400259 static int targetToIndex(GLenum target);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000260
261 protected:
Jamie Madill3c7fa222014-06-05 13:08:51 -0400262 friend class TextureCubeMapAttachment;
Geoff Lang8040f572013-07-25 16:49:54 -0400263 rx::RenderTarget *getRenderTarget(GLenum target, GLint level);
264 rx::RenderTarget *getDepthStencil(GLenum target, GLint level);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000265
266 private:
267 DISALLOW_COPY_AND_ASSIGN(TextureCubeMap);
268
Jamie Madill73b5d062013-10-24 17:49:38 -0400269 virtual void initializeStorage(bool renderTarget);
Jamie Madill3c0989c2013-10-24 17:49:39 -0400270 rx::TextureStorageInterfaceCube *createCompleteStorage(bool renderTarget) const;
271 void setCompleteTexStorage(rx::TextureStorageInterfaceCube *newCompleteTexStorage);
272
Jamie Madill169d1112013-10-24 17:49:37 -0400273 virtual void updateStorage();
Jamie Madille83d1a92013-10-24 17:49:33 -0400274 virtual bool ensureRenderTarget();
Jamie Madill2ebab852013-10-24 17:49:42 -0400275 virtual rx::TextureStorageInterface *getBaseLevelStorage();
Jamie Madilld3d2a342013-10-07 10:46:35 -0400276 virtual const rx::Image *getBaseLevelImage() const;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000277
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000278 bool isMipmapCubeComplete() const;
Jamie Madill07bb8cf2013-10-24 17:49:44 -0400279 bool isValidFaceLevel(int faceIndex, int level) const;
Jamie Madill2db197c2013-10-24 17:49:35 -0400280 bool isFaceLevelComplete(int faceIndex, int level) const;
Jamie Madill169d1112013-10-24 17:49:37 -0400281 void updateStorageFaceLevel(int faceIndex, int level);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000282
Geoff Lang005df412013-10-16 14:12:50 -0400283 void setImage(int faceIndex, GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000284 void commitRect(int faceIndex, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
Geoff Lang005df412013-10-16 14:12:50 -0400285 void redefineImage(int faceIndex, GLint level, GLenum internalformat, GLsizei width, GLsizei height);
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000286
daniel@transgaming.comd9ec9022012-12-20 20:52:16 +0000287 rx::Image *mImageArray[6][IMPLEMENTATION_MAX_TEXTURE_LEVELS];
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000288
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000289 rx::TextureStorageInterfaceCube *mTexStorage;
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000290};
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000291
292class Texture3D : public Texture
293{
294 public:
295 Texture3D(rx::Renderer *renderer, GLuint id);
296
297 ~Texture3D();
298
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000299 GLsizei getWidth(GLint level) const;
300 GLsizei getHeight(GLint level) const;
301 GLsizei getDepth(GLint level) const;
302 GLenum getInternalFormat(GLint level) const;
303 GLenum getActualFormat(GLint level) const;
304 bool isCompressed(GLint level) const;
305 bool isDepth(GLint level) const;
306
Geoff Lang005df412013-10-16 14:12:50 -0400307 void setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000308 void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
Jamie Madill88f18f42013-09-18 14:36:19 -0400309 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 +0000310 void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
311 void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
312
313 virtual void generateMipmaps();
314 virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
315
Jamie Madillf8989902013-07-19 16:36:58 -0400316 virtual bool isSamplerComplete(const SamplerState &samplerState) const;
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000317 virtual bool isMipmapComplete() const;
318
Geoff Lang8040f572013-07-25 16:49:54 -0400319 unsigned int getRenderTargetSerial(GLint level, GLint layer);
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000320
321 protected:
Jamie Madill3c7fa222014-06-05 13:08:51 -0400322 friend class Texture3DAttachment;
Jamie Madilla2d4e552013-10-10 15:12:01 -0400323 rx::RenderTarget *getRenderTarget(GLint level);
Geoff Lang8040f572013-07-25 16:49:54 -0400324 rx::RenderTarget *getRenderTarget(GLint level, GLint layer);
325 rx::RenderTarget *getDepthStencil(GLint level, GLint layer);
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000326
327 private:
328 DISALLOW_COPY_AND_ASSIGN(Texture3D);
329
Jamie Madill73b5d062013-10-24 17:49:38 -0400330 virtual void initializeStorage(bool renderTarget);
Jamie Madille664e202013-10-24 17:49:40 -0400331 rx::TextureStorageInterface3D *createCompleteStorage(bool renderTarget) const;
332 void setCompleteTexStorage(rx::TextureStorageInterface3D *newCompleteTexStorage);
333
Jamie Madill169d1112013-10-24 17:49:37 -0400334 virtual void updateStorage();
Jamie Madille83d1a92013-10-24 17:49:33 -0400335 virtual bool ensureRenderTarget();
336
Jamie Madill2ebab852013-10-24 17:49:42 -0400337 virtual rx::TextureStorageInterface *getBaseLevelStorage();
Jamie Madilld3d2a342013-10-07 10:46:35 -0400338 virtual const rx::Image *getBaseLevelImage() const;
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000339
Geoff Lang005df412013-10-16 14:12:50 -0400340 void redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000341 void commitRect(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);
342
Jamie Madill07bb8cf2013-10-24 17:49:44 -0400343 bool isValidLevel(int level) const;
Jamie Madill07edd442013-07-19 16:36:58 -0400344 bool isLevelComplete(int level) const;
Jamie Madill169d1112013-10-24 17:49:37 -0400345 void updateStorageLevel(int level);
Jamie Madill07edd442013-07-19 16:36:58 -0400346
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000347 rx::Image *mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
348
349 rx::TextureStorageInterface3D *mTexStorage;
shannon.woods%transgaming.com@gtempaccount.com95996562013-04-13 03:44:58 +0000350};
351
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000352class Texture2DArray : public Texture
353{
354 public:
355 Texture2DArray(rx::Renderer *renderer, GLuint id);
356
357 ~Texture2DArray();
358
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000359 GLsizei getWidth(GLint level) const;
360 GLsizei getHeight(GLint level) const;
Jamie Madillb8f8b892014-01-07 10:12:50 -0500361 GLsizei getLayers(GLint level) const;
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000362 GLenum getInternalFormat(GLint level) const;
363 GLenum getActualFormat(GLint level) const;
364 bool isCompressed(GLint level) const;
365 bool isDepth(GLint level) const;
366
Geoff Lang005df412013-10-16 14:12:50 -0400367 void setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000368 void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
Jamie Madill88f18f42013-09-18 14:36:19 -0400369 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 +0000370 void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
371 void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
372
373 virtual void generateMipmaps();
374 virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
375
Jamie Madillf8989902013-07-19 16:36:58 -0400376 virtual bool isSamplerComplete(const SamplerState &samplerState) const;
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000377 virtual bool isMipmapComplete() const;
378
Geoff Lang8040f572013-07-25 16:49:54 -0400379 unsigned int getRenderTargetSerial(GLint level, GLint layer);
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000380
381 protected:
Jamie Madill3c7fa222014-06-05 13:08:51 -0400382 friend class Texture2DArrayAttachment;
Geoff Lang8040f572013-07-25 16:49:54 -0400383 rx::RenderTarget *getRenderTarget(GLint level, GLint layer);
384 rx::RenderTarget *getDepthStencil(GLint level, GLint layer);
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000385
386 private:
387 DISALLOW_COPY_AND_ASSIGN(Texture2DArray);
388
Jamie Madill73b5d062013-10-24 17:49:38 -0400389 virtual void initializeStorage(bool renderTarget);
Jamie Madill884a4622013-10-24 17:49:41 -0400390 rx::TextureStorageInterface2DArray *createCompleteStorage(bool renderTarget) const;
391 void setCompleteTexStorage(rx::TextureStorageInterface2DArray *newCompleteTexStorage);
392
Jamie Madill169d1112013-10-24 17:49:37 -0400393 virtual void updateStorage();
Jamie Madille83d1a92013-10-24 17:49:33 -0400394 virtual bool ensureRenderTarget();
395
Jamie Madill2ebab852013-10-24 17:49:42 -0400396 virtual rx::TextureStorageInterface *getBaseLevelStorage();
Jamie Madilld3d2a342013-10-07 10:46:35 -0400397 virtual const rx::Image *getBaseLevelImage() const;
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000398
Jamie Madill884a4622013-10-24 17:49:41 -0400399 void deleteImages();
Geoff Lang005df412013-10-16 14:12:50 -0400400 void redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000401 void commitRect(GLint level, GLint xoffset, GLint yoffset, GLint layerTarget, GLsizei width, GLsizei height);
402
Jamie Madill07bb8cf2013-10-24 17:49:44 -0400403 bool isValidLevel(int level) const;
Jamie Madill07edd442013-07-19 16:36:58 -0400404 bool isLevelComplete(int level) const;
Jamie Madill169d1112013-10-24 17:49:37 -0400405 void updateStorageLevel(int level);
Jamie Madill07edd442013-07-19 16:36:58 -0400406
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000407 // Storing images as an array of single depth textures since D3D11 treats each array level of a
408 // Texture2D object as a separate subresource. Each layer would have to be looped over
409 // to update all the texture layers since they cannot all be updated at once and it makes the most
410 // 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 +0000411 GLsizei mLayerCounts[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
shannonwoods@chromium.org644f7662013-05-30 00:02:07 +0000412 rx::Image **mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000413
414 rx::TextureStorageInterface2DArray *mTexStorage;
shannon.woods%transgaming.com@gtempaccount.com7625f792013-04-13 03:46:07 +0000415};
416
daniel@transgaming.com95a758f2012-07-12 15:17:06 +0000417}
418
jbauman@chromium.org68715282012-07-12 23:28:41 +0000419#endif // LIBGLESV2_TEXTURE_H_