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.
This commit is contained in:
Brian Paul
2006-05-09 13:51:17 +00:00
parent 5e4c39dc0e
commit 008ed1df83
5 changed files with 31 additions and 21 deletions

View File

@@ -1068,13 +1068,13 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
break; break;
case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB: case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXT1(ARB_texture_compression, "GetBooleanv"); 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; break;
case GL_COMPRESSED_TEXTURE_FORMATS_ARB: case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXT1(ARB_texture_compression, "GetBooleanv"); CHECK_EXT1(ARB_texture_compression, "GetBooleanv");
{ {
GLint formats[100]; 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); ASSERT(n <= 100);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
params[i] = ENUM_TO_INT(formats[i]); params[i] = ENUM_TO_INT(formats[i]);
@@ -2886,13 +2886,13 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
break; break;
case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB: case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXT1(ARB_texture_compression, "GetFloatv"); 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; break;
case GL_COMPRESSED_TEXTURE_FORMATS_ARB: case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXT1(ARB_texture_compression, "GetFloatv"); CHECK_EXT1(ARB_texture_compression, "GetFloatv");
{ {
GLint formats[100]; 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); ASSERT(n <= 100);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
params[i] = ENUM_TO_INT(formats[i]); params[i] = ENUM_TO_INT(formats[i]);
@@ -4704,13 +4704,13 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
break; break;
case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB: case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXT1(ARB_texture_compression, "GetIntegerv"); 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; break;
case GL_COMPRESSED_TEXTURE_FORMATS_ARB: case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXT1(ARB_texture_compression, "GetIntegerv"); CHECK_EXT1(ARB_texture_compression, "GetIntegerv");
{ {
GLint formats[100]; 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); ASSERT(n <= 100);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
params[i] = ENUM_TO_INT(formats[i]); params[i] = ENUM_TO_INT(formats[i]);

View File

@@ -516,11 +516,12 @@ StateVars = [
( "GL_TEXTURE_COMPRESSION_HINT_ARB", GLint, ( "GL_TEXTURE_COMPRESSION_HINT_ARB", GLint,
["ctx->Hint.TextureCompression"], "", ["ARB_texture_compression"] ), ["ctx->Hint.TextureCompression"], "", ["ARB_texture_compression"] ),
( "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB", GLint, ( "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, ( "GL_COMPRESSED_TEXTURE_FORMATS_ARB", GLenum,
[], [],
"""GLint formats[100]; """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); ASSERT(n <= 100);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
params[i] = ENUM_TO_INT(formats[i]);""", params[i] = ENUM_TO_INT(formats[i]);""",

View File

@@ -1,8 +1,8 @@
/* /*
* Mesa 3-D graphics library * 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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -38,16 +38,21 @@
#include "texformat.h" #include "texformat.h"
#include "texstore.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 ctx the GL context
* \param formats the resulting format list (may be NULL). * \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. * \return number of formats.
*/ */
GLuint GLuint
_mesa_get_compressed_formats( GLcontext *ctx, GLint *formats ) _mesa_get_compressed_formats(GLcontext *ctx, GLint *formats, GLboolean all)
{ {
GLuint n = 0; GLuint n = 0;
if (ctx->Extensions.ARB_texture_compression) { 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 (ctx->Extensions.EXT_texture_compression_s3tc) {
if (formats) { if (formats) {
formats[n++] = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; formats[n++] = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
/* Skip this one because it has a restriction (all transparent /* This format has some restrictions/limitations and so should
* pixels become black). See the texture compressions spec for * not be returned via the GL_COMPRESSED_TEXTURE_FORMATS query.
* a detailed explanation. This is what NVIDIA does. * Specifically, all transparent pixels become black. NVIDIA
formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; * 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_DXT3_EXT;
formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
} }
else { else {
n += 3; n += 3;
if (all)
n += 1;
} }
} }
if (ctx->Extensions.S3_s3tc) { if (ctx->Extensions.S3_s3tc) {

View File

@@ -30,7 +30,7 @@
#if _HAVE_FULL_GL #if _HAVE_FULL_GL
extern GLuint extern GLuint
_mesa_get_compressed_formats( GLcontext *ctx, GLint *formats ); _mesa_get_compressed_formats(GLcontext *ctx, GLint *formats, GLboolean all);
extern GLuint extern GLuint
_mesa_compressed_texture_size( GLcontext *ctx, _mesa_compressed_texture_size( GLcontext *ctx,

View File

@@ -536,7 +536,7 @@ is_compressed_format(GLcontext *ctx, GLenum internalFormat)
GLint supported[100]; /* 100 should be plenty */ GLint supported[100]; /* 100 should be plenty */
GLuint i, n; GLuint i, n;
n = _mesa_get_compressed_formats(ctx, supported); n = _mesa_get_compressed_formats(ctx, supported, GL_TRUE);
ASSERT(n < 100); ASSERT(n < 100);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if ((GLint) internalFormat == supported[i]) { if ((GLint) internalFormat == supported[i]) {