Coder Social home page Coder Social logo

optifine-lwjgl-amd-fix's Introduction

Important

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.

LWJGL OpenGL AMD Optifine crash fix

It prevents your game to crash while enabling shaders like SEUS, Chocapic13, etc.

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.

Steps to reprodice

  • Install Optifine on a system with an AMD graphics card using the latest drivers.
  • Install a shaderpack and try to enable it.

Installation and fix

MultiMC is required!

  • Follow the BalintCsal PDF guide
  • Copy the MultiMC LWJGL json file from here

2021-07-10_12 28 52


How does it work

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);
}

How to patch the LWJGL-OpenGL jar file

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.

Disclaimer

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.

optifine-lwjgl-amd-fix's People

Contributors

gamerover98 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.