render3d: 671 frame-reachable allocation sites to 161 - declared, split, or made nothing
@alloc_ok with its reason on what is made once per resource and kept (textures, programs, samplers, views, layouts, memory blocks, the pipeline cache in gvk_pipe_build), on resize and swapchain remakes, on screenshots and dumps, on a world being set up (streams, layers, water, post, bakes), on loads (gltf_load, skin_load, tex_load*, png_decode, fonts) and on R3D_PROF / drawstats. gltf_cached's hit path is its own and makes nothing; the miss (gltf_cached_load) is declared. m4_look_at (now over m4_look_at_xyz) and m4_inverse work on scalars, and cam_update makes no scratch. Left: lazy first-use starts, error and debug prints, and scratch made and freed each call (churn, plan 25.3). Compiled (steady, and ludic deps over the game). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f2dd27f443
commit
5d0f83b81c
21 changed files with 118 additions and 42 deletions
|
|
@ -112,6 +112,7 @@ function png_unfilter(raw: pointer, cur: int, prev: int, stride: int, fbpp: int,
|
|||
}
|
||||
}
|
||||
|
||||
@alloc_ok("loading a model, a texture or a font: a load, not a frame (a guest loading a teammate's look is one)")
|
||||
function png_decode(render3d_st: mut Render3dState, path: pointer) -> pointer {
|
||||
let d = r3d_read_file(render3d_st, path)
|
||||
if d == null { print(`png: cannot read {path}`); return null }
|
||||
|
|
@ -260,8 +261,10 @@ function tex_upload(render3d_st: mut Render3dState, px: pointer, srgb: bool, mip
|
|||
}
|
||||
|
||||
# Load a PNG as a mipmapped, anisotropic texture (0 on failure). srgb for albedo.
|
||||
@alloc_ok("loading a model, a texture or a font: a load, not a frame (a guest loading a teammate's look is one)")
|
||||
function tex_load(render3d_st: mut Render3dState, path: pointer, srgb: bool) -> int { return tex_load_ex(render3d_st, path, srgb, 0) }
|
||||
# ... with `dilate` passes of edge padding for a cut-out atlas (0 = none)
|
||||
@alloc_ok("loading a model, a texture or a font: a load, not a frame (a guest loading a teammate's look is one)")
|
||||
function tex_load_ex(render3d_st: mut Render3dState, path: pointer, srgb: bool, dilate: int) -> int {
|
||||
# a .dds encoded beside the .png at build time goes to the GPU compressed, its mips included
|
||||
# (not for a cut-out atlas: its edge padding is made here, from the .png)
|
||||
|
|
@ -306,6 +309,7 @@ function tex_height(render3d_st: Render3dState, id: int) -> int {
|
|||
}
|
||||
|
||||
# A small solid-colour fallback texture (linear rgb 0..255), for missing maps.
|
||||
@alloc_ok("loading a model, a texture or a font: a load, not a frame (a guest loading a teammate's look is one)")
|
||||
function tex_solid(render3d_st: mut Render3dState, r: int, g: int, b: int, a: int) -> int {
|
||||
let px = bytes(16)
|
||||
for i in 0 .. 4 { px[i * 4] = r; px[i * 4 + 1] = g; px[i * 4 + 2] = b; px[i * 4 + 3] = a }
|
||||
|
|
@ -453,6 +457,7 @@ function tex_max(render3d_st: mut Render3dState, tex: int, w: int, h: int, tag:
|
|||
free(buf)
|
||||
}
|
||||
# Debug: write a 2D texture's level 0 (RGBA8, alpha dropped) as a binary PPM.
|
||||
@alloc_ok("asked for by the player or a tool, not by the frame")
|
||||
function tex_dump(render3d_st: mut Render3dState, tex: int, w: int, h: int, path: pointer) -> void {
|
||||
let f = file_open(path, "wb")
|
||||
if f == null { return }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue