Showing the changes to libraries/render-utils/src/FramebufferCache.cpp (1 of 18 files). Show all
Unified · Split
| @@ -33,22 +33,8 @@ void FramebufferCache::setFrameBufferSize(QSize frameBufferSize) { · 32 unmodified lines | |||
| 33 | //If the size changed, we need to delete our FBOs | 33 | //If the size changed, we need to delete our FBOs |
| 34 | if (_frameBufferSize != frameBufferSize) { | 34 | if (_frameBufferSize != frameBufferSize) { |
| 35 | _frameBufferSize = frameBufferSize; | 35 | _frameBufferSize = frameBufferSize; |
| 36 | /* _primaryFramebuffer.reset(); | 36 | _selfieFramebuffer.reset(); |
| 37 | _primaryDepthTexture.reset(); | ||
| 38 | _primaryColorTexture.reset(); | ||
| 39 | _deferredFramebuffer.reset(); | ||
| 40 | _deferredFramebufferDepthColor.reset(); | ||
| 41 | _deferredColorTexture.reset(); | ||
| 42 | _deferredNormalTexture.reset(); | ||
| 43 | _deferredSpecularTexture.reset(); | ||
| 44 | */ _selfieFramebuffer.reset(); | ||
| 45 | _cachedFramebuffers.clear(); | 37 | _cachedFramebuffers.clear(); |
| 46 | /* _lightingTexture.reset(); | ||
| 47 | _lightingFramebuffer.reset(); | ||
| 48 | */ _depthPyramidFramebuffer.reset(); | ||
| 49 | _depthPyramidTexture.reset(); | ||
| 50 | _curvatureFramebuffer.reset(); | ||
| 51 | _curvatureTexture.reset(); | ||
| 52 | _occlusionFramebuffer.reset(); | 38 | _occlusionFramebuffer.reset(); |
| 53 | _occlusionTexture.reset(); | 39 | _occlusionTexture.reset(); |
| 54 | _occlusionBlurredFramebuffer.reset(); | 40 | _occlusionBlurredFramebuffer.reset(); |
| @@ -57,66 +43,21 @@ void FramebufferCache::setFrameBufferSize(QSize frameBufferSize) { · 2 unmodified lines | |||
| 57 | } | 43 | } |
| 58 | 44 | ||
| 59 | void FramebufferCache::createPrimaryFramebuffer() { | 45 | void FramebufferCache::createPrimaryFramebuffer() { |
| 60 | /* _primaryFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create()); | 46 | auto colorFormat = gpu::Element::COLOR_SRGBA_32; |
| 61 | _deferredFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create()); | ||
| 62 | _deferredFramebufferDepthColor = gpu::FramebufferPointer(gpu::Framebuffer::create()); | ||
| 63 | */ | ||
| 64 | auto colorFormat = gpu::Element::COLOR_SRGBA_32; | ||
| 65 | auto linearFormat = gpu::Element::COLOR_RGBA_32; | 47 | auto linearFormat = gpu::Element::COLOR_RGBA_32; |
| 66 | auto width = _frameBufferSize.width(); | 48 | auto width = _frameBufferSize.width(); |
| 67 | auto height = _frameBufferSize.height(); | 49 | auto height = _frameBufferSize.height(); |
| 68 | 50 | ||
| 69 | auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_POINT); | 51 | auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_POINT); |
| 70 | /* _primaryColorTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler)); | ||
| 71 | |||
| 72 | _primaryFramebuffer->setRenderBuffer(0, _primaryColorTexture); | ||
| 73 | |||
| 74 | _deferredColorTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler)); | ||
| 75 | |||
| 76 | _deferredNormalTexture = gpu::TexturePointer(gpu::Texture::create2D(linearFormat, width, height, defaultSampler)); | ||
| 77 | _deferredSpecularTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler)); | ||
| 78 | |||
| 79 | _deferredFramebuffer->setRenderBuffer(0, _deferredColorTexture); | ||
| 80 | _deferredFramebuffer->setRenderBuffer(1, _deferredNormalTexture); | ||
| 81 | _deferredFramebuffer->setRenderBuffer(2, _deferredSpecularTexture); | ||
| 82 | |||
| 83 | _deferredFramebufferDepthColor->setRenderBuffer(0, _deferredColorTexture); | ||
| 84 | */ | ||
| 85 | // auto depthFormat = gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::DEPTH); | ||
| 86 | auto depthFormat = gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::DEPTH_STENCIL); // Depth24_Stencil8 texel format | 52 | auto depthFormat = gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::DEPTH_STENCIL); // Depth24_Stencil8 texel format |
| 87 | /* _primaryDepthTexture = gpu::TexturePointer(gpu::Texture::create2D(depthFormat, width, height, defaultSampler)); | ||
| 88 | |||
| 89 | _primaryFramebuffer->setDepthStencilBuffer(_primaryDepthTexture, depthFormat); | ||
| 90 | |||
| 91 | _deferredFramebuffer->setDepthStencilBuffer(_primaryDepthTexture, depthFormat); | ||
| 92 | |||
| 93 | _deferredFramebufferDepthColor->setDepthStencilBuffer(_primaryDepthTexture, depthFormat); | ||
| 94 | 53 | ||
| 95 | */ | ||
| 96 | _selfieFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create()); | 54 | _selfieFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create()); |
| 97 | auto tex = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width * 0.5, height * 0.5, defaultSampler)); | 55 | auto tex = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width * 0.5, height * 0.5, defaultSampler)); |
| 98 | _selfieFramebuffer->setRenderBuffer(0, tex); | 56 | _selfieFramebuffer->setRenderBuffer(0, tex); |
| 99 | 57 | ||
| 100 | auto smoothSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR); | 58 | auto smoothSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR); |
| 101 | 59 | ||
| 102 | /* _lightingTexture = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::R11G11B10), width, height, defaultSampler)); | ||
| 103 | _lightingFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create()); | ||
| 104 | _lightingFramebuffer->setRenderBuffer(0, _lightingTexture); | ||
| 105 | _lightingFramebuffer->setDepthStencilBuffer(_primaryDepthTexture, depthFormat); | ||
| 106 | 60 | ||
| 107 | _deferredFramebuffer->setRenderBuffer(3, _lightingTexture); | ||
| 108 | */ | ||
| 109 | // For AO: | ||
| 110 | auto pointMipSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_POINT); | ||
| 111 | _depthPyramidTexture = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::RGB), width, height, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT))); | ||
| 112 | _depthPyramidFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create()); | ||
| 113 | _depthPyramidFramebuffer->setRenderBuffer(0, _depthPyramidTexture); | ||
| 114 | // _depthPyramidFramebuffer->setDepthStencilBuffer(_primaryDepthTexture, depthFormat); | ||
| 115 | |||
| 116 | _curvatureTexture = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element::COLOR_RGBA_32, width, height, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT))); | ||
| 117 | _curvatureFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create()); | ||
| 118 | _curvatureFramebuffer->setRenderBuffer(0, _curvatureTexture); | ||
| 119 | // _curvatureFramebuffer->setDepthStencilBuffer(_primaryDepthTexture, depthFormat); | ||
| 120 | 61 | ||
| 121 | resizeAmbientOcclusionBuffers(); | 62 | resizeAmbientOcclusionBuffers(); |
| 122 | } | 63 | } |
| @@ -145,76 +86,7 @@ void FramebufferCache::resizeAmbientOcclusionBuffers() { · 22 unmodified lines | |||
| 145 | _occlusionBlurredFramebuffer->setRenderBuffer(0, _occlusionBlurredTexture); | 86 | _occlusionBlurredFramebuffer->setRenderBuffer(0, _occlusionBlurredTexture); |
| 146 | // _occlusionBlurredFramebuffer->setDepthStencilBuffer(_primaryDepthTexture, depthFormat); | 87 | // _occlusionBlurredFramebuffer->setDepthStencilBuffer(_primaryDepthTexture, depthFormat); |
| 147 | } | 88 | } |
| 148 | /* | ||
| 149 | gpu::FramebufferPointer FramebufferCache::getPrimaryFramebuffer() { | ||
| 150 | if (!_primaryFramebuffer) { | ||
| 151 | createPrimaryFramebuffer(); | ||
| 152 | } | ||
| 153 | return _primaryFramebuffer; | ||
| 154 | } | ||
| 155 | |||
| 156 | gpu::TexturePointer FramebufferCache::getPrimaryDepthTexture() { | ||
| 157 | if (!_primaryDepthTexture) { | ||
| 158 | createPrimaryFramebuffer(); | ||
| 159 | } | ||
| 160 | return _primaryDepthTexture; | ||
| 161 | } | ||
| 162 | |||
| 163 | gpu::TexturePointer FramebufferCache::getPrimaryColorTexture() { | ||
| 164 | if (!_primaryColorTexture) { | ||
| 165 | createPrimaryFramebuffer(); | ||
| 166 | } | ||
| 167 | return _primaryColorTexture; | ||
| 168 | } | ||
| 169 | |||
| 170 | gpu::FramebufferPointer FramebufferCache::getDeferredFramebuffer() { | ||
| 171 | if (!_deferredFramebuffer) { | ||
| 172 | createPrimaryFramebuffer(); | ||
| 173 | } | ||
| 174 | return _deferredFramebuffer; | ||
| 175 | } | ||
| 176 | |||
| 177 | gpu::FramebufferPointer FramebufferCache::getDeferredFramebufferDepthColor() { | ||
| 178 | if (!_deferredFramebufferDepthColor) { | ||
| 179 | createPrimaryFramebuffer(); | ||
| 180 | } | ||
| 181 | return _deferredFramebufferDepthColor; | ||
| 182 | } | ||
| 183 | |||
| 184 | gpu::TexturePointer FramebufferCache::getDeferredColorTexture() { | ||
| 185 | if (!_deferredColorTexture) { | ||
| 186 | createPrimaryFramebuffer(); | ||
| 187 | } | ||
| 188 | return _deferredColorTexture; | ||
| 189 | } | ||
| 190 | |||
| 191 | gpu::TexturePointer FramebufferCache::getDeferredNormalTexture() { | ||
| 192 | if (!_deferredNormalTexture) { | ||
| 193 | createPrimaryFramebuffer(); | ||
| 194 | } | ||
| 195 | return _deferredNormalTexture; | ||
| 196 | } | ||
| 197 | |||
| 198 | gpu::TexturePointer FramebufferCache::getDeferredSpecularTexture() { | ||
| 199 | if (!_deferredSpecularTexture) { | ||
| 200 | createPrimaryFramebuffer(); | ||
| 201 | } | ||
| 202 | return _deferredSpecularTexture; | ||
| 203 | } | ||
| 204 | |||
| 205 | gpu::FramebufferPointer FramebufferCache::getLightingFramebuffer() { | ||
| 206 | if (!_lightingFramebuffer) { | ||
| 207 | createPrimaryFramebuffer(); | ||
| 208 | } | ||
| 209 | return _lightingFramebuffer; | ||
| 210 | } | ||
| 211 | 89 | ||
| 212 | gpu::TexturePointer FramebufferCache::getLightingTexture() { | ||
| 213 | if (!_lightingTexture) { | ||
| 214 | createPrimaryFramebuffer(); | ||
| 215 | } | ||
| 216 | return _lightingTexture; | ||
| 217 | }*/ | ||
| 218 | 90 | ||
| 219 | gpu::FramebufferPointer FramebufferCache::getFramebuffer() { | 91 | gpu::FramebufferPointer FramebufferCache::getFramebuffer() { |
| 220 | if (_cachedFramebuffers.isEmpty()) { | 92 | if (_cachedFramebuffers.isEmpty()) { |
| @@ -238,34 +110,6 @@ gpu::FramebufferPointer FramebufferCache::getSelfieFramebuffer() { · 17 unmodified lines | |||
| 238 | return _selfieFramebuffer; | 110 | return _selfieFramebuffer; |
| 239 | } | 111 | } |
| 240 | 112 | ||
| 241 | gpu::FramebufferPointer FramebufferCache::getDepthPyramidFramebuffer() { | ||
| 242 | if (!_depthPyramidFramebuffer) { | ||
| 243 | createPrimaryFramebuffer(); | ||
| 244 | } | ||
| 245 | return _depthPyramidFramebuffer; | ||
| 246 | } | ||
| 247 | |||
| 248 | gpu::TexturePointer FramebufferCache::getDepthPyramidTexture() { | ||
| 249 | if (!_depthPyramidTexture) { | ||
| 250 | createPrimaryFramebuffer(); | ||
| 251 | } | ||
| 252 | return _depthPyramidTexture; | ||
| 253 | } | ||
| 254 | |||
| 255 | gpu::FramebufferPointer FramebufferCache::getCurvatureFramebuffer() { | ||
| 256 | if (!_curvatureFramebuffer) { | ||
| 257 | createPrimaryFramebuffer(); | ||
| 258 | } | ||
| 259 | return _curvatureFramebuffer; | ||
| 260 | } | ||
| 261 | |||
| 262 | gpu::TexturePointer FramebufferCache::getCurvatureTexture() { | ||
| 263 | if (!_curvatureTexture) { | ||
| 264 | createPrimaryFramebuffer(); | ||
| 265 | } | ||
| 266 | return _curvatureTexture; | ||
| 267 | } | ||
| 268 | |||
| 269 | void FramebufferCache::setAmbientOcclusionResolutionLevel(int level) { | 113 | void FramebufferCache::setAmbientOcclusionResolutionLevel(int level) { |
| 270 | const int MAX_AO_RESOLUTION_LEVEL = 4; | 114 | const int MAX_AO_RESOLUTION_LEVEL = 4; |
| 271 | level = std::max(0, std::min(level, MAX_AO_RESOLUTION_LEVEL)); | 115 | level = std::max(0, std::min(level, MAX_AO_RESOLUTION_LEVEL)); |