refactor(render3d): programs, GPU timers and the context behind gpu.ludic
The last of milestone 1: no OpenGL call is left in render3d outside gpu.ludic but the clock and the CPU-side buffer helpers. - gpu_program builds a program and remembers the variant it came from (vertex, fragment and defines as one line - the SPIR-V manifest's key), so a backend that cannot compile at run time finds the pipeline for the same handle. gpu_use_program and gpu_program_free replace 32 uses and 2 frees; the overlay's program is recorded under overlay.vert|overlay.frag. - gpu_query_new / _begin / _end / _result carry R3D_PROF's timers. - gpu_open, gpu_vsync, gpu_renderer_name and gpu_resize_check carry the context. - r3d_program_tess is gone: nothing called it and no tessellation shader exists. - R3D_GLCHECK also checks after framebuffer and renderbuffer changes, viewport, draw buffers, program use, texture parameters, the resize check and between frames. OpenGL frames are byte-identical at the five viewpoints; 59 self-tests pass with and without R3D_GLCHECK, with no GL error; ludic-dev test 140 passed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
447acc11bd
commit
ce3986bb02
12 changed files with 109 additions and 59 deletions
|
|
@ -53,7 +53,7 @@ var ov_clip_h: int = 0
|
|||
|
||||
function overlay_init(font_dir: string) -> bool {
|
||||
r3d_program_log("overlay.vert", "overlay.frag", "")
|
||||
ov_prog = gl_program("#version 410 core\n" + r3d_shader_file("overlay.vert"), "#version 410 core\n" + r3d_shader_file("overlay.frag"))
|
||||
ov_prog = gpu_program("#version 410 core\n" + r3d_shader_file("overlay.vert"), "#version 410 core\n" + r3d_shader_file("overlay.frag"), "overlay.vert", "overlay.frag", "")
|
||||
if ov_prog == 0 { print("overlay: program failed"); return false }
|
||||
ov_mesh = gpu_mesh_new()
|
||||
ov_vbo = gpu_mesh_vertices(ov_mesh, null, gl_bytes_of(OV_MAX_QUADS * 6 * OV_FLOATS), GPU_DYNAMIC)
|
||||
|
|
@ -161,7 +161,7 @@ function ov_begin() -> void {
|
|||
gpu_cull(false)
|
||||
gpu_blend(true)
|
||||
gpu_blend_func(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
|
||||
gl_use_program(ov_prog)
|
||||
gpu_use_program(ov_prog)
|
||||
u_f2(gpu_uniform(ov_prog, "u_screen"), fi(gl_w), fi(gl_h))
|
||||
ov_n = 0; ov_nr = 0; ov_range_start = 0
|
||||
ov_tex = ov_white
|
||||
|
|
@ -195,7 +195,7 @@ function ov_flush() -> void {
|
|||
# framebuffer operation. Saying the target at each flush is what a render pass says anyway.
|
||||
gpu_fb_bind(gpu_screen_fb())
|
||||
gpu_viewport(0, 0, gl_w, gl_h)
|
||||
gl_use_program(ov_prog)
|
||||
gpu_use_program(ov_prog)
|
||||
gpu_mesh_bind(ov_mesh)
|
||||
gpu_buffer_upload(ov_vbo, gl_bytes_of(ov_n * 6 * OV_FLOATS), ov_buf, GPU_STREAM)
|
||||
var last = -1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue