aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-12-17 12:16:30 +0100
committermarha <marha@users.sourceforge.net>2012-12-17 12:16:30 +0100
commitb3f7d4f6ce0d42d826f384223144936ba6797a10 (patch)
tree2f329beffff890b402625bff8547e243071c47bd /mesalib/src/mesa/main
parentc648afe73ef43a15094508d2dd439e05738735bf (diff)
parent840c8745518b92303d40f6834e9c616587242231 (diff)
downloadvcxsrv-b3f7d4f6ce0d42d826f384223144936ba6797a10.tar.gz
vcxsrv-b3f7d4f6ce0d42d826f384223144936ba6797a10.tar.bz2
vcxsrv-b3f7d4f6ce0d42d826f384223144936ba6797a10.zip
Merge remote-tracking branch 'origin/released'
* origin/released: libXft pixman mesa git update 17 dec 2012 Conflicts: mesalib/src/mesa/drivers/dri/swrast/swrast.c
Diffstat (limited to 'mesalib/src/mesa/main')
-rw-r--r--mesalib/src/mesa/main/api_exec.h4
-rw-r--r--mesalib/src/mesa/main/bufferobj.c4
-rw-r--r--mesalib/src/mesa/main/context.c7
-rw-r--r--mesalib/src/mesa/main/extensions.c3
-rw-r--r--mesalib/src/mesa/main/get.c9
-rw-r--r--mesalib/src/mesa/main/glformats.c42
-rw-r--r--mesalib/src/mesa/main/glformats.h3
-rw-r--r--mesalib/src/mesa/main/mtypes.h12
-rw-r--r--mesalib/src/mesa/main/texcompress.c139
-rw-r--r--mesalib/src/mesa/main/texcompress.h12
-rw-r--r--mesalib/src/mesa/main/texcompress_etc.c356
-rw-r--r--mesalib/src/mesa/main/texcompress_etc.h50
-rw-r--r--mesalib/src/mesa/main/texcompress_fxt1.c74
-rw-r--r--mesalib/src/mesa/main/texcompress_fxt1.h9
-rw-r--r--mesalib/src/mesa/main/texcompress_rgtc.c243
-rw-r--r--mesalib/src/mesa/main/texcompress_rgtc.h33
-rw-r--r--mesalib/src/mesa/main/texcompress_s3tc.c207
-rw-r--r--mesalib/src/mesa/main/texcompress_s3tc.h35
-rw-r--r--mesalib/src/mesa/main/teximage.c28
-rw-r--r--mesalib/src/mesa/main/texobj.c6
-rw-r--r--mesalib/src/mesa/main/texparam.c2
-rw-r--r--mesalib/src/mesa/main/uniform_query.cpp6
-rw-r--r--mesalib/src/mesa/main/uniforms.c8
-rw-r--r--mesalib/src/mesa/main/varray.c3
-rw-r--r--mesalib/src/mesa/main/version.c6
-rw-r--r--mesalib/src/mesa/main/vtxfmt.c20
-rw-r--r--mesalib/src/mesa/main/vtxfmt.h1
27 files changed, 644 insertions, 678 deletions
diff --git a/mesalib/src/mesa/main/api_exec.h b/mesalib/src/mesa/main/api_exec.h
index 7d37ff754..8292c12de 100644
--- a/mesalib/src/mesa/main/api_exec.h
+++ b/mesalib/src/mesa/main/api_exec.h
@@ -33,8 +33,8 @@ struct gl_context;
extern struct _glapi_table *
_mesa_alloc_dispatch_table(int size);
-extern struct _glapi_table *
-_mesa_create_exec_table(struct gl_context *ctx);
+extern void
+_mesa_initialize_exec_table(struct gl_context *ctx);
#endif
diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c
index ce873ecd7..107711560 100644
--- a/mesalib/src/mesa/main/bufferobj.c
+++ b/mesalib/src/mesa/main/bufferobj.c
@@ -93,8 +93,8 @@ get_buffer_target(struct gl_context *ctx, GLenum target)
}
break;
case GL_TEXTURE_BUFFER:
- if (_mesa_is_desktop_gl(ctx)
- && ctx->Extensions.ARB_texture_buffer_object) {
+ if (ctx->API == API_OPENGL_CORE &&
+ ctx->Extensions.ARB_texture_buffer_object) {
return &ctx->Texture.BufferObject;
}
break;
diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c
index fa552e818..fc2db1271 100644
--- a/mesalib/src/mesa/main/context.c
+++ b/mesalib/src/mesa/main/context.c
@@ -935,8 +935,8 @@ _mesa_initialize_context(struct gl_context *ctx,
return GL_FALSE;
}
- /* setup the API dispatch tables */
- ctx->Exec = _mesa_create_exec_table(ctx);
+ /* setup the API dispatch tables with all nop functions */
+ ctx->Exec = _mesa_alloc_dispatch_table(_gloffset_COUNT);
if (!ctx->Exec) {
_mesa_reference_shared_state(ctx, &ctx->Shared, NULL);
@@ -971,7 +971,6 @@ _mesa_initialize_context(struct gl_context *ctx,
return GL_FALSE;
}
- _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt );
/* fall-through */
case API_OPENGL_CORE:
break;
@@ -1462,7 +1461,7 @@ _mesa_make_current( struct gl_context *newCtx,
}
if (newCtx->FirstTimeCurrent) {
- _mesa_compute_version(newCtx);
+ assert(newCtx->Version > 0);
newCtx->Extensions.String = _mesa_make_extension_string(newCtx);
diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c
index 11cbea2b4..98711b395 100644
--- a/mesalib/src/mesa/main/extensions.c
+++ b/mesalib/src/mesa/main/extensions.c
@@ -126,7 +126,8 @@ static const struct extension extension_table[] = {
{ "GL_ARB_shadow", o(ARB_shadow), GLL, 2001 },
{ "GL_ARB_sync", o(ARB_sync), GL, 2003 },
{ "GL_ARB_texture_border_clamp", o(ARB_texture_border_clamp), GLL, 2000 },
- { "GL_ARB_texture_buffer_object", o(ARB_texture_buffer_object), GL, 2008 },
+ { "GL_ARB_texture_buffer_object", o(ARB_texture_buffer_object), GLC, 2008 },
+ { "GL_ARB_texture_buffer_object_rgb32", o(ARB_texture_buffer_object_rgb32), GLC, 2009 },
{ "GL_ARB_texture_compression", o(dummy_true), GLL, 2000 },
{ "GL_ARB_texture_compression_rgtc", o(ARB_texture_compression_rgtc), GL, 2004 },
{ "GL_ARB_texture_cube_map", o(ARB_texture_cube_map), GLL, 1999 },
diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c
index 97dccd0ed..f3dbda2d3 100644
--- a/mesalib/src/mesa/main/get.c
+++ b/mesalib/src/mesa/main/get.c
@@ -129,6 +129,7 @@ enum value_extra {
EXTRA_VERSION_31,
EXTRA_VERSION_32,
EXTRA_API_GL,
+ EXTRA_API_GL_CORE,
EXTRA_API_ES2,
EXTRA_NEW_BUFFERS,
EXTRA_NEW_FRAG_CLAMP,
@@ -283,6 +284,7 @@ static const int extra_GLSL_130[] = {
};
static const int extra_texture_buffer_object[] = {
+ EXTRA_API_GL_CORE,
EXTRA_VERSION_31,
EXT(ARB_texture_buffer_object),
EXTRA_END
@@ -329,7 +331,6 @@ EXTRA_EXT2(ARB_vertex_program, ARB_fragment_program);
EXTRA_EXT(ARB_geometry_shader4);
EXTRA_EXT(ARB_color_buffer_float);
EXTRA_EXT(EXT_framebuffer_sRGB);
-EXTRA_EXT(ARB_texture_buffer_object);
EXTRA_EXT(OES_EGL_image_external);
EXTRA_EXT(ARB_blend_func_extended);
EXTRA_EXT(ARB_uniform_buffer_object);
@@ -879,6 +880,12 @@ check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d
enabled++;
}
break;
+ case EXTRA_API_GL_CORE:
+ if (ctx->API == API_OPENGL_CORE) {
+ total++;
+ enabled++;
+ }
+ break;
case EXTRA_NEW_BUFFERS:
if (ctx->NewState & _NEW_BUFFERS)
_mesa_update_state(ctx);
diff --git a/mesalib/src/mesa/main/glformats.c b/mesalib/src/mesa/main/glformats.c
index fefa9c441..f33a0503d 100644
--- a/mesalib/src/mesa/main/glformats.c
+++ b/mesalib/src/mesa/main/glformats.c
@@ -308,6 +308,48 @@ _mesa_bytes_per_pixel(GLenum format, GLenum type)
/**
+ * Get the number of bytes for a vertex attrib with the given number of
+ * components and type.
+ *
+ * \param comps number of components.
+ * \param type data type.
+ *
+ * \return bytes per attribute, or -1 if a bad comps/type combination was given.
+ */
+GLint
+_mesa_bytes_per_vertex_attrib(GLint comps, GLenum type)
+{
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ return comps * sizeof(GLubyte);
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ return comps * sizeof(GLshort);
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ return comps * sizeof(GLint);
+ case GL_FLOAT:
+ return comps * sizeof(GLfloat);
+ case GL_HALF_FLOAT_ARB:
+ return comps * sizeof(GLhalfARB);
+ case GL_DOUBLE:
+ return comps * sizeof(GLdouble);
+ case GL_FIXED:
+ return comps * sizeof(GLfixed);
+ case GL_INT_2_10_10_10_REV:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ if (comps == 4)
+ return sizeof(GLuint);
+ else
+ return -1;
+ default:
+ return -1;
+ }
+}
+
+
+/**
* Test if the given format is an integer (non-normalized) format.
*/
GLboolean
diff --git a/mesalib/src/mesa/main/glformats.h b/mesalib/src/mesa/main/glformats.h
index 5d0995140..ccfb5e13c 100644
--- a/mesalib/src/mesa/main/glformats.h
+++ b/mesalib/src/mesa/main/glformats.h
@@ -49,6 +49,9 @@ _mesa_components_in_format( GLenum format );
extern GLint
_mesa_bytes_per_pixel( GLenum format, GLenum type );
+extern GLint
+_mesa_bytes_per_vertex_attrib(GLint comps, GLenum type);
+
extern GLboolean
_mesa_is_type_integer(GLenum type);
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index 11a832281..67eaadd9f 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -2928,6 +2928,17 @@ struct gl_constants
/** GL_ARB_map_buffer_alignment */
GLuint MinMapBufferAlignment;
+
+ /**
+ * Disable varying packing. This is out of spec, but potentially useful
+ * for older platforms that supports a limited number of texture
+ * indirections--on these platforms, unpacking the varyings in the fragment
+ * shader increases the number of texture indirections by 1, which might
+ * make some shaders not executable at all.
+ *
+ * Drivers that support transform feedback must set this value to GL_FALSE.
+ */
+ GLboolean DisableVaryingPacking;
};
@@ -2978,6 +2989,7 @@ struct gl_extensions
GLboolean ARB_sync;
GLboolean ARB_texture_border_clamp;
GLboolean ARB_texture_buffer_object;
+ GLboolean ARB_texture_buffer_object_rgb32;
GLboolean ARB_texture_compression_rgtc;
GLboolean ARB_texture_cube_map;
GLboolean ARB_texture_cube_map_array;
diff --git a/mesalib/src/mesa/main/texcompress.c b/mesalib/src/mesa/main/texcompress.c
index 372a483fa..33c580a88 100644
--- a/mesalib/src/mesa/main/texcompress.c
+++ b/mesalib/src/mesa/main/texcompress.c
@@ -42,7 +42,6 @@
#include "texcompress_rgtc.h"
#include "texcompress_s3tc.h"
#include "texcompress_etc.h"
-#include "swrast/s_context.h"
/**
@@ -523,129 +522,67 @@ _mesa_compressed_image_address(GLint col, GLint row, GLint img,
/**
- * Decompress a compressed texture image, returning a GL_RGBA/GL_FLOAT image.
- * \param srcRowStride stride in bytes between rows of blocks in the
- * compressed source image.
+ * Return a texel-fetch function for the given format, or NULL if
+ * invalid format.
*/
-void
-_mesa_decompress_image(gl_format format, GLuint width, GLuint height,
- const GLubyte *src, GLint srcRowStride,
- GLfloat *dest)
+compressed_fetch_func
+_mesa_get_compressed_fetch_func(gl_format format)
{
- void (*fetch)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
- struct swrast_texture_image texImage; /* dummy teximage */
- GLuint i, j;
- GLuint bytes, bw, bh;
-
- bytes = _mesa_get_format_bytes(format);
- _mesa_get_format_block_size(format, &bw, &bh);
-
- /* setup dummy texture image info */
- memset(&texImage, 0, sizeof(texImage));
- texImage.Map = (void *) src;
-
- /* XXX This line is a bit of a hack to adapt to the row stride
- * convention used by the texture decompression functions.
- */
- texImage.RowStride = srcRowStride * bh / bytes;
-
switch (format) {
- /* DXT formats */
case MESA_FORMAT_RGB_DXT1:
- fetch = _mesa_fetch_texel_rgb_dxt1;
- break;
case MESA_FORMAT_RGBA_DXT1:
- fetch = _mesa_fetch_texel_rgba_dxt1;
- break;
case MESA_FORMAT_RGBA_DXT3:
- fetch = _mesa_fetch_texel_rgba_dxt3;
- break;
case MESA_FORMAT_RGBA_DXT5:
- fetch = _mesa_fetch_texel_rgba_dxt5;
- break;
-
- /* FXT1 formats */
+ return _mesa_get_dxt_fetch_func(format);
case MESA_FORMAT_RGB_FXT1:
- fetch = _mesa_fetch_texel_2d_f_rgb_fxt1;
- break;
case MESA_FORMAT_RGBA_FXT1:
- fetch = _mesa_fetch_texel_2d_f_rgba_fxt1;
- break;
-
- /* Red/RG formats */
+ return _mesa_get_fxt_fetch_func(format);
case MESA_FORMAT_RED_RGTC1:
- fetch = _mesa_fetch_texel_red_rgtc1;
- break;
- case MESA_FORMAT_SIGNED_RED_RGTC1:
- fetch = _mesa_fetch_texel_signed_red_rgtc1;
- break;
- case MESA_FORMAT_RG_RGTC2:
- fetch = _mesa_fetch_texel_rg_rgtc2;
- break;
- case MESA_FORMAT_SIGNED_RG_RGTC2:
- fetch = _mesa_fetch_texel_signed_rg_rgtc2;
- break;
-
- /* L/LA formats */
case MESA_FORMAT_L_LATC1:
- fetch = _mesa_fetch_texel_l_latc1;
- break;
+ case MESA_FORMAT_SIGNED_RED_RGTC1:
case MESA_FORMAT_SIGNED_L_LATC1:
- fetch = _mesa_fetch_texel_signed_l_latc1;
- break;
+ case MESA_FORMAT_RG_RGTC2:
case MESA_FORMAT_LA_LATC2:
- fetch = _mesa_fetch_texel_la_latc2;
- break;
+ case MESA_FORMAT_SIGNED_RG_RGTC2:
case MESA_FORMAT_SIGNED_LA_LATC2:
- fetch = _mesa_fetch_texel_signed_la_latc2;
- break;
-
- /* ETC1 formats */
+ return _mesa_get_compressed_rgtc_func(format);
case MESA_FORMAT_ETC1_RGB8:
- fetch = _mesa_fetch_texel_2d_f_etc1_rgb8;
- break;
+ return _mesa_get_etc_fetch_func(format);
+ default:
+ return NULL;
+ }
+}
- /* ETC2 formats */
- case MESA_FORMAT_ETC2_RGB8:
- fetch = _mesa_fetch_texel_2d_f_etc2_rgb8;
- break;
- case MESA_FORMAT_ETC2_SRGB8:
- fetch = _mesa_fetch_texel_2d_f_etc2_srgb8;
- break;
- case MESA_FORMAT_ETC2_RGBA8_EAC:
- fetch = _mesa_fetch_texel_2d_f_etc2_rgba8_eac;
- break;
- case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC:
- fetch = _mesa_fetch_texel_2d_f_etc2_srgb8_alpha8_eac;
- break;
- case MESA_FORMAT_ETC2_R11_EAC:
- fetch = _mesa_fetch_texel_2d_f_etc2_r11_eac;
- break;
- case MESA_FORMAT_ETC2_RG11_EAC:
- fetch = _mesa_fetch_texel_2d_f_etc2_rg11_eac;
- break;
- case MESA_FORMAT_ETC2_SIGNED_R11_EAC:
- fetch = _mesa_fetch_texel_2d_f_etc2_signed_r11_eac;
- break;
- case MESA_FORMAT_ETC2_SIGNED_RG11_EAC:
- fetch = _mesa_fetch_texel_2d_f_etc2_signed_rg11_eac;
- break;
- case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1:
- fetch = _mesa_fetch_texel_2d_f_etc2_rgb8_punchthrough_alpha1;
- break;
- case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:
- fetch = _mesa_fetch_texel_2d_f_etc2_srgb8_punchthrough_alpha1;
- break;
- default:
+/**
+ * Decompress a compressed texture image, returning a GL_RGBA/GL_FLOAT image.
+ * \param srcRowStride stride in bytes between rows of blocks in the
+ * compressed source image.
+ */
+void
+_mesa_decompress_image(gl_format format, GLuint width, GLuint height,
+ const GLubyte *src, GLint srcRowStride,
+ GLfloat *dest)
+{
+ compressed_fetch_func fetch;
+ GLuint i, j;
+ GLuint bytes, bw, bh;
+ GLint stride;
+
+ bytes = _mesa_get_format_bytes(format);
+ _mesa_get_format_block_size(format, &bw, &bh);
+
+ fetch = _mesa_get_compressed_fetch_func(format);
+ if (!fetch) {
_mesa_problem(NULL, "Unexpected format in _mesa_decompress_image()");
return;
}
+
+ stride = srcRowStride * bh / bytes;
for (j = 0; j < height; j++) {
for (i = 0; i < width; i++) {
- fetch(&texImage, i, j, 0, dest);
+ fetch(src, NULL, stride, i, j, 0, dest);
dest += 4;
}
}
diff --git a/mesalib/src/mesa/main/texcompress.h b/mesalib/src/mesa/main/texcompress.h
index 359b9168a..b45e7cf1b 100644
--- a/mesalib/src/mesa/main/texcompress.h
+++ b/mesalib/src/mesa/main/texcompress.h
@@ -48,6 +48,18 @@ _mesa_compressed_image_address(GLint col, GLint row, GLint img,
gl_format mesaFormat,
GLsizei width, const GLubyte *image);
+
+/** A function to fetch one texel from a compressed texture */
+typedef void (*compressed_fetch_func)(const GLubyte *map,
+ const GLuint imageOffsets[],
+ GLint rowStride,
+ GLint i, GLint j, GLint k,
+ GLfloat *texel);
+
+extern compressed_fetch_func
+_mesa_get_compressed_fetch_func(gl_format format);
+
+
extern void
_mesa_decompress_image(gl_format format, GLuint width, GLuint height,
const GLubyte *src, GLint srcRowStride,
diff --git a/mesalib/src/mesa/main/texcompress_etc.c b/mesalib/src/mesa/main/texcompress_etc.c
index 73d2fa4fe..7ad4ddeb6 100644
--- a/mesalib/src/mesa/main/texcompress_etc.c
+++ b/mesalib/src/mesa/main/texcompress_etc.c
@@ -43,9 +43,9 @@
#include "texcompress_etc.h"
#include "texstore.h"
#include "macros.h"
-#include "swrast/s_context.h"
#include "format_unpack.h"
+
struct etc2_block {
int distance;
uint64_t pixel_indices[2];
@@ -113,25 +113,6 @@ _mesa_texstore_etc1_rgb8(TEXSTORE_PARAMS)
return GL_FALSE;
}
-void
-_mesa_fetch_texel_2d_f_etc1_rgb8(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- struct etc1_block block;
- GLubyte dst[3];
- const GLubyte *src;
-
- src = (const GLubyte *) texImage->Map +
- (((texImage->RowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
-
- etc1_parse_block(&block, src);
- etc1_fetch_texel(&block, i % 4, j % 4, dst);
-
- texel[RCOMP] = UBYTE_TO_FLOAT(dst[0]);
- texel[GCOMP] = UBYTE_TO_FLOAT(dst[1]);
- texel[BCOMP] = UBYTE_TO_FLOAT(dst[2]);
- texel[ACOMP] = 1.0f;
-}
/**
* Decode texture data in format `MESA_FORMAT_ETC1_RGB8` to
@@ -231,7 +212,7 @@ etc2_base_color1_h_mode(const uint8_t *in, GLuint index)
break;
}
return ((x << 4) | (x & 0xf));
- }
+}
static uint8_t
etc2_base_color2_h_mode(const uint8_t *in, GLuint index)
@@ -253,7 +234,7 @@ etc2_base_color2_h_mode(const uint8_t *in, GLuint index)
break;
}
return ((x << 4) | (x & 0xf));
- }
+}
static uint8_t
etc2_base_color_o_planar(const uint8_t *in, GLuint index)
@@ -468,7 +449,7 @@ etc2_rgb8_parse_block(struct etc2_block *block,
*/
block->base_colors[0][i] = etc1_base_color_diff_hi(src[i]);
block->base_colors[1][i] = etc1_base_color_diff_lo(src[i]);
- }
+ }
}
if (block->is_ind_mode || block->is_diff_mode) {
@@ -756,10 +737,10 @@ etc2_unpack_srgb8(uint8_t *dst_row,
}
}
src += bs;
- }
+ }
src_row += src_stride;
- }
+ }
}
static void
@@ -792,10 +773,10 @@ etc2_unpack_rgba8(uint8_t *dst_row,
}
}
src += bs;
- }
+ }
src_row += src_stride;
- }
+ }
}
static void
@@ -836,10 +817,10 @@ etc2_unpack_srgb8_alpha8(uint8_t *dst_row,
}
}
src += bs;
- }
+ }
src_row += src_stride;
- }
+ }
}
static void
@@ -871,10 +852,10 @@ etc2_unpack_r11(uint8_t *dst_row,
}
}
src += bs;
- }
+ }
src_row += src_stride;
- }
+ }
}
static void
@@ -919,10 +900,10 @@ etc2_unpack_rg11(uint8_t *dst_row,
}
}
src += bs;
- }
+ }
src_row += src_stride;
- }
+ }
}
static void
@@ -955,10 +936,10 @@ etc2_unpack_signed_r11(uint8_t *dst_row,
}
}
src += bs;
- }
+ }
src_row += src_stride;
- }
+ }
}
static void
@@ -1003,10 +984,10 @@ etc2_unpack_signed_rg11(uint8_t *dst_row,
}
}
src += bs;
- }
+ }
src_row += src_stride;
- }
+ }
}
static void
@@ -1166,16 +1147,112 @@ _mesa_texstore_etc2_srgb8_punchthrough_alpha1(TEXSTORE_PARAMS)
return GL_FALSE;
}
+
+/**
+ * Decode texture data in any one of following formats:
+ * `MESA_FORMAT_ETC2_RGB8`
+ * `MESA_FORMAT_ETC2_SRGB8`
+ * `MESA_FORMAT_ETC2_RGBA8_EAC`
+ * `MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC`
+ * `MESA_FORMAT_ETC2_R11_EAC`
+ * `MESA_FORMAT_ETC2_RG11_EAC`
+ * `MESA_FORMAT_ETC2_SIGNED_R11_EAC`
+ * `MESA_FORMAT_ETC2_SIGNED_RG11_EAC`
+ * `MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1`
+ * `MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1`
+ *
+ * The size of the source data must be a multiple of the ETC2 block size
+ * even if the texture image's dimensions are not aligned to 4.
+ *
+ * \param src_width in pixels
+ * \param src_height in pixels
+ * \param dst_stride in bytes
+ */
+
void
-_mesa_fetch_texel_2d_f_etc2_rgb8(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
+_mesa_unpack_etc2_format(uint8_t *dst_row,
+ unsigned dst_stride,
+ const uint8_t *src_row,
+ unsigned src_stride,
+ unsigned src_width,
+ unsigned src_height,
+ gl_format format)
+{
+ if (format == MESA_FORMAT_ETC2_RGB8)
+ etc2_unpack_rgb8(dst_row, dst_stride,
+ src_row, src_stride,
+ src_width, src_height);
+ else if (format == MESA_FORMAT_ETC2_SRGB8)
+ etc2_unpack_srgb8(dst_row, dst_stride,
+ src_row, src_stride,
+ src_width, src_height);
+ else if (format == MESA_FORMAT_ETC2_RGBA8_EAC)
+ etc2_unpack_rgba8(dst_row, dst_stride,
+ src_row, src_stride,
+ src_width, src_height);
+ else if (format == MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC)
+ etc2_unpack_srgb8_alpha8(dst_row, dst_stride,
+ src_row, src_stride,
+ src_width, src_height);
+ else if (format == MESA_FORMAT_ETC2_R11_EAC)
+ etc2_unpack_r11(dst_row, dst_stride,
+ src_row, src_stride,
+ src_width, src_height);
+ else if (format == MESA_FORMAT_ETC2_RG11_EAC)
+ etc2_unpack_rg11(dst_row, dst_stride,
+ src_row, src_stride,
+ src_width, src_height);
+ else if (format == MESA_FORMAT_ETC2_SIGNED_R11_EAC)
+ etc2_unpack_signed_r11(dst_row, dst_stride,
+ src_row, src_stride,
+ src_width, src_height);
+ else if (format == MESA_FORMAT_ETC2_SIGNED_RG11_EAC)
+ etc2_unpack_signed_rg11(dst_row, dst_stride,
+ src_row, src_stride,
+ src_width, src_height);
+ else if (format == MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1)
+ etc2_unpack_rgb8_punchthrough_alpha1(dst_row, dst_stride,
+ src_row, src_stride,
+ src_width, src_height);
+ else if (format == MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1)
+ etc2_unpack_srgb8_punchthrough_alpha1(dst_row, dst_stride,
+ src_row, src_stride,
+ src_width, src_height);
+}
+
+
+
+static void
+fetch_etc1_rgb8(const GLubyte *map, const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k,
+ GLfloat *texel)
+{
+ struct etc1_block block;
+ GLubyte dst[3];
+ const GLubyte *src;
+
+ src = map + (((rowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
+
+ etc1_parse_block(&block, src);
+ etc1_fetch_texel(&block, i % 4, j % 4, dst);
+
+ texel[RCOMP] = UBYTE_TO_FLOAT(dst[0]);
+ texel[GCOMP] = UBYTE_TO_FLOAT(dst[1]);
+ texel[BCOMP] = UBYTE_TO_FLOAT(dst[2]);
+ texel[ACOMP] = 1.0f;
+}
+
+
+static void
+fetch_etc2_rgb8(const GLubyte *map, const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k,
+ GLfloat *texel)
{
struct etc2_block block;
uint8_t dst[3];
const uint8_t *src;
- src = texImage->Map +
- (((texImage->RowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
+ src = map + (((rowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
etc2_rgb8_parse_block(&block, src,
false /* punchthrough_alpha */);
@@ -1188,16 +1265,16 @@ _mesa_fetch_texel_2d_f_etc2_rgb8(const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0f;
}
-void
-_mesa_fetch_texel_2d_f_etc2_srgb8(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
+static void
+fetch_etc2_srgb8(const GLubyte *map, const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k,
+ GLfloat *texel)
{
struct etc2_block block;
uint8_t dst[3];
const uint8_t *src;
- src = texImage->Map +
- (((texImage->RowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
+ src = map + (((rowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
etc2_rgb8_parse_block(&block, src,
false /* punchthrough_alpha */);
@@ -1210,16 +1287,16 @@ _mesa_fetch_texel_2d_f_etc2_srgb8(const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0f;
}
-void
-_mesa_fetch_texel_2d_f_etc2_rgba8_eac(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
+static void
+fetch_etc2_rgba8_eac(const GLubyte *map, const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k,
+ GLfloat *texel)
{
struct etc2_block block;
uint8_t dst[4];
const uint8_t *src;
- src = texImage->Map +
- (((texImage->RowStride + 3) / 4) * (j / 4) + (i / 4)) * 16;
+ src = map + (((rowStride + 3) / 4) * (j / 4) + (i / 4)) * 16;
etc2_rgba8_parse_block(&block, src);
etc2_rgba8_fetch_texel(&block, i % 4, j % 4, dst);
@@ -1230,18 +1307,16 @@ _mesa_fetch_texel_2d_f_etc2_rgba8_eac(const struct swrast_texture_image *texImag
texel[ACOMP] = UBYTE_TO_FLOAT(dst[3]);
}
-void
-_mesa_fetch_texel_2d_f_etc2_srgb8_alpha8_eac(const struct
- swrast_texture_image *texImage,
- GLint i, GLint j,
- GLint k, GLfloat *texel)
+static void
+fetch_etc2_srgb8_alpha8_eac(const GLubyte *map, const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k,
+ GLfloat *texel)
{
struct etc2_block block;
uint8_t dst[4];
const uint8_t *src;
- src = texImage->Map +
- (((texImage->RowStride + 3) / 4) * (j / 4) + (i / 4)) * 16;
+ src = map + (((rowStride + 3) / 4) * (j / 4) + (i / 4)) * 16;
etc2_rgba8_parse_block(&block, src);
etc2_rgba8_fetch_texel(&block, i % 4, j % 4, dst);
@@ -1252,16 +1327,16 @@ _mesa_fetch_texel_2d_f_etc2_srgb8_alpha8_eac(const struct
texel[ACOMP] = UBYTE_TO_FLOAT(dst[3]);
}
-void
-_mesa_fetch_texel_2d_f_etc2_r11_eac(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
+static void
+fetch_etc2_r11_eac(const GLubyte *map, const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k,
+ GLfloat *texel)
{
struct etc2_block block;
GLushort dst;
const uint8_t *src;
- src = texImage->Map +
- (((texImage->RowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
+ src = map + (((rowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
etc2_r11_parse_block(&block, src);
etc2_r11_fetch_texel(&block, i % 4, j % 4, (uint8_t *)&dst);
@@ -1272,18 +1347,16 @@ _mesa_fetch_texel_2d_f_etc2_r11_eac(const struct swrast_texture_image *texImage,
texel[ACOMP] = 1.0f;
}
-void
-_mesa_fetch_texel_2d_f_etc2_rg11_eac(const struct
- swrast_texture_image *texImage,
- GLint i, GLint j,
- GLint k, GLfloat *texel)
+static void
+fetch_etc2_rg11_eac(const GLubyte *map, const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k,
+ GLfloat *texel)
{
struct etc2_block block;
GLushort dst[2];
const uint8_t *src;
- src = texImage->Map +
- (((texImage->RowStride + 3) / 4) * (j / 4) + (i / 4)) * 16;
+ src = map + (((rowStride + 3) / 4) * (j / 4) + (i / 4)) * 16;
/* red component */
etc2_r11_parse_block(&block, src);
@@ -1299,16 +1372,16 @@ _mesa_fetch_texel_2d_f_etc2_rg11_eac(const struct
texel[ACOMP] = 1.0f;
}
-void
-_mesa_fetch_texel_2d_f_etc2_signed_r11_eac(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
+static void
+fetch_etc2_signed_r11_eac(const GLubyte *map, const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k,
+ GLfloat *texel)
{
struct etc2_block block;
GLushort dst;
const uint8_t *src;
- src = texImage->Map +
- (((texImage->RowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
+ src = map + (((rowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
etc2_r11_parse_block(&block, src);
etc2_signed_r11_fetch_texel(&block, i % 4, j % 4, (uint8_t *)&dst);
@@ -1319,16 +1392,16 @@ _mesa_fetch_texel_2d_f_etc2_signed_r11_eac(const struct swrast_texture_image *te
texel[ACOMP] = 1.0f;
}
-void
-_mesa_fetch_texel_2d_f_etc2_signed_rg11_eac(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
+static void
+fetch_etc2_signed_rg11_eac(const GLubyte *map, const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k,
+ GLfloat *texel)
{
struct etc2_block block;
GLushort dst[2];
const uint8_t *src;
- src = texImage->Map +
- (((texImage->RowStride + 3) / 4) * (j / 4) + (i / 4)) * 16;
+ src = map + (((rowStride + 3) / 4) * (j / 4) + (i / 4)) * 16;
/* red component */
etc2_r11_parse_block(&block, src);
@@ -1344,18 +1417,17 @@ _mesa_fetch_texel_2d_f_etc2_signed_rg11_eac(const struct swrast_texture_image *t
texel[ACOMP] = 1.0f;
}
-void
-_mesa_fetch_texel_2d_f_etc2_rgb8_punchthrough_alpha1(
- const struct swrast_texture_image *texImage,
- GLint i, GLint j,
- GLint k, GLfloat *texel)
+static void
+fetch_etc2_rgb8_punchthrough_alpha1(const GLubyte *map,
+ const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k,
+ GLfloat *texel)
{
struct etc2_block block;
uint8_t dst[4];
const uint8_t *src;
- src = texImage->Map +
- (((texImage->RowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
+ src = map + (((rowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
etc2_rgb8_parse_block(&block, src,
true /* punchthrough alpha */);
@@ -1367,18 +1439,18 @@ _mesa_fetch_texel_2d_f_etc2_rgb8_punchthrough_alpha1(
texel[ACOMP] = UBYTE_TO_FLOAT(dst[3]);
}
-void
-_mesa_fetch_texel_2d_f_etc2_srgb8_punchthrough_alpha1(
- const struct swrast_texture_image *texImage,
- GLint i, GLint j,
- GLint k, GLfloat *texel)
+static void
+fetch_etc2_srgb8_punchthrough_alpha1(const GLubyte *map,
+ const GLuint imageOffsets[],
+ GLint rowStride,
+ GLint i, GLint j, GLint k,
+ GLfloat *texel)
{
struct etc2_block block;
uint8_t dst[4];
const uint8_t *src;
- src = texImage->Map +
- (((texImage->RowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
+ src = map + (((rowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
etc2_rgb8_parse_block(&block, src,
true /* punchthrough alpha */);
@@ -1390,74 +1462,34 @@ _mesa_fetch_texel_2d_f_etc2_srgb8_punchthrough_alpha1(
texel[ACOMP] = UBYTE_TO_FLOAT(dst[3]);
}
-/**
- * Decode texture data in any one of following formats:
- * `MESA_FORMAT_ETC2_RGB8`
- * `MESA_FORMAT_ETC2_SRGB8`
- * `MESA_FORMAT_ETC2_RGBA8_EAC`
- * `MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC`
- * `MESA_FORMAT_ETC2_R11_EAC`
- * `MESA_FORMAT_ETC2_RG11_EAC`
- * `MESA_FORMAT_ETC2_SIGNED_R11_EAC`
- * `MESA_FORMAT_ETC2_SIGNED_RG11_EAC`
- * `MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1`
- * `MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1`
- *
- * The size of the source data must be a multiple of the ETC2 block size
- * even if the texture image's dimensions are not aligned to 4.
- *
- * \param src_width in pixels
- * \param src_height in pixels
- * \param dst_stride in bytes
- */
-void
-_mesa_unpack_etc2_format(uint8_t *dst_row,
- unsigned dst_stride,
- const uint8_t *src_row,
- unsigned src_stride,
- unsigned src_width,
- unsigned src_height,
- gl_format format)
+compressed_fetch_func
+_mesa_get_etc_fetch_func(gl_format format)
{
- if (format == MESA_FORMAT_ETC2_RGB8)
- etc2_unpack_rgb8(dst_row, dst_stride,
- src_row, src_stride,
- src_width, src_height);
- else if (format == MESA_FORMAT_ETC2_SRGB8)
- etc2_unpack_srgb8(dst_row, dst_stride,
- src_row, src_stride,
- src_width, src_height);
- else if (format == MESA_FORMAT_ETC2_RGBA8_EAC)
- etc2_unpack_rgba8(dst_row, dst_stride,
- src_row, src_stride,
- src_width, src_height);
- else if (format == MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC)
- etc2_unpack_srgb8_alpha8(dst_row, dst_stride,
- src_row, src_stride,
- src_width, src_height);
- else if (format == MESA_FORMAT_ETC2_R11_EAC)
- etc2_unpack_r11(dst_row, dst_stride,
- src_row, src_stride,
- src_width, src_height);
- else if (format == MESA_FORMAT_ETC2_RG11_EAC)
- etc2_unpack_rg11(dst_row, dst_stride,
- src_row, src_stride,
- src_width, src_height);
- else if (format == MESA_FORMAT_ETC2_SIGNED_R11_EAC)
- etc2_unpack_signed_r11(dst_row, dst_stride,
- src_row, src_stride,
- src_width, src_height);
- else if (format == MESA_FORMAT_ETC2_SIGNED_RG11_EAC)
- etc2_unpack_signed_rg11(dst_row, dst_stride,
- src_row, src_stride,
- src_width, src_height);
- else if (format == MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1)
- etc2_unpack_rgb8_punchthrough_alpha1(dst_row, dst_stride,
- src_row, src_stride,
- src_width, src_height);
- else if (format == MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1)
- etc2_unpack_srgb8_punchthrough_alpha1(dst_row, dst_stride,
- src_row, src_stride,
- src_width, src_height);
+ switch (format) {
+ case MESA_FORMAT_ETC1_RGB8:
+ return fetch_etc1_rgb8;
+ case MESA_FORMAT_ETC2_RGB8:
+ return fetch_etc2_rgb8;
+ case MESA_FORMAT_ETC2_SRGB8:
+ return fetch_etc2_srgb8;
+ case MESA_FORMAT_ETC2_RGBA8_EAC:
+ return fetch_etc2_rgba8_eac;
+ case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC:
+ return fetch_etc2_srgb8_alpha8_eac;
+ case MESA_FORMAT_ETC2_R11_EAC:
+ return fetch_etc2_r11_eac;
+ case MESA_FORMAT_ETC2_RG11_EAC:
+ return fetch_etc2_rg11_eac;
+ case MESA_FORMAT_ETC2_SIGNED_R11_EAC:
+ return fetch_etc2_signed_r11_eac;
+ case MESA_FORMAT_ETC2_SIGNED_RG11_EAC:
+ return fetch_etc2_signed_rg11_eac;
+ case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1:
+ return fetch_etc2_rgb8_punchthrough_alpha1;
+ case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:
+ return fetch_etc2_srgb8_punchthrough_alpha1;
+ default:
+ return NULL;
+ }
}
diff --git a/mesalib/src/mesa/main/texcompress_etc.h b/mesalib/src/mesa/main/texcompress_etc.h
index 5e086d4e7..503d0388a 100644
--- a/mesalib/src/mesa/main/texcompress_etc.h
+++ b/mesalib/src/mesa/main/texcompress_etc.h
@@ -27,9 +27,9 @@
#include <inttypes.h>
#include "glheader.h"
#include "mfeatures.h"
+#include "texcompress.h"
#include "texstore.h"
-struct swrast_texture_image;
GLboolean
_mesa_texstore_etc1_rgb8(TEXSTORE_PARAMS);
@@ -65,50 +65,6 @@ GLboolean
_mesa_texstore_etc2_srgb8_punchthrough_alpha1(TEXSTORE_PARAMS);
void
-_mesa_fetch_texel_2d_f_etc1_rgb8(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-void
-_mesa_fetch_texel_2d_f_etc2_rgb8(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-void
-_mesa_fetch_texel_2d_f_etc2_srgb8(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-void
-_mesa_fetch_texel_2d_f_etc2_rgba8_eac(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-void
-_mesa_fetch_texel_2d_f_etc2_srgb8_alpha8_eac(const struct
- swrast_texture_image *texImage,
- GLint i, GLint j,
- GLint k, GLfloat *texel);
-void
-_mesa_fetch_texel_2d_f_etc2_r11_eac(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-void
-_mesa_fetch_texel_2d_f_etc2_rg11_eac(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-void
-_mesa_fetch_texel_2d_f_etc2_signed_r11_eac(const struct
- swrast_texture_image *texImage,
- GLint i, GLint j,
- GLint k, GLfloat *texel);
-void
-_mesa_fetch_texel_2d_f_etc2_signed_rg11_eac(const struct
- swrast_texture_image *texImage,
- GLint i, GLint j,
- GLint k, GLfloat *texel);
-void
-_mesa_fetch_texel_2d_f_etc2_rgb8_punchthrough_alpha1(
- const struct swrast_texture_image *texImage,
- GLint i, GLint j,
- GLint k, GLfloat *texel);
-void
-_mesa_fetch_texel_2d_f_etc2_srgb8_punchthrough_alpha1(
- const struct swrast_texture_image *texImage,
- GLint i, GLint j,
- GLint k, GLfloat *texel);
-void
_mesa_etc1_unpack_rgba8888(uint8_t *dst_row,
unsigned dst_stride,
const uint8_t *src_row,
@@ -123,4 +79,8 @@ _mesa_unpack_etc2_format(uint8_t *dst_row,
unsigned src_width,
unsigned src_height,
gl_format format);
+
+compressed_fetch_func
+_mesa_get_etc_fetch_func(gl_format format);
+
#endif
diff --git a/mesalib/src/mesa/main/texcompress_fxt1.c b/mesalib/src/mesa/main/texcompress_fxt1.c
index eeed78891..f7254f92e 100644
--- a/mesalib/src/mesa/main/texcompress_fxt1.c
+++ b/mesalib/src/mesa/main/texcompress_fxt1.c
@@ -39,7 +39,6 @@
#include "texcompress.h"
#include "texcompress_fxt1.h"
#include "texstore.h"
-#include "swrast/s_context.h"
static void
@@ -151,37 +150,6 @@ _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS)
}
-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 GLubyte and convert to float here */
- GLubyte rgba[4];
- (void) k;
- fxt1_decode_1(texImage->Map, texImage->RowStride, i, j, rgba);
- texel[RCOMP] = UBYTE_TO_FLOAT(rgba[RCOMP]);
- texel[GCOMP] = UBYTE_TO_FLOAT(rgba[GCOMP]);
- texel[BCOMP] = UBYTE_TO_FLOAT(rgba[BCOMP]);
- texel[ACOMP] = UBYTE_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 GLubyte and convert to float here */
- GLubyte rgba[4];
- (void) k;
- fxt1_decode_1(texImage->Map, texImage->RowStride, i, j, rgba);
- texel[RCOMP] = UBYTE_TO_FLOAT(rgba[RCOMP]);
- texel[GCOMP] = UBYTE_TO_FLOAT(rgba[GCOMP]);
- texel[BCOMP] = UBYTE_TO_FLOAT(rgba[BCOMP]);
- texel[ACOMP] = 1.0F;
-}
-
-
-
/***************************************************************************\
* FXT1 encoder
*
@@ -1643,3 +1611,45 @@ fxt1_decode_1 (const void *texture, GLint stride, /* in pixels */
decode_1[mode](code, t, rgba);
}
+
+
+
+
+static void
+fetch_rgb_fxt1(const GLubyte *map, const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ GLubyte rgba[4];
+ fxt1_decode_1(map, rowStride, i, j, rgba);
+ texel[RCOMP] = UBYTE_TO_FLOAT(rgba[RCOMP]);
+ texel[GCOMP] = UBYTE_TO_FLOAT(rgba[GCOMP]);
+ texel[BCOMP] = UBYTE_TO_FLOAT(rgba[BCOMP]);
+ texel[ACOMP] = 1.0F;
+}
+
+
+static void
+fetch_rgba_fxt1(const GLubyte *map, const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ GLubyte rgba[4];
+ fxt1_decode_1(map, rowStride, i, j, rgba);
+ texel[RCOMP] = UBYTE_TO_FLOAT(rgba[RCOMP]);
+ texel[GCOMP] = UBYTE_TO_FLOAT(rgba[GCOMP]);
+ texel[BCOMP] = UBYTE_TO_FLOAT(rgba[BCOMP]);
+ texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
+}
+
+
+compressed_fetch_func
+_mesa_get_fxt_fetch_func(gl_format format)
+{
+ switch (format) {
+ case MESA_FORMAT_RGB_FXT1:
+ return fetch_rgb_fxt1;
+ case MESA_FORMAT_RGBA_FXT1:
+ return fetch_rgba_fxt1;
+ default:
+ return NULL;
+ }
+}
diff --git a/mesalib/src/mesa/main/texcompress_fxt1.h b/mesalib/src/mesa/main/texcompress_fxt1.h
index 2a8b8d653..5949df90f 100644
--- a/mesalib/src/mesa/main/texcompress_fxt1.h
+++ b/mesalib/src/mesa/main/texcompress_fxt1.h
@@ -29,7 +29,6 @@
#include "mfeatures.h"
#include "texstore.h"
-struct swrast_texture_image;
extern GLboolean
_mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS);
@@ -37,12 +36,8 @@ _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);
+compressed_fetch_func
+_mesa_get_fxt_fetch_func(gl_format format);
#endif /* TEXCOMPRESS_FXT1_H */
diff --git a/mesalib/src/mesa/main/texcompress_rgtc.c b/mesalib/src/mesa/main/texcompress_rgtc.c
index 5773459d7..fa9172aa2 100644
--- a/mesalib/src/mesa/main/texcompress_rgtc.c
+++ b/mesalib/src/mesa/main/texcompress_rgtc.c
@@ -43,7 +43,6 @@
#include "texcompress.h"
#include "texcompress_rgtc.h"
#include "texstore.h"
-#include "swrast/s_context.h"
#define RGTC_DEBUG 0
@@ -291,113 +290,120 @@ _mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS)
return GL_TRUE;
}
-void
-_mesa_fetch_texel_red_rgtc1(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
+
+#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
+
+
+
+static void
+fetch_red_rgtc1(const GLubyte *map, const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel)
{
GLubyte red;
- GLint sliceOffset = k ? texImage->ImageOffsets[k] / 2 : 0;
- unsigned_fetch_texel_rgtc(texImage->RowStride,
- texImage->Map + sliceOffset,
- i, j, &red, 1);
+ GLuint sliceOffset = k ? imageOffsets[k] / 2 : 0;
+ unsigned_fetch_texel_rgtc(rowStride, map + sliceOffset, 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_signed_red_rgtc1(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
+static void
+fetch_l_latc1(const GLubyte *map, const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel)
{
- GLbyte red;
- GLint sliceOffset = k ? texImage->ImageOffsets[k] / 2 : 0;
- signed_fetch_texel_rgtc(texImage->RowStride,
- (GLbyte *)(texImage->Map) + sliceOffset,
- 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_rg_rgtc2(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- GLubyte red, green;
- GLint sliceOffset = k ? texImage->ImageOffsets[k] : 0;
- unsigned_fetch_texel_rgtc(texImage->RowStride,
- texImage->Map + sliceOffset,
- i, j, &red, 2);
- unsigned_fetch_texel_rgtc(texImage->RowStride,
- texImage->Map + sliceOffset + 8,
- i, j, &green, 2);
- texel[RCOMP] = UBYTE_TO_FLOAT(red);
- texel[GCOMP] = UBYTE_TO_FLOAT(green);
- texel[BCOMP] = 0.0;
+ GLubyte red;
+ GLuint sliceOffset = k ? imageOffsets[k] / 2 : 0;
+ unsigned_fetch_texel_rgtc(rowStride, map + sliceOffset, i, j, &red, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = UBYTE_TO_FLOAT(red);
texel[ACOMP] = 1.0;
}
-void
-_mesa_fetch_texel_signed_rg_rgtc2(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
+static void
+fetch_signed_red_rgtc1(const GLubyte *map, const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k,
+ GLfloat *texel)
{
- GLbyte red, green;
- GLint sliceOffset = k ? texImage->ImageOffsets[k] : 0;
- signed_fetch_texel_rgtc(texImage->RowStride,
- (GLbyte *)(texImage->Map) + sliceOffset,
- i, j, &red, 2);
- signed_fetch_texel_rgtc(texImage->RowStride,
- (GLbyte *)(texImage->Map) + sliceOffset + 8,
- i, j, &green, 2);
+ GLbyte red;
+ GLuint sliceOffset = k ? imageOffsets[k] / 2 : 0;
+ signed_fetch_texel_rgtc(rowStride, (const GLbyte *) map + sliceOffset,
+ i, j, &red, 1);
texel[RCOMP] = BYTE_TO_FLOAT_TEX(red);
- texel[GCOMP] = BYTE_TO_FLOAT_TEX(green);
+ texel[GCOMP] = 0.0;
texel[BCOMP] = 0.0;
texel[ACOMP] = 1.0;
}
-void
-_mesa_fetch_texel_l_latc1(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
+static void
+fetch_signed_l_latc1(const GLubyte *map, const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k,
+ GLfloat *texel)
{
GLubyte red;
- GLint sliceOffset = k ? texImage->ImageOffsets[k] / 2 : 0;
- unsigned_fetch_texel_rgtc(texImage->RowStride,
- texImage->Map + sliceOffset,
- i, j, &red, 1);
+ GLuint sliceOffset = k ? imageOffsets[k] / 2 : 0;
+ unsigned_fetch_texel_rgtc(rowStride, map + sliceOffset, i, j, &red, 1);
texel[RCOMP] =
texel[GCOMP] =
- texel[BCOMP] = UBYTE_TO_FLOAT(red);
+ texel[BCOMP] = BYTE_TO_FLOAT(red);
texel[ACOMP] = 1.0;
}
-void
-_mesa_fetch_texel_signed_l_latc1(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
+static void
+fetch_rg_rgtc2(const GLubyte *map, const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k,
+ GLfloat *texel)
{
- GLbyte red;
- GLint sliceOffset = k ? texImage->ImageOffsets[k] / 2 : 0;
- signed_fetch_texel_rgtc(texImage->RowStride,
- (GLbyte *)(texImage->Map) + sliceOffset,
- i, j, &red, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = BYTE_TO_FLOAT_TEX(red);
+ GLubyte red, green;
+ GLuint sliceOffset = k ? imageOffsets[k] : 0;
+ unsigned_fetch_texel_rgtc(rowStride,
+ map + sliceOffset,
+ i, j, &red, 2);
+ unsigned_fetch_texel_rgtc(rowStride,
+ map + sliceOffset + 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_la_latc2(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
+static void
+fetch_la_latc2(const GLubyte *map, const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k,
+ GLfloat *texel)
{
GLubyte red, green;
- GLint sliceOffset = k ? texImage->ImageOffsets[k] : 0;
- unsigned_fetch_texel_rgtc(texImage->RowStride,
- texImage->Map + sliceOffset,
+ GLuint sliceOffset = k ? imageOffsets[k] : 0;
+ unsigned_fetch_texel_rgtc(rowStride,
+ map + sliceOffset,
i, j, &red, 2);
- unsigned_fetch_texel_rgtc(texImage->RowStride,
- texImage->Map + sliceOffset + 8,
+ unsigned_fetch_texel_rgtc(rowStride,
+ map + sliceOffset + 8,
i, j, &green, 2);
texel[RCOMP] =
texel[GCOMP] =
@@ -405,17 +411,39 @@ _mesa_fetch_texel_la_latc2(const struct swrast_texture_image *texImage,
texel[ACOMP] = UBYTE_TO_FLOAT(green);
}
-void
-_mesa_fetch_texel_signed_la_latc2(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
+
+static void
+fetch_signed_rg_rgtc2(const GLubyte *map, const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k,
+ GLfloat *texel)
+{
+ GLbyte red, green;
+ GLuint sliceOffset = k ? imageOffsets[k] : 0;
+ signed_fetch_texel_rgtc(rowStride,
+ (GLbyte *) map + sliceOffset,
+ i, j, &red, 2);
+ signed_fetch_texel_rgtc(rowStride,
+ (GLbyte *) map + sliceOffset + 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;
+}
+
+
+static void
+fetch_signed_la_latc2(const GLubyte *map, const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k,
+ GLfloat *texel)
{
GLbyte red, green;
- GLint sliceOffset = k ? texImage->ImageOffsets[k] : 0;
- signed_fetch_texel_rgtc(texImage->RowStride,
- (GLbyte *)(texImage->Map) + sliceOffset,
+ GLuint sliceOffset = k ? imageOffsets[k] : 0;
+ signed_fetch_texel_rgtc(rowStride,
+ (GLbyte *) map + sliceOffset,
i, j, &red, 2);
- signed_fetch_texel_rgtc(texImage->RowStride,
- (GLbyte *)(texImage->Map) + sliceOffset + 8,
+ signed_fetch_texel_rgtc(rowStride,
+ (GLbyte *) map + sliceOffset + 8,
i, j, &green, 2);
texel[RCOMP] =
texel[GCOMP] =
@@ -423,27 +451,28 @@ _mesa_fetch_texel_signed_la_latc2(const struct swrast_texture_image *texImage,
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
+compressed_fetch_func
+_mesa_get_compressed_rgtc_func(gl_format format)
+{
+ switch (format) {
+ case MESA_FORMAT_RED_RGTC1:
+ return fetch_red_rgtc1;
+ case MESA_FORMAT_L_LATC1:
+ return fetch_l_latc1;
+ case MESA_FORMAT_SIGNED_RED_RGTC1:
+ return fetch_signed_red_rgtc1;
+ case MESA_FORMAT_SIGNED_L_LATC1:
+ return fetch_signed_l_latc1;
+ case MESA_FORMAT_RG_RGTC2:
+ return fetch_rg_rgtc2;
+ case MESA_FORMAT_LA_LATC2:
+ return fetch_la_latc2;
+ case MESA_FORMAT_SIGNED_RG_RGTC2:
+ return fetch_signed_rg_rgtc2;
+ case MESA_FORMAT_SIGNED_LA_LATC2:
+ return fetch_signed_la_latc2;
+ default:
+ return NULL;
+ }
+}
diff --git a/mesalib/src/mesa/main/texcompress_rgtc.h b/mesalib/src/mesa/main/texcompress_rgtc.h
index 91fda882d..9e1cce438 100644
--- a/mesalib/src/mesa/main/texcompress_rgtc.h
+++ b/mesalib/src/mesa/main/texcompress_rgtc.h
@@ -28,7 +28,6 @@
#include "mfeatures.h"
#include "texstore.h"
-struct swrast_texture_image;
extern GLboolean
_mesa_texstore_red_rgtc1(TEXSTORE_PARAMS);
@@ -42,36 +41,8 @@ _mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS);
extern GLboolean
_mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS);
-extern void
-_mesa_fetch_texel_red_rgtc1(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
+extern compressed_fetch_func
+_mesa_get_compressed_rgtc_func(gl_format format);
-extern void
-_mesa_fetch_texel_signed_red_rgtc1(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-extern void
-_mesa_fetch_texel_rg_rgtc2(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-extern void
-_mesa_fetch_texel_signed_rg_rgtc2(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-extern void
-_mesa_fetch_texel_l_latc1(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-extern void
-_mesa_fetch_texel_signed_l_latc1(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-extern void
-_mesa_fetch_texel_la_latc2(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-extern void
-_mesa_fetch_texel_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 476b998e0..23a5a0868 100644
--- a/mesalib/src/mesa/main/texcompress_s3tc.c
+++ b/mesalib/src/mesa/main/texcompress_s3tc.c
@@ -44,7 +44,6 @@
#include "texcompress.h"
#include "texcompress_s3tc.h"
#include "texstore.h"
-#include "swrast/s_context.h"
#include "format_unpack.h"
@@ -58,7 +57,7 @@
#define DXTN_LIBNAME "libtxc_dxtn.so"
#endif
-typedef void (*dxtFetchTexelFuncExt)( GLint srcRowstride, GLubyte *pixdata, GLint col, GLint row, GLvoid *texelOut );
+typedef void (*dxtFetchTexelFuncExt)( GLint srcRowstride, const GLubyte *pixdata, GLint col, GLint row, GLvoid *texelOut );
static dxtFetchTexelFuncExt fetch_ext_rgb_dxt1 = NULL;
static dxtFetchTexelFuncExt fetch_ext_rgba_dxt1 = NULL;
@@ -332,165 +331,105 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS)
}
+/** Report problem with dxt texture decompression, once */
static void
-fetch_texel_2d_rgb_dxt1(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLubyte *texel)
+problem(const char *func)
{
- if (fetch_ext_rgb_dxt1) {
- GLint sliceOffset = k ? texImage->ImageOffsets[k] / 2 : 0;
- fetch_ext_rgb_dxt1(texImage->RowStride,
- texImage->Map + sliceOffset, i, j, texel);
+ static GLboolean warned = GL_FALSE;
+ if (!warned) {
+ _mesa_debug(NULL, "attempted to decode DXT texture without "
+ "library available: %s\n", func);
+ warned = GL_TRUE;
}
- else
- _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgb_dxt1");
}
-void
-_mesa_fetch_texel_rgb_dxt1(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
+static void
+fetch_rgb_dxt1(const GLubyte *map, const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel)
{
- /* just sample as GLubyte and convert to float here */
- GLubyte rgba[4];
- fetch_texel_2d_rgb_dxt1(texImage, i, j, k, rgba);
- texel[RCOMP] = UBYTE_TO_FLOAT(rgba[RCOMP]);
- texel[GCOMP] = UBYTE_TO_FLOAT(rgba[GCOMP]);
- texel[BCOMP] = UBYTE_TO_FLOAT(rgba[BCOMP]);
- texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
+ if (fetch_ext_rgb_dxt1) {
+ GLuint sliceOffset = k ? imageOffsets[k] / 2 : 0;
+ GLubyte tex[4];
+ fetch_ext_rgb_dxt1(rowStride, map + sliceOffset, i, j, tex);
+ texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]);
+ texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]);
+ texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]);
+ texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]);
+ }
+ else {
+ problem("rgb_dxt1");
+ }
}
-
static void
-fetch_texel_2d_rgba_dxt1(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLubyte *texel)
+fetch_rgba_dxt1(const GLubyte *map, const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel)
{
if (fetch_ext_rgba_dxt1) {
- GLint sliceOffset = k ? texImage->ImageOffsets[k] / 2 : 0;
- fetch_ext_rgba_dxt1(texImage->RowStride,
- texImage->Map + sliceOffset, i, j, texel);
+ GLuint sliceOffset = k ? imageOffsets[k] / 2 : 0;
+ GLubyte tex[4];
+ fetch_ext_rgba_dxt1(rowStride, map + sliceOffset, i, j, tex);
+ texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]);
+ texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]);
+ texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]);
+ texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]);
+ }
+ else {
+ problem("rgba_dxt1");
}
- else
- _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt1\n");
-}
-
-
-void
-_mesa_fetch_texel_rgba_dxt1(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- /* just sample as GLubyte and convert to float here */
- GLubyte rgba[4];
- fetch_texel_2d_rgba_dxt1(texImage, i, j, k, rgba);
- texel[RCOMP] = UBYTE_TO_FLOAT(rgba[RCOMP]);
- texel[GCOMP] = UBYTE_TO_FLOAT(rgba[GCOMP]);
- texel[BCOMP] = UBYTE_TO_FLOAT(rgba[BCOMP]);
- texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
}
-
static void
-fetch_texel_2d_rgba_dxt3(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLubyte *texel)
+fetch_rgba_dxt3(const GLubyte *map, const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel)
{
if (fetch_ext_rgba_dxt3) {
- GLint sliceOffset = k ? texImage->ImageOffsets[k] : 0;
- fetch_ext_rgba_dxt3(texImage->RowStride,
- texImage->Map + sliceOffset, i, j, texel);
+ GLuint sliceOffset = k ? imageOffsets[k] : 0;
+ GLubyte tex[4];
+ fetch_ext_rgba_dxt3(rowStride, map + sliceOffset, i, j, tex);
+ texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]);
+ texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]);
+ texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]);
+ texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]);
+ }
+ else {
+ problem("rgba_dxt3");
}
- else
- _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt3\n");
-}
-
-
-void
-_mesa_fetch_texel_rgba_dxt3(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- /* just sample as GLubyte and convert to float here */
- GLubyte rgba[4];
- fetch_texel_2d_rgba_dxt3(texImage, i, j, k, rgba);
- texel[RCOMP] = UBYTE_TO_FLOAT(rgba[RCOMP]);
- texel[GCOMP] = UBYTE_TO_FLOAT(rgba[GCOMP]);
- texel[BCOMP] = UBYTE_TO_FLOAT(rgba[BCOMP]);
- texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
}
-
static void
-fetch_texel_2d_rgba_dxt5(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLubyte *texel)
+fetch_rgba_dxt5(const GLubyte *map, const GLuint imageOffsets[],
+ GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel)
{
if (fetch_ext_rgba_dxt5) {
- GLint sliceOffset = k ? texImage->ImageOffsets[k] : 0;
- fetch_ext_rgba_dxt5(texImage->RowStride,
- texImage->Map + sliceOffset, i, j, texel);
+ GLuint sliceOffset = k ? imageOffsets[k] : 0;
+ GLubyte tex[4];
+ fetch_ext_rgba_dxt5(rowStride, map + sliceOffset, i, j, tex);
+ texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]);
+ texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]);
+ texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]);
+ texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]);
+ }
+ else {
+ problem("rgba_dxt5");
}
- else
- _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt5\n");
-}
-
-
-void
-_mesa_fetch_texel_rgba_dxt5(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- /* just sample as GLubyte and convert to float here */
- GLubyte rgba[4];
- fetch_texel_2d_rgba_dxt5(texImage, i, j, k, rgba);
- texel[RCOMP] = UBYTE_TO_FLOAT(rgba[RCOMP]);
- texel[GCOMP] = UBYTE_TO_FLOAT(rgba[GCOMP]);
- texel[BCOMP] = UBYTE_TO_FLOAT(rgba[BCOMP]);
- texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
-}
-
-void
-_mesa_fetch_texel_srgb_dxt1(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- /* just sample as GLubyte and convert to float here */
- GLubyte rgba[4];
- fetch_texel_2d_rgb_dxt1(texImage, i, j, k, rgba);
- texel[RCOMP] = _mesa_nonlinear_to_linear(rgba[RCOMP]);
- texel[GCOMP] = _mesa_nonlinear_to_linear(rgba[GCOMP]);
- texel[BCOMP] = _mesa_nonlinear_to_linear(rgba[BCOMP]);
- texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
}
-void
-_mesa_fetch_texel_srgba_dxt1(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- /* just sample as GLubyte and convert to float here */
- GLubyte rgba[4];
- fetch_texel_2d_rgba_dxt1(texImage, i, j, k, rgba);
- texel[RCOMP] = _mesa_nonlinear_to_linear(rgba[RCOMP]);
- texel[GCOMP] = _mesa_nonlinear_to_linear(rgba[GCOMP]);
- texel[BCOMP] = _mesa_nonlinear_to_linear(rgba[BCOMP]);
- texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
-}
-void
-_mesa_fetch_texel_srgba_dxt3(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
+compressed_fetch_func
+_mesa_get_dxt_fetch_func(gl_format format)
{
- /* just sample as GLubyte and convert to float here */
- GLubyte rgba[4];
- fetch_texel_2d_rgba_dxt3(texImage, i, j, k, rgba);
- texel[RCOMP] = _mesa_nonlinear_to_linear(rgba[RCOMP]);
- texel[GCOMP] = _mesa_nonlinear_to_linear(rgba[GCOMP]);
- texel[BCOMP] = _mesa_nonlinear_to_linear(rgba[BCOMP]);
- texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
-}
-
-void
-_mesa_fetch_texel_srgba_dxt5(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- /* just sample as GLubyte and convert to float here */
- GLubyte rgba[4];
- fetch_texel_2d_rgba_dxt5(texImage, i, j, k, rgba);
- texel[RCOMP] = _mesa_nonlinear_to_linear(rgba[RCOMP]);
- texel[GCOMP] = _mesa_nonlinear_to_linear(rgba[GCOMP]);
- texel[BCOMP] = _mesa_nonlinear_to_linear(rgba[BCOMP]);
- texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
+ switch (format) {
+ case MESA_FORMAT_RGB_DXT1:
+ return fetch_rgb_dxt1;
+ case MESA_FORMAT_RGBA_DXT1:
+ return fetch_rgba_dxt1;
+ case MESA_FORMAT_RGBA_DXT3:
+ return fetch_rgba_dxt3;
+ case MESA_FORMAT_RGBA_DXT5:
+ return fetch_rgba_dxt5;
+ default:
+ return NULL;
+ }
}
diff --git a/mesalib/src/mesa/main/texcompress_s3tc.h b/mesalib/src/mesa/main/texcompress_s3tc.h
index 524ac0c13..d9ef68992 100644
--- a/mesalib/src/mesa/main/texcompress_s3tc.h
+++ b/mesalib/src/mesa/main/texcompress_s3tc.h
@@ -29,9 +29,9 @@
#include "glheader.h"
#include "mfeatures.h"
#include "texstore.h"
+#include "texcompress.h"
struct gl_context;
-struct swrast_texture_image;
extern GLboolean
_mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS);
@@ -45,39 +45,12 @@ _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS);
extern GLboolean
_mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS);
-extern void
-_mesa_fetch_texel_rgb_dxt1(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-extern void
-_mesa_fetch_texel_rgba_dxt1(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-extern void
-_mesa_fetch_texel_rgba_dxt3(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-extern void
-_mesa_fetch_texel_rgba_dxt5(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
extern void
-_mesa_fetch_texel_srgb_dxt1(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-extern void
-_mesa_fetch_texel_srgba_dxt1(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
+_mesa_init_texture_s3tc(struct gl_context *ctx);
-extern void
-_mesa_fetch_texel_srgba_dxt3(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
+extern compressed_fetch_func
+_mesa_get_dxt_fetch_func(gl_format format);
-extern void
-_mesa_fetch_texel_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);
#endif /* TEXCOMPRESS_S3TC_H */
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c
index 83b7e1488..7a0d944fd 100644
--- a/mesalib/src/mesa/main/teximage.c
+++ b/mesalib/src/mesa/main/teximage.c
@@ -791,9 +791,9 @@ _mesa_select_tex_object(struct gl_context *ctx,
case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
return arrayTex ? ctx->Texture.ProxyTex[TEXTURE_2D_ARRAY_INDEX] : NULL;
case GL_TEXTURE_BUFFER:
- return _mesa_is_desktop_gl(ctx)
- && ctx->Extensions.ARB_texture_buffer_object
- ? texUnit->CurrentTex[TEXTURE_BUFFER_INDEX] : NULL;
+ return ctx->API == API_OPENGL_CORE &&
+ ctx->Extensions.ARB_texture_buffer_object ?
+ texUnit->CurrentTex[TEXTURE_BUFFER_INDEX] : NULL;
case GL_TEXTURE_EXTERNAL_OES:
return ctx->Extensions.OES_EGL_image_external
? texUnit->CurrentTex[TEXTURE_EXTERNAL_INDEX] : NULL;
@@ -994,9 +994,8 @@ _mesa_max_texture_levels(struct gl_context *ctx, GLenum target)
return ctx->Extensions.ARB_texture_cube_map_array
? ctx->Const.MaxCubeTextureLevels : 0;
case GL_TEXTURE_BUFFER:
- return _mesa_is_desktop_gl(ctx)
- && ctx->Extensions.ARB_texture_buffer_object
- ? 1 : 0;
+ return ctx->API == API_OPENGL_CORE &&
+ ctx->Extensions.ARB_texture_buffer_object ? 1 : 0;
case GL_TEXTURE_EXTERNAL_OES:
/* fall-through */
default:
@@ -3849,6 +3848,13 @@ get_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat)
case GL_R32UI:
return MESA_FORMAT_R_UINT32;
+ case GL_RGB32F:
+ return MESA_FORMAT_RGB_FLOAT32;
+ case GL_RGB32UI:
+ return MESA_FORMAT_RGB_UINT32;
+ case GL_RGB32I:
+ return MESA_FORMAT_RGB_INT32;
+
default:
return MESA_FORMAT_NONE;
}
@@ -3880,6 +3886,12 @@ validate_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat)
if (base_format == GL_R || base_format == GL_RG)
return MESA_FORMAT_NONE;
}
+
+ if (!ctx->Extensions.ARB_texture_buffer_object_rgb32) {
+ GLenum base_format = _mesa_get_format_base_format(format);
+ if (base_format == GL_RGB)
+ return MESA_FORMAT_NONE;
+ }
return format;
}
@@ -3895,8 +3907,8 @@ _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer)
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- if (!(ctx->Extensions.ARB_texture_buffer_object
- && _mesa_is_desktop_gl(ctx))) {
+ if (!(ctx->API == API_OPENGL_CORE &&
+ ctx->Extensions.ARB_texture_buffer_object)) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glTexBuffer");
return;
}
diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c
index d650c75e4..cb7ac19a8 100644
--- a/mesalib/src/mesa/main/texobj.c
+++ b/mesalib/src/mesa/main/texobj.c
@@ -1148,9 +1148,9 @@ target_enum_to_index(struct gl_context *ctx, GLenum target)
|| _mesa_is_gles3(ctx)
? TEXTURE_2D_ARRAY_INDEX : -1;
case GL_TEXTURE_BUFFER_ARB:
- return _mesa_is_desktop_gl(ctx)
- && ctx->Extensions.ARB_texture_buffer_object
- ? TEXTURE_BUFFER_INDEX : -1;
+ return ctx->API == API_OPENGL_CORE &&
+ ctx->Extensions.ARB_texture_buffer_object ?
+ TEXTURE_BUFFER_INDEX : -1;
case GL_TEXTURE_EXTERNAL_OES:
return _mesa_is_gles(ctx) && ctx->Extensions.OES_EGL_image_external
? TEXTURE_EXTERNAL_INDEX : -1;
diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c
index c2d161f9a..ca5a21f78 100644
--- a/mesalib/src/mesa/main/texparam.c
+++ b/mesalib/src/mesa/main/texparam.c
@@ -976,7 +976,7 @@ legal_get_tex_level_parameter_target(struct gl_context *ctx, GLenum target)
* From the OpenGL 3.1 spec:
* "target may also be TEXTURE_BUFFER, indicating the texture buffer."
*/
- return _mesa_is_desktop_gl(ctx) && ctx->Version >= 31;
+ return ctx->API == API_OPENGL_CORE && ctx->Version >= 31;
default:
return GL_FALSE;
}
diff --git a/mesalib/src/mesa/main/uniform_query.cpp b/mesalib/src/mesa/main/uniform_query.cpp
index c71577c6e..b6b73d16f 100644
--- a/mesalib/src/mesa/main/uniform_query.cpp
+++ b/mesalib/src/mesa/main/uniform_query.cpp
@@ -97,12 +97,16 @@ _mesa_GetActiveUniformsiv(GLuint program,
for (i = 0; i < uniformCount; i++) {
GLuint index = uniformIndices[i];
- const struct gl_uniform_storage *uni = &shProg->UniformStorage[index];
if (index >= shProg->NumUserUniformStorage) {
_mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveUniformsiv(index)");
return;
}
+ }
+
+ for (i = 0; i < uniformCount; i++) {
+ GLuint index = uniformIndices[i];
+ const struct gl_uniform_storage *uni = &shProg->UniformStorage[index];
switch (pname) {
case GL_UNIFORM_TYPE:
diff --git a/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c
index 3f156bf10..77b195edb 100644
--- a/mesalib/src/mesa/main/uniforms.c
+++ b/mesalib/src/mesa/main/uniforms.c
@@ -614,14 +614,14 @@ _mesa_UniformBlockBinding(GLuint program,
if (uniformBlockIndex >= shProg->NumUniformBlocks) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glUniformBlockBinding(block index %d >= %d)",
+ "glUniformBlockBinding(block index %u >= %u)",
uniformBlockIndex, shProg->NumUniformBlocks);
return;
}
if (uniformBlockBinding >= ctx->Const.MaxUniformBufferBindings) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glUniformBlockBinding(block binding %d >= %d)",
+ "glUniformBlockBinding(block binding %u >= %u)",
uniformBlockBinding, ctx->Const.MaxUniformBufferBindings);
return;
}
@@ -667,7 +667,7 @@ _mesa_GetActiveUniformBlockiv(GLuint program,
if (uniformBlockIndex >= shProg->NumUniformBlocks) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glGetActiveUniformBlockiv(block index %d >= %d)",
+ "glGetActiveUniformBlockiv(block index %u >= %u)",
uniformBlockIndex, shProg->NumUniformBlocks);
return;
}
@@ -750,7 +750,7 @@ _mesa_GetActiveUniformBlockName(GLuint program,
if (uniformBlockIndex >= shProg->NumUniformBlocks) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glGetActiveUniformBlockiv(block index %d >= %d)",
+ "glGetActiveUniformBlockiv(block index %u >= %u)",
uniformBlockIndex, shProg->NumUniformBlocks);
return;
}
diff --git a/mesalib/src/mesa/main/varray.c b/mesalib/src/mesa/main/varray.c
index f77014397..5e4d6c3e6 100644
--- a/mesalib/src/mesa/main/varray.c
+++ b/mesalib/src/mesa/main/varray.c
@@ -251,7 +251,8 @@ update_array(struct gl_context *ctx,
return;
}
- elementSize = _mesa_sizeof_type(type) * size;
+ elementSize = _mesa_bytes_per_vertex_attrib(size, type);
+ assert(elementSize != -1);
array = &ctx->Array.ArrayObj->VertexAttrib[attrib];
array->Size = size;
diff --git a/mesalib/src/mesa/main/version.c b/mesalib/src/mesa/main/version.c
index cfaf4bbda..91234e4d7 100644
--- a/mesalib/src/mesa/main/version.c
+++ b/mesalib/src/mesa/main/version.c
@@ -345,6 +345,12 @@ _mesa_compute_version(struct gl_context *ctx)
switch (ctx->API) {
case API_OPENGL_COMPAT:
+ /* Disable GLSL 1.40 and later for legacy contexts.
+ * This disallows creation of the GL 3.1 compatibility context. */
+ if (ctx->Const.GLSLVersion > 130) {
+ ctx->Const.GLSLVersion = 130;
+ }
+ /* fall through */
case API_OPENGL_CORE:
compute_version(ctx);
break;
diff --git a/mesalib/src/mesa/main/vtxfmt.c b/mesalib/src/mesa/main/vtxfmt.c
index 674edb5e1..6d687de60 100644
--- a/mesalib/src/mesa/main/vtxfmt.c
+++ b/mesalib/src/mesa/main/vtxfmt.c
@@ -36,6 +36,7 @@
#include "eval.h"
#include "dlist.h"
#include "main/dispatch.h"
+#include "vbo/vbo_context.h"
/**
@@ -46,6 +47,8 @@ static void
install_vtxfmt(struct gl_context *ctx, struct _glapi_table *tab,
const GLvertexformat *vfmt)
{
+ assert(ctx->Version > 0);
+
if (ctx->API != API_OPENGL_CORE && ctx->API != API_OPENGLES2) {
SET_Color4f(tab, vfmt->Color4f);
}
@@ -262,3 +265,20 @@ _mesa_install_save_vtxfmt(struct gl_context *ctx, const GLvertexformat *vfmt)
if (_mesa_is_desktop_gl(ctx))
install_vtxfmt( ctx, ctx->Save, vfmt );
}
+
+
+/**
+ * Install VBO vtxfmt functions.
+ *
+ * This function depends on ctx->Version.
+ */
+void
+_mesa_initialize_vbo_vtxfmt(struct gl_context *ctx)
+{
+ struct vbo_exec_context *exec = &vbo_context(ctx)->exec;
+ _mesa_install_exec_vtxfmt(ctx, &exec->vtxfmt);
+ if (ctx->API == API_OPENGL_COMPAT) {
+ _mesa_install_save_vtxfmt(ctx, &ctx->ListState.ListVtxfmt);
+ }
+}
+
diff --git a/mesalib/src/mesa/main/vtxfmt.h b/mesalib/src/mesa/main/vtxfmt.h
index 65a0e6c8e..16ffb6ffd 100644
--- a/mesalib/src/mesa/main/vtxfmt.h
+++ b/mesalib/src/mesa/main/vtxfmt.h
@@ -39,5 +39,6 @@
extern void _mesa_install_exec_vtxfmt( struct gl_context *ctx, const GLvertexformat *vfmt );
extern void _mesa_install_save_vtxfmt( struct gl_context *ctx, const GLvertexformat *vfmt );
+extern void _mesa_initialize_vbo_vtxfmt(struct gl_context *ctx);
#endif /* _VTXFMT_H_ */