Enable GL_ARB_texture_compression for XMesa/GLX driver. Texture
compression isn't really implmented. Just updated glTexImageXD() to accept compressed internal format tokens.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: xm_api.c,v 1.24 2001/06/04 22:33:02 brianp Exp $ */
|
/* $Id: xm_api.c,v 1.25 2001/06/15 14:18:46 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -77,6 +77,8 @@
|
|||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#endif
|
#endif
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
|
#include "texformat.h"
|
||||||
|
#include "texstore.h"
|
||||||
#include "swrast/swrast.h"
|
#include "swrast/swrast.h"
|
||||||
#include "swrast_setup/swrast_setup.h"
|
#include "swrast_setup/swrast_setup.h"
|
||||||
#include "array_cache/acache.h"
|
#include "array_cache/acache.h"
|
||||||
@@ -1634,6 +1636,10 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
|
|||||||
}
|
}
|
||||||
|
|
||||||
_mesa_enable_sw_extensions(ctx);
|
_mesa_enable_sw_extensions(ctx);
|
||||||
|
_mesa_enable_extension(ctx, "GL_ARB_texture_compression");
|
||||||
|
ctx->Driver.BaseCompressedTexFormat = _mesa_base_compressed_texformat;
|
||||||
|
ctx->Driver.CompressedTextureSize = _mesa_compressed_texture_size;
|
||||||
|
ctx->Driver.GetCompressedTexImage = _mesa_get_compressed_teximage;
|
||||||
|
|
||||||
if (CHECK_BYTE_ORDER(v)) {
|
if (CHECK_BYTE_ORDER(v)) {
|
||||||
c->swapbytes = GL_FALSE;
|
c->swapbytes = GL_FALSE;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: dd.h,v 1.61 2001/04/04 21:54:20 brianp Exp $ */
|
/* $Id: dd.h,v 1.62 2001/06/15 14:18:46 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -346,16 +346,12 @@ struct dd_function_table {
|
|||||||
* should do the job.
|
* should do the job.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GLboolean (*IsCompressedFormat)(GLcontext *ctx, GLint internalFormat);
|
|
||||||
/* Called to tell if a format is a compressed format.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void (*GetCompressedTexImage)( GLcontext *ctx, GLenum target,
|
void (*GetCompressedTexImage)( GLcontext *ctx, GLenum target,
|
||||||
GLint lod, void *image,
|
GLint level, void *image,
|
||||||
const struct gl_texture_object *texObj,
|
const struct gl_texture_object *texObj,
|
||||||
struct gl_texture_image *texImage );
|
struct gl_texture_image *texImage );
|
||||||
/* Called by glGetCompressedTexImageARB.
|
/* Called by glGetCompressedTexImageARB.
|
||||||
* <target>, <lod>, <image> are specified by user.
|
* <target>, <level>, <image> are specified by user.
|
||||||
* <texObj> is the source texture object.
|
* <texObj> is the source texture object.
|
||||||
* <texImage> is the source texture image.
|
* <texImage> is the source texture image.
|
||||||
*/
|
*/
|
||||||
@@ -368,6 +364,9 @@ struct dd_function_table {
|
|||||||
* Example: if internalFormat==GL_COMPRESSED_RGB_FXT1_3DFX, return GL_RGB.
|
* Example: if internalFormat==GL_COMPRESSED_RGB_FXT1_3DFX, return GL_RGB.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
GLint (*CompressedTextureSize)(GLcontext *ctx,
|
||||||
|
const struct gl_texture_image *texImage);
|
||||||
|
|
||||||
#if 000
|
#if 000
|
||||||
/* ... Note the
|
/* ... Note the
|
||||||
* return value differences between this function and
|
* return value differences between this function and
|
||||||
@@ -394,15 +393,6 @@ struct dd_function_table {
|
|||||||
* do the right thing with it.
|
* do the right thing with it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GLsizei (*CompressedImageSize)(GLcontext *ctx,
|
|
||||||
GLenum internalFormat,
|
|
||||||
GLuint numDimensions,
|
|
||||||
GLuint width,
|
|
||||||
GLuint height,
|
|
||||||
GLuint depth);
|
|
||||||
/* Calculate the size of a compressed image, given the image's
|
|
||||||
* format and dimensions.
|
|
||||||
*/
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/***
|
/***
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: extensions.c,v 1.61 2001/05/29 15:23:49 brianp Exp $ */
|
/* $Id: extensions.c,v 1.62 2001/06/15 14:18:46 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -203,6 +203,34 @@ _mesa_enable_imaging_extensions(GLcontext *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Enable all OpenGL 1.3 features and extensions.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
_mesa_enable_1_3_extensions(GLcontext *ctx)
|
||||||
|
{
|
||||||
|
const char *extensions[] = {
|
||||||
|
"GL_ARB_multisample",
|
||||||
|
"GL_ARB_multitexture",
|
||||||
|
"GL_ARB_texture_border_clamp",
|
||||||
|
"GL_ARB_texture_compression",
|
||||||
|
"GL_ARB_texture_cube_map",
|
||||||
|
"GL_ARB_texture_env_add",
|
||||||
|
"GL_ARB_texture_env_combine",
|
||||||
|
"GL_ARB_texture_env_dot3",
|
||||||
|
"GL_ARB_transpose_matrix",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
GLuint i;
|
||||||
|
|
||||||
|
for (i = 0; extensions[i]; i++) {
|
||||||
|
_mesa_enable_extension(ctx, extensions[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add a new extenstion. This would be called from a Mesa driver.
|
* Add a new extenstion. This would be called from a Mesa driver.
|
||||||
*/
|
*/
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: extensions.h,v 1.13 2001/03/12 00:48:37 gareth Exp $ */
|
/* $Id: extensions.h,v 1.14 2001/06/15 14:18:46 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -35,6 +35,8 @@ extern void _mesa_enable_sw_extensions(GLcontext *ctx);
|
|||||||
|
|
||||||
extern void _mesa_enable_imaging_extensions(GLcontext *ctx);
|
extern void _mesa_enable_imaging_extensions(GLcontext *ctx);
|
||||||
|
|
||||||
|
extern void _mesa_enable_1_3_extensions(GLcontext *ctx);
|
||||||
|
|
||||||
extern void _mesa_add_extension( GLcontext *ctx, GLboolean enabled,
|
extern void _mesa_add_extension( GLcontext *ctx, GLboolean enabled,
|
||||||
const char *name, GLboolean *flag_ptr );
|
const char *name, GLboolean *flag_ptr );
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: state.c,v 1.66 2001/05/29 15:23:49 brianp Exp $ */
|
/* $Id: state.c,v 1.67 2001/06/15 14:18:46 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -978,14 +978,16 @@ void _mesa_update_state( GLcontext *ctx )
|
|||||||
ASSERT(ctx->Driver.CopyTexSubImage2D);
|
ASSERT(ctx->Driver.CopyTexSubImage2D);
|
||||||
ASSERT(ctx->Driver.CopyTexSubImage3D);
|
ASSERT(ctx->Driver.CopyTexSubImage3D);
|
||||||
if (ctx->Extensions.ARB_texture_compression) {
|
if (ctx->Extensions.ARB_texture_compression) {
|
||||||
|
ASSERT(ctx->Driver.BaseCompressedTexFormat);
|
||||||
|
ASSERT(ctx->Driver.CompressedTextureSize);
|
||||||
|
ASSERT(ctx->Driver.GetCompressedTexImage);
|
||||||
|
#if 0 /* HW drivers need these, but not SW rasterizers */
|
||||||
ASSERT(ctx->Driver.CompressedTexImage1D);
|
ASSERT(ctx->Driver.CompressedTexImage1D);
|
||||||
ASSERT(ctx->Driver.CompressedTexImage2D);
|
ASSERT(ctx->Driver.CompressedTexImage2D);
|
||||||
ASSERT(ctx->Driver.CompressedTexImage3D);
|
ASSERT(ctx->Driver.CompressedTexImage3D);
|
||||||
ASSERT(ctx->Driver.CompressedTexSubImage1D);
|
ASSERT(ctx->Driver.CompressedTexSubImage1D);
|
||||||
ASSERT(ctx->Driver.CompressedTexSubImage2D);
|
ASSERT(ctx->Driver.CompressedTexSubImage2D);
|
||||||
ASSERT(ctx->Driver.CompressedTexSubImage3D);
|
ASSERT(ctx->Driver.CompressedTexSubImage3D);
|
||||||
ASSERT(ctx->Driver.IsCompressedFormat);
|
#endif
|
||||||
ASSERT(ctx->Driver.GetCompressedTexImage);
|
|
||||||
ASSERT(ctx->Driver.BaseCompressedTexFormat);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: texformat.c,v 1.10 2001/04/20 16:46:04 brianp Exp $ */
|
/* $Id: texformat.c,v 1.11 2001/06/15 14:18:46 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -469,10 +469,11 @@ _mesa_is_hardware_tex_format( const struct gl_texture_format *format )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Given an internal texture format or 1, 2, 3, 4 initialize the texture
|
/* Given an internal texture format (or 1, 2, 3, 4) return a pointer
|
||||||
* image structure's default format and type information. Drivers will
|
* to a gl_texture_format which which to store the texture.
|
||||||
* initialize these fields accordingly if they override the default
|
* This is called via ctx->Driver.ChooseTextureFormat().
|
||||||
* storage format.
|
* Hardware drivers should not use this function, but instead a
|
||||||
|
* specialized function.
|
||||||
*/
|
*/
|
||||||
const struct gl_texture_format *
|
const struct gl_texture_format *
|
||||||
_mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
|
_mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
|
||||||
@@ -560,13 +561,89 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
|
|||||||
case GL_DEPTH_COMPONENT16_SGIX:
|
case GL_DEPTH_COMPONENT16_SGIX:
|
||||||
case GL_DEPTH_COMPONENT24_SGIX:
|
case GL_DEPTH_COMPONENT24_SGIX:
|
||||||
case GL_DEPTH_COMPONENT32_SGIX:
|
case GL_DEPTH_COMPONENT32_SGIX:
|
||||||
if ( !ctx->Extensions.SGIX_depth_texture )
|
if (!ctx->Extensions.SGIX_depth_texture)
|
||||||
_mesa_problem( ctx, "depth format without GL_SGIX_depth_texture" );
|
_mesa_problem(ctx, "depth format without GL_SGIX_depth_texture");
|
||||||
return &_mesa_texformat_depth_component;
|
return &_mesa_texformat_depth_component;
|
||||||
|
|
||||||
|
case GL_COMPRESSED_ALPHA_ARB:
|
||||||
|
if (!ctx->Extensions.ARB_texture_compression)
|
||||||
|
_mesa_problem(ctx, "texture compression extension not enabled");
|
||||||
|
return &_mesa_texformat_alpha;
|
||||||
|
case GL_COMPRESSED_LUMINANCE_ARB:
|
||||||
|
if (!ctx->Extensions.ARB_texture_compression)
|
||||||
|
_mesa_problem(ctx, "texture compression extension not enabled");
|
||||||
|
return &_mesa_texformat_luminance;
|
||||||
|
case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
|
||||||
|
if (!ctx->Extensions.ARB_texture_compression)
|
||||||
|
_mesa_problem(ctx, "texture compression extension not enabled");
|
||||||
|
return &_mesa_texformat_luminance_alpha;
|
||||||
|
case GL_COMPRESSED_INTENSITY_ARB:
|
||||||
|
if (!ctx->Extensions.ARB_texture_compression)
|
||||||
|
_mesa_problem(ctx, "texture compression extension not enabled");
|
||||||
|
return &_mesa_texformat_intensity;
|
||||||
|
case GL_COMPRESSED_RGB_ARB:
|
||||||
|
if (!ctx->Extensions.ARB_texture_compression)
|
||||||
|
_mesa_problem(ctx, "texture compression extension not enabled");
|
||||||
|
return &_mesa_texformat_rgb;
|
||||||
|
case GL_COMPRESSED_RGBA_ARB:
|
||||||
|
if (!ctx->Extensions.ARB_texture_compression)
|
||||||
|
_mesa_problem(ctx, "texture compression extension not enabled");
|
||||||
|
return &_mesa_texformat_rgba;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
_mesa_problem( ctx, "unexpected format in _mesa_choose_tex_format()" );
|
_mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
|
||||||
printf("intformat = %d %x\n", internalFormat, internalFormat );
|
printf("intformat = %d %x\n", internalFormat, internalFormat);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the base texture format for the given compressed format
|
||||||
|
* Called via ctx->Driver.BaseCompressedTexFormat().
|
||||||
|
* This function is used by software rasterizers. Hardware drivers
|
||||||
|
* which support texture compression should not use this function but
|
||||||
|
* a specialized function instead.
|
||||||
|
*/
|
||||||
|
GLint
|
||||||
|
_mesa_base_compressed_texformat(GLcontext *ctx, GLint intFormat)
|
||||||
|
{
|
||||||
|
switch (intFormat) {
|
||||||
|
case GL_COMPRESSED_ALPHA_ARB:
|
||||||
|
return GL_ALPHA;
|
||||||
|
case GL_COMPRESSED_LUMINANCE_ARB:
|
||||||
|
return GL_LUMINANCE;
|
||||||
|
case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
|
||||||
|
return GL_LUMINANCE_ALPHA;
|
||||||
|
case GL_COMPRESSED_INTENSITY_ARB:
|
||||||
|
return GL_INTENSITY;
|
||||||
|
case GL_COMPRESSED_RGB_ARB:
|
||||||
|
return GL_RGB;
|
||||||
|
case GL_COMPRESSED_RGBA_ARB:
|
||||||
|
return GL_RGBA;
|
||||||
|
default:
|
||||||
|
return -1; /* not a recognized compressed format */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Called via ctx->Driver.CompressedTextureSize().
|
||||||
|
* This function is only used by software rasterizers.
|
||||||
|
* Hardware drivers will have to implement a specialized function.
|
||||||
|
*/
|
||||||
|
GLint
|
||||||
|
_mesa_compressed_texture_size(GLcontext *ctx,
|
||||||
|
const struct gl_texture_image *texImage)
|
||||||
|
{
|
||||||
|
GLint b;
|
||||||
|
assert(texImage);
|
||||||
|
assert(texImage->TexFormat);
|
||||||
|
|
||||||
|
b = texImage->Width * texImage->Height * texImage->Depth *
|
||||||
|
texImage->TexFormat->TexelBytes;
|
||||||
|
assert(b > 0);
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: texformat.h,v 1.6 2001/04/04 21:54:21 brianp Exp $ */
|
/* $Id: texformat.h,v 1.7 2001/06/15 14:18:46 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -90,6 +90,13 @@ extern const struct gl_texture_format *
|
|||||||
_mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
|
_mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
|
||||||
GLenum format, GLenum type );
|
GLenum format, GLenum type );
|
||||||
|
|
||||||
|
extern GLint
|
||||||
|
_mesa_base_compressed_texformat(GLcontext *ctx, GLint intFormat);
|
||||||
|
|
||||||
|
extern GLint
|
||||||
|
_mesa_compressed_texture_size(GLcontext *ctx,
|
||||||
|
const struct gl_texture_image *texImage);
|
||||||
|
|
||||||
|
|
||||||
/* The default formats, GLchan per component:
|
/* The default formats, GLchan per component:
|
||||||
*/
|
*/
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: teximage.c,v 1.97 2001/06/13 14:56:14 brianp Exp $ */
|
/* $Id: teximage.c,v 1.98 2001/06/15 14:18:46 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -307,10 +307,14 @@ is_index_format(GLenum format)
|
|||||||
static GLboolean
|
static GLboolean
|
||||||
is_compressed_format(GLcontext *ctx, GLenum internalFormat)
|
is_compressed_format(GLcontext *ctx, GLenum internalFormat)
|
||||||
{
|
{
|
||||||
if (ctx->Driver.IsCompressedFormat) {
|
if (ctx->Driver.BaseCompressedTexFormat) {
|
||||||
return (*ctx->Driver.IsCompressedFormat)(ctx, internalFormat);
|
GLint b = (*ctx->Driver.BaseCompressedTexFormat)(ctx, internalFormat);
|
||||||
}
|
if (b > 0)
|
||||||
return GL_FALSE;
|
return GL_TRUE;
|
||||||
|
else
|
||||||
|
return GL_FALSE;
|
||||||
|
}
|
||||||
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -593,6 +597,7 @@ _mesa_init_teximage_fields(GLcontext *ctx,
|
|||||||
{
|
{
|
||||||
ASSERT(img);
|
ASSERT(img);
|
||||||
img->Format = _mesa_base_tex_format( ctx, internalFormat );
|
img->Format = _mesa_base_tex_format( ctx, internalFormat );
|
||||||
|
ASSERT(img->Format > 0);
|
||||||
img->IntFormat = internalFormat;
|
img->IntFormat = internalFormat;
|
||||||
img->Border = border;
|
img->Border = border;
|
||||||
img->Width = width;
|
img->Width = width;
|
||||||
@@ -761,6 +766,8 @@ texture_error_check( GLcontext *ctx, GLenum target,
|
|||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ASSERT(iformat > 0);
|
||||||
|
|
||||||
if (!is_compressed_format( ctx, internalFormat ) &&
|
if (!is_compressed_format( ctx, internalFormat ) &&
|
||||||
!_mesa_is_legal_format_and_type( format, type )) {
|
!_mesa_is_legal_format_and_type( format, type )) {
|
||||||
/* Yes, generate GL_INVALID_OPERATION, not GL_INVALID_ENUM, if there
|
/* Yes, generate GL_INVALID_OPERATION, not GL_INVALID_ENUM, if there
|
||||||
@@ -796,6 +803,7 @@ subtexture_error_check( GLcontext *ctx, GLuint dimensions,
|
|||||||
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
|
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
|
||||||
struct gl_texture_image *destTex;
|
struct gl_texture_image *destTex;
|
||||||
GLint maxLevels = 0;
|
GLint maxLevels = 0;
|
||||||
|
GLboolean compressed;
|
||||||
|
|
||||||
if (dimensions == 1) {
|
if (dimensions == 1) {
|
||||||
if (target != GL_TEXTURE_1D) {
|
if (target != GL_TEXTURE_1D) {
|
||||||
@@ -898,14 +906,33 @@ subtexture_error_check( GLcontext *ctx, GLuint dimensions,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_compressed_format(ctx, destTex->IntFormat) &&
|
compressed = is_compressed_format(ctx, destTex->IntFormat);
|
||||||
!_mesa_is_legal_format_and_type(format, type)) {
|
|
||||||
|
if (!compressed && !_mesa_is_legal_format_and_type(format, type)) {
|
||||||
char message[100];
|
char message[100];
|
||||||
sprintf(message, "glTexSubImage%dD(format or type)", dimensions);
|
sprintf(message, "glTexSubImage%dD(format or type)", dimensions);
|
||||||
_mesa_error(ctx, GL_INVALID_ENUM, message);
|
_mesa_error(ctx, GL_INVALID_ENUM, message);
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (compressed) {
|
||||||
|
if (xoffset != -destTex->Border) {
|
||||||
|
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||||
|
"glTexSubImage1/2/3D(xoffset != -border");
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
if (dimensions > 1 && yoffset != -destTex->Border) {
|
||||||
|
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||||
|
"glTexSubImage2/3D(yoffset != -border");
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
if (dimensions > 2 && zoffset != -destTex->Border) {
|
||||||
|
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||||
|
"glTexSubImage3D(zoffset != -border");
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1019,6 +1046,7 @@ copytexsubimage_error_check( GLcontext *ctx, GLuint dimensions,
|
|||||||
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
|
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
|
||||||
struct gl_texture_image *teximage;
|
struct gl_texture_image *teximage;
|
||||||
GLint maxLevels = 0;
|
GLint maxLevels = 0;
|
||||||
|
GLboolean compressed;
|
||||||
|
|
||||||
if (dimensions == 1) {
|
if (dimensions == 1) {
|
||||||
if (target != GL_TEXTURE_1D) {
|
if (target != GL_TEXTURE_1D) {
|
||||||
@@ -1126,6 +1154,25 @@ copytexsubimage_error_check( GLcontext *ctx, GLuint dimensions,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compressed = is_compressed_format(ctx, teximage->IntFormat);
|
||||||
|
if (compressed) {
|
||||||
|
if (xoffset != -teximage->Border) {
|
||||||
|
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||||
|
"glCopyTexSubImage1/2/3D(xoffset != -border");
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
if (dimensions > 1 && yoffset != -teximage->Border) {
|
||||||
|
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||||
|
"glCopyTexSubImage2/3D(yoffset != -border");
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
if (dimensions > 2 && zoffset != -teximage->Border) {
|
||||||
|
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||||
|
"glCopyTexSubImage3D(zoffset != -border");
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* if we get here, the parameters are OK */
|
/* if we get here, the parameters are OK */
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
@@ -1329,6 +1376,10 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
|
|||||||
}
|
}
|
||||||
ASSERT(texImage->FetchTexel);
|
ASSERT(texImage->FetchTexel);
|
||||||
|
|
||||||
|
if (texImage->IsCompressed) {
|
||||||
|
ASSERT(texImage->CompressedSize > 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* state update */
|
/* state update */
|
||||||
texObj->Complete = GL_FALSE;
|
texObj->Complete = GL_FALSE;
|
||||||
ctx->NewState |= _NEW_TEXTURE;
|
ctx->NewState |= _NEW_TEXTURE;
|
||||||
@@ -1442,6 +1493,10 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
|
|||||||
}
|
}
|
||||||
ASSERT(texImage->FetchTexel);
|
ASSERT(texImage->FetchTexel);
|
||||||
|
|
||||||
|
if (texImage->IsCompressed) {
|
||||||
|
ASSERT(texImage->CompressedSize > 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* state update */
|
/* state update */
|
||||||
texObj->Complete = GL_FALSE;
|
texObj->Complete = GL_FALSE;
|
||||||
ctx->NewState |= _NEW_TEXTURE;
|
ctx->NewState |= _NEW_TEXTURE;
|
||||||
@@ -1551,6 +1606,10 @@ _mesa_TexImage3D( GLenum target, GLint level, GLenum internalFormat,
|
|||||||
}
|
}
|
||||||
ASSERT(texImage->FetchTexel);
|
ASSERT(texImage->FetchTexel);
|
||||||
|
|
||||||
|
if (texImage->IsCompressed) {
|
||||||
|
ASSERT(texImage->CompressedSize > 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* state update */
|
/* state update */
|
||||||
texObj->Complete = GL_FALSE;
|
texObj->Complete = GL_FALSE;
|
||||||
ctx->NewState |= _NEW_TEXTURE;
|
ctx->NewState |= _NEW_TEXTURE;
|
||||||
@@ -2416,7 +2475,7 @@ _mesa_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img)
|
|||||||
|
|
||||||
texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
|
texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
|
||||||
if (!texImage) {
|
if (!texImage) {
|
||||||
/* invalid mipmap level */
|
/* probably invalid mipmap level */
|
||||||
_mesa_error(ctx, GL_INVALID_VALUE, "glGetCompressedTexImageARB(level)");
|
_mesa_error(ctx, GL_INVALID_VALUE, "glGetCompressedTexImageARB(level)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: texstore.c,v 1.28 2001/06/13 14:56:14 brianp Exp $ */
|
/* $Id: texstore.c,v 1.29 2001/06/15 14:18:46 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -416,6 +416,8 @@ _mesa_transfer_teximage(GLcontext *ctx, GLuint dimensions,
|
|||||||
GLboolean freeSourceData = GL_FALSE;
|
GLboolean freeSourceData = GL_FALSE;
|
||||||
GLint postConvWidth = srcWidth, postConvHeight = srcHeight;
|
GLint postConvWidth = srcWidth, postConvHeight = srcHeight;
|
||||||
|
|
||||||
|
assert(baseInternalFormat > 0);
|
||||||
|
|
||||||
if (transferOps & IMAGE_CONVOLUTION_BIT) {
|
if (transferOps & IMAGE_CONVOLUTION_BIT) {
|
||||||
_mesa_adjust_image_for_convolution(ctx, dimensions, &postConvWidth,
|
_mesa_adjust_image_for_convolution(ctx, dimensions, &postConvWidth,
|
||||||
&postConvHeight);
|
&postConvHeight);
|
||||||
@@ -614,7 +616,7 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
|
|||||||
struct gl_texture_image *texImage)
|
struct gl_texture_image *texImage)
|
||||||
{
|
{
|
||||||
GLint postConvWidth = width;
|
GLint postConvWidth = width;
|
||||||
GLint texelBytes;
|
GLint texelBytes, sizeInBytes;
|
||||||
|
|
||||||
if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) {
|
if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) {
|
||||||
_mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL);
|
_mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL);
|
||||||
@@ -629,8 +631,19 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
|
|||||||
|
|
||||||
texelBytes = texImage->TexFormat->TexelBytes;
|
texelBytes = texImage->TexFormat->TexelBytes;
|
||||||
|
|
||||||
|
/* Compute image size, in bytes */
|
||||||
|
if (texImage->IsCompressed) {
|
||||||
|
assert(ctx->Driver.CompressedTextureSize);
|
||||||
|
sizeInBytes = ctx->Driver.CompressedTextureSize(ctx, texImage);
|
||||||
|
assert(sizeInBytes > 0);
|
||||||
|
texImage->CompressedSize = sizeInBytes;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sizeInBytes = postConvWidth * texelBytes;
|
||||||
|
}
|
||||||
|
|
||||||
/* allocate memory */
|
/* allocate memory */
|
||||||
texImage->Data = MALLOC(postConvWidth * texelBytes);
|
texImage->Data = MALLOC(sizeInBytes);
|
||||||
if (!texImage->Data) {
|
if (!texImage->Data) {
|
||||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
|
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
|
||||||
return;
|
return;
|
||||||
@@ -658,6 +671,8 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
|
|||||||
* The texture image format will be GL_COLOR_INDEX, GL_INTENSITY,
|
* The texture image format will be GL_COLOR_INDEX, GL_INTENSITY,
|
||||||
* GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_ALPHA, GL_RGB or GL_RGBA.
|
* GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_ALPHA, GL_RGB or GL_RGBA.
|
||||||
*
|
*
|
||||||
|
* NOTE: if real texture compression is supported, this whole function
|
||||||
|
* will need to be overridden.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
_mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
|
_mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
|
||||||
@@ -669,7 +684,7 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
|
|||||||
struct gl_texture_image *texImage)
|
struct gl_texture_image *texImage)
|
||||||
{
|
{
|
||||||
GLint postConvWidth = width, postConvHeight = height;
|
GLint postConvWidth = width, postConvHeight = height;
|
||||||
GLint texelBytes;
|
GLint texelBytes, sizeInBytes;
|
||||||
|
|
||||||
if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) {
|
if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) {
|
||||||
_mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth,
|
_mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth,
|
||||||
@@ -685,8 +700,19 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
|
|||||||
|
|
||||||
texelBytes = texImage->TexFormat->TexelBytes;
|
texelBytes = texImage->TexFormat->TexelBytes;
|
||||||
|
|
||||||
|
/* Compute image size, in bytes */
|
||||||
|
if (texImage->IsCompressed) {
|
||||||
|
assert(ctx->Driver.CompressedTextureSize);
|
||||||
|
sizeInBytes = ctx->Driver.CompressedTextureSize(ctx, texImage);
|
||||||
|
assert(sizeInBytes > 0);
|
||||||
|
texImage->CompressedSize = sizeInBytes;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sizeInBytes = postConvWidth * postConvHeight * texelBytes;
|
||||||
|
}
|
||||||
|
|
||||||
/* allocate memory */
|
/* allocate memory */
|
||||||
texImage->Data = MALLOC(postConvWidth * postConvHeight * texelBytes);
|
texImage->Data = MALLOC(sizeInBytes);
|
||||||
if (!texImage->Data) {
|
if (!texImage->Data) {
|
||||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
|
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
|
||||||
return;
|
return;
|
||||||
@@ -725,7 +751,7 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
|
|||||||
struct gl_texture_object *texObj,
|
struct gl_texture_object *texObj,
|
||||||
struct gl_texture_image *texImage)
|
struct gl_texture_image *texImage)
|
||||||
{
|
{
|
||||||
GLint texelBytes;
|
GLint texelBytes, sizeInBytes;
|
||||||
|
|
||||||
/* choose the texture format */
|
/* choose the texture format */
|
||||||
assert(ctx->Driver.ChooseTextureFormat);
|
assert(ctx->Driver.ChooseTextureFormat);
|
||||||
@@ -736,8 +762,19 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
|
|||||||
|
|
||||||
texelBytes = texImage->TexFormat->TexelBytes;
|
texelBytes = texImage->TexFormat->TexelBytes;
|
||||||
|
|
||||||
|
/* Compute image size, in bytes */
|
||||||
|
if (texImage->IsCompressed) {
|
||||||
|
assert(ctx->Driver.CompressedTextureSize);
|
||||||
|
sizeInBytes = ctx->Driver.CompressedTextureSize(ctx, texImage);
|
||||||
|
assert(sizeInBytes > 0);
|
||||||
|
texImage->CompressedSize = sizeInBytes;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sizeInBytes = width * height * depth * texelBytes;
|
||||||
|
}
|
||||||
|
|
||||||
/* allocate memory */
|
/* allocate memory */
|
||||||
texImage->Data = MALLOC(width * height * depth * texelBytes);
|
texImage->Data = MALLOC(sizeInBytes);
|
||||||
if (!texImage->Data) {
|
if (!texImage->Data) {
|
||||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
|
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
|
||||||
return;
|
return;
|
||||||
@@ -904,6 +941,25 @@ _mesa_store_compressed_teximage3d(GLcontext *ctx, GLenum target, GLint level,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fallback for Driver.GetCompressedTexImage3D()
|
||||||
|
* This will probably work find for hardware drivers. That is, hardware
|
||||||
|
* drivers won't have to override this function, unless the compressed
|
||||||
|
* texture must first be fetched from the TRAM.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
_mesa_get_compressed_teximage(GLcontext *ctx, GLenum target,
|
||||||
|
GLint level, void *image,
|
||||||
|
const struct gl_texture_object *texObj,
|
||||||
|
struct gl_texture_image *texImage)
|
||||||
|
{
|
||||||
|
assert(texImage->IsCompressed);
|
||||||
|
assert(texImage->CompressedSize > 0);
|
||||||
|
MEMCPY(image, texImage->Data, texImage->CompressedSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the fallback for Driver.TestProxyTexImage().
|
* This is the fallback for Driver.TestProxyTexImage().
|
||||||
*/
|
*/
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: texstore.h,v 1.8 2001/05/21 16:41:04 brianp Exp $ */
|
/* $Id: texstore.h,v 1.9 2001/06/15 14:18:46 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -135,6 +135,13 @@ _mesa_store_compressed_teximage3d(GLcontext *ctx, GLenum target, GLint level,
|
|||||||
struct gl_texture_image *texImage);
|
struct gl_texture_image *texImage);
|
||||||
|
|
||||||
|
|
||||||
|
extern void
|
||||||
|
_mesa_get_compressed_teximage(GLcontext *ctx, GLenum target,
|
||||||
|
GLint level, void *image,
|
||||||
|
const struct gl_texture_object *texObj,
|
||||||
|
struct gl_texture_image *texImage);
|
||||||
|
|
||||||
|
|
||||||
extern GLboolean
|
extern GLboolean
|
||||||
_mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
|
_mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
|
||||||
GLint internalFormat, GLenum format, GLenum type,
|
GLint internalFormat, GLenum format, GLenum type,
|
||||||
|
Reference in New Issue
Block a user