From 8f5fffe75d2f8ae7c7ee706b53379a25bc673ae4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 5 Jun 2012 16:32:23 -0600 Subject: mesa: consolidate internal glTexImage1/2/3D code The functions for handling 1D, 2D and 3D texture images were nearly identical. This folds them all together. Reviewed-by: Kenneth Graunke --- src/mesa/drivers/common/driverfuncs.c | 4 +- src/mesa/drivers/dri/intel/intel_tex_image.c | 60 +++----------------------- src/mesa/drivers/dri/nouveau/nouveau_texture.c | 43 ++++-------------- src/mesa/drivers/dri/radeon/radeon_texture.c | 41 +++--------------- 4 files changed, 23 insertions(+), 125 deletions(-) (limited to 'src/mesa/drivers') diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c index ca120578da9..54e5221b28b 100644 --- a/src/mesa/drivers/common/driverfuncs.c +++ b/src/mesa/drivers/common/driverfuncs.c @@ -91,9 +91,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver) /* Texture functions */ driver->ChooseTextureFormat = _mesa_choose_tex_format; - driver->TexImage1D = _mesa_store_teximage1d; - driver->TexImage2D = _mesa_store_teximage2d; - driver->TexImage3D = _mesa_store_teximage3d; + driver->TexImage = _mesa_store_teximage; driver->TexSubImage1D = _mesa_store_texsubimage1d; driver->TexSubImage2D = _mesa_store_texsubimage2d; driver->TexSubImage3D = _mesa_store_texsubimage3d; diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c index abd75c51d29..6e7e7018182 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_image.c +++ b/src/mesa/drivers/dri/intel/intel_tex_image.c @@ -203,13 +203,12 @@ try_pbo_upload(struct gl_context *ctx, static void intelTexImage(struct gl_context * ctx, - GLint dims, + GLuint dims, struct gl_texture_image *texImage, GLint internalFormat, - GLint width, GLint height, GLint depth, + GLint width, GLint height, GLint depth, GLint border, GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *unpack, - GLsizei imageSize) + const struct gl_pixelstore_attrib *unpack) { DBG("%s target %s level %d %dx%dx%d\n", __FUNCTION__, _mesa_lookup_enum_by_nr(texImage->TexObject->Target), @@ -226,52 +225,9 @@ intelTexImage(struct gl_context * ctx, DBG("%s: upload image %dx%dx%d pixels %p\n", __FUNCTION__, width, height, depth, pixels); - _mesa_store_teximage3d(ctx, texImage, internalFormat, - width, height, depth, 0, - format, type, pixels, unpack); -} - - -static void -intelTexImage3D(struct gl_context * ctx, - struct gl_texture_image *texImage, - GLint internalFormat, - GLint width, GLint height, GLint depth, - GLint border, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *unpack) -{ - intelTexImage(ctx, 3, texImage, - internalFormat, width, height, depth, - format, type, pixels, unpack, 0); -} - - -static void -intelTexImage2D(struct gl_context * ctx, - struct gl_texture_image *texImage, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *unpack) -{ - intelTexImage(ctx, 2, texImage, - internalFormat, width, height, 1, - format, type, pixels, unpack, 0); -} - - -static void -intelTexImage1D(struct gl_context * ctx, - struct gl_texture_image *texImage, - GLint internalFormat, - GLint width, GLint border, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *unpack) -{ - intelTexImage(ctx, 1, texImage, - internalFormat, width, 1, 1, - format, type, pixels, unpack, 0); + _mesa_store_teximage(ctx, dims, texImage, internalFormat, + width, height, depth, 0, + format, type, pixels, unpack); } @@ -398,9 +354,7 @@ intel_image_target_texture_2d(struct gl_context *ctx, GLenum target, void intelInitTextureImageFuncs(struct dd_function_table *functions) { - functions->TexImage1D = intelTexImage1D; - functions->TexImage2D = intelTexImage2D; - functions->TexImage3D = intelTexImage3D; + functions->TexImage = intelTexImage; #if FEATURE_OES_EGL_image functions->EGLImageTargetTexture2D = intel_image_target_texture_2d; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_texture.c b/src/mesa/drivers/dri/nouveau/nouveau_texture.c index a2e96aa1684..e5ef3d3ff9f 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_texture.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_texture.c @@ -540,41 +540,16 @@ nouveau_teximage(struct gl_context *ctx, GLint dims, context_dirty_i(ctx, TEX_ENV, ctx->Texture.CurrentUnit); } -static void -nouveau_teximage_1d(struct gl_context *ctx, - struct gl_texture_image *ti, - GLint internalFormat, - GLint width, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing) -{ - nouveau_teximage(ctx, 1, ti, internalFormat, - width, 1, 1, border, 0, format, type, pixels, - packing, GL_FALSE); -} static void -nouveau_teximage_2d(struct gl_context *ctx, - struct gl_texture_image *ti, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing) -{ - nouveau_teximage(ctx, 2, ti, internalFormat, - width, height, 1, border, 0, format, type, pixels, - packing, GL_FALSE); -} - -static void -nouveau_teximage_3d(struct gl_context *ctx, - struct gl_texture_image *ti, - GLint internalFormat, - GLint width, GLint height, GLint depth, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing) +nouveau_teximage_123d(struct gl_context *ctx, GLuint dims, + struct gl_texture_image *ti, + GLint internalFormat, + GLint width, GLint height, GLint depth, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing) { - nouveau_teximage(ctx, 3, ti, internalFormat, + nouveau_teximage(ctx, dims, ti, internalFormat, width, height, depth, border, 0, format, type, pixels, packing, GL_FALSE); } @@ -756,9 +731,7 @@ nouveau_texture_functions_init(struct dd_function_table *functions) functions->NewTextureImage = nouveau_teximage_new; functions->FreeTextureImageBuffer = nouveau_teximage_free; functions->ChooseTextureFormat = nouveau_choose_tex_format; - functions->TexImage1D = nouveau_teximage_1d; - functions->TexImage2D = nouveau_teximage_2d; - functions->TexImage3D = nouveau_teximage_3d; + functions->TexImage = nouveau_teximage_123d; functions->TexSubImage1D = nouveau_texsubimage_1d; functions->TexSubImage2D = nouveau_texsubimage_2d; functions->TexSubImage3D = nouveau_texsubimage_3d; diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c index ccb9956a8e6..8df5484f557 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texture.c +++ b/src/mesa/drivers/dri/radeon/radeon_texture.c @@ -586,39 +586,14 @@ static void radeon_teximage( const struct gl_pixelstore_attrib *packing, int compressed) { - _mesa_store_teximage3d(ctx, texImage, internalFormat, - width, height, depth, 0, - format, type, pixels, - packing); + _mesa_store_teximage(ctx, dims, texImage, internalFormat, + width, height, depth, 0, + format, type, pixels, + packing); } static void -radeonTexImage1D(struct gl_context * ctx, - struct gl_texture_image *texImage, - GLint internalFormat, - GLint width, GLint border, - GLenum format, GLenum type, const GLvoid * pixels, - const struct gl_pixelstore_attrib *packing) -{ - radeon_teximage(ctx, 1, texImage, internalFormat, width, 1, 1, - 0, format, type, pixels, packing, 0); -} - -static void -radeonTexImage2D(struct gl_context * ctx, - struct gl_texture_image *texImage, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLenum format, GLenum type, const GLvoid * pixels, - const struct gl_pixelstore_attrib *packing) - -{ - radeon_teximage(ctx, 2, texImage, internalFormat, width, height, 1, - 0, format, type, pixels, packing, 0); -} - -static void -radeonTexImage3D(struct gl_context * ctx, +radeonTexImage(struct gl_context * ctx, GLuint dims, struct gl_texture_image *texImage, GLint internalFormat, GLint width, GLint height, GLint depth, @@ -626,7 +601,7 @@ radeonTexImage3D(struct gl_context * ctx, GLenum format, GLenum type, const GLvoid * pixels, const struct gl_pixelstore_attrib *packing) { - radeon_teximage(ctx, 3, texImage, internalFormat, width, height, depth, + radeon_teximage(ctx, dims, texImage, internalFormat, width, height, depth, 0, format, type, pixels, packing, 0); } @@ -750,9 +725,7 @@ radeon_init_common_texture_funcs(radeonContextPtr radeon, functions->ChooseTextureFormat = radeonChooseTextureFormat_mesa; - functions->TexImage1D = radeonTexImage1D; - functions->TexImage2D = radeonTexImage2D; - functions->TexImage3D = radeonTexImage3D; + functions->TexImage = radeonTexImage; functions->CopyTexSubImage2D = radeonCopyTexSubImage2D; -- cgit v1.2.3