[Mesa-dev] [PATCH 08/14] radeon: Refactor the common texture hook setup to common code.

Eric Anholt eric at anholt.net
Wed Aug 24 11:08:22 PDT 2011


---
 src/mesa/drivers/dri/r200/r200_context.h     |    2 -
 src/mesa/drivers/dri/r200/r200_tex.c         |   41 ++------------------------
 src/mesa/drivers/dri/r300/r300_tex.c         |   28 ++----------------
 src/mesa/drivers/dri/r600/evergreen_tex.c    |   28 ++----------------
 src/mesa/drivers/dri/r600/r600_tex.c         |   32 ++------------------
 src/mesa/drivers/dri/radeon/radeon_tex.c     |   28 +-----------------
 src/mesa/drivers/dri/radeon/radeon_texture.c |   35 ++++++++++++++++++++++
 src/mesa/drivers/dri/radeon/radeon_texture.h |    4 ++
 8 files changed, 52 insertions(+), 146 deletions(-)

diff --git a/src/mesa/drivers/dri/r200/r200_context.h b/src/mesa/drivers/dri/r200/r200_context.h
index 657902f..38b00e5 100644
--- a/src/mesa/drivers/dri/r200/r200_context.h
+++ b/src/mesa/drivers/dri/r200/r200_context.h
@@ -47,8 +47,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r200_reg.h"
 #include "r200_vertprog.h"
 
-#define ENABLE_HW_3D_TEXTURE 1  /* XXX this is temporary! */
-
 #ifndef R200_EMIT_VAP_PVS_CNTL
 #error This driver requires a newer libdrm to compile
 #endif
