<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 28, 2015 at 7:50 AM, Nanley Chery <span dir="ltr"><<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
<br>
Reuse utility functions instead of reimplementing the same logic.<br>
<br>
* _mesa_is_compressed_format() performs the required checking to<br>
determine format support in the current context.<br>
* _mesa_gl_compressed_format_base_format() returns the base format.<br>
<br>
Signed-off-by: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
---<br>
src/mesa/main/teximage.c | 150 ++---------------------------------------------<br>
1 file changed, 5 insertions(+), 145 deletions(-)<br>
<br>
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c<br>
index 39d1281..8913a72 100644<br>
--- a/src/mesa/main/teximage.c<br>
+++ b/src/mesa/main/teximage.c<br>
@@ -252,44 +252,11 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )<br>
; /* fallthrough */<br>
}<br>
<br>
- if (ctx->Extensions.TDFX_texture_compression_FXT1) {<br>
- switch (internalFormat) {<br>
- case GL_COMPRESSED_RGB_FXT1_3DFX:<br>
- return GL_RGB;<br>
- case GL_COMPRESSED_RGBA_FXT1_3DFX:<br>
- return GL_RGBA;<br>
- default:<br>
- ; /* fallthrough */<br>
- }<br>
- }<br>
-<br>
- /* Assume that the ANGLE flag will always be set if the EXT flag is set.<br>
- */<br>
- if (ctx->Extensions.ANGLE_texture_compression_dxt) {<br>
- switch (internalFormat) {<br>
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:<br>
- return GL_RGB;<br>
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:<br>
- case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:<br>
- case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:<br>
- return GL_RGBA;<br>
- default:<br>
- ; /* fallthrough */<br>
- }<br>
- }<br>
-<br>
- if (_mesa_is_desktop_gl(ctx)<br>
- && ctx->Extensions.ANGLE_texture_compression_dxt) {<br>
- switch (internalFormat) {<br>
- case GL_RGB_S3TC:<br>
- case GL_RGB4_S3TC:<br>
- return GL_RGB;<br>
- case GL_RGBA_S3TC:<br>
- case GL_RGBA4_S3TC:<br>
- return GL_RGBA;<br>
- default:<br>
- ; /* fallthrough */<br>
- }<br>
+ if (_mesa_is_compressed_format(ctx, internalFormat)) {<br>
+ GLenum base_compressed =<br>
+ _mesa_gl_compressed_format_base_format(internalFormat);<br>
+ if (base_compressed)<br>
+ return base_compressed;<br>
}<br>
<br>
if (ctx->Extensions.MESA_ycbcr_texture) {<br>
@@ -367,16 +334,10 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )<br>
case GL_SRGB8_EXT:<br>
case GL_COMPRESSED_SRGB_EXT:<br>
return GL_RGB;<br>
- case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:<br>
- return ctx->Extensions.EXT_texture_compression_s3tc ? GL_RGB : -1;<br>
case GL_SRGB_ALPHA_EXT:<br>
case GL_SRGB8_ALPHA8_EXT:<br>
case GL_COMPRESSED_SRGB_ALPHA_EXT:<br>
return GL_RGBA;<br>
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:<br>
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:<br>
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:<br>
- return ctx->Extensions.EXT_texture_compression_s3tc ? GL_RGBA : -1;<br>
case GL_SLUMINANCE_ALPHA_EXT:<br>
case GL_SLUMINANCE8_ALPHA8_EXT:<br>
case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:<br>
@@ -521,111 +482,10 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )<br>
}<br>
}<br>
<br>
- if (ctx->Extensions.ARB_texture_compression_rgtc) {<br>
- switch (internalFormat) {<br>
- case GL_COMPRESSED_RED_RGTC1:<br>
- case GL_COMPRESSED_SIGNED_RED_RGTC1:<br>
- return GL_RED;<br>
- case GL_COMPRESSED_RG_RGTC2:<br>
- case GL_COMPRESSED_SIGNED_RG_RGTC2:<br>
- return GL_RG;<br>
- default:<br>
- ; /* fallthrough */<br>
- }<br>
- }<br>
-<br>
- if (_mesa_is_desktop_gl(ctx) &&<br>
- ctx->Extensions.EXT_texture_compression_latc) {<br>
- switch (internalFormat) {<br>
- case GL_COMPRESSED_LUMINANCE_LATC1_EXT:<br>
- case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT:<br>
- return GL_LUMINANCE;<br>
- case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:<br>
- case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:<br>
- return GL_LUMINANCE_ALPHA;<br>
- default:<br>
- ; /* fallthrough */<br>
- }<br>
- }<br>
-<br>
- if (_mesa_is_desktop_gl(ctx) &&<br>
- ctx->Extensions.ATI_texture_compression_3dc) {<br>
- switch (internalFormat) {<br>
- case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:<br>
- return GL_LUMINANCE_ALPHA;<br>
- default:<br>
- ; /* fallthrough */<br>
- }<br>
- }<br>
-<br>
- if (_mesa_is_gles(ctx) &&<br>
- ctx->Extensions.OES_compressed_ETC1_RGB8_texture) {<br>
- switch (internalFormat) {<br>
- case GL_ETC1_RGB8_OES:<br>
- return GL_RGB;<br>
- default:<br>
- ; /* fallthrough */<br>
- }<br>
- }<br>
-<br>
if (ctx->Extensions.KHR_texture_compression_astc_ldr &&<br>
_mesa_is_astc_format(internalFormat))<br>
return GL_RGBA;<br>
<br>
- if (_mesa_is_gles3(ctx) || ctx->Extensions.ARB_ES3_compatibility) {<br>
- switch (internalFormat) {<br>
- case GL_COMPRESSED_RGB8_ETC2:<br>
- case GL_COMPRESSED_SRGB8_ETC2:<br>
- return GL_RGB;<br>
- case GL_COMPRESSED_RGBA8_ETC2_EAC:<br>
- case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:<br>
- case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:<br>
- case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:<br>
- return GL_RGBA;<br>
- case GL_COMPRESSED_R11_EAC:<br>
- case GL_COMPRESSED_SIGNED_R11_EAC:<br>
- return GL_RED;<br>
- case GL_COMPRESSED_RG11_EAC:<br>
- case GL_COMPRESSED_SIGNED_RG11_EAC:<br>
- return GL_RG;<br>
- default:<br>
- ; /* fallthrough */<br>
- }<br>
- }<br>
-<br>
- if (_mesa_is_desktop_gl(ctx) &&<br>
- ctx->Extensions.ARB_texture_compression_bptc) {<br>
- switch (internalFormat) {<br>
- case GL_COMPRESSED_RGBA_BPTC_UNORM:<br>
- case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:<br>
- return GL_RGBA;<br>
- case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:<br>
- case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:<br>
- return GL_RGB;<br>
- default:<br>
- ; /* fallthrough */<br>
- }<br>
- }<br>
-<br>
- if (ctx->API == API_OPENGLES) {<br>
- switch (internalFormat) {<br>
- case GL_PALETTE4_RGB8_OES:<br>
- case GL_PALETTE4_R5_G6_B5_OES:<br>
- case GL_PALETTE8_RGB8_OES:<br>
- case GL_PALETTE8_R5_G6_B5_OES:<br>
- return GL_RGB;<br>
- case GL_PALETTE4_RGBA8_OES:<br>
- case GL_PALETTE8_RGB5_A1_OES:<br>
- case GL_PALETTE4_RGBA4_OES:<br>
- case GL_PALETTE4_RGB5_A1_OES:<br>
- case GL_PALETTE8_RGBA8_OES:<br>
- case GL_PALETTE8_RGBA4_OES:<br>
- return GL_RGBA;<br>
- default:<br>
- ; /* fallthrough */<br>
- }<br>
- }<br>
-<br>
return -1; /* error */<br>
}<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.5.0<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div><div class="gmail_extra">Nice cleanup Nanley.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Reviewed-by: Anuj Phogat <<a href="mailto:anuj.phogat@gmail.com">anuj.phogat@gmail.com</a>></div></div>