diff options
author | marha <marha@users.sourceforge.net> | 2012-04-10 10:49:59 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-04-10 10:49:59 +0200 |
commit | c6f80401dc533b04341afe8d596960d1bc25efce (patch) | |
tree | 2826007946218a8370d2eebc6aa32083618e2bfe /mesalib/src/mesa/main/teximage.c | |
parent | 31706e67674f308e3e7f2a8aaf02f1e0a00fbade (diff) | |
download | vcxsrv-c6f80401dc533b04341afe8d596960d1bc25efce.tar.gz vcxsrv-c6f80401dc533b04341afe8d596960d1bc25efce.tar.bz2 vcxsrv-c6f80401dc533b04341afe8d596960d1bc25efce.zip |
fontconfig mesa xkeyboard-config xserver pixman git update 10 Apr 2012
Diffstat (limited to 'mesalib/src/mesa/main/teximage.c')
-rw-r--r-- | mesalib/src/mesa/main/teximage.c | 295 |
1 files changed, 127 insertions, 168 deletions
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c index c54118212..23486467d 100644 --- a/mesalib/src/mesa/main/teximage.c +++ b/mesalib/src/mesa/main/teximage.c @@ -3746,228 +3746,186 @@ _mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, width, height, depth, format, imageSize, data); } - -/** - * Helper for glTexBuffer(). Check if internalFormat is legal. If so, - * return the basic data type and number of components for the format. - * \param return GL_TRUE if internalFormat is legal, GL_FALSE otherwise - */ -static GLboolean -get_sized_format_info(const struct gl_context *ctx, GLenum internalFormat, - GLenum *datatype, GLuint *components) +static gl_format +get_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat) { switch (internalFormat) { case GL_ALPHA8: - *datatype = GL_UNSIGNED_BYTE; - *components = 1; - break; + return MESA_FORMAT_A8; case GL_ALPHA16: - *datatype = GL_UNSIGNED_SHORT; - *components = 1; - break; + return MESA_FORMAT_A16; case GL_ALPHA16F_ARB: - *datatype = GL_HALF_FLOAT; - *components = 1; - break; + return MESA_FORMAT_ALPHA_FLOAT16; case GL_ALPHA32F_ARB: - *datatype = GL_FLOAT; - *components = 1; - break; + return MESA_FORMAT_ALPHA_FLOAT32; case GL_ALPHA8I_EXT: - *datatype = GL_BYTE; - *components = 1; - break; + return MESA_FORMAT_ALPHA_INT8; case GL_ALPHA16I_EXT: - *datatype = GL_SHORT; - *components = 1; - break; + return MESA_FORMAT_ALPHA_INT16; case GL_ALPHA32I_EXT: - *datatype = GL_INT; - *components = 1; - break; + return MESA_FORMAT_ALPHA_INT32; case GL_ALPHA8UI_EXT: - *datatype = GL_UNSIGNED_BYTE; - *components = 1; - break; + return MESA_FORMAT_ALPHA_UINT8; case GL_ALPHA16UI_EXT: - *datatype = GL_UNSIGNED_SHORT; - *components = 1; - break; + return MESA_FORMAT_ALPHA_UINT16; case GL_ALPHA32UI_EXT: - *datatype = GL_UNSIGNED_INT; - *components = 1; - break; + return MESA_FORMAT_ALPHA_UINT32; case GL_LUMINANCE8: - *datatype = GL_UNSIGNED_BYTE; - *components = 1; - break; + return MESA_FORMAT_L8; case GL_LUMINANCE16: - *datatype = GL_UNSIGNED_SHORT; - *components = 1; - break; + return MESA_FORMAT_L16; case GL_LUMINANCE16F_ARB: - *datatype = GL_HALF_FLOAT; - *components = 1; - break; + return MESA_FORMAT_LUMINANCE_FLOAT16; case GL_LUMINANCE32F_ARB: - *datatype = GL_FLOAT; - *components = 1; - break; + return MESA_FORMAT_LUMINANCE_FLOAT32; case GL_LUMINANCE8I_EXT: - *datatype = GL_BYTE; - *components = 1; - break; + return MESA_FORMAT_LUMINANCE_INT8; case GL_LUMINANCE16I_EXT: - *datatype = GL_SHORT; - *components = 1; - break; + return MESA_FORMAT_LUMINANCE_INT16; case GL_LUMINANCE32I_EXT: - *datatype = GL_INT; - *components = 1; - break; + return MESA_FORMAT_LUMINANCE_INT32; case GL_LUMINANCE8UI_EXT: - *datatype = GL_UNSIGNED_BYTE; - *components = 1; - break; + return MESA_FORMAT_LUMINANCE_UINT8; case GL_LUMINANCE16UI_EXT: - *datatype = GL_UNSIGNED_SHORT; - *components = 1; - break; + return MESA_FORMAT_LUMINANCE_UINT16; case GL_LUMINANCE32UI_EXT: - *datatype = GL_UNSIGNED_INT; - *components = 1; - break; + return MESA_FORMAT_LUMINANCE_UINT32; case GL_LUMINANCE8_ALPHA8: - *datatype = GL_UNSIGNED_BYTE; - *components = 2; - break; + return MESA_FORMAT_AL88; case GL_LUMINANCE16_ALPHA16: - *datatype = GL_UNSIGNED_SHORT; - *components = 2; - break; + return MESA_FORMAT_AL1616; case GL_LUMINANCE_ALPHA16F_ARB: - *datatype = GL_HALF_FLOAT; - *components = 2; - break; + return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16; case GL_LUMINANCE_ALPHA32F_ARB: - *datatype = GL_FLOAT; - *components = 2; - break; + return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32; case GL_LUMINANCE_ALPHA8I_EXT: - *datatype = GL_BYTE; - *components = 2; - break; + return MESA_FORMAT_LUMINANCE_ALPHA_INT8; case GL_LUMINANCE_ALPHA16I_EXT: - *datatype = GL_SHORT; - *components = 2; - break; + return MESA_FORMAT_LUMINANCE_ALPHA_INT8; case GL_LUMINANCE_ALPHA32I_EXT: - *datatype = GL_INT; - *components = 2; - break; + return MESA_FORMAT_LUMINANCE_ALPHA_INT16; case GL_LUMINANCE_ALPHA8UI_EXT: - *datatype = GL_UNSIGNED_BYTE; - *components = 2; - break; + return MESA_FORMAT_LUMINANCE_ALPHA_UINT8; case GL_LUMINANCE_ALPHA16UI_EXT: - *datatype = GL_UNSIGNED_SHORT; - *components = 2; - break; + return MESA_FORMAT_LUMINANCE_ALPHA_UINT16; case GL_LUMINANCE_ALPHA32UI_EXT: - *datatype = GL_UNSIGNED_INT; - *components = 2; - break; + return MESA_FORMAT_LUMINANCE_ALPHA_UINT32; case GL_INTENSITY8: - *datatype = GL_UNSIGNED_BYTE; - *components = 1; - break; + return MESA_FORMAT_I8; case GL_INTENSITY16: - *datatype = GL_UNSIGNED_SHORT; - *components = 1; - break; + return MESA_FORMAT_I16; case GL_INTENSITY16F_ARB: - *datatype = GL_HALF_FLOAT; - *components = 1; - break; + return MESA_FORMAT_INTENSITY_FLOAT16; case GL_INTENSITY32F_ARB: - *datatype = GL_FLOAT; - *components = 1; - break; + return MESA_FORMAT_INTENSITY_FLOAT32; case GL_INTENSITY8I_EXT: - *datatype = GL_BYTE; - *components = 1; - break; + return MESA_FORMAT_INTENSITY_INT8; case GL_INTENSITY16I_EXT: - *datatype = GL_SHORT; - *components = 1; - break; + return MESA_FORMAT_INTENSITY_INT16; case GL_INTENSITY32I_EXT: - *datatype = GL_INT; - *components = 1; - break; + return MESA_FORMAT_INTENSITY_INT32; case GL_INTENSITY8UI_EXT: - *datatype = GL_UNSIGNED_BYTE; - *components = 1; - break; + return MESA_FORMAT_INTENSITY_UINT8; case GL_INTENSITY16UI_EXT: - *datatype = GL_UNSIGNED_SHORT; - *components = 1; - break; + return MESA_FORMAT_INTENSITY_UINT16; case GL_INTENSITY32UI_EXT: - *datatype = GL_UNSIGNED_INT; - *components = 1; - break; + return MESA_FORMAT_INTENSITY_UINT32; case GL_RGBA8: - *datatype = GL_UNSIGNED_BYTE; - *components = 4; - break; + return MESA_FORMAT_RGBA8888_REV; case GL_RGBA16: - *datatype = GL_UNSIGNED_SHORT; - *components = 4; - break; + return MESA_FORMAT_RGBA_16; case GL_RGBA16F_ARB: - *datatype = GL_HALF_FLOAT; - *components = 4; - break; + return MESA_FORMAT_RGBA_FLOAT16; case GL_RGBA32F_ARB: - *datatype = GL_FLOAT; - *components = 4; - break; + return MESA_FORMAT_RGBA_FLOAT32; case GL_RGBA8I_EXT: - *datatype = GL_BYTE; - *components = 4; - break; + return MESA_FORMAT_RGBA_INT8; case GL_RGBA16I_EXT: - *datatype = GL_SHORT; - *components = 4; - break; + return MESA_FORMAT_RGBA_INT16; case GL_RGBA32I_EXT: - *datatype = GL_INT; - *components = 4; - break; + return MESA_FORMAT_RGBA_INT32; case GL_RGBA8UI_EXT: - *datatype = GL_UNSIGNED_BYTE; - *components = 4; - break; + return MESA_FORMAT_RGBA_UINT8; case GL_RGBA16UI_EXT: - *datatype = GL_UNSIGNED_SHORT; - *components = 4; - break; + return MESA_FORMAT_RGBA_UINT16; case GL_RGBA32UI_EXT: - *datatype = GL_UNSIGNED_INT; - *components = 4; - break; + return MESA_FORMAT_RGBA_UINT32; + + case GL_RG8: + return MESA_FORMAT_GR88; + case GL_RG16: + return MESA_FORMAT_RG1616; + case GL_RG16F: + return MESA_FORMAT_RG_FLOAT16; + case GL_RG32F: + return MESA_FORMAT_RG_FLOAT32; + case GL_RG8I: + return MESA_FORMAT_RG_INT8; + case GL_RG16I: + return MESA_FORMAT_RG_INT16; + case GL_RG32I: + return MESA_FORMAT_RG_INT32; + case GL_RG8UI: + return MESA_FORMAT_RG_UINT8; + case GL_RG16UI: + return MESA_FORMAT_RG_UINT16; + case GL_RG32UI: + return MESA_FORMAT_RG_UINT32; + + case GL_R8: + return MESA_FORMAT_R8; + case GL_R16: + return MESA_FORMAT_R16; + case GL_R16F: + return MESA_FORMAT_R_FLOAT16; + case GL_R32F: + return MESA_FORMAT_R_FLOAT32; + case GL_R8I: + return MESA_FORMAT_R_INT8; + case GL_R16I: + return MESA_FORMAT_R_INT16; + case GL_R32I: + return MESA_FORMAT_R_INT32; + case GL_R8UI: + return MESA_FORMAT_R_UINT8; + case GL_R16UI: + return MESA_FORMAT_R_UINT16; + case GL_R32UI: + return MESA_FORMAT_R_UINT32; + default: - return GL_FALSE; + return MESA_FORMAT_NONE; } +} - if (*datatype == GL_FLOAT && !ctx->Extensions.ARB_texture_float) - return GL_FALSE; +static gl_format +validate_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat) +{ + gl_format format = get_texbuffer_format(ctx, internalFormat); + GLenum datatype; - if (*datatype == GL_HALF_FLOAT && !ctx->Extensions.ARB_half_float_pixel) - return GL_FALSE; + if (format == MESA_FORMAT_NONE) + return MESA_FORMAT_NONE; - return GL_TRUE; + datatype = _mesa_get_format_datatype(format); + if (datatype == GL_FLOAT && !ctx->Extensions.ARB_texture_float) + return MESA_FORMAT_NONE; + + if (datatype == GL_HALF_FLOAT && !ctx->Extensions.ARB_half_float_pixel) + return MESA_FORMAT_NONE; + + /* The GL_ARB_texture_rg and GL_ARB_texture_buffer_object specs don't make + * any mention of R/RG formats, but they appear in the GL 3.1 core + * specification. + */ + if (ctx->VersionMajor < 3 || + (ctx->VersionMajor == 3 && ctx->VersionMinor == 0)) { + GLenum base_format = _mesa_get_format_base_format(format); + + if (base_format == GL_R || base_format == GL_RG) + return MESA_FORMAT_NONE; + } + return format; } @@ -3977,8 +3935,7 @@ _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer) { struct gl_texture_object *texObj; struct gl_buffer_object *bufObj; - GLenum dataType; - GLuint comps; + gl_format format; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); @@ -3993,7 +3950,8 @@ _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer) return; } - if (!get_sized_format_info(ctx, internalFormat, &dataType, &comps)) { + format = validate_texbuffer_format(ctx, internalFormat); + if (format == MESA_FORMAT_NONE) { _mesa_error(ctx, GL_INVALID_ENUM, "glTexBuffer(internalFormat 0x%x)", internalFormat); return; @@ -4011,6 +3969,7 @@ _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer) { _mesa_reference_buffer_object(ctx, &texObj->BufferObject, bufObj); texObj->BufferObjectFormat = internalFormat; + texObj->_BufferObjectFormat = format; } _mesa_unlock_texture(ctx, texObj); } |