Skip to content

fix(gl-dp): load this module's GLAD table before any GL call#26

Merged
dfattal merged 1 commit into
mainfrom
fix/gl-dp-glad-load
Jun 1, 2026
Merged

fix(gl-dp): load this module's GLAD table before any GL call#26
dfattal merged 1 commit into
mainfrom
fix/gl-dp-glad-load

Conversation

@dfattal
Copy link
Copy Markdown
Contributor

@dfattal dfattal commented Jun 1, 2026

Summary

The GL display processor crashed on the first frame (access violation — call through a null function pointer) for any standalone GL app (cube_handle_gl). D3D11/D3D12/VK were unaffected.

Root cause

aux_ogl is a static lib, so DisplayXR-LeiaSR.dll links its own copy of the glad_gl* function-pointer table. The runtime (comp_gl_compositor) loads its own copy at compositor-create, but that does not populate the plug-in's table. The first GL call in process_atlasglViewport(0, 0, target_w, target_h) — therefore dereferenced a null glad_glViewport and faulted.

Diagnosed via procdump + cdb: rip=0, faulting frame inside DisplayXR-LeiaSR.dll calling [DisplayXR-LeiaSR+0x277f0], with the whole surrounding pointer region all-zero (an unloaded dispatch table). Reproduced identically against a stock runtime baseline, confirming a plug-in bug (not the runtime).

Fix

Load this module's GLAD table once in leia_dp_factory_gl, mirroring the runtime's loader (gladLoadGLUserPtr with wglGetProcAddress + an opengl32.dll fallback). The compositor has made the GL context current before invoking the factory, so the load succeeds there.

Verification

Built the plug-in, deployed to C:\Program Files\DisplayXR\Plugins\LeiaSR\, ran cube_handle_gl on the Leia panel: now renders sustained frames (previously crashed after frame 1). Visually confirmed correct on the live display.

🤖 Generated with Claude Code

The GL display processor crashed on the first frame (access violation,
call through a null function pointer) for any standalone GL app
(cube_handle_gl). Root cause: aux_ogl is a static lib, so DisplayXR-LeiaSR.dll
links its OWN copy of the glad_gl* function-pointer table. The runtime
(comp_gl_compositor) loads its own copy, but that does not populate the
plug-in's — so the plug-in's glad_glViewport (the first GL call in
process_atlas) was null and dereferencing it faulted.

Fix: load the plug-in module's GLAD table once in leia_dp_factory_gl,
mirroring the runtime's loader (wglGetProcAddress with an opengl32.dll
fallback). The compositor has made the GL context current before invoking
the factory, so the load succeeds there. D3D11/D3D12/VK DPs were unaffected
(no GLAD dependency).

Diagnosed via procdump + cdb: rip=0, faulting frame in DisplayXR-LeiaSR.dll
calling [DisplayXR-LeiaSR+0x277f0], with the whole surrounding pointer
region all-zero (an unloaded dispatch table); reproduced identically on a
runtime baseline, confirming it is a plug-in bug.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dfattal dfattal merged commit 13c8011 into main Jun 1, 2026
3 checks passed
@dfattal dfattal deleted the fix/gl-dp-glad-load branch June 1, 2026 23:31
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.

1 participant