mesa/formats: only do type and component lookup for uncompressed formats
Only uncompressed formats have a non-void type and actual components per pixel. Rename _mesa_format_to_type_and_comps to _mesa_uncompressed_format_to_type_and_comps and require callers to check if the format is not compressed. v2. include compressed format cases to avoid gcc warnings (Chad). Reviewed-by: Chad Versace <chad.versace@intel.com> Signed-off-by: Nanley Chery <nanley.g.chery@intel.com>
This commit is contained in:
@@ -602,7 +602,7 @@ _mesa_format_to_array(mesa_format format, GLenum *type, int *num_components,
|
|||||||
|
|
||||||
*normalized = !_mesa_is_format_integer(format);
|
*normalized = !_mesa_is_format_integer(format);
|
||||||
|
|
||||||
_mesa_format_to_type_and_comps(format, type, &format_components);
|
_mesa_uncompressed_format_to_type_and_comps(format, type, &format_components);
|
||||||
|
|
||||||
switch (_mesa_get_format_layout(format)) {
|
switch (_mesa_get_format_layout(format)) {
|
||||||
case MESA_FORMAT_LAYOUT_ARRAY:
|
case MESA_FORMAT_LAYOUT_ARRAY:
|
||||||
|
@@ -885,9 +885,9 @@ _mesa_format_row_stride(mesa_format format, GLsizei width)
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Debug/test: check that all formats are handled in the
|
* Debug/test: check that all uncompressed formats are handled in the
|
||||||
* _mesa_format_to_type_and_comps() function. When new pixel formats
|
* _mesa_uncompressed_format_to_type_and_comps() function. When new pixel
|
||||||
* are added to Mesa, that function needs to be updated.
|
* formats are added to Mesa, that function needs to be updated.
|
||||||
* This is a no-op after the first call.
|
* This is a no-op after the first call.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
@@ -901,7 +901,8 @@ check_format_to_type_and_comps(void)
|
|||||||
/* This function will emit a problem/warning if the format is
|
/* This function will emit a problem/warning if the format is
|
||||||
* not handled.
|
* not handled.
|
||||||
*/
|
*/
|
||||||
_mesa_format_to_type_and_comps(f, &datatype, &comps);
|
if (!_mesa_is_format_compressed(f))
|
||||||
|
_mesa_uncompressed_format_to_type_and_comps(f, &datatype, &comps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -997,11 +998,11 @@ _mesa_test_formats(void)
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return datatype and number of components per texel for the given mesa_format.
|
* Return datatype and number of components per texel for the given
|
||||||
* Only used for mipmap generation code.
|
* uncompressed mesa_format. Only used for mipmap generation code.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
_mesa_format_to_type_and_comps(mesa_format format,
|
_mesa_uncompressed_format_to_type_and_comps(mesa_format format,
|
||||||
GLenum *datatype, GLuint *comps)
|
GLenum *datatype, GLuint *comps)
|
||||||
{
|
{
|
||||||
switch (format) {
|
switch (format) {
|
||||||
@@ -1235,44 +1236,6 @@ _mesa_format_to_type_and_comps(mesa_format format,
|
|||||||
*comps = 2;
|
*comps = 2;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case MESA_FORMAT_RGB_FXT1:
|
|
||||||
case MESA_FORMAT_RGBA_FXT1:
|
|
||||||
case MESA_FORMAT_RGB_DXT1:
|
|
||||||
case MESA_FORMAT_RGBA_DXT1:
|
|
||||||
case MESA_FORMAT_RGBA_DXT3:
|
|
||||||
case MESA_FORMAT_RGBA_DXT5:
|
|
||||||
case MESA_FORMAT_SRGB_DXT1:
|
|
||||||
case MESA_FORMAT_SRGBA_DXT1:
|
|
||||||
case MESA_FORMAT_SRGBA_DXT3:
|
|
||||||
case MESA_FORMAT_SRGBA_DXT5:
|
|
||||||
case MESA_FORMAT_R_RGTC1_UNORM:
|
|
||||||
case MESA_FORMAT_R_RGTC1_SNORM:
|
|
||||||
case MESA_FORMAT_RG_RGTC2_UNORM:
|
|
||||||
case MESA_FORMAT_RG_RGTC2_SNORM:
|
|
||||||
case MESA_FORMAT_L_LATC1_UNORM:
|
|
||||||
case MESA_FORMAT_L_LATC1_SNORM:
|
|
||||||
case MESA_FORMAT_LA_LATC2_UNORM:
|
|
||||||
case MESA_FORMAT_LA_LATC2_SNORM:
|
|
||||||
case MESA_FORMAT_ETC1_RGB8:
|
|
||||||
case MESA_FORMAT_ETC2_RGB8:
|
|
||||||
case MESA_FORMAT_ETC2_SRGB8:
|
|
||||||
case MESA_FORMAT_ETC2_RGBA8_EAC:
|
|
||||||
case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC:
|
|
||||||
case MESA_FORMAT_ETC2_R11_EAC:
|
|
||||||
case MESA_FORMAT_ETC2_RG11_EAC:
|
|
||||||
case MESA_FORMAT_ETC2_SIGNED_R11_EAC:
|
|
||||||
case MESA_FORMAT_ETC2_SIGNED_RG11_EAC:
|
|
||||||
case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1:
|
|
||||||
case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:
|
|
||||||
case MESA_FORMAT_BPTC_RGBA_UNORM:
|
|
||||||
case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM:
|
|
||||||
case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT:
|
|
||||||
case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT:
|
|
||||||
/* XXX generate error instead? */
|
|
||||||
*datatype = GL_UNSIGNED_BYTE;
|
|
||||||
*comps = 0;
|
|
||||||
return;
|
|
||||||
|
|
||||||
case MESA_FORMAT_RGBA_FLOAT32:
|
case MESA_FORMAT_RGBA_FLOAT32:
|
||||||
*datatype = GL_FLOAT;
|
*datatype = GL_FLOAT;
|
||||||
*comps = 4;
|
*comps = 4;
|
||||||
@@ -1571,12 +1534,46 @@ _mesa_format_to_type_and_comps(mesa_format format,
|
|||||||
assert(0);
|
assert(0);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
case MESA_FORMAT_RGB_FXT1:
|
||||||
|
case MESA_FORMAT_RGBA_FXT1:
|
||||||
|
case MESA_FORMAT_RGB_DXT1:
|
||||||
|
case MESA_FORMAT_RGBA_DXT1:
|
||||||
|
case MESA_FORMAT_RGBA_DXT3:
|
||||||
|
case MESA_FORMAT_RGBA_DXT5:
|
||||||
|
case MESA_FORMAT_SRGB_DXT1:
|
||||||
|
case MESA_FORMAT_SRGBA_DXT1:
|
||||||
|
case MESA_FORMAT_SRGBA_DXT3:
|
||||||
|
case MESA_FORMAT_SRGBA_DXT5:
|
||||||
|
case MESA_FORMAT_R_RGTC1_UNORM:
|
||||||
|
case MESA_FORMAT_R_RGTC1_SNORM:
|
||||||
|
case MESA_FORMAT_RG_RGTC2_UNORM:
|
||||||
|
case MESA_FORMAT_RG_RGTC2_SNORM:
|
||||||
|
case MESA_FORMAT_L_LATC1_UNORM:
|
||||||
|
case MESA_FORMAT_L_LATC1_SNORM:
|
||||||
|
case MESA_FORMAT_LA_LATC2_UNORM:
|
||||||
|
case MESA_FORMAT_LA_LATC2_SNORM:
|
||||||
|
case MESA_FORMAT_ETC1_RGB8:
|
||||||
|
case MESA_FORMAT_ETC2_RGB8:
|
||||||
|
case MESA_FORMAT_ETC2_SRGB8:
|
||||||
|
case MESA_FORMAT_ETC2_RGBA8_EAC:
|
||||||
|
case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC:
|
||||||
|
case MESA_FORMAT_ETC2_R11_EAC:
|
||||||
|
case MESA_FORMAT_ETC2_RG11_EAC:
|
||||||
|
case MESA_FORMAT_ETC2_SIGNED_R11_EAC:
|
||||||
|
case MESA_FORMAT_ETC2_SIGNED_RG11_EAC:
|
||||||
|
case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1:
|
||||||
|
case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:
|
||||||
|
case MESA_FORMAT_BPTC_RGBA_UNORM:
|
||||||
|
case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM:
|
||||||
|
case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT:
|
||||||
|
case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT:
|
||||||
|
assert(_mesa_is_format_compressed(format));
|
||||||
case MESA_FORMAT_NONE:
|
case MESA_FORMAT_NONE:
|
||||||
/* For debug builds, warn if any formats are not handled */
|
/* For debug builds, warn if any formats are not handled */
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
default:
|
default:
|
||||||
#endif
|
#endif
|
||||||
_mesa_problem(NULL, "bad format %s in _mesa_format_to_type_and_comps",
|
_mesa_problem(NULL, "bad format %s in _mesa_uncompressed_format_to_type_and_comps",
|
||||||
_mesa_get_format_name(format));
|
_mesa_get_format_name(format));
|
||||||
*datatype = 0;
|
*datatype = 0;
|
||||||
*comps = 1;
|
*comps = 1;
|
||||||
|
@@ -665,7 +665,7 @@ extern GLint
|
|||||||
_mesa_format_row_stride(mesa_format format, GLsizei width);
|
_mesa_format_row_stride(mesa_format format, GLsizei width);
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
_mesa_format_to_type_and_comps(mesa_format format,
|
_mesa_uncompressed_format_to_type_and_comps(mesa_format format,
|
||||||
GLenum *datatype, GLuint *comps);
|
GLenum *datatype, GLuint *comps);
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
|
@@ -1886,7 +1886,7 @@ generate_mipmap_uncompressed(struct gl_context *ctx, GLenum target,
|
|||||||
GLenum datatype;
|
GLenum datatype;
|
||||||
GLuint comps;
|
GLuint comps;
|
||||||
|
|
||||||
_mesa_format_to_type_and_comps(srcImage->TexFormat, &datatype, &comps);
|
_mesa_uncompressed_format_to_type_and_comps(srcImage->TexFormat, &datatype, &comps);
|
||||||
|
|
||||||
for (level = texObj->BaseLevel; level < maxLevel; level++) {
|
for (level = texObj->BaseLevel; level < maxLevel; level++) {
|
||||||
/* generate image[level+1] from image[level] */
|
/* generate image[level+1] from image[level] */
|
||||||
|
Reference in New Issue
Block a user