Files
qemu/include/ui/egl-helpers.h
Marc-André Lureau 7eff64f15d ui/gtk: move GL fence tracking from QemuDmaBuf to VirtualGfxConsole
The sync and fence_fd fields on QemuDmaBuf are only used by the GTK
display backend for GPU fence synchronization during draw. They are not
intrinsic properties of the DMA-BUF itself but transient GL state tied
to the display listener.

Move fence_fd to VirtualGfxConsole and keep the EGL sync local to the
draw operation. Change egl_dmabuf_create_sync() and
egl_dmabuf_create_fence() to return values instead of storing them on the
dmabuf. This makes the fence lifecycle independent of the dmabuf
lifetime.

Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-09-10 19:59:42 +04:00

89 lines
2.6 KiB
C

#ifndef EGL_HELPERS_H
#define EGL_HELPERS_H
#include <epoxy/gl.h>
#include <epoxy/egl.h>
#ifdef CONFIG_GBM
#include <gbm.h>
#endif
#include "ui/console.h"
#include "ui/shader.h"
extern EGLDisplay qemu_egl_display;
extern EGLConfig qemu_egl_config;
extern DisplayGLMode qemu_egl_mode;
extern bool qemu_egl_angle_d3d;
typedef struct egl_fb {
int width;
int height;
int x;
int y;
GLuint texture;
GLuint framebuffer;
bool delete_texture;
QemuDmaBuf *dmabuf;
} egl_fb;
#define EGL_FB_INIT { 0, }
void egl_fb_destroy(egl_fb *fb);
void egl_fb_setup_default(egl_fb *fb, int width, int height, int x, int y);
void egl_fb_setup_for_tex(egl_fb *fb, int width, int height,
GLuint texture, bool delete);
void egl_fb_setup_new_tex(egl_fb *fb, int width, int height);
void egl_fb_blit(egl_fb *dst, egl_fb *src, bool flip);
void egl_fb_read(DisplaySurface *dst, egl_fb *src);
void egl_fb_read_rect(DisplaySurface *dst, egl_fb *src, int x, int y, int w, int h);
void egl_texture_blit(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip);
void egl_texture_blend(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip,
int x, int y, double scale_x, double scale_y);
extern EGLContext qemu_egl_rn_ctx;
#ifdef CONFIG_GBM
extern int qemu_egl_rn_fd;
extern struct gbm_device *qemu_egl_rn_gbm_dev;
int egl_rendernode_init(const char *rendernode, DisplayGLMode mode);
bool egl_dmabuf_export_texture(uint32_t tex_id, int *fd, EGLint *offset,
EGLint *stride, EGLint *fourcc, int *num_planes,
EGLuint64KHR *modifier);
void egl_dmabuf_import_texture(QemuDmaBuf *dmabuf);
void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf);
EGLSyncKHR egl_create_sync(void);
int egl_create_fence(EGLSyncKHR sync);
#endif
EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, EGLNativeWindowType win);
#if defined(CONFIG_X11) || defined(CONFIG_GBM) || defined(WIN32)
EGLDisplay qemu_egl_get_display(EGLNativeDisplayType native,
EGLenum platform);
#endif
#if defined(CONFIG_X11) || defined(CONFIG_GBM)
int qemu_egl_init_dpy_x11(EGLNativeDisplayType dpy, DisplayGLMode mode);
int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, DisplayGLMode mode);
#endif
#ifdef WIN32
int qemu_egl_init_dpy_win32(EGLNativeDisplayType dpy, DisplayGLMode mode);
#endif
EGLContext qemu_egl_init_ctx(void);
bool qemu_egl_has_dmabuf(void);
bool egl_init(const char *rendernode, DisplayGLMode mode, Error **errp);
void egl_cleanup(void);
const char *qemu_egl_get_error_string(void);
#endif /* EGL_HELPERS_H */