gsk: Check for half float support

The GL renderer currently relies on half float support
in vertex buffers, so check that we have it.

Related: #4894
This commit is contained in:
Matthias Clasen 2022-05-05 13:09:26 -04:00
parent 2f9387630f
commit f2436eaf7b

View File

@ -24,6 +24,7 @@
#include <gdk/gdkdisplayprivate.h> #include <gdk/gdkdisplayprivate.h>
#include <gdk/gdkglcontextprivate.h> #include <gdk/gdkglcontextprivate.h>
#include <gdk/gdksurfaceprivate.h> #include <gdk/gdksurfaceprivate.h>
#include <gdk/gdkintl.h>
#include <gsk/gskdebugprivate.h> #include <gsk/gskdebugprivate.h>
#include <gsk/gskrendererprivate.h> #include <gsk/gskrendererprivate.h>
#include <gsk/gskrendernodeprivate.h> #include <gsk/gskrendernodeprivate.h>
@ -93,6 +94,7 @@ gsk_gl_renderer_realize (GskRenderer *renderer,
GdkDisplay *display; GdkDisplay *display;
gboolean ret = FALSE; gboolean ret = FALSE;
gboolean debug_shaders = FALSE; gboolean debug_shaders = FALSE;
GdkGLAPI api;
if (self->context != NULL) if (self->context != NULL)
return TRUE; return TRUE;
@ -115,6 +117,24 @@ gsk_gl_renderer_realize (GskRenderer *renderer,
if (!context || !gdk_gl_context_realize (context, error)) if (!context || !gdk_gl_context_realize (context, error))
goto failure; goto failure;
api = gdk_gl_context_get_api (context);
if (api == GDK_GL_API_GLES)
{
gdk_gl_context_make_current (context);
if (!gdk_gl_context_has_vertex_half_float (context))
{
int major, minor;
gdk_gl_context_get_version (context, &major, &minor);
g_set_error (error,
GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE,
_("This GLES %d.%d implementation does not support half-float vertex data"),
major, minor);
goto failure;
}
}
#ifdef G_ENABLE_DEBUG #ifdef G_ENABLE_DEBUG
if (GSK_RENDERER_DEBUG_CHECK (GSK_RENDERER (self), SHADERS)) if (GSK_RENDERER_DEBUG_CHECK (GSK_RENDERER (self), SHADERS))
debug_shaders = TRUE; debug_shaders = TRUE;