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

Code before:
                        // if the buffer is discarded (e.g. it's new) and we're blending,
                        // then clear it to transparent
                        out.params.flags.clear |= TargetBufferFlags::COLOR;
                        out.params.clearColor = {};
                    }
                }

                if (colorGradingConfig.asSubpass || colorGradingConfig.customResolve) {
                    out.params.subpassMask = 1;
                }

                driver.beginRenderPass(out.target, out.params);
                Platform* platform = engine.getPlatform();
                CircularBuffer const& circularBuffer = driver.getCircularBuffer();
                // b/479079631: Log the current command buffer size before and after executing the
                // render pass.
                if (platform->hasDebugUpdateStatFunc()) {
                    platform->debugUpdateStat(
                            "filament.renderer.color_pass.command_buffer_used_start",
                            circularBuffer.getUsed());
                }
                passExecutor.execute(engine, driver);
                if (platform->hasDebugUpdateStatFunc()) {
                    platform->debugUpdateStat(
                            "filament.renderer.color_pass.command_buffer_used_end",
                            driver.getCircularBuffer().getUsed());
                }
                driver.endRenderPass();

                // unbind all descriptor sets to avoid false dependencies with the next pass
                DescriptorSet::unbind(driver, DescriptorSetBindingPoints::PER_VIEW);
                DescriptorSet::unbind(driver, DescriptorSetBindingPoints::PER_RENDERABLE);
                DescriptorSet::unbind(driver, DescriptorSetBindingPoints::PER_MATERIAL);
            }
    );

    return {
            .linearColor = colorPass->color,
            .tonemappedColor = colorPass->output,   // can be null
            .depth = colorPass->depth
    };
}


RenderPass::Command const* RendererUtils::getFirstRefractionCommand(
    RenderPass const& pass) noexcept {

    // find the first refractive object in channel 2
    RenderPass::Command const* const refraction = std::partition_point(pass.begin(), pass.end(),
        [](auto const& command) {
            constexpr uint64_t mask  = RenderPass::CHANNEL_MASK | RenderPass::PASS_MASK;

Review comment (suggestion):
```suggestion
                            circularBuffer.getUsed());
```

Code after:
                        // if the buffer is discarded (e.g. it's new) and we're blending,
                        // then clear it to transparent
                        out.params.flags.clear |= TargetBufferFlags::COLOR;
                        out.params.clearColor = {};
                    }
                }

                if (colorGradingConfig.asSubpass || colorGradingConfig.customResolve) {
                    out.params.subpassMask = 1;
                }

                driver.beginRenderPass(out.target, out.params);
                Platform* platform = engine.getPlatform();
                CircularBuffer const& circularBuffer = driver.getCircularBuffer();
                // b/479079631: Log the current command buffer size before and after executing the
                // render pass.
                if (platform->hasDebugUpdateStatFunc()) {
                    platform->debugUpdateStat(
                            "filament.renderer.color_pass.command_buffer_used_start",
                            circularBuffer.getUsed());
                }
                passExecutor.execute(engine, driver);
                if (platform->hasDebugUpdateStatFunc()) {
                    platform->debugUpdateStat(
                            "filament.renderer.color_pass.command_buffer_used_end",
                            circularBuffer.getUsed());
                }
                driver.endRenderPass();

                // unbind all descriptor sets to avoid false dependencies with the next pass
                DescriptorSet::unbind(driver, DescriptorSetBindingPoints::PER_VIEW);
                DescriptorSet::unbind(driver, DescriptorSetBindingPoints::PER_RENDERABLE);
                DescriptorSet::unbind(driver, DescriptorSetBindingPoints::PER_MATERIAL);
            }
    );

    return {
            .linearColor = colorPass->color,
            .tonemappedColor = colorPass->output,   // can be null
            .depth = colorPass->depth
    };
}


RenderPass::Command const* RendererUtils::getFirstRefractionCommand(
    RenderPass const& pass) noexcept {

    // find the first refractive object in channel 2
    RenderPass::Command const* const refraction = std::partition_point(pass.begin(), pass.end(),
        [](auto const& command) {
            constexpr uint64_t mask  = RenderPass::CHANNEL_MASK | RenderPass::PASS_MASK;