mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 06:48:06 +02:00
mesa: move _mesa_es_error_check_format_and_type() to glformats.c
Where the non-ES _mesa_error_check_format_and_type() function lives. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
parent
8348076ae4
commit
3ba9dbbabf
5 changed files with 73 additions and 69 deletions
|
|
@ -1372,3 +1372,72 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
|
||||||
}
|
}
|
||||||
return GL_NO_ERROR;
|
return GL_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do error checking of format/type combinations for OpenGL ES glReadPixels
|
||||||
|
* and glTex[Sub]Image.
|
||||||
|
* \return error code, or GL_NO_ERROR.
|
||||||
|
*/
|
||||||
|
GLenum
|
||||||
|
_mesa_es_error_check_format_and_type(GLenum format, GLenum type,
|
||||||
|
unsigned dimensions)
|
||||||
|
{
|
||||||
|
GLboolean type_valid = GL_TRUE;
|
||||||
|
|
||||||
|
switch (format) {
|
||||||
|
case GL_ALPHA:
|
||||||
|
case GL_LUMINANCE:
|
||||||
|
case GL_LUMINANCE_ALPHA:
|
||||||
|
type_valid = (type == GL_UNSIGNED_BYTE
|
||||||
|
|| type == GL_FLOAT
|
||||||
|
|| type == GL_HALF_FLOAT_OES);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GL_RGB:
|
||||||
|
type_valid = (type == GL_UNSIGNED_BYTE
|
||||||
|
|| type == GL_UNSIGNED_SHORT_5_6_5
|
||||||
|
|| type == GL_FLOAT
|
||||||
|
|| type == GL_HALF_FLOAT_OES);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GL_RGBA:
|
||||||
|
type_valid = (type == GL_UNSIGNED_BYTE
|
||||||
|
|| type == GL_UNSIGNED_SHORT_4_4_4_4
|
||||||
|
|| type == GL_UNSIGNED_SHORT_5_5_5_1
|
||||||
|
|| type == GL_FLOAT
|
||||||
|
|| type == GL_HALF_FLOAT_OES
|
||||||
|
|| type == GL_UNSIGNED_INT_2_10_10_10_REV);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GL_DEPTH_COMPONENT:
|
||||||
|
/* This format is filtered against invalid dimensionalities elsewhere.
|
||||||
|
*/
|
||||||
|
type_valid = (type == GL_UNSIGNED_SHORT
|
||||||
|
|| type == GL_UNSIGNED_INT);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GL_DEPTH_STENCIL:
|
||||||
|
/* This format is filtered against invalid dimensionalities elsewhere.
|
||||||
|
*/
|
||||||
|
type_valid = (type == GL_UNSIGNED_INT_24_8);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GL_BGRA_EXT:
|
||||||
|
type_valid = (type == GL_UNSIGNED_BYTE);
|
||||||
|
|
||||||
|
/* This feels like a bug in the EXT_texture_format_BGRA8888 spec, but
|
||||||
|
* the format does not appear to be allowed for 3D textures in OpenGL
|
||||||
|
* ES.
|
||||||
|
*/
|
||||||
|
if (dimensions != 2)
|
||||||
|
return GL_INVALID_VALUE;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return GL_INVALID_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return type_valid ? GL_NO_ERROR : GL_INVALID_OPERATION;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,10 @@ extern GLenum
|
||||||
_mesa_error_check_format_and_type(const struct gl_context *ctx,
|
_mesa_error_check_format_and_type(const struct gl_context *ctx,
|
||||||
GLenum format, GLenum type);
|
GLenum format, GLenum type);
|
||||||
|
|
||||||
|
extern GLenum
|
||||||
|
_mesa_es_error_check_format_and_type(GLenum format, GLenum type,
|
||||||
|
unsigned dimensions);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "glformats.h"
|
#include "glformats.h"
|
||||||
#include "fbobject.h"
|
#include "fbobject.h"
|
||||||
#include "teximage.h"
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1681,71 +1681,6 @@ mutable_tex_object(struct gl_context *ctx, GLenum target)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GLenum
|
|
||||||
_mesa_es_error_check_format_and_type(GLenum format, GLenum type,
|
|
||||||
unsigned dimensions)
|
|
||||||
{
|
|
||||||
bool type_valid = true;
|
|
||||||
|
|
||||||
switch (format) {
|
|
||||||
case GL_ALPHA:
|
|
||||||
case GL_LUMINANCE:
|
|
||||||
case GL_LUMINANCE_ALPHA:
|
|
||||||
type_valid = (type == GL_UNSIGNED_BYTE
|
|
||||||
|| type == GL_FLOAT
|
|
||||||
|| type == GL_HALF_FLOAT_OES);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GL_RGB:
|
|
||||||
type_valid = (type == GL_UNSIGNED_BYTE
|
|
||||||
|| type == GL_UNSIGNED_SHORT_5_6_5
|
|
||||||
|| type == GL_FLOAT
|
|
||||||
|| type == GL_HALF_FLOAT_OES);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GL_RGBA:
|
|
||||||
type_valid = (type == GL_UNSIGNED_BYTE
|
|
||||||
|| type == GL_UNSIGNED_SHORT_4_4_4_4
|
|
||||||
|| type == GL_UNSIGNED_SHORT_5_5_5_1
|
|
||||||
|| type == GL_FLOAT
|
|
||||||
|| type == GL_HALF_FLOAT_OES
|
|
||||||
|| type == GL_UNSIGNED_INT_2_10_10_10_REV);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GL_DEPTH_COMPONENT:
|
|
||||||
/* This format is filtered against invalid dimensionalities elsewhere.
|
|
||||||
*/
|
|
||||||
type_valid = (type == GL_UNSIGNED_SHORT
|
|
||||||
|| type == GL_UNSIGNED_INT);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GL_DEPTH_STENCIL:
|
|
||||||
/* This format is filtered against invalid dimensionalities elsewhere.
|
|
||||||
*/
|
|
||||||
type_valid = (type == GL_UNSIGNED_INT_24_8);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GL_BGRA_EXT:
|
|
||||||
type_valid = (type == GL_UNSIGNED_BYTE);
|
|
||||||
|
|
||||||
/* This feels like a bug in the EXT_texture_format_BGRA8888 spec, but
|
|
||||||
* the format does not appear to be allowed for 3D textures in OpenGL
|
|
||||||
* ES.
|
|
||||||
*/
|
|
||||||
if (dimensions != 2)
|
|
||||||
return GL_INVALID_VALUE;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return GL_INVALID_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return type_valid ? GL_NO_ERROR : GL_INVALID_OPERATION;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return expected size of a compressed texture.
|
* Return expected size of a compressed texture.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -138,9 +138,6 @@ _mesa_tex_target_to_face(GLenum target);
|
||||||
extern GLint
|
extern GLint
|
||||||
_mesa_get_texture_dimensions(GLenum target);
|
_mesa_get_texture_dimensions(GLenum target);
|
||||||
|
|
||||||
extern GLenum
|
|
||||||
_mesa_es_error_check_format_and_type(GLenum format, GLenum type,
|
|
||||||
unsigned dimensions);
|
|
||||||
|
|
||||||
extern GLboolean
|
extern GLboolean
|
||||||
_mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
|
_mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue