From c6a6cc191813e8343a17b028146a34f193a6ce44 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Fri, 27 Mar 2009 19:39:52 +0100 Subject: mesa: add new signed rgba texture format This is a (partial) backport of the signed texture format support in OGL 3.1. Since it wasn't promoted from an existing extension roll our own. --- src/mesa/main/texformat.c | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) (limited to 'src/mesa/main/texformat.c') diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c index c372b49398..0ceaaf3ece 100644 --- a/src/mesa/main/texformat.c +++ b/src/mesa/main/texformat.c @@ -699,9 +699,7 @@ const struct gl_texture_format _mesa_texformat_intensity_float16 = { const struct gl_texture_format _mesa_texformat_dudv8 = { MESA_FORMAT_DUDV8, /* MesaFormat */ GL_DUDV_ATI, /* BaseFormat */ - /* FIXME: spec doesn't say since that parameter didn't exist then, - but this should be something like SIGNED_NORMALIZED */ - GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ + GL_SIGNED_NORMALIZED, /* DataType */ /* maybe should add dudvBits field, but spec seems to be lacking the ability to query with GetTexLevelParameter anyway */ 0, /* RedBits */ @@ -724,6 +722,30 @@ const struct gl_texture_format _mesa_texformat_dudv8 = { NULL /* StoreTexel */ }; +const struct gl_texture_format _mesa_texformat_signed_rgba8888 = { + MESA_FORMAT_SIGNED_RGBA8888, /* MesaFormat */ + GL_RGBA, /* BaseFormat */ + GL_SIGNED_NORMALIZED, /* DataType */ + 8, /* RedBits */ + 8, /* GreenBits */ + 8, /* BlueBits */ + 8, /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ + 0, /* DepthBits */ + 0, /* StencilBits */ + 4, /* TexelBytes */ + _mesa_texstore_signed_rgba8888, /* StoreTexImageFunc */ + NULL, /* FetchTexel1D */ + NULL, /* FetchTexel2D */ + NULL, /* FetchTexel3D */ + fetch_texel_1d_signed_rgba8888, /* FetchTexel1Df */ + fetch_texel_2d_signed_rgba8888, /* FetchTexel2Df */ + fetch_texel_3d_signed_rgba8888, /* FetchTexel3Df */ + store_texel_signed_rgba8888 /* StoreTexel */ +}; + /*@}*/ @@ -1671,6 +1693,17 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat, } } + if (ctx->Extensions.MESA_texture_signed_rgba) { + switch (internalFormat) { + case GL_RGBA_SNORM: + case GL_RGBA8_SNORM: + return &_mesa_texformat_signed_rgba8888; + default: + ; /* fallthrough */ + } + } + + #if FEATURE_EXT_texture_sRGB if (ctx->Extensions.EXT_texture_sRGB) { switch (internalFormat) { @@ -1820,6 +1853,11 @@ _mesa_format_to_type_and_comps(const struct gl_texture_format *format, *comps = 2; return; + case MESA_FORMAT_SIGNED_RGBA8888: + *datatype = GL_BYTE; + *comps = 4; + return; + #if FEATURE_EXT_texture_sRGB case MESA_FORMAT_SRGB8: *datatype = GL_UNSIGNED_BYTE; -- cgit v1.2.3