Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-223021

glShaderSource fails on some AMD drivers resulting in a crash on 1.17

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 1.17 Pre-release 1
    • 21w14a
    • None
    • Plausible
    • Crash, Rendering
    • Very Important

      AMD drivers ship with a bug that causes a crash on some glShaderSource calls. This causes the game to crash randomly when loading a world and almost every time when reloading resource packs when graphics settings are set to fabulous. A crash dump is attached to this issue

      This issue isn't directly Minecraft's fault, but the bug has been present for almost a year and so a workaround would be ideal.

      This can be "fixed" by replacing the GL20.glShaderSource call in com.mojang.blaze3d.platform.GlStateManager.glShaderSource with

      final MemoryStack stack = MemoryStack.stackGet();
      final int stackPointer = stack.getPointer();
      
      try {
         StringBuilder builder = new StringBuilder();
         for (String string : strings) {
            builder.append(string);
         }
         final ByteBuffer sourceBuffer = MemoryUtil.memUTF8(builder.toString(), true);
         final PointerBuffer pointers = stack.mallocPointer(1);
         pointers.put(sourceBuffer);
         GL20C.nglShaderSource(shader, 1, pointers.address0(), 0);
         org.lwjgl.system.APIUtil.apiArrayFree(pointers.address0(), 1);
      } finally {
         stack.setPointer(stackPointer);
      }

            xilefian [Mojang] Felix Jones
            BalintCsala BalintCsala
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: