This issue has been fixed on 2021-08-07 with the OptiFine 1.17.1_HD_U_G9_pre33 release but, if you need this fix with old Optifine versions, follow this guide.
Optifine crash due to glShaderSourceARB() function fails on some AMD drivers while enabling shaders
The crash has been solved by BalintCsal here: AMD crash on recent drivers with provided workaround
This project provides you only with the source code of the modified LWJGL-OpenGL (3.2.2) org.lwjgl.opengl.ARBShaderObjects.java class.
- Install Optifine on a system with an AMD graphics card using the latest drivers.
- Install a shaderpack and try to enable it.
MultiMC is required!
This simple Maven project provides you a copy of the original ARBShaderObjects class from the OpenGL module of LWJGL 3.2.2 (current Minecraft LWJGL version).
The ARBShaderObjects.glShaderSourceARB(shaderObj, string) method has been replaced with the following code:
MemoryStack stack = stackGet();
int stackPointer = stack.getPointer();
try {
ByteBuffer sourceBuffer = MemoryUtil.memUTF8(string, true);
PointerBuffer pointers = stack.mallocPointer(1);
pointers.put(sourceBuffer);
long stringAddress = org.lwjgl.system.APIUtil.apiArrayi(stack, MemoryUtil::memUTF8, string);
nglShaderSourceARB(shaderObj, 1, pointers.address0(), 0);
org.lwjgl.system.APIUtil.apiArrayFree(stringAddress, 1);
} finally {
stack.setPointer(stackPointer);
}
Apache Maven software is required to compile this project
- Download this repository as zip or clone it
- Type:
mvn clean compile
- After compiling, you'll find the compiled ARBShaderObjects class at target\classes\org\lwjgl\opengl
- Download LWJGL OpenGL 3.2.2 Jar from the maven repo
- Open the jar file with 7Zip, WinRar or similar
- Replace the org\lwjgl\opengl\ARBShaderObjects.class file with your.
I'm not the author of this fix. Waiting for an official Optifine update, I provide you with an easy way to use shaders with your AMD GPU.