From 1a2bb37264b4448d33f2948fe1702c9dc936395d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 5 Oct 2009 17:12:36 -0600 Subject: [PATCH] mesa: lift _mesa_set_fetch_functions() calls out of drivers Call it from in the main Mesa glTexImage functions. --- src/mesa/drivers/dri/intel/intel_tex_image.c | 4 ---- src/mesa/drivers/dri/radeon/radeon_texture.c | 3 --- src/mesa/drivers/dri/unichrome/via_tex.c | 3 --- src/mesa/main/texfetch.c | 12 ++++++------ src/mesa/main/teximage.c | 20 ++++++++++++++++++++ src/mesa/main/texstore.c | 9 --------- 6 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c index dd436becab2..f32ff0dd05b 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_image.c +++ b/src/mesa/drivers/dri/intel/intel_tex_image.c @@ -7,7 +7,6 @@ #include "main/convolve.h" #include "main/context.h" #include "main/texcompress.h" -#include "main/texfetch.h" #include "main/texformat.h" #include "main/texstore.h" #include "main/texgetimage.h" @@ -336,8 +335,6 @@ intelTexImage(GLcontext * ctx, texImage->TexFormat = intelChooseTextureFormat(ctx, internalFormat, format, type); - _mesa_set_fetch_functions(texImage, dims); - if (_mesa_is_format_compressed(texImage->TexFormat)) { texelBytes = 0; } @@ -794,7 +791,6 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, intelImage->level = level; texImage->TexFormat = intelChooseTextureFormat(&intel->ctx, internalFormat, type, format); - _mesa_set_fetch_functions(texImage, 2); texImage->RowStride = rb->region->pitch; intel_miptree_reference(&intelImage->mt, intelObj->mt); diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c index 2c28011057d..17e42e72eef 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texture.c +++ b/src/mesa/drivers/dri/radeon/radeon_texture.c @@ -34,7 +34,6 @@ #include "main/convolve.h" #include "main/mipmap.h" #include "main/texcompress.h" -#include "main/texfetch.h" #include "main/texformat.h" #include "main/texstore.h" #include "main/teximage.h" @@ -140,7 +139,6 @@ static void map_override(GLcontext *ctx, radeonTexObj *t) radeon_bo_map(t->bo, GL_FALSE); img->base.Data = t->bo->ptr; - _mesa_set_fetch_functions(&img->base, 2); } static void unmap_override(GLcontext *ctx, radeonTexObj *t) @@ -543,7 +541,6 @@ static void radeon_teximage( /* Choose and fill in the texture format for this image */ texImage->TexFormat = radeonChooseTextureFormat(ctx, internalFormat, format, type, 0); - _mesa_set_fetch_functions(texImage, dims); if (_mesa_is_format_compressed(texImage->TexFormat)) { texelBytes = 0; diff --git a/src/mesa/drivers/dri/unichrome/via_tex.c b/src/mesa/drivers/dri/unichrome/via_tex.c index a99aa9debc9..fa7542c5cbf 100644 --- a/src/mesa/drivers/dri/unichrome/via_tex.c +++ b/src/mesa/drivers/dri/unichrome/via_tex.c @@ -37,7 +37,6 @@ #include "main/mipmap.h" #include "main/simple_list.h" #include "main/texcompress.h" -#include "main/texfetch.h" #include "main/texformat.h" #include "main/texobj.h" #include "main/texstore.h" @@ -692,8 +691,6 @@ static void viaTexImage(GLcontext *ctx, assert(texImage->TexFormat); - _mesa_set_fetch_functions(texImage, dims); - texelBytes = _mesa_get_format_bytes(texImage->TexFormat); if (texelBytes == 0) { diff --git a/src/mesa/main/texfetch.c b/src/mesa/main/texfetch.c index 6b7db584f81..851659e9c53 100644 --- a/src/mesa/main/texfetch.c +++ b/src/mesa/main/texfetch.c @@ -595,6 +595,7 @@ fetch_texel_float_to_chan(const struct gl_texture_image *texImage, } +#if 0 /** * Adaptor for fetching a float texel from a GLchan-valued texture. */ @@ -620,6 +621,7 @@ fetch_texel_chan_to_float(const struct gl_texture_image *texImage, texelOut[3] = CHAN_TO_FLOAT(temp[3]); } } +#endif /** @@ -631,17 +633,15 @@ _mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims) ASSERT(dims == 1 || dims == 2 || dims == 3); ASSERT(texImage->TexFormat); - texImage->FetchTexelf = - _mesa_get_texel_fetch_func(texImage->TexFormat, dims); + if (!texImage->FetchTexelf) { + texImage->FetchTexelf = + _mesa_get_texel_fetch_func(texImage->TexFormat, dims); + } /* now check if we need to use a float/chan adaptor */ if (!texImage->FetchTexelc) { texImage->FetchTexelc = fetch_texel_float_to_chan; } - else if (!texImage->FetchTexelf) { - texImage->FetchTexelf = fetch_texel_chan_to_float; - } - ASSERT(texImage->FetchTexelc); ASSERT(texImage->FetchTexelf); diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 438a316b9c1..457380b8fab 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -43,6 +43,7 @@ #include "macros.h" #include "state.h" #include "texcompress.h" +#include "texfetch.h" #include "texformat.h" #include "teximage.h" #include "texstate.h" @@ -997,6 +998,9 @@ _mesa_init_teximage_fields(GLcontext *ctx, GLenum target, img->HeightScale = (GLfloat) img->Height; img->DepthScale = (GLfloat) img->Depth; } + + img->FetchTexelc = NULL; + img->FetchTexelf = NULL; } @@ -2200,6 +2204,8 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat, ASSERT(texImage->TexFormat); + _mesa_set_fetch_functions(texImage, 1); + check_gen_mipmap(ctx, target, texObj, level); update_fbo_texture(ctx, texObj, face, level); @@ -2314,6 +2320,8 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat, ASSERT(texImage->TexFormat); + _mesa_set_fetch_functions(texImage, 2); + check_gen_mipmap(ctx, target, texObj, level); update_fbo_texture(ctx, texObj, face, level); @@ -2424,6 +2432,8 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat, ASSERT(texImage->TexFormat); + _mesa_set_fetch_functions(texImage, 3); + check_gen_mipmap(ctx, target, texObj, level); update_fbo_texture(ctx, texObj, face, level); @@ -2732,6 +2742,8 @@ _mesa_CopyTexImage1D( GLenum target, GLint level, ASSERT(texImage->TexFormat); + _mesa_set_fetch_functions(texImage, 1); + check_gen_mipmap(ctx, target, texObj, level); update_fbo_texture(ctx, texObj, face, level); @@ -2807,6 +2819,8 @@ _mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat, ASSERT(texImage->TexFormat); + _mesa_set_fetch_functions(texImage, 2); + check_gen_mipmap(ctx, target, texObj, level); update_fbo_texture(ctx, texObj, face, level); @@ -3259,6 +3273,8 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level, imageSize, data, texObj, texImage); + _mesa_set_fetch_functions(texImage, 1); + check_gen_mipmap(ctx, target, texObj, level); /* state update */ @@ -3363,6 +3379,8 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level, border, imageSize, data, texObj, texImage); + _mesa_set_fetch_functions(texImage, 2); + check_gen_mipmap(ctx, target, texObj, level); /* state update */ @@ -3467,6 +3485,8 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level, border, imageSize, data, texObj, texImage); + _mesa_set_fetch_functions(texImage, 3); + check_gen_mipmap(ctx, target, texObj, level); /* state update */ diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 133b0370c8f..52502b70331 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -64,7 +64,6 @@ #include "texcompress.h" #include "texcompress_fxt1.h" #include "texcompress_s3tc.h" -#include "texfetch.h" #include "texformat.h" #include "teximage.h" #include "texstore.h" @@ -3213,8 +3212,6 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level, = ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type); ASSERT(texImage->TexFormat); - _mesa_set_fetch_functions(texImage, 1); - /* allocate memory */ sizeInBytes = texture_size(texImage); texImage->Data = _mesa_alloc_texmemory(sizeInBytes); @@ -3276,8 +3273,6 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level, = ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type); ASSERT(texImage->TexFormat); - _mesa_set_fetch_functions(texImage, 2); - /* allocate memory */ sizeInBytes = texture_size(texImage); texImage->Data = _mesa_alloc_texmemory(sizeInBytes); @@ -3335,8 +3330,6 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level, = ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type); ASSERT(texImage->TexFormat); - _mesa_set_fetch_functions(texImage, 3); - /* allocate memory */ sizeInBytes = texture_size(texImage); texImage->Data = _mesa_alloc_texmemory(sizeInBytes); @@ -3539,8 +3532,6 @@ _mesa_store_compressed_teximage2d(GLcontext *ctx, GLenum target, GLint level, = ctx->Driver.ChooseTextureFormat(ctx, internalFormat, 0, 0); ASSERT(texImage->TexFormat); - _mesa_set_fetch_functions(texImage, 2); - /* allocate storage */ texImage->Data = _mesa_alloc_texmemory(imageSize); if (!texImage->Data) { -- 2.30.2