Files
plezy/linux/runner/mpv/mpv_gpu_bootstrap.h
T
edde746 9cdfe7591e feat(linux): restore the Flutter-texture path as the SDR fallback
2.13.0 deleted the display-agnostic EGL/Flutter-texture renderer and made
the native Wayland plane the only path, hard-rejecting every session that
cannot host one - X11, XWayland (SteamOS Gaming Mode runs native apps
through Gamescope's XWayland), or a plane whose EGL bootstrap failed. This
restores the 2.11.0 texture path from git history as the fallback:

- Re-add mpv_texture.cc/.h and mpv_gpu_bootstrap.cc/.h (2.11.0 verbatim):
  an FlTextureGL whose populate renders mpv into an offscreen FBO sampled
  by Flutter via an EGL image.
- MpvPlayer gains the texture-mode render-context API (InitRenderContext,
  HasRenderContext, GetEglDisplay/Context, Render(w,h,fbo)) beside the
  plane's InitRenderContextForSurface/RenderToSurface. The isolated ES 2.0
  context on Flutter's display and the X11 display param are exactly the
  2.11.0 configuration hardware decode demonstrably worked in.
- initialize now tries the plane first and falls back to the texture path
  when it cannot be brought up, returning the texture id (Dart's 2.11.0
  'result is int' contract) with waitForVideoReady gating playback until
  the GPU bootstrap settles. Both paths share one mpv core, so the
  plane/texture decision precedes render-context creation.
- hdr-enabled/hdr-tone-mapping are intercepted in texture mode (no plane,
  no HDR); the HDR toggle hides itself via isHDRSupported.
- New Linux setting 'Video rendering mode' (Automatic / Texture) forces
  the fallback - the user-visible workaround for plane-only trouble and
  for the hwdec interop regression, plus translations in all locales.

SDR only on the fallback, matching 2.11.0; the plane path is unchanged.
2026-08-14 18:16:32 +02:00

48 lines
1.6 KiB
C++

#ifndef MPV_GPU_BOOTSTRAP_H_
#define MPV_GPU_BOOTSTRAP_H_
#include <epoxy/egl.h>
#include <epoxy/gl.h>
#include <string>
namespace mpv {
using EglCreateImageCoreProc = EGLImage (*)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLAttrib*);
using EglDestroyImageCoreProc = EGLBoolean (*)(EGLDisplay, EGLImage);
using EglCreateImageKhrProc = EGLImageKHR (*)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLint*);
using EglDestroyImageKhrProc = EGLBoolean (*)(EGLDisplay, EGLImageKHR);
using GlImageTargetTextureProc = void (*)(GLenum, GLeglImageOES);
struct GpuBootstrapProbe {
int egl_major = 0;
int egl_minor = 0;
const char* egl_extensions = nullptr;
const char* gl_extensions = nullptr;
void* create_image_core = nullptr;
void* destroy_image_core = nullptr;
void* create_image_khr = nullptr;
void* destroy_image_khr = nullptr;
void* image_target_texture = nullptr;
};
struct GpuImageDispatch {
bool uses_core = false;
EglCreateImageCoreProc create_image_core = nullptr;
EglDestroyImageCoreProc destroy_image_core = nullptr;
EglCreateImageKhrProc create_image_khr = nullptr;
EglDestroyImageKhrProc destroy_image_khr = nullptr;
GlImageTargetTextureProc image_target_texture = nullptr;
EGLImageKHR Create(EGLDisplay display, EGLContext context, EGLClientBuffer buffer) const;
bool Destroy(EGLDisplay display, EGLImageKHR image) const;
explicit operator bool() const;
};
bool ValidateGpuBootstrapProbe(const GpuBootstrapProbe& probe, std::string* error);
bool ResolveGpuImageDispatch(EGLDisplay display, GpuImageDispatch* dispatch, std::string* error);
} // namespace mpv
#endif // MPV_GPU_BOOTSTRAP_H_