aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src')
-rw-r--r--mesalib/src/SConscript2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_blitter.c44
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_blitter.h6
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_clear.h118
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_surface.c4
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_surface.h180
-rw-r--r--mesalib/src/mesa/SConscript2
-rw-r--r--mesalib/src/mesa/drivers/common/driverfuncs.c6
-rw-r--r--mesalib/src/mesa/drivers/common/meta.c6
-rw-r--r--mesalib/src/mesa/main/dd.h10
-rw-r--r--mesalib/src/mesa/main/format_unpack.c8
-rw-r--r--mesalib/src/mesa/main/mipmap.c20
-rw-r--r--mesalib/src/mesa/main/mtypes.h34
-rw-r--r--mesalib/src/mesa/main/texcompress.c9
-rw-r--r--mesalib/src/mesa/main/texcompress_fxt1.c3303
-rw-r--r--mesalib/src/mesa/main/texcompress_fxt1.h124
-rw-r--r--mesalib/src/mesa/main/texcompress_rgtc.c922
-rw-r--r--mesalib/src/mesa/main/texcompress_rgtc.h18
-rw-r--r--mesalib/src/mesa/main/texcompress_s3tc.c39
-rw-r--r--mesalib/src/mesa/main/texcompress_s3tc.h220
-rw-r--r--mesalib/src/mesa/main/teximage.c12
-rw-r--r--mesalib/src/mesa/main/texobj.c2
-rw-r--r--mesalib/src/mesa/main/texparam.c2
-rw-r--r--mesalib/src/mesa/main/texstore.c46
-rw-r--r--mesalib/src/mesa/sources.mak2
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_clear.c22
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_texture.c15
-rw-r--r--mesalib/src/mesa/state_tracker/st_format.h1
-rw-r--r--mesalib/src/mesa/swrast/s_context.c8
-rw-r--r--mesalib/src/mesa/swrast/s_context.h67
-rw-r--r--mesalib/src/mesa/swrast/s_texfetch.c (renamed from mesalib/src/mesa/main/texfetch.c)46
-rw-r--r--mesalib/src/mesa/swrast/s_texfetch.h (renamed from mesalib/src/mesa/main/texfetch.h)86
-rw-r--r--mesalib/src/mesa/swrast/s_texfetch_tmp.h (renamed from mesalib/src/mesa/main/texfetch_tmp.h)378
-rw-r--r--mesalib/src/mesa/swrast/s_texfilter.c92
-rw-r--r--mesalib/src/mesa/swrast/s_texrender.c31
-rw-r--r--mesalib/src/mesa/swrast/s_texture.c65
-rw-r--r--mesalib/src/mesa/swrast/swrast.h17
37 files changed, 3051 insertions, 2916 deletions
diff --git a/mesalib/src/SConscript b/mesalib/src/SConscript
index 87e244403..1eee8761a 100644
--- a/mesalib/src/SConscript
+++ b/mesalib/src/SConscript
@@ -21,7 +21,7 @@ SConscript('mesa/SConscript')
SConscript('mapi/vgapi/SConscript')
-if env['platform'] != 'embedded':
+if not env['embedded']:
SConscript('glx/SConscript')
SConscript('egl/main/SConscript')
SConscript('glu/sgi/SConscript')
diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.c b/mesalib/src/gallium/auxiliary/util/u_blitter.c
index d69fb1a11..58a52b3f2 100644
--- a/mesalib/src/gallium/auxiliary/util/u_blitter.c
+++ b/mesalib/src/gallium/auxiliary/util/u_blitter.c
@@ -111,7 +111,7 @@ static void blitter_draw_rectangle(struct blitter_context *blitter,
unsigned width, unsigned height,
float depth,
enum blitter_attrib_type type,
- const float attrib[4]);
+ const union pipe_color_union *attrib);
struct blitter_context *util_blitter_create(struct pipe_context *pipe)
@@ -398,16 +398,16 @@ static void blitter_set_rectangle(struct blitter_context_priv *ctx,
}
static void blitter_set_clear_color(struct blitter_context_priv *ctx,
- const float *rgba)
+ const union pipe_color_union *color)
{
int i;
- if (rgba) {
+ if (color) {
for (i = 0; i < 4; i++) {
- ctx->vertices[i][1][0] = rgba[0];
- ctx->vertices[i][1][1] = rgba[1];
- ctx->vertices[i][1][2] = rgba[2];
- ctx->vertices[i][1][3] = rgba[3];
+ ctx->vertices[i][1][0] = color->f[0];
+ ctx->vertices[i][1][1] = color->f[1];
+ ctx->vertices[i][1][2] = color->f[2];
+ ctx->vertices[i][1][3] = color->f[3];
}
} else {
for (i = 0; i < 4; i++) {
@@ -647,7 +647,7 @@ static void blitter_draw_rectangle(struct blitter_context *blitter,
unsigned x2, unsigned y2,
float depth,
enum blitter_attrib_type type,
- const float attrib[4])
+ const union pipe_color_union *attrib)
{
struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
@@ -657,7 +657,7 @@ static void blitter_draw_rectangle(struct blitter_context *blitter,
break;
case UTIL_BLITTER_ATTRIB_TEXCOORD:
- set_texcoords_in_vertices(attrib, &ctx->vertices[0][1][0], 8);
+ set_texcoords_in_vertices(attrib->f, &ctx->vertices[0][1][0], 8);
break;
default:;
@@ -674,7 +674,7 @@ static void util_blitter_clear_custom(struct blitter_context *blitter,
unsigned width, unsigned height,
unsigned num_cbufs,
unsigned clear_buffers,
- const float *rgba,
+ const union pipe_color_union *color,
double depth, unsigned stencil,
void *custom_blend, void *custom_dsa)
{
@@ -717,7 +717,7 @@ static void util_blitter_clear_custom(struct blitter_context *blitter,
blitter_set_dst_dimensions(ctx, width, height);
blitter->draw_rectangle(blitter, 0, 0, width, height, depth,
- UTIL_BLITTER_ATTRIB_COLOR, rgba);
+ UTIL_BLITTER_ATTRIB_COLOR, color);
blitter_restore_CSOs(ctx);
}
@@ -725,11 +725,11 @@ void util_blitter_clear(struct blitter_context *blitter,
unsigned width, unsigned height,
unsigned num_cbufs,
unsigned clear_buffers,
- const float *rgba,
+ const union pipe_color_union *color,
double depth, unsigned stencil)
{
util_blitter_clear_custom(blitter, width, height, num_cbufs,
- clear_buffers, rgba, depth, stencil,
+ clear_buffers, color, depth, stencil,
NULL, NULL);
}
@@ -737,9 +737,9 @@ void util_blitter_clear_depth_custom(struct blitter_context *blitter,
unsigned width, unsigned height,
double depth, void *custom_dsa)
{
- const float rgba[4] = {0, 0, 0, 0};
+ static const union pipe_color_union color;
util_blitter_clear_custom(blitter, width, height, 0,
- 0, rgba, depth, 0, NULL, custom_dsa);
+ 0, &color, depth, 0, NULL, custom_dsa);
}
static
@@ -869,14 +869,16 @@ void util_blitter_copy_texture(struct blitter_context *blitter,
case PIPE_TEXTURE_2D:
case PIPE_TEXTURE_RECT:
{
- /* Set texture coordinates. */
- float coord[4];
+ /* Set texture coordinates. - use a pipe color union
+ * for interface purposes
+ */
+ union pipe_color_union coord;
get_texcoords(src, srclevel, srcbox->x, srcbox->y,
- srcbox->x+width, srcbox->y+height, normalized, coord);
+ srcbox->x+width, srcbox->y+height, normalized, coord.f);
/* Draw. */
blitter->draw_rectangle(blitter, dstx, dsty, dstx+width, dsty+height, 0,
- UTIL_BLITTER_ATTRIB_TEXCOORD, coord);
+ UTIL_BLITTER_ATTRIB_TEXCOORD, &coord);
}
break;
@@ -925,7 +927,7 @@ void util_blitter_copy_texture(struct blitter_context *blitter,
/* Clear a region of a color surface to a constant value. */
void util_blitter_clear_render_target(struct blitter_context *blitter,
struct pipe_surface *dstsurf,
- const float *rgba,
+ const union pipe_color_union *color,
unsigned dstx, unsigned dsty,
unsigned width, unsigned height)
{
@@ -959,7 +961,7 @@ void util_blitter_clear_render_target(struct blitter_context *blitter,
blitter_set_dst_dimensions(ctx, dstsurf->width, dstsurf->height);
blitter->draw_rectangle(blitter, dstx, dsty, dstx+width, dsty+height, 0,
- UTIL_BLITTER_ATTRIB_COLOR, rgba);
+ UTIL_BLITTER_ATTRIB_COLOR, color);
blitter_restore_CSOs(ctx);
}
diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.h b/mesalib/src/gallium/auxiliary/util/u_blitter.h
index df6f023a6..a9ad02364 100644
--- a/mesalib/src/gallium/auxiliary/util/u_blitter.h
+++ b/mesalib/src/gallium/auxiliary/util/u_blitter.h
@@ -77,7 +77,7 @@ struct blitter_context
unsigned x1, unsigned y1, unsigned x2, unsigned y2,
float depth,
enum blitter_attrib_type type,
- const float attrib[4]);
+ const union pipe_color_union *color);
/* Whether the blitter is running. */
boolean running;
@@ -144,7 +144,7 @@ void util_blitter_clear(struct blitter_context *blitter,
unsigned width, unsigned height,
unsigned num_cbufs,
unsigned clear_buffers,
- const float *rgba,
+ const union pipe_color_union *color,
double depth, unsigned stencil);
void util_blitter_clear_depth_custom(struct blitter_context *blitter,
@@ -190,7 +190,7 @@ void util_blitter_copy_texture(struct blitter_context *blitter,
*/
void util_blitter_clear_render_target(struct blitter_context *blitter,
struct pipe_surface *dst,
- const float *rgba,
+ const union pipe_color_union *color,
unsigned dstx, unsigned dsty,
unsigned width, unsigned height);
diff --git a/mesalib/src/gallium/auxiliary/util/u_clear.h b/mesalib/src/gallium/auxiliary/util/u_clear.h
index c2f303261..e9fd874b1 100644
--- a/mesalib/src/gallium/auxiliary/util/u_clear.h
+++ b/mesalib/src/gallium/auxiliary/util/u_clear.h
@@ -1,59 +1,59 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc. 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"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * 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 NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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.
- *
- **************************************************************************/
-
-/* Authors:
- * Michel Dänzer
- */
-
-
-#include "pipe/p_context.h"
-#include "pipe/p_state.h"
-
-
-/**
- * Clear the given buffers to the specified values.
- * No masking, no scissor (clear entire buffer).
- */
-static INLINE void
-util_clear(struct pipe_context *pipe,
- struct pipe_framebuffer_state *framebuffer, unsigned buffers,
- const float *rgba, double depth, unsigned stencil)
-{
- if (buffers & PIPE_CLEAR_COLOR) {
- unsigned i;
- for (i = 0; i < framebuffer->nr_cbufs; i++) {
- struct pipe_surface *ps = framebuffer->cbufs[i];
- pipe->clear_render_target(pipe, ps, rgba, 0, 0, ps->width, ps->height);
- }
- }
-
- if (buffers & PIPE_CLEAR_DEPTHSTENCIL) {
- struct pipe_surface *ps = framebuffer->zsbuf;
- pipe->clear_depth_stencil(pipe, ps, buffers & PIPE_CLEAR_DEPTHSTENCIL,
- depth, stencil,
- 0, 0, ps->width, ps->height);
- }
-}
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc. 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"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * 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 NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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.
+ *
+ **************************************************************************/
+
+/* Authors:
+ * Michel Dänzer
+ */
+
+
+#include "pipe/p_context.h"
+#include "pipe/p_state.h"
+
+
+/**
+ * Clear the given buffers to the specified values.
+ * No masking, no scissor (clear entire buffer).
+ */
+static INLINE void
+util_clear(struct pipe_context *pipe,
+ struct pipe_framebuffer_state *framebuffer, unsigned buffers,
+ const union pipe_color_union *color, double depth, unsigned stencil)
+{
+ if (buffers & PIPE_CLEAR_COLOR) {
+ unsigned i;
+ for (i = 0; i < framebuffer->nr_cbufs; i++) {
+ struct pipe_surface *ps = framebuffer->cbufs[i];
+ pipe->clear_render_target(pipe, ps, color, 0, 0, ps->width, ps->height);
+ }
+ }
+
+ if (buffers & PIPE_CLEAR_DEPTHSTENCIL) {
+ struct pipe_surface *ps = framebuffer->zsbuf;
+ pipe->clear_depth_stencil(pipe, ps, buffers & PIPE_CLEAR_DEPTHSTENCIL,
+ depth, stencil,
+ 0, 0, ps->width, ps->height);
+ }
+}
diff --git a/mesalib/src/gallium/auxiliary/util/u_surface.c b/mesalib/src/gallium/auxiliary/util/u_surface.c
index 8e123867d..308511b33 100644
--- a/mesalib/src/gallium/auxiliary/util/u_surface.c
+++ b/mesalib/src/gallium/auxiliary/util/u_surface.c
@@ -228,7 +228,7 @@ util_resource_copy_region(struct pipe_context *pipe,
void
util_clear_render_target(struct pipe_context *pipe,
struct pipe_surface *dst,
- const float *rgba,
+ const union pipe_color_union *color,
unsigned dstx, unsigned dsty,
unsigned width, unsigned height)
{
@@ -254,7 +254,7 @@ util_clear_render_target(struct pipe_context *pipe,
if (dst_map) {
assert(dst_trans->stride > 0);
- util_pack_color(rgba, dst->texture->format, &uc);
+ util_pack_color(color->f, dst->texture->format, &uc);
util_fill_rect(dst_map, dst->texture->format,
dst_trans->stride,
0, 0, width, height, &uc);
diff --git a/mesalib/src/gallium/auxiliary/util/u_surface.h b/mesalib/src/gallium/auxiliary/util/u_surface.h
index e02931bbe..1117b78da 100644
--- a/mesalib/src/gallium/auxiliary/util/u_surface.h
+++ b/mesalib/src/gallium/auxiliary/util/u_surface.h
@@ -1,90 +1,90 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc. 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"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * 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 NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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.
- *
- **************************************************************************/
-
-
-#ifndef U_SURFACE_H
-#define U_SURFACE_H
-
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_state.h"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-extern void
-u_surface_default_template(struct pipe_surface *view,
- const struct pipe_resource *texture,
- unsigned bind);
-
-extern boolean
-util_create_rgba_surface(struct pipe_context *ctx,
- uint width, uint height, uint bind,
- struct pipe_resource **textureOut,
- struct pipe_surface **surfaceOut);
-
-
-extern void
-util_destroy_rgba_surface(struct pipe_resource *texture,
- struct pipe_surface *surface);
-
-
-
-extern void
-util_resource_copy_region(struct pipe_context *pipe,
- struct pipe_resource *dst,
- unsigned dst_level,
- unsigned dst_x, unsigned dst_y, unsigned dst_z,
- struct pipe_resource *src,
- unsigned src_level,
- const struct pipe_box *src_box);
-
-extern void
-util_clear_render_target(struct pipe_context *pipe,
- struct pipe_surface *dst,
- const float *rgba,
- unsigned dstx, unsigned dsty,
- unsigned width, unsigned height);
-
-extern void
-util_clear_depth_stencil(struct pipe_context *pipe,
- struct pipe_surface *dst,
- unsigned clear_flags,
- double depth,
- unsigned stencil,
- unsigned dstx, unsigned dsty,
- unsigned width, unsigned height);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* U_SURFACE_H */
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc. 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"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * 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 NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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.
+ *
+ **************************************************************************/
+
+
+#ifndef U_SURFACE_H
+#define U_SURFACE_H
+
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_state.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+extern void
+u_surface_default_template(struct pipe_surface *view,
+ const struct pipe_resource *texture,
+ unsigned bind);
+
+extern boolean
+util_create_rgba_surface(struct pipe_context *ctx,
+ uint width, uint height, uint bind,
+ struct pipe_resource **textureOut,
+ struct pipe_surface **surfaceOut);
+
+
+extern void
+util_destroy_rgba_surface(struct pipe_resource *texture,
+ struct pipe_surface *surface);
+
+
+
+extern void
+util_resource_copy_region(struct pipe_context *pipe,
+ struct pipe_resource *dst,
+ unsigned dst_level,
+ unsigned dst_x, unsigned dst_y, unsigned dst_z,
+ struct pipe_resource *src,
+ unsigned src_level,
+ const struct pipe_box *src_box);
+
+extern void
+util_clear_render_target(struct pipe_context *pipe,
+ struct pipe_surface *dst,
+ const union pipe_color_union *color,
+ unsigned dstx, unsigned dsty,
+ unsigned width, unsigned height);
+
+extern void
+util_clear_depth_stencil(struct pipe_context *pipe,
+ struct pipe_surface *dst,
+ unsigned clear_flags,
+ double depth,
+ unsigned stencil,
+ unsigned dstx, unsigned dsty,
+ unsigned width, unsigned height);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* U_SURFACE_H */
diff --git a/mesalib/src/mesa/SConscript b/mesalib/src/mesa/SConscript
index dfc8bd441..ff1ffe008 100644
--- a/mesalib/src/mesa/SConscript
+++ b/mesalib/src/mesa/SConscript
@@ -114,7 +114,6 @@ main_sources = [
'main/texcompress_s3tc.c',
'main/texcompress_fxt1.c',
'main/texenv.c',
- 'main/texfetch.c',
'main/texformat.c',
'main/texgen.c',
'main/texgetimage.c',
@@ -173,6 +172,7 @@ swrast_sources = [
'swrast/s_span.c',
'swrast/s_stencil.c',
'swrast/s_texcombine.c',
+ 'swrast/s_texfetch.c',
'swrast/s_texfilter.c',
'swrast/s_texrender.c',
'swrast/s_texture.c',
diff --git a/mesalib/src/mesa/drivers/common/driverfuncs.c b/mesalib/src/mesa/drivers/common/driverfuncs.c
index 36ed4f892..3e2896980 100644
--- a/mesalib/src/mesa/drivers/common/driverfuncs.c
+++ b/mesalib/src/mesa/drivers/common/driverfuncs.c
@@ -110,8 +110,10 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
driver->BindTexture = NULL;
driver->NewTextureObject = _mesa_new_texture_object;
driver->DeleteTexture = _mesa_delete_texture_object;
- driver->NewTextureImage = _mesa_new_texture_image;
- driver->FreeTextureImageBuffer = _mesa_free_texture_image_data;
+ driver->NewTextureImage = _swrast_new_texture_image;
+ driver->DeleteTextureImage = _swrast_delete_texture_image;
+ driver->AllocTextureImageBuffer = _swrast_alloc_texture_image_buffer;
+ driver->FreeTextureImageBuffer = _swrast_free_texture_image_buffer;
driver->MapTextureImage = _swrast_map_teximage;
driver->UnmapTextureImage = _swrast_unmap_teximage;
driver->MapTexture = NULL;
diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c
index 482bd98a2..1b71aa194 100644
--- a/mesalib/src/mesa/drivers/common/meta.c
+++ b/mesalib/src/mesa/drivers/common/meta.c
@@ -1222,7 +1222,9 @@ blitframebuffer_texture(struct gl_context *ctx,
_mesa_TexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT,
GL_SKIP_DECODE_EXT);
}
- _mesa_Disable(GL_FRAMEBUFFER_SRGB_EXT);
+ if (ctx->Extensions.EXT_framebuffer_sRGB) {
+ _mesa_Disable(GL_FRAMEBUFFER_SRGB_EXT);
+ }
_mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
_mesa_set_enable(ctx, target, GL_TRUE);
@@ -1288,7 +1290,7 @@ blitframebuffer_texture(struct gl_context *ctx,
if (ctx->Extensions.EXT_texture_sRGB_decode) {
_mesa_TexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT, srgbSave);
}
- if (ctx->Extensions.EXT_texture_sRGB_decode && fbo_srgb_save) {
+ if (ctx->Extensions.EXT_framebuffer_sRGB && fbo_srgb_save) {
_mesa_Enable(GL_FRAMEBUFFER_SRGB_EXT);
}
diff --git a/mesalib/src/mesa/main/dd.h b/mesalib/src/mesa/main/dd.h
index d6cc0196d..720e4f53d 100644
--- a/mesalib/src/mesa/main/dd.h
+++ b/mesalib/src/mesa/main/dd.h
@@ -476,6 +476,16 @@ struct dd_function_table {
*/
struct gl_texture_image * (*NewTextureImage)( struct gl_context *ctx );
+ /** Called to free a texture image object returned by NewTextureImage() */
+ void (*DeleteTextureImage)(struct gl_context *ctx,
+ struct gl_texture_image *);
+
+ /** Called to allocate memory for a single texture image */
+ GLboolean (*AllocTextureImageBuffer)(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ gl_format format, GLsizei width,
+ GLsizei height, GLsizei depth);
+
/**
* Called to free tImage->Data.
*/
diff --git a/mesalib/src/mesa/main/format_unpack.c b/mesalib/src/mesa/main/format_unpack.c
index c5146f72d..dadff0556 100644
--- a/mesalib/src/mesa/main/format_unpack.c
+++ b/mesalib/src/mesa/main/format_unpack.c
@@ -921,7 +921,11 @@ unpack_SIGNED_R16(const void *src, GLfloat dst[4])
static void
unpack_SIGNED_GR1616(const void *src, GLfloat dst[4])
{
- /* XXX TODO */
+ const GLuint s = *((const GLuint *) src);
+ dst[RCOMP] = SHORT_TO_FLOAT_TEX( s & 0xffff );
+ dst[GCOMP] = SHORT_TO_FLOAT_TEX( s >> 16 );
+ dst[BCOMP] = 0.0F;
+ dst[ACOMP] = 1.0F;
}
static void
@@ -947,7 +951,7 @@ unpack_SIGNED_RGBA_16(const void *src, GLfloat dst[4])
static void
unpack_RGBA_16(const void *src, GLfloat dst[4])
{
- const GLshort *s = (const GLshort *) src;
+ const GLushort *s = (const GLushort *) src;
dst[RCOMP] = USHORT_TO_FLOAT( s[0] );
dst[GCOMP] = USHORT_TO_FLOAT( s[1] );
dst[BCOMP] = USHORT_TO_FLOAT( s[2] );
diff --git a/mesalib/src/mesa/main/mipmap.c b/mesalib/src/mesa/main/mipmap.c
index 869243d1c..f170d235a 100644
--- a/mesalib/src/mesa/main/mipmap.c
+++ b/mesalib/src/mesa/main/mipmap.c
@@ -1955,23 +1955,17 @@ generate_mipmap_uncompressed(struct gl_context *ctx, GLenum target,
dstDepth, border, srcImage->InternalFormat,
srcImage->TexFormat);
dstImage->DriverData = NULL;
- dstImage->FetchTexelc = srcImage->FetchTexelc;
- dstImage->FetchTexelf = srcImage->FetchTexelf;
- /* Alloc new teximage data buffer */
- {
- GLuint size = _mesa_format_image_size(dstImage->TexFormat,
- dstWidth, dstHeight, dstDepth);
- dstImage->Data = _mesa_alloc_texmemory(size);
- if (!dstImage->Data) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps");
- return;
- }
+ /* Alloc storage for new texture image */
+ if (!ctx->Driver.AllocTextureImageBuffer(ctx, dstImage,
+ dstImage->TexFormat,
+ dstWidth, dstHeight,
+ dstDepth)) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps");
+ return;
}
ASSERT(dstImage->TexFormat);
- ASSERT(dstImage->FetchTexelc);
- ASSERT(dstImage->FetchTexelf);
_mesa_generate_mipmap_level(target, datatype, comps, border,
srcWidth, srcHeight, srcDepth,
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index 8671ecda9..429c8b430 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -1253,37 +1253,6 @@ typedef enum
/**
- * 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 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 (*FetchTexelFuncF)( const struct gl_texture_image *texImage,
- GLint col, GLint row, GLint img,
- GLfloat *texelOut );
-
-
-typedef void (*StoreTexelFunc)(struct gl_texture_image *texImage,
- GLint col, GLint row, GLint img,
- const void *texel);
-
-
-/**
* Texture image state. Describes the dimensions of a texture image,
* the texel format and pointers to Texel Fetch functions.
*/
@@ -1320,9 +1289,6 @@ struct gl_texture_image
/** Cube map face: index into gl_texture_object::Image[] array */
GLuint Face;
- FetchTexelFuncC FetchTexelc; /**< GLchan texel fetch function pointer */
- FetchTexelFuncF FetchTexelf; /**< Float texel fetch function pointer */
-
GLuint RowStride; /**< Padded width in units of texels */
GLuint *ImageOffsets; /**< if 3D texture: array [Depth] of offsets to
each 2D slice in 'Data', in texels */
diff --git a/mesalib/src/mesa/main/texcompress.c b/mesalib/src/mesa/main/texcompress.c
index 4e5c14cbb..b49d1b1ca 100644
--- a/mesalib/src/mesa/main/texcompress.c
+++ b/mesalib/src/mesa/main/texcompress.c
@@ -40,6 +40,7 @@
#include "texcompress_fxt1.h"
#include "texcompress_rgtc.h"
#include "texcompress_s3tc.h"
+#include "swrast/s_context.h"
/**
@@ -451,15 +452,15 @@ _mesa_decompress_image(gl_format format, GLuint width, GLuint height,
const GLubyte *src, GLint srcRowStride,
GLfloat *dest)
{
- void (*fetch)(const struct gl_texture_image *texImage,
+ void (*fetch)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel);
- struct gl_texture_image texImage; /* dummy teximage */
+ struct swrast_texture_image texImage; /* dummy teximage */
GLuint i, j;
/* setup dummy texture image info */
memset(&texImage, 0, sizeof(texImage));
- texImage.Data = (void *) src;
- texImage.RowStride = srcRowStride;
+ texImage.Base.Data = (void *) src;
+ texImage.Base.RowStride = srcRowStride;
switch (format) {
/* DXT formats */
diff --git a/mesalib/src/mesa/main/texcompress_fxt1.c b/mesalib/src/mesa/main/texcompress_fxt1.c
index 261014d63..a75487ce2 100644
--- a/mesalib/src/mesa/main/texcompress_fxt1.c
+++ b/mesalib/src/mesa/main/texcompress_fxt1.c
@@ -1,1651 +1,1652 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.1
- *
- * Copyright (C) 1999-2008 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"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-
-/**
- * \file texcompress_fxt1.c
- * GL_3DFX_texture_compression_FXT1 support.
- */
-
-
-#include "glheader.h"
-#include "imports.h"
-#include "colormac.h"
-#include "image.h"
-#include "macros.h"
-#include "mfeatures.h"
-#include "mipmap.h"
-#include "texcompress.h"
-#include "texcompress_fxt1.h"
-#include "texstore.h"
-
-
-#if FEATURE_texture_fxt1
-
-
-static void
-fxt1_encode (GLuint width, GLuint height, GLint comps,
- const void *source, GLint srcRowStride,
- void *dest, GLint destRowStride);
-
-void
-fxt1_decode_1 (const void *texture, GLint stride,
- GLint i, GLint j, GLchan *rgba);
-
-
-/**
- * Store user's image in rgb_fxt1 format.
- */
-GLboolean
-_mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS)
-{
- const GLchan *pixels;
- GLint srcRowStride;
- GLubyte *dst;
- const GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */
- const GLchan *tempImage = NULL;
-
- ASSERT(dstFormat == MESA_FORMAT_RGB_FXT1);
- ASSERT(dstXoffset % 8 == 0);
- ASSERT(dstYoffset % 4 == 0);
- ASSERT(dstZoffset == 0);
- (void) dstZoffset;
- (void) dstImageOffsets;
-
- if (srcFormat != GL_RGB ||
- srcType != CHAN_TYPE ||
- ctx->_ImageTransferState ||
- srcPacking->SwapBytes) {
- /* convert image to RGB/GLchan */
- tempImage = _mesa_make_temp_chan_image(ctx, dims,
- baseInternalFormat,
- _mesa_get_format_base_format(dstFormat),
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- if (!tempImage)
- return GL_FALSE; /* out of memory */
- pixels = tempImage;
- srcRowStride = 3 * srcWidth;
- srcFormat = GL_RGB;
- }
- else {
- pixels = (const GLchan *) srcAddr;
- srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
- srcType) / sizeof(GLchan);
- }
-
- dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
- dstFormat,
- texWidth, (GLubyte *) dstAddr);
-
- fxt1_encode(srcWidth, srcHeight, 3, pixels, srcRowStride,
- dst, dstRowStride);
-
- if (tempImage)
- free((void*) tempImage);
-
- return GL_TRUE;
-}
-
-
-/**
- * Store user's image in rgba_fxt1 format.
- */
-GLboolean
-_mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS)
-{
- const GLchan *pixels;
- GLint srcRowStride;
- GLubyte *dst;
- GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */
- const GLchan *tempImage = NULL;
-
- ASSERT(dstFormat == MESA_FORMAT_RGBA_FXT1);
- ASSERT(dstXoffset % 8 == 0);
- ASSERT(dstYoffset % 4 == 0);
- ASSERT(dstZoffset == 0);
- (void) dstZoffset;
- (void) dstImageOffsets;
-
- if (srcFormat != GL_RGBA ||
- srcType != CHAN_TYPE ||
- ctx->_ImageTransferState ||
- srcPacking->SwapBytes) {
- /* convert image to RGBA/GLchan */
- tempImage = _mesa_make_temp_chan_image(ctx, dims,
- baseInternalFormat,
- _mesa_get_format_base_format(dstFormat),
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- if (!tempImage)
- return GL_FALSE; /* out of memory */
- pixels = tempImage;
- srcRowStride = 4 * srcWidth;
- srcFormat = GL_RGBA;
- }
- else {
- pixels = (const GLchan *) srcAddr;
- srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
- srcType) / sizeof(GLchan);
- }
-
- dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
- dstFormat,
- texWidth, (GLubyte *) dstAddr);
-
- fxt1_encode(srcWidth, srcHeight, 4, pixels, srcRowStride,
- dst, dstRowStride);
-
- if (tempImage)
- free((void*) tempImage);
-
- return GL_TRUE;
-}
-
-
-void
-_mesa_fetch_texel_2d_f_rgba_fxt1( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- /* just sample as GLchan and convert to float here */
- GLchan rgba[4];
- (void) k;
- fxt1_decode_1(texImage->Data, texImage->RowStride, i, j, rgba);
- texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
- texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
- texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
- texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
-}
-
-
-void
-_mesa_fetch_texel_2d_f_rgb_fxt1( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- /* just sample as GLchan and convert to float here */
- GLchan rgba[4];
- (void) k;
- fxt1_decode_1(texImage->Data, texImage->RowStride, i, j, rgba);
- texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
- texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
- texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
- texel[ACOMP] = 1.0F;
-}
-
-
-
-/***************************************************************************\
- * FXT1 encoder
- *
- * The encoder was built by reversing the decoder,
- * and is vaguely based on Texus2 by 3dfx. Note that this code
- * is merely a proof of concept, since it is highly UNoptimized;
- * moreover, it is sub-optimal due to initial conditions passed
- * to Lloyd's algorithm (the interpolation modes are even worse).
-\***************************************************************************/
-
-
-#define MAX_COMP 4 /* ever needed maximum number of components in texel */
-#define MAX_VECT 4 /* ever needed maximum number of base vectors to find */
-#define N_TEXELS 32 /* number of texels in a block (always 32) */
-#define LL_N_REP 50 /* number of iterations in lloyd's vq */
-#define LL_RMS_D 10 /* fault tolerance (maximum delta) */
-#define LL_RMS_E 255 /* fault tolerance (maximum error) */
-#define ALPHA_TS 2 /* alpha threshold: (255 - ALPHA_TS) deemed opaque */
-#define ISTBLACK(v) (*((GLuint *)(v)) == 0)
-
-
-/*
- * Define a 64-bit unsigned integer type and macros
- */
-#if 1
-
-#define FX64_NATIVE 1
-
-typedef uint64_t Fx64;
-
-#define FX64_MOV32(a, b) a = b
-#define FX64_OR32(a, b) a |= b
-#define FX64_SHL(a, c) a <<= c
-
-#else
-
-#define FX64_NATIVE 0
-
-typedef struct {
- GLuint lo, hi;
-} Fx64;
-
-#define FX64_MOV32(a, b) a.lo = b
-#define FX64_OR32(a, b) a.lo |= b
-
-#define FX64_SHL(a, c) \
- do { \
- if ((c) >= 32) { \
- a.hi = a.lo << ((c) - 32); \
- a.lo = 0; \
- } else { \
- a.hi = (a.hi << (c)) | (a.lo >> (32 - (c))); \
- a.lo <<= (c); \
- } \
- } while (0)
-
-#endif
-
-
-#define F(i) (GLfloat)1 /* can be used to obtain an oblong metric: 0.30 / 0.59 / 0.11 */
-#define SAFECDOT 1 /* for paranoids */
-
-#define MAKEIVEC(NV, NC, IV, B, V0, V1) \
- do { \
- /* compute interpolation vector */ \
- GLfloat d2 = 0.0F; \
- GLfloat rd2; \
- \
- for (i = 0; i < NC; i++) { \
- IV[i] = (V1[i] - V0[i]) * F(i); \
- d2 += IV[i] * IV[i]; \
- } \
- rd2 = (GLfloat)NV / d2; \
- B = 0; \
- for (i = 0; i < NC; i++) { \
- IV[i] *= F(i); \
- B -= IV[i] * V0[i]; \
- IV[i] *= rd2; \
- } \
- B = B * rd2 + 0.5f; \
- } while (0)
-
-#define CALCCDOT(TEXEL, NV, NC, IV, B, V)\
- do { \
- GLfloat dot = 0.0F; \
- for (i = 0; i < NC; i++) { \
- dot += V[i] * IV[i]; \
- } \
- TEXEL = (GLint)(dot + B); \
- if (SAFECDOT) { \
- if (TEXEL < 0) { \
- TEXEL = 0; \
- } else if (TEXEL > NV) { \
- TEXEL = NV; \
- } \
- } \
- } while (0)
-
-
-static GLint
-fxt1_bestcol (GLfloat vec[][MAX_COMP], GLint nv,
- GLubyte input[MAX_COMP], GLint nc)
-{
- GLint i, j, best = -1;
- GLfloat err = 1e9; /* big enough */
-
- for (j = 0; j < nv; j++) {
- GLfloat e = 0.0F;
- for (i = 0; i < nc; i++) {
- e += (vec[j][i] - input[i]) * (vec[j][i] - input[i]);
- }
- if (e < err) {
- err = e;
- best = j;
- }
- }
-
- return best;
-}
-
-
-static GLint
-fxt1_worst (GLfloat vec[MAX_COMP],
- GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n)
-{
- GLint i, k, worst = -1;
- GLfloat err = -1.0F; /* small enough */
-
- for (k = 0; k < n; k++) {
- GLfloat e = 0.0F;
- for (i = 0; i < nc; i++) {
- e += (vec[i] - input[k][i]) * (vec[i] - input[k][i]);
- }
- if (e > err) {
- err = e;
- worst = k;
- }
- }
-
- return worst;
-}
-
-
-static GLint
-fxt1_variance (GLdouble variance[MAX_COMP],
- GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n)
-{
- GLint i, k, best = 0;
- GLint sx, sx2;
- GLdouble var, maxvar = -1; /* small enough */
- GLdouble teenth = 1.0 / n;
-
- for (i = 0; i < nc; i++) {
- sx = sx2 = 0;
- for (k = 0; k < n; k++) {
- GLint t = input[k][i];
- sx += t;
- sx2 += t * t;
- }
- var = sx2 * teenth - sx * sx * teenth * teenth;
- if (maxvar < var) {
- maxvar = var;
- best = i;
- }
- if (variance) {
- variance[i] = var;
- }
- }
-
- return best;
-}
-
-
-static GLint
-fxt1_choose (GLfloat vec[][MAX_COMP], GLint nv,
- GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n)
-{
-#if 0
- /* Choose colors from a grid.
- */
- GLint i, j;
-
- for (j = 0; j < nv; j++) {
- GLint m = j * (n - 1) / (nv - 1);
- for (i = 0; i < nc; i++) {
- vec[j][i] = input[m][i];
- }
- }
-#else
- /* Our solution here is to find the darkest and brightest colors in
- * the 8x4 tile and use those as the two representative colors.
- * There are probably better algorithms to use (histogram-based).
- */
- GLint i, j, k;
- GLint minSum = 2000; /* big enough */
- GLint maxSum = -1; /* small enough */
- GLint minCol = 0; /* phoudoin: silent compiler! */
- GLint maxCol = 0; /* phoudoin: silent compiler! */
-
- struct {
- GLint flag;
- GLint key;
- GLint freq;
- GLint idx;
- } hist[N_TEXELS];
- GLint lenh = 0;
-
- memset(hist, 0, sizeof(hist));
-
- for (k = 0; k < n; k++) {
- GLint l;
- GLint key = 0;
- GLint sum = 0;
- for (i = 0; i < nc; i++) {
- key <<= 8;
- key |= input[k][i];
- sum += input[k][i];
- }
- for (l = 0; l < n; l++) {
- if (!hist[l].flag) {
- /* alloc new slot */
- hist[l].flag = !0;
- hist[l].key = key;
- hist[l].freq = 1;
- hist[l].idx = k;
- lenh = l + 1;
- break;
- } else if (hist[l].key == key) {
- hist[l].freq++;
- break;
- }
- }
- if (minSum > sum) {
- minSum = sum;
- minCol = k;
- }
- if (maxSum < sum) {
- maxSum = sum;
- maxCol = k;
- }
- }
-
- if (lenh <= nv) {
- for (j = 0; j < lenh; j++) {
- for (i = 0; i < nc; i++) {
- vec[j][i] = (GLfloat)input[hist[j].idx][i];
- }
- }
- for (; j < nv; j++) {
- for (i = 0; i < nc; i++) {
- vec[j][i] = vec[0][i];
- }
- }
- return 0;
- }
-
- for (j = 0; j < nv; j++) {
- for (i = 0; i < nc; i++) {
- vec[j][i] = ((nv - 1 - j) * input[minCol][i] + j * input[maxCol][i] + (nv - 1) / 2) / (GLfloat)(nv - 1);
- }
- }
-#endif
-
- return !0;
-}
-
-
-static GLint
-fxt1_lloyd (GLfloat vec[][MAX_COMP], GLint nv,
- GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n)
-{
- /* Use the generalized lloyd's algorithm for VQ:
- * find 4 color vectors.
- *
- * for each sample color
- * sort to nearest vector.
- *
- * replace each vector with the centroid of its matching colors.
- *
- * repeat until RMS doesn't improve.
- *
- * if a color vector has no samples, or becomes the same as another
- * vector, replace it with the color which is farthest from a sample.
- *
- * vec[][MAX_COMP] initial vectors and resulting colors
- * nv number of resulting colors required
- * input[N_TEXELS][MAX_COMP] input texels
- * nc number of components in input / vec
- * n number of input samples
- */
-
- GLint sum[MAX_VECT][MAX_COMP]; /* used to accumulate closest texels */
- GLint cnt[MAX_VECT]; /* how many times a certain vector was chosen */
- GLfloat error, lasterror = 1e9;
-
- GLint i, j, k, rep;
-
- /* the quantizer */
- for (rep = 0; rep < LL_N_REP; rep++) {
- /* reset sums & counters */
- for (j = 0; j < nv; j++) {
- for (i = 0; i < nc; i++) {
- sum[j][i] = 0;
- }
- cnt[j] = 0;
- }
- error = 0;
-
- /* scan whole block */
- for (k = 0; k < n; k++) {
-#if 1
- GLint best = -1;
- GLfloat err = 1e9; /* big enough */
- /* determine best vector */
- for (j = 0; j < nv; j++) {
- GLfloat e = (vec[j][0] - input[k][0]) * (vec[j][0] - input[k][0]) +
- (vec[j][1] - input[k][1]) * (vec[j][1] - input[k][1]) +
- (vec[j][2] - input[k][2]) * (vec[j][2] - input[k][2]);
- if (nc == 4) {
- e += (vec[j][3] - input[k][3]) * (vec[j][3] - input[k][3]);
- }
- if (e < err) {
- err = e;
- best = j;
- }
- }
-#else
- GLint best = fxt1_bestcol(vec, nv, input[k], nc, &err);
-#endif
- assert(best >= 0);
- /* add in closest color */
- for (i = 0; i < nc; i++) {
- sum[best][i] += input[k][i];
- }
- /* mark this vector as used */
- cnt[best]++;
- /* accumulate error */
- error += err;
- }
-
- /* check RMS */
- if ((error < LL_RMS_E) ||
- ((error < lasterror) && ((lasterror - error) < LL_RMS_D))) {
- return !0; /* good match */
- }
- lasterror = error;
-
- /* move each vector to the barycenter of its closest colors */
- for (j = 0; j < nv; j++) {
- if (cnt[j]) {
- GLfloat div = 1.0F / cnt[j];
- for (i = 0; i < nc; i++) {
- vec[j][i] = div * sum[j][i];
- }
- } else {
- /* this vec has no samples or is identical with a previous vec */
- GLint worst = fxt1_worst(vec[j], input, nc, n);
- for (i = 0; i < nc; i++) {
- vec[j][i] = input[worst][i];
- }
- }
- }
- }
-
- return 0; /* could not converge fast enough */
-}
-
-
-static void
-fxt1_quantize_CHROMA (GLuint *cc,
- GLubyte input[N_TEXELS][MAX_COMP])
-{
- const GLint n_vect = 4; /* 4 base vectors to find */
- const GLint n_comp = 3; /* 3 components: R, G, B */
- GLfloat vec[MAX_VECT][MAX_COMP];
- GLint i, j, k;
- Fx64 hi; /* high quadword */
- GLuint lohi, lolo; /* low quadword: hi dword, lo dword */
-
- if (fxt1_choose(vec, n_vect, input, n_comp, N_TEXELS) != 0) {
- fxt1_lloyd(vec, n_vect, input, n_comp, N_TEXELS);
- }
-
- FX64_MOV32(hi, 4); /* cc-chroma = "010" + unused bit */
- for (j = n_vect - 1; j >= 0; j--) {
- for (i = 0; i < n_comp; i++) {
- /* add in colors */
- FX64_SHL(hi, 5);
- FX64_OR32(hi, (GLuint)(vec[j][i] / 8.0F));
- }
- }
- ((Fx64 *)cc)[1] = hi;
-
- lohi = lolo = 0;
- /* right microtile */
- for (k = N_TEXELS - 1; k >= N_TEXELS/2; k--) {
- lohi <<= 2;
- lohi |= fxt1_bestcol(vec, n_vect, input[k], n_comp);
- }
- /* left microtile */
- for (; k >= 0; k--) {
- lolo <<= 2;
- lolo |= fxt1_bestcol(vec, n_vect, input[k], n_comp);
- }
- cc[1] = lohi;
- cc[0] = lolo;
-}
-
-
-static void
-fxt1_quantize_ALPHA0 (GLuint *cc,
- GLubyte input[N_TEXELS][MAX_COMP],
- GLubyte reord[N_TEXELS][MAX_COMP], GLint n)
-{
- const GLint n_vect = 3; /* 3 base vectors to find */
- const GLint n_comp = 4; /* 4 components: R, G, B, A */
- GLfloat vec[MAX_VECT][MAX_COMP];
- GLint i, j, k;
- Fx64 hi; /* high quadword */
- GLuint lohi, lolo; /* low quadword: hi dword, lo dword */
-
- /* the last vector indicates zero */
- for (i = 0; i < n_comp; i++) {
- vec[n_vect][i] = 0;
- }
-
- /* the first n texels in reord are guaranteed to be non-zero */
- if (fxt1_choose(vec, n_vect, reord, n_comp, n) != 0) {
- fxt1_lloyd(vec, n_vect, reord, n_comp, n);
- }
-
- FX64_MOV32(hi, 6); /* alpha = "011" + lerp = 0 */
- for (j = n_vect - 1; j >= 0; j--) {
- /* add in alphas */
- FX64_SHL(hi, 5);
- FX64_OR32(hi, (GLuint)(vec[j][ACOMP] / 8.0F));
- }
- for (j = n_vect - 1; j >= 0; j--) {
- for (i = 0; i < n_comp - 1; i++) {
- /* add in colors */
- FX64_SHL(hi, 5);
- FX64_OR32(hi, (GLuint)(vec[j][i] / 8.0F));
- }
- }
- ((Fx64 *)cc)[1] = hi;
-
- lohi = lolo = 0;
- /* right microtile */
- for (k = N_TEXELS - 1; k >= N_TEXELS/2; k--) {
- lohi <<= 2;
- lohi |= fxt1_bestcol(vec, n_vect + 1, input[k], n_comp);
- }
- /* left microtile */
- for (; k >= 0; k--) {
- lolo <<= 2;
- lolo |= fxt1_bestcol(vec, n_vect + 1, input[k], n_comp);
- }
- cc[1] = lohi;
- cc[0] = lolo;
-}
-
-
-static void
-fxt1_quantize_ALPHA1 (GLuint *cc,
- GLubyte input[N_TEXELS][MAX_COMP])
-{
- const GLint n_vect = 3; /* highest vector number in each microtile */
- const GLint n_comp = 4; /* 4 components: R, G, B, A */
- GLfloat vec[1 + 1 + 1][MAX_COMP]; /* 1.5 extrema for each sub-block */
- GLfloat b, iv[MAX_COMP]; /* interpolation vector */
- GLint i, j, k;
- Fx64 hi; /* high quadword */
- GLuint lohi, lolo; /* low quadword: hi dword, lo dword */
-
- GLint minSum;
- GLint maxSum;
- GLint minColL = 0, maxColL = 0;
- GLint minColR = 0, maxColR = 0;
- GLint sumL = 0, sumR = 0;
- GLint nn_comp;
- /* Our solution here is to find the darkest and brightest colors in
- * the 4x4 tile and use those as the two representative colors.
- * There are probably better algorithms to use (histogram-based).
- */
- nn_comp = n_comp;
- while ((minColL == maxColL) && nn_comp) {
- minSum = 2000; /* big enough */
- maxSum = -1; /* small enough */
- for (k = 0; k < N_TEXELS / 2; k++) {
- GLint sum = 0;
- for (i = 0; i < nn_comp; i++) {
- sum += input[k][i];
- }
- if (minSum > sum) {
- minSum = sum;
- minColL = k;
- }
- if (maxSum < sum) {
- maxSum = sum;
- maxColL = k;
- }
- sumL += sum;
- }
-
- nn_comp--;
- }
-
- nn_comp = n_comp;
- while ((minColR == maxColR) && nn_comp) {
- minSum = 2000; /* big enough */
- maxSum = -1; /* small enough */
- for (k = N_TEXELS / 2; k < N_TEXELS; k++) {
- GLint sum = 0;
- for (i = 0; i < nn_comp; i++) {
- sum += input[k][i];
- }
- if (minSum > sum) {
- minSum = sum;
- minColR = k;
- }
- if (maxSum < sum) {
- maxSum = sum;
- maxColR = k;
- }
- sumR += sum;
- }
-
- nn_comp--;
- }
-
- /* choose the common vector (yuck!) */
- {
- GLint j1, j2;
- GLint v1 = 0, v2 = 0;
- GLfloat err = 1e9; /* big enough */
- GLfloat tv[2 * 2][MAX_COMP]; /* 2 extrema for each sub-block */
- for (i = 0; i < n_comp; i++) {
- tv[0][i] = input[minColL][i];
- tv[1][i] = input[maxColL][i];
- tv[2][i] = input[minColR][i];
- tv[3][i] = input[maxColR][i];
- }
- for (j1 = 0; j1 < 2; j1++) {
- for (j2 = 2; j2 < 4; j2++) {
- GLfloat e = 0.0F;
- for (i = 0; i < n_comp; i++) {
- e += (tv[j1][i] - tv[j2][i]) * (tv[j1][i] - tv[j2][i]);
- }
- if (e < err) {
- err = e;
- v1 = j1;
- v2 = j2;
- }
- }
- }
- for (i = 0; i < n_comp; i++) {
- vec[0][i] = tv[1 - v1][i];
- vec[1][i] = (tv[v1][i] * sumL + tv[v2][i] * sumR) / (sumL + sumR);
- vec[2][i] = tv[5 - v2][i];
- }
- }
-
- /* left microtile */
- cc[0] = 0;
- if (minColL != maxColL) {
- /* compute interpolation vector */
- MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]);
-
- /* add in texels */
- lolo = 0;
- for (k = N_TEXELS / 2 - 1; k >= 0; k--) {
- GLint texel;
- /* interpolate color */
- CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]);
- /* add in texel */
- lolo <<= 2;
- lolo |= texel;
- }
-
- cc[0] = lolo;
- }
-
- /* right microtile */
- cc[1] = 0;
- if (minColR != maxColR) {
- /* compute interpolation vector */
- MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[1]);
-
- /* add in texels */
- lohi = 0;
- for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) {
- GLint texel;
- /* interpolate color */
- CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]);
- /* add in texel */
- lohi <<= 2;
- lohi |= texel;
- }
-
- cc[1] = lohi;
- }
-
- FX64_MOV32(hi, 7); /* alpha = "011" + lerp = 1 */
- for (j = n_vect - 1; j >= 0; j--) {
- /* add in alphas */
- FX64_SHL(hi, 5);
- FX64_OR32(hi, (GLuint)(vec[j][ACOMP] / 8.0F));
- }
- for (j = n_vect - 1; j >= 0; j--) {
- for (i = 0; i < n_comp - 1; i++) {
- /* add in colors */
- FX64_SHL(hi, 5);
- FX64_OR32(hi, (GLuint)(vec[j][i] / 8.0F));
- }
- }
- ((Fx64 *)cc)[1] = hi;
-}
-
-
-static void
-fxt1_quantize_HI (GLuint *cc,
- GLubyte input[N_TEXELS][MAX_COMP],
- GLubyte reord[N_TEXELS][MAX_COMP], GLint n)
-{
- const GLint n_vect = 6; /* highest vector number */
- const GLint n_comp = 3; /* 3 components: R, G, B */
- GLfloat b = 0.0F; /* phoudoin: silent compiler! */
- GLfloat iv[MAX_COMP]; /* interpolation vector */
- GLint i, k;
- GLuint hihi; /* high quadword: hi dword */
-
- GLint minSum = 2000; /* big enough */
- GLint maxSum = -1; /* small enough */
- GLint minCol = 0; /* phoudoin: silent compiler! */
- GLint maxCol = 0; /* phoudoin: silent compiler! */
-
- /* Our solution here is to find the darkest and brightest colors in
- * the 8x4 tile and use those as the two representative colors.
- * There are probably better algorithms to use (histogram-based).
- */
- for (k = 0; k < n; k++) {
- GLint sum = 0;
- for (i = 0; i < n_comp; i++) {
- sum += reord[k][i];
- }
- if (minSum > sum) {
- minSum = sum;
- minCol = k;
- }
- if (maxSum < sum) {
- maxSum = sum;
- maxCol = k;
- }
- }
-
- hihi = 0; /* cc-hi = "00" */
- for (i = 0; i < n_comp; i++) {
- /* add in colors */
- hihi <<= 5;
- hihi |= reord[maxCol][i] >> 3;
- }
- for (i = 0; i < n_comp; i++) {
- /* add in colors */
- hihi <<= 5;
- hihi |= reord[minCol][i] >> 3;
- }
- cc[3] = hihi;
- cc[0] = cc[1] = cc[2] = 0;
-
- /* compute interpolation vector */
- if (minCol != maxCol) {
- MAKEIVEC(n_vect, n_comp, iv, b, reord[minCol], reord[maxCol]);
- }
-
- /* add in texels */
- for (k = N_TEXELS - 1; k >= 0; k--) {
- GLint t = k * 3;
- GLuint *kk = (GLuint *)((char *)cc + t / 8);
- GLint texel = n_vect + 1; /* transparent black */
-
- if (!ISTBLACK(input[k])) {
- if (minCol != maxCol) {
- /* interpolate color */
- CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]);
- /* add in texel */
- kk[0] |= texel << (t & 7);
- }
- } else {
- /* add in texel */
- kk[0] |= texel << (t & 7);
- }
- }
-}
-
-
-static void
-fxt1_quantize_MIXED1 (GLuint *cc,
- GLubyte input[N_TEXELS][MAX_COMP])
-{
- const GLint n_vect = 2; /* highest vector number in each microtile */
- const GLint n_comp = 3; /* 3 components: R, G, B */
- GLubyte vec[2 * 2][MAX_COMP]; /* 2 extrema for each sub-block */
- GLfloat b, iv[MAX_COMP]; /* interpolation vector */
- GLint i, j, k;
- Fx64 hi; /* high quadword */
- GLuint lohi, lolo; /* low quadword: hi dword, lo dword */
-
- GLint minSum;
- GLint maxSum;
- GLint minColL = 0, maxColL = -1;
- GLint minColR = 0, maxColR = -1;
-
- /* Our solution here is to find the darkest and brightest colors in
- * the 4x4 tile and use those as the two representative colors.
- * There are probably better algorithms to use (histogram-based).
- */
- minSum = 2000; /* big enough */
- maxSum = -1; /* small enough */
- for (k = 0; k < N_TEXELS / 2; k++) {
- if (!ISTBLACK(input[k])) {
- GLint sum = 0;
- for (i = 0; i < n_comp; i++) {
- sum += input[k][i];
- }
- if (minSum > sum) {
- minSum = sum;
- minColL = k;
- }
- if (maxSum < sum) {
- maxSum = sum;
- maxColL = k;
- }
- }
- }
- minSum = 2000; /* big enough */
- maxSum = -1; /* small enough */
- for (; k < N_TEXELS; k++) {
- if (!ISTBLACK(input[k])) {
- GLint sum = 0;
- for (i = 0; i < n_comp; i++) {
- sum += input[k][i];
- }
- if (minSum > sum) {
- minSum = sum;
- minColR = k;
- }
- if (maxSum < sum) {
- maxSum = sum;
- maxColR = k;
- }
- }
- }
-
- /* left microtile */
- if (maxColL == -1) {
- /* all transparent black */
- cc[0] = ~0u;
- for (i = 0; i < n_comp; i++) {
- vec[0][i] = 0;
- vec[1][i] = 0;
- }
- } else {
- cc[0] = 0;
- for (i = 0; i < n_comp; i++) {
- vec[0][i] = input[minColL][i];
- vec[1][i] = input[maxColL][i];
- }
- if (minColL != maxColL) {
- /* compute interpolation vector */
- MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]);
-
- /* add in texels */
- lolo = 0;
- for (k = N_TEXELS / 2 - 1; k >= 0; k--) {
- GLint texel = n_vect + 1; /* transparent black */
- if (!ISTBLACK(input[k])) {
- /* interpolate color */
- CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]);
- }
- /* add in texel */
- lolo <<= 2;
- lolo |= texel;
- }
- cc[0] = lolo;
- }
- }
-
- /* right microtile */
- if (maxColR == -1) {
- /* all transparent black */
- cc[1] = ~0u;
- for (i = 0; i < n_comp; i++) {
- vec[2][i] = 0;
- vec[3][i] = 0;
- }
- } else {
- cc[1] = 0;
- for (i = 0; i < n_comp; i++) {
- vec[2][i] = input[minColR][i];
- vec[3][i] = input[maxColR][i];
- }
- if (minColR != maxColR) {
- /* compute interpolation vector */
- MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[3]);
-
- /* add in texels */
- lohi = 0;
- for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) {
- GLint texel = n_vect + 1; /* transparent black */
- if (!ISTBLACK(input[k])) {
- /* interpolate color */
- CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]);
- }
- /* add in texel */
- lohi <<= 2;
- lohi |= texel;
- }
- cc[1] = lohi;
- }
- }
-
- FX64_MOV32(hi, 9 | (vec[3][GCOMP] & 4) | ((vec[1][GCOMP] >> 1) & 2)); /* chroma = "1" */
- for (j = 2 * 2 - 1; j >= 0; j--) {
- for (i = 0; i < n_comp; i++) {
- /* add in colors */
- FX64_SHL(hi, 5);
- FX64_OR32(hi, vec[j][i] >> 3);
- }
- }
- ((Fx64 *)cc)[1] = hi;
-}
-
-
-static void
-fxt1_quantize_MIXED0 (GLuint *cc,
- GLubyte input[N_TEXELS][MAX_COMP])
-{
- const GLint n_vect = 3; /* highest vector number in each microtile */
- const GLint n_comp = 3; /* 3 components: R, G, B */
- GLubyte vec[2 * 2][MAX_COMP]; /* 2 extrema for each sub-block */
- GLfloat b, iv[MAX_COMP]; /* interpolation vector */
- GLint i, j, k;
- Fx64 hi; /* high quadword */
- GLuint lohi, lolo; /* low quadword: hi dword, lo dword */
-
- GLint minColL = 0, maxColL = 0;
- GLint minColR = 0, maxColR = 0;
-#if 0
- GLint minSum;
- GLint maxSum;
-
- /* Our solution here is to find the darkest and brightest colors in
- * the 4x4 tile and use those as the two representative colors.
- * There are probably better algorithms to use (histogram-based).
- */
- minSum = 2000; /* big enough */
- maxSum = -1; /* small enough */
- for (k = 0; k < N_TEXELS / 2; k++) {
- GLint sum = 0;
- for (i = 0; i < n_comp; i++) {
- sum += input[k][i];
- }
- if (minSum > sum) {
- minSum = sum;
- minColL = k;
- }
- if (maxSum < sum) {
- maxSum = sum;
- maxColL = k;
- }
- }
- minSum = 2000; /* big enough */
- maxSum = -1; /* small enough */
- for (; k < N_TEXELS; k++) {
- GLint sum = 0;
- for (i = 0; i < n_comp; i++) {
- sum += input[k][i];
- }
- if (minSum > sum) {
- minSum = sum;
- minColR = k;
- }
- if (maxSum < sum) {
- maxSum = sum;
- maxColR = k;
- }
- }
-#else
- GLint minVal;
- GLint maxVal;
- GLint maxVarL = fxt1_variance(NULL, input, n_comp, N_TEXELS / 2);
- GLint maxVarR = fxt1_variance(NULL, &input[N_TEXELS / 2], n_comp, N_TEXELS / 2);
-
- /* Scan the channel with max variance for lo & hi
- * and use those as the two representative colors.
- */
- minVal = 2000; /* big enough */
- maxVal = -1; /* small enough */
- for (k = 0; k < N_TEXELS / 2; k++) {
- GLint t = input[k][maxVarL];
- if (minVal > t) {
- minVal = t;
- minColL = k;
- }
- if (maxVal < t) {
- maxVal = t;
- maxColL = k;
- }
- }
- minVal = 2000; /* big enough */
- maxVal = -1; /* small enough */
- for (; k < N_TEXELS; k++) {
- GLint t = input[k][maxVarR];
- if (minVal > t) {
- minVal = t;
- minColR = k;
- }
- if (maxVal < t) {
- maxVal = t;
- maxColR = k;
- }
- }
-#endif
-
- /* left microtile */
- cc[0] = 0;
- for (i = 0; i < n_comp; i++) {
- vec[0][i] = input[minColL][i];
- vec[1][i] = input[maxColL][i];
- }
- if (minColL != maxColL) {
- /* compute interpolation vector */
- MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]);
-
- /* add in texels */
- lolo = 0;
- for (k = N_TEXELS / 2 - 1; k >= 0; k--) {
- GLint texel;
- /* interpolate color */
- CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]);
- /* add in texel */
- lolo <<= 2;
- lolo |= texel;
- }
-
- /* funky encoding for LSB of green */
- if ((GLint)((lolo >> 1) & 1) != (((vec[1][GCOMP] ^ vec[0][GCOMP]) >> 2) & 1)) {
- for (i = 0; i < n_comp; i++) {
- vec[1][i] = input[minColL][i];
- vec[0][i] = input[maxColL][i];
- }
- lolo = ~lolo;
- }
-
- cc[0] = lolo;
- }
-
- /* right microtile */
- cc[1] = 0;
- for (i = 0; i < n_comp; i++) {
- vec[2][i] = input[minColR][i];
- vec[3][i] = input[maxColR][i];
- }
- if (minColR != maxColR) {
- /* compute interpolation vector */
- MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[3]);
-
- /* add in texels */
- lohi = 0;
- for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) {
- GLint texel;
- /* interpolate color */
- CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]);
- /* add in texel */
- lohi <<= 2;
- lohi |= texel;
- }
-
- /* funky encoding for LSB of green */
- if ((GLint)((lohi >> 1) & 1) != (((vec[3][GCOMP] ^ vec[2][GCOMP]) >> 2) & 1)) {
- for (i = 0; i < n_comp; i++) {
- vec[3][i] = input[minColR][i];
- vec[2][i] = input[maxColR][i];
- }
- lohi = ~lohi;
- }
-
- cc[1] = lohi;
- }
-
- FX64_MOV32(hi, 8 | (vec[3][GCOMP] & 4) | ((vec[1][GCOMP] >> 1) & 2)); /* chroma = "1" */
- for (j = 2 * 2 - 1; j >= 0; j--) {
- for (i = 0; i < n_comp; i++) {
- /* add in colors */
- FX64_SHL(hi, 5);
- FX64_OR32(hi, vec[j][i] >> 3);
- }
- }
- ((Fx64 *)cc)[1] = hi;
-}
-
-
-static void
-fxt1_quantize (GLuint *cc, const GLubyte *lines[], GLint comps)
-{
- GLint trualpha;
- GLubyte reord[N_TEXELS][MAX_COMP];
-
- GLubyte input[N_TEXELS][MAX_COMP];
- GLint i, k, l;
-
- if (comps == 3) {
- /* make the whole block opaque */
- memset(input, -1, sizeof(input));
- }
-
- /* 8 texels each line */
- for (l = 0; l < 4; l++) {
- for (k = 0; k < 4; k++) {
- for (i = 0; i < comps; i++) {
- input[k + l * 4][i] = *lines[l]++;
- }
- }
- for (; k < 8; k++) {
- for (i = 0; i < comps; i++) {
- input[k + l * 4 + 12][i] = *lines[l]++;
- }
- }
- }
-
- /* block layout:
- * 00, 01, 02, 03, 08, 09, 0a, 0b
- * 10, 11, 12, 13, 18, 19, 1a, 1b
- * 04, 05, 06, 07, 0c, 0d, 0e, 0f
- * 14, 15, 16, 17, 1c, 1d, 1e, 1f
- */
-
- /* [dBorca]
- * stupidity flows forth from this
- */
- l = N_TEXELS;
- trualpha = 0;
- if (comps == 4) {
- /* skip all transparent black texels */
- l = 0;
- for (k = 0; k < N_TEXELS; k++) {
- /* test all components against 0 */
- if (!ISTBLACK(input[k])) {
- /* texel is not transparent black */
- COPY_4UBV(reord[l], input[k]);
- if (reord[l][ACOMP] < (255 - ALPHA_TS)) {
- /* non-opaque texel */
- trualpha = !0;
- }
- l++;
- }
- }
- }
-
-#if 0
- if (trualpha) {
- fxt1_quantize_ALPHA0(cc, input, reord, l);
- } else if (l == 0) {
- cc[0] = cc[1] = cc[2] = -1;
- cc[3] = 0;
- } else if (l < N_TEXELS) {
- fxt1_quantize_HI(cc, input, reord, l);
- } else {
- fxt1_quantize_CHROMA(cc, input);
- }
- (void)fxt1_quantize_ALPHA1;
- (void)fxt1_quantize_MIXED1;
- (void)fxt1_quantize_MIXED0;
-#else
- if (trualpha) {
- fxt1_quantize_ALPHA1(cc, input);
- } else if (l == 0) {
- cc[0] = cc[1] = cc[2] = ~0u;
- cc[3] = 0;
- } else if (l < N_TEXELS) {
- fxt1_quantize_MIXED1(cc, input);
- } else {
- fxt1_quantize_MIXED0(cc, input);
- }
- (void)fxt1_quantize_ALPHA0;
- (void)fxt1_quantize_HI;
- (void)fxt1_quantize_CHROMA;
-#endif
-}
-
-
-static void
-fxt1_encode (GLuint width, GLuint height, GLint comps,
- const void *source, GLint srcRowStride,
- void *dest, GLint destRowStride)
-{
- GLuint x, y;
- const GLubyte *data;
- GLuint *encoded = (GLuint *)dest;
- void *newSource = NULL;
-
- assert(comps == 3 || comps == 4);
-
- /* Replicate image if width is not M8 or height is not M4 */
- if ((width & 7) | (height & 3)) {
- GLint newWidth = (width + 7) & ~7;
- GLint newHeight = (height + 3) & ~3;
- newSource = malloc(comps * newWidth * newHeight * sizeof(GLchan));
- if (!newSource) {
- GET_CURRENT_CONTEXT(ctx);
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture compression");
- goto cleanUp;
- }
- _mesa_upscale_teximage2d(width, height, newWidth, newHeight,
- comps, (const GLchan *) source,
- srcRowStride, (GLchan *) newSource);
- source = newSource;
- width = newWidth;
- height = newHeight;
- srcRowStride = comps * newWidth;
- }
-
- /* convert from 16/32-bit channels to GLubyte if needed */
- if (CHAN_TYPE != GL_UNSIGNED_BYTE) {
- const GLuint n = width * height * comps;
- const GLchan *src = (const GLchan *) source;
- GLubyte *dest = (GLubyte *) malloc(n * sizeof(GLubyte));
- GLuint i;
- if (!dest) {
- GET_CURRENT_CONTEXT(ctx);
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture compression");
- goto cleanUp;
- }
- for (i = 0; i < n; i++) {
- dest[i] = CHAN_TO_UBYTE(src[i]);
- }
- if (newSource != NULL) {
- free(newSource);
- }
- newSource = dest; /* we'll free this buffer before returning */
- source = dest; /* the new, GLubyte incoming image */
- }
-
- data = (const GLubyte *) source;
- destRowStride = (destRowStride - width * 2) / 4;
- for (y = 0; y < height; y += 4) {
- GLuint offs = 0 + (y + 0) * srcRowStride;
- for (x = 0; x < width; x += 8) {
- const GLubyte *lines[4];
- lines[0] = &data[offs];
- lines[1] = lines[0] + srcRowStride;
- lines[2] = lines[1] + srcRowStride;
- lines[3] = lines[2] + srcRowStride;
- offs += 8 * comps;
- fxt1_quantize(encoded, lines, comps);
- /* 128 bits per 8x4 block */
- encoded += 4;
- }
- encoded += destRowStride;
- }
-
- cleanUp:
- if (newSource != NULL) {
- free(newSource);
- }
-}
-
-
-/***************************************************************************\
- * FXT1 decoder
- *
- * The decoder is based on GL_3DFX_texture_compression_FXT1
- * specification and serves as a concept for the encoder.
-\***************************************************************************/
-
-
-/* lookup table for scaling 5 bit colors up to 8 bits */
-static const GLubyte _rgb_scale_5[] = {
- 0, 8, 16, 25, 33, 41, 49, 58,
- 66, 74, 82, 90, 99, 107, 115, 123,
- 132, 140, 148, 156, 165, 173, 181, 189,
- 197, 206, 214, 222, 230, 239, 247, 255
-};
-
-/* lookup table for scaling 6 bit colors up to 8 bits */
-static const GLubyte _rgb_scale_6[] = {
- 0, 4, 8, 12, 16, 20, 24, 28,
- 32, 36, 40, 45, 49, 53, 57, 61,
- 65, 69, 73, 77, 81, 85, 89, 93,
- 97, 101, 105, 109, 113, 117, 121, 125,
- 130, 134, 138, 142, 146, 150, 154, 158,
- 162, 166, 170, 174, 178, 182, 186, 190,
- 194, 198, 202, 206, 210, 215, 219, 223,
- 227, 231, 235, 239, 243, 247, 251, 255
-};
-
-
-#define CC_SEL(cc, which) (((GLuint *)(cc))[(which) / 32] >> ((which) & 31))
-#define UP5(c) _rgb_scale_5[(c) & 31]
-#define UP6(c, b) _rgb_scale_6[(((c) & 31) << 1) | ((b) & 1)]
-#define LERP(n, t, c0, c1) (((n) - (t)) * (c0) + (t) * (c1) + (n) / 2) / (n)
-
-
-static void
-fxt1_decode_1HI (const GLubyte *code, GLint t, GLchan *rgba)
-{
- const GLuint *cc;
-
- t *= 3;
- cc = (const GLuint *)(code + t / 8);
- t = (cc[0] >> (t & 7)) & 7;
-
- if (t == 7) {
- rgba[RCOMP] = rgba[GCOMP] = rgba[BCOMP] = rgba[ACOMP] = 0;
- } else {
- GLubyte r, g, b;
- cc = (const GLuint *)(code + 12);
- if (t == 0) {
- b = UP5(CC_SEL(cc, 0));
- g = UP5(CC_SEL(cc, 5));
- r = UP5(CC_SEL(cc, 10));
- } else if (t == 6) {
- b = UP5(CC_SEL(cc, 15));
- g = UP5(CC_SEL(cc, 20));
- r = UP5(CC_SEL(cc, 25));
- } else {
- b = LERP(6, t, UP5(CC_SEL(cc, 0)), UP5(CC_SEL(cc, 15)));
- g = LERP(6, t, UP5(CC_SEL(cc, 5)), UP5(CC_SEL(cc, 20)));
- r = LERP(6, t, UP5(CC_SEL(cc, 10)), UP5(CC_SEL(cc, 25)));
- }
- rgba[RCOMP] = UBYTE_TO_CHAN(r);
- rgba[GCOMP] = UBYTE_TO_CHAN(g);
- rgba[BCOMP] = UBYTE_TO_CHAN(b);
- rgba[ACOMP] = CHAN_MAX;
- }
-}
-
-
-static void
-fxt1_decode_1CHROMA (const GLubyte *code, GLint t, GLchan *rgba)
-{
- const GLuint *cc;
- GLuint kk;
-
- cc = (const GLuint *)code;
- if (t & 16) {
- cc++;
- t &= 15;
- }
- t = (cc[0] >> (t * 2)) & 3;
-
- t *= 15;
- cc = (const GLuint *)(code + 8 + t / 8);
- kk = cc[0] >> (t & 7);
- rgba[BCOMP] = UBYTE_TO_CHAN( UP5(kk) );
- rgba[GCOMP] = UBYTE_TO_CHAN( UP5(kk >> 5) );
- rgba[RCOMP] = UBYTE_TO_CHAN( UP5(kk >> 10) );
- rgba[ACOMP] = CHAN_MAX;
-}
-
-
-static void
-fxt1_decode_1MIXED (const GLubyte *code, GLint t, GLchan *rgba)
-{
- const GLuint *cc;
- GLuint col[2][3];
- GLint glsb, selb;
-
- cc = (const GLuint *)code;
- if (t & 16) {
- t &= 15;
- t = (cc[1] >> (t * 2)) & 3;
- /* col 2 */
- col[0][BCOMP] = (*(const GLuint *)(code + 11)) >> 6;
- col[0][GCOMP] = CC_SEL(cc, 99);
- col[0][RCOMP] = CC_SEL(cc, 104);
- /* col 3 */
- col[1][BCOMP] = CC_SEL(cc, 109);
- col[1][GCOMP] = CC_SEL(cc, 114);
- col[1][RCOMP] = CC_SEL(cc, 119);
- glsb = CC_SEL(cc, 126);
- selb = CC_SEL(cc, 33);
- } else {
- t = (cc[0] >> (t * 2)) & 3;
- /* col 0 */
- col[0][BCOMP] = CC_SEL(cc, 64);
- col[0][GCOMP] = CC_SEL(cc, 69);
- col[0][RCOMP] = CC_SEL(cc, 74);
- /* col 1 */
- col[1][BCOMP] = CC_SEL(cc, 79);
- col[1][GCOMP] = CC_SEL(cc, 84);
- col[1][RCOMP] = CC_SEL(cc, 89);
- glsb = CC_SEL(cc, 125);
- selb = CC_SEL(cc, 1);
- }
-
- if (CC_SEL(cc, 124) & 1) {
- /* alpha[0] == 1 */
-
- if (t == 3) {
- /* zero */
- rgba[RCOMP] = rgba[BCOMP] = rgba[GCOMP] = rgba[ACOMP] = 0;
- } else {
- GLubyte r, g, b;
- if (t == 0) {
- b = UP5(col[0][BCOMP]);
- g = UP5(col[0][GCOMP]);
- r = UP5(col[0][RCOMP]);
- } else if (t == 2) {
- b = UP5(col[1][BCOMP]);
- g = UP6(col[1][GCOMP], glsb);
- r = UP5(col[1][RCOMP]);
- } else {
- b = (UP5(col[0][BCOMP]) + UP5(col[1][BCOMP])) / 2;
- g = (UP5(col[0][GCOMP]) + UP6(col[1][GCOMP], glsb)) / 2;
- r = (UP5(col[0][RCOMP]) + UP5(col[1][RCOMP])) / 2;
- }
- rgba[RCOMP] = UBYTE_TO_CHAN(r);
- rgba[GCOMP] = UBYTE_TO_CHAN(g);
- rgba[BCOMP] = UBYTE_TO_CHAN(b);
- rgba[ACOMP] = CHAN_MAX;
- }
- } else {
- /* alpha[0] == 0 */
- GLubyte r, g, b;
- if (t == 0) {
- b = UP5(col[0][BCOMP]);
- g = UP6(col[0][GCOMP], glsb ^ selb);
- r = UP5(col[0][RCOMP]);
- } else if (t == 3) {
- b = UP5(col[1][BCOMP]);
- g = UP6(col[1][GCOMP], glsb);
- r = UP5(col[1][RCOMP]);
- } else {
- b = LERP(3, t, UP5(col[0][BCOMP]), UP5(col[1][BCOMP]));
- g = LERP(3, t, UP6(col[0][GCOMP], glsb ^ selb),
- UP6(col[1][GCOMP], glsb));
- r = LERP(3, t, UP5(col[0][RCOMP]), UP5(col[1][RCOMP]));
- }
- rgba[RCOMP] = UBYTE_TO_CHAN(r);
- rgba[GCOMP] = UBYTE_TO_CHAN(g);
- rgba[BCOMP] = UBYTE_TO_CHAN(b);
- rgba[ACOMP] = CHAN_MAX;
- }
-}
-
-
-static void
-fxt1_decode_1ALPHA (const GLubyte *code, GLint t, GLchan *rgba)
-{
- const GLuint *cc;
- GLubyte r, g, b, a;
-
- cc = (const GLuint *)code;
- if (CC_SEL(cc, 124) & 1) {
- /* lerp == 1 */
- GLuint col0[4];
-
- if (t & 16) {
- t &= 15;
- t = (cc[1] >> (t * 2)) & 3;
- /* col 2 */
- col0[BCOMP] = (*(const GLuint *)(code + 11)) >> 6;
- col0[GCOMP] = CC_SEL(cc, 99);
- col0[RCOMP] = CC_SEL(cc, 104);
- col0[ACOMP] = CC_SEL(cc, 119);
- } else {
- t = (cc[0] >> (t * 2)) & 3;
- /* col 0 */
- col0[BCOMP] = CC_SEL(cc, 64);
- col0[GCOMP] = CC_SEL(cc, 69);
- col0[RCOMP] = CC_SEL(cc, 74);
- col0[ACOMP] = CC_SEL(cc, 109);
- }
-
- if (t == 0) {
- b = UP5(col0[BCOMP]);
- g = UP5(col0[GCOMP]);
- r = UP5(col0[RCOMP]);
- a = UP5(col0[ACOMP]);
- } else if (t == 3) {
- b = UP5(CC_SEL(cc, 79));
- g = UP5(CC_SEL(cc, 84));
- r = UP5(CC_SEL(cc, 89));
- a = UP5(CC_SEL(cc, 114));
- } else {
- b = LERP(3, t, UP5(col0[BCOMP]), UP5(CC_SEL(cc, 79)));
- g = LERP(3, t, UP5(col0[GCOMP]), UP5(CC_SEL(cc, 84)));
- r = LERP(3, t, UP5(col0[RCOMP]), UP5(CC_SEL(cc, 89)));
- a = LERP(3, t, UP5(col0[ACOMP]), UP5(CC_SEL(cc, 114)));
- }
- } else {
- /* lerp == 0 */
-
- if (t & 16) {
- cc++;
- t &= 15;
- }
- t = (cc[0] >> (t * 2)) & 3;
-
- if (t == 3) {
- /* zero */
- r = g = b = a = 0;
- } else {
- GLuint kk;
- cc = (const GLuint *)code;
- a = UP5(cc[3] >> (t * 5 + 13));
- t *= 15;
- cc = (const GLuint *)(code + 8 + t / 8);
- kk = cc[0] >> (t & 7);
- b = UP5(kk);
- g = UP5(kk >> 5);
- r = UP5(kk >> 10);
- }
- }
- rgba[RCOMP] = UBYTE_TO_CHAN(r);
- rgba[GCOMP] = UBYTE_TO_CHAN(g);
- rgba[BCOMP] = UBYTE_TO_CHAN(b);
- rgba[ACOMP] = UBYTE_TO_CHAN(a);
-}
-
-
-void
-fxt1_decode_1 (const void *texture, GLint stride, /* in pixels */
- GLint i, GLint j, GLchan *rgba)
-{
- static void (*decode_1[]) (const GLubyte *, GLint, GLchan *) = {
- fxt1_decode_1HI, /* cc-high = "00?" */
- fxt1_decode_1HI, /* cc-high = "00?" */
- fxt1_decode_1CHROMA, /* cc-chroma = "010" */
- fxt1_decode_1ALPHA, /* alpha = "011" */
- fxt1_decode_1MIXED, /* mixed = "1??" */
- fxt1_decode_1MIXED, /* mixed = "1??" */
- fxt1_decode_1MIXED, /* mixed = "1??" */
- fxt1_decode_1MIXED /* mixed = "1??" */
- };
-
- const GLubyte *code = (const GLubyte *)texture +
- ((j / 4) * (stride / 8) + (i / 8)) * 16;
- GLint mode = CC_SEL(code, 125);
- GLint t = i & 7;
-
- if (t & 4) {
- t += 12;
- }
- t += (j & 3) * 4;
-
- decode_1[mode](code, t, rgba);
-}
-
-
-#endif /* FEATURE_texture_fxt1 */
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.1
+ *
+ * Copyright (C) 1999-2008 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"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * 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.
+ */
+
+
+/**
+ * \file texcompress_fxt1.c
+ * GL_3DFX_texture_compression_FXT1 support.
+ */
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "colormac.h"
+#include "image.h"
+#include "macros.h"
+#include "mfeatures.h"
+#include "mipmap.h"
+#include "texcompress.h"
+#include "texcompress_fxt1.h"
+#include "texstore.h"
+#include "swrast/s_context.h"
+
+
+#if FEATURE_texture_fxt1
+
+
+static void
+fxt1_encode (GLuint width, GLuint height, GLint comps,
+ const void *source, GLint srcRowStride,
+ void *dest, GLint destRowStride);
+
+void
+fxt1_decode_1 (const void *texture, GLint stride,
+ GLint i, GLint j, GLchan *rgba);
+
+
+/**
+ * Store user's image in rgb_fxt1 format.
+ */
+GLboolean
+_mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS)
+{
+ const GLchan *pixels;
+ GLint srcRowStride;
+ GLubyte *dst;
+ const GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */
+ const GLchan *tempImage = NULL;
+
+ ASSERT(dstFormat == MESA_FORMAT_RGB_FXT1);
+ ASSERT(dstXoffset % 8 == 0);
+ ASSERT(dstYoffset % 4 == 0);
+ ASSERT(dstZoffset == 0);
+ (void) dstZoffset;
+ (void) dstImageOffsets;
+
+ if (srcFormat != GL_RGB ||
+ srcType != CHAN_TYPE ||
+ ctx->_ImageTransferState ||
+ srcPacking->SwapBytes) {
+ /* convert image to RGB/GLchan */
+ tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ _mesa_get_format_base_format(dstFormat),
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ if (!tempImage)
+ return GL_FALSE; /* out of memory */
+ pixels = tempImage;
+ srcRowStride = 3 * srcWidth;
+ srcFormat = GL_RGB;
+ }
+ else {
+ pixels = (const GLchan *) srcAddr;
+ srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
+ srcType) / sizeof(GLchan);
+ }
+
+ dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
+ dstFormat,
+ texWidth, (GLubyte *) dstAddr);
+
+ fxt1_encode(srcWidth, srcHeight, 3, pixels, srcRowStride,
+ dst, dstRowStride);
+
+ if (tempImage)
+ free((void*) tempImage);
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Store user's image in rgba_fxt1 format.
+ */
+GLboolean
+_mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS)
+{
+ const GLchan *pixels;
+ GLint srcRowStride;
+ GLubyte *dst;
+ GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */
+ const GLchan *tempImage = NULL;
+
+ ASSERT(dstFormat == MESA_FORMAT_RGBA_FXT1);
+ ASSERT(dstXoffset % 8 == 0);
+ ASSERT(dstYoffset % 4 == 0);
+ ASSERT(dstZoffset == 0);
+ (void) dstZoffset;
+ (void) dstImageOffsets;
+
+ if (srcFormat != GL_RGBA ||
+ srcType != CHAN_TYPE ||
+ ctx->_ImageTransferState ||
+ srcPacking->SwapBytes) {
+ /* convert image to RGBA/GLchan */
+ tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ _mesa_get_format_base_format(dstFormat),
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ if (!tempImage)
+ return GL_FALSE; /* out of memory */
+ pixels = tempImage;
+ srcRowStride = 4 * srcWidth;
+ srcFormat = GL_RGBA;
+ }
+ else {
+ pixels = (const GLchan *) srcAddr;
+ srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
+ srcType) / sizeof(GLchan);
+ }
+
+ dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
+ dstFormat,
+ texWidth, (GLubyte *) dstAddr);
+
+ fxt1_encode(srcWidth, srcHeight, 4, pixels, srcRowStride,
+ dst, dstRowStride);
+
+ if (tempImage)
+ free((void*) tempImage);
+
+ return GL_TRUE;
+}
+
+
+void
+_mesa_fetch_texel_2d_f_rgba_fxt1( const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ /* just sample as GLchan and convert to float here */
+ GLchan rgba[4];
+ (void) k;
+ fxt1_decode_1(texImage->Base.Data, texImage->Base.RowStride, i, j, rgba);
+ texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
+ texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
+ texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
+ texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
+}
+
+
+void
+_mesa_fetch_texel_2d_f_rgb_fxt1( const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ /* just sample as GLchan and convert to float here */
+ GLchan rgba[4];
+ (void) k;
+ fxt1_decode_1(texImage->Base.Data, texImage->Base.RowStride, i, j, rgba);
+ texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
+ texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
+ texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
+ texel[ACOMP] = 1.0F;
+}
+
+
+
+/***************************************************************************\
+ * FXT1 encoder
+ *
+ * The encoder was built by reversing the decoder,
+ * and is vaguely based on Texus2 by 3dfx. Note that this code
+ * is merely a proof of concept, since it is highly UNoptimized;
+ * moreover, it is sub-optimal due to initial conditions passed
+ * to Lloyd's algorithm (the interpolation modes are even worse).
+\***************************************************************************/
+
+
+#define MAX_COMP 4 /* ever needed maximum number of components in texel */
+#define MAX_VECT 4 /* ever needed maximum number of base vectors to find */
+#define N_TEXELS 32 /* number of texels in a block (always 32) */
+#define LL_N_REP 50 /* number of iterations in lloyd's vq */
+#define LL_RMS_D 10 /* fault tolerance (maximum delta) */
+#define LL_RMS_E 255 /* fault tolerance (maximum error) */
+#define ALPHA_TS 2 /* alpha threshold: (255 - ALPHA_TS) deemed opaque */
+#define ISTBLACK(v) (*((GLuint *)(v)) == 0)
+
+
+/*
+ * Define a 64-bit unsigned integer type and macros
+ */
+#if 1
+
+#define FX64_NATIVE 1
+
+typedef uint64_t Fx64;
+
+#define FX64_MOV32(a, b) a = b
+#define FX64_OR32(a, b) a |= b
+#define FX64_SHL(a, c) a <<= c
+
+#else
+
+#define FX64_NATIVE 0
+
+typedef struct {
+ GLuint lo, hi;
+} Fx64;
+
+#define FX64_MOV32(a, b) a.lo = b
+#define FX64_OR32(a, b) a.lo |= b
+
+#define FX64_SHL(a, c) \
+ do { \
+ if ((c) >= 32) { \
+ a.hi = a.lo << ((c) - 32); \
+ a.lo = 0; \
+ } else { \
+ a.hi = (a.hi << (c)) | (a.lo >> (32 - (c))); \
+ a.lo <<= (c); \
+ } \
+ } while (0)
+
+#endif
+
+
+#define F(i) (GLfloat)1 /* can be used to obtain an oblong metric: 0.30 / 0.59 / 0.11 */
+#define SAFECDOT 1 /* for paranoids */
+
+#define MAKEIVEC(NV, NC, IV, B, V0, V1) \
+ do { \
+ /* compute interpolation vector */ \
+ GLfloat d2 = 0.0F; \
+ GLfloat rd2; \
+ \
+ for (i = 0; i < NC; i++) { \
+ IV[i] = (V1[i] - V0[i]) * F(i); \
+ d2 += IV[i] * IV[i]; \
+ } \
+ rd2 = (GLfloat)NV / d2; \
+ B = 0; \
+ for (i = 0; i < NC; i++) { \
+ IV[i] *= F(i); \
+ B -= IV[i] * V0[i]; \
+ IV[i] *= rd2; \
+ } \
+ B = B * rd2 + 0.5f; \
+ } while (0)
+
+#define CALCCDOT(TEXEL, NV, NC, IV, B, V)\
+ do { \
+ GLfloat dot = 0.0F; \
+ for (i = 0; i < NC; i++) { \
+ dot += V[i] * IV[i]; \
+ } \
+ TEXEL = (GLint)(dot + B); \
+ if (SAFECDOT) { \
+ if (TEXEL < 0) { \
+ TEXEL = 0; \
+ } else if (TEXEL > NV) { \
+ TEXEL = NV; \
+ } \
+ } \
+ } while (0)
+
+
+static GLint
+fxt1_bestcol (GLfloat vec[][MAX_COMP], GLint nv,
+ GLubyte input[MAX_COMP], GLint nc)
+{
+ GLint i, j, best = -1;
+ GLfloat err = 1e9; /* big enough */
+
+ for (j = 0; j < nv; j++) {
+ GLfloat e = 0.0F;
+ for (i = 0; i < nc; i++) {
+ e += (vec[j][i] - input[i]) * (vec[j][i] - input[i]);
+ }
+ if (e < err) {
+ err = e;
+ best = j;
+ }
+ }
+
+ return best;
+}
+
+
+static GLint
+fxt1_worst (GLfloat vec[MAX_COMP],
+ GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n)
+{
+ GLint i, k, worst = -1;
+ GLfloat err = -1.0F; /* small enough */
+
+ for (k = 0; k < n; k++) {
+ GLfloat e = 0.0F;
+ for (i = 0; i < nc; i++) {
+ e += (vec[i] - input[k][i]) * (vec[i] - input[k][i]);
+ }
+ if (e > err) {
+ err = e;
+ worst = k;
+ }
+ }
+
+ return worst;
+}
+
+
+static GLint
+fxt1_variance (GLdouble variance[MAX_COMP],
+ GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n)
+{
+ GLint i, k, best = 0;
+ GLint sx, sx2;
+ GLdouble var, maxvar = -1; /* small enough */
+ GLdouble teenth = 1.0 / n;
+
+ for (i = 0; i < nc; i++) {
+ sx = sx2 = 0;
+ for (k = 0; k < n; k++) {
+ GLint t = input[k][i];
+ sx += t;
+ sx2 += t * t;
+ }
+ var = sx2 * teenth - sx * sx * teenth * teenth;
+ if (maxvar < var) {
+ maxvar = var;
+ best = i;
+ }
+ if (variance) {
+ variance[i] = var;
+ }
+ }
+
+ return best;
+}
+
+
+static GLint
+fxt1_choose (GLfloat vec[][MAX_COMP], GLint nv,
+ GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n)
+{
+#if 0
+ /* Choose colors from a grid.
+ */
+ GLint i, j;
+
+ for (j = 0; j < nv; j++) {
+ GLint m = j * (n - 1) / (nv - 1);
+ for (i = 0; i < nc; i++) {
+ vec[j][i] = input[m][i];
+ }
+ }
+#else
+ /* Our solution here is to find the darkest and brightest colors in
+ * the 8x4 tile and use those as the two representative colors.
+ * There are probably better algorithms to use (histogram-based).
+ */
+ GLint i, j, k;
+ GLint minSum = 2000; /* big enough */
+ GLint maxSum = -1; /* small enough */
+ GLint minCol = 0; /* phoudoin: silent compiler! */
+ GLint maxCol = 0; /* phoudoin: silent compiler! */
+
+ struct {
+ GLint flag;
+ GLint key;
+ GLint freq;
+ GLint idx;
+ } hist[N_TEXELS];
+ GLint lenh = 0;
+
+ memset(hist, 0, sizeof(hist));
+
+ for (k = 0; k < n; k++) {
+ GLint l;
+ GLint key = 0;
+ GLint sum = 0;
+ for (i = 0; i < nc; i++) {
+ key <<= 8;
+ key |= input[k][i];
+ sum += input[k][i];
+ }
+ for (l = 0; l < n; l++) {
+ if (!hist[l].flag) {
+ /* alloc new slot */
+ hist[l].flag = !0;
+ hist[l].key = key;
+ hist[l].freq = 1;
+ hist[l].idx = k;
+ lenh = l + 1;
+ break;
+ } else if (hist[l].key == key) {
+ hist[l].freq++;
+ break;
+ }
+ }
+ if (minSum > sum) {
+ minSum = sum;
+ minCol = k;
+ }
+ if (maxSum < sum) {
+ maxSum = sum;
+ maxCol = k;
+ }
+ }
+
+ if (lenh <= nv) {
+ for (j = 0; j < lenh; j++) {
+ for (i = 0; i < nc; i++) {
+ vec[j][i] = (GLfloat)input[hist[j].idx][i];
+ }
+ }
+ for (; j < nv; j++) {
+ for (i = 0; i < nc; i++) {
+ vec[j][i] = vec[0][i];
+ }
+ }
+ return 0;
+ }
+
+ for (j = 0; j < nv; j++) {
+ for (i = 0; i < nc; i++) {
+ vec[j][i] = ((nv - 1 - j) * input[minCol][i] + j * input[maxCol][i] + (nv - 1) / 2) / (GLfloat)(nv - 1);
+ }
+ }
+#endif
+
+ return !0;
+}
+
+
+static GLint
+fxt1_lloyd (GLfloat vec[][MAX_COMP], GLint nv,
+ GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n)
+{
+ /* Use the generalized lloyd's algorithm for VQ:
+ * find 4 color vectors.
+ *
+ * for each sample color
+ * sort to nearest vector.
+ *
+ * replace each vector with the centroid of its matching colors.
+ *
+ * repeat until RMS doesn't improve.
+ *
+ * if a color vector has no samples, or becomes the same as another
+ * vector, replace it with the color which is farthest from a sample.
+ *
+ * vec[][MAX_COMP] initial vectors and resulting colors
+ * nv number of resulting colors required
+ * input[N_TEXELS][MAX_COMP] input texels
+ * nc number of components in input / vec
+ * n number of input samples
+ */
+
+ GLint sum[MAX_VECT][MAX_COMP]; /* used to accumulate closest texels */
+ GLint cnt[MAX_VECT]; /* how many times a certain vector was chosen */
+ GLfloat error, lasterror = 1e9;
+
+ GLint i, j, k, rep;
+
+ /* the quantizer */
+ for (rep = 0; rep < LL_N_REP; rep++) {
+ /* reset sums & counters */
+ for (j = 0; j < nv; j++) {
+ for (i = 0; i < nc; i++) {
+ sum[j][i] = 0;
+ }
+ cnt[j] = 0;
+ }
+ error = 0;
+
+ /* scan whole block */
+ for (k = 0; k < n; k++) {
+#if 1
+ GLint best = -1;
+ GLfloat err = 1e9; /* big enough */
+ /* determine best vector */
+ for (j = 0; j < nv; j++) {
+ GLfloat e = (vec[j][0] - input[k][0]) * (vec[j][0] - input[k][0]) +
+ (vec[j][1] - input[k][1]) * (vec[j][1] - input[k][1]) +
+ (vec[j][2] - input[k][2]) * (vec[j][2] - input[k][2]);
+ if (nc == 4) {
+ e += (vec[j][3] - input[k][3]) * (vec[j][3] - input[k][3]);
+ }
+ if (e < err) {
+ err = e;
+ best = j;
+ }
+ }
+#else
+ GLint best = fxt1_bestcol(vec, nv, input[k], nc, &err);
+#endif
+ assert(best >= 0);
+ /* add in closest color */
+ for (i = 0; i < nc; i++) {
+ sum[best][i] += input[k][i];
+ }
+ /* mark this vector as used */
+ cnt[best]++;
+ /* accumulate error */
+ error += err;
+ }
+
+ /* check RMS */
+ if ((error < LL_RMS_E) ||
+ ((error < lasterror) && ((lasterror - error) < LL_RMS_D))) {
+ return !0; /* good match */
+ }
+ lasterror = error;
+
+ /* move each vector to the barycenter of its closest colors */
+ for (j = 0; j < nv; j++) {
+ if (cnt[j]) {
+ GLfloat div = 1.0F / cnt[j];
+ for (i = 0; i < nc; i++) {
+ vec[j][i] = div * sum[j][i];
+ }
+ } else {
+ /* this vec has no samples or is identical with a previous vec */
+ GLint worst = fxt1_worst(vec[j], input, nc, n);
+ for (i = 0; i < nc; i++) {
+ vec[j][i] = input[worst][i];
+ }
+ }
+ }
+ }
+
+ return 0; /* could not converge fast enough */
+}
+
+
+static void
+fxt1_quantize_CHROMA (GLuint *cc,
+ GLubyte input[N_TEXELS][MAX_COMP])
+{
+ const GLint n_vect = 4; /* 4 base vectors to find */
+ const GLint n_comp = 3; /* 3 components: R, G, B */
+ GLfloat vec[MAX_VECT][MAX_COMP];
+ GLint i, j, k;
+ Fx64 hi; /* high quadword */
+ GLuint lohi, lolo; /* low quadword: hi dword, lo dword */
+
+ if (fxt1_choose(vec, n_vect, input, n_comp, N_TEXELS) != 0) {
+ fxt1_lloyd(vec, n_vect, input, n_comp, N_TEXELS);
+ }
+
+ FX64_MOV32(hi, 4); /* cc-chroma = "010" + unused bit */
+ for (j = n_vect - 1; j >= 0; j--) {
+ for (i = 0; i < n_comp; i++) {
+ /* add in colors */
+ FX64_SHL(hi, 5);
+ FX64_OR32(hi, (GLuint)(vec[j][i] / 8.0F));
+ }
+ }
+ ((Fx64 *)cc)[1] = hi;
+
+ lohi = lolo = 0;
+ /* right microtile */
+ for (k = N_TEXELS - 1; k >= N_TEXELS/2; k--) {
+ lohi <<= 2;
+ lohi |= fxt1_bestcol(vec, n_vect, input[k], n_comp);
+ }
+ /* left microtile */
+ for (; k >= 0; k--) {
+ lolo <<= 2;
+ lolo |= fxt1_bestcol(vec, n_vect, input[k], n_comp);
+ }
+ cc[1] = lohi;
+ cc[0] = lolo;
+}
+
+
+static void
+fxt1_quantize_ALPHA0 (GLuint *cc,
+ GLubyte input[N_TEXELS][MAX_COMP],
+ GLubyte reord[N_TEXELS][MAX_COMP], GLint n)
+{
+ const GLint n_vect = 3; /* 3 base vectors to find */
+ const GLint n_comp = 4; /* 4 components: R, G, B, A */
+ GLfloat vec[MAX_VECT][MAX_COMP];
+ GLint i, j, k;
+ Fx64 hi; /* high quadword */
+ GLuint lohi, lolo; /* low quadword: hi dword, lo dword */
+
+ /* the last vector indicates zero */
+ for (i = 0; i < n_comp; i++) {
+ vec[n_vect][i] = 0;
+ }
+
+ /* the first n texels in reord are guaranteed to be non-zero */
+ if (fxt1_choose(vec, n_vect, reord, n_comp, n) != 0) {
+ fxt1_lloyd(vec, n_vect, reord, n_comp, n);
+ }
+
+ FX64_MOV32(hi, 6); /* alpha = "011" + lerp = 0 */
+ for (j = n_vect - 1; j >= 0; j--) {
+ /* add in alphas */
+ FX64_SHL(hi, 5);
+ FX64_OR32(hi, (GLuint)(vec[j][ACOMP] / 8.0F));
+ }
+ for (j = n_vect - 1; j >= 0; j--) {
+ for (i = 0; i < n_comp - 1; i++) {
+ /* add in colors */
+ FX64_SHL(hi, 5);
+ FX64_OR32(hi, (GLuint)(vec[j][i] / 8.0F));
+ }
+ }
+ ((Fx64 *)cc)[1] = hi;
+
+ lohi = lolo = 0;
+ /* right microtile */
+ for (k = N_TEXELS - 1; k >= N_TEXELS/2; k--) {
+ lohi <<= 2;
+ lohi |= fxt1_bestcol(vec, n_vect + 1, input[k], n_comp);
+ }
+ /* left microtile */
+ for (; k >= 0; k--) {
+ lolo <<= 2;
+ lolo |= fxt1_bestcol(vec, n_vect + 1, input[k], n_comp);
+ }
+ cc[1] = lohi;
+ cc[0] = lolo;
+}
+
+
+static void
+fxt1_quantize_ALPHA1 (GLuint *cc,
+ GLubyte input[N_TEXELS][MAX_COMP])
+{
+ const GLint n_vect = 3; /* highest vector number in each microtile */
+ const GLint n_comp = 4; /* 4 components: R, G, B, A */
+ GLfloat vec[1 + 1 + 1][MAX_COMP]; /* 1.5 extrema for each sub-block */
+ GLfloat b, iv[MAX_COMP]; /* interpolation vector */
+ GLint i, j, k;
+ Fx64 hi; /* high quadword */
+ GLuint lohi, lolo; /* low quadword: hi dword, lo dword */
+
+ GLint minSum;
+ GLint maxSum;
+ GLint minColL = 0, maxColL = 0;
+ GLint minColR = 0, maxColR = 0;
+ GLint sumL = 0, sumR = 0;
+ GLint nn_comp;
+ /* Our solution here is to find the darkest and brightest colors in
+ * the 4x4 tile and use those as the two representative colors.
+ * There are probably better algorithms to use (histogram-based).
+ */
+ nn_comp = n_comp;
+ while ((minColL == maxColL) && nn_comp) {
+ minSum = 2000; /* big enough */
+ maxSum = -1; /* small enough */
+ for (k = 0; k < N_TEXELS / 2; k++) {
+ GLint sum = 0;
+ for (i = 0; i < nn_comp; i++) {
+ sum += input[k][i];
+ }
+ if (minSum > sum) {
+ minSum = sum;
+ minColL = k;
+ }
+ if (maxSum < sum) {
+ maxSum = sum;
+ maxColL = k;
+ }
+ sumL += sum;
+ }
+
+ nn_comp--;
+ }
+
+ nn_comp = n_comp;
+ while ((minColR == maxColR) && nn_comp) {
+ minSum = 2000; /* big enough */
+ maxSum = -1; /* small enough */
+ for (k = N_TEXELS / 2; k < N_TEXELS; k++) {
+ GLint sum = 0;
+ for (i = 0; i < nn_comp; i++) {
+ sum += input[k][i];
+ }
+ if (minSum > sum) {
+ minSum = sum;
+ minColR = k;
+ }
+ if (maxSum < sum) {
+ maxSum = sum;
+ maxColR = k;
+ }
+ sumR += sum;
+ }
+
+ nn_comp--;
+ }
+
+ /* choose the common vector (yuck!) */
+ {
+ GLint j1, j2;
+ GLint v1 = 0, v2 = 0;
+ GLfloat err = 1e9; /* big enough */
+ GLfloat tv[2 * 2][MAX_COMP]; /* 2 extrema for each sub-block */
+ for (i = 0; i < n_comp; i++) {
+ tv[0][i] = input[minColL][i];
+ tv[1][i] = input[maxColL][i];
+ tv[2][i] = input[minColR][i];
+ tv[3][i] = input[maxColR][i];
+ }
+ for (j1 = 0; j1 < 2; j1++) {
+ for (j2 = 2; j2 < 4; j2++) {
+ GLfloat e = 0.0F;
+ for (i = 0; i < n_comp; i++) {
+ e += (tv[j1][i] - tv[j2][i]) * (tv[j1][i] - tv[j2][i]);
+ }
+ if (e < err) {
+ err = e;
+ v1 = j1;
+ v2 = j2;
+ }
+ }
+ }
+ for (i = 0; i < n_comp; i++) {
+ vec[0][i] = tv[1 - v1][i];
+ vec[1][i] = (tv[v1][i] * sumL + tv[v2][i] * sumR) / (sumL + sumR);
+ vec[2][i] = tv[5 - v2][i];
+ }
+ }
+
+ /* left microtile */
+ cc[0] = 0;
+ if (minColL != maxColL) {
+ /* compute interpolation vector */
+ MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]);
+
+ /* add in texels */
+ lolo = 0;
+ for (k = N_TEXELS / 2 - 1; k >= 0; k--) {
+ GLint texel;
+ /* interpolate color */
+ CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]);
+ /* add in texel */
+ lolo <<= 2;
+ lolo |= texel;
+ }
+
+ cc[0] = lolo;
+ }
+
+ /* right microtile */
+ cc[1] = 0;
+ if (minColR != maxColR) {
+ /* compute interpolation vector */
+ MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[1]);
+
+ /* add in texels */
+ lohi = 0;
+ for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) {
+ GLint texel;
+ /* interpolate color */
+ CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]);
+ /* add in texel */
+ lohi <<= 2;
+ lohi |= texel;
+ }
+
+ cc[1] = lohi;
+ }
+
+ FX64_MOV32(hi, 7); /* alpha = "011" + lerp = 1 */
+ for (j = n_vect - 1; j >= 0; j--) {
+ /* add in alphas */
+ FX64_SHL(hi, 5);
+ FX64_OR32(hi, (GLuint)(vec[j][ACOMP] / 8.0F));
+ }
+ for (j = n_vect - 1; j >= 0; j--) {
+ for (i = 0; i < n_comp - 1; i++) {
+ /* add in colors */
+ FX64_SHL(hi, 5);
+ FX64_OR32(hi, (GLuint)(vec[j][i] / 8.0F));
+ }
+ }
+ ((Fx64 *)cc)[1] = hi;
+}
+
+
+static void
+fxt1_quantize_HI (GLuint *cc,
+ GLubyte input[N_TEXELS][MAX_COMP],
+ GLubyte reord[N_TEXELS][MAX_COMP], GLint n)
+{
+ const GLint n_vect = 6; /* highest vector number */
+ const GLint n_comp = 3; /* 3 components: R, G, B */
+ GLfloat b = 0.0F; /* phoudoin: silent compiler! */
+ GLfloat iv[MAX_COMP]; /* interpolation vector */
+ GLint i, k;
+ GLuint hihi; /* high quadword: hi dword */
+
+ GLint minSum = 2000; /* big enough */
+ GLint maxSum = -1; /* small enough */
+ GLint minCol = 0; /* phoudoin: silent compiler! */
+ GLint maxCol = 0; /* phoudoin: silent compiler! */
+
+ /* Our solution here is to find the darkest and brightest colors in
+ * the 8x4 tile and use those as the two representative colors.
+ * There are probably better algorithms to use (histogram-based).
+ */
+ for (k = 0; k < n; k++) {
+ GLint sum = 0;
+ for (i = 0; i < n_comp; i++) {
+ sum += reord[k][i];
+ }
+ if (minSum > sum) {
+ minSum = sum;
+ minCol = k;
+ }
+ if (maxSum < sum) {
+ maxSum = sum;
+ maxCol = k;
+ }
+ }
+
+ hihi = 0; /* cc-hi = "00" */
+ for (i = 0; i < n_comp; i++) {
+ /* add in colors */
+ hihi <<= 5;
+ hihi |= reord[maxCol][i] >> 3;
+ }
+ for (i = 0; i < n_comp; i++) {
+ /* add in colors */
+ hihi <<= 5;
+ hihi |= reord[minCol][i] >> 3;
+ }
+ cc[3] = hihi;
+ cc[0] = cc[1] = cc[2] = 0;
+
+ /* compute interpolation vector */
+ if (minCol != maxCol) {
+ MAKEIVEC(n_vect, n_comp, iv, b, reord[minCol], reord[maxCol]);
+ }
+
+ /* add in texels */
+ for (k = N_TEXELS - 1; k >= 0; k--) {
+ GLint t = k * 3;
+ GLuint *kk = (GLuint *)((char *)cc + t / 8);
+ GLint texel = n_vect + 1; /* transparent black */
+
+ if (!ISTBLACK(input[k])) {
+ if (minCol != maxCol) {
+ /* interpolate color */
+ CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]);
+ /* add in texel */
+ kk[0] |= texel << (t & 7);
+ }
+ } else {
+ /* add in texel */
+ kk[0] |= texel << (t & 7);
+ }
+ }
+}
+
+
+static void
+fxt1_quantize_MIXED1 (GLuint *cc,
+ GLubyte input[N_TEXELS][MAX_COMP])
+{
+ const GLint n_vect = 2; /* highest vector number in each microtile */
+ const GLint n_comp = 3; /* 3 components: R, G, B */
+ GLubyte vec[2 * 2][MAX_COMP]; /* 2 extrema for each sub-block */
+ GLfloat b, iv[MAX_COMP]; /* interpolation vector */
+ GLint i, j, k;
+ Fx64 hi; /* high quadword */
+ GLuint lohi, lolo; /* low quadword: hi dword, lo dword */
+
+ GLint minSum;
+ GLint maxSum;
+ GLint minColL = 0, maxColL = -1;
+ GLint minColR = 0, maxColR = -1;
+
+ /* Our solution here is to find the darkest and brightest colors in
+ * the 4x4 tile and use those as the two representative colors.
+ * There are probably better algorithms to use (histogram-based).
+ */
+ minSum = 2000; /* big enough */
+ maxSum = -1; /* small enough */
+ for (k = 0; k < N_TEXELS / 2; k++) {
+ if (!ISTBLACK(input[k])) {
+ GLint sum = 0;
+ for (i = 0; i < n_comp; i++) {
+ sum += input[k][i];
+ }
+ if (minSum > sum) {
+ minSum = sum;
+ minColL = k;
+ }
+ if (maxSum < sum) {
+ maxSum = sum;
+ maxColL = k;
+ }
+ }
+ }
+ minSum = 2000; /* big enough */
+ maxSum = -1; /* small enough */
+ for (; k < N_TEXELS; k++) {
+ if (!ISTBLACK(input[k])) {
+ GLint sum = 0;
+ for (i = 0; i < n_comp; i++) {
+ sum += input[k][i];
+ }
+ if (minSum > sum) {
+ minSum = sum;
+ minColR = k;
+ }
+ if (maxSum < sum) {
+ maxSum = sum;
+ maxColR = k;
+ }
+ }
+ }
+
+ /* left microtile */
+ if (maxColL == -1) {
+ /* all transparent black */
+ cc[0] = ~0u;
+ for (i = 0; i < n_comp; i++) {
+ vec[0][i] = 0;
+ vec[1][i] = 0;
+ }
+ } else {
+ cc[0] = 0;
+ for (i = 0; i < n_comp; i++) {
+ vec[0][i] = input[minColL][i];
+ vec[1][i] = input[maxColL][i];
+ }
+ if (minColL != maxColL) {
+ /* compute interpolation vector */
+ MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]);
+
+ /* add in texels */
+ lolo = 0;
+ for (k = N_TEXELS / 2 - 1; k >= 0; k--) {
+ GLint texel = n_vect + 1; /* transparent black */
+ if (!ISTBLACK(input[k])) {
+ /* interpolate color */
+ CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]);
+ }
+ /* add in texel */
+ lolo <<= 2;
+ lolo |= texel;
+ }
+ cc[0] = lolo;
+ }
+ }
+
+ /* right microtile */
+ if (maxColR == -1) {
+ /* all transparent black */
+ cc[1] = ~0u;
+ for (i = 0; i < n_comp; i++) {
+ vec[2][i] = 0;
+ vec[3][i] = 0;
+ }
+ } else {
+ cc[1] = 0;
+ for (i = 0; i < n_comp; i++) {
+ vec[2][i] = input[minColR][i];
+ vec[3][i] = input[maxColR][i];
+ }
+ if (minColR != maxColR) {
+ /* compute interpolation vector */
+ MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[3]);
+
+ /* add in texels */
+ lohi = 0;
+ for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) {
+ GLint texel = n_vect + 1; /* transparent black */
+ if (!ISTBLACK(input[k])) {
+ /* interpolate color */
+ CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]);
+ }
+ /* add in texel */
+ lohi <<= 2;
+ lohi |= texel;
+ }
+ cc[1] = lohi;
+ }
+ }
+
+ FX64_MOV32(hi, 9 | (vec[3][GCOMP] & 4) | ((vec[1][GCOMP] >> 1) & 2)); /* chroma = "1" */
+ for (j = 2 * 2 - 1; j >= 0; j--) {
+ for (i = 0; i < n_comp; i++) {
+ /* add in colors */
+ FX64_SHL(hi, 5);
+ FX64_OR32(hi, vec[j][i] >> 3);
+ }
+ }
+ ((Fx64 *)cc)[1] = hi;
+}
+
+
+static void
+fxt1_quantize_MIXED0 (GLuint *cc,
+ GLubyte input[N_TEXELS][MAX_COMP])
+{
+ const GLint n_vect = 3; /* highest vector number in each microtile */
+ const GLint n_comp = 3; /* 3 components: R, G, B */
+ GLubyte vec[2 * 2][MAX_COMP]; /* 2 extrema for each sub-block */
+ GLfloat b, iv[MAX_COMP]; /* interpolation vector */
+ GLint i, j, k;
+ Fx64 hi; /* high quadword */
+ GLuint lohi, lolo; /* low quadword: hi dword, lo dword */
+
+ GLint minColL = 0, maxColL = 0;
+ GLint minColR = 0, maxColR = 0;
+#if 0
+ GLint minSum;
+ GLint maxSum;
+
+ /* Our solution here is to find the darkest and brightest colors in
+ * the 4x4 tile and use those as the two representative colors.
+ * There are probably better algorithms to use (histogram-based).
+ */
+ minSum = 2000; /* big enough */
+ maxSum = -1; /* small enough */
+ for (k = 0; k < N_TEXELS / 2; k++) {
+ GLint sum = 0;
+ for (i = 0; i < n_comp; i++) {
+ sum += input[k][i];
+ }
+ if (minSum > sum) {
+ minSum = sum;
+ minColL = k;
+ }
+ if (maxSum < sum) {
+ maxSum = sum;
+ maxColL = k;
+ }
+ }
+ minSum = 2000; /* big enough */
+ maxSum = -1; /* small enough */
+ for (; k < N_TEXELS; k++) {
+ GLint sum = 0;
+ for (i = 0; i < n_comp; i++) {
+ sum += input[k][i];
+ }
+ if (minSum > sum) {
+ minSum = sum;
+ minColR = k;
+ }
+ if (maxSum < sum) {
+ maxSum = sum;
+ maxColR = k;
+ }
+ }
+#else
+ GLint minVal;
+ GLint maxVal;
+ GLint maxVarL = fxt1_variance(NULL, input, n_comp, N_TEXELS / 2);
+ GLint maxVarR = fxt1_variance(NULL, &input[N_TEXELS / 2], n_comp, N_TEXELS / 2);
+
+ /* Scan the channel with max variance for lo & hi
+ * and use those as the two representative colors.
+ */
+ minVal = 2000; /* big enough */
+ maxVal = -1; /* small enough */
+ for (k = 0; k < N_TEXELS / 2; k++) {
+ GLint t = input[k][maxVarL];
+ if (minVal > t) {
+ minVal = t;
+ minColL = k;
+ }
+ if (maxVal < t) {
+ maxVal = t;
+ maxColL = k;
+ }
+ }
+ minVal = 2000; /* big enough */
+ maxVal = -1; /* small enough */
+ for (; k < N_TEXELS; k++) {
+ GLint t = input[k][maxVarR];
+ if (minVal > t) {
+ minVal = t;
+ minColR = k;
+ }
+ if (maxVal < t) {
+ maxVal = t;
+ maxColR = k;
+ }
+ }
+#endif
+
+ /* left microtile */
+ cc[0] = 0;
+ for (i = 0; i < n_comp; i++) {
+ vec[0][i] = input[minColL][i];
+ vec[1][i] = input[maxColL][i];
+ }
+ if (minColL != maxColL) {
+ /* compute interpolation vector */
+ MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]);
+
+ /* add in texels */
+ lolo = 0;
+ for (k = N_TEXELS / 2 - 1; k >= 0; k--) {
+ GLint texel;
+ /* interpolate color */
+ CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]);
+ /* add in texel */
+ lolo <<= 2;
+ lolo |= texel;
+ }
+
+ /* funky encoding for LSB of green */
+ if ((GLint)((lolo >> 1) & 1) != (((vec[1][GCOMP] ^ vec[0][GCOMP]) >> 2) & 1)) {
+ for (i = 0; i < n_comp; i++) {
+ vec[1][i] = input[minColL][i];
+ vec[0][i] = input[maxColL][i];
+ }
+ lolo = ~lolo;
+ }
+
+ cc[0] = lolo;
+ }
+
+ /* right microtile */
+ cc[1] = 0;
+ for (i = 0; i < n_comp; i++) {
+ vec[2][i] = input[minColR][i];
+ vec[3][i] = input[maxColR][i];
+ }
+ if (minColR != maxColR) {
+ /* compute interpolation vector */
+ MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[3]);
+
+ /* add in texels */
+ lohi = 0;
+ for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) {
+ GLint texel;
+ /* interpolate color */
+ CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]);
+ /* add in texel */
+ lohi <<= 2;
+ lohi |= texel;
+ }
+
+ /* funky encoding for LSB of green */
+ if ((GLint)((lohi >> 1) & 1) != (((vec[3][GCOMP] ^ vec[2][GCOMP]) >> 2) & 1)) {
+ for (i = 0; i < n_comp; i++) {
+ vec[3][i] = input[minColR][i];
+ vec[2][i] = input[maxColR][i];
+ }
+ lohi = ~lohi;
+ }
+
+ cc[1] = lohi;
+ }
+
+ FX64_MOV32(hi, 8 | (vec[3][GCOMP] & 4) | ((vec[1][GCOMP] >> 1) & 2)); /* chroma = "1" */
+ for (j = 2 * 2 - 1; j >= 0; j--) {
+ for (i = 0; i < n_comp; i++) {
+ /* add in colors */
+ FX64_SHL(hi, 5);
+ FX64_OR32(hi, vec[j][i] >> 3);
+ }
+ }
+ ((Fx64 *)cc)[1] = hi;
+}
+
+
+static void
+fxt1_quantize (GLuint *cc, const GLubyte *lines[], GLint comps)
+{
+ GLint trualpha;
+ GLubyte reord[N_TEXELS][MAX_COMP];
+
+ GLubyte input[N_TEXELS][MAX_COMP];
+ GLint i, k, l;
+
+ if (comps == 3) {
+ /* make the whole block opaque */
+ memset(input, -1, sizeof(input));
+ }
+
+ /* 8 texels each line */
+ for (l = 0; l < 4; l++) {
+ for (k = 0; k < 4; k++) {
+ for (i = 0; i < comps; i++) {
+ input[k + l * 4][i] = *lines[l]++;
+ }
+ }
+ for (; k < 8; k++) {
+ for (i = 0; i < comps; i++) {
+ input[k + l * 4 + 12][i] = *lines[l]++;
+ }
+ }
+ }
+
+ /* block layout:
+ * 00, 01, 02, 03, 08, 09, 0a, 0b
+ * 10, 11, 12, 13, 18, 19, 1a, 1b
+ * 04, 05, 06, 07, 0c, 0d, 0e, 0f
+ * 14, 15, 16, 17, 1c, 1d, 1e, 1f
+ */
+
+ /* [dBorca]
+ * stupidity flows forth from this
+ */
+ l = N_TEXELS;
+ trualpha = 0;
+ if (comps == 4) {
+ /* skip all transparent black texels */
+ l = 0;
+ for (k = 0; k < N_TEXELS; k++) {
+ /* test all components against 0 */
+ if (!ISTBLACK(input[k])) {
+ /* texel is not transparent black */
+ COPY_4UBV(reord[l], input[k]);
+ if (reord[l][ACOMP] < (255 - ALPHA_TS)) {
+ /* non-opaque texel */
+ trualpha = !0;
+ }
+ l++;
+ }
+ }
+ }
+
+#if 0
+ if (trualpha) {
+ fxt1_quantize_ALPHA0(cc, input, reord, l);
+ } else if (l == 0) {
+ cc[0] = cc[1] = cc[2] = -1;
+ cc[3] = 0;
+ } else if (l < N_TEXELS) {
+ fxt1_quantize_HI(cc, input, reord, l);
+ } else {
+ fxt1_quantize_CHROMA(cc, input);
+ }
+ (void)fxt1_quantize_ALPHA1;
+ (void)fxt1_quantize_MIXED1;
+ (void)fxt1_quantize_MIXED0;
+#else
+ if (trualpha) {
+ fxt1_quantize_ALPHA1(cc, input);
+ } else if (l == 0) {
+ cc[0] = cc[1] = cc[2] = ~0u;
+ cc[3] = 0;
+ } else if (l < N_TEXELS) {
+ fxt1_quantize_MIXED1(cc, input);
+ } else {
+ fxt1_quantize_MIXED0(cc, input);
+ }
+ (void)fxt1_quantize_ALPHA0;
+ (void)fxt1_quantize_HI;
+ (void)fxt1_quantize_CHROMA;
+#endif
+}
+
+
+static void
+fxt1_encode (GLuint width, GLuint height, GLint comps,
+ const void *source, GLint srcRowStride,
+ void *dest, GLint destRowStride)
+{
+ GLuint x, y;
+ const GLubyte *data;
+ GLuint *encoded = (GLuint *)dest;
+ void *newSource = NULL;
+
+ assert(comps == 3 || comps == 4);
+
+ /* Replicate image if width is not M8 or height is not M4 */
+ if ((width & 7) | (height & 3)) {
+ GLint newWidth = (width + 7) & ~7;
+ GLint newHeight = (height + 3) & ~3;
+ newSource = malloc(comps * newWidth * newHeight * sizeof(GLchan));
+ if (!newSource) {
+ GET_CURRENT_CONTEXT(ctx);
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture compression");
+ goto cleanUp;
+ }
+ _mesa_upscale_teximage2d(width, height, newWidth, newHeight,
+ comps, (const GLchan *) source,
+ srcRowStride, (GLchan *) newSource);
+ source = newSource;
+ width = newWidth;
+ height = newHeight;
+ srcRowStride = comps * newWidth;
+ }
+
+ /* convert from 16/32-bit channels to GLubyte if needed */
+ if (CHAN_TYPE != GL_UNSIGNED_BYTE) {
+ const GLuint n = width * height * comps;
+ const GLchan *src = (const GLchan *) source;
+ GLubyte *dest = (GLubyte *) malloc(n * sizeof(GLubyte));
+ GLuint i;
+ if (!dest) {
+ GET_CURRENT_CONTEXT(ctx);
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture compression");
+ goto cleanUp;
+ }
+ for (i = 0; i < n; i++) {
+ dest[i] = CHAN_TO_UBYTE(src[i]);
+ }
+ if (newSource != NULL) {
+ free(newSource);
+ }
+ newSource = dest; /* we'll free this buffer before returning */
+ source = dest; /* the new, GLubyte incoming image */
+ }
+
+ data = (const GLubyte *) source;
+ destRowStride = (destRowStride - width * 2) / 4;
+ for (y = 0; y < height; y += 4) {
+ GLuint offs = 0 + (y + 0) * srcRowStride;
+ for (x = 0; x < width; x += 8) {
+ const GLubyte *lines[4];
+ lines[0] = &data[offs];
+ lines[1] = lines[0] + srcRowStride;
+ lines[2] = lines[1] + srcRowStride;
+ lines[3] = lines[2] + srcRowStride;
+ offs += 8 * comps;
+ fxt1_quantize(encoded, lines, comps);
+ /* 128 bits per 8x4 block */
+ encoded += 4;
+ }
+ encoded += destRowStride;
+ }
+
+ cleanUp:
+ if (newSource != NULL) {
+ free(newSource);
+ }
+}
+
+
+/***************************************************************************\
+ * FXT1 decoder
+ *
+ * The decoder is based on GL_3DFX_texture_compression_FXT1
+ * specification and serves as a concept for the encoder.
+\***************************************************************************/
+
+
+/* lookup table for scaling 5 bit colors up to 8 bits */
+static const GLubyte _rgb_scale_5[] = {
+ 0, 8, 16, 25, 33, 41, 49, 58,
+ 66, 74, 82, 90, 99, 107, 115, 123,
+ 132, 140, 148, 156, 165, 173, 181, 189,
+ 197, 206, 214, 222, 230, 239, 247, 255
+};
+
+/* lookup table for scaling 6 bit colors up to 8 bits */
+static const GLubyte _rgb_scale_6[] = {
+ 0, 4, 8, 12, 16, 20, 24, 28,
+ 32, 36, 40, 45, 49, 53, 57, 61,
+ 65, 69, 73, 77, 81, 85, 89, 93,
+ 97, 101, 105, 109, 113, 117, 121, 125,
+ 130, 134, 138, 142, 146, 150, 154, 158,
+ 162, 166, 170, 174, 178, 182, 186, 190,
+ 194, 198, 202, 206, 210, 215, 219, 223,
+ 227, 231, 235, 239, 243, 247, 251, 255
+};
+
+
+#define CC_SEL(cc, which) (((GLuint *)(cc))[(which) / 32] >> ((which) & 31))
+#define UP5(c) _rgb_scale_5[(c) & 31]
+#define UP6(c, b) _rgb_scale_6[(((c) & 31) << 1) | ((b) & 1)]
+#define LERP(n, t, c0, c1) (((n) - (t)) * (c0) + (t) * (c1) + (n) / 2) / (n)
+
+
+static void
+fxt1_decode_1HI (const GLubyte *code, GLint t, GLchan *rgba)
+{
+ const GLuint *cc;
+
+ t *= 3;
+ cc = (const GLuint *)(code + t / 8);
+ t = (cc[0] >> (t & 7)) & 7;
+
+ if (t == 7) {
+ rgba[RCOMP] = rgba[GCOMP] = rgba[BCOMP] = rgba[ACOMP] = 0;
+ } else {
+ GLubyte r, g, b;
+ cc = (const GLuint *)(code + 12);
+ if (t == 0) {
+ b = UP5(CC_SEL(cc, 0));
+ g = UP5(CC_SEL(cc, 5));
+ r = UP5(CC_SEL(cc, 10));
+ } else if (t == 6) {
+ b = UP5(CC_SEL(cc, 15));
+ g = UP5(CC_SEL(cc, 20));
+ r = UP5(CC_SEL(cc, 25));
+ } else {
+ b = LERP(6, t, UP5(CC_SEL(cc, 0)), UP5(CC_SEL(cc, 15)));
+ g = LERP(6, t, UP5(CC_SEL(cc, 5)), UP5(CC_SEL(cc, 20)));
+ r = LERP(6, t, UP5(CC_SEL(cc, 10)), UP5(CC_SEL(cc, 25)));
+ }
+ rgba[RCOMP] = UBYTE_TO_CHAN(r);
+ rgba[GCOMP] = UBYTE_TO_CHAN(g);
+ rgba[BCOMP] = UBYTE_TO_CHAN(b);
+ rgba[ACOMP] = CHAN_MAX;
+ }
+}
+
+
+static void
+fxt1_decode_1CHROMA (const GLubyte *code, GLint t, GLchan *rgba)
+{
+ const GLuint *cc;
+ GLuint kk;
+
+ cc = (const GLuint *)code;
+ if (t & 16) {
+ cc++;
+ t &= 15;
+ }
+ t = (cc[0] >> (t * 2)) & 3;
+
+ t *= 15;
+ cc = (const GLuint *)(code + 8 + t / 8);
+ kk = cc[0] >> (t & 7);
+ rgba[BCOMP] = UBYTE_TO_CHAN( UP5(kk) );
+ rgba[GCOMP] = UBYTE_TO_CHAN( UP5(kk >> 5) );
+ rgba[RCOMP] = UBYTE_TO_CHAN( UP5(kk >> 10) );
+ rgba[ACOMP] = CHAN_MAX;
+}
+
+
+static void
+fxt1_decode_1MIXED (const GLubyte *code, GLint t, GLchan *rgba)
+{
+ const GLuint *cc;
+ GLuint col[2][3];
+ GLint glsb, selb;
+
+ cc = (const GLuint *)code;
+ if (t & 16) {
+ t &= 15;
+ t = (cc[1] >> (t * 2)) & 3;
+ /* col 2 */
+ col[0][BCOMP] = (*(const GLuint *)(code + 11)) >> 6;
+ col[0][GCOMP] = CC_SEL(cc, 99);
+ col[0][RCOMP] = CC_SEL(cc, 104);
+ /* col 3 */
+ col[1][BCOMP] = CC_SEL(cc, 109);
+ col[1][GCOMP] = CC_SEL(cc, 114);
+ col[1][RCOMP] = CC_SEL(cc, 119);
+ glsb = CC_SEL(cc, 126);
+ selb = CC_SEL(cc, 33);
+ } else {
+ t = (cc[0] >> (t * 2)) & 3;
+ /* col 0 */
+ col[0][BCOMP] = CC_SEL(cc, 64);
+ col[0][GCOMP] = CC_SEL(cc, 69);
+ col[0][RCOMP] = CC_SEL(cc, 74);
+ /* col 1 */
+ col[1][BCOMP] = CC_SEL(cc, 79);
+ col[1][GCOMP] = CC_SEL(cc, 84);
+ col[1][RCOMP] = CC_SEL(cc, 89);
+ glsb = CC_SEL(cc, 125);
+ selb = CC_SEL(cc, 1);
+ }
+
+ if (CC_SEL(cc, 124) & 1) {
+ /* alpha[0] == 1 */
+
+ if (t == 3) {
+ /* zero */
+ rgba[RCOMP] = rgba[BCOMP] = rgba[GCOMP] = rgba[ACOMP] = 0;
+ } else {
+ GLubyte r, g, b;
+ if (t == 0) {
+ b = UP5(col[0][BCOMP]);
+ g = UP5(col[0][GCOMP]);
+ r = UP5(col[0][RCOMP]);
+ } else if (t == 2) {
+ b = UP5(col[1][BCOMP]);
+ g = UP6(col[1][GCOMP], glsb);
+ r = UP5(col[1][RCOMP]);
+ } else {
+ b = (UP5(col[0][BCOMP]) + UP5(col[1][BCOMP])) / 2;
+ g = (UP5(col[0][GCOMP]) + UP6(col[1][GCOMP], glsb)) / 2;
+ r = (UP5(col[0][RCOMP]) + UP5(col[1][RCOMP])) / 2;
+ }
+ rgba[RCOMP] = UBYTE_TO_CHAN(r);
+ rgba[GCOMP] = UBYTE_TO_CHAN(g);
+ rgba[BCOMP] = UBYTE_TO_CHAN(b);
+ rgba[ACOMP] = CHAN_MAX;
+ }
+ } else {
+ /* alpha[0] == 0 */
+ GLubyte r, g, b;
+ if (t == 0) {
+ b = UP5(col[0][BCOMP]);
+ g = UP6(col[0][GCOMP], glsb ^ selb);
+ r = UP5(col[0][RCOMP]);
+ } else if (t == 3) {
+ b = UP5(col[1][BCOMP]);
+ g = UP6(col[1][GCOMP], glsb);
+ r = UP5(col[1][RCOMP]);
+ } else {
+ b = LERP(3, t, UP5(col[0][BCOMP]), UP5(col[1][BCOMP]));
+ g = LERP(3, t, UP6(col[0][GCOMP], glsb ^ selb),
+ UP6(col[1][GCOMP], glsb));
+ r = LERP(3, t, UP5(col[0][RCOMP]), UP5(col[1][RCOMP]));
+ }
+ rgba[RCOMP] = UBYTE_TO_CHAN(r);
+ rgba[GCOMP] = UBYTE_TO_CHAN(g);
+ rgba[BCOMP] = UBYTE_TO_CHAN(b);
+ rgba[ACOMP] = CHAN_MAX;
+ }
+}
+
+
+static void
+fxt1_decode_1ALPHA (const GLubyte *code, GLint t, GLchan *rgba)
+{
+ const GLuint *cc;
+ GLubyte r, g, b, a;
+
+ cc = (const GLuint *)code;
+ if (CC_SEL(cc, 124) & 1) {
+ /* lerp == 1 */
+ GLuint col0[4];
+
+ if (t & 16) {
+ t &= 15;
+ t = (cc[1] >> (t * 2)) & 3;
+ /* col 2 */
+ col0[BCOMP] = (*(const GLuint *)(code + 11)) >> 6;
+ col0[GCOMP] = CC_SEL(cc, 99);
+ col0[RCOMP] = CC_SEL(cc, 104);
+ col0[ACOMP] = CC_SEL(cc, 119);
+ } else {
+ t = (cc[0] >> (t * 2)) & 3;
+ /* col 0 */
+ col0[BCOMP] = CC_SEL(cc, 64);
+ col0[GCOMP] = CC_SEL(cc, 69);
+ col0[RCOMP] = CC_SEL(cc, 74);
+ col0[ACOMP] = CC_SEL(cc, 109);
+ }
+
+ if (t == 0) {
+ b = UP5(col0[BCOMP]);
+ g = UP5(col0[GCOMP]);
+ r = UP5(col0[RCOMP]);
+ a = UP5(col0[ACOMP]);
+ } else if (t == 3) {
+ b = UP5(CC_SEL(cc, 79));
+ g = UP5(CC_SEL(cc, 84));
+ r = UP5(CC_SEL(cc, 89));
+ a = UP5(CC_SEL(cc, 114));
+ } else {
+ b = LERP(3, t, UP5(col0[BCOMP]), UP5(CC_SEL(cc, 79)));
+ g = LERP(3, t, UP5(col0[GCOMP]), UP5(CC_SEL(cc, 84)));
+ r = LERP(3, t, UP5(col0[RCOMP]), UP5(CC_SEL(cc, 89)));
+ a = LERP(3, t, UP5(col0[ACOMP]), UP5(CC_SEL(cc, 114)));
+ }
+ } else {
+ /* lerp == 0 */
+
+ if (t & 16) {
+ cc++;
+ t &= 15;
+ }
+ t = (cc[0] >> (t * 2)) & 3;
+
+ if (t == 3) {
+ /* zero */
+ r = g = b = a = 0;
+ } else {
+ GLuint kk;
+ cc = (const GLuint *)code;
+ a = UP5(cc[3] >> (t * 5 + 13));
+ t *= 15;
+ cc = (const GLuint *)(code + 8 + t / 8);
+ kk = cc[0] >> (t & 7);
+ b = UP5(kk);
+ g = UP5(kk >> 5);
+ r = UP5(kk >> 10);
+ }
+ }
+ rgba[RCOMP] = UBYTE_TO_CHAN(r);
+ rgba[GCOMP] = UBYTE_TO_CHAN(g);
+ rgba[BCOMP] = UBYTE_TO_CHAN(b);
+ rgba[ACOMP] = UBYTE_TO_CHAN(a);
+}
+
+
+void
+fxt1_decode_1 (const void *texture, GLint stride, /* in pixels */
+ GLint i, GLint j, GLchan *rgba)
+{
+ static void (*decode_1[]) (const GLubyte *, GLint, GLchan *) = {
+ fxt1_decode_1HI, /* cc-high = "00?" */
+ fxt1_decode_1HI, /* cc-high = "00?" */
+ fxt1_decode_1CHROMA, /* cc-chroma = "010" */
+ fxt1_decode_1ALPHA, /* alpha = "011" */
+ fxt1_decode_1MIXED, /* mixed = "1??" */
+ fxt1_decode_1MIXED, /* mixed = "1??" */
+ fxt1_decode_1MIXED, /* mixed = "1??" */
+ fxt1_decode_1MIXED /* mixed = "1??" */
+ };
+
+ const GLubyte *code = (const GLubyte *)texture +
+ ((j / 4) * (stride / 8) + (i / 8)) * 16;
+ GLint mode = CC_SEL(code, 125);
+ GLint t = i & 7;
+
+ if (t & 4) {
+ t += 12;
+ }
+ t += (j & 3) * 4;
+
+ decode_1[mode](code, t, rgba);
+}
+
+
+#endif /* FEATURE_texture_fxt1 */
diff --git a/mesalib/src/mesa/main/texcompress_fxt1.h b/mesalib/src/mesa/main/texcompress_fxt1.h
index a6beb07e5..bd84082e9 100644
--- a/mesalib/src/mesa/main/texcompress_fxt1.h
+++ b/mesalib/src/mesa/main/texcompress_fxt1.h
@@ -1,62 +1,62 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.1
- *
- * Copyright (C) 1999-2008 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"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#ifndef TEXCOMPRESS_FXT1_H
-#define TEXCOMPRESS_FXT1_H
-
-#include "glheader.h"
-#include "mfeatures.h"
-#include "texstore.h"
-
-struct gl_texture_image;
-
-#if FEATURE_texture_fxt1
-
-extern GLboolean
-_mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS);
-
-extern GLboolean
-_mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS);
-
-extern void
-_mesa_fetch_texel_2d_f_rgba_fxt1(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-extern void
-_mesa_fetch_texel_2d_f_rgb_fxt1(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-#else /* FEATURE_texture_fxt1 */
-
-/* these are used only in texstore_funcs[] */
-#define _mesa_texstore_rgb_fxt1 NULL
-#define _mesa_texstore_rgba_fxt1 NULL
-
-/* these are used only in texfetch_funcs[] */
-#define _mesa_fetch_texel_2d_f_rgba_fxt1 NULL
-#define _mesa_fetch_texel_2d_f_rgb_fxt1 NULL
-
-#endif /* FEATURE_texture_fxt1 */
-
-#endif /* TEXCOMPRESS_FXT1_H */
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.1
+ *
+ * Copyright (C) 1999-2008 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"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * 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.
+ */
+
+#ifndef TEXCOMPRESS_FXT1_H
+#define TEXCOMPRESS_FXT1_H
+
+#include "glheader.h"
+#include "mfeatures.h"
+#include "texstore.h"
+
+struct swrast_texture_image;
+
+#if FEATURE_texture_fxt1
+
+extern GLboolean
+_mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS);
+
+extern GLboolean
+_mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS);
+
+extern void
+_mesa_fetch_texel_2d_f_rgba_fxt1(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_fetch_texel_2d_f_rgb_fxt1(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
+
+#else /* FEATURE_texture_fxt1 */
+
+/* these are used only in texstore_funcs[] */
+#define _mesa_texstore_rgb_fxt1 NULL
+#define _mesa_texstore_rgba_fxt1 NULL
+
+/* these are used only in texfetch_funcs[] */
+#define _mesa_fetch_texel_2d_f_rgba_fxt1 NULL
+#define _mesa_fetch_texel_2d_f_rgb_fxt1 NULL
+
+#endif /* FEATURE_texture_fxt1 */
+
+#endif /* TEXCOMPRESS_FXT1_H */
diff --git a/mesalib/src/mesa/main/texcompress_rgtc.c b/mesalib/src/mesa/main/texcompress_rgtc.c
index d75546a92..7af3d6762 100644
--- a/mesalib/src/mesa/main/texcompress_rgtc.c
+++ b/mesalib/src/mesa/main/texcompress_rgtc.c
@@ -1,460 +1,462 @@
-/*
- * Copyright (C) 2011 Red Hat Inc.
- *
- * block compression parts are:
- * Copyright (C) 2004 Roland Scheidegger 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"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * 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
- * 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.
- *
- * Author:
- * Dave Airlie
- */
-
-/**
- * \file texcompress_rgtc.c
- * GL_EXT_texture_compression_rgtc support.
- */
-
-
-#include "glheader.h"
-#include "imports.h"
-#include "colormac.h"
-#include "image.h"
-#include "macros.h"
-#include "mfeatures.h"
-#include "mipmap.h"
-#include "texcompress.h"
-#include "texcompress_rgtc.h"
-#include "texstore.h"
-
-#define RGTC_DEBUG 0
-
-static void unsigned_encode_rgtc_chan(GLubyte *blkaddr, GLubyte srccolors[4][4],
- GLint numxpixels, GLint numypixels);
-static void signed_encode_rgtc_chan(GLbyte *blkaddr, GLbyte srccolors[4][4],
- GLint numxpixels, GLint numypixels);
-
-static void unsigned_fetch_texel_rgtc(unsigned srcRowStride, const GLubyte *pixdata,
- unsigned i, unsigned j, GLubyte *value, unsigned comps);
-
-static void signed_fetch_texel_rgtc(unsigned srcRowStride, const GLbyte *pixdata,
- unsigned i, unsigned j, GLbyte *value, unsigned comps);
-
-static void extractsrc_u( GLubyte srcpixels[4][4], const GLchan *srcaddr,
- GLint srcRowStride, GLint numxpixels, GLint numypixels, GLint comps)
-{
- GLubyte i, j;
- const GLchan *curaddr;
- for (j = 0; j < numypixels; j++) {
- curaddr = srcaddr + j * srcRowStride * comps;
- for (i = 0; i < numxpixels; i++) {
- srcpixels[j][i] = *curaddr / (CHAN_MAX / 255);
- curaddr += comps;
- }
- }
-}
-
-static void extractsrc_s( GLbyte srcpixels[4][4], const GLfloat *srcaddr,
- GLint srcRowStride, GLint numxpixels, GLint numypixels, GLint comps)
-{
- GLubyte i, j;
- const GLfloat *curaddr;
- for (j = 0; j < numypixels; j++) {
- curaddr = srcaddr + j * srcRowStride * comps;
- for (i = 0; i < numxpixels; i++) {
- srcpixels[j][i] = FLOAT_TO_BYTE_TEX(*curaddr);
- curaddr += comps;
- }
- }
-}
-
-
-GLboolean
-_mesa_texstore_red_rgtc1(TEXSTORE_PARAMS)
-{
- GLubyte *dst;
- const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
- const GLchan *tempImage = NULL;
- int i, j;
- int numxpixels, numypixels;
- const GLchan *srcaddr;
- GLubyte srcpixels[4][4];
- GLubyte *blkaddr;
- GLint dstRowDiff;
- ASSERT(dstFormat == MESA_FORMAT_RED_RGTC1 ||
- dstFormat == MESA_FORMAT_L_LATC1);
- ASSERT(dstXoffset % 4 == 0);
- ASSERT(dstYoffset % 4 == 0);
- ASSERT(dstZoffset % 4 == 0);
- (void) dstZoffset;
- (void) dstImageOffsets;
-
-
- tempImage = _mesa_make_temp_chan_image(ctx, dims,
- baseInternalFormat,
- _mesa_get_format_base_format(dstFormat),
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- if (!tempImage)
- return GL_FALSE; /* out of memory */
-
- dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
- dstFormat,
- texWidth, (GLubyte *) dstAddr);
-
- blkaddr = dst;
- dstRowDiff = dstRowStride >= (srcWidth * 2) ? dstRowStride - (((srcWidth + 3) & ~3) * 2) : 0;
- for (j = 0; j < srcHeight; j+=4) {
- if (srcHeight > j + 3) numypixels = 4;
- else numypixels = srcHeight - j;
- srcaddr = tempImage + j * srcWidth;
- for (i = 0; i < srcWidth; i += 4) {
- if (srcWidth > i + 3) numxpixels = 4;
- else numxpixels = srcWidth - i;
- extractsrc_u(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 1);
- unsigned_encode_rgtc_chan(blkaddr, srcpixels, numxpixels, numypixels);
- srcaddr += numxpixels;
- blkaddr += 8;
- }
- blkaddr += dstRowDiff;
- }
- if (tempImage)
- free((void *) tempImage);
-
- return GL_TRUE;
-}
-
-GLboolean
-_mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS)
-{
- GLbyte *dst;
- const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
- const GLfloat *tempImage = NULL;
- int i, j;
- int numxpixels, numypixels;
- const GLfloat *srcaddr;
- GLbyte srcpixels[4][4];
- GLbyte *blkaddr;
- GLint dstRowDiff;
- ASSERT(dstFormat == MESA_FORMAT_SIGNED_RED_RGTC1 ||
- dstFormat == MESA_FORMAT_SIGNED_L_LATC1);
- ASSERT(dstXoffset % 4 == 0);
- ASSERT(dstYoffset % 4 == 0);
- ASSERT(dstZoffset % 4 == 0);
- (void) dstZoffset;
- (void) dstImageOffsets;
-
- tempImage = _mesa_make_temp_float_image(ctx, dims,
- baseInternalFormat,
- _mesa_get_format_base_format(dstFormat),
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking, 0x0);
- if (!tempImage)
- return GL_FALSE; /* out of memory */
-
- dst = (GLbyte *)_mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
- dstFormat,
- texWidth, (GLubyte *) dstAddr);
-
- blkaddr = dst;
- dstRowDiff = dstRowStride >= (srcWidth * 2) ? dstRowStride - (((srcWidth + 3) & ~3) * 2) : 0;
- for (j = 0; j < srcHeight; j+=4) {
- if (srcHeight > j + 3) numypixels = 4;
- else numypixels = srcHeight - j;
- srcaddr = tempImage + j * srcWidth;
- for (i = 0; i < srcWidth; i += 4) {
- if (srcWidth > i + 3) numxpixels = 4;
- else numxpixels = srcWidth - i;
- extractsrc_s(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 1);
- signed_encode_rgtc_chan(blkaddr, srcpixels, numxpixels, numypixels);
- srcaddr += numxpixels;
- blkaddr += 8;
- }
- blkaddr += dstRowDiff;
- }
- if (tempImage)
- free((void *) tempImage);
-
- return GL_TRUE;
-}
-
-GLboolean
-_mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS)
-{
- GLubyte *dst;
- const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
- const GLchan *tempImage = NULL;
- int i, j;
- int numxpixels, numypixels;
- const GLchan *srcaddr;
- GLubyte srcpixels[4][4];
- GLubyte *blkaddr;
- GLint dstRowDiff;
-
- ASSERT(dstFormat == MESA_FORMAT_RG_RGTC2 ||
- dstFormat == MESA_FORMAT_LA_LATC2);
- ASSERT(dstXoffset % 4 == 0);
- ASSERT(dstYoffset % 4 == 0);
- ASSERT(dstZoffset % 4 == 0);
- (void) dstZoffset;
- (void) dstImageOffsets;
-
- tempImage = _mesa_make_temp_chan_image(ctx, dims,
- baseInternalFormat,
- _mesa_get_format_base_format(dstFormat),
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- if (!tempImage)
- return GL_FALSE; /* out of memory */
-
- dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
- dstFormat,
- texWidth, (GLubyte *) dstAddr);
-
- blkaddr = dst;
- dstRowDiff = dstRowStride >= (srcWidth * 4) ? dstRowStride - (((srcWidth + 3) & ~3) * 4) : 0;
- for (j = 0; j < srcHeight; j+=4) {
- if (srcHeight > j + 3) numypixels = 4;
- else numypixels = srcHeight - j;
- srcaddr = tempImage + j * srcWidth * 2;
- for (i = 0; i < srcWidth; i += 4) {
- if (srcWidth > i + 3) numxpixels = 4;
- else numxpixels = srcWidth - i;
- extractsrc_u(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 2);
- unsigned_encode_rgtc_chan(blkaddr, srcpixels, numxpixels, numypixels);
-
- blkaddr += 8;
- extractsrc_u(srcpixels, (GLchan *)srcaddr + 1, srcWidth, numxpixels, numypixels, 2);
- unsigned_encode_rgtc_chan(blkaddr, srcpixels, numxpixels, numypixels);
-
- blkaddr += 8;
-
- srcaddr += numxpixels * 2;
- }
- blkaddr += dstRowDiff;
- }
- if (tempImage)
- free((void *) tempImage);
-
- return GL_TRUE;
-}
-
-GLboolean
-_mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS)
-{
- GLbyte *dst;
- const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
- const GLfloat *tempImage = NULL;
- int i, j;
- int numxpixels, numypixels;
- const GLfloat *srcaddr;
- GLbyte srcpixels[4][4];
- GLbyte *blkaddr;
- GLint dstRowDiff;
-
- ASSERT(dstFormat == MESA_FORMAT_SIGNED_RG_RGTC2 ||
- dstFormat == MESA_FORMAT_SIGNED_LA_LATC2);
- ASSERT(dstXoffset % 4 == 0);
- ASSERT(dstYoffset % 4 == 0);
- ASSERT(dstZoffset % 4 == 0);
- (void) dstZoffset;
- (void) dstImageOffsets;
-
- tempImage = _mesa_make_temp_float_image(ctx, dims,
- baseInternalFormat,
- _mesa_get_format_base_format(dstFormat),
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking, 0x0);
- if (!tempImage)
- return GL_FALSE; /* out of memory */
-
- dst = (GLbyte *)_mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
- dstFormat,
- texWidth, (GLubyte *) dstAddr);
-
- blkaddr = dst;
- dstRowDiff = dstRowStride >= (srcWidth * 4) ? dstRowStride - (((srcWidth + 3) & ~3) * 4) : 0;
- for (j = 0; j < srcHeight; j += 4) {
- if (srcHeight > j + 3) numypixels = 4;
- else numypixels = srcHeight - j;
- srcaddr = tempImage + j * srcWidth * 2;
- for (i = 0; i < srcWidth; i += 4) {
- if (srcWidth > i + 3) numxpixels = 4;
- else numxpixels = srcWidth - i;
-
- extractsrc_s(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 2);
- signed_encode_rgtc_chan(blkaddr, srcpixels, numxpixels, numypixels);
- blkaddr += 8;
-
- extractsrc_s(srcpixels, srcaddr + 1, srcWidth, numxpixels, numypixels, 2);
- signed_encode_rgtc_chan(blkaddr, srcpixels, numxpixels, numypixels);
- blkaddr += 8;
-
- srcaddr += numxpixels * 2;
-
- }
- blkaddr += dstRowDiff;
- }
- if (tempImage)
- free((void *) tempImage);
-
- return GL_TRUE;
-}
-
-void
-_mesa_fetch_texel_2d_f_red_rgtc1(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- GLubyte red;
- unsigned_fetch_texel_rgtc(texImage->RowStride, (GLubyte *)(texImage->Data),
- i, j, &red, 1);
- texel[RCOMP] = UBYTE_TO_FLOAT(red);
- texel[GCOMP] = 0.0;
- texel[BCOMP] = 0.0;
- texel[ACOMP] = 1.0;
-}
-
-void
-_mesa_fetch_texel_2d_f_signed_red_rgtc1(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- GLbyte red;
- signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Data),
- i, j, &red, 1);
- texel[RCOMP] = BYTE_TO_FLOAT_TEX(red);
- texel[GCOMP] = 0.0;
- texel[BCOMP] = 0.0;
- texel[ACOMP] = 1.0;
-}
-
-void
-_mesa_fetch_texel_2d_f_rg_rgtc2(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- GLubyte red, green;
- unsigned_fetch_texel_rgtc(texImage->RowStride, (GLubyte *)(texImage->Data),
- i, j, &red, 2);
- unsigned_fetch_texel_rgtc(texImage->RowStride, (GLubyte *)(texImage->Data) + 8,
- i, j, &green, 2);
- texel[RCOMP] = UBYTE_TO_FLOAT(red);
- texel[GCOMP] = UBYTE_TO_FLOAT(green);
- texel[BCOMP] = 0.0;
- texel[ACOMP] = 1.0;
-}
-
-void
-_mesa_fetch_texel_2d_f_signed_rg_rgtc2(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- GLbyte red, green;
- signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Data),
- i, j, &red, 2);
- signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Data) + 8,
- i, j, &green, 2);
- texel[RCOMP] = BYTE_TO_FLOAT_TEX(red);
- texel[GCOMP] = BYTE_TO_FLOAT_TEX(green);
- texel[BCOMP] = 0.0;
- texel[ACOMP] = 1.0;
-}
-
-void
-_mesa_fetch_texel_2d_f_l_latc1(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- GLubyte red;
- unsigned_fetch_texel_rgtc(texImage->RowStride, (GLubyte *)(texImage->Data),
- i, j, &red, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = UBYTE_TO_FLOAT(red);
- texel[ACOMP] = 1.0;
-}
-
-void
-_mesa_fetch_texel_2d_f_signed_l_latc1(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- GLbyte red;
- signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Data),
- i, j, &red, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = BYTE_TO_FLOAT_TEX(red);
- texel[ACOMP] = 1.0;
-}
-
-void
-_mesa_fetch_texel_2d_f_la_latc2(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- GLubyte red, green;
- unsigned_fetch_texel_rgtc(texImage->RowStride, (GLubyte *)(texImage->Data),
- i, j, &red, 2);
- unsigned_fetch_texel_rgtc(texImage->RowStride, (GLubyte *)(texImage->Data) + 8,
- i, j, &green, 2);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = UBYTE_TO_FLOAT(red);
- texel[ACOMP] = UBYTE_TO_FLOAT(green);
-}
-
-void
-_mesa_fetch_texel_2d_f_signed_la_latc2(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- GLbyte red, green;
- signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Data),
- i, j, &red, 2);
- signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Data) + 8,
- i, j, &green, 2);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = BYTE_TO_FLOAT_TEX(red);
- texel[ACOMP] = BYTE_TO_FLOAT_TEX(green);
-}
-
-#define TAG(x) unsigned_##x
-
-#define TYPE GLubyte
-#define T_MIN 0
-#define T_MAX 0xff
-
-#include "texcompress_rgtc_tmp.h"
-
-#undef TAG
-#undef TYPE
-#undef T_MIN
-#undef T_MAX
-
-#define TAG(x) signed_##x
-#define TYPE GLbyte
-#define T_MIN (GLbyte)-128
-#define T_MAX (GLbyte)127
-
-#include "texcompress_rgtc_tmp.h"
-
-#undef TAG
-#undef TYPE
-#undef T_MIN
-#undef T_MAX
+/*
+ * Copyright (C) 2011 Red Hat Inc.
+ *
+ * block compression parts are:
+ * Copyright (C) 2004 Roland Scheidegger 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"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * 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
+ * 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.
+ *
+ * Author:
+ * Dave Airlie
+ */
+
+/**
+ * \file texcompress_rgtc.c
+ * GL_EXT_texture_compression_rgtc support.
+ */
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "colormac.h"
+#include "image.h"
+#include "macros.h"
+#include "mfeatures.h"
+#include "mipmap.h"
+#include "texcompress.h"
+#include "texcompress_rgtc.h"
+#include "texstore.h"
+#include "swrast/s_context.h"
+
+
+#define RGTC_DEBUG 0
+
+static void unsigned_encode_rgtc_chan(GLubyte *blkaddr, GLubyte srccolors[4][4],
+ GLint numxpixels, GLint numypixels);
+static void signed_encode_rgtc_chan(GLbyte *blkaddr, GLbyte srccolors[4][4],
+ GLint numxpixels, GLint numypixels);
+
+static void unsigned_fetch_texel_rgtc(unsigned srcRowStride, const GLubyte *pixdata,
+ unsigned i, unsigned j, GLubyte *value, unsigned comps);
+
+static void signed_fetch_texel_rgtc(unsigned srcRowStride, const GLbyte *pixdata,
+ unsigned i, unsigned j, GLbyte *value, unsigned comps);
+
+static void extractsrc_u( GLubyte srcpixels[4][4], const GLchan *srcaddr,
+ GLint srcRowStride, GLint numxpixels, GLint numypixels, GLint comps)
+{
+ GLubyte i, j;
+ const GLchan *curaddr;
+ for (j = 0; j < numypixels; j++) {
+ curaddr = srcaddr + j * srcRowStride * comps;
+ for (i = 0; i < numxpixels; i++) {
+ srcpixels[j][i] = *curaddr / (CHAN_MAX / 255);
+ curaddr += comps;
+ }
+ }
+}
+
+static void extractsrc_s( GLbyte srcpixels[4][4], const GLfloat *srcaddr,
+ GLint srcRowStride, GLint numxpixels, GLint numypixels, GLint comps)
+{
+ GLubyte i, j;
+ const GLfloat *curaddr;
+ for (j = 0; j < numypixels; j++) {
+ curaddr = srcaddr + j * srcRowStride * comps;
+ for (i = 0; i < numxpixels; i++) {
+ srcpixels[j][i] = FLOAT_TO_BYTE_TEX(*curaddr);
+ curaddr += comps;
+ }
+ }
+}
+
+
+GLboolean
+_mesa_texstore_red_rgtc1(TEXSTORE_PARAMS)
+{
+ GLubyte *dst;
+ const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
+ const GLchan *tempImage = NULL;
+ int i, j;
+ int numxpixels, numypixels;
+ const GLchan *srcaddr;
+ GLubyte srcpixels[4][4];
+ GLubyte *blkaddr;
+ GLint dstRowDiff;
+ ASSERT(dstFormat == MESA_FORMAT_RED_RGTC1 ||
+ dstFormat == MESA_FORMAT_L_LATC1);
+ ASSERT(dstXoffset % 4 == 0);
+ ASSERT(dstYoffset % 4 == 0);
+ ASSERT(dstZoffset % 4 == 0);
+ (void) dstZoffset;
+ (void) dstImageOffsets;
+
+
+ tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ _mesa_get_format_base_format(dstFormat),
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ if (!tempImage)
+ return GL_FALSE; /* out of memory */
+
+ dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
+ dstFormat,
+ texWidth, (GLubyte *) dstAddr);
+
+ blkaddr = dst;
+ dstRowDiff = dstRowStride >= (srcWidth * 2) ? dstRowStride - (((srcWidth + 3) & ~3) * 2) : 0;
+ for (j = 0; j < srcHeight; j+=4) {
+ if (srcHeight > j + 3) numypixels = 4;
+ else numypixels = srcHeight - j;
+ srcaddr = tempImage + j * srcWidth;
+ for (i = 0; i < srcWidth; i += 4) {
+ if (srcWidth > i + 3) numxpixels = 4;
+ else numxpixels = srcWidth - i;
+ extractsrc_u(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 1);
+ unsigned_encode_rgtc_chan(blkaddr, srcpixels, numxpixels, numypixels);
+ srcaddr += numxpixels;
+ blkaddr += 8;
+ }
+ blkaddr += dstRowDiff;
+ }
+ if (tempImage)
+ free((void *) tempImage);
+
+ return GL_TRUE;
+}
+
+GLboolean
+_mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS)
+{
+ GLbyte *dst;
+ const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
+ const GLfloat *tempImage = NULL;
+ int i, j;
+ int numxpixels, numypixels;
+ const GLfloat *srcaddr;
+ GLbyte srcpixels[4][4];
+ GLbyte *blkaddr;
+ GLint dstRowDiff;
+ ASSERT(dstFormat == MESA_FORMAT_SIGNED_RED_RGTC1 ||
+ dstFormat == MESA_FORMAT_SIGNED_L_LATC1);
+ ASSERT(dstXoffset % 4 == 0);
+ ASSERT(dstYoffset % 4 == 0);
+ ASSERT(dstZoffset % 4 == 0);
+ (void) dstZoffset;
+ (void) dstImageOffsets;
+
+ tempImage = _mesa_make_temp_float_image(ctx, dims,
+ baseInternalFormat,
+ _mesa_get_format_base_format(dstFormat),
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking, 0x0);
+ if (!tempImage)
+ return GL_FALSE; /* out of memory */
+
+ dst = (GLbyte *)_mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
+ dstFormat,
+ texWidth, (GLubyte *) dstAddr);
+
+ blkaddr = dst;
+ dstRowDiff = dstRowStride >= (srcWidth * 2) ? dstRowStride - (((srcWidth + 3) & ~3) * 2) : 0;
+ for (j = 0; j < srcHeight; j+=4) {
+ if (srcHeight > j + 3) numypixels = 4;
+ else numypixels = srcHeight - j;
+ srcaddr = tempImage + j * srcWidth;
+ for (i = 0; i < srcWidth; i += 4) {
+ if (srcWidth > i + 3) numxpixels = 4;
+ else numxpixels = srcWidth - i;
+ extractsrc_s(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 1);
+ signed_encode_rgtc_chan(blkaddr, srcpixels, numxpixels, numypixels);
+ srcaddr += numxpixels;
+ blkaddr += 8;
+ }
+ blkaddr += dstRowDiff;
+ }
+ if (tempImage)
+ free((void *) tempImage);
+
+ return GL_TRUE;
+}
+
+GLboolean
+_mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS)
+{
+ GLubyte *dst;
+ const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
+ const GLchan *tempImage = NULL;
+ int i, j;
+ int numxpixels, numypixels;
+ const GLchan *srcaddr;
+ GLubyte srcpixels[4][4];
+ GLubyte *blkaddr;
+ GLint dstRowDiff;
+
+ ASSERT(dstFormat == MESA_FORMAT_RG_RGTC2 ||
+ dstFormat == MESA_FORMAT_LA_LATC2);
+ ASSERT(dstXoffset % 4 == 0);
+ ASSERT(dstYoffset % 4 == 0);
+ ASSERT(dstZoffset % 4 == 0);
+ (void) dstZoffset;
+ (void) dstImageOffsets;
+
+ tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ _mesa_get_format_base_format(dstFormat),
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ if (!tempImage)
+ return GL_FALSE; /* out of memory */
+
+ dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
+ dstFormat,
+ texWidth, (GLubyte *) dstAddr);
+
+ blkaddr = dst;
+ dstRowDiff = dstRowStride >= (srcWidth * 4) ? dstRowStride - (((srcWidth + 3) & ~3) * 4) : 0;
+ for (j = 0; j < srcHeight; j+=4) {
+ if (srcHeight > j + 3) numypixels = 4;
+ else numypixels = srcHeight - j;
+ srcaddr = tempImage + j * srcWidth * 2;
+ for (i = 0; i < srcWidth; i += 4) {
+ if (srcWidth > i + 3) numxpixels = 4;
+ else numxpixels = srcWidth - i;
+ extractsrc_u(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 2);
+ unsigned_encode_rgtc_chan(blkaddr, srcpixels, numxpixels, numypixels);
+
+ blkaddr += 8;
+ extractsrc_u(srcpixels, (GLchan *)srcaddr + 1, srcWidth, numxpixels, numypixels, 2);
+ unsigned_encode_rgtc_chan(blkaddr, srcpixels, numxpixels, numypixels);
+
+ blkaddr += 8;
+
+ srcaddr += numxpixels * 2;
+ }
+ blkaddr += dstRowDiff;
+ }
+ if (tempImage)
+ free((void *) tempImage);
+
+ return GL_TRUE;
+}
+
+GLboolean
+_mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS)
+{
+ GLbyte *dst;
+ const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
+ const GLfloat *tempImage = NULL;
+ int i, j;
+ int numxpixels, numypixels;
+ const GLfloat *srcaddr;
+ GLbyte srcpixels[4][4];
+ GLbyte *blkaddr;
+ GLint dstRowDiff;
+
+ ASSERT(dstFormat == MESA_FORMAT_SIGNED_RG_RGTC2 ||
+ dstFormat == MESA_FORMAT_SIGNED_LA_LATC2);
+ ASSERT(dstXoffset % 4 == 0);
+ ASSERT(dstYoffset % 4 == 0);
+ ASSERT(dstZoffset % 4 == 0);
+ (void) dstZoffset;
+ (void) dstImageOffsets;
+
+ tempImage = _mesa_make_temp_float_image(ctx, dims,
+ baseInternalFormat,
+ _mesa_get_format_base_format(dstFormat),
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking, 0x0);
+ if (!tempImage)
+ return GL_FALSE; /* out of memory */
+
+ dst = (GLbyte *)_mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
+ dstFormat,
+ texWidth, (GLubyte *) dstAddr);
+
+ blkaddr = dst;
+ dstRowDiff = dstRowStride >= (srcWidth * 4) ? dstRowStride - (((srcWidth + 3) & ~3) * 4) : 0;
+ for (j = 0; j < srcHeight; j += 4) {
+ if (srcHeight > j + 3) numypixels = 4;
+ else numypixels = srcHeight - j;
+ srcaddr = tempImage + j * srcWidth * 2;
+ for (i = 0; i < srcWidth; i += 4) {
+ if (srcWidth > i + 3) numxpixels = 4;
+ else numxpixels = srcWidth - i;
+
+ extractsrc_s(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 2);
+ signed_encode_rgtc_chan(blkaddr, srcpixels, numxpixels, numypixels);
+ blkaddr += 8;
+
+ extractsrc_s(srcpixels, srcaddr + 1, srcWidth, numxpixels, numypixels, 2);
+ signed_encode_rgtc_chan(blkaddr, srcpixels, numxpixels, numypixels);
+ blkaddr += 8;
+
+ srcaddr += numxpixels * 2;
+
+ }
+ blkaddr += dstRowDiff;
+ }
+ if (tempImage)
+ free((void *) tempImage);
+
+ return GL_TRUE;
+}
+
+void
+_mesa_fetch_texel_2d_f_red_rgtc1(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ GLubyte red;
+ unsigned_fetch_texel_rgtc(texImage->Base.RowStride, (GLubyte *)(texImage->Base.Data),
+ i, j, &red, 1);
+ texel[RCOMP] = UBYTE_TO_FLOAT(red);
+ texel[GCOMP] = 0.0;
+ texel[BCOMP] = 0.0;
+ texel[ACOMP] = 1.0;
+}
+
+void
+_mesa_fetch_texel_2d_f_signed_red_rgtc1(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ GLbyte red;
+ signed_fetch_texel_rgtc(texImage->Base.RowStride, (GLbyte *)(texImage->Base.Data),
+ i, j, &red, 1);
+ texel[RCOMP] = BYTE_TO_FLOAT_TEX(red);
+ texel[GCOMP] = 0.0;
+ texel[BCOMP] = 0.0;
+ texel[ACOMP] = 1.0;
+}
+
+void
+_mesa_fetch_texel_2d_f_rg_rgtc2(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ GLubyte red, green;
+ unsigned_fetch_texel_rgtc(texImage->Base.RowStride, (GLubyte *)(texImage->Base.Data),
+ i, j, &red, 2);
+ unsigned_fetch_texel_rgtc(texImage->Base.RowStride, (GLubyte *)(texImage->Base.Data) + 8,
+ i, j, &green, 2);
+ texel[RCOMP] = UBYTE_TO_FLOAT(red);
+ texel[GCOMP] = UBYTE_TO_FLOAT(green);
+ texel[BCOMP] = 0.0;
+ texel[ACOMP] = 1.0;
+}
+
+void
+_mesa_fetch_texel_2d_f_signed_rg_rgtc2(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ GLbyte red, green;
+ signed_fetch_texel_rgtc(texImage->Base.RowStride, (GLbyte *)(texImage->Base.Data),
+ i, j, &red, 2);
+ signed_fetch_texel_rgtc(texImage->Base.RowStride, (GLbyte *)(texImage->Base.Data) + 8,
+ i, j, &green, 2);
+ texel[RCOMP] = BYTE_TO_FLOAT_TEX(red);
+ texel[GCOMP] = BYTE_TO_FLOAT_TEX(green);
+ texel[BCOMP] = 0.0;
+ texel[ACOMP] = 1.0;
+}
+
+void
+_mesa_fetch_texel_2d_f_l_latc1(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ GLubyte red;
+ unsigned_fetch_texel_rgtc(texImage->Base.RowStride, (GLubyte *)(texImage->Base.Data),
+ i, j, &red, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = UBYTE_TO_FLOAT(red);
+ texel[ACOMP] = 1.0;
+}
+
+void
+_mesa_fetch_texel_2d_f_signed_l_latc1(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ GLbyte red;
+ signed_fetch_texel_rgtc(texImage->Base.RowStride, (GLbyte *)(texImage->Base.Data),
+ i, j, &red, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = BYTE_TO_FLOAT_TEX(red);
+ texel[ACOMP] = 1.0;
+}
+
+void
+_mesa_fetch_texel_2d_f_la_latc2(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ GLubyte red, green;
+ unsigned_fetch_texel_rgtc(texImage->Base.RowStride, (GLubyte *)(texImage->Base.Data),
+ i, j, &red, 2);
+ unsigned_fetch_texel_rgtc(texImage->Base.RowStride, (GLubyte *)(texImage->Base.Data) + 8,
+ i, j, &green, 2);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = UBYTE_TO_FLOAT(red);
+ texel[ACOMP] = UBYTE_TO_FLOAT(green);
+}
+
+void
+_mesa_fetch_texel_2d_f_signed_la_latc2(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ GLbyte red, green;
+ signed_fetch_texel_rgtc(texImage->Base.RowStride, (GLbyte *)(texImage->Base.Data),
+ i, j, &red, 2);
+ signed_fetch_texel_rgtc(texImage->Base.RowStride, (GLbyte *)(texImage->Base.Data) + 8,
+ i, j, &green, 2);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = BYTE_TO_FLOAT_TEX(red);
+ texel[ACOMP] = BYTE_TO_FLOAT_TEX(green);
+}
+
+#define TAG(x) unsigned_##x
+
+#define TYPE GLubyte
+#define T_MIN 0
+#define T_MAX 0xff
+
+#include "texcompress_rgtc_tmp.h"
+
+#undef TAG
+#undef TYPE
+#undef T_MIN
+#undef T_MAX
+
+#define TAG(x) signed_##x
+#define TYPE GLbyte
+#define T_MIN (GLbyte)-128
+#define T_MAX (GLbyte)127
+
+#include "texcompress_rgtc_tmp.h"
+
+#undef TAG
+#undef TYPE
+#undef T_MIN
+#undef T_MAX
diff --git a/mesalib/src/mesa/main/texcompress_rgtc.h b/mesalib/src/mesa/main/texcompress_rgtc.h
index 18766770d..6be6ad9be 100644
--- a/mesalib/src/mesa/main/texcompress_rgtc.h
+++ b/mesalib/src/mesa/main/texcompress_rgtc.h
@@ -28,7 +28,7 @@
#include "mfeatures.h"
#include "texstore.h"
-struct gl_texture_image;
+struct swrast_texture_image;
extern GLboolean
_mesa_texstore_red_rgtc1(TEXSTORE_PARAMS);
@@ -43,35 +43,35 @@ extern GLboolean
_mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS);
extern void
-_mesa_fetch_texel_2d_f_red_rgtc1(const struct gl_texture_image *texImage,
+_mesa_fetch_texel_2d_f_red_rgtc1(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel);
extern void
-_mesa_fetch_texel_2d_f_signed_red_rgtc1(const struct gl_texture_image *texImage,
+_mesa_fetch_texel_2d_f_signed_red_rgtc1(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel);
extern void
-_mesa_fetch_texel_2d_f_rg_rgtc2(const struct gl_texture_image *texImage,
+_mesa_fetch_texel_2d_f_rg_rgtc2(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel);
extern void
-_mesa_fetch_texel_2d_f_signed_rg_rgtc2(const struct gl_texture_image *texImage,
+_mesa_fetch_texel_2d_f_signed_rg_rgtc2(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel);
extern void
-_mesa_fetch_texel_2d_f_l_latc1(const struct gl_texture_image *texImage,
+_mesa_fetch_texel_2d_f_l_latc1(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel);
extern void
-_mesa_fetch_texel_2d_f_signed_l_latc1(const struct gl_texture_image *texImage,
+_mesa_fetch_texel_2d_f_signed_l_latc1(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel);
extern void
-_mesa_fetch_texel_2d_f_la_latc2(const struct gl_texture_image *texImage,
+_mesa_fetch_texel_2d_f_la_latc2(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel);
extern void
-_mesa_fetch_texel_2d_f_signed_la_latc2(const struct gl_texture_image *texImage,
+_mesa_fetch_texel_2d_f_signed_la_latc2(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel);
#endif
diff --git a/mesalib/src/mesa/main/texcompress_s3tc.c b/mesalib/src/mesa/main/texcompress_s3tc.c
index 5798406db..779e1a4c8 100644
--- a/mesalib/src/mesa/main/texcompress_s3tc.c
+++ b/mesalib/src/mesa/main/texcompress_s3tc.c
@@ -44,6 +44,7 @@
#include "texcompress.h"
#include "texcompress_s3tc.h"
#include "texstore.h"
+#include "swrast/s_context.h"
#if FEATURE_texture_s3tc
@@ -392,14 +393,14 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS)
static void
-fetch_texel_2d_rgb_dxt1( const struct gl_texture_image *texImage,
+fetch_texel_2d_rgb_dxt1( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
(void) k;
if (fetch_ext_rgb_dxt1) {
ASSERT (sizeof(GLchan) == sizeof(GLubyte));
- fetch_ext_rgb_dxt1(texImage->RowStride,
- (GLubyte *)(texImage)->Data, i, j, texel);
+ fetch_ext_rgb_dxt1(texImage->Base.RowStride,
+ (GLubyte *)(texImage)->Base.Data, i, j, texel);
}
else
_mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgb_dxt1");
@@ -407,7 +408,7 @@ fetch_texel_2d_rgb_dxt1( const struct gl_texture_image *texImage,
void
-_mesa_fetch_texel_2d_f_rgb_dxt1(const struct gl_texture_image *texImage,
+_mesa_fetch_texel_2d_f_rgb_dxt1(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
/* just sample as GLchan and convert to float here */
@@ -421,13 +422,13 @@ _mesa_fetch_texel_2d_f_rgb_dxt1(const struct gl_texture_image *texImage,
static void
-fetch_texel_2d_rgba_dxt1( const struct gl_texture_image *texImage,
+fetch_texel_2d_rgba_dxt1( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
(void) k;
if (fetch_ext_rgba_dxt1) {
- fetch_ext_rgba_dxt1(texImage->RowStride,
- (GLubyte *)(texImage)->Data, i, j, texel);
+ fetch_ext_rgba_dxt1(texImage->Base.RowStride,
+ (GLubyte *)(texImage)->Base.Data, i, j, texel);
}
else
_mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt1\n");
@@ -435,7 +436,7 @@ fetch_texel_2d_rgba_dxt1( const struct gl_texture_image *texImage,
void
-_mesa_fetch_texel_2d_f_rgba_dxt1(const struct gl_texture_image *texImage,
+_mesa_fetch_texel_2d_f_rgba_dxt1(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
/* just sample as GLchan and convert to float here */
@@ -449,13 +450,14 @@ _mesa_fetch_texel_2d_f_rgba_dxt1(const struct gl_texture_image *texImage,
static void
-fetch_texel_2d_rgba_dxt3( const struct gl_texture_image *texImage,
+fetch_texel_2d_rgba_dxt3( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
(void) k;
if (fetch_ext_rgba_dxt3) {
ASSERT (sizeof(GLchan) == sizeof(GLubyte));
- fetch_ext_rgba_dxt3(texImage->RowStride, (GLubyte *)(texImage)->Data,
+ fetch_ext_rgba_dxt3(texImage->Base.RowStride,
+ (GLubyte *)(texImage)->Base.Data,
i, j, texel);
}
else
@@ -464,7 +466,7 @@ fetch_texel_2d_rgba_dxt3( const struct gl_texture_image *texImage,
void
-_mesa_fetch_texel_2d_f_rgba_dxt3(const struct gl_texture_image *texImage,
+_mesa_fetch_texel_2d_f_rgba_dxt3(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
/* just sample as GLchan and convert to float here */
@@ -478,12 +480,13 @@ _mesa_fetch_texel_2d_f_rgba_dxt3(const struct gl_texture_image *texImage,
static void
-fetch_texel_2d_rgba_dxt5( const struct gl_texture_image *texImage,
+fetch_texel_2d_rgba_dxt5( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
(void) k;
if (fetch_ext_rgba_dxt5) {
- fetch_ext_rgba_dxt5(texImage->RowStride, (GLubyte *)(texImage)->Data,
+ fetch_ext_rgba_dxt5(texImage->Base.RowStride,
+ (GLubyte *)(texImage)->Base.Data,
i, j, texel);
}
else
@@ -492,7 +495,7 @@ fetch_texel_2d_rgba_dxt5( const struct gl_texture_image *texImage,
void
-_mesa_fetch_texel_2d_f_rgba_dxt5(const struct gl_texture_image *texImage,
+_mesa_fetch_texel_2d_f_rgba_dxt5(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
/* just sample as GLchan and convert to float here */
@@ -506,7 +509,7 @@ _mesa_fetch_texel_2d_f_rgba_dxt5(const struct gl_texture_image *texImage,
#if FEATURE_EXT_texture_sRGB
void
-_mesa_fetch_texel_2d_f_srgb_dxt1( const struct gl_texture_image *texImage,
+_mesa_fetch_texel_2d_f_srgb_dxt1( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
/* just sample as GLchan and convert to float here */
@@ -519,7 +522,7 @@ _mesa_fetch_texel_2d_f_srgb_dxt1( const struct gl_texture_image *texImage,
}
void
-_mesa_fetch_texel_2d_f_srgba_dxt1(const struct gl_texture_image *texImage,
+_mesa_fetch_texel_2d_f_srgba_dxt1(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
/* just sample as GLchan and convert to float here */
@@ -532,7 +535,7 @@ _mesa_fetch_texel_2d_f_srgba_dxt1(const struct gl_texture_image *texImage,
}
void
-_mesa_fetch_texel_2d_f_srgba_dxt3(const struct gl_texture_image *texImage,
+_mesa_fetch_texel_2d_f_srgba_dxt3(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
/* just sample as GLchan and convert to float here */
@@ -545,7 +548,7 @@ _mesa_fetch_texel_2d_f_srgba_dxt3(const struct gl_texture_image *texImage,
}
void
-_mesa_fetch_texel_2d_f_srgba_dxt5(const struct gl_texture_image *texImage,
+_mesa_fetch_texel_2d_f_srgba_dxt5(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
/* just sample as GLchan and convert to float here */
diff --git a/mesalib/src/mesa/main/texcompress_s3tc.h b/mesalib/src/mesa/main/texcompress_s3tc.h
index 555cff9c2..709c35ae7 100644
--- a/mesalib/src/mesa/main/texcompress_s3tc.h
+++ b/mesalib/src/mesa/main/texcompress_s3tc.h
@@ -1,110 +1,110 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.1
- *
- * Copyright (C) 1999-2008 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"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#ifndef TEXCOMPRESS_S3TC_H
-#define TEXCOMPRESS_S3TC_H
-
-#include "compiler.h"
-#include "glheader.h"
-#include "mfeatures.h"
-#include "texstore.h"
-
-struct gl_context;
-struct gl_texture_image;
-
-#if FEATURE_texture_s3tc
-
-extern GLboolean
-_mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS);
-
-extern GLboolean
-_mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS);
-
-extern GLboolean
-_mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS);
-
-extern GLboolean
-_mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS);
-
-extern void
-_mesa_fetch_texel_2d_f_rgb_dxt1(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-extern void
-_mesa_fetch_texel_2d_f_rgba_dxt1(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-extern void
-_mesa_fetch_texel_2d_f_rgba_dxt3(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-extern void
-_mesa_fetch_texel_2d_f_rgba_dxt5(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-extern void
-_mesa_fetch_texel_2d_f_srgb_dxt1(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-extern void
-_mesa_fetch_texel_2d_f_srgba_dxt1(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-extern void
-_mesa_fetch_texel_2d_f_srgba_dxt3(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-extern void
-_mesa_fetch_texel_2d_f_srgba_dxt5(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-extern void
-_mesa_init_texture_s3tc(struct gl_context *ctx);
-
-#else /* FEATURE_texture_s3tc */
-
-/* these are used only in texstore_funcs[] */
-#define _mesa_texstore_rgb_dxt1 NULL
-#define _mesa_texstore_rgba_dxt1 NULL
-#define _mesa_texstore_rgba_dxt3 NULL
-#define _mesa_texstore_rgba_dxt5 NULL
-
-/* these are used only in texfetch_funcs[] */
-#define _mesa_fetch_texel_2d_f_rgb_dxt1 NULL
-#define _mesa_fetch_texel_2d_f_rgba_dxt1 NULL
-#define _mesa_fetch_texel_2d_f_rgba_dxt3 NULL
-#define _mesa_fetch_texel_2d_f_rgba_dxt5 NULL
-#define _mesa_fetch_texel_2d_f_srgb_dxt1 NULL
-#define _mesa_fetch_texel_2d_f_srgba_dxt1 NULL
-#define _mesa_fetch_texel_2d_f_srgba_dxt3 NULL
-#define _mesa_fetch_texel_2d_f_srgba_dxt5 NULL
-
-static INLINE void
-_mesa_init_texture_s3tc(struct gl_context *ctx)
-{
-}
-
-#endif /* FEATURE_texture_s3tc */
-
-#endif /* TEXCOMPRESS_S3TC_H */
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.1
+ *
+ * Copyright (C) 1999-2008 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"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * 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.
+ */
+
+#ifndef TEXCOMPRESS_S3TC_H
+#define TEXCOMPRESS_S3TC_H
+
+#include "compiler.h"
+#include "glheader.h"
+#include "mfeatures.h"
+#include "texstore.h"
+
+struct gl_context;
+struct swrast_texture_image;
+
+#if FEATURE_texture_s3tc
+
+extern GLboolean
+_mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS);
+
+extern GLboolean
+_mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS);
+
+extern GLboolean
+_mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS);
+
+extern GLboolean
+_mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS);
+
+extern void
+_mesa_fetch_texel_2d_f_rgb_dxt1(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_fetch_texel_2d_f_rgba_dxt1(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_fetch_texel_2d_f_rgba_dxt3(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_fetch_texel_2d_f_rgba_dxt5(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_fetch_texel_2d_f_srgb_dxt1(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_fetch_texel_2d_f_srgba_dxt1(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_fetch_texel_2d_f_srgba_dxt3(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_fetch_texel_2d_f_srgba_dxt5(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_init_texture_s3tc(struct gl_context *ctx);
+
+#else /* FEATURE_texture_s3tc */
+
+/* these are used only in texstore_funcs[] */
+#define _mesa_texstore_rgb_dxt1 NULL
+#define _mesa_texstore_rgba_dxt1 NULL
+#define _mesa_texstore_rgba_dxt3 NULL
+#define _mesa_texstore_rgba_dxt5 NULL
+
+/* these are used only in texfetch_funcs[] */
+#define _mesa_fetch_texel_2d_f_rgb_dxt1 NULL
+#define _mesa_fetch_texel_2d_f_rgba_dxt1 NULL
+#define _mesa_fetch_texel_2d_f_rgba_dxt3 NULL
+#define _mesa_fetch_texel_2d_f_rgba_dxt5 NULL
+#define _mesa_fetch_texel_2d_f_srgb_dxt1 NULL
+#define _mesa_fetch_texel_2d_f_srgba_dxt1 NULL
+#define _mesa_fetch_texel_2d_f_srgba_dxt3 NULL
+#define _mesa_fetch_texel_2d_f_srgba_dxt5 NULL
+
+static INLINE void
+_mesa_init_texture_s3tc(struct gl_context *ctx)
+{
+}
+
+#endif /* FEATURE_texture_s3tc */
+
+#endif /* TEXCOMPRESS_S3TC_H */
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c
index cb4a5b4e4..6113b2e9e 100644
--- a/mesalib/src/mesa/main/teximage.c
+++ b/mesalib/src/mesa/main/teximage.c
@@ -42,7 +42,6 @@
#include "mfeatures.h"
#include "state.h"
#include "texcompress.h"
-#include "texfetch.h"
#include "teximage.h"
#include "texstate.h"
#include "texpal.h"
@@ -602,7 +601,8 @@ _mesa_free_texture_image_data(struct gl_context *ctx,
/**
- * Free texture image.
+ * Free a gl_texture_image and associated data.
+ * This function is a fallback called via ctx->Driver.DeleteTextureImage().
*
* \param texImage texture image.
*
@@ -1076,8 +1076,6 @@ clear_teximage_fields(struct gl_texture_image *img)
img->DepthLog2 = 0;
img->Data = NULL;
img->TexFormat = MESA_FORMAT_NONE;
- img->FetchTexelc = NULL;
- img->FetchTexelf = NULL;
}
@@ -1104,7 +1102,7 @@ _mesa_init_teximage_fields(struct gl_context *ctx, GLenum target,
GLint border, GLenum internalFormat,
gl_format format)
{
- GLint i, dims;
+ GLint i;
ASSERT(img);
ASSERT(width >= 0);
@@ -1176,10 +1174,6 @@ _mesa_init_teximage_fields(struct gl_context *ctx, GLenum target,
}
img->TexFormat = format;
-
- dims = _mesa_get_texture_dimensions(target);
-
- _mesa_set_fetch_functions(img, dims);
}
diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c
index 1168f1842..1b90cca9b 100644
--- a/mesalib/src/mesa/main/texobj.c
+++ b/mesalib/src/mesa/main/texobj.c
@@ -202,7 +202,7 @@ _mesa_delete_texture_object(struct gl_context *ctx,
for (face = 0; face < 6; face++) {
for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
if (texObj->Image[face][i]) {
- _mesa_delete_texture_image( ctx, texObj->Image[face][i] );
+ ctx->Driver.DeleteTextureImage(ctx, texObj->Image[face][i]);
}
}
}
diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c
index 19a01a14d..44dabe6de 100644
--- a/mesalib/src/mesa/main/texparam.c
+++ b/mesalib/src/mesa/main/texparam.c
@@ -43,7 +43,6 @@
#include "main/texparam.h"
#include "main/teximage.h"
#include "main/texstate.h"
-#include "main/texfetch.h"
#include "program/prog_instruction.h"
@@ -432,7 +431,6 @@ set_tex_parameteri(struct gl_context *ctx,
if (texObj->Sampler.sRGBDecode != decode) {
flush(ctx);
texObj->Sampler.sRGBDecode = decode;
- _mesa_update_fetch_functions(texObj);
}
return GL_TRUE;
}
diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c
index 2cdc8ed67..b958615b5 100644
--- a/mesalib/src/mesa/main/texstore.c
+++ b/mesalib/src/mesa/main/texstore.c
@@ -4508,16 +4508,6 @@ _mesa_texstore(TEXSTORE_PARAMS)
}
-/** Return texture size in bytes */
-static GLuint
-texture_size(const struct gl_texture_image *texImage)
-{
- GLuint sz = _mesa_format_image_size(texImage->TexFormat, texImage->Width,
- texImage->Height, texImage->Depth);
- return sz;
-}
-
-
/**
* Normally, we'll only _write_ texel data to a texture when we map it.
* But if the user is providing depth or stencil values and the texture
@@ -4549,7 +4539,6 @@ _mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- GLuint sizeInBytes;
const GLbitfield rwMode = get_read_write_mode(format, texImage->TexFormat);
const GLuint zeroImageOffset = 0;
GLubyte *dstMap;
@@ -4558,10 +4547,9 @@ _mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level,
(void) border;
- /* allocate memory */
- sizeInBytes = texture_size(texImage);
- texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
- if (!texImage->Data) {
+ /* allocate storage for texture data */
+ if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat,
+ width, 1, 1)) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
return;
}
@@ -4614,7 +4602,6 @@ _mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- GLuint sizeInBytes;
const GLbitfield rwMode = get_read_write_mode(format, texImage->TexFormat);
const GLuint zeroImageOffset = 0;
GLubyte *dstMap;
@@ -4623,10 +4610,9 @@ _mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level,
(void) border;
- /* allocate memory */
- sizeInBytes = texture_size(texImage);
- texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
- if (!texImage->Data) {
+ /* allocate storage for texture data */
+ if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat,
+ width, height, 1)) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
return;
}
@@ -4678,7 +4664,6 @@ _mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- GLuint sizeInBytes;
const GLbitfield rwMode = get_read_write_mode(format, texImage->TexFormat);
GLboolean success;
GLint slice;
@@ -4689,13 +4674,10 @@ _mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level,
(void) border;
- /* allocate memory */
- sizeInBytes = texture_size(texImage);
- texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
- if (!texImage->Data) {
- /* Note: we check for a NULL image pointer here, _after_ we allocated
- * memory for the texture. That's what the GL spec calls for.
- */
+ /* allocate storage for texture data */
+ if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat,
+ width, height, depth)) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
return;
}
@@ -4966,10 +4948,10 @@ _mesa_store_compressed_teximage2d(struct gl_context *ctx,
ASSERT(texImage->Depth == 1);
ASSERT(texImage->Data == NULL); /* was freed in glCompressedTexImage2DARB */
- /* allocate storage */
- texImage->Data = _mesa_alloc_texmemory(imageSize);
- if (!texImage->Data) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB");
+ /* allocate storage for texture data */
+ if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat,
+ width, height, 1)) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
return;
}
diff --git a/mesalib/src/mesa/sources.mak b/mesalib/src/mesa/sources.mak
index 71f708f1e..19a105f15 100644
--- a/mesalib/src/mesa/sources.mak
+++ b/mesalib/src/mesa/sources.mak
@@ -85,7 +85,6 @@ MAIN_SOURCES = \
main/texcompress_s3tc.c \
main/texcompress_fxt1.c \
main/texenv.c \
- main/texfetch.c \
main/texformat.c \
main/texgen.c \
main/texgetimage.c \
@@ -144,6 +143,7 @@ SWRAST_SOURCES = \
swrast/s_span.c \
swrast/s_stencil.c \
swrast/s_texcombine.c \
+ swrast/s_texfetch.c \
swrast/s_texfilter.c \
swrast/s_texrender.c \
swrast/s_texture.c \
diff --git a/mesalib/src/mesa/state_tracker/st_cb_clear.c b/mesalib/src/mesa/state_tracker/st_cb_clear.c
index a4799e3cc..83802a5ea 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_clear.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_clear.c
@@ -136,7 +136,7 @@ set_vertex_shader(struct st_context *st)
static void
draw_quad(struct st_context *st,
float x0, float y0, float x1, float y1, GLfloat z,
- const GLfloat color[4])
+ const union pipe_color_union *color)
{
struct pipe_context *pipe = st->pipe;
@@ -182,10 +182,10 @@ draw_quad(struct st_context *st,
for (i = 0; i < 4; i++) {
st->clear.vertices[i][0][2] = z;
st->clear.vertices[i][0][3] = 1.0;
- st->clear.vertices[i][1][0] = color[0];
- st->clear.vertices[i][1][1] = color[1];
- st->clear.vertices[i][1][2] = color[2];
- st->clear.vertices[i][1][3] = color[3];
+ st->clear.vertices[i][1][0] = color->f[0];
+ st->clear.vertices[i][1][1] = color->f[1];
+ st->clear.vertices[i][1][2] = color->f[2];
+ st->clear.vertices[i][1][3] = color->f[3];
}
/* put vertex data into vbuf */
@@ -227,7 +227,7 @@ clear_with_quad(struct gl_context *ctx,
const GLfloat x1 = (GLfloat) ctx->DrawBuffer->_Xmax / fb_width * 2.0f - 1.0f;
const GLfloat y0 = (GLfloat) ctx->DrawBuffer->_Ymin / fb_height * 2.0f - 1.0f;
const GLfloat y1 = (GLfloat) ctx->DrawBuffer->_Ymax / fb_height * 2.0f - 1.0f;
- float clearColor[4];
+ union pipe_color_union clearColor;
/*
printf("%s %s%s%s %f,%f %f,%f\n", __FUNCTION__,
@@ -325,11 +325,11 @@ clear_with_quad(struct gl_context *ctx,
if (ctx->DrawBuffer->_ColorDrawBuffers[0]) {
st_translate_color(ctx->Color.ClearColor.f,
ctx->DrawBuffer->_ColorDrawBuffers[0]->_BaseFormat,
- clearColor);
+ clearColor.f);
}
/* draw quad matching scissor rect */
- draw_quad(st, x0, y0, x1, y1, (GLfloat) ctx->Depth.Clear, clearColor);
+ draw_quad(st, x0, y0, x1, y1, (GLfloat) ctx->Depth.Clear, &clearColor);
/* Restore pipe state */
cso_restore_blend(st->cso_context);
@@ -572,7 +572,7 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
* required from the visual. Hence fix this up to avoid potential
* read-modify-write in the driver.
*/
- float clearColor[4];
+ union pipe_color_union clearColor;
if ((clear_buffers & PIPE_CLEAR_DEPTHSTENCIL) &&
((clear_buffers & PIPE_CLEAR_DEPTHSTENCIL) != PIPE_CLEAR_DEPTHSTENCIL) &&
@@ -584,10 +584,10 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
if (ctx->DrawBuffer->_ColorDrawBuffers[0]) {
st_translate_color(ctx->Color.ClearColor.f,
ctx->DrawBuffer->_ColorDrawBuffers[0]->_BaseFormat,
- clearColor);
+ clearColor.f);
}
- st->pipe->clear(st->pipe, clear_buffers, clearColor,
+ st->pipe->clear(st->pipe, clear_buffers, &clearColor,
ctx->Depth.Clear, ctx->Stencil.Clear);
}
if (mask & BUFFER_BIT_ACCUM)
diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c
index eab02fb3b..68323a35a 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c
@@ -38,7 +38,6 @@
#include "main/pbo.h"
#include "main/pixeltransfer.h"
#include "main/texcompress.h"
-#include "main/texfetch.h"
#include "main/texgetimage.h"
#include "main/teximage.h"
#include "main/texobj.h"
@@ -106,6 +105,15 @@ st_NewTextureImage(struct gl_context * ctx)
}
+/** called via ctx->Driver.DeleteTextureImage() */
+static void
+st_DeleteTextureImage(struct gl_context * ctx, struct gl_texture_image *img)
+{
+ /* nothing special (yet) for st_texture_image */
+ _mesa_delete_texture_image(ctx, img);
+}
+
+
/** called via ctx->Driver.NewTextureObject() */
static struct gl_texture_object *
st_NewTextureObject(struct gl_context * ctx, GLuint name, GLenum target)
@@ -552,8 +560,6 @@ st_TexImage(struct gl_context * ctx,
stImage->base.Face = _mesa_tex_target_to_face(target);
stImage->base.Level = level;
- _mesa_set_fetch_functions(texImage, dims);
-
/* Release the reference to a potentially orphaned buffer.
* Release any old malloced memory.
*/
@@ -975,8 +981,6 @@ st_get_tex_image(struct gl_context * ctx, GLenum target, GLint level,
dest = (GLubyte *) pixels;
- _mesa_set_fetch_functions(texImage, get_texture_dims(target));
-
for (i = 0; i < depth; i++) {
if (compressed_dst) {
_mesa_get_compressed_teximage(ctx, target, level, dest,
@@ -1923,6 +1927,7 @@ st_init_texture_functions(struct dd_function_table *functions)
functions->NewTextureObject = st_NewTextureObject;
functions->NewTextureImage = st_NewTextureImage;
+ functions->DeleteTextureImage = st_DeleteTextureImage;
functions->DeleteTexture = st_DeleteTextureObject;
functions->FreeTextureImageBuffer = st_FreeTextureImageBuffer;
functions->MapTextureImage = st_MapTextureImage;
diff --git a/mesalib/src/mesa/state_tracker/st_format.h b/mesalib/src/mesa/state_tracker/st_format.h
index 1c1f5965f..10ffeaa73 100644
--- a/mesalib/src/mesa/state_tracker/st_format.h
+++ b/mesalib/src/mesa/state_tracker/st_format.h
@@ -83,5 +83,4 @@ extern void
st_translate_color(const GLfloat colorIn[4], GLenum baseFormat,
GLfloat colorOut[4]);
-
#endif /* ST_FORMAT_H */
diff --git a/mesalib/src/mesa/swrast/s_context.c b/mesalib/src/mesa/swrast/s_context.c
index df213357f..7651eaf22 100644
--- a/mesalib/src/mesa/swrast/s_context.c
+++ b/mesalib/src/mesa/swrast/s_context.c
@@ -39,6 +39,7 @@
#include "s_lines.h"
#include "s_points.h"
#include "s_span.h"
+#include "s_texfetch.h"
#include "s_triangle.h"
#include "s_texfilter.h"
@@ -469,11 +470,14 @@ _swrast_update_texture_samplers(struct gl_context *ctx)
return; /* pipe hack */
for (u = 0; u < ctx->Const.MaxTextureImageUnits; u++) {
- const struct gl_texture_object *tObj = ctx->Texture.Unit[u]._Current;
+ struct gl_texture_object *tObj = ctx->Texture.Unit[u]._Current;
/* Note: If tObj is NULL, the sample function will be a simple
* function that just returns opaque black (0,0,0,1).
*/
- swrast->TextureSample[u] = _swrast_choose_texture_sample_func(ctx, tObj);
+ if (tObj) {
+ _mesa_update_fetch_functions(tObj);
+ swrast->TextureSample[u] = _swrast_choose_texture_sample_func(ctx, tObj);
+ }
}
}
diff --git a/mesalib/src/mesa/swrast/s_context.h b/mesalib/src/mesa/swrast/s_context.h
index 8d7458c2d..8357483a2 100644
--- a/mesalib/src/mesa/swrast/s_context.h
+++ b/mesalib/src/mesa/swrast/s_context.h
@@ -109,6 +109,73 @@ typedef void (*validate_texture_image_func)(struct gl_context *ctx,
_NEW_DEPTH)
+struct swrast_texture_image;
+
+
+typedef void (*FetchTexelFuncC)(const struct swrast_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 (*FetchTexelFuncF)(const struct swrast_texture_image *texImage,
+ GLint col, GLint row, GLint img,
+ GLfloat *texelOut);
+
+
+typedef void (*StoreTexelFunc)(struct swrast_texture_image *texImage,
+ GLint col, GLint row, GLint img,
+ const void *texel);
+
+/**
+ * Subclass of gl_texture_image.
+ * We need extra fields/info to keep tracking of mapped texture buffers,
+ * strides and Fetch/Store functions.
+ */
+struct swrast_texture_image
+{
+ struct gl_texture_image Base;
+
+#if 0
+ /** used for mipmap LOD computation */
+ GLfloat WidthScale, HeightScale, DepthScale;
+ GLboolean _IsPowerOfTwo; /**< Are all dimensions powers of two? */
+
+ GLubyte *Data; /**< The actual texture data in malloc'd memory */
+
+ GLint TexelSize; /**< bytes per texel block */
+#endif
+
+ FetchTexelFuncC FetchTexelc;
+ FetchTexelFuncF FetchTexelf;
+ StoreTexelFunc Store;
+
+#if 0
+ /** These fields only valid when texture memory is mapped */
+ GLubyte **SliceMaps; /**< points to OneMap or a malloc'd array */
+ GLint RowStride; /**< bytes per row of blocks */
+#endif
+};
+
+
+/** cast wrapper */
+static INLINE struct swrast_texture_image *
+swrast_texture_image(struct gl_texture_image *img)
+{
+ return (struct swrast_texture_image *) img;
+}
+
+/** cast wrapper */
+static INLINE const struct swrast_texture_image *
+swrast_texture_image_const(const struct gl_texture_image *img)
+{
+ return (const struct swrast_texture_image *) img;
+}
+
+
/**
* \struct SWcontext
* \brief Per-context state that's private to the software rasterizer module.
diff --git a/mesalib/src/mesa/main/texfetch.c b/mesalib/src/mesa/swrast/s_texfetch.c
index 11cc8e047..ed17b4bda 100644
--- a/mesalib/src/mesa/main/texfetch.c
+++ b/mesalib/src/mesa/swrast/s_texfetch.c
@@ -25,7 +25,7 @@
/**
- * \file texfetch.c
+ * \file s_texfetch.c
*
* Texel fetch/store functions
*
@@ -33,14 +33,15 @@
*/
-#include "colormac.h"
-#include "macros.h"
-#include "texcompress.h"
-#include "texcompress_fxt1.h"
-#include "texcompress_s3tc.h"
-#include "texcompress_rgtc.h"
-#include "texfetch.h"
-#include "teximage.h"
+#include "main/colormac.h"
+#include "main/macros.h"
+#include "main/texcompress.h"
+#include "main/texcompress_fxt1.h"
+#include "main/texcompress_s3tc.h"
+#include "main/texcompress_rgtc.h"
+#include "main/teximage.h"
+#include "s_context.h"
+#include "s_texfetch.h"
#include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
#include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
@@ -77,20 +78,20 @@ nonlinear_to_linear(GLubyte cs8)
/* Texel fetch routines for all supported formats
*/
#define DIM 1
-#include "texfetch_tmp.h"
+#include "s_texfetch_tmp.h"
#define DIM 2
-#include "texfetch_tmp.h"
+#include "s_texfetch_tmp.h"
#define DIM 3
-#include "texfetch_tmp.h"
+#include "s_texfetch_tmp.h"
/**
* Null texel fetch function.
*
* Have to have this so the FetchTexel function pointer is never NULL.
*/
-static void fetch_null_texelf( const struct gl_texture_image *texImage,
+static void fetch_null_texelf( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
(void) texImage; (void) i; (void) j; (void) k;
@@ -101,7 +102,7 @@ static void fetch_null_texelf( const struct gl_texture_image *texImage,
_mesa_warning(NULL, "fetch_null_texelf() called!");
}
-static void store_null_texel(struct gl_texture_image *texImage,
+static void store_null_texel(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
(void) texImage;
@@ -964,11 +965,11 @@ _mesa_get_texel_store_func(gl_format format)
* Adaptor for fetching a GLchan texel from a float-valued texture.
*/
static void
-fetch_texel_float_to_chan(const struct gl_texture_image *texImage,
+fetch_texel_float_to_chan(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texelOut)
{
GLfloat temp[4];
- GLenum baseFormat = _mesa_get_format_base_format(texImage->TexFormat);
+ GLenum baseFormat = _mesa_get_format_base_format(texImage->Base.TexFormat);
ASSERT(texImage->FetchTexelf);
texImage->FetchTexelf(texImage, i, j, k, temp);
@@ -992,7 +993,7 @@ fetch_texel_float_to_chan(const struct gl_texture_image *texImage,
* Adaptor for fetching a float texel from a GLchan-valued texture.
*/
static void
-fetch_texel_chan_to_float(const struct gl_texture_image *texImage,
+fetch_texel_chan_to_float(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texelOut)
{
GLchan temp[4];
@@ -1019,14 +1020,14 @@ fetch_texel_chan_to_float(const struct gl_texture_image *texImage,
/**
* Initialize the texture image's FetchTexelc and FetchTexelf methods.
*/
-void
-_mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims)
+static void
+set_fetch_functions(struct swrast_texture_image *texImage, GLuint dims)
{
- gl_format format = texImage->TexFormat;
+ gl_format format = texImage->Base.TexFormat;
ASSERT(dims == 1 || dims == 2 || dims == 3);
- if (texImage->TexObject->Sampler.sRGBDecode == GL_SKIP_DECODE_EXT &&
+ if (texImage->Base.TexObject->Sampler.sRGBDecode == GL_SKIP_DECODE_EXT &&
_mesa_get_format_color_encoding(format) == GL_SRGB) {
format = _mesa_get_srgb_format_linear(format);
}
@@ -1050,7 +1051,8 @@ _mesa_update_fetch_functions(struct gl_texture_object *texObj)
for (face = 0; face < 6; face++) {
for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
if (texObj->Image[face][i]) {
- _mesa_set_fetch_functions(texObj->Image[face][i], dims);
+ set_fetch_functions(swrast_texture_image(texObj->Image[face][i]),
+ dims);
}
}
}
diff --git a/mesalib/src/mesa/main/texfetch.h b/mesalib/src/mesa/swrast/s_texfetch.h
index dad19cee1..19b196a5a 100644
--- a/mesalib/src/mesa/main/texfetch.h
+++ b/mesalib/src/mesa/swrast/s_texfetch.h
@@ -1,45 +1,41 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.7
- *
- * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
- * Copyright (c) 2009 VMware, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-
-#ifndef TEXFETCH_H
-#define TEXFETCH_H
-
-#include "mtypes.h"
-#include "formats.h"
-
-
-extern StoreTexelFunc
-_mesa_get_texel_store_func(gl_format format);
-
-extern FetchTexelFuncF
-_mesa_get_texel_fetch_func(gl_format format, GLuint dims);
-
-extern void
-_mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims);
-
-void
-_mesa_update_fetch_functions(struct gl_texture_object *texObj);
-#endif
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.7
+ *
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
+ * Copyright (c) 2009 VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * 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.
+ */
+
+
+#ifndef S_TEXFETCH_H
+#define S_TEXFETCH_H
+
+#include "swrast/s_context.h"
+
+extern StoreTexelFunc
+_mesa_get_texel_store_func(gl_format format);
+
+extern FetchTexelFuncF
+_mesa_get_texel_fetch_func(gl_format format, GLuint dims);
+
+void
+_mesa_update_fetch_functions(struct gl_texture_object *texObj);
+
+#endif /* S_TEXFETCH_H */
diff --git a/mesalib/src/mesa/main/texfetch_tmp.h b/mesalib/src/mesa/swrast/s_texfetch_tmp.h
index dbed3dba9..3eebd13d7 100644
--- a/mesalib/src/mesa/main/texfetch_tmp.h
+++ b/mesalib/src/mesa/swrast/s_texfetch_tmp.h
@@ -43,7 +43,7 @@
#if DIM == 1
#define TEXEL_ADDR( type, image, i, j, k, size ) \
- ((void) (j), (void) (k), ((type *)(image)->Data + (i) * (size)))
+ ((void) (j), (void) (k), ((type *)(image)->Base.Data + (i) * (size)))
#define FETCH(x) fetch_texel_1d_##x
@@ -51,15 +51,15 @@
#define TEXEL_ADDR( type, image, i, j, k, size ) \
((void) (k), \
- ((type *)(image)->Data + ((image)->RowStride * (j) + (i)) * (size)))
+ ((type *)(image)->Base.Data + ((image)->Base.RowStride * (j) + (i)) * (size)))
#define FETCH(x) fetch_texel_2d_##x
#elif DIM == 3
#define TEXEL_ADDR( type, image, i, j, k, size ) \
- ((type *)(image)->Data + ((image)->ImageOffsets[k] \
- + (image)->RowStride * (j) + (i)) * (size))
+ ((type *)(image)->Base.Data + ((image)->Base.ImageOffsets[k] \
+ + (image)->Base.RowStride * (j) + (i)) * (size))
#define FETCH(x) fetch_texel_3d_##x
@@ -74,7 +74,7 @@
* returning 1 GLfloat.
* Note: no GLchan version of this function.
*/
-static void FETCH(f_z32)( const struct gl_texture_image *texImage,
+static void FETCH(f_z32)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
@@ -82,7 +82,7 @@ static void FETCH(f_z32)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_z32(struct gl_texture_image *texImage,
+static void store_texel_z32(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLuint *depth = (const GLuint *) texel;
@@ -98,7 +98,7 @@ static void store_texel_z32(struct gl_texture_image *texImage,
* returning 1 GLfloat.
* Note: no GLchan version of this function.
*/
-static void FETCH(f_z16)(const struct gl_texture_image *texImage,
+static void FETCH(f_z16)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
@@ -106,7 +106,7 @@ static void FETCH(f_z16)(const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_z16(struct gl_texture_image *texImage,
+static void store_texel_z16(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLushort *depth = (const GLushort *) texel;
@@ -120,7 +120,7 @@ static void store_texel_z16(struct gl_texture_image *texImage,
/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT32 texture, returning 4 GLfloats.
*/
-static void FETCH(f_rgba_f32)( const struct gl_texture_image *texImage,
+static void FETCH(f_rgba_f32)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 4);
@@ -131,7 +131,7 @@ static void FETCH(f_rgba_f32)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_rgba_f32(struct gl_texture_image *texImage,
+static void store_texel_rgba_f32(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLfloat *depth = (const GLfloat *) texel;
@@ -149,7 +149,7 @@ static void store_texel_rgba_f32(struct gl_texture_image *texImage,
/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT16 texture,
* returning 4 GLfloats.
*/
-static void FETCH(f_rgba_f16)( const struct gl_texture_image *texImage,
+static void FETCH(f_rgba_f16)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 4);
@@ -160,7 +160,7 @@ static void FETCH(f_rgba_f16)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_rgba_f16(struct gl_texture_image *texImage,
+static void store_texel_rgba_f16(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLfloat *src = (const GLfloat *) texel;
@@ -177,7 +177,7 @@ static void store_texel_rgba_f16(struct gl_texture_image *texImage,
/* Fetch texel from 1D, 2D or 3D RGB_FLOAT32 texture,
* returning 4 GLfloats.
*/
-static void FETCH(f_rgb_f32)( const struct gl_texture_image *texImage,
+static void FETCH(f_rgb_f32)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 3);
@@ -188,7 +188,7 @@ static void FETCH(f_rgb_f32)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_rgb_f32(struct gl_texture_image *texImage,
+static void store_texel_rgb_f32(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLfloat *src = (const GLfloat *) texel;
@@ -205,7 +205,7 @@ static void store_texel_rgb_f32(struct gl_texture_image *texImage,
/* Fetch texel from 1D, 2D or 3D RGB_FLOAT16 texture,
* returning 4 GLfloats.
*/
-static void FETCH(f_rgb_f16)( const struct gl_texture_image *texImage,
+static void FETCH(f_rgb_f16)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 3);
@@ -216,7 +216,7 @@ static void FETCH(f_rgb_f16)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_rgb_f16(struct gl_texture_image *texImage,
+static void store_texel_rgb_f16(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLfloat *src = (const GLfloat *) texel;
@@ -233,7 +233,7 @@ static void store_texel_rgb_f16(struct gl_texture_image *texImage,
/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT32 texture,
* returning 4 GLfloats.
*/
-static void FETCH(f_alpha_f32)( const struct gl_texture_image *texImage,
+static void FETCH(f_alpha_f32)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
@@ -244,7 +244,7 @@ static void FETCH(f_alpha_f32)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_alpha_f32(struct gl_texture_image *texImage,
+static void store_texel_alpha_f32(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLfloat *rgba = (const GLfloat *) texel;
@@ -259,7 +259,7 @@ static void store_texel_alpha_f32(struct gl_texture_image *texImage,
/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT16 texture,
* returning 4 GLfloats.
*/
-static void FETCH(f_alpha_f16)( const struct gl_texture_image *texImage,
+static void FETCH(f_alpha_f16)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
@@ -270,7 +270,7 @@ static void FETCH(f_alpha_f16)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_alpha_f16(struct gl_texture_image *texImage,
+static void store_texel_alpha_f16(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLfloat *rgba = (const GLfloat *) texel;
@@ -285,7 +285,7 @@ static void store_texel_alpha_f16(struct gl_texture_image *texImage,
/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT32 texture,
* returning 4 GLfloats.
*/
-static void FETCH(f_luminance_f32)( const struct gl_texture_image *texImage,
+static void FETCH(f_luminance_f32)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
@@ -296,7 +296,7 @@ static void FETCH(f_luminance_f32)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_luminance_f32(struct gl_texture_image *texImage,
+static void store_texel_luminance_f32(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLfloat *rgba = (const GLfloat *) texel;
@@ -311,7 +311,7 @@ static void store_texel_luminance_f32(struct gl_texture_image *texImage,
/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT16 texture,
* returning 4 GLfloats.
*/
-static void FETCH(f_luminance_f16)( const struct gl_texture_image *texImage,
+static void FETCH(f_luminance_f16)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
@@ -322,7 +322,7 @@ static void FETCH(f_luminance_f16)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_luminance_f16(struct gl_texture_image *texImage,
+static void store_texel_luminance_f16(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLfloat *rgba = (const GLfloat *) texel;
@@ -337,7 +337,7 @@ static void store_texel_luminance_f16(struct gl_texture_image *texImage,
/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT32 texture,
* returning 4 GLfloats.
*/
-static void FETCH(f_luminance_alpha_f32)( const struct gl_texture_image *texImage,
+static void FETCH(f_luminance_alpha_f32)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
@@ -348,7 +348,7 @@ static void FETCH(f_luminance_alpha_f32)( const struct gl_texture_image *texImag
}
#if DIM == 3
-static void store_texel_luminance_alpha_f32(struct gl_texture_image *texImage,
+static void store_texel_luminance_alpha_f32(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLfloat *rgba = (const GLfloat *) texel;
@@ -364,7 +364,7 @@ static void store_texel_luminance_alpha_f32(struct gl_texture_image *texImage,
/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT16 texture,
* returning 4 GLfloats.
*/
-static void FETCH(f_luminance_alpha_f16)( const struct gl_texture_image *texImage,
+static void FETCH(f_luminance_alpha_f16)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2);
@@ -375,7 +375,7 @@ static void FETCH(f_luminance_alpha_f16)( const struct gl_texture_image *texImag
}
#if DIM == 3
-static void store_texel_luminance_alpha_f16(struct gl_texture_image *texImage,
+static void store_texel_luminance_alpha_f16(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLfloat *rgba = (const GLfloat *) texel;
@@ -391,7 +391,7 @@ static void store_texel_luminance_alpha_f16(struct gl_texture_image *texImage,
/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT32 texture,
* returning 4 GLfloats.
*/
-static void FETCH(f_intensity_f32)( const struct gl_texture_image *texImage,
+static void FETCH(f_intensity_f32)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
@@ -402,7 +402,7 @@ static void FETCH(f_intensity_f32)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_intensity_f32(struct gl_texture_image *texImage,
+static void store_texel_intensity_f32(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLfloat *rgba = (const GLfloat *) texel;
@@ -417,7 +417,7 @@ static void store_texel_intensity_f32(struct gl_texture_image *texImage,
/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT16 texture,
* returning 4 GLfloats.
*/
-static void FETCH(f_intensity_f16)( const struct gl_texture_image *texImage,
+static void FETCH(f_intensity_f16)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
@@ -428,7 +428,7 @@ static void FETCH(f_intensity_f16)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_intensity_f16(struct gl_texture_image *texImage,
+static void store_texel_intensity_f16(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLfloat *rgba = (const GLfloat *) texel;
@@ -443,7 +443,7 @@ static void store_texel_intensity_f16(struct gl_texture_image *texImage,
/* Fetch texel from 1D, 2D or 3D R_FLOAT32 texture,
* returning 4 GLfloats.
*/
-static void FETCH(f_r_f32)( const struct gl_texture_image *texImage,
+static void FETCH(f_r_f32)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
@@ -454,7 +454,7 @@ static void FETCH(f_r_f32)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_r_f32(struct gl_texture_image *texImage,
+static void store_texel_r_f32(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLfloat *rgba = (const GLfloat *) texel;
@@ -469,7 +469,7 @@ static void store_texel_r_f32(struct gl_texture_image *texImage,
/* Fetch texel from 1D, 2D or 3D R_FLOAT16 texture,
* returning 4 GLfloats.
*/
-static void FETCH(f_r_f16)( const struct gl_texture_image *texImage,
+static void FETCH(f_r_f16)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
@@ -480,7 +480,7 @@ static void FETCH(f_r_f16)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_r_f16(struct gl_texture_image *texImage,
+static void store_texel_r_f16(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLfloat *rgba = (const GLfloat *) texel;
@@ -495,7 +495,7 @@ static void store_texel_r_f16(struct gl_texture_image *texImage,
/* Fetch texel from 1D, 2D or 3D RG_FLOAT32 texture,
* returning 4 GLfloats.
*/
-static void FETCH(f_rg_f32)( const struct gl_texture_image *texImage,
+static void FETCH(f_rg_f32)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
@@ -506,7 +506,7 @@ static void FETCH(f_rg_f32)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_rg_f32(struct gl_texture_image *texImage,
+static void store_texel_rg_f32(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLfloat *rgba = (const GLfloat *) texel;
@@ -522,7 +522,7 @@ static void store_texel_rg_f32(struct gl_texture_image *texImage,
/* Fetch texel from 1D, 2D or 3D RG_FLOAT16 texture,
* returning 4 GLfloats.
*/
-static void FETCH(f_rg_f16)( const struct gl_texture_image *texImage,
+static void FETCH(f_rg_f16)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2);
@@ -533,7 +533,7 @@ static void FETCH(f_rg_f16)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_rg_f16(struct gl_texture_image *texImage,
+static void store_texel_rg_f16(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLfloat *rgba = (const GLfloat *) texel;
@@ -551,7 +551,7 @@ static void store_texel_rg_f16(struct gl_texture_image *texImage,
/* MESA_FORMAT_RGBA8888 ******************************************************/
/* Fetch texel from 1D, 2D or 3D rgba8888 texture, return 4 GLfloats */
-static void FETCH(f_rgba8888)( const struct gl_texture_image *texImage,
+static void FETCH(f_rgba8888)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
@@ -564,7 +564,7 @@ static void FETCH(f_rgba8888)( const struct gl_texture_image *texImage,
#if DIM == 3
-static void store_texel_rgba8888(struct gl_texture_image *texImage,
+static void store_texel_rgba8888(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -577,7 +577,7 @@ static void store_texel_rgba8888(struct gl_texture_image *texImage,
/* MESA_FORMAT_RGBA888_REV ***************************************************/
/* Fetch texel from 1D, 2D or 3D abgr8888 texture, return 4 GLchans */
-static void FETCH(f_rgba8888_rev)( const struct gl_texture_image *texImage,
+static void FETCH(f_rgba8888_rev)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
@@ -588,7 +588,7 @@ static void FETCH(f_rgba8888_rev)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_rgba8888_rev(struct gl_texture_image *texImage,
+static void store_texel_rgba8888_rev(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -601,7 +601,7 @@ static void store_texel_rgba8888_rev(struct gl_texture_image *texImage,
/* MESA_FORMAT_ARGB8888 ******************************************************/
/* Fetch texel from 1D, 2D or 3D argb8888 texture, return 4 GLchans */
-static void FETCH(f_argb8888)( const struct gl_texture_image *texImage,
+static void FETCH(f_argb8888)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
@@ -612,7 +612,7 @@ static void FETCH(f_argb8888)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_argb8888(struct gl_texture_image *texImage,
+static void store_texel_argb8888(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -625,7 +625,7 @@ static void store_texel_argb8888(struct gl_texture_image *texImage,
/* MESA_FORMAT_ARGB8888_REV **************************************************/
/* Fetch texel from 1D, 2D or 3D argb8888_rev texture, return 4 GLfloats */
-static void FETCH(f_argb8888_rev)( const struct gl_texture_image *texImage,
+static void FETCH(f_argb8888_rev)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
@@ -636,7 +636,7 @@ static void FETCH(f_argb8888_rev)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_argb8888_rev(struct gl_texture_image *texImage,
+static void store_texel_argb8888_rev(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -649,7 +649,7 @@ static void store_texel_argb8888_rev(struct gl_texture_image *texImage,
/* MESA_FORMAT_XRGB8888 ******************************************************/
/* Fetch texel from 1D, 2D or 3D xrgb8888 texture, return 4 GLchans */
-static void FETCH(f_xrgb8888)( const struct gl_texture_image *texImage,
+static void FETCH(f_xrgb8888)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
@@ -660,7 +660,7 @@ static void FETCH(f_xrgb8888)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_xrgb8888(struct gl_texture_image *texImage,
+static void store_texel_xrgb8888(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -673,7 +673,7 @@ static void store_texel_xrgb8888(struct gl_texture_image *texImage,
/* MESA_FORMAT_XRGB8888_REV **************************************************/
/* Fetch texel from 1D, 2D or 3D xrgb8888_rev texture, return 4 GLfloats */
-static void FETCH(f_xrgb8888_rev)( const struct gl_texture_image *texImage,
+static void FETCH(f_xrgb8888_rev)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
@@ -684,7 +684,7 @@ static void FETCH(f_xrgb8888_rev)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_xrgb8888_rev(struct gl_texture_image *texImage,
+static void store_texel_xrgb8888_rev(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -697,7 +697,7 @@ static void store_texel_xrgb8888_rev(struct gl_texture_image *texImage,
/* MESA_FORMAT_RGB888 ********************************************************/
/* Fetch texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */
-static void FETCH(f_rgb888)( const struct gl_texture_image *texImage,
+static void FETCH(f_rgb888)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
@@ -708,7 +708,7 @@ static void FETCH(f_rgb888)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_rgb888(struct gl_texture_image *texImage,
+static void store_texel_rgb888(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -723,7 +723,7 @@ static void store_texel_rgb888(struct gl_texture_image *texImage,
/* MESA_FORMAT_BGR888 ********************************************************/
/* Fetch texel from 1D, 2D or 3D bgr888 texture, return 4 GLchans */
-static void FETCH(f_bgr888)( const struct gl_texture_image *texImage,
+static void FETCH(f_bgr888)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
@@ -734,7 +734,7 @@ static void FETCH(f_bgr888)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_bgr888(struct gl_texture_image *texImage,
+static void store_texel_bgr888(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -752,7 +752,7 @@ static void store_texel_bgr888(struct gl_texture_image *texImage,
/* MESA_FORMAT_RGB565 ********************************************************/
/* Fetch texel from 1D, 2D or 3D rgb565 texture, return 4 GLchans */
-static void FETCH(f_rgb565)( const struct gl_texture_image *texImage,
+static void FETCH(f_rgb565)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
@@ -764,7 +764,7 @@ static void FETCH(f_rgb565)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_rgb565(struct gl_texture_image *texImage,
+static void store_texel_rgb565(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -777,7 +777,7 @@ static void store_texel_rgb565(struct gl_texture_image *texImage,
/* MESA_FORMAT_RGB565_REV ****************************************************/
/* Fetch texel from 1D, 2D or 3D rgb565_rev texture, return 4 GLchans */
-static void FETCH(f_rgb565_rev)( const struct gl_texture_image *texImage,
+static void FETCH(f_rgb565_rev)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
@@ -789,7 +789,7 @@ static void FETCH(f_rgb565_rev)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_rgb565_rev(struct gl_texture_image *texImage,
+static void store_texel_rgb565_rev(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLchan *rgba = (const GLchan *) texel;
@@ -805,7 +805,7 @@ static void store_texel_rgb565_rev(struct gl_texture_image *texImage,
/* MESA_FORMAT_ARGB4444 ******************************************************/
/* Fetch texel from 1D, 2D or 3D argb444 texture, return 4 GLchans */
-static void FETCH(f_argb4444)( const struct gl_texture_image *texImage,
+static void FETCH(f_argb4444)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
@@ -817,7 +817,7 @@ static void FETCH(f_argb4444)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_argb4444(struct gl_texture_image *texImage,
+static void store_texel_argb4444(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLchan *rgba = (const GLchan *) texel;
@@ -833,7 +833,7 @@ static void store_texel_argb4444(struct gl_texture_image *texImage,
/* MESA_FORMAT_ARGB4444_REV **************************************************/
/* Fetch texel from 1D, 2D or 3D argb4444_rev texture, return 4 GLchans */
-static void FETCH(f_argb4444_rev)( const struct gl_texture_image *texImage,
+static void FETCH(f_argb4444_rev)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
@@ -844,7 +844,7 @@ static void FETCH(f_argb4444_rev)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_argb4444_rev(struct gl_texture_image *texImage,
+static void store_texel_argb4444_rev(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLchan *rgba = (const GLchan *) texel;
@@ -859,7 +859,7 @@ static void store_texel_argb4444_rev(struct gl_texture_image *texImage,
/* MESA_FORMAT_RGBA5551 ******************************************************/
/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */
-static void FETCH(f_rgba5551)( const struct gl_texture_image *texImage,
+static void FETCH(f_rgba5551)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
@@ -871,7 +871,7 @@ static void FETCH(f_rgba5551)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_rgba5551(struct gl_texture_image *texImage,
+static void store_texel_rgba5551(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -883,7 +883,7 @@ static void store_texel_rgba5551(struct gl_texture_image *texImage,
/* MESA_FORMAT_ARGB1555 ******************************************************/
/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */
-static void FETCH(f_argb1555)( const struct gl_texture_image *texImage,
+static void FETCH(f_argb1555)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
@@ -895,7 +895,7 @@ static void FETCH(f_argb1555)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_argb1555(struct gl_texture_image *texImage,
+static void store_texel_argb1555(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -908,7 +908,7 @@ static void store_texel_argb1555(struct gl_texture_image *texImage,
/* MESA_FORMAT_ARGB1555_REV **************************************************/
/* Fetch texel from 1D, 2D or 3D argb1555_rev texture, return 4 GLchans */
-static void FETCH(f_argb1555_rev)( const struct gl_texture_image *texImage,
+static void FETCH(f_argb1555_rev)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
@@ -920,7 +920,7 @@ static void FETCH(f_argb1555_rev)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_argb1555_rev(struct gl_texture_image *texImage,
+static void store_texel_argb1555_rev(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -933,7 +933,7 @@ static void store_texel_argb1555_rev(struct gl_texture_image *texImage,
/* MESA_FORMAT_ARGB2101010 ***************************************************/
/* Fetch texel from 1D, 2D or 3D argb2101010 texture, return 4 GLchans */
-static void FETCH(f_argb2101010)( const struct gl_texture_image *texImage,
+static void FETCH(f_argb2101010)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
@@ -945,7 +945,7 @@ static void FETCH(f_argb2101010)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_argb2101010(struct gl_texture_image *texImage,
+static void store_texel_argb2101010(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLchan *rgba = (const GLchan *) texel;
@@ -962,7 +962,7 @@ static void store_texel_argb2101010(struct gl_texture_image *texImage,
/* MESA_FORMAT_RG88 **********************************************************/
/* Fetch texel from 1D, 2D or 3D rg88 texture, return 4 GLchans */
-static void FETCH(f_rg88)( const struct gl_texture_image *texImage,
+static void FETCH(f_rg88)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
@@ -973,7 +973,7 @@ static void FETCH(f_rg88)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_rg88(struct gl_texture_image *texImage,
+static void store_texel_rg88(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLchan *rgba = (const GLubyte *) texel;
@@ -988,7 +988,7 @@ static void store_texel_rg88(struct gl_texture_image *texImage,
/* MESA_FORMAT_RG88_REV ******************************************************/
/* Fetch texel from 1D, 2D or 3D rg88_rev texture, return 4 GLchans */
-static void FETCH(f_rg88_rev)( const struct gl_texture_image *texImage,
+static void FETCH(f_rg88_rev)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
@@ -999,7 +999,7 @@ static void FETCH(f_rg88_rev)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_rg88_rev(struct gl_texture_image *texImage,
+static void store_texel_rg88_rev(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -1012,7 +1012,7 @@ static void store_texel_rg88_rev(struct gl_texture_image *texImage,
/* MESA_FORMAT_AL44 **********************************************************/
/* Fetch texel from 1D, 2D or 3D al44 texture, return 4 GLchans */
-static void FETCH(f_al44)( const struct gl_texture_image *texImage,
+static void FETCH(f_al44)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLubyte s = *TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
@@ -1023,7 +1023,7 @@ static void FETCH(f_al44)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_al44(struct gl_texture_image *texImage,
+static void store_texel_al44(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -1036,7 +1036,7 @@ static void store_texel_al44(struct gl_texture_image *texImage,
/* MESA_FORMAT_AL88 **********************************************************/
/* Fetch texel from 1D, 2D or 3D al88 texture, return 4 GLchans */
-static void FETCH(f_al88)( const struct gl_texture_image *texImage,
+static void FETCH(f_al88)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
@@ -1047,7 +1047,7 @@ static void FETCH(f_al88)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_al88(struct gl_texture_image *texImage,
+static void store_texel_al88(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -1060,7 +1060,7 @@ static void store_texel_al88(struct gl_texture_image *texImage,
/* MESA_FORMAT_R8 ************************************************************/
/* Fetch texel from 1D, 2D or 3D rg88 texture, return 4 GLchans */
-static void FETCH(f_r8)(const struct gl_texture_image *texImage,
+static void FETCH(f_r8)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
const GLubyte s = *TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
@@ -1071,7 +1071,7 @@ static void FETCH(f_r8)(const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_r8(struct gl_texture_image *texImage,
+static void store_texel_r8(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -1084,7 +1084,7 @@ static void store_texel_r8(struct gl_texture_image *texImage,
/* MESA_FORMAT_R16 ***********************************************************/
/* Fetch texel from 1D, 2D or 3D r16 texture, return 4 GLchans */
-static void FETCH(f_r16)(const struct gl_texture_image *texImage,
+static void FETCH(f_r16)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
@@ -1095,7 +1095,7 @@ static void FETCH(f_r16)(const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_r16(struct gl_texture_image *texImage,
+static void store_texel_r16(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLchan *rgba = (const GLchan *) texel;
@@ -1108,7 +1108,7 @@ static void store_texel_r16(struct gl_texture_image *texImage,
/* MESA_FORMAT_AL88_REV ******************************************************/
/* Fetch texel from 1D, 2D or 3D al88_rev texture, return 4 GLchans */
-static void FETCH(f_al88_rev)( const struct gl_texture_image *texImage,
+static void FETCH(f_al88_rev)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
@@ -1119,7 +1119,7 @@ static void FETCH(f_al88_rev)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_al88_rev(struct gl_texture_image *texImage,
+static void store_texel_al88_rev(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -1132,7 +1132,7 @@ static void store_texel_al88_rev(struct gl_texture_image *texImage,
/* MESA_FORMAT_RG1616 ********************************************************/
/* Fetch texel from 1D, 2D or 3D rg1616 texture, return 4 GLchans */
-static void FETCH(f_rg1616)( const struct gl_texture_image *texImage,
+static void FETCH(f_rg1616)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
@@ -1143,7 +1143,7 @@ static void FETCH(f_rg1616)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_rg1616(struct gl_texture_image *texImage,
+static void store_texel_rg1616(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLchan *rgba = (const GLchan *) texel;
@@ -1158,7 +1158,7 @@ static void store_texel_rg1616(struct gl_texture_image *texImage,
/* MESA_FORMAT_RG1616_REV ****************************************************/
/* Fetch texel from 1D, 2D or 3D rg1616_rev texture, return 4 GLchans */
-static void FETCH(f_rg1616_rev)( const struct gl_texture_image *texImage,
+static void FETCH(f_rg1616_rev)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
@@ -1169,7 +1169,7 @@ static void FETCH(f_rg1616_rev)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_rg1616_rev(struct gl_texture_image *texImage,
+static void store_texel_rg1616_rev(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -1182,7 +1182,7 @@ static void store_texel_rg1616_rev(struct gl_texture_image *texImage,
/* MESA_FORMAT_AL1616 ********************************************************/
/* Fetch texel from 1D, 2D or 3D al1616 texture, return 4 GLchans */
-static void FETCH(f_al1616)( const struct gl_texture_image *texImage,
+static void FETCH(f_al1616)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
@@ -1193,7 +1193,7 @@ static void FETCH(f_al1616)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_al1616(struct gl_texture_image *texImage,
+static void store_texel_al1616(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLchan *rgba = (const GLchan *) texel;
@@ -1208,7 +1208,7 @@ static void store_texel_al1616(struct gl_texture_image *texImage,
/* MESA_FORMAT_AL1616_REV ****************************************************/
/* Fetch texel from 1D, 2D or 3D al1616_rev texture, return 4 GLchans */
-static void FETCH(f_al1616_rev)( const struct gl_texture_image *texImage,
+static void FETCH(f_al1616_rev)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
@@ -1219,7 +1219,7 @@ static void FETCH(f_al1616_rev)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_al1616_rev(struct gl_texture_image *texImage,
+static void store_texel_al1616_rev(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLushort *rgba = (const GLushort *) texel;
@@ -1232,7 +1232,7 @@ static void store_texel_al1616_rev(struct gl_texture_image *texImage,
/* MESA_FORMAT_RGB332 ********************************************************/
/* Fetch texel from 1D, 2D or 3D rgb332 texture, return 4 GLchans */
-static void FETCH(f_rgb332)( const struct gl_texture_image *texImage,
+static void FETCH(f_rgb332)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
@@ -1244,7 +1244,7 @@ static void FETCH(f_rgb332)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_rgb332(struct gl_texture_image *texImage,
+static void store_texel_rgb332(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -1257,7 +1257,7 @@ static void store_texel_rgb332(struct gl_texture_image *texImage,
/* MESA_FORMAT_A8 ************************************************************/
/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */
-static void FETCH(f_a8)( const struct gl_texture_image *texImage,
+static void FETCH(f_a8)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
@@ -1268,7 +1268,7 @@ static void FETCH(f_a8)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_a8(struct gl_texture_image *texImage,
+static void store_texel_a8(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -1281,7 +1281,7 @@ static void store_texel_a8(struct gl_texture_image *texImage,
/* MESA_FORMAT_A16 ************************************************************/
/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */
-static void FETCH(f_a16)( const struct gl_texture_image *texImage,
+static void FETCH(f_a16)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
@@ -1292,7 +1292,7 @@ static void FETCH(f_a16)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_a16(struct gl_texture_image *texImage,
+static void store_texel_a16(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLchan *rgba = (const GLchan *) texel;
@@ -1305,7 +1305,7 @@ static void store_texel_a16(struct gl_texture_image *texImage,
/* MESA_FORMAT_L8 ************************************************************/
/* Fetch texel from 1D, 2D or 3D l8 texture, return 4 GLchans */
-static void FETCH(f_l8)( const struct gl_texture_image *texImage,
+static void FETCH(f_l8)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
@@ -1316,7 +1316,7 @@ static void FETCH(f_l8)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_l8(struct gl_texture_image *texImage,
+static void store_texel_l8(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -1329,7 +1329,7 @@ static void store_texel_l8(struct gl_texture_image *texImage,
/* MESA_FORMAT_L16 ***********************************************************/
/* Fetch texel from 1D, 2D or 3D l16 texture, return 4 GLchans */
-static void FETCH(f_l16)( const struct gl_texture_image *texImage,
+static void FETCH(f_l16)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
@@ -1340,12 +1340,12 @@ static void FETCH(f_l16)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_l16(struct gl_texture_image *texImage,
+static void store_texel_l16(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
- const GLushort *rgba = (const GLushort *) texel;
+ const GLchan *rgba = (const GLchan *) texel;
GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = rgba[RCOMP];
+ *dst = CHAN_TO_USHORT(rgba[RCOMP]);
}
#endif
@@ -1353,7 +1353,7 @@ static void store_texel_l16(struct gl_texture_image *texImage,
/* MESA_FORMAT_I8 ************************************************************/
/* Fetch texel from 1D, 2D or 3D i8 texture, return 4 GLchans */
-static void FETCH(f_i8)( const struct gl_texture_image *texImage,
+static void FETCH(f_i8)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
@@ -1364,7 +1364,7 @@ static void FETCH(f_i8)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_i8(struct gl_texture_image *texImage,
+static void store_texel_i8(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -1377,7 +1377,7 @@ static void store_texel_i8(struct gl_texture_image *texImage,
/* MESA_FORMAT_I16 ***********************************************************/
/* Fetch texel from 1D, 2D or 3D i16 texture, return 4 GLchans */
-static void FETCH(f_i16)( const struct gl_texture_image *texImage,
+static void FETCH(f_i16)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
@@ -1388,19 +1388,19 @@ static void FETCH(f_i16)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_i16(struct gl_texture_image *texImage,
+static void store_texel_i16(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
- const GLushort *rgba = (const GLushort *) texel;
+ const GLchan *rgba = (const GLchan *) texel;
GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = rgba[RCOMP];
+ *dst = CHAN_TO_USHORT(rgba[RCOMP]);
}
#endif
/* Fetch texel from 1D, 2D or 3D srgb8 texture, return 4 GLfloats */
/* Note: component order is same as for MESA_FORMAT_RGB888 */
-static void FETCH(srgb8)(const struct gl_texture_image *texImage,
+static void FETCH(srgb8)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
@@ -1411,7 +1411,7 @@ static void FETCH(srgb8)(const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_srgb8(struct gl_texture_image *texImage,
+static void store_texel_srgb8(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -1423,7 +1423,7 @@ static void store_texel_srgb8(struct gl_texture_image *texImage,
#endif
/* Fetch texel from 1D, 2D or 3D srgba8 texture, return 4 GLfloats */
-static void FETCH(srgba8)(const struct gl_texture_image *texImage,
+static void FETCH(srgba8)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
@@ -1434,7 +1434,7 @@ static void FETCH(srgba8)(const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_srgba8(struct gl_texture_image *texImage,
+static void store_texel_srgba8(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -1444,7 +1444,7 @@ static void store_texel_srgba8(struct gl_texture_image *texImage,
#endif
/* Fetch texel from 1D, 2D or 3D sargb8 texture, return 4 GLfloats */
-static void FETCH(sargb8)(const struct gl_texture_image *texImage,
+static void FETCH(sargb8)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
@@ -1455,7 +1455,7 @@ static void FETCH(sargb8)(const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_sargb8(struct gl_texture_image *texImage,
+static void store_texel_sargb8(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -1465,7 +1465,7 @@ static void store_texel_sargb8(struct gl_texture_image *texImage,
#endif
/* Fetch texel from 1D, 2D or 3D sl8 texture, return 4 GLfloats */
-static void FETCH(sl8)(const struct gl_texture_image *texImage,
+static void FETCH(sl8)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
@@ -1476,7 +1476,7 @@ static void FETCH(sl8)(const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_sl8(struct gl_texture_image *texImage,
+static void store_texel_sl8(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -1486,7 +1486,7 @@ static void store_texel_sl8(struct gl_texture_image *texImage,
#endif
/* Fetch texel from 1D, 2D or 3D sla8 texture, return 4 GLfloats */
-static void FETCH(sla8)(const struct gl_texture_image *texImage,
+static void FETCH(sla8)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 2);
@@ -1497,7 +1497,7 @@ static void FETCH(sla8)(const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_sla8(struct gl_texture_image *texImage,
+static void store_texel_sla8(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -1511,7 +1511,7 @@ static void store_texel_sla8(struct gl_texture_image *texImage,
/* MESA_FORMAT_RGBA_INT8 **************************************************/
static void
-FETCH(rgba_int8)(const struct gl_texture_image *texImage,
+FETCH(rgba_int8)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLbyte *src = TEXEL_ADDR(GLbyte, texImage, i, j, k, 4);
@@ -1523,7 +1523,7 @@ FETCH(rgba_int8)(const struct gl_texture_image *texImage,
#if DIM == 3
static void
-store_texel_rgba_int8(struct gl_texture_image *texImage,
+store_texel_rgba_int8(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLbyte *rgba = (const GLbyte *) texel;
@@ -1539,7 +1539,7 @@ store_texel_rgba_int8(struct gl_texture_image *texImage,
/* MESA_FORMAT_RGBA_INT16 **************************************************/
static void
-FETCH(rgba_int16)(const struct gl_texture_image *texImage,
+FETCH(rgba_int16)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLshort *src = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
@@ -1551,7 +1551,7 @@ FETCH(rgba_int16)(const struct gl_texture_image *texImage,
#if DIM == 3
static void
-store_texel_rgba_int16(struct gl_texture_image *texImage,
+store_texel_rgba_int16(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLshort *rgba = (const GLshort *) texel;
@@ -1567,7 +1567,7 @@ store_texel_rgba_int16(struct gl_texture_image *texImage,
/* MESA_FORMAT_RGBA_INT32 **************************************************/
static void
-FETCH(rgba_int32)(const struct gl_texture_image *texImage,
+FETCH(rgba_int32)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLint *src = TEXEL_ADDR(GLint, texImage, i, j, k, 4);
@@ -1579,7 +1579,7 @@ FETCH(rgba_int32)(const struct gl_texture_image *texImage,
#if DIM == 3
static void
-store_texel_rgba_int32(struct gl_texture_image *texImage,
+store_texel_rgba_int32(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLint *rgba = (const GLint *) texel;
@@ -1595,7 +1595,7 @@ store_texel_rgba_int32(struct gl_texture_image *texImage,
/* MESA_FORMAT_RGBA_UINT8 **************************************************/
static void
-FETCH(rgba_uint8)(const struct gl_texture_image *texImage,
+FETCH(rgba_uint8)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4);
@@ -1607,7 +1607,7 @@ FETCH(rgba_uint8)(const struct gl_texture_image *texImage,
#if DIM == 3
static void
-store_texel_rgba_uint8(struct gl_texture_image *texImage,
+store_texel_rgba_uint8(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -1623,7 +1623,7 @@ store_texel_rgba_uint8(struct gl_texture_image *texImage,
/* MESA_FORMAT_RGBA_UINT16 **************************************************/
static void
-FETCH(rgba_uint16)(const struct gl_texture_image *texImage,
+FETCH(rgba_uint16)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 4);
@@ -1635,7 +1635,7 @@ FETCH(rgba_uint16)(const struct gl_texture_image *texImage,
#if DIM == 3
static void
-store_texel_rgba_uint16(struct gl_texture_image *texImage,
+store_texel_rgba_uint16(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLushort *rgba = (const GLushort *) texel;
@@ -1651,7 +1651,7 @@ store_texel_rgba_uint16(struct gl_texture_image *texImage,
/* MESA_FORMAT_RGBA_UINT32 **************************************************/
static void
-FETCH(rgba_uint32)(const struct gl_texture_image *texImage,
+FETCH(rgba_uint32)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 4);
@@ -1663,7 +1663,7 @@ FETCH(rgba_uint32)(const struct gl_texture_image *texImage,
#if DIM == 3
static void
-store_texel_rgba_uint32(struct gl_texture_image *texImage,
+store_texel_rgba_uint32(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLuint *rgba = (const GLuint *) texel;
@@ -1680,7 +1680,7 @@ store_texel_rgba_uint32(struct gl_texture_image *texImage,
/* this format by definition produces 0,0,0,1 as rgba values,
however we'll return the dudv values as rg and fix up elsewhere */
-static void FETCH(dudv8)(const struct gl_texture_image *texImage,
+static void FETCH(dudv8)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLbyte *src = TEXEL_ADDR(GLbyte, texImage, i, j, k, 2);
@@ -1693,7 +1693,7 @@ static void FETCH(dudv8)(const struct gl_texture_image *texImage,
/* MESA_FORMAT_SIGNED_R8 ***********************************************/
-static void FETCH(signed_r8)( const struct gl_texture_image *texImage,
+static void FETCH(signed_r8)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
@@ -1704,7 +1704,7 @@ static void FETCH(signed_r8)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_signed_r8(struct gl_texture_image *texImage,
+static void store_texel_signed_r8(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLbyte *rgba = (const GLbyte *) texel;
@@ -1716,7 +1716,7 @@ static void store_texel_signed_r8(struct gl_texture_image *texImage,
/* MESA_FORMAT_SIGNED_A8 ***********************************************/
-static void FETCH(signed_a8)( const struct gl_texture_image *texImage,
+static void FETCH(signed_a8)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
@@ -1727,7 +1727,7 @@ static void FETCH(signed_a8)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_signed_a8(struct gl_texture_image *texImage,
+static void store_texel_signed_a8(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLbyte *rgba = (const GLbyte *) texel;
@@ -1739,7 +1739,7 @@ static void store_texel_signed_a8(struct gl_texture_image *texImage,
/* MESA_FORMAT_SIGNED_L8 ***********************************************/
-static void FETCH(signed_l8)( const struct gl_texture_image *texImage,
+static void FETCH(signed_l8)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
@@ -1750,7 +1750,7 @@ static void FETCH(signed_l8)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_signed_l8(struct gl_texture_image *texImage,
+static void store_texel_signed_l8(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLbyte *rgba = (const GLbyte *) texel;
@@ -1762,7 +1762,7 @@ static void store_texel_signed_l8(struct gl_texture_image *texImage,
/* MESA_FORMAT_SIGNED_I8 ***********************************************/
-static void FETCH(signed_i8)( const struct gl_texture_image *texImage,
+static void FETCH(signed_i8)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
@@ -1773,7 +1773,7 @@ static void FETCH(signed_i8)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_signed_i8(struct gl_texture_image *texImage,
+static void store_texel_signed_i8(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLbyte *rgba = (const GLbyte *) texel;
@@ -1785,7 +1785,7 @@ static void store_texel_signed_i8(struct gl_texture_image *texImage,
/* MESA_FORMAT_SIGNED_RG88_REV ***********************************************/
-static void FETCH(signed_rg88_rev)( const struct gl_texture_image *texImage,
+static void FETCH(signed_rg88_rev)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLushort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
@@ -1796,7 +1796,7 @@ static void FETCH(signed_rg88_rev)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_signed_rg88_rev(struct gl_texture_image *texImage,
+static void store_texel_signed_rg88_rev(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLbyte *rg = (const GLbyte *) texel;
@@ -1808,7 +1808,7 @@ static void store_texel_signed_rg88_rev(struct gl_texture_image *texImage,
/* MESA_FORMAT_SIGNED_AL88 ***********************************************/
-static void FETCH(signed_al88)( const struct gl_texture_image *texImage,
+static void FETCH(signed_al88)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLushort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
@@ -1819,7 +1819,7 @@ static void FETCH(signed_al88)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_signed_al88(struct gl_texture_image *texImage,
+static void store_texel_signed_al88(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLbyte *rg = (const GLbyte *) texel;
@@ -1831,7 +1831,7 @@ static void store_texel_signed_al88(struct gl_texture_image *texImage,
/* MESA_FORMAT_SIGNED_RGBX8888 ***********************************************/
-static void FETCH(signed_rgbx8888)( const struct gl_texture_image *texImage,
+static void FETCH(signed_rgbx8888)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
@@ -1842,7 +1842,7 @@ static void FETCH(signed_rgbx8888)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_signed_rgbx8888(struct gl_texture_image *texImage,
+static void store_texel_signed_rgbx8888(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLbyte *rgba = (const GLbyte *) texel;
@@ -1854,7 +1854,7 @@ static void store_texel_signed_rgbx8888(struct gl_texture_image *texImage,
/* MESA_FORMAT_SIGNED_RGBA8888 ***********************************************/
-static void FETCH(signed_rgba8888)( const struct gl_texture_image *texImage,
+static void FETCH(signed_rgba8888)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
@@ -1865,7 +1865,7 @@ static void FETCH(signed_rgba8888)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_signed_rgba8888(struct gl_texture_image *texImage,
+static void store_texel_signed_rgba8888(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLbyte *rgba = (const GLbyte *) texel;
@@ -1874,7 +1874,7 @@ static void store_texel_signed_rgba8888(struct gl_texture_image *texImage,
}
#endif
-static void FETCH(signed_rgba8888_rev)( const struct gl_texture_image *texImage,
+static void FETCH(signed_rgba8888_rev)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
@@ -1885,7 +1885,7 @@ static void FETCH(signed_rgba8888_rev)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_signed_rgba8888_rev(struct gl_texture_image *texImage,
+static void store_texel_signed_rgba8888_rev(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
@@ -1899,7 +1899,7 @@ static void store_texel_signed_rgba8888_rev(struct gl_texture_image *texImage,
/* MESA_FORMAT_SIGNED_R16 ***********************************************/
static void
-FETCH(signed_r16)(const struct gl_texture_image *texImage,
+FETCH(signed_r16)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
@@ -1911,7 +1911,7 @@ FETCH(signed_r16)(const struct gl_texture_image *texImage,
#if DIM == 3
static void
-store_texel_signed_r16(struct gl_texture_image *texImage,
+store_texel_signed_r16(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLshort *rgba = (const GLshort *) texel;
@@ -1924,7 +1924,7 @@ store_texel_signed_r16(struct gl_texture_image *texImage,
/* MESA_FORMAT_SIGNED_A16 ***********************************************/
static void
-FETCH(signed_a16)(const struct gl_texture_image *texImage,
+FETCH(signed_a16)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
@@ -1936,7 +1936,7 @@ FETCH(signed_a16)(const struct gl_texture_image *texImage,
#if DIM == 3
static void
-store_texel_signed_a16(struct gl_texture_image *texImage,
+store_texel_signed_a16(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLshort *rgba = (const GLshort *) texel;
@@ -1949,7 +1949,7 @@ store_texel_signed_a16(struct gl_texture_image *texImage,
/* MESA_FORMAT_SIGNED_L16 ***********************************************/
static void
-FETCH(signed_l16)(const struct gl_texture_image *texImage,
+FETCH(signed_l16)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
@@ -1961,7 +1961,7 @@ FETCH(signed_l16)(const struct gl_texture_image *texImage,
#if DIM == 3
static void
-store_texel_signed_l16(struct gl_texture_image *texImage,
+store_texel_signed_l16(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLshort *rgba = (const GLshort *) texel;
@@ -1974,7 +1974,7 @@ store_texel_signed_l16(struct gl_texture_image *texImage,
/* MESA_FORMAT_SIGNED_I16 ***********************************************/
static void
-FETCH(signed_i16)(const struct gl_texture_image *texImage,
+FETCH(signed_i16)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
@@ -1986,7 +1986,7 @@ FETCH(signed_i16)(const struct gl_texture_image *texImage,
#if DIM == 3
static void
-store_texel_signed_i16(struct gl_texture_image *texImage,
+store_texel_signed_i16(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLshort *rgba = (const GLshort *) texel;
@@ -1999,7 +1999,7 @@ store_texel_signed_i16(struct gl_texture_image *texImage,
/* MESA_FORMAT_SIGNED_RG1616 ***********************************************/
static void
-FETCH(signed_rg1616)(const struct gl_texture_image *texImage,
+FETCH(signed_rg1616)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
@@ -2011,7 +2011,7 @@ FETCH(signed_rg1616)(const struct gl_texture_image *texImage,
#if DIM == 3
static void
-store_texel_signed_rg1616(struct gl_texture_image *texImage,
+store_texel_signed_rg1616(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLchan *rgba = (const GLchan *) texel;
@@ -2025,7 +2025,7 @@ store_texel_signed_rg1616(struct gl_texture_image *texImage,
/* MESA_FORMAT_SIGNED_AL1616 ***********************************************/
static void
-FETCH(signed_al1616)(const struct gl_texture_image *texImage,
+FETCH(signed_al1616)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
@@ -2037,7 +2037,7 @@ FETCH(signed_al1616)(const struct gl_texture_image *texImage,
#if DIM == 3
static void
-store_texel_signed_al1616(struct gl_texture_image *texImage,
+store_texel_signed_al1616(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLchan *rgba = (const GLchan *) texel;
@@ -2051,7 +2051,7 @@ store_texel_signed_al1616(struct gl_texture_image *texImage,
/* MESA_FORMAT_SIGNED_RGB_16 ***********************************************/
static void
-FETCH(signed_rgb_16)(const struct gl_texture_image *texImage,
+FETCH(signed_rgb_16)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 3);
@@ -2063,7 +2063,7 @@ FETCH(signed_rgb_16)(const struct gl_texture_image *texImage,
#if DIM == 3
static void
-store_texel_signed_rgb_16(struct gl_texture_image *texImage,
+store_texel_signed_rgb_16(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLchan *rgba = (const GLchan *) texel;
@@ -2078,7 +2078,7 @@ store_texel_signed_rgb_16(struct gl_texture_image *texImage,
/* MESA_FORMAT_SIGNED_RGBA_16 ***********************************************/
static void
-FETCH(signed_rgba_16)(const struct gl_texture_image *texImage,
+FETCH(signed_rgba_16)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
@@ -2090,7 +2090,7 @@ FETCH(signed_rgba_16)(const struct gl_texture_image *texImage,
#if DIM == 3
static void
-store_texel_signed_rgba_16(struct gl_texture_image *texImage,
+store_texel_signed_rgba_16(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLchan *rgba = (const GLchan *) texel;
@@ -2107,7 +2107,7 @@ store_texel_signed_rgba_16(struct gl_texture_image *texImage,
/* MESA_FORMAT_RGBA_16 ***********************************************/
static void
-FETCH(rgba_16)(const struct gl_texture_image *texImage,
+FETCH(rgba_16)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
const GLushort *s = TEXEL_ADDR(GLushort, texImage, i, j, k, 4);
@@ -2119,7 +2119,7 @@ FETCH(rgba_16)(const struct gl_texture_image *texImage,
#if DIM == 3
static void
-store_texel_rgba_16(struct gl_texture_image *texImage,
+store_texel_rgba_16(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLchan *rgba = (const GLchan *) texel;
@@ -2138,7 +2138,7 @@ store_texel_rgba_16(struct gl_texture_image *texImage,
/* Fetch 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,
+static void FETCH(f_ycbcr)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */
@@ -2161,7 +2161,7 @@ static void FETCH(f_ycbcr)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_ycbcr(struct gl_texture_image *texImage,
+static void store_texel_ycbcr(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
(void) texImage;
@@ -2179,7 +2179,7 @@ static void store_texel_ycbcr(struct gl_texture_image *texImage,
/* Fetch texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLfloats.
* We convert YCbCr to RGB here.
*/
-static void FETCH(f_ycbcr_rev)( const struct gl_texture_image *texImage,
+static void FETCH(f_ycbcr_rev)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */
@@ -2202,7 +2202,7 @@ static void FETCH(f_ycbcr_rev)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_ycbcr_rev(struct gl_texture_image *texImage,
+static void store_texel_ycbcr_rev(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
(void) texImage;
@@ -2217,21 +2217,21 @@ static void store_texel_ycbcr_rev(struct gl_texture_image *texImage,
/* MESA_TEXFORMAT_Z24_S8 ***************************************************/
-static void FETCH(f_z24_s8)( const struct gl_texture_image *texImage,
+static void FETCH(f_z24_s8)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
/* only return Z, not stencil data */
const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
const GLfloat scale = 1.0F / (GLfloat) 0xffffff;
texel[0] = ((*src) >> 8) * scale;
- ASSERT(texImage->TexFormat == MESA_FORMAT_Z24_S8 ||
- texImage->TexFormat == MESA_FORMAT_Z24_X8);
+ ASSERT(texImage->Base.TexFormat == MESA_FORMAT_Z24_S8 ||
+ texImage->Base.TexFormat == MESA_FORMAT_Z24_X8);
ASSERT(texel[0] >= 0.0F);
ASSERT(texel[0] <= 1.0F);
}
#if DIM == 3
-static void store_texel_z24_s8(struct gl_texture_image *texImage,
+static void store_texel_z24_s8(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
/* only store Z, not stencil */
@@ -2245,21 +2245,21 @@ static void store_texel_z24_s8(struct gl_texture_image *texImage,
/* MESA_TEXFORMAT_S8_Z24 ***************************************************/
-static void FETCH(f_s8_z24)( const struct gl_texture_image *texImage,
+static void FETCH(f_s8_z24)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
/* only return Z, not stencil data */
const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
const GLfloat scale = 1.0F / (GLfloat) 0xffffff;
texel[0] = ((*src) & 0x00ffffff) * scale;
- ASSERT(texImage->TexFormat == MESA_FORMAT_S8_Z24 ||
- texImage->TexFormat == MESA_FORMAT_X8_Z24);
+ ASSERT(texImage->Base.TexFormat == MESA_FORMAT_S8_Z24 ||
+ texImage->Base.TexFormat == MESA_FORMAT_X8_Z24);
ASSERT(texel[0] >= 0.0F);
ASSERT(texel[0] <= 1.0F);
}
#if DIM == 3
-static void store_texel_s8_z24(struct gl_texture_image *texImage,
+static void store_texel_s8_z24(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
/* only store Z, not stencil */
@@ -2273,7 +2273,7 @@ static void store_texel_s8_z24(struct gl_texture_image *texImage,
/* MESA_FORMAT_RGB9_E5 ******************************************************/
-static void FETCH(rgb9_e5)( const struct gl_texture_image *texImage,
+static void FETCH(rgb9_e5)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
@@ -2282,7 +2282,7 @@ static void FETCH(rgb9_e5)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_rgb9_e5(struct gl_texture_image *texImage,
+static void store_texel_rgb9_e5(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLfloat *src = (const GLfloat *) texel;
@@ -2294,7 +2294,7 @@ static void store_texel_rgb9_e5(struct gl_texture_image *texImage,
/* MESA_FORMAT_R11_G11_B10_FLOAT *********************************************/
-static void FETCH(r11_g11_b10f)( const struct gl_texture_image *texImage,
+static void FETCH(r11_g11_b10f)( const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
@@ -2303,7 +2303,7 @@ static void FETCH(r11_g11_b10f)( const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_r11_g11_b10f(struct gl_texture_image *texImage,
+static void store_texel_r11_g11_b10f(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLfloat *src = (const GLfloat *) texel;
@@ -2315,7 +2315,7 @@ static void store_texel_r11_g11_b10f(struct gl_texture_image *texImage,
/* MESA_FORMAT_Z32_FLOAT_X24S8 ***********************************************/
-static void FETCH(z32f_x24s8)(const struct gl_texture_image *texImage,
+static void FETCH(z32f_x24s8)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
@@ -2326,7 +2326,7 @@ static void FETCH(z32f_x24s8)(const struct gl_texture_image *texImage,
}
#if DIM == 3
-static void store_texel_z32f_x24s8(struct gl_texture_image *texImage,
+static void store_texel_z32f_x24s8(struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLfloat *src = (const GLfloat *) texel;
diff --git a/mesalib/src/mesa/swrast/s_texfilter.c b/mesalib/src/mesa/swrast/s_texfilter.c
index ad31e3778..a7a190ab6 100644
--- a/mesalib/src/mesa/swrast/s_texfilter.c
+++ b/mesalib/src/mesa/swrast/s_texfilter.c
@@ -802,6 +802,7 @@ sample_1d_nearest(struct gl_context *ctx,
const struct gl_texture_image *img,
const GLfloat texcoord[4], GLfloat rgba[4])
{
+ const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
const GLint width = img->Width2; /* without border, power of two */
GLint i;
i = nearest_texel_location(tObj->Sampler.WrapS, img, width, texcoord[0]);
@@ -812,7 +813,7 @@ sample_1d_nearest(struct gl_context *ctx,
get_border_color(tObj, img, rgba);
}
else {
- img->FetchTexelf(img, i, 0, 0, rgba);
+ swImg->FetchTexelf(swImg, i, 0, 0, rgba);
}
}
@@ -826,6 +827,7 @@ sample_1d_linear(struct gl_context *ctx,
const struct gl_texture_image *img,
const GLfloat texcoord[4], GLfloat rgba[4])
{
+ const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
const GLint width = img->Width2;
GLint i0, i1;
GLbitfield useBorderColor = 0x0;
@@ -848,13 +850,13 @@ sample_1d_linear(struct gl_context *ctx,
get_border_color(tObj, img, t0);
}
else {
- img->FetchTexelf(img, i0, 0, 0, t0);
+ swImg->FetchTexelf(swImg, i0, 0, 0, t0);
}
if (useBorderColor & I1BIT) {
get_border_color(tObj, img, t1);
}
else {
- img->FetchTexelf(img, i1, 0, 0, t1);
+ swImg->FetchTexelf(swImg, i1, 0, 0, t1);
}
lerp_rgba(rgba, a, t0, t1);
@@ -1060,6 +1062,7 @@ sample_2d_nearest(struct gl_context *ctx,
const GLfloat texcoord[4],
GLfloat rgba[])
{
+ const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
const GLint width = img->Width2; /* without border, power of two */
const GLint height = img->Height2; /* without border, power of two */
GLint i, j;
@@ -1077,7 +1080,7 @@ sample_2d_nearest(struct gl_context *ctx,
get_border_color(tObj, img, rgba);
}
else {
- img->FetchTexelf(img, i, j, 0, rgba);
+ swImg->FetchTexelf(swImg, i, j, 0, rgba);
}
}
@@ -1093,6 +1096,7 @@ sample_2d_linear(struct gl_context *ctx,
const GLfloat texcoord[4],
GLfloat rgba[])
{
+ const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
const GLint width = img->Width2;
const GLint height = img->Height2;
GLint i0, j0, i1, j1;
@@ -1121,25 +1125,25 @@ sample_2d_linear(struct gl_context *ctx,
get_border_color(tObj, img, t00);
}
else {
- img->FetchTexelf(img, i0, j0, 0, t00);
+ swImg->FetchTexelf(swImg, i0, j0, 0, t00);
}
if (useBorderColor & (I1BIT | J0BIT)) {
get_border_color(tObj, img, t10);
}
else {
- img->FetchTexelf(img, i1, j0, 0, t10);
+ swImg->FetchTexelf(swImg, i1, j0, 0, t10);
}
if (useBorderColor & (I0BIT | J1BIT)) {
get_border_color(tObj, img, t01);
}
else {
- img->FetchTexelf(img, i0, j1, 0, t01);
+ swImg->FetchTexelf(swImg, i0, j1, 0, t01);
}
if (useBorderColor & (I1BIT | J1BIT)) {
get_border_color(tObj, img, t11);
}
else {
- img->FetchTexelf(img, i1, j1, 0, t11);
+ swImg->FetchTexelf(swImg, i1, j1, 0, t11);
}
lerp_rgba_2d(rgba, a, b, t00, t10, t01, t11);
@@ -1157,6 +1161,7 @@ sample_2d_linear_repeat(struct gl_context *ctx,
const GLfloat texcoord[4],
GLfloat rgba[])
{
+ const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
const GLint width = img->Width2;
const GLint height = img->Height2;
GLint i0, j0, i1, j1;
@@ -1173,10 +1178,10 @@ sample_2d_linear_repeat(struct gl_context *ctx,
linear_repeat_texel_location(width, texcoord[0], &i0, &i1, &wi);
linear_repeat_texel_location(height, texcoord[1], &j0, &j1, &wj);
- img->FetchTexelf(img, i0, j0, 0, t00);
- img->FetchTexelf(img, i1, j0, 0, t10);
- img->FetchTexelf(img, i0, j1, 0, t01);
- img->FetchTexelf(img, i1, j1, 0, t11);
+ swImg->FetchTexelf(swImg, i0, j0, 0, t00);
+ swImg->FetchTexelf(swImg, i1, j0, 0, t10);
+ swImg->FetchTexelf(swImg, i0, j1, 0, t01);
+ swImg->FetchTexelf(swImg, i1, j1, 0, t11);
lerp_rgba_2d(rgba, wi, wj, t00, t10, t01, t11);
}
@@ -1934,6 +1939,7 @@ sample_3d_nearest(struct gl_context *ctx,
const GLfloat texcoord[4],
GLfloat rgba[4])
{
+ const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
const GLint width = img->Width2; /* without border, power of two */
const GLint height = img->Height2; /* without border, power of two */
const GLint depth = img->Depth2; /* without border, power of two */
@@ -1951,7 +1957,7 @@ sample_3d_nearest(struct gl_context *ctx,
get_border_color(tObj, img, rgba);
}
else {
- img->FetchTexelf(img, i, j, k, rgba);
+ swImg->FetchTexelf(swImg, i, j, k, rgba);
}
}
@@ -1966,6 +1972,7 @@ sample_3d_linear(struct gl_context *ctx,
const GLfloat texcoord[4],
GLfloat rgba[4])
{
+ const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
const GLint width = img->Width2;
const GLint height = img->Height2;
const GLint depth = img->Depth2;
@@ -2002,50 +2009,50 @@ sample_3d_linear(struct gl_context *ctx,
get_border_color(tObj, img, t000);
}
else {
- img->FetchTexelf(img, i0, j0, k0, t000);
+ swImg->FetchTexelf(swImg, i0, j0, k0, t000);
}
if (useBorderColor & (I1BIT | J0BIT | K0BIT)) {
get_border_color(tObj, img, t100);
}
else {
- img->FetchTexelf(img, i1, j0, k0, t100);
+ swImg->FetchTexelf(swImg, i1, j0, k0, t100);
}
if (useBorderColor & (I0BIT | J1BIT | K0BIT)) {
get_border_color(tObj, img, t010);
}
else {
- img->FetchTexelf(img, i0, j1, k0, t010);
+ swImg->FetchTexelf(swImg, i0, j1, k0, t010);
}
if (useBorderColor & (I1BIT | J1BIT | K0BIT)) {
get_border_color(tObj, img, t110);
}
else {
- img->FetchTexelf(img, i1, j1, k0, t110);
+ swImg->FetchTexelf(swImg, i1, j1, k0, t110);
}
if (useBorderColor & (I0BIT | J0BIT | K1BIT)) {
get_border_color(tObj, img, t001);
}
else {
- img->FetchTexelf(img, i0, j0, k1, t001);
+ swImg->FetchTexelf(swImg, i0, j0, k1, t001);
}
if (useBorderColor & (I1BIT | J0BIT | K1BIT)) {
get_border_color(tObj, img, t101);
}
else {
- img->FetchTexelf(img, i1, j0, k1, t101);
+ swImg->FetchTexelf(swImg, i1, j0, k1, t101);
}
if (useBorderColor & (I0BIT | J1BIT | K1BIT)) {
get_border_color(tObj, img, t011);
}
else {
- img->FetchTexelf(img, i0, j1, k1, t011);
+ swImg->FetchTexelf(swImg, i0, j1, k1, t011);
}
if (useBorderColor & (I1BIT | J1BIT | K1BIT)) {
get_border_color(tObj, img, t111);
}
else {
- img->FetchTexelf(img, i1, j1, k1, t111);
+ swImg->FetchTexelf(swImg, i1, j1, k1, t111);
}
/* trilinear interpolation of samples */
@@ -2544,6 +2551,7 @@ sample_nearest_rect(struct gl_context *ctx,
GLfloat rgba[][4])
{
const struct gl_texture_image *img = tObj->Image[0][0];
+ const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
const GLint width = img->Width;
const GLint height = img->Height;
GLuint i;
@@ -2565,7 +2573,7 @@ sample_nearest_rect(struct gl_context *ctx,
if (col < 0 || col >= width || row < 0 || row >= height)
get_border_color(tObj, img, rgba[i]);
else
- img->FetchTexelf(img, col, row, 0, rgba[i]);
+ swImg->FetchTexelf(swImg, col, row, 0, rgba[i]);
}
}
@@ -2577,6 +2585,7 @@ sample_linear_rect(struct gl_context *ctx,
const GLfloat lambda[], GLfloat rgba[][4])
{
const struct gl_texture_image *img = tObj->Image[0][0];
+ const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
const GLint width = img->Width;
const GLint height = img->Height;
GLuint i;
@@ -2612,22 +2621,22 @@ sample_linear_rect(struct gl_context *ctx,
if (useBorderColor & (I0BIT | J0BIT))
get_border_color(tObj, img, t00);
else
- img->FetchTexelf(img, i0, j0, 0, t00);
+ swImg->FetchTexelf(swImg, i0, j0, 0, t00);
if (useBorderColor & (I1BIT | J0BIT))
get_border_color(tObj, img, t10);
else
- img->FetchTexelf(img, i1, j0, 0, t10);
+ swImg->FetchTexelf(swImg, i1, j0, 0, t10);
if (useBorderColor & (I0BIT | J1BIT))
get_border_color(tObj, img, t01);
else
- img->FetchTexelf(img, i0, j1, 0, t01);
+ swImg->FetchTexelf(swImg, i0, j1, 0, t01);
if (useBorderColor & (I1BIT | J1BIT))
get_border_color(tObj, img, t11);
else
- img->FetchTexelf(img, i1, j1, 0, t11);
+ swImg->FetchTexelf(swImg, i1, j1, 0, t11);
lerp_rgba_2d(rgba[i], a, b, t00, t10, t01, t11);
}
@@ -2686,6 +2695,7 @@ sample_2d_array_nearest(struct gl_context *ctx,
const GLfloat texcoord[4],
GLfloat rgba[4])
{
+ const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
const GLint width = img->Width2; /* without border, power of two */
const GLint height = img->Height2; /* without border, power of two */
const GLint depth = img->Depth;
@@ -2704,7 +2714,7 @@ sample_2d_array_nearest(struct gl_context *ctx,
get_border_color(tObj, img, rgba);
}
else {
- img->FetchTexelf(img, i, j, array, rgba);
+ swImg->FetchTexelf(swImg, i, j, array, rgba);
}
}
@@ -2719,6 +2729,7 @@ sample_2d_array_linear(struct gl_context *ctx,
const GLfloat texcoord[4],
GLfloat rgba[4])
{
+ const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
const GLint width = img->Width2;
const GLint height = img->Height2;
const GLint depth = img->Depth;
@@ -2755,25 +2766,25 @@ sample_2d_array_linear(struct gl_context *ctx,
get_border_color(tObj, img, t00);
}
else {
- img->FetchTexelf(img, i0, j0, array, t00);
+ swImg->FetchTexelf(swImg, i0, j0, array, t00);
}
if (useBorderColor & (I1BIT | J0BIT)) {
get_border_color(tObj, img, t10);
}
else {
- img->FetchTexelf(img, i1, j0, array, t10);
+ swImg->FetchTexelf(swImg, i1, j0, array, t10);
}
if (useBorderColor & (I0BIT | J1BIT)) {
get_border_color(tObj, img, t01);
}
else {
- img->FetchTexelf(img, i0, j1, array, t01);
+ swImg->FetchTexelf(swImg, i0, j1, array, t01);
}
if (useBorderColor & (I1BIT | J1BIT)) {
get_border_color(tObj, img, t11);
}
else {
- img->FetchTexelf(img, i1, j1, array, t11);
+ swImg->FetchTexelf(swImg, i1, j1, array, t11);
}
/* trilinear interpolation of samples */
@@ -2996,6 +3007,7 @@ sample_1d_array_nearest(struct gl_context *ctx,
const GLfloat texcoord[4],
GLfloat rgba[4])
{
+ const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
const GLint width = img->Width2; /* without border, power of two */
const GLint height = img->Height;
GLint i;
@@ -3011,7 +3023,7 @@ sample_1d_array_nearest(struct gl_context *ctx,
get_border_color(tObj, img, rgba);
}
else {
- img->FetchTexelf(img, i, array, 0, rgba);
+ swImg->FetchTexelf(swImg, i, array, 0, rgba);
}
}
@@ -3026,6 +3038,7 @@ sample_1d_array_linear(struct gl_context *ctx,
const GLfloat texcoord[4],
GLfloat rgba[4])
{
+ const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
const GLint width = img->Width2;
const GLint height = img->Height;
GLint i0, i1;
@@ -3054,13 +3067,13 @@ sample_1d_array_linear(struct gl_context *ctx,
get_border_color(tObj, img, t0);
}
else {
- img->FetchTexelf(img, i0, array, 0, t0);
+ swImg->FetchTexelf(swImg, i0, array, 0, t0);
}
if (useBorderColor & (I1BIT | K0BIT)) {
get_border_color(tObj, img, t1);
}
else {
- img->FetchTexelf(img, i1, array, 0, t1);
+ swImg->FetchTexelf(swImg, i1, array, 0, t1);
}
/* bilinear interpolation of samples */
@@ -3388,6 +3401,7 @@ sample_depth_texture( struct gl_context *ctx,
{
const GLint level = choose_depth_texture_level(tObj, lambda[0]);
const struct gl_texture_image *img = tObj->Image[0][level];
+ const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
const GLint width = img->Width;
const GLint height = img->Height;
const GLint depth = img->Depth;
@@ -3423,7 +3437,7 @@ sample_depth_texture( struct gl_context *ctx,
if (col >= 0 && row >= 0 && col < width && row < height &&
slice >= 0 && slice < depth) {
- img->FetchTexelf(img, col, row, slice, &depthSample);
+ swImg->FetchTexelf(swImg, col, row, slice, &depthSample);
}
else {
depthSample = tObj->Sampler.BorderColor.f[0];
@@ -3492,13 +3506,13 @@ sample_depth_texture( struct gl_context *ctx,
depth00 = tObj->Sampler.BorderColor.f[0];
}
else {
- img->FetchTexelf(img, i0, j0, slice, &depth00);
+ swImg->FetchTexelf(swImg, i0, j0, slice, &depth00);
}
if (useBorderTexel & (I1BIT | J0BIT)) {
depth10 = tObj->Sampler.BorderColor.f[0];
}
else {
- img->FetchTexelf(img, i1, j0, slice, &depth10);
+ swImg->FetchTexelf(swImg, i1, j0, slice, &depth10);
}
if (tObj->Target != GL_TEXTURE_1D_ARRAY_EXT) {
@@ -3506,13 +3520,13 @@ sample_depth_texture( struct gl_context *ctx,
depth01 = tObj->Sampler.BorderColor.f[0];
}
else {
- img->FetchTexelf(img, i0, j1, slice, &depth01);
+ swImg->FetchTexelf(swImg, i0, j1, slice, &depth01);
}
if (useBorderTexel & (I1BIT | J1BIT)) {
depth11 = tObj->Sampler.BorderColor.f[0];
}
else {
- img->FetchTexelf(img, i1, j1, slice, &depth11);
+ swImg->FetchTexelf(swImg, i1, j1, slice, &depth11);
}
}
else {
diff --git a/mesalib/src/mesa/swrast/s_texrender.c b/mesalib/src/mesa/swrast/s_texrender.c
index 52d03c92a..643952875 100644
--- a/mesalib/src/mesa/swrast/s_texrender.c
+++ b/mesalib/src/mesa/swrast/s_texrender.c
@@ -3,10 +3,11 @@
#include "main/colormac.h"
#include "main/fbobject.h"
#include "main/macros.h"
-#include "main/texfetch.h"
#include "main/teximage.h"
#include "main/renderbuffer.h"
#include "swrast/swrast.h"
+#include "swrast/s_context.h"
+#include "swrast/s_texfetch.h"
/*
@@ -20,7 +21,7 @@
struct texture_renderbuffer
{
struct gl_renderbuffer Base; /**< Base class object */
- struct gl_texture_image *TexImage;
+ struct swrast_texture_image *TexImage;
StoreTexelFunc Store;
FetchTexelFuncF Fetchf;
GLint Yoffset; /**< Layer for 1D array textures. */
@@ -42,8 +43,8 @@ texture_get_row(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count
const GLint z = trb->Zoffset;
GLuint i;
- ASSERT(trb->TexImage->Width == rb->Width);
- ASSERT(trb->TexImage->Height == rb->Height);
+ ASSERT(trb->TexImage->Base.Width == rb->Width);
+ ASSERT(trb->TexImage->Base.Height == rb->Height);
y += trb->Yoffset;
@@ -468,7 +469,7 @@ texture_put_mono_values(struct gl_context *ctx, struct gl_renderbuffer *rb,
static void
-store_nop(struct gl_texture_image *texImage,
+store_nop(struct swrast_texture_image *texImage,
GLint col, GLint row, GLint img,
const void *texel)
{
@@ -534,16 +535,20 @@ update_wrapper(struct gl_context *ctx, struct gl_renderbuffer_attachment *att)
(void) ctx;
ASSERT(trb);
- trb->TexImage = _mesa_get_attachment_teximage(att);
+ trb->TexImage = swrast_texture_image(_mesa_get_attachment_teximage(att));
ASSERT(trb->TexImage);
- trb->Store = _mesa_get_texel_store_func(trb->TexImage->TexFormat);
+ trb->Store = _mesa_get_texel_store_func(trb->TexImage->Base.TexFormat);
if (!trb->Store) {
/* we'll never draw into some textures (compressed formats) */
trb->Store = store_nop;
}
+ if (!trb->TexImage->FetchTexelf) {
+ _mesa_update_fetch_functions(trb->TexImage->Base.TexObject);
+ }
trb->Fetchf = trb->TexImage->FetchTexelf;
+ assert(trb->Fetchf);
if (att->Texture->Target == GL_TEXTURE_1D_ARRAY_EXT) {
trb->Yoffset = att->Zoffset;
@@ -554,13 +559,13 @@ update_wrapper(struct gl_context *ctx, struct gl_renderbuffer_attachment *att)
trb->Zoffset = att->Zoffset;
}
- trb->Base.Width = trb->TexImage->Width;
- trb->Base.Height = trb->TexImage->Height;
- trb->Base.InternalFormat = trb->TexImage->InternalFormat;
- trb->Base.Format = trb->TexImage->TexFormat;
+ trb->Base.Width = trb->TexImage->Base.Width;
+ trb->Base.Height = trb->TexImage->Base.Height;
+ trb->Base.InternalFormat = trb->TexImage->Base.InternalFormat;
+ trb->Base.Format = trb->TexImage->Base.TexFormat;
/* XXX may need more special cases here */
- switch (trb->TexImage->TexFormat) {
+ switch (trb->TexImage->Base.TexFormat) {
case MESA_FORMAT_Z24_S8:
trb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
trb->Base._BaseFormat = GL_DEPTH_STENCIL;
@@ -605,7 +610,7 @@ update_wrapper(struct gl_context *ctx, struct gl_renderbuffer_attachment *att)
trb->Base.DataType = CHAN_TYPE;
trb->Base._BaseFormat = GL_RGBA;
}
- trb->Base.Data = trb->TexImage->Data;
+ trb->Base.Data = trb->TexImage->Base.Data;
}
diff --git a/mesalib/src/mesa/swrast/s_texture.c b/mesalib/src/mesa/swrast/s_texture.c
index 6cc72c582..7e3fc2806 100644
--- a/mesalib/src/mesa/swrast/s_texture.c
+++ b/mesalib/src/mesa/swrast/s_texture.c
@@ -28,9 +28,74 @@
#include "main/context.h"
#include "main/fbobject.h"
+#include "main/teximage.h"
#include "swrast/swrast.h"
#include "swrast/s_context.h"
+
+/**
+ * Allocate a new swrast_texture_image (a subclass of gl_texture_image).
+ * Called via ctx->Driver.NewTextureImage().
+ */
+struct gl_texture_image *
+_swrast_new_texture_image( struct gl_context *ctx )
+{
+ (void) ctx;
+ return (struct gl_texture_image *) CALLOC_STRUCT(swrast_texture_image);
+}
+
+
+/**
+ * Free a swrast_texture_image (a subclass of gl_texture_image).
+ * Called via ctx->Driver.DeleteTextureImage().
+ */
+void
+_swrast_delete_texture_image(struct gl_context *ctx,
+ struct gl_texture_image *texImage)
+{
+ /* Nothing special for the subclass yet */
+ _mesa_delete_texture_image(ctx, texImage);
+}
+
+
+/**
+ * Called via ctx->Driver.AllocTextureImageBuffer()
+ */
+GLboolean
+_swrast_alloc_texture_image_buffer(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ gl_format format, GLsizei width,
+ GLsizei height, GLsizei depth)
+{
+ GLuint bytes = _mesa_format_image_size(format, width, height, depth);
+
+ /* This _should_ be true (revisit if these ever fail) */
+ assert(texImage->Width == width);
+ assert(texImage->Height == height);
+ assert(texImage->Depth == depth);
+
+ assert(!texImage->Data);
+ texImage->Data = _mesa_align_malloc(bytes, 512);
+
+ return texImage->Data != NULL;
+}
+
+
+/**
+ * Called via ctx->Driver.FreeTextureImageBuffer()
+ */
+void
+_swrast_free_texture_image_buffer(struct gl_context *ctx,
+ struct gl_texture_image *texImage)
+{
+ if (texImage->Data && !texImage->IsClientData) {
+ _mesa_align_free(texImage->Data);
+ }
+
+ texImage->Data = NULL;
+}
+
+
/**
* Error checking for debugging only.
*/
diff --git a/mesalib/src/mesa/swrast/swrast.h b/mesalib/src/mesa/swrast/swrast.h
index c8b998635..390b42264 100644
--- a/mesalib/src/mesa/swrast/swrast.h
+++ b/mesalib/src/mesa/swrast/swrast.h
@@ -182,6 +182,23 @@ _swrast_render_start( struct gl_context *ctx );
extern void
_swrast_render_finish( struct gl_context *ctx );
+extern struct gl_texture_image *
+_swrast_new_texture_image( struct gl_context *ctx );
+
+extern void
+_swrast_delete_texture_image(struct gl_context *ctx,
+ struct gl_texture_image *texImage);
+
+extern GLboolean
+_swrast_alloc_texture_image_buffer(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ gl_format format, GLsizei width,
+ GLsizei height, GLsizei depth);
+
+extern void
+_swrast_free_texture_image_buffer(struct gl_context *ctx,
+ struct gl_texture_image *texImage);
+
extern void
_swrast_map_teximage(struct gl_context *ctx,
struct gl_texture_image *texImage,