blob: f27879db840fb525d9c80c60f9c1497c4375de6e [file] [log] [blame]
Nicolas Capens0bac2852016-05-07 06:09:58 -04001// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// Texture.h: Defines the abstract Texture class and its concrete derived
16// classes Texture2D and TextureCubeMap. Implements GL texture objects and
17// related functionality. [OpenGL ES 2.0.24] section 3.7 page 63.
18
19#ifndef LIBGLESV2_TEXTURE_H_
20#define LIBGLESV2_TEXTURE_H_
21
22#include "Renderbuffer.h"
23#include "common/Object.hpp"
24#include "utilities.h"
25#include "libEGL/Texture.hpp"
26#include "common/debug.h"
27
28#include <GLES2/gl2.h>
29
30#include <vector>
31
Nicolas Capens31c07a32017-06-13 23:44:13 -040032namespace gl { class Surface; }
Nicolas Capens0bac2852016-05-07 06:09:58 -040033
34namespace es2
35{
Nicolas Capens36552092018-09-07 00:03:22 -040036class Sampler;
37
Nicolas Capens0bac2852016-05-07 06:09:58 -040038enum
39{
40 IMPLEMENTATION_MAX_TEXTURE_LEVELS = sw::MIPMAP_LEVELS,
41 IMPLEMENTATION_MAX_TEXTURE_SIZE = 1 << (IMPLEMENTATION_MAX_TEXTURE_LEVELS - 1),
Nicolas Capensefdf1032018-05-08 16:03:16 -040042 IMPLEMENTATION_MAX_3D_TEXTURE_SIZE = IMPLEMENTATION_MAX_TEXTURE_SIZE,
43 IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE = IMPLEMENTATION_MAX_TEXTURE_SIZE,
44 IMPLEMENTATION_MAX_ARRAY_TEXTURE_LAYERS = IMPLEMENTATION_MAX_TEXTURE_SIZE,
Nicolas Capens0bac2852016-05-07 06:09:58 -040045 IMPLEMENTATION_MAX_RENDERBUFFER_SIZE = sw::OUTLINE_RESOLUTION,
46};
47
Alexis Hetucf47cfd2018-09-04 11:30:22 -040048class ImageLevels
49{
50public:
51 inline const egl::Image* operator[](size_t index) const
52 {
53 return (index < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? image[index] : nullptr;
54 }
55
56 inline egl::Image*& operator[](size_t index)
57 {
58 if(index < IMPLEMENTATION_MAX_TEXTURE_LEVELS)
59 {
60 return image[index];
61 }
62
Alexis Hetu0ab9f3b2018-11-26 17:25:23 -050063 return getNullImage();
Alexis Hetucf47cfd2018-09-04 11:30:22 -040064 }
65
66 inline void release()
67 {
68 for(int i = 0; i < IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
69 {
70 if(image[i])
71 {
72 image[i]->release();
73 image[i] = nullptr;
74 }
75 }
76 }
77
78 inline void unbind(const egl::Texture* texture)
79 {
80 for(int i = 0; i < IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
81 {
82 if(image[i])
83 {
84 image[i]->unbind(texture);
85 image[i] = nullptr;
86 }
87 }
88 }
89
90private:
91 egl::Image *image[IMPLEMENTATION_MAX_TEXTURE_LEVELS] = {};
Alexis Hetu0ab9f3b2018-11-26 17:25:23 -050092 static egl::Image*& getNullImage();
Alexis Hetucf47cfd2018-09-04 11:30:22 -040093};
94
Nicolas Capens0bac2852016-05-07 06:09:58 -040095class Texture : public egl::Texture
96{
97public:
98 explicit Texture(GLuint name);
99
Nicolas Capens74a45042017-06-27 17:03:24 -0400100 sw::Resource *getResource() const override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400101
102 virtual void addProxyRef(const Renderbuffer *proxy) = 0;
103 virtual void releaseProxy(const Renderbuffer *proxy) = 0;
104
105 virtual GLenum getTarget() const = 0;
106
107 bool setMinFilter(GLenum filter);
108 bool setMagFilter(GLenum filter);
109 bool setWrapS(GLenum wrap);
110 bool setWrapT(GLenum wrap);
111 bool setWrapR(GLenum wrap);
112 bool setMaxAnisotropy(GLfloat textureMaxAnisotropy);
113 bool setBaseLevel(GLint baseLevel);
114 bool setCompareFunc(GLenum compareFunc);
115 bool setCompareMode(GLenum compareMode);
116 void makeImmutable(GLsizei levels);
117 bool setMaxLevel(GLint maxLevel);
118 bool setMaxLOD(GLfloat maxLOD);
119 bool setMinLOD(GLfloat minLOD);
120 bool setSwizzleR(GLenum swizzleR);
121 bool setSwizzleG(GLenum swizzleG);
122 bool setSwizzleB(GLenum swizzleB);
123 bool setSwizzleA(GLenum swizzleA);
124
Nicolas Capenseab70762018-02-06 16:49:36 -0500125 GLenum getMinFilter() const { return mMinFilter; }
126 GLenum getMagFilter() const { return mMagFilter; }
127 GLenum getWrapS() const { return mWrapS; }
128 GLenum getWrapT() const { return mWrapT; }
129 GLenum getWrapR() const { return mWrapR; }
130 GLfloat getMaxAnisotropy() const { return mMaxAnisotropy; }
131 GLint getBaseLevel() const { return mBaseLevel; }
132 GLenum getCompareFunc() const { return mCompareFunc; }
133 GLenum getCompareMode() const { return mCompareMode; }
134 GLboolean getImmutableFormat() const { return mImmutableFormat; }
135 GLsizei getImmutableLevels() const { return mImmutableLevels; }
136 GLint getMaxLevel() const { return mMaxLevel; }
137 GLfloat getMaxLOD() const { return mMaxLOD; }
138 GLfloat getMinLOD() const { return mMinLOD; }
139 GLenum getSwizzleR() const { return mSwizzleR; }
140 GLenum getSwizzleG() const { return mSwizzleG; }
141 GLenum getSwizzleB() const { return mSwizzleB; }
142 GLenum getSwizzleA() const { return mSwizzleA; }
Nicolas Capens0bac2852016-05-07 06:09:58 -0400143
144 virtual GLsizei getWidth(GLenum target, GLint level) const = 0;
145 virtual GLsizei getHeight(GLenum target, GLint level) const = 0;
146 virtual GLsizei getDepth(GLenum target, GLint level) const;
Nicolas Capens3e5f6fd2018-02-26 17:47:06 -0500147 virtual GLint getFormat(GLenum target, GLint level) const = 0;
Nicolas Capensb3f54e82017-12-19 13:38:18 -0500148 virtual int getTopLevel() const = 0;
Alexis Hetu88482c32018-06-05 17:05:17 -0400149 virtual bool requiresSync() const = 0;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400150
Nicolas Capens36552092018-09-07 00:03:22 -0400151 virtual bool isSamplerComplete(Sampler *sampler) const = 0;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400152 virtual bool isCompressed(GLenum target, GLint level) const = 0;
153 virtual bool isDepth(GLenum target, GLint level) const = 0;
154
Nicolas Capensc4a3f242017-12-11 15:07:53 -0500155 virtual Renderbuffer *getRenderbuffer(GLenum target, GLint level) = 0;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400156 virtual egl::Image *getRenderTarget(GLenum target, unsigned int level) = 0;
Nicolas Capens74a45042017-06-27 17:03:24 -0400157 egl::Image *createSharedImage(GLenum target, unsigned int level);
Nicolas Capens0bac2852016-05-07 06:09:58 -0400158 virtual bool isShared(GLenum target, unsigned int level) const = 0;
159
160 virtual void generateMipmaps() = 0;
Nicolas Capens1529c2c2018-02-06 14:44:47 -0500161 virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Renderbuffer *source) = 0;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400162
163protected:
Nicolas Capens74a45042017-06-27 17:03:24 -0400164 ~Texture() override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400165
Nicolas Capens3b4a25c2018-02-22 20:14:07 -0500166 void setImage(GLenum format, GLenum type, const gl::PixelStorageModes &unpackParameters, const void *pixels, egl::Image *image);
167 void subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelStorageModes &unpackParameters, const void *pixels, egl::Image *image);
Nicolas Capens0bac2852016-05-07 06:09:58 -0400168 void setCompressedImage(GLsizei imageSize, const void *pixels, egl::Image *image);
169 void subImageCompressed(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels, egl::Image *image);
170
Nicolas Capensc61f46b2017-12-04 16:07:22 -0500171 bool copy(egl::Image *source, const sw::SliceRect &sourceRect, GLint xoffset, GLint yoffset, GLint zoffset, egl::Image *dest);
Nicolas Capens0bac2852016-05-07 06:09:58 -0400172
Nicolas Capens36552092018-09-07 00:03:22 -0400173 bool isMipmapFiltered(Sampler *sampler) const;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400174
175 GLenum mMinFilter;
176 GLenum mMagFilter;
177 GLenum mWrapS;
178 GLenum mWrapT;
179 GLenum mWrapR;
180 GLfloat mMaxAnisotropy;
181 GLint mBaseLevel;
182 GLenum mCompareFunc;
183 GLenum mCompareMode;
184 GLboolean mImmutableFormat;
185 GLsizei mImmutableLevels;
186 GLint mMaxLevel;
187 GLfloat mMaxLOD;
188 GLfloat mMinLOD;
189 GLenum mSwizzleR;
190 GLenum mSwizzleG;
191 GLenum mSwizzleB;
192 GLenum mSwizzleA;
193
194 sw::Resource *resource;
195};
196
197class Texture2D : public Texture
198{
199public:
200 explicit Texture2D(GLuint name);
201
202 void addProxyRef(const Renderbuffer *proxy) override;
203 void releaseProxy(const Renderbuffer *proxy) override;
204 void sweep() override;
205
Nicolas Capens74a45042017-06-27 17:03:24 -0400206 GLenum getTarget() const override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400207
Nicolas Capens74a45042017-06-27 17:03:24 -0400208 GLsizei getWidth(GLenum target, GLint level) const override;
209 GLsizei getHeight(GLenum target, GLint level) const override;
Nicolas Capens3e5f6fd2018-02-26 17:47:06 -0500210 GLint getFormat(GLenum target, GLint level) const override;
Nicolas Capensb3f54e82017-12-19 13:38:18 -0500211 int getTopLevel() const override;
Alexis Hetu88482c32018-06-05 17:05:17 -0400212 bool requiresSync() const override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400213
Nicolas Capens3b4a25c2018-02-22 20:14:07 -0500214 void setImage(GLint level, GLsizei width, GLsizei height, GLint internalformat, GLenum format, GLenum type, const gl::PixelStorageModes &unpackParameters, const void *pixels);
Nicolas Capens0bac2852016-05-07 06:09:58 -0400215 void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
Nicolas Capens3b4a25c2018-02-22 20:14:07 -0500216 void subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const gl::PixelStorageModes &unpackParameters, const void *pixels);
Nicolas Capens0bac2852016-05-07 06:09:58 -0400217 void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
Nicolas Capens3b4a25c2018-02-22 20:14:07 -0500218 void copyImage(GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, Renderbuffer *source);
Nicolas Capens1529c2c2018-02-06 14:44:47 -0500219 void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Renderbuffer *source) override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400220
Nicolas Capens58df2f62016-06-07 14:48:56 -0400221 void setSharedImage(egl::Image *image);
Nicolas Capens0bac2852016-05-07 06:09:58 -0400222
Nicolas Capens36552092018-09-07 00:03:22 -0400223 bool isSamplerComplete(Sampler *sampler) const override;
Nicolas Capens74a45042017-06-27 17:03:24 -0400224 bool isCompressed(GLenum target, GLint level) const override;
225 bool isDepth(GLenum target, GLint level) const override;
226 void bindTexImage(gl::Surface *surface);
227 void releaseTexImage() override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400228
Nicolas Capens74a45042017-06-27 17:03:24 -0400229 void generateMipmaps() override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400230
Nicolas Capensc4a3f242017-12-11 15:07:53 -0500231 Renderbuffer *getRenderbuffer(GLenum target, GLint level) override;
Nicolas Capens74a45042017-06-27 17:03:24 -0400232 egl::Image *getRenderTarget(GLenum target, unsigned int level) override;
233 bool isShared(GLenum target, unsigned int level) const override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400234
235 egl::Image *getImage(unsigned int level);
236
237protected:
Nicolas Capens74a45042017-06-27 17:03:24 -0400238 ~Texture2D() override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400239
240 bool isMipmapComplete() const;
241
Alexis Hetucf47cfd2018-09-04 11:30:22 -0400242 ImageLevels image;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400243
Nicolas Capens31c07a32017-06-13 23:44:13 -0400244 gl::Surface *mSurface;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400245
246 // A specific internal reference count is kept for colorbuffer proxy references,
247 // because, as the renderbuffer acting as proxy will maintain a binding pointer
248 // back to this texture, there would be a circular reference if we used a binding
249 // pointer here. This reference count will cause the pointer to be set to null if
250 // the count drops to zero, but will not cause deletion of the Renderbuffer.
251 Renderbuffer *mColorbufferProxy;
252 unsigned int mProxyRefs;
253};
254
Alexis Hetu46768622018-01-16 22:09:28 -0500255class Texture2DRect : public Texture2D
256{
257public:
258 explicit Texture2DRect(GLuint name);
259
260 GLenum getTarget() const override;
Alexis Hetu0988fb82018-02-02 17:23:48 -0500261
262 Renderbuffer *getRenderbuffer(GLenum target, GLint level) override;
Alexis Hetu46768622018-01-16 22:09:28 -0500263};
264
Nicolas Capens0bac2852016-05-07 06:09:58 -0400265class TextureCubeMap : public Texture
266{
267public:
268 explicit TextureCubeMap(GLuint name);
269
270 void addProxyRef(const Renderbuffer *proxy) override;
271 void releaseProxy(const Renderbuffer *proxy) override;
272 void sweep() override;
273
Nicolas Capens74a45042017-06-27 17:03:24 -0400274 GLenum getTarget() const override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400275
Nicolas Capens74a45042017-06-27 17:03:24 -0400276 GLsizei getWidth(GLenum target, GLint level) const override;
277 GLsizei getHeight(GLenum target, GLint level) const override;
Nicolas Capens3e5f6fd2018-02-26 17:47:06 -0500278 GLint getFormat(GLenum target, GLint level) const override;
Nicolas Capensb3f54e82017-12-19 13:38:18 -0500279 int getTopLevel() const override;
Alexis Hetu88482c32018-06-05 17:05:17 -0400280 bool requiresSync() const override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400281
Nicolas Capens3b4a25c2018-02-22 20:14:07 -0500282 void setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLint internalformat, GLenum format, GLenum type, const gl::PixelStorageModes &unpackParameters, const void *pixels);
Nicolas Capens0bac2852016-05-07 06:09:58 -0400283 void setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
284
Nicolas Capens3b4a25c2018-02-22 20:14:07 -0500285 void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const gl::PixelStorageModes &unpackParameters, const void *pixels);
Nicolas Capens0bac2852016-05-07 06:09:58 -0400286 void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
Nicolas Capens3b4a25c2018-02-22 20:14:07 -0500287 void copyImage(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, Renderbuffer *source);
Nicolas Capens1529c2c2018-02-06 14:44:47 -0500288 void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Renderbuffer *source) override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400289
Nicolas Capens36552092018-09-07 00:03:22 -0400290 bool isSamplerComplete(Sampler *sampler) const override;
Nicolas Capens74a45042017-06-27 17:03:24 -0400291 bool isCompressed(GLenum target, GLint level) const override;
292 bool isDepth(GLenum target, GLint level) const override;
293 void releaseTexImage() override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400294
Nicolas Capens74a45042017-06-27 17:03:24 -0400295 void generateMipmaps() override;
Alexis Hetua76a1bf2016-11-29 17:17:26 -0500296 void updateBorders(int level);
Nicolas Capens0bac2852016-05-07 06:09:58 -0400297
Nicolas Capensc4a3f242017-12-11 15:07:53 -0500298 Renderbuffer *getRenderbuffer(GLenum target, GLint level) override;
Nicolas Capens74a45042017-06-27 17:03:24 -0400299 egl::Image *getRenderTarget(GLenum target, unsigned int level) override;
300 bool isShared(GLenum target, unsigned int level) const override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400301
302 egl::Image *getImage(int face, unsigned int level);
303
Nicolas Capens5fc1e752017-12-19 10:35:40 -0500304 bool isCubeComplete() const;
305
Nicolas Capens0bac2852016-05-07 06:09:58 -0400306protected:
Nicolas Capens74a45042017-06-27 17:03:24 -0400307 ~TextureCubeMap() override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400308
309private:
Nicolas Capens0bac2852016-05-07 06:09:58 -0400310 bool isMipmapCubeComplete() const;
311
312 // face is one of the GL_TEXTURE_CUBE_MAP_* enumerants. Returns nullptr on failure.
313 egl::Image *getImage(GLenum face, unsigned int level);
314
Alexis Hetucf47cfd2018-09-04 11:30:22 -0400315 ImageLevels image[6];
Nicolas Capens0bac2852016-05-07 06:09:58 -0400316
317 // A specific internal reference count is kept for colorbuffer proxy references,
318 // because, as the renderbuffer acting as proxy will maintain a binding pointer
319 // back to this texture, there would be a circular reference if we used a binding
320 // pointer here. This reference count will cause the pointer to be set to null if
321 // the count drops to zero, but will not cause deletion of the Renderbuffer.
322 Renderbuffer *mFaceProxies[6];
323 unsigned int mFaceProxyRefs[6];
324};
325
326class Texture3D : public Texture
327{
328public:
329 explicit Texture3D(GLuint name);
330
331 void addProxyRef(const Renderbuffer *proxy) override;
332 void releaseProxy(const Renderbuffer *proxy) override;
333 void sweep() override;
334
Nicolas Capens74a45042017-06-27 17:03:24 -0400335 GLenum getTarget() const override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400336
Nicolas Capens74a45042017-06-27 17:03:24 -0400337 GLsizei getWidth(GLenum target, GLint level) const override;
338 GLsizei getHeight(GLenum target, GLint level) const override;
339 GLsizei getDepth(GLenum target, GLint level) const override;
Nicolas Capens3e5f6fd2018-02-26 17:47:06 -0500340 GLint getFormat(GLenum target, GLint level) const override;
Nicolas Capensb3f54e82017-12-19 13:38:18 -0500341 int getTopLevel() const override;
Alexis Hetu88482c32018-06-05 17:05:17 -0400342 bool requiresSync() const override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400343
Nicolas Capens3b4a25c2018-02-22 20:14:07 -0500344 void setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLint internalformat, GLenum format, GLenum type, const gl::PixelStorageModes &unpackParameters, const void *pixels);
Nicolas Capens0bac2852016-05-07 06:09:58 -0400345 void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
Nicolas Capens3b4a25c2018-02-22 20:14:07 -0500346 void subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelStorageModes &unpackParameters, const void *pixels);
Nicolas Capens0bac2852016-05-07 06:09:58 -0400347 void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
Nicolas Capens3b4a25c2018-02-22 20:14:07 -0500348 void copyImage(GLint level, GLenum internalformat, GLint x, GLint y, GLint z, GLsizei width, GLsizei height, GLsizei depth, Renderbuffer *source);
Takuto Ikutabf58b982018-04-25 22:57:42 +0900349 void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Renderbuffer *source) override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400350
Nicolas Capens58df2f62016-06-07 14:48:56 -0400351 void setSharedImage(egl::Image *image);
Nicolas Capens0bac2852016-05-07 06:09:58 -0400352
Nicolas Capens36552092018-09-07 00:03:22 -0400353 bool isSamplerComplete(Sampler *sampler) const override;
Nicolas Capens74a45042017-06-27 17:03:24 -0400354 bool isCompressed(GLenum target, GLint level) const override;
355 bool isDepth(GLenum target, GLint level) const override;
356 void releaseTexImage() override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400357
Nicolas Capens74a45042017-06-27 17:03:24 -0400358 void generateMipmaps() override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400359
Nicolas Capensc4a3f242017-12-11 15:07:53 -0500360 Renderbuffer *getRenderbuffer(GLenum target, GLint level) override;
Nicolas Capens74a45042017-06-27 17:03:24 -0400361 egl::Image *getRenderTarget(GLenum target, unsigned int level) override;
362 bool isShared(GLenum target, unsigned int level) const override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400363
364 egl::Image *getImage(unsigned int level);
365
366protected:
Nicolas Capens74a45042017-06-27 17:03:24 -0400367 ~Texture3D() override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400368
369 bool isMipmapComplete() const;
370
Alexis Hetucf47cfd2018-09-04 11:30:22 -0400371 ImageLevels image;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400372
Nicolas Capens31c07a32017-06-13 23:44:13 -0400373 gl::Surface *mSurface;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400374
375 // A specific internal reference count is kept for colorbuffer proxy references,
376 // because, as the renderbuffer acting as proxy will maintain a binding pointer
377 // back to this texture, there would be a circular reference if we used a binding
378 // pointer here. This reference count will cause the pointer to be set to null if
379 // the count drops to zero, but will not cause deletion of the Renderbuffer.
380 Renderbuffer *mColorbufferProxy;
381 unsigned int mProxyRefs;
382};
383
384class Texture2DArray : public Texture3D
385{
386public:
387 explicit Texture2DArray(GLuint name);
388
Nicolas Capens74a45042017-06-27 17:03:24 -0400389 GLenum getTarget() const override;
390 void generateMipmaps() override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400391
392protected:
Nicolas Capens74a45042017-06-27 17:03:24 -0400393 ~Texture2DArray() override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400394};
395
396class TextureExternal : public Texture2D
397{
398public:
399 explicit TextureExternal(GLuint name);
400
Nicolas Capens74a45042017-06-27 17:03:24 -0400401 GLenum getTarget() const override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400402
403protected:
Nicolas Capens74a45042017-06-27 17:03:24 -0400404 ~TextureExternal() override;
Nicolas Capens0bac2852016-05-07 06:09:58 -0400405};
406}
407
408#endif // LIBGLESV2_TEXTURE_H_