mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 06:58:05 +02:00
Removed the old teximage code.
Moved all code related to specific texture compression modes into new texcompress_s3tc.c and texcompress_fxt1.c files (but not implemented).
This commit is contained in:
parent
186d4d8cf4
commit
8f04c12e0a
17 changed files with 737 additions and 2900 deletions
|
|
@ -28,6 +28,7 @@
|
|||
#include "buffers.h"
|
||||
#include "context.h"
|
||||
#include "program.h"
|
||||
#include "texcompress.h"
|
||||
#include "texformat.h"
|
||||
#include "teximage.h"
|
||||
#include "texobj.h"
|
||||
|
|
@ -90,8 +91,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
|
|||
driver->CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
|
||||
driver->CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
|
||||
driver->CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
|
||||
driver->IsCompressedFormat = NULL; /* XXX?? */
|
||||
driver->CompressedTextureSize = NULL; /* XXX?? */
|
||||
driver->CompressedTextureSize = _mesa_compressed_texture_size;
|
||||
driver->BindTexture = NULL;
|
||||
driver->NewTextureObject = _mesa_new_texture_object;
|
||||
driver->DeleteTexture = _mesa_delete_texture_object;
|
||||
|
|
|
|||
|
|
@ -109,6 +109,7 @@
|
|||
#include "simple_list.h"
|
||||
#include "state.h"
|
||||
#include "stencil.h"
|
||||
#include "texcompress.h"
|
||||
#include "teximage.h"
|
||||
#include "texobj.h"
|
||||
#include "texstate.h"
|
||||
|
|
@ -1130,6 +1131,9 @@ init_attrib_groups( GLcontext *ctx )
|
|||
if (!_mesa_init_texture( ctx ))
|
||||
return GL_FALSE;
|
||||
|
||||
_mesa_init_texture_s3tc( ctx );
|
||||
_mesa_init_texture_fxt1( ctx );
|
||||
|
||||
/* Miscellaneous */
|
||||
ctx->NewState = _NEW_ALL;
|
||||
ctx->ErrorValue = (GLenum) GL_NO_ERROR;
|
||||
|
|
|
|||
|
|
@ -186,9 +186,8 @@ struct dd_function_table {
|
|||
* functions. The driver should examine \p internalFormat and return a
|
||||
* pointer to an appropriate gl_texture_format.
|
||||
*/
|
||||
const struct gl_texture_format *
|
||||
(*ChooseTextureFormat)( GLcontext *ctx, GLint internalFormat,
|
||||
GLenum srcFormat, GLenum srcType );
|
||||
const struct gl_texture_format *(*ChooseTextureFormat)( GLcontext *ctx,
|
||||
GLint internalFormat, GLenum srcFormat, GLenum srcType );
|
||||
|
||||
/**
|
||||
* Called by glTexImage1D().
|
||||
|
|
@ -454,16 +453,13 @@ struct dd_function_table {
|
|||
GLsizei imageSize, const GLvoid *data,
|
||||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage);
|
||||
|
||||
/**
|
||||
* Called to validate a certain compressed format.
|
||||
* Called to query number of bytes of storage needed to store the
|
||||
* specified compressed texture.
|
||||
*/
|
||||
GLboolean (*IsCompressedFormat)( GLcontext *ctx, GLenum internalFormat );
|
||||
/**
|
||||
* Called to get bytes of storage needed for the given texture size and
|
||||
* compressed format.
|
||||
*/
|
||||
GLuint (*CompressedTextureSize)( GLcontext *ctx,
|
||||
GLsizei width, GLsizei height, GLsizei depth,
|
||||
GLuint (*CompressedTextureSize)( GLcontext *ctx, GLsizei width,
|
||||
GLsizei height, GLsizei depth,
|
||||
GLenum format );
|
||||
/*@}*/
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,8 @@
|
|||
/**
|
||||
* \file texcompress.c
|
||||
* Compressed textures functions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 5.1
|
||||
* Version: 6.1
|
||||
*
|
||||
* Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2004 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"),
|
||||
|
|
@ -28,17 +23,24 @@
|
|||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \file texcompress.c
|
||||
* Helper functions for texture compression.
|
||||
*/
|
||||
|
||||
|
||||
#include "glheader.h"
|
||||
#include "imports.h"
|
||||
#include "colormac.h"
|
||||
#include "context.h"
|
||||
#include "image.h"
|
||||
#include "texcompress.h"
|
||||
#include "texformat.h"
|
||||
|
||||
#include "texstore.h"
|
||||
|
||||
/**
|
||||
* Get the list of supported internal compression formats.
|
||||
*
|
||||
*
|
||||
* \param ctx GL context.
|
||||
* \param formats the resulting format list (may be NULL).
|
||||
*
|
||||
|
|
@ -89,16 +91,19 @@ _mesa_get_compressed_formats( GLcontext *ctx, GLint *formats )
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return bytes of storage needed for the given texture size and
|
||||
* compressed format.
|
||||
*
|
||||
* Return number of bytes needed to store a texture of the given size
|
||||
* using the specified compressed format.
|
||||
* This is called via the ctx->Driver.CompressedTextureSize function,
|
||||
* unless a device driver overrides it.
|
||||
*
|
||||
* \param width texture width in texels.
|
||||
* \param height texture height in texels.
|
||||
* \param depth texture depth in texels.
|
||||
* \param texFormat one of the compressed format enums
|
||||
*
|
||||
* \return size in bytes, or zero if bad \p texFormat.
|
||||
* \param format - one of the specific compressed texture formats
|
||||
*
|
||||
* \return size in bytes, or zero if bad format
|
||||
*/
|
||||
GLuint
|
||||
_mesa_compressed_texture_size( GLcontext *ctx,
|
||||
|
|
@ -107,10 +112,6 @@ _mesa_compressed_texture_size( GLcontext *ctx,
|
|||
{
|
||||
GLuint size;
|
||||
|
||||
if (ctx->Driver.CompressedTextureSize) {
|
||||
return ctx->Driver.CompressedTextureSize(ctx, width, height, depth, format);
|
||||
}
|
||||
|
||||
ASSERT(depth == 1);
|
||||
|
||||
switch (format) {
|
||||
|
|
@ -164,7 +165,7 @@ _mesa_compressed_texture_size( GLcontext *ctx,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
/*
|
||||
* Compute the bytes per row in a compressed texture image.
|
||||
* We use this for computing the destination address for sub-texture updates.
|
||||
* \param format one of the specific texture compression formats
|
||||
|
|
@ -201,18 +202,14 @@ _mesa_compressed_row_stride(GLenum format, GLsizei width)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
/*
|
||||
* Return the address of the pixel at (col, row, img) in a
|
||||
* compressed texture image.
|
||||
*
|
||||
* \param col image position.
|
||||
* \param row image position.
|
||||
* \param img image position.
|
||||
* \param format compressed image format.
|
||||
* \param width image width.
|
||||
* \param image the image address.
|
||||
*
|
||||
* \return address of pixel at (row, col).
|
||||
* \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,
|
||||
|
|
@ -254,21 +251,3 @@ _mesa_compressed_image_address(GLint col, GLint row, GLint img,
|
|||
|
||||
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,
|
||||
const struct gl_texture_format *dstFormat,
|
||||
GLubyte *dest, GLint dstRowStride )
|
||||
{
|
||||
switch (dstFormat->MesaFormat) {
|
||||
default:
|
||||
_mesa_problem(ctx, "Bad dstFormat in _mesa_compress_teximage()");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 4.1
|
||||
* Version: 6.1
|
||||
*
|
||||
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2004 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"),
|
||||
|
|
@ -48,11 +47,13 @@ _mesa_compressed_image_address(GLint col, GLint row, GLint img,
|
|||
|
||||
|
||||
extern void
|
||||
_mesa_compress_teximage( GLcontext *ctx, GLsizei width, GLsizei height,
|
||||
GLenum srcFormat, const GLchan *source,
|
||||
GLint srcRowStride,
|
||||
const struct gl_texture_format *dstFormat,
|
||||
GLubyte *dest, GLint dstRowStride );
|
||||
_mesa_init_texture_s3tc( GLcontext *ctx );
|
||||
|
||||
extern void
|
||||
_mesa_init_texture_fxt1( GLcontext *ctx );
|
||||
|
||||
|
||||
|
||||
#else
|
||||
#define _mesa_get_compressed_formats( c, f ) 0
|
||||
#define _mesa_compressed_texture_size( c, w, h, d, f ) 0
|
||||
|
|
|
|||
155
src/mesa/main/texcompress_fxt1.c
Normal file
155
src/mesa/main/texcompress_fxt1.c
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.1
|
||||
*
|
||||
* Copyright (C) 1999-2004 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.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \file texcompress_fxt1.c
|
||||
* GL_EXT_texture_compression_fxt1 support.
|
||||
*/
|
||||
|
||||
|
||||
#include "glheader.h"
|
||||
#include "imports.h"
|
||||
#include "colormac.h"
|
||||
#include "context.h"
|
||||
#include "convolve.h"
|
||||
#include "image.h"
|
||||
#include "texcompress.h"
|
||||
#include "texformat.h"
|
||||
#include "texstore.h"
|
||||
|
||||
|
||||
void
|
||||
_mesa_init_texture_fxt1( GLcontext *ctx )
|
||||
{
|
||||
/* called during context initialization */
|
||||
}
|
||||
|
||||
|
||||
static GLboolean
|
||||
texstore_rgb_fxt1(STORE_PARAMS)
|
||||
{
|
||||
/* XXX to do */
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
static GLboolean
|
||||
texstore_rgba_fxt1(STORE_PARAMS)
|
||||
{
|
||||
/* XXX to do */
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
fetch_texel_2d_rgba_fxt1( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLchan *texel )
|
||||
{
|
||||
/* XXX to do */
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fetch_texel_2d_f_rgba_fxt1( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLfloat *texel )
|
||||
{
|
||||
/* just sample as GLchan and convert to float here */
|
||||
GLchan rgba[4];
|
||||
fetch_texel_2d_rgba_fxt1(texImage, i, j, k, rgba);
|
||||
texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
|
||||
texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
|
||||
texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
|
||||
texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fetch_texel_2d_rgb_fxt1( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLchan *texel )
|
||||
{
|
||||
/* XXX to do */
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fetch_texel_2d_f_rgb_fxt1( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLfloat *texel )
|
||||
{
|
||||
/* just sample as GLchan and convert to float here */
|
||||
GLchan rgba[4];
|
||||
fetch_texel_2d_rgb_fxt1(texImage, i, j, k, rgba);
|
||||
texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
|
||||
texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
|
||||
texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
|
||||
texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const struct gl_texture_format _mesa_texformat_rgb_fxt1 = {
|
||||
MESA_FORMAT_RGB_FXT1, /* MesaFormat */
|
||||
GL_RGB, /* BaseFormat */
|
||||
GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
|
||||
4, /*approx*/ /* RedBits */
|
||||
4, /*approx*/ /* GreenBits */
|
||||
4, /*approx*/ /* BlueBits */
|
||||
0, /* AlphaBits */
|
||||
0, /* LuminanceBits */
|
||||
0, /* IntensityBits */
|
||||
0, /* IndexBits */
|
||||
0, /* DepthBits */
|
||||
0, /* TexelBytes */
|
||||
texstore_rgb_fxt1, /* StoreTexImageFunc */
|
||||
NULL, /*impossible*/ /* FetchTexel1D */
|
||||
fetch_texel_2d_rgb_fxt1, /* FetchTexel2D */
|
||||
NULL, /*impossible*/ /* FetchTexel3D */
|
||||
NULL, /*impossible*/ /* FetchTexel1Df */
|
||||
fetch_texel_2d_f_rgb_fxt1, /* FetchTexel2Df */
|
||||
NULL, /*impossible*/ /* FetchTexel3Df */
|
||||
};
|
||||
|
||||
const struct gl_texture_format _mesa_texformat_rgba_fxt1 = {
|
||||
MESA_FORMAT_RGBA_FXT1, /* MesaFormat */
|
||||
GL_RGBA, /* BaseFormat */
|
||||
GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
|
||||
4, /*approx*/ /* RedBits */
|
||||
4, /*approx*/ /* GreenBits */
|
||||
4, /*approx*/ /* BlueBits */
|
||||
1, /*approx*/ /* AlphaBits */
|
||||
0, /* LuminanceBits */
|
||||
0, /* IntensityBits */
|
||||
0, /* IndexBits */
|
||||
0, /* DepthBits */
|
||||
0, /* TexelBytes */
|
||||
texstore_rgba_fxt1, /* StoreTexImageFunc */
|
||||
NULL, /*impossible*/ /* FetchTexel1D */
|
||||
fetch_texel_2d_rgba_fxt1, /* FetchTexel2D */
|
||||
NULL, /*impossible*/ /* FetchTexel3D */
|
||||
NULL, /*impossible*/ /* FetchTexel1Df */
|
||||
fetch_texel_2d_f_rgba_fxt1, /* FetchTexel2Df */
|
||||
NULL, /*impossible*/ /* FetchTexel3Df */
|
||||
};
|
||||
|
||||
441
src/mesa/main/texcompress_s3tc.c
Normal file
441
src/mesa/main/texcompress_s3tc.c
Normal file
|
|
@ -0,0 +1,441 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.1
|
||||
*
|
||||
* Copyright (C) 1999-2004 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.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \file texcompress_s3tc.c
|
||||
* GL_EXT_texture_compression_s3tc support.
|
||||
*/
|
||||
|
||||
|
||||
#include "glheader.h"
|
||||
#include "imports.h"
|
||||
#include "colormac.h"
|
||||
#include "context.h"
|
||||
#include "convolve.h"
|
||||
#include "image.h"
|
||||
#include "texcompress.h"
|
||||
#include "texformat.h"
|
||||
#include "texstore.h"
|
||||
|
||||
|
||||
|
||||
void
|
||||
_mesa_init_texture_s3tc( GLcontext *ctx )
|
||||
{
|
||||
/* called during context initialization */
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called via TexFormat->StoreImage to store an RGB_DXT1 texture.
|
||||
*/
|
||||
static GLboolean
|
||||
texstore_rgb_dxt1(STORE_PARAMS)
|
||||
{
|
||||
const GLchan *pixels;
|
||||
GLint srcRowStride;
|
||||
GLubyte *dst;
|
||||
const GLint texWidth = dstRowStride / 2; /* a bit of a hack */
|
||||
const GLchan *tempImage = NULL;
|
||||
|
||||
ASSERT(dstFormat == &_mesa_texformat_rgb_dxt1);
|
||||
ASSERT(dstXoffset % 4 == 0);
|
||||
ASSERT(dstYoffset % 4 == 0);
|
||||
ASSERT(dstZoffset % 4 == 0);
|
||||
|
||||
if (srcFormat != GL_RGB ||
|
||||
srcType != CHAN_TYPE ||
|
||||
ctx->_ImageTransferState ||
|
||||
srcPacking->SwapBytes) {
|
||||
/* convert image to RGB/GLchan */
|
||||
tempImage = _mesa_make_temp_chan_image(ctx, dims,
|
||||
baseInternalFormat,
|
||||
dstFormat->BaseFormat,
|
||||
srcWidth, srcHeight, srcDepth,
|
||||
srcFormat, srcType, srcAddr,
|
||||
srcPacking);
|
||||
if (!tempImage)
|
||||
return GL_FALSE; /* out of memory */
|
||||
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
|
||||
pixels = tempImage;
|
||||
srcRowStride = 3 * srcWidth;
|
||||
srcFormat = GL_RGB;
|
||||
}
|
||||
else {
|
||||
pixels = (const GLchan *) srcAddr;
|
||||
srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
|
||||
srcType) / sizeof(GLchan);
|
||||
}
|
||||
|
||||
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
|
||||
GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
||||
texWidth, dstAddr);
|
||||
|
||||
#if 0
|
||||
compress_dxt1(ctx, srcWidth, srcHeight, srcFormat, pixels, srcRowStride,
|
||||
dst, dstRowStride);
|
||||
#endif
|
||||
|
||||
if (tempImage)
|
||||
_mesa_free((void *) tempImage);
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called via TexFormat->StoreImage to store an RGBA_DXT1 texture.
|
||||
*/
|
||||
static GLboolean
|
||||
texstore_rgba_dxt1(STORE_PARAMS)
|
||||
{
|
||||
const GLchan *pixels;
|
||||
GLint srcRowStride;
|
||||
GLubyte *dst;
|
||||
const GLint texWidth = dstRowStride / 2; /* a bit of a hack */
|
||||
const GLchan *tempImage = NULL;
|
||||
|
||||
ASSERT(dstFormat == &_mesa_texformat_rgba_dxt1);
|
||||
ASSERT(dstXoffset % 4 == 0);
|
||||
ASSERT(dstYoffset % 4 == 0);
|
||||
ASSERT(dstZoffset % 4 == 0);
|
||||
|
||||
if (srcFormat != GL_RGBA ||
|
||||
srcType != CHAN_TYPE ||
|
||||
ctx->_ImageTransferState ||
|
||||
srcPacking->SwapBytes) {
|
||||
/* convert image to RGBA/GLchan */
|
||||
tempImage = _mesa_make_temp_chan_image(ctx, dims,
|
||||
baseInternalFormat,
|
||||
dstFormat->BaseFormat,
|
||||
srcWidth, srcHeight, srcDepth,
|
||||
srcFormat, srcType, srcAddr,
|
||||
srcPacking);
|
||||
if (!tempImage)
|
||||
return GL_FALSE; /* out of memory */
|
||||
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
|
||||
pixels = tempImage;
|
||||
srcRowStride = 4 * srcWidth;
|
||||
srcFormat = GL_RGBA;
|
||||
}
|
||||
else {
|
||||
pixels = (const GLchan *) srcAddr;
|
||||
srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
|
||||
srcType) / sizeof(GLchan);
|
||||
}
|
||||
|
||||
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
|
||||
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
|
||||
texWidth, dstAddr);
|
||||
#if 0
|
||||
compress_dxt1(ctx, srcWidth, srcHeight, srcFormat, pixels, srcRowStride,
|
||||
dst, dstRowStride);
|
||||
#endif
|
||||
if (tempImage)
|
||||
_mesa_free((void*) tempImage);
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called via TexFormat->StoreImage to store an RGBA_DXT3 texture.
|
||||
*/
|
||||
static GLboolean
|
||||
texstore_rgba_dxt3(STORE_PARAMS)
|
||||
{
|
||||
const GLchan *pixels;
|
||||
GLint srcRowStride;
|
||||
GLubyte *dst;
|
||||
const GLint texWidth = dstRowStride / 4; /* a bit of a hack */
|
||||
const GLchan *tempImage = NULL;
|
||||
|
||||
ASSERT(dstFormat == &_mesa_texformat_rgba_dxt3);
|
||||
ASSERT(dstXoffset % 4 == 0);
|
||||
ASSERT(dstYoffset % 4 == 0);
|
||||
ASSERT(dstZoffset % 4 == 0);
|
||||
|
||||
if (srcFormat != GL_RGBA ||
|
||||
srcType != CHAN_TYPE ||
|
||||
ctx->_ImageTransferState ||
|
||||
srcPacking->SwapBytes) {
|
||||
/* convert image to RGBA/GLchan */
|
||||
tempImage = _mesa_make_temp_chan_image(ctx, dims,
|
||||
baseInternalFormat,
|
||||
dstFormat->BaseFormat,
|
||||
srcWidth, srcHeight, srcDepth,
|
||||
srcFormat, srcType, srcAddr,
|
||||
srcPacking);
|
||||
if (!tempImage)
|
||||
return GL_FALSE; /* out of memory */
|
||||
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
|
||||
pixels = tempImage;
|
||||
srcRowStride = 4 * srcWidth;
|
||||
}
|
||||
else {
|
||||
pixels = (const GLchan *) srcAddr;
|
||||
srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
|
||||
srcType) / sizeof(GLchan);
|
||||
}
|
||||
|
||||
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
|
||||
GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
|
||||
texWidth, dstAddr);
|
||||
#if 0
|
||||
compress_rgba_dxt3(ctx, srcWidth, srcHeight, pixels,
|
||||
srcRowStride, dst, dstRowStride);
|
||||
#endif
|
||||
if (tempImage)
|
||||
_mesa_free((void *) tempImage);
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called via TexFormat->StoreImage to store an RGBA_DXT5 texture.
|
||||
*/
|
||||
static GLboolean
|
||||
texstore_rgba_dxt5(STORE_PARAMS)
|
||||
{
|
||||
const GLchan *pixels;
|
||||
GLint srcRowStride;
|
||||
GLubyte *dst;
|
||||
const GLint texWidth = dstRowStride / 4; /* a bit of a hack */
|
||||
const GLchan *tempImage = NULL;
|
||||
|
||||
ASSERT(dstFormat == &_mesa_texformat_rgba_dxt5);
|
||||
ASSERT(dstXoffset % 4 == 0);
|
||||
ASSERT(dstYoffset % 4 == 0);
|
||||
ASSERT(dstZoffset % 4 == 0);
|
||||
|
||||
if (srcFormat != GL_RGBA ||
|
||||
srcType != CHAN_TYPE ||
|
||||
ctx->_ImageTransferState ||
|
||||
srcPacking->SwapBytes) {
|
||||
/* convert image to RGBA/GLchan */
|
||||
tempImage = _mesa_make_temp_chan_image(ctx, dims,
|
||||
baseInternalFormat,
|
||||
dstFormat->BaseFormat,
|
||||
srcWidth, srcHeight, srcDepth,
|
||||
srcFormat, srcType, srcAddr,
|
||||
srcPacking);
|
||||
if (!tempImage)
|
||||
return GL_FALSE; /* out of memory */
|
||||
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
|
||||
pixels = tempImage;
|
||||
srcRowStride = 4 * srcWidth;
|
||||
}
|
||||
else {
|
||||
pixels = (const GLchan *) srcAddr;
|
||||
srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
|
||||
srcType) / sizeof(GLchan);
|
||||
}
|
||||
|
||||
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
|
||||
GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
|
||||
texWidth, dstAddr);
|
||||
#if 0
|
||||
compress_rgba_dxt5(ctx, srcWidth, srcHeight, pixels,
|
||||
srcRowStride, dst, dstRowStride);
|
||||
#endif
|
||||
if (tempImage)
|
||||
_mesa_free((void *) tempImage);
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fetch_texel_2d_rgb_dxt1( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLchan *texel )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fetch_texel_2d_f_rgb_dxt1( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLfloat *texel )
|
||||
{
|
||||
/* just sample as GLchan and convert to float here */
|
||||
GLchan rgba[4];
|
||||
fetch_texel_2d_rgb_dxt1(texImage, i, j, k, rgba);
|
||||
texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
|
||||
texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
|
||||
texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
|
||||
texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fetch_texel_2d_rgba_dxt1( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLchan *texel )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fetch_texel_2d_f_rgba_dxt1( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLfloat *texel )
|
||||
{
|
||||
/* just sample as GLchan and convert to float here */
|
||||
GLchan rgba[4];
|
||||
fetch_texel_2d_rgba_dxt1(texImage, i, j, k, rgba);
|
||||
texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
|
||||
texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
|
||||
texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
|
||||
texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fetch_texel_2d_rgba_dxt3( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLchan *texel )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fetch_texel_2d_f_rgba_dxt3( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLfloat *texel )
|
||||
{
|
||||
/* just sample as GLchan and convert to float here */
|
||||
GLchan rgba[4];
|
||||
fetch_texel_2d_rgba_dxt3(texImage, i, j, k, rgba);
|
||||
texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
|
||||
texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
|
||||
texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
|
||||
texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fetch_texel_2d_rgba_dxt5( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLchan *texel )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fetch_texel_2d_f_rgba_dxt5( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLfloat *texel )
|
||||
{
|
||||
/* just sample as GLchan and convert to float here */
|
||||
GLchan rgba[4];
|
||||
fetch_texel_2d_rgba_dxt5(texImage, i, j, k, rgba);
|
||||
texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
|
||||
texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
|
||||
texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
|
||||
texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
|
||||
}
|
||||
|
||||
|
||||
const struct gl_texture_format _mesa_texformat_rgb_dxt1 = {
|
||||
MESA_FORMAT_RGB_DXT1, /* MesaFormat */
|
||||
GL_RGB, /* BaseFormat */
|
||||
GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
|
||||
4, /*approx*/ /* RedBits */
|
||||
4, /*approx*/ /* GreenBits */
|
||||
4, /*approx*/ /* BlueBits */
|
||||
0, /* AlphaBits */
|
||||
0, /* LuminanceBits */
|
||||
0, /* IntensityBits */
|
||||
0, /* IndexBits */
|
||||
0, /* DepthBits */
|
||||
0, /* TexelBytes */
|
||||
texstore_rgb_dxt1, /* StoreTexImageFunc */
|
||||
NULL, /*impossible*/ /* FetchTexel1D */
|
||||
fetch_texel_2d_rgb_dxt1, /* FetchTexel2D */
|
||||
NULL, /*impossible*/ /* FetchTexel3D */
|
||||
NULL, /*impossible*/ /* FetchTexel1Df */
|
||||
fetch_texel_2d_f_rgb_dxt1, /* FetchTexel2Df */
|
||||
NULL, /*impossible*/ /* FetchTexel3Df */
|
||||
};
|
||||
|
||||
const struct gl_texture_format _mesa_texformat_rgba_dxt1 = {
|
||||
MESA_FORMAT_RGBA_DXT1, /* MesaFormat */
|
||||
GL_RGBA, /* BaseFormat */
|
||||
GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
|
||||
4, /*approx*/ /* RedBits */
|
||||
4, /*approx*/ /* GreenBits */
|
||||
4, /*approx*/ /* BlueBits */
|
||||
1, /*approx*/ /* AlphaBits */
|
||||
0, /* LuminanceBits */
|
||||
0, /* IntensityBits */
|
||||
0, /* IndexBits */
|
||||
0, /* DepthBits */
|
||||
0, /* TexelBytes */
|
||||
texstore_rgba_dxt1, /* StoreTexImageFunc */
|
||||
NULL, /*impossible*/ /* FetchTexel1D */
|
||||
fetch_texel_2d_rgba_dxt1, /* FetchTexel2D */
|
||||
NULL, /*impossible*/ /* FetchTexel3D */
|
||||
NULL, /*impossible*/ /* FetchTexel1Df */
|
||||
fetch_texel_2d_f_rgba_dxt1, /* FetchTexel2Df */
|
||||
NULL, /*impossible*/ /* FetchTexel3Df */
|
||||
};
|
||||
|
||||
const struct gl_texture_format _mesa_texformat_rgba_dxt3 = {
|
||||
MESA_FORMAT_RGBA_DXT3, /* MesaFormat */
|
||||
GL_RGBA, /* BaseFormat */
|
||||
GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
|
||||
4, /*approx*/ /* RedBits */
|
||||
4, /*approx*/ /* GreenBits */
|
||||
4, /*approx*/ /* BlueBits */
|
||||
4, /*approx*/ /* AlphaBits */
|
||||
0, /* LuminanceBits */
|
||||
0, /* IntensityBits */
|
||||
0, /* IndexBits */
|
||||
0, /* DepthBits */
|
||||
0, /* TexelBytes */
|
||||
texstore_rgba_dxt3, /* StoreTexImageFunc */
|
||||
NULL, /*impossible*/ /* FetchTexel1D */
|
||||
fetch_texel_2d_rgba_dxt3, /* FetchTexel2D */
|
||||
NULL, /*impossible*/ /* FetchTexel3D */
|
||||
NULL, /*impossible*/ /* FetchTexel1Df */
|
||||
fetch_texel_2d_f_rgba_dxt3, /* FetchTexel2Df */
|
||||
NULL, /*impossible*/ /* FetchTexel3Df */
|
||||
};
|
||||
|
||||
const struct gl_texture_format _mesa_texformat_rgba_dxt5 = {
|
||||
MESA_FORMAT_RGBA_DXT5, /* MesaFormat */
|
||||
GL_RGBA, /* BaseFormat */
|
||||
GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
|
||||
4,/*approx*/ /* RedBits */
|
||||
4,/*approx*/ /* GreenBits */
|
||||
4,/*approx*/ /* BlueBits */
|
||||
4,/*approx*/ /* AlphaBits */
|
||||
0, /* LuminanceBits */
|
||||
0, /* IntensityBits */
|
||||
0, /* IndexBits */
|
||||
0, /* DepthBits */
|
||||
0, /* TexelBytes */
|
||||
texstore_rgba_dxt5, /* StoreTexImageFunc */
|
||||
NULL, /*impossible*/ /* FetchTexel1D */
|
||||
fetch_texel_2d_rgba_dxt5, /* FetchTexel2D */
|
||||
NULL, /*impossible*/ /* FetchTexel3D */
|
||||
NULL, /*impossible*/ /* FetchTexel1Df */
|
||||
fetch_texel_2d_f_rgba_dxt5, /* FetchTexel2Df */
|
||||
NULL, /*impossible*/ /* FetchTexel3Df */
|
||||
};
|
||||
|
|
@ -863,138 +863,6 @@ const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
|
|||
fetch_texel_3d_f_ycbcr_rev, /* FetchTexel3Df */
|
||||
};
|
||||
|
||||
const struct gl_texture_format _mesa_texformat_rgb_fxt1 = {
|
||||
MESA_FORMAT_RGB_FXT1, /* MesaFormat */
|
||||
GL_RGB, /* BaseFormat */
|
||||
GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
|
||||
4, /*approx*/ /* RedBits */
|
||||
4, /*approx*/ /* GreenBits */
|
||||
4, /*approx*/ /* BlueBits */
|
||||
0, /* AlphaBits */
|
||||
0, /* LuminanceBits */
|
||||
0, /* IntensityBits */
|
||||
0, /* IndexBits */
|
||||
0, /* DepthBits */
|
||||
0, /* TexelBytes */
|
||||
_mesa_texstore_argb8888, /* StoreTexImageFunc */
|
||||
NULL, /*impossible*/ /* FetchTexel1D */
|
||||
fetch_texel_2d_rgb_fxt1, /* FetchTexel2D */
|
||||
NULL, /*impossible*/ /* FetchTexel3D */
|
||||
NULL, /*impossible*/ /* FetchTexel1Df */
|
||||
fetch_texel_2d_f_rgb_fxt1, /* FetchTexel2Df */
|
||||
NULL, /*impossible*/ /* FetchTexel3Df */
|
||||
};
|
||||
|
||||
const struct gl_texture_format _mesa_texformat_rgba_fxt1 = {
|
||||
MESA_FORMAT_RGBA_FXT1, /* MesaFormat */
|
||||
GL_RGBA, /* BaseFormat */
|
||||
GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
|
||||
4, /*approx*/ /* RedBits */
|
||||
4, /*approx*/ /* GreenBits */
|
||||
4, /*approx*/ /* BlueBits */
|
||||
1, /*approx*/ /* AlphaBits */
|
||||
0, /* LuminanceBits */
|
||||
0, /* IntensityBits */
|
||||
0, /* IndexBits */
|
||||
0, /* DepthBits */
|
||||
0, /* TexelBytes */
|
||||
_mesa_texstore_argb8888, /* StoreTexImageFunc */
|
||||
NULL, /*impossible*/ /* FetchTexel1D */
|
||||
fetch_texel_2d_rgba_fxt1, /* FetchTexel2D */
|
||||
NULL, /*impossible*/ /* FetchTexel3D */
|
||||
NULL, /*impossible*/ /* FetchTexel1Df */
|
||||
fetch_texel_2d_f_rgba_fxt1, /* FetchTexel2Df */
|
||||
NULL, /*impossible*/ /* FetchTexel3Df */
|
||||
};
|
||||
|
||||
const struct gl_texture_format _mesa_texformat_rgb_dxt1 = {
|
||||
MESA_FORMAT_RGB_DXT1, /* MesaFormat */
|
||||
GL_RGB, /* BaseFormat */
|
||||
GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
|
||||
4, /*approx*/ /* RedBits */
|
||||
4, /*approx*/ /* GreenBits */
|
||||
4, /*approx*/ /* BlueBits */
|
||||
0, /* AlphaBits */
|
||||
0, /* LuminanceBits */
|
||||
0, /* IntensityBits */
|
||||
0, /* IndexBits */
|
||||
0, /* DepthBits */
|
||||
0, /* TexelBytes */
|
||||
_mesa_texstore_argb8888, /* StoreTexImageFunc */
|
||||
NULL, /*impossible*/ /* FetchTexel1D */
|
||||
fetch_texel_2d_rgb_dxt1, /* FetchTexel2D */
|
||||
NULL, /*impossible*/ /* FetchTexel3D */
|
||||
NULL, /*impossible*/ /* FetchTexel1Df */
|
||||
fetch_texel_2d_f_rgb_dxt1, /* FetchTexel2Df */
|
||||
NULL, /*impossible*/ /* FetchTexel3Df */
|
||||
};
|
||||
|
||||
const struct gl_texture_format _mesa_texformat_rgba_dxt1 = {
|
||||
MESA_FORMAT_RGBA_DXT1, /* MesaFormat */
|
||||
GL_RGBA, /* BaseFormat */
|
||||
GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
|
||||
4, /*approx*/ /* RedBits */
|
||||
4, /*approx*/ /* GreenBits */
|
||||
4, /*approx*/ /* BlueBits */
|
||||
1, /*approx*/ /* AlphaBits */
|
||||
0, /* LuminanceBits */
|
||||
0, /* IntensityBits */
|
||||
0, /* IndexBits */
|
||||
0, /* DepthBits */
|
||||
0, /* TexelBytes */
|
||||
_mesa_texstore_argb8888, /* StoreTexImageFunc */
|
||||
NULL, /*impossible*/ /* FetchTexel1D */
|
||||
fetch_texel_2d_rgba_dxt1, /* FetchTexel2D */
|
||||
NULL, /*impossible*/ /* FetchTexel3D */
|
||||
NULL, /*impossible*/ /* FetchTexel1Df */
|
||||
fetch_texel_2d_f_rgba_dxt1, /* FetchTexel2Df */
|
||||
NULL, /*impossible*/ /* FetchTexel3Df */
|
||||
};
|
||||
|
||||
const struct gl_texture_format _mesa_texformat_rgba_dxt3 = {
|
||||
MESA_FORMAT_RGBA_DXT3, /* MesaFormat */
|
||||
GL_RGBA, /* BaseFormat */
|
||||
GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
|
||||
4, /*approx*/ /* RedBits */
|
||||
4, /*approx*/ /* GreenBits */
|
||||
4, /*approx*/ /* BlueBits */
|
||||
4, /*approx*/ /* AlphaBits */
|
||||
0, /* LuminanceBits */
|
||||
0, /* IntensityBits */
|
||||
0, /* IndexBits */
|
||||
0, /* DepthBits */
|
||||
0, /* TexelBytes */
|
||||
_mesa_texstore_argb8888, /* StoreTexImageFunc */
|
||||
NULL, /*impossible*/ /* FetchTexel1D */
|
||||
fetch_texel_2d_rgba_dxt3, /* FetchTexel2D */
|
||||
NULL, /*impossible*/ /* FetchTexel3D */
|
||||
NULL, /*impossible*/ /* FetchTexel1Df */
|
||||
fetch_texel_2d_f_rgba_dxt3, /* FetchTexel2Df */
|
||||
NULL, /*impossible*/ /* FetchTexel3Df */
|
||||
};
|
||||
|
||||
const struct gl_texture_format _mesa_texformat_rgba_dxt5 = {
|
||||
MESA_FORMAT_RGBA_DXT5, /* MesaFormat */
|
||||
GL_RGBA, /* BaseFormat */
|
||||
GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
|
||||
4,/*approx*/ /* RedBits */
|
||||
4,/*approx*/ /* GreenBits */
|
||||
4,/*approx*/ /* BlueBits */
|
||||
4,/*approx*/ /* AlphaBits */
|
||||
0, /* LuminanceBits */
|
||||
0, /* IntensityBits */
|
||||
0, /* IndexBits */
|
||||
0, /* DepthBits */
|
||||
0, /* TexelBytes */
|
||||
_mesa_texstore_argb8888, /* StoreTexImageFunc */
|
||||
NULL, /*impossible*/ /* FetchTexel1D */
|
||||
fetch_texel_2d_rgba_dxt5, /* FetchTexel2D */
|
||||
NULL, /*impossible*/ /* FetchTexel3D */
|
||||
NULL, /*impossible*/ /* FetchTexel1Df */
|
||||
fetch_texel_2d_f_rgba_dxt5, /* FetchTexel2Df */
|
||||
NULL, /*impossible*/ /* FetchTexel3Df */
|
||||
};
|
||||
|
||||
|
||||
/* Big-endian */
|
||||
#if 0
|
||||
|
|
@ -1198,27 +1066,6 @@ const struct gl_texture_format _mesa_null_texformat = {
|
|||
/*@}*/
|
||||
|
||||
|
||||
#if !NEWTEXSTORE
|
||||
/**
|
||||
* Determine whether a given texture format is a hardware texture
|
||||
* format.
|
||||
*
|
||||
* \param format texture format.
|
||||
*
|
||||
* \return GL_TRUE if \p format is a hardware texture format, or GL_FALSE
|
||||
* otherwise.
|
||||
*
|
||||
* \p format is a hardware texture format if gl_texture_format::MesaFormat is
|
||||
* lower than _format::MESA_FORMAT_RGBA.
|
||||
*/
|
||||
GLboolean
|
||||
_mesa_is_hardware_tex_format( const struct gl_texture_format *format )
|
||||
{
|
||||
return (format->MesaFormat < MESA_FORMAT_RGBA);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Choose an appropriate texture format given the format, type and
|
||||
* internalFormat parameters passed to glTexImage().
|
||||
|
|
@ -1448,33 +1295,3 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
|
|||
_mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the base texture format for the given compressed format
|
||||
*
|
||||
* Called via dd_function_table::Driver.BaseCompressedTexFormat.
|
||||
* This function is used by software rasterizers. Hardware drivers
|
||||
* which support texture compression should not use this function but
|
||||
* a specialized function instead.
|
||||
*/
|
||||
GLint
|
||||
_mesa_base_compressed_texformat(GLcontext *ctx, GLint intFormat)
|
||||
{
|
||||
switch (intFormat) {
|
||||
case GL_COMPRESSED_ALPHA_ARB:
|
||||
return GL_ALPHA;
|
||||
case GL_COMPRESSED_LUMINANCE_ARB:
|
||||
return GL_LUMINANCE;
|
||||
case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
|
||||
return GL_LUMINANCE_ALPHA;
|
||||
case GL_COMPRESSED_INTENSITY_ARB:
|
||||
return GL_INTENSITY;
|
||||
case GL_COMPRESSED_RGB_ARB:
|
||||
return GL_RGB;
|
||||
case GL_COMPRESSED_RGBA_ARB:
|
||||
return GL_RGBA;
|
||||
default:
|
||||
return -1; /* not a recognized compressed format */
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,18 +81,6 @@ enum _format {
|
|||
MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* \name Compressed texture formats.
|
||||
*/
|
||||
/*@{*/
|
||||
MESA_FORMAT_RGB_FXT1,
|
||||
MESA_FORMAT_RGBA_FXT1,
|
||||
MESA_FORMAT_RGB_DXT1,
|
||||
MESA_FORMAT_RGBA_DXT1,
|
||||
MESA_FORMAT_RGBA_DXT3,
|
||||
MESA_FORMAT_RGBA_DXT5,
|
||||
/*@}*/
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* \name Upcoming little-endian formats
|
||||
|
|
@ -111,6 +99,18 @@ enum _format {
|
|||
/*@}*/
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \name Compressed texture formats.
|
||||
*/
|
||||
/*@{*/
|
||||
MESA_FORMAT_RGB_FXT1,
|
||||
MESA_FORMAT_RGBA_FXT1,
|
||||
MESA_FORMAT_RGB_DXT1,
|
||||
MESA_FORMAT_RGBA_DXT1,
|
||||
MESA_FORMAT_RGBA_DXT3,
|
||||
MESA_FORMAT_RGBA_DXT5,
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* \name Generic GLchan-based formats.
|
||||
*
|
||||
|
|
@ -159,7 +159,7 @@ enum _format {
|
|||
};
|
||||
|
||||
|
||||
/** The default formats, GLchan per component */
|
||||
/** GLchan-valued formats */
|
||||
/*@{*/
|
||||
extern const struct gl_texture_format _mesa_texformat_rgba;
|
||||
extern const struct gl_texture_format _mesa_texformat_rgb;
|
||||
|
|
@ -192,7 +192,7 @@ extern const struct gl_texture_format _mesa_texformat_intensity_float32;
|
|||
extern const struct gl_texture_format _mesa_texformat_intensity_float16;
|
||||
/*@}*/
|
||||
|
||||
/** \name The hardware-friendly formats */
|
||||
/** \name Assorted hardware-friendly formats */
|
||||
/*@{*/
|
||||
extern const struct gl_texture_format _mesa_texformat_rgba8888;
|
||||
extern const struct gl_texture_format _mesa_texformat_argb8888;
|
||||
|
|
@ -206,8 +206,16 @@ extern const struct gl_texture_format _mesa_texformat_a8;
|
|||
extern const struct gl_texture_format _mesa_texformat_l8;
|
||||
extern const struct gl_texture_format _mesa_texformat_i8;
|
||||
extern const struct gl_texture_format _mesa_texformat_ci8;
|
||||
/*@}*/
|
||||
|
||||
/** \name YCbCr formats */
|
||||
/*@{*/
|
||||
extern const struct gl_texture_format _mesa_texformat_ycbcr;
|
||||
extern const struct gl_texture_format _mesa_texformat_ycbcr_rev;
|
||||
/*@}*/
|
||||
|
||||
/** \name Compressed formats */
|
||||
/*@{*/
|
||||
extern const struct gl_texture_format _mesa_texformat_rgb_fxt1;
|
||||
extern const struct gl_texture_format _mesa_texformat_rgba_fxt1;
|
||||
extern const struct gl_texture_format _mesa_texformat_rgb_dxt1;
|
||||
|
|
@ -222,17 +230,8 @@ extern const struct gl_texture_format _mesa_null_texformat;
|
|||
/*@}*/
|
||||
|
||||
|
||||
#if !NEWTEXSTORE
|
||||
extern GLboolean
|
||||
_mesa_is_hardware_tex_format( const struct gl_texture_format *format );
|
||||
#endif
|
||||
|
||||
extern const struct gl_texture_format *
|
||||
_mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
|
||||
GLenum format, GLenum type );
|
||||
|
||||
extern GLint
|
||||
_mesa_base_compressed_texformat(GLcontext *ctx, GLint intFormat);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1001,115 +1001,6 @@ static void FETCH(f_ycbcr_rev)( const struct gl_texture_image *texImage,
|
|||
}
|
||||
|
||||
|
||||
#if DIM == 2 /* Only 2D compressed textures possible */
|
||||
|
||||
static void FETCH(rgb_fxt1)( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLchan *texel )
|
||||
{
|
||||
/* Extract the (i,j) pixel from texImage->Data and return it
|
||||
* in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
|
||||
*/
|
||||
}
|
||||
|
||||
static void FETCH(f_rgb_fxt1)( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLfloat *texel )
|
||||
{
|
||||
/* Extract the (i,j) pixel from texImage->Data and return it
|
||||
* in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
|
||||
*/
|
||||
}
|
||||
|
||||
static void FETCH(rgba_fxt1)( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLchan *texel )
|
||||
{
|
||||
/* Extract the (i,j) pixel from texImage->Data and return it
|
||||
* in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
|
||||
*/
|
||||
}
|
||||
|
||||
static void FETCH(f_rgba_fxt1)( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLfloat *texel )
|
||||
{
|
||||
/* Extract the (i,j) pixel from texImage->Data and return it
|
||||
* in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
|
||||
*/
|
||||
}
|
||||
|
||||
#endif /* if DIM == 2 */
|
||||
|
||||
|
||||
#if DIM == 2 /* only 2D is valid */
|
||||
|
||||
static void FETCH(rgb_dxt1)( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLchan *texel )
|
||||
{
|
||||
/* Extract the (i,j) pixel from texImage->Data and return it
|
||||
* in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
|
||||
*/
|
||||
}
|
||||
|
||||
static void FETCH(f_rgb_dxt1)( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLfloat *texel )
|
||||
{
|
||||
/* Extract the (i,j) pixel from texImage->Data and return it
|
||||
* in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
static void FETCH(rgba_dxt1)( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLchan *texel )
|
||||
{
|
||||
/* Extract the (i,j) pixel from texImage->Data and return it
|
||||
* in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
|
||||
*/
|
||||
}
|
||||
|
||||
static void FETCH(f_rgba_dxt1)( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLfloat *texel )
|
||||
{
|
||||
/* Extract the (i,j) pixel from texImage->Data and return it
|
||||
* in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
static void FETCH(rgba_dxt3)( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLchan *texel )
|
||||
{
|
||||
/* Extract the (i,j) pixel from texImage->Data and return it
|
||||
* in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
|
||||
*/
|
||||
}
|
||||
|
||||
static void FETCH(f_rgba_dxt3)( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLfloat *texel )
|
||||
{
|
||||
/* Extract the (i,j) pixel from texImage->Data and return it
|
||||
* in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
static void FETCH(rgba_dxt5)( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLchan *texel )
|
||||
{
|
||||
/* Extract the (i,j) pixel from texImage->Data and return it
|
||||
* in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
|
||||
*/
|
||||
}
|
||||
|
||||
static void FETCH(f_rgba_dxt5)( const struct gl_texture_image *texImage,
|
||||
GLint i, GLint j, GLint k, GLfloat *texel )
|
||||
{
|
||||
/* Extract the (i,j) pixel from texImage->Data and return it
|
||||
* in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
|
||||
*/
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* big-endian */
|
||||
|
||||
|
|
|
|||
|
|
@ -255,8 +255,6 @@ _mesa_base_tex_format( GLcontext *ctx, GLint internalFormat )
|
|||
return GL_RGB;
|
||||
case GL_COMPRESSED_RGBA_FXT1_3DFX:
|
||||
return GL_RGBA;
|
||||
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
||||
return GL_RGB;
|
||||
default:
|
||||
; /* fallthrough */
|
||||
}
|
||||
|
|
@ -264,6 +262,8 @@ _mesa_base_tex_format( GLcontext *ctx, GLint internalFormat )
|
|||
|
||||
if (ctx->Extensions.EXT_texture_compression_s3tc) {
|
||||
switch (internalFormat) {
|
||||
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
||||
return GL_RGB;
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
|
||||
|
|
@ -312,7 +312,7 @@ _mesa_base_tex_format( GLcontext *ctx, GLint internalFormat )
|
|||
case GL_LUMINANCE_ALPHA32F_ARB:
|
||||
return GL_LUMINANCE_ALPHA;
|
||||
default:
|
||||
; /* nothing */
|
||||
; /* fallthrough */
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -474,9 +474,6 @@ is_compressed_format(GLcontext *ctx, GLenum internalFormat)
|
|||
case GL_RGBA4_S3TC:
|
||||
return GL_TRUE;
|
||||
default:
|
||||
if (ctx->Driver.IsCompressedFormat) {
|
||||
return ctx->Driver.IsCompressedFormat(ctx, internalFormat);
|
||||
}
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
|
@ -1000,8 +997,8 @@ _mesa_init_teximage_fields(GLcontext *ctx, GLenum target,
|
|||
img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2);
|
||||
img->IsCompressed = is_compressed_format(ctx, internalFormat);
|
||||
if (img->IsCompressed)
|
||||
img->CompressedSize = _mesa_compressed_texture_size(ctx, width, height,
|
||||
depth, internalFormat);
|
||||
img->CompressedSize = ctx->Driver.CompressedTextureSize(ctx, width,
|
||||
height, depth, internalFormat);
|
||||
else
|
||||
img->CompressedSize = 0;
|
||||
|
||||
|
|
@ -2756,8 +2753,8 @@ compressed_texture_error_check(GLcontext *ctx, GLint dimensions,
|
|||
if (level < 0 || level >= maxLevels)
|
||||
return GL_INVALID_VALUE;
|
||||
|
||||
expectedSize = _mesa_compressed_texture_size(ctx, width, height, depth,
|
||||
internalFormat);
|
||||
expectedSize = ctx->Driver.CompressedTextureSize(ctx, width, height, depth,
|
||||
internalFormat);
|
||||
if (expectedSize != imageSize)
|
||||
return GL_INVALID_VALUE;
|
||||
|
||||
|
|
@ -2833,8 +2830,8 @@ compressed_subtexture_error_check(GLcontext *ctx, GLint dimensions,
|
|||
if ((height & 3) != 0 && height != 2 && height != 1)
|
||||
return GL_INVALID_VALUE;
|
||||
|
||||
expectedSize = _mesa_compressed_texture_size(ctx, width, height, depth,
|
||||
format);
|
||||
expectedSize = ctx->Driver.CompressedTextureSize(ctx, width, height, depth,
|
||||
format);
|
||||
if (expectedSize != imageSize)
|
||||
return GL_INVALID_VALUE;
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -70,6 +70,23 @@ extern GLboolean _mesa_texstore_ci8(STORE_PARAMS);
|
|||
extern GLboolean _mesa_texstore_ycbcr(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgba_float32(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgba_float16(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgb_fxt1(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgba_fxt1(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgb_dxt1(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgba_dxt1(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgba_dxt3(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgba_dxt5(STORE_PARAMS);
|
||||
|
||||
|
||||
extern GLchan *
|
||||
_mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims,
|
||||
GLenum logicalBaseFormat,
|
||||
GLenum textureBaseFormat,
|
||||
GLint srcWidth, GLint srcHeight, GLint srcDepth,
|
||||
GLenum srcFormat, GLenum srcType,
|
||||
const GLvoid *srcAddr,
|
||||
const struct gl_pixelstore_attrib *srcPacking);
|
||||
|
||||
|
||||
#if !NEWTEXSTORE
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,72 +0,0 @@
|
|||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 3.5
|
||||
*
|
||||
* Copyright (C) 1999-2001 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.
|
||||
*
|
||||
* Authors:
|
||||
* Gareth Hughes
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TEXUTIL_H
|
||||
#define TEXUTIL_H
|
||||
|
||||
#include "mtypes.h"
|
||||
#include "texformat.h"
|
||||
|
||||
extern GLboolean
|
||||
_mesa_convert_texsubimage1d( GLint mesaFormat,
|
||||
GLint xoffset,
|
||||
GLint width,
|
||||
GLenum format, GLenum type,
|
||||
const struct gl_pixelstore_attrib *packing,
|
||||
const GLvoid *srcImage, GLvoid *dstImage );
|
||||
|
||||
extern GLboolean
|
||||
_mesa_convert_texsubimage2d( GLint mesaFormat,
|
||||
GLint xoffset, GLint yoffset,
|
||||
GLint width, GLint height,
|
||||
GLint imageWidth,
|
||||
GLenum format, GLenum type,
|
||||
const struct gl_pixelstore_attrib *packing,
|
||||
const GLvoid *srcImage, GLvoid *dstImage );
|
||||
|
||||
extern GLboolean
|
||||
_mesa_convert_texsubimage3d( GLint mesaFormat,
|
||||
GLint xoffset, GLint yoffset, GLint zoffset,
|
||||
GLint width, GLint height, GLint depth,
|
||||
GLint imageWidth, GLint imageHeight,
|
||||
GLenum format, GLenum type,
|
||||
const struct gl_pixelstore_attrib *packing,
|
||||
const GLvoid *srcImage, GLvoid *dstImage );
|
||||
|
||||
/* Nearest filtering only (for broken hardware that can't support
|
||||
* all aspect ratios). FIXME: Make this a subimage update as well...
|
||||
*/
|
||||
extern void
|
||||
_mesa_rescale_teximage2d( GLuint bytesPerPixel, GLuint dstRowStride,
|
||||
GLint srcWidth, GLint srcHeight,
|
||||
GLint dstWidth, GLint dstHeight,
|
||||
const GLvoid *srcImage, GLvoid *dstImage );
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,526 +0,0 @@
|
|||
/**
|
||||
* \file texutil_tmp.h
|
||||
* Texture conversion templates.
|
||||
*
|
||||
* \author Gareth Hughes
|
||||
*
|
||||
* For 2D and 3D texture images, we generate functions for
|
||||
* - conversion without pixel unpacking and standard stride
|
||||
* - conversion without pixel unpacking and non-standard stride
|
||||
* - conversion with pixel unpacking and standard stride
|
||||
* - conversion with pixel unpacking and non-standard stride
|
||||
*
|
||||
* Macros which need to be defined before including this file:
|
||||
* - \c TAG(x) - the function name wrapper
|
||||
* - \c DST_TYPE - the destination texel data type (GLuint, GLushort, etc)
|
||||
* - \c DST_TEXELS_PER_DWORD - number of destination texels that'll fit in 4 bytes
|
||||
* - \c CONVERT_TEXEL - code to convert from source to destination texel
|
||||
* - \c CONVER_TEXEL_DWORD - if multiple texels fit in 4 bytes, this macros
|
||||
* will convert/store multiple texels at once
|
||||
* - \c CONVERT_DIRECT - if defined, just memcpy texels from source to destination
|
||||
* - \c SRC_TEXEL_BYTES - bytes per source texel
|
||||
* - \c PRESERVE_DST_TYPE - if defined, don't undefined these macros at end
|
||||
*
|
||||
* \sa convert_func.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 4.0.2
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
#define DST_TEXEL_BYTES (4 / DST_TEXELS_PER_DWORD)
|
||||
#define DST_ROW_BYTES (convert->width * DST_TEXEL_BYTES)
|
||||
#define DST_ROW_STRIDE (convert->dstImageWidth * DST_TEXEL_BYTES)
|
||||
#define DST_IMG_STRIDE (convert->dstImageWidth * \
|
||||
convert->dstImageHeight * DST_TEXEL_BYTES)
|
||||
|
||||
|
||||
/***************************************************************/
|
||||
/** \name Doesn't require pixelstore attributes or stride
|
||||
*
|
||||
* \code width == dstImageWidth \endcode
|
||||
* and
|
||||
* \code height == dstImageHeight \endcode
|
||||
* if applicable.
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/** \sa convert_func */
|
||||
static GLboolean
|
||||
TAG(texsubimage2d)( const struct convert_info *convert )
|
||||
{
|
||||
const GLubyte *src = (const GLubyte *)convert->srcImage;
|
||||
GLuint *dst = (GLuint *)((GLubyte *)convert->dstImage +
|
||||
(convert->yoffset * convert->dstImageWidth +
|
||||
convert->xoffset) * DST_TEXEL_BYTES);
|
||||
|
||||
#if DEBUG_TEXUTIL
|
||||
_mesa_debug( NULL, __FUNCTION__ "\n" );
|
||||
#endif
|
||||
|
||||
#ifdef CONVERT_DIRECT
|
||||
MEMCPY( dst, src, convert->height * DST_ROW_BYTES );
|
||||
#else
|
||||
{
|
||||
const GLint texels = convert->width * convert->height;
|
||||
const GLint dwords = texels / DST_TEXELS_PER_DWORD;
|
||||
const GLint leftover = texels - dwords * DST_TEXELS_PER_DWORD;
|
||||
GLint i;
|
||||
for ( i = 0 ; i < dwords ; i++ ) {
|
||||
CONVERT_TEXEL_DWORD( *dst++, src );
|
||||
src += SRC_TEXEL_BYTES * DST_TEXELS_PER_DWORD;
|
||||
}
|
||||
for ( i = 0; i < leftover; i++ ) {
|
||||
CONVERT_TEXEL( *dst++, src );
|
||||
src += SRC_TEXEL_BYTES;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/** \sa convert_func */
|
||||
static GLboolean
|
||||
TAG(texsubimage3d)( const struct convert_info *convert )
|
||||
{
|
||||
const GLubyte *src = (const GLubyte *)convert->srcImage;
|
||||
GLuint *dst = (GLuint *)((GLubyte *)convert->dstImage +
|
||||
((convert->zoffset * convert->height +
|
||||
convert->yoffset) * convert->width +
|
||||
convert->xoffset) * DST_TEXEL_BYTES);
|
||||
#if DEBUG_TEXUTIL
|
||||
_mesa_debug( NULL, __FUNCTION__ "\n" );
|
||||
#endif
|
||||
|
||||
#ifdef CONVERT_DIRECT
|
||||
MEMCPY( dst, src, convert->depth * convert->height * DST_ROW_BYTES );
|
||||
#else
|
||||
{
|
||||
const GLint texels = convert->width * convert->height * convert->depth;
|
||||
const GLint dwords = texels / DST_TEXELS_PER_DWORD;
|
||||
const GLint leftover = texels - dwords * DST_TEXELS_PER_DWORD;
|
||||
GLint i;
|
||||
for ( i = 0 ; i < dwords ; i++ ) {
|
||||
CONVERT_TEXEL_DWORD( *dst++, src );
|
||||
src += SRC_TEXEL_BYTES * DST_TEXELS_PER_DWORD;
|
||||
}
|
||||
for ( i = 0; i < leftover; i++ ) {
|
||||
CONVERT_TEXEL( *dst++, src );
|
||||
src += SRC_TEXEL_BYTES;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
/***************************************************************/
|
||||
/** \name Requires stride but no pixelstore attributes
|
||||
*
|
||||
* \code width != dstImageWidth \endcode
|
||||
* or
|
||||
* \code height != dstImageHeight \endcode
|
||||
* if applicable.
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/** \sa convert_func */
|
||||
static GLboolean
|
||||
TAG(texsubimage2d_stride)( const struct convert_info *convert )
|
||||
{
|
||||
const GLubyte *src = (const GLubyte *)convert->srcImage;
|
||||
DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage +
|
||||
(convert->yoffset * convert->dstImageWidth +
|
||||
convert->xoffset) * DST_TEXEL_BYTES);
|
||||
GLint adjust;
|
||||
GLint row, col;
|
||||
|
||||
adjust = convert->dstImageWidth - convert->width;
|
||||
|
||||
#if DEBUG_TEXUTIL
|
||||
_mesa_debug( NULL, __FUNCTION__ ":\n" );
|
||||
_mesa_debug( NULL, " x=%d y=%d w=%d h=%d s=%d\n",
|
||||
convert->xoffset, convert->yoffset, convert->width,
|
||||
convert->height, convert->dstImageWidth );
|
||||
_mesa_debug( NULL, " adjust=%d\n", adjust );
|
||||
#endif
|
||||
|
||||
for ( row = 0 ; row < convert->height ; row++ ) {
|
||||
for ( col = 0 ; col < convert->width ; col++ ) {
|
||||
CONVERT_TEXEL( *dst++, src );
|
||||
src += SRC_TEXEL_BYTES;
|
||||
}
|
||||
dst += adjust;
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/** \sa convert_func */
|
||||
static GLboolean
|
||||
TAG(texsubimage3d_stride)( const struct convert_info *convert )
|
||||
{
|
||||
const GLubyte *src = (const GLubyte *)convert->srcImage;
|
||||
DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage +
|
||||
((convert->zoffset * convert->dstImageHeight +
|
||||
convert->yoffset) * convert->dstImageWidth +
|
||||
convert->xoffset) * DST_TEXEL_BYTES);
|
||||
GLint adjust;
|
||||
GLint row, col, img;
|
||||
|
||||
adjust = convert->dstImageWidth - convert->width;
|
||||
|
||||
#if DEBUG_TEXUTIL
|
||||
_mesa_debug( NULL, __FUNCTION__ ":\n" );
|
||||
_mesa_debug( NULL, " x=%d y=%d w=%d h=%d s=%d\n",
|
||||
convert->xoffset, convert->yoffset, convert->width,
|
||||
convert->height, convert->dstImageWidth );
|
||||
_mesa_debug( NULL, " adjust=%d\n", adjust );
|
||||
#endif
|
||||
|
||||
for ( img = 0 ; img < convert->depth ; img++ ) {
|
||||
for ( row = 0 ; row < convert->height ; row++ ) {
|
||||
for ( col = 0 ; col < convert->width ; col++ ) {
|
||||
CONVERT_TEXEL( *dst++, src );
|
||||
src += SRC_TEXEL_BYTES;
|
||||
}
|
||||
dst += adjust;
|
||||
}
|
||||
/* FIXME: ... */
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
/***************************************************************/
|
||||
/** \name Requires pixelstore attributes but no stride.
|
||||
*
|
||||
* \code width == dstImageWidth \endcode
|
||||
* and
|
||||
* \code height == dstImageHeight \endcode
|
||||
* if applicable.
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/** \sa convert_func */
|
||||
static GLboolean
|
||||
TAG(texsubimage2d_unpack)( const struct convert_info *convert )
|
||||
{
|
||||
const GLubyte *src = (const GLubyte *)
|
||||
_mesa_image_address( convert->unpacking, convert->srcImage,
|
||||
convert->width, convert->height,
|
||||
convert->format, convert->type, 0, 0, 0 );
|
||||
const GLint srcRowStride =
|
||||
_mesa_image_row_stride( convert->unpacking, convert->width,
|
||||
convert->format, convert->type );
|
||||
GLint row, col;
|
||||
|
||||
#if DEBUG_TEXUTIL
|
||||
_mesa_debug( NULL, __FUNCTION__ "\n" );
|
||||
#endif
|
||||
|
||||
if (convert->width & (DST_TEXELS_PER_DWORD - 1)) {
|
||||
/* Can't use dword conversion (i.e. when width = 1 and texels/dword = 2
|
||||
* or width = 2 and texels/dword = 4).
|
||||
*/
|
||||
DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage +
|
||||
(convert->yoffset * convert->width +
|
||||
convert->xoffset) * DST_TEXEL_BYTES);
|
||||
for ( row = 0 ; row < convert->height ; row++ ) {
|
||||
const GLubyte *srcRow = src;
|
||||
for ( col = 0; col < convert->width; col++ ) {
|
||||
CONVERT_TEXEL(*dst, src);
|
||||
src += SRC_TEXEL_BYTES;
|
||||
}
|
||||
src = srcRow + srcRowStride;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* the common case */
|
||||
GLuint *dst = (GLuint *)((GLubyte *)convert->dstImage +
|
||||
(convert->yoffset * convert->width +
|
||||
convert->xoffset) * DST_TEXEL_BYTES);
|
||||
for ( row = 0 ; row < convert->height ; row++ ) {
|
||||
#ifdef CONVERT_DIRECT
|
||||
MEMCPY( dst, src, DST_ROW_STRIDE );
|
||||
src += srcRowStride;
|
||||
dst = (GLuint *)((GLubyte *)dst + DST_ROW_STRIDE);
|
||||
#else
|
||||
const GLubyte *srcRow = src;
|
||||
for ( col = convert->width / DST_TEXELS_PER_DWORD ; col ; col-- ) {
|
||||
CONVERT_TEXEL_DWORD( *dst++, src );
|
||||
src += SRC_TEXEL_BYTES * DST_TEXELS_PER_DWORD;
|
||||
}
|
||||
src = srcRow + srcRowStride;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/** \sa convert_func */
|
||||
static GLboolean
|
||||
TAG(texsubimage3d_unpack)( const struct convert_info *convert )
|
||||
{
|
||||
const GLubyte *src = (const GLubyte *)
|
||||
_mesa_image_address( convert->unpacking, convert->srcImage,
|
||||
convert->width, convert->height,
|
||||
convert->format, convert->type, 0, 0, 0 );
|
||||
const GLint srcImgStride = (const GLubyte *)
|
||||
_mesa_image_address( convert->unpacking, convert->srcImage,
|
||||
convert->width, convert->height,
|
||||
convert->format, convert->type, 1, 0, 0 ) - src;
|
||||
const GLint srcRowStride =
|
||||
_mesa_image_row_stride( convert->unpacking, convert->width,
|
||||
convert->format, convert->type );
|
||||
GLint row, col, img;
|
||||
|
||||
#if DEBUG_TEXUTIL
|
||||
_mesa_debug( NULL, __FUNCTION__ "\n" );
|
||||
#endif
|
||||
|
||||
if (convert->width & (DST_TEXELS_PER_DWORD - 1)) {
|
||||
/* Can't use dword conversion (i.e. when width = 1 and texels/dword = 2
|
||||
* or width = 2 and texels/dword = 4).
|
||||
*/
|
||||
DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage +
|
||||
((convert->zoffset * convert->height +
|
||||
convert->yoffset) * convert->width +
|
||||
convert->xoffset) * DST_TEXEL_BYTES);
|
||||
for ( img = 0 ; img < convert->depth ; img++ ) {
|
||||
const GLubyte *srcImage = src;
|
||||
for ( row = 0 ; row < convert->height ; row++ ) {
|
||||
const GLubyte *srcRow = src;
|
||||
for ( col = 0; col < convert->width; col++ ) {
|
||||
CONVERT_TEXEL(*dst, src);
|
||||
src += SRC_TEXEL_BYTES;
|
||||
}
|
||||
src = srcRow + srcRowStride;
|
||||
}
|
||||
src = srcImage + srcImgStride;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* the common case */
|
||||
GLuint *dst = (GLuint *)((GLubyte *)convert->dstImage +
|
||||
((convert->zoffset * convert->height +
|
||||
convert->yoffset) * convert->width +
|
||||
convert->xoffset) * DST_TEXEL_BYTES);
|
||||
for ( img = 0 ; img < convert->depth ; img++ ) {
|
||||
const GLubyte *srcImage = src;
|
||||
for ( row = 0 ; row < convert->height ; row++ ) {
|
||||
#ifdef CONVERT_DIRECT
|
||||
MEMCPY( dst, src, DST_ROW_STRIDE );
|
||||
src += srcRowStride;
|
||||
dst = (GLuint *)((GLubyte *)dst + DST_ROW_STRIDE);
|
||||
#else
|
||||
const GLubyte *srcRow = src;
|
||||
for ( col = convert->width / DST_TEXELS_PER_DWORD ; col ; col-- ) {
|
||||
CONVERT_TEXEL_DWORD( *dst++, src );
|
||||
src += SRC_TEXEL_BYTES * DST_TEXELS_PER_DWORD;
|
||||
}
|
||||
src = srcRow + srcRowStride;
|
||||
#endif
|
||||
}
|
||||
src = srcImage + srcImgStride;
|
||||
}
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
/***************************************************************/
|
||||
/** \name Requires pixelstore attributes and stride.
|
||||
*
|
||||
* \code width != dstImageWidth \endcode
|
||||
* or
|
||||
* \code height != dstImageHeight \endcode
|
||||
* if applicable.
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/** \sa convert_func */
|
||||
static GLboolean
|
||||
TAG(texsubimage2d_stride_unpack)( const struct convert_info *convert )
|
||||
{
|
||||
const GLubyte *src = (const GLubyte *)
|
||||
_mesa_image_address( convert->unpacking, convert->srcImage,
|
||||
convert->width, convert->height,
|
||||
convert->format, convert->type, 0, 0, 0 );
|
||||
const GLint srcRowStride =
|
||||
_mesa_image_row_stride( convert->unpacking, convert->width,
|
||||
convert->format, convert->type );
|
||||
DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage +
|
||||
(convert->yoffset * convert->dstImageWidth +
|
||||
convert->xoffset) * DST_TEXEL_BYTES);
|
||||
GLint row;
|
||||
#ifndef CONVERT_DIRECT
|
||||
GLint adjust = convert->dstImageWidth - convert->width;
|
||||
#endif
|
||||
|
||||
#if DEBUG_TEXUTIL
|
||||
_mesa_debug( NULL, __FUNCTION__ ":\n" );
|
||||
_mesa_debug( NULL, " x=%d y=%d w=%d h=%d s=%d\n",
|
||||
convert->xoffset, convert->yoffset, convert->width,
|
||||
convert->height, convert->dstImageWidth );
|
||||
#endif
|
||||
|
||||
for ( row = 0 ; row < convert->height ; row++ ) {
|
||||
#ifdef CONVERT_DIRECT
|
||||
MEMCPY( dst, src, DST_ROW_BYTES );
|
||||
src += srcRowStride;
|
||||
dst += convert->dstImageWidth;
|
||||
#else
|
||||
const GLubyte *srcRow = src;
|
||||
GLint col;
|
||||
for ( col = 0 ; col < convert->width ; col++ ) {
|
||||
CONVERT_TEXEL( *dst++, src );
|
||||
src += SRC_TEXEL_BYTES;
|
||||
}
|
||||
src = srcRow + srcRowStride;
|
||||
dst += adjust;
|
||||
#endif
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/** \sa convert_func */
|
||||
static GLboolean
|
||||
TAG(texsubimage3d_stride_unpack)( const struct convert_info *convert )
|
||||
{
|
||||
const GLubyte *src = (const GLubyte *)
|
||||
_mesa_image_address( convert->unpacking, convert->srcImage,
|
||||
convert->width, convert->height,
|
||||
convert->format, convert->type, 0, 0, 0 );
|
||||
const GLint srcImgStride = (const GLubyte *)
|
||||
_mesa_image_address( convert->unpacking, convert->srcImage,
|
||||
convert->width, convert->height,
|
||||
convert->format, convert->type, 1, 0, 0 ) - src;
|
||||
const GLint srcRowStride =
|
||||
_mesa_image_row_stride( convert->unpacking, convert->width,
|
||||
convert->format, convert->type );
|
||||
DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage +
|
||||
((convert->zoffset * convert->dstImageHeight +
|
||||
convert->yoffset) * convert->dstImageWidth +
|
||||
convert->xoffset) * DST_TEXEL_BYTES);
|
||||
GLint row, img;
|
||||
#ifndef CONVERT_DIRECT
|
||||
GLint adjust = convert->dstImageWidth - convert->width;
|
||||
#endif
|
||||
|
||||
#if DEBUG_TEXUTIL
|
||||
_mesa_debug( NULL, __FUNCTION__ ":\n" );
|
||||
_mesa_debug( NULL, " x=%d y=%d w=%d h=%d s=%d\n",
|
||||
convert->xoffset, convert->yoffset, convert->width,
|
||||
convert->height, convert->dstImageWidth );
|
||||
#endif
|
||||
|
||||
for ( img = 0 ; img < convert->depth ; img++ ) {
|
||||
const GLubyte *srcImage = src;
|
||||
for ( row = 0 ; row < convert->height ; row++ ) {
|
||||
#ifdef CONVERT_DIRECT
|
||||
MEMCPY( dst, src, DST_ROW_BYTES );
|
||||
src += srcRowStride;
|
||||
dst += convert->dstImageWidth;
|
||||
#else
|
||||
const GLubyte *srcRow = src;
|
||||
GLint col;
|
||||
for ( col = 0 ; col < convert->width ; col++ ) {
|
||||
CONVERT_TEXEL( *dst++, src );
|
||||
src += SRC_TEXEL_BYTES;
|
||||
}
|
||||
src = srcRow + srcRowStride;
|
||||
dst += adjust;
|
||||
#endif
|
||||
}
|
||||
src = srcImage + srcImgStride;
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
/** \name Conversion function tables
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
* 2D texture conversion functions table.
|
||||
*
|
||||
* \sa convert_func.
|
||||
*/
|
||||
static convert_func TAG(texsubimage2d_tab)[] = {
|
||||
TAG(texsubimage2d),
|
||||
TAG(texsubimage2d_stride),
|
||||
TAG(texsubimage2d_unpack),
|
||||
TAG(texsubimage2d_stride_unpack),
|
||||
};
|
||||
|
||||
/**
|
||||
* 3D texture conversion functions table.
|
||||
*
|
||||
* \sa convert_func.
|
||||
*/
|
||||
static convert_func TAG(texsubimage3d_tab)[] = {
|
||||
TAG(texsubimage3d),
|
||||
TAG(texsubimage3d_stride),
|
||||
TAG(texsubimage3d_unpack),
|
||||
TAG(texsubimage3d_stride_unpack),
|
||||
};
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
#ifndef PRESERVE_DST_TYPE
|
||||
#undef DST_TYPE
|
||||
#undef DST_TEXELS_PER_DWORD
|
||||
#endif
|
||||
|
||||
#undef SRC_TEXEL_BYTES
|
||||
#undef DST_TEXEL_BYTES
|
||||
#undef DST_ROW_BYTES
|
||||
#undef DST_ROW_STRIDE
|
||||
|
||||
#undef CONVERT_TEXEL
|
||||
#undef CONVERT_TEXEL_DWORD
|
||||
#undef CONVERT_DIRECT
|
||||
|
||||
#undef TAG
|
||||
|
||||
#undef PRESERVE_DST_TYPE
|
||||
|
|
@ -42,12 +42,13 @@ MAIN_SOURCES = \
|
|||
main/state.c \
|
||||
main/stencil.c \
|
||||
main/texcompress.c \
|
||||
main/texcompress_s3tc.c \
|
||||
main/texcompress_fxt1.c \
|
||||
main/texformat.c \
|
||||
main/teximage.c \
|
||||
main/texobj.c \
|
||||
main/texstate.c \
|
||||
main/texstore.c \
|
||||
main/texutil.c \
|
||||
main/varray.c \
|
||||
main/vtxfmt.c
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue