3D map: material table with shared pools and texture arrays #519

Manually merged
github merged 6 commits from github-bot/gh-519 into gh-pr/519/base 2026-11-28 00:35:28 +00:00 AGit
Owner

@⁠holdmysocks on GitHub · 2026-11-28 00:02 UTC · original
holdmysocks:six-map3d-mattable → master · +1942 −188 · 4 files · 6 commits · merged 2026-11-28 00:31 UTC

3D map: draw static city models from one material table, shared geometry pools and texture arrays.

What changes

  • Material table. Every static model's materials go into one storage buffer. Each row holds the material's uniform plus its eight texture slots, and a slot names an array and a layer.
  • Texture arrays. Textures go into shared 2D arrays, one class per (format, size, mips). Arrays start at 4 layers and double, up to 256 layers or 64 MB. Each layer also gets a 2D view, so models outside the table still draw the old way.
  • One geometry pool. Vertices and indices share 128 MB chunks. Indices are relative to the model's first vertex, and each draw passes a base vertex. The instance pool is separate.
  • Compaction. Each frame moves up to 8 MB of models out of the least used chunk, so chunks that empty out after loading are freed.
  • Fewer calls. A model's solid and cut-out meshes join into one sub-draw. Each list (stencil, geometry chunk, instance chunk) is one multi_draw_indexed_indirect call. Shadows use the same lists.
  • Thread safety. Texture layer writes are queued and run by the render thread before its passes, never while it submits a frame that binds the arrays.
  • Fallback. Skinned models, strand hair and anything that doesn't fit stay on the old path.
  • Switches. SIXNG_MAP_GPU_DRAWS=0 turns the table off. SIXNG_MAP_GPU_TABLE takes a comma list of nodraw, noshadow, nomulti, noarray and nopool for bisecting.
  • Watchdog. A small thread logs where the table was if no frame arrives for 3 s.

Results (second PC, RTX 3090, round 38)

CPU sum of pass, finish and submit, last 30 s, µs:

View Off On Change
s3 7904 5510 −30 %
dtst 7111 5494 −23 %
rs 8886 7261 −18 %
wide 5594 4686 −16 %
  • Off's s3 submit was high in this run. Against the previous round's Off, s3 gains −17 %.
  • Calls: s3 49, dtst 50, rs 66, wide 26.
  • Draws Off → On: s3 2822 → 1839, dtst 2683 → 1676, rs 3834 → 2233, wide 1680 → 1120.
  • VRAM On − Off: +0.04 to +0.11 GB. Pools use 7–9 chunks after loading, 77–91 % full. While loading they peak at 22–30 chunks, then compaction shrinks them. After that it moves nothing.
  • GPU: main pass within ±0.25 ms, shadows +0.15 to +0.20 ms.
  • Images at 80 s against Off, pixels differing by more than 16: s3 0.000 %, dtst 0.000 %, rs 0.005 % (47 px), wide 0.002 %.
  • Stability: 23 runs with no watchdog line, lock wait, panic or validation error.

Round 39 (with the latest master merged in)

The table's material index now uses varying location 14. The table starts in every run, with no pipeline or validation errors across 16 runs.

View Off On Change
s3 6796 5484 −19 %
dtst 8275 5488 −34 %
rs 9403 7201 −23 %
wide 5642 3641 −35 %
  • Calls 27–67. VRAM On − Off is within run noise (−0.26 to +0.18 GB).
  • Images match Off as in round 38.
  • GPU main time rose 0.8–1.5 ms in both Off and On after the merge, so it is not from the table. On's main pass is 0.1–0.5 ms below Off.

Known issue

With nopool (a debug switch), one rs facade strip differs from Off (0.5 % of pixels). noarray and the default are clean. The patch needs both array textures and own-buffer geometry, which only that switch combines, so it is not in normal runs. Not yet explained.

