Commit ce2ae3c3 authored by Brian Paul's avatar Brian Paul

mesa: refactor _mesa_test_proxy_teximage() code

Basically, move the body into a new _mesa_legal_texture_dimensions() function.
More refactoring to come.
Reviewed-by: Jose Fonseca's avatarJose Fonseca <jfonseca@vmware.com>
parent b1874ec9
......@@ -1209,40 +1209,18 @@ _mesa_clear_texture_image(struct gl_context *ctx,
/**
* This is the fallback for Driver.TestProxyTexImage(). Test the texture
* width, height and depth against the ctx->Const limits for textures.
*
* A hardware driver might override this function if, for example, the
* max 3D texture size is 512x512x64 (i.e. not a cube).
*
* Note that width, height, depth == 0 is not an error. However, a
* texture with zero width/height/depth will be considered "incomplete"
* and texturing will effectively be disabled.
*
* \param target one of GL_PROXY_TEXTURE_1D, GL_PROXY_TEXTURE_2D,
* GL_PROXY_TEXTURE_3D, GL_PROXY_TEXTURE_RECTANGLE_NV,
* GL_PROXY_TEXTURE_CUBE_MAP_ARB.
* \param level as passed to glTexImage
* \param internalFormat as passed to glTexImage
* \param format as passed to glTexImage
* \param type as passed to glTexImage
* \param width as passed to glTexImage
* \param height as passed to glTexImage
* \param depth as passed to glTexImage
* \param border as passed to glTexImage
* \return GL_TRUE if the image is acceptable, GL_FALSE if not acceptable.
* Check the width, height, depth and border of a texture image
* against the max texture size constants.
* The target and level parameters will have already been validated.
* \return GL_TRUE if size is OK, GL_FALSE otherwise.
*/
GLboolean
_mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level,
GLint internalFormat, GLenum format, GLenum type,
GLint width, GLint height, GLint depth, GLint border)
_mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
GLint level, GLint width, GLint height,
GLint depth, GLint border)
{
GLint maxSize;
(void) internalFormat;
(void) format;
(void) type;
switch (target) {
case GL_PROXY_TEXTURE_1D:
maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); /* level zero size */
......@@ -1345,12 +1323,50 @@ _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level,
return GL_TRUE;
default:
_mesa_problem(ctx, "Invalid target in _mesa_test_proxy_teximage");
_mesa_problem(ctx, "Invalid target in _mesa_legal_texture_dimensions()");
return GL_FALSE;
}
}
/**
* This is the fallback for Driver.TestProxyTexImage(). Test the texture
* width, height and depth against the ctx->Const limits for textures.
*
* A hardware driver might override this function if, for example, the
* max 3D texture size is 512x512x64 (i.e. not a cube).
*
* Note that width, height, depth == 0 is not an error. However, a
* texture with zero width/height/depth will be considered "incomplete"
* and texturing will effectively be disabled.
*
* \param target one of GL_PROXY_TEXTURE_1D, GL_PROXY_TEXTURE_2D,
* GL_PROXY_TEXTURE_3D, GL_PROXY_TEXTURE_RECTANGLE_NV,
* GL_PROXY_TEXTURE_CUBE_MAP_ARB.
* \param level as passed to glTexImage
* \param internalFormat as passed to glTexImage
* \param format as passed to glTexImage
* \param type as passed to glTexImage
* \param width as passed to glTexImage
* \param height as passed to glTexImage
* \param depth as passed to glTexImage
* \param border as passed to glTexImage
* \return GL_TRUE if the image is acceptable, GL_FALSE if not acceptable.
*/
GLboolean
_mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level,
GLint internalFormat, GLenum format, GLenum type,
GLint width, GLint height, GLint depth, GLint border)
{
(void) internalFormat;
(void) format;
(void) type;
return _mesa_legal_texture_dimensions(ctx, target, level,
width, height, depth, border);
}
/**
* Check if the memory used by the texture would exceed the driver's limit.
* This lets us support a max 3D texture size of 8K (for example) but
......@@ -1680,6 +1696,10 @@ get_compressed_block_size(GLenum glformat, GLuint *bw, GLuint *bh)
* Verifies each of the parameters against the constants specified in
* __struct gl_contextRec::Const and the supported extensions, and according
* to the OpenGL specification.
* Note that we don't fully error-check the width, height, depth values
* here. That's done in _mesa_legal_texture_dimensions() which is used
* by several other GL entrypoints. Plus, texture dims have a special
* interaction with proxy textures.
*/
static GLenum
texture_error_check( struct gl_context *ctx,
......@@ -2028,6 +2048,7 @@ compressed_texture_error_check(struct gl_context *ctx, GLint dimensions,
}
/* check image size against compression block size */
/* XXX possibly move this into the _mesa_legal_texture_dimensions() func */
{
gl_format texFormat =
ctx->Driver.ChooseTextureFormat(ctx, target, proxy_format,
......
......@@ -142,6 +142,11 @@ extern GLenum
_mesa_es_error_check_format_and_type(GLenum format, GLenum type,
unsigned dimensions);
extern GLboolean
_mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
GLint level, GLint width, GLint height,
GLint depth, GLint border);
/**
* Lock a texture for updating. See also _mesa_lock_context_textures().
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment