Bug 100988

Summary: glXGetCurrentDisplay() no longer works for FakeGLX contexts?
Product: Mesa Reporter: Tom Hudson <tom.hudson.phd>
Component: GLXAssignee: Brian Paul <brianp>
Status: RESOLVED FIXED QA Contact: mesa-dev
Severity: normal    
Priority: medium    
Version: 17.0   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Fix for glxGetCurrentDisplay()

Description Tom Hudson 2017-05-10 13:24:44 UTC
I'm trying to upgrade a Mesa 10 installation to Mesa 17. There have been plenty of changes, but only one breakage that's left me perplexed.

https://cgit.freedesktop.org/mesa/mesa/commit/?id=c00b250c8061d042d9905e61b9077462ee91008b

In this CL, Mesa stopped maintaining a __GLXcontext for FakeGLX; there's just an XMesaContext.

Fake_glXGetCurrentContext() casts the XMesaContext to a __GLXContext and returns it. Perhaps the reasonable assumption is that a context is an opaque object.

However, glXGetCurrentDisplay() doesn't respect that assumption; it assumes it is getting a valid __GLXContext and returns __GLXContext::currentDpy, the first pointer.

The first pointer in an XMesaContext is *not* a pointer to a Display, and so any code that relies on this code path seems doomed to disappointment.

This is hitting us in open-source projects based on Ogre, but seems like a breakage in the public API that other users would have run into in the 3 years since that commit?
Comment 1 Brian Paul 2017-05-22 17:52:50 UTC
Created attachment 131440 [details] [review]
Fix for glxGetCurrentDisplay()

Hi Tom,

Looks like this has been broken for a long time.  Can you try the attached patch?

I hacked glxgears.c to call glXGetCurrentDisplay() and it seemed to work, but it would be great if you could check too.

Thanks.  Sorry for the slow reply.  I was out for a couple weeks.
Comment 2 Tom Hudson 2017-05-31 13:19:54 UTC
Awesome, unless I'm missing something this fixes all our tests, and is a lot simpler than anything we'd tried.
Comment 3 Brian Paul 2017-06-01 19:28:47 UTC
(In reply to Tom Hudson from comment #2)
> Awesome, unless I'm missing something this fixes all our tests, and is a lot
> simpler than anything we'd tried.

Great.  I'll put Tested-by: Tom Hudson <tom.hudson.phd@gmail.com> on the patch and push it soon.
Comment 4 Brian Paul 2017-06-02 14:23:05 UTC
Pushed as commit c6ba85a8c0f02b3b7058dae7afb6c49f56567319

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.