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