Repository navigation
Fix NVIDIA crash (GL_MAX_IMAGE_UNITS=8) and FMOD audio init failure on Linux - #133
brainAThome wants to merge 2 commits into
Conversation
NVIDIA fix: Remap image binding >= 8 to val % 8 in GLSL shaders, but ONLY on lines declaring image uniforms (image2D, image2DArray, etc.). Also remap glBindImageTexture unit parameter correspondingly. Add glCompileShader/glLinkProgram error logging. Audio fix: Validate SDL_GetAudioDeviceFormat return value before updating defaults. Add missing AAudioStreamBuilder hooks for setSampleRate, setChannelCount, setFormat. Propagate builder-configured values to stream. Return AAUDIO_STREAM_STATE_OPEN instead of CLOSED for created-but-not-started streams. Tested on: Kubuntu 24.04, NVIDIA RTX 4080 (driver 590.48), PipeWire 1.0.5, Minecraft Bedrock 1.26.0.2.
81a8b0c to
d04cfea
Compare
d04cfea to
a4c5495
Compare
Are you saying your nvidia card has a lower maximum than intel uhd 620, this sounds strange. I need to log this opengl variable to be included in reports |
|
@ChristopherHX No, the NVIDIA card does not have a lower maximum — they both report the same value. Here's the output from my system (RTX 4080, driver 590.48.01): For reference, the full texture/image unit picture:
The issue is that Minecraft's compute shaders use Logging this value in reports would definitely be helpful for diagnosing similar issues in the future 👍 |
I mean my intel UHD does not crash, so your response is odd. |
Summary
Two fixes that resolve:
GL_MAX_IMAGE_UNITS = 8Tested on: Kubuntu 24.04, NVIDIA RTX 4080 (driver 590.48), PipeWire 1.0.5, Minecraft Bedrock 1.26.0.2.
Fix 1: NVIDIA GL_MAX_IMAGE_UNITS crash (
fake_egl.cpp)Problem
Minecraft Bedrock uses compute shaders with
layout(binding = 9)onimage2DArrayuniforms. NVIDIA desktop GPUs reportGL_MAX_IMAGE_UNITS = 8(units 0-7), so binding index 9 causes a shader compilation failure →std::terminate()→ SIGABRT in the "Rendering Pool" thread.Solution
glShaderSourceto remapbinding = N(where N >= 8) toN % 8, but only on lines containingimageuniforms (image2D, image2DArray, etc.). Sampler and UBO bindings are not affected (they have much higher limits).glBindImageTextureto remapunit >= 8tounit % 8correspondingly.glCompileShaderandglLinkProgramerror logging hooks for easier debugging.Why image-only?
GL_MAX_IMAGE_UNITS(typically 8 on NVIDIA) only applies toimage*type uniforms. Sampler bindings (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, typically 32+) and UBO bindings (GL_MAX_UNIFORM_BUFFER_BINDINGS, typically 84+) must NOT be remapped — doing so causes wrong textures to be sampled, resulting in incorrect colors.Fix 2: FMOD/AAudio audio initialization failure (
fake_audio.cpp,fake_audio.h)Problem
When using the SDL3 audio backend (no host libfmod), FMOD fails to initialize with error code 28 (
FMOD_ERR_OUTPUT_INIT). Root causes:updateDefaults()uses unvalidated return fromSDL_GetAudioDeviceFormat(): When this call fails (common with PipeWire), theSDL_AudioSpecstruct contains garbage values, overwriting the sensible defaults (48000 Hz, 2 channels, 512 buffer) with invalid values likefreq=0,channels=11.Missing AAudio builder hooks: FMOD calls
AAudioStreamBuilder_setSampleRate,AAudioStreamBuilder_setChannelCount, andAAudioStreamBuilder_setFormatto configure the stream, but these were not hooked — the values were silently discarded.Incorrect stream state:
AAudioStream_getStatereturnedAAUDIO_STREAM_STATE_CLOSEDfor streams that were created but not yet started (stream->s == NULL). FMOD interprets this as a dead stream and aborts initialization. The correct state isAAUDIO_STREAM_STATE_OPEN.Solution
SDL_GetAudioDeviceFormatreturn value and sanitizespecfields before updating defaultsAAudioStreamBuilder_setSampleRate,setChannelCount,setFormat→ store on builder structsampleRate,channelCount,formatfields toFakeAudioStreamBuilderand propagate them to the stream inopenStreamAAUDIO_STREAM_STATE_OPENinstead ofCLOSEDwhen stream is created but not startedFiles Changed
src/fake_egl.cpp#include <regex>, NVIDIA image binding remap hooks, shader/program error loggingsrc/fake_audio.cppsrc/fake_audio.hsampleRate,channelCount,formatfields toFakeAudioStreamBuilderTesting