OpenGL: drop OSMesa backend

Fix #1618
This commit is contained in:
李通洲
2025-03-14 15:30:52 +08:00
parent 3227e934de
commit 3cd7c6c916
10 changed files with 15 additions and 104 deletions
-3
View File
@@ -227,9 +227,6 @@ void ffListFeatures(void)
#if FF_HAVE_GLX
"glx\n"
#endif
#if FF_HAVE_OSMESA
"osmesa\n"
#endif
#if FF_HAVE_OPENCL
"opencl\n"
#endif
+2 -3
View File
@@ -1419,10 +1419,9 @@
"arg": {
"type": "enum",
"enum": {
"auto": "Auto detection",
"auto": "Prefer EGL on *nix; prefer platform specific implementation on others",
"egl": "EGL",
"glx": "GLX",
"osmesa": "OSMesa"
"glx": "GLX (*nix only)"
},
"default": "auto"
}
+1 -73
View File
@@ -11,7 +11,7 @@
#endif
#endif
#if defined(FF_HAVE_EGL) || defined(FF_HAVE_GLX) || defined(FF_HAVE_OSMESA)
#if defined(FF_HAVE_EGL) || defined(FF_HAVE_GLX)
#define FF_HAVE_GL 1
#include "common/library.h"
@@ -155,66 +155,6 @@ static const char* detectByGlx(FFOpenGLResult* result)
#endif //FF_HAVE_GLX
#ifdef FF_HAVE_OSMESA
#if __has_include(<GL/osmesa.h>)
#include <GL/osmesa.h>
#else
#include <mesa/osmesa.h> // for sunos
#endif
typedef struct OSMesaData
{
FF_LIBRARY_SYMBOL(glGetString)
FF_LIBRARY_SYMBOL(OSMesaGetProcAddress)
FF_LIBRARY_SYMBOL(OSMesaCreateContext)
FF_LIBRARY_SYMBOL(OSMesaMakeCurrent)
FF_LIBRARY_SYMBOL(OSMesaDestroyContext)
OSMesaContext context;
} OSMesaData;
static const char* osMesaHandleContext(FFOpenGLResult* result, OSMesaData* data)
{
unsigned char buffer[FF_OPENGL_BUFFER_WIDTH * FF_OPENGL_BUFFER_HEIGHT * sizeof(uint32_t)]; // 4 bytes per pixel (RGBA)
if(data->ffOSMesaMakeCurrent(data->context, buffer, GL_UNSIGNED_BYTE, FF_OPENGL_BUFFER_WIDTH, FF_OPENGL_BUFFER_HEIGHT) != GL_TRUE)
return "OSMesaMakeCurrent returned GL_FALSE";
ffOpenGLHandleResult(result, data->ffglGetString);
ffStrbufSetF(&result->library, "OSMesa %d.%d.%d", OSMESA_MAJOR_VERSION, OSMESA_MINOR_VERSION, OSMESA_PATCH_VERSION);
return NULL;
}
static const char* osMesaHandleData(FFOpenGLResult* result, OSMesaData* data)
{
data->ffglGetString = (void*) data->ffOSMesaGetProcAddress("glGetString");
if(data->ffglGetString == NULL)
return "OSMesaGetProcAddress(glGetString) returned NULL";
data->context = data->ffOSMesaCreateContext(OSMESA_RGBA, NULL);
if(data->context == NULL)
return "OSMesaCreateContext returned NULL";
const char* error = osMesaHandleContext(result, data);
data->ffOSMesaDestroyContext(data->context);
return error;
}
static const char* detectByOsMesa(FFOpenGLResult* result)
{
OSMesaData data;
FF_LIBRARY_LOAD(osmesa, "dlopen osmesa failed", "libOSMesa" FF_LIBRARY_EXTENSION, 8);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(osmesa, data, OSMesaGetProcAddress);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(osmesa, data, OSMesaCreateContext);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(osmesa, data, OSMesaMakeCurrent);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(osmesa, data, OSMesaDestroyContext);
return osMesaHandleData(result, &data);
}
#endif //FF_HAVE_OSMESA
const char* ffDetectOpenGL(FFOpenGLOptions* options, FFOpenGLResult* result)
{
#if FF_HAVE_GL
@@ -238,15 +178,6 @@ const char* ffDetectOpenGL(FFOpenGLOptions* options, FFOpenGLResult* result)
#endif
}
if(options->library == FF_OPENGL_LIBRARY_OSMESA)
{
#ifdef FF_HAVE_OSMESA
return detectByOsMesa(result);
#else
return "fastfetch was compiled without osmesa support";
#endif
}
const char* error = ""; // not NULL dummy value
#ifdef FF_HAVE_EGL
@@ -259,9 +190,6 @@ const char* ffDetectOpenGL(FFOpenGLOptions* options, FFOpenGLResult* result)
error = detectByGlx(result);
#endif
//We don't use osmesa in auto mode here, because it is a software implementation,
//that doesn't reflect the opengl supported by the hardware
return error;
#else
-5
View File
@@ -56,7 +56,6 @@ bool ffParseOpenGLCommandOptions(FFOpenGLOptions* options, const char* key, cons
{ "auto", FF_OPENGL_LIBRARY_AUTO },
{ "egl", FF_OPENGL_LIBRARY_EGL },
{ "glx", FF_OPENGL_LIBRARY_GLX },
{ "osmesa", FF_OPENGL_LIBRARY_OSMESA },
{}
});
return true;
@@ -85,7 +84,6 @@ void ffParseOpenGLJsonObject(FFOpenGLOptions* options, yyjson_val* module)
{ "auto", FF_OPENGL_LIBRARY_AUTO },
{ "egl", FF_OPENGL_LIBRARY_EGL },
{ "glx", FF_OPENGL_LIBRARY_GLX },
{ "osmesa", FF_OPENGL_LIBRARY_OSMESA },
{},
});
if (error)
@@ -119,9 +117,6 @@ void ffGenerateOpenGLJsonConfig(FFOpenGLOptions* options, yyjson_mut_doc* doc, y
case FF_OPENGL_LIBRARY_GLX:
yyjson_mut_obj_add_str(doc, module, "library", "glx");
break;
case FF_OPENGL_LIBRARY_OSMESA:
yyjson_mut_obj_add_str(doc, module, "library", "osmesa");
break;
}
}
}
-1
View File
@@ -9,7 +9,6 @@ typedef enum __attribute__((__packed__)) FFOpenGLLibrary
FF_OPENGL_LIBRARY_AUTO,
FF_OPENGL_LIBRARY_EGL,
FF_OPENGL_LIBRARY_GLX,
FF_OPENGL_LIBRARY_OSMESA
} FFOpenGLLibrary;
typedef struct FFOpenGLOptions