mirror of
https://github.com/seedds/nxnative.git
synced 2026-11-25 06:20:08 -10:00
The OpenGL layer keeps GL's error flag: glGetError returned 0 always, so a game's misuse (a shader attached twice, a deleted name used) went unreported. Now the shader and program calls (glShaderSource, glCompileShader, glGetShaderiv, glDeleteShader, glAttachShader, glDetachShader, glLinkProgram, glBindAttribLocation, glGetProgramiv, glDeleteProgram, glUseProgram, glGetAttribLocation) record GL_INVALID_VALUE for a name with no object (and a negative count, an attribute index past 16) and GL_INVALID_OPERATION for a name of the other kind, a shader attached twice or detached when not attached; 0 stays silently ignored where GL ignores it, and a call that errs changes nothing (the current program included). glGetError returns the first error since it was last called and clears it, another not being recorded while one is pending (one flag, as GL allows). Recorded only where GL requires an error and the layer does what GL does: a call or a value it does not implement keeps its red line and records nothing, and a link the library cannot serve still reports success (GL_LINK_STATUS), so no game is told of the host's own gaps. The first 8 errors are logged with the call that recorded them (a game's misuse: not a red line). The GL reference entry says so. Also in t_gl_imports, two analyzer findings fixed in their code: the error checks compare one call with two results in two asserts (misc-redundant-expression), and 34608c72's depth-texture case compares the four floats by value instead of memcmp (bugprone-suspicious-memory-comparison), which had put lint-c above its baseline on main. Checked: make gl-imports with DM_GL_STUBS=0 and 1 (each error case, the first of two errors kept, the read clearing it, calls that succeed leaving it clear, the link case's deliberate second attach now recording GL_INVALID_OPERATION), lint_c.py tidy on the changed files (at the baseline), test_docs; Balatro (LÖVE, GL) with this host from a fresh save through the note's taps into the tutorial's blind selection, headless, 75 s to frame 4,200: no GL error recorded, so its glGetError answered 0 as on main, no red line, the screen right. Not run: Digimon and Well Dweller (no game files here), the iPhone
This commit is contained in:
1 parent
637f3fa76c
commit
8a5c5e7e1e
3 files changed
+72
-19
No files matched your search
+47
-15
@@ -65,6 +65,7 @@ typedef void *EGLDisplay, *EGLConfig, *EGLContext, *EGLSurface; typedef int32_t
|
||||
|
||||
// ---------- GL enums ----------
|
||||
enum {
|
||||
GL_NO_ERROR = 0, GL_INVALID_ENUM = 0x500, GL_INVALID_VALUE, GL_INVALID_OPERATION,
|
||||
GL_POINTS = 0, GL_LINES, GL_LINE_LOOP, GL_LINE_STRIP, GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_QUADS,
|
||||
GL_NEVER = 0x200, GL_SRC_COLOR = 0x300, GL_ONE_MINUS_SRC_COLOR, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA, GL_DST_COLOR,
|
||||
GL_ONE_MINUS_DST_COLOR, GL_SRC_ALPHA_SATURATE,
|
||||
@@ -339,6 +340,23 @@ typedef struct { int is_prog; union { shader_t s; prog_t p; }; } sp_t;
|
||||
NAMES(sp_t, g_sps, g_nsps, g_capsps)
|
||||
static shader_t *shader_of(GLuint n) { return n && n < g_nsps && g_sps[n] && !g_sps[n]->is_prog ? &g_sps[n]->s : NULL; }
|
||||
static prog_t *prog_of(GLuint n) { return n && n < g_nsps && g_sps[n] && g_sps[n]->is_prog ? &g_sps[n]->p : NULL; }
|
||||
// GL's error flag: the first error since the last glGetError, which returns it and clears it; another error is not recorded while one is (GL lets an implementation keep
|
||||
// one flag). Recorded only where GL requires an error and the host does what GL does: a call or a value the host does not implement says so in a red line instead and
|
||||
// records nothing, so a game is never told of the host's own gaps. A link the library cannot serve still reports success (GL_LINK_STATUS), its draws skipped and reported
|
||||
// The first 8 errors are logged with the call that recorded them (a game's misuse, not a host fault: no red line)
|
||||
static GLenum g_gl_error;
|
||||
static void gl_error_at(GLenum e, const char *fn) {
|
||||
if (!g_gl_error) g_gl_error = e;
|
||||
static int n; if (n < 8) { n++; GLOG("GL error %#x recorded by %s (glGetError returns it once)%s", e, fn, n == 8 ? "; no more of these lines" : ""); }
|
||||
}
|
||||
#define gl_error(e) gl_error_at(e, __func__)
|
||||
// A shader or program name, as a call that takes one checks it: 1 for an object of that kind; else GL_INVALID_VALUE (no such object) or GL_INVALID_OPERATION (the other kind)
|
||||
static int sp_check(GLuint n, int prog, const char *fn) {
|
||||
if (!n || n >= g_nsps || !g_sps[n]) { gl_error_at(GL_INVALID_VALUE, fn); return 0; }
|
||||
if (!g_sps[n]->is_prog != !prog) { gl_error_at(GL_INVALID_OPERATION, fn); return 0; }
|
||||
return 1;
|
||||
}
|
||||
#define SP_CHECK(n, prog) sp_check(n, prog, __func__)
|
||||
|
||||
// ---------- Context state ----------
|
||||
// units: as many as GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS says (LÖVE binds a texture of each type to every one at start); fb / read_fb: the draw and read framebuffers;
|
||||
@@ -1201,7 +1219,7 @@ GL(glColorTable, void, GLenum target, GLenum ifmt, GLsizei w, GLenum format, GLe
|
||||
RED1("paletted texture (glColorTable, %d entries): palette lookup at upload, the index shift is %d", w, S.index_shift);
|
||||
}
|
||||
GL(glTexEnvi, void, GLenum t, GLenum p, GLint v) { (void)t; (void)p; (void)v; }
|
||||
GL(glGetError, GLenum, void) { return 0; }
|
||||
GL(glGetError, GLenum, void) { GLenum e = g_gl_error; g_gl_error = GL_NO_ERROR; return e; } // the flag above, read and cleared
|
||||
// Everything recorded so far runs to its end (LÖVE when the window changes)
|
||||
// glFlush: hand the commands encoded so far to the GPU without waiting. The layer commits at the frame's end, so a game that flushes in the middle of a frame
|
||||
// (GameMaker's runner does, before a menu or a surface read) would otherwise see nothing but the pointer: eglGetProcAddress returned null for a name it only
|
||||
@@ -1696,7 +1714,9 @@ GL(glCreateProgram, GLuint, void) {
|
||||
GLuint n = name_new((void ***)&g_sps, &g_nsps, &g_capsps, sizeof(sp_t)); g_sps[n]->is_prog = 1; return n;
|
||||
}
|
||||
GL(glShaderSource, void, GLuint sh, GLsizei count, const GLchar *const *str, const GLint *len) {
|
||||
shader_t *s = shader_of(sh); if (!s) return;
|
||||
if (!SP_CHECK(sh, 0)) return;
|
||||
if (count < 0) { gl_error(GL_INVALID_VALUE); return; }
|
||||
shader_t *s = shader_of(sh);
|
||||
size_t n = 0;
|
||||
for (GLsizei i = 0; i < count; i++) n += len && len[i] >= 0 ? (size_t)len[i] : strlen(str[i]);
|
||||
free(s->src); s->src = zalloc(n + 1); s->len = 0;
|
||||
@@ -1705,7 +1725,8 @@ GL(glShaderSource, void, GLuint sh, GLsizei count, const GLchar *const *str, con
|
||||
s->compiled = 0;
|
||||
}
|
||||
GLB(glCompileShader, void, GLuint sh) {
|
||||
shader_t *s = shader_of(sh); if (!s || !s->src) return;
|
||||
if (!SP_CHECK(sh, 0)) return;
|
||||
shader_t *s = shader_of(sh); if (!s->src) return;
|
||||
uint8_t h[CC_SHA256_DIGEST_LENGTH]; CC_SHA256(s->src, (CC_LONG)s->len, h);
|
||||
for (int i = 0; i < 8; i++) snprintf(s->key + 2 * i, 3, "%02x", h[i]);
|
||||
sh_capture(s);
|
||||
@@ -1716,7 +1737,8 @@ GLB(glCompileShader, void, GLuint sh) {
|
||||
else OLOG("CompileShader %s", s->key);
|
||||
}
|
||||
GL(glGetShaderiv, void, GLuint sh, GLenum p, GLint *v) {
|
||||
shader_t *s = shader_of(sh); if (!s) { *v = 0; return; }
|
||||
if (!SP_CHECK(sh, 0)) { *v = 0; return; }
|
||||
shader_t *s = shader_of(sh);
|
||||
switch (p) {
|
||||
case GL_COMPILE_STATUS: *v = 1; return; // a shader the library lacks still compiles: its program's draws are skipped (and reported)
|
||||
case GL_INFO_LOG_LENGTH: *v = 0; return;
|
||||
@@ -1733,23 +1755,26 @@ static void shader_release(GLuint *slot) { // a program lets go of the shader
|
||||
if (s && --s->refs <= 0 && s->deleted) shader_free(sh);
|
||||
}
|
||||
GL(glDeleteShader, void, GLuint sh) {
|
||||
shader_t *s = shader_of(sh); if (!s) return;
|
||||
if (!sh || !SP_CHECK(sh, 0)) return; // 0 is silently ignored
|
||||
shader_t *s = shader_of(sh);
|
||||
OLOG("DeleteShader %u%s", sh, s->refs ? " (attached: flagged)" : "");
|
||||
if (s->refs) s->deleted = 1; else shader_free(sh);
|
||||
}
|
||||
// One shader per stage: attaching another replaces it (GLES refuses a second one; the shader tables have one stage each), said once: desktop GL would link both. The same
|
||||
// shader again is GL_INVALID_OPERATION, which this host does not record (glGetError is 0): nothing changes, its count included
|
||||
// shader again is GL_INVALID_OPERATION, and nothing changes, its count included
|
||||
GL(glAttachShader, void, GLuint pr, GLuint sh) {
|
||||
prog_t *p = prog_of(pr); shader_t *s = shader_of(sh); if (!p || !s) return;
|
||||
if (!SP_CHECK(pr, 1) || !SP_CHECK(sh, 0)) return;
|
||||
prog_t *p = prog_of(pr); shader_t *s = shader_of(sh);
|
||||
GLuint *slot = s->type == GL_VERTEX_SHADER ? &p->vs : &p->fs;
|
||||
if (*slot == sh) return;
|
||||
if (*slot == sh) { gl_error(GL_INVALID_OPERATION); return; }
|
||||
if (*slot) RED1("program %u: a second %s shader (%u) replaces the first (%u): desktop GL links both, the shader tables have one per stage", pr, s->type == GL_VERTEX_SHADER ? "vertex" : "fragment", sh, *slot);
|
||||
shader_release(slot); *slot = sh; s->refs++;
|
||||
}
|
||||
GL(glDetachShader, void, GLuint pr, GLuint sh) {
|
||||
prog_t *p = prog_of(pr); if (!p || !sh) return;
|
||||
if (!SP_CHECK(pr, 1) || !SP_CHECK(sh, 0)) return;
|
||||
prog_t *p = prog_of(pr);
|
||||
OLOG("DetachShader %u from %u", sh, pr);
|
||||
if (p->vs == sh) shader_release(&p->vs); else if (p->fs == sh) shader_release(&p->fs);
|
||||
if (p->vs == sh) shader_release(&p->vs); else if (p->fs == sh) shader_release(&p->fs); else gl_error(GL_INVALID_OPERATION); // not attached to it
|
||||
}
|
||||
static void prog_clear(prog_t *p) {
|
||||
for (int i = 0; i < p->npc; i++) if (p->pc[i].pso) CFRelease(p->pc[i].pso);
|
||||
@@ -1759,7 +1784,8 @@ static void prog_clear(prog_t *p) {
|
||||
// Uniforms are merged by name over both stages, as GL links them; a location is uniform index × 4096 + array element
|
||||
GLB(glLinkProgram, void, GLuint pr) {
|
||||
static uint32_t serials;
|
||||
prog_t *p = prog_of(pr); if (!p) return;
|
||||
if (!SP_CHECK(pr, 1)) return;
|
||||
prog_t *p = prog_of(pr);
|
||||
prog_clear(p);
|
||||
shader_t *vs = shader_of(p->vs), *fs = shader_of(p->fs);
|
||||
if (!vs || !fs || !vs->fn || !fs->fn) { RED1("program %u: a shader is missing from the library, its draws are skipped", pr); return; }
|
||||
@@ -1792,14 +1818,17 @@ GLB(glLinkProgram, void, GLuint pr) {
|
||||
OLOG("LinkProgram %u: vs %s fs %s, %d uniforms", pr, vs->key, fs->key, p->nu);
|
||||
}
|
||||
GL(glBindAttribLocation, void, GLuint pr, GLuint index, const GLchar *name) { // takes effect at the next link
|
||||
prog_t *p = prog_of(pr); if (!p || index >= 16 || !name) return;
|
||||
if (!SP_CHECK(pr, 1)) return;
|
||||
if (index >= 16) { gl_error(GL_INVALID_VALUE); return; } // GL_MAX_VERTEX_ATTRIBS
|
||||
prog_t *p = prog_of(pr); if (!name) return;
|
||||
int j = 0; while (j < p->nbind && strcmp(p->bind[j].name, name)) j++;
|
||||
if (j == 16) { RED1("more than 16 attribute bindings in a program"); return; }
|
||||
if (j == p->nbind) { strlcpy(p->bind[j].name, name, sizeof p->bind[j].name); p->nbind++; }
|
||||
p->bind[j].index = (int)index;
|
||||
}
|
||||
GL(glGetProgramiv, void, GLuint pr, GLenum p, GLint *v) {
|
||||
prog_t *x = prog_of(pr); if (!x) { *v = 0; return; }
|
||||
if (!SP_CHECK(pr, 1)) { *v = 0; return; }
|
||||
prog_t *x = prog_of(pr);
|
||||
switch (p) {
|
||||
case GL_LINK_STATUS: case GL_VALIDATE_STATUS: *v = 1; return; // as glGetShaderiv's compile status
|
||||
case GL_INFO_LOG_LENGTH: *v = 0; return;
|
||||
@@ -1816,16 +1845,19 @@ static void prog_free(GLuint pr) { // the program goes, and its attachments wi
|
||||
}
|
||||
// As in GL, the current program deleted stays in use, its draws going on, until another is made current
|
||||
GL(glDeleteProgram, void, GLuint pr) {
|
||||
prog_t *p = prog_of(pr); if (!p) return;
|
||||
if (!pr || !SP_CHECK(pr, 1)) return; // 0 is silently ignored
|
||||
prog_t *p = prog_of(pr);
|
||||
OLOG("DeleteProgram %u%s", pr, S.prog == pr ? " (current: flagged)" : "");
|
||||
if (S.prog == pr) p->deleted = 1; else prog_free(pr);
|
||||
}
|
||||
GL(glUseProgram, void, GLuint pr) {
|
||||
if (pr && !SP_CHECK(pr, 1)) return; // an error leaves the current program as it is
|
||||
GLuint old = S.prog; S.prog = pr;
|
||||
prog_t *o = prog_of(old); if (old != pr && o && o->deleted) prog_free(old);
|
||||
}
|
||||
GL(glGetAttribLocation, GLint, GLuint pr, const GLchar *name) {
|
||||
prog_t *p = prog_of(pr); if (!p || !p->linked) return -1;
|
||||
if (!SP_CHECK(pr, 1)) return -1;
|
||||
prog_t *p = prog_of(pr); if (!p->linked) return -1;
|
||||
for (int i = 0; i < p->si[0]->na; i++) if (!strcmp(p->si[0]->a[i].name, name)) return p->amap[p->si[0]->a[i].slot];
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ int main(int argc, char **argv) {
|
||||
id<MTLCommandBuffer> rcb = [g_q commandBuffer]; id<MTLBlitCommandEncoder> rbe = [rcb blitCommandEncoder]; // after the upload: one queue runs its command buffers in commit order
|
||||
[rbe copyFromTexture:dtex->tex sourceSlice:0 sourceLevel:0 sourceOrigin:MTLOriginMake(0, 0, 0) sourceSize:MTLSizeMake(4, 4, 1) toBuffer:rb destinationOffset:0 destinationBytesPerRow:16 destinationBytesPerImage:64];
|
||||
[rbe endEncoding]; [rcb commit]; [rcb waitUntilCompleted];
|
||||
assert(!memcmp(rb.contents, depth, sizeof depth));
|
||||
for (int i = 0; i < 16; i++) assert(((const float *)rb.contents)[i] == depth[i]); // the values as given, each exactly
|
||||
// A real link: the linked program keeps the stages' code (si, fn) whatever its attachments do afterwards; a relink without a stage fails. The same shader attached twice
|
||||
// changes nothing (its count included)
|
||||
void (*link)(GLuint) = import("glLinkProgram");
|
||||
@@ -104,7 +104,7 @@ int main(int argc, char **argv) {
|
||||
id vfn = [NSObject new], ffn = [NSObject new];
|
||||
GLuint pr3 = createprog(), vs3 = create(GL_VERTEX_SHADER), fs3 = create(GL_FRAGMENT_SHADER);
|
||||
shader_of(vs3)->si = &none; shader_of(vs3)->fn = vfn; shader_of(fs3)->si = &none; shader_of(fs3)->fn = ffn;
|
||||
attach(pr3, vs3); attach(pr3, fs3); attach(pr3, fs3); assert(shader_of(fs3)->refs == 1);
|
||||
attach(pr3, vs3); attach(pr3, fs3); attach(pr3, fs3); assert(shader_of(fs3)->refs == 1 && h_glGetError() == GL_INVALID_OPERATION);
|
||||
link(pr3); assert(prog_of(pr3)->linked && prog_of(pr3)->fn[0] == vfn && prog_of(pr3)->fn[1] == ffn);
|
||||
detach(pr3, vs3); delete(vs3); assert(!shader_of(vs3) && !prog_of(pr3)->vs);
|
||||
assert(prog_of(pr3)->linked && prog_of(pr3)->fn[0] == vfn && prog_of(pr3)->si[0] == &none); // detached and deleted: the linked executable stays
|
||||
@@ -112,6 +112,27 @@ int main(int argc, char **argv) {
|
||||
link(pr3); assert(!prog_of(pr3)->linked); // relinked without a vertex shader: the link fails
|
||||
delprog(pr3); assert(!prog_of(pr3) && !shader_of(fs3));
|
||||
|
||||
// GL's error flag: the first error since the last glGetError, which reads and clears it; a second error while one is pending is not recorded
|
||||
GLenum (*geterr)(void) = import("glGetError");
|
||||
assert(geterr() == GL_NO_ERROR);
|
||||
GLuint pr4 = createprog(), vs4 = create(GL_VERTEX_SHADER);
|
||||
attach(pr4, vs4); assert(geterr() == GL_NO_ERROR);
|
||||
attach(pr4, vs4); assert(geterr() == GL_INVALID_OPERATION); assert(geterr() == GL_NO_ERROR); // the same shader again; the read cleared it
|
||||
attach(pr4, 9999); assert(geterr() == GL_INVALID_VALUE); // no such object
|
||||
attach(vs4, vs4); assert(geterr() == GL_INVALID_OPERATION); // a shader where a program goes
|
||||
GLuint fs4 = create(GL_FRAGMENT_SHADER);
|
||||
detach(pr4, fs4); assert(geterr() == GL_INVALID_OPERATION); // not attached to it
|
||||
use(9999); assert(geterr() == GL_INVALID_VALUE);
|
||||
use(pr4); use(vs4); GLint cur4 = 0; h_glGetIntegerv(GL_CURRENT_PROGRAM, &cur4); assert(geterr() == GL_INVALID_OPERATION && cur4 == (GLint)pr4); // the error leaves the current program
|
||||
use(0); delete(0); delprog(0); assert(geterr() == GL_NO_ERROR); // 0 is silently ignored
|
||||
delete(9999); delprog(vs4); assert(geterr() == GL_INVALID_VALUE); assert(geterr() == GL_NO_ERROR); // the first of two errors is kept, the second not recorded
|
||||
getiv(pr4, GL_SHADER_TYPE, &value); assert(geterr() == GL_INVALID_OPERATION && value == 0);
|
||||
progiv(vs4, GL_ATTACHED_SHADERS, &value); assert(geterr() == GL_INVALID_OPERATION);
|
||||
void (*bindattr)(GLuint, GLuint, const GLchar *) = import("glBindAttribLocation");
|
||||
bindattr(pr4, 16, "a"); assert(geterr() == GL_INVALID_VALUE);
|
||||
getiv(vs4, GL_SHADER_TYPE, &value); progiv(pr4, GL_ATTACHED_SHADERS, &value); assert(geterr() == GL_NO_ERROR); // calls that succeed leave the flag clear
|
||||
delprog(pr4); delete(vs4); delete(fs4); assert(geterr() == GL_NO_ERROR);
|
||||
|
||||
unsigned long sz;
|
||||
const hle_ent *sec = (const hle_ent *)getsectiondata(&_mh_execute_header, "__DATA", "swhle", &sz);
|
||||
unsigned count = 0;
|
||||
@@ -129,6 +150,6 @@ int main(int argc, char **argv) {
|
||||
assert((h_eglGetProcAddress(missing) != NULL) == stubs);
|
||||
assert(resolve_import(NULL, missing) == (uint64_t)&unimpl_stubs[0]);
|
||||
assert(!strcmp(wrap_kind, "STUB"));
|
||||
printf("GL imports: %u shared entries, shader handle/source, shader and program lifetimes, a depth texture's data, wrappers and missing names (DM_GL_STUBS=%d): OK\n", count, stubs);
|
||||
printf("GL imports: %u shared entries, shader handle/source, shader and program lifetimes, the error flag, a depth texture's data, wrappers and missing names (DM_GL_STUBS=%d): OK\n", count, stubs);
|
||||
return 0;
|
||||
}
|
||||
@@ -1759,7 +1759,7 @@ Digimon Story Cyber Sleuth: Complete Edition (Media.Vision's MVGL engine, SDK 6.
|
||||
- **Cause:** `glDeleteShader` freed the shader at once and its name went to the next `glCreateShader`, while a program keeps its shaders by name: a link then found no shader, or another one (a fragment shader as the vertex stage). In GL a shader deleted while attached is only flagged (`GL_DELETE_STATUS` 1), keeps its name, and goes when its last program detaches it or is deleted. Likewise `glDeleteProgram` freed the current program and made none current, where GL keeps it in use until another `glUseProgram`. `glDetachShader` was not implemented.
|
||||
- **Fix:** `dm/gfx/gl/hle_gl.m` counts each shader's attachments (`shader_t.refs`; one shader per stage, a new one replaces and releases the old); `glDeleteShader` of an attached shader sets `deleted`, and `shader_release` frees it with its last attachment (`glDetachShader`, a replacing attach, the program's own end). `glDeleteProgram` of the current program sets `prog_t.deleted` and `glUseProgram` of another frees it (`prog_free`, which releases its shaders); any other program goes at once. Both `GL_DELETE_STATUS` queries report the flag. A linked program already held what its link took (functions, shader tables, uniforms), so later attach, detach and delete calls leave it drawing as linked. `make -C dm/gfx/tests GAME=<id> gl-imports` checks the lifetimes through the real entry points.
|
||||
- **Found on:** no game: the report reproduced it in `t_gl_imports.m` (an attached vertex shader deleted, then a new fragment shader took its name and the program's vertex stage resolved to it). [Balatro](../../dm/games/0100CD801CE5E000/README.md) takes the path without the symptom: when LÖVE makes its window again it deletes its first three default programs' shaders while they are attached, then the programs (`DM_GL_LOG=1`: `DeleteShader 1 (attached: flagged)` … `DeleteProgram 7`), so each shader now goes with its program; it never links after deleting a shader, and the title and the tutorial draw the same as before.
|
||||
- **Check:** `t_gl_imports` also links for real (shaders with their table entries): the linked program keeps both stages' code after its vertex shader is detached and deleted, a relink without that stage fails, and the same shader attached twice is counted once. A second shader of a stage replaces the first and says so once in a red line (desktop GL would link both; the shader tables have one per stage).
|
||||
- **Check:** `t_gl_imports` also links for real (shaders with their table entries): the linked program keeps both stages' code after its vertex shader is detached and deleted, a relink without that stage fails, and the same shader attached twice is counted once. A second shader of a stage replaces the first and says so once in a red line (desktop GL would link both; the shader tables have one per stage). Since then the layer keeps GL's error flag (`glGetError` returned 0 always): the shader and program calls record `GL_INVALID_VALUE` for a name with no object, `GL_INVALID_OPERATION` for one of the other kind, a shader attached twice or detached when not attached, and `glGetError` reads and clears the first error since it was last called (one flag, as GL allows). A call or a value the layer does not implement records nothing and keeps its red line, and a link the library cannot serve still reports success (`GL_LINK_STATUS`), so no game is told of the host's own gaps; the first 8 errors are logged with the call. `t_gl_imports` checks each case, the first of two errors kept, the flag cleared by the read and left clear by calls that succeed. Balatro from a fresh save into its tutorial (75 s, frame 4,200) recorded none, so its `glGetError` answered 0 as before. The other calls record nothing on purpose: `glBindTexture` makes a texture for a name `glGenTextures` never gave (as compatibility GL does), which a core context would refuse, and an enum the layer does not take cannot be told from one it does not implement; a game found to read errors there would take the same `gl_error` / name check.
|
||||
|
||||
### GL textures, swizzles and uploads
|
||||
|
||||
|
||||
Reference in new issue
Block a user