3D map: short vertex program for the material table's shadows #531

Manually merged
github merged 7 commits from github-bot/gh-531 into gh-pr/531/base 2026-11-28 04:51:53 +00:00 AGit
Owner

@⁠holdmysocks on GitHub · 2026-11-28 04:19 UTC · original
holdmysocks:six-map3d-tableshadow → master · +71 −18 · 3 files · 7 commits · merged 2026-11-28 04:48 UTC

3D map: a short vertex program for the material table's shadow casters.

With the material table on, the shadow cascades cost 0.14–0.21 ms more GPU time than with it off. That cost is now gone.

What changes

  • Short shadow vertex program. The table's shadow pipelines use vs_shadow_t: the instance matrix times the vertex, plus the base UV and the material index for the cut-out test. Table models have no joints and no strands, so the rest of the mesh vertex program did nothing for them.
  • Lighter material loads. The table's main vertex program loads only the strand width factor instead of the material's whole row. The shadow cut-out pixel program loads only its alpha inputs and base texture.
  • Shadow triangle count. The shot line now ends with the model shadow casters' triangles times instances, for both the table and the old path.
  • A/B switches in SIXNG_MAP_GPU_TABLE:
    • shadowfull: the full mesh vertex program for shadows.
    • shadowold: the table's models cast shadows the old way.
    • vsfull: whole-row material loads.

How the cause was found (second PC, RTX 3090, Vulkan)

Round Switch Shadow time vs table on
40 shadowold Back to table-off level. The cost is in the table's own shadow draws.
40 vsfull Unchanged. The material loads are not the cost.
41 one indirect call per sub-draw Unchanged
41 sub-draws in model order (about five times the calls) Unchanged
41 cut-outs without the alpha test Unchanged
42 short shadow vertex program Back to table-off level

The table submits the same number of shadow triangles as the old path, or up to 10 % fewer, so the cost was not extra geometry.

Results (round 42)

Shadows, ms:

View Table off Table on, before Table on, now
s3 1.80 2.01 1.80
dtst 1.61 1.74 1.55
rs 1.45 1.66 1.39
wide 1.67 1.81 1.66
  • Main pass: 0.07–1.12 ms below table off.
  • CPU (pass + finish + submit): 3.5–7.4 ms with the table on, against 5.7–9.1 ms off.
  • Images against table off, pixels differing by more than 16: s3 0, dtst 0, rs 47, wide 12. Against the previous program: 0–12 px.
  • No pipeline, validation or watchdog lines in 24 runs.
**@⁠holdmysocks** on GitHub · 2026-11-28 04:19 UTC · [original](https://github.com/holdmysocks/SixNG/pull/531) `holdmysocks:six-map3d-tableshadow` → `master` · +71 −18 · 3 files · 7 commits · merged 2026-11-28 04:48 UTC 3D map: a short vertex program for the material table's shadow casters. With the material table on, the shadow cascades cost 0.14–0.21 ms more GPU time than with it off. That cost is now gone. ## What changes - **Short shadow vertex program.** The table's shadow pipelines use `vs_shadow_t`: the instance matrix times the vertex, plus the base UV and the material index for the cut-out test. Table models have no joints and no strands, so the rest of the mesh vertex program did nothing for them. - **Lighter material loads.** The table's main vertex program loads only the strand width factor instead of the material's whole row. The shadow cut-out pixel program loads only its alpha inputs and base texture. - **Shadow triangle count.** The shot line now ends with the model shadow casters' triangles times instances, for both the table and the old path. - **A/B switches** in `SIXNG_MAP_GPU_TABLE`: - `shadowfull`: the full mesh vertex program for shadows. - `shadowold`: the table's models cast shadows the old way. - `vsfull`: whole-row material loads. ## How the cause was found (second PC, RTX 3090, Vulkan) | Round | Switch | Shadow time vs table on | |---|---|---| | 40 | `shadowold` | Back to table-off level. The cost is in the table's own shadow draws. | | 40 | `vsfull` | Unchanged. The material loads are not the cost. | | 41 | one indirect call per sub-draw | Unchanged | | 41 | sub-draws in model order (about five times the calls) | Unchanged | | 41 | cut-outs without the alpha test | Unchanged | | 42 | short shadow vertex program | Back to table-off level | The table submits the same number of shadow triangles as the old path, or up to 10 % fewer, so the cost was not extra geometry. ## Results (round 42) Shadows, ms: | View | Table off | Table on, before | Table on, now | |---|---|---|---| | s3 | 1.80 | 2.01 | 1.80 | | dtst | 1.61 | 1.74 | 1.55 | | rs | 1.45 | 1.66 | 1.39 | | wide | 1.67 | 1.81 | 1.66 | - Main pass: 0.07–1.12 ms below table off. - CPU (pass + finish + submit): 3.5–7.4 ms with the table on, against 5.7–9.1 ms off. - Images against table off, pixels differing by more than 16: s3 0, dtst 0, rs 47, wide 12. Against the previous program: 0–12 px. - No pipeline, validation or watchdog lines in 24 runs.
The vertex program loads only the strand width factor instead of the whole 176-byte row, and a shadow cut-out only its alpha inputs and base texture. SIXNG_MAP_GPU_TABLE gains vsfull (the earlier whole-row loads) and shadowold (the table's models cast shadows the old way).
# Conflicts:
#	crates/sixng-gui/src/gpu_draw.rs
shadownocut draws cut-out casters without their alpha test; shadowmodel keeps the shadow sub-draws in model order instead of grouping them by chunk.
Table models have no joints or strands, so their shadow casters need only the instance matrix times the vertex. The shot line now gives the model shadow casters' triangles times instances. shadowfull keeps the mesh vertex program for A/B runs.
shadownocut and shadowmodel answered their question (neither was the cost) and only change the picture.
# Conflicts:
#	crates/sixng-gui/src/gpu_draw.rs
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 04:19:53 +00:00
github-bot changed target branch from master to gh-pr/531/base 2026-11-28 04:51:51 +00:00
github manually merged commit 6b6df81abe into gh-pr/531/base 2026-11-28 04:51:53 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.