daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 1 | // |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2 | // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 3 | // 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.cpp: Implements the gl::Texture class and its derived classes |
| 8 | // Texture2D and TextureCubeMap. Implements GL texture objects and related |
| 9 | // functionality. [OpenGL ES 2.0.24] section 3.7 page 63. |
| 10 | |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 11 | #include "libANGLE/Texture.h" |
| 12 | #include "libANGLE/Context.h" |
| 13 | #include "libANGLE/formatutils.h" |
| 14 | #include "libANGLE/ImageIndex.h" |
| 15 | #include "libANGLE/Renderbuffer.h" |
| 16 | #include "libANGLE/renderer/Image.h" |
| 17 | #include "libANGLE/renderer/d3d/TextureStorage.h" |
Geoff Lang | 0b7eef7 | 2014-06-12 14:10:47 -0400 | [diff] [blame] | 18 | |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 19 | #include "libANGLE/Surface.h" |
Geoff Lang | 0b7eef7 | 2014-06-12 14:10:47 -0400 | [diff] [blame] | 20 | |
| 21 | #include "common/mathutil.h" |
| 22 | #include "common/utilities.h" |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 23 | |
| 24 | namespace gl |
| 25 | { |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 26 | |
Brandon Jones | 6053a52 | 2014-07-25 16:22:09 -0700 | [diff] [blame] | 27 | bool IsMipmapFiltered(const gl::SamplerState &samplerState) |
| 28 | { |
| 29 | switch (samplerState.minFilter) |
| 30 | { |
| 31 | case GL_NEAREST: |
| 32 | case GL_LINEAR: |
| 33 | return false; |
| 34 | case GL_NEAREST_MIPMAP_NEAREST: |
| 35 | case GL_LINEAR_MIPMAP_NEAREST: |
| 36 | case GL_NEAREST_MIPMAP_LINEAR: |
| 37 | case GL_LINEAR_MIPMAP_LINEAR: |
| 38 | return true; |
| 39 | default: UNREACHABLE(); |
| 40 | return false; |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | bool IsPointSampled(const gl::SamplerState &samplerState) |
| 45 | { |
| 46 | return (samplerState.magFilter == GL_NEAREST && (samplerState.minFilter == GL_NEAREST || samplerState.minFilter == GL_NEAREST_MIPMAP_NEAREST)); |
| 47 | } |
| 48 | |
Jamie Madill | 10ef215 | 2014-10-20 17:04:34 -0400 | [diff] [blame] | 49 | unsigned int Texture::mCurrentTextureSerial = 1; |
| 50 | |
Brandon Jones | 6053a52 | 2014-07-25 16:22:09 -0700 | [diff] [blame] | 51 | Texture::Texture(rx::TextureImpl *impl, GLuint id, GLenum target) |
Brandon Jones | f47bebc | 2014-07-09 14:28:42 -0700 | [diff] [blame] | 52 | : RefCountObject(id), |
Brandon Jones | 6053a52 | 2014-07-25 16:22:09 -0700 | [diff] [blame] | 53 | mTexture(impl), |
Jamie Madill | 10ef215 | 2014-10-20 17:04:34 -0400 | [diff] [blame] | 54 | mTextureSerial(issueTextureSerial()), |
Brandon Jones | f47bebc | 2014-07-09 14:28:42 -0700 | [diff] [blame] | 55 | mUsage(GL_NONE), |
Jamie Madill | 6948e30 | 2014-10-20 17:04:33 -0400 | [diff] [blame] | 56 | mImmutableLevelCount(0), |
Brandon Jones | f47bebc | 2014-07-09 14:28:42 -0700 | [diff] [blame] | 57 | mTarget(target) |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 58 | { |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | Texture::~Texture() |
| 62 | { |
Brandon Jones | 6053a52 | 2014-07-25 16:22:09 -0700 | [diff] [blame] | 63 | SafeDelete(mTexture); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 64 | } |
| 65 | |
Geoff Lang | 4907f2c | 2013-07-25 12:53:57 -0400 | [diff] [blame] | 66 | GLenum Texture::getTarget() const |
| 67 | { |
| 68 | return mTarget; |
| 69 | } |
| 70 | |
Geoff Lang | 63b5f1f | 2013-09-23 14:52:14 -0400 | [diff] [blame] | 71 | void Texture::setUsage(GLenum usage) |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 72 | { |
Geoff Lang | 63b5f1f | 2013-09-23 14:52:14 -0400 | [diff] [blame] | 73 | mUsage = usage; |
Brandon Jones | cef06ff | 2014-08-05 13:27:48 -0700 | [diff] [blame] | 74 | getImplementation()->setUsage(usage); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 75 | } |
| 76 | |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 77 | GLenum Texture::getUsage() const |
| 78 | { |
| 79 | return mUsage; |
| 80 | } |
| 81 | |
Jamie Madill | d3d2a34 | 2013-10-07 10:46:35 -0400 | [diff] [blame] | 82 | GLint Texture::getBaseLevelWidth() const |
| 83 | { |
| 84 | const rx::Image *baseImage = getBaseLevelImage(); |
| 85 | return (baseImage ? baseImage->getWidth() : 0); |
| 86 | } |
| 87 | |
| 88 | GLint Texture::getBaseLevelHeight() const |
| 89 | { |
| 90 | const rx::Image *baseImage = getBaseLevelImage(); |
| 91 | return (baseImage ? baseImage->getHeight() : 0); |
| 92 | } |
| 93 | |
| 94 | GLint Texture::getBaseLevelDepth() const |
| 95 | { |
| 96 | const rx::Image *baseImage = getBaseLevelImage(); |
| 97 | return (baseImage ? baseImage->getDepth() : 0); |
| 98 | } |
| 99 | |
Jamie Madill | b8f8b89 | 2014-01-07 10:12:50 -0500 | [diff] [blame] | 100 | // Note: "base level image" is loosely defined to be any image from the base level, |
| 101 | // where in the base of 2D array textures and cube maps there are several. Don't use |
| 102 | // the base level image for anything except querying texture format and size. |
Jamie Madill | d3d2a34 | 2013-10-07 10:46:35 -0400 | [diff] [blame] | 103 | GLenum Texture::getBaseLevelInternalFormat() const |
| 104 | { |
| 105 | const rx::Image *baseImage = getBaseLevelImage(); |
| 106 | return (baseImage ? baseImage->getInternalFormat() : GL_NONE); |
| 107 | } |
| 108 | |
Jamie Madill | 945f732 | 2014-09-03 15:07:14 -0400 | [diff] [blame] | 109 | GLsizei Texture::getWidth(const ImageIndex &index) const |
| 110 | { |
Jamie Madill | feda4d2 | 2014-09-17 13:03:29 -0400 | [diff] [blame] | 111 | rx::Image *image = mTexture->getImage(index); |
Jamie Madill | 945f732 | 2014-09-03 15:07:14 -0400 | [diff] [blame] | 112 | return image->getWidth(); |
| 113 | } |
| 114 | |
| 115 | GLsizei Texture::getHeight(const ImageIndex &index) const |
| 116 | { |
Jamie Madill | feda4d2 | 2014-09-17 13:03:29 -0400 | [diff] [blame] | 117 | rx::Image *image = mTexture->getImage(index); |
Jamie Madill | 945f732 | 2014-09-03 15:07:14 -0400 | [diff] [blame] | 118 | return image->getHeight(); |
| 119 | } |
| 120 | |
| 121 | GLenum Texture::getInternalFormat(const ImageIndex &index) const |
| 122 | { |
Jamie Madill | feda4d2 | 2014-09-17 13:03:29 -0400 | [diff] [blame] | 123 | rx::Image *image = mTexture->getImage(index); |
Jamie Madill | 945f732 | 2014-09-03 15:07:14 -0400 | [diff] [blame] | 124 | return image->getInternalFormat(); |
| 125 | } |
| 126 | |
Geoff Lang | 06ecf3d | 2014-09-23 16:39:50 -0400 | [diff] [blame] | 127 | Error Texture::generateMipmaps() |
Brandon Jones | cef06ff | 2014-08-05 13:27:48 -0700 | [diff] [blame] | 128 | { |
Geoff Lang | 06ecf3d | 2014-09-23 16:39:50 -0400 | [diff] [blame] | 129 | return getImplementation()->generateMipmaps(); |
Brandon Jones | cef06ff | 2014-08-05 13:27:48 -0700 | [diff] [blame] | 130 | } |
| 131 | |
Geoff Lang | ef7b016 | 2014-09-04 13:29:23 -0400 | [diff] [blame] | 132 | Error Texture::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, |
| 133 | GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source) |
Brandon Jones | 6b19b00 | 2014-07-16 14:32:05 -0700 | [diff] [blame] | 134 | { |
Geoff Lang | ef7b016 | 2014-09-04 13:29:23 -0400 | [diff] [blame] | 135 | return mTexture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, source); |
Brandon Jones | 6b19b00 | 2014-07-16 14:32:05 -0700 | [diff] [blame] | 136 | } |
| 137 | |
Jamie Madill | 10ef215 | 2014-10-20 17:04:34 -0400 | [diff] [blame] | 138 | unsigned int Texture::getTextureSerial() const |
Brandon Jones | f47bebc | 2014-07-09 14:28:42 -0700 | [diff] [blame] | 139 | { |
Jamie Madill | 10ef215 | 2014-10-20 17:04:34 -0400 | [diff] [blame] | 140 | return mTextureSerial; |
| 141 | } |
| 142 | |
| 143 | unsigned int Texture::issueTextureSerial() |
| 144 | { |
| 145 | return mCurrentTextureSerial++; |
Brandon Jones | f47bebc | 2014-07-09 14:28:42 -0700 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | bool Texture::isImmutable() const |
| 149 | { |
Jamie Madill | 6948e30 | 2014-10-20 17:04:33 -0400 | [diff] [blame] | 150 | return (mImmutableLevelCount > 0); |
Brandon Jones | f47bebc | 2014-07-09 14:28:42 -0700 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | int Texture::immutableLevelCount() |
| 154 | { |
Jamie Madill | 6948e30 | 2014-10-20 17:04:33 -0400 | [diff] [blame] | 155 | return mImmutableLevelCount; |
Brandon Jones | f47bebc | 2014-07-09 14:28:42 -0700 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | int Texture::mipLevels() const |
| 159 | { |
| 160 | return log2(std::max(std::max(getBaseLevelWidth(), getBaseLevelHeight()), getBaseLevelDepth())) + 1; |
| 161 | } |
| 162 | |
Brandon Jones | cef06ff | 2014-08-05 13:27:48 -0700 | [diff] [blame] | 163 | const rx::Image *Texture::getBaseLevelImage() const |
| 164 | { |
| 165 | return (getImplementation()->getLayerCount(0) > 0 ? getImplementation()->getImage(0, 0) : NULL); |
| 166 | } |
| 167 | |
Brandon Jones | 6053a52 | 2014-07-25 16:22:09 -0700 | [diff] [blame] | 168 | Texture2D::Texture2D(rx::TextureImpl *impl, GLuint id) |
| 169 | : Texture(impl, id, GL_TEXTURE_2D) |
Jamie Madill | 22f843a | 2013-10-24 17:49:36 -0400 | [diff] [blame] | 170 | { |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 171 | mSurface = NULL; |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | Texture2D::~Texture2D() |
| 175 | { |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 176 | if (mSurface) |
| 177 | { |
Jamie Madill | fb0580a | 2014-11-27 14:03:52 -0500 | [diff] [blame] | 178 | mSurface->releaseTexImage(EGL_BACK_BUFFER); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 179 | mSurface = NULL; |
| 180 | } |
Brandon Jones | f47bebc | 2014-07-09 14:28:42 -0700 | [diff] [blame] | 181 | } |
daniel@transgaming.com | d9ec902 | 2012-12-20 20:52:16 +0000 | [diff] [blame] | 182 | |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 183 | GLsizei Texture2D::getWidth(GLint level) const |
| 184 | { |
| 185 | if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) |
Brandon Jones | cef06ff | 2014-08-05 13:27:48 -0700 | [diff] [blame] | 186 | return mTexture->getImage(level, 0)->getWidth(); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 187 | else |
| 188 | return 0; |
| 189 | } |
| 190 | |
| 191 | GLsizei Texture2D::getHeight(GLint level) const |
| 192 | { |
| 193 | if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) |
Brandon Jones | cef06ff | 2014-08-05 13:27:48 -0700 | [diff] [blame] | 194 | return mTexture->getImage(level, 0)->getHeight(); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 195 | else |
| 196 | return 0; |
| 197 | } |
| 198 | |
| 199 | GLenum Texture2D::getInternalFormat(GLint level) const |
| 200 | { |
| 201 | if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) |
Brandon Jones | cef06ff | 2014-08-05 13:27:48 -0700 | [diff] [blame] | 202 | return mTexture->getImage(level, 0)->getInternalFormat(); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 203 | else |
| 204 | return GL_NONE; |
| 205 | } |
| 206 | |
Geoff Lang | 1ba6b8d | 2014-08-28 10:57:31 -0400 | [diff] [blame] | 207 | Error Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels) |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 208 | { |
| 209 | releaseTexImage(); |
shannon.woods@transgaming.com | 8a40668 | 2013-02-28 23:15:26 +0000 | [diff] [blame] | 210 | |
Geoff Lang | 1ba6b8d | 2014-08-28 10:57:31 -0400 | [diff] [blame] | 211 | return mTexture->setImage(GL_TEXTURE_2D, level, width, height, 1, internalFormat, format, type, unpack, pixels); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | void Texture2D::bindTexImage(egl::Surface *surface) |
| 215 | { |
| 216 | releaseTexImage(); |
Brandon Jones | f47bebc | 2014-07-09 14:28:42 -0700 | [diff] [blame] | 217 | mTexture->bindTexImage(surface); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 218 | mSurface = surface; |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | void Texture2D::releaseTexImage() |
| 222 | { |
| 223 | if (mSurface) |
| 224 | { |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 225 | mSurface = NULL; |
Brandon Jones | f47bebc | 2014-07-09 14:28:42 -0700 | [diff] [blame] | 226 | mTexture->releaseTexImage(); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 227 | } |
| 228 | } |
| 229 | |
Geoff Lang | b534833 | 2014-09-02 13:16:34 -0400 | [diff] [blame] | 230 | Error Texture2D::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 231 | const PixelUnpackState &unpack, const void *pixels) |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 232 | { |
Brandon Jones | cef06ff | 2014-08-05 13:27:48 -0700 | [diff] [blame] | 233 | releaseTexImage(); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 234 | |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 235 | return mTexture->setCompressedImage(GL_TEXTURE_2D, level, format, width, height, 1, imageSize, unpack, pixels); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 236 | } |
| 237 | |
Geoff Lang | 1ba6b8d | 2014-08-28 10:57:31 -0400 | [diff] [blame] | 238 | Error Texture2D::subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels) |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 239 | { |
Geoff Lang | 1ba6b8d | 2014-08-28 10:57:31 -0400 | [diff] [blame] | 240 | return mTexture->subImage(GL_TEXTURE_2D, level, xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 241 | } |
| 242 | |
Geoff Lang | b534833 | 2014-09-02 13:16:34 -0400 | [diff] [blame] | 243 | Error Texture2D::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 244 | GLenum format, GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels) |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 245 | { |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 246 | return mTexture->subImageCompressed(GL_TEXTURE_2D, level, xoffset, yoffset, 0, width, height, 1, format, imageSize, unpack, pixels); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 247 | } |
| 248 | |
Geoff Lang | ef7b016 | 2014-09-04 13:29:23 -0400 | [diff] [blame] | 249 | Error Texture2D::copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, |
| 250 | Framebuffer *source) |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 251 | { |
Brandon Jones | cef06ff | 2014-08-05 13:27:48 -0700 | [diff] [blame] | 252 | releaseTexImage(); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 253 | |
Geoff Lang | ef7b016 | 2014-09-04 13:29:23 -0400 | [diff] [blame] | 254 | return mTexture->copyImage(GL_TEXTURE_2D, level, format, x, y, width, height, source); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 255 | } |
| 256 | |
Geoff Lang | 1f8532b | 2014-09-05 09:46:13 -0400 | [diff] [blame] | 257 | Error Texture2D::storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 258 | { |
Geoff Lang | 1f8532b | 2014-09-05 09:46:13 -0400 | [diff] [blame] | 259 | Error error = mTexture->storage(GL_TEXTURE_2D, levels, internalformat, width, height, 1); |
| 260 | if (error.isError()) |
| 261 | { |
| 262 | return error; |
| 263 | } |
| 264 | |
Jamie Madill | 6948e30 | 2014-10-20 17:04:33 -0400 | [diff] [blame] | 265 | mImmutableLevelCount = levels; |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 266 | |
Geoff Lang | 1f8532b | 2014-09-05 09:46:13 -0400 | [diff] [blame] | 267 | return Error(GL_NO_ERROR); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 268 | } |
| 269 | |
Brandon Jones | 6053a52 | 2014-07-25 16:22:09 -0700 | [diff] [blame] | 270 | // Tests for 2D texture sampling completeness. [OpenGL ES 2.0.24] section 3.8.2 page 85. |
Geoff Lang | f4134d2 | 2014-12-15 10:29:47 -0500 | [diff] [blame] | 271 | bool Texture2D::isSamplerComplete(const SamplerState &samplerState, const Data &data) const |
Brandon Jones | 6053a52 | 2014-07-25 16:22:09 -0700 | [diff] [blame] | 272 | { |
| 273 | GLsizei width = getBaseLevelWidth(); |
| 274 | GLsizei height = getBaseLevelHeight(); |
| 275 | |
| 276 | if (width <= 0 || height <= 0) |
| 277 | { |
| 278 | return false; |
| 279 | } |
| 280 | |
Geoff Lang | f4134d2 | 2014-12-15 10:29:47 -0500 | [diff] [blame] | 281 | if (!data.textureCaps->get(getInternalFormat(0)).filterable && !IsPointSampled(samplerState)) |
Brandon Jones | 6053a52 | 2014-07-25 16:22:09 -0700 | [diff] [blame] | 282 | { |
| 283 | return false; |
| 284 | } |
| 285 | |
Geoff Lang | f4134d2 | 2014-12-15 10:29:47 -0500 | [diff] [blame] | 286 | bool npotSupport = data.extensions->textureNPOT; |
Brandon Jones | 6053a52 | 2014-07-25 16:22:09 -0700 | [diff] [blame] | 287 | if (!npotSupport) |
| 288 | { |
| 289 | if ((samplerState.wrapS != GL_CLAMP_TO_EDGE && !gl::isPow2(width)) || |
| 290 | (samplerState.wrapT != GL_CLAMP_TO_EDGE && !gl::isPow2(height))) |
| 291 | { |
| 292 | return false; |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | if (IsMipmapFiltered(samplerState)) |
| 297 | { |
| 298 | if (!npotSupport) |
| 299 | { |
| 300 | if (!gl::isPow2(width) || !gl::isPow2(height)) |
| 301 | { |
| 302 | return false; |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | if (!isMipmapComplete()) |
| 307 | { |
| 308 | return false; |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | // OpenGLES 3.0.2 spec section 3.8.13 states that a texture is not mipmap complete if: |
| 313 | // The internalformat specified for the texture arrays is a sized internal depth or |
| 314 | // depth and stencil format (see table 3.13), the value of TEXTURE_COMPARE_- |
| 315 | // MODE is NONE, and either the magnification filter is not NEAREST or the mini- |
| 316 | // fication filter is neither NEAREST nor NEAREST_MIPMAP_NEAREST. |
| 317 | const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(getInternalFormat(0)); |
Geoff Lang | f4134d2 | 2014-12-15 10:29:47 -0500 | [diff] [blame] | 318 | if (formatInfo.depthBits > 0 && data.clientVersion > 2) |
Brandon Jones | 6053a52 | 2014-07-25 16:22:09 -0700 | [diff] [blame] | 319 | { |
| 320 | if (samplerState.compareMode == GL_NONE) |
| 321 | { |
| 322 | if ((samplerState.minFilter != GL_NEAREST && samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST) || |
| 323 | samplerState.magFilter != GL_NEAREST) |
| 324 | { |
| 325 | return false; |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | return true; |
| 331 | } |
| 332 | |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 333 | bool Texture2D::isCompressed(GLint level) const |
| 334 | { |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 335 | return GetInternalFormatInfo(getInternalFormat(level)).compressed; |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | bool Texture2D::isDepth(GLint level) const |
| 339 | { |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 340 | return GetInternalFormatInfo(getInternalFormat(level)).depthBits > 0; |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 341 | } |
| 342 | |
Geoff Lang | 06ecf3d | 2014-09-23 16:39:50 -0400 | [diff] [blame] | 343 | Error Texture2D::generateMipmaps() |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 344 | { |
Brandon Jones | cef06ff | 2014-08-05 13:27:48 -0700 | [diff] [blame] | 345 | releaseTexImage(); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 346 | |
Geoff Lang | 06ecf3d | 2014-09-23 16:39:50 -0400 | [diff] [blame] | 347 | return mTexture->generateMipmaps(); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 348 | } |
| 349 | |
Brandon Jones | 6053a52 | 2014-07-25 16:22:09 -0700 | [diff] [blame] | 350 | // Tests for 2D texture (mipmap) completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81. |
| 351 | bool Texture2D::isMipmapComplete() const |
| 352 | { |
| 353 | int levelCount = mipLevels(); |
| 354 | |
| 355 | for (int level = 0; level < levelCount; level++) |
| 356 | { |
| 357 | if (!isLevelComplete(level)) |
| 358 | { |
| 359 | return false; |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | return true; |
| 364 | } |
| 365 | |
| 366 | bool Texture2D::isLevelComplete(int level) const |
| 367 | { |
| 368 | if (isImmutable()) |
| 369 | { |
| 370 | return true; |
| 371 | } |
| 372 | |
| 373 | const rx::Image *baseImage = getBaseLevelImage(); |
| 374 | |
| 375 | GLsizei width = baseImage->getWidth(); |
| 376 | GLsizei height = baseImage->getHeight(); |
| 377 | |
| 378 | if (width <= 0 || height <= 0) |
| 379 | { |
| 380 | return false; |
| 381 | } |
| 382 | |
| 383 | // The base image level is complete if the width and height are positive |
| 384 | if (level == 0) |
| 385 | { |
| 386 | return true; |
| 387 | } |
| 388 | |
| 389 | ASSERT(level >= 1 && level < IMPLEMENTATION_MAX_TEXTURE_LEVELS && mTexture->getImage(level, 0) != NULL); |
| 390 | rx::Image *image = mTexture->getImage(level, 0); |
| 391 | |
| 392 | if (image->getInternalFormat() != baseImage->getInternalFormat()) |
| 393 | { |
| 394 | return false; |
| 395 | } |
| 396 | |
| 397 | if (image->getWidth() != std::max(1, width >> level)) |
| 398 | { |
| 399 | return false; |
| 400 | } |
| 401 | |
| 402 | if (image->getHeight() != std::max(1, height >> level)) |
| 403 | { |
| 404 | return false; |
| 405 | } |
| 406 | |
| 407 | return true; |
| 408 | } |
| 409 | |
| 410 | TextureCubeMap::TextureCubeMap(rx::TextureImpl *impl, GLuint id) |
| 411 | : Texture(impl, id, GL_TEXTURE_CUBE_MAP) |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 412 | { |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 413 | } |
| 414 | |
| 415 | TextureCubeMap::~TextureCubeMap() |
| 416 | { |
Brandon Jones | 0511e80 | 2014-07-14 16:27:26 -0700 | [diff] [blame] | 417 | } |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 418 | |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 419 | GLsizei TextureCubeMap::getWidth(GLenum target, GLint level) const |
| 420 | { |
| 421 | if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) |
Brandon Jones | cef06ff | 2014-08-05 13:27:48 -0700 | [diff] [blame] | 422 | return mTexture->getImage(level, targetToLayerIndex(target))->getWidth(); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 423 | else |
| 424 | return 0; |
| 425 | } |
| 426 | |
| 427 | GLsizei TextureCubeMap::getHeight(GLenum target, GLint level) const |
| 428 | { |
| 429 | if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) |
Brandon Jones | cef06ff | 2014-08-05 13:27:48 -0700 | [diff] [blame] | 430 | return mTexture->getImage(level, targetToLayerIndex(target))->getHeight(); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 431 | else |
| 432 | return 0; |
| 433 | } |
| 434 | |
| 435 | GLenum TextureCubeMap::getInternalFormat(GLenum target, GLint level) const |
| 436 | { |
| 437 | if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) |
Brandon Jones | cef06ff | 2014-08-05 13:27:48 -0700 | [diff] [blame] | 438 | return mTexture->getImage(level, targetToLayerIndex(target))->getInternalFormat(); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 439 | else |
| 440 | return GL_NONE; |
| 441 | } |
| 442 | |
Geoff Lang | 8376cea | 2014-09-02 11:47:07 -0400 | [diff] [blame] | 443 | Error TextureCubeMap::setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels) |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 444 | { |
Geoff Lang | 8376cea | 2014-09-02 11:47:07 -0400 | [diff] [blame] | 445 | return mTexture->setImage(target, level, width, height, 1, internalFormat, format, type, unpack, pixels); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 446 | } |
| 447 | |
Geoff Lang | b534833 | 2014-09-02 13:16:34 -0400 | [diff] [blame] | 448 | Error TextureCubeMap::setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 449 | GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels) |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 450 | { |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 451 | return mTexture->setCompressedImage(target, level, format, width, height, 1, imageSize, unpack, pixels); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 452 | } |
| 453 | |
Geoff Lang | 1ba6b8d | 2014-08-28 10:57:31 -0400 | [diff] [blame] | 454 | Error TextureCubeMap::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.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 455 | { |
Geoff Lang | 1ba6b8d | 2014-08-28 10:57:31 -0400 | [diff] [blame] | 456 | return mTexture->subImage(target, level, xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 457 | } |
| 458 | |
Geoff Lang | b534833 | 2014-09-02 13:16:34 -0400 | [diff] [blame] | 459 | Error TextureCubeMap::subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, |
| 460 | GLsizei width, GLsizei height, GLenum format, |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 461 | GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels) |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 462 | { |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 463 | return mTexture->subImageCompressed(target, level, xoffset, yoffset, 0, width, height, 1, format, imageSize, unpack, pixels); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 464 | } |
| 465 | |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 466 | // Tests for cube texture completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81. |
| 467 | bool TextureCubeMap::isCubeComplete() const |
| 468 | { |
Brandon Jones | 6053a52 | 2014-07-25 16:22:09 -0700 | [diff] [blame] | 469 | int baseWidth = getBaseLevelWidth(); |
| 470 | int baseHeight = getBaseLevelHeight(); |
| 471 | GLenum baseFormat = getBaseLevelInternalFormat(); |
| 472 | |
| 473 | if (baseWidth <= 0 || baseWidth != baseHeight) |
| 474 | { |
| 475 | return false; |
| 476 | } |
| 477 | |
| 478 | for (int faceIndex = 1; faceIndex < 6; faceIndex++) |
| 479 | { |
| 480 | const rx::Image *faceBaseImage = mTexture->getImage(0, faceIndex); |
| 481 | |
| 482 | if (faceBaseImage->getWidth() != baseWidth || |
| 483 | faceBaseImage->getHeight() != baseHeight || |
| 484 | faceBaseImage->getInternalFormat() != baseFormat ) |
| 485 | { |
| 486 | return false; |
| 487 | } |
| 488 | } |
| 489 | |
| 490 | return true; |
Jamie Madill | 07edd44 | 2013-07-19 16:36:58 -0400 | [diff] [blame] | 491 | } |
| 492 | |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 493 | bool TextureCubeMap::isCompressed(GLenum target, GLint level) const |
| 494 | { |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 495 | return GetInternalFormatInfo(getInternalFormat(target, level)).compressed; |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 496 | } |
| 497 | |
Geoff Lang | 8040f57 | 2013-07-25 16:49:54 -0400 | [diff] [blame] | 498 | bool TextureCubeMap::isDepth(GLenum target, GLint level) const |
| 499 | { |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 500 | return GetInternalFormatInfo(getInternalFormat(target, level)).depthBits > 0; |
Geoff Lang | 8040f57 | 2013-07-25 16:49:54 -0400 | [diff] [blame] | 501 | } |
| 502 | |
Geoff Lang | ef7b016 | 2014-09-04 13:29:23 -0400 | [diff] [blame] | 503 | Error TextureCubeMap::copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, |
| 504 | GLsizei width, GLsizei height, Framebuffer *source) |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 505 | { |
Geoff Lang | ef7b016 | 2014-09-04 13:29:23 -0400 | [diff] [blame] | 506 | return mTexture->copyImage(target, level, format, x, y, width, height, source); |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 507 | } |
| 508 | |
Geoff Lang | 1f8532b | 2014-09-05 09:46:13 -0400 | [diff] [blame] | 509 | Error TextureCubeMap::storage(GLsizei levels, GLenum internalformat, GLsizei size) |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 510 | { |
Geoff Lang | 1f8532b | 2014-09-05 09:46:13 -0400 | [diff] [blame] | 511 | Error error = mTexture->storage(GL_TEXTURE_CUBE_MAP, levels, internalformat, size, size, 1); |
| 512 | if (error.isError()) |
| 513 | { |
| 514 | return error; |
| 515 | } |
| 516 | |
Jamie Madill | 6948e30 | 2014-10-20 17:04:33 -0400 | [diff] [blame] | 517 | mImmutableLevelCount = levels; |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 518 | |
Geoff Lang | 1f8532b | 2014-09-05 09:46:13 -0400 | [diff] [blame] | 519 | return Error(GL_NO_ERROR); |
Jamie Madill | 2ebab85 | 2013-10-24 17:49:42 -0400 | [diff] [blame] | 520 | } |
| 521 | |
Brandon Jones | 6053a52 | 2014-07-25 16:22:09 -0700 | [diff] [blame] | 522 | // Tests for texture sampling completeness |
Geoff Lang | f4134d2 | 2014-12-15 10:29:47 -0500 | [diff] [blame] | 523 | bool TextureCubeMap::isSamplerComplete(const SamplerState &samplerState, const Data &data) const |
Brandon Jones | 6053a52 | 2014-07-25 16:22:09 -0700 | [diff] [blame] | 524 | { |
| 525 | int size = getBaseLevelWidth(); |
| 526 | |
| 527 | bool mipmapping = IsMipmapFiltered(samplerState); |
| 528 | |
Geoff Lang | f4134d2 | 2014-12-15 10:29:47 -0500 | [diff] [blame] | 529 | if (!data.textureCaps->get(getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0)).filterable && !IsPointSampled(samplerState)) |
Brandon Jones | 6053a52 | 2014-07-25 16:22:09 -0700 | [diff] [blame] | 530 | { |
| 531 | return false; |
| 532 | } |
| 533 | |
Geoff Lang | f4134d2 | 2014-12-15 10:29:47 -0500 | [diff] [blame] | 534 | if (!gl::isPow2(size) && !data.extensions->textureNPOT) |
Brandon Jones | 6053a52 | 2014-07-25 16:22:09 -0700 | [diff] [blame] | 535 | { |
| 536 | if (samplerState.wrapS != GL_CLAMP_TO_EDGE || samplerState.wrapT != GL_CLAMP_TO_EDGE || mipmapping) |
| 537 | { |
| 538 | return false; |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | if (!mipmapping) |
| 543 | { |
| 544 | if (!isCubeComplete()) |
| 545 | { |
| 546 | return false; |
| 547 | } |
| 548 | } |
| 549 | else |
| 550 | { |
| 551 | if (!isMipmapComplete()) // Also tests for isCubeComplete() |
| 552 | { |
| 553 | return false; |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | return true; |
| 558 | } |
| 559 | |
Brandon Jones | cef06ff | 2014-08-05 13:27:48 -0700 | [diff] [blame] | 560 | int TextureCubeMap::targetToLayerIndex(GLenum target) |
| 561 | { |
| 562 | META_ASSERT(GL_TEXTURE_CUBE_MAP_NEGATIVE_X - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 1); |
| 563 | META_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_Y - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 2); |
| 564 | META_ASSERT(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 3); |
| 565 | META_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_Z - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 4); |
| 566 | META_ASSERT(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 5); |
| 567 | |
| 568 | return target - GL_TEXTURE_CUBE_MAP_POSITIVE_X; |
| 569 | } |
| 570 | |
| 571 | GLenum TextureCubeMap::layerIndexToTarget(GLint layer) |
| 572 | { |
| 573 | META_ASSERT(GL_TEXTURE_CUBE_MAP_NEGATIVE_X - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 1); |
| 574 | META_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_Y - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 2); |
| 575 | META_ASSERT(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 3); |
| 576 | META_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_Z - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 4); |
| 577 | META_ASSERT(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 5); |
| 578 | |
| 579 | return GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer; |
Geoff Lang | 8040f57 | 2013-07-25 16:49:54 -0400 | [diff] [blame] | 580 | } |
| 581 | |
Brandon Jones | 6053a52 | 2014-07-25 16:22:09 -0700 | [diff] [blame] | 582 | bool TextureCubeMap::isMipmapComplete() const |
| 583 | { |
| 584 | if (isImmutable()) |
| 585 | { |
| 586 | return true; |
| 587 | } |
| 588 | |
| 589 | if (!isCubeComplete()) |
| 590 | { |
| 591 | return false; |
| 592 | } |
| 593 | |
| 594 | int levelCount = mipLevels(); |
| 595 | |
| 596 | for (int face = 0; face < 6; face++) |
| 597 | { |
| 598 | for (int level = 1; level < levelCount; level++) |
| 599 | { |
| 600 | if (!isFaceLevelComplete(face, level)) |
| 601 | { |
| 602 | return false; |
| 603 | } |
| 604 | } |
| 605 | } |
| 606 | |
| 607 | return true; |
| 608 | } |
| 609 | |
| 610 | bool TextureCubeMap::isFaceLevelComplete(int faceIndex, int level) const |
| 611 | { |
| 612 | ASSERT(level >= 0 && faceIndex < 6 && level < IMPLEMENTATION_MAX_TEXTURE_LEVELS && mTexture->getImage(level, faceIndex) != NULL); |
| 613 | |
| 614 | if (isImmutable()) |
| 615 | { |
| 616 | return true; |
| 617 | } |
| 618 | |
| 619 | int baseSize = getBaseLevelWidth(); |
| 620 | |
| 621 | if (baseSize <= 0) |
| 622 | { |
| 623 | return false; |
| 624 | } |
| 625 | |
| 626 | // "isCubeComplete" checks for base level completeness and we must call that |
| 627 | // to determine if any face at level 0 is complete. We omit that check here |
| 628 | // to avoid re-checking cube-completeness for every face at level 0. |
| 629 | if (level == 0) |
| 630 | { |
| 631 | return true; |
| 632 | } |
| 633 | |
| 634 | // Check that non-zero levels are consistent with the base level. |
| 635 | const rx::Image *faceLevelImage = mTexture->getImage(level, faceIndex); |
| 636 | |
| 637 | if (faceLevelImage->getInternalFormat() != getBaseLevelInternalFormat()) |
| 638 | { |
| 639 | return false; |
| 640 | } |
| 641 | |
| 642 | if (faceLevelImage->getWidth() != std::max(1, baseSize >> level)) |
| 643 | { |
| 644 | return false; |
| 645 | } |
| 646 | |
| 647 | return true; |
| 648 | } |
| 649 | |
| 650 | |
| 651 | Texture3D::Texture3D(rx::TextureImpl *impl, GLuint id) |
| 652 | : Texture(impl, id, GL_TEXTURE_3D) |
shannon.woods%transgaming.com@gtempaccount.com | 9599656 | 2013-04-13 03:44:58 +0000 | [diff] [blame] | 653 | { |
shannon.woods%transgaming.com@gtempaccount.com | 9599656 | 2013-04-13 03:44:58 +0000 | [diff] [blame] | 654 | } |
| 655 | |
| 656 | Texture3D::~Texture3D() |
| 657 | { |
Brandon Jones | 78b1acd | 2014-07-15 15:33:07 -0700 | [diff] [blame] | 658 | } |
shannon.woods%transgaming.com@gtempaccount.com | 9599656 | 2013-04-13 03:44:58 +0000 | [diff] [blame] | 659 | |
shannon.woods%transgaming.com@gtempaccount.com | 9599656 | 2013-04-13 03:44:58 +0000 | [diff] [blame] | 660 | GLsizei Texture3D::getWidth(GLint level) const |
| 661 | { |
Brandon Jones | cef06ff | 2014-08-05 13:27:48 -0700 | [diff] [blame] | 662 | return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mTexture->getImage(level, 0)->getWidth() : 0; |
shannon.woods%transgaming.com@gtempaccount.com | 9599656 | 2013-04-13 03:44:58 +0000 | [diff] [blame] | 663 | } |
| 664 | |
| 665 | GLsizei Texture3D::getHeight(GLint level) const |
| 666 | { |
Brandon Jones | cef06ff | 2014-08-05 13:27:48 -0700 | [diff] [blame] | 667 | return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mTexture->getImage(level, 0)->getHeight() : 0; |
shannon.woods%transgaming.com@gtempaccount.com | 9599656 | 2013-04-13 03:44:58 +0000 | [diff] [blame] | 668 | } |
| 669 | |
| 670 | GLsizei Texture3D::getDepth(GLint level) const |
| 671 | { |
Brandon Jones | cef06ff | 2014-08-05 13:27:48 -0700 | [diff] [blame] | 672 | return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mTexture->getImage(level, 0)->getDepth() : 0; |
shannon.woods%transgaming.com@gtempaccount.com | 9599656 | 2013-04-13 03:44:58 +0000 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | GLenum Texture3D::getInternalFormat(GLint level) const |
| 676 | { |
Brandon Jones | cef06ff | 2014-08-05 13:27:48 -0700 | [diff] [blame] | 677 | return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mTexture->getImage(level, 0)->getInternalFormat() : GL_NONE; |
shannon.woods%transgaming.com@gtempaccount.com | 9599656 | 2013-04-13 03:44:58 +0000 | [diff] [blame] | 678 | } |
| 679 | |
shannon.woods%transgaming.com@gtempaccount.com | 9599656 | 2013-04-13 03:44:58 +0000 | [diff] [blame] | 680 | bool Texture3D::isCompressed(GLint level) const |
| 681 | { |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 682 | return GetInternalFormatInfo(getInternalFormat(level)).compressed; |
shannon.woods%transgaming.com@gtempaccount.com | 9599656 | 2013-04-13 03:44:58 +0000 | [diff] [blame] | 683 | } |
| 684 | |
| 685 | bool Texture3D::isDepth(GLint level) const |
| 686 | { |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 687 | return GetInternalFormatInfo(getInternalFormat(level)).depthBits > 0; |
shannon.woods%transgaming.com@gtempaccount.com | 9599656 | 2013-04-13 03:44:58 +0000 | [diff] [blame] | 688 | } |
| 689 | |
Geoff Lang | 1ba6b8d | 2014-08-28 10:57:31 -0400 | [diff] [blame] | 690 | Error Texture3D::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.com | 9599656 | 2013-04-13 03:44:58 +0000 | [diff] [blame] | 691 | { |
Geoff Lang | 1ba6b8d | 2014-08-28 10:57:31 -0400 | [diff] [blame] | 692 | return mTexture->setImage(GL_TEXTURE_3D, level, width, height, depth, internalFormat, format, type, unpack, pixels); |
shannon.woods%transgaming.com@gtempaccount.com | 9599656 | 2013-04-13 03:44:58 +0000 | [diff] [blame] | 693 | } |
| 694 | |
Geoff Lang | b534833 | 2014-09-02 13:16:34 -0400 | [diff] [blame] | 695 | Error Texture3D::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 696 | GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels) |
shannon.woods%transgaming.com@gtempaccount.com | 9599656 | 2013-04-13 03:44:58 +0000 | [diff] [blame] | 697 | { |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 698 | return mTexture->setCompressedImage(GL_TEXTURE_3D, level, format, width, height, depth, imageSize, unpack, pixels); |
shannon.woods%transgaming.com@gtempaccount.com | 9599656 | 2013-04-13 03:44:58 +0000 | [diff] [blame] | 699 | } |
| 700 | |
Geoff Lang | 1ba6b8d | 2014-08-28 10:57:31 -0400 | [diff] [blame] | 701 | Error Texture3D::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.com | 9599656 | 2013-04-13 03:44:58 +0000 | [diff] [blame] | 702 | { |
Geoff Lang | 1ba6b8d | 2014-08-28 10:57:31 -0400 | [diff] [blame] | 703 | return mTexture->subImage(GL_TEXTURE_3D, level, xoffset, yoffset, zoffset, width, height, depth, format, type, unpack, pixels); |
shannon.woods%transgaming.com@gtempaccount.com | 9599656 | 2013-04-13 03:44:58 +0000 | [diff] [blame] | 704 | } |
| 705 | |
Geoff Lang | b534833 | 2014-09-02 13:16:34 -0400 | [diff] [blame] | 706 | Error Texture3D::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, |
| 707 | GLsizei width, GLsizei height, GLsizei depth, GLenum format, |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 708 | GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels) |
shannon.woods%transgaming.com@gtempaccount.com | 9599656 | 2013-04-13 03:44:58 +0000 | [diff] [blame] | 709 | { |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 710 | return mTexture->subImageCompressed(GL_TEXTURE_3D, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, unpack, pixels); |
shannon.woods%transgaming.com@gtempaccount.com | 9599656 | 2013-04-13 03:44:58 +0000 | [diff] [blame] | 711 | } |
| 712 | |
Geoff Lang | 1f8532b | 2014-09-05 09:46:13 -0400 | [diff] [blame] | 713 | Error Texture3D::storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) |
shannon.woods%transgaming.com@gtempaccount.com | 9599656 | 2013-04-13 03:44:58 +0000 | [diff] [blame] | 714 | { |
Geoff Lang | 1f8532b | 2014-09-05 09:46:13 -0400 | [diff] [blame] | 715 | Error error = mTexture->storage(GL_TEXTURE_3D, levels, internalformat, width, height, depth); |
| 716 | if (error.isError()) |
| 717 | { |
| 718 | return error; |
| 719 | } |
| 720 | |
Jamie Madill | 6948e30 | 2014-10-20 17:04:33 -0400 | [diff] [blame] | 721 | mImmutableLevelCount = levels; |
shannon.woods%transgaming.com@gtempaccount.com | 9599656 | 2013-04-13 03:44:58 +0000 | [diff] [blame] | 722 | |
Geoff Lang | 1f8532b | 2014-09-05 09:46:13 -0400 | [diff] [blame] | 723 | return Error(GL_NO_ERROR); |
Jamie Madill | 2ebab85 | 2013-10-24 17:49:42 -0400 | [diff] [blame] | 724 | } |
| 725 | |
Geoff Lang | f4134d2 | 2014-12-15 10:29:47 -0500 | [diff] [blame] | 726 | bool Texture3D::isSamplerComplete(const SamplerState &samplerState, const Data &data) const |
Brandon Jones | 6053a52 | 2014-07-25 16:22:09 -0700 | [diff] [blame] | 727 | { |
| 728 | GLsizei width = getBaseLevelWidth(); |
| 729 | GLsizei height = getBaseLevelHeight(); |
| 730 | GLsizei depth = getBaseLevelDepth(); |
| 731 | |
| 732 | if (width <= 0 || height <= 0 || depth <= 0) |
| 733 | { |
| 734 | return false; |
| 735 | } |
| 736 | |
Geoff Lang | f4134d2 | 2014-12-15 10:29:47 -0500 | [diff] [blame] | 737 | if (!data.textureCaps->get(getInternalFormat(0)).filterable && !IsPointSampled(samplerState)) |
Brandon Jones | 6053a52 | 2014-07-25 16:22:09 -0700 | [diff] [blame] | 738 | { |
| 739 | return false; |
| 740 | } |
| 741 | |
| 742 | if (IsMipmapFiltered(samplerState) && !isMipmapComplete()) |
| 743 | { |
| 744 | return false; |
| 745 | } |
| 746 | |
| 747 | return true; |
| 748 | } |
| 749 | |
Brandon Jones | 6053a52 | 2014-07-25 16:22:09 -0700 | [diff] [blame] | 750 | bool Texture3D::isMipmapComplete() const |
| 751 | { |
| 752 | int levelCount = mipLevels(); |
| 753 | |
| 754 | for (int level = 0; level < levelCount; level++) |
| 755 | { |
| 756 | if (!isLevelComplete(level)) |
| 757 | { |
| 758 | return false; |
| 759 | } |
| 760 | } |
| 761 | |
| 762 | return true; |
| 763 | } |
| 764 | |
| 765 | bool Texture3D::isLevelComplete(int level) const |
| 766 | { |
| 767 | ASSERT(level >= 0 && level < IMPLEMENTATION_MAX_TEXTURE_LEVELS && mTexture->getImage(level, 0) != NULL); |
| 768 | |
| 769 | if (isImmutable()) |
| 770 | { |
| 771 | return true; |
| 772 | } |
| 773 | |
| 774 | GLsizei width = getBaseLevelWidth(); |
| 775 | GLsizei height = getBaseLevelHeight(); |
| 776 | GLsizei depth = getBaseLevelDepth(); |
| 777 | |
| 778 | if (width <= 0 || height <= 0 || depth <= 0) |
| 779 | { |
| 780 | return false; |
| 781 | } |
| 782 | |
| 783 | if (level == 0) |
| 784 | { |
| 785 | return true; |
| 786 | } |
| 787 | |
| 788 | rx::Image *levelImage = mTexture->getImage(level, 0); |
| 789 | |
| 790 | if (levelImage->getInternalFormat() != getBaseLevelInternalFormat()) |
| 791 | { |
| 792 | return false; |
| 793 | } |
| 794 | |
| 795 | if (levelImage->getWidth() != std::max(1, width >> level)) |
| 796 | { |
| 797 | return false; |
| 798 | } |
| 799 | |
| 800 | if (levelImage->getHeight() != std::max(1, height >> level)) |
| 801 | { |
| 802 | return false; |
| 803 | } |
| 804 | |
| 805 | if (levelImage->getDepth() != std::max(1, depth >> level)) |
| 806 | { |
| 807 | return false; |
| 808 | } |
| 809 | |
| 810 | return true; |
| 811 | } |
| 812 | |
| 813 | Texture2DArray::Texture2DArray(rx::TextureImpl *impl, GLuint id) |
| 814 | : Texture(impl, id, GL_TEXTURE_2D_ARRAY) |
shannon.woods%transgaming.com@gtempaccount.com | 7625f79 | 2013-04-13 03:46:07 +0000 | [diff] [blame] | 815 | { |
shannon.woods%transgaming.com@gtempaccount.com | 7625f79 | 2013-04-13 03:46:07 +0000 | [diff] [blame] | 816 | } |
| 817 | |
| 818 | Texture2DArray::~Texture2DArray() |
| 819 | { |
Jamie Madill | 884a462 | 2013-10-24 17:49:41 -0400 | [diff] [blame] | 820 | } |
| 821 | |
shannon.woods%transgaming.com@gtempaccount.com | 7625f79 | 2013-04-13 03:46:07 +0000 | [diff] [blame] | 822 | GLsizei Texture2DArray::getWidth(GLint level) const |
| 823 | { |
Brandon Jones | 142ec42 | 2014-07-16 10:31:30 -0700 | [diff] [blame] | 824 | return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS && mTexture->getLayerCount(level) > 0) ? mTexture->getImage(level, 0)->getWidth() : 0; |
shannon.woods%transgaming.com@gtempaccount.com | 7625f79 | 2013-04-13 03:46:07 +0000 | [diff] [blame] | 825 | } |
| 826 | |
| 827 | GLsizei Texture2DArray::getHeight(GLint level) const |
| 828 | { |
Brandon Jones | 142ec42 | 2014-07-16 10:31:30 -0700 | [diff] [blame] | 829 | return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS && mTexture->getLayerCount(level) > 0) ? mTexture->getImage(level, 0)->getHeight() : 0; |
shannon.woods%transgaming.com@gtempaccount.com | 7625f79 | 2013-04-13 03:46:07 +0000 | [diff] [blame] | 830 | } |
| 831 | |
Jamie Madill | b8f8b89 | 2014-01-07 10:12:50 -0500 | [diff] [blame] | 832 | GLsizei Texture2DArray::getLayers(GLint level) const |
shannon.woods%transgaming.com@gtempaccount.com | 7625f79 | 2013-04-13 03:46:07 +0000 | [diff] [blame] | 833 | { |
Brandon Jones | 142ec42 | 2014-07-16 10:31:30 -0700 | [diff] [blame] | 834 | return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mTexture->getLayerCount(level) : 0; |
shannon.woods%transgaming.com@gtempaccount.com | 7625f79 | 2013-04-13 03:46:07 +0000 | [diff] [blame] | 835 | } |
| 836 | |
| 837 | GLenum Texture2DArray::getInternalFormat(GLint level) const |
| 838 | { |
Brandon Jones | 142ec42 | 2014-07-16 10:31:30 -0700 | [diff] [blame] | 839 | return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS && mTexture->getLayerCount(level) > 0) ? mTexture->getImage(level, 0)->getInternalFormat() : GL_NONE; |
shannon.woods%transgaming.com@gtempaccount.com | 7625f79 | 2013-04-13 03:46:07 +0000 | [diff] [blame] | 840 | } |
| 841 | |
shannon.woods%transgaming.com@gtempaccount.com | 7625f79 | 2013-04-13 03:46:07 +0000 | [diff] [blame] | 842 | bool Texture2DArray::isCompressed(GLint level) const |
| 843 | { |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 844 | return GetInternalFormatInfo(getInternalFormat(level)).compressed; |
shannon.woods%transgaming.com@gtempaccount.com | 7625f79 | 2013-04-13 03:46:07 +0000 | [diff] [blame] | 845 | } |
| 846 | |
| 847 | bool Texture2DArray::isDepth(GLint level) const |
| 848 | { |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 849 | return GetInternalFormatInfo(getInternalFormat(level)).depthBits > 0; |
shannon.woods%transgaming.com@gtempaccount.com | 7625f79 | 2013-04-13 03:46:07 +0000 | [diff] [blame] | 850 | } |
| 851 | |
Geoff Lang | 1ba6b8d | 2014-08-28 10:57:31 -0400 | [diff] [blame] | 852 | Error Texture2DArray::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.com | 7625f79 | 2013-04-13 03:46:07 +0000 | [diff] [blame] | 853 | { |
Geoff Lang | 1ba6b8d | 2014-08-28 10:57:31 -0400 | [diff] [blame] | 854 | return mTexture->setImage(GL_TEXTURE_2D_ARRAY, level, width, height, depth, internalFormat, format, type, unpack, pixels); |
shannon.woods%transgaming.com@gtempaccount.com | 7625f79 | 2013-04-13 03:46:07 +0000 | [diff] [blame] | 855 | } |
| 856 | |
Geoff Lang | b534833 | 2014-09-02 13:16:34 -0400 | [diff] [blame] | 857 | Error Texture2DArray::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 858 | GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels) |
shannon.woods%transgaming.com@gtempaccount.com | 7625f79 | 2013-04-13 03:46:07 +0000 | [diff] [blame] | 859 | { |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 860 | return mTexture->setCompressedImage(GL_TEXTURE_2D_ARRAY, level, format, width, height, depth, imageSize, unpack, pixels); |
shannon.woods%transgaming.com@gtempaccount.com | 7625f79 | 2013-04-13 03:46:07 +0000 | [diff] [blame] | 861 | } |
| 862 | |
Geoff Lang | 1ba6b8d | 2014-08-28 10:57:31 -0400 | [diff] [blame] | 863 | Error Texture2DArray::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.com | 7625f79 | 2013-04-13 03:46:07 +0000 | [diff] [blame] | 864 | { |
Geoff Lang | 1ba6b8d | 2014-08-28 10:57:31 -0400 | [diff] [blame] | 865 | return mTexture->subImage(GL_TEXTURE_2D_ARRAY, level, xoffset, yoffset, zoffset, width, height, depth, format, type, unpack, pixels); |
shannon.woods%transgaming.com@gtempaccount.com | 7625f79 | 2013-04-13 03:46:07 +0000 | [diff] [blame] | 866 | } |
| 867 | |
Geoff Lang | b534833 | 2014-09-02 13:16:34 -0400 | [diff] [blame] | 868 | Error Texture2DArray::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, |
| 869 | GLsizei width, GLsizei height, GLsizei depth, GLenum format, |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 870 | GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels) |
shannon.woods%transgaming.com@gtempaccount.com | 7625f79 | 2013-04-13 03:46:07 +0000 | [diff] [blame] | 871 | { |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 872 | return mTexture->subImageCompressed(GL_TEXTURE_2D_ARRAY, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, unpack, pixels); |
shannon.woods%transgaming.com@gtempaccount.com | 7625f79 | 2013-04-13 03:46:07 +0000 | [diff] [blame] | 873 | } |
| 874 | |
Geoff Lang | 1f8532b | 2014-09-05 09:46:13 -0400 | [diff] [blame] | 875 | Error Texture2DArray::storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) |
shannon.woods%transgaming.com@gtempaccount.com | 7625f79 | 2013-04-13 03:46:07 +0000 | [diff] [blame] | 876 | { |
Geoff Lang | 1f8532b | 2014-09-05 09:46:13 -0400 | [diff] [blame] | 877 | Error error = mTexture->storage(GL_TEXTURE_2D_ARRAY, levels, internalformat, width, height, depth); |
| 878 | if (error.isError()) |
| 879 | { |
| 880 | return error; |
| 881 | } |
| 882 | |
Jamie Madill | 6948e30 | 2014-10-20 17:04:33 -0400 | [diff] [blame] | 883 | mImmutableLevelCount = levels; |
Brandon Jones | 142ec42 | 2014-07-16 10:31:30 -0700 | [diff] [blame] | 884 | |
Geoff Lang | 1f8532b | 2014-09-05 09:46:13 -0400 | [diff] [blame] | 885 | return Error(GL_NO_ERROR); |
Jamie Madill | 2ebab85 | 2013-10-24 17:49:42 -0400 | [diff] [blame] | 886 | } |
| 887 | |
Geoff Lang | f4134d2 | 2014-12-15 10:29:47 -0500 | [diff] [blame] | 888 | bool Texture2DArray::isSamplerComplete(const SamplerState &samplerState, const Data &data) const |
Brandon Jones | 6053a52 | 2014-07-25 16:22:09 -0700 | [diff] [blame] | 889 | { |
| 890 | GLsizei width = getBaseLevelWidth(); |
| 891 | GLsizei height = getBaseLevelHeight(); |
| 892 | GLsizei depth = getLayers(0); |
| 893 | |
| 894 | if (width <= 0 || height <= 0 || depth <= 0) |
| 895 | { |
| 896 | return false; |
| 897 | } |
| 898 | |
Geoff Lang | f4134d2 | 2014-12-15 10:29:47 -0500 | [diff] [blame] | 899 | if (!data.textureCaps->get(getBaseLevelInternalFormat()).filterable && !IsPointSampled(samplerState)) |
Brandon Jones | 6053a52 | 2014-07-25 16:22:09 -0700 | [diff] [blame] | 900 | { |
| 901 | return false; |
| 902 | } |
| 903 | |
| 904 | if (IsMipmapFiltered(samplerState) && !isMipmapComplete()) |
| 905 | { |
| 906 | return false; |
| 907 | } |
| 908 | |
| 909 | return true; |
| 910 | } |
| 911 | |
Brandon Jones | 6053a52 | 2014-07-25 16:22:09 -0700 | [diff] [blame] | 912 | bool Texture2DArray::isMipmapComplete() const |
| 913 | { |
| 914 | int levelCount = mipLevels(); |
| 915 | |
| 916 | for (int level = 1; level < levelCount; level++) |
| 917 | { |
| 918 | if (!isLevelComplete(level)) |
| 919 | { |
| 920 | return false; |
| 921 | } |
| 922 | } |
| 923 | |
| 924 | return true; |
| 925 | } |
| 926 | |
| 927 | bool Texture2DArray::isLevelComplete(int level) const |
| 928 | { |
| 929 | ASSERT(level >= 0 && level < IMPLEMENTATION_MAX_TEXTURE_LEVELS); |
| 930 | |
| 931 | if (isImmutable()) |
| 932 | { |
| 933 | return true; |
| 934 | } |
| 935 | |
| 936 | GLsizei width = getBaseLevelWidth(); |
| 937 | GLsizei height = getBaseLevelHeight(); |
| 938 | GLsizei layers = getLayers(0); |
| 939 | |
| 940 | if (width <= 0 || height <= 0 || layers <= 0) |
| 941 | { |
| 942 | return false; |
| 943 | } |
| 944 | |
| 945 | if (level == 0) |
| 946 | { |
| 947 | return true; |
| 948 | } |
| 949 | |
| 950 | if (getInternalFormat(level) != getInternalFormat(0)) |
| 951 | { |
| 952 | return false; |
| 953 | } |
| 954 | |
| 955 | if (getWidth(level) != std::max(1, width >> level)) |
| 956 | { |
| 957 | return false; |
| 958 | } |
| 959 | |
| 960 | if (getHeight(level) != std::max(1, height >> level)) |
| 961 | { |
| 962 | return false; |
| 963 | } |
| 964 | |
| 965 | if (getLayers(level) != layers) |
| 966 | { |
| 967 | return false; |
| 968 | } |
| 969 | |
| 970 | return true; |
| 971 | } |
| 972 | |
daniel@transgaming.com | 95a758f | 2012-07-12 15:17:06 +0000 | [diff] [blame] | 973 | } |