diff options
Diffstat (limited to 'src/mesa/main/teximage.c')
-rw-r--r-- | src/mesa/main/teximage.c | 197 |
1 files changed, 115 insertions, 82 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 2388ba3a5af..1b889292f8e 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -199,103 +199,124 @@ _mesa_base_tex_format( GLcontext *ctx, GLint internalFormat ) case GL_RGBA12: case GL_RGBA16: return GL_RGBA; - case GL_COLOR_INDEX: - case GL_COLOR_INDEX1_EXT: - case GL_COLOR_INDEX2_EXT: - case GL_COLOR_INDEX4_EXT: - case GL_COLOR_INDEX8_EXT: - case GL_COLOR_INDEX12_EXT: - case GL_COLOR_INDEX16_EXT: - if (ctx->Extensions.EXT_paletted_texture) + default: + ; /* fallthrough */ + } + + if (ctx->Extensions.EXT_paletted_texture) { + switch (internalFormat) { + case GL_COLOR_INDEX: + case GL_COLOR_INDEX1_EXT: + case GL_COLOR_INDEX2_EXT: + case GL_COLOR_INDEX4_EXT: + case GL_COLOR_INDEX8_EXT: + case GL_COLOR_INDEX12_EXT: + case GL_COLOR_INDEX16_EXT: return GL_COLOR_INDEX; - else - return -1; - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16_SGIX: - case GL_DEPTH_COMPONENT24_SGIX: - case GL_DEPTH_COMPONENT32_SGIX: - if (ctx->Extensions.SGIX_depth_texture) + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.SGIX_depth_texture) { + switch (internalFormat) { + case GL_DEPTH_COMPONENT: + case GL_DEPTH_COMPONENT16_SGIX: + case GL_DEPTH_COMPONENT24_SGIX: + case GL_DEPTH_COMPONENT32_SGIX: return GL_DEPTH_COMPONENT; - else - return -1; + default: + ; /* fallthrough */ + } + } - /* GL_ARB_texture_compression */ - case GL_COMPRESSED_ALPHA: - if (ctx->Extensions.ARB_texture_compression) + if (ctx->Extensions.ARB_texture_compression) { + switch (internalFormat) { + case GL_COMPRESSED_ALPHA: return GL_ALPHA; - else - return -1; - case GL_COMPRESSED_LUMINANCE: - if (ctx->Extensions.ARB_texture_compression) + case GL_COMPRESSED_LUMINANCE: return GL_LUMINANCE; - else - return -1; - case GL_COMPRESSED_LUMINANCE_ALPHA: - if (ctx->Extensions.ARB_texture_compression) + case GL_COMPRESSED_LUMINANCE_ALPHA: return GL_LUMINANCE_ALPHA; - else - return -1; - case GL_COMPRESSED_INTENSITY: - if (ctx->Extensions.ARB_texture_compression) + case GL_COMPRESSED_INTENSITY: return GL_INTENSITY; - else - return -1; - case GL_COMPRESSED_RGB: - if (ctx->Extensions.ARB_texture_compression) + case GL_COMPRESSED_RGB: return GL_RGB; - else - return -1; - case GL_COMPRESSED_RGBA: - if (ctx->Extensions.ARB_texture_compression) + case GL_COMPRESSED_RGBA: return GL_RGBA; - else - return -1; - case GL_COMPRESSED_RGB_FXT1_3DFX: - if (ctx->Extensions.TDFX_texture_compression_FXT1) + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.TDFX_texture_compression_FXT1) { + switch (internalFormat) { + case GL_COMPRESSED_RGB_FXT1_3DFX: return GL_RGB; - else - return -1; - case GL_COMPRESSED_RGBA_FXT1_3DFX: - if (ctx->Extensions.TDFX_texture_compression_FXT1) + case GL_COMPRESSED_RGBA_FXT1_3DFX: return GL_RGBA; - else - return -1; - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - if (ctx->Extensions.EXT_texture_compression_s3tc) + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: return GL_RGB; - else - return -1; - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - if (ctx->Extensions.EXT_texture_compression_s3tc) + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.EXT_texture_compression_s3tc) { + switch (internalFormat) { + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: return GL_RGBA; - else - return -1; - case GL_RGB_S3TC: - case GL_RGB4_S3TC: - if (ctx->Extensions.S3_s3tc) + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.S3_s3tc) { + switch (internalFormat) { + case GL_RGB_S3TC: + case GL_RGB4_S3TC: return GL_RGB; - else - return -1; - case GL_RGBA_S3TC: - case GL_RGBA4_S3TC: - if (ctx->Extensions.S3_s3tc) + case GL_RGBA_S3TC: + case GL_RGBA4_S3TC: return GL_RGBA; - else - return -1; - - case GL_YCBCR_MESA: - if (ctx->Extensions.MESA_ycbcr_texture) - return GL_YCBCR_MESA; - else - return -1; + default: + ; /* fallthrough */ + } + } - /* XXX add float texture formats here */ + if (ctx->Extensions.MESA_ycbcr_texture) { + if (internalFormat == GL_YCBCR_MESA) + return GL_YCBCR_MESA; + } - default: - return -1; /* error */ + if (ctx->Extensions.ARB_texture_float) { + switch (internalFormat) { + case GL_ALPHA16F_ARB: + case GL_ALPHA32F_ARB: + return GL_ALPHA; + case GL_RGBA16F_ARB: + case GL_RGBA32F_ARB: + return GL_RGBA; + case GL_RGB16F_ARB: + case GL_RGB32F_ARB: + return GL_RGB; + case GL_INTENSITY16F_ARB: + case GL_INTENSITY32F_ARB: + return GL_INTENSITY; + case GL_LUMINANCE16F_ARB: + case GL_LUMINANCE32F_ARB: + return GL_LUMINANCE; + case GL_LUMINANCE_ALPHA16F_ARB: + case GL_LUMINANCE_ALPHA32F_ARB: + return GL_LUMINANCE_ALPHA; + default: + ; /* nothing */ + } } + + return -1; /* error */ } @@ -351,7 +372,19 @@ is_color_format(GLenum internalFormat) case GL_RGB10_A2: case GL_RGBA12: case GL_RGBA16: - /* XXX add float texture formats here */ + /* float texture formats */ + case GL_ALPHA16F_ARB: + case GL_ALPHA32F_ARB: + case GL_LUMINANCE16F_ARB: + case GL_LUMINANCE32F_ARB: + case GL_LUMINANCE_ALPHA16F_ARB: + case GL_LUMINANCE_ALPHA32F_ARB: + case GL_INTENSITY16F_ARB: + case GL_INTENSITY32F_ARB: + case GL_RGB16F_ARB: + case GL_RGB32F_ARB: + case GL_RGBA16F_ARB: + case GL_RGBA32F_ARB: return GL_TRUE; case GL_YCBCR_MESA: /* not considered to be RGB */ default: @@ -1241,7 +1274,7 @@ texture_error_check( GLcontext *ctx, GLenum target, } /* Check incoming image format and type */ - if (!_mesa_is_legal_format_and_type(format, type)) { + if (!_mesa_is_legal_format_and_type(ctx, format, type)) { /* Yes, generate GL_INVALID_OPERATION, not GL_INVALID_ENUM, if there * is a type/format mismatch. See 1.2 spec page 94, sec 3.6.4. */ @@ -1449,7 +1482,7 @@ subtexture_error_check( GLcontext *ctx, GLuint dimensions, } } - if (!_mesa_is_legal_format_and_type(format, type)) { + if (!_mesa_is_legal_format_and_type(ctx, format, type)) { _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage%dD(format or type)", dimensions); return GL_TRUE; |