refactor(render3d): textures behind gpu.ludic, their sampler state recorded
Texture creation, 2D and array uploads, pixel packing, filters, wraps, comparison, border, anisotropy, mipmaps, texture units, read-backs and freeing now go through gpu_tex_* and gpu_bind_sampler, and no other file names them. Each call is the one GL call it replaces, in the same order, so OpenGL renders bit-identically at the fixed viewpoints and the game's self-tests report what they did before. What those calls say about a texture - size, format, layers, min and mag filter, wraps, comparison, mipmaps, anisotropy - is recorded per handle as it is set: a backend with immutable images and separate sampler objects creates both from exactly that. r3d_bind_tex takes a texture kind (GPU_TEX2D / GPU_TEX2D_ARRAY) instead of a GL target. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
43c379aa0f
commit
4d3479d431
10 changed files with 201 additions and 113 deletions
|
|
@ -87,12 +87,8 @@ function r3d_program(vs: string, fs: string, defines: string) -> int {
|
|||
}
|
||||
|
||||
# Bind a texture to a unit and point a sampler uniform at it.
|
||||
function r3d_bind_tex(prog: int, name: string, unit: int, target: int, tex: int) -> void {
|
||||
gl_active_texture(GL_TEXTURE0 + unit)
|
||||
gl_bind_texture(target, tex)
|
||||
u_i(gpu_uniform(prog, name), unit)
|
||||
}
|
||||
function r3d_bind_2d(prog: int, name: string, unit: int, tex: int) -> void { r3d_bind_tex(prog, name, unit, GL_TEXTURE_2D, tex) }
|
||||
function r3d_bind_tex(prog: int, name: string, unit: int, kind: int, tex: int) -> void { gpu_bind_sampler(prog, name, unit, kind, tex) }
|
||||
function r3d_bind_2d(prog: int, name: string, unit: int, tex: int) -> void { gpu_bind_sampler(prog, name, unit, GPU_TEX2D, tex) }
|
||||
|
||||
# A framebuffer with one colour texture (and optionally a depth texture).
|
||||
property Target {
|
||||
|
|
@ -122,8 +118,8 @@ function target_free(t: Target) -> void {
|
|||
if t == null { return }
|
||||
let ids = gl_scratch()
|
||||
ids[0] = t.fbo; gl_delete_framebuffers(1, ids)
|
||||
ids[0] = t.color; gl_delete_textures(1, ids)
|
||||
if t.depth != 0 { ids[0] = t.depth; gl_delete_textures(1, ids) }
|
||||
gpu_tex_free(t.color)
|
||||
if t.depth != 0 { gpu_tex_free(t.depth) }
|
||||
}
|
||||
function target_bind(t: Target) -> void {
|
||||
gl_bind_framebuffer(GL_FRAMEBUFFER, t.fbo)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue