From bc62eafd2e29c013122e918d695fe4df2c38b842 Mon Sep 17 00:00:00 2001 From: whitebelyash Date: Wed, 1 Jul 2026 22:19:47 +0400 Subject: [PATCH] Feat[main]: add a workaround to ignore program link errors Minecraft 26.3-s2 has new shaders around block transparency, however, these shaders aren't handled well by most GLES drivers. Allow an optional workaround to force successful program link status to make the game not blow up. From my testing on ANGLE (one of the problematic drivers) the only thing breaking is transparent blocks - it's quite hard to call them broken though, just a bit weird. The error itself is seemingly unrelated to our shader transpiler and can be reproduced on other GLES wrappers. --- ltw/src/main/tinywrapper/es3_overrides.h | 3 ++- ltw/src/main/tinywrapper/main.c | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ltw/src/main/tinywrapper/es3_overrides.h b/ltw/src/main/tinywrapper/es3_overrides.h index 600ee85..8234bfc 100644 --- a/ltw/src/main/tinywrapper/es3_overrides.h +++ b/ltw/src/main/tinywrapper/es3_overrides.h @@ -134,4 +134,5 @@ GLESOVERRIDE(glGetError) GLESOVERRIDE(glTexBuffer) GLESOVERRIDE(glTexBufferRange) GLESOVERRIDE(glMapBufferRange) -GLESOVERRIDE(glFlushMappedBufferRange) \ No newline at end of file +GLESOVERRIDE(glFlushMappedBufferRange) +GLESOVERRIDE(glGetProgramiv) \ No newline at end of file diff --git a/ltw/src/main/tinywrapper/main.c b/ltw/src/main/tinywrapper/main.c index 3d1cdd6..a4e0ee1 100644 --- a/ltw/src/main/tinywrapper/main.c +++ b/ltw/src/main/tinywrapper/main.c @@ -263,6 +263,7 @@ void glRenderbufferStorage( GLenum target, static bool never_flush_buffers; static bool coherent_dynamic_storage; +static bool ignore_linking_errors; void glBufferStorage(GLenum target, GLsizeiptr size, @@ -447,6 +448,16 @@ void glGetIntegerv(GLenum pname, GLint* data) { } } +void glGetProgramiv(GLuint program, GLenum pname, GLint *params){ + if(!current_context) return; + es3_functions.glGetProgramiv(program, pname, params); + // HACK: Some drivers fail linking programs due to fragment shader build failures. Let's ignore this so the game at least boots + if(ignore_linking_errors && pname == GL_LINK_STATUS && *params == GL_FALSE){ + printf("LTW: Invalid program %u, will pass anyway\n", program); + *params = GL_TRUE; + } +} + void glDepthRange(GLdouble nearVal, GLdouble farVal) { if(!current_context) return; @@ -499,10 +510,12 @@ __attribute((constructor)) void init_noerror() { debug = env_istrue("LTW_DEBUG"); never_flush_buffers = env_istrue_d("LTW_NEVER_FLUSH_BUFFERS", true); coherent_dynamic_storage = env_istrue_d("LTW_COHERENT_DYNAMIC_STORAGE", true); + ignore_linking_errors = env_istrue_d("LTW_IGNORE_LINK_ERRORS", false); if(!noerror) printf("LTW will NOT ignore GL errors. This may break mods, consider yourself warned.\n"); if(coherent_dynamic_storage) printf("LTW will force dynamic storage buffers to be coherent.\n"); if(debug) printf("LTW will allow GL_DEBUG_OUTPUT to be enabled. Expect massive logs.\n"); if(never_flush_buffers) printf("LTW will prevent all explicit buffer flushes.\n"); + if(ignore_linking_errors) printf("LTW will ignore program linking errors. This may cause graphical artifacts\n"); } GLenum glGetError() {