-# $Id: Makefile.X11,v 1.68 2002/06/13 04:28:29 brianp Exp $
+# $Id: Makefile.X11,v 1.69 2002/09/27 02:45:37 brianp Exp $
# Mesa 3-D graphics library
# Version: 4.1
rastpos.c \
state.c \
stencil.c \
+ texcompress.c \
texformat.c \
teximage.c \
texobj.c \
ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;\r
ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;\r
\r
+ ctx->Driver.CompressedTexImage1D = _mesa_store_compressed_teximage1d;\r
+ ctx->Driver.CompressedTexImage2D = _mesa_store_compressed_teximage2d;\r
+ ctx->Driver.CompressedTexImage3D = _mesa_store_compressed_teximage3d;\r
+ ctx->Driver.CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;\r
+ ctx->Driver.CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;\r
+ ctx->Driver.CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;\r
+\r
ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;\r
ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;\r
ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;\r
ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;\r
ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;\r
\r
- ctx->Driver.BaseCompressedTexFormat = _mesa_base_compressed_texformat;\r
- ctx->Driver.CompressedTextureSize = _mesa_compressed_texture_size;\r
- ctx->Driver.GetCompressedTexImage = _mesa_get_compressed_teximage;\r
-\r
/* Swrast hooks for imaging extensions:\r
*/\r
ctx->Driver.CopyColorTable = _swrast_CopyColorTable;\r
ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
+ ctx->Driver.CompressedTexImage1D = _mesa_store_compressed_teximage1d;
+ ctx->Driver.CompressedTexImage2D = _mesa_store_compressed_teximage2d;
+ ctx->Driver.CompressedTexImage3D = _mesa_store_compressed_teximage3d;
+ ctx->Driver.CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
+ ctx->Driver.CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
+ ctx->Driver.CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
+
ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;
ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;
- ctx->Driver.BaseCompressedTexFormat = _mesa_base_compressed_texformat;
- ctx->Driver.CompressedTextureSize = _mesa_compressed_texture_size;
- ctx->Driver.GetCompressedTexImage = _mesa_get_compressed_teximage;
-
/* Imaging extensions */
ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
-/* $Id: fxdd.c,v 1.90 2002/08/21 02:59:31 brianp Exp $ */
+/* $Id: fxdd.c,v 1.91 2002/09/27 02:45:38 brianp Exp $ */
/*
* Mesa 3-D graphics library
ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
ctx->Driver.TexSubImage2D = fxDDTexSubImage2D;
ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
+ ctx->Driver.CompressedTexImage1D = _mesa_store_compressed_teximage1d;
+ ctx->Driver.CompressedTexImage2D = _mesa_store_compressed_teximage2d;
+ ctx->Driver.CompressedTexImage3D = _mesa_store_compressed_teximage3d;
+ ctx->Driver.CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
+ ctx->Driver.CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
+ ctx->Driver.CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
-/* $Id: osmesa.c,v 1.87 2002/08/07 00:45:07 brianp Exp $ */
+/* $Id: osmesa.c,v 1.88 2002/09/27 02:45:39 brianp Exp $ */
/*
* Mesa 3-D graphics library
ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
+ ctx->Driver.CompressedTexImage1D = _mesa_store_compressed_teximage1d;
+ ctx->Driver.CompressedTexImage2D = _mesa_store_compressed_teximage2d;
+ ctx->Driver.CompressedTexImage3D = _mesa_store_compressed_teximage3d;
+ ctx->Driver.CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
+ ctx->Driver.CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
+ ctx->Driver.CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
+
ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
- ctx->Driver.BaseCompressedTexFormat = _mesa_base_compressed_texformat;
- ctx->Driver.CompressedTextureSize = _mesa_compressed_texture_size;
- ctx->Driver.GetCompressedTexImage = _mesa_get_compressed_teximage;
-
swdd->SetBuffer = set_buffer;
/* RGB(A) span/pixel functions */
-/* $Id: wmesa.c,v 1.35 2002/09/12 17:05:55 kschultz Exp $ */
+/* $Id: wmesa.c,v 1.36 2002/09/27 02:45:39 brianp Exp $ */
/*
* Windows (Win32) device driver for Mesa 3.4
ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
+ ctx->Driver.CompressedTexImage1D = _mesa_store_compressed_teximage1d;
+ ctx->Driver.CompressedTexImage2D = _mesa_store_compressed_teximage2d;
+ ctx->Driver.CompressedTexImage3D = _mesa_store_compressed_teximage3d;
+ ctx->Driver.CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
+ ctx->Driver.CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
+ ctx->Driver.CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
+
ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
-
- ctx->Driver.BaseCompressedTexFormat = _mesa_base_compressed_texformat;
- ctx->Driver.CompressedTextureSize = _mesa_compressed_texture_size;
- ctx->Driver.GetCompressedTexImage = _mesa_get_compressed_teximage;
-
-
+
swdd->SetBuffer = set_buffer;
-
-
+
/* Pixel/span writing functions: */
swdd->WriteRGBASpan = write_rgba_span;
swdd->WriteRGBSpan = write_rgb_span;
ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
+ ctx->Driver.CompressedTexImage1D = _mesa_store_compressed_teximage1d;
+ ctx->Driver.CompressedTexImage2D = _mesa_store_compressed_teximage2d;
+ ctx->Driver.CompressedTexImage3D = _mesa_store_compressed_teximage3d;
+ ctx->Driver.CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
+ ctx->Driver.CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
+ ctx->Driver.CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
+
ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
- ctx->Driver.BaseCompressedTexFormat = _mesa_base_compressed_texformat;
- ctx->Driver.CompressedTextureSize = _mesa_compressed_texture_size;
- ctx->Driver.GetCompressedTexImage = _mesa_get_compressed_teximage;
-
swdd->SetBuffer = set_buffer;
/* Pixel/span writing functions: */
-/* $Id: xm_dd.c,v 1.35 2002/09/23 17:21:53 brianp Exp $ */
+/* $Id: xm_dd.c,v 1.36 2002/09/27 02:45:39 brianp Exp $ */
/*
* Mesa 3-D graphics library
ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;
ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;
- ctx->Driver.BaseCompressedTexFormat = _mesa_base_compressed_texformat;
- ctx->Driver.CompressedTextureSize = _mesa_compressed_texture_size;
- ctx->Driver.GetCompressedTexImage = _mesa_get_compressed_teximage;
+ ctx->Driver.CompressedTexImage1D = _mesa_store_compressed_teximage1d;
+ ctx->Driver.CompressedTexImage2D = _mesa_store_compressed_teximage2d;
+ ctx->Driver.CompressedTexImage3D = _mesa_store_compressed_teximage3d;
+ ctx->Driver.CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
+ ctx->Driver.CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
+ ctx->Driver.CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
/* Swrast hooks for imaging extensions:
*/
rastpos.c \
state.c \
stencil.c \
+ texcompress.c \
texformat.c \
teximage.c \
texobj.c \
# Mesa 3-D graphics library\r
-# Version: 4.0\r
+# Version: 4.1\r
# \r
-# Copyright (C) 1999 Brian Paul All Rights Reserved.\r
+# Copyright (C) 1999-2002 Brian Paul All Rights Reserved.\r
# \r
# Permission is hereby granted, free of charge, to any person obtaining a\r
# copy of this software and associated documentation files (the "Software"),\r
rastpos.c \\r
state.c \\r
stencil.c \\r
+ texcompress.c \\r
texformat.c \\r
teximage.c \\r
texobj.c \\r
-# $Id: Makefile.OSMesa16,v 1.7 2002/06/13 04:28:29 brianp Exp $
+# $Id: Makefile.OSMesa16,v 1.8 2002/09/27 02:45:37 brianp Exp $
# Mesa 3-D graphics library
# Version: 4.1
rastpos.c \
state.c \
stencil.c \
+ texcompress.c \
texformat.c \
teximage.c \
texobj.c \
-# $Id: Makefile.X11,v 1.68 2002/06/13 04:28:29 brianp Exp $
+# $Id: Makefile.X11,v 1.69 2002/09/27 02:45:37 brianp Exp $
# Mesa 3-D graphics library
# Version: 4.1
rastpos.c \
state.c \
stencil.c \
+ texcompress.c \
texformat.c \
teximage.c \
texobj.c \
rastpos.c \
state.c \
stencil.c \
+ texcompress.c \
texformat.c \
teximage.c \
texobj.c \
rastpos.c \
state.c \
stencil.c \
+ texcompress.c \
teximage.c \
texformat.c \
texobj.c \
-/* $Id: context.c,v 1.176 2002/09/06 02:56:08 brianp Exp $ */
+/* $Id: context.c,v 1.177 2002/09/27 02:45:37 brianp Exp $ */
/*
* Mesa 3-D graphics library
ctx->Const.MaxColorTableSize = MAX_COLOR_TABLE_SIZE;
ctx->Const.MaxConvolutionWidth = MAX_CONVOLUTION_WIDTH;
ctx->Const.MaxConvolutionHeight = MAX_CONVOLUTION_HEIGHT;
- ctx->Const.NumCompressedTextureFormats = 0;
ctx->Const.MaxClipPlanes = MAX_CLIP_PLANES;
ctx->Const.MaxLights = MAX_LIGHTS;
-/* $Id: dd.h,v 1.71 2002/09/06 02:56:08 brianp Exp $ */
+/* $Id: dd.h,v 1.72 2002/09/27 02:45:37 brianp Exp $ */
/*
* Mesa 3-D graphics library
* should do the job.
*/
- void (*GetCompressedTexImage)( GLcontext *ctx, GLenum target,
- GLint level, void *image,
- const struct gl_texture_object *texObj,
- struct gl_texture_image *texImage );
- /* Called by glGetCompressedTexImageARB.
- * <target>, <level>, <image> are specified by user.
- * <texObj> is the source texture object.
- * <texImage> is the source texture image.
- */
-
- GLint (*BaseCompressedTexFormat)(GLcontext *ctx,
- GLint internalFormat);
- /* Called to compute the base format for a specific compressed
- * format. Return -1 if the internalFormat is not a specific
- * compressed format that the driver recognizes.
- * Example: if internalFormat==GL_COMPRESSED_RGB_FXT1_3DFX, return GL_RGB.
- */
-
- GLint (*CompressedTextureSize)(GLcontext *ctx,
- const struct gl_texture_image *texImage);
-
-#if 000
- /* ... Note the
- * return value differences between this function and
- * SpecificCompressedTexFormat below.
- */
-
- GLint (*SpecificCompressedTexFormat)(GLcontext *ctx,
- GLint internalFormat,
- GLint numDimensions,
- GLint *levelp,
- GLsizei *widthp,
- GLsizei *heightp,
- GLsizei *depthp,
- GLint *borderp,
- GLenum *formatp,
- GLenum *typep);
- /* Called to turn a generic texture format into a specific
- * texture format. For example, if a driver implements
- * GL_3DFX_texture_compression_FXT1, this would map
- * GL_COMPRESSED_RGBA_ARB to GL_COMPRESSED_RGBA_FXT1_3DFX.
- *
- * If the driver does not know how to handle the compressed
- * format, then just return the generic format, and Mesa will
- * do the right thing with it.
- */
-
-#endif
-
/***
*** Texture object functions:
***/
-/* $Id: extensions.c,v 1.80 2002/09/21 17:34:56 brianp Exp $ */
+/* $Id: extensions.c,v 1.81 2002/09/27 02:45:37 brianp Exp $ */
/*
* Mesa 3-D graphics library
{ OFF, "GL_SGIX_pixel_texture", F(SGIX_pixel_texture) },
{ OFF, "GL_SGIX_shadow", F(SGIX_shadow) },
{ OFF, "GL_SGIX_shadow_ambient", F(SGIX_shadow_ambient) },
- { OFF, "GL_3DFX_texture_compression_FXT1", F(_3DFX_texture_compression_FXT1) },
+ { OFF, "GL_3DFX_texture_compression_FXT1", F(TDFX_texture_compression_FXT1) },
{ OFF, "GL_APPLE_client_storage", F(APPLE_client_storage) }
-
};
-/* $Id: get.c,v 1.91 2002/09/21 17:34:56 brianp Exp $ */
+/* $Id: get.c,v 1.92 2002/09/27 02:45:37 brianp Exp $ */
/*
* Mesa 3-D graphics library
#include "macros.h"
#include "mmath.h"
#include "mtypes.h"
-
+#include "texcompress.h"
#include "math/m_matrix.h"
#endif
break;
case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXTENSION_B(ARB_texture_compression, pname);
- *params = INT_TO_BOOL(ctx->Const.NumCompressedTextureFormats);
+ *params = INT_TO_BOOL(_mesa_get_compressed_formats(ctx, NULL));
break;
case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXTENSION_B(ARB_texture_compression, pname);
{
- GLuint i;
- for (i = 0; i < ctx->Const.NumCompressedTextureFormats; i++)
- params[i] = INT_TO_BOOL(ctx->Const.CompressedTextureFormats[i]);
+ GLint formats[100];
+ GLuint i, n;
+ n = _mesa_get_compressed_formats(ctx, formats);
+ for (i = 0; i < n; i++)
+ params[i] = INT_TO_BOOL(formats[i]);
}
break;
break;
case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXTENSION_D(ARB_texture_compression, pname);
- *params = (GLdouble) ctx->Const.NumCompressedTextureFormats;
+ *params = (GLdouble) _mesa_get_compressed_formats(ctx, NULL);
break;
case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXTENSION_D(ARB_texture_compression, pname);
{
- GLuint i;
- for (i = 0; i < ctx->Const.NumCompressedTextureFormats; i++)
- params[i] = (GLdouble) ctx->Const.CompressedTextureFormats[i];
+ GLint formats[100];
+ GLuint i, n;
+ n = _mesa_get_compressed_formats(ctx, formats);
+ for (i = 0; i < n; i++)
+ params[i] = (GLdouble) formats[i];
}
break;
break;
case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXTENSION_F(ARB_texture_compression, pname);
- *params = (GLfloat) ctx->Const.NumCompressedTextureFormats;
+ *params = (GLfloat) _mesa_get_compressed_formats(ctx, NULL);
break;
case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXTENSION_F(ARB_texture_compression, pname);
{
- GLuint i;
- for (i = 0; i < ctx->Const.NumCompressedTextureFormats; i++)
- params[i] = (GLfloat) ctx->Const.CompressedTextureFormats[i];
+ GLint formats[100];
+ GLuint i, n;
+ n = _mesa_get_compressed_formats(ctx, formats);
+ for (i = 0; i < n; i++)
+ params[i] = (GLfloat) formats[i];
}
break;
break;
case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXTENSION_I(ARB_texture_compression, pname);
- *params = (GLint) ctx->Const.NumCompressedTextureFormats;
+ *params = (GLint) _mesa_get_compressed_formats(ctx, NULL);
break;
case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
CHECK_EXTENSION_I(ARB_texture_compression, pname);
- {
- GLuint i;
- for (i = 0; i < ctx->Const.NumCompressedTextureFormats; i++)
- params[i] = (GLint) ctx->Const.CompressedTextureFormats[i];
- }
+ (void) _mesa_get_compressed_formats(ctx, params);
break;
/* GL_EXT_compiled_vertex_array */
-/* $Id: mtypes.h,v 1.88 2002/09/23 16:37:13 brianp Exp $ */
+/* $Id: mtypes.h,v 1.89 2002/09/27 02:45:37 brianp Exp $ */
/*
* Mesa 3-D graphics library
* GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA,
* GL_COLOR_INDEX or GL_DEPTH_COMPONENT.
*/
- GLenum Type; /* Internal type as GL enum value - UNUSED?? */
-
GLubyte RedBits; /* Bits per texel component */
- GLubyte GreenBits;
- GLubyte BlueBits;
+ GLubyte GreenBits; /* These are just rough approximations for */
+ GLubyte BlueBits; /* compressed texture formats. */
GLubyte AlphaBits;
GLubyte LuminanceBits;
GLubyte IntensityBits;
GLubyte IndexBits;
GLubyte DepthBits;
- GLint TexelBytes;
+ GLint TexelBytes; /* Bytes per texel (0 for compressed formats */
FetchTexelFunc FetchTexel1D; /* Texel fetch function pointers */
FetchTexelFunc FetchTexel2D;
GLenum Format; /* GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA,
* GL_INTENSITY, GL_RGB, GL_RGBA,
* GL_COLOR_INDEX or GL_DEPTH_COMPONENT only.
+ * Used for choosing TexEnv arithmetic.
*/
GLint IntFormat; /* Internal format as given by the user */
GLuint Border; /* 0 or 1 */
GLuint MaxColorTableSize;
GLuint MaxConvolutionWidth;
GLuint MaxConvolutionHeight;
- GLuint NumCompressedTextureFormats; /* GL_ARB_texture_compression */
- GLenum CompressedTextureFormats[MAX_COMPRESSED_TEXTURE_FORMATS];
GLuint MaxClipPlanes;
GLuint MaxLights;
};
GLboolean SGIX_pixel_texture;
GLboolean SGIX_shadow;
GLboolean SGIX_shadow_ambient; /* or GL_ARB_shadow_ambient */
- GLboolean _3DFX_texture_compression_FXT1;
+ GLboolean TDFX_texture_compression_FXT1;
GLboolean APPLE_client_storage;
};
-/* $Id: state.c,v 1.91 2002/09/06 03:20:21 brianp Exp $ */
+/* $Id: state.c,v 1.92 2002/09/27 02:45:38 brianp Exp $ */
/*
* Mesa 3-D graphics library
ASSERT(ctx->Driver.CopyTexSubImage2D);
ASSERT(ctx->Driver.CopyTexSubImage3D);
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.CompressedTexImage2D);
--- /dev/null
+/* $Id: texcompress.c,v 1.1 2002/09/27 02:45:38 brianp Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.1
+ *
+ * Copyright (C) 1999-2002 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"),
+ * 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 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
+ * BRIAN PAUL 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.
+ */
+
+
+#include "glheader.h"
+#include "context.h"
+#include "image.h"
+#include "mem.h"
+#include "texcompress.h"
+#include "texformat.h"
+
+
+/**
+ * Get the list of supported internal compression formats.
+ * \param formats - the results list (may be NULL)
+ * \return number of formats.
+ */
+GLuint
+_mesa_get_compressed_formats( GLcontext *ctx, GLint *formats )
+{
+ GLuint n = 0;
+ if (ctx->Extensions.ARB_texture_compression) {
+ if (ctx->Extensions.TDFX_texture_compression_FXT1) {
+ if (formats) {
+ formats[n++] = GL_COMPRESSED_RGB_FXT1_3DFX;
+ formats[n++] = GL_COMPRESSED_RGBA_FXT1_3DFX;
+ }
+ else {
+ n += 4;
+ }
+ }
+ }
+ return n;
+}
+
+
+
+/**
+ * Return bytes of storage needed for the given texture size and compressed
+ * format.
+ * \param width, height, depth - texture size in texels
+ * \param texFormat - one of the compressed format enums
+ * \return size in bytes, or zero if bad texFormat
+ */
+GLuint
+_mesa_compressed_texture_size( GLcontext *ctx,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format )
+{
+ GLuint size;
+
+ switch (format) {
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ /* round up to multiple of 4 */
+ size = ((width + 7) / 8) * ((height + 3) / 4) * 16;
+ return size;
+ default:
+ _mesa_problem(ctx, "bad texformat in compressed_texture_size");
+ return 0;
+ }
+}
+
+
+/*
+ * Compute the bytes per row in a compressed texture image.
+ */
+GLint
+_mesa_compressed_row_stride(GLenum format, GLsizei width)
+{
+ GLint bytesPerTile, stride;
+
+ switch (format) {
+ default:
+ return 0;
+ }
+
+ stride = ((width + 3) / 4) * bytesPerTile;
+ return stride;
+}
+
+
+/*
+ * Return the address of the pixel at (col, row, img) in a
+ * compressed texture image.
+ * \param col, row, img - image position (3D)
+ * \param format - compressed image format
+ * \param width - image width
+ * \param image - the image address
+ * \return address of pixel at (row, col)
+ */
+GLubyte *
+_mesa_compressed_image_address(GLint col, GLint row, GLint img,
+ GLenum format,
+ GLsizei width, const GLubyte *image)
+{
+ GLint bytesPerTile, stride;
+ GLubyte *addr;
+
+ ASSERT((row & 3) == 0);
+ ASSERT((col & 3) == 0);
+ (void) img;
+
+ switch (format) {
+ default:
+ return 0;
+ }
+
+ stride = ((width + 3) / 4) * bytesPerTile;
+
+ addr = (GLubyte *) image + (row / 4) * stride + (col / 4) * bytesPerTile;
+ return addr;
+}
+
+
+
+/*
+ * \param srcRowStride - source stride, in pixels
+ */
+void
+_mesa_compress_teximage( GLcontext *ctx, GLsizei width, GLsizei height,
+ GLenum srcFormat, const GLchan *source, GLint srcRowStride,
+ GLenum dstFormat, GLubyte *dest, GLint dstRowStride )
+{
+ GLuint len = 0;
+
+ switch (dstFormat) {
+ default:
+ _mesa_problem(ctx, "Bad dstFormat in _mesa_compress_teximage()");
+ return;
+ }
+
+ /* sanity check */
+ ASSERT(len == _mesa_compressed_texture_size(ctx, width, height,
+ 1, dstFormat));
+}
--- /dev/null
+/* $Id: texcompress.h,v 1.1 2002/09/27 02:45:38 brianp Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.1
+ *
+ * Copyright (C) 1999-2002 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"),
+ * 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 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
+ * BRIAN PAUL 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_H
+#define TEXCOMPRESS_H
+
+#include "mtypes.h"
+
+
+extern GLuint
+_mesa_get_compressed_formats( GLcontext *ctx, GLint *formats );
+
+extern GLuint
+_mesa_compressed_texture_size( GLcontext *ctx,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format );
+
+extern GLint
+_mesa_compressed_row_stride(GLenum format, GLsizei width);
+
+
+extern GLubyte *
+_mesa_compressed_image_address(GLint col, GLint row, GLint img,
+ GLenum format,
+ GLsizei width, const GLubyte *image);
+
+
+extern void
+_mesa_compress_teximage( GLcontext *ctx, GLsizei width, GLsizei height,
+ GLenum srcFormat,
+ const GLchan *source, GLint srcRowStride,
+ GLenum dstformat, GLubyte *dest, GLint dstRowStride );
+
+
+#endif /* TEXCOMPRESS_H */
-/* $Id: texformat.c,v 1.15 2002/09/21 16:51:25 brianp Exp $ */
+/* $Id: texformat.c,v 1.16 2002/09/27 02:45:38 brianp Exp $ */
/*
* Mesa 3-D graphics library
const struct gl_texture_format _mesa_texformat_rgba = {
MESA_FORMAT_RGBA, /* MesaFormat */
GL_RGBA, /* BaseFormat */
- CHAN_TYPE, /* Type */
CHAN_BITS, /* RedBits */
CHAN_BITS, /* GreenBits */
CHAN_BITS, /* BlueBits */
const struct gl_texture_format _mesa_texformat_rgb = {
MESA_FORMAT_RGB, /* MesaFormat */
GL_RGB, /* BaseFormat */
- CHAN_TYPE, /* Type */
CHAN_BITS, /* RedBits */
CHAN_BITS, /* GreenBits */
CHAN_BITS, /* BlueBits */
const struct gl_texture_format _mesa_texformat_alpha = {
MESA_FORMAT_ALPHA, /* MesaFormat */
GL_ALPHA, /* BaseFormat */
- CHAN_TYPE, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
const struct gl_texture_format _mesa_texformat_luminance = {
MESA_FORMAT_LUMINANCE, /* MesaFormat */
GL_LUMINANCE, /* BaseFormat */
- CHAN_TYPE, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
const struct gl_texture_format _mesa_texformat_luminance_alpha = {
MESA_FORMAT_LUMINANCE_ALPHA, /* MesaFormat */
GL_LUMINANCE_ALPHA, /* BaseFormat */
- CHAN_TYPE, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
const struct gl_texture_format _mesa_texformat_intensity = {
MESA_FORMAT_INTENSITY, /* MesaFormat */
GL_INTENSITY, /* BaseFormat */
- CHAN_TYPE, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
const struct gl_texture_format _mesa_texformat_color_index = {
MESA_FORMAT_COLOR_INDEX, /* MesaFormat */
GL_COLOR_INDEX, /* BaseFormat */
- CHAN_TYPE, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
const struct gl_texture_format _mesa_texformat_depth_component = {
MESA_FORMAT_DEPTH_COMPONENT, /* MesaFormat */
GL_DEPTH_COMPONENT, /* BaseFormat */
- GL_FLOAT, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
const struct gl_texture_format _mesa_texformat_rgba8888 = {
MESA_FORMAT_RGBA8888, /* MesaFormat */
GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_INT_8_8_8_8, /* Type */
8, /* RedBits */
8, /* GreenBits */
8, /* BlueBits */
const struct gl_texture_format _mesa_texformat_argb8888 = {
MESA_FORMAT_ARGB8888, /* MesaFormat */
GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_INT_8_8_8_8_REV, /* Type */
8, /* RedBits */
8, /* GreenBits */
8, /* BlueBits */
const struct gl_texture_format _mesa_texformat_rgb888 = {
MESA_FORMAT_RGB888, /* MesaFormat */
GL_RGB, /* BaseFormat */
- GL_UNSIGNED_BYTE, /* Type */
8, /* RedBits */
8, /* GreenBits */
8, /* BlueBits */
const struct gl_texture_format _mesa_texformat_rgb565 = {
MESA_FORMAT_RGB565, /* MesaFormat */
GL_RGB, /* BaseFormat */
- GL_UNSIGNED_SHORT_5_6_5, /* Type */
5, /* RedBits */
6, /* GreenBits */
5, /* BlueBits */
const struct gl_texture_format _mesa_texformat_argb4444 = {
MESA_FORMAT_ARGB4444, /* MesaFormat */
GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_SHORT_4_4_4_4_REV, /* Type */
4, /* RedBits */
4, /* GreenBits */
4, /* BlueBits */
const struct gl_texture_format _mesa_texformat_argb1555 = {
MESA_FORMAT_ARGB1555, /* MesaFormat */
GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_SHORT_1_5_5_5_REV, /* Type */
5, /* RedBits */
5, /* GreenBits */
5, /* BlueBits */
const struct gl_texture_format _mesa_texformat_al88 = {
MESA_FORMAT_AL88, /* MesaFormat */
GL_LUMINANCE_ALPHA, /* BaseFormat */
- GL_UNSIGNED_BYTE, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
const struct gl_texture_format _mesa_texformat_rgb332 = {
MESA_FORMAT_RGB332, /* MesaFormat */
GL_RGB, /* BaseFormat */
- GL_UNSIGNED_BYTE_3_3_2, /* Type */
3, /* RedBits */
3, /* GreenBits */
2, /* BlueBits */
const struct gl_texture_format _mesa_texformat_a8 = {
MESA_FORMAT_A8, /* MesaFormat */
GL_ALPHA, /* BaseFormat */
- GL_UNSIGNED_BYTE, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
const struct gl_texture_format _mesa_texformat_l8 = {
MESA_FORMAT_L8, /* MesaFormat */
GL_LUMINANCE, /* BaseFormat */
- GL_UNSIGNED_BYTE, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
const struct gl_texture_format _mesa_texformat_i8 = {
MESA_FORMAT_I8, /* MesaFormat */
GL_INTENSITY, /* BaseFormat */
- GL_UNSIGNED_BYTE, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
const struct gl_texture_format _mesa_texformat_ci8 = {
MESA_FORMAT_CI8, /* MesaFormat */
GL_COLOR_INDEX, /* BaseFormat */
- GL_UNSIGNED_BYTE, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
fetch_3d_texel_ci8, /* FetchTexel3D */
};
-
const struct gl_texture_format _mesa_texformat_ycbcr = {
MESA_FORMAT_YCBCR, /* MesaFormat */
GL_YCBCR_MESA, /* BaseFormat */
- GL_UNSIGNED_SHORT_8_8_MESA, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
MESA_FORMAT_YCBCR_REV, /* MesaFormat */
GL_YCBCR_MESA, /* BaseFormat */
- GL_UNSIGNED_SHORT_8_8_REV_MESA, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
#endif
/* =============================================================
- * Null format:
+ * Null format (useful for proxy textures):
*/
const struct gl_texture_format _mesa_null_texformat = {
-1, /* MesaFormat */
0, /* BaseFormat */
- 0, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
};
-
GLboolean
_mesa_is_hardware_tex_format( const struct gl_texture_format *format )
{
_mesa_problem(ctx, "texture compression extension not enabled");
return &_mesa_texformat_rgba;
+ /* GL_MESA_ycrcr_texture */
case GL_YCBCR_MESA:
if (type == GL_UNSIGNED_SHORT_8_8_MESA)
return &_mesa_texformat_ycbcr;
default:
_mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
- _mesa_debug(ctx, "intformat = %d %x\n", internalFormat, internalFormat);
return NULL;
}
}
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;
-}
-/* $Id: texformat.h,v 1.11 2002/09/23 16:37:14 brianp Exp $ */
+/* $Id: texformat.h,v 1.12 2002/09/27 02:45:38 brianp Exp $ */
/*
* Mesa 3-D graphics library
MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */
MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */
-
#if 0
/* upcoming little-endian formats: */
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:
*/
-/* $Id: texformat_tmp.h,v 1.8 2002/09/23 16:37:14 brianp Exp $ */
+/* $Id: texformat_tmp.h,v 1.9 2002/09/27 02:45:38 brianp Exp $ */
/*
* Mesa 3-D graphics library
* 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.
*
- * Author:
+ * Authors:
* Gareth Hughes <gareth@valinux.com>
+ * Brian Paul
*/
+
+/*
+ * This template file generates texel fetch functions for 1-D, 2-D and 3-D
+ * texture images.
+ */
+
+
#if DIM == 1
#define CHAN_SRC( t, i, j, k, sz ) \
}
-
/* big-endian */
#if 0
-/* $Id: teximage.c,v 1.116 2002/09/23 16:37:14 brianp Exp $ */
+/* $Id: teximage.c,v 1.117 2002/09/27 02:45:38 brianp Exp $ */
/*
* Mesa 3-D graphics library
#include "mem.h"
#include "mmath.h"
#include "state.h"
+#include "texcompress.h"
#include "texformat.h"
#include "teximage.h"
#include "texstate.h"
* Given an internal texture format enum or 1, 2, 3, 4 return the
* corresponding _base_ internal format: GL_ALPHA, GL_LUMINANCE,
* GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, or GL_RGBA.
+ *
+ * This is the format which is used during texture application (i.e. the
+ * texture format and env mode determine the arithmetic used.
+ *
* Return -1 if invalid enum.
*/
GLint
* Ask the driver for the base format, if it doesn't
* know, it will return -1;
*/
- if (ctx->Driver.BaseCompressedTexFormat) {
- GLint ifmt = (*ctx->Driver.BaseCompressedTexFormat)(ctx, format);
- if (ifmt >= 0) {
- return ifmt;
- }
- }
switch (format) {
case GL_ALPHA:
case GL_ALPHA4:
return GL_DEPTH_COMPONENT;
else
return -1;
+
+ /* GL_ARB_texture_compression */
+ case GL_COMPRESSED_ALPHA:
+ if (ctx->Extensions.ARB_texture_compression)
+ return GL_ALPHA;
+ else
+ return -1;
+ case GL_COMPRESSED_LUMINANCE:
+ if (ctx->Extensions.ARB_texture_compression)
+ return GL_LUMINANCE;
+ else
+ return -1;
+ case GL_COMPRESSED_LUMINANCE_ALPHA:
+ if (ctx->Extensions.ARB_texture_compression)
+ return GL_LUMINANCE_ALPHA;
+ else
+ return -1;
+ case GL_COMPRESSED_INTENSITY:
+ if (ctx->Extensions.ARB_texture_compression)
+ return GL_INTENSITY;
+ else
+ return -1;
+ case GL_COMPRESSED_RGB:
+ if (ctx->Extensions.ARB_texture_compression)
+ return GL_RGB;
+ else
+ return -1;
+ case GL_COMPRESSED_RGBA:
+ if (ctx->Extensions.ARB_texture_compression)
+ return GL_RGBA;
+ else
+ return -1;
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ if (ctx->Extensions.TDFX_texture_compression_FXT1)
+ return GL_RGB;
+ else
+ return -1;
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ if (ctx->Extensions.TDFX_texture_compression_FXT1)
+ return GL_RGBA;
+ else
+ return -1;
+
case GL_YCBCR_MESA:
if (ctx->Extensions.MESA_ycbcr_texture)
return GL_YCBCR_MESA;
else
return -1;
+
default:
return -1; /* error */
}
}
-/*
- * Return GL_TRUE if internalFormat is a compressed format, return GL_FALSE
- * otherwise.
+/**
+ * Return GL_TRUE if internalFormat is a supported compressed format,
+ * return GL_FALSE otherwise.
+ * \param - internalFormat - the internal format token provided by the user
*/
static GLboolean
-is_compressed_format(GLcontext *ctx, GLenum internalFormat)
+is_compressed_format(GLenum internalFormat)
{
- if (ctx->Driver.BaseCompressedTexFormat) {
- GLint b = (*ctx->Driver.BaseCompressedTexFormat)(ctx, internalFormat);
- if (b > 0)
+ switch (internalFormat) {
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
return GL_TRUE;
- else
+ default:
return GL_FALSE;
}
- return GL_FALSE;
}
-
/*
* Store a gl_texture_image pointer in a gl_texture_object structure
* according to the target and level parameters.
img->Height2 = 1 << img->HeightLog2;
img->Depth2 = 1 << img->DepthLog2;
img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2);
- img->IsCompressed = is_compressed_format(ctx, internalFormat);
+ img->IsCompressed = is_compressed_format(internalFormat);
+ if (img->IsCompressed)
+ img->CompressedSize = _mesa_compressed_texture_size(ctx, width, height,
+ depth, internalFormat);
+ else
+ img->CompressedSize = 0;
+
/* Compute Width/Height/DepthScale for mipmap lod computation */
if (target == GL_TEXTURE_RECTANGLE_NV) {
/* scale = 1.0 since texture coords directly map to texels */
GLint depth, GLint border )
{
GLboolean isProxy;
- GLint iformat;
GLint maxLevels = 0, maxTextureSize;
if (dimensions == 1) {
}
}
- iformat = _mesa_base_tex_format( ctx, internalFormat );
- if (iformat < 0) {
+ if (_mesa_base_tex_format(ctx, internalFormat) < 0) {
if (!isProxy) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glTexImage%dD(internalFormat=0x%x)",
return GL_TRUE;
}
- ASSERT(iformat > 0);
-
- if (!is_compressed_format( ctx, internalFormat ) &&
- !_mesa_is_legal_format_and_type( format, type )) {
+ if (!_mesa_is_legal_format_and_type(format, type)) {
/* Yes, generate GL_INVALID_OPERATION, not GL_INVALID_ENUM, if there
* is a type/format mismatch. See 1.2 spec page 94, sec 3.6.4.
*/
if (!isProxy) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
+ _mesa_error(ctx, GL_INVALID_OPERATION,
"glTexImage%dD(format or type)", dimensions);
}
return GL_TRUE;
}
- if (format == GL_YCBCR_MESA || iformat == GL_YCBCR_MESA) {
+ if (format == GL_YCBCR_MESA || internalFormat == GL_YCBCR_MESA) {
ASSERT(ctx->Extensions.MESA_ycbcr_texture);
if (format != GL_YCBCR_MESA ||
- iformat != GL_YCBCR_MESA ||
+ internalFormat != GL_YCBCR_MESA ||
(type != GL_UNSIGNED_SHORT_8_8_MESA &&
type != GL_UNSIGNED_SHORT_8_8_REV_MESA)) {
char message[100];
}
}
+ if (is_compressed_format(internalFormat)) {
+ if (target == GL_TEXTURE_2D || target == GL_PROXY_TEXTURE_2D) {
+ /* OK */
+ }
+ else if (ctx->Extensions.ARB_texture_cube_map &&
+ (target == GL_PROXY_TEXTURE_CUBE_MAP ||
+ (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X &&
+ target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z))) {
+ /* OK */
+ }
+ else {
+ if (!isProxy) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexImage%d(target)", dimensions);
+ return GL_TRUE;
+ }
+ }
+ if (border != 0) {
+ if (!isProxy) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTexImage%D(border!=0)", dimensions);
+ }
+ return GL_TRUE;
+ }
+ }
+
/* if we get here, the parameters are OK */
return GL_FALSE;
}
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
struct gl_texture_image *destTex;
GLint maxLevels = 0;
- GLboolean compressed;
if (dimensions == 1) {
if (target != GL_TEXTURE_1D) {
}
}
- compressed = is_compressed_format(ctx, destTex->IntFormat);
-
- if (!compressed && !_mesa_is_legal_format_and_type(format, type)) {
+ if (!_mesa_is_legal_format_and_type(format, type)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glTexSubImage%dD(format or type)", dimensions);
return GL_TRUE;
}
- if (compressed) {
- if (xoffset != -((GLint)destTex->Border)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTexSubImage1/2/3D(xoffset != -border");
+ if (destTex->IsCompressed) {
+ const struct gl_texture_unit *texUnit;
+ const struct gl_texture_object *texObj;
+ const struct gl_texture_image *texImage;
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+
+ if (target == GL_TEXTURE_2D || target == GL_PROXY_TEXTURE_2D) {
+ /* OK */
+ }
+ else if (ctx->Extensions.ARB_texture_cube_map &&
+ (target == GL_PROXY_TEXTURE_CUBE_MAP ||
+ (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X &&
+ target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z))) {
+ /* OK */
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexSubImage%D(target)", dimensions);
return GL_TRUE;
}
- if (dimensions > 1 && yoffset != -((GLint)destTex->Border)) {
+ /* offset must be multiple of 4 */
+ if ((xoffset & 3) || (yoffset & 3)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glTexSubImage2/3D(yoffset != -border");
+ "glTexSubImage%D(xoffset or yoffset)", dimensions);
return GL_TRUE;
}
- if (dimensions > 2 && zoffset != -((GLint)destTex->Border)) {
+ /* size must be multiple of 4 or equal to whole texture size */
+ if ((width & 3) && width != texImage->Width) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glTexSubImage3D(zoffset != -border");
+ "glTexSubImage%D(width)", dimensions);
return GL_TRUE;
- }
+ }
+ if ((height & 3) && height != texImage->Height) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTexSubImage%D(width)", dimensions);
+ return GL_TRUE;
+ }
}
return GL_FALSE;
GLenum target, GLint level, GLint internalFormat,
GLint width, GLint height, GLint border )
{
- GLint iformat;
GLint maxLevels = 0, maxTextureSize;
if (dimensions == 1) {
return GL_TRUE;
}
- iformat = _mesa_base_tex_format(ctx, internalFormat);
- if (iformat < 0) {
+ if (_mesa_base_tex_format(ctx, internalFormat) < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glCopyTexImage%dD(internalFormat)", dimensions);
return GL_TRUE;
}
+ if (is_compressed_format(internalFormat)) {
+ if (target != GL_TEXTURE_2D) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glCopyTexImage%d(target)", dimensions);
+ return GL_TRUE;
+ }
+ if (border != 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCopyTexImage%D(border!=0)", dimensions);
+ return GL_TRUE;
+ }
+ }
+
/* if we get here, the parameters are OK */
return GL_FALSE;
}
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
struct gl_texture_image *teximage;
GLint maxLevels = 0;
- GLboolean compressed;
if (dimensions == 1) {
if (target != GL_TEXTURE_1D) {
}
}
- compressed = is_compressed_format(ctx, teximage->IntFormat);
- if (compressed) {
- if (xoffset != -((GLint)teximage->Border)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCopyTexSubImage1/2/3D(xoffset != -border");
+ if (teximage->IsCompressed) {
+ if (target != GL_TEXTURE_2D) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glCopyTexSubImage%d(target)", dimensions);
return GL_TRUE;
}
- if (dimensions > 1 && yoffset != -((GLint)teximage->Border)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCopyTexSubImage2/3D(yoffset != -border");
+ /* offset must be multiple of 4 */
+ if ((xoffset & 3) || (yoffset & 3)) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%D(xoffset or yoffset)", dimensions);
return GL_TRUE;
}
- if (dimensions > 2 && zoffset != -((GLint)teximage->Border)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCopyTexSubImage3D(zoffset != -border");
+ /* size must be multiple of 4 */
+ if ((width & 3) != 0 && width != teximage->Width) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%D(width)", dimensions);
return GL_TRUE;
- }
+ }
+ if ((height & 3) != 0 && height != teximage->Height) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%D(height)", dimensions);
+ return GL_TRUE;
+ }
}
/* if we get here, the parameters are OK */
ASSERT(ctx->Driver.TexImage1D);
-#if 0 /* don't make default teximage anymore */
- if (pixels) {
- (*ctx->Driver.TexImage1D)(ctx, target, level, internalFormat,
- width, border, format, type, pixels,
- &ctx->Unpack, texObj, texImage);
- }
- else {
- GLubyte *dummy = make_null_texture(width, 1, 1, format);
- if (dummy) {
- (*ctx->Driver.TexImage1D)(ctx, target, level, internalFormat,
- width, border,
- format, GL_UNSIGNED_BYTE, dummy,
- &_mesa_native_packing, texObj, texImage);
- FREE(dummy);
- }
- }
-#else
- /* <pixels> may be null! */
+ /* Give the texture to the driver! <pixels> may be null! */
(*ctx->Driver.TexImage1D)(ctx, target, level, internalFormat,
width, border, format, type, pixels,
&ctx->Unpack, texObj, texImage);
-#endif
ASSERT(texImage->TexFormat);
if (!texImage->FetchTexel) {
}
ASSERT(texImage->FetchTexel);
- if (texImage->IsCompressed) {
- ASSERT(texImage->CompressedSize > 0);
- }
-
/* state update */
texObj->Complete = GL_FALSE;
ctx->NewState |= _NEW_TEXTURE;
}
else if (target == GL_PROXY_TEXTURE_1D) {
/* Proxy texture: check for errors and update proxy state */
- GLenum error = texture_error_check(ctx, target, level, internalFormat,
- format, type, 1,
- postConvWidth, 1, 1, border);
+ GLboolean error = texture_error_check(ctx, target, level, internalFormat,
+ format, type, 1, postConvWidth, 1, 1, border);
if (!error) {
- struct gl_texture_unit *texUnit;
- struct gl_texture_image *texImage;
- texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
- _mesa_init_teximage_fields(ctx, target, texImage,
- postConvWidth, 1, 1,
- border, internalFormat);
ASSERT(ctx->Driver.TestProxyTexImage);
error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level,
internalFormat, format, type,
clear_teximage_fields(ctx->Texture.Proxy1D->Image[level]);
}
}
+ else {
+ /* no error, set the tex image parameters */
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_image *texImage;
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ _mesa_init_teximage_fields(ctx, target, texImage,
+ postConvWidth, 1, 1,
+ border, internalFormat);
+ }
}
else {
_mesa_error( ctx, GL_INVALID_ENUM, "glTexImage1D(target)" );
ASSERT(ctx->Driver.TexImage2D);
-#if 0 /* don't make default teximage anymore */
- if (pixels) {
- (*ctx->Driver.TexImage2D)(ctx, target, level, internalFormat,
- width, height, border, format, type, pixels,
- &ctx->Unpack, texObj, texImage);
- }
- else {
- GLubyte *dummy = make_null_texture(width, height, 1, format);
- if (dummy) {
- (*ctx->Driver.TexImage2D)(ctx, target, level, internalFormat,
- width, height, border,
- format, GL_UNSIGNED_BYTE, dummy,
- &_mesa_native_packing, texObj, texImage);
- FREE(dummy);
- }
- }
-#else
- /* <pixels> may be null! */
+ /* Give the texture to the driver! <pixels> may be null! */
(*ctx->Driver.TexImage2D)(ctx, target, level, internalFormat,
width, height, border, format, type, pixels,
&ctx->Unpack, texObj, texImage);
-#endif
ASSERT(texImage->TexFormat);
if (!texImage->FetchTexel) {
}
ASSERT(texImage->FetchTexel);
- if (texImage->IsCompressed) {
- ASSERT(texImage->CompressedSize > 0);
- }
-
/* state update */
texObj->Complete = GL_FALSE;
ctx->NewState |= _NEW_TEXTURE;
(target == GL_PROXY_TEXTURE_RECTANGLE_NV &&
ctx->Extensions.NV_texture_rectangle)) {
/* Proxy texture: check for errors and update proxy state */
- GLenum error = texture_error_check(ctx, target, level, internalFormat,
- format, type, 2,
- postConvWidth, postConvHeight, 1, border);
+ GLboolean error = texture_error_check(ctx, target, level, internalFormat,
+ format, type, 2, postConvWidth, postConvHeight, 1, border);
if (!error) {
- struct gl_texture_unit *texUnit;
- struct gl_texture_image *texImage;
- texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
- _mesa_init_teximage_fields(ctx, target, texImage,
- postConvWidth, postConvHeight, 1,
- border, internalFormat);
ASSERT(ctx->Driver.TestProxyTexImage);
error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level,
internalFormat, format, type,
clear_teximage_fields(ctx->Texture.Proxy2D->Image[level]);
}
}
+ else {
+ /* no error, set the tex image parameters */
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_image *texImage;
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ _mesa_init_teximage_fields(ctx, target, texImage,
+ postConvWidth, postConvHeight, 1,
+ border, internalFormat);
+ }
}
else {
_mesa_error( ctx, GL_INVALID_ENUM, "glTexImage2D(target)" );
ASSERT(ctx->Driver.TexImage3D);
-#if 0 /* don't make default teximage anymore */
- if (pixels) {
- (*ctx->Driver.TexImage3D)(ctx, target, level, (GLint) internalFormat,
- width, height, depth, border,
- format, type, pixels,
- &ctx->Unpack, texObj, texImage);
- }
- else {
- GLubyte *dummy = make_null_texture(width, height, depth, format);
- if (dummy) {
- (*ctx->Driver.TexImage3D)(ctx, target, level,
- (GLint) internalFormat,
- width, height, depth, border,
- format, GL_UNSIGNED_BYTE, dummy,
- &_mesa_native_packing, texObj, texImage);
- FREE(dummy);
- }
- }
-#else
- /* <pixels> may be null! */
+ /* Give the texture to the driver! <pixels> may be null! */
(*ctx->Driver.TexImage3D)(ctx, target, level, internalFormat,
width, height, depth, border, format, type,
pixels, &ctx->Unpack, texObj, texImage);
-#endif
ASSERT(texImage->TexFormat);
if (!texImage->FetchTexel) {
}
ASSERT(texImage->FetchTexel);
- if (texImage->IsCompressed) {
- ASSERT(texImage->CompressedSize > 0);
- }
-
/* state update */
texObj->Complete = GL_FALSE;
ctx->NewState |= _NEW_TEXTURE;
}
else if (target == GL_PROXY_TEXTURE_3D) {
/* Proxy texture: check for errors and update proxy state */
- GLenum error = texture_error_check(ctx, target, level, internalFormat,
+ GLboolean error = texture_error_check(ctx, target, level, internalFormat,
format, type, 3, width, height, depth, border);
if (!error) {
- struct gl_texture_unit *texUnit;
- struct gl_texture_image *texImage;
- texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
- _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
- border, internalFormat);
ASSERT(ctx->Driver.TestProxyTexImage);
error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level,
internalFormat, format, type,
clear_teximage_fields(ctx->Texture.Proxy3D->Image[level]);
}
}
+ else {
+ /* no error, set the tex image parameters */
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_image *texImage;
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
+ border, internalFormat);
+ }
}
else {
_mesa_error( ctx, GL_INVALID_ENUM, "glTexImage3D(target)" );
GLint border, GLenum format, GLenum type,
const GLvoid *pixels )
{
- _mesa_TexImage3D(target, level, internalFormat, width, height,
+ _mesa_TexImage3D(target, level, (GLint) internalFormat, width, height,
depth, border, format, type, pixels);
}
+
+/**********************************************************************/
+/****** Compressed Textures ******/
+/**********************************************************************/
+
+
+/**
+ * Error checking for glCompressedTexImage[123]D().
+ * \return error code or GL_NO_ERROR.
+ */
+static GLenum
+compressed_texture_error_check(GLcontext *ctx, GLint dimensions,
+ GLenum target, GLint level,
+ GLenum internalFormat, GLsizei width,
+ GLsizei height, GLsizei depth, GLint border,
+ GLsizei imageSize)
+{
+ GLboolean isProxy = GL_FALSE;
+ GLint expectedSize, maxLevels = 0, maxTextureSize;
+
+ if (dimensions == 1) {
+ /* 1D compressed textures not allowed */
+ return GL_INVALID_ENUM;
+ }
+ else if (dimensions == 2) {
+ if (target == GL_PROXY_TEXTURE_2D) {
+ maxLevels = ctx->Const.MaxTextureLevels;
+ isProxy = GL_TRUE;
+ }
+ else if (target == GL_TEXTURE_2D) {
+ maxLevels = ctx->Const.MaxTextureLevels;
+ }
+ else if (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) {
+ if (!ctx->Extensions.ARB_texture_cube_map)
+ return GL_INVALID_ENUM; /*target*/
+ maxLevels = ctx->Const.MaxCubeTextureLevels;
+ isProxy = GL_TRUE;
+ }
+ else if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
+ target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) {
+ if (!ctx->Extensions.ARB_texture_cube_map)
+ return GL_INVALID_ENUM; /*target*/
+ maxLevels = ctx->Const.MaxCubeTextureLevels;
+ }
+ else {
+ return GL_INVALID_ENUM; /*target*/
+ }
+ }
+ else if (dimensions == 3) {
+ /* 3D compressed textures not allowed */
+ return GL_INVALID_ENUM;
+ }
+
+ maxTextureSize = 1 << (maxLevels - 1);
+
+ if (!is_compressed_format(internalFormat))
+ return GL_INVALID_ENUM;
+
+ if (border != 0)
+ return GL_INVALID_VALUE;
+
+ if (width < 1 || width > maxTextureSize || logbase2(width) < 0)
+ return GL_INVALID_VALUE;
+
+ if ((height < 1 || height > maxTextureSize || logbase2(height) < 0)
+ && dimensions > 1)
+ return GL_INVALID_VALUE;
+
+ if ((depth < 1 || depth > maxTextureSize || logbase2(depth) < 0)
+ && dimensions > 2)
+ return GL_INVALID_VALUE;
+
+ /* For cube map, width must equal height */
+ if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
+ target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB && width != height)
+ return GL_INVALID_VALUE;
+
+ if (level < 0 || level >= maxLevels)
+ return GL_INVALID_VALUE;
+
+ expectedSize = _mesa_compressed_texture_size(ctx, width, height, depth,
+ internalFormat);
+ if (expectedSize != imageSize)
+ return GL_INVALID_VALUE;
+
+ return GL_NO_ERROR;
+}
+
+
+/**
+ * Error checking for glCompressedTexSubImage[123]D().
+ * \return error code or GL_NO_ERROR.
+ */
+static GLenum
+compressed_subtexture_error_check(GLcontext *ctx, GLint dimensions,
+ GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLsizei imageSize)
+{
+ GLboolean isProxy = GL_FALSE;
+ GLint expectedSize, maxLevels = 0, maxTextureSize;
+
+ if (dimensions == 1) {
+ /* 1D compressed textures not allowed */
+ return GL_INVALID_ENUM;
+ }
+ else if (dimensions == 2) {
+ if (target == GL_PROXY_TEXTURE_2D) {
+ maxLevels = ctx->Const.MaxTextureLevels;
+ isProxy = GL_TRUE;
+ }
+ else if (target == GL_TEXTURE_2D) {
+ maxLevels = ctx->Const.MaxTextureLevels;
+ }
+ else if (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) {
+ if (!ctx->Extensions.ARB_texture_cube_map)
+ return GL_INVALID_ENUM; /*target*/
+ maxLevels = ctx->Const.MaxCubeTextureLevels;
+ isProxy = GL_TRUE;
+ }
+ else if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
+ target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) {
+ if (!ctx->Extensions.ARB_texture_cube_map)
+ return GL_INVALID_ENUM; /*target*/
+ maxLevels = ctx->Const.MaxCubeTextureLevels;
+ }
+ else {
+ return GL_INVALID_ENUM; /*target*/
+ }
+ }
+ else if (dimensions == 3) {
+ /* 3D compressed textures not allowed */
+ return GL_INVALID_ENUM;
+ }
+
+ maxTextureSize = 1 << (maxLevels - 1);
+
+ if (!is_compressed_format(format))
+ return GL_INVALID_ENUM;
+
+ if (width < 1 || width > maxTextureSize || logbase2(width) < 0)
+ return GL_INVALID_VALUE;
+
+ if ((height < 1 || height > maxTextureSize || logbase2(height) < 0)
+ && dimensions > 1)
+ return GL_INVALID_VALUE;
+
+ if (level < 0 || level >= maxLevels)
+ return GL_INVALID_VALUE;
+
+ if ((xoffset & 3) != 0 || (yoffset & 3) != 0)
+ return GL_INVALID_VALUE;
+
+ if ((width & 3) != 0 && width != 2 && width != 1)
+ return GL_INVALID_VALUE;
+
+ if ((height & 3) != 0 && height != 2 && height != 1)
+ return GL_INVALID_VALUE;
+
+ expectedSize = _mesa_compressed_texture_size(ctx, width, height, depth,
+ format);
+ if (expectedSize != imageSize)
+ return GL_INVALID_VALUE;
+
+ return GL_NO_ERROR;
+}
+
+
+
void
_mesa_CompressedTexImage1DARB(GLenum target, GLint level,
GLenum internalFormat, GLsizei width,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- switch (internalFormat) {
- case GL_COMPRESSED_ALPHA_ARB:
- case GL_COMPRESSED_LUMINANCE_ARB:
- case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
- case GL_COMPRESSED_INTENSITY_ARB:
- case GL_COMPRESSED_RGB_ARB:
- case GL_COMPRESSED_RGBA_ARB:
- _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage1DARB");
- return;
- default:
- /* silence compiler warning */
- ;
- }
-
if (target == GL_TEXTURE_1D) {
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
-
- if (texture_error_check(ctx, target, level, internalFormat,
- GL_NONE, GL_NONE, 1, width, 1, 1, border)) {
- return; /* error in texture image was detected */
+ GLenum error = compressed_texture_error_check(ctx, 1, target, level,
+ internalFormat, width, 1, 1, border, imageSize);
+ if (error) {
+ _mesa_error(ctx, error, "glCompressedTexImage1D");
+ return;
}
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
texImage = _mesa_alloc_texture_image();
texObj->Image[level] = texImage;
if (!texImage) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB");
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1D");
return;
}
}
_mesa_init_teximage_fields(ctx, target, texImage, width, 1, 1,
border, internalFormat);
- if (ctx->Extensions.ARB_texture_compression) {
- ASSERT(ctx->Driver.CompressedTexImage1D);
- (*ctx->Driver.CompressedTexImage1D)(ctx, target, level,
- internalFormat, width, border,
- imageSize, data,
- texObj, texImage);
- ASSERT(texImage->CompressedSize > 0); /* sanity */
- }
+ ASSERT(ctx->Driver.CompressedTexImage1D);
+ (*ctx->Driver.CompressedTexImage1D)(ctx, target, level,
+ internalFormat, width, border,
+ imageSize, data,
+ texObj, texImage);
/* state update */
texObj->Complete = GL_FALSE;
}
else if (target == GL_PROXY_TEXTURE_1D) {
/* Proxy texture: check for errors and update proxy state */
- GLenum error = texture_error_check(ctx, target, level, internalFormat,
- GL_NONE, GL_NONE, 1, width, 1, 1, border);
+ GLenum error = compressed_texture_error_check(ctx, 1, target, level,
+ internalFormat, width, 1, 1, border, imageSize);
if (!error) {
- struct gl_texture_unit *texUnit;
- struct gl_texture_image *texImage;
- texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
- _mesa_init_teximage_fields(ctx, target, texImage, width, 1, 1,
- border, internalFormat);
ASSERT(ctx->Driver.TestProxyTexImage);
error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level,
internalFormat, GL_NONE, GL_NONE,
clear_teximage_fields(ctx->Texture.Proxy1D->Image[level]);
}
}
+ else {
+ /* store the teximage parameters */
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_image *texImage;
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ _mesa_init_teximage_fields(ctx, target, texImage, width, 1, 1,
+ border, internalFormat);
+ }
}
else {
- _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage1DARB(target)");
+ _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage1D(target)");
return;
}
}
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- switch (internalFormat) {
- case GL_COMPRESSED_ALPHA_ARB:
- case GL_COMPRESSED_LUMINANCE_ARB:
- case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
- case GL_COMPRESSED_INTENSITY_ARB:
- case GL_COMPRESSED_RGB_ARB:
- case GL_COMPRESSED_RGBA_ARB:
- _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage2DARB");
- return;
- default:
- /* silence compiler warning */
- ;
- }
-
if (target == GL_TEXTURE_2D ||
(ctx->Extensions.ARB_texture_cube_map &&
target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
- target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) ||
- (ctx->Extensions.NV_texture_rectangle &&
- target == GL_TEXTURE_RECTANGLE_NV)) {
+ target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) {
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
-
- if (texture_error_check(ctx, target, level, internalFormat,
- GL_NONE, GL_NONE, 2, width, height, 1, border)) {
- return; /* error in texture image was detected */
+ GLenum error = compressed_texture_error_check(ctx, 2, target, level,
+ internalFormat, width, height, 1, border, imageSize);
+ if (error) {
+ _mesa_error(ctx, error, "glCompressedTexImage2D");
+ return;
}
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
texImage = _mesa_alloc_texture_image();
texObj->Image[level] = texImage;
if (!texImage) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB");
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
return;
}
}
_mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
border, internalFormat);
- if (ctx->Extensions.ARB_texture_compression) {
- ASSERT(ctx->Driver.CompressedTexImage2D);
- (*ctx->Driver.CompressedTexImage2D)(ctx, target, level,
- internalFormat, width, height,
- border, imageSize, data,
- texObj, texImage);
- ASSERT(texImage->CompressedSize > 0); /* sanity */
- }
+ ASSERT(ctx->Driver.CompressedTexImage2D);
+ (*ctx->Driver.CompressedTexImage2D)(ctx, target, level,
+ internalFormat, width, height,
+ border, imageSize, data,
+ texObj, texImage);
/* state update */
texObj->Complete = GL_FALSE;
ctx->NewState |= _NEW_TEXTURE;
}
- else if (target == GL_PROXY_TEXTURE_2D) {
+ else if (target == GL_PROXY_TEXTURE_2D ||
+ (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB &&
+ ctx->Extensions.ARB_texture_cube_map)) {
/* Proxy texture: check for errors and update proxy state */
- GLenum error = texture_error_check(ctx, target, level, internalFormat,
- GL_NONE, GL_NONE, 2, width, height, 1, border);
+ GLenum error = compressed_texture_error_check(ctx, 2, target, level,
+ internalFormat, width, height, 1, border, imageSize);
if (!error) {
- struct gl_texture_unit *texUnit;
- struct gl_texture_image *texImage;
- texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
- _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
- border, internalFormat);
ASSERT(ctx->Driver.TestProxyTexImage);
error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level,
internalFormat, GL_NONE, GL_NONE,
clear_teximage_fields(ctx->Texture.Proxy2D->Image[level]);
}
}
+ else {
+ /* store the teximage parameters */
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_image *texImage;
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
+ border, internalFormat);
+ }
}
else {
- _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage2DARB(target)");
+ _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage2D(target)");
return;
}
}
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- switch (internalFormat) {
- case GL_COMPRESSED_ALPHA_ARB:
- case GL_COMPRESSED_LUMINANCE_ARB:
- case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
- case GL_COMPRESSED_INTENSITY_ARB:
- case GL_COMPRESSED_RGB_ARB:
- case GL_COMPRESSED_RGBA_ARB:
- _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage3DARB");
- return;
- default:
- /* silence compiler warning */
- ;
- }
-
if (target == GL_TEXTURE_3D) {
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
-
- if (texture_error_check(ctx, target, level, internalFormat,
- GL_NONE, GL_NONE, 3, width, height, depth, border)) {
- return; /* error in texture image was detected */
+ GLenum error = compressed_texture_error_check(ctx, 3, target, level,
+ internalFormat, width, height, depth, border, imageSize);
+ if (error) {
+ _mesa_error(ctx, error, "glCompressedTexImage3D");
+ return;
}
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
texImage = _mesa_alloc_texture_image();
texObj->Image[level] = texImage;
if (!texImage) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB");
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3D");
return;
}
}
_mesa_init_teximage_fields(ctx, target, texImage, width, height, depth,
border, internalFormat);
- if (ctx->Extensions.ARB_texture_compression) {
- ASSERT(ctx->Driver.CompressedTexImage3D);
- (*ctx->Driver.CompressedTexImage3D)(ctx, target, level,
- internalFormat,
- width, height, depth,
- border, imageSize, data,
- texObj, texImage);
- ASSERT(texImage->CompressedSize > 0); /* sanity */
- }
+ ASSERT(ctx->Driver.CompressedTexImage3D);
+ (*ctx->Driver.CompressedTexImage3D)(ctx, target, level,
+ internalFormat,
+ width, height, depth,
+ border, imageSize, data,
+ texObj, texImage);
/* state update */
texObj->Complete = GL_FALSE;
}
else if (target == GL_PROXY_TEXTURE_3D) {
/* Proxy texture: check for errors and update proxy state */
- GLenum error = texture_error_check(ctx, target, level, internalFormat,
- GL_NONE, GL_NONE, 3, width, height, depth, border);
+ GLenum error = compressed_texture_error_check(ctx, 3, target, level,
+ internalFormat, width, height, depth, border, imageSize);
if (!error) {
- struct gl_texture_unit *texUnit;
- struct gl_texture_image *texImage;
- texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
- _mesa_init_teximage_fields(ctx, target, texImage,
- width, height, depth,
- border, internalFormat);
ASSERT(ctx->Driver.TestProxyTexImage);
error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level,
internalFormat, GL_NONE, GL_NONE,
clear_teximage_fields(ctx->Texture.Proxy3D->Image[level]);
}
}
+ else {
+ /* store the teximage parameters */
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_image *texImage;
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ _mesa_init_teximage_fields(ctx, target, texImage, width, height,
+ depth, border, internalFormat);
+ }
}
else {
- _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage3DARB(target)");
+ _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage3D(target)");
return;
}
}
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
+ GLenum error;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- if (subtexture_error_check(ctx, 1, target, level, xoffset, 0, 0,
- width, 1, 1, format, GL_NONE)) {
- return; /* error was detected */
+ error = compressed_subtexture_error_check(ctx, 1, target, level,
+ xoffset, 0, 0, width, 1, 1, format, imageSize);
+ if (error) {
+ _mesa_error(ctx, error, "glCompressedTexSubImage1D");
+ return;
}
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
assert(texImage);
+ if (format != texImage->IntFormat) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCompressedTexSubImage1D(format)");
+ return;
+ }
+
+ if ((width == 1 || width == 2) && width != texImage->Width) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glCompressedTexSubImage1D(width)");
+ return;
+ }
+
if (width == 0 || !data)
return; /* no-op, not an error */
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
+ GLenum error;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- if (subtexture_error_check(ctx, 2, target, level, xoffset, yoffset, 0,
- width, height, 1, format, GL_NONE)) {
- return; /* error was detected */
+ error = compressed_subtexture_error_check(ctx, 2, target, level,
+ xoffset, yoffset, 0, width, height, 1, format, imageSize);
+ if (error) {
+ _mesa_error(ctx, error, "glCompressedTexSubImage2D");
+ return;
}
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
assert(texImage);
+ if (format != texImage->IntFormat) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCompressedTexSubImage2D(format)");
+ return;
+ }
+
+ if (((width == 1 || width == 2) && width != texImage->Width) ||
+ ((height == 1 || height == 2) && height != texImage->Height)) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glCompressedTexSubImage2D(size)");
+ return;
+ }
+
if (width == 0 || height == 0 || !data)
return; /* no-op, not an error */
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
+ GLenum error;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- if (subtexture_error_check(ctx, 3, target, level, xoffset, yoffset, zoffset,
- width, height, depth, format, GL_NONE)) {
- return; /* error was detected */
+ error = compressed_subtexture_error_check(ctx, 3, target, level,
+ xoffset, yoffset, zoffset, width, height, depth, format, imageSize);
+ if (error) {
+ _mesa_error(ctx, error, "glCompressedTexSubImage2D");
+ return;
}
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
assert(texImage);
+ if (format != texImage->IntFormat) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCompressedTexSubImage3D(format)");
+ return;
+ }
+
+ if (((width == 1 || width == 2) && width != texImage->Width) ||
+ ((height == 1 || height == 2) && height != texImage->Height) ||
+ ((depth == 1 || depth == 2) && depth != texImage->Depth)) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glCompressedTexSubImage3D(size)");
+ return;
+ }
+
if (width == 0 || height == 0 || depth == 0 || !data)
return; /* no-op, not an error */
if (!img)
return;
- if (ctx->Extensions.ARB_texture_compression) {
- ASSERT(ctx->Driver.GetCompressedTexImage);
- (*ctx->Driver.GetCompressedTexImage)(ctx, target, level, img, texObj,
- texImage);
- }
+ /* just memcpy, no pixelstore or pixel transfer */
+ MEMCPY(img, texImage->Data, texImage->CompressedSize);
}
-/* $Id: texstate.c,v 1.78 2002/09/08 17:29:16 brianp Exp $ */
+/* $Id: texstate.c,v 1.79 2002/09/27 02:45:38 brianp Exp $ */
/*
* Mesa 3-D graphics library
maxLevels = 1;
break;
default:
- _mesa_printf(ctx, "bad target in _mesa_GetTexLevelParameter (0x%x)", target);
+ _mesa_problem(ctx, "switch in _mesa_GetTexLevelParameter");
return;
}
if (ctx->Extensions.SGIX_depth_texture)
*params = img->TexFormat->DepthBits;
else
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)");
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname)");
return;
/* GL_ARB_texture_compression */
*params = img->CompressedSize;
else
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetTexLevelParameter[if]v(pname)");
+ "glGetTexLevelParameter[if]v(pname)");
}
else {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)");
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname)");
}
return;
case GL_TEXTURE_COMPRESSED_ARB:
*params = (GLint) img->IsCompressed;
}
else {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)");
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname)");
}
return;
default:
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)");
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname)");
}
}
-/* $Id: texstore.c,v 1.41 2002/09/21 16:51:25 brianp Exp $ */
+/* $Id: texstore.c,v 1.42 2002/09/27 02:45:38 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Brian Paul
*/
+/*
+ * The GL texture image functions in teximage.c basically just do
+ * error checking and data structure allocation. They in turn call
+ * device driver functions which actually copy/convert/store the user's
+ * texture image data.
+ *
+ * However, most device drivers will be able to use the fallback functions
+ * in this file. That is, most drivers will have the following bit of
+ * code:
+ * ctx->Driver.TexImage1D = _mesa_store_teximage1d;
+ * ctx->Driver.TexImage2D = _mesa_store_teximage2d;
+ * ctx->Driver.TexImage3D = _mesa_store_teximage3d;
+ * etc...
+ *
+ * Texture image processing is actually kind of complicated. We have to do:
+ * Format/type conversions
+ * pixel unpacking
+ * pixel transfer (scale, bais, lookup, convolution!, etc)
+ *
+ * These functions can handle most everything, including processing full
+ * images and sub-images.
+ */
+
+
+
#include "colormac.h"
#include "context.h"
#include "convolve.h"
#include "image.h"
#include "macros.h"
#include "mem.h"
+#include "texcompress.h"
#include "texformat.h"
#include "teximage.h"
#include "texstore.h"
* corresponding _base_ internal format: GL_ALPHA, GL_LUMINANCE,
* GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, or GL_RGBA. Return the
* number of components for the format. Return -1 if invalid enum.
- *
- * GH: Do we really need this? We have the number of bytes per texel
- * in the texture format structures, so why don't we just use that?
*/
static GLint
components_in_intformat( GLint format )
* We also take care of all image transfer operations here, including
* convolution, scale/bias, colortables, etc.
*
- * The destination texel channel type is always GLchan.
+ * The destination texel type is always GLchan.
+ * The destination texel format is one of the 6 basic types.
*
* A hardware driver may use this as a helper routine to unpack and
* apply pixel transfer ops into a temporary image buffer. Then,
*
* Input:
* dimensions - 1, 2, or 3
- * texFormat - GL_LUMINANCE, GL_INTENSITY, GL_LUMINANCE_ALPHA, GL_ALPHA,
- * GL_RGB or GL_RGBA
+ * texDestFormat - GL_LUMINANCE, GL_INTENSITY, GL_LUMINANCE_ALPHA, GL_ALPHA,
+ * GL_RGB or GL_RGBA (the destination format)
* texDestAddr - destination image address
* srcWidth, srcHeight, srcDepth - size (in pixels) of src and dest images
* dstXoffset, dstYoffset, dstZoffset - position to store the image within
ASSERT(ctx);
ASSERT(dimensions >= 1 && dimensions <= 3);
+ ASSERT(texDestFormat == GL_LUMINANCE ||
+ texDestFormat == GL_INTENSITY ||
+ texDestFormat == GL_LUMINANCE_ALPHA ||
+ texDestFormat == GL_ALPHA ||
+ texDestFormat == GL_RGB ||
+ texDestFormat == GL_RGBA);
ASSERT(texDestAddr);
ASSERT(srcWidth >= 1);
ASSERT(srcHeight >= 1);
GLint postConvWidth = srcWidth, postConvHeight = srcHeight;
assert(baseInternalFormat > 0);
+ ASSERT(baseInternalFormat == GL_LUMINANCE ||
+ baseInternalFormat == GL_INTENSITY ||
+ baseInternalFormat == GL_LUMINANCE_ALPHA ||
+ baseInternalFormat == GL_ALPHA ||
+ baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_RGBA);
if (transferOps & IMAGE_CONVOLUTION_BIT) {
_mesa_adjust_image_for_convolution(ctx, dimensions, &postConvWidth,
}
+
+/**
+ * Given a user's uncompressed texture image, this function takes care of
+ * pixel unpacking, pixel transfer, format conversion and compression.
+ */
+static void
+transfer_compressed_teximage(GLcontext *ctx, GLuint dimensions,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum srcFormat, GLenum srcType,
+ const struct gl_pixelstore_attrib *unpacking,
+ const GLvoid *source,
+ GLenum dstFormat, GLubyte *dest,
+ GLint dstRowStride)
+{
+ GLchan *tempImage = NULL;
+ GLint srcRowStride;
+ GLenum baseFormat;
+
+ ASSERT(dimensions == 2);
+
+ baseFormat = _mesa_base_tex_format(ctx, dstFormat);
+
+ if (srcFormat != baseFormat || srcType != CHAN_TYPE ||
+ ctx->_ImageTransferState != 0 || unpacking->SwapBytes) {
+ /* need to convert user's image to texImage->Format, GLchan */
+ GLint comps = components_in_intformat(baseFormat);
+ GLint postConvWidth = width, postConvHeight = height;
+
+ /* XXX convolution untested */
+ if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) {
+ _mesa_adjust_image_for_convolution(ctx, dimensions, &postConvWidth,
+ &postConvHeight);
+ }
+
+ tempImage = (GLchan*) MALLOC(width * height * comps * sizeof(GLchan));
+ if (!tempImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ transfer_teximage(ctx, dimensions,
+ baseFormat, /* dest format */
+ tempImage, /* dst address */
+ width, height, depth, /* src size */
+ 0, 0, 0, /* x/y/zoffset */
+ comps * width, /* dst row stride */
+ comps * width * height, /* dst image stride */
+ srcFormat, srcType, /* src format, type */
+ source, unpacking, /* src and src packing */
+ ctx->_ImageTransferState);
+ source = tempImage;
+ width = postConvWidth;
+ height = postConvHeight;
+ srcRowStride = width;
+ }
+ else {
+ if (unpacking->RowLength)
+ srcRowStride = unpacking->RowLength;
+ else
+ srcRowStride = width;
+ }
+
+ _mesa_compress_teximage(ctx, width, height, baseFormat,
+ (const GLchan *) source, srcRowStride,
+ dstFormat, dest, dstRowStride);
+ if (tempImage) {
+ FREE(tempImage);
+ }
+}
+
+
+
/*
- * This is the software fallback for Driver.TexImage1D().
+ * This is the software fallback for Driver.TexImage1D()
+ * and Driver.CopyTexImage2D().
* The texture image type will be GLchan.
* The texture image format will be GL_COLOR_INDEX, GL_INTENSITY,
* GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_ALPHA, GL_RGB or GL_RGBA.
- *
*/
void
_mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
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 */
+ if (texImage->IsCompressed)
+ sizeInBytes = texImage->CompressedSize;
+ else
+ sizeInBytes = postConvWidth * texelBytes;
texImage->Data = MESA_PBUFFER_ALLOC(sizeInBytes);
if (!texImage->Data) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
return;
}
- if (pixels) {
- /* unpack image, apply transfer ops and store in texImage->Data */
+ if (!pixels)
+ return;
+
+ /* unpack image, apply transfer ops and store in texImage->Data */
+ if (texImage->IsCompressed) {
+ GLint dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat,
+ width);
+ transfer_compressed_teximage(ctx, 1, width, 1, 1,
+ format, type, packing,
+ pixels, texImage->IntFormat,
+ (GLubyte *) texImage->Data, dstRowStride);
+ }
+ else {
_mesa_transfer_teximage(ctx, 1,
- _mesa_base_tex_format(ctx, internalFormat),
+ texImage->Format, /* base format */
texImage->TexFormat, texImage->Data,
- width, 1, 1, 0, 0, 0,
+ width, 1, 1, /* src size */
+ 0, 0, 0, /* dstX/Y/Zoffset */
0, /* dstRowStride */
0, /* dstImageStride */
format, type, pixels, packing);
+ }
- /* GL_SGIS_generate_mipmap */
- if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
- _mesa_generate_mipmap(ctx, target,
- &ctx->Texture.Unit[ctx->Texture.CurrentUnit],
- texObj);
- }
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ _mesa_generate_mipmap(ctx, target,
+ &ctx->Texture.Unit[ctx->Texture.CurrentUnit],
+ texObj);
}
}
/*
- * This is the software fallback for Driver.TexImage2D().
+ * This is the software fallback for Driver.TexImage2D()
+ * and Driver.CopyTexImage2D().
* The texture image type will be GLchan.
* The texture image format will be GL_COLOR_INDEX, GL_INTENSITY,
* 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
_mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
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 */
+ if (texImage->IsCompressed)
+ sizeInBytes = texImage->CompressedSize;
+ else
+ sizeInBytes = postConvWidth * postConvHeight * texelBytes;
texImage->Data = MESA_PBUFFER_ALLOC(sizeInBytes);
if (!texImage->Data) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
return;
}
- if (pixels) {
- /* unpack image, apply transfer ops and store in texImage->Data */
+ if (!pixels)
+ return;
+
+ /* unpack image, apply transfer ops and store in texImage->Data */
+ if (texImage->IsCompressed) {
+ GLint dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat,
+ width);
+ transfer_compressed_teximage(ctx, 2, width, height, 1,
+ format, type, packing,
+ pixels, texImage->IntFormat,
+ (GLubyte *) texImage->Data, dstRowStride);
+ }
+ else {
_mesa_transfer_teximage(ctx, 2,
- _mesa_base_tex_format(ctx, internalFormat),
+ texImage->Format,
texImage->TexFormat, texImage->Data,
- width, height, 1, 0, 0, 0,
- texImage->Width * texelBytes,
+ width, height, 1, /* src size */
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ texImage->Width * texelBytes, /* dstRowStride */
0, /* dstImageStride */
format, type, pixels, packing);
+ }
- /* GL_SGIS_generate_mipmap */
- if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
- _mesa_generate_mipmap(ctx, target,
- &ctx->Texture.Unit[ctx->Texture.CurrentUnit],
- texObj);
- }
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ _mesa_generate_mipmap(ctx, target,
+ &ctx->Texture.Unit[ctx->Texture.CurrentUnit],
+ texObj);
}
}
/*
- * This is the software fallback for Driver.TexImage3D().
+ * This is the software fallback for Driver.TexImage3D()
+ * and Driver.CopyTexImage3D().
* The texture image type will be GLchan.
* The texture image format will be GL_COLOR_INDEX, GL_INTENSITY,
* GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_ALPHA, GL_RGB or GL_RGBA.
- *
*/
void
_mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
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 */
+ if (texImage->IsCompressed)
+ sizeInBytes = texImage->CompressedSize;
+ else
+ sizeInBytes = width * height * depth * texelBytes;
texImage->Data = MESA_PBUFFER_ALLOC(sizeInBytes);
if (!texImage->Data) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
return;
}
- if (pixels) {
- /* unpack image, apply transfer ops and store in texImage->Data */
+ if (!pixels)
+ return;
+
+ /* unpack image, apply transfer ops and store in texImage->Data */
+ if (texImage->IsCompressed) {
+ GLint dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat,
+ width);
+ transfer_compressed_teximage(ctx, 3, width, height, depth,
+ format, type, packing,
+ pixels, texImage->IntFormat,
+ (GLubyte *) texImage->Data, dstRowStride);
+ }
+ else {
_mesa_transfer_teximage(ctx, 3,
- _mesa_base_tex_format(ctx, internalFormat),
+ texImage->Format,
texImage->TexFormat, texImage->Data,
- width, height, depth, 0, 0, 0,
- texImage->Width * texelBytes,
+ width, height, depth, /* src size */
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ texImage->Width * texelBytes, /* dstRowStride */
texImage->Width * texImage->Height * texelBytes,
format, type, pixels, packing);
+ }
- /* GL_SGIS_generate_mipmap */
- if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
- _mesa_generate_mipmap(ctx, target,
- &ctx->Texture.Unit[ctx->Texture.CurrentUnit],
- texObj);
- }
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ _mesa_generate_mipmap(ctx, target,
+ &ctx->Texture.Unit[ctx->Texture.CurrentUnit],
+ texObj);
}
}
/*
- * This is the software fallback for Driver.TexSubImage1D().
+ * This is the software fallback for Driver.TexSubImage1D()
+ * and Driver.CopyTexSubImage1D().
*/
void
_mesa_store_texsubimage1d(GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- _mesa_transfer_teximage(ctx, 1,
- _mesa_base_tex_format(ctx, texImage->IntFormat),
- texImage->TexFormat, texImage->Data,
- width, 1, 1, /* src size */
- xoffset, 0, 0, /* dest offsets */
- 0, /* dstRowStride */
- 0, /* dstImageStride */
- format, type, pixels, packing);
+ if (texImage->IsCompressed) {
+ GLint dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat,
+ texImage->Width);
+ GLubyte *dest = _mesa_compressed_image_address(xoffset, 0, 0,
+ texImage->IntFormat,
+ texImage->Width,
+ texImage->Data);
+ transfer_compressed_teximage(ctx, 1, /* dimensions */
+ width, 1, 1, /* size to replace */
+ format, type, /* source format/type */
+ packing, /* source packing */
+ pixels, /* source data */
+ texImage->IntFormat,/* dest format */
+ dest, dstRowStride);
+ }
+ else {
+ _mesa_transfer_teximage(ctx, 1,
+ texImage->Format,
+ texImage->TexFormat, texImage->Data,
+ width, 1, 1, /* src size */
+ xoffset, 0, 0, /* dest offsets */
+ 0, /* dstRowStride */
+ 0, /* dstImageStride */
+ format, type, pixels, packing);
+ }
/* GL_SGIS_generate_mipmap */
if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
}
+
/*
- * This is the software fallback for Driver.TexSubImage2D().
+ * This is the software fallback for Driver.TexSubImage2D()
+ * and Driver.CopyTexSubImage2D().
*/
void
_mesa_store_texsubimage2d(GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- _mesa_transfer_teximage(ctx, 2,
- _mesa_base_tex_format(ctx, texImage->IntFormat),
- texImage->TexFormat, texImage->Data,
- width, height, 1, /* src size */
- xoffset, yoffset, 0, /* dest offsets */
- texImage->Width * texImage->TexFormat->TexelBytes,
- 0, /* dstImageStride */
- format, type, pixels, packing);
+ if (texImage->IsCompressed) {
+ GLint dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat,
+ texImage->Width);
+ GLubyte *dest = _mesa_compressed_image_address(xoffset, yoffset, 0,
+ texImage->IntFormat,
+ texImage->Width,
+ texImage->Data);
+ transfer_compressed_teximage(ctx, 2, /* dimensions */
+ width, height, 1, /* size to replace */
+ format, type, /* source format/type */
+ packing, /* source packing */
+ pixels, /* source data */
+ texImage->IntFormat,/* dest format */
+ dest, dstRowStride);
+ }
+ else {
+ _mesa_transfer_teximage(ctx, 2,
+ texImage->Format,
+ texImage->TexFormat, texImage->Data,
+ width, height, 1, /* src size */
+ xoffset, yoffset, 0, /* dest offsets */
+ texImage->Width *texImage->TexFormat->TexelBytes,
+ 0, /* dstImageStride */
+ format, type, pixels, packing);
+ }
/* GL_SGIS_generate_mipmap */
if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
/*
* This is the software fallback for Driver.TexSubImage3D().
+ * and Driver.CopyTexSubImage3D().
*/
void
_mesa_store_texsubimage3d(GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- const GLint texelBytes = texImage->TexFormat->TexelBytes;
- _mesa_transfer_teximage(ctx, 3,
- _mesa_base_tex_format(ctx, texImage->IntFormat),
+ if (texImage->IsCompressed) {
+ GLint dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat,
+ texImage->Width);
+ GLubyte *dest = _mesa_compressed_image_address(xoffset, yoffset, zoffset,
+ texImage->IntFormat,
+ texImage->Width,
+ texImage->Data);
+ transfer_compressed_teximage(ctx, 3, /* dimensions */
+ width, height, depth,/* size to replace */
+ format, type, /* source format/type */
+ packing, /* source packing */
+ pixels, /* source data */
+ texImage->IntFormat,/* dest format */
+ dest, dstRowStride);
+ }
+ else {
+ const GLint texelBytes = texImage->TexFormat->TexelBytes;
+ _mesa_transfer_teximage(ctx, 3,
+ texImage->Format,
texImage->TexFormat, texImage->Data,
width, height, depth, /* src size */
xoffset, yoffset, xoffset, /* dest offsets */
- texImage->Width * texelBytes,
+ texImage->Width * texelBytes, /* dst row stride */
texImage->Width * texImage->Height * texelBytes,
format, type, pixels, packing);
+ }
+
/* GL_SGIS_generate_mipmap */
if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
_mesa_generate_mipmap(ctx, target,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- /* Nothing here.
- * The device driver has to do it all.
- */
+ /* this space intentionally left blank */
}
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- /* Nothing here.
- * The device driver has to do it all.
+ /* This is pretty simple, basically just do a memcpy without worrying
+ * about the usual image unpacking or image transfer operations.
*/
+ ASSERT(texObj);
+ ASSERT(texImage);
+ ASSERT(texImage->Width > 0);
+ ASSERT(texImage->Height > 0);
+ ASSERT(texImage->Depth == 1);
+ ASSERT(texImage->Data == NULL); /* was freed in glCompressedTexImage2DARB */
+
+ /* choose the texture format */
+ assert(ctx->Driver.ChooseTextureFormat);
+ texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
+ internalFormat, 0, 0);
+ assert(texImage->TexFormat);
+ texImage->FetchTexel = texImage->TexFormat->FetchTexel2D;
+
+ /* allocate storage */
+ texImage->Data = MESA_PBUFFER_ALLOC(imageSize);
+ if (!texImage->Data) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB");
+ return;
+ }
+
+ /* copy the data */
+ ASSERT(texImage->CompressedSize == imageSize);
+ MEMCPY(texImage->Data, data, imageSize);
}
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- /* Nothing here.
- * The device driver has to do it all.
- */
+ /* this space intentionally left blank */
}
-/*
- * 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.
+/**
+ * Fallback for Driver.CompressedTexSubImage1D()
*/
void
-_mesa_get_compressed_teximage(GLcontext *ctx, GLenum target,
- GLint level, void *image,
- const struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
+_mesa_store_compressed_texsubimage1d(GLcontext *ctx, GLenum target,
+ GLint level,
+ GLint xoffset, GLsizei width,
+ GLenum format,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
{
- assert(texImage->IsCompressed);
- assert(texImage->CompressedSize > 0);
- MEMCPY(image, texImage->Data, texImage->CompressedSize);
+ /* this space intentionally left blank */
}
+/**
+ * Fallback for Driver.CompressedTexSubImage2D()
+ */
+void
+_mesa_store_compressed_texsubimage2d(GLcontext *ctx, GLenum target,
+ GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ GLint bytesPerRow, destRowStride, srcRowStride;
+ GLint i, rows;
+ GLubyte *dest;
+ const GLubyte *src;
+
+ /* these should have been caught sooner */
+ ASSERT((width & 3) == 0 || width == 2 || width == 1);
+ ASSERT((height & 3) == 0 || height == 2 || height == 1);
+ ASSERT((xoffset & 3) == 0);
+ ASSERT((yoffset & 3) == 0);
+
+ srcRowStride = _mesa_compressed_row_stride(texImage->IntFormat, width);
+ src = (const GLubyte *) data;
+
+ destRowStride = _mesa_compressed_row_stride(texImage->IntFormat,
+ texImage->Width);
+ dest = _mesa_compressed_image_address(xoffset, yoffset, 0,
+ texImage->IntFormat,
+ texImage->Width, texImage->Data);
+
+ bytesPerRow = srcRowStride;
+ rows = height / 4;
+
+ for (i = 0; i < rows; i++) {
+ MEMCPY(dest, src, bytesPerRow);
+ dest += destRowStride;
+ src += srcRowStride;
+ }
+}
+
+
+/**
+ * Fallback for Driver.CompressedTexSubImage3D()
+ */
+void
+_mesa_store_compressed_texsubimage3d(GLcontext *ctx, GLenum target,
+ GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ /* this space intentionally left blank */
+}
+
+
+
+
/*
* This is the fallback for Driver.TestProxyTexImage().
const struct gl_texture_unit *texUnit,
struct gl_texture_object *texObj)
{
+ const GLubyte *srcData;
+ GLubyte *dstData;
GLint level;
GLint maxLevels = 0;
return;
}
+ /* setup for compressed textures */
+ {
+ const struct gl_texture_image *srcImage;
+ srcImage = texObj->Image[texObj->BaseLevel];
+ if (srcImage->IsCompressed) {
+ /* allocate storage for uncompressed images */
+ GLint size = _mesa_bytes_per_pixel(srcImage->Format, CHAN_TYPE)
+ * srcImage->Width * srcImage->Height * srcImage->Depth;
+ srcData = MALLOC(size);
+ if (!srcData) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "generate mipmaps");
+ return;
+ }
+ dstData = MALLOC(size / 2); /* 1/4 would probably be OK */
+ if (!dstData) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "generate mipmaps");
+ FREE((void *) srcData);
+ return;
+ }
+ /* XXX decompress base image here */
+ }
+ }
+
for (level = texObj->BaseLevel; level < texObj->MaxLevel
&& level < maxLevels - 1; level++) {
/* generate image[level+1] from image[level] */
GLint dstWidth, dstHeight, dstDepth;
GLint border, bytesPerTexel;
+ /* get src image parameters */
srcImage = texObj->Image[level];
ASSERT(srcImage);
srcWidth = srcImage->Width;
srcHeight = srcImage->Height;
srcDepth = srcImage->Depth;
border = srcImage->Border;
- bytesPerTexel = srcImage->TexFormat->TexelBytes;
/* compute next (level+1) image size */
if (srcWidth - 2 * border > 1) {
dstHeight == srcHeight &&
dstDepth == srcDepth) {
/* all done */
+ if (srcImage->IsCompressed) {
+ FREE((void *) srcData);
+ FREE(dstData);
+ }
return;
}
/* initialize new image */
_mesa_init_teximage_fields(ctx, target, dstImage, dstWidth, dstHeight,
- dstDepth, border, srcImage->Format);
+ dstDepth, border, srcImage->IntFormat);
dstImage->DriverData = NULL;
dstImage->TexFormat = srcImage->TexFormat;
dstImage->FetchTexel = srcImage->FetchTexel;
ASSERT(dstImage->TexFormat);
ASSERT(dstImage->FetchTexel);
- ASSERT(dstWidth * dstHeight * dstDepth * bytesPerTexel > 0);
-
- /* alloc new image buffer */
- dstImage->Data = MESA_PBUFFER_ALLOC(dstWidth * dstHeight * dstDepth
- * bytesPerTexel);
- if (!dstImage->Data) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps");
- return;
+ /* Alloc new teximage data buffer.
+ * Setup src and dest data pointers.
+ */
+ if (dstImage->IsCompressed) {
+ ASSERT(dstImage->CompressedSize > 0); /* set by init_teximage_fields*/
+ dstImage->Data = MESA_PBUFFER_ALLOC(dstImage->CompressedSize);
+ if (!dstImage->Data) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps");
+ return;
+ }
+ /* srcData and dstData are all set */
+ ASSERT(srcData);
+ ASSERT(dstData);
+ }
+ else {
+ bytesPerTexel = srcImage->TexFormat->TexelBytes;
+ ASSERT(dstWidth * dstHeight * dstDepth * bytesPerTexel > 0);
+ dstImage->Data = MESA_PBUFFER_ALLOC(dstWidth * dstHeight * dstDepth
+ * bytesPerTexel);
+ if (!dstImage->Data) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps");
+ return;
+ }
+ srcData = (const GLubyte *) srcImage->Data;
+ dstData = (GLubyte *) dstImage->Data;
}
/*
* We use simple 2x2 averaging to compute the next mipmap level.
*/
switch (target) {
- case GL_TEXTURE_1D:
- make_1d_mipmap(srcImage->TexFormat, border,
- srcWidth, (const GLubyte *) srcImage->Data,
- dstWidth, (GLubyte *) dstImage->Data);
- break;
- case GL_TEXTURE_2D:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
- make_2d_mipmap(srcImage->TexFormat, border,
- srcWidth, srcHeight, (const GLubyte *) srcImage->Data,
- dstWidth, dstHeight, (GLubyte *) dstImage->Data);
- break;
- case GL_TEXTURE_3D:
- make_3d_mipmap(srcImage->TexFormat, border,
- srcWidth, srcHeight, srcDepth,
- (const GLubyte *) srcImage->Data,
- dstWidth, dstHeight, dstDepth,
- (GLubyte *) dstImage->Data);
- break;
- case GL_TEXTURE_RECTANGLE_NV:
- /* no mipmaps, do nothing */
- break;
- default:
- _mesa_problem(ctx, "bad dimensions in _mesa_generate_mipmaps");
- return;
+ case GL_TEXTURE_1D:
+ make_1d_mipmap(srcImage->TexFormat, border,
+ srcWidth, srcData,
+ dstWidth, dstData);
+ break;
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
+ make_2d_mipmap(srcImage->TexFormat, border,
+ srcWidth, srcHeight, srcData,
+ dstWidth, dstHeight, dstData);
+ break;
+ case GL_TEXTURE_3D:
+ make_3d_mipmap(srcImage->TexFormat, border,
+ srcWidth, srcHeight, srcDepth, srcData,
+ dstWidth, dstHeight, dstDepth, dstData);
+ break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ /* no mipmaps, do nothing */
+ break;
+ default:
+ _mesa_problem(ctx, "bad dimensions in _mesa_generate_mipmaps");
+ return;
}
+
+ if (dstImage->IsCompressed) {
+ GLubyte *temp;
+ /* XXX compress from dstData into dstImage->Data */
+
+ /* swap src and dest pointers */
+ temp = (GLubyte *) srcData;
+ srcData = dstData;
+ dstData = temp;
+ }
+
} /* loop over mipmap levels */
}
-/* $Id: texstore.h,v 1.10 2002/09/16 17:57:14 brianp Exp $ */
+/* $Id: texstore.h,v 1.11 2002/09/27 02:45:38 brianp Exp $ */
/*
* Mesa 3-D graphics library
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);
+_mesa_store_compressed_texsubimage1d(GLcontext *ctx, GLenum target,
+ GLint level,
+ GLint xoffset, GLsizei width,
+ GLenum format,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
+
+extern void
+_mesa_store_compressed_texsubimage2d(GLcontext *ctx, GLenum target,
+ GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
+
+extern void
+_mesa_store_compressed_texsubimage3d(GLcontext *ctx, GLenum target,
+ GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
extern GLboolean
-/* $Id: texutil.c,v 1.31 2002/09/21 16:51:25 brianp Exp $ */
+/* $Id: texutil.c,v 1.32 2002/09/27 02:45:38 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 4.0.3
+ * Version: 4.1
*
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
-/* $Id: s_texstore.c,v 1.7 2002/09/16 17:57:14 brianp Exp $ */
+/* $Id: s_texstore.c,v 1.8 2002/09/27 02:45:39 brianp Exp $ */
/*
* Mesa 3-D graphics library
*/
void
_swrast_copy_teximage1d( GLcontext *ctx, GLenum target, GLint level,
- GLenum internalFormat,
- GLint x, GLint y, GLsizei width, GLint border )
+ GLenum internalFormat,
+ GLint x, GLint y, GLsizei width, GLint border )
{
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
*/
void
_swrast_copy_teximage2d( GLcontext *ctx, GLenum target, GLint level,
- GLenum internalFormat,
- GLint x, GLint y, GLsizei width, GLsizei height,
- GLint border )
+ GLenum internalFormat,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLint border )
{
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
* Fallback for Driver.CopyTexSubImage1D().
*/
void
-_swrast_copy_texsubimage1d(GLcontext *ctx, GLenum target, GLint level,
- GLint xoffset, GLint x, GLint y, GLsizei width)
+_swrast_copy_texsubimage1d( GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint x, GLint y, GLsizei width )
{
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
ASSERT(ctx->Driver.TexImage1D);
- if (texImage->Format != GL_DEPTH_COMPONENT) {
- /* read RGBA image from framebuffer */
- GLchan *image = read_color_image(ctx, x, y, width, 1);
+ if (texImage->Format == GL_DEPTH_COMPONENT) {
+ /* read depth image from framebuffer */
+ GLfloat *image = read_depth_image(ctx, x, y, width, 1);
if (!image) {
- _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage1D" );
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage1D");
return;
}
-#if 0
- /*
- * XXX this is a bit of a hack. We need to be sure that the alpha
- * channel is 1.0 if the internal texture format is not supposed to
- * have an alpha channel. This is because some drivers may store
- * RGB textures as RGBA and the texutil.c code isn't smart enough
- * to set the alpha channel to 1.0 in this situation.
- */
- if (texImage->Format == GL_LUMINANCE ||
- texImage->Format == GL_RGB) {
- const GLuint n = width * 4;
- GLuint i;
- for (i = 0; i < n; i += 4) {
- image[i + 3] = CHAN_MAX;
- }
- }
-#endif
- /* now call glTexSubImage1D to do the real work */
+ /* call glTexSubImage1D to redefine the texture */
(*ctx->Driver.TexSubImage1D)(ctx, target, level, xoffset, width,
- GL_RGBA, CHAN_TYPE, image,
+ GL_DEPTH_COMPONENT, GL_FLOAT, image,
&_mesa_native_packing, texObj, texImage);
FREE(image);
}
else {
- /* read depth image from framebuffer */
- GLfloat *image = read_depth_image(ctx, x, y, width, 1);
+ /* read RGBA image from framebuffer */
+ GLchan *image = read_color_image(ctx, x, y, width, 1);
if (!image) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage1D");
+ _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage1D" );
return;
}
- /* call glTexSubImage1D to redefine the texture */
+ /* now call glTexSubImage1D to do the real work */
(*ctx->Driver.TexSubImage1D)(ctx, target, level, xoffset, width,
- GL_DEPTH_COMPONENT, GL_FLOAT, image,
+ GL_RGBA, CHAN_TYPE, image,
&_mesa_native_packing, texObj, texImage);
FREE(image);
}
*/
void
_swrast_copy_texsubimage2d( GLcontext *ctx,
- GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLint x, GLint y, GLsizei width, GLsizei height )
+ GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLint x, GLint y, GLsizei width, GLsizei height )
{
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
ASSERT(ctx->Driver.TexImage2D);
- if (texImage->Format != GL_DEPTH_COMPONENT) {
- /* read RGBA image from framebuffer */
- GLchan *image = read_color_image(ctx, x, y, width, height);
+ if (texImage->Format == GL_DEPTH_COMPONENT) {
+ /* read depth image from framebuffer */
+ GLfloat *image = read_depth_image(ctx, x, y, width, height);
if (!image) {
- _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage2D" );
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage2D");
return;
}
-#if 0
- /*
- * XXX this is a bit of a hack. We need to be sure that the alpha
- * channel is 1.0 if the internal texture format is not supposed to
- * have an alpha channel. This is because some drivers may store
- * RGB textures as RGBA and the texutil.c code isn't smart enough
- * to set the alpha channel to 1.0 in this situation.
- */
- if (texImage->Format == GL_LUMINANCE ||
- texImage->Format == GL_RGB) {
- const GLuint n = width * height * 4;
- GLuint i;
- for (i = 0; i < n; i += 4) {
- image[i + 3] = CHAN_MAX;
- }
- }
-#endif
- /* now call glTexSubImage2D to do the real work */
+ /* call glTexImage1D to redefine the texture */
(*ctx->Driver.TexSubImage2D)(ctx, target, level,
xoffset, yoffset, width, height,
- GL_RGBA, CHAN_TYPE, image,
+ GL_DEPTH_COMPONENT, GL_FLOAT, image,
&_mesa_native_packing, texObj, texImage);
FREE(image);
}
else {
- /* read depth image from framebuffer */
- GLfloat *image = read_depth_image(ctx, x, y, width, height);
+ /* read RGBA image from framebuffer */
+ GLchan *image = read_color_image(ctx, x, y, width, height);
if (!image) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage2D");
+ _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage2D" );
return;
}
- /* call glTexImage1D to redefine the texture */
+ /* now call glTexSubImage2D to do the real work */
(*ctx->Driver.TexSubImage2D)(ctx, target, level,
xoffset, yoffset, width, height,
- GL_DEPTH_COMPONENT, GL_FLOAT, image,
+ GL_RGBA, CHAN_TYPE, image,
&_mesa_native_packing, texObj, texImage);
FREE(image);
}
*/
void
_swrast_copy_texsubimage3d( GLcontext *ctx,
- GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLint x, GLint y, GLsizei width, GLsizei height )
+ GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLint x, GLint y, GLsizei width, GLsizei height )
{
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
ASSERT(ctx->Driver.TexImage3D);
- if (texImage->Format != GL_DEPTH_COMPONENT) {
- /* read RGBA image from framebuffer */
- GLchan *image = read_color_image(ctx, x, y, width, height);
+ if (texImage->Format == GL_DEPTH_COMPONENT) {
+ /* read depth image from framebuffer */
+ GLfloat *image = read_depth_image(ctx, x, y, width, height);
if (!image) {
- _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage3D" );
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage3D");
return;
}
-#if 0
- /*
- * XXX this is a bit of a hack. We need to be sure that the alpha
- * channel is 1.0 if the internal texture format is not supposed to
- * have an alpha channel. This is because some drivers may store
- * RGB textures as RGBA and the texutil.c code isn't smart enough
- * to set the alpha channel to 1.0 in this situation.
- */
- if (texImage->Format == GL_LUMINANCE ||
- texImage->Format == GL_RGB) {
- const GLuint n = width * height * 4;
- GLuint i;
- for (i = 0; i < n; i += 4) {
- image[i + 3] = CHAN_MAX;
- }
- }
-#endif
- /* now call glTexSubImage3D to do the real work */
+
+ /* call glTexImage1D to redefine the texture */
(*ctx->Driver.TexSubImage3D)(ctx, target, level,
xoffset, yoffset, zoffset, width, height, 1,
- GL_RGBA, CHAN_TYPE, image,
+ GL_DEPTH_COMPONENT, GL_FLOAT, image,
&_mesa_native_packing, texObj, texImage);
FREE(image);
}
else {
- /* read depth image from framebuffer */
- GLfloat *image = read_depth_image(ctx, x, y, width, height);
+ /* read RGBA image from framebuffer */
+ GLchan *image = read_color_image(ctx, x, y, width, height);
if (!image) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage3D");
+ _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage3D" );
return;
}
- /* call glTexImage1D to redefine the texture */
+ /* now call glTexSubImage3D to do the real work */
(*ctx->Driver.TexSubImage3D)(ctx, target, level,
xoffset, yoffset, zoffset, width, height, 1,
- GL_DEPTH_COMPONENT, GL_FLOAT, image,
+ GL_RGBA, CHAN_TYPE, image,
&_mesa_native_packing, texObj, texImage);
FREE(image);
}