Skip to content

Fix/flaky fog visual evidence test - #465

Merged
drsnuggles8 merged 3 commits into
masterfrom
fix/flaky-fog-visual-evidence-test
Jun 29, 2026
Merged

drsnuggles8 merged 3 commits into
masterfrom
fix/flaky-fog-visual-evidence-test

Conversation

@drsnuggles8

@drsnuggles8 drsnuggles8 commented Jun 29, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes
    • Fixed fog rendering so it stays correct even when GPU buffer bindings change during a frame.
    • Improved stability for scenes placed far from the origin, preventing incorrect fog behavior and visual glitches.
    • Added safeguards so fog effects continue to render with the expected camera data and distance-based fade.

drsnuggles8 and others added 2 commits June 29, 2026 10:46
…ogVisualEvidenceTest (#446)

The Fog (binding 17) and FogVolumes (binding 20) UBOs are glBindBufferBase'd only
in their constructor and thereafter only have their contents refreshed via SetData.
Deleting any GL buffer that GL currently has bound at a slot reverts that slot to 0,
so ordinary cross-test buffer churn in the full suite knocked binding 17 to 0. The
late post-process fog pass then read an unbound FogData UBO (all zeros) ->
u_FogFlags.x == 0 -> the shader's disabled early-out -> fog silently not applied,
producing a frame byte-identical with fog OFF. This only manifested in the full
suite (isolation never accumulated the churn), making FogVisualEvidenceTest flaky.

Re-bind the Fog and FogVolumes UBOs after every per-frame SetData, mirroring the
binding-8 motion-blur UBO which already guards against this exact hazard.

Adds a deterministic regression test (ReappliesFogAfterFogUboBindingKnockedOut)
that knocks binding 17 to 0 directly so it guards the fix even in isolation, plus
a postmortem in docs/bug-investigations.

Confirmed via GPU read-back of the live UBO binding ids: full suite had binding 17
unbound (id 0) vs id 46 in isolation. Full clean suite now green.

Fixes #446

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…raPosition read

During the fog post-process pass, UBO binding 0 can hold a 64-byte
ViewProjection-only camera UBO (Renderer2D / ParticleBatchRenderer style) left by
an earlier stage, not the full 272-byte CameraUBO. The fog shaders read past it:
u_CameraPosition (std140 offset 192, PostProcess_Fog.glsl) and u_Projection
(offset 128, PostProcess_FogUpsample.glsl). Origin-centred scenes survive only
because NVIDIA's robust-buffer-access returns 0 for OOB reads (0 happens to equal
the true camera there); OOB UBO reads are undefined per the GL spec, and any
scene whose camera sits far from the world origin fogs wrong.

FogRenderPass::Execute now re-binds the full shared camera UBO at binding 0
before drawing (plumbed via SetCameraUBO), mirroring its existing binding-7
PostProcess UBO re-bind. Re-binding at the per-frame upload site does not work
here because a later scene stage re-binds the 64-byte buffer afterward.

Adds FogVisualEvidenceOffOriginTest, which renders the identical scene ~1000
units from the origin; verified empirically that without the re-bind the near
floor floods blue (nearOn.R=113 B=182) and with it the near floor stays warm.
Surfaced during the #446 investigation; documented in docs/bug-investigations.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@drsnuggles8, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 25 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 658557f4-8678-4b76-8b5a-d3318a41ccbc

📥 Commits

Reviewing files that changed from the base of the PR and between 5e111cb and 8eaf61f.

📒 Files selected for processing (2)
  • OloEngine/src/OloEngine/Renderer/Passes/FogRenderPass.h
  • OloEngine/tests/Rendering/PropertyTests/FogVisualEvidenceTest.cpp
📝 Walkthrough

Walkthrough

Two OpenGL UBO binding hazards in fog rendering are fixed. RenderPipeline::UploadExecutionState now explicitly re-binds the Fog (slot 17) and FogVolumes (slot 20) UBOs after each per-frame SetData call. FogRenderPass gains a SetCameraUBO setter and re-binds the full shared camera UBO at slot 0 in Execute to prevent out-of-bounds reads from a smaller VP-only UBO left by earlier pipeline stages. Regression tests and an investigation document are added.

