gpu: Gles3Gpu — GLES3 implementation of the GPU protocol
Mirror of metal.sx, talks to GLES3 via opengl.sx's runtime-loaded fn-pointer variables. EGL bootstrap is owned by AndroidPlatform; this module just calls `load_gl(@eglGetProcAddress)` once during `init` to populate the pointers, then drives raw draw/state from there. The renderer's vertex layout (12 floats: pos2/uv2/color4/params4 = 48 bytes, attribute locations 0-3) is hardcoded in a single shared VAO the Gles3Gpu owns — `set_vertex_buffer` rebinds the active VBO against it. `set_vertex_constants(slot=1, data, 64)` is treated as the 4x4 projection matrix; `set_texture(slot=0, ...)` binds texture unit 0 and sets `uniform sampler2D uTex` — both match renderer.sx's shader contract. A subtle gotcha caught + recorded in the file header: declaring the same GL name as a `#foreign` function while opengl.sx also declares it as an fn-pointer global silently lets the global win, and calling through the uninitialized variable jumps to PC=0. Solution: don't re-declare; use opengl.sx's pointers and `load_gl` them. renderer.sx: the GPU-protocol shader-source branch now passes (UI_VERT_SRC_ES, UI_FRAG_SRC_ES) on Android (separate vert+frag) vs. the combined MSL library on iOS. Both gated with `inline if OS == X`.
This commit is contained in:
@@ -62,7 +62,15 @@ UIRenderer :: struct {
|
||||
// draw reads from its own slice and can outlive earlier in-
|
||||
// flight draws without corruption.
|
||||
metal_buf_size := buf_size * 4;
|
||||
self.mtl_shader = self.gpu.create_shader(UI_MSL_SRC, "");
|
||||
// Backend-specific shader sources: Metal takes a combined MSL
|
||||
// library with `vmain` + `fmain` entry points; GLES3 takes a
|
||||
// separate vertex / fragment pair. Caller selects via OS gate.
|
||||
inline if OS == .android {
|
||||
self.mtl_shader = self.gpu.create_shader(UI_VERT_SRC_ES, UI_FRAG_SRC_ES);
|
||||
}
|
||||
inline if OS == .ios {
|
||||
self.mtl_shader = self.gpu.create_shader(UI_MSL_SRC, "");
|
||||
}
|
||||
self.mtl_vbuf = self.gpu.create_buffer(metal_buf_size);
|
||||
self.mtl_buf_capacity = metal_buf_size;
|
||||
white_px : [4]u8 = .[255, 255, 255, 255];
|
||||
|
||||
Reference in New Issue
Block a user