Skip to content

The coverage of a program in a traversal records no texture feedback - #84

Merged
tomaszbk merged 1 commit into
mainfrom
shaders/coverage-without-feedback
Nov 15, 2026
Merged

tomaszbk merged 1 commit into
mainfrom
shaders/coverage-without-feedback

Conversation

@5hif7y

@5hif7y 5hif7y commented Nov 15, 2026

Copy link
Copy Markdown
Member

Closes #83.

Changes

hit_alpha evaluates the alpha of a program with coverage inside every traversal (surface_coverage.slang). In a stage with MIRAI_TEXTURE_FEEDBACK, each sample of the program also writes the feedback of its texture: an atomic, which the optimizer keeps, and with it every read and the code around it.

  • texture_feedback_quiet (scene.slang) keeps those samples from writing while hit_alpha evaluates the alpha (trace.slang).
  • Only what the alpha reads stays of the program in the traversal.
  • The hit the ray stops at is shaded, and records its feedback, as before.
  • materials.md (Coverage in the traversal) says so.

+13/−1 in the shaders, plus 2 lines of docs. No new mechanism and no per-program opt-in: it holds for every program with coverage.

Measured

RX 580, amdvlk, Windows 10, 16 GB.

SPIR-V of demo, against the same generation without this change. Only stages with texture feedback change:

Stage Before After
reflect.comp 3.37 MB 2.66 MB
reflect_hw.comp 2.25 MB 1.92 MB
ddgi_trace.comp 1.24 MB 0.90 MB
ddgi_trace_hw.comp 0.88 MB 0.71 MB

Making demo's reflect.comp in a test, one variant per process, with the driver's VkCache moved aside:

Time Peak private memory
Before (all 4 variants) not done after 220 s, killed > 13 GB
After, constants {color, unlayered} 144 s 5.4 GB
After, no constants 144 s 5.4 GB

The main editor opened on demo, windowed and not --copy:

  • Before: no API after 30 min, private memory 25 GB.
  • After: the API answers at 268 s, peak 7.8 GB, renderer_problem empty.

Tests

Not tested

  • The full mirai test render suite does not finish on this machine, on main either: a device lost in Ddgi_Trace while Glass_Light runs, then 4 gpu_ tests wait past the timeout. Those 4 pass alone on both sides.
  • A test that fails without this change. The property is the size of a compiled stage, measured above.
  • Linux and macOS. Metal has no MIRAI_TEXTURE_FEEDBACK path in the traversal to change.
  • The residency of a texture read only by the coverage of a program, a mask seen only through rays: its level now follows the other samples of the frame.

🤖 Generated with Claude Code

…feedback

hit_alpha evaluates the alpha of a program with coverage inside every
traversal (surface_coverage.slang). Each sample of a program writes the
feedback of its texture in a stage with MIRAI_TEXTURE_FEEDBACK, an atomic
the optimizer keeps, and with it every read and the code around it: the
whole program, colors and normals too, in every traversal of the stage.
On demo, Terrain_Layers made reflect.comp 3.37 MB, which amdvlk did not
compile in 15 minutes with 19 GB, so a cold editor without ray queries
never opened.

texture_feedback_quiet keeps those samples from writing while the alpha is
evaluated, and only what the alpha reads stays. On demo: reflect.comp
2.66 MB, 144 s and 5.4 GB to make on an RX 580; ddgi_trace and the
hardware stages shrink too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

The coverage of a Surface program keeps the whole program in every traversal, and a tracer stage may never compile

2 participants