aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa
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
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')
-rw-r--r--mesalib/src/mesa/Android.libmesa_glsl_utils.mk4
-rwxr-xr-x[-rw-r--r--]mesalib/src/mesa/drivers/dri/swrast/swrast.c8
-rw-r--r--mesalib/src/mesa/drivers/windows/gdi/wmesa.c7
-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
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_framebuffer.c1
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_rasterizer.c3
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_condrender.c11
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_eglimage.c8
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_fbo.c3
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_texture.c14
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.c25
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.h8
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c33
-rw-r--r--mesalib/src/mesa/state_tracker/st_gen_mipmap.c9
-rw-r--r--mesalib/src/mesa/state_tracker/st_manager.c17
-rw-r--r--mesalib/src/mesa/state_tracker/st_manager.h3
-rw-r--r--mesalib/src/mesa/swrast/s_context.h4
-rw-r--r--mesalib/src/mesa/swrast/s_texfetch.c237
-rw-r--r--mesalib/src/mesa/swrast/s_texfetch.h3
-rw-r--r--mesalib/src/mesa/vbo/vbo_exec.c4
-rw-r--r--mesalib/src/mesa/vbo/vbo_exec_api.c4
-rw-r--r--mesalib/src/mesa/vbo/vbo_save_api.c1
48 files changed, 840 insertions, 889 deletions
diff --git a/mesalib/src/mesa/Android.libmesa_glsl_utils.mk b/mesalib/src/mesa/Android.libmesa_glsl_utils.mk
index 9beeda57f..9c5f3493c 100644
--- a/mesalib/src/mesa/Android.libmesa_glsl_utils.mk
+++ b/mesalib/src/mesa/Android.libmesa_glsl_utils.mk
@@ -35,6 +35,8 @@ include $(CLEAR_VARS)
LOCAL_MODULE := libmesa_glsl_utils
+LOCAL_C_INCLUDES := $(MESA_TOP)/src/glsl
+
LOCAL_SRC_FILES := \
main/hash_table.c \
program/prog_hash_table.c \
@@ -52,6 +54,8 @@ include $(CLEAR_VARS)
LOCAL_MODULE := libmesa_glsl_utils
LOCAL_IS_HOST_MODULE := true
+LOCAL_C_INCLUDES := $(MESA_TOP)/src/glsl
+
LOCAL_SRC_FILES := \
main/hash_table.c \
program/prog_hash_table.c \
diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast.c b/mesalib/src/mesa/drivers/dri/swrast/swrast.c
index 005ab08d4..c6b2f0df7 100644..100755
--- a/mesalib/src/mesa/drivers/dri/swrast/swrast.c
+++ b/mesalib/src/mesa/drivers/dri/swrast/swrast.c
@@ -36,12 +36,15 @@
#include <windows.h>
#endif
+#include "main/api_exec.h"
#include "main/context.h"
#include "main/extensions.h"
#include "main/formats.h"
#include "main/framebuffer.h"
#include "main/imports.h"
#include "main/renderbuffer.h"
+#include "main/version.h"
+#include "main/vtxfmt.h"
#include "swrast/swrast.h"
#include "swrast/s_renderbuffer.h"
#include "swrast_setup/swrast_setup.h"
@@ -791,6 +794,11 @@ dri_create_context(gl_api api,
break;
}
+ _mesa_compute_version(mesaCtx);
+
+ _mesa_initialize_exec_table(mesaCtx);
+ _mesa_initialize_vbo_vtxfmt(mesaCtx);
+
*error = __DRI_CTX_ERROR_SUCCESS;
return GL_TRUE;
diff --git a/mesalib/src/mesa/drivers/windows/gdi/wmesa.c b/mesalib/src/mesa/drivers/windows/gdi/wmesa.c
index 50347cf77..af9ae6be6 100644
--- a/mesalib/src/mesa/drivers/windows/gdi/wmesa.c
+++ b/mesalib/src/mesa/drivers/windows/gdi/wmesa.c
@@ -12,6 +12,7 @@
#include "main/framebuffer.h"
#include "main/renderbuffer.h"
#include "main/macros.h"
+#include "main/vtxfmt.h"
#include "drivers/common/driverfuncs.h"
#include "drivers/common/meta.h"
#include "vbo/vbo.h"
@@ -637,6 +638,12 @@ WMesaContext WMesaCreateContext(HDC hDC,
_swsetup_Wakeup(ctx);
TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline;
+ _mesa_compute_version(ctx);
+
+ /* Exec table initialization requires the version to be computed */
+ _mesa_initialize_exec_table(ctx);
+ _mesa_initialize_vbo_vtxfmt(ctx);
+
return c;
}
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_ */
diff --git a/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c b/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c
index a10dbfbd0..3df8691f4 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c
@@ -71,7 +71,6 @@ update_renderbuffer_surface(struct st_context *st,
struct pipe_surface surf_tmpl;
memset(&surf_tmpl, 0, sizeof(surf_tmpl));
surf_tmpl.format = format;
- surf_tmpl.usage = PIPE_BIND_RENDER_TARGET;
surf_tmpl.u.tex.level = level;
surf_tmpl.u.tex.first_layer = strb->rtt_face + strb->rtt_slice;
surf_tmpl.u.tex.last_layer = strb->rtt_face + strb->rtt_slice;
diff --git a/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c b/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c
index d9e9d21f6..f20df9e9b 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c
@@ -230,8 +230,7 @@ static void update_raster_state( struct st_context *st )
raster->line_stipple_factor = ctx->Line.StippleFactor - 1;
/* _NEW_MULTISAMPLE */
- if (ctx->Multisample._Enabled || st->force_msaa)
- raster->multisample = 1;
+ raster->multisample = ctx->Multisample._Enabled;
/* _NEW_SCISSOR */
if (ctx->Scissor.Enabled)
diff --git a/mesalib/src/mesa/state_tracker/st_cb_condrender.c b/mesalib/src/mesa/state_tracker/st_cb_condrender.c
index 1ced560e1..3a5835ecd 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_condrender.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_condrender.c
@@ -38,6 +38,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
+#include "cso_cache/cso_context.h"
#include "st_context.h"
#include "st_cb_queryobj.h"
#include "st_cb_condrender.h"
@@ -53,7 +54,6 @@ st_BeginConditionalRender(struct gl_context *ctx, struct gl_query_object *q,
{
struct st_query_object *stq = st_query_object(q);
struct st_context *st = st_context(ctx);
- struct pipe_context *pipe = st->pipe;
uint m;
st_flush_bitmap_cache(st);
@@ -76,10 +76,7 @@ st_BeginConditionalRender(struct gl_context *ctx, struct gl_query_object *q,
m = PIPE_RENDER_COND_WAIT;
}
- st->render_condition = stq->pq;
- st->condition_mode = m;
-
- pipe->render_condition(pipe, stq->pq, m);
+ cso_set_render_condition(st->cso_context, stq->pq, m);
}
@@ -90,13 +87,11 @@ static void
st_EndConditionalRender(struct gl_context *ctx, struct gl_query_object *q)
{
struct st_context *st = st_context(ctx);
- struct pipe_context *pipe = st->pipe;
(void) q;
st_flush_bitmap_cache(st);
- pipe->render_condition(pipe, NULL, 0);
- st->render_condition = NULL;
+ cso_set_render_condition(st->cso_context, NULL, 0);
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_eglimage.c b/mesalib/src/mesa/state_tracker/st_cb_eglimage.c
index 0679e7d44..8c78e5ef4 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_eglimage.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_eglimage.c
@@ -76,10 +76,8 @@ st_egl_image_target_renderbuffer_storage(struct gl_context *ctx,
struct st_context *st = st_context(ctx);
struct st_renderbuffer *strb = st_renderbuffer(rb);
struct pipe_surface *ps;
- unsigned usage;
- usage = PIPE_BIND_RENDER_TARGET;
- ps = st_manager_get_egl_image_surface(st, (void *) image_handle, usage);
+ ps = st_manager_get_egl_image_surface(st, (void *) image_handle);
if (ps) {
strb->Base.Width = ps->width;
strb->Base.Height = ps->height;
@@ -146,10 +144,8 @@ st_egl_image_target_texture_2d(struct gl_context *ctx, GLenum target,
{
struct st_context *st = st_context(ctx);
struct pipe_surface *ps;
- unsigned usage;
- usage = PIPE_BIND_SAMPLER_VIEW;
- ps = st_manager_get_egl_image_surface(st, (void *) image_handle, usage);
+ ps = st_manager_get_egl_image_surface(st, (void *) image_handle);
if (ps) {
st_bind_surface(ctx, target, texObj, texImage, ps);
pipe_surface_reference(&ps, NULL);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.c b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
index ae280bfa9..bf206b025 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_fbo.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
@@ -206,7 +206,7 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx,
if (!strb->texture)
return FALSE;
- u_surface_default_template(&surf_tmpl, strb->texture, templ.bind);
+ u_surface_default_template(&surf_tmpl, strb->texture);
strb->surface = pipe->create_surface(pipe,
strb->texture,
&surf_tmpl);
@@ -444,7 +444,6 @@ st_render_texture(struct gl_context *ctx,
memset(&surf_tmpl, 0, sizeof(surf_tmpl));
surf_tmpl.format = ctx->Color.sRGBEnabled
? strb->texture->format : util_format_linear(strb->texture->format);
- surf_tmpl.usage = PIPE_BIND_RENDER_TARGET;
surf_tmpl.u.tex.level = strb->rtt_level;
surf_tmpl.u.tex.first_layer = strb->rtt_face + strb->rtt_slice;
surf_tmpl.u.tex.last_layer = strb->rtt_face + strb->rtt_slice;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c
index ae069eb2c..bf13526d2 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c
@@ -60,7 +60,6 @@
#include "pipe/p_shader_tokens.h"
#include "util/u_tile.h"
#include "util/u_blit.h"
-#include "util/u_blitter.h"
#include "util/u_format.h"
#include "util/u_surface.h"
#include "util/u_sampler.h"
@@ -1089,14 +1088,8 @@ st_CopyTexSubImage(struct gl_context *ctx, GLuint dims,
goto fallback;
}
- /* Disable conditional rendering. */
- if (st->render_condition) {
- pipe->render_condition(pipe, NULL, 0);
- }
-
memset(&surf_tmpl, 0, sizeof(surf_tmpl));
surf_tmpl.format = util_format_linear(stImage->pt->format);
- surf_tmpl.usage = dst_usage;
surf_tmpl.u.tex.level = stImage->base.Level;
surf_tmpl.u.tex.first_layer = stImage->base.Face + destZ;
surf_tmpl.u.tex.last_layer = stImage->base.Face + destZ;
@@ -1115,13 +1108,6 @@ st_CopyTexSubImage(struct gl_context *ctx, GLuint dims,
0.0, PIPE_TEX_MIPFILTER_NEAREST,
color_writemask, 0);
pipe_surface_reference(&dest_surface, NULL);
-
- /* Restore conditional rendering state. */
- if (st->render_condition) {
- pipe->render_condition(pipe, st->render_condition,
- st->condition_mode);
- }
-
return;
fallback:
diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c
index 69bd50336..368a30b68 100644
--- a/mesalib/src/mesa/state_tracker/st_context.c
+++ b/mesalib/src/mesa/state_tracker/st_context.c
@@ -27,9 +27,12 @@
#include "main/imports.h"
#include "main/accum.h"
+#include "main/api_exec.h"
#include "main/context.h"
#include "main/samplerobj.h"
#include "main/shaderobj.h"
+#include "main/version.h"
+#include "main/vtxfmt.h"
#include "program/prog_cache.h"
#include "vbo/vbo.h"
#include "glapi/glapi.h"
@@ -97,22 +100,6 @@ void st_invalidate_state(struct gl_context * ctx, GLuint new_state)
_vbo_InvalidateState(ctx, new_state);
}
-
-/**
- * Check for multisample env var override.
- */
-int
-st_get_msaa(void)
-{
- const char *msaa = _mesa_getenv("__GL_FSAA_MODE");
- if (msaa)
- return atoi(msaa);
- return 0;
-}
-
-
-
-
static struct st_context *
st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe,
const struct st_config_options *options)
@@ -193,7 +180,6 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe,
st->pixel_xfer.cache = _mesa_new_program_cache();
- st->force_msaa = st_get_msaa();
st->has_stencil_export =
screen->get_param(screen, PIPE_CAP_SHADER_STENCIL_EXPORT);
@@ -201,6 +187,11 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe,
st_init_limits(st);
st_init_extensions(st);
+ _mesa_compute_version(ctx);
+
+ _mesa_initialize_exec_table(ctx);
+ _mesa_initialize_vbo_vtxfmt(ctx);
+
return st;
}
diff --git a/mesalib/src/mesa/state_tracker/st_context.h b/mesalib/src/mesa/state_tracker/st_context.h
index 2cc52773e..eeb7f0c4f 100644
--- a/mesalib/src/mesa/state_tracker/st_context.h
+++ b/mesalib/src/mesa/state_tracker/st_context.h
@@ -185,16 +185,11 @@ struct st_context
struct cso_context *cso_context;
- int force_msaa;
void *winsys_drawable_handle;
/* The number of vertex buffers from the last call of validate_arrays. */
unsigned last_num_vbuffers;
- /* Active render condition. */
- struct pipe_query *render_condition;
- unsigned condition_mode;
-
int32_t draw_stamp;
int32_t read_stamp;
@@ -265,9 +260,6 @@ st_fb_orientation(const struct gl_framebuffer *fb)
#define ST_CALLOC_STRUCT(T) (struct T *) calloc(1, sizeof(struct T))
-extern int
-st_get_msaa(void);
-
extern struct st_context *
st_create_context(gl_api api, struct pipe_context *pipe,
const struct gl_config *visual,
diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index 93ef7a91c..262cc3d6c 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -494,6 +494,14 @@ void st_init_extensions(struct st_context *st)
PIPE_FORMAT_B10G10R10A2_SSCALED } },
};
+ static const struct st_extension_format_mapping tbo_rgb32[] = {
+ { {o(ARB_texture_buffer_object_rgb32) },
+ { PIPE_FORMAT_R32G32B32_FLOAT,
+ PIPE_FORMAT_R32G32B32_UINT,
+ PIPE_FORMAT_R32G32B32_SINT,
+ } },
+ };
+
/*
* Extensions that are supported by all Gallium drivers:
*/
@@ -570,10 +578,7 @@ void st_init_extensions(struct st_context *st)
glsl_feature_level = screen->get_param(screen, PIPE_CAP_GLSL_FEATURE_LEVEL);
if (glsl_feature_level >= 140) {
- if (ctx->API == API_OPENGL_CORE)
- ctx->Const.GLSLVersion = 140;
- else
- ctx->Const.GLSLVersion = 130;
+ ctx->Const.GLSLVersion = 140;
} else if (glsl_feature_level >= 130) {
ctx->Const.GLSLVersion = 130;
} else {
@@ -664,6 +669,24 @@ void st_init_extensions(struct st_context *st)
if (ctx->Const.MinMapBufferAlignment >= 64) {
ctx->Extensions.ARB_map_buffer_alignment = GL_TRUE;
}
- if (screen->get_param(screen, PIPE_CAP_TEXTURE_BUFFER_OBJECTS))
+ if (screen->get_param(screen, PIPE_CAP_TEXTURE_BUFFER_OBJECTS)) {
ctx->Extensions.ARB_texture_buffer_object = GL_TRUE;
+ init_format_extensions(st, tbo_rgb32, Elements(tbo_rgb32),
+ PIPE_BUFFER, PIPE_BIND_SAMPLER_VIEW);
+ }
+
+
+ /* Unpacking a varying in the fragment shader costs 1 texture indirection.
+ * If the number of available texture indirections is very limited, then we
+ * prefer to disable varying packing rather than run the risk of varying
+ * packing preventing a shader from running.
+ */
+ if (screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
+ PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS) <= 8) {
+ /* We can't disable varying packing if transform feedback is available,
+ * because transform feedback code assumes a packed varying layout.
+ */
+ if (!ctx->Extensions.EXT_transform_feedback)
+ ctx->Const.DisableVaryingPacking = GL_TRUE;
+ }
}
diff --git a/mesalib/src/mesa/state_tracker/st_gen_mipmap.c b/mesalib/src/mesa/state_tracker/st_gen_mipmap.c
index c09261312..8ce2e06a2 100644
--- a/mesalib/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/mesalib/src/mesa/state_tracker/st_gen_mipmap.c
@@ -93,18 +93,9 @@ st_render_mipmap(struct st_context *st,
psv = st_create_texture_sampler_view(pipe, stObj->pt);
- /* Disable conditional rendering. */
- if (st->render_condition) {
- pipe->render_condition(pipe, NULL, 0);
- }
-
util_gen_mipmap(st->gen_mipmap, psv, face, baseLevel, lastLevel,
PIPE_TEX_FILTER_LINEAR);
- if (st->render_condition) {
- pipe->render_condition(pipe, st->render_condition, st->condition_mode);
- }
-
pipe_sampler_view_reference(&psv, NULL);
return TRUE;
diff --git a/mesalib/src/mesa/state_tracker/st_manager.c b/mesalib/src/mesa/state_tracker/st_manager.c
index b065db0ac..30f5ca5ed 100644
--- a/mesalib/src/mesa/state_tracker/st_manager.c
+++ b/mesalib/src/mesa/state_tracker/st_manager.c
@@ -224,8 +224,7 @@ st_framebuffer_validate(struct st_framebuffer *stfb,
continue;
}
- u_surface_default_template(&surf_tmpl, textures[i],
- PIPE_BIND_RENDER_TARGET);
+ u_surface_default_template(&surf_tmpl, textures[i]);
ps = st->pipe->create_surface(st->pipe, textures[i], &surf_tmpl);
if (ps) {
pipe_surface_reference(&strb->surface, ps);
@@ -285,7 +284,6 @@ st_framebuffer_add_renderbuffer(struct st_framebuffer *stfb,
{
struct gl_renderbuffer *rb;
enum pipe_format format;
- int samples;
boolean sw;
if (!stfb->iface)
@@ -313,11 +311,7 @@ st_framebuffer_add_renderbuffer(struct st_framebuffer *stfb,
if (format == PIPE_FORMAT_NONE)
return FALSE;
- samples = stfb->iface->visual->samples;
- if (!samples)
- samples = st_get_msaa();
-
- rb = st_new_renderbuffer_fb(format, samples, sw);
+ rb = st_new_renderbuffer_fb(format, stfb->iface->visual->samples, sw);
if (!rb)
return FALSE;
@@ -653,8 +647,6 @@ st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
/* need to perform version check */
if (attribs->major > 1 || attribs->minor > 0) {
- _mesa_compute_version(st->ctx);
-
/* Is the actual version less than the requested version?
*/
if (st->ctx->Version < attribs->major * 10 + attribs->minor) {
@@ -797,8 +789,7 @@ st_manager_flush_frontbuffer(struct st_context *st)
* FIXME: I think this should operate on resources, not surfaces
*/
struct pipe_surface *
-st_manager_get_egl_image_surface(struct st_context *st,
- void *eglimg, unsigned usage)
+st_manager_get_egl_image_surface(struct st_context *st, void *eglimg)
{
struct st_manager *smapi =
(struct st_manager *) st->iface.st_context_private;
@@ -812,7 +803,7 @@ st_manager_get_egl_image_surface(struct st_context *st,
if (!smapi->get_egl_image(smapi, eglimg, &stimg))
return NULL;
- u_surface_default_template(&surf_tmpl, stimg.texture, usage);
+ u_surface_default_template(&surf_tmpl, stimg.texture);
surf_tmpl.u.tex.level = stimg.level;
surf_tmpl.u.tex.first_layer = stimg.layer;
surf_tmpl.u.tex.last_layer = stimg.layer;
diff --git a/mesalib/src/mesa/state_tracker/st_manager.h b/mesalib/src/mesa/state_tracker/st_manager.h
index 6a9497839..f729cff1f 100644
--- a/mesalib/src/mesa/state_tracker/st_manager.h
+++ b/mesalib/src/mesa/state_tracker/st_manager.h
@@ -36,8 +36,7 @@
struct st_context;
struct pipe_surface *
-st_manager_get_egl_image_surface(struct st_context *st,
- void *eglimg, unsigned usage);
+st_manager_get_egl_image_surface(struct st_context *st, void *eglimg);
void
st_manager_flush_frontbuffer(struct st_context *st);
diff --git a/mesalib/src/mesa/swrast/s_context.h b/mesalib/src/mesa/swrast/s_context.h
index 18353c416..f3f188e47 100644
--- a/mesalib/src/mesa/swrast/s_context.h
+++ b/mesalib/src/mesa/swrast/s_context.h
@@ -45,6 +45,7 @@
#include "main/compiler.h"
#include "main/mtypes.h"
+#include "main/texcompress.h"
#include "program/prog_execute.h"
#include "swrast.h"
#include "s_fragprog.h"
@@ -146,6 +147,9 @@ struct swrast_texture_image
GLubyte *Buffer;
FetchTexelFunc FetchTexel;
+
+ /** For fetching texels from compressed textures */
+ compressed_fetch_func FetchCompressedTexel;
};
diff --git a/mesalib/src/mesa/swrast/s_texfetch.c b/mesalib/src/mesa/swrast/s_texfetch.c
index 86b01a0b3..1f1964172 100644
--- a/mesalib/src/mesa/swrast/s_texfetch.c
+++ b/mesalib/src/mesa/swrast/s_texfetch.c
@@ -88,6 +88,23 @@ nonlinear_to_linear(GLubyte cs8)
#define DIM 3
#include "s_texfetch_tmp.h"
+
+/**
+ * All compressed texture texel fetching is done though this function.
+ * Basically just call a core-Mesa texel fetch function.
+ */
+static void
+fetch_compressed(const struct swrast_texture_image *swImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ swImage->FetchCompressedTexel(swImage->Map,
+ swImage->ImageOffsets,
+ swImage->RowStride,
+ i, j, k, texel);
+}
+
+
+
/**
* Null texel fetch function.
*
@@ -426,64 +443,64 @@ texfetch_funcs[] =
},
{
MESA_FORMAT_SRGB_DXT1,
- _mesa_fetch_texel_srgb_dxt1,
- _mesa_fetch_texel_srgb_dxt1,
- _mesa_fetch_texel_srgb_dxt1
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_SRGBA_DXT1,
- _mesa_fetch_texel_srgba_dxt1,
- _mesa_fetch_texel_srgba_dxt1,
- _mesa_fetch_texel_srgba_dxt1
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_SRGBA_DXT3,
- _mesa_fetch_texel_srgba_dxt3,
- _mesa_fetch_texel_srgba_dxt3,
- _mesa_fetch_texel_srgba_dxt3
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_SRGBA_DXT5,
- _mesa_fetch_texel_srgba_dxt5,
- _mesa_fetch_texel_srgba_dxt5,
- _mesa_fetch_texel_srgba_dxt5
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_RGB_FXT1,
- NULL,
- _mesa_fetch_texel_2d_f_rgb_fxt1,
- NULL
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_RGBA_FXT1,
- NULL,
- _mesa_fetch_texel_2d_f_rgba_fxt1,
- NULL
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_RGB_DXT1,
- _mesa_fetch_texel_rgb_dxt1,
- _mesa_fetch_texel_rgb_dxt1,
- _mesa_fetch_texel_rgb_dxt1
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_RGBA_DXT1,
- _mesa_fetch_texel_rgba_dxt1,
- _mesa_fetch_texel_rgba_dxt1,
- _mesa_fetch_texel_rgba_dxt1
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_RGBA_DXT3,
- _mesa_fetch_texel_rgba_dxt3,
- _mesa_fetch_texel_rgba_dxt3,
- _mesa_fetch_texel_rgba_dxt3
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_RGBA_DXT5,
- _mesa_fetch_texel_rgba_dxt5,
- _mesa_fetch_texel_rgba_dxt5,
- _mesa_fetch_texel_rgba_dxt5
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_RGBA_FLOAT32,
@@ -976,117 +993,117 @@ texfetch_funcs[] =
},
{
MESA_FORMAT_RED_RGTC1,
- _mesa_fetch_texel_red_rgtc1,
- _mesa_fetch_texel_red_rgtc1,
- _mesa_fetch_texel_red_rgtc1
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_SIGNED_RED_RGTC1,
- _mesa_fetch_texel_signed_red_rgtc1,
- _mesa_fetch_texel_signed_red_rgtc1,
- _mesa_fetch_texel_signed_red_rgtc1
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_RG_RGTC2,
- _mesa_fetch_texel_rg_rgtc2,
- _mesa_fetch_texel_rg_rgtc2,
- _mesa_fetch_texel_rg_rgtc2
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_SIGNED_RG_RGTC2,
- _mesa_fetch_texel_signed_rg_rgtc2,
- _mesa_fetch_texel_signed_rg_rgtc2,
- _mesa_fetch_texel_signed_rg_rgtc2
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_L_LATC1,
- _mesa_fetch_texel_l_latc1,
- _mesa_fetch_texel_l_latc1,
- _mesa_fetch_texel_l_latc1
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_SIGNED_L_LATC1,
- _mesa_fetch_texel_signed_l_latc1,
- _mesa_fetch_texel_signed_l_latc1,
- _mesa_fetch_texel_signed_l_latc1
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_LA_LATC2,
- _mesa_fetch_texel_la_latc2,
- _mesa_fetch_texel_la_latc2,
- _mesa_fetch_texel_la_latc2
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_SIGNED_LA_LATC2,
- _mesa_fetch_texel_signed_la_latc2,
- _mesa_fetch_texel_signed_la_latc2,
- _mesa_fetch_texel_signed_la_latc2
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_ETC1_RGB8,
- NULL,
- _mesa_fetch_texel_2d_f_etc1_rgb8,
- NULL
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_ETC2_RGB8,
- NULL,
- _mesa_fetch_texel_2d_f_etc2_rgb8,
- NULL
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_ETC2_SRGB8,
- NULL,
- _mesa_fetch_texel_2d_f_etc2_srgb8,
- NULL
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_ETC2_RGBA8_EAC,
- NULL,
- _mesa_fetch_texel_2d_f_etc2_rgba8_eac,
- NULL
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC,
- NULL,
- _mesa_fetch_texel_2d_f_etc2_srgb8_alpha8_eac,
- NULL
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_ETC2_R11_EAC,
- NULL,
- _mesa_fetch_texel_2d_f_etc2_r11_eac,
- NULL
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_ETC2_RG11_EAC,
- NULL,
- _mesa_fetch_texel_2d_f_etc2_rg11_eac,
- NULL
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_ETC2_SIGNED_R11_EAC,
- NULL,
- _mesa_fetch_texel_2d_f_etc2_signed_r11_eac,
- NULL
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_ETC2_SIGNED_RG11_EAC,
- NULL,
- _mesa_fetch_texel_2d_f_etc2_signed_rg11_eac,
- NULL
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1,
- NULL,
- _mesa_fetch_texel_2d_f_etc2_rgb8_punchthrough_alpha1,
- NULL
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1,
- NULL,
- _mesa_fetch_texel_2d_f_etc2_srgb8_punchthrough_alpha1,
- NULL
+ fetch_compressed,
+ fetch_compressed,
+ fetch_compressed
},
{
MESA_FORMAT_SIGNED_A8,
@@ -1175,9 +1192,15 @@ texfetch_funcs[] =
};
-FetchTexelFunc
-_mesa_get_texel_fetch_func(gl_format format, GLuint dims)
+/**
+ * Initialize the texture image's FetchTexel methods.
+ */
+static void
+set_fetch_functions(const struct gl_sampler_object *samp,
+ struct swrast_texture_image *texImage, GLuint dims)
{
+ gl_format format = texImage->Base.TexFormat;
+
#ifdef DEBUG
/* check that the table entries are sorted by format name */
gl_format fmt;
@@ -1188,39 +1211,29 @@ _mesa_get_texel_fetch_func(gl_format format, GLuint dims)
STATIC_ASSERT(Elements(texfetch_funcs) == MESA_FORMAT_COUNT);
+ if (samp->sRGBDecode == GL_SKIP_DECODE_EXT &&
+ _mesa_get_format_color_encoding(format) == GL_SRGB) {
+ format = _mesa_get_srgb_format_linear(format);
+ }
+
assert(format < MESA_FORMAT_COUNT);
switch (dims) {
case 1:
- return texfetch_funcs[format].Fetch1D;
+ texImage->FetchTexel = texfetch_funcs[format].Fetch1D;
+ break;
case 2:
- return texfetch_funcs[format].Fetch2D;
+ texImage->FetchTexel = texfetch_funcs[format].Fetch2D;
+ break;
case 3:
- return texfetch_funcs[format].Fetch3D;
+ texImage->FetchTexel = texfetch_funcs[format].Fetch3D;
+ break;
default:
- assert(0 && "bad dims in _mesa_get_texel_fetch_func");
- return NULL;
+ assert(!"Bad dims in set_fetch_functions()");
}
-}
-
-/**
- * Initialize the texture image's FetchTexel methods.
- */
-static void
-set_fetch_functions(struct gl_sampler_object *samp,
- struct swrast_texture_image *texImage, GLuint dims)
-{
- gl_format format = texImage->Base.TexFormat;
-
- ASSERT(dims == 1 || dims == 2 || dims == 3);
-
- if (samp->sRGBDecode == GL_SKIP_DECODE_EXT &&
- _mesa_get_format_color_encoding(format) == GL_SRGB) {
- format = _mesa_get_srgb_format_linear(format);
- }
+ texImage->FetchCompressedTexel = _mesa_get_compressed_fetch_func(format);
- texImage->FetchTexel = _mesa_get_texel_fetch_func(format, dims);
ASSERT(texImage->FetchTexel);
}
diff --git a/mesalib/src/mesa/swrast/s_texfetch.h b/mesalib/src/mesa/swrast/s_texfetch.h
index 33950ce44..4e4397e13 100644
--- a/mesalib/src/mesa/swrast/s_texfetch.h
+++ b/mesalib/src/mesa/swrast/s_texfetch.h
@@ -29,9 +29,6 @@
#include "swrast/s_context.h"
-extern FetchTexelFunc
-_mesa_get_texel_fetch_func(gl_format format, GLuint dims);
-
void
_mesa_update_fetch_functions(struct gl_context *ctx, GLuint unit);
diff --git a/mesalib/src/mesa/vbo/vbo_exec.c b/mesalib/src/mesa/vbo/vbo_exec.c
index 81a4d25ff..361d7a3e4 100644
--- a/mesalib/src/mesa/vbo/vbo_exec.c
+++ b/mesalib/src/mesa/vbo/vbo_exec.c
@@ -49,10 +49,6 @@ void vbo_exec_init( struct gl_context *ctx )
vbo_exec_vtx_init( exec );
vbo_exec_array_init( exec );
- /* Hook our functions into exec and compile dispatch tables.
- */
- _mesa_install_exec_vtxfmt( ctx, &exec->vtxfmt );
-
ctx->Driver.NeedFlush = 0;
ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END;
ctx->Driver.BeginVertices = vbo_exec_BeginVertices;
diff --git a/mesalib/src/mesa/vbo/vbo_exec_api.c b/mesalib/src/mesa/vbo/vbo_exec_api.c
index 2aaa2895c..657c9aaee 100644
--- a/mesalib/src/mesa/vbo/vbo_exec_api.c
+++ b/mesalib/src/mesa/vbo/vbo_exec_api.c
@@ -1120,10 +1120,6 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec )
vbo_exec_vtxfmt_init( exec );
_mesa_noop_vtxfmt_init(&exec->vtxfmt_noop);
- /* Hook our functions into the dispatch table.
- */
- _mesa_install_exec_vtxfmt( ctx, &exec->vtxfmt );
-
for (i = 0 ; i < VBO_ATTRIB_MAX ; i++) {
ASSERT(i < Elements(exec->vtx.attrsz));
exec->vtx.attrsz[i] = 0;
diff --git a/mesalib/src/mesa/vbo/vbo_save_api.c b/mesalib/src/mesa/vbo/vbo_save_api.c
index 75b8ca338..b4c90a05c 100644
--- a/mesalib/src/mesa/vbo/vbo_save_api.c
+++ b/mesalib/src/mesa/vbo/vbo_save_api.c
@@ -1667,5 +1667,4 @@ vbo_save_api_init(struct vbo_save_context *save)
ctx->ListState.ListVtxfmt.DrawRangeElements = _save_OBE_DrawRangeElements;
ctx->ListState.ListVtxfmt.MultiDrawElementsEXT = _save_OBE_MultiDrawElements;
ctx->ListState.ListVtxfmt.MultiDrawElementsBaseVertex = _save_OBE_MultiDrawElementsBaseVertex;
- _mesa_install_save_vtxfmt(ctx, &ctx->ListState.ListVtxfmt);
}