Draft: Fix chroma VA-API + OpenGL ES (without breaking iOS)
The interop used "RG textures" (GL_RED
/GL_RG
) for 2-planes pictures only when the "GL_ARB_texture_rg"
extension was available; otherwise, it used GL_LUMINANCE
/GL_LUMINANCE_ALPHA
. However, RG textures are also available on OpenGL >= 3 and OpenGL ES >= 3, even if the extension is not available.
This storage difference impacts the swizzle to access the two components:
-
GL_RG
(r, g, undef, undef):.rg
-
GL_LUMINANCE_ALPHA
(l, l, l, a):.ra
On desktop with OpenGL ES 3, the extension "GL_ARB_texture_rg"
does not exist, but RG textures are actually used. As a consequence, when using VA-API (which outputs NV12 pictures), the wrong components were read, causing #26735 (closed).
To fix this issue, the swizzle was changed by !1651 (merged), but then it broke the case where OpenGL ES 2 is used (on iOS: vlc-ios#1299 (closed)).
To fix the issue in both cases, always consider that RG textures are used for OpenGL >= 3 and OpenGL ES >= 3, and consider the "GL_ARB_texture_rg"
extension only for lower versions.
- Fixes #26735 (closed)
- Fixes #26769 (closed)
This MR is based on !1693 (merged) (which reverts parts of !1651 (merged)).
It first adds a function to get the exact OpenGL version. Since GL_MAJOR_VERSION
and GL_MINOR_VERSION
are not available before OpenGL 3 and OpenGL ES 3, parse the version string to retrieve the actual version in all cases. (Here, checking against version 3 would be sufficient, but providing a function to get the actual version in all cases is more future-proof.)
Then it stores the format determined by the interop so that the sampler can use it without guessing.
Finally, the version is checked to correctly determine if RG textures are used.
"without breaking iOS" → test welcome