Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preferring core profile when creating GL context #80

Closed
Swoorup opened this issue Dec 28, 2014 · 16 comments
Closed

Preferring core profile when creating GL context #80

Swoorup opened this issue Dec 28, 2014 · 16 comments

Comments

@Swoorup
Copy link

Swoorup commented Dec 28, 2014

By default with mesa drivers, the context is created in compatibility profile. For example, my mesa driver supports core profile of opengl 3.3 and compatability is set to 3.0.

Magnum does not consider this and thinks its using opengl 3.3 profile and error is thrown. Shown below is error from cubemap example.

Renderer: Gallium 0.4 on AMD ARUBA by X.Org
OpenGL version: 3.0 Mesa 10.4.0
Using optional features:
    GL_ARB_ES2_compatibility
    GL_ARB_invalidate_subdata
    GL_ARB_multi_bind
    GL_ARB_robustness
    GL_ARB_separate_shader_objects
    GL_ARB_texture_storage
    GL_ARB_texture_storage_multisample
    GL_ARB_vertex_array_object
    GL_EXT_texture_filter_anisotropic
    GL_KHR_debug
Shader::compile(): compilation of vertex shader 1 failed with the following message:
0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES
Shader::compile(): compilation of fragment shader 2 failed with the following message:
0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES
Assertion Shader::compile({vert, frag}) failed in /home/swoorup/git/magnum-examples/src/cubemap/CubeMapShader.cpp on line 48
[1]    6555 abort (core dumped)  ./cubemap
@mosra
Copy link
Owner

mosra commented Dec 29, 2014

Hi, thanks for reporting. Similar thing was already done on OSX, so I just reenabled it also for other platforms.

Should be fixed in 48e666e, hopefully I didn't break anything else. Please reopen if you find any issues.

@mosra mosra closed this as completed Dec 29, 2014
@mosra mosra added the bug label Dec 29, 2014
@Swoorup
Copy link
Author

Swoorup commented Jan 2, 2015

Instead of creating 3.0 context, why not create 3.3 context for mesa? Some magnum examples like motionblur still require 3.3 context

@mosra
Copy link
Owner

mosra commented Jan 2, 2015

As far as I know, creating 3.0 context means that minimal required version is 3.0, thus the implementation will create context with the most recent version that is still compatible with 3.0.

If I would force the version to 3.3, it would cut off users with driver/hardware combination that supports only GL 3.0, 3.1 or 3.2. In their case the GL 2.1 fallback would be used, even though their system could handle newer versions.

@Swoorup
Copy link
Author

Swoorup commented Oct 1, 2015

Hi mosra, the issue is still prevalent and commit didn't seem to fix the issue

@Swoorup
Copy link
Author

Swoorup commented Oct 1, 2015

Renderer: Mesa DRI Intel(R) Haswell Mobile by Intel Open Source Technology Center
OpenGL version: 3.0 Mesa 11.0.2
Using optional features:
GL_ARB_ES2_compatibility
GL_ARB_get_texture_sub_image
GL_ARB_invalidate_subdata
GL_ARB_multi_bind
GL_ARB_robustness
GL_ARB_separate_shader_objects
GL_ARB_texture_storage
GL_ARB_texture_storage_multisample
GL_ARB_vertex_array_object
GL_EXT_texture_filter_anisotropic
GL_KHR_debug
Shader::compile(): compilation of vertex shader 1 failed with the following message:
0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES
Shader::compile(): compilation of fragment shader 2 failed with the following message:
0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES
Assertion Shader::compile({vert, frag}) failed in /home/swoorup/git/magnum-examples/src/picking/PickingExample.cpp on line 123
[1] 9533 abort (core dumped) ./magnum-picking

@Swoorup
Copy link
Author

Swoorup commented Oct 1, 2015

GLX INFO:
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Haswell Mobile
OpenGL core profile version string: 3.3 (Core Profile) Mesa 11.0.2
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 11.0.2
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 11.0.2
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
OpenGL ES profile extensions:

@Swoorup Swoorup changed the title mesa opengl context creation mesa opengl 3.3 context not created Oct 1, 2015
@ytain
Copy link

ytain commented Oct 1, 2015

I get the same error as Swoorup on an Atom laptop regarding the Core profile 3.30.

glxinfo snippet:

OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Bay Trail
OpenGL core profile version string: 3.3 (Core Profile) Mesa 11.1.0-devel (git-1c6689b 2015-10-01 trusty-oibaf-ppa)
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
...

OpenGL version string: 3.0 Mesa 11.1.0-devel (git-1c6689b 2015-10-01 trusty-oibaf-ppa)
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
...

