Showing the changes to libraries/render-utils/src/RenderCommonTask.cpp (1 of 4 files). Show all
Unified · Split
| @@ -197,7 +197,73 @@ void Blit::run(const RenderContextPointer& renderContext, const gpu::Framebuffer · 196 unmodified lines | ||
| 197 | 197 | }); |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | −void ExtractFrustums::run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& output) { | |
| 200 | + | |
| 201 | +void ResolveFramebuffer::run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs) { | |
| 202 | + RenderArgs* args = renderContext->args; | |
| 203 | + auto srcFbo = inputs.get0(); | |
| 204 | + auto destFbo = inputs.get1(); | |
| 205 | + | |
| 206 | + if (!destFbo) { | |
| 207 | + destFbo = args->_blitFramebuffer; | |
| 208 | + } | |
| 209 | + outputs = destFbo; | |
| 210 | + | |
| 211 | + // Check valid src and dest | |
| 212 | + if (!srcFbo || !destFbo) { | |
| 213 | + return; | |
| 214 | + } | |
| 215 | + | |
| 216 | + // Check valid size for sr and dest | |
| 217 | + auto frameSize(srcFbo->getSize()); | |
| 218 | + if (destFbo->getSize() != frameSize) { | |
| 219 | + return; | |
| 220 | + } | |
| 221 | + | |
| 222 | + gpu::Vec4i rectSrc; | |
| 223 | + rectSrc.z = frameSize.x; | |
| 224 | + rectSrc.w = frameSize.y; | |
| 225 | + gpu::doInBatch("Resolve", args->_context, [&](gpu::Batch& batch) { | |
| 226 | + batch.blit(srcFbo, rectSrc, destFbo, rectSrc); | |
| 227 | + }); | |
| 228 | +} | |
| 229 | + | |
| 230 | +void ResolveNewFramebuffer::run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs) { | |
| 231 | + RenderArgs* args = renderContext->args; | |
| 232 | + auto srcFbo = inputs; | |
| 233 | + outputs.reset(); | |
| 234 | + | |
| 235 | + // Check valid src | |
| 236 | + if (!srcFbo) { | |
| 237 | + return; | |
| 238 | + } | |
| 239 | + | |
| 240 | + // Check valid size for sr and dest | |
| 241 | + auto frameSize(srcFbo->getSize()); | |
| 242 | + | |
| 243 | + // Resizing framebuffers instead of re-building them seems to cause issues with threaded rendering | |
| 244 | + if (_outputFramebuffer && _outputFramebuffer->getSize() != frameSize) { | |
| 245 | + _outputFramebuffer.reset(); | |
| 246 | + } | |
| 247 | + | |
| 248 | + if (!_outputFramebuffer) { | |
| 249 | + _outputFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("resolvedNew.out")); | |
| 250 | + auto colorFormat = gpu::Element::COLOR_SRGBA_32; | |
| 251 | + auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR); | |
| 252 | + auto colorTexture = gpu::Texture::createRenderBuffer(colorFormat, frameSize.x, frameSize.y, gpu::Texture::SINGLE_MIP, defaultSampler); | |
| 253 | + _outputFramebuffer->setRenderBuffer(0, colorTexture); | |
| 254 | + } | |
| 255 | + | |
| 256 | + gpu::Vec4i rectSrc; | |
| 257 | + rectSrc.z = frameSize.x; | |
| 258 | + rectSrc.w = frameSize.y; | |
| 259 | + gpu::doInBatch("ResolveNew", args->_context, [&](gpu::Batch& batch) { batch.blit(srcFbo, rectSrc, _outputFramebuffer, rectSrc); }); | |
| 260 | + | |
| 261 | + outputs = _outputFramebuffer; | |
| 262 | +} | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + void ExtractFrustums::run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& output) { | |
| 201 | 267 | assert(renderContext->args); |
| 202 | 268 | assert(renderContext->args->_context); |
| 203 | 269 | |