3D map: the material-table shader without the sticker part #520

Manually merged
github merged 1 commit from github-bot/gh-520 into gh-pr/520/base 2026-11-28 01:56:47 +00:00 AGit
Owner

@⁠holdmysocks on GitHub · 2026-11-28 01:45 UTC · original
holdmysocks:claude/livery-flat-cost → master · +6 −1 · 1 files · 1 commits · merged 2026-11-28 01:56 UTC

What

The 3D map's main pass took about 0.5 ms a frame longer since PR 509 (stickers laid on flat). This takes most of it back.

The map's material-table shader is made from the shared mesh shader by text replacements. One more replacement leaves the sticker part of the pixel program out there (st_n becomes the constant 0). The map has no stickers, so nothing drawn changes. The shared shader itself is unchanged, so the vehicle viewer draws stickers as before.

Where the time goes was measured before choosing this (same view, RTX 4080, 2560x1440, GPU time of the main pass from the map's own tick lines, each figure steady to about 0.05 ms over two or more runs):

build main pass
before PR 509 (master with the flat part and its two outputs taken out) 4.39 to 4.46 ms
master 4.90 to 5.04 ms
the position in spare numbers of existing outputs, written but not read 4.41 to 4.44 ms
the same, read, with the face normal from derivatives 4.75 ms
the same with the derivatives behind a "a flat sticker exists" switch 4.71 to 4.74 ms
master without derivatives of the stored position 4.86 to 4.95 ms
the position in the third and fourth UV sets (no new output read) 4.72 to 4.77 ms
this change 4.53 to 4.63 ms

So what the vertex program writes costs nothing by itself. The cost comes with the extra code in the sticker part of the pixel program, in every form tried, although the sticker list is empty on the map and that part never runs there. Gating it does not help; leaving it out of the program does.

Checked

  • The figures above. With this change the material-table path still comes up ("GPU-driven draws: on") and draws the same number of draw calls (1775 to 1778 in all builds).
  • cargo test -p sixng-gui: 66 pass, 2 ignored.

Not decoded / not done

  • About 0.1 ms of the 0.5 ms is left. The meshes the map still draws with the shared shader (not through the material table) keep the sticker part.
  • With the material table off (SIXNG_MAP_GPU_DRAWS=0, or where it is not available) nothing changes: 5.39 ms on master against 4.69 to 4.84 ms before PR 509 on that path. Taking it back there needs a second set of mesh pipelines without stickers, or with them only for models that have some.
  • Why code that never runs costs this much was not found (the compiled programs were not looked at).
  • The sticker part as it was before PR 509 was not measured on its own; on the material-table path it is gone with this change as well.
  • Measured on one view of the map and one GPU.
**@⁠holdmysocks** on GitHub · 2026-11-28 01:45 UTC · [original](https://github.com/holdmysocks/SixNG/pull/520) `holdmysocks:claude/livery-flat-cost` → `master` · +6 −1 · 1 files · 1 commits · merged 2026-11-28 01:56 UTC ## What The 3D map's main pass took about 0.5 ms a frame longer since PR 509 (stickers laid on flat). This takes most of it back. The map's material-table shader is made from the shared mesh shader by text replacements. One more replacement leaves the sticker part of the pixel program out there (`st_n` becomes the constant 0). The map has no stickers, so nothing drawn changes. The shared shader itself is unchanged, so the vehicle viewer draws stickers as before. Where the time goes was measured before choosing this (same view, RTX 4080, 2560x1440, GPU time of the main pass from the map's own tick lines, each figure steady to about 0.05 ms over two or more runs): | build | main pass | |---|---| | before PR 509 (master with the flat part and its two outputs taken out) | 4.39 to 4.46 ms | | master | 4.90 to 5.04 ms | | the position in spare numbers of existing outputs, written but not read | 4.41 to 4.44 ms | | the same, read, with the face normal from derivatives | 4.75 ms | | the same with the derivatives behind a "a flat sticker exists" switch | 4.71 to 4.74 ms | | master without derivatives of the stored position | 4.86 to 4.95 ms | | the position in the third and fourth UV sets (no new output read) | 4.72 to 4.77 ms | | **this change** | 4.53 to 4.63 ms | So what the vertex program writes costs nothing by itself. The cost comes with the extra code in the sticker part of the pixel program, in every form tried, although the sticker list is empty on the map and that part never runs there. Gating it does not help; leaving it out of the program does. ## Checked - The figures above. With this change the material-table path still comes up ("GPU-driven draws: on") and draws the same number of draw calls (1775 to 1778 in all builds). - `cargo test -p sixng-gui`: 66 pass, 2 ignored. ## Not decoded / not done - About 0.1 ms of the 0.5 ms is left. The meshes the map still draws with the shared shader (not through the material table) keep the sticker part. - With the material table off (`SIXNG_MAP_GPU_DRAWS=0`, or where it is not available) nothing changes: 5.39 ms on master against 4.69 to 4.84 ms before PR 509 on that path. Taking it back there needs a second set of mesh pipelines without stickers, or with them only for models that have some. - Why code that never runs costs this much was not found (the compiled programs were not looked at). - The sticker part as it was before PR 509 was not measured on its own; on the material-table path it is gone with this change as well. - Measured on one view of the map and one GPU.
The map's main pass took about 0.5 ms a frame longer since stickers laid on flat (PR 509), although the sticker list is empty on the map. Leaving the sticker part out of the map's own shader takes about 0.4 ms of it back.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 01:50:57 +00:00
github-bot changed target branch from master to gh-pr/520/base 2026-11-28 01:56:45 +00:00
github manually merged commit 3d626ce0b1 into gh-pr/520/base 2026-11-28 01:56:46 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.