Skip to content

perf ticket 008: visibility buffer (Nanite-style) replaces 4-MRT G-buffer #27

Description

@proggeramlug

Parent roadmap: #126
Design/qualification contract: docs/perf/008-visibility-buffer.md
Active implementation: PR #147

Corrected objective

Qualify a Nanite-style visibility-buffer composition path without assuming a bandwidth or overdraw win. Bloom already has an alpha-aware depth prepass, so the comparison must include depth, visibility raster, reconstructed PBR shading, compatibility rendering, all MRT writes, memory, and frame total.

The packed target is Rg32Uint (8 bytes/pixel), not Rgba32Uint (16 bytes/pixel). It stores a 32-bit draw ID plus a 31-bit primitive ID and front-face bit. Perspective-correct barycentrics are reconstructed from the referenced triangle rather than stored.

Landed architecture

  • Shared CPU/WGSL ID, face, barycentric, vertex/index, first-index, and base-vertex contract.
  • Exact 96-byte Vertex3D storage decoder using six packed vec4<u32> lanes.
  • Real depth-equal visibility raster against GPU-driven indirect geometry.
  • Full-screen shading reconstructs the production VertexOutputScene and calls the exact authoritative shade_main_scene; material, clustered lighting, shadows, IBL, velocity, and MRT logic are not forked.
  • Static fully opaque Tier-A shared-arena draws are eligible. Cutout/masked, blend, transmission, layered/custom, skinned, deforming, and unsupported draws remain explicitly forward-compatible.
  • BLOOM_VISIBILITY_BUFFER=validate|debug|shade selects qualification modes before device creation. Default/off requests no PRIMITIVE_INDEX, creates no visibility pipeline/resource, and records no work.
  • Shade mode owns one Rg32Uint target (8 bytes/pixel). Validate/debug also own an 8-byte diagnostic reconstruction target.
  • Capability telemetry exposes request state, activation reason, composition owner, eligible/compatibility counts, extent, bytes, and current-frame recording.

Verified evidence

  • Packed ID/front-face ABI and background sentinel tests.
  • CPU/GPU perspective reconstruction oracle, including non-zero first index and base vertex.
  • All 24 packed vertex lanes reconstructed from real storage buffers.
  • Real GPU visibility raster/reconstruction runtime test.
  • Real GPU full-PBR shading test where eligible forward fragments are deliberately suppressed.
  • Compatibility composition test includes a layered-PBR draw.
  • Deterministic off-vs-shade image test: 89 of 81,920 channels differ, maximum 1 LSB, mean delta 0.00108643.
  • Shade steady state creates no new texture or bind group after initialization.
  • Default/off path has zero allocation/work and preserves the shipping renderer.
  • Strict lint, WebAssembly check, contracts, 376 unit tests, 59 golden tests, render-target tests, and visibility GPU tests pass locally on Metal.

Remaining activation gates

  • Separate/compact eligible and compatibility indirect command streams so eligible geometry is not still dispatched through the forward compatibility shader. The current opt-in correctness path may cost more GPU time and must not ship as default.
  • Capture total uncapped GPU time for depth_prepass, visibility_raster_pass, visibility_pbr_pass, main_hdr_pass, and frame total against forward/off.
  • Prove all individual MRT outputs—not only the final screenshot—match for HDR, material, velocity, and albedo.
  • Run identical-camera Bistro and stress-scene corpora with SSR, SSGI, SSAO, TAA, VSM/cascades, planar probes, custom opaque materials, cutouts, skinning, refraction, and transparency.
  • Demonstrate no regression on low-overdraw scenes and a material improvement on a representative admitted workload.
  • Qualify at least one discrete and one integrated/tile-based adapter; retain fallback for adapters without PRIMITIVE_INDEX.
  • Decide whether masked/cutout geometry remains compatibility-only or gains an alpha-aware visibility raster without changing silhouettes/order.
  • Enable outside explicit qualification only after every visual, memory, and total-GPU gate passes.

Next implementation slice

  1. Extend GPU culling/compaction to route visibility-eligible and compatibility draws into distinct bounded indirect streams and counters.
  2. Make the main forward pass submit only compatibility commands in shade mode; preserve today’s single stream byte-for-byte in off/validate/debug modes.
  3. Add CPU-oracle tests for routing, zero-eligible/all-eligible/mixed counts, fixed-count fallback, and capacity/steady-state invariants.
  4. Add per-pass and frame-total A/B artifacts, followed by deterministic Bistro camera-corpus captures and individual-MRT readback gates.

Likely files

  • native/shared/src/renderer/gpu_driven.rs
  • native/shared/src/renderer/visibility_buffer.rs
  • native/shared/src/renderer/visibility_shading.rs
  • native/shared/src/renderer/scene_pass.rs
  • native/shared/tests/visibility_buffer_*.rs
  • tools/quality/ for governed Bistro/MRT/timing comparison

Non-goals for activation

  • Claiming a win from target byte size alone.
  • Replacing compatibility paths before they have equivalent semantics.
  • Enabling the path by default while total GPU time or any downstream buffer is unproven.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions