From 8021d3e2ebeced1921a973b325275c3e000655a2 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Fri, 23 Jul 2010 17:44:53 +0100 Subject: [PATCH] cogl-shader: Store the CoglShaderType in CoglShader Instead of having to query GL and translate the GL enum into a CoglShaderType each time cogl_shader_get_type is called we now keep track of the type in CoglShader. --- clutter/cogl/cogl/driver/gl/cogl-shader-private.h | 1 + clutter/cogl/cogl/driver/gl/cogl-shader.c | 14 ++------------ clutter/cogl/cogl/driver/gles/cogl-shader.c | 13 +------------ 3 files changed, 4 insertions(+), 24 deletions(-) diff --git a/clutter/cogl/cogl/driver/gl/cogl-shader-private.h b/clutter/cogl/cogl/driver/gl/cogl-shader-private.h index e80f20b..52faa23 100644 --- a/clutter/cogl/cogl/driver/gl/cogl-shader-private.h +++ b/clutter/cogl/cogl/driver/gl/cogl-shader-private.h @@ -32,6 +32,7 @@ struct _CoglShader { CoglHandleObject _parent; GLhandleARB gl_handle; + CoglShaderType type; }; CoglShader *_cogl_shader_pointer_from_handle (CoglHandle handle); diff --git a/clutter/cogl/cogl/driver/gl/cogl-shader.c b/clutter/cogl/cogl/driver/gl/cogl-shader.c index 8c07285..ae18a54 100644 --- a/clutter/cogl/cogl/driver/gl/cogl-shader.c +++ b/clutter/cogl/cogl/driver/gl/cogl-shader.c @@ -77,6 +77,7 @@ cogl_create_shader (CoglShaderType type) shader = g_slice_new (CoglShader); shader->gl_handle = glCreateShader (gl_type); + shader->type = type; return _cogl_shader_handle_new (shader); } @@ -132,7 +133,6 @@ cogl_shader_get_info_log (CoglHandle handle) CoglShaderType cogl_shader_get_type (CoglHandle handle) { - GLint type; CoglShader *shader; _COGL_GET_CONTEXT (ctx, COGL_SHADER_TYPE_VERTEX); @@ -144,17 +144,7 @@ cogl_shader_get_type (CoglHandle handle) } shader = _cogl_shader_pointer_from_handle (handle); - - GE (glGetShaderiv (shader->gl_handle, GL_SHADER_TYPE, &type)); - if (type == GL_VERTEX_SHADER) - return COGL_SHADER_TYPE_VERTEX; - else if (type == GL_FRAGMENT_SHADER) - return COGL_SHADER_TYPE_VERTEX; - else - { - g_warning ("Unexpected shader type 0x%08lX", (unsigned long)type); - return COGL_SHADER_TYPE_VERTEX; - } + return shader->type; } gboolean diff --git a/clutter/cogl/cogl/driver/gles/cogl-shader.c b/clutter/cogl/cogl/driver/gles/cogl-shader.c index a86104d..8410130 100644 --- a/clutter/cogl/cogl/driver/gles/cogl-shader.c +++ b/clutter/cogl/cogl/driver/gles/cogl-shader.c @@ -125,7 +125,6 @@ cogl_shader_get_info_log (CoglHandle handle) CoglShaderType cogl_shader_get_type (CoglHandle handle) { - GLint type; CoglShader *shader; if (!cogl_is_shader (handle)) @@ -135,17 +134,7 @@ cogl_shader_get_type (CoglHandle handle) } shader = _cogl_shader_pointer_from_handle (handle); - - GE (glGetShaderiv (shader->gl_handle, GL_SHADER_TYPE, &type)); - if (type == GL_VERTEX_SHADER) - return COGL_SHADER_TYPE_VERTEX; - else if (type == GL_FRAGMENT_SHADER) - return COGL_SHADER_TYPE_VERTEX; - else - { - g_warning ("Unexpected shader type 0x%08lX", (unsigned long)type); - return COGL_SHADER_TYPE_VERTEX; - } + return shader->type; } gboolean -- 2.7.4