Merge pull request #2 from Vera-Firefly/test-3

zink renderer
This commit is contained in:
Vera-Firefly 2023-09-08 18:56:48 +08:00 committed by GitHub
commit 3a738c0896
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 73 deletions

View File

@ -36,7 +36,6 @@ GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
if (ctxconfig->source != GLFW_NATIVE_CONTEXT_API &&
ctxconfig->source != GLFW_EGL_CONTEXT_API &&
ctxconfig->source != GLFW_OSMESA_CONTEXT_API_1 &&
ctxconfig->source != GLFW_OSMESA_CONTEXT_API)
{
_glfwInputError(GLFW_INVALID_ENUM,

View File

@ -330,21 +330,13 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
return GLFW_FALSE;
}
else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API_1)
else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
{
const char *renderer = getenv("LIBGL_STRING");
if (strcmp(renderer, "VirGLRenderer") == 0) {
if (!_glfwInitEGL())
return GLFW_FALSE;
}
if (!_glfwInitOSMesa1())
return GLFW_FALSE;
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
return GLFW_FALSE;
}
else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
{
const char *renderer = getenv("LIBGL_STRING");
if (strcmp(renderer, "Zink") == 0) {
if (!_glfwInitEGL())
return GLFW_FALSE;

View File

@ -989,7 +989,6 @@ extern "C" {
* [attribute](@ref GLFW_CONTEXT_CREATION_API_attrib).
*/
#define GLFW_CONTEXT_CREATION_API 0x0002200B
#define GLFW_CONTEXT_CREATION_API_1 0x0002200D
/*! @brief Window content area scaling window
* [window hint](@ref GLFW_SCALE_TO_MONITOR).
*/
@ -1045,7 +1044,6 @@ extern "C" {
#define GLFW_NATIVE_CONTEXT_API 0x00036001
#define GLFW_EGL_CONTEXT_API 0x00036002
#define GLFW_OSMESA_CONTEXT_API 0x00036003
#define GLFW_OSMESA_CONTEXT_API_1 0x00036007
/*! @defgroup shapes Standard cursor shapes
* @brief Standard system cursor shapes.
@ -1070,7 +1068,6 @@ extern "C" {
* The crosshair shape.
*/
#define GLFW_CROSSHAIR_CURSOR 0x00036003
#define GLFW_CROSSHAIR_CURSOR_1 0x00036007
/*! @brief The hand shape.
*
* The hand shape.

View File

@ -444,7 +444,6 @@ GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape)
if (shape != GLFW_ARROW_CURSOR &&
shape != GLFW_IBEAM_CURSOR &&
shape != GLFW_CROSSHAIR_CURSOR &&
shape != GLFW_CROSSHAIR_CURSOR_1 &&
shape != GLFW_HAND_CURSOR &&
shape != GLFW_HRESIZE_CURSOR &&
shape != GLFW_VRESIZE_CURSOR)

View File

@ -151,12 +151,18 @@ static int extensionSupportedOSMesa(const char* extension)
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
GLFWbool _glfwInitOSMesa1(void)
GLFWbool _glfwInitOSMesa(void)
{
if (_glfw.osmesa.handle)
return GLFW_TRUE;
const char *renderer = getenv("LIBGL_STRING");
if (strcmp(renderer, "VirGLRenderer") == 0) {
_glfw.osmesa.handle = _glfw_dlopen("libOSMesa_81.so");
} else if (strcmp(renderer, "Zink") == 0) {
_glfw.osmesa.handle = _glfw_dlopen("libOSMesa_8.so");
}
if (!_glfw.osmesa.handle)
{
@ -181,7 +187,6 @@ GLFWbool _glfwInitOSMesa1(void)
_glfw.osmesa.GetProcAddress = (PFN_OSMesaGetProcAddress)
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetProcAddress");
const char *renderer = getenv("LIBGL_STRING");
if (strcmp(renderer, "VirGLRenderer") == 0) {
char* fileName = calloc(1, 1024);
sprintf(fileName, "%s/libvirgl_test_server.so", getenv("FCL_NATIVEDIR"));
@ -217,54 +222,6 @@ GLFWbool _glfwInitOSMesa1(void)
return GLFW_TRUE;
}
GLFWbool _glfwInitOSMesa(void)
{
if (_glfw.osmesa.handle)
return GLFW_TRUE;
_glfw.osmesa.handle = _glfw_dlopen("libOSMesa_8.so");
if (!_glfw.osmesa.handle)
{
_glfwInputError(GLFW_API_UNAVAILABLE, "OSMesa: Library not found");
return GLFW_FALSE;
}
_glfw.osmesa.CreateContext = (PFN_OSMesaCreateContext)
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaCreateContext");
_glfw.osmesa.GetCurrentContext = (PFN_OSMesaGetCurrentContext)
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetCurrentContext");
_glfw.osmesa.DestroyContext = (PFN_OSMesaDestroyContext)
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaDestroyContext");
_glfw.osmesa.PixelStore = (PFN_OSMesaPixelStore)
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaPixelStore");
_glfw.osmesa.MakeCurrent = (PFN_OSMesaMakeCurrent)
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaMakeCurrent");
_glfw.osmesa.GetColorBuffer = (PFN_OSMesaGetColorBuffer)
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetColorBuffer");
_glfw.osmesa.GetDepthBuffer = (PFN_OSMesaGetDepthBuffer)
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetDepthBuffer");
_glfw.osmesa.GetProcAddress = (PFN_OSMesaGetProcAddress)
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetProcAddress");
const char *renderer = getenv("LIBGL_STRING");
if (!_glfw.osmesa.CreateContext ||
!_glfw.osmesa.GetCurrentContext ||
!_glfw.osmesa.DestroyContext ||
!_glfw.osmesa.PixelStore ||
!_glfw.osmesa.MakeCurrent ||
!_glfw.osmesa.GetColorBuffer ||
!_glfw.osmesa.GetDepthBuffer ||
!_glfw.osmesa.GetProcAddress)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "OSMesa: Failed to load required entry points");
_glfwTerminateOSMesa();
return GLFW_FALSE;
}
return GLFW_TRUE;
}
void _glfwTerminateOSMesa(void)
{
if (_glfw.osmesa.handle)

View File

@ -229,8 +229,7 @@ void glfwDefaultWindowHints(void)
// The default is OpenGL with minimum version 1.0
memset(&_glfw.hints.context, 0, sizeof(_glfw.hints.context));
_glfw.hints.context.client = GLFW_OPENGL_API;
_glfw.hints.context.source = strcmp(getenv("LIBGL_NAME"), "libOSMesa_81.so") == 0 ? GLFW_OSMESA_CONTEXT_API_1 : GLFW_NATIVE_CONTEXT_API;
_glfw.hints.context.source = strcmp(getenv("LIBGL_NAME"), "libOSMesa_8.so") == 0 ? GLFW_OSMESA_CONTEXT_API : GLFW_NATIVE_CONTEXT_API;
_glfw.hints.context.source = (strcmp(getenv("LIBGL_NAME"), "libOSMesa_8.so") == 0 || strcmp(getenv("LIBGL_NAME"), "libOSMesa_81.so") == 0) ? GLFW_OSMESA_CONTEXT_API : GLFW_NATIVE_CONTEXT_API;
_glfw.hints.context.major = 1;
_glfw.hints.context.minor = 0;
@ -355,11 +354,8 @@ GLFWAPI void glfwWindowHint(int hint, int value)
case GLFW_CLIENT_API:
_glfw.hints.context.client = value;
return;
case GLFW_CONTEXT_CREATION_API_1:
_glfw.hints.context.source = strcmp(getenv("LIBGL_NAME"), "libOSMesa_81.so") == 0 ? GLFW_OSMESA_CONTEXT_API_1 : value;
return;
case GLFW_CONTEXT_CREATION_API:
_glfw.hints.context.source = strcmp(getenv("LIBGL_NAME"), "libOSMesa_8.so") == 0 ? GLFW_OSMESA_CONTEXT_API : value;
_glfw.hints.context.source = (strcmp(getenv("LIBGL_NAME"), "libOSMesa_8.so") == 0 || strcmp(getenv("LIBGL_NAME"), "libOSMesa_81.so") == 0) ? GLFW_OSMESA_CONTEXT_API : value;
return;
case GLFW_CONTEXT_VERSION_MAJOR:
_glfw.hints.context.major = value;
@ -811,8 +807,6 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
return window->autoIconify;
case GLFW_CLIENT_API:
return window->context.client;
case GLFW_CONTEXT_CREATION_API_1:
return window->context.source;
case GLFW_CONTEXT_CREATION_API:
return window->context.source;
case GLFW_CONTEXT_VERSION_MAJOR: