render3d: debug prints in the shadow and scatter passes moved into declared helpers

shadow_pass's fbo status and probe block, shadow_bind's two location prints, layer_partition_lods'
LOD line and layer_update's dump are each a function of their own under @alloc_ok (debug switches
only), so the passes themselves hold no allocation site. Compiled (steady).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-28 16:23:06 +03:00
parent 9f233104a3
commit b41f18692b
2 changed files with 66 additions and 33 deletions

View file

@ -831,7 +831,7 @@ function layer_partition_lods(render3d_st: mut Render3dState, l: Layer, src: flo
}
l.n_near = counts[0]
l.n_far = counts[n]
if render3d_st.sc_dbg_lod and total > 1000 { print(`lod partition: total {total} dropped {counts[n + 1]} far {counts[n]} l0 {counts[0]} l1 {counts[1]} l2 {counts[2]} l3 {counts[3]} dist0 {fixed(l.lod_dist[0])} dist3 {fixed(l.lod_dist[n - 1])} cull {fixed(l.cull)} cam {fixed(render3d_st.cam_pos[0])} {fixed(render3d_st.cam_pos[2])} first {fixed(src[0])} {fixed(src[2])}`) }
if render3d_st.sc_dbg_lod and total > 1000 { sc_debug_lods(render3d_st, l, counts, n, total, src) }
if l.n_far > 0 {
gpu_buffer_upload(render3d_st, l.imp_buf, l.n_far * INST_FLOATS * 4, mem_off(tmp, start[n] * INST_FLOATS * 4), GPU_DYNAMIC)
}
@ -894,11 +894,7 @@ function layer_update(render3d_st: mut Render3dState, l: Layer) -> void {
}
l.n_near = nn
l.n_far = nf
if l.imp != null and nn > 0 and render3d_st.sc_debug_dump { print(`near full-mesh instances: {nn} (first at {fixed(tmp[0])} {fixed(tmp[1])} {fixed(tmp[2])})`) }
if render3d_st.sc_debug_dump and l.imp != null {
print(`layer: near {nn} far {nf}`)
for k in 0 .. nn { let q = k * INST_FLOATS; print(` near {fixed(tmp[q])} {fixed(tmp[q + 1])} {fixed(tmp[q + 2])} s {fixed(tmp[q + 3])}`) }
}
if render3d_st.sc_debug_dump { sc_debug_layer(l, tmp, nn, nf) }
# Every instance, unculled and unsplit, for the shadow pass. What the camera draws is
# allowed to change with distance; what casts must not, or shadows blink in and out as
# you walk. This is the whole set, drawn one way, into every cascade.
@ -1354,3 +1350,20 @@ function scatter_clear_all(render3d_st: mut Render3dState) -> void {
render3d_st.sc_layers = new []Layer
render3d_st.sc_view_gen += 1
}
# R3D_DUMP_ATLAS / the LOD debug switch: what a layer holds, printed (text made only then)
@alloc_ok("debug output, only under R3D_DUMP_ATLAS and the LOD debug switch")
function sc_debug_lods(render3d_st: Render3dState, l: Layer, counts: words, n: int, total: int, src: floats) -> void {
print(`lod partition: total {total} dropped {counts[n + 1]} far {counts[n]} l0 {counts[0]} l1 {counts[1]} l2 {counts[2]} l3 {counts[3]} dist0 {fixed(l.lod_dist[0])} dist3 {fixed(l.lod_dist[n - 1])} cull {fixed(l.cull)} cam {fixed(render3d_st.cam_pos[0])} {fixed(render3d_st.cam_pos[2])} first {fixed(src[0])} {fixed(src[2])}`)
}
@alloc_ok("debug output, only under R3D_DUMP_ATLAS and the LOD debug switch")
function sc_debug_layer(l: Layer, tmp: floats, nn: int, nf: int) -> void {
if l.imp != null and nn > 0 { print(`near full-mesh instances: {nn} (first at {fixed(tmp[0])} {fixed(tmp[1])} {fixed(tmp[2])})`) }
if l.imp != null {
print(`layer: near {nn} far {nf}`)
for k in 0 .. nn {
let q = k * INST_FLOATS
print(` near {fixed(tmp[q])} {fixed(tmp[q + 1])} {fixed(tmp[q + 2])} s {fixed(tmp[q + 3])}`)
}
}
}