History

Trying to fix oculus rendering

Bradley Austin Davis committed 11 years ago

Commit 95964521 parent bd5da875 files · +73 −30Browse files

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

Unified · Split

libraries/render-utils/src/FramebufferCache.cpp+45−16
@@ -35,30 +35,34 @@ void FramebufferCache::setFrameBufferSize(QSize frameBufferSize) { · 34 unmodified lines
3535 if (_frameBufferSize != frameBufferSize) {
3636 _frameBufferSize = frameBufferSize;
3737 _primaryFramebuffer.reset();
38+ _primaryDepthTexture.reset();
39+ _primaryColorTexture.reset();
40+ _primaryNormalTexture.reset();
41+ _primarySpecularTexture.reset();
3842 }
3943 }
4044
4145 void FramebufferCache::createPrimaryFramebuffer() {
4246 _primaryFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create());
4347
44− static auto colorFormat = gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA);
45− static auto depthFormat = gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::DEPTH);
46−
48+ auto colorFormat = gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA);
4749 auto width = _frameBufferSize.width();
4850 auto height = _frameBufferSize.height();
4951
5052 auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_POINT);
51− auto colorTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler));
52− auto normalTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler));
53− auto specularTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler));
53+ _primaryColorTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler));
54+ _primaryNormalTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler));
55+ _primarySpecularTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler));
56+
57+ _primaryFramebuffer->setRenderBuffer(0, _primaryColorTexture);
58+ _primaryFramebuffer->setRenderBuffer(1, _primaryNormalTexture);
59+ _primaryFramebuffer->setRenderBuffer(2, _primarySpecularTexture);
5460
55− _primaryFramebuffer->setRenderBuffer(0, colorTexture);
56− _primaryFramebuffer->setRenderBuffer(1, normalTexture);
57− _primaryFramebuffer->setRenderBuffer(2, specularTexture);
5861
62+ auto depthFormat = gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::DEPTH);
63+ _primaryDepthTexture = gpu::TexturePointer(gpu::Texture::create2D(depthFormat, width, height, defaultSampler));
5964
60− auto depthTexture = gpu::TexturePointer(gpu::Texture::create2D(depthFormat, width, height, defaultSampler));
61− _primaryFramebuffer->setDepthStencilBuffer(depthTexture, depthFormat);
65+ _primaryFramebuffer->setDepthStencilBuffer(_primaryDepthTexture, depthFormat);
6266 }
6367
6468 gpu::FramebufferPointer FramebufferCache::getPrimaryFramebuffer() {
@@ -68,6 +72,36 @@ gpu::FramebufferPointer FramebufferCache::getPrimaryFramebuffer() { · 3 unmodified lines
6872 return _primaryFramebuffer;
6973 }
7074
75+
76+
77+gpu::TexturePointer FramebufferCache::getPrimaryDepthTexture() {
78+ if (!_primaryDepthTexture) {
79+ createPrimaryFramebuffer();
80+ }
81+ return _primaryDepthTexture;
82+}
83+
84+gpu::TexturePointer FramebufferCache::getPrimaryColorTexture() {
85+ if (!_primaryColorTexture) {
86+ createPrimaryFramebuffer();
87+ }
88+ return _primaryColorTexture;
89+}
90+
91+gpu::TexturePointer FramebufferCache::getPrimaryNormalTexture() {
92+ if (!_primaryNormalTexture) {
93+ createPrimaryFramebuffer();
94+ }
95+ return _primaryNormalTexture;
96+}
97+
98+gpu::TexturePointer FramebufferCache::getPrimarySpecularTexture() {
99+ if (!_primarySpecularTexture) {
100+ createPrimaryFramebuffer();
101+ }
102+ return _primarySpecularTexture;
103+}
104+
71105 void FramebufferCache::setPrimaryDrawBuffers(gpu::Batch& batch, bool color, bool normal, bool specular) {
72106 GLenum buffers[3];
73107 int bufferCount = 0;
@@ -98,11 +132,6 @@ void FramebufferCache::releaseFramebuffer(const gpu::FramebufferPointer& framebu · 24 unmodified lines
98132 _cachedFramebuffers.push_back(framebuffer);
99133 }
100134
101−gpu::FramebufferPointer FramebufferCache::getSecondaryFramebuffer() {
102− static auto _secondaryFramebuffer = getFramebuffer();
103− return _secondaryFramebuffer;
104−}
105−
106135 gpu::FramebufferPointer FramebufferCache::getShadowFramebuffer() {
107136 if (!_shadowFramebuffer) {
108137 const int SHADOW_MAP_SIZE = 2048;