summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2006-05-09 13:51:17 +0000
committerBrian Paul <[email protected]>2006-05-09 13:51:17 +0000
commit008ed1df83735c72c2731c509a3665938d3c7209 (patch)
treef08ae0c53abfa916f28f408d8dac17ab5b3725c5 /src
parent5e4c39dc0e0fd6bc4324aa9030430822348aa3b4 (diff)
Add a new 'all' parameter to _mesa_get_compressed_formats() to indicate whether
all formats or just those without restrictions/limitations should be returned. We want all when validating the internalFormat parameter to glCompressedTexImage2D but only want unrestricted formats when handling the GL_COMPRESSED_TEXTURE_FORMATS query.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/get.c12
-rw-r--r--src/mesa/main/get_gen.py5
-rw-r--r--src/mesa/main/texcompress.c31
-rw-r--r--src/mesa/main/texcompress.h2
-rw-r--r--src/mesa/main/teximage.c2
5 files changed, 31 insertions, 21 deletions
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 9684ccb8a44..2e2da7d933d 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1068,13 +1068,13 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
break;
case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXT1(ARB_texture_compression, "GetBooleanv");
- params[0] = INT_TO_BOOLEAN(_mesa_get_compressed_formats(ctx, NULL));
+ params[0] = INT_TO_BOOLEAN(_mesa_get_compressed_formats(ctx, NULL, GL_FALSE));
break;
case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXT1(ARB_texture_compression, "GetBooleanv");
{
GLint formats[100];
- GLuint i, n = _mesa_get_compressed_formats(ctx, formats);
+ GLuint i, n = _mesa_get_compressed_formats(ctx, formats, GL_FALSE);
ASSERT(n <= 100);
for (i = 0; i < n; i++)
params[i] = ENUM_TO_INT(formats[i]);
@@ -2886,13 +2886,13 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
break;
case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXT1(ARB_texture_compression, "GetFloatv");
- params[0] = (GLfloat)(_mesa_get_compressed_formats(ctx, NULL));
+ params[0] = (GLfloat)(_mesa_get_compressed_formats(ctx, NULL, GL_FALSE));
break;
case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXT1(ARB_texture_compression, "GetFloatv");
{
GLint formats[100];
- GLuint i, n = _mesa_get_compressed_formats(ctx, formats);
+ GLuint i, n = _mesa_get_compressed_formats(ctx, formats, GL_FALSE);
ASSERT(n <= 100);
for (i = 0; i < n; i++)
params[i] = ENUM_TO_INT(formats[i]);
@@ -4704,13 +4704,13 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
break;
case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXT1(ARB_texture_compression, "GetIntegerv");
- params[0] = _mesa_get_compressed_formats(ctx, NULL);
+ params[0] = _mesa_get_compressed_formats(ctx, NULL, GL_FALSE);
break;
case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXT1(ARB_texture_compression, "GetIntegerv");
{
GLint formats[100];
- GLuint i, n = _mesa_get_compressed_formats(ctx, formats);
+ GLuint i, n = _mesa_get_compressed_formats(ctx, formats, GL_FALSE);
ASSERT(n <= 100);
for (i = 0; i < n; i++)
params[i] = ENUM_TO_INT(formats[i]);
diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py
index 63aed5ab252..78d50663550 100644
--- a/src/mesa/main/get_gen.py
+++ b/src/mesa/main/get_gen.py
@@ -516,11 +516,12 @@ StateVars = [
( "GL_TEXTURE_COMPRESSION_HINT_ARB", GLint,
["ctx->Hint.TextureCompression"], "", ["ARB_texture_compression"] ),
( "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB", GLint,
- ["_mesa_get_compressed_formats(ctx, NULL)"], "", ["ARB_texture_compression"] ),
+ ["_mesa_get_compressed_formats(ctx, NULL, GL_FALSE)"],
+ "", ["ARB_texture_compression"] ),
( "GL_COMPRESSED_TEXTURE_FORMATS_ARB", GLenum,
[],
"""GLint formats[100];
- GLuint i, n = _mesa_get_compressed_formats(ctx, formats);
+ GLuint i, n = _mesa_get_compressed_formats(ctx, formats, GL_FALSE);
ASSERT(n <= 100);
for (i = 0; i < n; i++)
params[i] = ENUM_TO_INT(formats[i]);""",
diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c
index 0a92c926836..2516339e112 100644
--- a/src/mesa/main/texcompress.c
+++ b/src/mesa/main/texcompress.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.1
+ * Version: 6.5.1
*
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -38,16 +38,21 @@
#include "texformat.h"
#include "texstore.h"
+
/**
- * Get the list of supported internal compression formats.
+ * Return list of (and count of) all specific texture compression
+ * formats that are supported.
*
- * \param ctx GL context.
- * \param formats the resulting format list (may be NULL).
+ * \param ctx the GL context
+ * \param formats the resulting format list (may be NULL).
+ * \param all if true return all formats, even those with some kind
+ * of restrictions/limitations (See GL_ARB_texture_compression
+ * spec for more info).
*
* \return number of formats.
*/
GLuint
-_mesa_get_compressed_formats( GLcontext *ctx, GLint *formats )
+_mesa_get_compressed_formats(GLcontext *ctx, GLint *formats, GLboolean all)
{
GLuint n = 0;
if (ctx->Extensions.ARB_texture_compression) {
@@ -63,16 +68,20 @@ _mesa_get_compressed_formats( GLcontext *ctx, GLint *formats )
if (ctx->Extensions.EXT_texture_compression_s3tc) {
if (formats) {
formats[n++] = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
- /* Skip this one because it has a restriction (all transparent
- * pixels become black). See the texture compressions spec for
- * a detailed explanation. This is what NVIDIA does.
- formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
- */
+ /* This format has some restrictions/limitations and so should
+ * not be returned via the GL_COMPRESSED_TEXTURE_FORMATS query.
+ * Specifically, all transparent pixels become black. NVIDIA
+ * omits this format too.
+ */
+ if (all)
+ formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
}
else {
n += 3;
+ if (all)
+ n += 1;
}
}
if (ctx->Extensions.S3_s3tc) {
diff --git a/src/mesa/main/texcompress.h b/src/mesa/main/texcompress.h
index 5b5e64e15dd..44f33382228 100644
--- a/src/mesa/main/texcompress.h
+++ b/src/mesa/main/texcompress.h
@@ -30,7 +30,7 @@
#if _HAVE_FULL_GL
extern GLuint
-_mesa_get_compressed_formats( GLcontext *ctx, GLint *formats );
+_mesa_get_compressed_formats(GLcontext *ctx, GLint *formats, GLboolean all);
extern GLuint
_mesa_compressed_texture_size( GLcontext *ctx,
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index f993e219581..91a96e871b0 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -536,7 +536,7 @@ is_compressed_format(GLcontext *ctx, GLenum internalFormat)
GLint supported[100]; /* 100 should be plenty */
GLuint i, n;
- n = _mesa_get_compressed_formats(ctx, supported);
+ n = _mesa_get_compressed_formats(ctx, supported, GL_TRUE);
ASSERT(n < 100);
for (i = 0; i < n; i++) {
if ((GLint) internalFormat == supported[i]) {