Jump to content
  • Advertisement
Sign in to follow this  
Misantes

OpenGL OpenGL/GLSL version handling

This topic is 1510 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So, some general advice is needed here.

 

I recently got a laptop that only supports glsl 1.3 and opengl 3.0 (it's a chromebook 14, with chromeOS erased and Ubuntu 14.10 installed over it).

I'm realizing that with my current project, I've written the shaders with 330 support. I'd like it to support glsl 1.3 as well. I think the only things in my shaders that aren't compatible are the "layout" portions of things (they're rather simple lighting shaders). I've made a build that adds glBindAttribLocation and glBindFragDataLocation on object creation, and changed the shaders to account for that. It runs, albeit rather jittery, though I haven't profiled it to find out why yet.

 

If I don't want to maintain two builds, what's the best way to handle this? My initial reaction is to have a low/high setting, and depending on which, on item creation have two separate rendering methods. However, I was curious how everyone else handled this. Is there any performance benefit to using the layout functions, or is this purely for convenience? If it's just convenience, I'm happy to simply use the deprecated functions and have it support lower end hardware.

 

Anyhow, I'm curious to know everyone else's approach to compatibility, as this is rather a new realm for me.

 

Cheers, and thanks!

Edited by Misantes

Share this post


Link to post
Share on other sites
Advertisement

What the GL driver does with the locations is the same as if you called glBindAttribLocation and glBindFragDataLocation, except the location comes from your shader and not through an API call. The only difference is that the layout qualifier is a lot more convenient as you don't have to recompile your code.

 

Those two API functions, by the way, aren't deprecated. They're just an alternative way of doing things.

Share this post


Link to post
Share on other sites


I recently got a laptop that only supports glsl 1.3 and opengl 3.0 (it's a chromebook 14, with chromeOS erased and Ubuntu 14.10 installed over it).
Which one exactly? 

 

If its the one with the 2955U Celeron,  It might have an Intel HD 4xxx card or similar which should run OpenGL 3.3 fine. I'm not sure what kind of Mesa drivers Ubuntu ships tho.

 

If its one with a Tegra chip, then it might go up to OpenGL 4.4 if its recent (not sure how the state of the linux drivers are for Tegra either).

 

OpenGL 3.0 only seems kinda weird, most OpenGL 3 class hardware go up to 3.1 with updated drivers, 3.2 if they support geometry shaders, or 3.3 if they support geometry shaders and the vendor feels like supporting it.

Share this post


Link to post
Share on other sites

 


I recently got a laptop that only supports glsl 1.3 and opengl 3.0 (it's a chromebook 14, with chromeOS erased and Ubuntu 14.10 installed over it).
Which one exactly? 

 

If its the one with the 2955U Celeron,  It might have an Intel HD 4xxx card or similar which should run OpenGL 3.3 fine. I'm not sure what kind of Mesa drivers Ubuntu ships tho.

 

If its one with a Tegra chip, then it might go up to OpenGL 4.4 if its recent (not sure how the state of the linux drivers are for Tegra either).

 

OpenGL 3.0 only seems kinda weird, most OpenGL 3 class hardware go up to 3.1 with updated drivers, 3.2 if they support geometry shaders, or 3.3 if they support geometry shaders and the vendor feels like supporting it.

 

You're might be correct (though it still refuses to show anything tongue.png), it may have 3.3 support for opengl. But, glsl still shows 1.3 (i think). What's the difference between core and version support?

Hm. It does have a 2955U celeron, I'm going to admit, I'm a little uncertain on the video card (also, a little uncertain on verifying the card info. I've never used an on-board graphics card as this is my first laptop). The system reports just "Intel Haswell Mobile" and lspci | grep VGA just reports 

VGA compatible controller: Intel Corporation Haswell-ULT Integrated Graphics Controller (rev 0b)

similarly, sudo lshw -C video reports only:

description: VGA compatible controller
       product: Haswell-ULT Integrated Graphics Controller
       vendor: Intel Corporation
       physical id: 2
       bus info: pci@0000:00:02.0
       version: 0b
       width: 64 bits
       clock: 33MHz
       capabilities: msi pm vga_controller bus_master cap_list rom
       configuration: driver=i915 latency=0
       resources: irq:59 memory:e0000000-e03fffff memory:d0000000-dfffffff iopor

I'm on the 3.16 kernel, with 14.10. I've upgraded to Mesa 10, but it still reports only 3.0 (unless I'm reading things wrong).

grep opengl reports:

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 10.4.0-devel (git-8c7ac37 2014-10-24 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 10.4.0-devel (git-8c7ac37 2014-10-24 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 10.4.0-devel (git-8c7ac37 2014-10-24 trusty-oibaf-ppa)
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.0
OpenGL ES profile extensions:

How do the core and version profiles differ? If I leave in the "core" part of my shaders, it refuses to render, though, if I remove it, things work fine.

I would absolutely love to get this running modern opengl. If you have any advice on where I may be going wrong configuring things, I'd appreciate the input.

 

@ Xycaleth

That's wonderful to know, especially if I end up not getting the 3.3 support running.

Edited by Misantes

Share this post


Link to post
Share on other sites

What's the difference between core and version support?
You should read up on OpenGL profiles then. It seems your card supports core 3.3, and GLSL 3.30.

 

Mesa drivers doesn't implements ARB_compatibility extension, thus, you only got 'core' profiles, ie, no deprecated functions.

 

I'm not sure what that second "version" is, maybe its just Mesa's software OpenGL implementation, or just the version of a dummy context created to query OpenGL data, no idea. But you should be looking at the first one, the 'core' version.

 

Just try to create an OpenGL 3.3 core/forward compatible context and use #version 330 in your GLSL files. If you can create it and run it, then your rendering issues must be somewhere else (hello different driver implementations!).

 

Are you using deprecated functions? Did you coded initially on a nVidia card? nVidia drivers tends to be more lenient, whereas AMD and possibly Intel drivers might strive more to follow the OGL spec to the letter (first time I ran my shaders on an AMD card, it practically spit on my face :D ).

 

Then again, sometimes its nothing to do with the spec, driver just bugs out at specific circumstances.

Share this post


Link to post
Share on other sites

They're fairly basic shaders, using #version 330 core, no ARB functions, though they were initially developed on an nvidia driver.

 

Though, it appears you're right, and it looks like I just have a driver/library error somewhere. as the error I'm now getting is:

X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 155 (GLX)
Minor opcode of failed request: 34 ()
Serial number of failed request: 75
Current serial number in output stream: 74

downgrading to version 130 gets rid of it, with the appropriate changes to the shader, but I think I was mistaken initially, in reading the second output of grep opengl, and the fact that it ran as 130. But, after digging a little, that error is usually associated with driver and library issues. I can't quite parse it myself, but I'll keep looking into it and see where I've gone wrong in my upgrade.

 

If I had to guess, it's because I initially used the intel graphics driver tool to update my graphics driver, but it's not supported on 14.10 yet, so there are probably lingering files in there somewhere. I reinstalled mesa, as it was still on the trusty build, but that didn't seem to fix it. If you have any insight, I'm all ears. 

 

edit*

Though, I should note that I was getting that error on 14.04 as well, prior to upgrading anything, so I'm a little skeptical that the issue is there.

In hindsight, upgrading to 14.10 may have been a bit premature (I had read that the intel drivers got a bit of love, support-wise, I tend to wait a bit for upgrades). So, I may end up just downgrading/reinstalling the lts version for the time being and trying again. I loathe driver issues tongue.png

Edited by Misantes

Share this post


Link to post
Share on other sites

It's almost like TheChubu said:

You only get GLSL 3.30 when you create a core-context with version 3.3. The other version-info shown in your output (I guess it's from glxinfo) is for old non-core contexts.

This irritated the hell out of me when I first encountered this behaviour :-)

So everything regarding your drivers seems to be correct!

 

Are you using GL_KHR_debug or GL_ARB_debug_output yet?

I can really recommend using them as they might give you more information about the error you are still encountering.

 

Regards

Markus

Share this post


Link to post
Share on other sites
Anyhow, I'm curious to know everyone else's approach to compatibility, as this is rather a new realm for me.

I use a 2 step mechanism, a coarse one bases on dynamic library selection, and a fine one based on late binding. This works because of a layered solution of the graphics sub-system.

 

First of, somewhere in the starting process of the application, a OpenGL context is created with the highest supported version. If this fails then a context with the next lower version is tried until the lowest supported version. This can be done in a comfortable way on Mac OS, because it gives one the highest available version when asked for a 3.2 core profile anyway. On Windows, the process is less comfortable. However, if a context was generated, the belonging dynamic library is loaded. If this fails, then again the next lower version for context creation is tried. In the end I hope to have a library successfully loaded, or else the application is not runnable, of course. 

 

Such a library brings in the lowest layer of the graphics sub-system w.r.t. the own implementation. It is able to process graphics jobs that are generated within the middle layer of the graphics sub-system. However, when a library was loaded successfully it has a defined minimum of features. Additional features or better implementations are then recognized by the set-up routine of the graphics sub-system layer loaded with the library. This is based on investigating the minor version number and the extensions. The layer then does symbol binding by its own.

 

Regarding shader scripts: Some scripts are assembled at the runtime, and this considers to use the mechanisms available from the loaded library. Pre-made scripts need to be available for each loadable library, of course, and hence are simply selected.

 

 

EDIT: BTW: The above mechanism is not only used for version compatibility but is abstract enough to also select between OpenGL and D3D.

Edited by haegarr

Share this post


Link to post
Share on other sites

Ick,

So, everything seems to be sorted out driver-wise. However, my current program uses opengl within an sfml context window. According to the sfml forums:

sfml-graphics will not allow you to use GLSL 1.30 or higher on systems that are only able to provide GLSL 1.30 or higher exclusively in core contexts.

I read up a bit on opengl profiles, and if I'm reading the output right, my driver only supports glsl 130 and opengl 3.0 without a explicitly creating core contexts. So, I believe I may be SOL with running this project on this system within sfml (my non-sfml OpenGL programs handle it just fine, after some testing).

 

If anyone's dealt with this before, I'm open to advice, but it seems a bit of a fringe problem. I'll likely try to implement haegarr's advice and create a  version 130 shader if it reports that as the highest available.

 

Otherwise, thank you for the input everyone. 

Edited by Misantes

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!