History

grouping the depth and stencil buffer into a single buffer

samcake committed 11 years ago

Commit bad5ea71 parent f1058034 files · +8 −45Browse files

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

Unified · Split

libraries/render-utils/src/FramebufferCache.cpp+2−29
@@ -35,9 +35,7 @@ void FramebufferCache::setFrameBufferSize(QSize frameBufferSize) { · 34 unmodified lines
35 _frameBufferSize = frameBufferSize;35 _frameBufferSize = frameBufferSize;
36 _primaryFramebufferFull.reset();36 _primaryFramebufferFull.reset();
37 _primaryFramebufferDepthColor.reset();37 _primaryFramebufferDepthColor.reset();
38 _primaryFramebufferStencilColor.reset();
39 _primaryDepthTexture.reset();38 _primaryDepthTexture.reset();
40 _primaryStencilTexture.reset();
41 _primaryColorTexture.reset();39 _primaryColorTexture.reset();
42 _primaryNormalTexture.reset();40 _primaryNormalTexture.reset();
43 _primarySpecularTexture.reset();41 _primarySpecularTexture.reset();
@@ -49,7 +47,6 @@ void FramebufferCache::setFrameBufferSize(QSize frameBufferSize) { · 5 unmodified lines
49void FramebufferCache::createPrimaryFramebuffer() {47void FramebufferCache::createPrimaryFramebuffer() {
50 _primaryFramebufferFull = gpu::FramebufferPointer(gpu::Framebuffer::create());48 _primaryFramebufferFull = gpu::FramebufferPointer(gpu::Framebuffer::create());
51 _primaryFramebufferDepthColor = gpu::FramebufferPointer(gpu::Framebuffer::create());49 _primaryFramebufferDepthColor = gpu::FramebufferPointer(gpu::Framebuffer::create());
52 _primaryFramebufferStencilColor = gpu::FramebufferPointer(gpu::Framebuffer::create());
53 50
54 auto colorFormat = gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA);51 auto colorFormat = gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA);
55 auto width = _frameBufferSize.width();52 auto width = _frameBufferSize.width();
@@ -66,24 +63,14 @@ void FramebufferCache::createPrimaryFramebuffer() { · 10 unmodified lines
66 63
67 _primaryFramebufferDepthColor->setRenderBuffer(0, _primaryColorTexture);64 _primaryFramebufferDepthColor->setRenderBuffer(0, _primaryColorTexture);
68 65
69 _primaryFramebufferStencilColor->setRenderBuffer(0, _primaryColorTexture);
70
71 // auto depthFormat = gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::DEPTH);66 // auto depthFormat = gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::DEPTH);
72 auto depthFormat = gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::DEPTH_STENCIL); // Depth24_Stencil8 texel format67 auto depthFormat = gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::DEPTH_STENCIL); // Depth24_Stencil8 texel format
73 _primaryDepthTexture = gpu::TexturePointer(gpu::Texture::create2D(depthFormat, width, height, defaultSampler));68 _primaryDepthTexture = gpu::TexturePointer(gpu::Texture::create2D(depthFormat, width, height, defaultSampler));
74 69
75 // auto stencilFormat = gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::DEPTH_STENCIL); // Depth24_Stencil8 texel format
76 auto stencilFormat = depthFormat;
77 // _primaryStencilTexture = gpu::TexturePointer(gpu::Texture::create2D(stencilFormat, width, height, defaultSampler));
78 _primaryStencilTexture = _primaryDepthTexture;
79
80 _primaryFramebufferFull->setDepthStencilBuffer(_primaryDepthTexture, depthFormat);70 _primaryFramebufferFull->setDepthStencilBuffer(_primaryDepthTexture, depthFormat);
81 71
82 _primaryFramebufferDepthColor->setDepthStencilBuffer(_primaryDepthTexture, depthFormat);72 _primaryFramebufferDepthColor->setDepthStencilBuffer(_primaryDepthTexture, depthFormat);
83 73
84 // _primaryFramebufferStencilColor->setDepthStencilBuffer(_primaryStencilTexture, stencilFormat);
85 _primaryFramebufferStencilColor = _primaryFramebufferDepthColor;
86
87 _selfieFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create());74 _selfieFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create());
88 auto tex = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width * 0.5, height * 0.5, defaultSampler));75 auto tex = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width * 0.5, height * 0.5, defaultSampler));
89 _selfieFramebuffer->setRenderBuffer(0, tex);76 _selfieFramebuffer->setRenderBuffer(0, tex);
@@ -103,13 +90,6 @@ gpu::FramebufferPointer FramebufferCache::getPrimaryFramebufferDepthColor() { · 13 unmodified lines
103 return _primaryFramebufferDepthColor;90 return _primaryFramebufferDepthColor;
104}91}
105 92
106gpu::FramebufferPointer FramebufferCache::getPrimaryFramebufferStencilColor() {
107 if (!_primaryFramebufferStencilColor) {
108 createPrimaryFramebuffer();
109 }
110 return _primaryFramebufferStencilColor;
111}
112
113gpu::TexturePointer FramebufferCache::getPrimaryDepthTexture() {93gpu::TexturePointer FramebufferCache::getPrimaryDepthTexture() {
114 if (!_primaryDepthTexture) {94 if (!_primaryDepthTexture) {
115 createPrimaryFramebuffer();95 createPrimaryFramebuffer();
@@ -117,13 +97,6 @@ gpu::TexturePointer FramebufferCache::getPrimaryDepthTexture() { · 1 unmodified line
117 return _primaryDepthTexture;97 return _primaryDepthTexture;
118}98}
119 99
120gpu::TexturePointer FramebufferCache::getPrimaryStencilTexture() {
121 if (!_primaryStencilTexture) {
122 createPrimaryFramebuffer();
123 }
124 return _primaryStencilTexture;
125}
126
127gpu::TexturePointer FramebufferCache::getPrimaryColorTexture() {100gpu::TexturePointer FramebufferCache::getPrimaryColorTexture() {
128 if (!_primaryColorTexture) {101 if (!_primaryColorTexture) {
129 createPrimaryFramebuffer();102 createPrimaryFramebuffer();