More texture image changes.
1. Added ctx->Driver.ChooseTextureFormat() function. Examines user's internalFormat, format, type params and returns a gl_texture_format. 2. _mesa_store_teximage[123]d() calls ctx->Driver.ChooseTextureFormat(), allocates storage and transfers the image into the desired format. 3. _mesa_transfer_teximage() now takes a gl_texture_format to describe the destination format. Any combination of input format/type and output gl_texture_format is accepted. Uses optimized _mesa_convert_- texsubimage[123]d() functions when possible. 3. DRI driver's TexImage[123]D functions should be a lot simpler now.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: osmesa.c,v 1.52 2001/03/29 17:15:21 brianp Exp $ */
|
/* $Id: osmesa.c,v 1.53 2001/04/04 21:54:21 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -46,6 +46,7 @@
|
|||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#include "mmath.h"
|
#include "mmath.h"
|
||||||
#include "mtypes.h"
|
#include "mtypes.h"
|
||||||
|
#include "texformat.h"
|
||||||
#include "texstore.h"
|
#include "texstore.h"
|
||||||
#include "array_cache/acache.h"
|
#include "array_cache/acache.h"
|
||||||
#include "swrast/swrast.h"
|
#include "swrast/swrast.h"
|
||||||
@@ -1786,6 +1787,7 @@ static void osmesa_update_state( GLcontext *ctx, GLuint new_state )
|
|||||||
ctx->Driver.DrawPixels = _swrast_DrawPixels;
|
ctx->Driver.DrawPixels = _swrast_DrawPixels;
|
||||||
ctx->Driver.ReadPixels = _swrast_ReadPixels;
|
ctx->Driver.ReadPixels = _swrast_ReadPixels;
|
||||||
|
|
||||||
|
ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
|
||||||
ctx->Driver.TexImage1D = _mesa_store_teximage1d;
|
ctx->Driver.TexImage1D = _mesa_store_teximage1d;
|
||||||
ctx->Driver.TexImage2D = _mesa_store_teximage2d;
|
ctx->Driver.TexImage2D = _mesa_store_teximage2d;
|
||||||
ctx->Driver.TexImage3D = _mesa_store_teximage3d;
|
ctx->Driver.TexImage3D = _mesa_store_teximage3d;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: xm_dd.c,v 1.21 2001/04/03 17:35:54 brianp Exp $ */
|
/* $Id: xm_dd.c,v 1.22 2001/04/04 21:54:21 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -35,6 +35,7 @@
|
|||||||
#include "mtypes.h"
|
#include "mtypes.h"
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "texstore.h"
|
#include "texstore.h"
|
||||||
|
#include "texformat.h"
|
||||||
#include "xmesaP.h"
|
#include "xmesaP.h"
|
||||||
#include "array_cache/acache.h"
|
#include "array_cache/acache.h"
|
||||||
#include "swrast/swrast.h"
|
#include "swrast/swrast.h"
|
||||||
@@ -952,6 +953,7 @@ void xmesa_init_pointers( GLcontext *ctx )
|
|||||||
|
|
||||||
/* Software texture functions:
|
/* Software texture functions:
|
||||||
*/
|
*/
|
||||||
|
ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
|
||||||
ctx->Driver.TexImage1D = _mesa_store_teximage1d;
|
ctx->Driver.TexImage1D = _mesa_store_teximage1d;
|
||||||
ctx->Driver.TexImage2D = _mesa_store_teximage2d;
|
ctx->Driver.TexImage2D = _mesa_store_teximage2d;
|
||||||
ctx->Driver.TexImage3D = _mesa_store_teximage3d;
|
ctx->Driver.TexImage3D = _mesa_store_teximage3d;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: dd.h,v 1.60 2001/03/22 00:36:27 gareth Exp $ */
|
/* $Id: dd.h,v 1.61 2001/04/04 21:54:20 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -170,6 +170,14 @@ struct dd_function_table {
|
|||||||
/***
|
/***
|
||||||
*** Texture image functions:
|
*** Texture image functions:
|
||||||
***/
|
***/
|
||||||
|
const struct gl_texture_format *
|
||||||
|
(*ChooseTextureFormat)( GLcontext *ctx, GLint internalFormat,
|
||||||
|
GLenum srcFormat, GLenum srcType );
|
||||||
|
/* This is called by the _mesa_store_tex[sub]image[123]d() fallback
|
||||||
|
* functions. The driver should examine <internalFormat> and return a
|
||||||
|
* pointer to an appropriate gl_texture_format.
|
||||||
|
*/
|
||||||
|
|
||||||
void (*TexImage1D)( GLcontext *ctx, GLenum target, GLint level,
|
void (*TexImage1D)( GLcontext *ctx, GLenum target, GLint level,
|
||||||
GLint internalFormat,
|
GLint internalFormat,
|
||||||
GLint width, GLint border,
|
GLint width, GLint border,
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: texformat.c,v 1.7 2001/03/30 14:44:43 gareth Exp $ */
|
/* $Id: texformat.c,v 1.8 2001/04/04 21:54:21 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -462,26 +462,24 @@ const struct gl_texture_format _mesa_null_texformat = {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GLboolean
|
||||||
|
_mesa_is_hardware_tex_format( const struct gl_texture_format *format )
|
||||||
|
{
|
||||||
|
return (format->MesaFormat < MESA_FORMAT_RGBA);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Given an internal texture format or 1, 2, 3, 4 initialize the texture
|
/* Given an internal texture format or 1, 2, 3, 4 initialize the texture
|
||||||
* image structure's default format and type information. Drivers will
|
* image structure's default format and type information. Drivers will
|
||||||
* initialize these fields accordingly if they override the default
|
* initialize these fields accordingly if they override the default
|
||||||
* storage format.
|
* storage format.
|
||||||
*/
|
*/
|
||||||
void _mesa_init_tex_format( GLcontext *ctx, GLenum internalFormat,
|
const struct gl_texture_format *
|
||||||
struct gl_texture_image *texImage )
|
_mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
|
||||||
|
GLenum format, GLenum type )
|
||||||
{
|
{
|
||||||
const struct gl_texture_format *texFormat;
|
(void) format;
|
||||||
|
(void) type;
|
||||||
/* Ask the driver for the base format, if it doesn't know, it will
|
|
||||||
* return -1;
|
|
||||||
*/
|
|
||||||
if ( ctx->Driver.BaseCompressedTexFormat ) {
|
|
||||||
GLint format = 0; /* Silence compiler warning */
|
|
||||||
format = (*ctx->Driver.BaseCompressedTexFormat)( ctx, format );
|
|
||||||
if ( format >= 0 ) {
|
|
||||||
internalFormat = format;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ( internalFormat ) {
|
switch ( internalFormat ) {
|
||||||
/* GH: Bias towards GL_RGB, GL_RGBA texture formats. This has
|
/* GH: Bias towards GL_RGB, GL_RGBA texture formats. This has
|
||||||
@@ -490,13 +488,11 @@ void _mesa_init_tex_format( GLcontext *ctx, GLenum internalFormat,
|
|||||||
*/
|
*/
|
||||||
case 4: /* Quake3 uses this... */
|
case 4: /* Quake3 uses this... */
|
||||||
case GL_RGBA:
|
case GL_RGBA:
|
||||||
texFormat = &_mesa_texformat_rgba;
|
return &_mesa_texformat_rgba;
|
||||||
break;
|
|
||||||
|
|
||||||
case 3: /* ... and this. */
|
case 3: /* ... and this. */
|
||||||
case GL_RGB:
|
case GL_RGB:
|
||||||
texFormat = &_mesa_texformat_rgb;
|
return &_mesa_texformat_rgb;
|
||||||
break;
|
|
||||||
|
|
||||||
/* GH: Okay, keep checking as normal. Still test for GL_RGB,
|
/* GH: Okay, keep checking as normal. Still test for GL_RGB,
|
||||||
* GL_RGBA formats first.
|
* GL_RGBA formats first.
|
||||||
@@ -508,8 +504,7 @@ void _mesa_init_tex_format( GLcontext *ctx, GLenum internalFormat,
|
|||||||
case GL_RGB10_A2:
|
case GL_RGB10_A2:
|
||||||
case GL_RGBA12:
|
case GL_RGBA12:
|
||||||
case GL_RGBA16:
|
case GL_RGBA16:
|
||||||
texFormat = &_mesa_texformat_rgba;
|
return &_mesa_texformat_rgba;
|
||||||
break;
|
|
||||||
|
|
||||||
case GL_R3_G3_B2:
|
case GL_R3_G3_B2:
|
||||||
case GL_RGB4:
|
case GL_RGB4:
|
||||||
@@ -518,16 +513,14 @@ void _mesa_init_tex_format( GLcontext *ctx, GLenum internalFormat,
|
|||||||
case GL_RGB10:
|
case GL_RGB10:
|
||||||
case GL_RGB12:
|
case GL_RGB12:
|
||||||
case GL_RGB16:
|
case GL_RGB16:
|
||||||
texFormat = &_mesa_texformat_rgb;
|
return &_mesa_texformat_rgb;
|
||||||
break;
|
|
||||||
|
|
||||||
case GL_ALPHA:
|
case GL_ALPHA:
|
||||||
case GL_ALPHA4:
|
case GL_ALPHA4:
|
||||||
case GL_ALPHA8:
|
case GL_ALPHA8:
|
||||||
case GL_ALPHA12:
|
case GL_ALPHA12:
|
||||||
case GL_ALPHA16:
|
case GL_ALPHA16:
|
||||||
texFormat = &_mesa_texformat_alpha;
|
return &_mesa_texformat_alpha;
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
case GL_LUMINANCE:
|
case GL_LUMINANCE:
|
||||||
@@ -535,8 +528,7 @@ void _mesa_init_tex_format( GLcontext *ctx, GLenum internalFormat,
|
|||||||
case GL_LUMINANCE8:
|
case GL_LUMINANCE8:
|
||||||
case GL_LUMINANCE12:
|
case GL_LUMINANCE12:
|
||||||
case GL_LUMINANCE16:
|
case GL_LUMINANCE16:
|
||||||
texFormat = &_mesa_texformat_luminance;
|
return &_mesa_texformat_luminance;
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
case GL_LUMINANCE_ALPHA:
|
case GL_LUMINANCE_ALPHA:
|
||||||
@@ -546,16 +538,14 @@ void _mesa_init_tex_format( GLcontext *ctx, GLenum internalFormat,
|
|||||||
case GL_LUMINANCE12_ALPHA4:
|
case GL_LUMINANCE12_ALPHA4:
|
||||||
case GL_LUMINANCE12_ALPHA12:
|
case GL_LUMINANCE12_ALPHA12:
|
||||||
case GL_LUMINANCE16_ALPHA16:
|
case GL_LUMINANCE16_ALPHA16:
|
||||||
texFormat = &_mesa_texformat_luminance_alpha;
|
return &_mesa_texformat_luminance_alpha;
|
||||||
break;
|
|
||||||
|
|
||||||
case GL_INTENSITY:
|
case GL_INTENSITY:
|
||||||
case GL_INTENSITY4:
|
case GL_INTENSITY4:
|
||||||
case GL_INTENSITY8:
|
case GL_INTENSITY8:
|
||||||
case GL_INTENSITY12:
|
case GL_INTENSITY12:
|
||||||
case GL_INTENSITY16:
|
case GL_INTENSITY16:
|
||||||
texFormat = &_mesa_texformat_intensity;
|
return &_mesa_texformat_intensity;
|
||||||
break;
|
|
||||||
|
|
||||||
case GL_COLOR_INDEX:
|
case GL_COLOR_INDEX:
|
||||||
case GL_COLOR_INDEX1_EXT:
|
case GL_COLOR_INDEX1_EXT:
|
||||||
@@ -564,8 +554,7 @@ void _mesa_init_tex_format( GLcontext *ctx, GLenum internalFormat,
|
|||||||
case GL_COLOR_INDEX8_EXT:
|
case GL_COLOR_INDEX8_EXT:
|
||||||
case GL_COLOR_INDEX12_EXT:
|
case GL_COLOR_INDEX12_EXT:
|
||||||
case GL_COLOR_INDEX16_EXT:
|
case GL_COLOR_INDEX16_EXT:
|
||||||
texFormat = &_mesa_texformat_color_index;
|
return &_mesa_texformat_color_index;
|
||||||
break;
|
|
||||||
|
|
||||||
case GL_DEPTH_COMPONENT:
|
case GL_DEPTH_COMPONENT:
|
||||||
case GL_DEPTH_COMPONENT16_SGIX:
|
case GL_DEPTH_COMPONENT16_SGIX:
|
||||||
@@ -573,13 +562,11 @@ void _mesa_init_tex_format( GLcontext *ctx, GLenum internalFormat,
|
|||||||
case GL_DEPTH_COMPONENT32_SGIX:
|
case GL_DEPTH_COMPONENT32_SGIX:
|
||||||
if ( !ctx->Extensions.SGIX_depth_texture )
|
if ( !ctx->Extensions.SGIX_depth_texture )
|
||||||
_mesa_problem( ctx, "depth format without GL_SGIX_depth_texture" );
|
_mesa_problem( ctx, "depth format without GL_SGIX_depth_texture" );
|
||||||
texFormat = &_mesa_texformat_depth_component;
|
return &_mesa_texformat_depth_component;
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
_mesa_problem( ctx, "unexpected format in _mesa_init_tex_format" );
|
_mesa_problem( ctx, "unexpected format in _mesa_choose_tex_format()" );
|
||||||
return;
|
printf("intformat = %d %x\n", internalFormat, internalFormat );
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
texImage->TexFormat = texFormat;
|
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: texformat.h,v 1.5 2001/03/22 06:26:18 gareth Exp $ */
|
/* $Id: texformat.h,v 1.6 2001/04/04 21:54:21 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -83,9 +83,12 @@ enum _format {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern void
|
extern GLboolean
|
||||||
_mesa_init_tex_format( GLcontext *ctx, GLenum internalFormat,
|
_mesa_is_hardware_tex_format( const struct gl_texture_format *format );
|
||||||
struct gl_texture_image *texImage );
|
|
||||||
|
extern const struct gl_texture_format *
|
||||||
|
_mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
|
||||||
|
GLenum format, GLenum type );
|
||||||
|
|
||||||
|
|
||||||
/* The default formats, GLchan per component:
|
/* The default formats, GLchan per component:
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: texstore.c,v 1.21 2001/03/28 20:40:51 gareth Exp $ */
|
/* $Id: texstore.c,v 1.22 2001/04/04 21:54:21 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -47,6 +47,7 @@
|
|||||||
#include "texformat.h"
|
#include "texformat.h"
|
||||||
#include "teximage.h"
|
#include "teximage.h"
|
||||||
#include "texstore.h"
|
#include "texstore.h"
|
||||||
|
#include "texutil.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -154,15 +155,15 @@ components_in_intformat( GLint format )
|
|||||||
* srcType - GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT_5_6_5, GL_FLOAT, etc
|
* srcType - GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT_5_6_5, GL_FLOAT, etc
|
||||||
* srcPacking - describes packing of incoming image.
|
* srcPacking - describes packing of incoming image.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
_mesa_transfer_teximage(GLcontext *ctx, GLuint dimensions,
|
transfer_teximage(GLcontext *ctx, GLuint dimensions,
|
||||||
GLenum texDestFormat, GLvoid *texDestAddr,
|
GLenum texDestFormat, GLvoid *texDestAddr,
|
||||||
GLint srcWidth, GLint srcHeight, GLint srcDepth,
|
GLint srcWidth, GLint srcHeight, GLint srcDepth,
|
||||||
GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
|
GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
|
||||||
GLint dstRowStride, GLint dstImageStride,
|
GLint dstRowStride, GLint dstImageStride,
|
||||||
GLenum srcFormat, GLenum srcType,
|
GLenum srcFormat, GLenum srcType,
|
||||||
const GLvoid *srcAddr,
|
const GLvoid *srcAddr,
|
||||||
const struct gl_pixelstore_attrib *srcPacking)
|
const struct gl_pixelstore_attrib *srcPacking)
|
||||||
{
|
{
|
||||||
GLint texComponents;
|
GLint texComponents;
|
||||||
|
|
||||||
@@ -381,6 +382,163 @@ _mesa_transfer_teximage(GLcontext *ctx, GLuint dimensions,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Transfer a texture image from user space to <destAddr> applying all
|
||||||
|
* needed image transfer operations and storing the result in the format
|
||||||
|
* specified by <dstFormat>. <dstFormat> may be any format from texformat.h.
|
||||||
|
* Input:
|
||||||
|
* dstRowStride - stride between dest rows in bytes
|
||||||
|
* dstImagetride - stride between dest images in bytes
|
||||||
|
*
|
||||||
|
* XXX this function is a bit more complicated than it should be. If
|
||||||
|
* _mesa_convert_texsubimage[123]d could handle any dest/source formats
|
||||||
|
* or if transfer_teximage() could store in any MESA_FORMAT_* format, we
|
||||||
|
* could simplify things here.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
_mesa_transfer_teximage(GLcontext *ctx, GLuint dimensions,
|
||||||
|
const struct gl_texture_format *dstFormat,
|
||||||
|
GLvoid *dstAddr,
|
||||||
|
GLint srcWidth, GLint srcHeight, GLint srcDepth,
|
||||||
|
GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
|
||||||
|
GLint dstRowStride, GLint dstImageStride,
|
||||||
|
GLenum srcFormat, GLenum srcType,
|
||||||
|
const GLvoid *srcAddr,
|
||||||
|
const struct gl_pixelstore_attrib *srcPacking)
|
||||||
|
{
|
||||||
|
const GLint dstRowStridePixels = dstRowStride / dstFormat->TexelBytes;
|
||||||
|
const GLint dstImageStridePixels = dstImageStride / dstFormat->TexelBytes;
|
||||||
|
GLboolean makeTemp;
|
||||||
|
|
||||||
|
/* First, determine if need to make a temporary, intermediate image */
|
||||||
|
if (_mesa_is_hardware_tex_format(dstFormat)) {
|
||||||
|
if (ctx->_ImageTransferState) {
|
||||||
|
makeTemp = GL_TRUE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (dimensions == 1) {
|
||||||
|
makeTemp = !_mesa_convert_texsubimage1d(dstFormat->MesaFormat,
|
||||||
|
dstXoffset,
|
||||||
|
srcWidth,
|
||||||
|
srcFormat, srcType,
|
||||||
|
srcPacking, srcAddr,
|
||||||
|
dstAddr);
|
||||||
|
}
|
||||||
|
else if (dimensions == 2) {
|
||||||
|
makeTemp = !_mesa_convert_texsubimage2d(dstFormat->MesaFormat,
|
||||||
|
dstXoffset, dstYoffset,
|
||||||
|
srcWidth, srcHeight,
|
||||||
|
dstRowStridePixels,
|
||||||
|
srcFormat, srcType,
|
||||||
|
srcPacking, srcAddr,
|
||||||
|
dstAddr);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
assert(dimensions == 3);
|
||||||
|
makeTemp = !_mesa_convert_texsubimage3d(dstFormat->MesaFormat,
|
||||||
|
dstXoffset, dstYoffset, dstZoffset,
|
||||||
|
srcWidth, srcHeight, srcDepth,
|
||||||
|
dstRowStridePixels, dstImageStridePixels,
|
||||||
|
srcFormat, srcType,
|
||||||
|
srcPacking, srcAddr, dstAddr);
|
||||||
|
}
|
||||||
|
if (!makeTemp) {
|
||||||
|
/* all done! */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* software texture format */
|
||||||
|
makeTemp = GL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (makeTemp) {
|
||||||
|
GLint postConvWidth = srcWidth, postConvHeight = srcHeight;
|
||||||
|
GLenum tmpFormat;
|
||||||
|
GLuint tmpComps, tmpTexelSize;
|
||||||
|
GLint tmpRowStride, tmpImageStride;
|
||||||
|
GLubyte *tmpImage;
|
||||||
|
|
||||||
|
if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) {
|
||||||
|
_mesa_adjust_image_for_convolution(ctx, dimensions, &postConvWidth,
|
||||||
|
&postConvHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
tmpFormat = _mesa_base_tex_format(ctx, dstFormat->IntFormat);
|
||||||
|
tmpComps = _mesa_components_in_format(tmpFormat);
|
||||||
|
tmpTexelSize = tmpComps * sizeof(CHAN_TYPE);
|
||||||
|
tmpRowStride = postConvWidth * tmpTexelSize;
|
||||||
|
tmpImageStride = postConvWidth * postConvHeight * tmpTexelSize;
|
||||||
|
tmpImage = (GLubyte *) MALLOC(postConvWidth * postConvHeight *
|
||||||
|
srcDepth * tmpTexelSize);
|
||||||
|
if (!tmpImage)
|
||||||
|
return;
|
||||||
|
|
||||||
|
transfer_teximage(ctx, dimensions, tmpFormat, tmpImage,
|
||||||
|
srcWidth, srcHeight, srcDepth,
|
||||||
|
0, 0, 0, /* x/y/zoffset */
|
||||||
|
tmpRowStride, tmpImageStride,
|
||||||
|
srcFormat, srcType, srcAddr, srcPacking);
|
||||||
|
|
||||||
|
/* the temp image is our new source image */
|
||||||
|
srcWidth = postConvWidth;
|
||||||
|
srcHeight = postConvHeight;
|
||||||
|
srcFormat = tmpFormat;
|
||||||
|
srcType = CHAN_TYPE;
|
||||||
|
srcAddr = tmpImage;
|
||||||
|
srcPacking = &_mesa_native_packing;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_mesa_is_hardware_tex_format(dstFormat)) {
|
||||||
|
assert(makeTemp);
|
||||||
|
if (dimensions == 1) {
|
||||||
|
GLboolean b;
|
||||||
|
b = _mesa_convert_texsubimage1d(dstFormat->MesaFormat,
|
||||||
|
dstXoffset,
|
||||||
|
srcWidth,
|
||||||
|
srcFormat, srcType,
|
||||||
|
srcPacking, srcAddr,
|
||||||
|
dstAddr);
|
||||||
|
assert(b);
|
||||||
|
}
|
||||||
|
else if (dimensions == 2) {
|
||||||
|
GLboolean b;
|
||||||
|
b = _mesa_convert_texsubimage2d(dstFormat->MesaFormat,
|
||||||
|
dstXoffset, dstYoffset,
|
||||||
|
srcWidth, srcHeight,
|
||||||
|
dstRowStridePixels,
|
||||||
|
srcFormat, srcType,
|
||||||
|
srcPacking, srcAddr,
|
||||||
|
dstAddr);
|
||||||
|
assert(b);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
GLboolean b;
|
||||||
|
b = _mesa_convert_texsubimage3d(dstFormat->MesaFormat,
|
||||||
|
dstXoffset, dstYoffset, dstZoffset,
|
||||||
|
srcWidth, srcHeight, srcDepth,
|
||||||
|
dstRowStridePixels, dstImageStridePixels,
|
||||||
|
srcFormat, srcType,
|
||||||
|
srcPacking, srcAddr, dstAddr);
|
||||||
|
assert(b);
|
||||||
|
}
|
||||||
|
FREE((void *) srcAddr); /* the temp image */
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* software format */
|
||||||
|
GLenum dstBaseFormat = _mesa_base_tex_format(ctx, dstFormat->IntFormat);
|
||||||
|
assert(!makeTemp);
|
||||||
|
transfer_teximage(ctx, dimensions, dstBaseFormat, dstAddr,
|
||||||
|
srcWidth, srcHeight, srcDepth,
|
||||||
|
dstXoffset, dstYoffset, dstZoffset,
|
||||||
|
dstRowStride, dstImageStride,
|
||||||
|
srcFormat, srcType, srcAddr, srcPacking);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the software fallback for Driver.TexImage1D().
|
* This is the software fallback for Driver.TexImage1D().
|
||||||
* The texture image type will be GLchan.
|
* The texture image type will be GLchan.
|
||||||
@@ -404,18 +562,23 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
|
|||||||
_mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL);
|
_mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* setup the teximage struct's fields */
|
/* choose the texture format */
|
||||||
_mesa_init_tex_format( ctx, internalFormat, texImage );
|
assert(ctx->Driver.ChooseTextureFormat);
|
||||||
|
texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
|
||||||
|
internalFormat, format, type);
|
||||||
|
assert(texImage->TexFormat);
|
||||||
|
|
||||||
texelBytes = texImage->TexFormat->TexelBytes;
|
texelBytes = texImage->TexFormat->TexelBytes;
|
||||||
|
|
||||||
/* allocate memory */
|
/* allocate memory */
|
||||||
texImage->Data = (GLchan *) MALLOC(postConvWidth * texelBytes);
|
texImage->Data = MALLOC(postConvWidth * texelBytes);
|
||||||
if (!texImage->Data)
|
if (!texImage->Data) {
|
||||||
return; /* out of memory */
|
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* unpack image, apply transfer ops and store in texImage->Data */
|
/* unpack image, apply transfer ops and store in texImage->Data */
|
||||||
_mesa_transfer_teximage(ctx, 1, texImage->Format, texImage->Data,
|
_mesa_transfer_teximage(ctx, 1, texImage->TexFormat, texImage->Data,
|
||||||
width, 1, 1, 0, 0, 0,
|
width, 1, 1, 0, 0, 0,
|
||||||
0, /* dstRowStride */
|
0, /* dstRowStride */
|
||||||
0, /* dstImageStride */
|
0, /* dstImageStride */
|
||||||
@@ -447,19 +610,23 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
|
|||||||
&postConvHeight);
|
&postConvHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* setup the teximage struct's fields */
|
/* choose the texture format */
|
||||||
_mesa_init_tex_format( ctx, internalFormat, texImage );
|
assert(ctx->Driver.ChooseTextureFormat);
|
||||||
|
texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
|
||||||
|
internalFormat, format, type);
|
||||||
|
assert(texImage->TexFormat);
|
||||||
|
|
||||||
texelBytes = texImage->TexFormat->TexelBytes;
|
texelBytes = texImage->TexFormat->TexelBytes;
|
||||||
|
|
||||||
/* allocate memory */
|
/* allocate memory */
|
||||||
texImage->Data = (GLchan *) MALLOC(postConvWidth * postConvHeight *
|
texImage->Data = MALLOC(postConvWidth * postConvHeight * texelBytes);
|
||||||
texelBytes);
|
if (!texImage->Data) {
|
||||||
if (!texImage->Data)
|
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
|
||||||
return; /* out of memory */
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* unpack image, apply transfer ops and store in texImage->Data */
|
/* unpack image, apply transfer ops and store in texImage->Data */
|
||||||
_mesa_transfer_teximage(ctx, 2, texImage->Format, texImage->Data,
|
_mesa_transfer_teximage(ctx, 2, texImage->TexFormat, texImage->Data,
|
||||||
width, height, 1, 0, 0, 0,
|
width, height, 1, 0, 0, 0,
|
||||||
texImage->Width * texelBytes,
|
texImage->Width * texelBytes,
|
||||||
0, /* dstImageStride */
|
0, /* dstImageStride */
|
||||||
@@ -486,18 +653,23 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
|
|||||||
{
|
{
|
||||||
GLint texelBytes;
|
GLint texelBytes;
|
||||||
|
|
||||||
/* setup the teximage struct's fields */
|
/* choose the texture format */
|
||||||
_mesa_init_tex_format( ctx, internalFormat, texImage );
|
assert(ctx->Driver.ChooseTextureFormat);
|
||||||
|
texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
|
||||||
|
internalFormat, format, type);
|
||||||
|
assert(texImage->TexFormat);
|
||||||
|
|
||||||
texelBytes = texImage->TexFormat->TexelBytes;
|
texelBytes = texImage->TexFormat->TexelBytes;
|
||||||
|
|
||||||
/* allocate memory */
|
/* allocate memory */
|
||||||
texImage->Data = (GLchan *) MALLOC(width * height * depth * texelBytes);
|
texImage->Data = MALLOC(width * height * depth * texelBytes);
|
||||||
if (!texImage->Data)
|
if (!texImage->Data) {
|
||||||
return; /* out of memory */
|
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* unpack image, apply transfer ops and store in texImage->Data */
|
/* unpack image, apply transfer ops and store in texImage->Data */
|
||||||
_mesa_transfer_teximage(ctx, 3, texImage->Format, texImage->Data,
|
_mesa_transfer_teximage(ctx, 3, texImage->TexFormat, texImage->Data,
|
||||||
width, height, depth, 0, 0, 0,
|
width, height, depth, 0, 0, 0,
|
||||||
texImage->Width * texelBytes,
|
texImage->Width * texelBytes,
|
||||||
texImage->Width * texImage->Height * texelBytes,
|
texImage->Width * texImage->Height * texelBytes,
|
||||||
@@ -518,7 +690,7 @@ _mesa_store_texsubimage1d(GLcontext *ctx, GLenum target, GLint level,
|
|||||||
struct gl_texture_object *texObj,
|
struct gl_texture_object *texObj,
|
||||||
struct gl_texture_image *texImage)
|
struct gl_texture_image *texImage)
|
||||||
{
|
{
|
||||||
_mesa_transfer_teximage(ctx, 1, texImage->Format, texImage->Data,
|
_mesa_transfer_teximage(ctx, 1, texImage->TexFormat, texImage->Data,
|
||||||
width, 1, 1, /* src size */
|
width, 1, 1, /* src size */
|
||||||
xoffset, 0, 0, /* dest offsets */
|
xoffset, 0, 0, /* dest offsets */
|
||||||
0, /* dstRowStride */
|
0, /* dstRowStride */
|
||||||
@@ -539,7 +711,7 @@ _mesa_store_texsubimage2d(GLcontext *ctx, GLenum target, GLint level,
|
|||||||
struct gl_texture_object *texObj,
|
struct gl_texture_object *texObj,
|
||||||
struct gl_texture_image *texImage)
|
struct gl_texture_image *texImage)
|
||||||
{
|
{
|
||||||
_mesa_transfer_teximage(ctx, 2, texImage->Format, texImage->Data,
|
_mesa_transfer_teximage(ctx, 2, texImage->TexFormat, texImage->Data,
|
||||||
width, height, 1, /* src size */
|
width, height, 1, /* src size */
|
||||||
xoffset, yoffset, 0, /* dest offsets */
|
xoffset, yoffset, 0, /* dest offsets */
|
||||||
texImage->Width * texImage->TexFormat->TexelBytes,
|
texImage->Width * texImage->TexFormat->TexelBytes,
|
||||||
@@ -561,7 +733,7 @@ _mesa_store_texsubimage3d(GLcontext *ctx, GLenum target, GLint level,
|
|||||||
struct gl_texture_image *texImage)
|
struct gl_texture_image *texImage)
|
||||||
{
|
{
|
||||||
const GLint texelBytes = texImage->TexFormat->TexelBytes;
|
const GLint texelBytes = texImage->TexFormat->TexelBytes;
|
||||||
_mesa_transfer_teximage(ctx, 3, texImage->Format, texImage->Data,
|
_mesa_transfer_teximage(ctx, 3, texImage->TexFormat, texImage->Data,
|
||||||
width, height, depth, /* src size */
|
width, height, depth, /* src size */
|
||||||
xoffset, yoffset, xoffset, /* dest offsets */
|
xoffset, yoffset, xoffset, /* dest offsets */
|
||||||
texImage->Width * texelBytes,
|
texImage->Width * texelBytes,
|
||||||
@@ -627,9 +799,6 @@ _mesa_store_compressed_teximage3d(GLcontext *ctx, GLenum target, GLint level,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the fallback for Driver.TestProxyTexImage().
|
* This is the fallback for Driver.TestProxyTexImage().
|
||||||
*/
|
*/
|
||||||
@@ -654,8 +823,11 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
|
|||||||
* Drivers may have more stringent texture limits to enforce and will
|
* Drivers may have more stringent texture limits to enforce and will
|
||||||
* have to override this function.
|
* have to override this function.
|
||||||
*/
|
*/
|
||||||
/* setup the teximage struct's fields */
|
/* choose the texture format */
|
||||||
_mesa_init_tex_format( ctx, internalFormat, texImage );
|
assert(ctx->Driver.ChooseTextureFormat);
|
||||||
|
texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
|
||||||
|
internalFormat, format, type);
|
||||||
|
assert(texImage->TexFormat);
|
||||||
|
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: texstore.h,v 1.5 2001/03/21 16:44:08 brianp Exp $ */
|
/* $Id: texstore.h,v 1.6 2001/04/04 21:54:21 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -39,7 +39,8 @@
|
|||||||
|
|
||||||
extern void
|
extern void
|
||||||
_mesa_transfer_teximage(GLcontext *ctx, GLuint dimensions,
|
_mesa_transfer_teximage(GLcontext *ctx, GLuint dimensions,
|
||||||
GLenum texDestFormat, GLvoid *texDestAddr,
|
const struct gl_texture_format *texDestFormat,
|
||||||
|
GLvoid *texDestAddr,
|
||||||
GLint srcWidth, GLint srcHeight, GLint srcDepth,
|
GLint srcWidth, GLint srcHeight, GLint srcDepth,
|
||||||
GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
|
GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
|
||||||
GLint dstRowStride, GLint dstImageStride,
|
GLint dstRowStride, GLint dstImageStride,
|
||||||
|
Reference in New Issue
Block a user