diff --git a/src/mesa/drivers/dri/r200/r200_tex.c b/src/mesa/drivers/dri/r200/r200_tex.c
index 665d9e1..7f26bfa 100644
--- a/src/mesa/drivers/dri/r200/r200_tex.c
+++ b/src/mesa/drivers/dri/r200/r200_tex.c
@@ -497,23 +497,9 @@ void r200InitTextureFuncs( radeonContextPtr radeon, struct dd_function_table *fu
    /* Note: we only plug in the functions we implement in the driver
     * since _mesa_init_driver_functions() was already called.
     */
-   functions->ChooseTextureFormat	= radeonChooseTextureFormat_mesa;
-   functions->TexImage1D		= radeonTexImage1D;
-   functions->TexImage2D		= radeonTexImage2D;
-#if ENABLE_HW_3D_TEXTURE
-   functions->TexImage3D		= radeonTexImage3D;
-#else
-   functions->TexImage3D		= _mesa_store_teximage3d;
-#endif
-   functions->TexSubImage1D		= radeonTexSubImage1D;
-   functions->TexSubImage2D		= radeonTexSubImage2D;
-#if ENABLE_HW_3D_TEXTURE
-   functions->TexSubImage3D		= radeonTexSubImage3D;
-#else
-   functions->TexSubImage3D		= _mesa_store_texsubimage3d;
-#endif
-   functions->GetTexImage               = radeonGetTexImage;
-   functions->GetCompressedTexImage     = radeonGetCompressedTexImage;
+
+   radeon_init_common_texture_funcs(radeon, functions);
+
    functions->NewTextureObject		= r200NewTextureObject;
    //   functions->BindTexture		= r200BindTexture;
    functions->DeleteTexture		= r200DeleteTexture;
@@ -522,25 +508,4 @@ void r200InitTextureFuncs( radeonContextPtr radeon, struct dd_function_table *fu
    functions->TexEnv			= r200TexEnv;
    functions->TexParameter		= r200TexParameter;
    functions->TexGen			= r200TexGen;
-
-   functions->CompressedTexImage2D	= radeonCompressedTexImage2D;
-   functions->CompressedTexSubImage2D	= radeonCompressedTexSubImage2D;
-
-   if (radeon->radeonScreen->kernel_mm) {
-      functions->CopyTexSubImage2D = radeonCopyTexSubImage2D;
-   }
-
-   functions->GenerateMipmap = radeonGenerateMipmap;
-
-   functions->NewTextureImage = radeonNewTextureImage;
-   functions->FreeTextureImageBuffer = radeonFreeTextureImageBuffer;
-   functions->MapTexture = radeonMapTexture;
-   functions->UnmapTexture = radeonUnmapTexture;
-
-#if FEATURE_OES_EGL_image
-   functions->EGLImageTargetTexture2D = radeon_image_target_texture_2d;
-#endif
-
-   driInitTextureFormats();
-
 }
diff --git a/src/mesa/drivers/dri/r300/r300_tex.c b/src/mesa/drivers/dri/r300/r300_tex.c
index 9dff68c..ed47880 100644
--- a/src/mesa/drivers/dri/r300/r300_tex.c
+++ b/src/mesa/drivers/dri/r300/r300_tex.c
@@ -355,38 +355,16 @@ void r300InitTextureFuncs(radeonContextPtr radeon, struct dd_function_table *fun
 	/* Note: we only plug in the functions we implement in the driver
 	 * since _mesa_init_driver_functions() was already called.
 	 */
-	functions->NewTextureImage = radeonNewTextureImage;
-	functions->FreeTextureImageBuffer = radeonFreeTextureImageBuffer;
-	functions->MapTexture = radeonMapTexture;
-	functions->UnmapTexture = radeonUnmapTexture;
-
-	functions->ChooseTextureFormat = radeonChooseTextureFormat_mesa;
-	functions->TexImage1D = radeonTexImage1D;
-	functions->TexImage2D = radeonTexImage2D;
-	functions->TexImage3D = radeonTexImage3D;
-	functions->TexSubImage1D = radeonTexSubImage1D;
-	functions->TexSubImage2D = radeonTexSubImage2D;
-	functions->TexSubImage3D = radeonTexSubImage3D;
-	functions->GetTexImage = radeonGetTexImage;
-	functions->GetCompressedTexImage = radeonGetCompressedTexImage;
+
+	radeon_init_common_texture_funcs(radeon, functions);
+
 	functions->NewTextureObject = r300NewTextureObject;
 	functions->DeleteTexture = r300DeleteTexture;
 	functions->IsTextureResident = driIsTextureResident;
 
 	functions->TexParameter = r300TexParameter;
 
-	functions->CompressedTexImage2D = radeonCompressedTexImage2D;
-	functions->CompressedTexSubImage2D = radeonCompressedTexSubImage2D;
-
-	if (radeon->radeonScreen->kernel_mm) {
-		functions->CopyTexSubImage2D = radeonCopyTexSubImage2D;
-	}
-
-	functions->GenerateMipmap = radeonGenerateMipmap;
-
 #if FEATURE_OES_EGL_image
 	functions->EGLImageTargetTexture2D = radeon_image_target_texture_2d;
 #endif
-
-	driInitTextureFormats();
 }
diff --git a/src/mesa/drivers/dri/r600/evergreen_tex.c b/src/mesa/drivers/dri/r600/evergreen_tex.c
index b560ac4..7222e5a 100644
--- a/src/mesa/drivers/dri/r600/evergreen_tex.c
+++ b/src/mesa/drivers/dri/r600/evergreen_tex.c
@@ -1657,34 +1657,12 @@ void evergreenInitTextureFuncs(radeonContextPtr radeon, struct dd_function_table
 	/* Note: we only plug in the functions we implement in the driver
 	 * since _mesa_init_driver_functions() was already called.
 	 */
-	functions->NewTextureImage = radeonNewTextureImage;
-	functions->FreeTextureImageBuffer = radeonFreeTextureImageBuffer;
-	functions->MapTexture = radeonMapTexture;
-	functions->UnmapTexture = radeonUnmapTexture;
-
-	functions->ChooseTextureFormat = radeonChooseTextureFormat_mesa;
-	functions->TexImage1D = radeonTexImage1D;
-	functions->TexImage2D = radeonTexImage2D;
-	functions->TexImage3D = radeonTexImage3D;
-	functions->TexSubImage1D = radeonTexSubImage1D;
-	functions->TexSubImage2D = radeonTexSubImage2D;
-	functions->TexSubImage3D = radeonTexSubImage3D;
-	functions->GetTexImage = radeonGetTexImage;
-	functions->GetCompressedTexImage = radeonGetCompressedTexImage;
+
+	radeon_init_common_texture_funcs(radeon, functions);
+
 	functions->NewTextureObject = evergreenNewTextureObject;
 	functions->DeleteTexture = evergreenDeleteTexture;
 	functions->IsTextureResident = driIsTextureResident;
 
 	functions->TexParameter = evergreenTexParameter;
-
-	functions->CompressedTexImage2D = radeonCompressedTexImage2D;
-	functions->CompressedTexSubImage2D = radeonCompressedTexSubImage2D;
-
-	if (radeon->radeonScreen->kernel_mm) {
-		functions->CopyTexSubImage2D = radeonCopyTexSubImage2D;
-	}
-
-	functions->GenerateMipmap = radeonGenerateMipmap;
-
-	driInitTextureFormats();
 }
diff --git a/src/mesa/drivers/dri/r600/r600_tex.c b/src/mesa/drivers/dri/r600/r600_tex.c
index f1d704e..ac704e6 100644
--- a/src/mesa/drivers/dri/r600/r600_tex.c
+++ b/src/mesa/drivers/dri/r600/r600_tex.c
@@ -446,38 +446,12 @@ void r600InitTextureFuncs(radeonContextPtr radeon, struct dd_function_table *fun
 	/* Note: we only plug in the functions we implement in the driver
 	 * since _mesa_init_driver_functions() was already called.
 	 */
-	functions->NewTextureImage = radeonNewTextureImage;
-	functions->FreeTextureImageBuffer = radeonFreeTextureImageBuffer;
-	functions->MapTexture = radeonMapTexture;
-	functions->UnmapTexture = radeonUnmapTexture;
-
-	functions->ChooseTextureFormat = radeonChooseTextureFormat_mesa;
-	functions->TexImage1D = radeonTexImage1D;
-	functions->TexImage2D = radeonTexImage2D;
-	functions->TexImage3D = radeonTexImage3D;
-	functions->TexSubImage1D = radeonTexSubImage1D;
-	functions->TexSubImage2D = radeonTexSubImage2D;
-	functions->TexSubImage3D = radeonTexSubImage3D;
-	functions->GetTexImage = radeonGetTexImage;
-	functions->GetCompressedTexImage = radeonGetCompressedTexImage;
+
+	radeon_init_common_texture_funcs(radeon, functions);
+
 	functions->NewTextureObject = r600NewTextureObject;
 	functions->DeleteTexture = r600DeleteTexture;
 	functions->IsTextureResident = driIsTextureResident;
 
 	functions->TexParameter = r600TexParameter;
-
-	functions->CompressedTexImage2D = radeonCompressedTexImage2D;
-	functions->CompressedTexSubImage2D = radeonCompressedTexSubImage2D;
-
-	if (radeon->radeonScreen->kernel_mm) {
-		functions->CopyTexSubImage2D = radeonCopyTexSubImage2D;
-	}
-
-	functions->GenerateMipmap = radeonGenerateMipmap;
-
-#if FEATURE_OES_EGL_image
-	functions->EGLImageTargetTexture2D = radeon_image_target_texture_2d;
-#endif
-
-	driInitTextureFormats();
 }
diff --git a/src/mesa/drivers/dri/radeon/radeon_tex.c b/src/mesa/drivers/dri/radeon/radeon_tex.c
index bb83de5..c5282ae 100644
--- a/src/mesa/drivers/dri/radeon/radeon_tex.c
+++ b/src/mesa/drivers/dri/radeon/radeon_tex.c
@@ -435,13 +435,7 @@ radeonNewTextureObject( struct gl_context *ctx, GLuint name, GLenum target )
 
 void radeonInitTextureFuncs( radeonContextPtr radeon, struct dd_function_table *functions )
 {
-   functions->ChooseTextureFormat	= radeonChooseTextureFormat_mesa;
-   functions->TexImage1D		= radeonTexImage1D;
-   functions->TexImage2D		= radeonTexImage2D;
-   functions->TexSubImage1D		= radeonTexSubImage1D;
-   functions->TexSubImage2D		= radeonTexSubImage2D;
-   functions->GetTexImage               = radeonGetTexImage;
-   functions->GetCompressedTexImage     = radeonGetCompressedTexImage;
+   radeon_init_common_texture_funcs(radeon, functions);
 
    functions->NewTextureObject		= radeonNewTextureObject;
    //   functions->BindTexture		= radeonBindTexture;
@@ -450,24 +444,4 @@ void radeonInitTextureFuncs( radeonContextPtr radeon, struct dd_function_table *
    functions->TexEnv			= radeonTexEnv;
    functions->TexParameter		= radeonTexParameter;
    functions->TexGen			= radeonTexGen;
-
-   functions->CompressedTexImage2D	= radeonCompressedTexImage2D;
-   functions->CompressedTexSubImage2D	= radeonCompressedTexSubImage2D;
-
-   if (radeon->radeonScreen->kernel_mm) {
-      functions->CopyTexSubImage2D = radeonCopyTexSubImage2D;
-   }
-
-   functions->GenerateMipmap = radeonGenerateMipmap;
-
-   functions->NewTextureImage = radeonNewTextureImage;
-   functions->FreeTextureImageBuffer = radeonFreeTextureImageBuffer;
-   functions->MapTexture = radeonMapTexture;
-   functions->UnmapTexture = radeonUnmapTexture;
-
-#if FEATURE_OES_EGL_image
-   functions->EGLImageTargetTexture2D = radeon_image_target_texture_2d;
-#endif
-
-   driInitTextureFormats();
 }
diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c
index 50cf564..d9bc1c0 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texture.c
+++ b/src/mesa/drivers/dri/radeon/radeon_texture.c
@@ -1081,3 +1081,38 @@ void radeon_image_target_texture_2d(struct gl_context *ctx, GLenum target,
 		fprintf(stderr, "miptree doesn't match image\n");
 }
 #endif
+
+void
+radeon_init_common_texture_funcs(radeonContextPtr radeon,
+				 struct dd_function_table *functions)
+{
+	functions->NewTextureImage = radeonNewTextureImage;
+	functions->FreeTextureImageBuffer = radeonFreeTextureImageBuffer;
+	functions->MapTexture = radeonMapTexture;
+	functions->UnmapTexture = radeonUnmapTexture;
+
+	functions->ChooseTextureFormat	= radeonChooseTextureFormat_mesa;
+
+	functions->TexImage1D = radeonTexImage1D;
+	functions->TexImage2D = radeonTexImage2D;
+	functions->TexImage3D = radeonTexImage3D;
+	functions->TexSubImage1D = radeonTexSubImage1D;
+	functions->TexSubImage2D = radeonTexSubImage2D;
+	functions->TexSubImage3D = radeonTexSubImage3D;
+	functions->CompressedTexImage2D = radeonCompressedTexImage2D;
+	functions->CompressedTexSubImage2D = radeonCompressedTexSubImage2D;
+	functions->GetCompressedTexImage = radeonGetCompressedTexImage;
+	functions->GetTexImage = radeonGetTexImage;
+
+	functions->GenerateMipmap = radeonGenerateMipmap;
+
+	if (radeon->radeonScreen->kernel_mm) {
+		functions->CopyTexSubImage2D = radeonCopyTexSubImage2D;
+	}
+
+#if FEATURE_OES_EGL_image
+	functions->EGLImageTargetTexture2D = radeon_image_target_texture_2d;
+#endif
+
+	driInitTextureFormats();
+}
diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.h b/src/mesa/drivers/dri/radeon/radeon_texture.h
index 388512a..c02aa30 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texture.h
+++ b/src/mesa/drivers/dri/radeon/radeon_texture.h
@@ -140,4 +140,8 @@ void radeon_image_target_texture_2d(struct gl_context *ctx, GLenum target,
 				    GLeglImageOES image_handle);
 #endif
 
+void
+radeon_init_common_texture_funcs(radeonContextPtr radeon,
+				 struct dd_function_table *functions);
+
 #endif
-- 
1.7.5.4



More information about the mesa-dev mailing list