Changes

Fog UBO Binding Fixes

Layer / File(s) Summary
Per-frame fog UBO re-bind in RenderPipeline
OloEngine/src/OloEngine/Renderer/RenderPipeline.cpp
After uploading fog and fog-volumes data each frame, explicit Bind() calls re-pin UBO slots 17 and 20, preventing binding knock-out from other buffer deletions.
Full camera UBO wired to FogRenderPass
OloEngine/src/OloEngine/Renderer/Passes/FogRenderPass.h, OloEngine/src/OloEngine/Renderer/Passes/FogRenderPass.cpp, OloEngine/src/OloEngine/Renderer/RenderPipeline.cpp
FogRenderPass adds SetCameraUBO/m_CameraUBO; ConfigurePassesForFrame passes the shared camera UBO; Execute re-binds it at slot 0 before drawing.
Regression tests for both binding hazards
OloEngine/tests/Rendering/PropertyTests/FogVisualEvidenceTest.cpp
m_WorldOffset enables scene shifting; a knockout test deliberately unbinds slot 17 and asserts re-bind and far-band fog color; an off-origin test asserts near-band warmth and far-band blue dominance.
Bug investigation docs and README
docs/bug-investigations/fog-ubo-binding-knockout-investigation.md, docs/README.md
Investigation document records root cause, GPU instrumentation findings, binding mechanism, both fixes, regression test descriptions, and debugging heuristics; README index links to it.

Possibly related issues

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: fixing a flaky fog visual evidence test and related fog-binding issues.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@OloEngine/src/OloEngine/Renderer/Passes/FogRenderPass.h`:
- Around line 76-85: `FogRenderPass` still treats the pass as ready without
verifying `m_CameraUBO`, so a missing `SetCameraUBO()` can let `Execute()` run
against an unintended binding-0 UBO. Update `IsReadyForExecution()` to include
`m_CameraUBO` in its readiness check, or add a fail-fast guard in `Execute()`
using the same `FogRenderPass`/`SetCameraUBO` state so the pass cannot run
without the required camera buffer.

In `@OloEngine/tests/Rendering/PropertyTests/FogVisualEvidenceTest.cpp`:
- Around line 395-411: The FogVisualEvidenceTest setup is mutating global GL
state by unbinding the Fog UBO without restoring it, which can leak into later
GPU tests. In the test around the glBindBufferBase(GL_UNIFORM_BUFFER,
ShaderBindingLayout::UBO_FOG, 0) call, save the current binding first and
restore it afterward using a small RAII/scoped guard so the original Fog UBO
binding is reinstated even on fatal failures. Keep the change localized to the
test flow around Capture and the post-frame glGetIntegeri_v invariant check.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d03d4706-21c4-40f1-9f27-4c52f0b181f1

📥 Commits

Reviewing files that changed from the base of the PR and between 06f49ad and 5e111cb.

⛔ Files ignored due to path filters (2)
  • OloEditor/assets/tests/visual/Fog_KnockoutOn.png is excluded by !**/*.png
  • OloEditor/assets/tests/visual/Fog_OffOriginOn.png is excluded by !**/*.png
📒 Files selected for processing (6)
  • OloEngine/src/OloEngine/Renderer/Passes/FogRenderPass.cpp
  • OloEngine/src/OloEngine/Renderer/Passes/FogRenderPass.h
  • OloEngine/src/OloEngine/Renderer/RenderPipeline.cpp
  • OloEngine/tests/Rendering/PropertyTests/FogVisualEvidenceTest.cpp
  • docs/README.md
  • docs/bug-investigations/fog-ubo-binding-knockout-investigation.md

@drsnuggles8
drsnuggles8 merged commit 21a8d89 into master Jun 29, 2026
2 of 8 checks passed
@drsnuggles8
drsnuggles8 deleted the fix/flaky-fog-visual-evidence-test branch June 29, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant