[gtk/wip.win32.fixes: 12/13] gskglcompiler.c: Set version as appropriate for GLES 3.0+ contexts
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip.win32.fixes: 12/13] gskglcompiler.c: Set version as appropriate for GLES 3.0+ contexts
- Date: Thu, 2 Dec 2021 03:31:08 +0000 (UTC)
commit 0ab3ebbeddf4fa6620110ede772a538978198aa3
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Thu Nov 25 16:09:50 2021 +0800
gskglcompiler.c: Set version as appropriate for GLES 3.0+ contexts
Instead of just using "300 es" as the shader target version for libANGLE
GLES contexts, just apply that whenever we are using GLES 3.0+ contexts.
Also simplify the code by making ->glsl_version a const char* and make
the existing macros defined appropriately, and add a new macro for the
"300 es" version string.
gsk/gl/gskglcompiler.c | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
---
diff --git a/gsk/gl/gskglcompiler.c b/gsk/gl/gskglcompiler.c
index 30f2ae585d..70a2da24ad 100644
--- a/gsk/gl/gskglcompiler.c
+++ b/gsk/gl/gskglcompiler.c
@@ -28,10 +28,11 @@
#include "gskglcompilerprivate.h"
#include "gskglprogramprivate.h"
-#define SHADER_VERSION_GLES 100
-#define SHADER_VERSION_GL2_LEGACY 110
-#define SHADER_VERSION_GL3_LEGACY 130
-#define SHADER_VERSION_GL3 150
+#define SHADER_VERSION_GLES "100"
+#define SHADER_VERSION_GLES3 "300 es"
+#define SHADER_VERSION_GL2_LEGACY "110"
+#define SHADER_VERSION_GL3_LEGACY "130"
+#define SHADER_VERSION_GL3 "150"
struct _GskGLCompiler
{
@@ -49,11 +50,11 @@ struct _GskGLCompiler
GArray *attrib_locations;
- int glsl_version;
+ const char *glsl_version;
guint gl3 : 1;
guint gles : 1;
- guint force_glsl_300es : 1;
+ guint use_glsl_300es : 1;
guint legacy : 1;
guint debug_shaders : 1;
};
@@ -99,7 +100,7 @@ gsk_gl_compiler_class_init (GskGLCompilerClass *klass)
static void
gsk_gl_compiler_init (GskGLCompiler *self)
{
- self->glsl_version = 150;
+ self->glsl_version = "150";
self->attrib_locations = g_array_new (FALSE, FALSE, sizeof (GskGLProgramAttrib));
self->all_preamble = g_bytes_ref (empty_bytes);
self->vertex_preamble = g_bytes_ref (empty_bytes);
@@ -128,10 +129,13 @@ gsk_gl_compiler_new (GskGLDriver *driver,
if (gdk_gl_context_get_use_es (context))
{
- /* for libANGLE to work with our shaders, we must use 300 es as our shader version */
- self->force_glsl_300es =
- (strncmp ("ANGLE ", (const char *) glGetString (GL_RENDERER), 6) == 0);
- self->glsl_version = SHADER_VERSION_GLES;
+ int maj, min;
+
+ /* for OpenGL/ES 3.0+, use "300 es" as our shader version */
+ gdk_gl_context_get_version (context, &maj, &min);
+ self->use_glsl_300es = (maj >= 3);
+
+ self->glsl_version = self->use_glsl_300es ? SHADER_VERSION_GLES3 : SHADER_VERSION_GLES;
self->gles = TRUE;
}
else if (gdk_gl_context_is_legacy (context))
@@ -551,10 +555,7 @@ gsk_gl_compiler_compile (GskGLCompiler *self,
gsk_gl_command_queue_make_current (self->driver->command_queue);
- if (self->force_glsl_300es)
- g_snprintf (version, sizeof version, "#version 300 es\n");
- else
- g_snprintf (version, sizeof version, "#version %d\n", self->glsl_version);
+ g_snprintf (version, sizeof version, "#version %s\n", self->glsl_version);
if (self->debug_shaders)
debug = "#define GSK_DEBUG 1\n";
@@ -564,7 +565,7 @@ gsk_gl_compiler_compile (GskGLCompiler *self,
if (self->gles)
{
- if (self->force_glsl_300es)
+ if (self->use_glsl_300es)
gles = "#define GSK_GLES3 1\n";
else
gles = "#define GSK_GLES 1\n";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]