[cogl/wip/rib/cogl-1.12: 70/101] Use the internal format to check if the texture size is supported



commit 88b43b09b0e944cd22ea9610d69b16661b276cfc
Author: Damien Lespiau <damien lespiau intel com>
Date:   Wed May 23 14:47:57 2012 +0100

    Use the internal format to check if the texture size is supported
    
    Until now, we hardcoded the internal format to GL_RGBA and used the
    internal format returned by pixel_format_to_gl() as the format for
    checking the texture size and format we're asked to create.
    
    Let's use the proper internal format/format from now on.
    
    This is needed as a later patch introduces DEPTH and DEPTH_STENCIL
    textures.
    
    Reviewed-by: Robert Bragg <robert linux intel com>
    
    (cherry picked from commit ec45f60ee2545f88302da314bcdbe1439c4ba9c9)

 cogl/cogl-atlas.c                           |    8 ++++++--
 cogl/cogl-texture-2d-sliced.c               |    5 ++++-
 cogl/cogl-texture-2d.c                      |    4 +++-
 cogl/cogl-texture-driver.h                  |    1 +
 cogl/cogl-texture-rectangle.c               |    4 +++-
 cogl/driver/gl/cogl-texture-driver-gl.c     |    3 ++-
 cogl/driver/gles/cogl-texture-driver-gles.c |    1 +
 7 files changed, 20 insertions(+), 6 deletions(-)
