Skip to content

[Rendering][P0] Restore deterministic path-tracing goldens and oracle correctness #127

Description

@proggeramlug

Parent: #126

Problem

Bloom's GPU path tracer is the closest in-engine correctness oracle for BRDF energy, direct/indirect visibility, motion reprojection, and denoising. It cannot serve that role unless its golden tests are deterministic and trusted.

The audit found the two path-tracing goldens in native/shared/tests/golden_render.rs failing on the audited worktree:

  • pt_progressive: large mean error plus broad black/speckled regions;
  • pt_realtime_motion: lower mean error but localized high-error trails/outliers.

The worktree contains renderer changes, so the first task is to reproduce on a clean main checkout before assigning blame. Do not update the goldens to make the test green. First determine whether the baseline, harness, backend, or renderer is wrong.

Outcome

A deterministic GPU path-tracing correctness suite that:

  • passes on every supported ray-query backend within documented backend-specific tolerance;
  • fails loudly on transport, TLAS/BLAS, temporal reprojection, denoiser, or resource-lifetime regressions;
  • emits enough evidence for an agent to diagnose a failure without reproducing locally;
  • can act as a reference for realtime renderer changes.

Implementation contract

1. Reproduce and classify

  1. Run each PT golden separately on clean main, recording commit, OS, adapter, driver, backend, features, and actual diff metrics.
  2. Capture pt_progressive.actual.png and pt_realtime_motion.actual.png plus heatmaps.
  3. Add debug captures for raw radiance, albedo, normal, depth, motion, moments/variance, history length, and denoised output.
  4. Classify the first divergent stage. Do not start by widening tolerances.

2. Make stochastic inputs explicit

  • Put the sample seed, sample index, camera frame index, and jitter sequence under test control.
  • Reset all path-tracing history and resource state at test start.
  • Ensure headless initialization cannot inherit process-global or prior-test state.
  • Document which floating-point/backend differences are expected and why.

3. Fix the first incorrect stage

Likely areas include native/shared/src/renderer/pt_pass.rs, native/shared/src/renderer/shaders/pt.rs, TLAS/BLAS update ordering in renderer/mod.rs, motion matrices, SVGF history validation, and render-graph resource ordering. Fix the earliest provably incorrect stage rather than compensating downstream.

4. Improve the failure artifact

On failure, write an artifact directory containing:

  • expected, actual, absolute-diff, and false-color heatmap PNGs;
  • JSON with mean/max error, outlier percentage, SSIM, adapter/backend, seed, frames/spp, and enabled features;
  • named intermediate buffers when BLOOM_GOLDEN_DIAGNOSTICS=1.

Acceptance criteria

  • golden_pt_progressive and golden_pt_realtime_motion pass three consecutive runs on the same adapter with identical or explicitly bounded metrics.
  • At least one Metal and one DX12 or Vulkan ray-query adapter pass in CI or a documented scheduled hardware runner.
  • Injecting a known reprojection error makes the motion golden fail; injecting a BRDF energy error makes the progressive golden fail.
  • No black regions, block trails, NaN/Inf pixels, or uninitialized-history pixels are present in accepted output.
  • CPU reference renders from tools/bloom-reference are used to sanity-check the static scene's energy and occlusion; any expected model difference is documented.
  • Golden changes, if genuinely required after a correctness fix, are isolated in a second reviewable commit with before/after images and an explanation.
  • Unsupported adapters skip with a structured reason; supported ray-query adapters may not silently skip because DXC or a feature was packaged incorrectly.

Verification

cd native/shared
cargo test --release golden_pt_progressive -- --nocapture
cargo test --release golden_pt_realtime_motion -- --nocapture
cargo test --release golden -- --nocapture

Run the relevant reference scene through tools/bloom-reference and attach the result metadata to the PR.

Non-goals

  • Adding new path-tracing features.
  • Raising tolerances to hide a structural regression.
  • Requiring ray query on baseline adapters.

Dependencies

None. This blocks quality claims in every renderer issue under #126.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions