diff options
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/mtypes.h | 43 | ||||
-rw-r--r-- | src/mesa/main/texformat.c | 309 | ||||
-rw-r--r-- | src/mesa/main/texformat_tmp.h | 732 | ||||
-rw-r--r-- | src/mesa/main/teximage.c | 82 | ||||
-rw-r--r-- | src/mesa/main/texstore.c | 24 |
5 files changed, 846 insertions, 344 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index a5f7e366c1f..a9c5f2ceca4 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -7,9 +7,9 @@ /* * Mesa 3-D graphics library - * Version: 5.1 + * Version: 6.1 * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2004 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"), @@ -955,20 +955,31 @@ struct gl_stencil_attrib { #define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i)) #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i)) + /** - * Texel fetch function prototype. + * Texel fetch function prototype. We use texel fetch functions to + * extract RGBA, color indexes and depth components out of 1D, 2D and 3D + * texture images. These functions help to isolate us from the gritty + * details of all the various texture image encodings. * * \param texImage texture image. * \param col texel column. * \param row texel row. - * \param img texel level. - * \param texelOut output texel. If \p texImage is color-index, \p texelOut - * returns <tt>GLchan[1]</tt>. If \p texImage is depth, \p texelOut returns - * <tt>GLfloat[1]</tt>. Otherwise, \p texelOut returns <tt>GLchan[4]</tt>. + * \param img texel image level/layer. + * \param texelOut output texel (up to 4 GLchans) + */ +typedef void (*FetchTexelFuncC)( const struct gl_texture_image *texImage, + GLint col, GLint row, GLint img, + GLchan *texelOut ); + +/** + * As above, but returns floats. + * Used for depth component images and for upcoming signed/float + * texture images. */ -typedef void (*FetchTexelFunc)( const struct gl_texture_image *texImage, - GLint col, GLint row, GLint img, - GLvoid *texelOut ); +typedef void (*FetchTexelFuncF)( const struct gl_texture_image *texImage, + GLint col, GLint row, GLint img, + GLfloat *texelOut ); /** * Texture format record @@ -995,9 +1006,12 @@ struct gl_texture_format { * \name Texel fetch function pointers */ /*@{*/ - FetchTexelFunc FetchTexel1D; - FetchTexelFunc FetchTexel2D; - FetchTexelFunc FetchTexel3D; + FetchTexelFuncC FetchTexel1D; + FetchTexelFuncC FetchTexel2D; + FetchTexelFuncC FetchTexel3D; + FetchTexelFuncF FetchTexel1Df; + FetchTexelFuncF FetchTexel2Df; + FetchTexelFuncF FetchTexel3Df; /*@}*/ }; @@ -1033,7 +1047,8 @@ struct gl_texture_image { const struct gl_texture_format *TexFormat; - FetchTexelFunc FetchTexel; /**< Texel fetch function pointer */ + FetchTexelFuncC FetchTexelc; /**< GLchan texel fetch function pointer */ + FetchTexelFuncF FetchTexelf; /**< Float texel fetch function pointer */ GLboolean IsCompressed; /**< GL_ARB_texture_compression */ GLuint CompressedSize; /**< GL_ARB_texture_compression */ diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c index 7af0b1cdf48..7d366b51d79 100644 --- a/src/mesa/main/texformat.c +++ b/src/mesa/main/texformat.c @@ -58,13 +58,23 @@ * Have to have this so the FetchTexel function pointer is never NULL. */ static void fetch_null_texel( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = 0; - rgba[GCOMP] = 0; - rgba[BCOMP] = 0; - rgba[ACOMP] = 0; + texel[RCOMP] = 0; + texel[GCOMP] = 0; + texel[BCOMP] = 0; + texel[ACOMP] = 0; + _mesa_warning(NULL, "fetch_null_texel() called!"); +} + +static void fetch_null_texelf( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + texel[RCOMP] = 0.0; + texel[GCOMP] = 0.0; + texel[BCOMP] = 0.0; + texel[ACOMP] = 0.0; + _mesa_warning(NULL, "fetch_null_texelf() called!"); } @@ -84,9 +94,12 @@ const struct gl_texture_format _mesa_texformat_rgba = { 0, /* IndexBits */ 0, /* DepthBits */ 4 * CHAN_BITS / 8, /* TexelBytes */ - fetch_1d_texel_rgba, /* FetchTexel1D */ - fetch_2d_texel_rgba, /* FetchTexel2D */ - fetch_3d_texel_rgba, /* FetchTexel3D */ + fetch_texel_1d_rgba, /* FetchTexel1D */ + fetch_texel_2d_rgba, /* FetchTexel2D */ + fetch_texel_3d_rgba, /* FetchTexel3D */ + fetch_texel_1d_f_rgba, /* FetchTexel1Df */ + fetch_texel_2d_f_rgba, /* FetchTexel2Df */ + fetch_texel_3d_f_rgba, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_rgb = { @@ -101,9 +114,12 @@ const struct gl_texture_format _mesa_texformat_rgb = { 0, /* IndexBits */ 0, /* DepthBits */ 3 * CHAN_BITS / 8, /* TexelBytes */ - fetch_1d_texel_rgb, /* FetchTexel1D */ - fetch_2d_texel_rgb, /* FetchTexel2D */ - fetch_3d_texel_rgb, /* FetchTexel3D */ + fetch_texel_1d_rgb, /* FetchTexel1D */ + fetch_texel_2d_rgb, /* FetchTexel2D */ + fetch_texel_3d_rgb, /* FetchTexel3D */ + fetch_texel_1d_f_rgb, /* FetchTexel1Df */ + fetch_texel_2d_f_rgb, /* FetchTexel2Df */ + fetch_texel_3d_f_rgb, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_alpha = { @@ -118,9 +134,12 @@ const struct gl_texture_format _mesa_texformat_alpha = { 0, /* IndexBits */ 0, /* DepthBits */ CHAN_BITS / 8, /* TexelBytes */ - fetch_1d_texel_alpha, /* FetchTexel1D */ - fetch_2d_texel_alpha, /* FetchTexel2D */ - fetch_3d_texel_alpha, /* FetchTexel3D */ + fetch_texel_1d_alpha, /* FetchTexel1D */ + fetch_texel_2d_alpha, /* FetchTexel2D */ + fetch_texel_3d_alpha, /* FetchTexel3D */ + fetch_texel_1d_f_alpha, /* FetchTexel1Df */ + fetch_texel_2d_f_alpha, /* FetchTexel2Df */ + fetch_texel_3d_f_alpha, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_luminance = { @@ -135,9 +154,12 @@ const struct gl_texture_format _mesa_texformat_luminance = { 0, /* IndexBits */ 0, /* DepthBits */ CHAN_BITS / 8, /* TexelBytes */ - fetch_1d_texel_luminance, /* FetchTexel1D */ - fetch_2d_texel_luminance, /* FetchTexel2D */ - fetch_3d_texel_luminance, /* FetchTexel3D */ + fetch_texel_1d_luminance, /* FetchTexel1D */ + fetch_texel_2d_luminance, /* FetchTexel2D */ + fetch_texel_3d_luminance, /* FetchTexel3D */ + fetch_texel_1d_f_luminance, /* FetchTexel1Df */ + fetch_texel_2d_f_luminance, /* FetchTexel2Df */ + fetch_texel_3d_f_luminance, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_luminance_alpha = { @@ -152,9 +174,12 @@ const struct gl_texture_format _mesa_texformat_luminance_alpha = { 0, /* IndexBits */ 0, /* DepthBits */ 2 * CHAN_BITS / 8, /* TexelBytes */ - fetch_1d_texel_luminance_alpha, /* FetchTexel1D */ - fetch_2d_texel_luminance_alpha, /* FetchTexel2D */ - fetch_3d_texel_luminance_alpha, /* FetchTexel3D */ + fetch_texel_1d_luminance_alpha, /* FetchTexel1D */ + fetch_texel_2d_luminance_alpha, /* FetchTexel2D */ + fetch_texel_3d_luminance_alpha, /* FetchTexel3D */ + fetch_texel_1d_f_luminance_alpha, /* FetchTexel1Df */ + fetch_texel_2d_f_luminance_alpha, /* FetchTexel2Df */ + fetch_texel_3d_f_luminance_alpha, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_intensity = { @@ -169,9 +194,12 @@ const struct gl_texture_format _mesa_texformat_intensity = { 0, /* IndexBits */ 0, /* DepthBits */ CHAN_BITS / 8, /* TexelBytes */ - fetch_1d_texel_intensity, /* FetchTexel1D */ - fetch_2d_texel_intensity, /* FetchTexel2D */ - fetch_3d_texel_intensity, /* FetchTexel3D */ + fetch_texel_1d_intensity, /* FetchTexel1D */ + fetch_texel_2d_intensity, /* FetchTexel2D */ + fetch_texel_3d_intensity, /* FetchTexel3D */ + fetch_texel_1d_f_intensity, /* FetchTexel1Df */ + fetch_texel_2d_f_intensity, /* FetchTexel2Df */ + fetch_texel_3d_f_intensity, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_color_index = { @@ -186,9 +214,12 @@ const struct gl_texture_format _mesa_texformat_color_index = { CHAN_BITS, /* IndexBits */ 0, /* DepthBits */ CHAN_BITS / 8, /* TexelBytes */ - fetch_1d_texel_color_index, /* FetchTexel1D */ - fetch_2d_texel_color_index, /* FetchTexel2D */ - fetch_3d_texel_color_index, /* FetchTexel3D */ + fetch_texel_1d_color_index, /* FetchTexel1D */ + fetch_texel_2d_color_index, /* FetchTexel2D */ + fetch_texel_3d_color_index, /* FetchTexel3D */ + fetch_texel_1d_f_color_index, /* FetchTexel1Df */ + fetch_texel_2d_f_color_index, /* FetchTexel2Df */ + fetch_texel_3d_f_color_index, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_depth_component = { @@ -203,9 +234,12 @@ const struct gl_texture_format _mesa_texformat_depth_component = { 0, /* IndexBits */ sizeof(GLfloat) * 8, /* DepthBits */ sizeof(GLfloat), /* TexelBytes */ - fetch_1d_texel_depth_component, /* FetchTexel1D */ - fetch_2d_texel_depth_component, /* FetchTexel2D */ - fetch_3d_texel_depth_component, /* FetchTexel3D */ + fetch_null_texel, /* FetchTexel1D */ + fetch_null_texel, /* FetchTexel1D */ + fetch_null_texel, /* FetchTexel1D */ + fetch_texel_1d_f_depth_component, /* FetchTexel1Df */ + fetch_texel_2d_f_depth_component, /* FetchTexel2Df */ + fetch_texel_3d_f_depth_component, /* FetchTexel3Df */ }; /*@}*/ @@ -227,9 +261,12 @@ const struct gl_texture_format _mesa_texformat_rgba8888 = { 0, /* IndexBits */ 0, /* DepthBits */ 4, /* TexelBytes */ - fetch_1d_texel_rgba8888, /* FetchTexel1D */ - fetch_2d_texel_rgba8888, /* FetchTexel2D */ - fetch_3d_texel_rgba8888, /* FetchTexel3D */ + fetch_texel_1d_rgba8888, /* FetchTexel1D */ + fetch_texel_2d_rgba8888, /* FetchTexel2D */ + fetch_texel_3d_rgba8888, /* FetchTexel3D */ + fetch_texel_1d_f_rgba8888, /* FetchTexel1Df */ + fetch_texel_2d_f_rgba8888, /* FetchTexel2Df */ + fetch_texel_3d_f_rgba8888, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_argb8888 = { @@ -244,9 +281,12 @@ const struct gl_texture_format _mesa_texformat_argb8888 = { 0, /* IndexBits */ 0, /* DepthBits */ 4, /* TexelBytes */ - fetch_1d_texel_argb8888, /* FetchTexel1D */ - fetch_2d_texel_argb8888, /* FetchTexel2D */ - fetch_3d_texel_argb8888, /* FetchTexel3D */ + fetch_texel_1d_argb8888, /* FetchTexel1D */ + fetch_texel_2d_argb8888, /* FetchTexel2D */ + fetch_texel_3d_argb8888, /* FetchTexel3D */ + fetch_texel_1d_f_argb8888, /* FetchTexel1Df */ + fetch_texel_2d_f_argb8888, /* FetchTexel2Df */ + fetch_texel_3d_f_argb8888, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_rgb888 = { @@ -261,9 +301,12 @@ const struct gl_texture_format _mesa_texformat_rgb888 = { 0, /* IndexBits */ 0, /* DepthBits */ 3, /* TexelBytes */ - fetch_1d_texel_rgb888, /* FetchTexel1D */ - fetch_2d_texel_rgb888, /* FetchTexel2D */ - fetch_3d_texel_rgb888, /* FetchTexel3D */ + fetch_texel_1d_rgb888, /* FetchTexel1D */ + fetch_texel_2d_rgb888, /* FetchTexel2D */ + fetch_texel_3d_rgb888, /* FetchTexel3D */ + fetch_texel_1d_f_rgb888, /* FetchTexel1Df */ + fetch_texel_2d_f_rgb888, /* FetchTexel2Df */ + fetch_texel_3d_f_rgb888, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_rgb565 = { @@ -278,9 +321,12 @@ const struct gl_texture_format _mesa_texformat_rgb565 = { 0, /* IndexBits */ 0, /* DepthBits */ 2, /* TexelBytes */ - fetch_1d_texel_rgb565, /* FetchTexel1D */ - fetch_2d_texel_rgb565, /* FetchTexel2D */ - fetch_3d_texel_rgb565, /* FetchTexel3D */ + fetch_texel_1d_rgb565, /* FetchTexel1D */ + fetch_texel_2d_rgb565, /* FetchTexel2D */ + fetch_texel_3d_rgb565, /* FetchTexel3D */ + fetch_texel_1d_f_rgb565, /* FetchTexel1Df */ + fetch_texel_2d_f_rgb565, /* FetchTexel2Df */ + fetch_texel_3d_f_rgb565, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_argb4444 = { @@ -295,9 +341,12 @@ const struct gl_texture_format _mesa_texformat_argb4444 = { 0, /* IndexBits */ 0, /* DepthBits */ 2, /* TexelBytes */ - fetch_1d_texel_argb4444, /* FetchTexel1D */ - fetch_2d_texel_argb4444, /* FetchTexel2D */ - fetch_3d_texel_argb4444, /* FetchTexel3D */ + fetch_texel_1d_argb4444, /* FetchTexel1D */ + fetch_texel_2d_argb4444, /* FetchTexel2D */ + fetch_texel_3d_argb4444, /* FetchTexel3D */ + fetch_texel_1d_f_argb4444, /* FetchTexel1Df */ + fetch_texel_2d_f_argb4444, /* FetchTexel2Df */ + fetch_texel_3d_f_argb4444, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_argb1555 = { @@ -312,9 +361,12 @@ const struct gl_texture_format _mesa_texformat_argb1555 = { 0, /* IndexBits */ 0, /* DepthBits */ 2, /* TexelBytes */ - fetch_1d_texel_argb1555, /* FetchTexel1D */ - fetch_2d_texel_argb1555, /* FetchTexel2D */ - fetch_3d_texel_argb1555, /* FetchTexel3D */ + fetch_texel_1d_argb1555, /* FetchTexel1D */ + fetch_texel_2d_argb1555, /* FetchTexel2D */ + fetch_texel_3d_argb1555, /* FetchTexel3D */ + fetch_texel_1d_f_argb1555, /* FetchTexel1Df */ + fetch_texel_2d_f_argb1555, /* FetchTexel2Df */ + fetch_texel_3d_f_argb1555, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_al88 = { @@ -329,9 +381,12 @@ const struct gl_texture_format _mesa_texformat_al88 = { 0, /* IndexBits */ 0, /* DepthBits */ 2, /* TexelBytes */ - fetch_1d_texel_al88, /* FetchTexel1D */ - fetch_2d_texel_al88, /* FetchTexel2D */ - fetch_3d_texel_al88, /* FetchTexel3D */ + fetch_texel_1d_al88, /* FetchTexel1D */ + fetch_texel_2d_al88, /* FetchTexel2D */ + fetch_texel_3d_al88, /* FetchTexel3D */ + fetch_texel_1d_f_al88, /* FetchTexel1Df */ + fetch_texel_2d_f_al88, /* FetchTexel2Df */ + fetch_texel_3d_f_al88, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_rgb332 = { @@ -346,9 +401,12 @@ const struct gl_texture_format _mesa_texformat_rgb332 = { 0, /* IndexBits */ 0, /* DepthBits */ 1, /* TexelBytes */ - fetch_1d_texel_rgb332, /* FetchTexel1D */ - fetch_2d_texel_rgb332, /* FetchTexel2D */ - fetch_3d_texel_rgb332, /* FetchTexel3D */ + fetch_texel_1d_rgb332, /* FetchTexel1D */ + fetch_texel_2d_rgb332, /* FetchTexel2D */ + fetch_texel_3d_rgb332, /* FetchTexel3D */ + fetch_texel_1d_f_rgb332, /* FetchTexel1Df */ + fetch_texel_2d_f_rgb332, /* FetchTexel2Df */ + fetch_texel_3d_f_rgb332, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_a8 = { @@ -363,9 +421,12 @@ const struct gl_texture_format _mesa_texformat_a8 = { 0, /* IndexBits */ 0, /* DepthBits */ 1, /* TexelBytes */ - fetch_1d_texel_a8, /* FetchTexel1D */ - fetch_2d_texel_a8, /* FetchTexel2D */ - fetch_3d_texel_a8, /* FetchTexel3D */ + fetch_texel_1d_a8, /* FetchTexel1D */ + fetch_texel_2d_a8, /* FetchTexel2D */ + fetch_texel_3d_a8, /* FetchTexel3D */ + fetch_texel_1d_f_a8, /* FetchTexel1Df */ + fetch_texel_2d_f_a8, /* FetchTexel2Df */ + fetch_texel_3d_f_a8, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_l8 = { @@ -380,9 +441,12 @@ const struct gl_texture_format _mesa_texformat_l8 = { 0, /* IndexBits */ 0, /* DepthBits */ 1, /* TexelBytes */ - fetch_1d_texel_l8, /* FetchTexel1D */ - fetch_2d_texel_l8, /* FetchTexel2D */ - fetch_3d_texel_l8, /* FetchTexel3D */ + fetch_texel_1d_l8, /* FetchTexel1D */ + fetch_texel_2d_l8, /* FetchTexel2D */ + fetch_texel_3d_l8, /* FetchTexel3D */ + fetch_texel_1d_f_l8, /* FetchTexel1Df */ + fetch_texel_2d_f_l8, /* FetchTexel2Df */ + fetch_texel_3d_f_l8, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_i8 = { @@ -397,9 +461,12 @@ const struct gl_texture_format _mesa_texformat_i8 = { 0, /* IndexBits */ 0, /* DepthBits */ 1, /* TexelBytes */ - fetch_1d_texel_i8, /* FetchTexel1D */ - fetch_2d_texel_i8, /* FetchTexel2D */ - fetch_3d_texel_i8, /* FetchTexel3D */ + fetch_texel_1d_i8, /* FetchTexel1D */ + fetch_texel_2d_i8, /* FetchTexel2D */ + fetch_texel_3d_i8, /* FetchTexel3D */ + fetch_texel_1d_f_i8, /* FetchTexel1Df */ + fetch_texel_2d_f_i8, /* FetchTexel2Df */ + fetch_texel_3d_f_i8, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_ci8 = { @@ -414,9 +481,12 @@ const struct gl_texture_format _mesa_texformat_ci8 = { 8, /* IndexBits */ 0, /* DepthBits */ 1, /* TexelBytes */ - fetch_1d_texel_ci8, /* FetchTexel1D */ - fetch_2d_texel_ci8, /* FetchTexel2D */ - fetch_3d_texel_ci8, /* FetchTexel3D */ + fetch_texel_1d_ci8, /* FetchTexel1D */ + fetch_texel_2d_ci8, /* FetchTexel2D */ + fetch_texel_3d_ci8, /* FetchTexel3D */ + fetch_texel_1d_f_ci8, /* FetchTexel1Df */ + fetch_texel_2d_f_ci8, /* FetchTexel2Df */ + fetch_texel_3d_f_ci8, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_ycbcr = { @@ -431,9 +501,12 @@ const struct gl_texture_format _mesa_texformat_ycbcr = { 0, /* IndexBits */ 0, /* DepthBits */ 2, /* TexelBytes */ - fetch_1d_texel_ycbcr, /* FetchTexel1D */ - fetch_2d_texel_ycbcr, /* FetchTexel2D */ - fetch_3d_texel_ycbcr, /* FetchTexel3D */ + fetch_texel_1d_ycbcr, /* FetchTexel1D */ + fetch_texel_2d_ycbcr, /* FetchTexel2D */ + fetch_texel_3d_ycbcr, /* FetchTexel3D */ + fetch_texel_1d_f_ycbcr, /* FetchTexel1Df */ + fetch_texel_2d_f_ycbcr, /* FetchTexel2Df */ + fetch_texel_3d_f_ycbcr, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_ycbcr_rev = { @@ -448,9 +521,12 @@ const struct gl_texture_format _mesa_texformat_ycbcr_rev = { 0, /* IndexBits */ 0, /* DepthBits */ 2, /* TexelBytes */ - fetch_1d_texel_ycbcr_rev, /* FetchTexel1D */ - fetch_2d_texel_ycbcr_rev, /* FetchTexel2D */ - fetch_3d_texel_ycbcr_rev, /* FetchTexel3D */ + fetch_texel_1d_ycbcr_rev, /* FetchTexel1D */ + fetch_texel_2d_ycbcr_rev, /* FetchTexel2D */ + fetch_texel_3d_ycbcr_rev, /* FetchTexel3D */ + fetch_texel_1d_f_ycbcr_rev, /* FetchTexel1Df */ + fetch_texel_2d_f_ycbcr_rev, /* FetchTexel2Df */ + fetch_texel_3d_f_ycbcr_rev, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_rgb_fxt1 = { @@ -466,8 +542,11 @@ const struct gl_texture_format _mesa_texformat_rgb_fxt1 = { 0, /* DepthBits */ 0, /* TexelBytes */ NULL, /*impossible*/ /* FetchTexel1D */ - fetch_2d_texel_rgb_fxt1, /* FetchTexel2D */ + fetch_texel_2d_rgb_fxt1, /* FetchTexel2D */ NULL, /*impossible*/ /* FetchTexel3D */ + NULL, /*impossible*/ /* FetchTexel1Df */ + fetch_texel_2d_f_rgb_fxt1, /* FetchTexel2Df */ + NULL, /*impossible*/ /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_rgba_fxt1 = { @@ -483,8 +562,11 @@ const struct gl_texture_format _mesa_texformat_rgba_fxt1 = { 0, /* DepthBits */ 0, /* TexelBytes */ NULL, /*impossible*/ /* FetchTexel1D */ - fetch_2d_texel_rgba_fxt1, /* FetchTexel2D */ + fetch_texel_2d_rgba_fxt1, /* FetchTexel2D */ NULL, /*impossible*/ /* FetchTexel3D */ + NULL, /*impossible*/ /* FetchTexel1Df */ + fetch_texel_2d_f_rgba_fxt1, /* FetchTexel2Df */ + NULL, /*impossible*/ /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_rgb_dxt1 = { @@ -500,8 +582,11 @@ const struct gl_texture_format _mesa_texformat_rgb_dxt1 = { 0, /* DepthBits */ 0, /* TexelBytes */ NULL, /*impossible*/ /* FetchTexel1D */ - fetch_2d_texel_rgb_dxt1, /* FetchTexel2D */ + fetch_texel_2d_rgb_dxt1, /* FetchTexel2D */ NULL, /*impossible*/ /* FetchTexel3D */ + NULL, /*impossible*/ /* FetchTexel1Df */ + fetch_texel_2d_f_rgb_dxt1, /* FetchTexel2Df */ + NULL, /*impossible*/ /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_rgba_dxt1 = { @@ -517,8 +602,11 @@ const struct gl_texture_format _mesa_texformat_rgba_dxt1 = { 0, /* DepthBits */ 0, /* TexelBytes */ NULL, /*impossible*/ /* FetchTexel1D */ - fetch_2d_texel_rgba_dxt1, /* FetchTexel2D */ + fetch_texel_2d_rgba_dxt1, /* FetchTexel2D */ NULL, /*impossible*/ /* FetchTexel3D */ + NULL, /*impossible*/ /* FetchTexel1Df */ + fetch_texel_2d_f_rgba_dxt1, /* FetchTexel2Df */ + NULL, /*impossible*/ /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_rgba_dxt3 = { @@ -534,8 +622,11 @@ const struct gl_texture_format _mesa_texformat_rgba_dxt3 = { 0, /* DepthBits */ 0, /* TexelBytes */ NULL, /*impossible*/ /* FetchTexel1D */ - fetch_2d_texel_rgba_dxt3, /* FetchTexel2D */ + fetch_texel_2d_rgba_dxt3, /* FetchTexel2D */ NULL, /*impossible*/ /* FetchTexel3D */ + NULL, /*impossible*/ /* FetchTexel1Df */ + fetch_texel_2d_f_rgba_dxt3, /* FetchTexel2Df */ + NULL, /*impossible*/ /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_rgba_dxt5 = { @@ -551,8 +642,11 @@ const struct gl_texture_format _mesa_texformat_rgba_dxt5 = { 0, /* DepthBits */ 0, /* TexelBytes */ NULL, /*impossible*/ /* FetchTexel1D */ - fetch_2d_texel_rgba_dxt5, /* FetchTexel2D */ + fetch_texel_2d_rgba_dxt5, /* FetchTexel2D */ NULL, /*impossible*/ /* FetchTexel3D */ + NULL, /*impossible*/ /* FetchTexel1Df */ + fetch_texel_2d_f_rgba_dxt5, /* FetchTexel2Df */ + NULL, /*impossible*/ /* FetchTexel3Df */ }; @@ -571,9 +665,10 @@ const struct gl_texture_format _mesa_texformat_abgr8888 = { 0, /* IndexBits */ 0, /* DepthBits */ 4, /* TexelBytes */ - fetch_1d_texel_abgr8888, /* FetchTexel1D */ - fetch_2d_texel_abgr8888, /* FetchTexel2D */ - fetch_3d_texel_abgr8888, /* FetchTexel3D */ + fetch_texel_1d_abgr8888, /* FetchTexel1D */ + fetch_texel_2d_abgr8888, /* FetchTexel2D */ + fetch_texel_3d_abgr8888, /* FetchTexel3D */ + /* XXX float fetchers */ }; const struct gl_texture_format _mesa_texformat_bgra8888 = { @@ -589,9 +684,10 @@ const struct gl_texture_format _mesa_texformat_bgra8888 = { 0, /* IndexBits */ 0, /* DepthBits */ 4, /* TexelBytes */ - fetch_1d_texel_bgra8888, /* FetchTexel1D */ - fetch_2d_texel_bgra8888, /* FetchTexel2D */ - fetch_3d_texel_bgra8888, /* FetchTexel3D */ + fetch_texel_1d_bgra8888, /* FetchTexel1D */ + fetch_texel_2d_bgra8888, /* FetchTexel2D */ + fetch_texel_3d_bgra8888, /* FetchTexel3D */ + /* XXX float fetchers */ }; const struct gl_texture_format _mesa_texformat_bgr888 = { @@ -607,9 +703,10 @@ const struct gl_texture_format _mesa_texformat_bgr888 = { 0, /* IndexBits */ 0, /* DepthBits */ 3, /* TexelBytes */ - fetch_1d_texel_bgr888, /* FetchTexel1D */ - fetch_2d_texel_bgr888, /* FetchTexel2D */ - fetch_3d_texel_bgr888, /* FetchTexel3D */ + fetch_texel_1d_bgr888, /* FetchTexel1D */ + fetch_texel_2d_bgr888, /* FetchTexel2D */ + fetch_texel_3d_bgr888, /* FetchTexel3D */ + /* XXX float fetchers */ }; const struct gl_texture_format _mesa_texformat_bgr565 = { @@ -625,9 +722,10 @@ const struct gl_texture_format _mesa_texformat_bgr565 = { 0, /* IndexBits */ 0, /* DepthBits */ 2, /* TexelBytes */ - fetch_1d_texel_bgr565, /* FetchTexel1D */ - fetch_2d_texel_bgr565, /* FetchTexel2D */ - fetch_3d_texel_bgr565, /* FetchTexel3D */ + fetch_texel_1d_bgr565, /* FetchTexel1D */ + fetch_texel_2d_bgr565, /* FetchTexel2D */ + fetch_texel_3d_bgr565, /* FetchTexel3D */ + /* XXX float fetchers */ }; const struct gl_texture_format _mesa_texformat_bgra4444 = { @@ -643,9 +741,10 @@ const struct gl_texture_format _mesa_texformat_bgra4444 = { 0, /* IndexBits */ 0, /* DepthBits */ 2, /* TexelBytes */ - fetch_1d_texel_bgra4444, /* FetchTexel1D */ - fetch_2d_texel_bgra4444, /* FetchTexel2D */ - fetch_3d_texel_bgra4444, /* FetchTexel3D */ + fetch_texel_1d_bgra4444, /* FetchTexel1D */ + fetch_texel_2d_bgra4444, /* FetchTexel2D */ + fetch_texel_3d_bgra4444, /* FetchTexel3D */ + /* XXX float fetchers */ }; const struct gl_texture_format _mesa_texformat_bgra5551 = { @@ -661,9 +760,10 @@ const struct gl_texture_format _mesa_texformat_bgra5551 = { 0, /* IndexBits */ 0, /* DepthBits */ 2, /* TexelBytes */ - fetch_1d_texel_bgra1555, /* FetchTexel1D */ - fetch_2d_texel_bgra1555, /* FetchTexel2D */ - fetch_3d_texel_bgra1555, /* FetchTexel3D */ + fetch_texel_1d_bgra1555, /* FetchTexel1D */ + fetch_texel_2d_bgra1555, /* FetchTexel2D */ + fetch_texel_3d_bgra1555, /* FetchTexel3D */ + /* XXX float fetchers */ }; const struct gl_texture_format _mesa_texformat_la88 = { @@ -679,9 +779,10 @@ const struct gl_texture_format _mesa_texformat_la88 = { 0, /* IndexBits */ 0, /* DepthBits */ 2, /* TexelBytes */ - fetch_1d_texel_la88, /* FetchTexel1D */ - fetch_2d_texel_la88, /* FetchTexel2D */ - fetch_3d_texel_la88, /* FetchTexel3D */ + fetch_texel_1d_la88, /* FetchTexel1D */ + fetch_texel_2d_la88, /* FetchTexel2D */ + fetch_texel_3d_la88, /* FetchTexel3D */ + /* XXX float fetchers */ }; const struct gl_texture_format _mesa_texformat_bgr233 = { @@ -697,9 +798,10 @@ const struct gl_texture_format _mesa_texformat_bgr233 = { 0, /* IndexBits */ 0, /* DepthBits */ 1, /* TexelBytes */ - fetch_1d_texel_bgr233, /* FetchTexel1D */ - fetch_2d_texel_bgr233, /* FetchTexel2D */ - fetch_3d_texel_bgr233, /* FetchTexel3D */ + fetch_texel_1d_bgr233, /* FetchTexel1D */ + fetch_texel_2d_bgr233, /* FetchTexel2D */ + fetch_texel_3d_bgr233, /* FetchTexel3D */ + /* XXX float fetchers */ }; #endif @@ -725,6 +827,9 @@ const struct gl_texture_format _mesa_null_texformat = { fetch_null_texel, /* FetchTexel1D */ fetch_null_texel, /* FetchTexel2D */ fetch_null_texel, /* FetchTexel3D */ + fetch_null_texelf, /* FetchTexel1Df */ + fetch_null_texelf, /* FetchTexel2Df */ + fetch_null_texelf, /* FetchTexel3Df */ }; /*@}*/ diff --git a/src/mesa/main/texformat_tmp.h b/src/mesa/main/texformat_tmp.h index 14eb0463abf..061f11daca3 100644 --- a/src/mesa/main/texformat_tmp.h +++ b/src/mesa/main/texformat_tmp.h @@ -17,9 +17,9 @@ /* * Mesa 3-D graphics library - * Version: 5.1 + * Version: 6.1 * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2004 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"), @@ -51,7 +51,7 @@ #define FLOAT_SRC( t, i, j, k ) \ ((GLfloat *)(t)->Data + (i)) -#define FETCH(x) fetch_1d_texel_##x +#define FETCH(x) fetch_texel_1d_##x #elif DIM == 2 @@ -64,7 +64,7 @@ #define FLOAT_SRC( t, i, j, k ) \ ((GLfloat *)(t)->Data + ((t)->RowStride * (j) + (i))) -#define FETCH(x) fetch_2d_texel_##x +#define FETCH(x) fetch_texel_2d_##x #elif DIM == 3 @@ -81,228 +81,477 @@ ((GLfloat *)(t)->Data + (((t)->Height * (k) + (j)) * \ (t)->RowStride + (i))) -#define FETCH(x) fetch_3d_texel_##x +#define FETCH(x) fetch_texel_3d_##x #else #error illegal number of texture dimensions #endif +/* Fetch color texel from 1D, 2D or 3D RGBA texture, returning 4 GLchans */ static void FETCH(rgba)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLchan *src = CHAN_SRC( texImage, i, j, k, 4 ); - GLchan *rgba = (GLchan *) texel; - COPY_CHAN4( rgba, src ); + COPY_CHAN4( texel, src ); } +/* Fetch color texel from 1D, 2D or 3D RGBA texture, returning 4 GLfloats */ +static void FETCH(f_rgba)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLchan *src = CHAN_SRC( texImage, i, j, k, 4 ); + texel[RCOMP] = CHAN_TO_FLOAT(src[0]); + texel[GCOMP] = CHAN_TO_FLOAT(src[1]); + texel[BCOMP] = CHAN_TO_FLOAT(src[2]); + texel[ACOMP] = CHAN_TO_FLOAT(src[3]); +} + + +/* Fetch color texel from 1D, 2D or 3D RGB texture, returning 4 GLchans */ static void FETCH(rgb)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) +{ + const GLchan *src = CHAN_SRC( texImage, i, j, k, 3 ); + texel[RCOMP] = src[0]; + texel[GCOMP] = src[1]; + texel[BCOMP] = src[2]; + texel[ACOMP] = CHAN_MAX; +} + +/* Fetch color texel from 1D, 2D or 3D RGB texture, returning 4 GLfloats */ +static void FETCH(f_rgb)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) { const GLchan *src = CHAN_SRC( texImage, i, j, k, 3 ); - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = src[0]; - rgba[GCOMP] = src[1]; - rgba[BCOMP] = src[2]; - rgba[ACOMP] = CHAN_MAX; + texel[RCOMP] = CHAN_TO_FLOAT(src[0]); + texel[GCOMP] = CHAN_TO_FLOAT(src[1]); + texel[BCOMP] = CHAN_TO_FLOAT(src[2]); + texel[ACOMP] = CHAN_MAXF; } +/* Fetch color texel from 1D, 2D or 3D ALPHA texture, returning 4 GLchans */ static void FETCH(alpha)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) +{ + const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 ); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = 0; + texel[ACOMP] = src[0]; +} + +/* Fetch color texel from 1D, 2D or 3D ALPHA texture, returning 4 GLfloats */ +static void FETCH(f_alpha)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) { const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 ); - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = 0; - rgba[GCOMP] = 0; - rgba[BCOMP] = 0; - rgba[ACOMP] = src[0]; + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = 0.0; + texel[ACOMP] = CHAN_TO_FLOAT(src[0]); } +/* Fetch color texel from 1D, 2D or 3D LUMIN texture, returning 4 GLchans */ static void FETCH(luminance)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) +{ + const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 ); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = src[0]; + texel[ACOMP] = CHAN_MAX; +} + +/* Fetch color texel from 1D, 2D or 3D LUMIN texture, returning 4 GLchans */ +static void FETCH(f_luminance)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) { const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 ); - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = src[0]; - rgba[GCOMP] = src[0]; - rgba[BCOMP] = src[0]; - rgba[ACOMP] = CHAN_MAX; + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = CHAN_TO_FLOAT(src[0]); + texel[ACOMP] = CHAN_MAXF; } +/* Fetch color texel from 1D, 2D or 3D L_A texture, returning 4 GLchans */ static void FETCH(luminance_alpha)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) +{ + const GLchan *src = CHAN_SRC( texImage, i, j, k, 2 ); + texel[RCOMP] = src[0]; + texel[GCOMP] = src[0]; + texel[BCOMP] = src[0]; + texel[ACOMP] = src[1]; +} + +/* Fetch color texel from 1D, 2D or 3D L_A texture, returning 4 GLfloats */ +static void FETCH(f_luminance_alpha)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) { const GLchan *src = CHAN_SRC( texImage, i, j, k, 2 ); - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = src[0]; - rgba[GCOMP] = src[0]; - rgba[BCOMP] = src[0]; - rgba[ACOMP] = src[1]; + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = CHAN_TO_FLOAT(src[0]); + texel[ACOMP] = CHAN_TO_FLOAT(src[1]); } + +/* Fetch color texel from 1D, 2D or 3D INT. texture, returning 4 GLchans */ static void FETCH(intensity)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 ); - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = src[0]; - rgba[GCOMP] = src[0]; - rgba[BCOMP] = src[0]; - rgba[ACOMP] = src[0]; + texel[RCOMP] = src[0]; + texel[GCOMP] = src[0]; + texel[BCOMP] = src[0]; + texel[ACOMP] = src[0]; } +/* Fetch color texel from 1D, 2D or 3D INT. texture, returning 4 GLfloats */ +static void FETCH(f_intensity)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 ); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = + texel[ACOMP] = CHAN_TO_FLOAT(src[0]); +} + + +/* Fetch CI texel from 1D, 2D or 3D CI texture, returning 1 GLchan */ static void FETCH(color_index)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 ); GLchan *index = (GLchan *) texel; - *index = *src; + index[0] = src[0]; +} + +/* Fetch CI texel from 1D, 2D or 3D CI texture, returning 1 GLfloat */ +static void FETCH(f_color_index)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 ); + texel[0] = (GLfloat) src[0]; } + +#if 000 +/* Fetch depth texel from 1D, 2D or 3D DEPTH texture, returning 1 GLfloat */ static void FETCH(depth_component)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { +#if 0 const GLfloat *src = FLOAT_SRC( texImage, i, j, k ); GLfloat *depth = (GLfloat *) texel; - *depth = *src; + depth[0] = src[0]; +#else + _mesa_problem(NULL, "fetching depth component as non-float!"); +#endif } +#endif + +/* Fetch depth texel from 1D, 2D or 3D DEPTH texture, returning 1 GLfloat */ +static void FETCH(f_depth_component)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLfloat *src = FLOAT_SRC( texImage, i, j, k ); + texel[0] = src[0]; +} + + +/* Fetch color texel from 1D, 2D or 3D rgba8888 texture, return 4 GLchans */ static void FETCH(rgba8888)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = UBYTE_TO_CHAN( src[3] ); - rgba[GCOMP] = UBYTE_TO_CHAN( src[2] ); - rgba[BCOMP] = UBYTE_TO_CHAN( src[1] ); - rgba[ACOMP] = UBYTE_TO_CHAN( src[0] ); + texel[RCOMP] = UBYTE_TO_CHAN( src[3] ); + texel[GCOMP] = UBYTE_TO_CHAN( src[2] ); + texel[BCOMP] = UBYTE_TO_CHAN( src[1] ); + texel[ACOMP] = UBYTE_TO_CHAN( src[0] ); } +/* Fetch color texel from 1D, 2D or 3D rgba8888 texture, return 4 GLfloats */ +static void FETCH(f_rgba8888)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); + texel[RCOMP] = UBYTE_TO_FLOAT( src[3] ); + texel[GCOMP] = UBYTE_TO_FLOAT( src[2] ); + texel[BCOMP] = UBYTE_TO_FLOAT( src[1] ); + texel[ACOMP] = UBYTE_TO_FLOAT( src[0] ); +} + + +/* Fetch color texel from 1D, 2D or 3D argb8888 texture, return 4 GLchans */ static void FETCH(argb8888)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = UBYTE_TO_CHAN( src[2] ); - rgba[GCOMP] = UBYTE_TO_CHAN( src[1] ); - rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); - rgba[ACOMP] = UBYTE_TO_CHAN( src[3] ); + texel[RCOMP] = UBYTE_TO_CHAN( src[2] ); + texel[GCOMP] = UBYTE_TO_CHAN( src[1] ); + texel[BCOMP] = UBYTE_TO_CHAN( src[0] ); + texel[ACOMP] = UBYTE_TO_CHAN( src[3] ); } +/* Fetch color texel from 1D, 2D or 3D argb8888 texture, return 4 GLfloats */ +static void FETCH(f_argb8888)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); + texel[RCOMP] = UBYTE_TO_FLOAT( src[2] ); + texel[GCOMP] = UBYTE_TO_FLOAT( src[1] ); + texel[BCOMP] = UBYTE_TO_FLOAT( src[0] ); + texel[ACOMP] = UBYTE_TO_FLOAT( src[3] ); +} + + +/* Fetch color texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */ static void FETCH(rgb888)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) +{ + const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 3 ); + texel[RCOMP] = UBYTE_TO_CHAN( src[2] ); + texel[GCOMP] = UBYTE_TO_CHAN( src[1] ); + texel[BCOMP] = UBYTE_TO_CHAN( src[0] ); + texel[ACOMP] = CHAN_MAX; +} + +/* Fetch color texel from 1D, 2D or 3D rgb888 texture, return 4 GLfloats */ +static void FETCH(f_rgb888)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) { const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 3 ); - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = UBYTE_TO_CHAN( src[2] ); - rgba[GCOMP] = UBYTE_TO_CHAN( src[1] ); - rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); - rgba[ACOMP] = CHAN_MAX; + texel[RCOMP] = UBYTE_TO_FLOAT( src[2] ); + texel[GCOMP] = UBYTE_TO_FLOAT( src[1] ); + texel[BCOMP] = UBYTE_TO_FLOAT( src[0] ); + texel[ACOMP] = CHAN_MAXF; } + +/* Fetch color texel from 1D, 2D or 3D rgb565 texture, return 4 GLchans */ static void FETCH(rgb565)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) +{ + const GLushort *src = USHORT_SRC( texImage, i, j, k ); + const GLushort s = *src; + texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 ); + texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc ); + texel[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) * 255 / 0xf8 ); + texel[ACOMP] = CHAN_MAX; +} + +/* Fetch color texel from 1D, 2D or 3D rgb565 texture, return 4 GLfloats */ +static void FETCH(f_rgb565)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) { const GLushort *src = USHORT_SRC( texImage, i, j, k ); const GLushort s = *src; - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 ); - rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc ); - rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) * 255 / 0xf8 ); - rgba[ACOMP] = CHAN_MAX; + /* xxx fixup */ + texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 8) & 0xf8) * 255 / 0xf8 ); + texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 3) & 0xfc) * 255 / 0xfc ); + texel[BCOMP] = UBYTE_TO_FLOAT( ((s << 3) & 0xf8) * 255 / 0xf8 ); + texel[ACOMP] = CHAN_MAXF; } + +/* Fetch color texel from 1D, 2D or 3D rgb565 texture, return 4 GLchans */ static void FETCH(argb4444)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) +{ + const GLushort *src = USHORT_SRC( texImage, i, j, k ); + const GLushort s = *src; + texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) * 255 / 0xf ); + texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) * 255 / 0xf ); + texel[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) * 255 / 0xf ); + texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf ); +} + +/* Fetch color texel from 1D, 2D or 3D rgb565 texture, return 4 GLfloats */ +static void FETCH(f_argb4444)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) { const GLushort *src = USHORT_SRC( texImage, i, j, k ); const GLushort s = *src; - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) * 255 / 0xf ); - rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) * 255 / 0xf ); - rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) * 255 / 0xf ); - rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf ); + /* xxx fixup */ + texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 8) & 0xf) * 255 / 0xf ); + texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 4) & 0xf) * 255 / 0xf ); + texel[BCOMP] = UBYTE_TO_FLOAT( ((s ) & 0xf) * 255 / 0xf ); + texel[ACOMP] = UBYTE_TO_FLOAT( ((s >> 12) & 0xf) * 255 / 0xf ); } + +/* Fetch color texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */ static void FETCH(argb1555)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLushort *src = USHORT_SRC( texImage, i, j, k ); const GLushort s = *src; - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 10) & 0x1f) * 255 / 0x1f ); - rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 0x1f) * 255 / 0x1f ); - rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0x1f) * 255 / 0x1f ); - rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 ); + texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 10) & 0x1f) * 255 / 0x1f ); + texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 0x1f) * 255 / 0x1f ); + texel[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0x1f) * 255 / 0x1f ); + texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 ); } +/* Fetch color texel from 1D, 2D or 3D argb1555 texture, return 4 GLfloats */ +static void FETCH(f_argb1555)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort *src = USHORT_SRC( texImage, i, j, k ); + const GLushort s = *src; + /* xxx better */ + texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 10) & 0x1f) * 255 / 0x1f ); + texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 5) & 0x1f) * 255 / 0x1f ); + texel[BCOMP] = UBYTE_TO_FLOAT( ((s ) & 0x1f) * 255 / 0x1f ); + texel[ACOMP] = UBYTE_TO_FLOAT( ((s >> 15) & 0x01) * 255 ); +} + + +/* Fetch color texel from 1D, 2D or 3D al88 texture, return 4 GLchans */ static void FETCH(al88)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) +{ + const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 2 ); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = UBYTE_TO_CHAN( src[0] ); + texel[ACOMP] = UBYTE_TO_CHAN( src[1] ); +} + +/* Fetch color texel from 1D, 2D or 3D al88 texture, return 4 GLfloats */ +static void FETCH(f_al88)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) { const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 2 ); - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = UBYTE_TO_CHAN( src[0] ); - rgba[GCOMP] = UBYTE_TO_CHAN( src[0] ); - rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); - rgba[ACOMP] = UBYTE_TO_CHAN( src[1] ); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = UBYTE_TO_FLOAT( src[0] ); + texel[ACOMP] = UBYTE_TO_FLOAT( src[1] ); } + +/* Fetch color texel from 1D, 2D or 3D rgb332 texture, return 4 GLchans */ static void FETCH(rgb332)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); const GLubyte s = *src; - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xe0) * 255 / 0xe0 ); - rgba[GCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xe0) * 255 / 0xe0 ); - rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 5) & 0xc0) * 255 / 0xc0 ); - rgba[ACOMP] = CHAN_MAX; + texel[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xe0) * 255 / 0xe0 ); + texel[GCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xe0) * 255 / 0xe0 ); + texel[BCOMP] = UBYTE_TO_CHAN( ((s << 5) & 0xc0) * 255 / 0xc0 ); + texel[ACOMP] = CHAN_MAX; } +/* Fetch color texel from 1D, 2D or 3D rgb332 texture, return 4 GLfloats */ +static void FETCH(f_rgb332)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); + const GLubyte s = *src; + /* xxx improve */ + texel[RCOMP] = UBYTE_TO_FLOAT( ((s ) & 0xe0) * 255 / 0xe0 ); + texel[GCOMP] = UBYTE_TO_FLOAT( ((s << 3) & 0xe0) * 255 / 0xe0 ); + texel[BCOMP] = UBYTE_TO_FLOAT( ((s << 5) & 0xc0) * 255 / 0xc0 ); + texel[ACOMP] = CHAN_MAXF; +} + + +/* Fetch color texel from 1D, 2D or 3D a8 texture, return 4 GLchans */ static void FETCH(a8)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = 0; - rgba[GCOMP] = 0; - rgba[BCOMP] = 0; - rgba[ACOMP] = UBYTE_TO_CHAN( src[0] ); + texel[RCOMP] = 0; + texel[GCOMP] = 0; + texel[BCOMP] = 0; + texel[ACOMP] = UBYTE_TO_CHAN( src[0] ); } +/* Fetch color texel from 1D, 2D or 3D a8 texture, return 4 GLfloats */ +static void FETCH(f_a8)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = 0.0; + texel[ACOMP] = UBYTE_TO_FLOAT( src[0] ); +} + + +/* Fetch color texel from 1D, 2D or 3D l8 texture, return 4 GLchans */ static void FETCH(l8)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = UBYTE_TO_CHAN( src[0] ); - rgba[GCOMP] = UBYTE_TO_CHAN( src[0] ); - rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); - rgba[ACOMP] = CHAN_MAX; + texel[RCOMP] = UBYTE_TO_CHAN( src[0] ); + texel[GCOMP] = UBYTE_TO_CHAN( src[0] ); + texel[BCOMP] = UBYTE_TO_CHAN( src[0] ); + texel[ACOMP] = CHAN_MAX; } +/* Fetch color texel from 1D, 2D or 3D l8 texture, return 4 GLfloats */ +static void FETCH(f_l8)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = UBYTE_TO_FLOAT( src[0] ); + texel[ACOMP] = CHAN_MAXF; +} + + +/* Fetch color texel from 1D, 2D or 3D i8 texture, return 4 GLchans */ static void FETCH(i8)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) +{ + const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); + texel[RCOMP] = UBYTE_TO_CHAN( src[0] ); + texel[GCOMP] = UBYTE_TO_CHAN( src[0] ); + texel[BCOMP] = UBYTE_TO_CHAN( src[0] ); + texel[ACOMP] = UBYTE_TO_CHAN( src[0] ); +} + +/* Fetch color texel from 1D, 2D or 3D i8 texture, return 4 GLfloats */ +static void FETCH(f_i8)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) { const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = UBYTE_TO_CHAN( src[0] ); - rgba[GCOMP] = UBYTE_TO_CHAN( src[0] ); - rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); - rgba[ACOMP] = UBYTE_TO_CHAN( src[0] ); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = + texel[ACOMP] = UBYTE_TO_FLOAT( src[0] ); } + +/* Fetch color texel from 1D, 2D or 3D ci8 texture, return 1 GLchan */ static void FETCH(ci8)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); GLchan *index = (GLchan *) texel; *index = UBYTE_TO_CHAN( *src ); } + +/* Fetch color texel from 1D, 2D or 3D ci8 texture, return 1 GLfloat */ +static void FETCH(f_ci8)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); + texel[0] = UBYTE_TO_FLOAT( *src ); +} + + +/* Fetch color texel from 1D, 2D or 3D ycbcr texture, return 4 GLchans */ +/* We convert YCbCr to RGB here */ /* XXX this may break if GLchan != GLubyte */ static void FETCH(ycbcr)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLushort *src0 = USHORT_SRC( texImage, (i & ~1), j, k ); /* even */ const GLushort *src1 = src0 + 1; /* odd */ @@ -310,7 +559,6 @@ static void FETCH(ycbcr)( const struct gl_texture_image *texImage, const GLubyte cb = *src0 & 0xff; /* chroma U */ const GLubyte y1 = (*src1 >> 8) & 0xff; /* luminance */ const GLubyte cr = *src1 & 0xff; /* chroma V */ - GLchan *rgba = (GLchan *) texel; GLint r, g, b; if (i & 1) { /* odd pixel: use y1,cr,cb */ @@ -324,15 +572,53 @@ static void FETCH(ycbcr)( const struct gl_texture_image *texImage, g = (GLint) (1.164 * (y0-16) - 0.813 * (cr-128) - 0.391 * (cb-128)); b = (GLint) (1.164 * (y0-16) + 2.018 * (cb-128)); } - rgba[RCOMP] = CLAMP(r, 0, CHAN_MAX); - rgba[GCOMP] = CLAMP(g, 0, CHAN_MAX); - rgba[BCOMP] = CLAMP(b, 0, CHAN_MAX); - rgba[ACOMP] = CHAN_MAX; + texel[RCOMP] = CLAMP(r, 0, CHAN_MAX); + texel[GCOMP] = CLAMP(g, 0, CHAN_MAX); + texel[BCOMP] = CLAMP(b, 0, CHAN_MAX); + texel[ACOMP] = CHAN_MAX; } +/* Fetch color texel from 1D, 2D or 3D ycbcr texture, return 4 GLfloats */ +/* We convert YCbCr to RGB here */ +static void FETCH(f_ycbcr)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort *src0 = USHORT_SRC( texImage, (i & ~1), j, k ); /* even */ + const GLushort *src1 = src0 + 1; /* odd */ + const GLubyte y0 = (*src0 >> 8) & 0xff; /* luminance */ + const GLubyte cb = *src0 & 0xff; /* chroma U */ + const GLubyte y1 = (*src1 >> 8) & 0xff; /* luminance */ + const GLubyte cr = *src1 & 0xff; /* chroma V */ + GLfloat r, g, b; + if (i & 1) { + /* odd pixel: use y1,cr,cb */ + r = (1.164 * (y1-16) + 1.596 * (cr-128)); + g = (1.164 * (y1-16) - 0.813 * (cr-128) - 0.391 * (cb-128)); + b = (1.164 * (y1-16) + 2.018 * (cb-128)); + } + else { + /* even pixel: use y0,cr,cb */ + r = (1.164 * (y0-16) + 1.596 * (cr-128)); + g = (1.164 * (y0-16) - 0.813 * (cr-128) - 0.391 * (cb-128)); + b = (1.164 * (y0-16) + 2.018 * (cb-128)); + } + /* XXX remove / 255 here by tweaking arithmetic above */ + r /= 255.0; + g /= 255.0; + b /= 255.0; + /* XXX should we really clamp??? */ + texel[RCOMP] = CLAMP(r, 0.0, 1.0); + texel[GCOMP] = CLAMP(g, 0.0, 1.0); + texel[BCOMP] = CLAMP(b, 0.0, 1.0); + texel[ACOMP] = CHAN_MAXF; +} + + +/* Fetch color texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLchans */ +/* We convert YCbCr to RGB here */ /* XXX this may break if GLchan != GLubyte */ static void FETCH(ycbcr_rev)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLushort *src0 = USHORT_SRC( texImage, (i & ~1), j, k ); /* even */ const GLushort *src1 = src0 + 1; /* odd */ @@ -340,7 +626,6 @@ static void FETCH(ycbcr_rev)( const struct gl_texture_image *texImage, const GLubyte cr = (*src0 >> 8) & 0xff; /* chroma V */ const GLubyte y1 = *src1 & 0xff; /* luminance */ const GLubyte cb = (*src1 >> 8) & 0xff; /* chroma U */ - GLchan *rgba = (GLchan *) texel; GLint r, g, b; if (i & 1) { /* odd pixel: use y1,cr,cb */ @@ -354,72 +639,155 @@ static void FETCH(ycbcr_rev)( const struct gl_texture_image *texImage, g = (GLint) (1.164 * (y0-16) - 0.813 * (cr-128) - 0.391 * (cb-128)); b = (GLint) (1.164 * (y0-16) + 2.018 * (cb-128)); } - rgba[RCOMP] = CLAMP(r, 0, CHAN_MAX); - rgba[GCOMP] = CLAMP(g, 0, CHAN_MAX); - rgba[BCOMP] = CLAMP(b, 0, CHAN_MAX); - rgba[ACOMP] = CHAN_MAX; + texel[RCOMP] = CLAMP(r, 0, CHAN_MAX); + texel[GCOMP] = CLAMP(g, 0, CHAN_MAX); + texel[BCOMP] = CLAMP(b, 0, CHAN_MAX); + texel[ACOMP] = CHAN_MAX; +} + +/* Fetch color texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLfloats */ +/* We convert YCbCr to RGB here */ +/* XXX this may break if GLchan != GLubyte */ +static void FETCH(f_ycbcr_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort *src0 = USHORT_SRC( texImage, (i & ~1), j, k ); /* even */ + const GLushort *src1 = src0 + 1; /* odd */ + const GLubyte y0 = *src0 & 0xff; /* luminance */ + const GLubyte cr = (*src0 >> 8) & 0xff; /* chroma V */ + const GLubyte y1 = *src1 & 0xff; /* luminance */ + const GLubyte cb = (*src1 >> 8) & 0xff; /* chroma U */ + GLfloat r, g, b; + if (i & 1) { + /* odd pixel: use y1,cr,cb */ + r = (1.164 * (y1-16) + 1.596 * (cr-128)); + g = (1.164 * (y1-16) - 0.813 * (cr-128) - 0.391 * (cb-128)); + b = (1.164 * (y1-16) + 2.018 * (cb-128)); + } + else { + /* even pixel: use y0,cr,cb */ + r = (1.164 * (y0-16) + 1.596 * (cr-128)); + g = (1.164 * (y0-16) - 0.813 * (cr-128) - 0.391 * (cb-128)); + b = (1.164 * (y0-16) + 2.018 * (cb-128)); + } + /* XXX remove / 255 here by tweaking arithmetic above */ + r /= 255.0; + g /= 255.0; + b /= 255.0; + /* XXX should we really clamp??? */ + texel[RCOMP] = CLAMP(r, 0.0, 1.0); + texel[GCOMP] = CLAMP(g, 0.0, 1.0); + texel[BCOMP] = CLAMP(b, 0.0, 1.0); + texel[ACOMP] = CHAN_MAXF; } -#if DIM == 2 +#if DIM == 2 /* Only 2D compressed textures possible */ + static void FETCH(rgb_fxt1)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) +{ + /* Extract the (i,j) pixel from texImage->Data and return it + * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. + */ +} + +static void FETCH(f_rgb_fxt1)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) { /* Extract the (i,j) pixel from texImage->Data and return it * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. */ } -#endif -#if DIM == 2 static void FETCH(rgba_fxt1)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { /* Extract the (i,j) pixel from texImage->Data and return it * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. */ } -#endif +static void FETCH(f_rgba_fxt1)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + /* Extract the (i,j) pixel from texImage->Data and return it + * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. + */ +} + +#endif /* if DIM == 2 */ + + +#if DIM == 2 /* only 2D is valid */ -#if DIM == 2 static void FETCH(rgb_dxt1)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { /* Extract the (i,j) pixel from texImage->Data and return it * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. */ } -#endif -#if DIM == 2 +static void FETCH(f_rgb_dxt1)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + /* Extract the (i,j) pixel from texImage->Data and return it + * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. + */ +} + + static void FETCH(rgba_dxt1)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { /* Extract the (i,j) pixel from texImage->Data and return it * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. */ } -#endif -#if DIM == 2 +static void FETCH(f_rgba_dxt1)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + /* Extract the (i,j) pixel from texImage->Data and return it + * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. + */ +} + + static void FETCH(rgba_dxt3)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { /* Extract the (i,j) pixel from texImage->Data and return it * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. */ } -#endif -#if DIM == 2 +static void FETCH(f_rgba_dxt3)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + /* Extract the (i,j) pixel from texImage->Data and return it + * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. + */ +} + + static void FETCH(rgba_dxt5)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { /* Extract the (i,j) pixel from texImage->Data and return it * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. */ } + +static void FETCH(f_rgba_dxt5)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + /* Extract the (i,j) pixel from texImage->Data and return it + * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. + */ +} + #endif @@ -428,95 +796,87 @@ static void FETCH(rgba_dxt5)( const struct gl_texture_image *texImage, #if 0 static void FETCH(abgr8888)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = UBYTE_TO_CHAN( src[3] ); - rgba[GCOMP] = UBYTE_TO_CHAN( src[2] ); - rgba[BCOMP] = UBYTE_TO_CHAN( src[1] ); - rgba[ACOMP] = UBYTE_TO_CHAN( src[0] ); + texel[RCOMP] = UBYTE_TO_CHAN( src[3] ); + texel[GCOMP] = UBYTE_TO_CHAN( src[2] ); + texel[BCOMP] = UBYTE_TO_CHAN( src[1] ); + texel[ACOMP] = UBYTE_TO_CHAN( src[0] ); } static void FETCH(bgra8888)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = UBYTE_TO_CHAN( src[2] ); - rgba[GCOMP] = UBYTE_TO_CHAN( src[1] ); - rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); - rgba[ACOMP] = UBYTE_TO_CHAN( src[3] ); + texel[RCOMP] = UBYTE_TO_CHAN( src[2] ); + texel[GCOMP] = UBYTE_TO_CHAN( src[1] ); + texel[BCOMP] = UBYTE_TO_CHAN( src[0] ); + texel[ACOMP] = UBYTE_TO_CHAN( src[3] ); } static void FETCH(bgr888)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 3 ); - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = UBYTE_TO_CHAN( src[2] ); - rgba[GCOMP] = UBYTE_TO_CHAN( src[1] ); - rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); - rgba[ACOMP] = CHAN_MAX; + texel[RCOMP] = UBYTE_TO_CHAN( src[2] ); + texel[GCOMP] = UBYTE_TO_CHAN( src[1] ); + texel[BCOMP] = UBYTE_TO_CHAN( src[0] ); + texel[ACOMP] = CHAN_MAX; } static void FETCH(bgr565)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLushort *src = USHORT_SRC( texImage, i, j, k ); const GLushort s = *src; - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 ); - rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc ); - rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) * 255 / 0xf8 ); - rgba[ACOMP] = CHAN_MAX; + texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 ); + texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc ); + texel[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) * 255 / 0xf8 ); + texel[ACOMP] = CHAN_MAX; } static void FETCH(bgra4444)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLushort *src = USHORT_SRC( texImage, i, j, k ); const GLushort s = *src; - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) * 255 / 0xf ); - rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) * 255 / 0xf ); - rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) * 255 / 0xf ); - rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf ); + texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) * 255 / 0xf ); + texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) * 255 / 0xf ); + texel[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) * 255 / 0xf ); + texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf ); } static void FETCH(bgra5551)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLushort *src = USHORT_SRC( texImage, i, j, k ); const GLushort s = *src; - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 10) & 0x1f) * 255 / 0x1f ); - rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 0x1f) * 255 / 0x1f ); - rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0x1f) * 255 / 0x1f ); - rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 ); + texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 10) & 0x1f) * 255 / 0x1f ); + texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 0x1f) * 255 / 0x1f ); + texel[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0x1f) * 255 / 0x1f ); + texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 ); } static void FETCH(la88)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 2 ); - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = UBYTE_TO_CHAN( src[0] ); - rgba[GCOMP] = UBYTE_TO_CHAN( src[0] ); - rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); - rgba[ACOMP] = UBYTE_TO_CHAN( src[1] ); + texel[RCOMP] = UBYTE_TO_CHAN( src[0] ); + texel[GCOMP] = UBYTE_TO_CHAN( src[0] ); + texel[BCOMP] = UBYTE_TO_CHAN( src[0] ); + texel[ACOMP] = UBYTE_TO_CHAN( src[1] ); } static void FETCH(bgr233)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); const GLubyte s = *src; - GLchan *rgba = (GLchan *) texel; - rgba[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xe0) * 255 / 0xe0 ); - rgba[GCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xe0) * 255 / 0xe0 ); - rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 5) & 0xc0) * 255 / 0xc0 ); - rgba[ACOMP] = CHAN_MAX; + texel[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xe0) * 255 / 0xe0 ); + texel[GCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xe0) * 255 / 0xe0 ); + texel[BCOMP] = UBYTE_TO_CHAN( ((s << 5) & 0xc0) * 255 / 0xc0 ); + texel[ACOMP] = CHAN_MAX; } #endif diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 96b5038111a..3833b2681e6 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.0 + * Version: 6.1 * * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. * @@ -904,7 +904,8 @@ clear_teximage_fields(struct gl_texture_image *img) img->DepthLog2 = 0; img->Data = NULL; img->TexFormat = &_mesa_null_texformat; - img->FetchTexel = NULL; + img->FetchTexelc = NULL; + img->FetchTexelf = NULL; img->IsCompressed = 0; img->CompressedSize = 0; } @@ -1875,8 +1876,9 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format, GLuint indexRow[MAX_WIDTH]; GLint col; for (col = 0; col < width; col++) { - (*texImage->FetchTexel)(texImage, col, row, img, - (GLvoid *) &indexRow[col]); + GLchan indx; + (*texImage->FetchTexelc)(texImage, col, row, img, &indx); + indexRow[col] = indx; } _mesa_pack_index_span(ctx, width, type, dest, indexRow, &ctx->Pack, @@ -1886,8 +1888,8 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format, GLfloat depthRow[MAX_WIDTH]; GLint col; for (col = 0; col < width; col++) { - (*texImage->FetchTexel)(texImage, col, row, img, - (GLvoid *) &depthRow[col]); + (*texImage->FetchTexelf)(texImage, col, row, img, + (GLvoid *) &depthRow[col]); } _mesa_pack_depth_span(ctx, width, dest, type, depthRow, &ctx->Pack); @@ -1915,8 +1917,7 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format, GLchan rgba[MAX_WIDTH][4]; GLint col; for (col = 0; col < width; col++) { - (*texImage->FetchTexel)(texImage, col, row, img, - (GLvoid *) rgba[col]); + (*texImage->FetchTexelc)(texImage, col, row, img, rgba[col]); } _mesa_pack_rgba_span(ctx, width, (const GLchan (*)[4])rgba, format, type, dest, &ctx->Pack, @@ -1984,11 +1985,14 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat, &ctx->Unpack, texObj, texImage); ASSERT(texImage->TexFormat); - if (!texImage->FetchTexel) { - /* If driver didn't explicitly set this, use the default */ - texImage->FetchTexel = texImage->TexFormat->FetchTexel1D; - } - ASSERT(texImage->FetchTexel); + + /* If driver didn't explicitly set this, use the defaults */ + if (!texImage->FetchTexelc) + texImage->FetchTexelc = texImage->TexFormat->FetchTexel1D; + if (!texImage->FetchTexelf) + texImage->FetchTexelf = texImage->TexFormat->FetchTexel1Df; + ASSERT(texImage->FetchTexelc); + ASSERT(texImage->FetchTexelf); /* state update */ texObj->Complete = GL_FALSE; @@ -2081,11 +2085,14 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat, &ctx->Unpack, texObj, texImage); ASSERT(texImage->TexFormat); - if (!texImage->FetchTexel) { - /* If driver didn't explicitly set this, use the default */ - texImage->FetchTexel = texImage->TexFormat->FetchTexel2D; - } - ASSERT(texImage->FetchTexel); + + /* If driver didn't explicitly set these, use the defaults */ + if (!texImage->FetchTexelc) + texImage->FetchTexelc = texImage->TexFormat->FetchTexel2D; + if (!texImage->FetchTexelf) + texImage->FetchTexelf = texImage->TexFormat->FetchTexel2Df; + ASSERT(texImage->FetchTexelc); + ASSERT(texImage->FetchTexelf); /* state update */ texObj->Complete = GL_FALSE; @@ -2172,11 +2179,14 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat, pixels, &ctx->Unpack, texObj, texImage); ASSERT(texImage->TexFormat); - if (!texImage->FetchTexel) { - /* If driver didn't explicitly set this, use the default */ - texImage->FetchTexel = texImage->TexFormat->FetchTexel3D; - } - ASSERT(texImage->FetchTexel); + + /* If driver didn't explicitly set these, use the defaults */ + if (!texImage->FetchTexelc) + texImage->FetchTexelc = texImage->TexFormat->FetchTexel3D; + if (!texImage->FetchTexelf) + texImage->FetchTexelf = texImage->TexFormat->FetchTexel3Df; + ASSERT(texImage->FetchTexelc); + ASSERT(texImage->FetchTexelf); /* state update */ texObj->Complete = GL_FALSE; @@ -2405,11 +2415,14 @@ _mesa_CopyTexImage1D( GLenum target, GLint level, x, y, width, border); ASSERT(texImage->TexFormat); - if (!texImage->FetchTexel) { - /* If driver didn't explicitly set this, use the default */ - texImage->FetchTexel = texImage->TexFormat->FetchTexel1D; - } - ASSERT(texImage->FetchTexel); + + /* If driver didn't explicitly set these, use the defaults */ + if (!texImage->FetchTexelc) + texImage->FetchTexelc = texImage->TexFormat->FetchTexel1D; + if (!texImage->FetchTexelf) + texImage->FetchTexelf = texImage->TexFormat->FetchTexel1Df; + ASSERT(texImage->FetchTexelc); + ASSERT(texImage->FetchTexelf); /* state update */ texObj->Complete = GL_FALSE; @@ -2465,11 +2478,14 @@ _mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat, x, y, width, height, border); ASSERT(texImage->TexFormat); - if (!texImage->FetchTexel) { - /* If driver didn't explicitly set this, use the default */ - texImage->FetchTexel = texImage->TexFormat->FetchTexel2D; - } - ASSERT(texImage->FetchTexel); + + /* If driver didn't explicitly set these, use the defaults */ + if (!texImage->FetchTexelc) + texImage->FetchTexelc = texImage->TexFormat->FetchTexel2D; + if (!texImage->FetchTexelf) + texImage->FetchTexelf = texImage->TexFormat->FetchTexel2Df; + ASSERT(texImage->FetchTexelc); + ASSERT(texImage->FetchTexelf); /* state update */ texObj->Complete = GL_FALSE; diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 899201e6c4a..db51aebc9a9 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 5.1 + * Version: 6.1 * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2004 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"), @@ -770,7 +770,8 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level, texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx, internalFormat, format, type); assert(texImage->TexFormat); - texImage->FetchTexel = texImage->TexFormat->FetchTexel1D; + texImage->FetchTexelc = texImage->TexFormat->FetchTexel1D; + texImage->FetchTexelf = texImage->TexFormat->FetchTexel1Df; texelBytes = texImage->TexFormat->TexelBytes; @@ -846,7 +847,8 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level, texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx, internalFormat, format, type); assert(texImage->TexFormat); - texImage->FetchTexel = texImage->TexFormat->FetchTexel2D; + texImage->FetchTexelc = texImage->TexFormat->FetchTexel2D; + texImage->FetchTexelf = texImage->TexFormat->FetchTexel2Df; texelBytes = texImage->TexFormat->TexelBytes; @@ -917,7 +919,8 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level, texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx, internalFormat, format, type); assert(texImage->TexFormat); - texImage->FetchTexel = texImage->TexFormat->FetchTexel3D; + texImage->FetchTexelc = texImage->TexFormat->FetchTexel3D; + texImage->FetchTexelf = texImage->TexFormat->FetchTexel3Df; texelBytes = texImage->TexFormat->TexelBytes; @@ -1155,7 +1158,8 @@ _mesa_store_compressed_teximage2d(GLcontext *ctx, GLenum target, GLint level, texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx, internalFormat, 0, 0); assert(texImage->TexFormat); - texImage->FetchTexel = texImage->TexFormat->FetchTexel2D; + texImage->FetchTexelc = texImage->TexFormat->FetchTexel2D; + texImage->FetchTexelf = texImage->TexFormat->FetchTexel2Df; /* allocate storage */ texImage->Data = MESA_PBUFFER_ALLOC(imageSize); @@ -1919,7 +1923,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target, for (row = 0; row < srcImage->Height; row++) { GLuint col; for (col = 0; col < srcImage->Width; col++) { - (*srcImage->FetchTexel)(srcImage, col, row, 0, (GLvoid *) dst); + srcImage->FetchTexelc(srcImage, col, row, 0, dst); dst += components; } } @@ -1993,9 +1997,11 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target, dstDepth, border, srcImage->IntFormat); dstImage->DriverData = NULL; dstImage->TexFormat = srcImage->TexFormat; - dstImage->FetchTexel = srcImage->FetchTexel; + dstImage->FetchTexelc = srcImage->FetchTexelc; + dstImage->FetchTexelf = srcImage->FetchTexelf; ASSERT(dstImage->TexFormat); - ASSERT(dstImage->FetchTexel); + ASSERT(dstImage->FetchTexelc); + ASSERT(dstImage->FetchTexelf); /* Alloc new teximage data buffer. * Setup src and dest data pointers. |