mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 21:50:12 +01:00
made some changes to the initialization of gl_texture_image fields
This commit is contained in:
parent
dde2da64b5
commit
6628bc9cff
2 changed files with 65 additions and 57 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: teximage.c,v 1.72 2001/02/06 23:35:26 brianp Exp $ */
|
||||
/* $Id: teximage.c,v 1.73 2001/02/07 03:27:41 brianp Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
|
|
@ -501,6 +501,39 @@ clear_teximage_fields(struct gl_texture_image *img)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Initialize basic fields of the gl_texture_image struct.
|
||||
*/
|
||||
static void
|
||||
init_teximage_fields(GLcontext *ctx,
|
||||
struct gl_texture_image *img,
|
||||
GLsizei width, GLsizei height, GLsizei depth,
|
||||
GLint border, GLenum internalFormat)
|
||||
{
|
||||
ASSERT(img);
|
||||
|
||||
img->IntFormat = internalFormat;
|
||||
img->Border = border;
|
||||
img->Width = width;
|
||||
img->Height = height;
|
||||
img->Depth = depth;
|
||||
img->WidthLog2 = logbase2(width - 2 * border);
|
||||
if (height == 1) /* 1-D texture */
|
||||
img->HeightLog2 = 0;
|
||||
else
|
||||
img->HeightLog2 = logbase2(height - 2 * border);
|
||||
if (depth == 1) /* 2-D texture */
|
||||
img->DepthLog2 = 0;
|
||||
else
|
||||
img->DepthLog2 = logbase2(depth - 2 * border);
|
||||
img->Width2 = 1 << img->WidthLog2;
|
||||
img->Height2 = 1 << img->HeightLog2;
|
||||
img->Depth2 = 1 << img->DepthLog2;
|
||||
img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2);
|
||||
img->IsCompressed = is_compressed_format(ctx, internalFormat);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Test glTexImage[123]D() parameters for errors.
|
||||
|
|
@ -1173,6 +1206,8 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
|
|||
texImage->Data = NULL;
|
||||
}
|
||||
clear_teximage_fields(texImage); /* not really needed, but helpful */
|
||||
init_teximage_fields(ctx, texImage, postConvWidth, 1, 1,
|
||||
border, internalFormat);
|
||||
|
||||
if (ctx->NewState & _NEW_PIXEL)
|
||||
gl_update_state(ctx);
|
||||
|
|
@ -1273,6 +1308,8 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
|
|||
texImage->Data = NULL;
|
||||
}
|
||||
clear_teximage_fields(texImage); /* not really needed, but helpful */
|
||||
init_teximage_fields(ctx, texImage, postConvWidth, postConvHeight, 1,
|
||||
border, internalFormat);
|
||||
|
||||
if (ctx->NewState & _NEW_PIXEL)
|
||||
gl_update_state(ctx);
|
||||
|
|
@ -1368,6 +1405,8 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat,
|
|||
texImage->Data = NULL;
|
||||
}
|
||||
clear_teximage_fields(texImage); /* not really needed, but helpful */
|
||||
init_teximage_fields(ctx, texImage, width, height, depth, border,
|
||||
internalFormat);
|
||||
|
||||
if (ctx->NewState & _NEW_PIXEL)
|
||||
gl_update_state(ctx);
|
||||
|
|
@ -1879,6 +1918,8 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level,
|
|||
texImage->Data = NULL;
|
||||
}
|
||||
|
||||
init_teximage_fields(ctx, texImage, width, 1, 1, border, internalFormat);
|
||||
|
||||
if (ctx->Extensions.ARB_texture_compression) {
|
||||
ASSERT(ctx->Driver.CompressedTexImage1D);
|
||||
(*ctx->Driver.CompressedTexImage1D)(ctx, target, level,
|
||||
|
|
@ -1969,6 +2010,9 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level,
|
|||
texImage->Data = NULL;
|
||||
}
|
||||
|
||||
init_teximage_fields(ctx, texImage, width, height, 1, border,
|
||||
internalFormat);
|
||||
|
||||
if (ctx->Extensions.ARB_texture_compression) {
|
||||
ASSERT(ctx->Driver.CompressedTexImage2D);
|
||||
(*ctx->Driver.CompressedTexImage2D)(ctx, target, level,
|
||||
|
|
@ -2056,6 +2100,9 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level,
|
|||
texImage->Data = NULL;
|
||||
}
|
||||
|
||||
init_teximage_fields(ctx, texImage, width, height, depth, border,
|
||||
internalFormat);
|
||||
|
||||
if (ctx->Extensions.ARB_texture_compression) {
|
||||
ASSERT(ctx->Driver.CompressedTexImage3D);
|
||||
(*ctx->Driver.CompressedTexImage3D)(ctx, target, level,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: texstore.c,v 1.1 2001/02/06 21:42:48 brianp Exp $ */
|
||||
/* $Id: texstore.c,v 1.2 2001/02/07 03:27:41 brianp Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
|
|
@ -433,53 +433,6 @@ is_compressed_format(GLcontext *ctx, GLenum internalFormat)
|
|||
|
||||
|
||||
|
||||
/*
|
||||
* Initialize most fields of a gl_texture_image struct.
|
||||
*/
|
||||
static void
|
||||
init_teximage_fields( GLcontext *ctx,
|
||||
struct gl_texture_image *img,
|
||||
GLsizei width, GLsizei height, GLsizei depth,
|
||||
GLint border, GLenum internalFormat )
|
||||
{
|
||||
ASSERT(img);
|
||||
ASSERT(!img->Data);
|
||||
img->Format = (GLenum) _mesa_base_tex_format(ctx, internalFormat);
|
||||
img->Type = CHAN_TYPE; /* usually GL_UNSIGNED_BYTE */
|
||||
set_teximage_component_sizes( img );
|
||||
img->IntFormat = internalFormat;
|
||||
img->Border = border;
|
||||
img->Width = width;
|
||||
img->Height = height;
|
||||
img->Depth = depth;
|
||||
img->WidthLog2 = logbase2(width - 2 * border);
|
||||
if (height == 1) /* 1-D texture */
|
||||
img->HeightLog2 = 0;
|
||||
else
|
||||
img->HeightLog2 = logbase2(height - 2 * border);
|
||||
if (depth == 1) /* 2-D texture */
|
||||
img->DepthLog2 = 0;
|
||||
else
|
||||
img->DepthLog2 = logbase2(depth - 2 * border);
|
||||
img->Width2 = 1 << img->WidthLog2;
|
||||
img->Height2 = 1 << img->HeightLog2;
|
||||
img->Depth2 = 1 << img->DepthLog2;
|
||||
img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2);
|
||||
img->IsCompressed = is_compressed_format(ctx, internalFormat);
|
||||
|
||||
if (height == 1 && depth == 1) {
|
||||
img->FetchTexel = fetch_1d_texel;
|
||||
}
|
||||
else if (depth == 1) {
|
||||
img->FetchTexel = fetch_2d_texel;
|
||||
}
|
||||
else {
|
||||
img->FetchTexel = fetch_3d_texel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Given an internal texture format enum or 1, 2, 3, 4 return the
|
||||
* corresponding _base_ internal format: GL_ALPHA, GL_LUMINANCE,
|
||||
|
|
@ -810,8 +763,10 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
|
|||
}
|
||||
|
||||
/* setup the teximage struct's fields */
|
||||
init_teximage_fields(ctx, texImage, postConvWidth, 1, 1,
|
||||
border, internalFormat);
|
||||
texImage->Format = (GLenum) _mesa_base_tex_format(ctx, internalFormat);
|
||||
texImage->Type = CHAN_TYPE; /* usually GL_UNSIGNED_BYTE */
|
||||
texImage->FetchTexel = fetch_1d_texel;
|
||||
set_teximage_component_sizes(texImage);
|
||||
|
||||
/* allocate memory */
|
||||
texImage->Data = (GLchan *) MALLOC(postConvWidth
|
||||
|
|
@ -853,8 +808,10 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
|
|||
}
|
||||
|
||||
/* setup the teximage struct's fields */
|
||||
init_teximage_fields(ctx, texImage, postConvWidth, postConvHeight, 1,
|
||||
border, internalFormat);
|
||||
texImage->Format = (GLenum) _mesa_base_tex_format(ctx, internalFormat);
|
||||
texImage->Type = CHAN_TYPE; /* usually GL_UNSIGNED_BYTE */
|
||||
texImage->FetchTexel = fetch_2d_texel;
|
||||
set_teximage_component_sizes(texImage);
|
||||
|
||||
/* allocate memory */
|
||||
texImage->Data = (GLchan *) MALLOC(postConvWidth * postConvHeight
|
||||
|
|
@ -891,8 +848,10 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
|
|||
const GLint components = components_in_intformat(internalFormat);
|
||||
|
||||
/* setup the teximage struct's fields */
|
||||
init_teximage_fields(ctx, texImage, width, height, depth,
|
||||
border, internalFormat);
|
||||
texImage->Format = (GLenum) _mesa_base_tex_format(ctx, internalFormat);
|
||||
texImage->Type = CHAN_TYPE; /* usually GL_UNSIGNED_BYTE */
|
||||
texImage->FetchTexel = fetch_3d_texel;
|
||||
set_teximage_component_sizes(texImage);
|
||||
|
||||
/* allocate memory */
|
||||
texImage->Data = (GLchan *) MALLOC(width * height * depth
|
||||
|
|
@ -1060,8 +1019,10 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
|
|||
* Drivers may have more stringent texture limits to enforce and will
|
||||
* have to override this function.
|
||||
*/
|
||||
init_teximage_fields(ctx, texImage, width, height, depth, border,
|
||||
internalFormat);
|
||||
/* setup the teximage struct's fields */
|
||||
texImage->Format = (GLenum) _mesa_base_tex_format(ctx, internalFormat);
|
||||
texImage->Type = CHAN_TYPE; /* usually GL_UNSIGNED_BYTE */
|
||||
set_teximage_component_sizes(texImage);
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue