render3d: a renderer that cannot draw says so and stops - LUDIC_HOME's leading ~ expanded (an unexpanded one left a run without shaders, logging 27 missing variants and drawing on), the SPIR-V manifest ends with E <count> and a cut or miscounted one is refused, and every such failure is a fault: r3d_open / r3d_load_step fail on it, r3d_fault() / r3d_fault_exit(code) for the game; tests/manifest_test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-29 22:12:39 +03:00
parent aac58ec6fa
commit c3fc896dea
13 changed files with 227 additions and 54 deletions

View file

@ -0,0 +1,33 @@
# r3d_root.ludic - where the renderer's own files are: the package checked out beside the project,
# else the copy in the toolchain ($LUDIC_HOME, else ~/.ludic). Not finding them is a fault
# (gpu_fault.ludic), never a quiet start on nothing.
# The install root, as the compiler computes it: $LUDIC_HOME, else ~/.ludic. A leading "~" is
# the home directory: `env LUDIC_HOME=~/x` hands one over unexpanded, and nothing was found there.
@alloc_ok("once a run: the install root, asked only when the shaders are not beside the program")
function r3d_home() -> string {
let env = Os.env("LUDIC_HOME")
if env != null and env != "" { return r3d_tilde(env, Os.env("HOME")) }
return `{Os.env("HOME")}/.ludic`
}
# a path with a leading "~" or "~/" put under `home`; any other path as it is
@alloc_ok("once a run: the install root, asked only when the shaders are not beside the program")
function r3d_tilde(path: string, home: string) -> string {
if home == null or len(path) == 0 or path[0] != '~' { return path }
if len(path) == 1 { return home }
if path[1] != '/' { return path } # ~user is another user's, not ours to guess
return home + path[1 .. len(path)]
}
# Settle r3d_root on first use: the package as checked out beside the project, else the
# copy that ships with the toolchain.
@alloc_ok("start-up: the device, its tables, the programs, the passes and the world's first textures are made once, before play")
function r3d_find_root(render3d_st: mut Render3dState) -> void {
if render3d_st.r3d_root_found { return }
render3d_st.r3d_root_found = true
if Fs.exists(`{render3d_st.r3d_root}/shaders/lighting.glsl`) { return }
let home = r3d_home()
let alt = `{home}/packages/ludic.render3d`
if Fs.exists(`{alt}/shaders/lighting.glsl`) { render3d_st.r3d_root = alt; return }
gpu_fault_set(render3d_st, `cannot find the renderer's shaders (looked in {render3d_st.r3d_root}/shaders and {alt}/shaders)`)
}