Merge branch 'gles-vao' into 'main'

glcontext: Add api to check for vertex arrays

Closes #6173

See merge request GNOME/gtk!6501
This commit is contained in:
Matthias Clasen 2023-10-20 10:52:53 +00:00
commit f4a67ebcbb
3 changed files with 26 additions and 2 deletions

View File

@ -1867,6 +1867,7 @@ gdk_gl_context_has_sync (GdkGLContext *self)
return priv->has_sync;
}
/* Return if GL_BGRA works with glTexImage2D */
gboolean
gdk_gl_context_has_bgra (GdkGLContext *self)
{
@ -1875,6 +1876,27 @@ gdk_gl_context_has_bgra (GdkGLContext *self)
return priv->has_bgra;
}
/* Return if glGenVertexArrays, glBindVertexArray and glDeleteVertexArrays
* can be used
*/
gboolean
gdk_gl_context_has_vertex_arrays (GdkGLContext *self)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (self);
switch (priv->api)
{
case GDK_GL_API_GL:
return TRUE;
case GDK_GL_API_GLES:
return gdk_gl_version_get_major (&priv->gl_version) >= 3;
default:
g_return_val_if_reached (FALSE);
}
}
/* This is currently private! */
/* When using GL/ES, don't flip the 'R' and 'B' bits on Windows/ANGLE for glReadPixels() */
gboolean

View File

@ -159,6 +159,8 @@ gboolean gdk_gl_context_has_sync (GdkGLContext
gboolean gdk_gl_context_has_bgra (GdkGLContext *self) G_GNUC_PURE;
gboolean gdk_gl_context_has_vertex_arrays (GdkGLContext *self) G_GNUC_PURE;
double gdk_gl_context_get_scale (GdkGLContext *self);
G_END_DECLS

View File

@ -1070,7 +1070,7 @@ gsk_gl_command_queue_execute (GskGLCommandQueue *self,
glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glBlendEquation (GL_FUNC_ADD);
if (!gdk_gl_context_get_use_es (self->context))
if (gdk_gl_context_has_vertex_arrays (self->context))
{
glGenVertexArrays (1, &vao_id);
glBindVertexArray (vao_id);
@ -1257,7 +1257,7 @@ gsk_gl_command_queue_execute (GskGLCommandQueue *self,
}
glDeleteBuffers (1, &vbo_id);
if (!gdk_gl_context_get_use_es (self->context))
if (gdk_gl_context_has_vertex_arrays (self->context))
glDeleteVertexArrays (1, &vao_id);
gdk_profiler_set_int_counter (self->metrics.n_binds, n_binds);