From 8e39ad2cd67d49be40ff0822f3269affdf83d601 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 6 Feb 2001 21:42:48 +0000 Subject: Overhaul of texture image handling. 1. gl_texture_image struct's Data pointer points to images in driver's format. 2. Added FetchTexel() function pointer to struct gl_texture_image. 3. Changed Driver Tex[Sub]Image functions, return void now. 4. Texture storage/fetch code in new texstore.c file. 5. Removed texture.[ch] - functions moved to state.c Note: FX driver updates not finished yet. --- src/mesa/drivers/glide/fxdd.c | 11 ++++--- src/mesa/drivers/glide/fxddtex.c | 65 +++++++++++++++++++--------------------- src/mesa/drivers/glide/fxdrv.h | 20 +++++-------- src/mesa/drivers/osmesa/osmesa.c | 22 ++++++++------ src/mesa/drivers/x11/xm_dd.c | 27 ++++++++++++----- 5 files changed, 75 insertions(+), 70 deletions(-) (limited to 'src/mesa/drivers') diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c index 175077833c9..d6ba79b22bf 100644 --- a/src/mesa/drivers/glide/fxdd.c +++ b/src/mesa/drivers/glide/fxdd.c @@ -1108,12 +1108,11 @@ void fxSetupDDPointers(GLcontext *ctx) ctx->Driver.TexImage2D = fxDDTexImage2D; ctx->Driver.TexSubImage2D = fxDDTexSubImage2D; - ctx->Driver.GetTexImage = fxDDGetTexImage; - ctx->Driver.TexEnv=fxDDTexEnv; - ctx->Driver.TexParameter=fxDDTexParam; - ctx->Driver.BindTexture=fxDDTexBind; - ctx->Driver.DeleteTexture=fxDDTexDel; - ctx->Driver.UpdateTexturePalette=fxDDTexPalette; + ctx->Driver.TexEnv = fxDDTexEnv; + ctx->Driver.TexParameter = fxDDTexParam; + ctx->Driver.BindTexture = fxDDTexBind; + ctx->Driver.DeleteTexture = fxDDTexDel; + ctx->Driver.UpdateTexturePalette = fxDDTexPalette; ctx->Driver.AlphaFunc=fxDDAlphaFunc; ctx->Driver.BlendFunc=fxDDBlendFunc; diff --git a/src/mesa/drivers/glide/fxddtex.c b/src/mesa/drivers/glide/fxddtex.c index 7c101e823d9..bc899170503 100644 --- a/src/mesa/drivers/glide/fxddtex.c +++ b/src/mesa/drivers/glide/fxddtex.c @@ -836,31 +836,29 @@ static void PrintTexture(int w, int h, int c, const GLubyte *data) } -GLboolean fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage, - GLboolean *retainInternalCopy) +void +fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level, + GLint internalFormat, GLint width, GLint height, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) { fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx; - if (target != GL_TEXTURE_2D) - return GL_FALSE; - if (!texObj->DriverData) texObj->DriverData = fxAllocTexObjData(fxMesa); - if (fxIsTexSupported(target, texImage->IntFormat, texImage)) { + if (fxIsTexSupported(target, internalFormat, texImage)) { GrTextureFormat_t gldformat; tfxTexInfo *ti = fxTMGetTexInfo(texObj); tfxMipMapLevel *mml = &ti->mipmapLevel[level]; GLint dstWidth, dstHeight, wScale, hScale, texelSize, dstStride; MesaIntTexFormat intFormat; - fxTexGetFormat(texImage->IntFormat, &gldformat, NULL); + fxTexGetFormat(internalFormat, &gldformat, NULL); - fxTexGetInfo(texImage->Width, texImage->Height, NULL,NULL,NULL,NULL, + fxTexGetInfo(width, height, NULL,NULL,NULL,NULL, NULL,NULL, &wScale, &hScale); dstWidth = texImage->Width * wScale; @@ -942,7 +940,7 @@ GLboolean fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level, break; default: gl_problem(NULL, "tdfx driver: texbuildimagemap() bad format"); - return GL_FALSE; + return; } _mesa_set_teximage_component_sizes(intFormat, texImage); @@ -955,7 +953,7 @@ GLboolean fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level, FREE(mml->data); mml->data = MALLOC(dstWidth * dstHeight * texelSize); if (!mml->data) - return GL_FALSE; + return; mml->glideFormat = gldformat; mml->width = dstWidth; mml->height = dstHeight; @@ -967,9 +965,9 @@ GLboolean fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level, /* store the texture image */ if (!_mesa_convert_teximage(intFormat, dstWidth, dstHeight, mml->data, dstStride, - texImage->Width, texImage->Height, + width, height, format, type, pixels, packing)) { - return GL_FALSE; + return; } @@ -981,24 +979,21 @@ GLboolean fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level, /*printf("invalidate2\n");*/ fxTexInvalidate(ctx,texObj); } - - *retainInternalCopy = GL_FALSE; - return GL_TRUE; } else { gl_problem(NULL, "fx Driver: unsupported texture in fxDDTexImg()\n"); - return GL_FALSE; } } -GLboolean fxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) +void +fxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) { fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx; tfxTexInfo *ti; @@ -1006,11 +1001,10 @@ GLboolean fxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, tfxMipMapLevel *mml; GLboolean result; - if (target != GL_TEXTURE_2D) - return GL_FALSE; - - if (!texObj->DriverData) - return GL_FALSE; + if (!texObj->DriverData) { + gl_problem(ctx, "problem in fxDDTexSubImage2D"); + return; + } ti = fxTMGetTexInfo(texObj); mml = &ti->mipmapLevel[level]; @@ -1083,7 +1077,7 @@ GLboolean fxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, } if (!result) { - return GL_FALSE; + return; } if (ti->validated && ti->isInTM) @@ -1091,11 +1085,10 @@ GLboolean fxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, else fxTexInvalidate(ctx, texObj); - return GL_TRUE; } - +#if 000 GLvoid *fxDDGetTexImage(GLcontext *ctx, GLenum target, GLint level, const struct gl_texture_object *texObj, GLenum *formatOut, GLenum *typeOut, @@ -1174,6 +1167,8 @@ GLvoid *fxDDGetTexImage(GLcontext *ctx, GLenum target, GLint level, return NULL; } } +#endif + #else diff --git a/src/mesa/drivers/glide/fxdrv.h b/src/mesa/drivers/glide/fxdrv.h index 6861160c1a6..c8876f7433d 100644 --- a/src/mesa/drivers/glide/fxdrv.h +++ b/src/mesa/drivers/glide/fxdrv.h @@ -60,7 +60,6 @@ #include "macros.h" #include "matrix.h" #include "mem.h" -#include "texture.h" #include "mtypes.h" #include "GL/fxmesa.h" @@ -541,23 +540,20 @@ extern void fxUpdateDDSpanPointers(GLcontext *); extern void fxSetupDDSpanPointers(GLcontext *); extern void fxPrintTextureData(tfxTexInfo *ti); -extern GLboolean fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage, - GLboolean *retainInternalCopy); -extern GLboolean fxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, +extern void fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level, + GLint internalFormat, GLint width, GLint height, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + +extern void fxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage); -extern GLvoid *fxDDGetTexImage(GLcontext *ctx, GLenum target, GLint level, - const struct gl_texture_object *texObj, - GLenum *formatOut, GLenum *typeOut, - GLboolean *freeImageOut ); extern void fxDDTexEnv(GLcontext *, GLenum, GLenum, const GLfloat *); extern void fxDDTexParam(GLcontext *, GLenum, struct gl_texture_object *, GLenum, const GLfloat *); diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index ac155a8e2ac..2656b5531d8 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -1,4 +1,4 @@ -/* $Id: osmesa.c,v 1.43 2001/01/29 20:56:32 keithw Exp $ */ +/* $Id: osmesa.c,v 1.44 2001/02/06 21:42:49 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -35,20 +35,19 @@ */ -#ifdef PC_HEADER -#include "all.h" -#else #include "glheader.h" #include "GL/osmesa.h" #include "context.h" #include "colormac.h" #include "depth.h" +#include "extensions.h" #include "macros.h" -#include "mem.h" #include "matrix.h" +#include "mem.h" #include "mmath.h" #include "mtypes.h" -#include "extensions.h" +#include "texstore.h" +#include "array_cache/acache.h" #include "swrast/swrast.h" #include "swrast_setup/swrast_setup.h" #include "swrast/s_context.h" @@ -56,9 +55,6 @@ #include "swrast/s_lines.h" #include "swrast/s_triangle.h" #include "tnl/tnl.h" -#include "array_cache/acache.h" -#endif - @@ -1784,6 +1780,14 @@ static void osmesa_update_state( GLcontext *ctx, GLuint new_state ) ctx->Driver.GetBufferSize = buffer_size; + ctx->Driver.TexImage1D = _mesa_store_teximage1d; + ctx->Driver.TexImage2D = _mesa_store_teximage2d; + ctx->Driver.TexImage3D = _mesa_store_teximage3d; + ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d; + ctx->Driver.TexSubImage2D = _mesa_store_texsubimage2d; + ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d; + ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage; + ctx->Driver.PointsFunc = _swsetup_Points; ctx->Driver.LineFunc = _swsetup_Line; ctx->Driver.TriangleFunc = _swsetup_Triangle; diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index f7530d947b3..424d0fb48e3 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -1,10 +1,10 @@ -/* $Id: xm_dd.c,v 1.13 2001/01/29 20:56:32 keithw Exp $ */ +/* $Id: xm_dd.c,v 1.14 2001/02/06 21:42:49 brianp Exp $ */ /* * Mesa 3-D graphics library * Version: 3.5 * - * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. + * 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"), @@ -27,18 +27,20 @@ #include "glxheader.h" #include "context.h" -#include "drawpix.h" -#include "mem.h" -#include "state.h" #include "depth.h" +#include "drawpix.h" +#include "extensions.h" #include "macros.h" +#include "mem.h" #include "mtypes.h" +#include "state.h" +#include "texstore.h" #include "xmesaP.h" -#include "extensions.h" +#include "array_cache/acache.h" #include "swrast/swrast.h" #include "swrast_setup/swrast_setup.h" #include "tnl/tnl.h" -#include "array_cache/acache.h" + /* * Return the size (width,height of the current color buffer. @@ -955,7 +957,16 @@ void xmesa_init_pointers( GLcontext *ctx ) ctx->Driver.DrawPixels = _swrast_DrawPixels; ctx->Driver.ReadPixels = _swrast_ReadPixels; - + /* Software texture functions: + */ + ctx->Driver.TexImage1D = _mesa_store_teximage1d; + ctx->Driver.TexImage2D = _mesa_store_teximage2d; + ctx->Driver.TexImage3D = _mesa_store_teximage3d; + ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d; + ctx->Driver.TexSubImage2D = _mesa_store_texsubimage2d; + ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d; + ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage; + /* */ ctx->Driver.SetDrawBuffer = set_draw_buffer; -- cgit v1.2.3