mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
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:
parent
e58b21017e
commit
81bb87e037
@ -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))
|
||||
{
|
||||
|
@ -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))
|
||||
|
@ -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))
|
||||
|
@ -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,
|
||||
|
@ -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))
|
||||
|
@ -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) );
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user