---
diff --git a/cogl/cogl-atlas.c b/cogl/cogl-atlas.c
index f892a9d..2fe85f0 100644
--- a/cogl/cogl-atlas.c
+++ b/cogl/cogl-atlas.c
@@ -173,6 +173,7 @@ _cogl_atlas_get_initial_size (CoglPixelFormat format,
 {
   unsigned int size;
   GLenum gl_intformat;
+  GLenum gl_format;
   GLenum gl_type;
 
   _COGL_GET_CONTEXT (ctx, NO_RETVAL);
@@ -180,7 +181,7 @@ _cogl_atlas_get_initial_size (CoglPixelFormat format,
   ctx->driver_vtable->pixel_format_to_gl (ctx,
                                           format,
                                           &gl_intformat,
-                                          NULL, /* gl_format */
+                                          &gl_format,
                                           &gl_type);
 
   /* At least on Intel hardware, the texture size will be rounded up
@@ -199,6 +200,7 @@ _cogl_atlas_get_initial_size (CoglPixelFormat format,
          !ctx->texture_driver->size_supported (ctx,
                                                GL_TEXTURE_2D,
                                                gl_intformat,
+                                               gl_format,
                                                gl_type,
                                                size, size))
     size >>= 1;
@@ -215,6 +217,7 @@ _cogl_atlas_create_map (CoglPixelFormat          format,
                         CoglAtlasRepositionData *textures)
 {
   GLenum gl_intformat;
+  GLenum gl_format;
   GLenum gl_type;
 
   _COGL_GET_CONTEXT (ctx, NULL);
@@ -222,7 +225,7 @@ _cogl_atlas_create_map (CoglPixelFormat          format,
   ctx->driver_vtable->pixel_format_to_gl (ctx,
                                           format,
                                           &gl_intformat,
-                                          NULL, /* gl_format */
+                                          &gl_format,
                                           &gl_type);
 
   /* Keep trying increasingly larger atlases until we can fit all of
@@ -230,6 +233,7 @@ _cogl_atlas_create_map (CoglPixelFormat          format,
   while (ctx->texture_driver->size_supported (ctx,
                                               GL_TEXTURE_2D,
                                               gl_intformat,
+                                              gl_format,
                                               gl_type,
                                               map_width, map_height))
     {
diff --git a/cogl/cogl-texture-2d-sliced.c b/cogl/cogl-texture-2d-sliced.c
index 11e6adf..fc33abe 100644
--- a/cogl/cogl-texture-2d-sliced.c
+++ b/cogl/cogl-texture-2d-sliced.c
@@ -622,6 +622,7 @@ _cogl_texture_2d_sliced_slices_create (CoglContext *ctx,
   CoglSpan *x_span;
   CoglSpan *y_span;
   GLenum gl_intformat;
+  GLenum gl_format;
   GLenum gl_type;
 
   int   (*slices_for_size) (int, int, int, GArray*);
@@ -643,7 +644,7 @@ _cogl_texture_2d_sliced_slices_create (CoglContext *ctx,
   ctx->driver_vtable->pixel_format_to_gl (ctx,
                                           format,
                                           &gl_intformat,
-                                          NULL,
+                                          &gl_format,
                                           &gl_type);
 
   /* Negative number means no slicing forced by the user */
@@ -655,6 +656,7 @@ _cogl_texture_2d_sliced_slices_create (CoglContext *ctx,
       if (!ctx->texture_driver->size_supported (ctx,
                                                 GL_TEXTURE_2D,
                                                 gl_intformat,
+                                                gl_format,
                                                 gl_type,
                                                 max_width,
                                                 max_height))
@@ -690,6 +692,7 @@ _cogl_texture_2d_sliced_slices_create (CoglContext *ctx,
       while (!ctx->texture_driver->size_supported (ctx,
                                                    GL_TEXTURE_2D,
                                                    gl_intformat,
+                                                   gl_format,
                                                    gl_type,
                                                    max_width,
                                                    max_height))
diff --git a/cogl/cogl-texture-2d.c b/cogl/cogl-texture-2d.c
index efb1933..8ea4c75 100644
--- a/cogl/cogl-texture-2d.c
+++ b/cogl/cogl-texture-2d.c
@@ -109,6 +109,7 @@ _cogl_texture_2d_can_create (unsigned int width,
                              CoglPixelFormat internal_format)
 {
   GLenum gl_intformat;
+  GLenum gl_format;
   GLenum gl_type;
 
   _COGL_GET_CONTEXT (ctx, FALSE);
@@ -123,13 +124,14 @@ _cogl_texture_2d_can_create (unsigned int width,
   ctx->driver_vtable->pixel_format_to_gl (ctx,
                                           internal_format,
                                           &gl_intformat,
-                                          NULL,
+                                          &gl_format,
                                           &gl_type);
 
   /* Check that the driver can create a texture with that size */
   if (!ctx->texture_driver->size_supported (ctx,
                                             GL_TEXTURE_2D,
                                             gl_intformat,
+                                            gl_format,
                                             gl_type,
                                             width,
                                             height))
diff --git a/cogl/cogl-texture-driver.h b/cogl/cogl-texture-driver.h
index 1513381..d4b2b0d 100644
--- a/cogl/cogl-texture-driver.h
+++ b/cogl/cogl-texture-driver.h
@@ -147,6 +147,7 @@ struct _CoglTextureDriver
   CoglBool
   (* size_supported) (CoglContext *ctx,
                       GLenum gl_target,
+                      GLenum gl_intformat,
                       GLenum gl_format,
                       GLenum gl_type,
                       int width,
diff --git a/cogl/cogl-texture-rectangle.c b/cogl/cogl-texture-rectangle.c
index 53d5a80..688bc18 100644
--- a/cogl/cogl-texture-rectangle.c
+++ b/cogl/cogl-texture-rectangle.c
@@ -115,6 +115,7 @@ _cogl_texture_rectangle_can_create (unsigned int width,
                                     GError **error)
 {
   GLenum gl_intformat;
+  GLenum gl_format;
   GLenum gl_type;
 
   _COGL_GET_CONTEXT (ctx, FALSE);
@@ -131,13 +132,14 @@ _cogl_texture_rectangle_can_create (unsigned int width,
   ctx->driver_vtable->pixel_format_to_gl (ctx,
                                           internal_format,
                                           &gl_intformat,
-                                          NULL,
+                                          &gl_format,
                                           &gl_type);
 
   /* Check that the driver can create a texture with that size */
   if (!ctx->texture_driver->size_supported (ctx,
                                             GL_TEXTURE_RECTANGLE_ARB,
                                             gl_intformat,
+                                            gl_format,
                                             gl_type,
                                             width,
                                             height))
diff --git a/cogl/driver/gl/cogl-texture-driver-gl.c b/cogl/driver/gl/cogl-texture-driver-gl.c
index 6d0a908..2c59177 100644
--- a/cogl/driver/gl/cogl-texture-driver-gl.c
+++ b/cogl/driver/gl/cogl-texture-driver-gl.c
@@ -314,6 +314,7 @@ _cogl_texture_driver_size_supported_3d (CoglContext *ctx,
 static CoglBool
 _cogl_texture_driver_size_supported (CoglContext *ctx,
                                      GLenum gl_target,
+                                     GLenum gl_intformat,
                                      GLenum gl_format,
                                      GLenum gl_type,
                                      int width,
@@ -333,7 +334,7 @@ _cogl_texture_driver_size_supported (CoglContext *ctx,
     return FALSE;
 
   /* Proxy texture allows for a quick check for supported size */
-  GE( ctx, glTexImage2D (proxy_target, 0, GL_RGBA,
+  GE( ctx, glTexImage2D (proxy_target, 0, gl_intformat,
                          width, height, 0 /* border */,
                          gl_format, gl_type, NULL) );
 
diff --git a/cogl/driver/gles/cogl-texture-driver-gles.c b/cogl/driver/gles/cogl-texture-driver-gles.c
index 50f8e30..d4d2b5d 100644
--- a/cogl/driver/gles/cogl-texture-driver-gles.c
+++ b/cogl/driver/gles/cogl-texture-driver-gles.c
@@ -410,6 +410,7 @@ _cogl_texture_driver_size_supported_3d (CoglContext *ctx,
 static CoglBool
 _cogl_texture_driver_size_supported (CoglContext *ctx,
                                      GLenum gl_target,
+                                     GLenum gl_intformat,
                                      GLenum gl_format,
                                      GLenum gl_type,
                                      int width,



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