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 712830 - Add COGL_PIXEL_FORMAT_U_V
Add COGL_PIXEL_FORMAT_U_V
Status: RESOLVED FIXED
Product: cogl
Classification: Platform
Component: GL
1.16.x
Other Linux
: Normal normal
: ---
Assigned To: Cogl maintainer(s)
Cogl maintainer(s)
Depends on:
Blocks: 712832
 
 
Reported: 2013-11-21 17:03 UTC by Matthieu Bouron
Modified: 2014-01-20 14:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add COGL_PIXEL_FORMAAT_U_V (3.98 KB, patch)
2013-11-21 17:04 UTC, Matthieu Bouron
none Details | Review

Description Matthieu Bouron 2013-11-21 17:03:54 UTC
The following patch (applied on top 1.16 release) add COGL_PIXEL_FORMAT_U_V format used for sampling the chrominance plane of NV12 buffers.
Comment 1 Matthieu Bouron 2013-11-21 17:04:55 UTC
Created attachment 260465 [details] [review]
Add COGL_PIXEL_FORMAAT_U_V
Comment 2 Neil Roberts 2013-11-25 13:28:27 UTC
I think this one is a bit tricky. I guess for the NV12 buffers you really just need a two-component texture to represent the UV data and it doesn't really matter which components they are because they will only be used from a shader. In that case I think naming it U_V isn't ideal because it's not clear how that format maps to the components in the shader.

GL3 doesn't have the GL_LUMINANCE_* texture formats and instead it just has formats that represent a number of components from 1-4. Eg, GL_RED, GL_RG, GL_RGB and GL_RGBA. Ideally Cogl would be forward-looking and only advertise these formats as well. However the problem is that we also want to support GLES2 and that doesn't have all of these. Cogl already has a single-component texture and we've already had to compromise to support that. It is represented as GL_ALPHA instead of GL_RED and this is emulated on GL3 using the texture swizzle outside of the shader.

I think the best thing to do would be do have a similar compromise for a two-component texture. That would mean the format would be called COGL_PIXEL_FORMAT_GA_88 and it would represent luminance-alpha instead of trying say it is only appropriate for UV textures. For GL3 would again have to upload this as GL_RG and use the texture swizzle to map the R component to RGB and the G component to A.
Comment 3 Robert Bragg 2013-11-25 22:57:53 UTC
Just for reference, to see a bit more detail about Neil's thinking; the patch he wrote to add support for the _A_8 pixel format textures on GL3 is 32bacf81ebaa3be21a8f26af07d8f6eed6607652. Hopefully that should give a good idea of how we could do a similar thing for a _GA_88 format too.
Comment 4 Matthieu Bouron 2013-11-26 11:37:48 UTC
Thanks, (In reply to comment #3)
> Just for reference, to see a bit more detail about Neil's thinking; the patch
> he wrote to add support for the _A_8 pixel format textures on GL3 is
> 32bacf81ebaa3be21a8f26af07d8f6eed6607652. Hopefully that should give a good
> idea of how we could do a similar thing for a _GA_88 format too.

Thanks for the reference, it will be very helpful.
Comment 5 Neil Roberts 2014-01-14 15:57:07 UTC
I've posted a patch to the mailing list to provide a two-component texture format:

http://lists.freedesktop.org/archives/cogl/2014-January/001559.html

Instead of trying to use GL_LUMINANCE_ALPHA I've just made it always use GL_RG. There is a feature flag for whether the format is supported and it won't work on GLES2 or GL2 without the GL_EXT_texture_rg or GL_ARB_texture_rg extension. I think this should be good enough for the cogl-gst use case and it avoids the mess of having to support the strange semantics of luminance textures.
Comment 6 Neil Roberts 2014-01-20 14:47:11 UTC
I've pushed the patch to master and the 1.18 branch so I guess we can consider this bug fixed.

https://git.gnome.org/browse/cogl/commit/?id=eb7ef457cb281d5ed75863a269da2a94