[cogl] Don't set GL_TEXTURE_MAX_LEVEL on GLES



commit ba51c393818582b058f5f1e66cf8d13835ad10e5
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>

 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 --------
 tests/conform/test-conform-main.c              |    4 +++-
 6 files changed, 18 insertions(+), 13 deletions(-)
---
diff --git a/cogl/cogl-private.h b/cogl/cogl-private.h
index ea7c8d2..d1c32e8 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 d0776ee..140a0e7 100644
--- a/cogl/driver/gl/gl/cogl-driver-gl.c
+++ b/cogl/driver/gl/gl/cogl-driver-gl.c
@@ -562,7 +562,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 8c20ead..731ef7e 100644
--- a/cogl/driver/gl/gl/cogl-texture-driver-gl.c
+++ b/cogl/driver/gl/gl/cogl-texture-driver-gl.c
@@ -72,7 +72,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 6c2abe7..1afab86 100644
--- a/cogl/driver/gl/gles/cogl-texture-driver-gles.c
+++ b/cogl/driver/gl/gles/cogl-texture-driver-gles.c
@@ -81,14 +81,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,
diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c
index 389f611..167a39d 100644
--- a/tests/conform/test-conform-main.c
+++ b/tests/conform/test-conform-main.c
@@ -75,7 +75,9 @@ main (int argc, char **argv)
   ADD_TEST (test_wrap_modes, 0, 0);
   UNPORTED_TEST (test_texture_pixmap_x11);
   ADD_TEST (test_texture_get_set_data, 0, 0);
-  ADD_TEST (test_texture_mipmap_get_set, 0, 0);
+  /* This test won't work on GLES because that doesn't support setting
+   * the maximum texture level. */
+  ADD_TEST (test_texture_mipmap_get_set, TEST_REQUIREMENT_GL, 0);
   ADD_TEST (test_atlas_migration, 0, 0);
   ADD_TEST (test_read_texture_formats, 0, 0);
   ADD_TEST (test_write_texture_formats, 0, 0);



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