fixed some osx metal compability with Distant horizon 1.7.10 backport (#2261)

This commit is contained in:
HariboApfel authored and GitHub committed 2026-10-15 09:59:28 -07:00
1 parent 49db8e111d
commit f81ee4b03a
3 files changed
+26

No files matched your search

@@ -369,6 +369,7 @@ public class SDLGPURenderBackend extends RenderBackend {
LOG.info("Splash offscreen target {}x{} (window {}x{}, max desktop {}x{})", splashTexW, splashTexH, splashW, splashH, maxDesktop[0], maxDesktop[1]);
}
Lwjgl3GLCapabilitiesShim.installFunctionProvider();
Lwjgl3GLCapabilitiesShim.installOnCurrentThread(advertisedCapabilities());
LOG.info("SDLGPURenderBackend initialized: renderer={}, version={}", cachedRenderer, cachedVersion);
@@ -31,6 +31,16 @@ public final class Lwjgl3GLCapabilitiesShim {
LOG.info("Cleared fabricated LWJGL3 GLCapabilities on {}", Thread.currentThread().getName());
}
/**
* Aware mods probe extension entry points through {@code GL.getFunctionProvider()}, which is null with no GL context.
* Every name resolves to 0 so those probes see the extension as absent and use the core path, which GLSM routes.
*/
public static void installFunctionProvider() {
if (GL.getFunctionProvider() != null) return;
GL.create(name -> 0L);
LOG.info("Installed null-address LWJGL3 GL function provider");
}
public static GLCapabilities create(Set<String> advertised) {
final FunctionProvider provider = name -> SENTINEL_ADDRESS;
final IntFunction<PointerBuffer> bufferFactory = BufferUtils::createPointerBuffer;
@@ -87,6 +87,21 @@ class Lwjgl3GLCapabilitiesShimTest {
assertThrows(IllegalStateException.class, GL::getCapabilities, "clearing on release must stop the thread answering yes to runningOnRenderThread()");
}
@Test
void functionProviderResolvesEveryNameToAbsent() {
final boolean preinstalled = GL.getFunctionProvider() != null;
Lwjgl3GLCapabilitiesShim.installFunctionProvider();
try {
assertNotNull(GL.getFunctionProvider());
if (!preinstalled) {
assertEquals(0L, GL.getFunctionProvider().getFunctionAddress("glBindVertexArrayAPPLE"));
}
Lwjgl3GLCapabilitiesShim.installFunctionProvider();
} finally {
if (!preinstalled) GL.destroy();
}
}
@Test
void advertisedSetHasNoDuplicatesOrBlanks() {
final Set<String> advertised = SDLGPURenderBackend.advertisedCapabilities();