1717public class LwjglRedirections {
1818 public static final int GL_TEXTURE_WIDTH = 4096 ;
1919 public static final int GL_TEXTURE_INTERNAL_FORMAT_CONST = 4099 ;
20+ public static final int GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT = 0x8A34 ;
21+
2022 public static final int GL_TEXTURE_INTERNAL_FORMAT = Integer .parseInt (
2123 System .getProperty (LwjglProperties .GL_TEXTURE_INTERNAL_FORMAT , "32856" )); //RGBA8
2224 public static final int TEXTURE_SIZE = Integer .parseInt (
@@ -33,6 +35,8 @@ public class LwjglRedirections {
3335 System .getProperty (LwjglProperties .BITS_PER_PIXEL , "32" ));
3436 public static final int JNI_VERSION = Integer .parseInt (
3537 System .getProperty (LwjglProperties .JNI_VERSION , "24" ));
38+ public static final int UNIFORM_OFFSET_ALIGNMENT = Integer .parseInt (
39+ System .getProperty (LwjglProperties .UNIFORM_OFFSET_ALIGNMENT , "1" ));
3640 private static final ThreadLocal <Long > CURRENT_BUFFER_SIZE =
3741 ThreadLocal .withInitial (() -> 0L );
3842 private static final long START = System .nanoTime ();
@@ -315,6 +319,19 @@ public static void register(RedirectionManager manager) {
315319 //j net.caffeinemc.mods.sodium.api.memory.MemoryIntrinsics.copyMemory(JJI)V+8
316320 //j net.minecraft.class_287.push(Lorg/lwjgl/system/MemoryStack;JILnet/caffeinemc/mods/sodium/api/vertex/format/VertexFormatDescription;)V+47
317321 //j me.jellysquid.mods.sodium.client.render.vertex.buffer.SodiumBufferBuilder.push(Lorg/lwjgl/system/MemoryStack;JILnet/caffeinemc/mods/sodium/api/vertex/format
322+
323+ // 1.21.6 onwards
324+ // DynamicUniformStorage.<init>
325+ // GlDevice this.uniformOffsetAlignment = GL11.glGetInteger(35380);
326+ // division by zero, because the integer returned is 0
327+ manager .redirect ("Lorg/lwjgl/opengl/GL11;glGetInteger(I)I" ,
328+ (obj , desc , type , args ) -> {
329+ if ((int ) args [0 ] == GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT ) {
330+ return UNIFORM_OFFSET_ALIGNMENT ;
331+ }
332+
333+ return 0 ;
334+ });
318335 }
319336
320337}
0 commit comments