OpenGL ES profile version string: OpenGL ES 3.0 Mesa 11.1.0-devel (git-1c6689b 2015-10-01 trusty-oibaf-ppa)
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
OpenGL ES profile extensions:
...

I think the selection of OpenGL profile chooses the wrong profile cause it picks the one with GLSL 1.30 instead of the profile which supports GLSL 3.30.

So you'll need to provide a way to enumerate the profiles and pick the one that satisfies the GLSL version requirement. Or give us a way to create a context with the GLSL version we choose to use.

@mosra mosra reopened this Oct 2, 2015
@mosra
Copy link
Owner

mosra commented Oct 2, 2015

Right, so this is not fixed at all. Sorry about that, I didn't have Mesa drivers installed to test the change on. From the output it doesn't even seem to print the

Platform::Sdl2Application::tryCreateContext(): cannot create core context

line, so I guess SDL2 is just not creating the core profile even though it is told to do so.

I think the selection of OpenGL profile chooses the wrong profile cause it picks the one with GLSL 1.30 instead of the profile which supports GLSL 3.30.

So you'll need to provide a way to enumerate the profiles and pick the one that satisfies the GLSL version requirement. Or give us a way to create a context with the GLSL version we choose to use.

@ytain just ensuring that Core GL context is created would be enough to satisfy GLSL version requirements (the core 3.3 context would support GLSL 1.10 through 3.30).

Briefly looking at the code, I think I found the problem. Can you try to change this line to say SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); instead of 0? The same thing is done for OSX and it works there. It would be even better if that worked also with SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); (because I think Mesa supports only 3.1 for some HW).

I can't test the change right now, sorry (maybe at the end of the weekend), so if someone can test this for me that would be very appreciated. Thanks.

@Swoorup
Copy link
Author

Swoorup commented Oct 2, 2015

Can conform both works. Though now, profile just jumps to 3.3

The example binary now gives,
OpenGL version: 3.3 (Core Profile) Mesa 11.0.2

With the picking example, I can only seem to rotate, clicking does not do any visible change at all. I'll dig in later

@mosra
Copy link
Owner

mosra commented Oct 2, 2015

Awesome, thanks for the quick test. Yes, it's expected to be at highest available GL version. Will try to push the fix as soon as possible.

I had similar problems with the picking example (although on WebGL 2, some of the mentioned issues might be relevant to desktop GL too). "It worked on my NVidia", so I probably ran into some driver-specific implementation difference or used some more recent functionality by accident.

@mosra
Copy link
Owner

mosra commented Oct 6, 2015

Sorry for the delay.

The fix is in a7661d7. Please reopen (again) if the issue (still) persists. Moving the discussion about broken example to mosra/magnum-examples#17.

@mosra mosra closed this as completed Oct 6, 2015
@mosra mosra reopened this Oct 6, 2015
@mosra
Copy link
Owner

mosra commented Oct 6, 2015

Aargh. Fuck this. I hate OpenGL.

On NVidia the fix causes the version to be forced to GL 3.1, not the highest version available, which is completely useless behavior. Googling found some workaround from 2012. It's still not fixed yet? Unbelievable.

It seems that the only solution is to:

  1. create compatibility context
  2. check if we are on nvidia, then we are done
  3. otherwise try to create core context
  4. if that fails, create compatibility context

Uglyy.

@Swoorup
Copy link
Author

Swoorup commented Oct 7, 2015

I had that too. I use a optimus laptop and got the same result with nvidia. OpenGL implementation differs so vastly across different vendors. Then, I just created a OpenGL 3.3 context which worked.

@mosra
Copy link
Owner

mosra commented Oct 9, 2015

Commit 7e82eb2 should have this finally fixed even with the NVidia workarounds.

I also tried to do similar thing in WindowlessGlxApplication in 4ea5dc4, @Swoorup can you try running magnum-info to check if it says OpenGL 3.3 too? Thanks a lot.

@mosra mosra changed the title mesa opengl 3.3 context not created Preferring core profile when creating GL context Oct 30, 2015
@mosra
Copy link
Owner

mosra commented Oct 30, 2015

It seems that both NVidia and AMD are having the same problems -- specifying context version makes the driver use exactly that version and not any later comatible one, even though I think the specification allows it and Mesa is doing it -- if I specify core GL 3.1, it happily gives me 3.3 or any later version.

So I may need to do the workaround also for AMD drivers, ugh.

@mosra
Copy link
Owner

mosra commented Nov 16, 2015

Finally got a machine with Mesa, confirming that this works for both Sdl2Application and WindowlessGlxApplication. Closing as fixed.

EDIT: Workaround for AMD was added in 81f227b.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

3 participants