[gtk/wip/otte/gles: 2/5] gl: Change gdk_gl_context_check_version()




commit 2caab68be9669366d6c55c3064f75796d2552e0b
Author: Benjamin Otte <otte redhat com>
Date:   Sat Dec 25 14:14:52 2021 +0100

    gl: Change gdk_gl_context_check_version()
    
    Instead of just passing major/minor, pass them twice, once for GL and
    once for GLES. This way, we don't need to check for GL and GLES
    separately.
    
    If something is supported unconditionally, passing 0/0 works fine.
    
    That said, I'd like to group the arguments somehow, because otherwise
    it's just a confusing list of numbers - but I have no idea how to do
    that.

 gdk/gdkglcontext.c         | 31 ++++++++++++++++++++++++-------
 gdk/gdkglcontextprivate.h  |  6 ++++--
 gsk/gl/gskglcommandqueue.c |  2 +-
 3 files changed, 29 insertions(+), 10 deletions(-)
---
diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
index f8af9275a0..042c30a41d 100644
--- a/gdk/gdkglcontext.c
+++ b/gdk/gdkglcontext.c
@@ -1003,16 +1003,33 @@ gdk_gl_context_set_required_version (GdkGLContext *context,
 }
 
 gboolean
-gdk_gl_context_check_version (GdkGLContext *context,
-                              int           required_major,
-                              int           required_minor)
+gdk_gl_context_check_version (GdkGLContext *self,
+                              int           required_gl_major,
+                              int           required_gl_minor,
+                              int           required_gles_major,
+                              int           required_gles_minor)
 {
-  GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
+  GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (self);
 
-  g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), FALSE);
-  g_return_val_if_fail (required_minor < 10, FALSE);
+  g_return_val_if_fail (GDK_IS_GL_CONTEXT (self), FALSE);
+  g_return_val_if_fail (required_gl_minor < 10, FALSE);
+  g_return_val_if_fail (required_gles_minor < 10, FALSE);
+
+  if (!gdk_gl_context_is_realized (self))
+    return FALSE;
 
-  return priv->gl_version >= required_major * 10 + required_minor;
+  switch (priv->api)
+    {
+    case GDK_GL_API_GL:
+      return priv->gl_version >= required_gl_major * 10 + required_gl_minor;
+
+    case GDK_GL_API_GLES:
+      return priv->gl_version >= required_gles_major * 10 + required_gles_minor;
+
+    default:
+      g_return_val_if_reached (FALSE);
+
+    }
 }
 
 /**
diff --git a/gdk/gdkglcontextprivate.h b/gdk/gdkglcontextprivate.h
index fccffdb013..ff11349b3e 100644
--- a/gdk/gdkglcontextprivate.h
+++ b/gdk/gdkglcontextprivate.h
@@ -111,8 +111,10 @@ void                    gdk_gl_context_set_is_legacy            (GdkGLContext
                                                                  gboolean         is_legacy);
 
 gboolean                gdk_gl_context_check_version            (GdkGLContext    *context,
-                                                                 int              required_major,
-                                                                 int              required_minor);
+                                                                 int              required_gl_major,
+                                                                 int              required_gl_minor,
+                                                                 int              required_gles_major,
+                                                                 int              required_gles_minor);
 
 gboolean                gdk_gl_context_has_unpack_subimage      (GdkGLContext    *context);
 void                    gdk_gl_context_push_debug_group         (GdkGLContext    *context,
diff --git a/gsk/gl/gskglcommandqueue.c b/gsk/gl/gskglcommandqueue.c
index 3c7762e6fc..3af8c1eb09 100644
--- a/gsk/gl/gskglcommandqueue.c
+++ b/gsk/gl/gskglcommandqueue.c
@@ -1396,7 +1396,7 @@ gsk_gl_command_queue_do_upload_texture (GskGLCommandQueue *self,
       glTexImage2D (GL_TEXTURE_2D, 0, gl_internalformat, width, height, 0, gl_format, gl_type, data);
     }
   else if (stride % bpp == 0 &&
-           (!use_es || gdk_gl_context_check_version (context, 3, 0) || gdk_gl_context_has_unpack_subimage 
(context)))
+           (gdk_gl_context_check_version (context, 0, 0, 3, 0) || gdk_gl_context_has_unpack_subimage 
(context)))
     {
       glPixelStorei (GL_UNPACK_ROW_LENGTH, stride / bpp);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]