Repository: google/filament
File: filament/src/PostProcessManager.cpp (C++)

Code before:
    driver.beginRenderPass(out.target, out.params);
    driver.draw(pipeline, mFullScreenQuadRph, 0, 3, 1);
    driver.endRenderPass();
}

UTILS_NOINLINE
void PostProcessManager::renderFullScreenQuadWithScissor(
        FrameGraphResources::RenderPassInfo const& out,
        PipelineState const& pipeline,
        backend::Viewport const scissor,
        DriverApi& driver) const noexcept {
    assert_invariant(
            ((out.params.readOnlyDepthStencil & RenderPassParams::READONLY_DEPTH)
                    && !pipeline.rasterState.depthWrite)
            || !(out.params.readOnlyDepthStencil & RenderPassParams::READONLY_DEPTH));
    driver.beginRenderPass(out.target, out.params);
    driver.scissor(scissor);
    driver.draw(pipeline, mFullScreenQuadRph, 0, 3, 1);
    driver.endRenderPass();
}

UTILS_NOINLINE
void PostProcessManager::commitAndRenderFullScreenQuad(DriverApi& driver,
        FrameGraphResources::RenderPassInfo const& out, FMaterialInstance const* mi,
        PostProcessVariant const variant) const noexcept {
    mi->commit(driver, mEngine.getUboManager());
    mi->use(driver);
    FMaterial const* const ma = mi->getMaterial();
    PipelineState const pipeline = getPipelineState(ma, variant);

    assert_invariant(
            ((out.params.readOnlyDepthStencil & RenderPassParams::READONLY_DEPTH)
             && !pipeline.rasterState.depthWrite)
            || !(out.params.readOnlyDepthStencil & RenderPassParams::READONLY_DEPTH));

    driver.beginRenderPass(out.target, out.params);
    driver.draw(pipeline, mFullScreenQuadRph, 0, 3, 1);
    driver.endRenderPass();
    DescriptorSet::unbind(driver, DescriptorSetBindingPoints::PER_MATERIAL);
}

// ------------------------------------------------------------------------------------------------

PostProcessManager::StructurePassOutput PostProcessManager::structure(FrameGraph& fg,
        RenderPassBuilder const& passBuilder, uint8_t const structureRenderFlags,
        uint32_t width, uint32_t height,
        StructurePassConfig const& config) noexcept {

    const float scale = config.scale;

    // structure pass -- automatically culled if not used, currently used by:

Review comment (suggestion):
I would add a `getUboManager()` to `PostProcessManager`. This way, if for some reason in the future we want to use a different instance of UboManager for the PostProcessManager we can do that easily.

Code after:
    assert_invariant(
            ((out.params.readOnlyDepthStencil & RenderPassParams::READONLY_DEPTH)
                    && !pipeline.rasterState.depthWrite)
            || !(out.params.readOnlyDepthStencil & RenderPassParams::READONLY_DEPTH));
    driver.beginRenderPass(out.target, out.params);
    driver.draw(pipeline, mFullScreenQuadRph, 0, 3, 1);
    driver.endRenderPass();
}

UTILS_NOINLINE
void PostProcessManager::renderFullScreenQuadWithScissor(
        FrameGraphResources::RenderPassInfo const& out,
        PipelineState const& pipeline,
        backend::Viewport const scissor,
        DriverApi& driver) const noexcept {
    assert_invariant(
            ((out.params.readOnlyDepthStencil & RenderPassParams::READONLY_DEPTH)
                    && !pipeline.rasterState.depthWrite)
            || !(out.params.readOnlyDepthStencil & RenderPassParams::READONLY_DEPTH));
    driver.beginRenderPass(out.target, out.params);
    driver.scissor(scissor);
    driver.draw(pipeline, mFullScreenQuadRph, 0, 3, 1);
    driver.endRenderPass();
}

UTILS_NOINLINE
void PostProcessManager::commitAndRenderFullScreenQuad(DriverApi& driver,
        FrameGraphResources::RenderPassInfo const& out, FMaterialInstance const* mi,
        PostProcessVariant const variant) const noexcept {
    mi->commit(driver, getUboManager());
    mi->use(driver);
    FMaterial const* const ma = mi->getMaterial();
    PipelineState const pipeline = getPipelineState(ma, variant);

    assert_invariant(
            ((out.params.readOnlyDepthStencil & RenderPassParams::READONLY_DEPTH)
             && !pipeline.rasterState.depthWrite)
            || !(out.params.readOnlyDepthStencil & RenderPassParams::READONLY_DEPTH));

    driver.beginRenderPass(out.target, out.params);
    driver.draw(pipeline, mFullScreenQuadRph, 0, 3, 1);
    driver.endRenderPass();
    DescriptorSet::unbind(driver, DescriptorSetBindingPoints::PER_MATERIAL);
}

// ------------------------------------------------------------------------------------------------

PostProcessManager::StructurePassOutput PostProcessManager::structure(FrameGraph& fg,
        RenderPassBuilder const& passBuilder, uint8_t const structureRenderFlags,
        uint32_t width, uint32_t height,
        StructurePassConfig const& config) noexcept {