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 | |
| 118 | unsigned int Texture2DAttachment::getTextureSerial() const |
| 119 | { |
| 120 | return mTexture2D->getTextureSerial(); |
| 121 | } |
| 122 | |
| 123 | ///// TextureCubeMapAttachment Implementation //////// |
| 124 | |
| 125 | TextureCubeMapAttachment::TextureCubeMapAttachment(TextureCubeMap *texture, GLenum faceTarget, GLint level) |
| 126 | : mFaceTarget(faceTarget), mLevel(level) |
| 127 | { |
| 128 | mTextureCubeMap.set(texture); |
| 129 | } |
| 130 | |
| 131 | TextureCubeMapAttachment::~TextureCubeMapAttachment() |
| 132 | { |
| 133 | mTextureCubeMap.set(NULL); |
| 134 | } |
| 135 | |
| 136 | // Textures need to maintain their own reference count for references via |
| 137 | // Renderbuffers acting as proxies. Here, we notify the texture of a reference. |
| 138 | void TextureCubeMapAttachment::addProxyRef(const FramebufferAttachment *proxy) |
| 139 | { |
| 140 | mTextureCubeMap->addProxyRef(proxy); |
| 141 | } |
| 142 | |
| 143 | void TextureCubeMapAttachment::releaseProxy(const FramebufferAttachment *proxy) |
| 144 | { |
| 145 | mTextureCubeMap->releaseProxy(proxy); |
| 146 | } |
| 147 | |
| 148 | rx::RenderTarget *TextureCubeMapAttachment::getRenderTarget() |
| 149 | { |
| 150 | return mTextureCubeMap->getRenderTarget(mFaceTarget, mLevel); |
| 151 | } |
| 152 | |
| 153 | rx::RenderTarget *TextureCubeMapAttachment::getDepthStencil() |
| 154 | { |
| 155 | return mTextureCubeMap->getDepthStencil(mFaceTarget, mLevel); |
| 156 | } |
| 157 | |
| 158 | rx::TextureStorage *TextureCubeMapAttachment::getTextureStorage() |
| 159 | { |
| 160 | return mTextureCubeMap->getNativeTexture()->getStorageInstance(); |
| 161 | } |
| 162 | |
| 163 | GLsizei TextureCubeMapAttachment::getWidth() const |
| 164 | { |
| 165 | return mTextureCubeMap->getWidth(mFaceTarget, mLevel); |
| 166 | } |
| 167 | |
| 168 | GLsizei TextureCubeMapAttachment::getHeight() const |
| 169 | { |
| 170 | return mTextureCubeMap->getHeight(mFaceTarget, mLevel); |
| 171 | } |
| 172 | |
| 173 | GLenum TextureCubeMapAttachment::getInternalFormat() const |
| 174 | { |
| 175 | return mTextureCubeMap->getInternalFormat(mFaceTarget, mLevel); |
| 176 | } |
| 177 | |
| 178 | GLenum TextureCubeMapAttachment::getActualFormat() const |
| 179 | { |
| 180 | return mTextureCubeMap->getActualFormat(mFaceTarget, mLevel); |
| 181 | } |
| 182 | |
| 183 | GLsizei TextureCubeMapAttachment::getSamples() const |
| 184 | { |
| 185 | return 0; |
| 186 | } |
| 187 | |
| 188 | unsigned int TextureCubeMapAttachment::getSerial() const |
| 189 | { |
| 190 | return mTextureCubeMap->getRenderTargetSerial(mFaceTarget, mLevel); |
| 191 | } |
| 192 | |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame^] | 193 | GLuint TextureCubeMapAttachment::id() const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 194 | { |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame^] | 195 | return mTextureCubeMap->id(); |
| 196 | } |
| 197 | |
| 198 | GLenum TextureCubeMapAttachment::type() const |
| 199 | { |
| 200 | return mFaceTarget; |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | unsigned int TextureCubeMapAttachment::getTextureSerial() const |
| 204 | { |
| 205 | return mTextureCubeMap->getTextureSerial(); |
| 206 | } |
| 207 | |
| 208 | ///// Texture3DAttachment Implementation //////// |
| 209 | |
| 210 | Texture3DAttachment::Texture3DAttachment(Texture3D *texture, GLint level, GLint layer) |
| 211 | : mLevel(level), mLayer(layer) |
| 212 | { |
| 213 | mTexture3D.set(texture); |
| 214 | } |
| 215 | |
| 216 | Texture3DAttachment::~Texture3DAttachment() |
| 217 | { |
| 218 | mTexture3D.set(NULL); |
| 219 | } |
| 220 | |
| 221 | // Textures need to maintain their own reference count for references via |
| 222 | // Renderbuffers acting as proxies. Here, we notify the texture of a reference. |
| 223 | void Texture3DAttachment::addProxyRef(const FramebufferAttachment *proxy) |
| 224 | { |
| 225 | mTexture3D->addProxyRef(proxy); |
| 226 | } |
| 227 | |
| 228 | void Texture3DAttachment::releaseProxy(const FramebufferAttachment *proxy) |
| 229 | { |
| 230 | mTexture3D->releaseProxy(proxy); |
| 231 | } |
| 232 | |
| 233 | rx::RenderTarget *Texture3DAttachment::getRenderTarget() |
| 234 | { |
| 235 | return mTexture3D->getRenderTarget(mLevel, mLayer); |
| 236 | } |
| 237 | |
| 238 | rx::RenderTarget *Texture3DAttachment::getDepthStencil() |
| 239 | { |
| 240 | return mTexture3D->getDepthStencil(mLevel, mLayer); |
| 241 | } |
| 242 | |
| 243 | rx::TextureStorage *Texture3DAttachment::getTextureStorage() |
| 244 | { |
| 245 | return mTexture3D->getNativeTexture()->getStorageInstance(); |
| 246 | } |
| 247 | |
| 248 | GLsizei Texture3DAttachment::getWidth() const |
| 249 | { |
| 250 | return mTexture3D->getWidth(mLevel); |
| 251 | } |
| 252 | |
| 253 | GLsizei Texture3DAttachment::getHeight() const |
| 254 | { |
| 255 | return mTexture3D->getHeight(mLevel); |
| 256 | } |
| 257 | |
| 258 | GLenum Texture3DAttachment::getInternalFormat() const |
| 259 | { |
| 260 | return mTexture3D->getInternalFormat(mLevel); |
| 261 | } |
| 262 | |
| 263 | GLenum Texture3DAttachment::getActualFormat() const |
| 264 | { |
| 265 | return mTexture3D->getActualFormat(mLevel); |
| 266 | } |
| 267 | |
| 268 | GLsizei Texture3DAttachment::getSamples() const |
| 269 | { |
| 270 | return 0; |
| 271 | } |
| 272 | |
| 273 | unsigned int Texture3DAttachment::getSerial() const |
| 274 | { |
| 275 | return mTexture3D->getRenderTargetSerial(mLevel, mLayer); |
| 276 | } |
| 277 | |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame^] | 278 | GLuint Texture3DAttachment::id() const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 279 | { |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame^] | 280 | return mTexture3D->id(); |
| 281 | } |
| 282 | |
| 283 | GLenum Texture3DAttachment::type() const |
| 284 | { |
| 285 | return GL_TEXTURE_3D; |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | unsigned int Texture3DAttachment::getTextureSerial() const |
| 289 | { |
| 290 | return mTexture3D->getTextureSerial(); |
| 291 | } |
| 292 | |
| 293 | ////// Texture2DArrayAttachment Implementation ////// |
| 294 | |
| 295 | Texture2DArrayAttachment::Texture2DArrayAttachment(Texture2DArray *texture, GLint level, GLint layer) |
| 296 | : mLevel(level), mLayer(layer) |
| 297 | { |
| 298 | mTexture2DArray.set(texture); |
| 299 | } |
| 300 | |
| 301 | Texture2DArrayAttachment::~Texture2DArrayAttachment() |
| 302 | { |
| 303 | mTexture2DArray.set(NULL); |
| 304 | } |
| 305 | |
| 306 | void Texture2DArrayAttachment::addProxyRef(const FramebufferAttachment *proxy) |
| 307 | { |
| 308 | mTexture2DArray->addProxyRef(proxy); |
| 309 | } |
| 310 | |
| 311 | void Texture2DArrayAttachment::releaseProxy(const FramebufferAttachment *proxy) |
| 312 | { |
| 313 | mTexture2DArray->releaseProxy(proxy); |
| 314 | } |
| 315 | |
| 316 | rx::RenderTarget *Texture2DArrayAttachment::getRenderTarget() |
| 317 | { |
| 318 | return mTexture2DArray->getRenderTarget(mLevel, mLayer); |
| 319 | } |
| 320 | |
| 321 | rx::RenderTarget *Texture2DArrayAttachment::getDepthStencil() |
| 322 | { |
| 323 | return mTexture2DArray->getDepthStencil(mLevel, mLayer); |
| 324 | } |
| 325 | |
| 326 | rx::TextureStorage *Texture2DArrayAttachment::getTextureStorage() |
| 327 | { |
| 328 | return mTexture2DArray->getNativeTexture()->getStorageInstance(); |
| 329 | } |
| 330 | |
| 331 | GLsizei Texture2DArrayAttachment::getWidth() const |
| 332 | { |
| 333 | return mTexture2DArray->getWidth(mLevel); |
| 334 | } |
| 335 | |
| 336 | GLsizei Texture2DArrayAttachment::getHeight() const |
| 337 | { |
| 338 | return mTexture2DArray->getHeight(mLevel); |
| 339 | } |
| 340 | |
| 341 | GLenum Texture2DArrayAttachment::getInternalFormat() const |
| 342 | { |
| 343 | return mTexture2DArray->getInternalFormat(mLevel); |
| 344 | } |
| 345 | |
| 346 | GLenum Texture2DArrayAttachment::getActualFormat() const |
| 347 | { |
| 348 | return mTexture2DArray->getActualFormat(mLevel); |
| 349 | } |
| 350 | |
| 351 | GLsizei Texture2DArrayAttachment::getSamples() const |
| 352 | { |
| 353 | return 0; |
| 354 | } |
| 355 | |
| 356 | unsigned int Texture2DArrayAttachment::getSerial() const |
| 357 | { |
| 358 | return mTexture2DArray->getRenderTargetSerial(mLevel, mLayer); |
| 359 | } |
| 360 | |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame^] | 361 | GLuint Texture2DArrayAttachment::id() const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 362 | { |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame^] | 363 | return mTexture2DArray->id(); |
| 364 | } |
| 365 | |
| 366 | GLenum Texture2DArrayAttachment::type() const |
| 367 | { |
| 368 | return GL_TEXTURE_2D_ARRAY; |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | unsigned int Texture2DArrayAttachment::getTextureSerial() const |
| 372 | { |
| 373 | return mTexture2DArray->getTextureSerial(); |
| 374 | } |
| 375 | |
| 376 | ////// FramebufferAttachment Implementation ////// |
| 377 | |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 378 | FramebufferAttachment::FramebufferAttachment(GLuint id, FramebufferAttachmentImpl *instance) |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 379 | : RefCountObject(id), |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 380 | mImpl(instance) |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 381 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 382 | ASSERT(mImpl != NULL); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | FramebufferAttachment::~FramebufferAttachment() |
| 386 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 387 | SafeDelete(mImpl); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 388 | } |
| 389 | |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 390 | // The FramebufferAttachmentImpl contained in this FramebufferAttachment may need to maintain |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 391 | // its own reference count, so we pass it on here. |
| 392 | void FramebufferAttachment::addRef() const |
| 393 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 394 | mImpl->addProxyRef(this); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 395 | |
| 396 | RefCountObject::addRef(); |
| 397 | } |
| 398 | |
| 399 | void FramebufferAttachment::release() const |
| 400 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 401 | mImpl->releaseProxy(this); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 402 | |
| 403 | RefCountObject::release(); |
| 404 | } |
| 405 | |
| 406 | rx::RenderTarget *FramebufferAttachment::getRenderTarget() |
| 407 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 408 | return mImpl->getRenderTarget(); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 409 | } |
| 410 | |
| 411 | rx::RenderTarget *FramebufferAttachment::getDepthStencil() |
| 412 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 413 | return mImpl->getDepthStencil(); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 414 | } |
| 415 | |
| 416 | rx::TextureStorage *FramebufferAttachment::getTextureStorage() |
| 417 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 418 | return mImpl->getTextureStorage(); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 419 | } |
| 420 | |
| 421 | GLsizei FramebufferAttachment::getWidth() const |
| 422 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 423 | return mImpl->getWidth(); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | GLsizei FramebufferAttachment::getHeight() const |
| 427 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 428 | return mImpl->getHeight(); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | GLenum FramebufferAttachment::getInternalFormat() const |
| 432 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 433 | return mImpl->getInternalFormat(); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 434 | } |
| 435 | |
| 436 | GLenum FramebufferAttachment::getActualFormat() const |
| 437 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 438 | return mImpl->getActualFormat(); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 439 | } |
| 440 | |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 441 | GLuint FramebufferAttachment::getRedSize(int clientVersion) const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 442 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 443 | if (gl::GetRedBits(getInternalFormat(), clientVersion) > 0) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 444 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 445 | return gl::GetRedBits(getActualFormat(), clientVersion); |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 446 | } |
| 447 | else |
| 448 | { |
| 449 | return 0; |
| 450 | } |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 451 | } |
| 452 | |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 453 | GLuint FramebufferAttachment::getGreenSize(int clientVersion) const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 454 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 455 | if (gl::GetGreenBits(getInternalFormat(), clientVersion) > 0) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 456 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 457 | return gl::GetGreenBits(getActualFormat(), clientVersion); |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 458 | } |
| 459 | else |
| 460 | { |
| 461 | return 0; |
| 462 | } |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 463 | } |
| 464 | |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 465 | GLuint FramebufferAttachment::getBlueSize(int clientVersion) const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 466 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 467 | if (gl::GetBlueBits(getInternalFormat(), clientVersion) > 0) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 468 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 469 | return gl::GetBlueBits(getActualFormat(), clientVersion); |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 470 | } |
| 471 | else |
| 472 | { |
| 473 | return 0; |
| 474 | } |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 475 | } |
| 476 | |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 477 | GLuint FramebufferAttachment::getAlphaSize(int clientVersion) const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 478 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 479 | if (gl::GetAlphaBits(getInternalFormat(), clientVersion) > 0) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 480 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 481 | return gl::GetAlphaBits(getActualFormat(), clientVersion); |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 482 | } |
| 483 | else |
| 484 | { |
| 485 | return 0; |
| 486 | } |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 487 | } |
| 488 | |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 489 | GLuint FramebufferAttachment::getDepthSize(int clientVersion) const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 490 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 491 | if (gl::GetDepthBits(getInternalFormat(), clientVersion) > 0) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 492 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 493 | return gl::GetDepthBits(getActualFormat(), clientVersion); |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 494 | } |
| 495 | else |
| 496 | { |
| 497 | return 0; |
| 498 | } |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 499 | } |
| 500 | |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 501 | GLuint FramebufferAttachment::getStencilSize(int clientVersion) const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 502 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 503 | if (gl::GetStencilBits(getInternalFormat(), clientVersion) > 0) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 504 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 505 | return gl::GetStencilBits(getActualFormat(), clientVersion); |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 506 | } |
| 507 | else |
| 508 | { |
| 509 | return 0; |
| 510 | } |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 511 | } |
| 512 | |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 513 | GLenum FramebufferAttachment::getComponentType(int clientVersion) const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 514 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 515 | return gl::GetComponentType(getActualFormat(), clientVersion); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 516 | } |
| 517 | |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 518 | GLenum FramebufferAttachment::getColorEncoding(int clientVersion) const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 519 | { |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 520 | return gl::GetColorEncoding(getActualFormat(), clientVersion); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 521 | } |
| 522 | |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame^] | 523 | bool FramebufferAttachment::isTexture() const |
| 524 | { |
| 525 | return (type() != GL_RENDERBUFFER); |
| 526 | } |
| 527 | |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 528 | GLsizei FramebufferAttachment::getSamples() const |
| 529 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 530 | return mImpl->getSamples(); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 531 | } |
| 532 | |
| 533 | unsigned int FramebufferAttachment::getSerial() const |
| 534 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 535 | return mImpl->getSerial(); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 536 | } |
| 537 | |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame^] | 538 | GLuint FramebufferAttachment::id() const |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 539 | { |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame^] | 540 | return mImpl->id(); |
| 541 | } |
| 542 | |
| 543 | GLuint FramebufferAttachment::type() const |
| 544 | { |
| 545 | return mImpl->type(); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 546 | } |
| 547 | |
| 548 | unsigned int FramebufferAttachment::getTextureSerial() const |
| 549 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 550 | return mImpl->getTextureSerial(); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 551 | } |
| 552 | |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 553 | void FramebufferAttachment::setImplementation(FramebufferAttachmentImpl *newImpl) |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 554 | { |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 555 | ASSERT(newImpl != NULL); |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 556 | |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 557 | delete mImpl; |
| 558 | mImpl = newImpl; |
| 559 | } |
| 560 | |
| 561 | RenderbufferAttachment::RenderbufferAttachment(Renderbuffer *renderbuffer) |
| 562 | { |
| 563 | ASSERT(renderbuffer); |
| 564 | mRenderbuffer.set(renderbuffer); |
| 565 | } |
| 566 | |
| 567 | RenderbufferAttachment::~RenderbufferAttachment() |
| 568 | { |
| 569 | mRenderbuffer.set(NULL); |
| 570 | } |
| 571 | |
| 572 | rx::RenderTarget *RenderbufferAttachment::getRenderTarget() |
| 573 | { |
| 574 | return mRenderbuffer->getStorage()->getRenderTarget(); |
| 575 | } |
| 576 | |
| 577 | rx::RenderTarget *RenderbufferAttachment::getDepthStencil() |
| 578 | { |
| 579 | return mRenderbuffer->getStorage()->getDepthStencil(); |
| 580 | } |
| 581 | |
| 582 | rx::TextureStorage *RenderbufferAttachment::getTextureStorage() |
| 583 | { |
| 584 | UNREACHABLE(); |
| 585 | return NULL; |
| 586 | } |
| 587 | |
| 588 | GLsizei RenderbufferAttachment::getWidth() const |
| 589 | { |
| 590 | return mRenderbuffer->getWidth(); |
| 591 | } |
| 592 | |
| 593 | GLsizei RenderbufferAttachment::getHeight() const |
| 594 | { |
| 595 | return mRenderbuffer->getHeight(); |
| 596 | } |
| 597 | |
| 598 | GLenum RenderbufferAttachment::getInternalFormat() const |
| 599 | { |
| 600 | return mRenderbuffer->getInternalFormat(); |
| 601 | } |
| 602 | |
| 603 | GLenum RenderbufferAttachment::getActualFormat() const |
| 604 | { |
| 605 | return mRenderbuffer->getActualFormat(); |
| 606 | } |
| 607 | |
| 608 | GLsizei RenderbufferAttachment::getSamples() const |
| 609 | { |
| 610 | return mRenderbuffer->getStorage()->getSamples(); |
| 611 | } |
| 612 | |
| 613 | unsigned int RenderbufferAttachment::getSerial() const |
| 614 | { |
| 615 | return mRenderbuffer->getStorage()->getSerial(); |
| 616 | } |
| 617 | |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame^] | 618 | GLuint RenderbufferAttachment::id() const |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 619 | { |
Jamie Madill | 218b6ed | 2014-06-16 10:34:01 -0400 | [diff] [blame^] | 620 | return mRenderbuffer->id(); |
| 621 | } |
| 622 | |
| 623 | GLenum RenderbufferAttachment::type() const |
| 624 | { |
| 625 | return GL_RENDERBUFFER; |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 626 | } |
| 627 | |
| 628 | unsigned int RenderbufferAttachment::getTextureSerial() const |
| 629 | { |
| 630 | UNREACHABLE(); |
| 631 | return 0; |
Jamie Madill | afc21c0 | 2014-06-04 15:29:47 -0400 | [diff] [blame] | 632 | } |
| 633 | |
| 634 | } |