render3d: the lists sized at start-up carry @max at their room

The retire, free-range and spare-id lists (4096), the per-buffer flags and the prime handles (16384),
the stage and the actor spares (2048), the per-program uniform offsets (4096) and a draw's set key
(130) are each @max'd at the room gvk_startup_state / actor_init made, so outgrowing one ends a dev
run with its name instead of quietly copying. Compiled (steady).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-28 16:47:20 +03:00
parent 46000362ba
commit c6bea826f6

View file

@ -11,9 +11,9 @@ export state Render3dState {
ac_sh_cut: AcProg = null
ac_out: AcProg = null
ac_out_cut: AcProg = null
ac_actors: []Actor = null
@max(2048) ac_actors: []Actor = null
ac_next_id: int = 0
ac_spare: []Actor = null # released actors, taken again by actor_new (actor_release)
@max(2048) ac_spare: []Actor = null # released actors, taken again by actor_new (actor_release)
ac_frame: int = 0
ac_oq: []OutlineReq = null
ac_oq_n: int = 0 # live entries; the array is kept and reused
@ -181,15 +181,15 @@ export state Render3dState {
gvk_blk_kind: []int = null # memory type * 2, + 1 for images
gvk_blk_size: []int = null
gvk_blk_map: []pointer = null
gvk_fr_blk: []int = null # free ranges: block, offset, length (0 = an unused slot)
gvk_fr_off: []int = null
gvk_fr_len: []int = null
@max(4096) gvk_fr_blk: []int = null # free ranges: block, offset, length (0 = an unused slot)
@max(4096) gvk_fr_off: []int = null
@max(4096) gvk_fr_len: []int = null
gvk_al_blk: []int = null # per allocation id: its block, or -1 for its own memory
gvk_al_mem: []long = null # its own memory when it has one
gvk_al_off: []int = null
gvk_al_len: []int = null
gvk_al_map: []pointer = null
gvk_al_spare: []int = null # ids to reuse
@max(4096) gvk_al_spare: []int = null # ids to reuse
gvk_pool: long = 0
gvk_fence: bytes = null
gvk_frame_fence: bytes = null # the presented frame still on the GPU (one frame in flight)
@ -201,7 +201,7 @@ export state Render3dState {
gvk_frame_pending_no: int = -1 # which frame it is (gvk_frame_no when it was submitted)
gvk_dpools: []long = null # a descriptor pool per frame slot (frame_no & 1)
gvk_ring_end: int = 0 # the end of this frame's half of the ring
gvk_retired_frame: []int = null # the last frame that read each retired buffer
@max(4096) gvk_retired_frame: []int = null # the last frame that read each retired buffer
gvk_labels: bool = false # R3D_VK_LABELS: each profiled pass is a debug label (Metal System Trace)
gvk_inflight: int = -1
gvk_nopool: bool = false
@ -212,8 +212,8 @@ export state Render3dState {
gvk_lay_flat: []int = null # every layout known, end to end; gvk_lay_off / _len find each
gvk_lay_off: []int = null
gvk_lay_len: []int = null
gvk_tex_spare: []int = null # ids of freed textures, handed out again by gvk_tex_new
gvk_buf_spare: []int = null # the same for buffers (gvk_buf_delete)
@max(4096) gvk_tex_spare: []int = null # ids of freed textures, handed out again by gvk_tex_new
@max(4096) gvk_buf_spare: []int = null # the same for buffers (gvk_buf_delete)
gvk_has_bc: bool = false # textureCompressionBC: .dds textures are uploaded compressed
# R3D_VK_PROF: Vulkan objects made and destroyed, reported every 120 frames
gvk_mk_img: int = 0
@ -271,12 +271,12 @@ export state Render3dState {
gvk_sc_next: []int = null # the program's next cached set, -1 at the end
gvk_sc_keys: []long = null # per texture of a key: handle * 65536 + generation, sampler
gvk_sc_head: words = null # per program (< 4096): its most recently made set, -1 if none
gvk_sc_tmp: []long = null # this draw's key while it is looked up
@max(130) gvk_sc_tmp: []long = null # this draw's key while it is looked up
gvk_set_offs: bytes = null # this draw's dynamic offsets, in binding order
gvk_set_ndyn: int = 0
gvk_ub_frame: []int = null # per program: the frame its blocks were last copied into the ring
gvk_ub_offv: []int = null
gvk_ub_offf: []int = null
@max(4096) gvk_ub_frame: []int = null # per program: the frame its blocks were last copied into the ring
@max(4096) gvk_ub_offv: []int = null
@max(4096) gvk_ub_offf: []int = null
gvk_sc_made: int = 0 # sets made since start (R3D_VK_PROF)
gvk_default_smp: long = 0 # linear, clamped: for a texture slot nothing was bound to
gvk_cb: pointer = null
@ -376,9 +376,9 @@ export state Render3dState {
gvk_buf_map: []pointer = null # host-visible buffers stay mapped for their whole life
gvk_buf_used: []int = null # the frame (gvk_frame_no) a draw last bound the buffer in
gvk_frame_no: int = 1
gvk_retired_buf: []long = null
gvk_retired_mem: []long = null
gvk_buf_gpu: []int = null
@max(4096) gvk_retired_buf: []long = null
@max(4096) gvk_retired_mem: []long = null
@max(16384) gvk_buf_gpu: []int = null
grass_prog: int = 0
grass_mesh: Mesh = null
grass_on: bool = true
@ -696,7 +696,7 @@ export state Render3dState {
ov_nine_buf: floats = floats(16) # ov_nine's corners and uvs
gvk_ac: pointer = null # the VkAllocationCallbacks every create and destroy is given (R3D_ALLOC_VK=1)
gvk_prime_b: words = null # buffers made since the frame began, read once so MoltenVK makes their
gvk_prime_h: []long = null # Metal buffers now (gvk_prime), and their handles
@max(16384) gvk_prime_h: []long = null # Metal buffers now (gvk_prime), and their handles
gvk_prime_n: int = 0
gvk_prime_dst: long = 0 # the 64 bytes those reads land in
gvk_prime_mem: long = 0