Login  Register

Re: libgl version 8 issues - no profiles available

Posted by zeno on Mar 19, 2012; 10:34pm
URL: https://forum.jogamp.org/libgl-version-8-issues-no-profiles-available-tp3832159p3840554.html

Hi Sven,
i've tried new builds from repository (namely jogl b705), still the same error. No more test outputs this time, just
pathway to solution. Lets start what jogl behaviour is different between mesa versions 7 and 8. While you have
mesa 7xx, following lines (from newest sources, added in latest commit) in X11GLXContext.java (lines 342+)
results in false:

final boolean isProcCreateContextAttribsARBAvailable = isFunctionAvailable("glXCreateContextAttribsARB");
final boolean isExtARBCreateContextAvailable = isExtensionAvailable("GLX_ARB_create_context");
if ( isProcCreateContextAttribsARBAvailable && isExtARBCreateContextAvailable )
     contextHandle = createContextARB(share, direct);
...
so this if condition is not met. Ok, contextHandle was and still is 0, nothing changed... after a while code
continues with old temporary context (line 380 +). From now on, everything is OK with mesa 7xx.

Now the difference - after switching to mesa 8xx,  the ARB functions are available and (lines 342, 343)
results in true, but still (line 346):

contextHandle = createContextARB(share, direct);

returns 0 and this behaviour leads to both parts of my problem. In GLContextImpl class on line 664 (body of
previously mentioned method createContextARB(...)) is a method call:

mapGLVersions(device);

inside of this method are several calls of createContextARBMapVersionsAvailable(...) functions. Each call of
this method resets context states (GLContextImpl.java line 776) so that gl property of
X11GLXContext instance becomes null. Ok, some code runs until we are back to X11GLXContext, boolean flag
createContextARBTried is set to true and contextHandle is still 0. Code continues as usually with old temporary
context. Seems ok, code runs well until makeCurrent is called. Precisely line 470 in class GLContextImpl.
There is verification of profiles:

getGLDrawable().getGLProfile().verifyEquality(gl.getGLProfile());

where, as I described, gl property is now null -> throws naturally nullpointerexception...
This is only one part of my problem. At start, I tried restoring gl property with setGLFunctionAvailability(..)
method only, but i found that last internal part of mapGLVersions() method
modifies deviceVersionsAvailableSet property of our context instance and this finally causes my
mismatch in profiles.

So, that's all to the description of my problems, I've continued my research in code and found a solution:
Insert following code  after line number 370 in X11GLXContext.java, so that gl property null state is
prohibited and deviceVersionsAvailableSet are regenerated... But I don't know if this is the best solution...

if(this.gl == null)
{
  //clear deviceVersionsAvailableSet, which was set in createContextARB(...)
  shutdown();
 
  //set back temp context as current
  if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), temp_ctx)) {
    throw new GLException("Error making temp context(1) current: display "+toHexString(display)+", context "+toHexString(temp_ctx)+", drawable "+drawable);
  }
 
  //refresh functions etc.
  setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT); // use GL_VERSION
}

From this point, everything works on my machine with mesa 8. Please let me know what you think about it.
I am really sorry for posting such a long message in this place, I swear I will not do this next time... :) I bet bugzilla
is designed for this problems... If you can point me in the right direction, I can offcourse produce some kind of
patch or whatever - but i am beginner in this, so please be patient...
Still I hope this helps.
Zeno