After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 753640 - gl: DepthRange uses raw double instead of GLclampd
gl: DepthRange uses raw double instead of GLclampd
Status: RESOLVED WONTFIX
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal minor
: NONE
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-08-14 18:47 UTC by Martin Kelly
Modified: 2016-01-08 13:07 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch (1.02 KB, patch)
2015-08-14 18:48 UTC, Martin Kelly
none Details | Review

Description Martin Kelly 2015-08-14 18:47:10 UTC
The opengl DepthRange call uses a raw double, but it should be using the opengl type GLclampd.

I will post a patch to fix this.
Comment 1 Martin Kelly 2015-08-14 18:48:38 UTC
Created attachment 309302 [details] [review]
Patch
Comment 2 Matthew Waters (ystreet00) 2015-08-14 22:24:09 UTC
Does this actually cause an issue for you or is it just a cosmetic fix?
Comment 3 Martin Kelly 2015-08-15 16:20:02 UTC
It doesn't cause an issue for me right now (because double is typedef'd to GLdouble in the current gl.h), but it's also more than cosmetic. The opengl types were defined so that we don't have issues with types sizes. double is not guaranteed to be any particular size, so by using GLdouble we can keep portability across compilers even if the particular definition of GLdouble in gl.h changes in the future. We're already using opengl types for everything else, so it's also better to be self-consistent.

That said, Sebastian Dröge noticed that GLclampd was removed in later opengl versions, so I think we should probably be using GLdouble instead of GLclampd.
Comment 4 Sebastian Dröge (slomo) 2015-08-15 16:37:22 UTC
GLclampd only seems to be removed from GLES, not sure if it was also removed from desktop GL in later versions.


double is defined to be a 64 bit IEEE754 floating point number
Comment 5 Martin Kelly 2015-08-15 17:23:16 UTC
It appears that GLclampd was entirely removed (in favor of GLdouble) starting with opengl 4.2:
https://www.opengl.org/sdk/docs/man/html/removedTypes.xhtml

AFAICT, double is not guaranteed to be 64 bit or IEEE754; it just has to be a floating point representation of some kind. In contrast, GLdouble is guaranteed to be 64 bit IEEE754. On most (all? not sure) machines and compilers, they end up being the same, but in principle, they don't have to be.

Opengl reference:
https://www.opengl.org/wiki/OpenGL_Type

C reference (I'm sure we could find the actual standard, but this is quick and handy):
https://en.wikipedia.org/wiki/C_data_types
"Actual properties unspecified (except minimum limits), however on most systems this is the IEEE 754 double-precision binary floating-point format. This format is required by the optional Annex F "IEC 60559 floating-point arithmetic."

"The actual size and behavior of floating-point types also vary by implementation. The only guarantee is that long double is not smaller than double, which is not smaller than float."
Comment 6 Matthew Waters (ystreet00) 2015-08-15 17:35:56 UTC
https://en.wikipedia.org/wiki/Double-precision_floating-point_format disagrees.  They are both guaranteed to be 64-bits.  That being said, I'm fine with the change to GLdouble for the GL prototype/s.
Comment 7 Martin Kelly 2015-08-15 18:16:24 UTC
Thanks; I'll send a patch on Monday to convert double --> GLdouble in the prototypes.
Comment 8 Matthew Waters (ystreet00) 2015-08-16 09:10:42 UTC
Actually GLdouble is not defined by GLES at all so that will not work either without a typedef for GLES.
Comment 9 Martin Kelly 2015-08-17 15:49:16 UTC
I'm a little confused. Looking at glprototypes/opengl.h, it appears that all these functions are defined only for normal opengl anyway. That said, I'm still pretty new to this codebase; am I missing something?

glprototypes/opengl.h:

/* These are the core GL functions which are only available in big
   GL */
GST_GL_EXT_BEGIN (only_in_big_gl,
                  GST_GL_API_OPENGL | GST_GL_API_OPENGL3,
                  1, 0,
                  255, 255, /* not in GLES */
                  "\0",
                  "\0")

[snip]

GST_GL_EXT_FUNCTION (void, ClearDepth,

[snip]

GST_GL_EXT_END ()
Comment 10 Matthew Waters (ystreet00) 2015-08-18 04:00:14 UTC
All functions are defined for all GL api's GLES or otherwise as the function table is public API/ABI.  Compiling with different symbols in the vfunc table would break applications built against versions of the library targetting a different GL api set.
Comment 11 Martin Kelly 2015-08-18 16:04:18 UTC
I understand that part. What confuses me is that these functions are Opengl-specific section, with comments indicating that they're not in GLES. There are other such functions in the section that are Opengl-specific, such as GetTexImage.

If all these functions are going to have NULL vfunc table entries in GLES contexts anyway, why does the prototype (double/GLdouble) matter? Am I misunderstanding the way the contexts are handled?
Comment 12 Matthew Waters (ystreet00) 2015-08-18 22:15:18 UTC
It matters because GLdouble will not exist with GLES only systems and using it unconditionally will break compilation there.
Comment 13 Martin Kelly 2015-08-18 22:24:41 UTC
Yeah, that makes sense. I agree with you then that raw double is the only solution unless we add a typedef for GLES. Any opinion between the two?
Comment 14 Tim-Philipp Müller 2016-01-07 17:28:20 UTC
Matthew?
Comment 15 Matthew Waters (ystreet00) 2016-01-08 00:41:57 UTC
I don't really mind which way, staying with raw double means no code has to be changed.  If someone really wants to go to the effort of changing these to GLdouble, then by all means, go ahead.
Comment 16 Tim-Philipp Müller 2016-01-08 13:07:59 UTC
Let's close it for now then.

If anyone feels like making a patch, please re-open or file a new bug, thanks!