[cogl/cogl-1.14] Don't set GL_TEXTURE_MAX_LEVEL on GLES



commit da7971f6be9d9dae3c28a70ae82b6bbce95e30c7
Author: Neil Roberts <neil linux intel com>
Date:   Thu Jan 24 11:44:31 2013 +0000

    Don't set GL_TEXTURE_MAX_LEVEL on GLES
    
    GL_TEXTURE_MAX_LEVEL is not supported on GLES so we can't set it. It
    looks like Mesa was letting us get away with this but on other drivers
    it may cause errors. The enum is not defined in the GLES headers so it
    was failing to compile unless the GL driver is also enabled.
    
    The test-texture-mipmap-get-set test is now marked as n/a on GLES2
    because it can't support limiting the sampled mipmaps.
    
    Reviewed-by: Robert Bragg <robert linux intel com>
    
    (cherry picked from commit ba51c393818582b058f5f1e66cf8d13835ad10e5)
    
    Conflicts:
    	tests/conform/test-conform-main.c

 cogl/cogl-private.h                            |    3 ++-
 cogl/driver/gl/cogl-texture-gl.c               |    8 +++++++-
 cogl/driver/gl/gl/cogl-driver-gl.c             |    3 ++-
 cogl/driver/gl/gl/cogl-texture-driver-gl.c     |    5 ++++-
 cogl/driver/gl/gles/cogl-texture-driver-gles.c |    8 --------
 5 files changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/cogl/cogl-private.h b/cogl/cogl-private.h
index ce47eec..6e2d301 100644
--- a/cogl/cogl-private.h
+++ b/cogl/cogl-private.h
@@ -55,7 +55,8 @@ typedef enum
   COGL_PRIVATE_FEATURE_BUILTIN_POINT_SIZE_UNIFORM = 1L<<19,
   COGL_PRIVATE_FEATURE_QUERY_TEXTURE_PARAMETERS = 1L<<20,
   COGL_PRIVATE_FEATURE_ALPHA_TEXTURES = 1L<<21,
-  COGL_PRIVATE_FEATURE_TEXTURE_SWIZZLE = 1L<<22
+  COGL_PRIVATE_FEATURE_TEXTURE_SWIZZLE = 1L<<22,
+  COGL_PRIVATE_FEATURE_TEXTURE_MAX_LEVEL = 1L<<23
 } CoglPrivateFeatureFlags;
 
 /* Sometimes when evaluating pipelines, either during comparisons or
diff --git a/cogl/driver/gl/cogl-texture-gl.c b/cogl/driver/gl/cogl-texture-gl.c
index 3dd4607..a7dfc68 100644
--- a/cogl/driver/gl/cogl-texture-gl.c
+++ b/cogl/driver/gl/cogl-texture-gl.c
@@ -99,7 +99,12 @@ void
 _cogl_texture_gl_maybe_update_max_level (CoglTexture *texture,
                                          int max_level)
 {
-  if (texture->max_level < max_level)
+  /* This isn't supported on GLES */
+#ifdef HAVE_COGL_GL
+  CoglContext *ctx = texture->context;
+
+  if ((ctx->private_feature_flags & COGL_PRIVATE_FEATURE_TEXTURE_MAX_LEVEL) &&
+      texture->max_level < max_level)
     {
       CoglContext *ctx = texture->context;
       GLuint gl_handle;
@@ -116,6 +121,7 @@ _cogl_texture_gl_maybe_update_max_level (CoglTexture *texture,
       GE( ctx, glTexParameteri (gl_target,
                                 GL_TEXTURE_MAX_LEVEL, texture->max_level));
     }
+#endif /* HAVE_COGL_GL */
 }
 
 void
diff --git a/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/driver/gl/gl/cogl-driver-gl.c
index e4b45cb..713390c 100644
--- a/cogl/driver/gl/gl/cogl-driver-gl.c
+++ b/cogl/driver/gl/gl/cogl-driver-gl.c
@@ -594,7 +594,8 @@ _cogl_driver_update_features (CoglContext *ctx,
                     COGL_PRIVATE_FEATURE_FORMAT_CONVERSION |
                     COGL_PRIVATE_FEATURE_BLEND_CONSTANT |
                     COGL_PRIVATE_FEATURE_BUILTIN_POINT_SIZE_UNIFORM |
-                    COGL_PRIVATE_FEATURE_QUERY_TEXTURE_PARAMETERS);
+                    COGL_PRIVATE_FEATURE_QUERY_TEXTURE_PARAMETERS |
+                    COGL_PRIVATE_FEATURE_TEXTURE_MAX_LEVEL);
 
   /* Cache features */
   ctx->private_feature_flags |= private_flags;
diff --git a/cogl/driver/gl/gl/cogl-texture-driver-gl.c b/cogl/driver/gl/gl/cogl-texture-driver-gl.c
index 4fce7ab..46da7f6 100644
--- a/cogl/driver/gl/gl/cogl-texture-driver-gl.c
+++ b/cogl/driver/gl/gl/cogl-texture-driver-gl.c
@@ -73,7 +73,10 @@ _cogl_texture_driver_gen (CoglContext *ctx,
        * level to 0 so OpenGL will consider the texture storage to be
        * "complete".
        */
-      GE( ctx, glTexParameteri (gl_target, GL_TEXTURE_MAX_LEVEL, 0));
+#ifdef HAVE_COGL_GL
+      if ((ctx->private_feature_flags & COGL_PRIVATE_FEATURE_TEXTURE_MAX_LEVEL))
+        GE( ctx, glTexParameteri (gl_target, GL_TEXTURE_MAX_LEVEL, 0));
+#endif
 
       /* GL_TEXTURE_MAG_FILTER defaults to GL_LINEAR, no need to set it */
       GE( ctx, glTexParameteri (gl_target,
diff --git a/cogl/driver/gl/gles/cogl-texture-driver-gles.c b/cogl/driver/gl/gles/cogl-texture-driver-gles.c
index 77de3ac..4162dbc 100644
--- a/cogl/driver/gl/gles/cogl-texture-driver-gles.c
+++ b/cogl/driver/gl/gles/cogl-texture-driver-gles.c
@@ -82,14 +82,6 @@ _cogl_texture_driver_gen (CoglContext *ctx,
     {
     case GL_TEXTURE_2D:
     case GL_TEXTURE_3D:
-      /* In case automatic mipmap generation gets disabled for this
-       * texture but a minification filter depending on mipmap
-       * interpolation is selected then we initialize the max mipmap
-       * level to 0 so OpenGL will consider the texture storage to be
-       * "complete".
-       */
-      GE( ctx, glTexParameteri (gl_target, GL_TEXTURE_MAX_LEVEL, 0));
-
       /* GL_TEXTURE_MAG_FILTER defaults to GL_LINEAR, no need to set it */
       GE( ctx, glTexParameteri (gl_target,
                                 GL_TEXTURE_MIN_FILTER,



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