mesa: Add RGTC texture store/fetch support.

This adds support for the RGTC unsigned and signed
texture storage and fetch methods.

the code is a port of the DXT5 alpha compression code.

Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
Dave Airlie 2011-02-22 10:35:15 +10:00
parent e792e79f5a
commit 8d47c91985
8 changed files with 1287 additions and 3 deletions

View file

@ -890,7 +890,43 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
16, 16, 16, 16,
0, 0, 0, 0, 0,
1, 1, 8
}
},
{
MESA_FORMAT_RED_RGTC1,
"MESA_FORMAT_RED_RGTC1",
GL_RED,
GL_UNSIGNED_NORMALIZED,
4, 0, 0, 0,
0, 0, 0, 0, 0,
4, 4, 8 /* 8 bytes per 4x4 block */
},
{
MESA_FORMAT_SIGNED_RED_RGTC1,
"MESA_FORMAT_SIGNED_RED_RGTC1",
GL_RED,
GL_SIGNED_NORMALIZED,
4, 0, 0, 0,
0, 0, 0, 0, 0,
4, 4, 8 /* 8 bytes per 4x4 block */
},
{
MESA_FORMAT_RG_RGTC2,
"MESA_FORMAT_RG_RGTC2",
GL_RG,
GL_UNSIGNED_NORMALIZED,
4, 4, 0, 0,
0, 0, 0, 0, 0,
4, 4, 16 /* 16 bytes per 4x4 block */
},
{
MESA_FORMAT_SIGNED_RG_RGTC2,
"MESA_FORMAT_SIGNED_RG_RGTC2",
GL_RG,
GL_SIGNED_NORMALIZED,
4, 4, 0, 0,
0, 0, 0, 0, 0,
4, 4, 16 /* 16 bytes per 4x4 block */
},
};
@ -1530,6 +1566,10 @@ _mesa_format_to_type_and_comps(gl_format format,
case MESA_FORMAT_SRGBA_DXT5:
#endif
#endif
case MESA_FORMAT_RED_RGTC1:
case MESA_FORMAT_SIGNED_RED_RGTC1:
case MESA_FORMAT_RG_RGTC2:
case MESA_FORMAT_SIGNED_RG_RGTC2:
/* XXX generate error instead? */
*datatype = GL_UNSIGNED_BYTE;
*comps = 0;

View file

@ -179,6 +179,12 @@ typedef enum
MESA_FORMAT_RGBA_16, /* ... */
/*@}*/
/*@{*/
MESA_FORMAT_RED_RGTC1,
MESA_FORMAT_SIGNED_RED_RGTC1,
MESA_FORMAT_RG_RGTC2,
MESA_FORMAT_SIGNED_RG_RGTC2,
/*@}*/
MESA_FORMAT_COUNT
} gl_format;

View file

