From: Brian Paul Date: Sat, 15 Sep 2012 16:30:20 +0000 (-0600) Subject: mesa: refactor _mesa_test_proxy_teximage() code X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ce2ae3c3a2e4bef78047a28723f2d06264d6e4b6;p=mesa.git 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 --- diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 36ed227cb8e..48a4cccd834 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -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, diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h index 36fd1c2bc5d..340297f82a2 100644 --- a/src/mesa/main/teximage.h +++ b/src/mesa/main/teximage.h @@ -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(). */