render3d: the uniform ring is 16 MB a half and grows when a frame outgrows it; streamed layers are sized for the fog's reach

The ring held 2 x 64 MB of host memory for a frame that uses 3 MB at most (2761 draws at the
overlook, 1.7 MB in town): it starts at 16 MB a half, and a frame that ever runs out grows it for the
frames after (gvk_ring_grow, making the kept sets again; R3D_RING_KB=<n> starts small to watch it).
-95 MB at every fog level, off included.

A streamed layer's arrays and its stream's arena are made for the reach a fog wall leaves (twice its
area's share, at least 4096 instances) and emptied to refill within the frame budget
(fog_streams.ludic). The near streams' reach is already inside most walls, so it is -9 MB at 30 m.

R3D_VKMEM adds the ring's high-water mark, the largest buffers and the streamed layers' share.
Footprint at the overlook: 2008 MB off (2108 before this phase), 1748 MB at 175 m, 1682 MB at 30 m.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-29 16:22:45 +03:00
parent 4d485a1778
commit f8c81e4066
7 changed files with 136 additions and 4 deletions

View file

@ -39,7 +39,8 @@ property Stream {
htab: words, # open-addressed key -> chunk index + 1 (0 = empty)
arena: words, # every kept chunk's instances, in the order of `chunks`
top: int = 0, # words of the arena in use
spare: []Chunk # records not in use: all of them are made with the stream
spare: []Chunk, # records not in use: all of them are made with the stream
cap0: int = 0 # the layer's capacity for the whole reach (fog_streams.ludic)
}
# microseconds spent per frame, split so the hitch can be attributed (R3D_PROF=1)
@ -82,6 +83,8 @@ function stream_new__t(render3d_st: mut Render3dState, layer: Layer, size: float
for i in 0 .. STREAM_HASH { s.htab[i] = 0 }
if render3d_st.stream_all == null { render3d_st.stream_all = new []Stream }
push(render3d_st.stream_all, s)
s.cap0 = layer.cap
fog_stream(render3d_st, s)
return s
}