Merge pull request #1011 from absolutelynothelix/decouple-glx-and-egl-backends

This commit is contained in:
Yuxuan Shui 2023-06-19 10:19:23 +01:00 committed by GitHub
commit b85272312a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 15 deletions

View File

@ -67,7 +67,7 @@ const char *eglGetErrorString(EGLint error) {
}
/**
* Free a glx_texture_t.
* Free a gl_texture_t.
*/
static void egl_release_image(backend_t *base, struct gl_texture *tex) {
struct egl_data *gd = (void *)base;
@ -88,14 +88,14 @@ static void egl_release_image(backend_t *base, struct gl_texture *tex) {
}
/**
* Destroy GLX related resources.
* Destroy EGL related resources.
*/
void egl_deinit(backend_t *base) {
struct egl_data *gd = (void *)base;
gl_deinit(&gd->gl);
// Destroy GLX context
// Destroy EGL context
if (gd->ctx != EGL_NO_CONTEXT) {
eglMakeCurrent(gd->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroyContext(gd->display, gd->ctx);
@ -225,12 +225,12 @@ static backend_t *egl_init(session_t *ps) {
gd->ctx = eglCreateContext(gd->display, config, NULL, NULL);
if (gd->ctx == EGL_NO_CONTEXT) {
log_error("Failed to get GLX context.");
log_error("Failed to get EGL context.");
goto end;
}
if (!eglMakeCurrent(gd->display, gd->target_win, gd->target_win, gd->ctx)) {
log_error("Failed to attach GLX context.");
log_error("Failed to attach EGL context.");
goto end;
}
@ -423,7 +423,7 @@ struct backend_operations egl_ops = {
PFNEGLGETDISPLAYDRIVERNAMEPROC eglGetDisplayDriverName;
/**
* Check if a GLX extension exists.
* Check if a EGL extension exists.
*/
static inline bool egl_has_extension(EGLDisplay dpy, const char *ext) {
const char *egl_exts = eglQueryString(dpy, EGL_EXTENSIONS);

View File

@ -1,13 +1,11 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) Yuxuan Shui <yshuiv7@gmail.com>
#pragma once
#include <stdbool.h>
// Older version of glx.h defines function prototypes for these extensions...
// Rename them to avoid conflicts
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GL/gl.h>
#include <GL/glext.h>
#include <stdbool.h>
#include <xcb/render.h>
#include <xcb/xcb.h>

View File

@ -808,7 +808,7 @@ bool gl_init(struct gl_data *gd, session_t *ps) {
glGenQueries(2, gd->frame_timing);
gd->current_frame_timing = 0;
// Initialize GLX data structure
// Initialize GL data structure
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);

View File

@ -77,7 +77,7 @@ typedef struct {
GLint color_loc;
} gl_fill_shader_t;
/// @brief Wrapper of a binded GLX texture.
/// @brief Wrapper of a binded GL texture.
struct gl_texture {
int refcount;
bool has_alpha;
@ -214,7 +214,7 @@ static inline const char *gl_get_err_str(GLenum err) {
}
/**
* Check for GLX error.
* Check for GL error.
*
* http://blog.nobel-joergensen.com/2013/01/29/debugging-opengl-using-glgeterror/
*/
@ -225,10 +225,10 @@ static inline void gl_check_err_(const char *func, int line) {
const char *errtext = gl_get_err_str(err);
if (errtext) {
log_printf(tls_logger, LOG_LEVEL_ERROR, func,
"GLX error at line %d: %s", line, errtext);
"GL error at line %d: %s", line, errtext);
} else {
log_printf(tls_logger, LOG_LEVEL_ERROR, func,
"GLX error at line %d: %d", line, err);
"GL error at line %d: %d", line, err);
}
}
}
@ -265,7 +265,7 @@ static inline bool gl_check_fb_complete_(const char *func, int line, GLenum fb)
#define gl_check_fb_complete(fb) gl_check_fb_complete_(__func__, __LINE__, (fb))
/**
* Check if a GLX extension exists.
* Check if a GL extension exists.
*/
static inline bool gl_has_extension(const char *ext) {
int nexts = 0;