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:
@@ -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]);
|
||||
|
@@ -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]);""",
|
||||
|
@@ -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) {
|
||||
|
@@ -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,
|
||||
|
@@ -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]) {
|
||||
|
Reference in New Issue
Block a user