History

FIund a nasty bug with the scissor which was the reason for many issues, tried to integrate the framebuffer setup and clear as part of the enginepipeline so calling display side is simpler

Sam Gateau committed 11 years ago

Commit cb375e81 parent 66cd17e8 files · +79 −108Browse files

Showing the changes to libraries/render-utils/src/FramebufferCache.cpp (1 of 8 files). Show all

Unified · Split

libraries/render-utils/src/FramebufferCache.cpp+19−8
@@ -34,7 +34,8 @@ void FramebufferCache::setFrameBufferSize(QSize frameBufferSize) { · 33 unmodified lines
34 //If the size changed, we need to delete our FBOs34 //If the size changed, we need to delete our FBOs
35 if (_frameBufferSize != frameBufferSize) {35 if (_frameBufferSize != frameBufferSize) {
36 _frameBufferSize = frameBufferSize;36 _frameBufferSize = frameBufferSize;
37 _primaryFramebuffer.reset();37 _primaryFramebufferFull.reset();
38 _primaryFramebufferDepthColor.reset();
38 _primaryDepthTexture.reset();39 _primaryDepthTexture.reset();
39 _primaryColorTexture.reset();40 _primaryColorTexture.reset();
40 _primaryNormalTexture.reset();41 _primaryNormalTexture.reset();
@@ -45,7 +46,8 @@ void FramebufferCache::setFrameBufferSize(QSize frameBufferSize) { · 4 unmodified lines
45}46}
46 47
47void FramebufferCache::createPrimaryFramebuffer() {48void FramebufferCache::createPrimaryFramebuffer() {
48 _primaryFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create());49 _primaryFramebufferFull = gpu::FramebufferPointer(gpu::Framebuffer::create());
50 _primaryFramebufferDepthColor = gpu::FramebufferPointer(gpu::Framebuffer::create());
49 51
50 auto colorFormat = gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA);52 auto colorFormat = gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA);
51 auto width = _frameBufferSize.width();53 auto width = _frameBufferSize.width();
@@ -56,24 +58,33 @@ void FramebufferCache::createPrimaryFramebuffer() { · 4 unmodified lines
56 _primaryNormalTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler));58 _primaryNormalTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler));
57 _primarySpecularTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler));59 _primarySpecularTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler));
58 60
59 _primaryFramebuffer->setRenderBuffer(0, _primaryColorTexture);61 _primaryFramebufferFull->setRenderBuffer(0, _primaryColorTexture);
60 _primaryFramebuffer->setRenderBuffer(1, _primaryNormalTexture);62 _primaryFramebufferFull->setRenderBuffer(1, _primaryNormalTexture);
61 _primaryFramebuffer->setRenderBuffer(2, _primarySpecularTexture);63 _primaryFramebufferFull->setRenderBuffer(2, _primarySpecularTexture);
62 64
65 _primaryFramebufferDepthColor->setRenderBuffer(0, _primaryColorTexture);
63 66
64 auto depthFormat = gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::DEPTH);67 auto depthFormat = gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::DEPTH);
65 _primaryDepthTexture = gpu::TexturePointer(gpu::Texture::create2D(depthFormat, width, height, defaultSampler));68 _primaryDepthTexture = gpu::TexturePointer(gpu::Texture::create2D(depthFormat, width, height, defaultSampler));
66 69
67 _primaryFramebuffer->setDepthStencilBuffer(_primaryDepthTexture, depthFormat);70 _primaryFramebufferFull->setDepthStencilBuffer(_primaryDepthTexture, depthFormat);
71
72 _primaryFramebufferDepthColor->setDepthStencilBuffer(_primaryDepthTexture, depthFormat);
68}73}
69 74
70gpu::FramebufferPointer FramebufferCache::getPrimaryFramebuffer() {75gpu::FramebufferPointer FramebufferCache::getPrimaryFramebuffer() {
71 if (!_primaryFramebuffer) {76 if (!_primaryFramebufferFull) {
72 createPrimaryFramebuffer();77 createPrimaryFramebuffer();
73 }78 }
74 return _primaryFramebuffer;79 return _primaryFramebufferFull;
75}80}
76 81
82gpu::FramebufferPointer FramebufferCache::getPrimaryFramebufferDepthColor() {
83 if (!_primaryFramebufferDepthColor) {
84 createPrimaryFramebuffer();
85 }
86 return _primaryFramebufferDepthColor;
87}
77 88
78 89
79gpu::TexturePointer FramebufferCache::getPrimaryDepthTexture() {90gpu::TexturePointer FramebufferCache::getPrimaryDepthTexture() {