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

Helper function to determine the highest supported GLSL version #145

Closed
haasn opened this issue Nov 1, 2017 · 4 comments
Closed

Helper function to determine the highest supported GLSL version #145

haasn opened this issue Nov 1, 2017 · 4 comments

Comments

@haasn
Copy link

haasn commented Nov 1, 2017

It can be nontrivial to figure out which GLSL version is supported, based on the combination of GL context type (GL, GLES) and the supported GL_SHADING_LANGUAGE_VERSION (or lack thereof).

It might be worthwhile to export epoxy_glsl_version, to mirror epoxy_gl_version and epoxy_has_gl_extension. It seems to fit the theme of these helpers.

@ebassi
Copy link
Collaborator

ebassi commented Nov 1, 2017

Yes, I agree it would be a good addition. Care to open a pull request?

@haasn
Copy link
Author

haasn commented Nov 3, 2017

I can give it a try, but I'm not entirely sure what the correct logic is. (Part of the reason I made this issue)

Obviously there's glGetString(GL_SHADING_LANGUAGE_VERSION), but I couldn't figure out whether this is always available or always contains useful results. Seems like other projects (e.g. mpv) have fallback code that sets the GLSL version to 300 for GLES 3, 200 for GLES 2, and 110 otherwise.

@ebassi
Copy link
Collaborator

ebassi commented Nov 3, 2017

The GL/GLES specifications typically assign a version to the GLSL shading language that goes along with their own version; this means we can provide a fallback value depending on the GL/GLES version of the currently bound context — if the GL implementation is returning something we can't use. I surely expect any conformant GL and GLES driver to return a reasonable value, though, otherwise we may just as well pack up our bags, and go home.

Alternatively, we could give up early, and return 0, and let client code decide what's best in their interests.

@nwnk
Copy link
Collaborator

nwnk commented Nov 3, 2017

glGetString(GL_SHADING_LANGUAGE_VERSION) is a valid enum for GL 2.0+ and GLES 2.0+, and for GL 1.x plus GL_ARB_shading_language_100. Certain GL versions imply a minimum GLSL version, but I'd consider any case where the GLSL version is less than the version the GL requires to be an implementation error and not something we should try to reinterpret.

Since GL2 and GLES2 will have the "same" version number, maybe something like:

int
epoxy_glsl_version(void)
{
    if (epoxy_gl_version() >= 20 ||
        epoxy_has_gl_extension("GL_ARB_shading_language_100")) {
        return epoxy_internal_gl_version(GL_SHADING_LANGUAGE_VERSION, 0);
    return 0;
}

Where epoxy_internal_gl_version been changed to pass in the enum of the string to parse.

@ebassi ebassi closed this as completed in d8726f2 Feb 23, 2018
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

No branches or pull requests

3 participants