GNOME Bugzilla – Bug 712830
Add COGL_PIXEL_FORMAT_U_V
Last modified: 2014-01-20 14:47:11 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.
Created attachment 260465 [details] [review] Add COGL_PIXEL_FORMAAT_U_V
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.
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, (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.
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.
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