**@⁠holdmysocks** on GitHub · 2026-11-28 00:02 UTC · [original](https://github.com/holdmysocks/SixNG/pull/519) `holdmysocks:six-map3d-mattable` → `master` · +1942 −188 · 4 files · 6 commits · merged 2026-11-28 00:31 UTC 3D map: draw static city models from one material table, shared geometry pools and texture arrays. ## What changes - **Material table.** Every static model's materials go into one storage buffer. Each row holds the material's uniform plus its eight texture slots, and a slot names an array and a layer. - **Texture arrays.** Textures go into shared 2D arrays, one class per (format, size, mips). Arrays start at 4 layers and double, up to 256 layers or 64 MB. Each layer also gets a 2D view, so models outside the table still draw the old way. - **One geometry pool.** Vertices and indices share 128 MB chunks. Indices are relative to the model's first vertex, and each draw passes a base vertex. The instance pool is separate. - **Compaction.** Each frame moves up to 8 MB of models out of the least used chunk, so chunks that empty out after loading are freed. - **Fewer calls.** A model's solid and cut-out meshes join into one sub-draw. Each list (stencil, geometry chunk, instance chunk) is one `multi_draw_indexed_indirect` call. Shadows use the same lists. - **Thread safety.** Texture layer writes are queued and run by the render thread before its passes, never while it submits a frame that binds the arrays. - **Fallback.** Skinned models, strand hair and anything that doesn't fit stay on the old path. - **Switches.** `SIXNG_MAP_GPU_DRAWS=0` turns the table off. `SIXNG_MAP_GPU_TABLE` takes a comma list of `nodraw`, `noshadow`, `nomulti`, `noarray` and `nopool` for bisecting. - **Watchdog.** A small thread logs where the table was if no frame arrives for 3 s. ## Results (second PC, RTX 3090, round 38) CPU sum of pass, finish and submit, last 30 s, µs: | View | Off | On | Change | |---|---|---|---| | s3 | 7904 | 5510 | −30 % | | dtst | 7111 | 5494 | −23 % | | rs | 8886 | 7261 | −18 % | | wide | 5594 | 4686 | −16 % | - Off's s3 submit was high in this run. Against the previous round's Off, s3 gains −17 %. - Calls: s3 49, dtst 50, rs 66, wide 26. - Draws Off → On: s3 2822 → 1839, dtst 2683 → 1676, rs 3834 → 2233, wide 1680 → 1120. - VRAM On − Off: +0.04 to +0.11 GB. Pools use 7–9 chunks after loading, 77–91 % full. While loading they peak at 22–30 chunks, then compaction shrinks them. After that it moves nothing. - GPU: main pass within ±0.25 ms, shadows +0.15 to +0.20 ms. - Images at 80 s against Off, pixels differing by more than 16: s3 0.000 %, dtst 0.000 %, rs 0.005 % (47 px), wide 0.002 %. - Stability: 23 runs with no watchdog line, lock wait, panic or validation error. ## Round 39 (with the latest master merged in) The table's material index now uses varying location 14. The table starts in every run, with no pipeline or validation errors across 16 runs. | View | Off | On | Change | |---|---|---|---| | s3 | 6796 | 5484 | −19 % | | dtst | 8275 | 5488 | −34 % | | rs | 9403 | 7201 | −23 % | | wide | 5642 | 3641 | −35 % | - Calls 27–67. VRAM On − Off is within run noise (−0.26 to +0.18 GB). - Images match Off as in round 38. - GPU main time rose 0.8–1.5 ms in both Off and On after the merge, so it is not from the table. On's main pass is 0.1–0.5 ms below Off. ## Known issue With `nopool` (a debug switch), one rs facade strip differs from Off (0.5 % of pixels). `noarray` and the default are clean. The patch needs both array textures and own-buffer geometry, which only that switch combines, so it is not in normal runs. Not yet explained.
Static map models keep their geometry, instances and materials in shared pools and one storage table, and their textures as layers of texture arrays grouped by format, size and mip count. The vertex carries its material within the model, so a model's solid and cut-out meshes are one sub-draw, and each pass draws a set of pool chunks with one indirect call. Decals, see-through meshes and other models draw as before. SIXNG_MAP_GPU_DRAWS=0 turns it off.
Prints where the render, loader and other threads are once frames stop for 3 s, and who waits on the table lock. SIXNG_MAP_GPU_TABLE=nodraw, noshadow or nomulti turn parts of the table path off.
Writing a layer of a texture array from the loader thread while the render thread submits a frame that binds the array hung both inside wgpu. The loader now queues the writes and the render thread runs them before the next frame's passes. Pool chunks are halved and filled fullest first, so emptier chunks drain and go back.
Vertices and indices share 128 MB chunks; indices are relative to the model's first vertex and each draw passes a base vertex. Each frame moves up to 8 MB of models out of the least used chunk so empty chunks can be freed. Adds noarray and nopool switches to SIXNG_MAP_GPU_TABLE for bisecting.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 00:07:59 +00:00
github-bot changed target branch from master to gh-pr/519/base 2026-11-28 00:35:26 +00:00
github manually merged commit 6dacefa495 into gh-pr/519/base 2026-11-28 00:35:28 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.