Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 1 | #include "precompiled.h" |
| 2 | // |
| 3 | // Copyright (c) 2014 The ANGLE Project Authors. All rights reserved. |
| 4 | // Use of this source code is governed by a BSD-style license that can be |
| 5 | // found in the LICENSE file. |
| 6 | // |
| 7 | |
| 8 | // FramebufferAttachment.cpp: the gl::FramebufferAttachment class and its derived classes |
| 9 | // objects and related functionality. [OpenGL ES 2.0.24] section 4.4.3 page 108. |
| 10 | |
| 11 | #include "libGLESv2/FramebufferAttachment.h" |
| 12 | #include "libGLESv2/renderer/RenderTarget.h" |
| 13 | |
| 14 | #include "libGLESv2/Texture.h" |
| 15 | #include "libGLESv2/renderer/Renderer.h" |
| 16 | #include "libGLESv2/renderer/TextureStorage.h" |
| 17 | #include "common/utilities.h" |
| 18 | #include "libGLESv2/formatutils.h" |
| 19 | #include "libGLESv2/Renderbuffer.h" |
| 20 | |
| 21 | namespace gl |
| 22 | { |
| 23 | |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 24 | FramebufferAttachmentImpl::FramebufferAttachmentImpl() |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 25 | { |
| 26 | } |
| 27 | |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 28 | // The default case for classes inherited from FramebufferAttachmentImpl is not to |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 29 | // need to do anything upon the reference count to the parent FramebufferAttachment incrementing |
| 30 | // or decrementing. |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 31 | void FramebufferAttachmentImpl::addProxyRef(const FramebufferAttachment *proxy) |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 32 | { |
| 33 | } |
| 34 | |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 35 | void FramebufferAttachmentImpl::releaseProxy(const FramebufferAttachment *proxy) |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 36 | { |
| 37 | } |
| 38 | |
| 39 | ///// Texture2DAttachment Implementation //////// |
| 40 | |
| 41 | Texture2DAttachment::Texture2DAttachment(Texture2D *texture, GLint level) : mLevel(level) |
| 42 | { |
| 43 | mTexture2D.set(texture); |
| 44 | } |
| 45 | |
| 46 | Texture2DAttachment::~Texture2DAttachment() |
| 47 | { |
| 48 | mTexture2D.set(NULL); |
| 49 | } |
| 50 | |
| 51 | // Textures need to maintain their own reference count for references via |
| 52 | // Renderbuffers acting as proxies. Here, we notify the texture of a reference. |
| 53 | void Texture2DAttachment::addProxyRef(const FramebufferAttachment *proxy) |
| 54 | { |
| 55 | mTexture2D->addProxyRef(proxy); |
| 56 | } |
| 57 | |
| 58 | void Texture2DAttachment::releaseProxy(const FramebufferAttachment *proxy) |
| 59 | { |
| 60 | mTexture2D->releaseProxy(proxy); |
| 61 | } |
| 62 | |
| 63 | rx::RenderTarget *Texture2DAttachment::getRenderTarget() |
| 64 | { |
| 65 | return mTexture2D->getRenderTarget(mLevel); |
| 66 | } |
| 67 | |
| 68 | rx::RenderTarget *Texture2DAttachment::getDepthStencil() |
| 69 | { |
| 70 | return mTexture2D->getDepthSencil(mLevel); |
| 71 | } |
| 72 | |
| 73 | rx::TextureStorage *Texture2DAttachment::getTextureStorage() |
| 74 | { |
| 75 | return mTexture2D->getNativeTexture()->getStorageInstance(); |
| 76 | } |
| 77 | |
| 78 | GLsizei Texture2DAttachment::getWidth() const |
| 79 | { |
| 80 | return mTexture2D->getWidth(mLevel); |
| 81 | } |
| 82 | |
| 83 | GLsizei Texture2DAttachment::getHeight() const |
| 84 | { |
| 85 | return mTexture2D->getHeight(mLevel); |
| 86 | } |
| 87 | |
| 88 | GLenum Texture2DAttachment::getInternalFormat() const |
| 89 | { |
| 90 | return mTexture2D->getInternalFormat(mLevel); |
| 91 | } |
| 92 | |
| 93 | GLenum Texture2DAttachment::getActualFormat() const |
| 94 | { |
| 95 | return mTexture2D->getActualFormat(mLevel); |
| 96 | } |
| 97 | |
| 98 | GLsizei Texture2DAttachment::getSamples() const |
| 99 | { |
| 100 | return 0; |
| 101 | } |
| 102 | |
| 103 | unsigned int Texture2DAttachment::getSerial() const |
| 104 | { |
| 105 | return mTexture2D->getRenderTargetSerial(mLevel); |
| 106 | } |
| 107 | |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame] | 108 | GLuint Texture2DAttachment::id() const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 109 | { |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame] | 110 | return mTexture2D->id(); |
| 111 | } |
| 112 | |
| 113 | GLenum Texture2DAttachment::type() const |
| 114 | { |
| 115 | return GL_TEXTURE_2D; |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 116 | } |
| 117 | |
Jamie Madill | 9c074a3 | 2014-06-16 10:34:02 -0400 | [diff] [blame] | 118 | GLint Texture2DAttachment::mipLevel() const |
| 119 | { |
| 120 | return mLevel; |
| 121 | } |
| 122 | |
| 123 | GLint Texture2DAttachment::layer() const |
| 124 | { |
| 125 | return 0; |
| 126 | } |
| 127 | |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 128 | unsigned int Texture2DAttachment::getTextureSerial() const |
| 129 | { |
| 130 | return mTexture2D->getTextureSerial(); |
| 131 | } |
| 132 | |
| 133 | ///// TextureCubeMapAttachment Implementation //////// |
| 134 | |
| 135 | TextureCubeMapAttachment::TextureCubeMapAttachment(TextureCubeMap *texture, GLenum faceTarget, GLint level) |
| 136 | : mFaceTarget(faceTarget), mLevel(level) |
| 137 | { |
| 138 | mTextureCubeMap.set(texture); |
| 139 | } |
| 140 | |
| 141 | TextureCubeMapAttachment::~TextureCubeMapAttachment() |
| 142 | { |
| 143 | mTextureCubeMap.set(NULL); |
| 144 | } |
| 145 | |
| 146 | // Textures need to maintain their own reference count for references via |
| 147 | // Renderbuffers acting as proxies. Here, we notify the texture of a reference. |
| 148 | void TextureCubeMapAttachment::addProxyRef(const FramebufferAttachment *proxy) |
| 149 | { |
| 150 | mTextureCubeMap->addProxyRef(proxy); |
| 151 | } |
| 152 | |
| 153 | void TextureCubeMapAttachment::releaseProxy(const FramebufferAttachment *proxy) |
| 154 | { |
| 155 | mTextureCubeMap->releaseProxy(proxy); |
| 156 | } |
| 157 | |
| 158 | rx::RenderTarget *TextureCubeMapAttachment::getRenderTarget() |
| 159 | { |
| 160 | return mTextureCubeMap->getRenderTarget(mFaceTarget, mLevel); |
| 161 | } |
| 162 | |
| 163 | rx::RenderTarget *TextureCubeMapAttachment::getDepthStencil() |
| 164 | { |
| 165 | return mTextureCubeMap->getDepthStencil(mFaceTarget, mLevel); |
| 166 | } |
| 167 | |
| 168 | rx::TextureStorage *TextureCubeMapAttachment::getTextureStorage() |
| 169 | { |
| 170 | return mTextureCubeMap->getNativeTexture()->getStorageInstance(); |
| 171 | } |
| 172 | |
| 173 | GLsizei TextureCubeMapAttachment::getWidth() const |
| 174 | { |
| 175 | return mTextureCubeMap->getWidth(mFaceTarget, mLevel); |
| 176 | } |
| 177 | |
| 178 | GLsizei TextureCubeMapAttachment::getHeight() const |
| 179 | { |
| 180 | return mTextureCubeMap->getHeight(mFaceTarget, mLevel); |
| 181 | } |
| 182 | |
| 183 | GLenum TextureCubeMapAttachment::getInternalFormat() const |
| 184 | { |
| 185 | return mTextureCubeMap->getInternalFormat(mFaceTarget, mLevel); |
| 186 | } |
| 187 | |
| 188 | GLenum TextureCubeMapAttachment::getActualFormat() const |
| 189 | { |
| 190 | return mTextureCubeMap->getActualFormat(mFaceTarget, mLevel); |
| 191 | } |
| 192 | |
| 193 | GLsizei TextureCubeMapAttachment::getSamples() const |
| 194 | { |
| 195 | return 0; |
| 196 | } |
| 197 | |
| 198 | unsigned int TextureCubeMapAttachment::getSerial() const |
| 199 | { |
| 200 | return mTextureCubeMap->getRenderTargetSerial(mFaceTarget, mLevel); |
| 201 | } |
| 202 | |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame] | 203 | GLuint TextureCubeMapAttachment::id() const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 204 | { |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame] | 205 | return mTextureCubeMap->id(); |
| 206 | } |
| 207 | |
| 208 | GLenum TextureCubeMapAttachment::type() const |
| 209 | { |
| 210 | return mFaceTarget; |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 211 | } |
| 212 | |
Jamie Madill | 9c074a3 | 2014-06-16 10:34:02 -0400 | [diff] [blame] | 213 | GLint TextureCubeMapAttachment::mipLevel() const |
| 214 | { |
| 215 | return mLevel; |
| 216 | } |
| 217 | |
| 218 | GLint TextureCubeMapAttachment::layer() const |
| 219 | { |
| 220 | return 0; |
| 221 | } |
| 222 | |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 223 | unsigned int TextureCubeMapAttachment::getTextureSerial() const |
| 224 | { |
| 225 | return mTextureCubeMap->getTextureSerial(); |
| 226 | } |
| 227 | |
| 228 | ///// Texture3DAttachment Implementation //////// |
| 229 | |
| 230 | Texture3DAttachment::Texture3DAttachment(Texture3D *texture, GLint level, GLint layer) |
| 231 | : mLevel(level), mLayer(layer) |
| 232 | { |
| 233 | mTexture3D.set(texture); |
| 234 | } |
| 235 | |
| 236 | Texture3DAttachment::~Texture3DAttachment() |
| 237 | { |
| 238 | mTexture3D.set(NULL); |
| 239 | } |
| 240 | |
| 241 | // Textures need to maintain their own reference count for references via |
| 242 | // Renderbuffers acting as proxies. Here, we notify the texture of a reference. |
| 243 | void Texture3DAttachment::addProxyRef(const FramebufferAttachment *proxy) |
| 244 | { |
| 245 | mTexture3D->addProxyRef(proxy); |
| 246 | } |
| 247 | |
| 248 | void Texture3DAttachment::releaseProxy(const FramebufferAttachment *proxy) |
| 249 | { |
| 250 | mTexture3D->releaseProxy(proxy); |
| 251 | } |
| 252 | |
| 253 | rx::RenderTarget *Texture3DAttachment::getRenderTarget() |
| 254 | { |
| 255 | return mTexture3D->getRenderTarget(mLevel, mLayer); |
| 256 | } |
| 257 | |
| 258 | rx::RenderTarget *Texture3DAttachment::getDepthStencil() |
| 259 | { |
| 260 | return mTexture3D->getDepthStencil(mLevel, mLayer); |
| 261 | } |
| 262 | |
| 263 | rx::TextureStorage *Texture3DAttachment::getTextureStorage() |
| 264 | { |
| 265 | return mTexture3D->getNativeTexture()->getStorageInstance(); |
| 266 | } |
| 267 | |
| 268 | GLsizei Texture3DAttachment::getWidth() const |
| 269 | { |
| 270 | return mTexture3D->getWidth(mLevel); |
| 271 | } |
| 272 | |
| 273 | GLsizei Texture3DAttachment::getHeight() const |
| 274 | { |
| 275 | return mTexture3D->getHeight(mLevel); |
| 276 | } |
| 277 | |
| 278 | GLenum Texture3DAttachment::getInternalFormat() const |
| 279 | { |
| 280 | return mTexture3D->getInternalFormat(mLevel); |
| 281 | } |
| 282 | |
| 283 | GLenum Texture3DAttachment::getActualFormat() const |
| 284 | { |
| 285 | return mTexture3D->getActualFormat(mLevel); |
| 286 | } |
| 287 | |
| 288 | GLsizei Texture3DAttachment::getSamples() const |
| 289 | { |
| 290 | return 0; |
| 291 | } |
| 292 | |
| 293 | unsigned int Texture3DAttachment::getSerial() const |
| 294 | { |
| 295 | return mTexture3D->getRenderTargetSerial(mLevel, mLayer); |
| 296 | } |
| 297 | |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame] | 298 | GLuint Texture3DAttachment::id() const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 299 | { |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame] | 300 | return mTexture3D->id(); |
| 301 | } |
| 302 | |
| 303 | GLenum Texture3DAttachment::type() const |
| 304 | { |
| 305 | return GL_TEXTURE_3D; |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 306 | } |
| 307 | |
Jamie Madill | 9c074a3 | 2014-06-16 10:34:02 -0400 | [diff] [blame] | 308 | GLint Texture3DAttachment::mipLevel() const |
| 309 | { |
| 310 | return mLevel; |
| 311 | } |
| 312 | |
| 313 | GLint Texture3DAttachment::layer() const |
| 314 | { |
| 315 | return mLayer; |
| 316 | } |
| 317 | |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 318 | unsigned int Texture3DAttachment::getTextureSerial() const |
| 319 | { |
| 320 | return mTexture3D->getTextureSerial(); |
| 321 | } |
| 322 | |
| 323 | ////// Texture2DArrayAttachment Implementation ////// |
| 324 | |
| 325 | Texture2DArrayAttachment::Texture2DArrayAttachment(Texture2DArray *texture, GLint level, GLint layer) |
| 326 | : mLevel(level), mLayer(layer) |
| 327 | { |
| 328 | mTexture2DArray.set(texture); |
| 329 | } |
| 330 | |
| 331 | Texture2DArrayAttachment::~Texture2DArrayAttachment() |
| 332 | { |
| 333 | mTexture2DArray.set(NULL); |
| 334 | } |
| 335 | |
| 336 | void Texture2DArrayAttachment::addProxyRef(const FramebufferAttachment *proxy) |
| 337 | { |
| 338 | mTexture2DArray->addProxyRef(proxy); |
| 339 | } |
| 340 | |
| 341 | void Texture2DArrayAttachment::releaseProxy(const FramebufferAttachment *proxy) |
| 342 | { |
| 343 | mTexture2DArray->releaseProxy(proxy); |
| 344 | } |
| 345 | |
| 346 | rx::RenderTarget *Texture2DArrayAttachment::getRenderTarget() |
| 347 | { |
| 348 | return mTexture2DArray->getRenderTarget(mLevel, mLayer); |
| 349 | } |
| 350 | |
| 351 | rx::RenderTarget *Texture2DArrayAttachment::getDepthStencil() |
| 352 | { |
| 353 | return mTexture2DArray->getDepthStencil(mLevel, mLayer); |
| 354 | } |
| 355 | |
| 356 | rx::TextureStorage *Texture2DArrayAttachment::getTextureStorage() |
| 357 | { |
| 358 | return mTexture2DArray->getNativeTexture()->getStorageInstance(); |
| 359 | } |
| 360 | |
| 361 | GLsizei Texture2DArrayAttachment::getWidth() const |
| 362 | { |
| 363 | return mTexture2DArray->getWidth(mLevel); |
| 364 | } |
| 365 | |
| 366 | GLsizei Texture2DArrayAttachment::getHeight() const |
| 367 | { |
| 368 | return mTexture2DArray->getHeight(mLevel); |
| 369 | } |
| 370 | |
| 371 | GLenum Texture2DArrayAttachment::getInternalFormat() const |
| 372 | { |
| 373 | return mTexture2DArray->getInternalFormat(mLevel); |
| 374 | } |
| 375 | |
| 376 | GLenum Texture2DArrayAttachment::getActualFormat() const |
| 377 | { |
| 378 | return mTexture2DArray->getActualFormat(mLevel); |
| 379 | } |
| 380 | |
| 381 | GLsizei Texture2DArrayAttachment::getSamples() const |
| 382 | { |
| 383 | return 0; |
| 384 | } |
| 385 | |
| 386 | unsigned int Texture2DArrayAttachment::getSerial() const |
| 387 | { |
| 388 | return mTexture2DArray->getRenderTargetSerial(mLevel, mLayer); |
| 389 | } |
| 390 | |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame] | 391 | GLuint Texture2DArrayAttachment::id() const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 392 | { |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame] | 393 | return mTexture2DArray->id(); |
| 394 | } |
| 395 | |
| 396 | GLenum Texture2DArrayAttachment::type() const |
| 397 | { |
| 398 | return GL_TEXTURE_2D_ARRAY; |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 399 | } |
| 400 | |
Jamie Madill | 9c074a3 | 2014-06-16 10:34:02 -0400 | [diff] [blame] | 401 | GLint Texture2DArrayAttachment::mipLevel() const |
| 402 | { |
| 403 | return mLevel; |
| 404 | } |
| 405 | |
| 406 | GLint Texture2DArrayAttachment::layer() const |
| 407 | { |
| 408 | return mLayer; |
| 409 | } |
| 410 | |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 411 | unsigned int Texture2DArrayAttachment::getTextureSerial() const |
| 412 | { |
| 413 | return mTexture2DArray->getTextureSerial(); |
| 414 | } |
| 415 | |
| 416 | ////// FramebufferAttachment Implementation ////// |
| 417 | |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 418 | FramebufferAttachment::FramebufferAttachment(GLuint id, FramebufferAttachmentImpl *instance) |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 419 | : RefCountObject(id), |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 420 | mImpl(instance) |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 421 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 422 | ASSERT(mImpl != NULL); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | FramebufferAttachment::~FramebufferAttachment() |
| 426 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 427 | SafeDelete(mImpl); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 428 | } |
| 429 | |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 430 | // The FramebufferAttachmentImpl contained in this FramebufferAttachment may need to maintain |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 431 | // its own reference count, so we pass it on here. |
| 432 | void FramebufferAttachment::addRef() const |
| 433 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 434 | mImpl->addProxyRef(this); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 435 | |
| 436 | RefCountObject::addRef(); |
| 437 | } |
| 438 | |
| 439 | void FramebufferAttachment::release() const |
| 440 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 441 | mImpl->releaseProxy(this); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 442 | |
| 443 | RefCountObject::release(); |
| 444 | } |
| 445 | |
| 446 | rx::RenderTarget *FramebufferAttachment::getRenderTarget() |
| 447 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 448 | return mImpl->getRenderTarget(); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | rx::RenderTarget *FramebufferAttachment::getDepthStencil() |
| 452 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 453 | return mImpl->getDepthStencil(); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | rx::TextureStorage *FramebufferAttachment::getTextureStorage() |
| 457 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 458 | return mImpl->getTextureStorage(); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 459 | } |
| 460 | |
| 461 | GLsizei FramebufferAttachment::getWidth() const |
| 462 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 463 | return mImpl->getWidth(); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 464 | } |
| 465 | |
| 466 | GLsizei FramebufferAttachment::getHeight() const |
| 467 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 468 | return mImpl->getHeight(); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 469 | } |
| 470 | |
| 471 | GLenum FramebufferAttachment::getInternalFormat() const |
| 472 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 473 | return mImpl->getInternalFormat(); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 474 | } |
| 475 | |
| 476 | GLenum FramebufferAttachment::getActualFormat() const |
| 477 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 478 | return mImpl->getActualFormat(); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 479 | } |
| 480 | |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 481 | GLuint FramebufferAttachment::getRedSize(int clientVersion) const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 482 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 483 | if (gl::GetRedBits(getInternalFormat(), clientVersion) > 0) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 484 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 485 | return gl::GetRedBits(getActualFormat(), clientVersion); |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 486 | } |
| 487 | else |
| 488 | { |
| 489 | return 0; |
| 490 | } |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 491 | } |
| 492 | |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 493 | GLuint FramebufferAttachment::getGreenSize(int clientVersion) const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 494 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 495 | if (gl::GetGreenBits(getInternalFormat(), clientVersion) > 0) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 496 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 497 | return gl::GetGreenBits(getActualFormat(), clientVersion); |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 498 | } |
| 499 | else |
| 500 | { |
| 501 | return 0; |
| 502 | } |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 503 | } |
| 504 | |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 505 | GLuint FramebufferAttachment::getBlueSize(int clientVersion) const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 506 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 507 | if (gl::GetBlueBits(getInternalFormat(), clientVersion) > 0) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 508 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 509 | return gl::GetBlueBits(getActualFormat(), clientVersion); |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 510 | } |
| 511 | else |
| 512 | { |
| 513 | return 0; |
| 514 | } |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 515 | } |
| 516 | |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 517 | GLuint FramebufferAttachment::getAlphaSize(int clientVersion) const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 518 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 519 | if (gl::GetAlphaBits(getInternalFormat(), clientVersion) > 0) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 520 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 521 | return gl::GetAlphaBits(getActualFormat(), clientVersion); |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 522 | } |
| 523 | else |
| 524 | { |
| 525 | return 0; |
| 526 | } |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 527 | } |
| 528 | |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 529 | GLuint FramebufferAttachment::getDepthSize(int clientVersion) const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 530 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 531 | if (gl::GetDepthBits(getInternalFormat(), clientVersion) > 0) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 532 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 533 | return gl::GetDepthBits(getActualFormat(), clientVersion); |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 534 | } |
| 535 | else |
| 536 | { |
| 537 | return 0; |
| 538 | } |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 539 | } |
| 540 | |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 541 | GLuint FramebufferAttachment::getStencilSize(int clientVersion) const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 542 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 543 | if (gl::GetStencilBits(getInternalFormat(), clientVersion) > 0) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 544 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 545 | return gl::GetStencilBits(getActualFormat(), clientVersion); |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 546 | } |
| 547 | else |
| 548 | { |
| 549 | return 0; |
| 550 | } |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 551 | } |
| 552 | |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 553 | GLenum FramebufferAttachment::getComponentType(int clientVersion) const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 554 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 555 | return gl::GetComponentType(getActualFormat(), clientVersion); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 556 | } |
| 557 | |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 558 | GLenum FramebufferAttachment::getColorEncoding(int clientVersion) const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 559 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 560 | return gl::GetColorEncoding(getActualFormat(), clientVersion); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 561 | } |
| 562 | |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame] | 563 | bool FramebufferAttachment::isTexture() const |
| 564 | { |
| 565 | return (type() != GL_RENDERBUFFER); |
| 566 | } |
| 567 | |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 568 | GLsizei FramebufferAttachment::getSamples() const |
| 569 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 570 | return mImpl->getSamples(); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 571 | } |
| 572 | |
| 573 | unsigned int FramebufferAttachment::getSerial() const |
| 574 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 575 | return mImpl->getSerial(); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 576 | } |
| 577 | |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame] | 578 | GLuint FramebufferAttachment::id() const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 579 | { |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame] | 580 | return mImpl->id(); |
| 581 | } |
| 582 | |
| 583 | GLuint FramebufferAttachment::type() const |
| 584 | { |
| 585 | return mImpl->type(); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 586 | } |
| 587 | |
Jamie Madill | 9c074a3 | 2014-06-16 10:34:02 -0400 | [diff] [blame] | 588 | GLint FramebufferAttachment::mipLevel() const |
| 589 | { |
| 590 | return mImpl->mipLevel(); |
| 591 | } |
| 592 | |
| 593 | GLint FramebufferAttachment::layer() const |
| 594 | { |
| 595 | return mImpl->layer(); |
| 596 | } |
| 597 | |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 598 | unsigned int FramebufferAttachment::getTextureSerial() const |
| 599 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 600 | return mImpl->getTextureSerial(); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 601 | } |
| 602 | |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 603 | void FramebufferAttachment::setImplementation(FramebufferAttachmentImpl *newImpl) |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 604 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 605 | ASSERT(newImpl != NULL); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 606 | |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 607 | delete mImpl; |
| 608 | mImpl = newImpl; |
| 609 | } |
| 610 | |
| 611 | RenderbufferAttachment::RenderbufferAttachment(Renderbuffer *renderbuffer) |
| 612 | { |
| 613 | ASSERT(renderbuffer); |
| 614 | mRenderbuffer.set(renderbuffer); |
| 615 | } |
| 616 | |
| 617 | RenderbufferAttachment::~RenderbufferAttachment() |
| 618 | { |
| 619 | mRenderbuffer.set(NULL); |
| 620 | } |
| 621 | |
| 622 | rx::RenderTarget *RenderbufferAttachment::getRenderTarget() |
| 623 | { |
| 624 | return mRenderbuffer->getStorage()->getRenderTarget(); |
| 625 | } |
| 626 | |
| 627 | rx::RenderTarget *RenderbufferAttachment::getDepthStencil() |
| 628 | { |
| 629 | return mRenderbuffer->getStorage()->getDepthStencil(); |
| 630 | } |
| 631 | |
| 632 | rx::TextureStorage *RenderbufferAttachment::getTextureStorage() |
| 633 | { |
| 634 | UNREACHABLE(); |
| 635 | return NULL; |
| 636 | } |
| 637 | |
| 638 | GLsizei RenderbufferAttachment::getWidth() const |
| 639 | { |
| 640 | return mRenderbuffer->getWidth(); |
| 641 | } |
| 642 | |
| 643 | GLsizei RenderbufferAttachment::getHeight() const |
| 644 | { |
| 645 | return mRenderbuffer->getHeight(); |
| 646 | } |
| 647 | |
| 648 | GLenum RenderbufferAttachment::getInternalFormat() const |
| 649 | { |
| 650 | return mRenderbuffer->getInternalFormat(); |
| 651 | } |
| 652 | |
| 653 | GLenum RenderbufferAttachment::getActualFormat() const |
| 654 | { |
| 655 | return mRenderbuffer->getActualFormat(); |
| 656 | } |
| 657 | |
| 658 | GLsizei RenderbufferAttachment::getSamples() const |
| 659 | { |
| 660 | return mRenderbuffer->getStorage()->getSamples(); |
| 661 | } |
| 662 | |
| 663 | unsigned int RenderbufferAttachment::getSerial() const |
| 664 | { |
| 665 | return mRenderbuffer->getStorage()->getSerial(); |
| 666 | } |
| 667 | |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame] | 668 | GLuint RenderbufferAttachment::id() const |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 669 | { |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame] | 670 | return mRenderbuffer->id(); |
| 671 | } |
| 672 | |
| 673 | GLenum RenderbufferAttachment::type() const |
| 674 | { |
| 675 | return GL_RENDERBUFFER; |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 676 | } |
| 677 | |
Jamie Madill | 9c074a3 | 2014-06-16 10:34:02 -0400 | [diff] [blame] | 678 | GLint RenderbufferAttachment::mipLevel() const |
| 679 | { |
| 680 | return 0; |
| 681 | } |
| 682 | |
| 683 | GLint RenderbufferAttachment::layer() const |
| 684 | { |
| 685 | return 0; |
| 686 | } |
| 687 | |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 688 | unsigned int RenderbufferAttachment::getTextureSerial() const |
| 689 | { |
| 690 | UNREACHABLE(); |
| 691 | return 0; |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 692 | } |
| 693 | |
| 694 | } |