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)
This commit is contained in:
Damien Lespiau 2012-05-23 14:47:57 +01:00 committed by Robert Bragg
parent e58b21017e
commit 81bb87e037
7 changed files with 20 additions and 6 deletions

View File

@ -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))
{

View File

@ -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))

View File

@ -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))

View File

@ -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,

View File

@ -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))

View File

@ -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) );

View File

@ -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,