aboutsummaryrefslogtreecommitdiff
path: root/mesalib
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib')
-rw-r--r--mesalib/Makefile2
-rw-r--r--mesalib/configure.ac74
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_blitter.c65
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_blitter.h18
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_debug.h5
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_dump.h2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_dump_state.c32
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format.h22
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_latc.c7
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_pack.py2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_parse.py3
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_rgtc.c11
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_table.py12
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_inlines.h7
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_tile.c28
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_upload_mgr.c19
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_upload_mgr.h7
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_vbuf.c557
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_vbuf.h2
-rw-r--r--mesalib/src/glsl/Makefile.sources1
-rw-r--r--mesalib/src/glsl/ast_to_hir.cpp2
-rw-r--r--mesalib/src/glsl/glsl_lexer.ll2
-rw-r--r--mesalib/src/glsl/glsl_parser.yy4
-rw-r--r--mesalib/src/glsl/ir_optimization.h1
-rw-r--r--mesalib/src/glsl/linker.cpp167
-rw-r--r--mesalib/src/glsl/lower_output_reads.cpp141
-rw-r--r--mesalib/src/mesa/drivers/common/meta.c18
-rw-r--r--mesalib/src/mesa/drivers/dri/common/dri_util.c107
-rw-r--r--mesalib/src/mesa/drivers/dri/common/dri_util.h4
-rw-r--r--mesalib/src/mesa/drivers/dri/common/drisw_util.c76
-rw-r--r--mesalib/src/mesa/drivers/dri/swrast/swrast.c26
-rw-r--r--mesalib/src/mesa/main/bufferobj.c18
-rw-r--r--mesalib/src/mesa/main/dd.h188
-rw-r--r--mesalib/src/mesa/main/ff_fragment_shader.cpp16
-rw-r--r--mesalib/src/mesa/main/format_pack.c2
-rw-r--r--mesalib/src/mesa/main/get.c2
-rw-r--r--mesalib/src/mesa/main/imports.h2
-rw-r--r--mesalib/src/mesa/main/mipmap.c7
-rw-r--r--mesalib/src/mesa/main/mtypes.h34
-rw-r--r--mesalib/src/mesa/main/pack.c39
-rw-r--r--mesalib/src/mesa/main/shaderapi.c2
-rw-r--r--mesalib/src/mesa/main/shaderobj.c5
-rw-r--r--mesalib/src/mesa/main/texcompress_fxt1.c18
-rw-r--r--mesalib/src/mesa/main/texcompress_rgtc.c37
-rw-r--r--mesalib/src/mesa/main/texcompress_s3tc.c39
-rw-r--r--mesalib/src/mesa/main/texgetimage.c10
-rw-r--r--mesalib/src/mesa/main/texgetimage.h7
-rw-r--r--mesalib/src/mesa/main/teximage.c81
-rw-r--r--mesalib/src/mesa/main/teximage.h2
-rw-r--r--mesalib/src/mesa/main/texobj.c6
-rw-r--r--mesalib/src/mesa/main/texstorage.c6
-rw-r--r--mesalib/src/mesa/main/texstore.c525
-rw-r--r--mesalib/src/mesa/main/texstore.h94
-rw-r--r--mesalib/src/mesa/main/transformfeedback.c71
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c4
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_drawpixels.c1
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_eglimage.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_texture.c548
-rw-r--r--mesalib/src/mesa/state_tracker/st_draw.c90
-rw-r--r--mesalib/src/mesa/state_tracker/st_draw.h2
-rw-r--r--mesalib/src/mesa/state_tracker/st_draw_feedback.c20
-rw-r--r--mesalib/src/mesa/state_tracker/st_gen_mipmap.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp189
-rw-r--r--mesalib/src/mesa/state_tracker/st_manager.c10
-rw-r--r--mesalib/src/mesa/state_tracker/st_program.c22
-rw-r--r--mesalib/src/mesa/state_tracker/st_texture.c11
-rw-r--r--mesalib/src/mesa/swrast/s_blit.c352
-rw-r--r--mesalib/src/mesa/swrast/s_copypix.c27
-rw-r--r--mesalib/src/mesa/swrast/s_depth.c9
-rw-r--r--mesalib/src/mesa/swrast/s_span.c2
-rw-r--r--mesalib/src/mesa/swrast/swrast.h5
-rw-r--r--mesalib/src/mesa/tnl/t_draw.c20
-rw-r--r--mesalib/src/mesa/vbo/vbo.h4
-rw-r--r--mesalib/src/mesa/vbo/vbo_exec_array.c52
74 files changed, 2082 insertions, 1925 deletions
diff --git a/mesalib/Makefile b/mesalib/Makefile
index cf6555c78..c73894789 100644
--- a/mesalib/Makefile
+++ b/mesalib/Makefile
@@ -23,7 +23,7 @@ doxygen:
check:
cd src/glsl/tests/ && ./optimization-test
- @echo "All tests passed."
+ make -C tests check
clean:
-@touch $(TOP)/configs/current
diff --git a/mesalib/configure.ac b/mesalib/configure.ac
index 8e809b938..e5a5e8842 100644
--- a/mesalib/configure.ac
+++ b/mesalib/configure.ac
@@ -1,6 +1,6 @@
dnl Process this file with autoconf to create configure.
-AC_PREREQ([2.59])
+AC_PREREQ([2.60])
dnl Versioning - scrape the version from configs/default
m4_define([mesa_version],
@@ -16,6 +16,7 @@ AC_INIT([Mesa],[mesa_version],
[https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa])
AC_CONFIG_AUX_DIR([bin])
AC_CANONICAL_HOST
+AM_INIT_AUTOMAKE([foreign])
dnl Save user CFLAGS and CXXFLAGS so one can override the default ones
USER_CFLAGS="$CFLAGS"
@@ -24,7 +25,7 @@ USER_CXXFLAGS="$CXXFLAGS"
dnl Versions for external dependencies
LIBDRM_REQUIRED=2.4.24
LIBDRM_RADEON_REQUIRED=2.4.24
-LIBDRM_INTEL_REQUIRED=2.4.27
+LIBDRM_INTEL_REQUIRED=2.4.30
LIBDRM_NOUVEAU_REQUIRED=0.6
DRI2PROTO_REQUIRED=2.6
GLPROTO_REQUIRED=1.4.14
@@ -65,6 +66,19 @@ solaris*)
;;
esac
+AC_PATH_PROG([GTESTCONFIG], [gtest-config])
+if test "x$GTESTCONFIG" != "x"; then
+ GTEST_CFLAGS=`gtest-config --cppflags --cxxflags`
+ GTEST_LIBS=`gtest-config --ldflags --libs`
+ HAVE_GTEST=1
+ AC_SUBST([GTEST_CFLAGS])
+ AC_SUBST([GTEST_LIBS])
+ HAVE_GTEST=yes
+else
+ HAVE_GTEST=no
+fi
+AM_CONDITIONAL(HAVE_GTEST, test x$HAVE_GTEST = xyes)
+
dnl clang is mostly GCC-compatible, but its version is much lower,
dnl so we have to check for it.
AC_MSG_CHECKING([if compiling with clang])
@@ -926,16 +940,8 @@ if test "x$enable_glx" = xyes -a "x$no_x" = xyes; then
AC_MSG_ERROR([X11 development libraries needed for GLX])
fi
-dnl XCB - this is only used for GLX right now
-AC_ARG_ENABLE([xcb],
- [AS_HELP_STRING([--enable-xcb],
- [use XCB for GLX @<:@default=disabled@:>@])],
- [enable_xcb="$enableval"],
- [enable_xcb=no])
-if test "x$enable_xcb" = xyes; then
+if test "x$enable_glx" = xyes; then
DEFINES="$DEFINES -DUSE_XCB"
-else
- enable_xcb=no
fi
dnl Direct rendering or just indirect rendering
@@ -994,7 +1000,7 @@ xyesno)
# find the DRI deps for libGL
if test "$x11_pkgconfig" = yes; then
- dri_modules="x11 xext xdamage xfixes"
+ dri_modules="x11 xext xdamage xfixes x11-xcb xcb-glx"
# add xf86vidmode if available
PKG_CHECK_MODULES([XF86VIDMODE], [xxf86vm], HAVE_XF86VIDMODE=yes, HAVE_XF86VIDMODE=no)
@@ -1002,11 +1008,6 @@ xyesno)
dri_modules="$dri_modules xxf86vm"
fi
- # add xcb modules if necessary
- if test "$enable_xcb" = yes; then
- dri_modules="$dri_modules x11-xcb xcb-glx"
- fi
-
PKG_CHECK_MODULES([DRIGL], [$dri_modules])
GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV $dri_modules"
X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
@@ -1023,12 +1024,27 @@ xyesno)
GL_PC_CFLAGS="$X11_INCLUDES"
# XCB can only be used from pkg-config
- if test "$enable_xcb" = yes; then
- PKG_CHECK_MODULES([XCB],[x11-xcb xcb-glx])
- GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV x11-xcb xcb-glx"
- X11_INCLUDES="$X11_INCLUDES $XCB_CFLAGS"
- GL_LIB_DEPS="$GL_LIB_DEPS $XCB_LIBS"
- fi
+ PKG_CHECK_MODULES([XCB],[x11-xcb xcb-glx])
+ GL_PC_REQ_PRIV="$GL_PC_REQ_PRIV x11-xcb xcb-glx"
+ X11_INCLUDES="$X11_INCLUDES $XCB_CFLAGS"
+ GL_LIB_DEPS="$GL_LIB_DEPS $XCB_LIBS"
+ fi
+
+ # Check to see if the xcb-glx library is new enough to support
+ # GLX_ARB_create_context. This bit of hackery is necessary until XCB 1.8
+ # is released.
+ save_CPPFLAGS="$CPPFLAGS"
+ save_LDFLAGS="$LDFLAGS"
+ CPPFLAGS="$CPPFLAGS $X11_INCLUDES"
+ LDFLAGS="$LDFLAGS $GL_LIB_DEPS"
+ AC_CHECK_LIB(xcb-glx, xcb_glx_create_context_attribs_arb_checked,
+ [HAVE_XCB_GLX_CREATE_CONTEXT=yes],
+ [HAVE_XCB_GLX_CREATE_CONTEXT=no])
+ CPPFLAGS="$save_CPPFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+
+ if test x$HAVE_XCB_GLX_CREATE_CONTEXT = xyes; then
+ X11_INCLUDES="$X11_INCLUDES -DHAVE_XCB_GLX_CREATE_CONTEXT"
fi
# need DRM libs, -lpthread, etc.
@@ -1037,6 +1053,11 @@ xyesno)
;;
esac
+# This is outside the case (above) so that it is invoked even for non-GLX
+# builds.
+AM_CONDITIONAL(HAVE_XCB_GLX_CREATE_CONTEXT,
+ test x$HAVE_XCB_GLX_CREATE_CONTEXT = xyes)
+
GLESv1_CM_LIB_DEPS="$LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
GLESv1_CM_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS"
GLESv2_LIB_DEPS="$LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
@@ -1752,7 +1773,7 @@ if test "x$enable_gallium_llvm" = xyes; then
AC_PATH_PROG([LLVM_CONFIG], [llvm-config], [no])
if test "x$LLVM_CONFIG" != xno; then
- LLVM_VERSION=`$LLVM_CONFIG --version`
+ LLVM_VERSION=`$LLVM_CONFIG --version | sed 's/svn.*//g'`
LLVM_CFLAGS=`$LLVM_CONFIG --cppflags|sed -e 's/-DNDEBUG\>//g' -e 's/-pedantic//g'`
LLVM_LIBS="`$LLVM_CONFIG --libs`"
@@ -1907,7 +1928,9 @@ CFLAGS="$CFLAGS $USER_CFLAGS"
CXXFLAGS="$CXXFLAGS $USER_CXXFLAGS"
dnl Substitute the config
-AC_CONFIG_FILES([configs/autoconf])
+AC_CONFIG_FILES([configs/autoconf
+ tests/Makefile
+ tests/glx/Makefile])
dnl Replace the configs/current symlink
AC_CONFIG_COMMANDS([configs],[
@@ -1965,7 +1988,6 @@ xyesyes)
;;
xyesno)
echo " GLX: DRI-based"
- echo " Use XCB: $enable_xcb"
;;
*)
echo " GLX: $enable_glx"
diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.c b/mesalib/src/gallium/auxiliary/util/u_blitter.c
index 3c501814e..80fdfe0a9 100644
--- a/mesalib/src/gallium/auxiliary/util/u_blitter.c
+++ b/mesalib/src/gallium/auxiliary/util/u_blitter.c
@@ -850,6 +850,43 @@ boolean is_overlap(unsigned sx1, unsigned sx2, unsigned sy1, unsigned sy2,
return sx1 < dx2 && sx2 > dx1 && sy1 < dy2 && sy2 > dy1;
}
+void util_blitter_default_dst_texture(struct pipe_surface *dst_templ,
+ struct pipe_resource *dst,
+ unsigned dstlevel,
+ unsigned dstz,
+ const struct pipe_box *srcbox)
+{
+ memset(dst_templ, 0, sizeof(*dst_templ));
+ dst_templ->format = dst->format;
+ if (util_format_is_depth_or_stencil(dst->format)) {
+ dst_templ->usage = PIPE_BIND_DEPTH_STENCIL;
+ } else {
+ dst_templ->usage = PIPE_BIND_RENDER_TARGET;
+ }
+ dst_templ->format = util_format_linear(dst->format);
+ dst_templ->u.tex.level = dstlevel;
+ dst_templ->u.tex.first_layer = dstz;
+ dst_templ->u.tex.last_layer = dstz + srcbox->depth - 1;
+}
+
+void util_blitter_default_src_texture(struct pipe_sampler_view *src_templ,
+ struct pipe_resource *src,
+ unsigned srclevel)
+{
+ memset(src_templ, 0, sizeof(*src_templ));
+ src_templ->format = util_format_linear(src->format);
+ src_templ->u.tex.first_level = srclevel;
+ src_templ->u.tex.last_level = srclevel;
+ src_templ->u.tex.first_layer = 0;
+ src_templ->u.tex.last_layer =
+ src->target == PIPE_TEXTURE_3D ? src->depth0 - 1
+ : src->array_size - 1;
+ src_templ->swizzle_r = PIPE_SWIZZLE_RED;
+ src_templ->swizzle_g = PIPE_SWIZZLE_GREEN;
+ src_templ->swizzle_b = PIPE_SWIZZLE_BLUE;
+ src_templ->swizzle_a = PIPE_SWIZZLE_ALPHA;
+}
+
void util_blitter_copy_texture(struct blitter_context *blitter,
struct pipe_resource *dst,
unsigned dstlevel,
@@ -862,8 +899,8 @@ void util_blitter_copy_texture(struct blitter_context *blitter,
struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
struct pipe_context *pipe = ctx->base.pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_surface *dstsurf, surf_templ;
- struct pipe_sampler_view viewTempl, *view;
+ struct pipe_surface *dst_view, dst_templ;
+ struct pipe_sampler_view src_templ, *src_view;
unsigned bind;
boolean is_stencil, is_depth;
@@ -898,27 +935,19 @@ void util_blitter_copy_texture(struct blitter_context *blitter,
}
/* Initialize the surface. */
- memset(&surf_templ, 0, sizeof(surf_templ));
- u_surface_default_template(&surf_templ, dst, bind);
- surf_templ.format = util_format_linear(dst->format);
- surf_templ.u.tex.level = dstlevel;
- surf_templ.u.tex.first_layer = dstz;
- surf_templ.u.tex.last_layer = dstz + srcbox->depth - 1;
- dstsurf = pipe->create_surface(pipe, dst, &surf_templ);
+ util_blitter_default_dst_texture(&dst_templ, dst, dstlevel, dstz, srcbox);
+ dst_view = pipe->create_surface(pipe, dst, &dst_templ);
/* Initialize the sampler view. */
- u_sampler_view_default_template(&viewTempl, src,
- util_format_linear(src->format));
- viewTempl.u.tex.first_level = srclevel;
- viewTempl.u.tex.last_level = srclevel;
- view = pipe->create_sampler_view(pipe, src, &viewTempl);
+ util_blitter_default_src_texture(&src_templ, src, srclevel);
+ src_view = pipe->create_sampler_view(pipe, src, &src_templ);
/* Copy. */
- util_blitter_copy_texture_view(blitter, dstsurf, dstx, dsty, view, srcbox,
- src->width0, src->height0);
+ util_blitter_copy_texture_view(blitter, dst_view, dstx, dsty, src_view,
+ srcbox, src->width0, src->height0);
- pipe_surface_reference(&dstsurf, NULL);
- pipe_sampler_view_reference(&view, NULL);
+ pipe_surface_reference(&dst_view, NULL);
+ pipe_sampler_view_reference(&src_view, NULL);
}
void util_blitter_copy_texture_view(struct blitter_context *blitter,
diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.h b/mesalib/src/gallium/auxiliary/util/u_blitter.h
index f605a7e7a..4dd64c516 100644
--- a/mesalib/src/gallium/auxiliary/util/u_blitter.h
+++ b/mesalib/src/gallium/auxiliary/util/u_blitter.h
@@ -218,6 +218,24 @@ void util_blitter_copy_texture_view(struct blitter_context *blitter,
unsigned src_width0, unsigned src_height0);
/**
+ * Helper function to initialize a view for copy_texture_view.
+ * The parameters must match copy_texture_view.
+ */
+void util_blitter_default_dst_texture(struct pipe_surface *dst_templ,
+ struct pipe_resource *dst,
+ unsigned dstlevel,
+ unsigned dstz,
+ const struct pipe_box *srcbox);
+
+/**
+ * Helper function to initialize a view for copy_texture_view.
+ * The parameters must match copy_texture_view.
+ */
+void util_blitter_default_src_texture(struct pipe_sampler_view *src_templ,
+ struct pipe_resource *src,
+ unsigned srclevel);
+
+/**
* Copy data from one buffer to another using the Stream Output functionality.
* Some alignment is required, otherwise software fallback is used.
*/
diff --git a/mesalib/src/gallium/auxiliary/util/u_debug.h b/mesalib/src/gallium/auxiliary/util/u_debug.h
index b5ea40506..cbea35830 100644
--- a/mesalib/src/gallium/auxiliary/util/u_debug.h
+++ b/mesalib/src/gallium/auxiliary/util/u_debug.h
@@ -91,8 +91,11 @@ debug_printf(const char *format, ...)
(void) format; /* silence warning */
#endif
}
+#else /* is Haiku */
+/* Haiku provides debug_printf in libroot with OS.h */
+#include <OS.h>
+#endif
-#endif /* !PIPE_OS_HAIKU */
/*
* ... isn't portable so we need to pass arguments in parentheses.
diff --git a/mesalib/src/gallium/auxiliary/util/u_dump.h b/mesalib/src/gallium/auxiliary/util/u_dump.h
index 3890b3bdd..87d84bead 100644
--- a/mesalib/src/gallium/auxiliary/util/u_dump.h
+++ b/mesalib/src/gallium/auxiliary/util/u_dump.h
@@ -162,6 +162,8 @@ void
util_dump_vertex_element(FILE *stream,
const struct pipe_vertex_element *state);
+void
+util_dump_draw_info(FILE *stream, const struct pipe_draw_info *state);
/* FIXME: Move the other debug_dump_xxx functions out of u_debug.h into here. */
diff --git a/mesalib/src/gallium/auxiliary/util/u_dump_state.c b/mesalib/src/gallium/auxiliary/util/u_dump_state.c
index 91f4aae69..e44c6194c 100644
--- a/mesalib/src/gallium/auxiliary/util/u_dump_state.c
+++ b/mesalib/src/gallium/auxiliary/util/u_dump_state.c
@@ -725,3 +725,35 @@ util_dump_vertex_element(FILE *stream, const struct pipe_vertex_element *state)
util_dump_struct_end(stream);
}
+
+
+void
+util_dump_draw_info(FILE *stream, const struct pipe_draw_info *state)
+{
+ if(!state) {
+ util_dump_null(stream);
+ return;
+ }
+
+ util_dump_struct_begin(stream, "pipe_draw_info");
+
+ util_dump_member(stream, bool, state, indexed);
+
+ util_dump_member(stream, uint, state, mode);
+ util_dump_member(stream, uint, state, start);
+ util_dump_member(stream, uint, state, count);
+
+ util_dump_member(stream, uint, state, start_instance);
+ util_dump_member(stream, uint, state, instance_count);
+
+ util_dump_member(stream, int, state, index_bias);
+ util_dump_member(stream, uint, state, min_index);
+ util_dump_member(stream, uint, state, max_index);
+
+ util_dump_member(stream, bool, state, primitive_restart);
+ util_dump_member(stream, uint, state, restart_index);
+
+ util_dump_member(stream, ptr, state, count_from_stream_output);
+
+ util_dump_struct_end(stream);
+}
diff --git a/mesalib/src/gallium/auxiliary/util/u_format.h b/mesalib/src/gallium/auxiliary/util/u_format.h
index 9694c9034..874ea7eb1 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format.h
+++ b/mesalib/src/gallium/auxiliary/util/u_format.h
@@ -254,7 +254,7 @@ struct util_format_description
/**
* Fetch a single pixel (i, j) from a block.
*
- * Only defined for non-depth-stencil formats.
+ * Only defined for non-depth-stencil and non-integer formats.
*/
void
(*fetch_rgba_float)(float *dst,
@@ -358,6 +358,26 @@ struct util_format_description
(*pack_rgba_sint)(uint8_t *dst, unsigned dst_stride,
const int *src, unsigned src_stride,
unsigned width, unsigned height);
+
+ /**
+ * Fetch a single pixel (i, j) from a block.
+ *
+ * Only defined for unsigned (pure) integer formats.
+ */
+ void
+ (*fetch_rgba_uint)(uint32_t *dst,
+ const uint8_t *src,
+ unsigned i, unsigned j);
+
+ /**
+ * Fetch a single pixel (i, j) from a block.
+ *
+ * Only defined for signed (pure) integer formats.
+ */
+ void
+ (*fetch_rgba_sint)(int32_t *dst,
+ const uint8_t *src,
+ unsigned i, unsigned j);
};
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_latc.c b/mesalib/src/gallium/auxiliary/util/u_format_latc.c
index 113a793e2..20feb241e 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_latc.c
+++ b/mesalib/src/gallium/auxiliary/util/u_format_latc.c
@@ -47,6 +47,9 @@ util_format_latc1_unorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsi
(void) u_format_signed_encode_rgtc_ubyte;
u_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 1);
+ dst[1] = dst[0];
+ dst[2] = dst[0];
+ dst[3] = 255;
}
void
@@ -173,7 +176,9 @@ void
util_format_latc2_unorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
{
u_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 2);
- u_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, dst + 1, 2);
+ dst[1] = dst[0];
+ dst[2] = dst[0];
+ u_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, dst + 3, 2);
}
void
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_pack.py b/mesalib/src/gallium/auxiliary/util/u_format_pack.py
index fff409fb7..0b3a890d5 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_pack.py
+++ b/mesalib/src/gallium/auxiliary/util/u_format_pack.py
@@ -686,6 +686,7 @@ def generate(formats):
generate_format_unpack(format, channel, native_type, suffix)
generate_format_pack(format, channel, native_type, suffix)
+ generate_format_fetch(format, channel, native_type, suffix)
channel = Channel(SIGNED, False, True, 32)
native_type = 'int'
@@ -699,6 +700,7 @@ def generate(formats):
generate_format_unpack(format, channel, native_type, suffix)
generate_format_pack(format, channel, native_type, suffix)
+ generate_format_fetch(format, channel, native_type, suffix)
native_type = 'unsigned'
suffix = 'unsigned'
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_parse.py b/mesalib/src/gallium/auxiliary/util/u_format_parse.py
index 73a4bcb21..3a39e5ba5 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_parse.py
+++ b/mesalib/src/gallium/auxiliary/util/u_format_parse.py
@@ -196,10 +196,11 @@ class Format:
def inv_swizzles(self):
'''Return an array[4] of inverse swizzle terms'''
+ '''Only pick the first matching value to avoid l8 getting blue and i8 getting alpha'''
inv_swizzle = [None]*4
for i in range(4):
swizzle = self.swizzles[i]
- if swizzle < 4:
+ if swizzle < 4 and inv_swizzle[swizzle] == None:
inv_swizzle[swizzle] = i
return inv_swizzle
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_rgtc.c b/mesalib/src/gallium/auxiliary/util/u_format_rgtc.c
index 2371bab1e..ff04e37b5 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_rgtc.c
+++ b/mesalib/src/gallium/auxiliary/util/u_format_rgtc.c
@@ -42,6 +42,9 @@ void
util_format_rgtc1_unorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
{
u_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 1);
+ dst[1] = 0;
+ dst[2] = 0;
+ dst[3] = 255;
}
void
@@ -58,6 +61,9 @@ util_format_rgtc1_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride
for(i = 0; i < bw; ++i) {
uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*comps;
u_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 1);
+ dst[1] = 0;
+ dst[2] = 0;
+ dst[3] = 255;
}
}
src += block_size;
@@ -229,6 +235,8 @@ util_format_rgtc2_unorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsi
{
u_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 2);
u_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, dst + 1, 2);
+ dst[2] = 0;
+ dst[3] = 255;
}
void
@@ -246,7 +254,8 @@ util_format_rgtc2_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride
uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*comps;
u_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 2);
u_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, dst + 1, 2);
-
+ dst[2] = 0;
+ dst[3] = 255;
}
}
src += block_size;
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_table.py b/mesalib/src/gallium/auxiliary/util/u_format_table.py
index 07beb3872..8edb50523 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_table.py
+++ b/mesalib/src/gallium/auxiliary/util/u_format_table.py
@@ -169,17 +169,23 @@ def write_format_table(formats):
print " &util_format_%s_unpack_unsigned, /* unpack_rgba_uint */" % format.short_name()
print " &util_format_%s_pack_unsigned, /* pack_rgba_uint */" % format.short_name()
print " &util_format_%s_unpack_signed, /* unpack_rgba_sint */" % format.short_name()
- print " &util_format_%s_pack_signed /* pack_rgba_sint */" % format.short_name()
+ print " &util_format_%s_pack_signed, /* pack_rgba_sint */" % format.short_name()
+ print " &util_format_%s_fetch_unsigned, /* fetch_rgba_uint */" % format.short_name()
+ print " NULL /* fetch_rgba_sint */"
elif format.colorspace != ZS and format.channels[0].pure == True and format.channels[0].type == SIGNED:
print " &util_format_%s_unpack_unsigned, /* unpack_rgba_uint */" % format.short_name()
print " &util_format_%s_pack_unsigned, /* pack_rgba_uint */" % format.short_name()
print " &util_format_%s_unpack_signed, /* unpack_rgba_sint */" % format.short_name()
- print " &util_format_%s_pack_signed /* pack_rgba_sint */" % format.short_name()
+ print " &util_format_%s_pack_signed, /* pack_rgba_sint */" % format.short_name()
+ print " NULL, /* fetch_rgba_uint */"
+ print " &util_format_%s_fetch_signed /* fetch_rgba_sint */" % format.short_name()
else:
print " NULL, /* unpack_rgba_uint */"
print " NULL, /* pack_rgba_uint */"
print " NULL, /* unpack_rgba_sint */"
- print " NULL /* pack_rgba_sint */"
+ print " NULL, /* pack_rgba_sint */"
+ print " NULL, /* fetch_rgba_uint */"
+ print " NULL /* fetch_rgba_sint */"
print "};"
print
diff --git a/mesalib/src/gallium/auxiliary/util/u_inlines.h b/mesalib/src/gallium/auxiliary/util/u_inlines.h
index 44283909a..9660cdc6e 100644
--- a/mesalib/src/gallium/auxiliary/util/u_inlines.h
+++ b/mesalib/src/gallium/auxiliary/util/u_inlines.h
@@ -252,10 +252,7 @@ pipe_buffer_map_range(struct pipe_context *pipe,
return NULL;
}
- /* Match old screen->buffer_map_range() behaviour, return pointer
- * to where the beginning of the buffer would be:
- */
- return (void *)((char *)map - offset);
+ return map;
}
@@ -374,7 +371,7 @@ pipe_buffer_read(struct pipe_context *pipe,
&src_transfer);
if (map)
- memcpy(data, map + offset, size);
+ memcpy(data, map, size);
pipe_buffer_unmap(pipe, src_transfer);
}
diff --git a/mesalib/src/gallium/auxiliary/util/u_tile.c b/mesalib/src/gallium/auxiliary/util/u_tile.c
index 02bdb731d..ea4b91f95 100644
--- a/mesalib/src/gallium/auxiliary/util/u_tile.c
+++ b/mesalib/src/gallium/auxiliary/util/u_tile.c
@@ -344,6 +344,31 @@ z32f_x24s8_get_tile_rgba(const float *src,
}
}
+/*** PIPE_FORMAT_X32_S8X24_UINT ***/
+
+/**
+ * Return S component as four uint32_t in [0..255]. Z part ignored.
+ */
+static void
+x32_s8_get_tile_rgba(const unsigned *src,
+ unsigned w, unsigned h,
+ float *p,
+ unsigned dst_stride)
+{
+ unsigned i, j;
+
+ for (i = 0; i < h; i++) {
+ float *pRow = p;
+ for (j = 0; j < w; j++, pRow += 4) {
+ src++;
+ pRow[0] =
+ pRow[1] =
+ pRow[2] =
+ pRow[3] = (float)(*src++ & 0xff);
+ }
+ p += dst_stride;
+ }
+}
void
pipe_tile_raw_to_rgba(enum pipe_format format,
@@ -381,6 +406,9 @@ pipe_tile_raw_to_rgba(enum pipe_format format,
case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
z32f_x24s8_get_tile_rgba((float *) src, w, h, dst, dst_stride);
break;
+ case PIPE_FORMAT_X32_S8X24_UINT:
+ x32_s8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride);
+ break;
default:
util_format_read_4f(format,
dst, dst_stride * sizeof(float),
diff --git a/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c b/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c
index a2319d0c4..b4b4c91f1 100644
--- a/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c
+++ b/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c
@@ -158,7 +158,6 @@ enum pipe_error u_upload_alloc( struct u_upload_mgr *upload,
unsigned size,
unsigned *out_offset,
struct pipe_resource **outbuf,
- boolean *flushed,
void **ptr )
{
unsigned alloc_size = align( size, upload->alignment );
@@ -172,10 +171,6 @@ enum pipe_error u_upload_alloc( struct u_upload_mgr *upload,
alloc_offset + alloc_size);
if (ret != PIPE_OK)
return ret;
-
- *flushed = TRUE;
- } else {
- *flushed = FALSE;
}
offset = MAX2(upload->offset, alloc_offset);
@@ -192,6 +187,8 @@ enum pipe_error u_upload_alloc( struct u_upload_mgr *upload,
*ptr = NULL;
return PIPE_ERROR_OUT_OF_MEMORY;
}
+
+ upload->map -= offset;
}
assert(offset < upload->buffer->width0);
@@ -212,12 +209,11 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload,
unsigned size,
const void *data,
unsigned *out_offset,
- struct pipe_resource **outbuf,
- boolean *flushed )
+ struct pipe_resource **outbuf)
{
uint8_t *ptr;
enum pipe_error ret = u_upload_alloc(upload, min_out_offset, size,
- out_offset, outbuf, flushed,
+ out_offset, outbuf,
(void**)&ptr);
if (ret != PIPE_OK)
return ret;
@@ -238,8 +234,7 @@ enum pipe_error u_upload_buffer( struct u_upload_mgr *upload,
unsigned size,
struct pipe_resource *inbuf,
unsigned *out_offset,
- struct pipe_resource **outbuf,
- boolean *flushed )
+ struct pipe_resource **outbuf)
{
enum pipe_error ret = PIPE_OK;
struct pipe_transfer *transfer = NULL;
@@ -261,9 +256,9 @@ enum pipe_error u_upload_buffer( struct u_upload_mgr *upload,
ret = u_upload_data( upload,
min_out_offset,
size,
- map + offset,
+ map,
out_offset,
- outbuf, flushed );
+ outbuf);
pipe_buffer_unmap( upload->pipe, transfer );
diff --git a/mesalib/src/gallium/auxiliary/util/u_upload_mgr.h b/mesalib/src/gallium/auxiliary/util/u_upload_mgr.h
index 989151398..b50d3f32c 100644
--- a/mesalib/src/gallium/auxiliary/util/u_upload_mgr.h
+++ b/mesalib/src/gallium/auxiliary/util/u_upload_mgr.h
@@ -94,7 +94,6 @@ enum pipe_error u_upload_alloc( struct u_upload_mgr *upload,
unsigned size,
unsigned *out_offset,
struct pipe_resource **outbuf,
- boolean *flushed,
void **ptr );
@@ -109,8 +108,7 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload,
unsigned size,
const void *data,
unsigned *out_offset,
- struct pipe_resource **outbuf,
- boolean *flushed );
+ struct pipe_resource **outbuf);
/**
@@ -125,8 +123,7 @@ enum pipe_error u_upload_buffer( struct u_upload_mgr *upload,
unsigned size,
struct pipe_resource *inbuf,
unsigned *out_offset,
- struct pipe_resource **outbuf,
- boolean *flushed );
+ struct pipe_resource **outbuf);
diff --git a/mesalib/src/gallium/auxiliary/util/u_vbuf.c b/mesalib/src/gallium/auxiliary/util/u_vbuf.c
index 5b0e26e30..711ad10e8 100644
--- a/mesalib/src/gallium/auxiliary/util/u_vbuf.c
+++ b/mesalib/src/gallium/auxiliary/util/u_vbuf.c
@@ -27,12 +27,15 @@
#include "util/u_vbuf.h"
+#include "util/u_dump.h"
#include "util/u_format.h"
#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "util/u_upload_mgr.h"
#include "translate/translate.h"
#include "translate/translate_cache.h"
+#include "cso_cache/cso_cache.h"
+#include "cso_cache/cso_hash.h"
struct u_vbuf_elements {
unsigned count;
@@ -54,10 +57,18 @@ struct u_vbuf_elements {
boolean incompatible_layout_elem[PIPE_MAX_ATTRIBS];
};
+enum {
+ VB_VERTEX = 0,
+ VB_INSTANCE = 1,
+ VB_CONST = 2,
+ VB_NUM = 3
+};
+
struct u_vbuf_priv {
struct u_vbuf b;
struct pipe_context *pipe;
struct translate_cache *translate_cache;
+ struct cso_cache *cso_cache;
/* Vertex element state bound by the state tracker. */
void *saved_ve;
@@ -71,7 +82,7 @@ struct u_vbuf_priv {
void *fallback_ve;
/* The vertex buffer slot index where translated vertices have been
* stored in. */
- unsigned fallback_vb_slot;
+ unsigned fallback_vbs[VB_NUM];
/* When binding the fallback vertex element state, we don't want to
* change saved_ve and ve. This is set to TRUE in such cases. */
boolean ve_binding_lock;
@@ -123,8 +134,9 @@ u_vbuf_create(struct pipe_context *pipe,
struct u_vbuf_priv *mgr = CALLOC_STRUCT(u_vbuf_priv);
mgr->pipe = pipe;
+ mgr->cso_cache = cso_cache_create();
mgr->translate_cache = translate_cache_create();
- mgr->fallback_vb_slot = ~0;
+ memset(mgr->fallback_vbs, ~0, sizeof(mgr->fallback_vbs));
mgr->b.uploader = u_upload_create(pipe, upload_buffer_size,
upload_buffer_alignment,
@@ -138,6 +150,46 @@ u_vbuf_create(struct pipe_context *pipe,
return &mgr->b;
}
+/* XXX I had to fork this off of cso_context. */
+static void *
+u_vbuf_pipe_set_vertex_elements(struct u_vbuf_priv *mgr,
+ unsigned count,
+ const struct pipe_vertex_element *states)
+{
+ unsigned key_size, hash_key;
+ struct cso_hash_iter iter;
+ void *handle;
+ struct cso_velems_state velems_state;
+
+ /* need to include the count into the stored state data too. */
+ key_size = sizeof(struct pipe_vertex_element) * count + sizeof(unsigned);
+ velems_state.count = count;
+ memcpy(velems_state.velems, states,
+ sizeof(struct pipe_vertex_element) * count);
+ hash_key = cso_construct_key((void*)&velems_state, key_size);
+ iter = cso_find_state_template(mgr->cso_cache, hash_key, CSO_VELEMENTS,
+ (void*)&velems_state, key_size);
+
+ if (cso_hash_iter_is_null(iter)) {
+ struct cso_velements *cso = MALLOC_STRUCT(cso_velements);
+ memcpy(&cso->state, &velems_state, key_size);
+ cso->data =
+ mgr->pipe->create_vertex_elements_state(mgr->pipe, count,
+ &cso->state.velems[0]);
+ cso->delete_state =
+ (cso_state_callback)mgr->pipe->delete_vertex_elements_state;
+ cso->context = mgr->pipe;
+
+ iter = cso_insert_state(mgr->cso_cache, hash_key, CSO_VELEMENTS, cso);
+ handle = cso->data;
+ } else {
+ handle = ((struct cso_velements *)cso_hash_iter_data(iter))->data;
+ }
+
+ mgr->pipe->bind_vertex_elements_state(mgr->pipe, handle);
+ return handle;
+}
+
void u_vbuf_destroy(struct u_vbuf *mgrb)
{
struct u_vbuf_priv *mgr = (struct u_vbuf_priv*)mgrb;
@@ -152,15 +204,136 @@ void u_vbuf_destroy(struct u_vbuf *mgrb)
translate_cache_destroy(mgr->translate_cache);
u_upload_destroy(mgr->b.uploader);
+ cso_cache_delete(mgr->cso_cache);
FREE(mgr);
}
+static void
+u_vbuf_translate_buffers(struct u_vbuf_priv *mgr, struct translate_key *key,
+ unsigned vb_mask, unsigned out_vb,
+ int start_vertex, unsigned num_vertices,
+ int start_index, unsigned num_indices, int min_index,
+ bool unroll_indices)
+{
+ struct translate *tr;
+ struct pipe_transfer *vb_transfer[PIPE_MAX_ATTRIBS] = {0};
+ struct pipe_resource *out_buffer = NULL;
+ uint8_t *out_map;
+ unsigned i, out_offset;
+
+ /* Get a translate object. */
+ tr = translate_cache_find(mgr->translate_cache, key);
+
+ /* Map buffers we want to translate. */
+ for (i = 0; i < mgr->b.nr_vertex_buffers; i++) {
+ if (vb_mask & (1 << i)) {
+ struct pipe_vertex_buffer *vb = &mgr->b.vertex_buffer[i];
+ unsigned offset = vb->buffer_offset + vb->stride * start_vertex;
+ uint8_t *map;
+
+ if (u_vbuf_resource(vb->buffer)->user_ptr) {
+ map = u_vbuf_resource(vb->buffer)->user_ptr + offset;
+ } else {
+ unsigned size = vb->stride ? num_vertices * vb->stride
+ : sizeof(double)*4;
+
+ if (offset+size > vb->buffer->width0) {
+ size = vb->buffer->width0 - offset;
+ }
+
+ map = pipe_buffer_map_range(mgr->pipe, vb->buffer, offset, size,
+ PIPE_TRANSFER_READ, &vb_transfer[i]);
+ }
+
+ /* Subtract min_index so that indexing with the index buffer works. */
+ if (unroll_indices) {
+ map -= vb->stride * min_index;
+ }
+
+ tr->set_buffer(tr, i, map, vb->stride, ~0);
+ }
+ }
+
+ /* Translate. */
+ if (unroll_indices) {
+ struct pipe_index_buffer *ib = &mgr->b.index_buffer;
+ struct pipe_transfer *transfer = NULL;
+ unsigned offset = ib->offset + start_index * ib->index_size;
+ uint8_t *map;
+
+ assert(ib->buffer && ib->index_size);
-static unsigned u_vbuf_get_free_real_vb_slot(struct u_vbuf_priv *mgr)
+ if (u_vbuf_resource(ib->buffer)->user_ptr) {
+ map = u_vbuf_resource(ib->buffer)->user_ptr + offset;
+ } else {
+ map = pipe_buffer_map_range(mgr->pipe, ib->buffer, offset,
+ num_indices * ib->index_size,
+ PIPE_TRANSFER_READ, &transfer);
+ }
+
+ /* Create and map the output buffer. */
+ u_upload_alloc(mgr->b.uploader, 0,
+ key->output_stride * num_indices,
+ &out_offset, &out_buffer,
+ (void**)&out_map);
+
+ switch (ib->index_size) {
+ case 4:
+ tr->run_elts(tr, (unsigned*)map, num_indices, 0, out_map);
+ break;
+ case 2:
+ tr->run_elts16(tr, (uint16_t*)map, num_indices, 0, out_map);
+ break;
+ case 1:
+ tr->run_elts8(tr, map, num_indices, 0, out_map);
+ break;
+ }
+
+ if (transfer) {
+ pipe_buffer_unmap(mgr->pipe, transfer);
+ }
+ } else {
+ /* Create and map the output buffer. */
+ u_upload_alloc(mgr->b.uploader,
+ key->output_stride * start_vertex,
+ key->output_stride * num_vertices,
+ &out_offset, &out_buffer,
+ (void**)&out_map);
+
+ out_offset -= key->output_stride * start_vertex;
+
+ tr->run(tr, 0, num_vertices, 0, out_map);
+ }
+
+ /* Unmap all buffers. */
+ for (i = 0; i < mgr->b.nr_vertex_buffers; i++) {
+ if (vb_transfer[i]) {
+ pipe_buffer_unmap(mgr->pipe, vb_transfer[i]);
+ }
+ }
+
+ /* Setup the new vertex buffer. */
+ mgr->b.real_vertex_buffer[out_vb].buffer_offset = out_offset;
+ mgr->b.real_vertex_buffer[out_vb].stride = key->output_stride;
+
+ /* Move the buffer reference. */
+ pipe_resource_reference(
+ &mgr->b.real_vertex_buffer[out_vb].buffer, NULL);
+ mgr->b.real_vertex_buffer[out_vb].buffer = out_buffer;
+}
+
+static boolean
+u_vbuf_translate_find_free_vb_slots(struct u_vbuf_priv *mgr,
+ unsigned mask[VB_NUM])
{
- unsigned i, nr = mgr->ve->count;
+ unsigned i, type;
+ unsigned nr = mgr->ve->count;
boolean used_vb[PIPE_MAX_ATTRIBS] = {0};
+ unsigned fallback_vbs[VB_NUM];
+
+ memset(fallback_vbs, ~0, sizeof(fallback_vbs));
+ /* Mark used vertex buffers as... used. */
for (i = 0; i < nr; i++) {
if (!mgr->ve->incompatible_layout_elem[i]) {
unsigned index = mgr->ve->ve[i].vertex_buffer_index;
@@ -171,179 +344,199 @@ static unsigned u_vbuf_get_free_real_vb_slot(struct u_vbuf_priv *mgr)
}
}
- for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
- if (!used_vb[i]) {
- if (i >= mgr->b.nr_real_vertex_buffers) {
- mgr->b.nr_real_vertex_buffers = i+1;
+ /* Find free slots for each type if needed. */
+ i = 0;
+ for (type = 0; type < VB_NUM; type++) {
+ if (mask[type]) {
+ for (; i < PIPE_MAX_ATTRIBS; i++) {
+ if (!used_vb[i]) {
+ /*printf("found slot=%i for type=%i\n", i, type);*/
+ fallback_vbs[type] = i;
+ i++;
+ if (i > mgr->b.nr_real_vertex_buffers) {
+ mgr->b.nr_real_vertex_buffers = i;
+ }
+ break;
+ }
+ }
+ if (i == PIPE_MAX_ATTRIBS) {
+ /* fail, reset the number to its original value */
+ mgr->b.nr_real_vertex_buffers = mgr->b.nr_vertex_buffers;
+ return FALSE;
}
- return i;
}
}
- return ~0;
+
+ memcpy(mgr->fallback_vbs, fallback_vbs, sizeof(fallback_vbs));
+ return TRUE;
}
-static void
+static boolean
u_vbuf_translate_begin(struct u_vbuf_priv *mgr,
- int min_index, int max_index)
+ int start_vertex, unsigned num_vertices,
+ int start_instance, unsigned num_instances,
+ int start_index, unsigned num_indices, int min_index,
+ bool unroll_indices)
{
- struct translate_key key;
- struct translate_element *te;
- unsigned tr_elem_index[PIPE_MAX_ATTRIBS];
- struct translate *tr;
- boolean vb_translated[PIPE_MAX_ATTRIBS] = {0};
- uint8_t *out_map;
- struct pipe_transfer *vb_transfer[PIPE_MAX_ATTRIBS] = {0};
- struct pipe_resource *out_buffer = NULL;
- unsigned i, num_verts, out_offset;
- boolean upload_flushed = FALSE;
+ unsigned mask[VB_NUM] = {0};
+ struct translate_key key[VB_NUM];
+ unsigned elem_index[VB_NUM][PIPE_MAX_ATTRIBS]; /* ... into key.elements */
+ unsigned i, type;
+
+ int start[VB_NUM] = {
+ start_vertex, /* VERTEX */
+ start_instance, /* INSTANCE */
+ 0 /* CONST */
+ };
+
+ unsigned num[VB_NUM] = {
+ num_vertices, /* VERTEX */
+ num_instances, /* INSTANCE */
+ 1 /* CONST */
+ };
+
+ memset(key, 0, sizeof(key));
+ memset(elem_index, ~0, sizeof(elem_index));
+
+ /* See if there are vertex attribs of each type to translate and
+ * which ones. */
+ for (i = 0; i < mgr->ve->count; i++) {
+ unsigned vb_index = mgr->ve->ve[i].vertex_buffer_index;
- memset(&key, 0, sizeof(key));
- memset(tr_elem_index, 0xff, sizeof(tr_elem_index));
+ if (!mgr->b.vertex_buffer[vb_index].stride) {
+ if (!mgr->ve->incompatible_layout_elem[i] &&
+ !mgr->incompatible_vb[vb_index]) {
+ continue;
+ }
+ mask[VB_CONST] |= 1 << vb_index;
+ } else if (mgr->ve->ve[i].instance_divisor) {
+ if (!mgr->ve->incompatible_layout_elem[i] &&
+ !mgr->incompatible_vb[vb_index]) {
+ continue;
+ }
+ mask[VB_INSTANCE] |= 1 << vb_index;
+ } else {
+ if (!unroll_indices &&
+ !mgr->ve->incompatible_layout_elem[i] &&
+ !mgr->incompatible_vb[vb_index]) {
+ continue;
+ }
+ mask[VB_VERTEX] |= 1 << vb_index;
+ }
+ }
- /* Get a new vertex buffer slot. */
- mgr->fallback_vb_slot = u_vbuf_get_free_real_vb_slot(mgr);
+ assert(mask[VB_VERTEX] || mask[VB_INSTANCE] || mask[VB_CONST]);
- if (mgr->fallback_vb_slot == ~0) {
- return; /* XXX error, not enough attribs */
+ /* Find free vertex buffer slots. */
+ if (!u_vbuf_translate_find_free_vb_slots(mgr, mask)) {
+ return FALSE;
}
- /* Initialize the description of how vertices should be translated. */
+ /* Initialize the translate keys. */
for (i = 0; i < mgr->ve->count; i++) {
- enum pipe_format output_format = mgr->ve->native_format[i];
- unsigned output_format_size = mgr->ve->native_format_size[i];
+ struct translate_key *k;
+ struct translate_element *te;
+ unsigned bit, vb_index = mgr->ve->ve[i].vertex_buffer_index;
+ bit = 1 << vb_index;
- /* Check for support. */
if (!mgr->ve->incompatible_layout_elem[i] &&
- !mgr->incompatible_vb[mgr->ve->ve[i].vertex_buffer_index]) {
+ !mgr->incompatible_vb[vb_index] &&
+ (!unroll_indices || !(mask[VB_VERTEX] & bit))) {
continue;
}
- /* Workaround for translate: output floats instead of halfs. */
- switch (output_format) {
- case PIPE_FORMAT_R16_FLOAT:
- output_format = PIPE_FORMAT_R32_FLOAT;
- output_format_size = 4;
- break;
- case PIPE_FORMAT_R16G16_FLOAT:
- output_format = PIPE_FORMAT_R32G32_FLOAT;
- output_format_size = 8;
- break;
- case PIPE_FORMAT_R16G16B16_FLOAT:
- output_format = PIPE_FORMAT_R32G32B32_FLOAT;
- output_format_size = 12;
- break;
- case PIPE_FORMAT_R16G16B16A16_FLOAT:
- output_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
- output_format_size = 16;
- break;
- default:;
+ /* Set type to what we will translate.
+ * Whether vertex, instance, or constant attribs. */
+ for (type = 0; type < VB_NUM; type++) {
+ if (mask[type] & bit) {
+ break;
+ }
}
+ assert(type < VB_NUM);
+ assert(translate_is_output_format_supported(mgr->ve->native_format[i]));
+ /*printf("velem=%i type=%i\n", i, type);*/
+
+ /* Add the vertex element. */
+ k = &key[type];
+ elem_index[type][i] = k->nr_elements;
- /* Add this vertex element. */
- te = &key.element[key.nr_elements];
+ te = &k->element[k->nr_elements];
te->type = TRANSLATE_ELEMENT_NORMAL;
te->instance_divisor = 0;
- te->input_buffer = mgr->ve->ve[i].vertex_buffer_index;
+ te->input_buffer = vb_index;
te->input_format = mgr->ve->ve[i].src_format;
te->input_offset = mgr->ve->ve[i].src_offset;
- te->output_format = output_format;
- te->output_offset = key.output_stride;
+ te->output_format = mgr->ve->native_format[i];
+ te->output_offset = k->output_stride;
- key.output_stride += output_format_size;
- vb_translated[mgr->ve->ve[i].vertex_buffer_index] = TRUE;
- tr_elem_index[i] = key.nr_elements;
- key.nr_elements++;
+ k->output_stride += mgr->ve->native_format_size[i];
+ k->nr_elements++;
}
- /* Get a translate object. */
- tr = translate_cache_find(mgr->translate_cache, &key);
-
- /* Map buffers we want to translate. */
- for (i = 0; i < mgr->b.nr_vertex_buffers; i++) {
- if (vb_translated[i]) {
- struct pipe_vertex_buffer *vb = &mgr->b.vertex_buffer[i];
-
- uint8_t *map = pipe_buffer_map(mgr->pipe, vb->buffer,
- PIPE_TRANSFER_READ, &vb_transfer[i]);
-
- tr->set_buffer(tr, i,
- map + vb->buffer_offset + vb->stride * min_index,
- vb->stride, ~0);
- }
- }
-
- /* Create and map the output buffer. */
- num_verts = max_index + 1 - min_index;
-
- u_upload_alloc(mgr->b.uploader,
- key.output_stride * min_index,
- key.output_stride * num_verts,
- &out_offset, &out_buffer, &upload_flushed,
- (void**)&out_map);
-
- out_offset -= key.output_stride * min_index;
-
- /* Translate. */
- tr->run(tr, 0, num_verts, 0, out_map);
-
- /* Unmap all buffers. */
- for (i = 0; i < mgr->b.nr_vertex_buffers; i++) {
- if (vb_translated[i]) {
- pipe_buffer_unmap(mgr->pipe, vb_transfer[i]);
+ /* Translate buffers. */
+ for (type = 0; type < VB_NUM; type++) {
+ if (key[type].nr_elements) {
+ u_vbuf_translate_buffers(mgr, &key[type], mask[type],
+ mgr->fallback_vbs[type],
+ start[type], num[type],
+ start_index, num_indices, min_index,
+ unroll_indices && type == VB_VERTEX);
+
+ /* Fixup the stride for constant attribs. */
+ if (type == VB_CONST) {
+ mgr->b.real_vertex_buffer[mgr->fallback_vbs[VB_CONST]].stride = 0;
+ }
}
}
- /* Setup the new vertex buffer. */
- mgr->b.real_vertex_buffer[mgr->fallback_vb_slot].buffer_offset = out_offset;
- mgr->b.real_vertex_buffer[mgr->fallback_vb_slot].stride = key.output_stride;
-
- /* Move the buffer reference. */
- pipe_resource_reference(
- &mgr->b.real_vertex_buffer[mgr->fallback_vb_slot].buffer, NULL);
- mgr->b.real_vertex_buffer[mgr->fallback_vb_slot].buffer = out_buffer;
- out_buffer = NULL;
-
/* Setup new vertex elements. */
for (i = 0; i < mgr->ve->count; i++) {
- if (tr_elem_index[i] < key.nr_elements) {
- te = &key.element[tr_elem_index[i]];
- mgr->fallback_velems[i].instance_divisor = mgr->ve->ve[i].instance_divisor;
- mgr->fallback_velems[i].src_format = te->output_format;
- mgr->fallback_velems[i].src_offset = te->output_offset;
- mgr->fallback_velems[i].vertex_buffer_index = mgr->fallback_vb_slot;
- } else {
+ for (type = 0; type < VB_NUM; type++) {
+ if (elem_index[type][i] < key[type].nr_elements) {
+ struct translate_element *te = &key[type].element[elem_index[type][i]];
+ mgr->fallback_velems[i].instance_divisor = mgr->ve->ve[i].instance_divisor;
+ mgr->fallback_velems[i].src_format = te->output_format;
+ mgr->fallback_velems[i].src_offset = te->output_offset;
+ mgr->fallback_velems[i].vertex_buffer_index = mgr->fallback_vbs[type];
+
+ /* elem_index[type][i] can only be set for one type. */
+ assert(type > VB_INSTANCE || elem_index[type+1][i] == ~0);
+ assert(type > VB_VERTEX || elem_index[type+2][i] == ~0);
+ break;
+ }
+ }
+ /* No translating, just copy the original vertex element over. */
+ if (type == VB_NUM) {
memcpy(&mgr->fallback_velems[i], &mgr->ve->ve[i],
sizeof(struct pipe_vertex_element));
}
}
-
- mgr->fallback_ve =
- mgr->pipe->create_vertex_elements_state(mgr->pipe, mgr->ve->count,
- mgr->fallback_velems);
-
/* Preserve saved_ve. */
mgr->ve_binding_lock = TRUE;
- mgr->pipe->bind_vertex_elements_state(mgr->pipe, mgr->fallback_ve);
+ mgr->fallback_ve = u_vbuf_pipe_set_vertex_elements(mgr, mgr->ve->count,
+ mgr->fallback_velems);
mgr->ve_binding_lock = FALSE;
+ return TRUE;
}
static void u_vbuf_translate_end(struct u_vbuf_priv *mgr)
{
- if (mgr->fallback_ve == NULL) {
- return;
- }
+ unsigned i;
/* Restore vertex elements. */
/* Note that saved_ve will be overwritten in bind_vertex_elements_state. */
mgr->pipe->bind_vertex_elements_state(mgr->pipe, mgr->saved_ve);
- mgr->pipe->delete_vertex_elements_state(mgr->pipe, mgr->fallback_ve);
mgr->fallback_ve = NULL;
- /* Delete the now-unused VBO. */
- pipe_resource_reference(&mgr->b.real_vertex_buffer[mgr->fallback_vb_slot].buffer,
- NULL);
- mgr->fallback_vb_slot = ~0;
+ /* Unreference the now-unused VBOs. */
+ for (i = 0; i < VB_NUM; i++) {
+ unsigned vb = mgr->fallback_vbs[i];
+ if (vb != ~0) {
+ pipe_resource_reference(&mgr->b.real_vertex_buffer[vb].buffer, NULL);
+ mgr->fallback_vbs[i] = ~0;
+ }
+ }
mgr->b.nr_real_vertex_buffers = mgr->b.nr_vertex_buffers;
}
@@ -554,11 +747,10 @@ void u_vbuf_set_index_buffer(struct u_vbuf *mgr,
static void
u_vbuf_upload_buffers(struct u_vbuf_priv *mgr,
- int min_index, int max_index,
- unsigned instance_count)
+ int start_vertex, unsigned num_vertices,
+ int start_instance, unsigned num_instances)
{
unsigned i;
- unsigned count = max_index + 1 - min_index;
unsigned nr_velems = mgr->ve->count;
unsigned nr_vbufs = mgr->b.nr_vertex_buffers;
struct pipe_vertex_element *velems =
@@ -573,8 +765,10 @@ u_vbuf_upload_buffers(struct u_vbuf_priv *mgr,
struct pipe_vertex_buffer *vb = &mgr->b.vertex_buffer[index];
unsigned instance_div, first, size;
- /* Skip the buffer generated by translate. */
- if (index == mgr->fallback_vb_slot) {
+ /* Skip the buffers generated by translate. */
+ if (index == mgr->fallback_vbs[VB_VERTEX] ||
+ index == mgr->fallback_vbs[VB_INSTANCE] ||
+ index == mgr->fallback_vbs[VB_CONST]) {
continue;
}
@@ -592,12 +786,13 @@ u_vbuf_upload_buffers(struct u_vbuf_priv *mgr,
size = mgr->ve->src_format_size[i];
} else if (instance_div) {
/* Per-instance attrib. */
- unsigned count = (instance_count + instance_div - 1) / instance_div;
+ unsigned count = (num_instances + instance_div - 1) / instance_div;
+ first += vb->stride * start_instance;
size = vb->stride * (count - 1) + mgr->ve->src_format_size[i];
} else {
/* Per-vertex attrib. */
- first += vb->stride * min_index;
- size = vb->stride * (count - 1) + mgr->ve->src_format_size[i];
+ first += vb->stride * start_vertex;
+ size = vb->stride * (num_vertices - 1) + mgr->ve->src_format_size[i];
}
/* Update offsets. */
@@ -615,7 +810,6 @@ u_vbuf_upload_buffers(struct u_vbuf_priv *mgr,
/* Upload buffers. */
for (i = 0; i < nr_vbufs; i++) {
unsigned start, end = end_offset[i];
- boolean flushed;
struct pipe_vertex_buffer *real_vb;
uint8_t *ptr;
@@ -630,7 +824,7 @@ u_vbuf_upload_buffers(struct u_vbuf_priv *mgr,
ptr = u_vbuf_resource(mgr->b.vertex_buffer[i].buffer)->user_ptr;
u_upload_data(mgr->b.uploader, start, end - start, ptr + start,
- &real_vb->buffer_offset, &real_vb->buffer, &flushed);
+ &real_vb->buffer_offset, &real_vb->buffer);
real_vb->buffer_offset -= start;
}
@@ -819,10 +1013,12 @@ static void u_vbuf_get_minmax_index(struct pipe_context *pipe,
enum u_vbuf_return_flags
u_vbuf_draw_begin(struct u_vbuf *mgrb,
- const struct pipe_draw_info *info)
+ struct pipe_draw_info *info)
{
struct u_vbuf_priv *mgr = (struct u_vbuf_priv*)mgrb;
- int min_index, max_index;
+ int start_vertex, min_index;
+ unsigned num_vertices;
+ bool unroll_indices = false;
if (!mgr->incompatible_vb_layout &&
!mgr->ve->incompatible_layout &&
@@ -831,32 +1027,95 @@ u_vbuf_draw_begin(struct u_vbuf *mgrb,
}
if (info->indexed) {
+ int max_index;
+ bool index_bounds_valid = false;
+
if (info->max_index != ~0) {
- min_index = info->min_index + info->index_bias;
- max_index = info->max_index + info->index_bias;
+ min_index = info->min_index;
+ max_index = info->max_index;
+ index_bounds_valid = true;
} else if (u_vbuf_need_minmax_index(mgr)) {
u_vbuf_get_minmax_index(mgr->pipe, &mgr->b.index_buffer, info,
&min_index, &max_index);
- min_index += info->index_bias;
- max_index += info->index_bias;
+ index_bounds_valid = true;
+ }
+
+ /* If the index bounds are valid, it means some upload or translation
+ * of per-vertex attribs will be performed. */
+ if (index_bounds_valid) {
+ assert(min_index <= max_index);
+
+ start_vertex = min_index + info->index_bias;
+ num_vertices = max_index + 1 - min_index;
+
+ /* Primitive restart doesn't work when unrolling indices.
+ * We would have to break this drawing operation into several ones. */
+ /* Use some heuristic to see if unrolling indices improves
+ * performance. */
+ if (!info->primitive_restart &&
+ num_vertices > info->count*2 &&
+ num_vertices-info->count > 32) {
+ /*printf("num_vertices=%i count=%i\n", num_vertices, info->count);*/
+ unroll_indices = true;
+ }
} else {
+ /* Nothing to do for per-vertex attribs. */
+ start_vertex = 0;
+ num_vertices = 0;
min_index = 0;
- max_index = 0;
}
} else {
- min_index = info->start;
- max_index = info->start + info->count - 1;
+ start_vertex = info->start;
+ num_vertices = info->count;
+ min_index = 0;
}
/* Translate vertices with non-native layouts or formats. */
- if (mgr->incompatible_vb_layout || mgr->ve->incompatible_layout) {
- u_vbuf_translate_begin(mgr, min_index, max_index);
+ if (unroll_indices ||
+ mgr->incompatible_vb_layout ||
+ mgr->ve->incompatible_layout) {
+ /* XXX check the return value */
+ u_vbuf_translate_begin(mgr, start_vertex, num_vertices,
+ info->start_instance, info->instance_count,
+ info->start, info->count, min_index,
+ unroll_indices);
}
/* Upload user buffers. */
if (mgr->any_user_vbs) {
- u_vbuf_upload_buffers(mgr, min_index, max_index, info->instance_count);
+ u_vbuf_upload_buffers(mgr, start_vertex, num_vertices,
+ info->start_instance, info->instance_count);
+ }
+
+ /*
+ if (unroll_indices) {
+ printf("unrolling indices: start_vertex = %i, num_vertices = %i\n",
+ start_vertex, num_vertices);
+ util_dump_draw_info(stdout, info);
+ printf("\n");
}
+
+ unsigned i;
+ for (i = 0; i < mgr->b.nr_vertex_buffers; i++) {
+ printf("input %i: ", i);
+ util_dump_vertex_buffer(stdout, mgr->b.vertex_buffer+i);
+ printf("\n");
+ }
+ for (i = 0; i < mgr->b.nr_real_vertex_buffers; i++) {
+ printf("real %i: ", i);
+ util_dump_vertex_buffer(stdout, mgr->b.real_vertex_buffer+i);
+ printf("\n");
+ }
+ */
+
+ if (unroll_indices) {
+ info->indexed = FALSE;
+ info->index_bias = 0;
+ info->min_index = 0;
+ info->max_index = info->count - 1;
+ info->start = 0;
+ }
+
return U_VBUF_BUFFERS_UPDATED;
}
diff --git a/mesalib/src/gallium/auxiliary/util/u_vbuf.h b/mesalib/src/gallium/auxiliary/util/u_vbuf.h
index 57b93ddea..3669c9b87 100644
--- a/mesalib/src/gallium/auxiliary/util/u_vbuf.h
+++ b/mesalib/src/gallium/auxiliary/util/u_vbuf.h
@@ -130,7 +130,7 @@ void u_vbuf_set_index_buffer(struct u_vbuf *mgr,
const struct pipe_index_buffer *ib);
enum u_vbuf_return_flags u_vbuf_draw_begin(struct u_vbuf *mgr,
- const struct pipe_draw_info *info);
+ struct pipe_draw_info *info);
unsigned u_vbuf_draw_max_vertex_count(struct u_vbuf *mgr);
diff --git a/mesalib/src/glsl/Makefile.sources b/mesalib/src/glsl/Makefile.sources
index c65bfe4ff..5e80af297 100644
--- a/mesalib/src/glsl/Makefile.sources
+++ b/mesalib/src/glsl/Makefile.sources
@@ -60,6 +60,7 @@ LIBGLSL_CXX_SOURCES := \
lower_vec_index_to_cond_assign.cpp \
lower_vec_index_to_swizzle.cpp \
lower_vector.cpp \
+ lower_output_reads.cpp \
opt_algebraic.cpp \
opt_constant_folding.cpp \
opt_constant_propagation.cpp \
diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp
index d5b04e9d7..f0c921875 100644
--- a/mesalib/src/glsl/ast_to_hir.cpp
+++ b/mesalib/src/glsl/ast_to_hir.cpp
@@ -1184,7 +1184,7 @@ ast_expression::hir(exec_list *instructions,
error_emitted = true;
}
- type = op[0]->type;
+ type = error_emitted ? glsl_type::error_type : op[0]->type;
result = new(ctx) ir_expression(ir_unop_bit_not, type, op[0], NULL);
break;
diff --git a/mesalib/src/glsl/glsl_lexer.ll b/mesalib/src/glsl/glsl_lexer.ll
index c7cfedd42..936a90726 100644
--- a/mesalib/src/glsl/glsl_lexer.ll
+++ b/mesalib/src/glsl/glsl_lexer.ll
@@ -148,7 +148,7 @@ HASH ^{SPC}#{SPC}
/* Preprocessor tokens. */
^[ \t]*#[ \t]*$ ;
-^[ \t]*#[ \t]*version { BEGIN PP; return VERSION; }
+^[ \t]*#[ \t]*version { BEGIN PP; return VERSION_TOK; }
^[ \t]*#[ \t]*extension { BEGIN PP; return EXTENSION; }
{HASH}line{SPCP}{INT}{SPCP}{INT}{SPC}$ {
/* Eat characters until the first digit is
diff --git a/mesalib/src/glsl/glsl_parser.yy b/mesalib/src/glsl/glsl_parser.yy
index 8a0377f49..e774b4697 100644
--- a/mesalib/src/glsl/glsl_parser.yy
+++ b/mesalib/src/glsl/glsl_parser.yy
@@ -118,7 +118,7 @@ static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg)
%token INVARIANT
%token LOWP MEDIUMP HIGHP SUPERP PRECISION
-%token VERSION EXTENSION LINE COLON EOL INTERFACE OUTPUT
+%token VERSION_TOK EXTENSION LINE COLON EOL INTERFACE OUTPUT
%token PRAGMA_DEBUG_ON PRAGMA_DEBUG_OFF
%token PRAGMA_OPTIMIZE_ON PRAGMA_OPTIMIZE_OFF
%token PRAGMA_INVARIANT_ALL
@@ -246,7 +246,7 @@ translation_unit:
version_statement:
/* blank - no #version specified: defaults are already set */
- | VERSION INTCONSTANT EOL
+ | VERSION_TOK INTCONSTANT EOL
{
bool supported = false;
diff --git a/mesalib/src/glsl/ir_optimization.h b/mesalib/src/glsl/ir_optimization.h
index 7b32e84f0..085b96903 100644
--- a/mesalib/src/glsl/ir_optimization.h
+++ b/mesalib/src/glsl/ir_optimization.h
@@ -72,6 +72,7 @@ bool lower_variable_index_to_cond_assign(exec_list *instructions,
bool lower_input, bool lower_output, bool lower_temp, bool lower_uniform);
bool lower_quadop_vector(exec_list *instructions, bool dont_lower_swz);
bool lower_clip_distance(exec_list *instructions);
+void lower_output_reads(exec_list *instructions);
bool optimize_redundant_jumps(exec_list *instructions);
ir_rvalue *
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index 65870087b..88c81c41b 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -1376,13 +1376,14 @@ demote_shader_inputs_and_outputs(gl_shader *sh, enum ir_variable_mode mode)
class tfeedback_decl
{
public:
- bool init(struct gl_shader_program *prog, const void *mem_ctx,
- const char *input);
+ bool init(struct gl_context *ctx, struct gl_shader_program *prog,
+ const void *mem_ctx, const char *input);
static bool is_same(const tfeedback_decl &x, const tfeedback_decl &y);
bool assign_location(struct gl_context *ctx, struct gl_shader_program *prog,
ir_variable *output_var);
bool store(struct gl_shader_program *prog,
- struct gl_transform_feedback_info *info, unsigned buffer) const;
+ struct gl_transform_feedback_info *info, unsigned buffer,
+ unsigned varying) const;
/**
@@ -1413,24 +1414,31 @@ public:
private:
/**
* The name that was supplied to glTransformFeedbackVaryings. Used for
- * error reporting.
+ * error reporting and glGetTransformFeedbackVarying().
*/
const char *orig_name;
/**
* The name of the variable, parsed from orig_name.
*/
- char *var_name;
+ const char *var_name;
/**
* True if the declaration in orig_name represents an array.
*/
- bool is_array;
+ bool is_subscripted;
/**
- * If is_array is true, the array index that was specified in orig_name.
+ * If is_subscripted is true, the subscript that was specified in orig_name.
*/
- unsigned array_index;
+ unsigned array_subscript;
+
+ /**
+ * Which component to extract from the vertex shader output location that
+ * the linker assigned to this variable. -1 if all components should be
+ * extracted.
+ */
+ int single_component;
/**
* The vertex shader output location that the linker assigned for this
@@ -1449,6 +1457,15 @@ private:
* if this variable is not a matrix.
*/
unsigned matrix_columns;
+
+ /** Type of the varying returned by glGetTransformFeedbackVarying() */
+ GLenum type;
+
+ /**
+ * If location != -1, the size that should be returned by
+ * glGetTransformFeedbackVarying().
+ */
+ unsigned size;
};
@@ -1458,8 +1475,8 @@ private:
* reported using linker_error(), and false is returned.
*/
bool
-tfeedback_decl::init(struct gl_shader_program *prog, const void *mem_ctx,
- const char *input)
+tfeedback_decl::init(struct gl_context *ctx, struct gl_shader_program *prog,
+ const void *mem_ctx, const char *input)
{
/* We don't have to be pedantic about what is a valid GLSL variable name,
* because any variable with an invalid name can't exist in the IR anyway.
@@ -1467,23 +1484,36 @@ tfeedback_decl::init(struct gl_shader_program *prog, const void *mem_ctx,
this->location = -1;
this->orig_name = input;
+ this->single_component = -1;
const char *bracket = strrchr(input, '[');
if (bracket) {
this->var_name = ralloc_strndup(mem_ctx, input, bracket - input);
- if (sscanf(bracket, "[%u]", &this->array_index) == 1) {
- this->is_array = true;
- return true;
+ if (sscanf(bracket, "[%u]", &this->array_subscript) != 1) {
+ linker_error(prog, "Cannot parse transform feedback varying %s", input);
+ return false;
}
+ this->is_subscripted = true;
} else {
this->var_name = ralloc_strdup(mem_ctx, input);
- this->is_array = false;
- return true;
+ this->is_subscripted = false;
}
- linker_error(prog, "Cannot parse transform feedback varying %s", input);
- return false;
+ /* For drivers that lower gl_ClipDistance to gl_ClipDistanceMESA, we need
+ * to convert a request for gl_ClipDistance[n] into a request for a
+ * component of gl_ClipDistanceMESA[n/4].
+ */
+ if (ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].LowerClipDistance &&
+ strcmp(this->var_name, "gl_ClipDistance") == 0) {
+ this->var_name = "gl_ClipDistanceMESA";
+ if (this->is_subscripted) {
+ this->single_component = this->array_subscript % 4;
+ this->array_subscript /= 4;
+ }
+ }
+
+ return true;
}
@@ -1496,9 +1526,11 @@ tfeedback_decl::is_same(const tfeedback_decl &x, const tfeedback_decl &y)
{
if (strcmp(x.var_name, y.var_name) != 0)
return false;
- if (x.is_array != y.is_array)
+ if (x.is_subscripted != y.is_subscripted)
+ return false;
+ if (x.is_subscripted && x.array_subscript != y.array_subscript)
return false;
- if (x.is_array && x.array_index != y.array_index)
+ if (x.single_component != y.single_component)
return false;
return true;
}
@@ -1518,37 +1550,42 @@ tfeedback_decl::assign_location(struct gl_context *ctx,
{
if (output_var->type->is_array()) {
/* Array variable */
- if (!this->is_array) {
- linker_error(prog, "Transform feedback varying %s found, "
- "but it's not an array ([] not expected).",
- this->orig_name);
- return false;
- }
- /* Check array bounds. */
- if (this->array_index >=
- (unsigned) output_var->type->array_size()) {
- linker_error(prog, "Transform feedback varying %s has index "
- "%i, but the array size is %i.",
- this->orig_name, this->array_index,
- output_var->type->array_size());
- return false;
- }
const unsigned matrix_cols =
output_var->type->fields.array->matrix_columns;
- this->location = output_var->location + this->array_index * matrix_cols;
+
+ if (this->is_subscripted) {
+ /* Check array bounds. */
+ if (this->array_subscript >=
+ (unsigned) output_var->type->array_size()) {
+ linker_error(prog, "Transform feedback varying %s has index "
+ "%i, but the array size is %i.",
+ this->orig_name, this->array_subscript,
+ output_var->type->array_size());
+ return false;
+ }
+ this->location =
+ output_var->location + this->array_subscript * matrix_cols;
+ this->size = 1;
+ } else {
+ this->location = output_var->location;
+ this->size = (unsigned) output_var->type->array_size();
+ }
this->vector_elements = output_var->type->fields.array->vector_elements;
this->matrix_columns = matrix_cols;
+ this->type = output_var->type->fields.array->gl_type;
} else {
/* Regular variable (scalar, vector, or matrix) */
- if (this->is_array) {
+ if (this->is_subscripted) {
linker_error(prog, "Transform feedback varying %s found, "
"but it's an array ([] expected).",
this->orig_name);
return false;
}
this->location = output_var->location;
+ this->size = 1;
this->vector_elements = output_var->type->vector_elements;
this->matrix_columns = output_var->type->matrix_columns;
+ this->type = output_var->type->gl_type;
}
/* From GL_EXT_transform_feedback:
* A program will fail to link if:
@@ -1580,7 +1617,7 @@ tfeedback_decl::assign_location(struct gl_context *ctx,
bool
tfeedback_decl::store(struct gl_shader_program *prog,
struct gl_transform_feedback_info *info,
- unsigned buffer) const
+ unsigned buffer, unsigned varying) const
{
if (!this->is_assigned()) {
/* From GL_EXT_transform_feedback:
@@ -1594,14 +1631,27 @@ tfeedback_decl::store(struct gl_shader_program *prog,
this->orig_name);
return false;
}
- for (unsigned v = 0; v < this->matrix_columns; ++v) {
- info->Outputs[info->NumOutputs].OutputRegister = this->location + v;
- info->Outputs[info->NumOutputs].NumComponents = this->vector_elements;
- info->Outputs[info->NumOutputs].OutputBuffer = buffer;
- info->Outputs[info->NumOutputs].DstOffset = info->BufferStride[buffer];
- ++info->NumOutputs;
- info->BufferStride[buffer] += this->vector_elements;
+ for (unsigned index = 0; index < this->size; ++index) {
+ for (unsigned v = 0; v < this->matrix_columns; ++v) {
+ unsigned num_components =
+ this->single_component >= 0 ? 1 : this->vector_elements;
+ info->Outputs[info->NumOutputs].OutputRegister =
+ this->location + v + index * this->matrix_columns;
+ info->Outputs[info->NumOutputs].NumComponents = num_components;
+ info->Outputs[info->NumOutputs].OutputBuffer = buffer;
+ info->Outputs[info->NumOutputs].DstOffset = info->BufferStride[buffer];
+ info->Outputs[info->NumOutputs].ComponentOffset =
+ this->single_component >= 0 ? this->single_component : 0;
+ ++info->NumOutputs;
+ info->BufferStride[buffer] += num_components;
+ }
}
+
+ info->Varyings[varying].Name = ralloc_strdup(prog, this->orig_name);
+ info->Varyings[varying].Type = this->type;
+ info->Varyings[varying].Size = this->size;
+ info->NumVarying++;
+
return true;
}
@@ -1614,12 +1664,12 @@ tfeedback_decl::store(struct gl_shader_program *prog,
* is returned.
*/
static bool
-parse_tfeedback_decls(struct gl_shader_program *prog, const void *mem_ctx,
- unsigned num_names, char **varying_names,
- tfeedback_decl *decls)
+parse_tfeedback_decls(struct gl_context *ctx, struct gl_shader_program *prog,
+ const void *mem_ctx, unsigned num_names,
+ char **varying_names, tfeedback_decl *decls)
{
for (unsigned i = 0; i < num_names; ++i) {
- if (!decls[i].init(prog, mem_ctx, varying_names[i]))
+ if (!decls[i].init(ctx, prog, mem_ctx, varying_names[i]))
return false;
/* From GL_EXT_transform_feedback:
* A program will fail to link if:
@@ -1865,13 +1915,26 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog,
tfeedback_decl *tfeedback_decls)
{
unsigned total_tfeedback_components = 0;
+ bool separate_attribs_mode =
+ prog->TransformFeedback.BufferMode == GL_SEPARATE_ATTRIBS;
+
+ ralloc_free(prog->LinkedTransformFeedback.Varyings);
+
memset(&prog->LinkedTransformFeedback, 0,
sizeof(prog->LinkedTransformFeedback));
+
+ prog->LinkedTransformFeedback.NumBuffers =
+ separate_attribs_mode ? num_tfeedback_decls : 1;
+
+ prog->LinkedTransformFeedback.Varyings =
+ rzalloc_array(prog->LinkedTransformFeedback.Varyings,
+ struct gl_transform_feedback_varying_info,
+ num_tfeedback_decls);
+
for (unsigned i = 0; i < num_tfeedback_decls; ++i) {
- unsigned buffer =
- prog->TransformFeedback.BufferMode == GL_SEPARATE_ATTRIBS ? i : 0;
+ unsigned buffer = separate_attribs_mode ? i : 0;
if (!tfeedback_decls[i].store(prog, &prog->LinkedTransformFeedback,
- buffer))
+ buffer, i))
return false;
total_tfeedback_components += tfeedback_decls[i].num_components();
}
@@ -2182,7 +2245,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
tfeedback_decls = ralloc_array(mem_ctx, tfeedback_decl,
prog->TransformFeedback.NumVarying);
- if (!parse_tfeedback_decls(prog, mem_ctx, num_tfeedback_decls,
+ if (!parse_tfeedback_decls(ctx, prog, mem_ctx, num_tfeedback_decls,
prog->TransformFeedback.VaryingNames,
tfeedback_decls))
goto done;
diff --git a/mesalib/src/glsl/lower_output_reads.cpp b/mesalib/src/glsl/lower_output_reads.cpp
new file mode 100644
index 000000000..415b541c3
--- /dev/null
+++ b/mesalib/src/glsl/lower_output_reads.cpp
@@ -0,0 +1,141 @@
+/*
+ * Copyright © 2012 Vincent Lejeune
+ * Copyright © 2012 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "ir.h"
+#include "program/hash_table.h"
+
+/**
+ * \file lower_output_reads.cpp
+ *
+ * In GLSL, shader output variables (such as varyings) can be both read and
+ * written. However, on some hardware, reading an output register causes
+ * trouble.
+ *
+ * This pass creates temporary shadow copies of every (used) shader output,
+ * and replaces all accesses to use those instead. It also adds code to the
+ * main() function to copy the final values to the actual shader outputs.
+ */
+
+class output_read_remover : public ir_hierarchical_visitor {
+protected:
+ /**
+ * A hash table mapping from the original ir_variable shader outputs
+ * (ir_var_out mode) to the new temporaries to be used instead.
+ */
+ hash_table *replacements;
+
+ void *mem_ctx;
+public:
+ output_read_remover();
+ ~output_read_remover();
+ virtual ir_visitor_status visit(class ir_dereference_variable *);
+ virtual ir_visitor_status visit_leave(class ir_return *);
+ virtual ir_visitor_status visit_leave(class ir_function_signature *);
+};
+
+output_read_remover::output_read_remover()
+{
+ mem_ctx = ralloc_context(NULL);
+ replacements =
+ hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare);
+}
+
+output_read_remover::~output_read_remover()
+{
+ hash_table_dtor(replacements);
+ ralloc_free(mem_ctx);
+}
+
+ir_visitor_status
+output_read_remover::visit(ir_dereference_variable *ir)
+{
+ if (ir->var->mode != ir_var_out)
+ return visit_continue;
+
+ ir_variable *temp = (ir_variable *) hash_table_find(replacements, ir->var);
+
+ /* If we don't have an existing temporary, create one. */
+ if (temp == NULL) {
+ void *var_ctx = ralloc_parent(ir->var);
+ temp = new(var_ctx) ir_variable(ir->var->type, ir->var->name,
+ ir_var_temporary);
+ hash_table_insert(replacements, temp, ir->var);
+ }
+
+ /* Update the dereference to use the temporary */
+ ir->var = temp;
+
+ return visit_continue;
+}
+
+/**
+ * Create an assignment to copy a temporary value back to the actual output.
+ */
+static ir_assignment *
+copy(void *ctx, ir_variable *output, ir_variable *temp)
+{
+ ir_dereference_variable *lhs = new(ctx) ir_dereference_variable(output);
+ ir_dereference_variable *rhs = new(ctx) ir_dereference_variable(temp);
+ return new(ctx) ir_assignment(lhs, rhs);
+}
+
+/** Insert a copy-back assignment before a "return" statement */
+static void
+emit_return_copy(const void *key, void *data, void *closure)
+{
+ ir_return *ir = (ir_return *) closure;
+ ir->insert_before(copy(ir, (ir_variable *) key, (ir_variable *) data));
+}
+
+/** Insert a copy-back assignment at the end of the main() function */
+static void
+emit_main_copy(const void *key, void *data, void *closure)
+{
+ ir_function_signature *sig = (ir_function_signature *) closure;
+ sig->body.push_tail(copy(sig, (ir_variable *) key, (ir_variable *) data));
+}
+
+ir_visitor_status
+output_read_remover::visit_leave(ir_return *ir)
+{
+ hash_table_call_foreach(replacements, emit_return_copy, ir);
+ return visit_continue;
+}
+
+ir_visitor_status
+output_read_remover::visit_leave(ir_function_signature *sig)
+{
+ if (strcmp(sig->function_name(), "main") != 0)
+ return visit_continue;
+
+ hash_table_call_foreach(replacements, emit_main_copy, sig);
+ return visit_continue;
+}
+
+void
+lower_output_reads(exec_list *instructions)
+{
+ output_read_remover v;
+ visit_list_elements(&v, instructions);
+}
diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c
index 5098680b6..785a59531 100644
--- a/mesalib/src/mesa/drivers/common/meta.c
+++ b/mesalib/src/mesa/drivers/common/meta.c
@@ -3157,19 +3157,19 @@ copy_tex_sub_image(struct gl_context *ctx,
*/
_mesa_meta_begin(ctx, MESA_META_PIXEL_STORE);
if (target == GL_TEXTURE_1D) {
- ctx->Driver.TexSubImage1D(ctx, target, level, xoffset,
- width, format, type, buf,
- &ctx->Unpack, texObj, texImage);
+ ctx->Driver.TexSubImage1D(ctx, texImage,
+ xoffset, width,
+ format, type, buf, &ctx->Unpack);
}
else if (target == GL_TEXTURE_3D) {
- ctx->Driver.TexSubImage3D(ctx, target, level, xoffset, yoffset, zoffset,
- width, height, 1, format, type, buf,
- &ctx->Unpack, texObj, texImage);
+ ctx->Driver.TexSubImage3D(ctx, texImage,
+ xoffset, yoffset, zoffset, width, height, 1,
+ format, type, buf, &ctx->Unpack);
}
else {
- ctx->Driver.TexSubImage2D(ctx, target, level, xoffset, yoffset,
- width, height, format, type, buf,
- &ctx->Unpack, texObj, texImage);
+ ctx->Driver.TexSubImage2D(ctx, texImage,
+ xoffset, yoffset, width, height,
+ format, type, buf, &ctx->Unpack);
}
_mesa_meta_end(ctx);
diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.c b/mesalib/src/mesa/drivers/dri/common/dri_util.c
index a153d525d..db7322ec4 100644
--- a/mesalib/src/mesa/drivers/dri/common/dri_util.c
+++ b/mesalib/src/mesa/drivers/dri/common/dri_util.c
@@ -134,35 +134,98 @@ static const __DRIextension **driGetExtensions(__DRIscreen *psp)
/*@{*/
static __DRIcontext *
-dri2CreateNewContextForAPI(__DRIscreen *screen, int api,
- const __DRIconfig *config,
- __DRIcontext *shared, void *data)
+dri2CreateContextAttribs(__DRIscreen *screen, int api,
+ const __DRIconfig *config,
+ __DRIcontext *shared,
+ unsigned num_attribs,
+ const uint32_t *attribs,
+ unsigned *error,
+ void *data)
{
__DRIcontext *context;
const struct gl_config *modes = (config != NULL) ? &config->modes : NULL;
void *shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;
gl_api mesa_api;
+ unsigned major_version = 1;
+ unsigned minor_version = 0;
+ uint32_t flags = 0;
- if (!(screen->api_mask & (1 << api)))
+ assert((num_attribs == 0) || (attribs != NULL));
+
+ if (!(screen->api_mask & (1 << api))) {
+ *error = __DRI_CTX_ERROR_BAD_API;
return NULL;
+ }
switch (api) {
case __DRI_API_OPENGL:
- mesa_api = API_OPENGL;
- break;
+ mesa_api = API_OPENGL;
+ break;
case __DRI_API_GLES:
- mesa_api = API_OPENGLES;
- break;
+ mesa_api = API_OPENGLES;
+ break;
case __DRI_API_GLES2:
- mesa_api = API_OPENGLES2;
- break;
+ mesa_api = API_OPENGLES2;
+ break;
+ case __DRI_API_OPENGL_CORE:
default:
+ *error = __DRI_CTX_ERROR_BAD_API;
+ return NULL;
+ }
+
+ if (mesa_api != API_OPENGL && num_attribs != 0) {
+ *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
+ assert(!"Should not get here.");
+ return NULL;
+ }
+
+ for (unsigned i = 0; i < num_attribs; i++) {
+ switch (attribs[i * 2]) {
+ case __DRI_CTX_ATTRIB_MAJOR_VERSION:
+ major_version = attribs[i * 2 + 1];
+ break;
+ case __DRI_CTX_ATTRIB_MINOR_VERSION:
+ minor_version = attribs[i * 2 + 1];
+ break;
+ case __DRI_CTX_ATTRIB_FLAGS:
+ flags = attribs[i * 2 + 1];
+ break;
+ default:
+ /* We can't create a context that satisfies the requirements of an
+ * attribute that we don't understand. Return failure.
+ */
+ assert(!"Should not get here.");
+ *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
return NULL;
+ }
+ }
+
+ /* There are no forward-compatible contexts before OpenGL 3.0. The
+ * GLX_ARB_create_context spec says:
+ *
+ * "Forward-compatible contexts are defined only for OpenGL versions
+ * 3.0 and later."
+ *
+ * Moreover, Mesa can't fulfill the requirements of a forward-looking
+ * context. Return failure if a forward-looking context is requested.
+ *
+ * In Mesa, a debug context is the same as a regular context.
+ */
+ if ((flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0) {
+ *error = __DRI_CTX_ERROR_BAD_FLAG;
+ return NULL;
+ }
+
+ if ((flags & ~__DRI_CTX_FLAG_DEBUG) != 0) {
+ *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
+ return NULL;
}
context = malloc(sizeof *context);
- if (!context)
+ if (!context) {
+ *error = __DRI_CTX_ERROR_NO_MEMORY;
return NULL;
+ }
context->loaderPrivate = data;
@@ -170,14 +233,27 @@ dri2CreateNewContextForAPI(__DRIscreen *screen, int api,
context->driDrawablePriv = NULL;
context->driReadablePriv = NULL;
- if (!driDriverAPI.CreateContext(mesa_api, modes, context, shareCtx) ) {
+ if (!driDriverAPI.CreateContext(mesa_api, modes, context,
+ major_version, minor_version,
+ flags, error, shareCtx) ) {
free(context);
return NULL;
}
+ *error = __DRI_CTX_ERROR_SUCCESS;
return context;
}
+static __DRIcontext *
+dri2CreateNewContextForAPI(__DRIscreen *screen, int api,
+ const __DRIconfig *config,
+ __DRIcontext *shared, void *data)
+{
+ unsigned error;
+
+ return dri2CreateContextAttribs(screen, api, config, shared, 0, NULL,
+ &error, data);
+}
static __DRIcontext *
dri2CreateNewContext(__DRIscreen *screen, const __DRIconfig *config,
@@ -454,10 +530,7 @@ const __DRIcoreExtension driCoreExtension = {
/** DRI2 interface */
const __DRIdri2Extension driDRI2Extension = {
- /* Force the version to 2 because the underlying drivers don't (can't!)
- * support the extra requirements of CreateContextAttribs.
- */
- { __DRI_DRI2, 2 },
+ { __DRI_DRI2, __DRI_DRI2_VERSION },
dri2CreateNewScreen,
dri2CreateNewDrawable,
dri2CreateNewContext,
@@ -465,7 +538,7 @@ const __DRIdri2Extension driDRI2Extension = {
dri2CreateNewContextForAPI,
dri2AllocateBuffer,
dri2ReleaseBuffer,
- NULL
+ dri2CreateContextAttribs
};
const __DRI2configQueryExtension dri2ConfigQueryExtension = {
diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.h b/mesalib/src/mesa/drivers/dri/common/dri_util.h
index bebb021f6..900f04853 100644
--- a/mesalib/src/mesa/drivers/dri/common/dri_util.h
+++ b/mesalib/src/mesa/drivers/dri/common/dri_util.h
@@ -84,6 +84,10 @@ struct __DriverAPIRec {
GLboolean (*CreateContext)(gl_api api,
const struct gl_config *glVis,
__DRIcontext *driContextPriv,
+ unsigned major_version,
+ unsigned minor_version,
+ uint32_t flags,
+ unsigned *error,
void *sharedContextPrivate);
void (*DestroyContext)(__DRIcontext *driContextPriv);
diff --git a/mesalib/src/mesa/drivers/dri/common/drisw_util.c b/mesalib/src/mesa/drivers/dri/common/drisw_util.c
index 76b41231a..0ec124ae5 100644
--- a/mesalib/src/mesa/drivers/dri/common/drisw_util.c
+++ b/mesalib/src/mesa/drivers/dri/common/drisw_util.c
@@ -94,14 +94,26 @@ static const __DRIextension **driGetExtensions(__DRIscreen *psp)
*/
static __DRIcontext *
-driCreateNewContextForAPI(__DRIscreen *psp, int api,
- const __DRIconfig *config,
- __DRIcontext *shared, void *data)
+driCreateContextAttribs(__DRIscreen *screen, int api,
+ const __DRIconfig *config,
+ __DRIcontext *shared,
+ unsigned num_attribs,
+ const uint32_t *attribs,
+ unsigned *error,
+ void *data)
{
__DRIcontext *pcp;
const struct gl_config *modes = (config != NULL) ? &config->modes : NULL;
void * const shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;
gl_api mesa_api;
+ unsigned major_version = 1;
+ unsigned minor_version = 0;
+ uint32_t flags = 0;
+
+ /* Either num_attribs is zero and attribs is NULL, or num_attribs is not
+ * zero and attribs is not NULL.
+ */
+ assert((num_attribs == 0) == (attribs == NULL));
switch (api) {
case __DRI_API_OPENGL:
@@ -113,21 +125,59 @@ driCreateNewContextForAPI(__DRIscreen *psp, int api,
case __DRI_API_GLES2:
mesa_api = API_OPENGLES2;
break;
+ case __DRI_API_OPENGL_CORE:
default:
return NULL;
}
+ for (unsigned i = 0; i < num_attribs; i++) {
+ switch (attribs[i * 2]) {
+ case __DRI_CTX_ATTRIB_MAJOR_VERSION:
+ major_version = attribs[i * 2 + 1];
+ break;
+ case __DRI_CTX_ATTRIB_MINOR_VERSION:
+ minor_version = attribs[i * 2 + 1];
+ break;
+ case __DRI_CTX_ATTRIB_FLAGS:
+ flags = attribs[i * 2 + 1];
+ break;
+ default:
+ /* We can't create a context that satisfies the requirements of an
+ * attribute that we don't understand. Return failure.
+ */
+ return NULL;
+ }
+ }
+
+ /* There are no forward-compatible contexts before OpenGL 3.0. The
+ * GLX_ARB_create_context spec says:
+ *
+ * "Forward-compatible contexts are defined only for OpenGL versions
+ * 3.0 and later."
+ *
+ * Moreover, Mesa can't fulfill the requirements of a forward-looking
+ * context. Return failure if a forward-looking context is requested.
+ *
+ * In Mesa, a debug context is the same as a regular context.
+ */
+ if (major_version >= 3) {
+ if ((flags & ~__DRI_CTX_FLAG_DEBUG) != 0)
+ return NULL;
+ }
+
pcp = CALLOC_STRUCT(__DRIcontextRec);
if (!pcp)
return NULL;
pcp->loaderPrivate = data;
- pcp->driScreenPriv = psp;
+ pcp->driScreenPriv = screen;
pcp->driDrawablePriv = NULL;
pcp->driReadablePriv = NULL;
- if (!driDriverAPI.CreateContext(mesa_api, modes, pcp, shareCtx)) {
+ if (!driDriverAPI.CreateContext(mesa_api, modes, pcp,
+ major_version, minor_version,
+ flags, error, shareCtx)) {
FREE(pcp);
return NULL;
}
@@ -136,6 +186,17 @@ driCreateNewContextForAPI(__DRIscreen *psp, int api,
}
static __DRIcontext *
+driCreateNewContextForAPI(__DRIscreen *psp, int api,
+ const __DRIconfig *config,
+ __DRIcontext *shared, void *data)
+{
+ unsigned error;
+
+ return driCreateContextAttribs(psp, api, config, shared, 0, NULL,
+ &error, data);
+}
+
+static __DRIcontext *
driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config,
__DRIcontext *shared, void *data)
{
@@ -288,12 +349,9 @@ const __DRIcoreExtension driCoreExtension = {
};
const __DRIswrastExtension driSWRastExtension = {
- /* Force the version to 2 because the underlying driver don't (can't!)
- * support the extra requirements of CreateContextAttribs.
- */
{ __DRI_SWRAST, __DRI_SWRAST_VERSION },
driCreateNewScreen,
driCreateNewDrawable,
driCreateNewContextForAPI,
- NULL
+ driCreateContextAttribs
};
diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast.c b/mesalib/src/mesa/drivers/dri/swrast/swrast.c
index b31700d10..f8d749453 100644
--- a/mesalib/src/mesa/drivers/dri/swrast/swrast.c
+++ b/mesalib/src/mesa/drivers/dri/swrast/swrast.c
@@ -96,7 +96,7 @@ static void swrastSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
else
texFormat = MESA_FORMAT_ARGB8888;
- _mesa_init_teximage_fields(&dri_ctx->Base, target, texImage,
+ _mesa_init_teximage_fields(&dri_ctx->Base, texImage,
w, h, 1, 0, internalFormat, texFormat);
sPriv->swrast_loader->getImage(dPriv, x, y, w, h, (char *)swImage->Data,
@@ -707,7 +707,12 @@ InitExtensionsES2(struct gl_context *ctx)
static GLboolean
dri_create_context(gl_api api,
const struct gl_config * visual,
- __DRIcontext * cPriv, void *sharedContextPrivate)
+ __DRIcontext * cPriv,
+ unsigned major_version,
+ unsigned minor_version,
+ uint32_t flags,
+ unsigned *error,
+ void *sharedContextPrivate)
{
struct dri_context *ctx = NULL;
struct dri_context *share = (struct dri_context *)sharedContextPrivate;
@@ -717,9 +722,22 @@ dri_create_context(gl_api api,
TRACE;
+ /* Flag filtering is handled in dri2CreateContextAttribs.
+ */
+ (void) flags;
+
+ if (api == API_OPENGL
+ && (major_version > 2
+ || (major_version == 2 && minor_version > 1))) {
+ *error = __DRI_CTX_ERROR_BAD_VERSION;
+ goto context_fail;
+ }
+
ctx = CALLOC_STRUCT(dri_context);
- if (ctx == NULL)
+ if (ctx == NULL) {
+ *error = __DRI_CTX_ERROR_NO_MEMORY;
goto context_fail;
+ }
cPriv->driverPrivate = ctx;
ctx->cPriv = cPriv;
@@ -736,6 +754,7 @@ dri_create_context(gl_api api,
/* basic context setup */
if (!_mesa_initialize_context(mesaCtx, api, visual, sharedCtx, &functions, (void *) cPriv)) {
+ *error = __DRI_CTX_ERROR_NO_MEMORY;
goto context_fail;
}
@@ -777,6 +796,7 @@ dri_create_context(gl_api api,
break;
}
+ *error = __DRI_CTX_ERROR_SUCCESS;
return GL_TRUE;
context_fail:
diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c
index 9e6f56b14..63eb6faaa 100644
--- a/mesalib/src/mesa/main/bufferobj.c
+++ b/mesalib/src/mesa/main/bufferobj.c
@@ -184,7 +184,10 @@ buffer_object_subdata_range_good( struct gl_context * ctx, GLenum target,
}
if (offset + size > bufObj->Size) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "%s(size + offset > buffer size)", caller);
+ "%s(offset %lu + size %lu > buffer size %lu)", caller,
+ (unsigned long) offset,
+ (unsigned long) size,
+ (unsigned long) bufObj->Size);
return NULL;
}
if (_mesa_bufferobj_mapped(bufObj)) {
@@ -499,19 +502,20 @@ _mesa_copy_buffer_subdata(struct gl_context *ctx,
GLintptr readOffset, GLintptr writeOffset,
GLsizeiptr size)
{
- GLubyte *srcPtr, *dstPtr;
+ void *srcPtr, *dstPtr;
/* buffer should not already be mapped */
assert(!_mesa_bufferobj_mapped(src));
assert(!_mesa_bufferobj_mapped(dst));
- srcPtr = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0, src->Size,
- GL_MAP_READ_BIT, src);
- dstPtr = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0, dst->Size,
- GL_MAP_WRITE_BIT, dst);
+ srcPtr = ctx->Driver.MapBufferRange(ctx, readOffset, size,
+ GL_MAP_READ_BIT, src);
+ dstPtr = ctx->Driver.MapBufferRange(ctx, writeOffset, size,
+ (GL_MAP_WRITE_BIT |
+ GL_MAP_INVALIDATE_RANGE_BIT), dst);
if (srcPtr && dstPtr)
- memcpy(dstPtr + writeOffset, srcPtr + readOffset, size);
+ memcpy(dstPtr, srcPtr, size);
ctx->Driver.UnmapBuffer(ctx, src);
ctx->Driver.UnmapBuffer(ctx, dst);
diff --git a/mesalib/src/mesa/main/dd.h b/mesalib/src/mesa/main/dd.h
index 5816faa78..6707e785d 100644
--- a/mesalib/src/mesa/main/dd.h
+++ b/mesalib/src/mesa/main/dd.h
@@ -203,83 +203,77 @@ struct dd_function_table {
* fully initialized.
* The parameters are the same as glTexImage1D(), plus:
* \param packing describes how to unpack the source data.
- * \param texObj is the target texture object.
- * \param texImage is the target texture image.
+ * \param texImage is the destination texture image.
*/
- void (*TexImage1D)( struct gl_context *ctx, GLenum target, GLint level,
- GLint internalFormat,
- GLint width, GLint border,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage );
+ void (*TexImage1D)(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ GLint internalFormat,
+ GLint width, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing);
/**
* Called by glTexImage2D().
*
* \sa dd_function_table::TexImage1D.
*/
- void (*TexImage2D)( struct gl_context *ctx, GLenum target, GLint level,
- GLint internalFormat,
- GLint width, GLint height, GLint border,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage );
+ void (*TexImage2D)(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing);
/**
* Called by glTexImage3D().
*
* \sa dd_function_table::TexImage1D.
*/
- void (*TexImage3D)( struct gl_context *ctx, GLenum target, GLint level,
- GLint internalFormat,
- GLint width, GLint height, GLint depth, GLint border,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage );
+ void (*TexImage3D)(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ GLint internalFormat,
+ GLint width, GLint height, GLint depth, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing);
/**
* Called by glTexSubImage1D(). Replace a subset of the target texture
* with new texel data.
* \sa dd_function_table::TexImage1D.
*/
- void (*TexSubImage1D)( struct gl_context *ctx, GLenum target, GLint level,
- GLint xoffset, GLsizei width,
- GLenum format, GLenum type,
- const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage );
+ void (*TexSubImage1D)(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ GLint xoffset, GLsizei width,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing);
/**
* Called by glTexSubImage2D().
*
* \sa dd_function_table::TexSubImage1D.
*/
- void (*TexSubImage2D)( struct gl_context *ctx, GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage );
+ void (*TexSubImage2D)(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing);
/**
* Called by glTexSubImage3D().
*
* \sa dd_function_table::TexSubImage1D.
*/
- void (*TexSubImage3D)( struct gl_context *ctx, GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLint depth,
- GLenum format, GLenum type,
- const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage );
+ void (*TexSubImage3D)(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLint depth,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing);
+
/**
* Called by glGetTexImage().
@@ -342,105 +336,73 @@ struct dd_function_table {
/**
* Called by glCompressedTexImage1D().
- *
- * \param target user specified.
- * \param format user specified.
- * \param type user specified.
- * \param pixels user specified.
- * \param packing indicates the image packing of pixels.
- * \param texObj is the target texture object.
- * \param texImage is the target texture image. It will have the texture \p
- * width, \p height, \p depth, \p border and \p internalFormat information.
- *
- * \a retainInternalCopy is returned by this function and indicates whether
- * core Mesa should keep an internal copy of the texture image.
- */
- void (*CompressedTexImage1D)( struct gl_context *ctx, GLenum target,
- GLint level, GLint internalFormat,
- GLsizei width, GLint border,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage );
+ * The parameters are the same as for glCompressedTexImage1D(), plus a
+ * pointer to the destination texure image.
+ */
+ void (*CompressedTexImage1D)(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ GLint internalFormat,
+ GLsizei width, GLint border,
+ GLsizei imageSize, const GLvoid *data);
/**
* Called by glCompressedTexImage2D().
*
* \sa dd_function_table::CompressedTexImage1D.
*/
- void (*CompressedTexImage2D)( struct gl_context *ctx, GLenum target,
- GLint level, GLint internalFormat,
- GLsizei width, GLsizei height, GLint border,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage );
+ void (*CompressedTexImage2D)(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ GLint internalFormat,
+ GLsizei width, GLsizei height, GLint border,
+ GLsizei imageSize, const GLvoid *data);
+
/**
* Called by glCompressedTexImage3D().
*
* \sa dd_function_table::CompressedTexImage3D.
*/
- void (*CompressedTexImage3D)( struct gl_context *ctx, GLenum target,
- GLint level, GLint internalFormat,
- GLsizei width, GLsizei height, GLsizei depth,
- GLint border,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage );
+ void (*CompressedTexImage3D)(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ GLint internalFormat,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLint border,
+ GLsizei imageSize, const GLvoid *data);
/**
* Called by glCompressedTexSubImage1D().
- *
- * \param target user specified.
- * \param level user specified.
- * \param xoffset user specified.
- * \param yoffset user specified.
- * \param zoffset user specified.
- * \param width user specified.
- * \param height user specified.
- * \param depth user specified.
- * \param imageSize user specified.
- * \param data user specified.
- * \param texObj is the target texture object.
- * \param texImage is the target texture image. It will have the texture \p
- * width, \p height, \p depth, \p border and \p internalFormat information.
- */
- void (*CompressedTexSubImage1D)(struct gl_context *ctx, GLenum target, GLint level,
+ */
+ void (*CompressedTexSubImage1D)(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint xoffset, GLsizei width,
GLenum format,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
+ GLsizei imageSize, const GLvoid *data);
+
/**
* Called by glCompressedTexSubImage2D().
- *
- * \sa dd_function_table::CompressedTexImage3D.
*/
- void (*CompressedTexSubImage2D)(struct gl_context *ctx, GLenum target, GLint level,
+ void (*CompressedTexSubImage2D)(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint xoffset, GLint yoffset,
GLsizei width, GLint height,
GLenum format,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
+ GLsizei imageSize, const GLvoid *data);
+
/**
* Called by glCompressedTexSubImage3D().
- *
- * \sa dd_function_table::CompressedTexImage3D.
*/
- void (*CompressedTexSubImage3D)(struct gl_context *ctx, GLenum target, GLint level,
+ void (*CompressedTexSubImage3D)(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint xoffset, GLint yoffset, GLint zoffset,
GLsizei width, GLint height, GLint depth,
GLenum format,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
+ GLsizei imageSize, const GLvoid *data);
/**
* Called by glGetCompressedTexImage.
*/
- void (*GetCompressedTexImage)(struct gl_context *ctx, GLenum target, GLint level,
- GLvoid *img,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
+ void (*GetCompressedTexImage)(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ GLvoid *data);
/*@}*/
diff --git a/mesalib/src/mesa/main/ff_fragment_shader.cpp b/mesalib/src/mesa/main/ff_fragment_shader.cpp
index 008da0d0e..3e736fa15 100644
--- a/mesalib/src/mesa/main/ff_fragment_shader.cpp
+++ b/mesalib/src/mesa/main/ff_fragment_shader.cpp
@@ -632,15 +632,19 @@ emit_combine_source(struct texenv_fragment_program *p,
new(p->mem_ctx) ir_constant(1.0f),
src);
- case OPR_SRC_ALPHA:
- return new(p->mem_ctx) ir_swizzle(src, 3, 3, 3, 3, 1);
+ case OPR_SRC_ALPHA:
+ return src->type->is_scalar()
+ ? src : (ir_rvalue *) new(p->mem_ctx) ir_swizzle(src, 3, 3, 3, 3, 1);
+
+ case OPR_ONE_MINUS_SRC_ALPHA: {
+ ir_rvalue *const scalar = (src->type->is_scalar())
+ ? src : (ir_rvalue *) new(p->mem_ctx) ir_swizzle(src, 3, 3, 3, 3, 1);
- case OPR_ONE_MINUS_SRC_ALPHA:
return new(p->mem_ctx) ir_expression(ir_binop_sub,
new(p->mem_ctx) ir_constant(1.0f),
- new(p->mem_ctx) ir_swizzle(src,
- 3, 3,
- 3, 3, 1));
+ scalar);
+ }
+
case OPR_ZERO:
return new(p->mem_ctx) ir_constant(0.0f);
case OPR_ONE:
diff --git a/mesalib/src/mesa/main/format_pack.c b/mesalib/src/mesa/main/format_pack.c
index 840559bac..43677117e 100644
--- a/mesalib/src/mesa/main/format_pack.c
+++ b/mesalib/src/mesa/main/format_pack.c
@@ -2453,7 +2453,7 @@ _mesa_pack_ubyte_stencil_row(gl_format format, GLuint n,
break;
case MESA_FORMAT_Z32_FLOAT_X24S8:
{
- GLfloat *d = ((GLfloat *) dst);
+ GLuint *d = dst;
GLuint i;
for (i = 0; i < n; i++) {
d[i * 2 + 1] = src[i];
diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c
index 0c9d6b391..5ad601242 100644
--- a/mesalib/src/mesa/main/get.c
+++ b/mesalib/src/mesa/main/get.c
@@ -2498,7 +2498,7 @@ find_value_indexed(const char *func, GLenum pname, int index, union value *v)
goto invalid_value;
if (!ctx->Extensions.EXT_transform_feedback)
goto invalid_enum;
- v->value_int = ctx->TransformFeedback.CurrentObject->Buffers[index]->Name;
+ v->value_int = ctx->TransformFeedback.CurrentObject->BufferNames[index];
return TYPE_INT;
}
diff --git a/mesalib/src/mesa/main/imports.h b/mesalib/src/mesa/main/imports.h
index d5e3859f8..b7e87439f 100644
--- a/mesalib/src/mesa/main/imports.h
+++ b/mesalib/src/mesa/main/imports.h
@@ -568,7 +568,7 @@ _mesa_init_sqrt_table(void);
#ifdef __GNUC__
-#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(ANDROID)
+#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(ANDROID) || defined(__APPLE__)
#define ffs __builtin_ffs
#define ffsll __builtin_ffsll
#endif
diff --git a/mesalib/src/mesa/main/mipmap.c b/mesalib/src/mesa/main/mipmap.c
index 867cb22e2..867506c9f 100644
--- a/mesalib/src/mesa/main/mipmap.c
+++ b/mesalib/src/mesa/main/mipmap.c
@@ -1860,7 +1860,7 @@ _mesa_prepare_mipmap_level(struct gl_context *ctx,
/* need to (re)allocate image */
ctx->Driver.FreeTextureImageBuffer(ctx, dstImage);
- _mesa_init_teximage_fields(ctx, target, dstImage,
+ _mesa_init_teximage_fields(ctx, dstImage,
width, height, depth,
border, intFormat, format);
@@ -2132,11 +2132,10 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum target,
}
/* The image space was allocated above so use glTexSubImage now */
- ctx->Driver.TexSubImage2D(ctx, target, level + 1,
+ ctx->Driver.TexSubImage2D(ctx, dstImage,
0, 0, dstWidth, dstHeight,
temp_base_format, temp_datatype,
- temp_dst, &ctx->DefaultPacking,
- texObj, dstImage);
+ temp_dst, &ctx->DefaultPacking);
/* swap src and dest pointers */
{
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index 107371e52..dcb987116 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -1817,10 +1817,21 @@ struct prog_instruction;
struct gl_program_parameter_list;
struct gl_uniform_list;
+struct gl_transform_feedback_varying_info {
+ char *Name;
+ GLenum Type;
+ GLint Size;
+};
+
/** Post-link transform feedback info. */
struct gl_transform_feedback_info {
unsigned NumOutputs;
+ /**
+ * Number of transform feedback buffers in use by this program.
+ */
+ unsigned NumBuffers;
+
struct {
unsigned OutputRegister;
unsigned OutputBuffer;
@@ -1828,8 +1839,22 @@ struct gl_transform_feedback_info {
/** offset (in DWORDs) of this output within the interleaved structure */
unsigned DstOffset;
+
+ /**
+ * Offset into the output register of the data to output. For example,
+ * if NumComponents is 2 and ComponentOffset is 1, then the data to
+ * offset is in the y and z components of the output register.
+ */
+ unsigned ComponentOffset;
} Outputs[MAX_PROGRAM_OUTPUTS];
+ /** Transform feedback varyings used for the linking of this shader program.
+ *
+ * Use for glGetTransformFeedbackVarying().
+ */
+ struct gl_transform_feedback_varying_info *Varyings;
+ GLint NumVarying;
+
/**
* Total number of components stored in each buffer. This may be used by
* hardware back-ends to determine the correct stride when interleaving
@@ -2222,7 +2247,13 @@ struct gl_shader_program
*/
struct string_to_uint_map *FragDataBindings;
- /** Transform feedback varyings */
+ /**
+ * Transform feedback varyings last specified by
+ * glTransformFeedbackVaryings().
+ *
+ * For the current set of transform feeedback varyings used for transform
+ * feedback output, see LinkedTransformFeedback.
+ */
struct {
GLenum BufferMode;
GLuint NumVarying;
@@ -2273,7 +2304,6 @@ struct gl_shader_program
/** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */
gl_texture_index SamplerTargets[MAX_SAMPLERS];
- struct gl_program_parameter_list *Varying;
GLboolean LinkStatus; /**< GL_LINK_STATUS */
GLboolean Validated;
GLboolean _Used; /**< Ever used for drawing? */
diff --git a/mesalib/src/mesa/main/pack.c b/mesalib/src/mesa/main/pack.c
index 2933ff638..8f2c8fd97 100644
--- a/mesalib/src/mesa/main/pack.c
+++ b/mesalib/src/mesa/main/pack.c
@@ -692,6 +692,12 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4],
dst[i] = (GLubyte) rgba[i][ACOMP];
}
break;
+ case GL_RG_INTEGER:
+ for (i=0;i<n;i++) {
+ dst[i*2+0] = (GLubyte) rgba[i][RCOMP];
+ dst[i*2+1] = (GLubyte) rgba[i][GCOMP];
+ }
+ break;
case GL_RGB_INTEGER_EXT:
for (i=0;i<n;i++) {
dst[i*3+0] = (GLubyte) rgba[i][RCOMP];
@@ -843,6 +849,12 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4],
dst[i] = (GLbyte) rgba[i][ACOMP];
}
break;
+ case GL_RG_INTEGER:
+ for (i=0;i<n;i++) {
+ dst[i*2+0] = (GLbyte) rgba[i][RCOMP];
+ dst[i*2+1] = (GLbyte) rgba[i][GCOMP];
+ }
+ break;
case GL_RGB_INTEGER_EXT:
for (i=0;i<n;i++) {
dst[i*3+0] = (GLbyte) rgba[i][RCOMP];
@@ -994,6 +1006,12 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4],
dst[i] = (GLushort) rgba[i][ACOMP];
}
break;
+ case GL_RG_INTEGER:
+ for (i=0;i<n;i++) {
+ dst[i*2+0] = (GLushort) rgba[i][RCOMP];
+ dst[i*2+1] = (GLushort) rgba[i][GCOMP];
+ }
+ break;
case GL_RGB_INTEGER_EXT:
for (i=0;i<n;i++) {
dst[i*3+0] = (GLushort) rgba[i][RCOMP];
@@ -1145,6 +1163,13 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4],
dst[i] = (GLshort) rgba[i][ACOMP];
}
break;
+ case GL_RG_INTEGER:
+ for (i=0;i<n;i++) {
+ dst[i*3+0] = (GLshort) rgba[i][RCOMP];
+ dst[i*3+1] = (GLshort) rgba[i][GCOMP];
+ dst[i*3+2] = (GLshort) rgba[i][BCOMP];
+ }
+ break;
case GL_RGB_INTEGER_EXT:
for (i=0;i<n;i++) {
dst[i*3+0] = (GLshort) rgba[i][RCOMP];
@@ -1296,6 +1321,12 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4],
dst[i] = (GLuint) rgba[i][ACOMP];
}
break;
+ case GL_RG_INTEGER:
+ for (i=0;i<n;i++) {
+ dst[i*2+0] = (GLuint) rgba[i][RCOMP];
+ dst[i*2+1] = (GLuint) rgba[i][GCOMP];
+ }
+ break;
case GL_RGB_INTEGER_EXT:
for (i=0;i<n;i++) {
dst[i*3+0] = (GLuint) rgba[i][RCOMP];
@@ -1454,6 +1485,12 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4],
dst[i] = (GLint) rgba[i][ACOMP];
}
break;
+ case GL_RG_INTEGER:
+ for (i=0;i<n;i++) {
+ dst[i*2+0] = (GLint) rgba[i][RCOMP];
+ dst[i*2+1] = (GLint) rgba[i][GCOMP];
+ }
+ break;
case GL_RGB_INTEGER_EXT:
for (i=0;i<n;i++) {
dst[i*3+0] = (GLint) rgba[i][RCOMP];
@@ -2397,6 +2434,7 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
srcFormat == GL_GREEN_INTEGER_EXT ||
srcFormat == GL_BLUE_INTEGER_EXT ||
srcFormat == GL_ALPHA_INTEGER_EXT ||
+ srcFormat == GL_RG_INTEGER ||
srcFormat == GL_RGB_INTEGER_EXT ||
srcFormat == GL_RGBA_INTEGER_EXT ||
srcFormat == GL_BGR_INTEGER_EXT ||
@@ -3778,6 +3816,7 @@ _mesa_unpack_color_span_float( struct gl_context *ctx,
srcFormat == GL_GREEN_INTEGER_EXT ||
srcFormat == GL_BLUE_INTEGER_EXT ||
srcFormat == GL_ALPHA_INTEGER_EXT ||
+ srcFormat == GL_RG_INTEGER ||
srcFormat == GL_RGB_INTEGER_EXT ||
srcFormat == GL_RGBA_INTEGER_EXT ||
srcFormat == GL_BGR_INTEGER_EXT ||
diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c
index b71b44b70..52a9bd452 100644
--- a/mesalib/src/mesa/main/shaderapi.c
+++ b/mesalib/src/mesa/main/shaderapi.c
@@ -751,7 +751,7 @@ link_program(struct gl_context *ctx, GLuint program)
|| shProg == ctx->Shader.CurrentGeometryProgram
|| shProg == ctx->Shader.CurrentFragmentProgram)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glLinkProgram(transform feedback active");
+ "glLinkProgram(transform feedback active)");
return;
}
diff --git a/mesalib/src/mesa/main/shaderobj.c b/mesalib/src/mesa/main/shaderobj.c
index 454007f83..de66851e9 100644
--- a/mesalib/src/mesa/main/shaderobj.c
+++ b/mesalib/src/mesa/main/shaderobj.c
@@ -286,11 +286,6 @@ _mesa_clear_shader_program_data(struct gl_context *ctx,
shProg->UniformHash = NULL;
}
- if (shProg->Varying) {
- _mesa_free_parameter_list(shProg->Varying);
- shProg->Varying = NULL;
- }
-
assert(shProg->InfoLog != NULL);
ralloc_free(shProg->InfoLog);
shProg->InfoLog = ralloc_strdup(shProg, "");
diff --git a/mesalib/src/mesa/main/texcompress_fxt1.c b/mesalib/src/mesa/main/texcompress_fxt1.c
index d5c73e3b4..2480ffb38 100644
--- a/mesalib/src/mesa/main/texcompress_fxt1.c
+++ b/mesalib/src/mesa/main/texcompress_fxt1.c
@@ -64,14 +64,9 @@ _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS)
const GLubyte *pixels;
GLint srcRowStride;
GLubyte *dst;
- const GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */
const GLubyte *tempImage = NULL;
ASSERT(dstFormat == MESA_FORMAT_RGB_FXT1);
- ASSERT(dstXoffset % 8 == 0);
- ASSERT(dstYoffset % 4 == 0);
- ASSERT(dstZoffset == 0);
- (void) dstZoffset;
if (srcFormat != GL_RGB ||
srcType != GL_UNSIGNED_BYTE ||
@@ -99,9 +94,7 @@ _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS)
srcType) / sizeof(GLubyte);
}
- dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
- dstFormat,
- texWidth, dstSlices[0]);
+ dst = dstSlices[0];
fxt1_encode(srcWidth, srcHeight, 3, pixels, srcRowStride,
dst, dstRowStride);
@@ -122,14 +115,9 @@ _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS)
const GLubyte *pixels;
GLint srcRowStride;
GLubyte *dst;
- GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */
const GLubyte *tempImage = NULL;
ASSERT(dstFormat == MESA_FORMAT_RGBA_FXT1);
- ASSERT(dstXoffset % 8 == 0);
- ASSERT(dstYoffset % 4 == 0);
- ASSERT(dstZoffset == 0);
- (void) dstZoffset;
if (srcFormat != GL_RGBA ||
srcType != GL_UNSIGNED_BYTE ||
@@ -156,9 +144,7 @@ _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS)
srcType) / sizeof(GLubyte);
}
- dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
- dstFormat,
- texWidth, dstSlices[0]);
+ dst = dstSlices[0];
fxt1_encode(srcWidth, srcHeight, 4, pixels, srcRowStride,
dst, dstRowStride);
diff --git a/mesalib/src/mesa/main/texcompress_rgtc.c b/mesalib/src/mesa/main/texcompress_rgtc.c
index 3586fc39d..b8e334b45 100644
--- a/mesalib/src/mesa/main/texcompress_rgtc.c
+++ b/mesalib/src/mesa/main/texcompress_rgtc.c
@@ -92,7 +92,6 @@ GLboolean
_mesa_texstore_red_rgtc1(TEXSTORE_PARAMS)
{
GLubyte *dst;
- const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
const GLubyte *tempImage = NULL;
int i, j;
int numxpixels, numypixels;
@@ -102,11 +101,6 @@ _mesa_texstore_red_rgtc1(TEXSTORE_PARAMS)
GLint dstRowDiff;
ASSERT(dstFormat == MESA_FORMAT_RED_RGTC1 ||
dstFormat == MESA_FORMAT_L_LATC1);
- ASSERT(dstXoffset % 4 == 0);
- ASSERT(dstYoffset % 4 == 0);
- ASSERT(dstZoffset % 4 == 0);
- (void) dstZoffset;
-
tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
baseInternalFormat,
@@ -117,9 +111,7 @@ _mesa_texstore_red_rgtc1(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE; /* out of memory */
- dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
- dstFormat,
- texWidth, dstSlices[0]);
+ dst = dstSlices[0];
blkaddr = dst;
dstRowDiff = dstRowStride >= (srcWidth * 2) ? dstRowStride - (((srcWidth + 3) & ~3) * 2) : 0;
@@ -147,7 +139,6 @@ GLboolean
_mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS)
{
GLbyte *dst;
- const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
const GLfloat *tempImage = NULL;
int i, j;
int numxpixels, numypixels;
@@ -157,10 +148,6 @@ _mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS)
GLint dstRowDiff;
ASSERT(dstFormat == MESA_FORMAT_SIGNED_RED_RGTC1 ||
dstFormat == MESA_FORMAT_SIGNED_L_LATC1);
- ASSERT(dstXoffset % 4 == 0);
- ASSERT(dstYoffset % 4 == 0);
- ASSERT(dstZoffset % 4 == 0);
- (void) dstZoffset;
tempImage = _mesa_make_temp_float_image(ctx, dims,
baseInternalFormat,
@@ -171,9 +158,7 @@ _mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE; /* out of memory */
- dst = (GLbyte *)_mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
- dstFormat,
- texWidth, dstSlices[0]);
+ dst = (GLbyte *) dstSlices[0];
blkaddr = dst;
dstRowDiff = dstRowStride >= (srcWidth * 2) ? dstRowStride - (((srcWidth + 3) & ~3) * 2) : 0;
@@ -201,7 +186,6 @@ GLboolean
_mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS)
{
GLubyte *dst;
- const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
const GLubyte *tempImage = NULL;
int i, j;
int numxpixels, numypixels;
@@ -212,10 +196,6 @@ _mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS)
ASSERT(dstFormat == MESA_FORMAT_RG_RGTC2 ||
dstFormat == MESA_FORMAT_LA_LATC2);
- ASSERT(dstXoffset % 4 == 0);
- ASSERT(dstYoffset % 4 == 0);
- ASSERT(dstZoffset % 4 == 0);
- (void) dstZoffset;
tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
baseInternalFormat,
@@ -226,9 +206,7 @@ _mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE; /* out of memory */
- dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
- dstFormat,
- texWidth, dstSlices[0]);
+ dst = dstSlices[0];
blkaddr = dst;
dstRowDiff = dstRowStride >= (srcWidth * 4) ? dstRowStride - (((srcWidth + 3) & ~3) * 4) : 0;
@@ -262,7 +240,6 @@ GLboolean
_mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS)
{
GLbyte *dst;
- const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
const GLfloat *tempImage = NULL;
int i, j;
int numxpixels, numypixels;
@@ -273,10 +250,6 @@ _mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS)
ASSERT(dstFormat == MESA_FORMAT_SIGNED_RG_RGTC2 ||
dstFormat == MESA_FORMAT_SIGNED_LA_LATC2);
- ASSERT(dstXoffset % 4 == 0);
- ASSERT(dstYoffset % 4 == 0);
- ASSERT(dstZoffset % 4 == 0);
- (void) dstZoffset;
tempImage = _mesa_make_temp_float_image(ctx, dims,
baseInternalFormat,
@@ -287,9 +260,7 @@ _mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE; /* out of memory */
- dst = (GLbyte *)_mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
- dstFormat,
- texWidth, dstSlices[0]);
+ dst = (GLbyte *) dstSlices[0];
blkaddr = dst;
dstRowDiff = dstRowStride >= (srcWidth * 4) ? dstRowStride - (((srcWidth + 3) & ~3) * 4) : 0;
diff --git a/mesalib/src/mesa/main/texcompress_s3tc.c b/mesalib/src/mesa/main/texcompress_s3tc.c
index 11c7db4ef..2b796dac0 100644
--- a/mesalib/src/mesa/main/texcompress_s3tc.c
+++ b/mesalib/src/mesa/main/texcompress_s3tc.c
@@ -169,15 +169,10 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS)
{
const GLubyte *pixels;
GLubyte *dst;
- const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
const GLubyte *tempImage = NULL;
ASSERT(dstFormat == MESA_FORMAT_RGB_DXT1 ||
dstFormat == MESA_FORMAT_SRGB_DXT1);
- ASSERT(dstXoffset % 4 == 0);
- ASSERT(dstYoffset % 4 == 0);
- ASSERT(dstZoffset % 4 == 0);
- (void) dstZoffset;
if (srcFormat != GL_RGB ||
srcType != GL_UNSIGNED_BYTE ||
@@ -201,9 +196,7 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS)
srcFormat, srcType, 0, 0);
}
- dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
- dstFormat,
- texWidth, dstSlices[0]);
+ dst = dstSlices[0];
if (ext_tx_compress_dxtn) {
(*ext_tx_compress_dxtn)(3, srcWidth, srcHeight, pixels,
@@ -229,15 +222,10 @@ _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS)
{
const GLubyte *pixels;
GLubyte *dst;
- const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
const GLubyte *tempImage = NULL;
ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT1 ||
dstFormat == MESA_FORMAT_SRGBA_DXT1);
- ASSERT(dstXoffset % 4 == 0);
- ASSERT(dstYoffset % 4 == 0);
- ASSERT(dstZoffset % 4 == 0);
- (void) dstZoffset;
if (srcFormat != GL_RGBA ||
srcType != GL_UNSIGNED_BYTE ||
@@ -261,9 +249,8 @@ _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS)
srcFormat, srcType, 0, 0);
}
- dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
- dstFormat,
- texWidth, dstSlices[0]);
+ dst = dstSlices[0];
+
if (ext_tx_compress_dxtn) {
(*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels,
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
@@ -288,15 +275,10 @@ _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS)
{
const GLubyte *pixels;
GLubyte *dst;
- const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
const GLubyte *tempImage = NULL;
ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT3 ||
dstFormat == MESA_FORMAT_SRGBA_DXT3);
- ASSERT(dstXoffset % 4 == 0);
- ASSERT(dstYoffset % 4 == 0);
- ASSERT(dstZoffset % 4 == 0);
- (void) dstZoffset;
if (srcFormat != GL_RGBA ||
srcType != GL_UNSIGNED_BYTE ||
@@ -319,9 +301,8 @@ _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS)
srcFormat, srcType, 0, 0);
}
- dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
- dstFormat,
- texWidth, dstSlices[0]);
+ dst = dstSlices[0];
+
if (ext_tx_compress_dxtn) {
(*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels,
GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
@@ -346,15 +327,10 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS)
{
const GLubyte *pixels;
GLubyte *dst;
- const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
const GLubyte *tempImage = NULL;
ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT5 ||
dstFormat == MESA_FORMAT_SRGBA_DXT5);
- ASSERT(dstXoffset % 4 == 0);
- ASSERT(dstYoffset % 4 == 0);
- ASSERT(dstZoffset % 4 == 0);
- (void) dstZoffset;
if (srcFormat != GL_RGBA ||
srcType != GL_UNSIGNED_BYTE ||
@@ -377,9 +353,8 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS)
srcFormat, srcType, 0, 0);
}
- dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
- dstFormat,
- texWidth, dstSlices[0]);
+ dst = dstSlices[0];
+
if (ext_tx_compress_dxtn) {
(*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels,
GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c
index 738c18112..f848aa89d 100644
--- a/mesalib/src/mesa/main/texgetimage.c
+++ b/mesalib/src/mesa/main/texgetimage.c
@@ -603,10 +603,9 @@ _mesa_get_teximage(struct gl_context *ctx,
* All error checking will have been done before this routine is called.
*/
void
-_mesa_get_compressed_teximage(struct gl_context *ctx, GLenum target, GLint level,
- GLvoid *img,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
+_mesa_get_compressed_teximage(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ GLvoid *img)
{
const GLuint row_stride =
_mesa_format_row_stride(texImage->TexFormat, texImage->Width);
@@ -981,8 +980,7 @@ _mesa_GetnCompressedTexImageARB(GLenum target, GLint level, GLsizei bufSize,
_mesa_lock_texture(ctx, texObj);
{
- ctx->Driver.GetCompressedTexImage(ctx, target, level, img,
- texObj, texImage);
+ ctx->Driver.GetCompressedTexImage(ctx, texImage, img);
}
_mesa_unlock_texture(ctx, texObj);
}
diff --git a/mesalib/src/mesa/main/texgetimage.h b/mesalib/src/mesa/main/texgetimage.h
index 02b1cf459..cd8e76e7a 100644
--- a/mesalib/src/mesa/main/texgetimage.h
+++ b/mesalib/src/mesa/main/texgetimage.h
@@ -40,10 +40,9 @@ _mesa_get_teximage(struct gl_context *ctx,
extern void
-_mesa_get_compressed_teximage(struct gl_context *ctx, GLenum target, GLint level,
- GLvoid *img,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
+_mesa_get_compressed_teximage(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ GLvoid *data);
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c
index 18a7b87c0..6dd70b96c 100644
--- a/mesalib/src/mesa/main/teximage.c
+++ b/mesalib/src/mesa/main/teximage.c
@@ -1059,7 +1059,6 @@ clear_teximage_fields(struct gl_texture_image *img)
* Initialize basic fields of the gl_texture_image struct.
*
* \param ctx GL context.
- * \param target texture target (GL_TEXTURE_1D, GL_TEXTURE_RECTANGLE, etc).
* \param img texture image structure to be initialized.
* \param width image width.
* \param height image height.
@@ -1072,7 +1071,7 @@ clear_teximage_fields(struct gl_texture_image *img)
* Note: width, height and depth include the border.
*/
void
-_mesa_init_teximage_fields(struct gl_context *ctx, GLenum target,
+_mesa_init_teximage_fields(struct gl_context *ctx,
struct gl_texture_image *img,
GLsizei width, GLsizei height, GLsizei depth,
GLint border, GLenum internalFormat,
@@ -2422,7 +2421,7 @@ teximage(struct gl_context *ctx, GLuint dims,
format, type);
if (legal_texture_size(ctx, texFormat, width, height, depth)) {
- _mesa_init_teximage_fields(ctx, target, texImage, width, height,
+ _mesa_init_teximage_fields(ctx, texImage, width, height,
depth, border, internalFormat,
texFormat);
}
@@ -2473,7 +2472,7 @@ teximage(struct gl_context *ctx, GLuint dims,
type);
if (legal_texture_size(ctx, texFormat, width, height, depth)) {
- _mesa_init_teximage_fields(ctx, target, texImage,
+ _mesa_init_teximage_fields(ctx, texImage,
width, height, depth,
border, internalFormat, texFormat);
@@ -2481,22 +2480,19 @@ teximage(struct gl_context *ctx, GLuint dims,
ASSERT(ctx->Driver.TexImage3D);
switch (dims) {
case 1:
- ctx->Driver.TexImage1D(ctx, target, level, internalFormat,
+ ctx->Driver.TexImage1D(ctx, texImage, internalFormat,
width, border, format,
- type, pixels, unpack, texObj,
- texImage);
+ type, pixels, unpack);
break;
case 2:
- ctx->Driver.TexImage2D(ctx, target, level, internalFormat,
+ ctx->Driver.TexImage2D(ctx, texImage, internalFormat,
width, height, border, format,
- type, pixels, unpack, texObj,
- texImage);
+ type, pixels, unpack);
break;
case 3:
- ctx->Driver.TexImage3D(ctx, target, level, internalFormat,
+ ctx->Driver.TexImage3D(ctx, texImage, internalFormat,
width, height, depth, border, format,
- type, pixels, unpack, texObj,
- texImage);
+ type, pixels, unpack);
break;
default:
_mesa_problem(ctx, "invalid dims=%u in teximage()", dims);
@@ -2681,23 +2677,20 @@ texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level,
switch (dims) {
case 1:
- ctx->Driver.TexSubImage1D(ctx, target, level,
+ ctx->Driver.TexSubImage1D(ctx, texImage,
xoffset, width,
- format, type, pixels,
- &ctx->Unpack, texObj, texImage );
+ format, type, pixels, &ctx->Unpack);
break;
case 2:
- ctx->Driver.TexSubImage2D(ctx, target, level,
+ ctx->Driver.TexSubImage2D(ctx, texImage,
xoffset, yoffset, width, height,
- format, type, pixels,
- &ctx->Unpack, texObj, texImage );
+ format, type, pixels, &ctx->Unpack);
break;
case 3:
- ctx->Driver.TexSubImage3D(ctx, target, level,
+ ctx->Driver.TexSubImage3D(ctx, texImage,
xoffset, yoffset, zoffset,
width, height, depth,
- format, type, pixels,
- &ctx->Unpack, texObj, texImage );
+ format, type, pixels, &ctx->Unpack);
break;
default:
_mesa_problem(ctx, "unexpected dims in subteximage()");
@@ -2818,19 +2811,19 @@ copyteximage(struct gl_context *ctx, GLuint dims,
/* Free old texture image */
ctx->Driver.FreeTextureImageBuffer(ctx, texImage);
- _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
+ _mesa_init_teximage_fields(ctx, texImage, width, height, 1,
border, internalFormat, texFormat);
/* Allocate texture memory (no pixel data yet) */
if (dims == 1) {
- ctx->Driver.TexImage1D(ctx, target, level, internalFormat,
+ ctx->Driver.TexImage1D(ctx, texImage, internalFormat,
width, border, GL_NONE, GL_NONE, NULL,
- &ctx->Unpack, texObj, texImage);
+ &ctx->Unpack);
}
else {
- ctx->Driver.TexImage2D(ctx, target, level, internalFormat,
+ ctx->Driver.TexImage2D(ctx, texImage, internalFormat,
width, height, border, GL_NONE, GL_NONE,
- NULL, &ctx->Unpack, texObj, texImage);
+ NULL, &ctx->Unpack);
}
if (_mesa_clip_copytexsubimage(ctx, &dstX, &dstY, &srcX, &srcY,
@@ -3410,7 +3403,7 @@ compressedteximage(struct gl_context *ctx, GLuint dims,
}
else {
/* no error: store the teximage parameters */
- _mesa_init_teximage_fields(ctx, target, texImage, width, height,
+ _mesa_init_teximage_fields(ctx, texImage, width, height,
depth, border, internalFormat,
MESA_FORMAT_NONE);
}
@@ -3445,34 +3438,31 @@ compressedteximage(struct gl_context *ctx, GLuint dims,
GL_NONE);
if (legal_texture_size(ctx, texFormat, width, height, depth)) {
- _mesa_init_teximage_fields(ctx, target, texImage,
+ _mesa_init_teximage_fields(ctx, texImage,
width, height, depth,
border, internalFormat, texFormat);
switch (dims) {
case 1:
ASSERT(ctx->Driver.CompressedTexImage1D);
- ctx->Driver.CompressedTexImage1D(ctx, target, level,
+ ctx->Driver.CompressedTexImage1D(ctx, texImage,
internalFormat,
width,
- border, imageSize, data,
- texObj, texImage);
+ border, imageSize, data);
break;
case 2:
ASSERT(ctx->Driver.CompressedTexImage2D);
- ctx->Driver.CompressedTexImage2D(ctx, target, level,
+ ctx->Driver.CompressedTexImage2D(ctx, texImage,
internalFormat,
width, height,
- border, imageSize, data,
- texObj, texImage);
+ border, imageSize, data);
break;
case 3:
ASSERT(ctx->Driver.CompressedTexImage3D);
- ctx->Driver.CompressedTexImage3D(ctx, target, level,
+ ctx->Driver.CompressedTexImage3D(ctx, texImage,
internalFormat,
width, height, depth,
- border, imageSize, data,
- texObj, texImage);
+ border, imageSize, data);
break;
default:
_mesa_problem(ctx, "bad dims in compressedteximage");
@@ -3570,28 +3560,25 @@ compressed_tex_sub_image(GLuint dims, GLenum target, GLint level,
switch (dims) {
case 1:
if (ctx->Driver.CompressedTexSubImage1D) {
- ctx->Driver.CompressedTexSubImage1D(ctx, target, level,
+ ctx->Driver.CompressedTexSubImage1D(ctx, texImage,
xoffset, width,
- format, imageSize, data,
- texObj, texImage);
+ format, imageSize, data);
}
break;
case 2:
if (ctx->Driver.CompressedTexSubImage2D) {
- ctx->Driver.CompressedTexSubImage2D(ctx, target, level,
+ ctx->Driver.CompressedTexSubImage2D(ctx, texImage,
xoffset, yoffset,
width, height,
- format, imageSize, data,
- texObj, texImage);
+ format, imageSize, data);
}
break;
case 3:
if (ctx->Driver.CompressedTexSubImage3D) {
- ctx->Driver.CompressedTexSubImage3D(ctx, target, level,
+ ctx->Driver.CompressedTexSubImage3D(ctx, texImage,
xoffset, yoffset, zoffset,
width, height, depth,
- format, imageSize, data,
- texObj, texImage);
+ format, imageSize, data);
}
break;
default:
diff --git a/mesalib/src/mesa/main/teximage.h b/mesalib/src/mesa/main/teximage.h
index 0354c9ac5..12af0e6d6 100644
--- a/mesalib/src/mesa/main/teximage.h
+++ b/mesalib/src/mesa/main/teximage.h
@@ -67,7 +67,7 @@ _mesa_delete_texture_image( struct gl_context *ctx,
extern void
-_mesa_init_teximage_fields(struct gl_context *ctx, GLenum target,
+_mesa_init_teximage_fields(struct gl_context *ctx,
struct gl_texture_image *img,
GLsizei width, GLsizei height, GLsizei depth,
GLint border, GLenum internalFormat,
diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c
index 8e447cabd..7ee200585 100644
--- a/mesalib/src/mesa/main/texobj.c
+++ b/mesalib/src/mesa/main/texobj.c
@@ -793,16 +793,16 @@ _mesa_get_fallback_texture(struct gl_context *ctx)
GL_UNSIGNED_BYTE);
/* init the image fields */
- _mesa_init_teximage_fields(ctx, GL_TEXTURE_2D, texImage,
+ _mesa_init_teximage_fields(ctx, texImage,
8, 8, 1, 0, GL_RGBA, texFormat);
ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
/* set image data */
- ctx->Driver.TexImage2D(ctx, GL_TEXTURE_2D, 0, GL_RGBA,
+ ctx->Driver.TexImage2D(ctx, texImage, GL_RGBA,
8, 8, 0,
GL_RGBA, GL_UNSIGNED_BYTE, texels,
- &ctx->DefaultPacking, texObj, texImage);
+ &ctx->DefaultPacking);
_mesa_test_texobj_completeness(ctx, texObj);
assert(texObj->_Complete);
diff --git a/mesalib/src/mesa/main/texstorage.c b/mesalib/src/mesa/main/texstorage.c
index 241a940cc..5e1f31a93 100644
--- a/mesalib/src/mesa/main/texstorage.c
+++ b/mesalib/src/mesa/main/texstorage.c
@@ -155,7 +155,7 @@ setup_texstorage(struct gl_context *ctx,
return;
}
- _mesa_init_teximage_fields(ctx, target, texImage,
+ _mesa_init_teximage_fields(ctx, texImage,
levelWidth, levelHeight, levelDepth,
0, internalFormat, texFormat);
}
@@ -180,7 +180,7 @@ setup_texstorage(struct gl_context *ctx,
for (face = 0; face < numFaces; face++) {
struct gl_texture_image *texImage = texObj->Image[face][level];
if (texImage) {
- _mesa_init_teximage_fields(ctx, target, texImage,
+ _mesa_init_teximage_fields(ctx, texImage,
0, 0, 0, 0,
GL_NONE, MESA_FORMAT_NONE);
}
@@ -223,7 +223,7 @@ clear_image_fields(struct gl_context *ctx,
return;
}
- _mesa_init_teximage_fields(ctx, target, texImage,
+ _mesa_init_teximage_fields(ctx, texImage,
0, 0, 0, 0, GL_NONE, MESA_FORMAT_NONE);
}
}
diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c
index 86c35d38f..512965fc3 100644
--- a/mesalib/src/mesa/main/texstore.c
+++ b/mesalib/src/mesa/main/texstore.c
@@ -851,7 +851,6 @@ _mesa_swizzle_ubyte_image(struct gl_context *ctx,
const GLubyte *rgba2dst,
GLuint dstComponents,
- GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
GLint dstRowStride,
GLubyte **dstSlices,
@@ -896,9 +895,7 @@ _mesa_swizzle_ubyte_image(struct gl_context *ctx,
srcRowStride == srcWidth * srcComponents &&
dimensions < 3) {
/* 1 and 2D images only */
- GLubyte *dstImage = dstSlices[0]
- + dstYoffset * dstRowStride
- + dstXoffset * dstComponents;
+ GLubyte *dstImage = dstSlices[0];
swizzle_copy(dstImage, dstComponents, srcImage, srcComponents, map,
srcWidth * srcHeight);
}
@@ -906,9 +903,7 @@ _mesa_swizzle_ubyte_image(struct gl_context *ctx,
GLint img, row;
for (img = 0; img < srcDepth; img++) {
const GLubyte *srcRow = srcImage;
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * dstComponents;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
swizzle_copy(dstRow, dstComponents, srcRow, srcComponents, map, srcWidth);
dstRow += dstRowStride;
@@ -929,7 +924,6 @@ static void
memcpy_texture(struct gl_context *ctx,
GLuint dimensions,
gl_format dstFormat,
- GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
GLint dstRowStride,
GLubyte **dstSlices,
GLint srcWidth, GLint srcHeight, GLint srcDepth,
@@ -951,9 +945,7 @@ memcpy_texture(struct gl_context *ctx,
/* memcpy image by image */
GLint img;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstImage = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstImage = dstSlices[img];
memcpy(dstImage, srcImage, bytesPerRow * srcHeight);
srcImage += srcImageStride;
}
@@ -963,9 +955,7 @@ memcpy_texture(struct gl_context *ctx,
GLint img, row;
for (img = 0; img < srcDepth; img++) {
const GLubyte *srcRow = srcImage;
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
memcpy(dstRow, srcRow, bytesPerRow);
dstRow += dstRowStride;
@@ -985,12 +975,11 @@ static GLboolean
_mesa_texstore_z32(TEXSTORE_PARAMS)
{
const GLuint depthScale = 0xffffffff;
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
GLenum dstType;
(void) dims;
ASSERT(dstFormat == MESA_FORMAT_Z32 ||
dstFormat == MESA_FORMAT_Z32_FLOAT);
- ASSERT(texelBytes == sizeof(GLuint));
+ ASSERT(_mesa_get_format_bytes(dstFormat) == sizeof(GLuint));
if (dstFormat == MESA_FORMAT_Z32)
dstType = GL_UNSIGNED_INT;
@@ -1005,7 +994,7 @@ _mesa_texstore_z32(TEXSTORE_PARAMS)
srcType == dstType) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -1014,9 +1003,7 @@ _mesa_texstore_z32(TEXSTORE_PARAMS)
/* general path */
GLint img, row;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
const GLvoid *src = _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
@@ -1038,7 +1025,6 @@ static GLboolean
_mesa_texstore_x8_z24(TEXSTORE_PARAMS)
{
const GLuint depthScale = 0xffffff;
- const GLuint texelBytes = 4;
(void) dims;
ASSERT(dstFormat == MESA_FORMAT_X8_Z24);
@@ -1047,9 +1033,7 @@ _mesa_texstore_x8_z24(TEXSTORE_PARAMS)
/* general path */
GLint img, row;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
const GLvoid *src = _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
@@ -1071,7 +1055,6 @@ static GLboolean
_mesa_texstore_z24_x8(TEXSTORE_PARAMS)
{
const GLuint depthScale = 0xffffff;
- const GLuint texelBytes = 4;
(void) dims;
ASSERT(dstFormat == MESA_FORMAT_Z24_X8);
@@ -1080,9 +1063,7 @@ _mesa_texstore_z24_x8(TEXSTORE_PARAMS)
/* general path */
GLint img, row;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
const GLvoid *src = _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
@@ -1108,10 +1089,9 @@ static GLboolean
_mesa_texstore_z16(TEXSTORE_PARAMS)
{
const GLuint depthScale = 0xffff;
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
(void) dims;
ASSERT(dstFormat == MESA_FORMAT_Z16);
- ASSERT(texelBytes == sizeof(GLushort));
+ ASSERT(_mesa_get_format_bytes(dstFormat) == sizeof(GLushort));
if (ctx->Pixel.DepthScale == 1.0f &&
ctx->Pixel.DepthBias == 0.0f &&
@@ -1121,7 +1101,7 @@ _mesa_texstore_z16(TEXSTORE_PARAMS)
srcType == GL_UNSIGNED_SHORT) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -1130,9 +1110,7 @@ _mesa_texstore_z16(TEXSTORE_PARAMS)
/* general path */
GLint img, row;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
const GLvoid *src = _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
@@ -1154,12 +1132,11 @@ _mesa_texstore_z16(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_rgb565(TEXSTORE_PARAMS)
{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_RGB565 ||
dstFormat == MESA_FORMAT_RGB565_REV);
- ASSERT(texelBytes == 2);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 2);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
@@ -1169,7 +1146,7 @@ _mesa_texstore_rgb565(TEXSTORE_PARAMS)
srcType == GL_UNSIGNED_SHORT_5_6_5) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -1186,9 +1163,7 @@ _mesa_texstore_rgb565(TEXSTORE_PARAMS)
const GLubyte *src = (const GLubyte *)
_mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight,
srcFormat, srcType, 0, 0, 0);
- GLubyte *dst = dstSlices[0]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dst = dstSlices[0];
GLint row, col;
for (row = 0; row < srcHeight; row++) {
const GLubyte *srcUB = (const GLubyte *) src;
@@ -1223,9 +1198,7 @@ _mesa_texstore_rgb565(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLushort *dstUS = (GLushort *) dstRow;
/* check for byteswapped format */
@@ -1261,14 +1234,13 @@ static GLboolean
_mesa_texstore_rgba8888(TEXSTORE_PARAMS)
{
const GLboolean littleEndian = _mesa_little_endian();
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_RGBA8888 ||
dstFormat == MESA_FORMAT_RGBA8888_REV ||
dstFormat == MESA_FORMAT_RGBX8888 ||
dstFormat == MESA_FORMAT_RGBX8888_REV);
- ASSERT(texelBytes == 4);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
@@ -1281,7 +1253,7 @@ _mesa_texstore_rgba8888(TEXSTORE_PARAMS)
(srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && littleEndian))) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -1297,7 +1269,7 @@ _mesa_texstore_rgba8888(TEXSTORE_PARAMS)
(srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && !littleEndian))) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -1334,7 +1306,6 @@ _mesa_texstore_rgba8888(TEXSTORE_PARAMS)
srcType,
baseInternalFormat,
dstmap, 4,
- dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcAddr,
srcPacking);
@@ -1352,9 +1323,7 @@ _mesa_texstore_rgba8888(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLuint *dstUI = (GLuint *) dstRow;
if (dstFormat == MESA_FORMAT_RGBA8888 ||
@@ -1389,14 +1358,13 @@ static GLboolean
_mesa_texstore_argb8888(TEXSTORE_PARAMS)
{
const GLboolean littleEndian = _mesa_little_endian();
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = GL_RGBA;
ASSERT(dstFormat == MESA_FORMAT_ARGB8888 ||
dstFormat == MESA_FORMAT_ARGB8888_REV ||
dstFormat == MESA_FORMAT_XRGB8888 ||
dstFormat == MESA_FORMAT_XRGB8888_REV );
- ASSERT(texelBytes == 4);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
@@ -1408,7 +1376,7 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) {
/* simple memcpy path (little endian) */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -1423,7 +1391,7 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
srcType == GL_UNSIGNED_INT_8_8_8_8)) {
/* simple memcpy path (big endian) */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -1442,9 +1410,7 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
_mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLuint *d4 = (GLuint *) dstRow;
for (col = 0; col < srcWidth; col++) {
@@ -1477,9 +1443,7 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
_mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLuint *d4 = (GLuint *) dstRow;
for (col = 0; col < srcWidth; col++) {
@@ -1529,7 +1493,6 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
srcType,
baseInternalFormat,
dstmap, 4,
- dstXoffset, dstYoffset, dstZoffset,
dstRowStride,
dstSlices,
srcWidth, srcHeight, srcDepth, srcAddr,
@@ -1548,9 +1511,7 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLuint *dstUI = (GLuint *) dstRow;
if (dstFormat == MESA_FORMAT_ARGB8888) {
@@ -1593,11 +1554,10 @@ static GLboolean
_mesa_texstore_rgb888(TEXSTORE_PARAMS)
{
const GLboolean littleEndian = _mesa_little_endian();
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_RGB888);
- ASSERT(texelBytes == 3);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 3);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
@@ -1607,7 +1567,7 @@ _mesa_texstore_rgb888(TEXSTORE_PARAMS)
littleEndian) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -1623,9 +1583,7 @@ _mesa_texstore_rgb888(TEXSTORE_PARAMS)
_mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
for (col = 0; col < srcWidth; col++) {
dstRow[col * 3 + 0] = srcRow[col * 4 + BCOMP];
@@ -1656,7 +1614,6 @@ _mesa_texstore_rgb888(TEXSTORE_PARAMS)
srcType,
baseInternalFormat,
dstmap, 3,
- dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcAddr,
srcPacking);
@@ -1674,9 +1631,7 @@ _mesa_texstore_rgb888(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
#if 0
if (littleEndian) {
@@ -1716,11 +1671,10 @@ static GLboolean
_mesa_texstore_bgr888(TEXSTORE_PARAMS)
{
const GLboolean littleEndian = _mesa_little_endian();
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_BGR888);
- ASSERT(texelBytes == 3);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 3);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
@@ -1730,7 +1684,7 @@ _mesa_texstore_bgr888(TEXSTORE_PARAMS)
littleEndian) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -1746,9 +1700,7 @@ _mesa_texstore_bgr888(TEXSTORE_PARAMS)
_mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
for (col = 0; col < srcWidth; col++) {
dstRow[col * 3 + 0] = srcRow[col * 4 + RCOMP];
@@ -1779,7 +1731,6 @@ _mesa_texstore_bgr888(TEXSTORE_PARAMS)
srcType,
baseInternalFormat,
dstmap, 3,
- dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcAddr,
srcPacking);
@@ -1797,9 +1748,7 @@ _mesa_texstore_bgr888(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
for (col = 0; col < srcWidth; col++) {
dstRow[col * 3 + 0] = src[RCOMP];
@@ -1819,12 +1768,11 @@ _mesa_texstore_bgr888(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_argb4444(TEXSTORE_PARAMS)
{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_ARGB4444 ||
dstFormat == MESA_FORMAT_ARGB4444_REV);
- ASSERT(texelBytes == 2);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 2);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
@@ -1834,7 +1782,7 @@ _mesa_texstore_argb4444(TEXSTORE_PARAMS)
srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -1852,9 +1800,7 @@ _mesa_texstore_argb4444(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLushort *dstUS = (GLushort *) dstRow;
if (dstFormat == MESA_FORMAT_ARGB4444) {
@@ -1886,11 +1832,10 @@ _mesa_texstore_argb4444(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_rgba5551(TEXSTORE_PARAMS)
{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_RGBA5551);
- ASSERT(texelBytes == 2);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 2);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
@@ -1900,7 +1845,7 @@ _mesa_texstore_rgba5551(TEXSTORE_PARAMS)
srcType == GL_UNSIGNED_SHORT_5_5_5_1) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -1918,9 +1863,7 @@ _mesa_texstore_rgba5551(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLushort *dstUS = (GLushort *) dstRow;
for (col = 0; col < srcWidth; col++) {
@@ -1941,12 +1884,11 @@ _mesa_texstore_rgba5551(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_argb1555(TEXSTORE_PARAMS)
{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_ARGB1555 ||
dstFormat == MESA_FORMAT_ARGB1555_REV);
- ASSERT(texelBytes == 2);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 2);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
@@ -1956,7 +1898,7 @@ _mesa_texstore_argb1555(TEXSTORE_PARAMS)
srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -1974,9 +1916,7 @@ _mesa_texstore_argb1555(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLushort *dstUS = (GLushort *) dstRow;
if (dstFormat == MESA_FORMAT_ARGB1555) {
@@ -2009,11 +1949,10 @@ _mesa_texstore_argb1555(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_argb2101010(TEXSTORE_PARAMS)
{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_ARGB2101010);
- ASSERT(texelBytes == 4);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
@@ -2023,7 +1962,7 @@ _mesa_texstore_argb2101010(TEXSTORE_PARAMS)
baseInternalFormat == GL_RGBA) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -2042,9 +1981,7 @@ _mesa_texstore_argb2101010(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
if (baseInternalFormat == GL_RGBA) {
for (row = 0; row < srcHeight; row++) {
GLuint *dstUI = (GLuint *) dstRow;
@@ -2090,11 +2027,10 @@ _mesa_texstore_argb2101010(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_unorm44(TEXSTORE_PARAMS)
{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_AL44);
- ASSERT(texelBytes == 1);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 1);
{
/* general path */
@@ -2109,9 +2045,7 @@ _mesa_texstore_unorm44(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLubyte *dstUS = (GLubyte *) dstRow;
for (col = 0; col < srcWidth; col++) {
@@ -2136,14 +2070,13 @@ static GLboolean
_mesa_texstore_unorm88(TEXSTORE_PARAMS)
{
const GLboolean littleEndian = _mesa_little_endian();
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_AL88 ||
dstFormat == MESA_FORMAT_AL88_REV ||
dstFormat == MESA_FORMAT_GR88 ||
dstFormat == MESA_FORMAT_RG88);
- ASSERT(texelBytes == 2);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 2);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
@@ -2156,7 +2089,7 @@ _mesa_texstore_unorm88(TEXSTORE_PARAMS)
littleEndian) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -2200,7 +2133,6 @@ _mesa_texstore_unorm88(TEXSTORE_PARAMS)
srcType,
baseInternalFormat,
dstmap, 2,
- dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcAddr,
srcPacking);
@@ -2218,9 +2150,7 @@ _mesa_texstore_unorm88(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLushort *dstUS = (GLushort *) dstRow;
if (dstFormat == MESA_FORMAT_AL88 ||
@@ -2256,14 +2186,13 @@ static GLboolean
_mesa_texstore_unorm1616(TEXSTORE_PARAMS)
{
const GLboolean littleEndian = _mesa_little_endian();
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_AL1616 ||
dstFormat == MESA_FORMAT_AL1616_REV ||
dstFormat == MESA_FORMAT_RG1616 ||
dstFormat == MESA_FORMAT_RG1616_REV);
- ASSERT(texelBytes == 4);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
@@ -2276,7 +2205,7 @@ _mesa_texstore_unorm1616(TEXSTORE_PARAMS)
littleEndian) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -2295,9 +2224,7 @@ _mesa_texstore_unorm1616(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLuint *dstUI = (GLuint *) dstRow;
if (dstFormat == MESA_FORMAT_AL1616 ||
@@ -2335,14 +2262,13 @@ static GLboolean
_mesa_texstore_unorm16(TEXSTORE_PARAMS)
{
const GLboolean littleEndian = _mesa_little_endian();
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_R16 ||
dstFormat == MESA_FORMAT_A16 ||
dstFormat == MESA_FORMAT_L16 ||
dstFormat == MESA_FORMAT_I16);
- ASSERT(texelBytes == 2);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 2);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
@@ -2351,7 +2277,7 @@ _mesa_texstore_unorm16(TEXSTORE_PARAMS)
littleEndian) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -2370,9 +2296,7 @@ _mesa_texstore_unorm16(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLushort *dstUS = (GLushort *) dstRow;
for (col = 0; col < srcWidth; col++) {
@@ -2394,11 +2318,10 @@ _mesa_texstore_unorm16(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_rgba_16(TEXSTORE_PARAMS)
{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_RGBA_16);
- ASSERT(texelBytes == 8);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 8);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
@@ -2407,7 +2330,7 @@ _mesa_texstore_rgba_16(TEXSTORE_PARAMS)
srcType == GL_UNSIGNED_SHORT) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -2426,9 +2349,7 @@ _mesa_texstore_rgba_16(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLushort *dstUS = (GLushort *) dstRow;
for (col = 0; col < srcWidth; col++) {
@@ -2456,7 +2377,6 @@ _mesa_texstore_rgba_16(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_signed_rgba_16(TEXSTORE_PARAMS)
{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGB_16 ||
@@ -2470,7 +2390,7 @@ _mesa_texstore_signed_rgba_16(TEXSTORE_PARAMS)
srcType == GL_SHORT) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -2495,9 +2415,7 @@ _mesa_texstore_signed_rgba_16(TEXSTORE_PARAMS)
* 3 or 4 components/pixel here.
*/
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLshort *dstRowS = (GLshort *) dstRow;
if (dstFormat == MESA_FORMAT_SIGNED_RGBA_16) {
@@ -2534,11 +2452,10 @@ _mesa_texstore_signed_rgba_16(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_rgb332(TEXSTORE_PARAMS)
{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_RGB332);
- ASSERT(texelBytes == 1);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 1);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
@@ -2546,7 +2463,7 @@ _mesa_texstore_rgb332(TEXSTORE_PARAMS)
srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE_3_3_2) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -2564,9 +2481,7 @@ _mesa_texstore_rgb332(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
for (col = 0; col < srcWidth; col++) {
dstRow[col] = PACK_COLOR_332( src[RCOMP],
@@ -2589,14 +2504,13 @@ _mesa_texstore_rgb332(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_unorm8(TEXSTORE_PARAMS)
{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_A8 ||
dstFormat == MESA_FORMAT_L8 ||
dstFormat == MESA_FORMAT_I8 ||
dstFormat == MESA_FORMAT_R8);
- ASSERT(texelBytes == 1);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 1);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
@@ -2604,7 +2518,7 @@ _mesa_texstore_unorm8(TEXSTORE_PARAMS)
srcType == GL_UNSIGNED_BYTE) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -2632,7 +2546,6 @@ _mesa_texstore_unorm8(TEXSTORE_PARAMS)
srcType,
baseInternalFormat,
dstmap, 1,
- dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcAddr,
srcPacking);
@@ -2650,9 +2563,7 @@ _mesa_texstore_unorm8(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
for (col = 0; col < srcWidth; col++) {
dstRow[col] = src[col];
@@ -2675,13 +2586,12 @@ static GLboolean
_mesa_texstore_ycbcr(TEXSTORE_PARAMS)
{
const GLboolean littleEndian = _mesa_little_endian();
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
(void) ctx; (void) dims; (void) baseInternalFormat;
ASSERT((dstFormat == MESA_FORMAT_YCBCR) ||
(dstFormat == MESA_FORMAT_YCBCR_REV));
- ASSERT(texelBytes == 2);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 2);
ASSERT(ctx->Extensions.MESA_ycbcr_texture);
ASSERT(srcFormat == GL_YCBCR_MESA);
ASSERT((srcType == GL_UNSIGNED_SHORT_8_8_MESA) ||
@@ -2690,7 +2600,7 @@ _mesa_texstore_ycbcr(TEXSTORE_PARAMS)
/* always just memcpy since no pixel transfer ops apply */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -2703,9 +2613,7 @@ _mesa_texstore_ycbcr(TEXSTORE_PARAMS)
!littleEndian) {
GLint img, row;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
_mesa_swap2((GLushort *) dstRow, srcWidth);
dstRow += dstRowStride;
@@ -2732,7 +2640,7 @@ _mesa_texstore_dudv8(TEXSTORE_PARAMS)
littleEndian) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -2758,7 +2666,6 @@ _mesa_texstore_dudv8(TEXSTORE_PARAMS)
GL_UNSIGNED_BYTE, /* hack */
GL_LUMINANCE_ALPHA, /* hack */
dstmap, 2,
- dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcAddr,
srcPacking);
@@ -2791,9 +2698,7 @@ _mesa_texstore_dudv8(TEXSTORE_PARAMS)
}
src = tempImage;
- dst = (GLbyte *) dstSlices[0]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ dst = (GLbyte *) dstSlices[0];
for (row = 0; row < srcHeight; row++) {
memcpy(dst, src, srcWidth * texelBytes);
dst += dstRowStride;
@@ -2811,14 +2716,13 @@ _mesa_texstore_dudv8(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_snorm8(TEXSTORE_PARAMS)
{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_SIGNED_A8 ||
dstFormat == MESA_FORMAT_SIGNED_L8 ||
dstFormat == MESA_FORMAT_SIGNED_I8 ||
dstFormat == MESA_FORMAT_SIGNED_R8);
- ASSERT(texelBytes == 1);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 1);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
@@ -2826,7 +2730,7 @@ _mesa_texstore_snorm8(TEXSTORE_PARAMS)
srcType == GL_BYTE) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -2845,9 +2749,7 @@ _mesa_texstore_snorm8(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLbyte *dstRow = (GLbyte *) dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLbyte *dstRow = (GLbyte *) dstSlices[img];
for (row = 0; row < srcHeight; row++) {
for (col = 0; col < srcWidth; col++) {
dstRow[col] = FLOAT_TO_BYTE_TEX(src[col]);
@@ -2869,12 +2771,11 @@ static GLboolean
_mesa_texstore_snorm88(TEXSTORE_PARAMS)
{
const GLboolean littleEndian = _mesa_little_endian();
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_SIGNED_AL88 ||
dstFormat == MESA_FORMAT_SIGNED_RG88_REV);
- ASSERT(texelBytes == 2);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 2);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
@@ -2883,7 +2784,7 @@ _mesa_texstore_snorm88(TEXSTORE_PARAMS)
littleEndian) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -2902,9 +2803,7 @@ _mesa_texstore_snorm88(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLbyte *dstRow = (GLbyte *) dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLbyte *dstRow = (GLbyte *) dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLbyte *dst = dstRow;
for (col = 0; col < srcWidth; col++) {
@@ -2926,14 +2825,13 @@ static GLboolean
_mesa_texstore_snorm16(TEXSTORE_PARAMS)
{
const GLboolean littleEndian = _mesa_little_endian();
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_SIGNED_R16 ||
dstFormat == MESA_FORMAT_SIGNED_A16 ||
dstFormat == MESA_FORMAT_SIGNED_L16 ||
dstFormat == MESA_FORMAT_SIGNED_I16);
- ASSERT(texelBytes == 2);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 2);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
@@ -2942,7 +2840,7 @@ _mesa_texstore_snorm16(TEXSTORE_PARAMS)
littleEndian) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -2961,9 +2859,7 @@ _mesa_texstore_snorm16(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLshort *dstUS = (GLshort *) dstRow;
for (col = 0; col < srcWidth; col++) {
@@ -2988,12 +2884,11 @@ static GLboolean
_mesa_texstore_snorm1616(TEXSTORE_PARAMS)
{
const GLboolean littleEndian = _mesa_little_endian();
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_SIGNED_AL1616 ||
dstFormat == MESA_FORMAT_SIGNED_GR1616);
- ASSERT(texelBytes == 4);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
@@ -3002,7 +2897,7 @@ _mesa_texstore_snorm1616(TEXSTORE_PARAMS)
littleEndian) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -3021,9 +2916,7 @@ _mesa_texstore_snorm1616(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLshort *dst = (GLshort *) dstRow;
for (col = 0; col < srcWidth; col++) {
@@ -3050,11 +2943,10 @@ _mesa_texstore_snorm1616(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_signed_rgbx8888(TEXSTORE_PARAMS)
{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGBX8888);
- ASSERT(texelBytes == 4);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
{
/* general path */
@@ -3070,9 +2962,7 @@ _mesa_texstore_signed_rgbx8888(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLbyte *dstRow = (GLbyte *) dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLbyte *dstRow = (GLbyte *) dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLbyte *dst = dstRow;
for (col = 0; col < srcWidth; col++) {
@@ -3101,12 +2991,11 @@ static GLboolean
_mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS)
{
const GLboolean littleEndian = _mesa_little_endian();
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGBA8888 ||
dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV);
- ASSERT(texelBytes == 4);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
@@ -3116,7 +3005,7 @@ _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS)
(srcFormat == GL_ABGR_EXT && srcType == GL_BYTE && littleEndian))) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -3129,7 +3018,7 @@ _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS)
(srcFormat == GL_ABGR_EXT && srcType == GL_BYTE && !littleEndian))) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -3148,9 +3037,7 @@ _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLbyte *dstRow = (GLbyte *) dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLbyte *dstRow = (GLbyte *) dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLbyte *dst = dstRow;
if (dstFormat == MESA_FORMAT_SIGNED_RGBA8888) {
@@ -3204,7 +3091,7 @@ _mesa_texstore_z24_s8(TEXSTORE_PARAMS)
!srcPacking->SwapBytes) {
/* simple path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -3213,9 +3100,7 @@ _mesa_texstore_z24_s8(TEXSTORE_PARAMS)
srcFormat == GL_STENCIL_INDEX) {
/* In case we only upload depth we need to preserve the stencil */
for (img = 0; img < srcDepth; img++) {
- GLuint *dstRow = (GLuint *) (dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * 4);
+ GLuint *dstRow = (GLuint *) dstSlices[img];
const GLubyte *src
= (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
srcWidth, srcHeight,
@@ -3285,9 +3170,7 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS)
srcType == GL_UNSIGNED_INT_24_8_EXT);
for (img = 0; img < srcDepth; img++) {
- GLuint *dstRow = (GLuint *) (dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * 4);
+ GLuint *dstRow = (GLuint *) dstSlices[img];
const GLubyte *src
= (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
srcWidth, srcHeight,
@@ -3353,7 +3236,7 @@ _mesa_texstore_s8(TEXSTORE_PARAMS)
srcType == GL_UNSIGNED_BYTE) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -3364,9 +3247,7 @@ _mesa_texstore_s8(TEXSTORE_PARAMS)
GLint img, row;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride / sizeof(GLuint)
- + dstXoffset;
+ GLubyte *dstRow = dstSlices[img];
const GLubyte *src
= (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
srcWidth, srcHeight,
@@ -3409,7 +3290,6 @@ _mesa_texstore_s8(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_rgba_float32(TEXSTORE_PARAMS)
{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
const GLint components = _mesa_components_in_format(baseFormat);
@@ -3429,7 +3309,7 @@ _mesa_texstore_rgba_float32(TEXSTORE_PARAMS)
baseInternalFormat == GL_INTENSITY ||
baseInternalFormat == GL_RED ||
baseInternalFormat == GL_RG);
- ASSERT(texelBytes == components * sizeof(GLfloat));
+ ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLfloat));
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
@@ -3438,7 +3318,7 @@ _mesa_texstore_rgba_float32(TEXSTORE_PARAMS)
srcType == GL_FLOAT) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -3459,9 +3339,7 @@ _mesa_texstore_rgba_float32(TEXSTORE_PARAMS)
return GL_FALSE;
bytesPerRow = srcWidth * components * sizeof(GLfloat);
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
memcpy(dstRow, srcRow, bytesPerRow);
dstRow += dstRowStride;
@@ -3482,7 +3360,6 @@ _mesa_texstore_rgba_float32(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_rgba_float16(TEXSTORE_PARAMS)
{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
const GLint components = _mesa_components_in_format(baseFormat);
@@ -3502,7 +3379,7 @@ _mesa_texstore_rgba_float16(TEXSTORE_PARAMS)
baseInternalFormat == GL_INTENSITY ||
baseInternalFormat == GL_RED ||
baseInternalFormat == GL_RG);
- ASSERT(texelBytes == components * sizeof(GLhalfARB));
+ ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLhalfARB));
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
@@ -3511,7 +3388,7 @@ _mesa_texstore_rgba_float16(TEXSTORE_PARAMS)
srcType == GL_HALF_FLOAT_ARB) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -3530,9 +3407,7 @@ _mesa_texstore_rgba_float16(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLhalfARB *dstTexel = (GLhalfARB *) dstRow;
GLint i;
@@ -3554,7 +3429,6 @@ _mesa_texstore_rgba_float16(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_rgba_int8(TEXSTORE_PARAMS)
{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
const GLint components = _mesa_components_in_format(baseFormat);
@@ -3574,7 +3448,7 @@ _mesa_texstore_rgba_int8(TEXSTORE_PARAMS)
baseInternalFormat == GL_LUMINANCE ||
baseInternalFormat == GL_LUMINANCE_ALPHA ||
baseInternalFormat == GL_INTENSITY);
- ASSERT(texelBytes == components * sizeof(GLbyte));
+ ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLbyte));
/* Note: Pixel transfer ops (scale, bias, table lookup) do not apply
* to integer formats.
@@ -3584,7 +3458,7 @@ _mesa_texstore_rgba_int8(TEXSTORE_PARAMS)
srcType == GL_BYTE) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -3602,9 +3476,7 @@ _mesa_texstore_rgba_int8(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLbyte *dstTexel = (GLbyte *) dstRow;
GLint i;
@@ -3626,7 +3498,6 @@ _mesa_texstore_rgba_int8(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_rgba_int16(TEXSTORE_PARAMS)
{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
const GLint components = _mesa_components_in_format(baseFormat);
@@ -3646,7 +3517,7 @@ _mesa_texstore_rgba_int16(TEXSTORE_PARAMS)
baseInternalFormat == GL_LUMINANCE ||
baseInternalFormat == GL_LUMINANCE_ALPHA ||
baseInternalFormat == GL_INTENSITY);
- ASSERT(texelBytes == components * sizeof(GLshort));
+ ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLshort));
/* Note: Pixel transfer ops (scale, bias, table lookup) do not apply
* to integer formats.
@@ -3656,7 +3527,7 @@ _mesa_texstore_rgba_int16(TEXSTORE_PARAMS)
srcType == GL_SHORT) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -3674,9 +3545,7 @@ _mesa_texstore_rgba_int16(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLshort *dstTexel = (GLshort *) dstRow;
GLint i;
@@ -3698,7 +3567,6 @@ _mesa_texstore_rgba_int16(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_rgba_int32(TEXSTORE_PARAMS)
{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
const GLint components = _mesa_components_in_format(baseFormat);
@@ -3718,7 +3586,7 @@ _mesa_texstore_rgba_int32(TEXSTORE_PARAMS)
baseInternalFormat == GL_LUMINANCE ||
baseInternalFormat == GL_LUMINANCE_ALPHA ||
baseInternalFormat == GL_INTENSITY);
- ASSERT(texelBytes == components * sizeof(GLint));
+ ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLint));
/* Note: Pixel transfer ops (scale, bias, table lookup) do not apply
* to integer formats.
@@ -3728,7 +3596,7 @@ _mesa_texstore_rgba_int32(TEXSTORE_PARAMS)
srcType == GL_INT) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -3746,9 +3614,7 @@ _mesa_texstore_rgba_int32(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLint *dstTexel = (GLint *) dstRow;
GLint i;
@@ -3770,7 +3636,6 @@ _mesa_texstore_rgba_int32(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_rgba_uint8(TEXSTORE_PARAMS)
{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
const GLint components = _mesa_components_in_format(baseFormat);
@@ -3790,7 +3655,7 @@ _mesa_texstore_rgba_uint8(TEXSTORE_PARAMS)
baseInternalFormat == GL_LUMINANCE ||
baseInternalFormat == GL_LUMINANCE_ALPHA ||
baseInternalFormat == GL_INTENSITY);
- ASSERT(texelBytes == components * sizeof(GLubyte));
+ ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLubyte));
/* Note: Pixel transfer ops (scale, bias, table lookup) do not apply
* to integer formats.
@@ -3800,7 +3665,7 @@ _mesa_texstore_rgba_uint8(TEXSTORE_PARAMS)
srcType == GL_UNSIGNED_BYTE) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -3816,9 +3681,7 @@ _mesa_texstore_rgba_uint8(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLubyte *dstTexel = (GLubyte *) dstRow;
GLint i;
@@ -3840,7 +3703,6 @@ _mesa_texstore_rgba_uint8(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_rgba_uint16(TEXSTORE_PARAMS)
{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
const GLint components = _mesa_components_in_format(baseFormat);
@@ -3860,7 +3722,7 @@ _mesa_texstore_rgba_uint16(TEXSTORE_PARAMS)
baseInternalFormat == GL_LUMINANCE ||
baseInternalFormat == GL_LUMINANCE_ALPHA ||
baseInternalFormat == GL_INTENSITY);
- ASSERT(texelBytes == components * sizeof(GLushort));
+ ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLushort));
/* Note: Pixel transfer ops (scale, bias, table lookup) do not apply
* to integer formats.
@@ -3870,7 +3732,7 @@ _mesa_texstore_rgba_uint16(TEXSTORE_PARAMS)
srcType == GL_UNSIGNED_SHORT) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -3886,9 +3748,7 @@ _mesa_texstore_rgba_uint16(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLushort *dstTexel = (GLushort *) dstRow;
GLint i;
@@ -3910,7 +3770,6 @@ _mesa_texstore_rgba_uint16(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_rgba_uint32(TEXSTORE_PARAMS)
{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
const GLint components = _mesa_components_in_format(baseFormat);
@@ -3930,7 +3789,7 @@ _mesa_texstore_rgba_uint32(TEXSTORE_PARAMS)
baseInternalFormat == GL_LUMINANCE ||
baseInternalFormat == GL_LUMINANCE_ALPHA ||
baseInternalFormat == GL_INTENSITY);
- ASSERT(texelBytes == components * sizeof(GLuint));
+ ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLuint));
/* Note: Pixel transfer ops (scale, bias, table lookup) do not apply
* to integer formats.
@@ -3940,7 +3799,7 @@ _mesa_texstore_rgba_uint32(TEXSTORE_PARAMS)
srcType == GL_UNSIGNED_INT) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -3956,9 +3815,7 @@ _mesa_texstore_rgba_uint32(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLuint *dstTexel = (GLuint *) dstRow;
GLint i;
@@ -3992,7 +3849,6 @@ _mesa_texstore_srgb8(TEXSTORE_PARAMS)
k = _mesa_texstore_rgb888(ctx, dims, baseInternalFormat,
newDstFormat,
- dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth,
srcFormat, srcType,
@@ -4013,7 +3869,6 @@ _mesa_texstore_srgba8(TEXSTORE_PARAMS)
newDstFormat = MESA_FORMAT_RGBA8888;
k = _mesa_texstore_rgba8888(ctx, dims, baseInternalFormat,
newDstFormat,
- dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth,
srcFormat, srcType,
@@ -4035,7 +3890,6 @@ _mesa_texstore_sargb8(TEXSTORE_PARAMS)
k = _mesa_texstore_argb8888(ctx, dims, baseInternalFormat,
newDstFormat,
- dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth,
srcFormat, srcType,
@@ -4057,7 +3911,6 @@ _mesa_texstore_sl8(TEXSTORE_PARAMS)
/* _mesa_textore_a8 handles luminance8 too */
k = _mesa_texstore_unorm8(ctx, dims, baseInternalFormat,
newDstFormat,
- dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth,
srcFormat, srcType,
@@ -4079,7 +3932,6 @@ _mesa_texstore_sla8(TEXSTORE_PARAMS)
k = _mesa_texstore_unorm88(ctx, dims, baseInternalFormat,
newDstFormat,
- dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth,
srcFormat, srcType,
@@ -4112,7 +3964,7 @@ _mesa_texstore_rgb9_e5(TEXSTORE_PARAMS)
srcType == GL_UNSIGNED_INT_5_9_9_9_REV) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -4131,9 +3983,7 @@ _mesa_texstore_rgb9_e5(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * 4;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLuint *dstUI = (GLuint*)dstRow;
for (col = 0; col < srcWidth; col++) {
@@ -4163,7 +4013,7 @@ _mesa_texstore_r11_g11_b10f(TEXSTORE_PARAMS)
srcType == GL_UNSIGNED_INT_10F_11F_11F_REV) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -4182,9 +4032,7 @@ _mesa_texstore_r11_g11_b10f(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * 4;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLuint *dstUI = (GLuint*)dstRow;
for (col = 0; col < srcWidth; col++) {
@@ -4217,7 +4065,7 @@ _mesa_texstore_z32f_x24s8(TEXSTORE_PARAMS)
!srcPacking->SwapBytes) {
/* simple path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -4231,9 +4079,7 @@ _mesa_texstore_z32f_x24s8(TEXSTORE_PARAMS)
/* In case we only upload depth we need to preserve the stencil */
for (img = 0; img < srcDepth; img++) {
- uint64_t *dstRow = (uint64_t *) (dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * 8);
+ uint64_t *dstRow = (uint64_t *) dstSlices[img];
const uint64_t *src
= (const uint64_t *) _mesa_image_address(dims, srcPacking, srcAddr,
srcWidth, srcHeight,
@@ -4268,11 +4114,10 @@ _mesa_texstore_z32f_x24s8(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_argb2101010_uint(TEXSTORE_PARAMS)
{
- const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_ARGB2101010_UINT);
- ASSERT(texelBytes == 4);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
if (!srcPacking->SwapBytes &&
dstFormat == MESA_FORMAT_ARGB2101010_UINT &&
@@ -4281,7 +4126,7 @@ _mesa_texstore_argb2101010_uint(TEXSTORE_PARAMS)
baseInternalFormat == GL_RGBA) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -4300,9 +4145,7 @@ _mesa_texstore_argb2101010_uint(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[dstZoffset + img]
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
+ GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
GLuint *dstUI = (GLuint *) dstRow;
@@ -4329,7 +4172,6 @@ _mesa_texstore_null(TEXSTORE_PARAMS)
(void) ctx; (void) dims;
(void) baseInternalFormat;
(void) dstFormat;
- (void) dstXoffset; (void) dstYoffset; (void) dstZoffset;
(void) dstRowStride; (void) dstSlices,
(void) srcWidth; (void) srcHeight; (void) srcDepth;
(void) srcFormat; (void) srcType;
@@ -4539,7 +4381,7 @@ _mesa_texstore(TEXSTORE_PARAMS)
storeImage = _mesa_get_texstore_func(dstFormat);
success = storeImage(ctx, dims, baseInternalFormat,
- dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstFormat,
dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth,
srcFormat, srcType, srcAddr, srcPacking);
@@ -4671,7 +4513,6 @@ store_texsubimage(struct gl_context *ctx,
*/
success = _mesa_texstore(ctx, dims, texImage->_BaseFormat,
texImage->TexFormat,
- 0, 0, 0, /* dstX/Y/Zoffset */
dstRowStride,
&dstMap,
width, height, 1, /* w, h, d */
@@ -4698,13 +4539,12 @@ store_texsubimage(struct gl_context *ctx,
* This is the fallback for Driver.TexImage1D().
*/
void
-_mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_store_teximage1d(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint internalFormat,
GLint width, GLint border,
GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
+ const struct gl_pixelstore_attrib *packing)
{
if (width == 0)
return;
@@ -4726,13 +4566,12 @@ _mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level,
* This is the fallback for Driver.TexImage2D().
*/
void
-_mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_store_teximage2d(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint internalFormat,
GLint width, GLint height, GLint border,
GLenum format, GLenum type, const void *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
+ const struct gl_pixelstore_attrib *packing)
{
if (width == 0 || height == 0)
return;
@@ -4755,13 +4594,12 @@ _mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level,
* This is the fallback for Driver.TexImage3D().
*/
void
-_mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_store_teximage3d(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint internalFormat,
GLint width, GLint height, GLint depth, GLint border,
GLenum format, GLenum type, const void *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
+ const struct gl_pixelstore_attrib *packing)
{
if (width == 0 || height == 0 || depth == 0)
return;
@@ -4785,12 +4623,11 @@ _mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level,
* This is the fallback for Driver.TexSubImage1D().
*/
void
-_mesa_store_texsubimage1d(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_store_texsubimage1d(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint xoffset, GLint width,
GLenum format, GLenum type, const void *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
+ const struct gl_pixelstore_attrib *packing)
{
store_texsubimage(ctx, texImage,
xoffset, 0, 0, width, 1, 1,
@@ -4803,13 +4640,12 @@ _mesa_store_texsubimage1d(struct gl_context *ctx, GLenum target, GLint level,
* This is the fallback for Driver.TexSubImage2D().
*/
void
-_mesa_store_texsubimage2d(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_store_texsubimage2d(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint xoffset, GLint yoffset,
GLint width, GLint height,
GLenum format, GLenum type, const void *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
+ const struct gl_pixelstore_attrib *packing)
{
store_texsubimage(ctx, texImage,
xoffset, yoffset, 0, width, height, 1,
@@ -4821,13 +4657,12 @@ _mesa_store_texsubimage2d(struct gl_context *ctx, GLenum target, GLint level,
* This is the fallback for Driver.TexSubImage3D().
*/
void
-_mesa_store_texsubimage3d(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_store_texsubimage3d(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint xoffset, GLint yoffset, GLint zoffset,
GLint width, GLint height, GLint depth,
GLenum format, GLenum type, const void *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
+ const struct gl_pixelstore_attrib *packing)
{
store_texsubimage(ctx, texImage,
xoffset, yoffset, zoffset, width, height, depth,
@@ -4840,20 +4675,16 @@ _mesa_store_texsubimage3d(struct gl_context *ctx, GLenum target, GLint level,
*/
void
_mesa_store_compressed_teximage1d(struct gl_context *ctx,
- GLenum target, GLint level,
+ struct gl_texture_image *texImage,
GLint internalFormat,
GLint width, GLint border,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
+ GLsizei imageSize, const GLvoid *data)
{
- /* this space intentionally left blank */
+ /* no compressed 1D image formats at this time */
(void) ctx;
- (void) target; (void) level;
(void) internalFormat;
(void) width; (void) border;
(void) imageSize; (void) data;
- (void) texObj;
(void) texImage;
}
@@ -4864,18 +4695,15 @@ _mesa_store_compressed_teximage1d(struct gl_context *ctx,
*/
void
_mesa_store_compressed_teximage2d(struct gl_context *ctx,
- GLenum target, GLint level,
+ struct gl_texture_image *texImage,
GLint internalFormat,
GLint width, GLint height, GLint border,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
+ GLsizei imageSize, const GLvoid *data)
{
/* This is pretty simple, because unlike the general texstore path we don't
* have to worry about the usual image unpacking or image transfer
* operations.
*/
- ASSERT(texObj);
ASSERT(texImage);
ASSERT(texImage->Width > 0);
ASSERT(texImage->Height > 0);
@@ -4888,12 +4716,11 @@ _mesa_store_compressed_teximage2d(struct gl_context *ctx,
return;
}
- _mesa_store_compressed_texsubimage2d(ctx, target, level,
+ _mesa_store_compressed_texsubimage2d(ctx, texImage,
0, 0,
width, height,
texImage->TexFormat,
- imageSize, data,
- texObj, texImage);
+ imageSize, data);
}
@@ -4903,22 +4730,18 @@ _mesa_store_compressed_teximage2d(struct gl_context *ctx,
*/
void
_mesa_store_compressed_teximage3d(struct gl_context *ctx,
- GLenum target, GLint level,
+ struct gl_texture_image *texImage,
GLint internalFormat,
GLint width, GLint height, GLint depth,
GLint border,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
+ GLsizei imageSize, const GLvoid *data)
{
/* this space intentionally left blank */
(void) ctx;
- (void) target; (void) level;
(void) internalFormat;
(void) width; (void) height; (void) depth;
(void) border;
(void) imageSize; (void) data;
- (void) texObj;
(void) texImage;
}
@@ -4928,21 +4751,17 @@ _mesa_store_compressed_teximage3d(struct gl_context *ctx,
* Fallback for Driver.CompressedTexSubImage1D()
*/
void
-_mesa_store_compressed_texsubimage1d(struct gl_context *ctx, GLenum target,
- GLint level,
+_mesa_store_compressed_texsubimage1d(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint xoffset, GLsizei width,
GLenum format,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
+ GLsizei imageSize, const GLvoid *data)
{
/* there are no compressed 1D texture formats yet */
(void) ctx;
- (void) target; (void) level;
(void) xoffset; (void) width;
(void) format;
(void) imageSize; (void) data;
- (void) texObj;
(void) texImage;
}
@@ -4951,14 +4770,12 @@ _mesa_store_compressed_texsubimage1d(struct gl_context *ctx, GLenum target,
* Fallback for Driver.CompressedTexSubImage2D()
*/
void
-_mesa_store_compressed_texsubimage2d(struct gl_context *ctx, GLenum target,
- GLint level,
+_mesa_store_compressed_texsubimage2d(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height,
GLenum format,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
+ GLsizei imageSize, const GLvoid *data)
{
GLint bytesPerRow, dstRowStride, srcRowStride;
GLint i, rows;
@@ -5016,22 +4833,18 @@ _mesa_store_compressed_texsubimage2d(struct gl_context *ctx, GLenum target,
* Fallback for Driver.CompressedTexSubImage3D()
*/
void
-_mesa_store_compressed_texsubimage3d(struct gl_context *ctx, GLenum target,
- GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth,
- GLenum format,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
+_mesa_store_compressed_texsubimage3d(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format,
+ GLsizei imageSize, const GLvoid *data)
{
/* there are no compressed 3D texture formats yet */
(void) ctx;
- (void) target; (void) level;
(void) xoffset; (void) yoffset; (void) zoffset;
(void) width; (void) height; (void) depth;
(void) format;
(void) imageSize; (void) data;
- (void) texObj;
(void) texImage;
}
diff --git a/mesalib/src/mesa/main/texstore.h b/mesalib/src/mesa/main/texstore.h
index f956b0436..85e33b0fe 100644
--- a/mesalib/src/mesa/main/texstore.h
+++ b/mesalib/src/mesa/main/texstore.h
@@ -58,7 +58,6 @@
struct gl_context *ctx, GLuint dims, \
GLenum baseInternalFormat, \
gl_format dstFormat, \
- GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, \
GLint dstRowStride, \
GLubyte **dstSlices, \
GLint srcWidth, GLint srcHeight, GLint srcDepth, \
@@ -91,118 +90,103 @@ _mesa_make_temp_float_image(struct gl_context *ctx, GLuint dims,
GLbitfield transferOps);
extern void
-_mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_store_teximage1d(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint internalFormat,
GLint width, GLint border,
GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
+ const struct gl_pixelstore_attrib *packing);
extern void
-_mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_store_teximage2d(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint internalFormat,
GLint width, GLint height, GLint border,
GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
+ const struct gl_pixelstore_attrib *packing);
extern void
-_mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_store_teximage3d(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint internalFormat,
GLint width, GLint height, GLint depth, GLint border,
GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
+ const struct gl_pixelstore_attrib *packing);
extern void
-_mesa_store_texsubimage1d(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_store_texsubimage1d(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint xoffset, GLint width,
GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
+ const struct gl_pixelstore_attrib *packing);
extern void
-_mesa_store_texsubimage2d(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_store_texsubimage2d(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint xoffset, GLint yoffset,
GLint width, GLint height,
GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
+ const struct gl_pixelstore_attrib *packing);
extern void
-_mesa_store_texsubimage3d(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_store_texsubimage3d(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint xoffset, GLint yoffset, GLint zoffset,
GLint width, GLint height, GLint depth,
GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
+ const struct gl_pixelstore_attrib *packing);
extern void
-_mesa_store_compressed_teximage1d(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_store_compressed_teximage1d(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint internalFormat,
GLint width, GLint border,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
+ GLsizei imageSize, const GLvoid *data);
extern void
-_mesa_store_compressed_teximage2d(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_store_compressed_teximage2d(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint internalFormat,
GLint width, GLint height, GLint border,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
+ GLsizei imageSize, const GLvoid *data);
extern void
-_mesa_store_compressed_teximage3d(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_store_compressed_teximage3d(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint internalFormat,
GLint width, GLint height, GLint depth,
GLint border,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
+ GLsizei imageSize, const GLvoid *data);
extern void
-_mesa_store_compressed_texsubimage1d(struct gl_context *ctx, GLenum target,
- GLint level,
+_mesa_store_compressed_texsubimage1d(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint xoffset, GLsizei width,
GLenum format,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
+ GLsizei imageSize, const GLvoid *data);
extern void
-_mesa_store_compressed_texsubimage2d(struct gl_context *ctx, GLenum target,
- GLint level,
+_mesa_store_compressed_texsubimage2d(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height,
GLenum format,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
+ GLsizei imageSize, const GLvoid *data);
extern void
-_mesa_store_compressed_texsubimage3d(struct gl_context *ctx, GLenum target,
- GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth,
- GLenum format,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage);
+_mesa_store_compressed_texsubimage3d(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format,
+ GLsizei imageSize, const GLvoid *data);
#endif
diff --git a/mesalib/src/mesa/main/transformfeedback.c b/mesalib/src/mesa/main/transformfeedback.c
index be0d0ff19..c2114c227 100644
--- a/mesalib/src/mesa/main/transformfeedback.c
+++ b/mesalib/src/mesa/main/transformfeedback.c
@@ -342,10 +342,26 @@ void GLAPIENTRY
_mesa_BeginTransformFeedback(GLenum mode)
{
struct gl_transform_feedback_object *obj;
+ struct gl_transform_feedback_info *info;
+ int i;
GET_CURRENT_CONTEXT(ctx);
obj = ctx->TransformFeedback.CurrentObject;
+ if (ctx->Shader.CurrentVertexProgram == NULL) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBeginTransformFeedback(no program active)");
+ return;
+ }
+
+ info = &ctx->Shader.CurrentVertexProgram->LinkedTransformFeedback;
+
+ if (info->NumOutputs == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBeginTransformFeedback(no varyings to record)");
+ return;
+ }
+
switch (mode) {
case GL_POINTS:
case GL_LINES:
@@ -363,6 +379,15 @@ _mesa_BeginTransformFeedback(GLenum mode)
return;
}
+ for (i = 0; i < info->NumBuffers; ++i) {
+ if (obj->BufferNames[i] == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBeginTransformFeedback(binding point %d does not have "
+ "a buffer object bound)", i);
+ return;
+ }
+ }
+
FLUSH_VERTICES(ctx, _NEW_TRANSFORM_FEEDBACK);
obj->Active = GL_TRUE;
ctx->TransformFeedback.Mode = mode;
@@ -461,7 +486,7 @@ _mesa_BindBufferRange(GLenum target, GLuint index,
if ((size <= 0) || (size & 0x3)) {
/* must be positive and multiple of four */
- _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(size%d)", (int) size);
+ _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(size=%d)", (int) size);
return;
}
@@ -569,6 +594,13 @@ _mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer,
return;
}
+ if (offset & 0x3) {
+ /* must be multiple of four */
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glBindBufferOffsetEXT(offset=%d)", (int) offset);
+ return;
+ }
+
bufObj = _mesa_lookup_bufferobj(ctx, buffer);
if (!bufObj) {
_mesa_error(ctx, GL_INVALID_OPERATION,
@@ -662,8 +694,7 @@ _mesa_GetTransformFeedbackVarying(GLuint program, GLuint index,
GLsizei *size, GLenum *type, GLchar *name)
{
const struct gl_shader_program *shProg;
- const GLchar *varyingName;
- GLint v;
+ const struct gl_transform_feedback_info *linked_xfb_info;
GET_CURRENT_CONTEXT(ctx);
shProg = _mesa_lookup_shader_program(ctx, program);
@@ -673,36 +704,22 @@ _mesa_GetTransformFeedbackVarying(GLuint program, GLuint index,
return;
}
- if (index >= shProg->TransformFeedback.NumVarying) {
+ linked_xfb_info = &shProg->LinkedTransformFeedback;
+ if (index >= linked_xfb_info->NumVarying) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glGetTransformFeedbackVaryings(index=%u)", index);
return;
}
- varyingName = shProg->TransformFeedback.VaryingNames[index];
+ /* return the varying's name and length */
+ _mesa_copy_string(name, bufSize, length,
+ linked_xfb_info->Varyings[index].Name);
- v = _mesa_lookup_parameter_index(shProg->Varying, -1, varyingName);
- if (v >= 0) {
- struct gl_program_parameter *param = &shProg->Varying->Parameters[v];
-
- /* return the varying's name and length */
- _mesa_copy_string(name, bufSize, length, varyingName);
-
- /* return the datatype and value's size (in datatype units) */
- if (type)
- *type = param->DataType;
- if (size)
- *size = param->Size;
- }
- else {
- name[0] = 0;
- if (length)
- *length = 0;
- if (type)
- *type = 0;
- if (size)
- *size = 0;
- }
+ /* return the datatype and value's size (in datatype units) */
+ if (type)
+ *type = linked_xfb_info->Varyings[index].Type;
+ if (size)
+ *size = linked_xfb_info->Varyings[index].Size;
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
index adac92f2c..6d95d57c1 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -291,10 +291,6 @@ st_bufferobj_map_range(struct gl_context *ctx,
flags,
&st_obj->transfer);
if (obj->Pointer) {
- obj->Pointer = (ubyte *) obj->Pointer + offset;
- }
-
- if (obj->Pointer) {
obj->Offset = offset;
obj->Length = length;
obj->AccessFlags = access;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
index 318ba7d06..0609a54ea 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -517,7 +517,6 @@ make_texture(struct st_context *st,
success = _mesa_texstore(ctx, 2, /* dims */
baseInternalFormat, /* baseInternalFormat */
mformat, /* gl_format */
- 0, 0, 0, /* dstX/Y/Zoffset */
transfer->stride, /* dstRowStride, bytes */
&dest, /* destSlices */
width, height, 1, /* size */
diff --git a/mesalib/src/mesa/state_tracker/st_cb_eglimage.c b/mesalib/src/mesa/state_tracker/st_cb_eglimage.c
index 37c20ebe3..5209fc795 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_eglimage.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_eglimage.c
@@ -125,7 +125,7 @@ st_bind_surface(struct gl_context *ctx, GLenum target,
texFormat = st_pipe_format_to_mesa_format(ps->format);
- _mesa_init_teximage_fields(ctx, target, texImage,
+ _mesa_init_teximage_fields(ctx, texImage,
ps->width, ps->height, 1, 0, internalFormat,
texFormat);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c
index 289ad5114..592d04b92 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c
@@ -153,7 +153,8 @@ st_DeleteTextureObject(struct gl_context *ctx,
/** called via ctx->Driver.FreeTextureImageBuffer() */
static void
-st_FreeTextureImageBuffer(struct gl_context * ctx, struct gl_texture_image *texImage)
+st_FreeTextureImageBuffer(struct gl_context *ctx,
+ struct gl_texture_image *texImage)
{
struct st_texture_image *stImage = st_texture_image(texImage);
@@ -415,8 +416,6 @@ guess_and_alloc_texture(struct st_context *st,
* Called via ctx->Driver.AllocTextureImageBuffer().
* If the texture object/buffer already has space for the indicated image,
* we're done. Otherwise, allocate memory for the new texture image.
- * XXX This function and st_TexImage() have some duplicated code. That
- * can be cleaned up in the future.
*/
static GLboolean
st_AllocTextureImageBuffer(struct gl_context *ctx,
@@ -471,7 +470,10 @@ st_AllocTextureImageBuffer(struct gl_context *ctx,
}
else {
/* Create a new, temporary texture/resource/buffer to hold this
- * one texture image.
+ * one texture image. Note that when we later access this image
+ * (either for mapping or copying) we'll want to always specify
+ * mipmap level=0, even if the image represents some other mipmap
+ * level.
*/
enum pipe_format format =
st_mesa_format_to_pipe_format(texImage->TexFormat);
@@ -495,34 +497,24 @@ st_AllocTextureImageBuffer(struct gl_context *ctx,
}
}
+
/**
- * Do glTexImage1/2/3D().
+ * Preparation prior to glTexImage. Basically check the 'surface_based'
+ * field and switch to a "normal" tex image if necessary.
*/
static void
-st_TexImage(struct gl_context * ctx,
- GLint dims,
- GLenum target, GLint level,
- GLint internalFormat,
- GLint width, GLint height, GLint depth,
- GLint border,
- GLenum format, GLenum type, const void *pixels,
- const struct gl_pixelstore_attrib *unpack,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage,
- GLsizei imageSize, GLboolean compressed_src)
+prep_teximage(struct gl_context *ctx, struct gl_texture_image *texImage,
+ GLint internalFormat,
+ GLint width, GLint height, GLint depth, GLint border,
+ GLenum format, GLenum type)
{
- struct st_context *st = st_context(ctx);
+ struct gl_texture_object *texObj = texImage->TexObject;
struct st_texture_object *stObj = st_texture_object(texObj);
- struct st_texture_image *stImage = st_texture_image(texImage);
- GLuint dstRowStride = 0;
- enum pipe_transfer_usage transfer_usage = 0;
- GLubyte *dstMap;
-
- DBG("%s target %s level %d %dx%dx%d border %d\n", __FUNCTION__,
- _mesa_lookup_enum_by_nr(target), level, width, height, depth, border);
/* switch to "normal" */
if (stObj->surface_based) {
+ const GLenum target = texObj->Target;
+ const GLuint level = texImage->Level;
gl_format texFormat;
_mesa_clear_texture_object(ctx, texObj);
@@ -532,265 +524,72 @@ st_TexImage(struct gl_context * ctx,
texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
internalFormat, format, type);
- _mesa_init_teximage_fields(ctx, target, texImage,
+ _mesa_init_teximage_fields(ctx, texImage,
width, height, depth, border,
internalFormat, texFormat);
stObj->surface_based = GL_FALSE;
}
-
- assert(texImage->Width == width);
- assert(texImage->Height == height);
- assert(texImage->Depth == depth);
-
- stImage->base.Face = _mesa_tex_target_to_face(target);
- stImage->base.Level = level;
-
- /* Release the reference to a potentially orphaned buffer.
- * Release any old malloced memory.
- */
- if (stImage->pt) {
- pipe_resource_reference(&stImage->pt, NULL);
- assert(!stImage->TexData);
- }
- else if (stImage->TexData) {
- _mesa_align_free(stImage->TexData);
- }
-
- /*
- * See if the new image is somehow incompatible with the existing
- * mipmap. If so, free the old mipmap.
- */
- if (stObj->pt) {
- if (level > (GLint) stObj->pt->last_level ||
- !st_texture_match_image(stObj->pt, &stImage->base)) {
- DBG("release it\n");
- pipe_resource_reference(&stObj->pt, NULL);
- assert(!stObj->pt);
- pipe_sampler_view_reference(&stObj->sampler_view, NULL);
- }
- }
-
- if (width == 0 || height == 0 || depth == 0) {
- /* stop after freeing old image */
- return;
- }
-
- if (!stObj->pt) {
- if (!guess_and_alloc_texture(st, stObj, stImage)) {
- /* Probably out of memory.
- * Try flushing any pending rendering, then retry.
- */
- st_finish(st);
- if (!guess_and_alloc_texture(st, stObj, stImage)) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
- return;
- }
- }
- }
-
- assert(!stImage->pt);
-
- /* Check if this texture image can live inside the texture object's buffer.
- * If so, store the image there. Otherwise the image will temporarily live
- * in its own buffer.
- */
- if (stObj->pt &&
- st_texture_match_image(stObj->pt, &stImage->base)) {
-
- pipe_resource_reference(&stImage->pt, stObj->pt);
- assert(stImage->pt);
- }
-
- if (!stImage->pt)
- DBG("XXX: Image did not fit into texture - storing in local memory!\n");
-
- /* Pixel data may come from regular user memory or a PBO. For the later,
- * do bounds checking and map the PBO to read pixels data from it.
- *
- * XXX we should try to use a GPU-accelerated path to copy the image data
- * from the PBO to the texture.
- */
- if (compressed_src) {
- pixels = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, pixels,
- unpack,
- "glCompressedTexImage");
- }
- else {
- pixels = _mesa_validate_pbo_teximage(ctx, dims, width, height, 1,
- format, type,
- pixels, unpack, "glTexImage");
- }
-
- /* for a 1D array upload the image as a series of layer with height = 1 */
- if (target == GL_TEXTURE_1D_ARRAY) {
- depth = height;
- height = 1;
- }
-
- /*
- * Prepare to store the texture data. Either map the gallium texture buffer
- * memory or malloc space for it.
- */
- if (stImage->pt) {
- if (!pixels) {
- /* We've allocated texture resource, but have no pixel data - all done. */
- goto done;
- }
-
- /* Store the image in the gallium transfer object */
- if (format == GL_DEPTH_COMPONENT &&
- util_format_is_depth_and_stencil(stImage->pt->format))
- transfer_usage = PIPE_TRANSFER_READ_WRITE;
- else
- transfer_usage = PIPE_TRANSFER_WRITE;
-
- dstMap = st_texture_image_map(st, stImage, 0,
- transfer_usage, 0, 0, width, height);
- if(stImage->transfer)
- dstRowStride = stImage->transfer->stride;
- }
- else {
- /* Allocate regular memory and store the image there temporarily. */
- GLuint imageSize = _mesa_format_image_size(texImage->TexFormat,
- width, height, depth);
- dstRowStride = _mesa_format_row_stride(texImage->TexFormat, width);
-
- stImage->TexData = _mesa_align_malloc(imageSize, 16);
- dstMap = stImage->TexData;
- }
-
- if (!dstMap) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
- return;
- }
-
- if (!pixels) {
- /* We've allocated texture memory, but have no pixel data - all done. */
- goto done;
- }
-
- DBG("Upload image %dx%dx%d row_len %x pitch %x\n",
- width, height, depth, width, dstRowStride);
-
- /* Copy user texture image into the mapped texture buffer.
- */
- if (compressed_src) {
- const GLuint srcRowStride =
- _mesa_format_row_stride(texImage->TexFormat, width);
- if (dstRowStride == srcRowStride) {
- memcpy(dstMap, pixels, imageSize);
- }
- else {
- GLubyte *dst = dstMap;
- const char *src = pixels;
- GLuint i, bw, bh, lines;
- _mesa_get_format_block_size(texImage->TexFormat, &bw, &bh);
- lines = (height + bh - 1) / bh;
-
- for (i = 0; i < lines; ++i) {
- memcpy(dst, src, srcRowStride);
- dst += dstRowStride;
- src += srcRowStride;
- }
- }
- }
- else {
- const GLuint srcImageStride =
- _mesa_image_image_stride(unpack, width, height, format, type);
- GLint i;
- const GLubyte *src = (const GLubyte *) pixels;
-
- for (i = 0; i < depth; i++) {
- if (!_mesa_texstore(ctx, dims,
- texImage->_BaseFormat,
- texImage->TexFormat,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- (GLubyte **) &dstMap, /* dstSlice */
- width, height, 1,
- format, type, src, unpack)) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
- }
-
- if (stImage->pt && i + 1 < depth) {
- /* unmap this slice */
- st_texture_image_unmap(st, stImage);
- /* map next slice of 3D texture */
- dstMap = st_texture_image_map(st, stImage, i + 1,
- transfer_usage, 0, 0,
- width, height);
- src += srcImageStride;
- }
- }
- }
-
-done:
- _mesa_unmap_teximage_pbo(ctx, unpack);
-
- if (stImage->pt && stImage->transfer) {
- st_texture_image_unmap(st, stImage);
- }
}
static void
st_TexImage3D(struct gl_context * ctx,
- GLenum target, GLint level,
+ struct gl_texture_image *texImage,
GLint internalFormat,
GLint width, GLint height, GLint depth,
GLint border,
GLenum format, GLenum type, const void *pixels,
- const struct gl_pixelstore_attrib *unpack,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
+ const struct gl_pixelstore_attrib *unpack)
{
- st_TexImage(ctx, 3, target, level, internalFormat, width, height, depth,
- border, format, type, pixels, unpack, texObj, texImage,
- 0, GL_FALSE);
+ prep_teximage(ctx, texImage, internalFormat, width, height, depth, border,
+ format, type);
+ _mesa_store_teximage3d(ctx, texImage, internalFormat, width, height, depth,
+ border, format, type, pixels, unpack);
}
static void
st_TexImage2D(struct gl_context * ctx,
- GLenum target, GLint level,
+ struct gl_texture_image *texImage,
GLint internalFormat,
GLint width, GLint height, GLint border,
GLenum format, GLenum type, const void *pixels,
- const struct gl_pixelstore_attrib *unpack,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
+ const struct gl_pixelstore_attrib *unpack)
{
- st_TexImage(ctx, 2, target, level, internalFormat, width, height, 1, border,
- format, type, pixels, unpack, texObj, texImage, 0, GL_FALSE);
+ prep_teximage(ctx, texImage, internalFormat, width, height, 1, border,
+ format, type);
+ _mesa_store_teximage2d(ctx, texImage, internalFormat, width, height,
+ border, format, type, pixels, unpack);
}
static void
st_TexImage1D(struct gl_context * ctx,
- GLenum target, GLint level,
+ struct gl_texture_image *texImage,
GLint internalFormat,
GLint width, GLint border,
GLenum format, GLenum type, const void *pixels,
- const struct gl_pixelstore_attrib *unpack,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
+ const struct gl_pixelstore_attrib *unpack)
{
- st_TexImage(ctx, 1, target, level, internalFormat, width, 1, 1, border,
- format, type, pixels, unpack, texObj, texImage, 0, GL_FALSE);
+ prep_teximage(ctx, texImage, internalFormat, width, 1, 1, border,
+ format, type);
+ _mesa_store_teximage1d(ctx, texImage, internalFormat, width,
+ border, format, type, pixels, unpack);
}
static void
-st_CompressedTexImage2D(struct gl_context *ctx, GLenum target, GLint level,
+st_CompressedTexImage2D(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint internalFormat,
GLint width, GLint height, GLint border,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
+ GLsizei imageSize, const GLvoid *data)
{
- st_TexImage(ctx, 2, target, level, internalFormat, width, height, 1, border,
- 0, 0, data, &ctx->Unpack, texObj, texImage, imageSize, GL_TRUE);
+ prep_teximage(ctx, texImage, internalFormat, width, 1, 1, border,
+ GL_NONE, GL_NONE);
+ _mesa_store_compressed_teximage2d(ctx, texImage, internalFormat, width,
+ height, border, imageSize, data);
}
@@ -929,224 +728,6 @@ st_GetTexImage(struct gl_context * ctx,
}
-static void
-st_TexSubimage(struct gl_context *ctx, GLint dims, GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLint width, GLint height, GLint depth,
- GLenum format, GLenum type, const void *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
-{
- struct st_context *st = st_context(ctx);
- struct st_texture_image *stImage = st_texture_image(texImage);
- GLuint dstRowStride;
- const GLuint srcImageStride =
- _mesa_image_image_stride(packing, width, height, format, type);
- GLint i;
- const GLubyte *src;
- /* init to silence warning only: */
- enum pipe_transfer_usage transfer_usage = PIPE_TRANSFER_WRITE;
- GLubyte *dstMap;
-
- DBG("%s target %s level %d offset %d,%d %dx%d\n", __FUNCTION__,
- _mesa_lookup_enum_by_nr(target),
- level, xoffset, yoffset, width, height);
-
- pixels =
- _mesa_validate_pbo_teximage(ctx, dims, width, height, depth, format,
- type, pixels, packing, "glTexSubImage2D");
- if (!pixels)
- return;
-
- /* for a 1D array upload the image as a series of layer with height = 1 */
- if (target == GL_TEXTURE_1D_ARRAY) {
- depth = height;
- height = 1;
- }
-
- /* Map buffer if necessary. Need to lock to prevent other contexts
- * from uploading the buffer under us.
- */
- if (stImage->pt) {
- if (format == GL_DEPTH_COMPONENT &&
- util_format_is_depth_and_stencil(stImage->pt->format))
- transfer_usage = PIPE_TRANSFER_READ_WRITE;
- else
- transfer_usage = PIPE_TRANSFER_WRITE;
-
- dstMap = st_texture_image_map(st, stImage, zoffset,
- transfer_usage,
- xoffset, yoffset,
- width, height);
- }
-
- if (!dstMap) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage");
- goto done;
- }
-
- src = (const GLubyte *) pixels;
- dstRowStride = stImage->transfer->stride;
-
- for (i = 0; i < depth; i++) {
- if (!_mesa_texstore(ctx, dims, texImage->_BaseFormat,
- texImage->TexFormat,
- 0, 0, 0,
- dstRowStride,
- (GLubyte **) &dstMap,
- width, height, 1,
- format, type, src, packing)) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage");
- }
-
- if (stImage->pt && i + 1 < depth) {
- /* unmap this slice */
- st_texture_image_unmap(st, stImage);
- /* map next slice of 3D texture */
- dstMap = st_texture_image_map(st, stImage,
- zoffset + i + 1,
- transfer_usage,
- xoffset, yoffset,
- width, height);
- src += srcImageStride;
- }
- }
-
-done:
- _mesa_unmap_teximage_pbo(ctx, packing);
-
- if (stImage->pt && stImage->transfer) {
- st_texture_image_unmap(st, stImage);
- }
-}
-
-
-
-static void
-st_TexSubImage3D(struct gl_context *ctx, GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
-{
- st_TexSubimage(ctx, 3, target, level, xoffset, yoffset, zoffset,
- width, height, depth, format, type,
- pixels, packing, texObj, texImage);
-}
-
-
-static void
-st_TexSubImage2D(struct gl_context *ctx, GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type, const GLvoid * pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
-{
- st_TexSubimage(ctx, 2, target, level, xoffset, yoffset, 0,
- width, height, 1, format, type,
- pixels, packing, texObj, texImage);
-}
-
-
-static void
-st_TexSubImage1D(struct gl_context *ctx, GLenum target, GLint level,
- GLint xoffset, GLsizei width, GLenum format, GLenum type,
- const GLvoid * pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
-{
- st_TexSubimage(ctx, 1, target, level, xoffset, 0, 0, width, 1, 1,
- format, type, pixels, packing, texObj, texImage);
-}
-
-
-static void
-st_CompressedTexSubImage1D(struct gl_context *ctx, GLenum target, GLint level,
- GLint xoffset, GLsizei width,
- GLenum format,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
-{
- assert(0);
-}
-
-
-static void
-st_CompressedTexSubImage2D(struct gl_context *ctx, GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLint height,
- GLenum format,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
-{
- struct st_context *st = st_context(ctx);
- struct st_texture_image *stImage = st_texture_image(texImage);
- int srcBlockStride;
- int dstBlockStride;
- int y;
- enum pipe_format pformat;
- GLubyte *dstMap;
-
- if (stImage->pt) {
- pformat = stImage->pt->format;
-
- dstMap = st_texture_image_map(st, stImage, 0,
- PIPE_TRANSFER_WRITE,
- xoffset, yoffset,
- width, height);
-
- srcBlockStride = util_format_get_stride(pformat, width);
- dstBlockStride = stImage->transfer->stride;
- } else {
- assert(stImage->pt);
- /* TODO find good values for block and strides */
- /* TODO also adjust texImage->data for yoffset/xoffset */
- return;
- }
-
- if (!dstMap) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage");
- return;
- }
-
- assert(xoffset % util_format_get_blockwidth(pformat) == 0);
- assert(yoffset % util_format_get_blockheight(pformat) == 0);
-
- for (y = 0; y < height; y += util_format_get_blockheight(pformat)) {
- /* don't need to adjust for xoffset and yoffset as st_texture_image_map does that */
- const char *src = (const char*)data + srcBlockStride * util_format_get_nblocksy(pformat, y);
- char *dst = (char *) dstMap + dstBlockStride * util_format_get_nblocksy(pformat, y);
- memcpy(dst, src, util_format_get_stride(pformat, width));
- }
-
- if (stImage->pt && stImage->transfer) {
- st_texture_image_unmap(st, stImage);
- }
-}
-
-
-static void
-st_CompressedTexSubImage3D(struct gl_context *ctx, GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLint height, GLint depth,
- GLenum format,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage)
-{
- assert(0);
-}
-
-
-
/**
* Do a CopyTexSubImage operation using a read transfer from the source,
* a write transfer to the destination and get_tile()/put_tile() to access
@@ -1255,7 +836,6 @@ fallback_copy_texsubimage(struct gl_context *ctx, GLenum target, GLint level,
_mesa_texstore(ctx, dims,
texImage->_BaseFormat,
texImage->TexFormat,
- 0, 0, 0,
dstRowStride,
(GLubyte **) &texDest,
width, height, 1,
@@ -1515,11 +1095,11 @@ st_copy_texsubimage(struct gl_context *ctx,
return;
fallback:
- /* software fallback */
- fallback_copy_texsubimage(ctx, target, level,
- strb, stImage, texBaseFormat,
- destX, destY, destZ,
- srcX, srcY, width, height);
+ /* software fallback */
+ fallback_copy_texsubimage(ctx, target, level,
+ strb, stImage, texBaseFormat,
+ destX, destY, destZ,
+ srcX, srcY, width, height);
}
@@ -1582,9 +1162,15 @@ copy_image_data_to_texture(struct st_context *st,
if (stImage->pt) {
/* Copy potentially with the blitter:
*/
+ GLuint src_level;
+ if (stImage->pt != stObj->pt)
+ src_level = 0;
+ else
+ src_level = stImage->base.Level;
+
st_texture_image_copy(st->pipe,
stObj->pt, dstLevel, /* dest texture, level */
- stImage->pt, stImage->base.Level, /* src texture, level */
+ stImage->pt, src_level, /* src texture, level */
stImage->base.Face);
pipe_resource_reference(&stImage->pt, NULL);
@@ -1777,17 +1363,15 @@ st_get_default_texture(struct st_context *st)
texImg = _mesa_get_tex_image(st->ctx, texObj, target, 0);
- _mesa_init_teximage_fields(st->ctx, target, texImg,
+ _mesa_init_teximage_fields(st->ctx, texImg,
16, 16, 1, 0, /* w, h, d, border */
GL_RGBA, MESA_FORMAT_RGBA8888);
- st_TexImage(st->ctx, 2, target,
- 0, GL_RGBA, /* level, intformat */
- 16, 16, 1, 0, /* w, h, d, border */
- GL_RGBA, GL_UNSIGNED_BYTE, pixels,
- &st->ctx->DefaultPacking,
- texObj, texImg,
- 0, 0);
+ _mesa_store_teximage2d(st->ctx, texImg,
+ GL_RGBA, /* level, intformat */
+ 16, 16, 1, /* w, h, d, border */
+ GL_RGBA, GL_UNSIGNED_BYTE, pixels,
+ &st->ctx->DefaultPacking);
texObj->Sampler.MinFilter = GL_NEAREST;
texObj->Sampler.MagFilter = GL_NEAREST;
@@ -1866,12 +1450,12 @@ st_init_texture_functions(struct dd_function_table *functions)
functions->TexImage1D = st_TexImage1D;
functions->TexImage2D = st_TexImage2D;
functions->TexImage3D = st_TexImage3D;
- functions->TexSubImage1D = st_TexSubImage1D;
- functions->TexSubImage2D = st_TexSubImage2D;
- functions->TexSubImage3D = st_TexSubImage3D;
- functions->CompressedTexSubImage1D = st_CompressedTexSubImage1D;
- functions->CompressedTexSubImage2D = st_CompressedTexSubImage2D;
- functions->CompressedTexSubImage3D = st_CompressedTexSubImage3D;
+ functions->TexSubImage1D = _mesa_store_texsubimage1d;
+ functions->TexSubImage2D = _mesa_store_texsubimage2d;
+ functions->TexSubImage3D = _mesa_store_texsubimage3d;
+ functions->CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
+ functions->CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
+ functions->CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
functions->CopyTexSubImage1D = st_CopyTexSubImage1D;
functions->CopyTexSubImage2D = st_CopyTexSubImage2D;
functions->CopyTexSubImage3D = st_CopyTexSubImage3D;
diff --git a/mesalib/src/mesa/state_tracker/st_draw.c b/mesalib/src/mesa/state_tracker/st_draw.c
index 87a997865..6d6fc858d 100644
--- a/mesalib/src/mesa/state_tracker/st_draw.c
+++ b/mesalib/src/mesa/state_tracker/st_draw.c
@@ -102,6 +102,13 @@ static GLuint uint_types_scale[4] = {
PIPE_FORMAT_R32G32B32A32_USCALED
};
+static GLuint uint_types_int[4] = {
+ PIPE_FORMAT_R32_UINT,
+ PIPE_FORMAT_R32G32_UINT,
+ PIPE_FORMAT_R32G32B32_UINT,
+ PIPE_FORMAT_R32G32B32A32_UINT
+};
+
static GLuint int_types_norm[4] = {
PIPE_FORMAT_R32_SNORM,
PIPE_FORMAT_R32G32_SNORM,
@@ -116,6 +123,13 @@ static GLuint int_types_scale[4] = {
PIPE_FORMAT_R32G32B32A32_SSCALED
};
+static GLuint int_types_int[4] = {
+ PIPE_FORMAT_R32_SINT,
+ PIPE_FORMAT_R32G32_SINT,
+ PIPE_FORMAT_R32G32B32_SINT,
+ PIPE_FORMAT_R32G32B32A32_SINT
+};
+
static GLuint ushort_types_norm[4] = {
PIPE_FORMAT_R16_UNORM,
PIPE_FORMAT_R16G16_UNORM,
@@ -130,6 +144,13 @@ static GLuint ushort_types_scale[4] = {
PIPE_FORMAT_R16G16B16A16_USCALED
};
+static GLuint ushort_types_int[4] = {
+ PIPE_FORMAT_R16_UINT,
+ PIPE_FORMAT_R16G16_UINT,
+ PIPE_FORMAT_R16G16B16_UINT,
+ PIPE_FORMAT_R16G16B16A16_UINT
+};
+
static GLuint short_types_norm[4] = {
PIPE_FORMAT_R16_SNORM,
PIPE_FORMAT_R16G16_SNORM,
@@ -144,6 +165,13 @@ static GLuint short_types_scale[4] = {
PIPE_FORMAT_R16G16B16A16_SSCALED
};
+static GLuint short_types_int[4] = {
+ PIPE_FORMAT_R16_SINT,
+ PIPE_FORMAT_R16G16_SINT,
+ PIPE_FORMAT_R16G16B16_SINT,
+ PIPE_FORMAT_R16G16B16A16_SINT
+};
+
static GLuint ubyte_types_norm[4] = {
PIPE_FORMAT_R8_UNORM,
PIPE_FORMAT_R8G8_UNORM,
@@ -158,6 +186,13 @@ static GLuint ubyte_types_scale[4] = {
PIPE_FORMAT_R8G8B8A8_USCALED
};
+static GLuint ubyte_types_int[4] = {
+ PIPE_FORMAT_R8_UINT,
+ PIPE_FORMAT_R8G8_UINT,
+ PIPE_FORMAT_R8G8B8_UINT,
+ PIPE_FORMAT_R8G8B8A8_UINT
+};
+
static GLuint byte_types_norm[4] = {
PIPE_FORMAT_R8_SNORM,
PIPE_FORMAT_R8G8_SNORM,
@@ -172,6 +207,13 @@ static GLuint byte_types_scale[4] = {
PIPE_FORMAT_R8G8B8A8_SSCALED
};
+static GLuint byte_types_int[4] = {
+ PIPE_FORMAT_R8_SINT,
+ PIPE_FORMAT_R8G8_SINT,
+ PIPE_FORMAT_R8G8B8_SINT,
+ PIPE_FORMAT_R8G8B8A8_SINT
+};
+
static GLuint fixed_types[4] = {
PIPE_FORMAT_R32_FIXED,
PIPE_FORMAT_R32G32_FIXED,
@@ -186,7 +228,7 @@ static GLuint fixed_types[4] = {
*/
enum pipe_format
st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
- GLboolean normalized)
+ GLboolean normalized, GLboolean integer)
{
assert((type >= GL_BYTE && type <= GL_DOUBLE) ||
type == GL_FIXED || type == GL_HALF_FLOAT ||
@@ -199,6 +241,7 @@ st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
if (type == GL_INT_2_10_10_10_REV ||
type == GL_UNSIGNED_INT_2_10_10_10_REV) {
assert(size == 4);
+ assert(!integer);
if (format == GL_BGRA) {
if (type == GL_INT_2_10_10_10_REV) {
@@ -234,7 +277,18 @@ st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
return PIPE_FORMAT_B8G8R8A8_UNORM;
}
- if (normalized) {
+ if (integer) {
+ switch (type) {
+ case GL_INT: return int_types_int[size-1];
+ case GL_SHORT: return short_types_int[size-1];
+ case GL_BYTE: return byte_types_int[size-1];
+ case GL_UNSIGNED_INT: return uint_types_int[size-1];
+ case GL_UNSIGNED_SHORT: return ushort_types_int[size-1];
+ case GL_UNSIGNED_BYTE: return ubyte_types_int[size-1];
+ default: assert(0); return 0;
+ }
+ }
+ else if (normalized) {
switch (type) {
case GL_DOUBLE: return double_types[size-1];
case GL_FLOAT: return float_types[size-1];
@@ -407,7 +461,8 @@ setup_interleaved_attribs(struct gl_context *ctx,
velements[attr].src_format = st_pipe_vertex_format(array->Type,
array->Size,
array->Format,
- array->Normalized);
+ array->Normalized,
+ array->Integer);
assert(velements[attr].src_format);
if (!usingVBO) {
@@ -564,7 +619,8 @@ setup_non_interleaved_attribs(struct gl_context *ctx,
velements[attr].src_format = st_pipe_vertex_format(array->Type,
array->Size,
array->Format,
- array->Normalized);
+ array->Normalized,
+ array->Integer);
assert(velements[attr].src_format);
}
@@ -584,20 +640,7 @@ setup_index_buffer(struct gl_context *ctx,
if (ib) {
struct gl_buffer_object *bufobj = ib->obj;
- switch (ib->type) {
- case GL_UNSIGNED_INT:
- ibuffer->index_size = 4;
- break;
- case GL_UNSIGNED_SHORT:
- ibuffer->index_size = 2;
- break;
- case GL_UNSIGNED_BYTE:
- ibuffer->index_size = 1;
- break;
- default:
- assert(0);
- return;
- }
+ ibuffer->index_size = vbo_sizeof_ib_type(ib->type);
/* get/create the index buffer object */
if (_mesa_is_bufferobj(bufobj)) {
@@ -781,16 +824,17 @@ handle_fallback_primitive_restart(struct pipe_context *pipe,
start * ibuffer->index_size, /* start */
count * ibuffer->index_size, /* length */
PIPE_TRANSFER_READ, &transfer);
+ if (!ptr)
+ return;
+
+ ptr = (uint8_t*)ptr + (ibuffer->offset - start * ibuffer->index_size);
}
else {
ptr = ib->ptr;
+ if (!ptr)
+ return;
}
- if (!ptr)
- return;
-
- ptr = ADD_POINTERS(ptr, ibuffer->offset);
-
sub_prims = find_sub_primitives(ptr, ibuffer->index_size,
0, count, orig_info->restart_index,
&num_sub_prims);
diff --git a/mesalib/src/mesa/state_tracker/st_draw.h b/mesalib/src/mesa/state_tracker/st_draw.h
index 2623cdbb1..47bdb11f8 100644
--- a/mesalib/src/mesa/state_tracker/st_draw.h
+++ b/mesalib/src/mesa/state_tracker/st_draw.h
@@ -73,7 +73,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
*/
extern enum pipe_format
st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
- GLboolean normalized);
+ GLboolean normalized, GLboolean integer);
/**
diff --git a/mesalib/src/mesa/state_tracker/st_draw_feedback.c b/mesalib/src/mesa/state_tracker/st_draw_feedback.c
index 4c1e67495..fbf0349b4 100644
--- a/mesalib/src/mesa/state_tracker/st_draw_feedback.c
+++ b/mesalib/src/mesa/state_tracker/st_draw_feedback.c
@@ -196,7 +196,8 @@ st_feedback_draw_vbo(struct gl_context *ctx,
st_pipe_vertex_format(arrays[mesaAttr]->Type,
arrays[mesaAttr]->Size,
arrays[mesaAttr]->Format,
- arrays[mesaAttr]->Normalized);
+ arrays[mesaAttr]->Normalized,
+ arrays[mesaAttr]->Integer);
assert(velements[attr].src_format);
/* tell draw about this attribute */
@@ -218,20 +219,9 @@ st_feedback_draw_vbo(struct gl_context *ctx,
if (ib) {
struct gl_buffer_object *bufobj = ib->obj;
- switch (ib->type) {
- case GL_UNSIGNED_INT:
- ibuffer.index_size = 4;
- break;
- case GL_UNSIGNED_SHORT:
- ibuffer.index_size = 2;
- break;
- case GL_UNSIGNED_BYTE:
- ibuffer.index_size = 1;
- break;
- default:
- assert(0);
- goto out_unref_vertex;
- }
+ ibuffer.index_size = vbo_sizeof_ib_type(ib->type);
+ if (ibuffer.index_size == 0)
+ goto out_unref_vertex;
if (bufobj && bufobj->Name) {
struct st_buffer_object *stobj = st_buffer_object(bufobj);
diff --git a/mesalib/src/mesa/state_tracker/st_gen_mipmap.c b/mesalib/src/mesa/state_tracker/st_gen_mipmap.c
index 36fea3d7f..d817a9c2b 100644
--- a/mesalib/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/mesalib/src/mesa/state_tracker/st_gen_mipmap.c
@@ -244,7 +244,7 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
ctx->Driver.FreeTextureImageBuffer(ctx, dstImage);
/* initialize new image */
- _mesa_init_teximage_fields(ctx, target, dstImage, dstWidth, dstHeight,
+ _mesa_init_teximage_fields(ctx, dstImage, dstWidth, dstHeight,
dstDepth, border, srcImage->InternalFormat,
srcImage->TexFormat);
diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 77aa0d17b..73d956ea1 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -304,6 +304,7 @@ public:
int samplers_used;
bool indirect_addr_temps;
bool indirect_addr_consts;
+ int num_clip_distances;
int glsl_version;
bool native_integers;
@@ -413,7 +414,6 @@ public:
bool process_move_condition(ir_rvalue *ir);
- void remove_output_reads(gl_register_file type);
void simplify_cmp(void);
void rename_temp_register(int index, int new_index);
@@ -1781,6 +1781,9 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
case ir_unop_floor:
emit(ir, TGSI_OPCODE_FLR, result_dst, op[0]);
break;
+ case ir_unop_round_even:
+ emit(ir, TGSI_OPCODE_ROUND, result_dst, op[0]);
+ break;
case ir_unop_fract:
emit(ir, TGSI_OPCODE_FRC, result_dst, op[0]);
break;
@@ -1830,7 +1833,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
emit(ir, TGSI_OPCODE_OR, result_dst, op[0], op[1]);
break;
}
- case ir_unop_round_even:
+
assert(!"GLSL 1.30 features unsupported");
break;
@@ -2920,89 +2923,6 @@ set_uniform_initializer(struct gl_context *ctx, void *mem_ctx,
}
}
-/*
- * Scan/rewrite program to remove reads of custom (output) registers.
- * The passed type has to be either PROGRAM_OUTPUT or PROGRAM_VARYING
- * (for vertex shaders).
- * In GLSL shaders, varying vars can be read and written.
- * On some hardware, trying to read an output register causes trouble.
- * So, rewrite the program to use a temporary register in this case.
- *
- * Based on _mesa_remove_output_reads from programopt.c.
- */
-void
-glsl_to_tgsi_visitor::remove_output_reads(gl_register_file type)
-{
- GLuint i;
- GLint outputMap[VERT_RESULT_MAX];
- GLint outputTypes[VERT_RESULT_MAX];
- GLuint numVaryingReads = 0;
- GLboolean *usedTemps;
- GLuint firstTemp = 0;
-
- usedTemps = new GLboolean[MAX_TEMPS];
- if (!usedTemps) {
- return;
- }
- _mesa_find_used_registers(prog, PROGRAM_TEMPORARY,
- usedTemps, MAX_TEMPS);
-
- assert(type == PROGRAM_VARYING || type == PROGRAM_OUTPUT);
- assert(prog->Target == GL_VERTEX_PROGRAM_ARB || type != PROGRAM_VARYING);
-
- for (i = 0; i < VERT_RESULT_MAX; i++)
- outputMap[i] = -1;
-
- /* look for instructions which read from varying vars */
- foreach_iter(exec_list_iterator, iter, this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get();
- const GLuint numSrc = num_inst_src_regs(inst->op);
- GLuint j;
- for (j = 0; j < numSrc; j++) {
- if (inst->src[j].file == type) {
- /* replace the read with a temp reg */
- const GLuint var = inst->src[j].index;
- if (outputMap[var] == -1) {
- numVaryingReads++;
- outputMap[var] = _mesa_find_free_register(usedTemps,
- MAX_TEMPS,
- firstTemp);
- outputTypes[var] = inst->src[j].type;
- firstTemp = outputMap[var] + 1;
- }
- inst->src[j].file = PROGRAM_TEMPORARY;
- inst->src[j].index = outputMap[var];
- }
- }
- }
-
- delete [] usedTemps;
-
- if (numVaryingReads == 0)
- return; /* nothing to be done */
-
- /* look for instructions which write to the varying vars identified above */
- foreach_iter(exec_list_iterator, iter, this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get();
- if (inst->dst.file == type && outputMap[inst->dst.index] >= 0) {
- /* change inst to write to the temp reg, instead of the varying */
- inst->dst.file = PROGRAM_TEMPORARY;
- inst->dst.index = outputMap[inst->dst.index];
- }
- }
-
- /* insert new MOV instructions at the end */
- for (i = 0; i < VERT_RESULT_MAX; i++) {
- if (outputMap[i] >= 0) {
- /* MOV VAR[i], TEMP[tmp]; */
- st_src_reg src = st_src_reg(PROGRAM_TEMPORARY, outputMap[i], outputTypes[i]);
- st_dst_reg dst = st_dst_reg(type, WRITEMASK_XYZW, outputTypes[i]);
- dst.index = i;
- this->emit(NULL, TGSI_OPCODE_MOV, dst, src);
- }
- }
-}
-
/**
* Returns the mask of channels (bitmask of WRITEMASK_X,Y,Z,W) which
* are read from the given src in this instruction
@@ -3505,10 +3425,15 @@ glsl_to_tgsi_visitor::eliminate_dead_code_advanced(void)
switch (inst->op) {
case TGSI_OPCODE_BGNLOOP:
case TGSI_OPCODE_ENDLOOP:
+ case TGSI_OPCODE_CONT:
+ case TGSI_OPCODE_BRK:
/* End of a basic block, clear the write array entirely.
- * FIXME: This keeps us from killing dead code when the writes are
+ *
+ * This keeps us from killing dead code when the writes are
* on either side of a loop, even when the register isn't touched
- * inside the loop.
+ * inside the loop. However, glsl_to_tgsi_visitor doesn't seem to emit
+ * dead code of this type, so it shouldn't make a difference as long as
+ * the dead code elimination pass in the GLSL compiler does its job.
*/
memset(writes, 0, sizeof(*writes) * this->next_temp * 4);
break;
@@ -3708,6 +3633,7 @@ get_pixel_transfer_visitor(struct st_fragment_program *fp,
/* Copy attributes of the glsl_to_tgsi_visitor in the original shader. */
v->ctx = original->ctx;
v->prog = prog;
+ v->shader_program = NULL;
v->glsl_version = original->glsl_version;
v->native_integers = original->native_integers;
v->options = original->options;
@@ -3837,6 +3763,7 @@ get_bitmap_visitor(struct st_fragment_program *fp,
/* Copy attributes of the glsl_to_tgsi_visitor in the original shader. */
v->ctx = original->ctx;
v->prog = prog;
+ v->shader_program = NULL;
v->glsl_version = original->glsl_version;
v->native_integers = original->native_integers;
v->options = original->options;
@@ -4550,6 +4477,15 @@ st_translate_program(
t->pointSizeOutIndex = -1;
t->prevInstWrotePointSize = GL_FALSE;
+ if (program->shader_program) {
+ for (i = 0; i < program->shader_program->NumUserUniformStorage; i++) {
+ struct gl_uniform_storage *const storage =
+ &program->shader_program->UniformStorage[i];
+
+ _mesa_uniform_detach_all_driver_storage(storage);
+ }
+ }
+
/*
* Declare input attributes.
*/
@@ -4622,9 +4558,17 @@ st_translate_program(
}
for (i = 0; i < numOutputs; i++) {
- t->outputs[i] = ureg_DECL_output(ureg,
- outputSemanticName[i],
- outputSemanticIndex[i]);
+ if (outputSemanticName[i] == TGSI_SEMANTIC_CLIPDIST) {
+ int mask = ((1 << (program->num_clip_distances - 4*outputSemanticIndex[i])) - 1) & TGSI_WRITEMASK_XYZW;
+ t->outputs[i] = ureg_DECL_output_masked(ureg,
+ outputSemanticName[i],
+ outputSemanticIndex[i],
+ mask);
+ } else {
+ t->outputs[i] = ureg_DECL_output(ureg,
+ outputSemanticName[i],
+ outputSemanticIndex[i]);
+ }
if ((outputSemanticName[i] == TGSI_SEMANTIC_PSIZE) && proginfo->Id) {
/* Writing to the point size result register requires special
* handling to implement clamping.
@@ -4776,6 +4720,20 @@ st_translate_program(
t->insn[t->labels[i].branch_target]);
}
+ if (program->shader_program) {
+ /* This has to be done last. Any operation the can cause
+ * prog->ParameterValues to get reallocated (e.g., anything that adds a
+ * program constant) has to happen before creating this linkage.
+ */
+ for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
+ if (program->shader_program->_LinkedShaders[i] == NULL)
+ continue;
+
+ _mesa_associate_uniform_storage(ctx, program->shader_program,
+ program->shader_program->_LinkedShaders[i]->Program->Parameters);
+ }
+ }
+
out:
if (t) {
FREE(t->insn);
@@ -4801,7 +4759,8 @@ out:
static struct gl_program *
get_mesa_program(struct gl_context *ctx,
struct gl_shader_program *shader_program,
- struct gl_shader *shader)
+ struct gl_shader *shader,
+ int num_clip_distances)
{
glsl_to_tgsi_visitor* v = new glsl_to_tgsi_visitor();
struct gl_program *prog;
@@ -4846,10 +4805,18 @@ get_mesa_program(struct gl_context *ctx,
v->options = options;
v->glsl_version = ctx->Const.GLSLVersion;
v->native_integers = ctx->Const.NativeIntegers;
+ v->num_clip_distances = num_clip_distances;
_mesa_generate_parameters_list_for_uniforms(shader_program, shader,
prog->Parameters);
+ if (!screen->get_shader_param(screen, pipe_shader_type,
+ PIPE_SHADER_CAP_OUTPUT_READ)) {
+ /* Remove reads to output registers, and to varyings in vertex shaders. */
+ lower_output_reads(shader->ir);
+ }
+
+
/* Emit intermediate IR for main(). */
visit_exec_list(shader->ir, v);
@@ -4896,14 +4863,6 @@ get_mesa_program(struct gl_context *ctx,
}
#endif
- if (!screen->get_shader_param(screen, pipe_shader_type,
- PIPE_SHADER_CAP_OUTPUT_READ)) {
- /* Remove reads to output registers, and to varyings in vertex shaders. */
- v->remove_output_reads(PROGRAM_OUTPUT);
- if (target == GL_VERTEX_PROGRAM_ARB)
- v->remove_output_reads(PROGRAM_VARYING);
- }
-
/* Perform optimizations on the instructions in the glsl_to_tgsi_visitor. */
v->simplify_cmp();
v->copy_propagate();
@@ -4975,6 +4934,25 @@ get_mesa_program(struct gl_context *ctx,
return prog;
}
+/**
+ * Searches through the IR for a declaration of gl_ClipDistance and returns the
+ * declared size of the gl_ClipDistance array. Returns 0 if gl_ClipDistance is
+ * not declared in the IR.
+ */
+int get_clip_distance_size(exec_list *ir)
+{
+ foreach_iter (exec_list_iterator, iter, *ir) {
+ ir_instruction *inst = (ir_instruction *)iter.get();
+ ir_variable *var = inst->as_variable();
+ if (var == NULL) continue;
+ if (!strcmp(var->name, "gl_ClipDistance")) {
+ return var->type->length;
+ }
+ }
+
+ return 0;
+}
+
extern "C" {
struct gl_shader *
@@ -5013,6 +4991,7 @@ st_new_shader_program(struct gl_context *ctx, GLuint name)
GLboolean
st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
{
+ int num_clip_distances[MESA_SHADER_TYPES];
assert(prog->LinkStatus);
for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
@@ -5024,6 +5003,11 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
const struct gl_shader_compiler_options *options =
&ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(prog->_LinkedShaders[i]->Type)];
+ /* We have to determine the length of the gl_ClipDistance array before
+ * the array is lowered to two vec4s by lower_clip_distance().
+ */
+ num_clip_distances[i] = get_clip_distance_size(ir);
+
do {
progress = false;
@@ -5040,6 +5024,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|| progress;
progress = lower_quadop_vector(ir, false) || progress;
+ progress = lower_clip_distance(ir) || progress;
if (options->MaxIfDepth == 0)
progress = lower_discard(ir) || progress;
@@ -5074,7 +5059,8 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
if (prog->_LinkedShaders[i] == NULL)
continue;
- linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]);
+ linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i],
+ num_clip_distances[i]);
if (linked_prog) {
static const GLenum targets[] = {
@@ -5120,7 +5106,8 @@ st_translate_stream_output_info(struct glsl_to_tgsi_visitor *glsl_to_tgsi,
so->output[i].register_index =
outputMapping[info->Outputs[i].OutputRegister];
so->output[i].register_mask =
- comps_to_mask[info->Outputs[i].NumComponents];
+ comps_to_mask[info->Outputs[i].NumComponents]
+ << info->Outputs[i].ComponentOffset;
so->output[i].output_buffer = info->Outputs[i].OutputBuffer;
}
so->num_outputs = info->NumOutputs;
diff --git a/mesalib/src/mesa/state_tracker/st_manager.c b/mesalib/src/mesa/state_tracker/st_manager.c
index 828f0d81f..c0af3ce11 100644
--- a/mesalib/src/mesa/state_tracker/st_manager.c
+++ b/mesalib/src/mesa/state_tracker/st_manager.c
@@ -535,7 +535,7 @@ st_context_teximage(struct st_context_iface *stctxi,
texFormat = st_ChooseTextureFormat(ctx, internalFormat,
GL_BGRA, GL_UNSIGNED_BYTE);
- _mesa_init_teximage_fields(ctx, target, texImage,
+ _mesa_init_teximage_fields(ctx, texImage,
tex->width0, tex->height0, 1, 0,
internalFormat, texFormat);
@@ -647,9 +647,13 @@ st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
if (attribs->major > 1 || attribs->minor > 0) {
_mesa_compute_version(st->ctx);
- /* is the actual version less than the requested version? */
+ /* Is the actual version less than the requested version? Mesa can't
+ * yet enforce the added restrictions of a forward-looking context, so
+ * fail that too.
+ */
if (st->ctx->VersionMajor * 10 + st->ctx->VersionMinor <
- attribs->major * 10 + attribs->minor) {
+ attribs->major * 10 + attribs->minor
+ || (attribs->flags & ~ST_CONTEXT_FLAG_DEBUG) != 0) {
*error = ST_CONTEXT_ERROR_BAD_VERSION;
st_destroy_context(st);
return NULL;
diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c
index b83c56165..aceaaf8c5 100644
--- a/mesalib/src/mesa/state_tracker/st_program.c
+++ b/mesalib/src/mesa/state_tracker/st_program.c
@@ -244,6 +244,14 @@ st_prepare_vertex_program(struct gl_context *ctx,
stvp->output_semantic_name[slot] = TGSI_SEMANTIC_PSIZE;
stvp->output_semantic_index[slot] = 0;
break;
+ case VERT_RESULT_CLIP_DIST0:
+ stvp->output_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST;
+ stvp->output_semantic_index[slot] = 0;
+ break;
+ case VERT_RESULT_CLIP_DIST1:
+ stvp->output_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST;
+ stvp->output_semantic_index[slot] = 1;
+ break;
case VERT_RESULT_EDGE:
assert(0);
break;
@@ -530,12 +538,12 @@ st_translate_fragment_program(struct st_context *st,
case FRAG_ATTRIB_COL0:
input_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
input_semantic_index[slot] = 0;
- interpMode[slot] = TGSI_INTERPOLATE_LINEAR;
+ interpMode[slot] = st_translate_interp(stfp->Base.InterpQualifier[attr]);
break;
case FRAG_ATTRIB_COL1:
input_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
input_semantic_index[slot] = 1;
- interpMode[slot] = TGSI_INTERPOLATE_LINEAR;
+ interpMode[slot] = st_translate_interp(stfp->Base.InterpQualifier[attr]);
break;
case FRAG_ATTRIB_FOGC:
input_semantic_name[slot] = TGSI_SEMANTIC_FOG;
@@ -547,6 +555,16 @@ st_translate_fragment_program(struct st_context *st,
input_semantic_index[slot] = 0;
interpMode[slot] = TGSI_INTERPOLATE_CONSTANT;
break;
+ case FRAG_ATTRIB_CLIP_DIST0:
+ input_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST;
+ input_semantic_index[slot] = 0;
+ interpMode[slot] = TGSI_INTERPOLATE_LINEAR;
+ break;
+ case FRAG_ATTRIB_CLIP_DIST1:
+ input_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST;
+ input_semantic_index[slot] = 1;
+ interpMode[slot] = TGSI_INTERPOLATE_LINEAR;
+ break;
/* In most cases, there is nothing special about these
* inputs, so adopt a convention to use the generic
* semantic name and the mesa FRAG_ATTRIB_ number as the
diff --git a/mesalib/src/mesa/state_tracker/st_texture.c b/mesalib/src/mesa/state_tracker/st_texture.c
index 3323bbbbe..132d7a81c 100644
--- a/mesalib/src/mesa/state_tracker/st_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_texture.c
@@ -215,12 +215,19 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage,
GLuint zoffset, enum pipe_transfer_usage usage,
GLuint x, GLuint y, GLuint w, GLuint h)
{
+ struct st_texture_object *stObj =
+ st_texture_object(stImage->base.TexObject);
struct pipe_context *pipe = st->pipe;
- struct pipe_resource *pt = stImage->pt;
+ GLuint level;
DBG("%s \n", __FUNCTION__);
- stImage->transfer = pipe_get_transfer(st->pipe, pt, stImage->base.Level,
+ if (stObj->pt != stImage->pt)
+ level = 0;
+ else
+ level = stImage->base.Level;
+
+ stImage->transfer = pipe_get_transfer(st->pipe, stImage->pt, level,
stImage->base.Face + zoffset,
usage, x, y, w, h);
diff --git a/mesalib/src/mesa/swrast/s_blit.c b/mesalib/src/mesa/swrast/s_blit.c
index 803ad2e89..1063024fb 100644
--- a/mesalib/src/mesa/swrast/s_blit.c
+++ b/mesalib/src/mesa/swrast/s_blit.c
@@ -27,6 +27,8 @@
#include "main/condrender.h"
#include "main/image.h"
#include "main/macros.h"
+#include "main/format_unpack.h"
+#include "main/format_pack.h"
#include "s_context.h"
@@ -122,10 +124,18 @@ blit_nearest(struct gl_context *ctx,
const GLboolean invertX = (srcX1 < srcX0) ^ (dstX1 < dstX0);
const GLboolean invertY = (srcY1 < srcY0) ^ (dstY1 < dstY0);
-
+ enum mode {
+ DIRECT,
+ UNPACK_RGBA_FLOAT,
+ UNPACK_Z_FLOAT,
+ UNPACK_Z_INT,
+ UNPACK_S,
+ } mode;
+ GLubyte *srcMap, *dstMap;
+ GLint srcRowStride, dstRowStride;
GLint dstRow;
- GLint comps, pixelSize;
+ GLint pixelSize;
GLvoid *srcBuffer, *dstBuffer;
GLint prevY = -1;
@@ -138,42 +148,43 @@ blit_nearest(struct gl_context *ctx,
case GL_COLOR_BUFFER_BIT:
readRb = ctx->ReadBuffer->_ColorReadBuffer;
drawRb = ctx->DrawBuffer->_ColorDrawBuffers[0];
- comps = 4;
+
+ if (readRb->Format == drawRb->Format) {
+ mode = DIRECT;
+ pixelSize = _mesa_get_format_bytes(readRb->Format);
+ } else {
+ mode = UNPACK_RGBA_FLOAT;
+ pixelSize = 16;
+ }
+
break;
case GL_DEPTH_BUFFER_BIT:
- readRb = ctx->ReadBuffer->_DepthBuffer;
- drawRb = ctx->DrawBuffer->_DepthBuffer;
- comps = 1;
+ readRb = ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+ drawRb = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+
+ /* Note that for depth/stencil, the formats of src/dst must match. By
+ * using the core helpers for pack/unpack, we avoid needing to handle
+ * masking for things like DEPTH copies of Z24S8.
+ */
+ if (readRb->Format == MESA_FORMAT_Z32_FLOAT ||
+ readRb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ mode = UNPACK_Z_FLOAT;
+ } else {
+ mode = UNPACK_Z_INT;
+ }
+ pixelSize = 4;
break;
case GL_STENCIL_BUFFER_BIT:
- readRb = ctx->ReadBuffer->_StencilBuffer;
- drawRb = ctx->DrawBuffer->_StencilBuffer;
- comps = 1;
+ readRb = ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
+ drawRb = ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
+ mode = UNPACK_S;
+ pixelSize = 1;
break;
default:
_mesa_problem(ctx, "unexpected buffer in blit_nearest()");
return;
}
- switch (readRb->DataType) {
- case GL_UNSIGNED_BYTE:
- pixelSize = comps * sizeof(GLubyte);
- break;
- case GL_UNSIGNED_SHORT:
- pixelSize = comps * sizeof(GLushort);
- break;
- case GL_UNSIGNED_INT:
- pixelSize = comps * sizeof(GLuint);
- break;
- case GL_FLOAT:
- pixelSize = comps * sizeof(GLfloat);
- break;
- default:
- _mesa_problem(ctx, "unexpected buffer type (0x%x) in blit_nearest",
- readRb->DataType);
- return;
- }
-
/* choose row resampler */
switch (pixelSize) {
case 1:
@@ -197,6 +208,62 @@ blit_nearest(struct gl_context *ctx,
return;
}
+ if (readRb == drawRb) {
+ /* map whole buffer for read/write */
+ /* XXX we could be clever and just map the union region of the
+ * source and dest rects.
+ */
+ GLubyte *map;
+ GLint rowStride;
+ GLint formatSize = _mesa_get_format_bytes(readRb->Format);
+
+ ctx->Driver.MapRenderbuffer(ctx, readRb, 0, 0,
+ readRb->Width, readRb->Height,
+ GL_MAP_READ_BIT | GL_MAP_WRITE_BIT,
+ &map, &rowStride);
+ if (!map) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBlitFramebuffer");
+ return;
+ }
+
+ srcMap = map + srcYpos * rowStride + srcXpos * formatSize;
+ dstMap = map + dstYpos * rowStride + dstXpos * formatSize;
+
+ /* this handles overlapping copies */
+ if (srcY0 < dstY0) {
+ /* copy in reverse (top->down) order */
+ srcMap += rowStride * (readRb->Height - 1);
+ dstMap += rowStride * (readRb->Height - 1);
+ srcRowStride = -rowStride;
+ dstRowStride = -rowStride;
+ }
+ else {
+ /* copy in normal (bottom->up) order */
+ srcRowStride = rowStride;
+ dstRowStride = rowStride;
+ }
+ }
+ else {
+ /* different src/dst buffers */
+ ctx->Driver.MapRenderbuffer(ctx, readRb,
+ srcXpos, srcYpos,
+ srcWidth, srcHeight,
+ GL_MAP_READ_BIT, &srcMap, &srcRowStride);
+ if (!srcMap) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBlitFramebuffer");
+ return;
+ }
+ ctx->Driver.MapRenderbuffer(ctx, drawRb,
+ dstXpos, dstYpos,
+ dstWidth, dstHeight,
+ GL_MAP_WRITE_BIT, &dstMap, &dstRowStride);
+ if (!dstMap) {
+ ctx->Driver.UnmapRenderbuffer(ctx, readRb);
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBlitFramebuffer");
+ return;
+ }
+ }
+
/* allocate the src/dst row buffers */
srcBuffer = malloc(pixelSize * srcWidth);
if (!srcBuffer) {
@@ -211,9 +278,8 @@ blit_nearest(struct gl_context *ctx,
}
for (dstRow = 0; dstRow < dstHeight; dstRow++) {
- const GLint dstY = dstYpos + dstRow;
GLint srcRow = (dstRow * srcHeight) / dstHeight;
- GLint srcY;
+ GLubyte *dstRowStart = dstMap + dstRowStride * dstRow;
ASSERT(srcRow >= 0);
ASSERT(srcRow < srcHeight);
@@ -222,21 +288,67 @@ blit_nearest(struct gl_context *ctx,
srcRow = srcHeight - 1 - srcRow;
}
- srcY = srcYpos + srcRow;
-
/* get pixel row from source and resample to match dest width */
- if (prevY != srcY) {
- readRb->GetRow(ctx, readRb, srcWidth, srcXpos, srcY, srcBuffer);
+ if (prevY != srcRow) {
+ GLubyte *srcRowStart = srcMap + srcRowStride * srcRow;
+
+ switch (mode) {
+ case DIRECT:
+ memcpy(srcBuffer, srcRowStart, pixelSize * srcWidth);
+ break;
+ case UNPACK_RGBA_FLOAT:
+ _mesa_unpack_rgba_row(readRb->Format, srcWidth, srcRowStart,
+ srcBuffer);
+ break;
+ case UNPACK_Z_FLOAT:
+ _mesa_unpack_float_z_row(readRb->Format, srcWidth, srcRowStart,
+ srcBuffer);
+ break;
+ case UNPACK_Z_INT:
+ _mesa_unpack_uint_z_row(readRb->Format, srcWidth, srcRowStart,
+ srcBuffer);
+ break;
+ case UNPACK_S:
+ _mesa_unpack_ubyte_stencil_row(readRb->Format, srcWidth,
+ srcRowStart, srcBuffer);
+ break;
+ }
+
(*resampleRow)(srcWidth, dstWidth, srcBuffer, dstBuffer, invertX);
- prevY = srcY;
+ prevY = srcRow;
}
/* store pixel row in destination */
- drawRb->PutRow(ctx, drawRb, dstWidth, dstXpos, dstY, dstBuffer, NULL);
+ switch (mode) {
+ case DIRECT:
+ memcpy(dstRowStart, dstBuffer, pixelSize * srcWidth);
+ break;
+ case UNPACK_RGBA_FLOAT:
+ _mesa_pack_float_rgba_row(drawRb->Format, dstWidth, dstBuffer,
+ dstRowStart);
+ break;
+ case UNPACK_Z_FLOAT:
+ _mesa_pack_float_z_row(drawRb->Format, dstWidth, dstBuffer,
+ dstRowStart);
+ break;
+ case UNPACK_Z_INT:
+ _mesa_pack_uint_z_row(drawRb->Format, dstWidth, dstBuffer,
+ dstRowStart);
+ break;
+ case UNPACK_S:
+ _mesa_pack_ubyte_stencil_row(drawRb->Format, dstWidth, dstBuffer,
+ dstRowStart);
+ break;
+ }
}
free(srcBuffer);
free(dstBuffer);
+
+ ctx->Driver.UnmapRenderbuffer(ctx, readRb);
+ if (drawRb != readRb) {
+ ctx->Driver.UnmapRenderbuffer(ctx, drawRb);
+ }
}
@@ -449,117 +561,6 @@ blit_linear(struct gl_context *ctx,
free(dstBuffer);
}
-
-/**
- * Simple case: Blit color, depth or stencil with no scaling or flipping.
- * XXX we could easily support vertical flipping here.
- */
-static void
-simple_blit(struct gl_context *ctx,
- GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
- GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
- GLbitfield buffer)
-{
- struct gl_renderbuffer *readRb, *drawRb;
- const GLint width = srcX1 - srcX0;
- const GLint height = srcY1 - srcY0;
- GLint row, srcY, dstY, yStep;
- GLint comps, bytesPerRow;
- void *rowBuffer;
-
- /* only one buffer */
- ASSERT(_mesa_bitcount(buffer) == 1);
- /* no flipping checks */
- ASSERT(srcX0 < srcX1);
- ASSERT(srcY0 < srcY1);
- ASSERT(dstX0 < dstX1);
- ASSERT(dstY0 < dstY1);
- /* size checks */
- ASSERT(srcX1 - srcX0 == dstX1 - dstX0);
- ASSERT(srcY1 - srcY0 == dstY1 - dstY0);
-
- /* From the GL_ARB_framebuffer_object spec:
- *
- * "If the source and destination buffers are identical, and the source
- * and destination rectangles overlap, the result of the blit operation
- * is undefined."
- *
- * However, we provide the expected result anyway by flipping the order of
- * the memcpy of rows.
- */
- if (srcY0 > dstY0) {
- /* src above dst: copy bottom-to-top */
- yStep = 1;
- srcY = srcY0;
- dstY = dstY0;
- }
- else {
- /* src below dst: copy top-to-bottom */
- yStep = -1;
- srcY = srcY1 - 1;
- dstY = dstY1 - 1;
- }
-
- switch (buffer) {
- case GL_COLOR_BUFFER_BIT:
- readRb = ctx->ReadBuffer->_ColorReadBuffer;
- drawRb = ctx->DrawBuffer->_ColorDrawBuffers[0];
- comps = 4;
- break;
- case GL_DEPTH_BUFFER_BIT:
- readRb = ctx->ReadBuffer->_DepthBuffer;
- drawRb = ctx->DrawBuffer->_DepthBuffer;
- comps = 1;
- break;
- case GL_STENCIL_BUFFER_BIT:
- readRb = ctx->ReadBuffer->_StencilBuffer;
- drawRb = ctx->DrawBuffer->_StencilBuffer;
- comps = 1;
- break;
- default:
- _mesa_problem(ctx, "unexpected buffer in simple_blit()");
- return;
- }
-
- ASSERT(readRb->DataType == drawRb->DataType);
-
- /* compute bytes per row */
- switch (readRb->DataType) {
- case GL_UNSIGNED_BYTE:
- bytesPerRow = comps * width * sizeof(GLubyte);
- break;
- case GL_UNSIGNED_SHORT:
- bytesPerRow = comps * width * sizeof(GLushort);
- break;
- case GL_UNSIGNED_INT:
- bytesPerRow = comps * width * sizeof(GLuint);
- break;
- case GL_FLOAT:
- bytesPerRow = comps * width * sizeof(GLfloat);
- break;
- default:
- _mesa_problem(ctx, "unexpected buffer type in simple_blit");
- return;
- }
-
- /* allocate the row buffer */
- rowBuffer = malloc(bytesPerRow);
- if (!rowBuffer) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBlitFrameBufferEXT");
- return;
- }
-
- for (row = 0; row < height; row++) {
- readRb->GetRow(ctx, readRb, width, srcX0, srcY, rowBuffer);
- drawRb->PutRow(ctx, drawRb, width, dstX0, dstY, rowBuffer, NULL);
- srcY += yStep;
- dstY += yStep;
- }
-
- free(rowBuffer);
-}
-
-
/**
* Software fallback for glBlitFramebufferEXT().
*/
@@ -574,6 +575,11 @@ _swrast_BlitFramebuffer(struct gl_context *ctx,
GL_DEPTH_BUFFER_BIT,
GL_STENCIL_BUFFER_BIT
};
+ static const GLenum buffer_enums[3] = {
+ GL_COLOR,
+ GL_DEPTH,
+ GL_STENCIL,
+ };
GLint i;
if (!_mesa_clip_blit(ctx, &srcX0, &srcY0, &srcX1, &srcY1,
@@ -584,41 +590,47 @@ _swrast_BlitFramebuffer(struct gl_context *ctx,
if (SWRAST_CONTEXT(ctx)->NewState)
_swrast_validate_derived(ctx);
- swrast_render_start(ctx);
-
+ /* First, try covering whatever buffers possible using the fast 1:1 copy
+ * path.
+ */
if (srcX1 - srcX0 == dstX1 - dstX0 &&
srcY1 - srcY0 == dstY1 - dstY0 &&
srcX0 < srcX1 &&
srcY0 < srcY1 &&
dstX0 < dstX1 &&
dstY0 < dstY1) {
- /* no stretching or flipping.
- * filter doesn't matter.
- */
for (i = 0; i < 3; i++) {
if (mask & buffers[i]) {
- simple_blit(ctx, srcX0, srcY0, srcX1, srcY1,
- dstX0, dstY0, dstX1, dstY1, buffers[i]);
- }
+ if (swrast_fast_copy_pixels(ctx,
+ srcX0, srcY0,
+ srcX1 - srcX0, srcY1 - srcY0,
+ dstX0, dstY0,
+ buffer_enums[i])) {
+ mask &= ~buffers[i];
+ }
+ }
+ }
+
+ if (!mask)
+ return;
+ }
+
+ if (filter == GL_NEAREST) {
+ for (i = 0; i < 3; i++) {
+ if (mask & buffers[i]) {
+ blit_nearest(ctx, srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1, buffers[i]);
+ }
}
}
else {
- if (filter == GL_NEAREST) {
- for (i = 0; i < 3; i++) {
- if (mask & buffers[i]) {
- blit_nearest(ctx, srcX0, srcY0, srcX1, srcY1,
- dstX0, dstY0, dstX1, dstY1, buffers[i]);
- }
- }
- }
- else {
- ASSERT(filter == GL_LINEAR);
- if (mask & GL_COLOR_BUFFER_BIT) { /* depth/stencil not allowed */
- blit_linear(ctx, srcX0, srcY0, srcX1, srcY1,
- dstX0, dstY0, dstX1, dstY1);
- }
+ ASSERT(filter == GL_LINEAR);
+ if (mask & GL_COLOR_BUFFER_BIT) { /* depth/stencil not allowed */
+ swrast_render_start(ctx);
+ blit_linear(ctx, srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1);
+ swrast_render_finish(ctx);
}
}
- swrast_render_finish(ctx);
}
diff --git a/mesalib/src/mesa/swrast/s_copypix.c b/mesalib/src/mesa/swrast/s_copypix.c
index 1dc4286a3..1e0f9fe7d 100644
--- a/mesalib/src/mesa/swrast/s_copypix.c
+++ b/mesalib/src/mesa/swrast/s_copypix.c
@@ -422,13 +422,13 @@ copy_stencil_pixels( struct gl_context *ctx, GLint srcx, GLint srcy,
/**
- * Try to do a fast copy pixels with memcpy.
+ * Try to do a fast 1:1 blit with memcpy.
* \return GL_TRUE if successful, GL_FALSE otherwise.
*/
-static GLboolean
-fast_copy_pixels(struct gl_context *ctx,
- GLint srcX, GLint srcY, GLsizei width, GLsizei height,
- GLint dstX, GLint dstY, GLenum type)
+GLboolean
+swrast_fast_copy_pixels(struct gl_context *ctx,
+ GLint srcX, GLint srcY, GLsizei width, GLsizei height,
+ GLint dstX, GLint dstY, GLenum type)
{
struct gl_framebuffer *srcFb = ctx->ReadBuffer;
struct gl_framebuffer *dstFb = ctx->DrawBuffer;
@@ -438,14 +438,6 @@ fast_copy_pixels(struct gl_context *ctx,
GLubyte *srcMap, *dstMap;
GLint srcRowStride, dstRowStride;
- if (SWRAST_CONTEXT(ctx)->_RasterMask != 0x0 ||
- ctx->Pixel.ZoomX != 1.0F ||
- ctx->Pixel.ZoomY != 1.0F ||
- ctx->_ImageTransferState) {
- /* can't handle these */
- return GL_FALSE;
- }
-
if (type == GL_COLOR) {
if (dstFb->_NumColorDrawBuffers != 1)
return GL_FALSE;
@@ -508,7 +500,7 @@ fast_copy_pixels(struct gl_context *ctx,
srcRb->Width, srcRb->Height,
GL_MAP_READ_BIT | GL_MAP_WRITE_BIT,
&map, &rowStride);
- if (!srcMap) {
+ if (!map) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels");
return GL_TRUE; /* don't retry with slow path */
}
@@ -582,7 +574,12 @@ _swrast_CopyPixels( struct gl_context *ctx,
if (swrast->NewState)
_swrast_validate_derived( ctx );
- if (fast_copy_pixels(ctx, srcx, srcy, width, height, destx, desty, type)) {
+ if (!(SWRAST_CONTEXT(ctx)->_RasterMask != 0x0 ||
+ ctx->Pixel.ZoomX != 1.0F ||
+ ctx->Pixel.ZoomY != 1.0F ||
+ ctx->_ImageTransferState) &&
+ swrast_fast_copy_pixels(ctx, srcx, srcy, width, height, destx, desty,
+ type)) {
/* all done */
return;
}
diff --git a/mesalib/src/mesa/swrast/s_depth.c b/mesalib/src/mesa/swrast/s_depth.c
index f87adaa84..53f21cb69 100644
--- a/mesalib/src/mesa/swrast/s_depth.c
+++ b/mesalib/src/mesa/swrast/s_depth.c
@@ -489,7 +489,6 @@ _swrast_clear_depth_buffer(struct gl_context *ctx)
{
struct gl_renderbuffer *rb =
ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
- GLuint clearValue;
GLint x, y, width, height;
GLubyte *map;
GLint rowStride, i, j;
@@ -500,14 +499,6 @@ _swrast_clear_depth_buffer(struct gl_context *ctx)
return;
}
- /* compute integer clearing value */
- if (ctx->Depth.Clear == 1.0) {
- clearValue = ctx->DrawBuffer->_DepthMax;
- }
- else {
- clearValue = (GLuint) (ctx->Depth.Clear * ctx->DrawBuffer->_DepthMaxF);
- }
-
/* compute region to clear */
x = ctx->DrawBuffer->_Xmin;
y = ctx->DrawBuffer->_Ymin;
diff --git a/mesalib/src/mesa/swrast/s_span.c b/mesalib/src/mesa/swrast/s_span.c
index 4124e444e..8f02eeae7 100644
--- a/mesalib/src/mesa/swrast/s_span.c
+++ b/mesalib/src/mesa/swrast/s_span.c
@@ -776,7 +776,7 @@ clip_span( struct gl_context *ctx, SWspan *span )
span->intTex[1] += leftClip * span->intTexStep[1];
#define SHIFT_ARRAY(ARRAY, SHIFT, LEN) \
- memcpy(ARRAY, ARRAY + (SHIFT), (LEN) * sizeof(ARRAY[0]))
+ memmove(ARRAY, ARRAY + (SHIFT), (LEN) * sizeof(ARRAY[0]))
for (i = 0; i < FRAG_ATTRIB_MAX; i++) {
if (span->arrayAttribs & (1 << i)) {
diff --git a/mesalib/src/mesa/swrast/swrast.h b/mesalib/src/mesa/swrast/swrast.h
index dd4055159..468d22f0b 100644
--- a/mesalib/src/mesa/swrast/swrast.h
+++ b/mesalib/src/mesa/swrast/swrast.h
@@ -110,6 +110,11 @@ _swrast_CopyPixels( struct gl_context *ctx,
GLsizei width, GLsizei height,
GLenum type );
+extern GLboolean
+swrast_fast_copy_pixels(struct gl_context *ctx,
+ GLint srcX, GLint srcY, GLsizei width, GLsizei height,
+ GLint dstX, GLint dstY, GLenum type);
+
extern void
_swrast_DrawPixels( struct gl_context *ctx,
GLint x, GLint y,
diff --git a/mesalib/src/mesa/tnl/t_draw.c b/mesalib/src/mesa/tnl/t_draw.c
index 83ded1949..f949c34d3 100644
--- a/mesalib/src/mesa/tnl/t_draw.c
+++ b/mesalib/src/mesa/tnl/t_draw.c
@@ -349,26 +349,10 @@ static void bind_indices( struct gl_context *ctx,
if (_mesa_is_bufferobj(ib->obj) && !_mesa_bufferobj_mapped(ib->obj)) {
/* if the buffer object isn't mapped yet, map it now */
- unsigned map_size;
-
- switch (ib->type) {
- case GL_UNSIGNED_BYTE:
- map_size = ib->count * sizeof(GLubyte);
- break;
- case GL_UNSIGNED_SHORT:
- map_size = ib->count * sizeof(GLushort);
- break;
- case GL_UNSIGNED_INT:
- map_size = ib->count * sizeof(GLuint);
- break;
- default:
- assert(0);
- map_size = 0;
- }
-
bo[*nr_bo] = ib->obj;
(*nr_bo)++;
- ptr = ctx->Driver.MapBufferRange(ctx, (GLsizeiptr) ib->ptr, map_size,
+ ptr = ctx->Driver.MapBufferRange(ctx, (GLsizeiptr) ib->ptr,
+ ib->count * vbo_sizeof_ib_type(ib->type),
GL_MAP_READ_BIT, ib->obj);
assert(ib->obj->Pointer);
} else {
diff --git a/mesalib/src/mesa/vbo/vbo.h b/mesalib/src/mesa/vbo/vbo.h
index 7384790e3..ed8fc1722 100644
--- a/mesalib/src/mesa/vbo/vbo.h
+++ b/mesalib/src/mesa/vbo/vbo.h
@@ -122,6 +122,10 @@ void vbo_rebase_prims( struct gl_context *ctx,
GLuint min_index,
GLuint max_index,
vbo_draw_func draw );
+
+int
+vbo_sizeof_ib_type(GLenum type);
+
void
vbo_get_minmax_index(struct gl_context *ctx, const struct _mesa_prim *prim,
const struct _mesa_index_buffer *ib,
diff --git a/mesalib/src/mesa/vbo/vbo_exec_array.c b/mesalib/src/mesa/vbo/vbo_exec_array.c
index 2db85e2e5..fec49d35e 100644
--- a/mesalib/src/mesa/vbo/vbo_exec_array.c
+++ b/mesalib/src/mesa/vbo/vbo_exec_array.c
@@ -75,6 +75,22 @@ vbo_check_buffers_are_unmapped(struct gl_context *ctx)
assert(!_mesa_bufferobj_mapped(exec->vtx.bufferobj));
}
+int
+vbo_sizeof_ib_type(GLenum type)
+{
+ switch (type) {
+ case GL_UNSIGNED_INT:
+ return sizeof(GLuint);
+ case GL_UNSIGNED_SHORT:
+ return sizeof(GLushort);
+ case GL_UNSIGNED_BYTE:
+ return sizeof(GLubyte);
+ default:
+ assert(!"unsupported index data type");
+ /* In case assert is turned off */
+ return 0;
+ }
+}
/**
@@ -96,24 +112,8 @@ vbo_get_minmax_index(struct gl_context *ctx,
GLuint i;
if (_mesa_is_bufferobj(ib->obj)) {
- unsigned map_size;
-
- switch (ib->type) {
- case GL_UNSIGNED_INT:
- map_size = count * sizeof(GLuint);
- break;
- case GL_UNSIGNED_SHORT:
- map_size = count * sizeof(GLushort);
- break;
- case GL_UNSIGNED_BYTE:
- map_size = count * sizeof(GLubyte);
- break;
- default:
- assert(0);
- map_size = 0;
- }
-
- indices = ctx->Driver.MapBufferRange(ctx, (GLsizeiptr) ib->ptr, map_size,
+ indices = ctx->Driver.MapBufferRange(ctx, (GLsizeiptr) ib->ptr,
+ count * vbo_sizeof_ib_type(ib->type),
GL_MAP_READ_BIT, ib->obj);
} else {
indices = ib->ptr;
@@ -1053,7 +1053,7 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
struct vbo_exec_context *exec = &vbo->exec;
struct _mesa_index_buffer ib;
struct _mesa_prim *prim;
- unsigned int index_type_size = 0;
+ unsigned int index_type_size = vbo_sizeof_ib_type(type);
uintptr_t min_index_ptr, max_index_ptr;
GLboolean fallback = GL_FALSE;
int i;
@@ -1083,20 +1083,6 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
if (ctx->NewState)
_mesa_update_state( ctx );
- switch (type) {
- case GL_UNSIGNED_INT:
- index_type_size = 4;
- break;
- case GL_UNSIGNED_SHORT:
- index_type_size = 2;
- break;
- case GL_UNSIGNED_BYTE:
- index_type_size = 1;
- break;
- default:
- assert(0);
- }
-
min_index_ptr = (uintptr_t)indices[0];
max_index_ptr = 0;
for (i = 0; i < primcount; i++) {