@ -64,6 +64,7 @@ _mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats, GLboolean a
n += 2;
}
}
/* don't return RGTC - ARB_texture_compression_rgtc query 19 */
if (ctx->Extensions.EXT_texture_compression_s3tc) {
if (formats) {
formats[n++] = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
@ -163,6 +164,15 @@ _mesa_glenum_to_compressed_format(GLenum format)
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
return MESA_FORMAT_SRGBA_DXT5;
case GL_COMPRESSED_RED_RGTC1:
return MESA_FORMAT_RED_RGTC1;
case GL_COMPRESSED_SIGNED_RED_RGTC1:
return MESA_FORMAT_SIGNED_RED_RGTC1;
case GL_COMPRESSED_RG_RGTC2:
return MESA_FORMAT_RG_RGTC2;
case GL_COMPRESSED_SIGNED_RG_RGTC2:
return MESA_FORMAT_SIGNED_RG_RGTC2;
default:
return MESA_FORMAT_NONE;
}
@ -209,6 +219,16 @@ _mesa_compressed_format_to_glenum(struct gl_context *ctx, GLuint mesaFormat)
return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
#endif
#endif
case MESA_FORMAT_RED_RGTC1:
return GL_COMPRESSED_RED_RGTC1;
case MESA_FORMAT_SIGNED_RED_RGTC1:
return GL_COMPRESSED_SIGNED_RED_RGTC1;
case MESA_FORMAT_RG_RGTC2:
return GL_COMPRESSED_RG_RGTC2;
case MESA_FORMAT_SIGNED_RG_RGTC2:
return GL_COMPRESSED_SIGNED_RG_RGTC2;
default:
_mesa_problem(ctx, "Unexpected mesa texture format in"
" _mesa_compressed_format_to_glenum()");

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,60 @@
/*
* Copyright (C) 2011 Red Hat Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef TEXCOMPRESS_RGTC_H
#define TEXCOMPRESS_RGTC_H
#include "glheader.h"
#include "mfeatures.h"
#include "texstore.h"
struct gl_texture_image;
extern GLboolean
_mesa_texstore_red_rgtc1(TEXSTORE_PARAMS);
extern GLboolean
_mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS);
extern GLboolean
_mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS);
extern GLboolean
_mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS);
extern void
_mesa_fetch_texel_2d_f_red_rgtc1(const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel);
extern void
_mesa_fetch_texel_2d_f_signed_red_rgtc1(const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel);
extern void
_mesa_fetch_texel_2d_f_rg_rgtc2(const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel);
extern void
_mesa_fetch_texel_2d_f_signed_rg_rgtc2(const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel);
#endif

View file

@ -38,6 +38,7 @@
#include "texcompress.h"
#include "texcompress_fxt1.h"
#include "texcompress_s3tc.h"
#include "texcompress_rgtc.h"
#include "texfetch.h"
#include "teximage.h"
@ -756,7 +757,35 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
fetch_texel_2d_rgba_16,
fetch_texel_3d_rgba_16,
store_texel_rgba_16
}
},
{
MESA_FORMAT_RED_RGTC1,
NULL,
_mesa_fetch_texel_2d_f_red_rgtc1,
NULL,
NULL
},
{
MESA_FORMAT_SIGNED_RED_RGTC1,
NULL,
_mesa_fetch_texel_2d_f_signed_red_rgtc1,
NULL,
NULL
},
{
MESA_FORMAT_RG_RGTC2,
NULL,
_mesa_fetch_texel_2d_f_rg_rgtc2,
NULL,
NULL
},
{
MESA_FORMAT_SIGNED_RG_RGTC2,
NULL,
_mesa_fetch_texel_2d_f_signed_rg_rgtc2,
NULL,
NULL
},
};

View file

@ -65,6 +65,7 @@
#include "pack.h"
#include "texcompress.h"
#include "texcompress_fxt1.h"
#include "texcompress_rgtc.h"
#include "texcompress_s3tc.h"
#include "teximage.h"
#include "texstore.h"
@ -4128,7 +4129,12 @@ texstore_funcs[MESA_FORMAT_COUNT] =
{ MESA_FORMAT_SIGNED_RG_16, _mesa_texstore_signed_rgba_16 },
{ MESA_FORMAT_SIGNED_RGB_16, _mesa_texstore_signed_rgba_16 },
{ MESA_FORMAT_SIGNED_RGBA_16, _mesa_texstore_signed_rgba_16 },
{ MESA_FORMAT_RGBA_16, _mesa_texstore_rgba_16 }
{ MESA_FORMAT_RGBA_16, _mesa_texstore_rgba_16 },
{ MESA_FORMAT_RED_RGTC1, _mesa_texstore_red_rgtc1 },
{ MESA_FORMAT_SIGNED_RED_RGTC1, _mesa_texstore_signed_red_rgtc1 },
{ MESA_FORMAT_RG_RGTC2, _mesa_texstore_rg_rgtc2 },
{ MESA_FORMAT_SIGNED_RG_RGTC2, _mesa_texstore_signed_rg_rgtc2 }
};

View file

@ -78,6 +78,7 @@ MAIN_SOURCES = \
main/stencil.c \
main/syncobj.c \
main/texcompress.c \
main/texcompress_rgtc.c \
main/texcompress_s3tc.c \
main/texcompress_fxt1.c \
main/texenv.c \