Bug 165253

Summary: [GTK] Use an OpenGL < 3.0 compliant way to request the OpenGL version
Product: WebKit Reporter: Miguel Gomez <magomez>
Component: WebKitGTKAssignee: Miguel Gomez <magomez>
Status: RESOLVED FIXED    
Severity: Normal CC: bugs-noreply, commit-queue, mcatanzaro
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=165283
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Miguel Gomez 2016-12-01 07:21:15 PST
We are currently using glGetIntegerv() with GL_MAJOR_VERSION and GL_MINOR_VERSION to get the opengl version, but this is not compatible with OpenGL < 3.0.

We need to use glGetString(GL_VERSION) instead, which is compatible with all versions (so far).
Comment 1 Miguel Gomez 2016-12-01 07:32:03 PST
Created attachment 295849 [details]
Patch
Comment 2 Michael Catanzaro 2016-12-01 08:37:33 PST
Comment on attachment 295849 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=295849&action=review

> Source/WebCore/platform/graphics/GLContext.cpp:168
> +        // The version number always has the form "mayor.minor.release".

mayor -> major.

Nit, since I'm leaving other comments on this comment: vendor-specific with a hyphen.

Nit: If you want to leave a line break in the middle of the comment then you should leave an extra blank line as well. I'd prefer to write this comment on just two lines. Looks like it fits:

// Version string always begins with the version number, then a space and the vendor-
// specific info. The version number always has the form "major.minor.release".

Alternatively (less-preferred):

// Version string always begins with the version number, then a space and the vendor-
// specific info.
//
// The version number always has the form "major.minor.release".

> Source/WebCore/platform/graphics/GLContext.cpp:174
> +        versionStringComponents.at(0).split('.', versionDigits);
> +        m_version = versionDigits.at(0).toUInt() * 100 + versionDigits.at(1).toUInt() * 10;

Looks like it's going to crash if the version does not have a . character. I guess it will always exist, but is it guaranteed, or should we be robust to that?
Comment 3 Carlos Garcia Campos 2016-12-01 23:50:01 PST
Comment on attachment 295849 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=295849&action=review

> Source/WebCore/platform/graphics/GLContext.cpp:167
> +        // Version string always begins with the version number, then a space and then vendor
> +        // specific info.

I think this is not always true, in case of OpenGL ES, the version string starts with "OpenGL ES", see https://www.khronos.org/opengles/sdk/1.1/docs/man/glGetString.xml.

>> Source/WebCore/platform/graphics/GLContext.cpp:168
>> +        // The version number always has the form "mayor.minor.release".
> 
> mayor -> major.
> 
> Nit, since I'm leaving other comments on this comment: vendor-specific with a hyphen.
> 
> Nit: If you want to leave a line break in the middle of the comment then you should leave an extra blank line as well. I'd prefer to write this comment on just two lines. Looks like it fits:
> 
> // Version string always begins with the version number, then a space and the vendor-
> // specific info. The version number always has the form "major.minor.release".
> 
> Alternatively (less-preferred):
> 
> // Version string always begins with the version number, then a space and the vendor-
> // specific info.
> //
> // The version number always has the form "major.minor.release".

And this is not true either, it could be major.minor.release or just major.minor see https://www.opengl.org/wiki/GLAPI/glGetString
Comment 4 Miguel Gomez 2016-12-02 02:08:39 PST
Created attachment 295934 [details]
Patch
Comment 5 Miguel Gomez 2016-12-02 03:06:01 PST
Created attachment 295937 [details]
Patch
Comment 6 WebKit Commit Bot 2016-12-02 05:23:13 PST
Comment on attachment 295937 [details]
Patch

Clearing flags on attachment: 295937

Committed r209234: <http://trac.webkit.org/changeset/209234>
Comment 7 WebKit Commit Bot 2016-12-02 05:23:16 PST
All reviewed patches have been landed.  Closing bug.
Comment 8 Michael Catanzaro 2016-12-02 08:12:28 PST
Is there seriously no forwards-compatible way to check OpenGL version? What we committed looks pretty fragile.