[mutter/gbsneto/sharing-is-good] cogl/gl: Move shared functions to shared file
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/sharing-is-good] cogl/gl: Move shared functions to shared file
- Date: Thu, 26 Mar 2020 21:34:58 +0000 (UTC)
commit 1e1040ad3730bd0cc730dbbcb9ad1df284e554a4
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Mar 26 18:13:51 2020 -0300
cogl/gl: Move shared functions to shared file
Cogl shares some GL functions between the GLES and the big
GL drivers. Namely, it shares _cogl_driver_gl_context_init
and _cogl_driver_gl_context_deinit between these two drivers.
The plot twist is: even though these functions are shared and
their prototypes are in cogl-util-gl-private.h, they're actually
implemented inside cogl-driver-gl.c, which is strictly only
about the big GL driver.
This is problematic when building Mutter on ARM v7, where we
need to disable OpenGL, but keep GLES enabled.
Fix this by moving the shared GL functions to a shared GL file.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1151
cogl/cogl/driver/gl/cogl-pipeline-opengl-private.h | 15 +++++++
cogl/cogl/driver/gl/cogl-pipeline-opengl.c | 15 -------
cogl/cogl/driver/gl/cogl-util-gl.c | 51 ++++++++++++++++++++++
cogl/cogl/driver/gl/gl/cogl-driver-gl.c | 51 ----------------------
4 files changed, 66 insertions(+), 66 deletions(-)
---
diff --git a/cogl/cogl/driver/gl/cogl-pipeline-opengl-private.h
b/cogl/cogl/driver/gl/cogl-pipeline-opengl-private.h
index afcb4460e..debeb7749 100644
--- a/cogl/cogl/driver/gl/cogl-pipeline-opengl-private.h
+++ b/cogl/cogl/driver/gl/cogl-pipeline-opengl-private.h
@@ -37,6 +37,21 @@
#include "cogl-pipeline-private.h"
#include "cogl-matrix-stack.h"
+/*
+ * GL/GLES compatability defines for pipeline thingies:
+ */
+
+/* These aren't defined in the GLES headers */
+#ifndef GL_POINT_SPRITE
+#define GL_POINT_SPRITE 0x8861
+#endif
+#ifndef GL_COORD_REPLACE
+#define GL_COORD_REPLACE 0x8862
+#endif
+#ifndef GL_CLAMP_TO_BORDER
+#define GL_CLAMP_TO_BORDER 0x812d
+#endif
+
/*
* cogl-pipeline.c owns the GPU's texture unit state so we have some
* private structures for describing the current state of a texture
diff --git a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c
index 44a968a2c..9e21c76d2 100644
--- a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c
+++ b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c
@@ -50,21 +50,6 @@
#include <glib.h>
#include <string.h>
-/*
- * GL/GLES compatability defines for pipeline thingies:
- */
-
-/* These aren't defined in the GLES headers */
-#ifndef GL_POINT_SPRITE
-#define GL_POINT_SPRITE 0x8861
-#endif
-#ifndef GL_COORD_REPLACE
-#define GL_COORD_REPLACE 0x8862
-#endif
-#ifndef GL_CLAMP_TO_BORDER
-#define GL_CLAMP_TO_BORDER 0x812d
-#endif
-
static void
texture_unit_init (CoglContext *ctx,
CoglTextureUnit *unit,
diff --git a/cogl/cogl/driver/gl/cogl-util-gl.c b/cogl/cogl/driver/gl/cogl-util-gl.c
index 7939deabc..92c9784dc 100644
--- a/cogl/cogl/driver/gl/cogl-util-gl.c
+++ b/cogl/cogl/driver/gl/cogl-util-gl.c
@@ -34,6 +34,7 @@
#include "cogl-types.h"
#include "cogl-context-private.h"
+#include "driver/gl/cogl-pipeline-opengl-private.h"
#include "driver/gl/cogl-util-gl-private.h"
#ifdef COGL_GL_DEBUG
@@ -74,6 +75,56 @@ _cogl_gl_error_to_string (GLenum error_code)
}
#endif /* COGL_GL_DEBUG */
+gboolean
+_cogl_driver_gl_context_init (CoglContext *context,
+ GError **error)
+{
+ context->texture_units =
+ g_array_new (FALSE, FALSE, sizeof (CoglTextureUnit));
+
+ /* See cogl-pipeline.c for more details about why we leave texture unit 1
+ * active by default... */
+ context->active_texture_unit = 1;
+ GE (context, glActiveTexture (GL_TEXTURE1));
+
+ if ((context->driver == COGL_DRIVER_GL3))
+ {
+ GLuint vertex_array;
+
+ /* In a forward compatible context, GL 3 doesn't support rendering
+ * using the default vertex array object. Cogl doesn't use vertex
+ * array objects yet so for now we just create a dummy array
+ * object that we will use as our own default object. Eventually
+ * it could be good to attach the vertex array objects to
+ * CoglPrimitives */
+ context->glGenVertexArrays (1, &vertex_array);
+ context->glBindVertexArray (vertex_array);
+ }
+
+ /* As far as I can tell, GL_POINT_SPRITE doesn't have any effect
+ unless GL_COORD_REPLACE is enabled for an individual layer.
+ Therefore it seems like it should be ok to just leave it enabled
+ all the time instead of having to have a set property on each
+ pipeline to track whether any layers have point sprite coords
+ enabled. We don't need to do this for GL3 or GLES2 because point
+ sprites are handled using a builtin varying in the shader. */
+ if (context->driver == COGL_DRIVER_GL)
+ GE (context, glEnable (GL_POINT_SPRITE));
+
+ /* There's no enable for this in GLES2, it's always on */
+ if (context->driver == COGL_DRIVER_GL ||
+ context->driver == COGL_DRIVER_GL3)
+ GE (context, glEnable (GL_PROGRAM_POINT_SIZE) );
+
+ return TRUE;
+}
+
+void
+_cogl_driver_gl_context_deinit (CoglContext *context)
+{
+ _cogl_destroy_texture_units (context);
+}
+
GLenum
_cogl_gl_util_get_error (CoglContext *ctx)
{
diff --git a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
index f1b748118..6e8e19818 100644
--- a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
+++ b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
@@ -42,57 +42,6 @@
#include "driver/gl/cogl-attribute-gl-private.h"
#include "driver/gl/cogl-clip-stack-gl-private.h"
#include "driver/gl/cogl-buffer-gl-private.h"
-#include "driver/gl/cogl-pipeline-opengl-private.h"
-
-gboolean
-_cogl_driver_gl_context_init (CoglContext *context,
- GError **error)
-{
- context->texture_units =
- g_array_new (FALSE, FALSE, sizeof (CoglTextureUnit));
-
- /* See cogl-pipeline.c for more details about why we leave texture unit 1
- * active by default... */
- context->active_texture_unit = 1;
- GE (context, glActiveTexture (GL_TEXTURE1));
-
- if ((context->driver == COGL_DRIVER_GL3))
- {
- GLuint vertex_array;
-
- /* In a forward compatible context, GL 3 doesn't support rendering
- * using the default vertex array object. Cogl doesn't use vertex
- * array objects yet so for now we just create a dummy array
- * object that we will use as our own default object. Eventually
- * it could be good to attach the vertex array objects to
- * CoglPrimitives */
- context->glGenVertexArrays (1, &vertex_array);
- context->glBindVertexArray (vertex_array);
- }
-
- /* As far as I can tell, GL_POINT_SPRITE doesn't have any effect
- unless GL_COORD_REPLACE is enabled for an individual layer.
- Therefore it seems like it should be ok to just leave it enabled
- all the time instead of having to have a set property on each
- pipeline to track whether any layers have point sprite coords
- enabled. We don't need to do this for GL3 or GLES2 because point
- sprites are handled using a builtin varying in the shader. */
- if (context->driver == COGL_DRIVER_GL)
- GE (context, glEnable (GL_POINT_SPRITE));
-
- /* There's no enable for this in GLES2, it's always on */
- if (context->driver == COGL_DRIVER_GL ||
- context->driver == COGL_DRIVER_GL3)
- GE (context, glEnable (GL_PROGRAM_POINT_SIZE) );
-
- return TRUE;
-}
-
-void
-_cogl_driver_gl_context_deinit (CoglContext *context)
-{
- _cogl_destroy_texture_units (context);
-}
static gboolean
_cogl_driver_pixel_format_from_gl_internal (CoglContext *context,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]