Skip to content

OGL: do not call glMemoryBarrier when ARB_shader_image_load_store is missing - #467

Merged
cscd98 merged 1 commit into
libretro:masterfrom
Andy1210:fix/bbox-memorybarrier-null
Aug 8, 2026
Merged

OGL: do not call glMemoryBarrier when ARB_shader_image_load_store is missing#467
cscd98 merged 1 commit into
libretro:masterfrom
Andy1210:fix/bbox-memorybarrier-null

Conversation

@Andy1210

@Andy1210 Andy1210 commented Aug 7, 2026

Copy link
Copy Markdown

Fixes #466.

OGLBoundingBox::Read calls glMemoryBarrier on the non-GLES path, but that
entry point comes from ARB_shader_image_load_store. On a desktop context below
GL 4.2 the pointer is null, while bSupportsBBox can still be true because it
is set from bSupportsFragmentStoresAndAtomics. Saving a state reads the
bounding box and calls the null pointer.

This adds bSupportsImageLoadStore to the condition, the same check
UsePersistentStagingBuffers() in OGLTexture.cpp already uses for that
function. Drivers without it fall to the glMapBufferRange path below.

Tested on Mesa v3d (Raspberry Pi 5, GL 3.1), where saving a state segfaulted
every time and now saves and loads a 55 MB state repeatedly. I have no other
GL 3.1 hardware to check it against.

…missing

OGLBoundingBox::Read calls glMemoryBarrier on the non-GLES path, but that entry
point comes from ARB_shader_image_load_store. On a desktop context below GL 4.2
the pointer is null, while bSupportsBBox can still be true because it is set
from bSupportsFragmentStoresAndAtomics. Saving a state reads the bounding box
and calls the null pointer.

Add bSupportsImageLoadStore to the condition, the same check
UsePersistentStagingBuffers() in OGLTexture.cpp already uses for that function.
Drivers without it fall to the glMapBufferRange path below.
@cscd98

cscd98 commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Please make this PR to dolphin-emu as its a core bug if it is one as well.

@Andy1210

Andy1210 commented Aug 7, 2026

Copy link
Copy Markdown
Author

Yes, submitted there too: dolphin-emu#14803

@cscd98
cscd98 merged commit b4c88b4 into libretro:master Aug 8, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Save state crashes with a null glMemoryBarrier on a GL 3.1 context

2 participants