You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The coverage of a Surface program keeps the whole program in every traversal, and a tracer stage may never compile #83
The coverage of a Surface program keeps the whole program in every traversal, and a tracer stage may never compile
What happens
On a GPU without ray queries, the software tracer stages of a project whose Surface programs have coverage, such as demo with Terrain_Layers, can be too large for the driver to compile.
Measured on an RX 580 (amdvlk, Windows 10, 16 GB), compiling reflect.comp alone in a test, one variant per process, with the driver's VkCache moved aside:
reflect.comp
SPIR-V
Compile
Peak private memory
Engine generation (no programs)
2.24 MB
80–90 s
~5 GB
demo generation
3.37 MB
not done after 220 s (killed)
> 13 GB, still rising
demo, in the editor
3.37 MB
not done after 15 min
19 GB, Windows paging
Effects seen on that machine:
A cold main editor never opens its API: it compiles the tracer before the API, and its private memory reaches 25 GB.
A headless editor that draws (engine.step, bench compare) waits for the stage forever.
surface_coverage.slang evaluates the alpha of a program with coverage inside the traversal (hit_alpha → mirai_program_alpha → <Program>::evaluate(...).alpha).
The alpha of Terrain_Layers depends only on whether the point is over a hole.
Its evaluate also reads the normal map, the paint map and up to 4 layers.
Every texture read of a program goes through mirai_sample_texture*, which calls texture_feedback. In a stage with MIRAI_TEXTURE_FEEDBACK (reflect, ddgi_trace, surface_points…), that is an InterlockedMin into the feedback buffer: a side effect. So the optimizer keeps every read and the code around it, the whole program, in every inlined traversal of the stage, although only alpha is used there.
Isolated with slangc (the cook's flags, reproducing the 3,373,500-byte stage exactly):
Change to demo's reflect.comp
SPIR-V
None
3.37 MB
Ray hook of the portals off
3.36 MB
Ray, light and probe hooks off
3.21 MB
Terrain_Layers coverage replaced by alpha = 1
2.61 MB
Coverage samples record no feedback
2.66 MB
[loop] on the 2-iteration loops of trace_ray, trace_segment and direct_lighting changes nothing, and neither do spirv-opt -O or Slang -O2: the reads stay because they write.
Expected
The coverage test inside a traversal keeps only what alpha reads, for any program, so a stage that traces costs about the same with or without programs with coverage.
Activity