Showing the changes to libraries/render-utils/src/FramebufferCache.cpp (1 of 7 files). Show all
Unified · Split
| @@ -33,12 +33,14 @@ void FramebufferCache::setFrameBufferSize(QSize frameBufferSize) { · 32 unmodified lines | ||
| 33 | 33 | //If the size changed, we need to delete our FBOs |
| 34 | 34 | if (_frameBufferSize != frameBufferSize) { |
| 35 | 35 | _frameBufferSize = frameBufferSize; |
| 36 | − _primaryFramebufferFull.reset(); | |
| 37 | 36 | _primaryFramebufferDepthColor.reset(); |
| 38 | 37 | _primaryDepthTexture.reset(); |
| 39 | 38 | _primaryColorTexture.reset(); |
| 40 | − _primaryNormalTexture.reset(); | |
| 41 | − _primarySpecularTexture.reset(); | |
| 39 | + _deferredFramebuffer.reset(); | |
| 40 | + _deferredFramebufferDepthColor.reset(); | |
| 41 | + _deferredColorTexture.reset(); | |
| 42 | + _deferredNormalTexture.reset(); | |
| 43 | + _deferredSpecularTexture.reset(); | |
| 42 | 44 | _selfieFramebuffer.reset(); |
| 43 | 45 | _cachedFramebuffers.clear(); |
| 44 | 46 | _lightingTexture.reset(); |
| @@ -47,8 +49,9 @@ void FramebufferCache::setFrameBufferSize(QSize frameBufferSize) { · 2 unmodified lines | ||
| 47 | 49 | } |
| 48 | 50 | |
| 49 | 51 | void FramebufferCache::createPrimaryFramebuffer() { |
| 50 | − _primaryFramebufferFull = gpu::FramebufferPointer(gpu::Framebuffer::create()); | |
| 51 | 52 | _primaryFramebufferDepthColor = gpu::FramebufferPointer(gpu::Framebuffer::create()); |
| 53 | + _deferredFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create()); | |
| 54 | + _deferredFramebufferDepthColor = gpu::FramebufferPointer(gpu::Framebuffer::create()); | |
| 52 | 55 | |
| 53 | 56 | auto colorFormat = gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA); |
| 54 | 57 | auto width = _frameBufferSize.width(); |
| @@ -56,23 +59,30 @@ void FramebufferCache::createPrimaryFramebuffer() { · 1 unmodified line | ||
| 56 | 59 | |
| 57 | 60 | auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_POINT); |
| 58 | 61 | _primaryColorTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler)); |
| 59 | − _primaryNormalTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler)); | |
| 60 | − _primarySpecularTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler)); | |
| 61 | − | |
| 62 | − _primaryFramebufferFull->setRenderBuffer(0, _primaryColorTexture); | |
| 63 | − _primaryFramebufferFull->setRenderBuffer(1, _primaryNormalTexture); | |
| 64 | − _primaryFramebufferFull->setRenderBuffer(2, _primarySpecularTexture); | |
| 65 | 62 | |
| 66 | 63 | _primaryFramebufferDepthColor->setRenderBuffer(0, _primaryColorTexture); |
| 67 | 64 | |
| 65 | + _deferredColorTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler)); | |
| 66 | + _deferredNormalTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler)); | |
| 67 | + _deferredSpecularTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler)); | |
| 68 | + | |
| 69 | + _deferredFramebuffer->setRenderBuffer(0, _deferredColorTexture); | |
| 70 | + _deferredFramebuffer->setRenderBuffer(1, _deferredNormalTexture); | |
| 71 | + _deferredFramebuffer->setRenderBuffer(2, _deferredSpecularTexture); | |
| 72 | + | |
| 73 | + _deferredFramebufferDepthColor->setRenderBuffer(0, _deferredColorTexture); | |
| 74 | + | |
| 68 | 75 | // auto depthFormat = gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::DEPTH); |
| 69 | 76 | auto depthFormat = gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::DEPTH_STENCIL); // Depth24_Stencil8 texel format |
| 70 | 77 | _primaryDepthTexture = gpu::TexturePointer(gpu::Texture::create2D(depthFormat, width, height, defaultSampler)); |
| 71 | − | |
| 72 | − _primaryFramebufferFull->setDepthStencilBuffer(_primaryDepthTexture, depthFormat); | |
| 73 | 78 | |
| 74 | 79 | _primaryFramebufferDepthColor->setDepthStencilBuffer(_primaryDepthTexture, depthFormat); |
| 75 | − | |
| 80 | + | |
| 81 | + _deferredFramebuffer->setDepthStencilBuffer(_primaryDepthTexture, depthFormat); | |
| 82 | + | |
| 83 | + _deferredFramebufferDepthColor->setDepthStencilBuffer(_primaryDepthTexture, depthFormat); | |
| 84 | + | |
| 85 | + | |
| 76 | 86 | _selfieFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create()); |
| 77 | 87 | auto tex = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width * 0.5, height * 0.5, defaultSampler)); |
| 78 | 88 | _selfieFramebuffer->setRenderBuffer(0, tex); |
| @@ -84,13 +94,6 @@ void FramebufferCache::createPrimaryFramebuffer() { · 5 unmodified lines | ||
| 84 | 94 | _lightingFramebuffer->setRenderBuffer(0, _lightingTexture); |
| 85 | 95 | } |
| 86 | 96 | |
| 87 | −gpu::FramebufferPointer FramebufferCache::getPrimaryFramebuffer() { | |
| 88 | − if (!_primaryFramebufferFull) { | |
| 89 | − createPrimaryFramebuffer(); | |
| 90 | − } | |
| 91 | − return _primaryFramebufferFull; | |
| 92 | −} | |
| 93 | − | |
| 94 | 97 | gpu::FramebufferPointer FramebufferCache::getPrimaryFramebufferDepthColor() { |
| 95 | 98 | if (!_primaryFramebufferDepthColor) { |
| 96 | 99 | createPrimaryFramebuffer(); |
| @@ -112,18 +115,39 @@ gpu::TexturePointer FramebufferCache::getPrimaryColorTexture() { · 15 unmodified lines | ||
| 112 | 115 | return _primaryColorTexture; |
| 113 | 116 | } |
| 114 | 117 | |
| 115 | −gpu::TexturePointer FramebufferCache::getPrimaryNormalTexture() { | |
| 116 | − if (!_primaryNormalTexture) { | |
| 118 | +gpu::FramebufferPointer FramebufferCache::getDeferredFramebuffer() { | |
| 119 | + if (!_deferredFramebuffer) { | |
| 120 | + createPrimaryFramebuffer(); | |
| 121 | + } | |
| 122 | + return _deferredFramebuffer; | |
| 123 | +} | |
| 124 | + | |
| 125 | +gpu::FramebufferPointer FramebufferCache::getDeferredFramebufferDepthColor() { | |
| 126 | + if (!_deferredFramebufferDepthColor) { | |
| 127 | + createPrimaryFramebuffer(); | |
| 128 | + } | |
| 129 | + return _deferredFramebufferDepthColor; | |
| 130 | +} | |
| 131 | + | |
| 132 | +gpu::TexturePointer FramebufferCache::getDeferredColorTexture() { | |
| 133 | + if (!_deferredColorTexture) { | |
| 134 | + createPrimaryFramebuffer(); | |
| 135 | + } | |
| 136 | + return _deferredColorTexture; | |
| 137 | +} | |
| 138 | + | |
| 139 | +gpu::TexturePointer FramebufferCache::getDeferredNormalTexture() { | |
| 140 | + if (!_deferredNormalTexture) { | |
| 117 | 141 | createPrimaryFramebuffer(); |
| 118 | 142 | } |
| 119 | − return _primaryNormalTexture; | |
| 143 | + return _deferredNormalTexture; | |
| 120 | 144 | } |
| 121 | 145 | |
| 122 | −gpu::TexturePointer FramebufferCache::getPrimarySpecularTexture() { | |
| 123 | − if (!_primarySpecularTexture) { | |
| 146 | +gpu::TexturePointer FramebufferCache::getDeferredSpecularTexture() { | |
| 147 | + if (!_deferredSpecularTexture) { | |
| 124 | 148 | createPrimaryFramebuffer(); |
| 125 | 149 | } |
| 126 | − return _primarySpecularTexture; | |
| 150 | + return _deferredSpecularTexture; | |
| 127 | 151 | } |
| 128 | 152 | |
| 129 | 153 | gpu::FramebufferPointer FramebufferCache::getLightingFramebuffer() { |