vo_gpu: opengl: support GL_EXT_framebuffer_object

Some GL 2.1 drivers (e.g. Mesa lima) expose GL_EXT_framebuffer_object
but not GL_ARB_framebuffer_object, leaving MPGL_CAP_FB unset even
though FBOs are usable. Load the EXT entrypoints as an alternative
provider of MPGL_CAP_FB; mpv's FBO usage (Gen'd names, GL_FRAMEBUFFER
target, single color attachment, runtime completeness checks) is
within the subset EXT and ARB share. The section is placed before the
ARB/core one so the latter overwrites the function pointers whenever
it is available.

Querying attachment parameters of the default framebuffer is an
ARB/GL 3.0 addition, so skip that query in ra_gl_ctx_color_depth()
when only the EXT extension is present.
This commit is contained in:
Vasily Khoruzhick
2026-07-13 16:35:14 -07:00
committed by Kacper Michajłow
parent e6887ed972
commit 37eb6a0de0
2 changed files with 26 additions and 0 deletions
+20
View File
@@ -212,6 +212,26 @@ static const struct gl_functions gl_functions[] = {
.extension = "GL_EXT_unpack_subimage",
.provides = MPGL_CAP_ROW_LENGTH,
},
// Framebuffers, alternative extension name. Some GL 2.1 drivers (e.g.
// Mesa lima) expose only this one. It provides a compatible subset of
// GL_ARB_framebuffer_object for our purposes; the entrypoints loaded
// here are overwritten by the ARB/core ones below if available.
{
.ver_exclude = 300,
.ver_es_exclude = 200, // FBOs are core in ES2
.extension = "GL_EXT_framebuffer_object",
.provides = MPGL_CAP_FB,
.functions = (const struct gl_function[]) {
DEF_FN_NAME(BindFramebuffer, "glBindFramebufferEXT"),
DEF_FN_NAME(GenFramebuffers, "glGenFramebuffersEXT"),
DEF_FN_NAME(DeleteFramebuffers, "glDeleteFramebuffersEXT"),
DEF_FN_NAME(CheckFramebufferStatus, "glCheckFramebufferStatusEXT"),
DEF_FN_NAME(FramebufferTexture2D, "glFramebufferTexture2DEXT"),
DEF_FN_NAME(GetFramebufferAttachmentParameteriv,
"glGetFramebufferAttachmentParameterivEXT"),
{0}
},
},
// Framebuffers, extension in GL 2.x, core in GL 3.x core.
{
.ver_core = 300,
+6
View File
@@ -193,6 +193,12 @@ int ra_gl_ctx_color_depth(struct ra_swapchain *sw)
if ((gl->es < 300 && !gl->version) || !(gl->mpgl_caps & MPGL_CAP_FB))
return 0;
// The *_SIZE attachment queries need GL_ARB_framebuffer_object or
// GL 3.0+; GL_EXT_framebuffer_object does not provide them.
if (gl->version && gl->version < 300 &&
!gl_check_extension(gl->extensions, "GL_ARB_framebuffer_object"))
return 0;
gl->BindFramebuffer(GL_FRAMEBUFFER, p->main_fb);
GLenum obj = gl->version ? GL_BACK_LEFT : GL_BACK;