/*
* Mesa 3-D graphics library
- * Version: 7.7
*
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
* Copyright (c) 2009 VMware, Inc.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
*/
#define DIM 3
#include "s_texfetch_tmp.h"
+
+/**
+ * All compressed texture texel fetching is done though this function.
+ * Basically just call a core-Mesa texel fetch function.
+ */
+static void
+fetch_compressed(const struct swrast_texture_image *swImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ /* The FetchCompressedTexel function takes an integer pixel rowstride,
+ * while the image's rowstride is bytes per row of blocks.
+ */
+ GLuint bw, bh;
+ GLuint texelBytes = _mesa_get_format_bytes(swImage->Base.TexFormat);
+ _mesa_get_format_block_size(swImage->Base.TexFormat, &bw, &bh);
+ assert(swImage->RowStride * bw % texelBytes == 0);
+
+ swImage->FetchCompressedTexel(swImage->ImageSlices[k],
+ swImage->RowStride * bw / texelBytes,
+ i, j, texel);
+}
+
+
+
/**
* Null texel fetch function.
*
fetch_texel_3d_f_r16
},
{
- MESA_FORMAT_RG1616,
+ MESA_FORMAT_GR1616,
fetch_texel_1d_f_rg1616,
fetch_texel_2d_f_rg1616,
fetch_texel_3d_f_rg1616
},
{
- MESA_FORMAT_RG1616_REV,
+ MESA_FORMAT_RG1616,
fetch_texel_1d_f_rg1616_rev,
fetch_texel_2d_f_rg1616_rev,
fetch_texel_3d_f_rg1616_rev
},
{
MESA_FORMAT_SRGB_DXT1,
- _mesa_fetch_texel_srgb_dxt1,
- _mesa_fetch_texel_srgb_dxt1,
- _mesa_fetch_texel_srgb_dxt1
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_SRGBA_DXT1,
- _mesa_fetch_texel_srgba_dxt1,
- _mesa_fetch_texel_srgba_dxt1,
- _mesa_fetch_texel_srgba_dxt1
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_SRGBA_DXT3,
- _mesa_fetch_texel_srgba_dxt3,
- _mesa_fetch_texel_srgba_dxt3,
- _mesa_fetch_texel_srgba_dxt3
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_SRGBA_DXT5,
- _mesa_fetch_texel_srgba_dxt5,
- _mesa_fetch_texel_srgba_dxt5,
- _mesa_fetch_texel_srgba_dxt5
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_RGB_FXT1,
- NULL,
- _mesa_fetch_texel_2d_f_rgb_fxt1,
- NULL
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_RGBA_FXT1,
- NULL,
- _mesa_fetch_texel_2d_f_rgba_fxt1,
- NULL
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_RGB_DXT1,
- _mesa_fetch_texel_rgb_dxt1,
- _mesa_fetch_texel_rgb_dxt1,
- _mesa_fetch_texel_rgb_dxt1
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_RGBA_DXT1,
- _mesa_fetch_texel_rgba_dxt1,
- _mesa_fetch_texel_rgba_dxt1,
- _mesa_fetch_texel_rgba_dxt1
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_RGBA_DXT3,
- _mesa_fetch_texel_rgba_dxt3,
- _mesa_fetch_texel_rgba_dxt3,
- _mesa_fetch_texel_rgba_dxt3
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_RGBA_DXT5,
- _mesa_fetch_texel_rgba_dxt5,
- _mesa_fetch_texel_rgba_dxt5,
- _mesa_fetch_texel_rgba_dxt5
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_RGBA_FLOAT32,
},
{
MESA_FORMAT_RED_RGTC1,
- _mesa_fetch_texel_red_rgtc1,
- _mesa_fetch_texel_red_rgtc1,
- _mesa_fetch_texel_red_rgtc1
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_SIGNED_RED_RGTC1,
- _mesa_fetch_texel_signed_red_rgtc1,
- _mesa_fetch_texel_signed_red_rgtc1,
- _mesa_fetch_texel_signed_red_rgtc1
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_RG_RGTC2,
- _mesa_fetch_texel_rg_rgtc2,
- _mesa_fetch_texel_rg_rgtc2,
- _mesa_fetch_texel_rg_rgtc2
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_SIGNED_RG_RGTC2,
- _mesa_fetch_texel_signed_rg_rgtc2,
- _mesa_fetch_texel_signed_rg_rgtc2,
- _mesa_fetch_texel_signed_rg_rgtc2
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_L_LATC1,
- _mesa_fetch_texel_l_latc1,
- _mesa_fetch_texel_l_latc1,
- _mesa_fetch_texel_l_latc1
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_SIGNED_L_LATC1,
- _mesa_fetch_texel_signed_l_latc1,
- _mesa_fetch_texel_signed_l_latc1,
- _mesa_fetch_texel_signed_l_latc1
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_LA_LATC2,
- _mesa_fetch_texel_la_latc2,
- _mesa_fetch_texel_la_latc2,
- _mesa_fetch_texel_la_latc2
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_SIGNED_LA_LATC2,
- _mesa_fetch_texel_signed_la_latc2,
- _mesa_fetch_texel_signed_la_latc2,
- _mesa_fetch_texel_signed_la_latc2
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_ETC1_RGB8,
- NULL,
- _mesa_fetch_texel_2d_f_etc1_rgb8,
- NULL
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
+ },
+ {
+ MESA_FORMAT_ETC2_RGB8,
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
+ },
+ {
+ MESA_FORMAT_ETC2_SRGB8,
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
+ },
+ {
+ MESA_FORMAT_ETC2_RGBA8_EAC,
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
+ },
+ {
+ MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC,
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
+ },
+ {
+ MESA_FORMAT_ETC2_R11_EAC,
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
+ },
+ {
+ MESA_FORMAT_ETC2_RG11_EAC,
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
+ },
+ {
+ MESA_FORMAT_ETC2_SIGNED_R11_EAC,
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
+ },
+ {
+ MESA_FORMAT_ETC2_SIGNED_RG11_EAC,
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
+ },
+ {
+ MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1,
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
+ },
+ {
+ MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1,
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_SIGNED_A8,
NULL,
NULL
},
+ {
+ MESA_FORMAT_XRGB4444_UNORM,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_XRGB1555_UNORM,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_XBGR8888_SNORM,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_XBGR8888_SRGB,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_XBGR8888_UINT,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_XBGR8888_SINT,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_XRGB2101010_UNORM,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_XBGR16161616_UNORM,
+ fetch_texel_1d_xbgr16161616_unorm,
+ fetch_texel_2d_xbgr16161616_unorm,
+ fetch_texel_3d_xbgr16161616_unorm
+ },
+ {
+ MESA_FORMAT_XBGR16161616_SNORM,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_XBGR16161616_FLOAT,
+ fetch_texel_1d_xbgr16161616_float,
+ fetch_texel_2d_xbgr16161616_float,
+ fetch_texel_3d_xbgr16161616_float
+ },
+ {
+ MESA_FORMAT_XBGR16161616_UINT,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_XBGR16161616_SINT,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_XBGR32323232_FLOAT,
+ fetch_texel_1d_xbgr32323232_float,
+ fetch_texel_2d_xbgr32323232_float,
+ fetch_texel_3d_xbgr32323232_float
+ },
+ {
+ MESA_FORMAT_XBGR32323232_UINT,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_XBGR32323232_SINT,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_ABGR2101010,
+ NULL,
+ NULL,
+ NULL
+ },
};
-FetchTexelFunc
-_mesa_get_texel_fetch_func(gl_format format, GLuint dims)
+/**
+ * Initialize the texture image's FetchTexel methods.
+ */
+static void
+set_fetch_functions(const struct gl_sampler_object *samp,
+ struct swrast_texture_image *texImage, GLuint dims)
{
+ gl_format format = texImage->Base.TexFormat;
+
#ifdef DEBUG
/* check that the table entries are sorted by format name */
gl_format fmt;
STATIC_ASSERT(Elements(texfetch_funcs) == MESA_FORMAT_COUNT);
+ if (samp->sRGBDecode == GL_SKIP_DECODE_EXT &&
+ _mesa_get_format_color_encoding(format) == GL_SRGB) {
+ format = _mesa_get_srgb_format_linear(format);
+ }
+
assert(format < MESA_FORMAT_COUNT);
switch (dims) {
case 1:
- return texfetch_funcs[format].Fetch1D;
+ texImage->FetchTexel = texfetch_funcs[format].Fetch1D;
+ break;
case 2:
- return texfetch_funcs[format].Fetch2D;
+ texImage->FetchTexel = texfetch_funcs[format].Fetch2D;
+ break;
case 3:
- return texfetch_funcs[format].Fetch3D;
+ texImage->FetchTexel = texfetch_funcs[format].Fetch3D;
+ break;
default:
- assert(0 && "bad dims in _mesa_get_texel_fetch_func");
- return NULL;
+ assert(!"Bad dims in set_fetch_functions()");
}
-}
-
-
-/**
- * Initialize the texture image's FetchTexel methods.
- */
-static void
-set_fetch_functions(struct gl_sampler_object *samp,
- struct swrast_texture_image *texImage, GLuint dims)
-{
- gl_format format = texImage->Base.TexFormat;
-
- ASSERT(dims == 1 || dims == 2 || dims == 3);
- if (samp->sRGBDecode == GL_SKIP_DECODE_EXT &&
- _mesa_get_format_color_encoding(format) == GL_SRGB) {
- format = _mesa_get_srgb_format_linear(format);
- }
+ texImage->FetchCompressedTexel = _mesa_get_compressed_fetch_func(format);
- texImage->FetchTexel = _mesa_get_texel_fetch_func(format, dims);
ASSERT(texImage->FetchTexel);
}