aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-07-31 10:17:14 +0200
committermarha <marha@users.sourceforge.net>2012-07-31 10:17:14 +0200
commit83da3ad0287bc51cd16ee6911fe73dc98ebe000b (patch)
tree48d48590a0b0a3770006aeda8ec2b2a45054d1f1
parent00e30605ffc7ac3cf1a091ff2c1f46cfefb780d7 (diff)
parentbd27b3d008b0abf9ae2edcb127302728808533e4 (diff)
downloadvcxsrv-83da3ad0287bc51cd16ee6911fe73dc98ebe000b.tar.gz
vcxsrv-83da3ad0287bc51cd16ee6911fe73dc98ebe000b.tar.bz2
vcxsrv-83da3ad0287bc51cd16ee6911fe73dc98ebe000b.zip
Merge remote-tracking branch 'origin/released'
-rw-r--r--fontconfig/README8
-rw-r--r--fontconfig/conf.d/Makefile.am2
-rw-r--r--fontconfig/configure.ac2
-rw-r--r--fontconfig/fontconfig.pc.in2
-rw-r--r--fontconfig/fontconfig/fontconfig.h2
-rw-r--r--libXext/src/XSync.c4
-rw-r--r--mesalib/configs/current.in7
-rw-r--r--mesalib/configs/default1
-rw-r--r--mesalib/configure.ac43
-rw-r--r--mesalib/docs/WL_bind_wayland_display.spec63
-rw-r--r--mesalib/docs/relnotes-8.1.html6
-rw-r--r--mesalib/include/EGL/eglmesaext.h14
-rw-r--r--mesalib/scons/gallium.py3
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_debug_symbol.c2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_tests.c5
-rw-r--r--mesalib/src/glsl/ast.h6
-rw-r--r--mesalib/src/glsl/ast_to_hir.cpp116
-rw-r--r--mesalib/src/glsl/builtin_types.h5
-rw-r--r--mesalib/src/glsl/glcpp/glcpp-parse.y4
-rw-r--r--mesalib/src/glsl/glsl_parser.yy4
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.cpp16
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.h4
-rw-r--r--mesalib/src/glsl/glsl_types.cpp220
-rw-r--r--mesalib/src/glsl/glsl_types.h18
-rw-r--r--mesalib/src/glsl/ir.cpp1
-rw-r--r--mesalib/src/glsl/ir.h15
-rw-r--r--mesalib/src/glsl/ir_clone.cpp1
-rw-r--r--mesalib/src/glsl/ir_set_program_inouts.cpp36
-rw-r--r--mesalib/src/glsl/ir_uniform.h34
-rw-r--r--mesalib/src/glsl/link_uniforms.cpp177
-rw-r--r--mesalib/src/glsl/linker.cpp91
-rw-r--r--mesalib/src/glsl/linker.h9
-rw-r--r--mesalib/src/glsl/lower_vector.cpp2
-rw-r--r--mesalib/src/glsl/opt_dead_code.cpp8
-rw-r--r--mesalib/src/glsl/strtod.c2
-rw-r--r--mesalib/src/mesa/Android.gen.mk68
-rw-r--r--mesalib/src/mesa/Android.mk1
-rw-r--r--mesalib/src/mesa/Makefile.am9
-rw-r--r--mesalib/src/mesa/Makefile.old27
-rw-r--r--mesalib/src/mesa/SConscript1
-rw-r--r--mesalib/src/mesa/drivers/common/meta.c7
-rw-r--r--mesalib/src/mesa/drivers/dri/common/drirc10
-rw-r--r--mesalib/src/mesa/drivers/dri/common/xmlpool/options.h10
-rw-r--r--mesalib/src/mesa/main/api_exec.c227
-rw-r--r--mesalib/src/mesa/main/api_exec.h3
-rw-r--r--mesalib/src/mesa/main/api_validate.c1
-rw-r--r--mesalib/src/mesa/main/arbprogram.c4
-rw-r--r--mesalib/src/mesa/main/arrayobj.h1
-rw-r--r--mesalib/src/mesa/main/context.c23
-rw-r--r--mesalib/src/mesa/main/context.h20
-rw-r--r--mesalib/src/mesa/main/dlist.c1
-rw-r--r--mesalib/src/mesa/main/drawpix.c7
-rw-r--r--mesalib/src/mesa/main/extensions.c4
-rw-r--r--mesalib/src/mesa/main/fbobject.c128
-rw-r--r--mesalib/src/mesa/main/ffvertex_prog.c10
-rw-r--r--mesalib/src/mesa/main/format_pack.c28
-rw-r--r--mesalib/src/mesa/main/format_unpack.c68
-rw-r--r--mesalib/src/mesa/main/formats.c28
-rw-r--r--mesalib/src/mesa/main/formats.h5
-rw-r--r--mesalib/src/mesa/main/framebuffer.c15
-rw-r--r--mesalib/src/mesa/main/get.c11
-rw-r--r--mesalib/src/mesa/main/getstring.c1
-rw-r--r--mesalib/src/mesa/main/glformats.c1329
-rw-r--r--mesalib/src/mesa/main/glformats.h103
-rw-r--r--mesalib/src/mesa/main/image.c1207
-rw-r--r--mesalib/src/mesa/main/image.h49
-rw-r--r--mesalib/src/mesa/main/imports.c222
-rw-r--r--mesalib/src/mesa/main/imports.h29
-rw-r--r--mesalib/src/mesa/main/matrix.c4
-rw-r--r--mesalib/src/mesa/main/mipmap.c1
-rw-r--r--mesalib/src/mesa/main/mtypes.h58
-rw-r--r--mesalib/src/mesa/main/nvprogram.c21
-rw-r--r--mesalib/src/mesa/main/pack.c39
-rw-r--r--mesalib/src/mesa/main/pack_tmp.h9
-rw-r--r--mesalib/src/mesa/main/pbo.c29
-rw-r--r--mesalib/src/mesa/main/readpix.c11
-rw-r--r--mesalib/src/mesa/main/shaderapi.c8
-rw-r--r--mesalib/src/mesa/main/shared.c10
-rw-r--r--mesalib/src/mesa/main/state.c15
-rw-r--r--mesalib/src/mesa/main/texformat.c3
-rw-r--r--mesalib/src/mesa/main/texgetimage.c1
-rw-r--r--mesalib/src/mesa/main/teximage.c13
-rw-r--r--mesalib/src/mesa/main/texparam.c2
-rw-r--r--mesalib/src/mesa/main/texstore.c73
-rw-r--r--mesalib/src/mesa/main/uniform_query.cpp98
-rw-r--r--mesalib/src/mesa/main/uniforms.c70
-rw-r--r--mesalib/src/mesa/main/uniforms.h11
-rw-r--r--mesalib/src/mesa/main/varray.c2
-rw-r--r--mesalib/src/mesa/main/version.c1
-rw-r--r--mesalib/src/mesa/main/vtxfmt.c171
-rw-r--r--mesalib/src/mesa/math/m_debug_norm.c4
-rw-r--r--mesalib/src/mesa/math/m_matrix.c56
-rw-r--r--mesalib/src/mesa/math/m_matrix.h5
-rw-r--r--mesalib/src/mesa/program/arbprogparse.c1
-rw-r--r--mesalib/src/mesa/program/ir_to_mesa.cpp10
-rw-r--r--mesalib/src/mesa/program/prog_statevars.c4
-rw-r--r--mesalib/src/mesa/program/program.c31
-rw-r--r--mesalib/src/mesa/program/program.h54
-rw-r--r--mesalib/src/mesa/program/program_parse.y2
-rw-r--r--mesalib/src/mesa/program/program_parser.h1
-rw-r--r--mesalib/src/mesa/sources.mak560
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_array.c3
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_clip.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_depth.c16
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_framebuffer.c9
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_bitmap.c84
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_bitmap.h6
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_blit.c15
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_drawpixels.c3
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_fbo.c10
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_flush.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_viewport.c4
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.c6
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.h5
-rw-r--r--mesalib/src/mesa/state_tracker/st_draw.c6
-rw-r--r--mesalib/src/mesa/state_tracker/st_format.c1
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp46
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.h1
-rw-r--r--mesalib/src/mesa/state_tracker/st_manager.c4
-rw-r--r--mesalib/src/mesa/state_tracker/st_program.c4
-rw-r--r--mesalib/src/mesa/swrast/s_texfetch.c8
-rw-r--r--mesalib/src/mesa/tnl/t_rasterpos.c2
-rw-r--r--mesalib/src/mesa/tnl/t_vb_points.c2
-rw-r--r--mesalib/src/mesa/tnl/t_vb_texgen.c4
-rw-r--r--mesalib/src/mesa/vbo/vbo_split_copy.c2
-rw-r--r--mesalib/src/mesa/vbo/vbo_split_inplace.c2
-rw-r--r--pixman/.gitignore2
-rw-r--r--pixman/demos/Makefile.am4
-rw-r--r--pixman/demos/srgb-test.c96
-rw-r--r--pixman/pixman/Makefile.sources5
-rw-r--r--pixman/pixman/make-srgb.pl112
-rw-r--r--pixman/pixman/pixman-access.c134
-rw-r--r--pixman/pixman/pixman-image.c3
-rw-r--r--pixman/pixman/pixman-private.h15
-rw-r--r--pixman/pixman/pixman.c1
-rw-r--r--pixman/pixman/pixman.h4
-rw-r--r--pixman/test/composite.c76
-rw-r--r--pixman/test/stress-test.c1
-rw-r--r--pixman/test/utils.c36
-rw-r--r--pixman/test/utils.h6
-rw-r--r--xorg-server/configure.ac5
-rw-r--r--xorg-server/hw/xfree86/common/xaarop.h43
-rw-r--r--xorg-server/hw/xfree86/man/xorg.conf.man70
-rw-r--r--xorg-server/hw/xquartz/GL/indirect.c10
-rw-r--r--xorg-server/hw/xquartz/quartz.c12
-rw-r--r--xorg-server/hw/xquartz/xpr/xprEvent.c32
-rw-r--r--xorg-server/include/screenint.h6
-rw-r--r--xorg-server/mi/miinitext.c6
-rw-r--r--xorg-server/miext/Makefile.am19
-rw-r--r--xorg-server/miext/cw/Makefile.am11
-rw-r--r--xorg-server/miext/cw/cw.c524
-rw-r--r--xorg-server/miext/cw/cw.h173
-rw-r--r--xorg-server/miext/cw/cw_ops.c477
-rw-r--r--xorg-server/miext/cw/cw_render.c383
-rw-r--r--xorg-server/miext/damage/damage.c3
-rw-r--r--xorg-server/xkeyboard-config/rules/base.xml.in6
-rw-r--r--xorg-server/xkeyboard-config/symbols/no30
157 files changed, 4362 insertions, 4158 deletions
diff --git a/fontconfig/README b/fontconfig/README
index 624ffa4ce..02f4f27d6 100644
--- a/fontconfig/README
+++ b/fontconfig/README
@@ -1,12 +1,18 @@
Fontconfig
Font configuration and customization library
- Version 2.10.0
+ Version 2.10.1
2012-03-11
Check INSTALL for compilation and installation instructions.
Report bugs to https://bugs.freedesktop.org in the fontconfig module.
+2.10.1
+
+Akira TAGOH (2):
+ Fix a typo in fontconfig.pc
+ Install config files first
+
2.10.0
Akira TAGOH (5):
diff --git a/fontconfig/conf.d/Makefile.am b/fontconfig/conf.d/Makefile.am
index 7f14920d0..0f6f59c60 100644
--- a/fontconfig/conf.d/Makefile.am
+++ b/fontconfig/conf.d/Makefile.am
@@ -76,7 +76,7 @@ template_DATA = \
80-delicious.conf \
90-synthetic.conf
-install-data-local:
+install-data-hook:
mkdir -p $(DESTDIR)$(configdir)
@(echo cd $(DESTDIR)$(configdir); \
cd $(DESTDIR)$(configdir); \
diff --git a/fontconfig/configure.ac b/fontconfig/configure.ac
index 8aa3d6ba7..4de2d089c 100644
--- a/fontconfig/configure.ac
+++ b/fontconfig/configure.ac
@@ -34,7 +34,7 @@ dnl This is the package version number, not the shared library
dnl version. This same version number must appear in fontconfig/fontconfig.h
dnl Yes, it is a pain to synchronize version numbers. Unfortunately, it's
dnl not possible to extract the version number here from fontconfig.h
-AM_INIT_AUTOMAKE(fontconfig, 2.10.0)
+AM_INIT_AUTOMAKE(fontconfig, 2.10.1)
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
dnl libtool versioning
diff --git a/fontconfig/fontconfig.pc.in b/fontconfig/fontconfig.pc.in
index 7d846a533..9ef2c273f 100644
--- a/fontconfig/fontconfig.pc.in
+++ b/fontconfig/fontconfig.pc.in
@@ -5,7 +5,7 @@ includedir=@includedir@
sysconfdir=@sysconfdir@
localstatedir=@localstatedir@
PACKAGE=@PACKAGE@
-confdir=@confdir@
+confdir=@baseconfigdir@
cachedir=@fc_cachedir@
Name: Fontconfig
diff --git a/fontconfig/fontconfig/fontconfig.h b/fontconfig/fontconfig/fontconfig.h
index 41af47074..d3aeaf359 100644
--- a/fontconfig/fontconfig/fontconfig.h
+++ b/fontconfig/fontconfig/fontconfig.h
@@ -52,7 +52,7 @@ typedef int FcBool;
#define FC_MAJOR 2
#define FC_MINOR 10
-#define FC_REVISION 0
+#define FC_REVISION 1
#define FC_VERSION ((FC_MAJOR * 10000) + (FC_MINOR * 100) + (FC_REVISION))
diff --git a/libXext/src/XSync.c b/libXext/src/XSync.c
index df7c43542..577529388 100644
--- a/libXext/src/XSync.c
+++ b/libXext/src/XSync.c
@@ -107,8 +107,8 @@ static /* const */ SyncVersionInfo supported_versions[] = {
};
#define NUM_VERSIONS (sizeof(supported_versions)/sizeof(supported_versions[0]))
-#define GET_VERSION(info) ((info) ? (const SyncVersionInfo*)(info)->data : NULL)
-#define IS_VERSION_SUPPORTED(info) (!!GET_VERSION(info))
+#define GET_VERSION(info) ((const SyncVersionInfo*)(info)->data)
+#define IS_VERSION_SUPPORTED(info) (!!(info))
static
const SyncVersionInfo* GetVersionInfo(Display *dpy)
diff --git a/mesalib/configs/current.in b/mesalib/configs/current.in
index dc0dea835..c4f3f4df9 100644
--- a/mesalib/configs/current.in
+++ b/mesalib/configs/current.in
@@ -9,16 +9,14 @@ CONFIG_NAME = autoconf
# Compiler and flags
CC = @CC@
CXX = @CXX@
-OPT_FLAGS = @OPT_FLAGS@
-ARCH_FLAGS = @ARCH_FLAGS@
PIC_FLAGS = @PIC_FLAGS@
DEFINES = @DEFINES@
API_DEFINES = @API_DEFINES@
SHARED_GLAPI = @SHARED_GLAPI@
CFLAGS_NOVISIBILITY = @CPPFLAGS@ @CFLAGS@ \
- $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES)
+ $(PIC_FLAGS) $(DEFINES)
CXXFLAGS_NOVISIBILITY = @CPPFLAGS@ @CXXFLAGS@ \
- $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES)
+ $(PIC_FLAGS) $(DEFINES)
CFLAGS = $(CFLAGS_NOVISIBILITY) @VISIBILITY_CFLAGS@
CXXFLAGS = $(CXXFLAGS_NOVISIBILITY) @VISIBILITY_CXXFLAGS@
LDFLAGS = @LDFLAGS@
@@ -99,7 +97,6 @@ GLAPI_LIB_NAME = @GLAPI_LIB_NAME@
GL_LIB_GLOB = @GL_LIB_GLOB@
GLU_LIB_GLOB = @GLU_LIB_GLOB@
GLW_LIB_GLOB = @GLW_LIB_GLOB@
-OSMESA_LIB_GLOB = @OSMESA_LIB_GLOB@
EGL_LIB_GLOB = @EGL_LIB_GLOB@
GLESv1_CM_LIB_GLOB = @GLESv1_CM_LIB_GLOB@
GLESv2_LIB_GLOB = @GLESv2_LIB_GLOB@
diff --git a/mesalib/configs/default b/mesalib/configs/default
index 734b2f62e..8a8d8f8d2 100644
--- a/mesalib/configs/default
+++ b/mesalib/configs/default
@@ -76,7 +76,6 @@ GLAPI_LIB_NAME = lib$(GLAPI_LIB).so
GL_LIB_GLOB = $(GL_LIB_NAME)*
GLU_LIB_GLOB = $(GLU_LIB_NAME)*
GLW_LIB_GLOB = $(GLW_LIB_NAME)*
-OSMESA_LIB_GLOB = $(OSMESA_LIB_NAME)*
EGL_LIB_GLOB = $(EGL_LIB_NAME)*
GLESv1_CM_LIB_GLOB = $(GLESv1_CM_LIB_NAME)*
GLESv2_LIB_GLOB = $(GLESv2_LIB_NAME)*
diff --git a/mesalib/configure.ac b/mesalib/configure.ac
index 1d60957af..47b918720 100644
--- a/mesalib/configure.ac
+++ b/mesalib/configure.ac
@@ -246,14 +246,6 @@ esac
AC_SUBST([VISIBILITY_CFLAGS])
AC_SUBST([VISIBILITY_CXXFLAGS])
-dnl These should be unnecessary, but let the user set them if they want
-AC_ARG_VAR([OPT_FLAGS], [Additional optimization flags for the compiler.
- Default is to use CFLAGS.])
-AC_ARG_VAR([ARCH_FLAGS], [Additional architecture specific flags for the
- compiler. Default is to use CFLAGS.])
-AC_SUBST([OPT_FLAGS])
-AC_SUBST([ARCH_FLAGS])
-
dnl
dnl Hacks to enable 32 or 64 bit build
dnl
@@ -266,7 +258,6 @@ AC_ARG_ENABLE([32-bit],
if test "x$enable_32bit" = xyes; then
if test "x$GCC" = xyes; then
CFLAGS="$CFLAGS -m32"
- ARCH_FLAGS="$ARCH_FLAGS -m32"
CCASFLAGS="$CCASFLAGS -m32"
fi
if test "x$GXX" = xyes; then
@@ -389,7 +380,6 @@ fi
AC_SUBST([GL_LIB])
AC_SUBST([GLU_LIB])
AC_SUBST([OSMESA_LIB])
-AM_CONDITIONAL(HAVE_MANGLED_GL, test "x${enable_mangling}" = "xyes")
dnl
dnl potentially-infringing-but-nobody-knows-for-sure stuff
@@ -417,7 +407,6 @@ GLAPI_LIB_NAME='lib$(GLAPI_LIB).'${LIB_EXTENSION}
GL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
GLU_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLU_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
-OSMESA_LIB_GLOB=${LIB_PREFIX_GLOB}'$(OSMESA_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
EGL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(EGL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
EGL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(EGL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
GLESv1_CM_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLESv1_CM_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
@@ -436,7 +425,6 @@ AC_SUBST([GLAPI_LIB_NAME])
AC_SUBST([GL_LIB_GLOB])
AC_SUBST([GLU_LIB_GLOB])
-AC_SUBST([OSMESA_LIB_GLOB])
AC_SUBST([EGL_LIB_GLOB])
AC_SUBST([GLESv1_CM_LIB_GLOB])
AC_SUBST([GLESv2_LIB_GLOB])
@@ -1829,6 +1817,13 @@ AC_ARG_WITH([llvm-shared-libs],
[with_llvm_shared_libs=yes],
[with_llvm_shared_libs=no])
+AC_ARG_WITH([llvm-prefix],
+ [AS_HELP_STRING([--with-llvm-prefix],
+ [Prefix for LLVM installations in non-standard locations])],
+ [llvm_prefix="$withval"],
+ [llvm_prefix=""])
+
+
if test "x$with_gallium_drivers" = x; then
enable_gallium_llvm=no
fi
@@ -1838,7 +1833,11 @@ if test "x$enable_gallium_llvm" = xauto; then
esac
fi
if test "x$enable_gallium_llvm" = xyes; then
- AC_PATH_PROG([LLVM_CONFIG], [llvm-config], [no])
+ if test "x$llvm_prefix" != x; then
+ AC_PATH_PROG([LLVM_CONFIG], [llvm-config], [no], ["$llvm_prefix/bin"])
+ else
+ AC_PATH_PROG([LLVM_CONFIG], [llvm-config], [no])
+ fi
if test "x$LLVM_CONFIG" != xno; then
LLVM_VERSION=`$LLVM_CONFIG --version | sed 's/svn.*//g'`
@@ -1847,10 +1846,14 @@ if test "x$enable_gallium_llvm" = xyes; then
dnl We can't use $LLVM_VERSION because it has 'svn' stripped out,
LLVM_LIBS="-lLLVM-`$LLVM_CONFIG --version`"
else
- LLVM_LIBS="`$LLVM_CONFIG --libs engine bitwriter mcjit`"
+ LLVM_COMPONENTS="engine bitwriter"
+ if $LLVM_CONFIG --components | grep -q '\<mcjit\>'; then
+ LLVM_COMPONENTS="${LLVM_COMPONENTS} mcjit"
+ fi
if test "x$enable_opencl" = xyes; then
- LLVM_LIBS="${LLVM_LIBS} `$LLVM_CONFIG --libs ipo linker instrumentation`"
+ LLVM_COMPONENTS="${LLVM_COMPONENTS} ipo linker instrumentation"
fi
+ LLVM_LIBS="`$LLVM_CONFIG --libs ${LLVM_COMPONENTS}`"
fi
LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags`
LLVM_BINDIR=`$LLVM_CONFIG --bindir`
@@ -2073,6 +2076,12 @@ if test "x$enable_gallium_loader" = xyes; then
if test "x$enable_gallium_drm_loader" = xyes; then
GALLIUM_PIPE_LOADER_DEFINES="$GALLIUM_PIPE_LOADER_DEFINES -DHAVE_PIPE_LOADER_DRM"
+ PKG_CHECK_MODULES([GALLIUM_PIPE_LOADER_XCB], [xcb xcb-dri2],
+ pipe_loader_have_xcb=yes, pipe_loader_have_xcb=no)
+ if test "x$pipe_loader_have_xcb" = xyes; then
+ GALLIUM_PIPE_LOADER_DEFINES="$GALLIUM_PIPE_LOADER_DEFINES -DPIPE_LOADER_HAVE_XCB"
+ GALLIUM_PIPE_LOADER_LIBS="$GALLIUM_PIPE_LOADER_LIBS $GALLIUM_PIPE_LOADER_XCB_LIBS $LIBDRM_LIBS"
+ fi
fi
AC_SUBST([GALLIUM_PIPE_LOADER_DEFINES])
@@ -2287,9 +2296,9 @@ echo " Static libs: $enable_static"
dnl Compiler options
# cleanup the CFLAGS/CXXFLAGS/DEFINES vars
-cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
+cflags=`echo $CFLAGS $PIC_FLAGS | \
$SED 's/^ *//;s/ */ /;s/ *$//'`
-cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
+cxxflags=`echo $CXXFLAGS $PIC_FLAGS | \
$SED 's/^ *//;s/ */ /;s/ *$//'`
defines=`echo $DEFINES | $SED 's/^ *//;s/ */ /;s/ *$//'`
echo ""
diff --git a/mesalib/docs/WL_bind_wayland_display.spec b/mesalib/docs/WL_bind_wayland_display.spec
index e1aca5380..02bd6ea21 100644
--- a/mesalib/docs/WL_bind_wayland_display.spec
+++ b/mesalib/docs/WL_bind_wayland_display.spec
@@ -70,18 +70,11 @@ New Tokens
EGL_WAYLAND_PLANE_WL 0x31D6
+ Possible values for EGL_TEXTURE_FORMAT:
- Accepted as a eglQueryWaylandBufferWL attribute:
-
- EGL_WAYLAND_BUFFER_COMPONENTS_WL 0x31D7
-
- Possible values for EGL_WAYLAND_BUFFER_COMPONENTS_WL:
-
- EGL_WAYLAND_BUFFER_RGB_WL 0x31D8
- EGL_WAYLAND_BUFFER_RGBA_WL 0x31D9
- EGL_WAYLAND_BUFFER_Y_U_V_WL 0x31Da
- EGL_WAYLAND_BUFFER_Y_UV_WL 0x31Db
- EGL_WAYLAND_BUFFER_Y_XUXV_WL 0x31Dc
+ EGL_TEXTURE_Y_U_V_WL 0x31D7
+ EGL_TEXTURE_Y_UV_WL 0x31D8
+ EGL_TEXTURE_Y_XUXV_WL 0x31D9
Additions to the EGL 1.4 Specification:
@@ -106,48 +99,47 @@ Additions to the EGL 1.4 Specification:
YUV formats. Depending on the exact YUV format in use, the
compositor will have to create one or more EGLImages for the
various planes. The eglQueryWaylandBufferWL function should be
- used to first query the wl_buffer components using
- EGL_WAYLAND_BUFFER_COMPONENTS_WL as the attribute. If the
- wl_buffer object is not an EGL wl_buffer (wl_shm and other wayland
- extensions can create wl_buffer objects), this query will return
- EGL_FALSE. In that case the wl_buffer can not be used with EGL
- and the compositor should have another way to get the buffer
+ used to first query the wl_buffer texture format using
+ EGL_TEXTURE_FORMAT as the attribute. If the wl_buffer object is
+ not an EGL wl_buffer (wl_shm and other wayland extensions can
+ create wl_buffer objects of different types), this query will
+ return EGL_FALSE. In that case the wl_buffer can not be used with
+ EGL and the compositor should have another way to get the buffer
contents.
If eglQueryWaylandBufferWL succeeds, the returned value will be
- one of EGL_WAYLAND_BUFFER_RGB_WL, EGL_WAYLAND_BUFFER_RGBA_WL,
- EGL_WAYLAND_BUFFER_Y_U_V_WL, EGL_WAYLAND_BUFFER_Y_UV_WL,
- EGL_WAYLAND_BUFFER_Y_XUXV_WL. The value returned describes how
- many EGLImages must be used, which components will be sampled from
- each EGLImage and how they map to rgba components in the shader.
- The naming conventions separates planes by _ and within each
- plane, the order or R, G, B, A, Y, U, and V indicates how those
- components map to the rgba value returned by the sampler. X
- indicates that the corresponding component in the rgba value isn't
- used.
+ one of EGL_TEXTURE_RGB, EGL_TEXTURE_RGBA, EGL_TEXTURE_Y_U_V_WL,
+ EGL_TEXTURE_Y_UV_WL, EGL_TEXTURE_Y_XUXV_WL. The value returned
+ describes how many EGLImages must be used, which components will
+ be sampled from each EGLImage and how they map to rgba components
+ in the shader. The naming conventions separates planes by _ and
+ within each plane, the order or R, G, B, A, Y, U, and V indicates
+ how those components map to the rgba value returned by the
+ sampler. X indicates that the corresponding component in the rgba
+ value isn't used.
RGB and RGBA buffer types:
- EGL_WAYLAND_BUFFER_RGB_WL
+ EGL_TEXTURE_RGB
One plane, samples RGB from the texture to rgb in the
shader. Alpha channel is not valid.
- EGL_WAYLAND_BUFFER_RGBA_WL 0x31D9
+ EGL_TEXTURE_RGBA
One plane, samples RGBA from the texture to rgba in the
shader.
YUV buffer types:
- EGL_WAYLAND_BUFFER_Y_U_V_WL 0x31Da
+ EGL_TEXTURE_Y_U_V_WL
Three planes, samples Y from the first plane to r in
the shader, U from the second plane to r, and V from
the third plane to r.
- EGL_WAYLAND_BUFFER_Y_UV_WL 0x31Db
+ EGL_TEXTURE_Y_UV_WL
Two planes, samples Y from the first plane to r in
the shader, U and V from the second plane to rg.
- EGL_WAYLAND_BUFFER_Y_XUXV_WL 0x31Dc
+ EGL_TEXTURE_Y_XUXV_WL
Two planes, samples Y from the first plane to r in
the shader, U and V from the second plane to g and a.
@@ -162,6 +154,9 @@ Additions to the EGL 1.4 Specification:
from a wl_buffer in any way (such as glTexImage2D, binding the
EGLImage as a renderbuffer etc) will result in undefined behavior.
+ Further, eglQueryWaylandBufferWL accepts attributes EGL_WIDTH and
+ EGL_HEIGHT to query the width and height of the wl_buffer.
+
Issues
Revision History
@@ -174,3 +169,7 @@ Revision History
Version 3, July 10, 2012
Add eglQueryWaylandBufferWL and the various buffer
formats. (Kristian Høgsberg)
+ Version 4, July 19, 2012
+ Use EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB, and EGL_TEXTURE_RGBA,
+ and just define the new YUV texture formats. Add support for
+ EGL_WIDTH and EGL_HEIGHT in the query attributes (Kristian Høgsberg)
diff --git a/mesalib/docs/relnotes-8.1.html b/mesalib/docs/relnotes-8.1.html
index 45770d392..4c4d48715 100644
--- a/mesalib/docs/relnotes-8.1.html
+++ b/mesalib/docs/relnotes-8.1.html
@@ -53,8 +53,10 @@ Note: some of the new features are only available with certain drivers.
<h2>Changes</h2>
-<p>TBD</p>
-
+<p>
+The legacy/static Makefile system (ex: 'make linux-dri') has been removed.
+The two supported build methods are now autoconf/automake and SCons.
+</p>
</body>
diff --git a/mesalib/include/EGL/eglmesaext.h b/mesalib/include/EGL/eglmesaext.h
index 74d8ced37..d476d18a2 100644
--- a/mesalib/include/EGL/eglmesaext.h
+++ b/mesalib/include/EGL/eglmesaext.h
@@ -112,16 +112,12 @@ typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETDRMDISPLAYMESA) (int fd);
#ifndef EGL_WL_bind_wayland_display
#define EGL_WL_bind_wayland_display 1
-#define EGL_WAYLAND_BUFFER_WL 0x31D5 /* eglCreateImageKHR target */
-#define EGL_WAYLAND_PLANE_WL 0x31D6 /* eglCreateImageKHR target */
+#define EGL_WAYLAND_BUFFER_WL 0x31D5 /* eglCreateImageKHR target */
+#define EGL_WAYLAND_PLANE_WL 0x31D6 /* eglCreateImageKHR target */
-#define EGL_WAYLAND_BUFFER_COMPONENTS_WL 0x31D7 /* eglQueryWaylandBufferWL attribute */
-
-#define EGL_WAYLAND_BUFFER_RGB_WL 0x31D8
-#define EGL_WAYLAND_BUFFER_RGBA_WL 0x31D9
-#define EGL_WAYLAND_BUFFER_Y_U_V_WL 0x31Da
-#define EGL_WAYLAND_BUFFER_Y_UV_WL 0x31Db
-#define EGL_WAYLAND_BUFFER_Y_XUXV_WL 0x31Dc
+#define EGL_TEXTURE_Y_U_V_WL 0x31D7
+#define EGL_TEXTURE_Y_UV_WL 0x31D8
+#define EGL_TEXTURE_Y_XUXV_WL 0x31D9
struct wl_display;
struct wl_buffer;
diff --git a/mesalib/scons/gallium.py b/mesalib/scons/gallium.py
index 001a5def1..458651b45 100644
--- a/mesalib/scons/gallium.py
+++ b/mesalib/scons/gallium.py
@@ -140,6 +140,7 @@ def generate(env):
env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-')
env['msvc'] = env['CC'] == 'cl'
env['suncc'] = env['platform'] == 'sunos' and os.path.basename(env['CC']) == 'cc'
+ env['clang'] = env['CC'] == 'clang'
if env['msvc'] and env['toolchain'] == 'default' and env['machine'] == 'x86_64':
# MSVC x64 support is broken in earlier versions of scons
@@ -482,7 +483,7 @@ def generate(env):
env.Append(SHLINKFLAGS = shlinkflags)
# We have C++ in several libraries, so always link with the C++ compiler
- if env['gcc']:
+ if env['gcc'] or env['clang']:
env['LINK'] = env['CXX']
# Default libs
diff --git a/mesalib/src/gallium/auxiliary/util/u_debug_symbol.c b/mesalib/src/gallium/auxiliary/util/u_debug_symbol.c
index bae9be87a..3d2f8ebc3 100644
--- a/mesalib/src/gallium/auxiliary/util/u_debug_symbol.c
+++ b/mesalib/src/gallium/auxiliary/util/u_debug_symbol.c
@@ -152,7 +152,9 @@ debug_symbol_name_dbghelp(const void *addr, char* buf, unsigned size)
#endif
#ifdef __GLIBC__
+#ifndef __UCLIBC__
#include <execinfo.h>
+#endif
/* This can only provide dynamic symbols, or binary offsets into a file.
*
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_tests.c b/mesalib/src/gallium/auxiliary/util/u_format_tests.c
index 457fda6c8..d34860886 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_tests.c
+++ b/mesalib/src/gallium/auxiliary/util/u_format_tests.c
@@ -66,8 +66,13 @@
{{ 0, 0, 0, 0}, { 0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}}
+#ifdef __GNUC__
+#define NAN __builtin_nan("")
+#define INF __builtin_inf()
+#else
#define NAN (0.0 / 0.0)
#define INF (1.0 / 0.0)
+#endif
/**
* Test cases.
diff --git a/mesalib/src/glsl/ast.h b/mesalib/src/glsl/ast.h
index 6d81afc99..3c0a2b838 100644
--- a/mesalib/src/glsl/ast.h
+++ b/mesalib/src/glsl/ast.h
@@ -517,6 +517,12 @@ public:
* is used to note these cases when no type is specified.
*/
int invariant;
+
+ /**
+ * Flag indicating that these declarators are in a uniform block,
+ * allowing UBO type qualifiers.
+ */
+ bool ubo_qualifiers_valid;
};
diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp
index bbe8f0596..1c54991cf 100644
--- a/mesalib/src/glsl/ast_to_hir.cpp
+++ b/mesalib/src/glsl/ast_to_hir.cpp
@@ -1917,7 +1917,8 @@ static void
apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
ir_variable *var,
struct _mesa_glsl_parse_state *state,
- YYLTYPE *loc)
+ YYLTYPE *loc,
+ bool ubo_qualifiers_valid)
{
if (qual->flags.q.invariant) {
if (var->used) {
@@ -2010,24 +2011,10 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
if (var->interpolation != INTERP_QUALIFIER_NONE &&
!(state->target == vertex_shader && var->mode == ir_var_out) &&
!(state->target == fragment_shader && var->mode == ir_var_in)) {
- const char *qual_string = NULL;
- switch (var->interpolation) {
- case INTERP_QUALIFIER_FLAT:
- qual_string = "flat";
- break;
- case INTERP_QUALIFIER_NOPERSPECTIVE:
- qual_string = "noperspective";
- break;
- case INTERP_QUALIFIER_SMOOTH:
- qual_string = "smooth";
- break;
- }
-
_mesa_glsl_error(loc, state,
"interpolation qualifier `%s' can only be applied to "
"vertex shader outputs and fragment shader inputs.",
- qual_string);
-
+ var->interpolation_string());
}
var->pixel_center_integer = qual->flags.q.pixel_center_integer;
@@ -2191,6 +2178,23 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
var->depth_layout = ir_depth_layout_unchanged;
else
var->depth_layout = ir_depth_layout_none;
+
+ if (qual->flags.q.std140 ||
+ qual->flags.q.packed ||
+ qual->flags.q.shared) {
+ _mesa_glsl_error(loc, state,
+ "uniform block layout qualifiers std140, packed, and "
+ "shared can only be applied to uniform blocks, not "
+ "members");
+ }
+
+ if (!ubo_qualifiers_valid &&
+ (qual->flags.q.row_major || qual->flags.q.column_major)) {
+ _mesa_glsl_error(loc, state,
+ "uniform block layout qualifiers row_major and "
+ "column_major can only be applied to uniform block "
+ "members");
+ }
}
/**
@@ -2611,7 +2615,7 @@ ast_declarator_list::hir(exec_list *instructions,
}
apply_type_qualifier_to_variable(& this->type->qualifier, var, state,
- & loc);
+ & loc, this->ubo_qualifiers_valid);
if (this->type->qualifier.flags.q.invariant) {
if ((state->target == vertex_shader) && !(var->mode == ir_var_out ||
@@ -3028,7 +3032,8 @@ ast_parameter_declarator::hir(exec_list *instructions,
/* Apply any specified qualifiers to the parameter declaration. Note that
* for function parameters the default mode is 'in'.
*/
- apply_type_qualifier_to_variable(& this->type->qualifier, var, state, & loc);
+ apply_type_qualifier_to_variable(& this->type->qualifier, var, state, & loc,
+ false);
/* From page 17 (page 23 of the PDF) of the GLSL 1.20 spec:
*
@@ -3989,6 +3994,25 @@ ast_struct_specifier::hir(exec_list *instructions,
return NULL;
}
+static struct gl_uniform_block *
+get_next_uniform_block(struct _mesa_glsl_parse_state *state)
+{
+ if (state->num_uniform_blocks >= state->uniform_block_array_size) {
+ state->uniform_block_array_size *= 2;
+ if (state->uniform_block_array_size <= 4)
+ state->uniform_block_array_size = 4;
+
+ state->uniform_blocks = reralloc(state,
+ state->uniform_blocks,
+ struct gl_uniform_block,
+ state->uniform_block_array_size);
+ }
+
+ memset(&state->uniform_blocks[state->num_uniform_blocks],
+ 0, sizeof(*state->uniform_blocks));
+ return &state->uniform_blocks[state->num_uniform_blocks++];
+}
+
ir_rvalue *
ast_uniform_block::hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state)
@@ -3997,6 +4021,62 @@ ast_uniform_block::hir(exec_list *instructions,
* need to turn those into ir_variables with an association
* with this uniform block.
*/
+ struct gl_uniform_block *ubo = get_next_uniform_block(state);
+ ubo->Name = ralloc_strdup(state->uniform_blocks, this->block_name);
+
+ unsigned int num_variables = 0;
+ foreach_list_typed(ast_declarator_list, decl_list, link, &declarations) {
+ foreach_list_const(node, &decl_list->declarations) {
+ num_variables++;
+ }
+ }
+
+ bool block_row_major = this->layout.flags.q.row_major;
+
+ ubo->Uniforms = rzalloc_array(state->uniform_blocks,
+ struct gl_uniform_buffer_variable,
+ num_variables);
+
+ foreach_list_typed(ast_declarator_list, decl_list, link, &declarations) {
+ exec_list declared_variables;
+
+ decl_list->hir(&declared_variables, state);
+
+ foreach_list_const(node, &declared_variables) {
+ struct ir_variable *var = (ir_variable *)node;
+
+ struct gl_uniform_buffer_variable *ubo_var =
+ &ubo->Uniforms[ubo->NumUniforms++];
+
+ var->uniform_block = ubo - state->uniform_blocks;
+
+ ubo_var->Name = ralloc_strdup(state->uniform_blocks, var->name);
+ ubo_var->Type = var->type;
+ ubo_var->Buffer = ubo - state->uniform_blocks;
+ ubo_var->Offset = 0; /* Assigned at link time. */
+ ubo_var->RowMajor = block_row_major;
+ if (decl_list->type->qualifier.flags.q.row_major)
+ ubo_var->RowMajor = true;
+ else if (decl_list->type->qualifier.flags.q.column_major)
+ ubo_var->RowMajor = false;
+
+ /* From the GL_ARB_uniform_buffer_object spec:
+ *
+ * "Sampler types are not allowed inside of uniform
+ * blocks. All other types, arrays, and structures
+ * allowed for uniforms are allowed within a uniform
+ * block."
+ */
+ if (var->type->contains_sampler()) {
+ YYLTYPE loc = decl_list->get_location();
+ _mesa_glsl_error(&loc, state,
+ "Uniform in non-default uniform block contains sampler\n");
+ }
+ }
+
+ instructions->append_list(&declared_variables);
+ }
+
return NULL;
}
diff --git a/mesalib/src/glsl/builtin_types.h b/mesalib/src/glsl/builtin_types.h
index 8c136e4ab..d75c56261 100644
--- a/mesalib/src/glsl/builtin_types.h
+++ b/mesalib/src/glsl/builtin_types.h
@@ -63,7 +63,12 @@ const glsl_type glsl_type::builtin_core_types[] = {
};
const glsl_type *const glsl_type::bool_type = & builtin_core_types[0];
+const glsl_type *const glsl_type::bvec2_type = & builtin_core_types[1];
+const glsl_type *const glsl_type::bvec3_type = & builtin_core_types[2];
+const glsl_type *const glsl_type::bvec4_type = & builtin_core_types[3];
const glsl_type *const glsl_type::int_type = & builtin_core_types[4];
+const glsl_type *const glsl_type::ivec2_type = & builtin_core_types[5];
+const glsl_type *const glsl_type::ivec3_type = & builtin_core_types[6];
const glsl_type *const glsl_type::ivec4_type = & builtin_core_types[7];
const glsl_type *const glsl_type::float_type = & builtin_core_types[8];
const glsl_type *const glsl_type::vec2_type = & builtin_core_types[9];
diff --git a/mesalib/src/glsl/glcpp/glcpp-parse.y b/mesalib/src/glsl/glcpp/glcpp-parse.y
index c0c1ca197..bf6f3ad01 100644
--- a/mesalib/src/glsl/glcpp/glcpp-parse.y
+++ b/mesalib/src/glsl/glcpp/glcpp-parse.y
@@ -213,7 +213,7 @@ expanded_line:
parser->new_line_number = $2;
ralloc_asprintf_rewrite_tail (&parser->output,
&parser->output_length,
- "#line %" PRIiMAX,
+ "#line %" PRIiMAX "\n",
$2);
}
| LINE_EXPANDED integer_constant integer_constant NEWLINE {
@@ -223,7 +223,7 @@ expanded_line:
parser->new_source_number = $3;
ralloc_asprintf_rewrite_tail (&parser->output,
&parser->output_length,
- "#line %" PRIiMAX " %" PRIiMAX,
+ "#line %" PRIiMAX " %" PRIiMAX "\n",
$2, $3);
}
;
diff --git a/mesalib/src/glsl/glsl_parser.yy b/mesalib/src/glsl/glsl_parser.yy
index 337337591..f61d6b8dd 100644
--- a/mesalib/src/glsl/glsl_parser.yy
+++ b/mesalib/src/glsl/glsl_parser.yy
@@ -301,7 +301,7 @@ pragma_statement:
| PRAGMA_OPTIMIZE_OFF EOL
| PRAGMA_INVARIANT_ALL EOL
{
- if (state->language_version < 120) {
+ if (state->language_version < 120 && !state->Const.GLSL_100ES) {
_mesa_glsl_warning(& @1, state,
"pragma `invariant(all)' not supported in %s",
state->version_string);
@@ -1967,6 +1967,7 @@ member_declaration:
type->specifier = $3;
$$ = new(ctx) ast_declarator_list(type);
$$->set_location(yylloc);
+ $$->ubo_qualifiers_valid = true;
$$->declarations.push_degenerate_list_at_head(& $4->link);
}
@@ -1980,6 +1981,7 @@ member_declaration:
type->specifier = $2;
$$ = new(ctx) ast_declarator_list(type);
$$->set_location(yylloc);
+ $$->ubo_qualifiers_valid = true;
$$->declarations.push_degenerate_list_at_head(& $3->link);
}
diff --git a/mesalib/src/glsl/glsl_parser_extras.cpp b/mesalib/src/glsl/glsl_parser_extras.cpp
index d9ee406cf..7a9b22197 100644
--- a/mesalib/src/glsl/glsl_parser_extras.cpp
+++ b/mesalib/src/glsl/glsl_parser_extras.cpp
@@ -27,6 +27,7 @@
extern "C" {
#include "main/core.h" /* for struct gl_context */
+#include "main/context.h"
}
#include "ralloc.h"
@@ -90,19 +91,17 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
*/
this->Const.GLSL_100ES = (ctx->API == API_OPENGLES2)
|| ctx->Extensions.ARB_ES2_compatibility;
- this->Const.GLSL_110 = (ctx->API == API_OPENGL);
- this->Const.GLSL_120 = (ctx->API == API_OPENGL)
- && (ctx->Const.GLSLVersion >= 120);
- this->Const.GLSL_130 = (ctx->API == API_OPENGL)
- && (ctx->Const.GLSLVersion >= 130);
- this->Const.GLSL_140 = (ctx->API == API_OPENGL)
- && (ctx->Const.GLSLVersion >= 140);
+ bool is_desktop_gl = _mesa_is_desktop_gl(ctx);
+ this->Const.GLSL_110 = is_desktop_gl;
+ this->Const.GLSL_120 = is_desktop_gl && (ctx->Const.GLSLVersion >= 120);
+ this->Const.GLSL_130 = is_desktop_gl && (ctx->Const.GLSLVersion >= 130);
+ this->Const.GLSL_140 = is_desktop_gl && (ctx->Const.GLSLVersion >= 140);
const unsigned lowest_version =
(ctx->API == API_OPENGLES2) || ctx->Extensions.ARB_ES2_compatibility
? 100 : 110;
const unsigned highest_version =
- (ctx->API == API_OPENGL) ? ctx->Const.GLSLVersion : 100;
+ is_desktop_gl ? ctx->Const.GLSLVersion : 100;
char *supported = ralloc_strdup(this, "");
for (unsigned ver = lowest_version; ver <= highest_version; ver += 10) {
@@ -773,6 +772,7 @@ ast_declarator_list::ast_declarator_list(ast_fully_specified_type *type)
{
this->type = type;
this->invariant = false;
+ this->ubo_qualifiers_valid = false;
}
void
diff --git a/mesalib/src/glsl/glsl_parser_extras.h b/mesalib/src/glsl/glsl_parser_extras.h
index 2564e5856..cf6dfbe3b 100644
--- a/mesalib/src/glsl/glsl_parser_extras.h
+++ b/mesalib/src/glsl/glsl_parser_extras.h
@@ -86,6 +86,10 @@ struct _mesa_glsl_parse_state {
exec_list translation_unit;
glsl_symbol_table *symbols;
+ unsigned num_uniform_blocks;
+ unsigned uniform_block_array_size;
+ struct gl_uniform_block *uniform_blocks;
+
bool es_shader;
unsigned language_version;
const char *version_string;
diff --git a/mesalib/src/glsl/glsl_types.cpp b/mesalib/src/glsl/glsl_types.cpp
index 8a34b8eb0..3d7866058 100644
--- a/mesalib/src/glsl/glsl_types.cpp
+++ b/mesalib/src/glsl/glsl_types.cpp
@@ -628,3 +628,223 @@ glsl_type::can_implicitly_convert_to(const glsl_type *desired) const
&& this->is_integer()
&& this->vector_elements == desired->vector_elements;
}
+
+unsigned
+glsl_type::std140_base_alignment(bool row_major) const
+{
+ /* (1) If the member is a scalar consuming <N> basic machine units, the
+ * base alignment is <N>.
+ *
+ * (2) If the member is a two- or four-component vector with components
+ * consuming <N> basic machine units, the base alignment is 2<N> or
+ * 4<N>, respectively.
+ *
+ * (3) If the member is a three-component vector with components consuming
+ * <N> basic machine units, the base alignment is 4<N>.
+ */
+ if (this->is_scalar() || this->is_vector()) {
+ switch (this->vector_elements) {
+ case 1:
+ return 4;
+ case 2:
+ return 8;
+ case 3:
+ case 4:
+ return 16;
+ }
+ }
+
+ /* (4) If the member is an array of scalars or vectors, the base alignment
+ * and array stride are set to match the base alignment of a single
+ * array element, according to rules (1), (2), and (3), and rounded up
+ * to the base alignment of a vec4. The array may have padding at the
+ * end; the base offset of the member following the array is rounded up
+ * to the next multiple of the base alignment.
+ *
+ * (6) If the member is an array of <S> column-major matrices with <C>
+ * columns and <R> rows, the matrix is stored identically to a row of
+ * <S>*<C> column vectors with <R> components each, according to rule
+ * (4).
+ *
+ * (8) If the member is an array of <S> row-major matrices with <C> columns
+ * and <R> rows, the matrix is stored identically to a row of <S>*<R>
+ * row vectors with <C> components each, according to rule (4).
+ *
+ * (10) If the member is an array of <S> structures, the <S> elements of
+ * the array are laid out in order, according to rule (9).
+ */
+ if (this->is_array()) {
+ if (this->fields.array->is_scalar() ||
+ this->fields.array->is_vector() ||
+ this->fields.array->is_matrix()) {
+ return MAX2(this->fields.array->std140_base_alignment(row_major), 16);
+ } else {
+ assert(this->fields.array->is_record());
+ return this->fields.array->std140_base_alignment(row_major);
+ }
+ }
+
+ /* (5) If the member is a column-major matrix with <C> columns and
+ * <R> rows, the matrix is stored identically to an array of
+ * <C> column vectors with <R> components each, according to
+ * rule (4).
+ *
+ * (7) If the member is a row-major matrix with <C> columns and <R>
+ * rows, the matrix is stored identically to an array of <R>
+ * row vectors with <C> components each, according to rule (4).
+ */
+ if (this->is_matrix()) {
+ const struct glsl_type *vec_type;
+ if (row_major) {
+ vec_type = get_instance(GLSL_TYPE_FLOAT, this->vector_elements, 1);
+ } else {
+ vec_type = get_instance(GLSL_TYPE_FLOAT, this->matrix_columns, 1);
+ }
+
+ return vec_type->std140_base_alignment(false);
+ }
+
+ /* (9) If the member is a structure, the base alignment of the
+ * structure is <N>, where <N> is the largest base alignment
+ * value of any of its members, and rounded up to the base
+ * alignment of a vec4. The individual members of this
+ * sub-structure are then assigned offsets by applying this set
+ * of rules recursively, where the base offset of the first
+ * member of the sub-structure is equal to the aligned offset
+ * of the structure. The structure may have padding at the end;
+ * the base offset of the member following the sub-structure is
+ * rounded up to the next multiple of the base alignment of the
+ * structure.
+ */
+ if (this->is_record()) {
+ unsigned base_alignment = 16;
+ for (unsigned i = 0; i < this->length; i++) {
+ const struct glsl_type *field_type = this->fields.structure[i].type;
+ base_alignment = MAX2(base_alignment,
+ field_type->std140_base_alignment(row_major));
+ }
+ return base_alignment;
+ }
+
+ assert(!"not reached");
+ return -1;
+}
+
+static unsigned
+align(unsigned val, unsigned align)
+{
+ return (val + align - 1) / align * align;
+}
+
+unsigned
+glsl_type::std140_size(bool row_major) const
+{
+ /* (1) If the member is a scalar consuming <N> basic machine units, the
+ * base alignment is <N>.
+ *
+ * (2) If the member is a two- or four-component vector with components
+ * consuming <N> basic machine units, the base alignment is 2<N> or
+ * 4<N>, respectively.
+ *
+ * (3) If the member is a three-component vector with components consuming
+ * <N> basic machine units, the base alignment is 4<N>.
+ */
+ if (this->is_scalar() || this->is_vector()) {
+ return this->vector_elements * 4;
+ }
+
+ /* (5) If the member is a column-major matrix with <C> columns and
+ * <R> rows, the matrix is stored identically to an array of
+ * <C> column vectors with <R> components each, according to
+ * rule (4).
+ *
+ * (6) If the member is an array of <S> column-major matrices with <C>
+ * columns and <R> rows, the matrix is stored identically to a row of
+ * <S>*<C> column vectors with <R> components each, according to rule
+ * (4).
+ *
+ * (7) If the member is a row-major matrix with <C> columns and <R>
+ * rows, the matrix is stored identically to an array of <R>
+ * row vectors with <C> components each, according to rule (4).
+ *
+ * (8) If the member is an array of <S> row-major matrices with <C> columns
+ * and <R> rows, the matrix is stored identically to a row of <S>*<R>
+ * row vectors with <C> components each, according to rule (4).
+ */
+ if (this->is_matrix() || (this->is_array() &&
+ this->fields.array->is_matrix())) {
+ const struct glsl_type *element_type;
+ const struct glsl_type *vec_type;
+ unsigned int array_len;
+
+ if (this->is_array()) {
+ element_type = this->fields.array;
+ array_len = this->length;
+ } else {
+ element_type = this;
+ array_len = 1;
+ }
+
+ if (row_major) {
+ vec_type = get_instance(GLSL_TYPE_FLOAT,
+ element_type->matrix_columns, 1);
+ array_len *= element_type->vector_elements;
+ } else {
+ vec_type = get_instance(GLSL_TYPE_FLOAT,
+ element_type->vector_elements, 1);
+ array_len *= element_type->matrix_columns;
+ }
+ const glsl_type *array_type = glsl_type::get_array_instance(vec_type,
+ array_len);
+
+ return array_type->std140_size(false);
+ }
+
+ /* (4) If the member is an array of scalars or vectors, the base alignment
+ * and array stride are set to match the base alignment of a single
+ * array element, according to rules (1), (2), and (3), and rounded up
+ * to the base alignment of a vec4. The array may have padding at the
+ * end; the base offset of the member following the array is rounded up
+ * to the next multiple of the base alignment.
+ *
+ * (10) If the member is an array of <S> structures, the <S> elements of
+ * the array are laid out in order, according to rule (9).
+ */
+ if (this->is_array()) {
+ if (this->fields.array->is_record()) {
+ return this->length * this->fields.array->std140_size(row_major);
+ } else {
+ unsigned element_base_align =
+ this->fields.array->std140_base_alignment(row_major);
+ return this->length * MAX2(element_base_align, 16);
+ }
+ }
+
+ /* (9) If the member is a structure, the base alignment of the
+ * structure is <N>, where <N> is the largest base alignment
+ * value of any of its members, and rounded up to the base
+ * alignment of a vec4. The individual members of this
+ * sub-structure are then assigned offsets by applying this set
+ * of rules recursively, where the base offset of the first
+ * member of the sub-structure is equal to the aligned offset
+ * of the structure. The structure may have padding at the end;
+ * the base offset of the member following the sub-structure is
+ * rounded up to the next multiple of the base alignment of the
+ * structure.
+ */
+ if (this->is_record()) {
+ unsigned size = 0;
+ for (unsigned i = 0; i < this->length; i++) {
+ const struct glsl_type *field_type = this->fields.structure[i].type;
+ unsigned align = field_type->std140_base_alignment(row_major);
+ size = (size + align - 1) / align * align;
+ size += field_type->std140_size(row_major);
+ }
+ size = align(size,
+ this->fields.structure[0].type->std140_base_alignment(row_major));
+ return size;
+ }
+
+ assert(!"not reached");
+ return -1;
+}
diff --git a/mesalib/src/glsl/glsl_types.h b/mesalib/src/glsl/glsl_types.h
index 48d41d7f8..915d1a22b 100644
--- a/mesalib/src/glsl/glsl_types.h
+++ b/mesalib/src/glsl/glsl_types.h
@@ -152,6 +152,8 @@ struct glsl_type {
static const glsl_type *const error_type;
static const glsl_type *const void_type;
static const glsl_type *const int_type;
+ static const glsl_type *const ivec2_type;
+ static const glsl_type *const ivec3_type;
static const glsl_type *const ivec4_type;
static const glsl_type *const uint_type;
static const glsl_type *const uvec2_type;
@@ -162,6 +164,9 @@ struct glsl_type {
static const glsl_type *const vec3_type;
static const glsl_type *const vec4_type;
static const glsl_type *const bool_type;
+ static const glsl_type *const bvec2_type;
+ static const glsl_type *const bvec3_type;
+ static const glsl_type *const bvec4_type;
static const glsl_type *const mat2_type;
static const glsl_type *const mat2x3_type;
static const glsl_type *const mat2x4_type;
@@ -243,6 +248,19 @@ struct glsl_type {
unsigned component_slots() const;
/**
+ * Alignment in bytes of the start of this type in a std140 uniform
+ * block.
+ */
+ unsigned std140_base_alignment(bool row_major) const;
+
+ /** Size in bytes of this type in a std140 uniform block.
+ *
+ * Note that this is not GL_UNIFORM_SIZE (which is the number of
+ * elements in the array)
+ */
+ unsigned std140_size(bool row_major) const;
+
+ /**
* \brief Can this type be implicitly converted to another?
*
* \return True if the types are identical or if this type can be converted
diff --git a/mesalib/src/glsl/ir.cpp b/mesalib/src/glsl/ir.cpp
index 1c9eec6e2..b0e38d820 100644
--- a/mesalib/src/glsl/ir.cpp
+++ b/mesalib/src/glsl/ir.cpp
@@ -1491,6 +1491,7 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name,
this->explicit_location = false;
this->has_initializer = false;
this->location = -1;
+ this->uniform_block = -1;
this->warn_extension = NULL;
this->constant_value = NULL;
this->constant_initializer = NULL;
diff --git a/mesalib/src/glsl/ir.h b/mesalib/src/glsl/ir.h
index 9bbf3b7ef..f019837d5 100644
--- a/mesalib/src/glsl/ir.h
+++ b/mesalib/src/glsl/ir.h
@@ -453,7 +453,8 @@ public:
* - Vertex shader output: one of the values from \c gl_vert_result.
* - Fragment shader input: one of the values from \c gl_frag_attrib.
* - Fragment shader output: one of the values from \c gl_frag_result.
- * - Uniforms: Per-stage uniform slot number.
+ * - Uniforms: Per-stage uniform slot number for default uniform block.
+ * - Uniforms: Index within the uniform block definition for UBO members.
* - Other: This field is not currently used.
*
* If the variable is a uniform, shader input, or shader output, and the
@@ -462,6 +463,16 @@ public:
int location;
/**
+ * Uniform block number for uniforms.
+ *
+ * This index is into the shader's list of uniform blocks, not the
+ * linked program's merged list.
+ *
+ * If the variable is not in a uniform block, the value will be -1.
+ */
+ int uniform_block;
+
+ /**
* output index for dual source blending.
*/
int index;
@@ -1016,7 +1027,7 @@ enum ir_expression_operation {
/**
* A sentinel marking the last of all operations.
*/
- ir_last_opcode = ir_last_binop
+ ir_last_opcode = ir_quadop_vector
};
class ir_expression : public ir_rvalue {
diff --git a/mesalib/src/glsl/ir_clone.cpp b/mesalib/src/glsl/ir_clone.cpp
index 591fe7b77..4314efa76 100644
--- a/mesalib/src/glsl/ir_clone.cpp
+++ b/mesalib/src/glsl/ir_clone.cpp
@@ -54,6 +54,7 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) const
var->interpolation = this->interpolation;
var->location = this->location;
var->index = this->index;
+ var->uniform_block = this->uniform_block;
var->warn_extension = this->warn_extension;
var->origin_upper_left = this->origin_upper_left;
var->pixel_center_integer = this->pixel_center_integer;
diff --git a/mesalib/src/glsl/ir_set_program_inouts.cpp b/mesalib/src/glsl/ir_set_program_inouts.cpp
index a7415c7e3..e5de07e01 100644
--- a/mesalib/src/glsl/ir_set_program_inouts.cpp
+++ b/mesalib/src/glsl/ir_set_program_inouts.cpp
@@ -26,8 +26,8 @@
*
* Sets the InputsRead and OutputsWritten of Mesa programs.
*
- * Additionally, for fragment shaders, sets the InterpQualifier array and
- * IsCentroid bitfield.
+ * Additionally, for fragment shaders, sets the InterpQualifier array, the
+ * IsCentroid bitfield, and the UsesDFdy flag.
*
* Mesa programs (gl_program, not gl_shader_program) have a set of
* flags indicating which varyings are read and written. Computing
@@ -61,6 +61,8 @@ public:
virtual ir_visitor_status visit_enter(ir_dereference_array *);
virtual ir_visitor_status visit_enter(ir_function_signature *);
+ virtual ir_visitor_status visit_enter(ir_expression *);
+ virtual ir_visitor_status visit_enter(ir_discard *);
virtual ir_visitor_status visit(ir_dereference_variable *);
virtual ir_visitor_status visit(ir_variable *);
@@ -169,6 +171,28 @@ ir_set_program_inouts_visitor::visit_enter(ir_function_signature *ir)
return visit_continue_with_parent;
}
+ir_visitor_status
+ir_set_program_inouts_visitor::visit_enter(ir_expression *ir)
+{
+ if (is_fragment_shader && ir->operation == ir_unop_dFdy) {
+ gl_fragment_program *fprog = (gl_fragment_program *) prog;
+ fprog->UsesDFdy = true;
+ }
+ return visit_continue;
+}
+
+ir_visitor_status
+ir_set_program_inouts_visitor::visit_enter(ir_discard *)
+{
+ /* discards are only allowed in fragment shaders. */
+ assert(is_fragment_shader);
+
+ gl_fragment_program *fprog = (gl_fragment_program *) prog;
+ fprog->UsesKill = true;
+
+ return visit_continue;
+}
+
void
do_set_program_inouts(exec_list *instructions, struct gl_program *prog,
bool is_fragment_shader)
@@ -179,9 +203,11 @@ do_set_program_inouts(exec_list *instructions, struct gl_program *prog,
prog->OutputsWritten = 0;
prog->SystemValuesRead = 0;
if (is_fragment_shader) {
- memset(((gl_fragment_program *) prog)->InterpQualifier, 0,
- sizeof(((gl_fragment_program *) prog)->InterpQualifier));
- ((gl_fragment_program *) prog)->IsCentroid = 0;
+ gl_fragment_program *fprog = (gl_fragment_program *) prog;
+ memset(fprog->InterpQualifier, 0, sizeof(fprog->InterpQualifier));
+ fprog->IsCentroid = 0;
+ fprog->UsesDFdy = false;
+ fprog->UsesKill = false;
}
visit_list_elements(&v, instructions);
}
diff --git a/mesalib/src/glsl/ir_uniform.h b/mesalib/src/glsl/ir_uniform.h
index 225da3fc5..913c53773 100644
--- a/mesalib/src/glsl/ir_uniform.h
+++ b/mesalib/src/glsl/ir_uniform.h
@@ -119,6 +119,40 @@ struct gl_uniform_storage {
* uniform if the \c ::driver_storage interface is not used.
*/
union gl_constant_value *storage;
+
+ /** Fields for GL_ARB_uniform_buffer_object
+ * @{
+ */
+
+ /**
+ * GL_UNIFORM_BLOCK_INDEX: index of the uniform block containing
+ * the uniform, or -1 for the default uniform block. Note that the
+ * index is into the linked program's UniformBlocks[] array, not
+ * the linked shader's.
+ */
+ int block_index;
+
+ /** GL_UNIFORM_OFFSET: byte offset within the uniform block, or -1. */
+ int offset;
+
+ /**
+ * GL_UNIFORM_MATRIX_STRIDE: byte stride between columns or rows of
+ * a matrix. Set to 0 for non-matrices in UBOs, or -1 for uniforms
+ * in the default uniform block.
+ */
+ int matrix_stride;
+
+ /**
+ * GL_UNIFORM_ARRAY_STRIDE: byte stride between elements of the
+ * array. Set to zero for non-arrays in UBOs, or -1 for uniforms
+ * in the default uniform block.
+ */
+ int array_stride;
+
+ /** GL_UNIFORM_ROW_MAJOR: true iff it's a row-major matrix in a UBO */
+ bool row_major;
+
+ /** @} */
};
#ifdef __cplusplus
diff --git a/mesalib/src/glsl/link_uniforms.cpp b/mesalib/src/glsl/link_uniforms.cpp
index 3cbc50510..307f5de09 100644
--- a/mesalib/src/glsl/link_uniforms.cpp
+++ b/mesalib/src/glsl/link_uniforms.cpp
@@ -27,6 +27,13 @@
#include "ir_uniform.h"
#include "glsl_symbol_table.h"
#include "program/hash_table.h"
+#include "program.h"
+
+static inline unsigned int
+align(unsigned int a, unsigned int align)
+{
+ return (a + align - 1) / align * align;
+}
/**
* \file link_uniforms.cpp
@@ -216,6 +223,28 @@ public:
this->shader_shadow_samplers = 0;
}
+ void set_and_process(struct gl_shader_program *prog,
+ ir_variable *var)
+ {
+ ubo_var = NULL;
+ if (var->uniform_block != -1) {
+ struct gl_uniform_block *block =
+ &prog->UniformBlocks[var->uniform_block];
+
+ ubo_block_index = var->uniform_block;
+ ubo_var_index = var->location;
+ ubo_var = &block->Uniforms[var->location];
+ ubo_byte_offset = ubo_var->Offset;
+ }
+
+ process(var);
+ }
+
+ struct gl_uniform_buffer_variable *ubo_var;
+ int ubo_block_index;
+ int ubo_var_index;
+ int ubo_byte_offset;
+
private:
virtual void visit_field(const glsl_type *type, const char *name)
{
@@ -291,6 +320,25 @@ private:
this->uniforms[id].num_driver_storage = 0;
this->uniforms[id].driver_storage = NULL;
this->uniforms[id].storage = this->values;
+ if (this->ubo_var) {
+ this->uniforms[id].block_index = this->ubo_block_index;
+
+ unsigned alignment = type->std140_base_alignment(ubo_var->RowMajor);
+ this->ubo_byte_offset = align(this->ubo_byte_offset, alignment);
+ this->uniforms[id].offset = this->ubo_byte_offset;
+ this->ubo_byte_offset += type->std140_size(ubo_var->RowMajor);
+
+ this->uniforms[id].array_stride = 0;
+ this->uniforms[id].matrix_stride = 0;
+ this->uniforms[id].row_major = base_type->is_matrix() &&
+ ubo_var->RowMajor;
+ } else {
+ this->uniforms[id].block_index = -1;
+ this->uniforms[id].offset = -1;
+ this->uniforms[id].array_stride = -1;
+ this->uniforms[id].matrix_stride = -1;
+ this->uniforms[id].row_major = false;
+ }
this->values += values_for_type(type);
}
@@ -316,6 +364,125 @@ public:
unsigned shader_shadow_samplers;
};
+/**
+ * Merges a uniform block into an array of uniform blocks that may or
+ * may not already contain a copy of it.
+ *
+ * Returns the index of the new block in the array.
+ */
+int
+link_cross_validate_uniform_block(void *mem_ctx,
+ struct gl_uniform_block **linked_blocks,
+ unsigned int *num_linked_blocks,
+ struct gl_uniform_block *new_block)
+{
+ for (unsigned int i = 0; i < *num_linked_blocks; i++) {
+ struct gl_uniform_block *old_block = &(*linked_blocks)[i];
+ if (strcmp(old_block->Name, new_block->Name) == 0) {
+ if (old_block->NumUniforms != new_block->NumUniforms) {
+ return -1;
+ }
+
+ for (unsigned j = 0; j < old_block->NumUniforms; j++) {
+ if (strcmp(old_block->Uniforms[j].Name,
+ new_block->Uniforms[j].Name) != 0)
+ return -1;
+
+ if (old_block->Uniforms[j].Offset !=
+ new_block->Uniforms[j].Offset)
+ return -1;
+
+ if (old_block->Uniforms[j].RowMajor !=
+ new_block->Uniforms[j].RowMajor)
+ return -1;
+ }
+ return i;
+ }
+ }
+
+ *linked_blocks = reralloc(mem_ctx, *linked_blocks,
+ struct gl_uniform_block,
+ *num_linked_blocks + 1);
+ int linked_block_index = (*num_linked_blocks)++;
+ struct gl_uniform_block *linked_block = &(*linked_blocks)[linked_block_index];
+
+ memcpy(linked_block, new_block, sizeof(*new_block));
+ linked_block->Uniforms = ralloc_array(*linked_blocks,
+ struct gl_uniform_buffer_variable,
+ linked_block->NumUniforms);
+
+ memcpy(linked_block->Uniforms,
+ new_block->Uniforms,
+ sizeof(*linked_block->Uniforms) * linked_block->NumUniforms);
+
+ for (unsigned int i = 0; i < linked_block->NumUniforms; i++) {
+ struct gl_uniform_buffer_variable *ubo_var =
+ &linked_block->Uniforms[i];
+
+ ubo_var->Name = ralloc_strdup(*linked_blocks, ubo_var->Name);
+ }
+
+ return linked_block_index;
+}
+
+/**
+ * Walks the IR and update the references to uniform blocks in the
+ * ir_variables to point at linked shader's list (previously, they
+ * would point at the uniform block list in one of the pre-linked
+ * shaders).
+ */
+static bool
+link_update_uniform_buffer_variables(struct gl_shader *shader)
+{
+ foreach_list(node, shader->ir) {
+ ir_variable *const var = ((ir_instruction *) node)->as_variable();
+
+ if ((var == NULL) || (var->uniform_block == -1))
+ continue;
+
+ assert(var->mode == ir_var_uniform);
+
+ bool found = false;
+ for (unsigned i = 0; i < shader->NumUniformBlocks; i++) {
+ for (unsigned j = 0; j < shader->UniformBlocks[i].NumUniforms; j++) {
+ if (!strcmp(var->name, shader->UniformBlocks[i].Uniforms[j].Name)) {
+ found = true;
+ var->uniform_block = i;
+ var->location = j;
+ break;
+ }
+ }
+ if (found)
+ break;
+ }
+ assert(found);
+ }
+
+ return true;
+}
+
+void
+link_assign_uniform_block_offsets(struct gl_shader *shader)
+{
+ for (unsigned b = 0; b < shader->NumUniformBlocks; b++) {
+ struct gl_uniform_block *block = &shader->UniformBlocks[b];
+
+ unsigned offset = 0;
+ for (unsigned int i = 0; i < block->NumUniforms; i++) {
+ struct gl_uniform_buffer_variable *ubo_var = &block->Uniforms[i];
+ const struct glsl_type *type = ubo_var->Type;
+
+ unsigned alignment = type->std140_base_alignment(ubo_var->RowMajor);
+ unsigned size = type->std140_size(ubo_var->RowMajor);
+
+ offset = align(offset, alignment);
+ ubo_var->Offset = offset;
+ offset += size;
+ }
+ block->UniformBufferSize = offset;
+ }
+}
+
void
link_assign_uniform_locations(struct gl_shader_program *prog)
{
@@ -340,6 +507,14 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
*/
memset(prog->SamplerUnits, 0, sizeof(prog->SamplerUnits));
+ for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
+ if (prog->_LinkedShaders[i] == NULL)
+ continue;
+
+ if (!link_update_uniform_buffer_variables(prog->_LinkedShaders[i]))
+ return;
+ }
+
/* First pass: Count the uniform resources used by the user-defined
* uniforms. While this happens, each active uniform will have an index
* assigned to it.
@@ -412,7 +587,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
if (strncmp("gl_", var->name, 3) == 0)
continue;
- parcel.process(var);
+ parcel.set_and_process(prog, var);
}
prog->_LinkedShaders[i]->active_samplers = parcel.shader_samplers_used;
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index f06298cf6..bfdde4023 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -581,6 +581,48 @@ cross_validate_uniforms(struct gl_shader_program *prog)
MESA_SHADER_TYPES, true);
}
+/**
+ * Accumulates the array of prog->UniformBlocks and checks that all
+ * definitons of blocks agree on their contents.
+ */
+static bool
+interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog)
+{
+ unsigned max_num_uniform_blocks = 0;
+ for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
+ if (prog->_LinkedShaders[i])
+ max_num_uniform_blocks += prog->_LinkedShaders[i]->NumUniformBlocks;
+ }
+
+ for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
+ struct gl_shader *sh = prog->_LinkedShaders[i];
+
+ prog->UniformBlockStageIndex[i] = ralloc_array(prog, int,
+ max_num_uniform_blocks);
+ for (unsigned int j = 0; j < max_num_uniform_blocks; j++)
+ prog->UniformBlockStageIndex[i][j] = -1;
+
+ if (sh == NULL)
+ continue;
+
+ for (unsigned int j = 0; j < sh->NumUniformBlocks; j++) {
+ int index = link_cross_validate_uniform_block(prog,
+ &prog->UniformBlocks,
+ &prog->NumUniformBlocks,
+ &sh->UniformBlocks[j]);
+
+ if (index == -1) {
+ linker_error(prog, "uniform block `%s' has mismatching definitions",
+ sh->UniformBlocks[j].Name);
+ return false;
+ }
+
+ prog->UniformBlockStageIndex[i][index] = j;
+ }
+ }
+
+ return true;
+}
/**
* Validate that outputs from one stage match inputs of another
@@ -910,7 +952,6 @@ public:
}
};
-
/**
* Combine a group of shaders for a single stage to generate a linked shader
*
@@ -925,11 +966,33 @@ link_intrastage_shaders(void *mem_ctx,
struct gl_shader **shader_list,
unsigned num_shaders)
{
+ struct gl_uniform_block *uniform_blocks = NULL;
+ unsigned num_uniform_blocks = 0;
+
/* Check that global variables defined in multiple shaders are consistent.
*/
if (!cross_validate_globals(prog, shader_list, num_shaders, false))
return NULL;
+ /* Check that uniform blocks between shaders for a stage agree. */
+ for (unsigned i = 0; i < num_shaders; i++) {
+ struct gl_shader *sh = shader_list[i];
+
+ for (unsigned j = 0; j < shader_list[i]->NumUniformBlocks; j++) {
+ link_assign_uniform_block_offsets(shader_list[i]);
+
+ int index = link_cross_validate_uniform_block(mem_ctx,
+ &uniform_blocks,
+ &num_uniform_blocks,
+ &sh->UniformBlocks[j]);
+ if (index == -1) {
+ linker_error(prog, "uniform block `%s' has mismatching definitions",
+ sh->UniformBlocks[j].Name);
+ return NULL;
+ }
+ }
+ }
+
/* Check that there is only a single definition of each function signature
* across all shaders.
*/
@@ -997,6 +1060,10 @@ link_intrastage_shaders(void *mem_ctx,
linked->ir = new(linked) exec_list;
clone_ir_list(mem_ctx, linked->ir, main->ir);
+ linked->UniformBlocks = uniform_blocks;
+ linked->NumUniformBlocks = num_uniform_blocks;
+ ralloc_steal(linked, linked->UniformBlocks);
+
populate_symbol_table(linked);
/* The a pointer to the main function in the final linked shader (i.e., the
@@ -1100,6 +1167,13 @@ update_array_sizes(struct gl_shader_program *prog)
!var->type->is_array())
continue;
+ /* GL_ARB_uniform_buffer_object says that std140 uniforms
+ * will not be eliminated. Since we always do std140, just
+ * don't resize arrays in UBOs.
+ */
+ if (var->uniform_block != -1)
+ continue;
+
unsigned int size = var->max_array_access;
for (unsigned j = 0; j < MESA_SHADER_TYPES; j++) {
if (prog->_LinkedShaders[j] == NULL)
@@ -2289,11 +2363,17 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
prog->Validated = false;
prog->_Used = false;
- if (prog->InfoLog != NULL)
- ralloc_free(prog->InfoLog);
-
+ ralloc_free(prog->InfoLog);
prog->InfoLog = ralloc_strdup(NULL, "");
+ ralloc_free(prog->UniformBlocks);
+ prog->UniformBlocks = NULL;
+ prog->NumUniformBlocks = 0;
+ for (int i = 0; i < MESA_SHADER_TYPES; i++) {
+ ralloc_free(prog->UniformBlockStageIndex[i]);
+ prog->UniformBlockStageIndex[i] = NULL;
+ }
+
/* Separate the shaders into groups based on their type.
*/
struct gl_shader **vert_shader_list;
@@ -2422,6 +2502,9 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
}
}
+ if (!interstage_cross_validate_uniform_blocks(prog))
+ goto done;
+
/* Do common optimization before assigning storage for attributes,
* uniforms, and varyings. Later optimization could possibly make
* some of that unused.
diff --git a/mesalib/src/glsl/linker.h b/mesalib/src/glsl/linker.h
index d0aaf3e1e..7d2e98a15 100644
--- a/mesalib/src/glsl/linker.h
+++ b/mesalib/src/glsl/linker.h
@@ -40,6 +40,15 @@ link_assign_uniform_locations(struct gl_shader_program *prog);
extern void
link_set_uniform_initializers(struct gl_shader_program *prog);
+extern int
+link_cross_validate_uniform_block(void *mem_ctx,
+ struct gl_uniform_block **linked_blocks,
+ unsigned int *num_linked_blocks,
+ struct gl_uniform_block *new_block);
+
+void
+link_assign_uniform_block_offsets(struct gl_shader *shader);
+
/**
* Class for processing all of the leaf fields of an uniform
*
diff --git a/mesalib/src/glsl/lower_vector.cpp b/mesalib/src/glsl/lower_vector.cpp
index 57963a121..0cd6909db 100644
--- a/mesalib/src/glsl/lower_vector.cpp
+++ b/mesalib/src/glsl/lower_vector.cpp
@@ -183,7 +183,7 @@ lower_vector_visitor::handle_rvalue(ir_rvalue **rvalue)
if (assigned > 0) {
ir_constant *const c =
new(mem_ctx) ir_constant(glsl_type::get_instance(expr->type->base_type,
- assigned, 0),
+ assigned, 1),
&d);
ir_dereference *const lhs = new(mem_ctx) ir_dereference_variable(temp);
ir_assignment *const assign =
diff --git a/mesalib/src/glsl/opt_dead_code.cpp b/mesalib/src/glsl/opt_dead_code.cpp
index 0578f1737..de8475f95 100644
--- a/mesalib/src/glsl/opt_dead_code.cpp
+++ b/mesalib/src/glsl/opt_dead_code.cpp
@@ -95,9 +95,15 @@ do_dead_code(exec_list *instructions, bool uniform_locations_assigned)
/* uniform initializers are precious, and could get used by another
* stage. Also, once uniform locations have been assigned, the
* declaration cannot be deleted.
+ *
+ * Also, GL_ARB_uniform_buffer_object says that std140
+ * uniforms will not be eliminated. Since we always do
+ * std140, just don't eliminate uniforms in UBOs.
*/
if (entry->var->mode == ir_var_uniform &&
- (uniform_locations_assigned || entry->var->constant_value))
+ (uniform_locations_assigned ||
+ entry->var->constant_value ||
+ entry->var->uniform_block != -1))
continue;
entry->var->remove();
diff --git a/mesalib/src/glsl/strtod.c b/mesalib/src/glsl/strtod.c
index a876e138b..47c1f0ed6 100644
--- a/mesalib/src/glsl/strtod.c
+++ b/mesalib/src/glsl/strtod.c
@@ -45,7 +45,7 @@ double
glsl_strtod(const char *s, char **end)
{
#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \
- !defined(__HAIKU__)
+ !defined(__HAIKU__) && !defined(__UCLIBC__)
static locale_t loc = NULL;
if (!loc) {
loc = newlocale(LC_CTYPE_MASK, "C", NULL);
diff --git a/mesalib/src/mesa/Android.gen.mk b/mesalib/src/mesa/Android.gen.mk
index 2ea8cc433..5443bb99f 100644
--- a/mesalib/src/mesa/Android.gen.mk
+++ b/mesalib/src/mesa/Android.gen.mk
@@ -28,12 +28,19 @@ LOCAL_MODULE_CLASS := STATIC_LIBRARIES
endif
intermediates := $(call local-intermediates-dir)
-mydir := $(call my-dir)
+# This is the list of auto-generated files: sources and headers
sources := \
+ main/enums.c \
+ main/api_exec_es1.c \
main/api_exec_es1_dispatch.h \
main/api_exec_es1_remap_helper.h \
+ main/api_exec_es2.c \
main/api_exec_es2_dispatch.h \
+ program/program_parse.tab.c \
+ program/lex.yy.c \
+ main/dispatch.h \
+ main/remap_helper.h \
main/api_exec_es2_remap_helper.h
LOCAL_SRC_FILES := $(filter-out $(sources), $(LOCAL_SRC_FILES))
@@ -65,37 +72,49 @@ es_hdr_deps := \
$(wildcard $(glapi)/*.py) \
$(wildcard $(glapi)/*.xml)
+define local-l-to-c
+ @mkdir -p $(dir $@)
+ @echo "Mesa Lex: $(PRIVATE_MODULE) <= $<"
+ $(hide) $(LEX) -o$@ $<
+endef
+
+define local-y-to-c-and-h
+ @mkdir -p $(dir $@)
+ @echo "Mesa Yacc: $(PRIVATE_MODULE) <= $<"
+ $(hide) $(YACC) -o $@ $<
+endef
+
define es-gen
@mkdir -p $(dir $@)
@echo "Gen ES: $(PRIVATE_MODULE) <= $(notdir $(@))"
$(hide) $(PRIVATE_SCRIPT) $(1) $(PRIVATE_XML) > $@
endef
-define generate-local
- @echo "generate local sources"
- $(hide) $(MESA_PYTHON2) $(glapi)/gl_enums.py -f $(glapi)/gl_and_es_API.xml > $(mydir)/main/enums.c
- $(hide) $(MESA_PYTHON2) $(glapi)/gl_table.py -m remap_table -f $(glapi)/gl_and_es_API.xml > $(mydir)/main/dispatch.h
- $(hide) $(MESA_PYTHON2) $(glapi)/remap_helper.py -f $(glapi)/gl_API.xml > $(mydir)/main/remap_helper.h
- $(hide) $(MESA_PYTHON2) $(mydir)/main/es_generator.py -V GLES1.1 -S $(mydir)/main/APIspec.xml > $(mydir)/main/api_exec_es1.c
- $(hide) $(MESA_PYTHON2) $(mydir)/main/es_generator.py -V GLES2.0 -S $(mydir)/main/APIspec.xml > $(mydir)/main/api_exec_es2.c
-
- @echo "Mesa Lex : $(PRIVATE_MODULE)"
- $(hide) $(LEX) -o $(mydir)/program/lex.yy.c $(mydir)/program/program_lexer.l
- @echo "Mesa Yacc: $(PRIVATE_MODULE)"
- $(hide) $(YACC) -d -o $(mydir)/program/program_parse.tab.c $(mydir)/program/program_parse.y
-endef
-
+$(intermediates)/main/api_exec_%.c: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(LOCAL_PATH)/main/es_generator.py
+$(intermediates)/main/api_exec_%.c: PRIVATE_XML := -S $(LOCAL_PATH)/main/APIspec.xml
$(intermediates)/main/api_exec_%_dispatch.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/gl_table.py
$(intermediates)/main/api_exec_%_dispatch.h: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
$(intermediates)/main/api_exec_%_remap_helper.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/remap_helper.py
$(intermediates)/main/api_exec_%_remap_helper.h: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
+$(intermediates)/main/api_exec_es1.c: $(es_src_deps)
+ $(call es-gen, -V GLES1.1)
+
+$(intermediates)/main/api_exec_es2.c: $(es_src_deps)
+ $(call es-gen, -V GLES2.0)
+
$(intermediates)/main/api_exec_%_dispatch.h: $(es_hdr_deps)
$(call es-gen, -c $* -m remap_table)
$(intermediates)/main/api_exec_%_remap_helper.h: $(es_hdr_deps)
$(call es-gen, -c $*)
+$(intermediates)/program/program_parse.tab.c: $(LOCAL_PATH)/program/program_parse.y
+ $(local-y-to-c-and-h)
+
+$(intermediates)/program/lex.yy.c: $(LOCAL_PATH)/program/program_lexer.l
+ $(local-l-to-c)
+
$(intermediates)/main/git_sha1.h:
@mkdir -p $(dir $@)
@echo "GIT-SHA1: $(PRIVATE_MODULE) <= git"
@@ -115,4 +134,21 @@ $(intermediates)/x86/matypes.h: $(matypes_deps)
@mkdir -p $(dir $@)
@echo "MATYPES: $(PRIVATE_MODULE) <= $(notdir $@)"
$(hide) $< > $@
- $(call generate-local)
+
+$(intermediates)/main/dispatch.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/gl_table.py
+$(intermediates)/main/dispatch.h: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
+
+$(intermediates)/main/dispatch.h: $(es_hdr_deps)
+ $(call es-gen, $* -m remap_table)
+
+$(intermediates)/main/remap_helper.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/remap_helper.py
+$(intermediates)/main/remap_helper.h: PRIVATE_XML := -f $(glapi)/gl_API.xml
+
+$(intermediates)/main/remap_helper.h: $(es_hdr_deps)
+ $(call es-gen, $*)
+
+$(intermediates)/main/enums.c: PRIVATE_SCRIPT :=$(MESA_PYTHON2) $(glapi)/gl_enums.py
+$(intermediates)/main/enums.c: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
+
+$(intermediates)/main/enums.c: $(es_src_deps)
+ $(call es-gen)
diff --git a/mesalib/src/mesa/Android.mk b/mesalib/src/mesa/Android.mk
index 115db4703..4b62b8194 100644
--- a/mesalib/src/mesa/Android.mk
+++ b/mesalib/src/mesa/Android.mk
@@ -31,7 +31,6 @@ LOCAL_PATH := $(call my-dir)
# MESA_GALLIUM_FILES
# MESA_FILES
# X86_FILES
-SRCDIR = .
include $(LOCAL_PATH)/sources.mak
common_CFLAGS := \
diff --git a/mesalib/src/mesa/Makefile.am b/mesalib/src/mesa/Makefile.am
index 2b023d727..2ec57ea91 100644
--- a/mesalib/src/mesa/Makefile.am
+++ b/mesalib/src/mesa/Makefile.am
@@ -95,7 +95,7 @@ program/lex.yy.c: program/program_lexer.l
noinst_LTLIBRARIES = libmesa.la libmesagallium.la
-SRCDIR = $(top_srcdir)/src/mesa
+SRCDIR = $(top_srcdir)/src/mesa/
include sources.mak
AM_CPPFLAGS = $(API_DEFINES) $(DEFINES) $(INCLUDE_DIRS)
@@ -131,9 +131,6 @@ libmesagallium_la_SOURCES = \
libmesagallium_la_LIBADD = $(top_builddir)/src/glsl/libglsl.la
libmesagallium_la_LDFLAGS =
-install-exec-local:
- $(MAKE) -f $(srcdir)/Makefile.old install
-
# Provide compatibility with scripts for the old Mesa build system for
# a while by putting a link to the library in the current directory.
all-local: libmesa.la libmesagallium.la
@@ -149,3 +146,7 @@ pkgconfig_DATA = osmesa.pc
else
pkgconfig_DATA = gl.pc
endif
+
+# Emacs tags
+tags:
+ etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h
diff --git a/mesalib/src/mesa/Makefile.old b/mesalib/src/mesa/Makefile.old
deleted file mode 100644
index 3266a5de0..000000000
--- a/mesalib/src/mesa/Makefile.old
+++ /dev/null
@@ -1,27 +0,0 @@
-# src/mesa/Makefile
-
-TOP = ../..
-include $(TOP)/configs/current
-
-SRCDIR = .
-include sources.mak
-
-default:
-
-######################################################################
-# Installation rules
-
-install: default $(DRICORE_INSTALL_TARGET)
- @for driver in $(DRIVER_DIRS) ; do \
- case "$$driver" in \
- osmesa) $(MAKE) -f Makefile.old install-osmesa || exit 1 ;; \
- esac ; \
- done
-
-install-osmesa: default
- $(MINSTALL) $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_GLOB) \
- $(DESTDIR)$(INSTALL_LIB_DIR)
-
-# Emacs tags
-tags:
- etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h
diff --git a/mesalib/src/mesa/SConscript b/mesalib/src/mesa/SConscript
index 906c57962..a3cbc16de 100644
--- a/mesalib/src/mesa/SConscript
+++ b/mesalib/src/mesa/SConscript
@@ -80,6 +80,7 @@ main_sources = [
'main/framebuffer.c',
'main/get.c',
'main/getstring.c',
+ 'main/glformats.c',
'main/hash.c',
'main/hint.c',
'main/histogram.c',
diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c
index cf2d05337..6846bbc60 100644
--- a/mesalib/src/mesa/drivers/common/meta.c
+++ b/mesalib/src/mesa/drivers/common/meta.c
@@ -46,6 +46,7 @@
#include "main/fbobject.h"
#include "main/feedback.h"
#include "main/formats.h"
+#include "main/glformats.h"
#include "main/image.h"
#include "main/macros.h"
#include "main/matrix.h"
@@ -1847,7 +1848,7 @@ meta_glsl_clear_init(struct gl_context *ctx, struct clear_state *clear)
clear->ColorLocation = _mesa_GetUniformLocationARB(clear->ShaderProg,
"color");
- if (ctx->API == API_OPENGL && ctx->Const.GLSLVersion >= 130) {
+ if (_mesa_is_desktop_gl(ctx) && ctx->Const.GLSLVersion >= 130) {
vs = compile_shader_with_debug(ctx, GL_VERTEX_SHADER, vs_int_source);
fs = compile_shader_with_debug(ctx, GL_FRAGMENT_SHADER, fs_int_source);
@@ -2280,8 +2281,7 @@ _mesa_meta_DrawPixels(struct gl_context *ctx,
* Determine if we can do the glDrawPixels with texture mapping.
*/
fallback = GL_FALSE;
- if (ctx->_ImageTransferState ||
- ctx->Fog.Enabled) {
+ if (ctx->Fog.Enabled) {
fallback = GL_TRUE;
}
@@ -2316,6 +2316,7 @@ _mesa_meta_DrawPixels(struct gl_context *ctx,
texIntFormat = GL_ALPHA;
metaExtraSave = (MESA_META_COLOR_MASK |
MESA_META_DEPTH_TEST |
+ MESA_META_PIXEL_TRANSFER |
MESA_META_SHADER |
MESA_META_STENCIL_TEST);
}
diff --git a/mesalib/src/mesa/drivers/dri/common/drirc b/mesalib/src/mesa/drivers/dri/common/drirc
index 2d9287852..cf13cdb80 100644
--- a/mesalib/src/mesa/drivers/dri/common/drirc
+++ b/mesalib/src/mesa/drivers/dri/common/drirc
@@ -2,15 +2,25 @@
<device screen="0" driver="i965">
<application name="Unigine Sanctuary" executable="Sanctuary">
<option name="force_glsl_extensions_warn" value="true" />
+ <option name="disable_blend_func_extended" value="true" />
</application>
<application name="Unigine Tropics" executable="Tropics">
<option name="force_glsl_extensions_warn" value="true" />
+ <option name="disable_blend_func_extended" value="true" />
</application>
<application name="Unigine Heaven (32-bit)" executable="heaven_x86">
<option name="force_glsl_extensions_warn" value="true" />
+ <option name="disable_blend_func_extended" value="true" />
</application>
<application name="Unigine Heaven (64-bit)" executable="heaven_x64">
<option name="force_glsl_extensions_warn" value="true" />
+ <option name="disable_blend_func_extended" value="true" />
+ </application>
+ <application name="Unigine OilRush (32-bit)" executable="OilRush_x86">
+ <option name="disable_blend_func_extended" value="true" />
+ </application>
+ <application name="Unigine OilRush (64-bit)" executable="OilRush_x64">
+ <option name="disable_blend_func_extended" value="true" />
</application>
</device>
</driconf>
diff --git a/mesalib/src/mesa/drivers/dri/common/xmlpool/options.h b/mesalib/src/mesa/drivers/dri/common/xmlpool/options.h
index 75c887e5d..a20e3d12d 100644
--- a/mesalib/src/mesa/drivers/dri/common/xmlpool/options.h
+++ b/mesalib/src/mesa/drivers/dri/common/xmlpool/options.h
@@ -636,3 +636,13 @@ DRI_CONF_OPT_BEGIN(force_glsl_extensions_warn,bool,def) \
DRI_CONF_DESC(fr,"Force GLSL extension default behavior to 'warn'") \
DRI_CONF_DESC(sv,"Force GLSL extension default behavior to 'warn'") \
DRI_CONF_OPT_END
+
+#define DRI_CONF_DISABLE_BLEND_FUNC_EXTENDED(def) \
+DRI_CONF_OPT_BEGIN(disable_blend_func_extended,bool,def) \
+ DRI_CONF_DESC(en,"Disable dual source blending") \
+ DRI_CONF_DESC(de,"Disable dual source blending") \
+ DRI_CONF_DESC(es,"Disable dual source blending") \
+ DRI_CONF_DESC(nl,"Disable dual source blending") \
+ DRI_CONF_DESC(fr,"Disable dual source blending") \
+ DRI_CONF_DESC(sv,"Disable dual source blending") \
+DRI_CONF_OPT_END
diff --git a/mesalib/src/mesa/main/api_exec.c b/mesalib/src/mesa/main/api_exec.c
index 19e7f9807..81be46d5f 100644
--- a/mesalib/src/mesa/main/api_exec.c
+++ b/mesalib/src/mesa/main/api_exec.c
@@ -120,7 +120,7 @@
* \param exec dispatch table.
*/
struct _glapi_table *
-_mesa_create_exec_table(void)
+_mesa_create_exec_table(struct gl_context *ctx)
{
struct _glapi_table *exec;
@@ -133,7 +133,10 @@ _mesa_create_exec_table(void)
#endif
/* load the dispatch slots we understand */
- SET_AlphaFunc(exec, _mesa_AlphaFunc);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_AlphaFunc(exec, _mesa_AlphaFunc);
+ }
+
SET_BlendFunc(exec, _mesa_BlendFunc);
SET_Clear(exec, _mesa_Clear);
SET_ClearColor(exec, _mesa_ClearColor);
@@ -149,42 +152,62 @@ _mesa_create_exec_table(void)
SET_Finish(exec, _mesa_Finish);
SET_Flush(exec, _mesa_Flush);
SET_FrontFace(exec, _mesa_FrontFace);
- SET_Frustum(exec, _mesa_Frustum);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_Frustum(exec, _mesa_Frustum);
+ }
SET_GetError(exec, _mesa_GetError);
SET_GetFloatv(exec, _mesa_GetFloatv);
SET_GetString(exec, _mesa_GetString);
- SET_LineStipple(exec, _mesa_LineStipple);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_LineStipple(exec, _mesa_LineStipple);
+ }
SET_LineWidth(exec, _mesa_LineWidth);
- SET_LoadIdentity(exec, _mesa_LoadIdentity);
- SET_LoadMatrixf(exec, _mesa_LoadMatrixf);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_LoadIdentity(exec, _mesa_LoadIdentity);
+ SET_LoadMatrixf(exec, _mesa_LoadMatrixf);
+ }
SET_LogicOp(exec, _mesa_LogicOp);
- SET_MatrixMode(exec, _mesa_MatrixMode);
- SET_MultMatrixf(exec, _mesa_MultMatrixf);
- SET_Ortho(exec, _mesa_Ortho);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_MatrixMode(exec, _mesa_MatrixMode);
+ SET_MultMatrixf(exec, _mesa_MultMatrixf);
+ SET_Ortho(exec, _mesa_Ortho);
+ }
SET_PixelStorei(exec, _mesa_PixelStorei);
- SET_PopMatrix(exec, _mesa_PopMatrix);
- SET_PushMatrix(exec, _mesa_PushMatrix);
- SET_Rotatef(exec, _mesa_Rotatef);
- SET_Scalef(exec, _mesa_Scalef);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_PopMatrix(exec, _mesa_PopMatrix);
+ SET_PushMatrix(exec, _mesa_PushMatrix);
+ SET_Rotatef(exec, _mesa_Rotatef);
+ SET_Scalef(exec, _mesa_Scalef);
+ }
SET_Scissor(exec, _mesa_Scissor);
- SET_ShadeModel(exec, _mesa_ShadeModel);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_ShadeModel(exec, _mesa_ShadeModel);
+ }
SET_StencilFunc(exec, _mesa_StencilFunc);
SET_StencilMask(exec, _mesa_StencilMask);
SET_StencilOp(exec, _mesa_StencilOp);
- SET_TexEnvfv(exec, _mesa_TexEnvfv);
- SET_TexEnvi(exec, _mesa_TexEnvi);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_TexEnvfv(exec, _mesa_TexEnvfv);
+ SET_TexEnvi(exec, _mesa_TexEnvi);
+ }
SET_TexImage2D(exec, _mesa_TexImage2D);
SET_TexParameteri(exec, _mesa_TexParameteri);
- SET_Translatef(exec, _mesa_Translatef);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_Translatef(exec, _mesa_Translatef);
+ }
SET_Viewport(exec, _mesa_Viewport);
- _mesa_init_accum_dispatch(exec);
- _mesa_init_dlist_dispatch(exec);
+ if (ctx->API != API_OPENGL_CORE) {
+ _mesa_init_accum_dispatch(exec);
+ _mesa_init_dlist_dispatch(exec);
+ }
SET_ClearDepth(exec, _mesa_ClearDepth);
- SET_ClearIndex(exec, _mesa_ClearIndex);
- SET_ClipPlane(exec, _mesa_ClipPlane);
- SET_ColorMaterial(exec, _mesa_ColorMaterial);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_ClearIndex(exec, _mesa_ClearIndex);
+ SET_ClipPlane(exec, _mesa_ClipPlane);
+ SET_ColorMaterial(exec, _mesa_ColorMaterial);
+ }
SET_DepthFunc(exec, _mesa_DepthFunc);
SET_DepthMask(exec, _mesa_DepthMask);
SET_DepthRange(exec, _mesa_DepthRange);
@@ -192,43 +215,53 @@ _mesa_create_exec_table(void)
_mesa_init_drawpix_dispatch(exec);
_mesa_init_feedback_dispatch(exec);
- SET_FogCoordPointerEXT(exec, _mesa_FogCoordPointerEXT);
- SET_Fogf(exec, _mesa_Fogf);
- SET_Fogfv(exec, _mesa_Fogfv);
- SET_Fogi(exec, _mesa_Fogi);
- SET_Fogiv(exec, _mesa_Fogiv);
- SET_GetClipPlane(exec, _mesa_GetClipPlane);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_FogCoordPointerEXT(exec, _mesa_FogCoordPointerEXT);
+ SET_Fogf(exec, _mesa_Fogf);
+ SET_Fogfv(exec, _mesa_Fogfv);
+ SET_Fogi(exec, _mesa_Fogi);
+ SET_Fogiv(exec, _mesa_Fogiv);
+ SET_GetClipPlane(exec, _mesa_GetClipPlane);
+ }
SET_GetBooleanv(exec, _mesa_GetBooleanv);
SET_GetDoublev(exec, _mesa_GetDoublev);
SET_GetIntegerv(exec, _mesa_GetIntegerv);
- SET_GetLightfv(exec, _mesa_GetLightfv);
- SET_GetLightiv(exec, _mesa_GetLightiv);
- SET_GetMaterialfv(exec, _mesa_GetMaterialfv);
- SET_GetMaterialiv(exec, _mesa_GetMaterialiv);
- SET_GetPolygonStipple(exec, _mesa_GetPolygonStipple);
- SET_GetTexEnvfv(exec, _mesa_GetTexEnvfv);
- SET_GetTexEnviv(exec, _mesa_GetTexEnviv);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_GetLightfv(exec, _mesa_GetLightfv);
+ SET_GetLightiv(exec, _mesa_GetLightiv);
+ SET_GetMaterialfv(exec, _mesa_GetMaterialfv);
+ SET_GetMaterialiv(exec, _mesa_GetMaterialiv);
+ SET_GetPolygonStipple(exec, _mesa_GetPolygonStipple);
+ SET_GetTexEnvfv(exec, _mesa_GetTexEnvfv);
+ SET_GetTexEnviv(exec, _mesa_GetTexEnviv);
+ }
SET_GetTexLevelParameterfv(exec, _mesa_GetTexLevelParameterfv);
SET_GetTexLevelParameteriv(exec, _mesa_GetTexLevelParameteriv);
SET_GetTexParameterfv(exec, _mesa_GetTexParameterfv);
SET_GetTexParameteriv(exec, _mesa_GetTexParameteriv);
SET_GetTexImage(exec, _mesa_GetTexImage);
SET_Hint(exec, _mesa_Hint);
- SET_IndexMask(exec, _mesa_IndexMask);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_IndexMask(exec, _mesa_IndexMask);
+ }
SET_IsEnabled(exec, _mesa_IsEnabled);
- SET_LightModelf(exec, _mesa_LightModelf);
- SET_LightModelfv(exec, _mesa_LightModelfv);
- SET_LightModeli(exec, _mesa_LightModeli);
- SET_LightModeliv(exec, _mesa_LightModeliv);
- SET_Lightf(exec, _mesa_Lightf);
- SET_Lightfv(exec, _mesa_Lightfv);
- SET_Lighti(exec, _mesa_Lighti);
- SET_Lightiv(exec, _mesa_Lightiv);
- SET_LoadMatrixd(exec, _mesa_LoadMatrixd);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_LightModelf(exec, _mesa_LightModelf);
+ SET_LightModelfv(exec, _mesa_LightModelfv);
+ SET_LightModeli(exec, _mesa_LightModeli);
+ SET_LightModeliv(exec, _mesa_LightModeliv);
+ SET_Lightf(exec, _mesa_Lightf);
+ SET_Lightfv(exec, _mesa_Lightfv);
+ SET_Lighti(exec, _mesa_Lighti);
+ SET_Lightiv(exec, _mesa_Lightiv);
+ SET_LoadMatrixd(exec, _mesa_LoadMatrixd);
+ }
_mesa_init_eval_dispatch(exec);
- SET_MultMatrixd(exec, _mesa_MultMatrixd);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_MultMatrixd(exec, _mesa_MultMatrixd);
+ }
_mesa_init_pixel_dispatch(exec);
@@ -236,17 +269,21 @@ _mesa_create_exec_table(void)
SET_PointSize(exec, _mesa_PointSize);
SET_PolygonMode(exec, _mesa_PolygonMode);
SET_PolygonOffset(exec, _mesa_PolygonOffset);
- SET_PolygonStipple(exec, _mesa_PolygonStipple);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_PolygonStipple(exec, _mesa_PolygonStipple);
+ }
_mesa_init_attrib_dispatch(exec);
_mesa_init_rastpos_dispatch(exec);
SET_ReadPixels(exec, _mesa_ReadPixels);
- SET_Rotated(exec, _mesa_Rotated);
- SET_Scaled(exec, _mesa_Scaled);
- SET_SecondaryColorPointerEXT(exec, _mesa_SecondaryColorPointerEXT);
- SET_TexEnvf(exec, _mesa_TexEnvf);
- SET_TexEnviv(exec, _mesa_TexEnviv);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_Rotated(exec, _mesa_Rotated);
+ SET_Scaled(exec, _mesa_Scaled);
+ SET_SecondaryColorPointerEXT(exec, _mesa_SecondaryColorPointerEXT);
+ SET_TexEnvf(exec, _mesa_TexEnvf);
+ SET_TexEnviv(exec, _mesa_TexEnviv);
+ }
_mesa_init_texgen_dispatch(exec);
@@ -254,32 +291,42 @@ _mesa_create_exec_table(void)
SET_TexParameterf(exec, _mesa_TexParameterf);
SET_TexParameterfv(exec, _mesa_TexParameterfv);
SET_TexParameteriv(exec, _mesa_TexParameteriv);
- SET_Translated(exec, _mesa_Translated);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_Translated(exec, _mesa_Translated);
+ }
/* 1.1 */
SET_BindTexture(exec, _mesa_BindTexture);
SET_DeleteTextures(exec, _mesa_DeleteTextures);
SET_GenTextures(exec, _mesa_GenTextures);
#if _HAVE_FULL_GL
- SET_AreTexturesResident(exec, _mesa_AreTexturesResident);
- SET_ColorPointer(exec, _mesa_ColorPointer);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_AreTexturesResident(exec, _mesa_AreTexturesResident);
+ SET_ColorPointer(exec, _mesa_ColorPointer);
+ }
SET_CopyTexImage1D(exec, _mesa_CopyTexImage1D);
SET_CopyTexImage2D(exec, _mesa_CopyTexImage2D);
SET_CopyTexSubImage1D(exec, _mesa_CopyTexSubImage1D);
SET_CopyTexSubImage2D(exec, _mesa_CopyTexSubImage2D);
- SET_DisableClientState(exec, _mesa_DisableClientState);
- SET_EdgeFlagPointer(exec, _mesa_EdgeFlagPointer);
- SET_EnableClientState(exec, _mesa_EnableClientState);
- SET_GetPointerv(exec, _mesa_GetPointerv);
- SET_IndexPointer(exec, _mesa_IndexPointer);
- SET_InterleavedArrays(exec, _mesa_InterleavedArrays);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_DisableClientState(exec, _mesa_DisableClientState);
+ SET_EdgeFlagPointer(exec, _mesa_EdgeFlagPointer);
+ SET_EnableClientState(exec, _mesa_EnableClientState);
+ SET_GetPointerv(exec, _mesa_GetPointerv);
+ SET_IndexPointer(exec, _mesa_IndexPointer);
+ SET_InterleavedArrays(exec, _mesa_InterleavedArrays);
+ }
SET_IsTexture(exec, _mesa_IsTexture);
- SET_NormalPointer(exec, _mesa_NormalPointer);
- SET_PrioritizeTextures(exec, _mesa_PrioritizeTextures);
- SET_TexCoordPointer(exec, _mesa_TexCoordPointer);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_NormalPointer(exec, _mesa_NormalPointer);
+ SET_PrioritizeTextures(exec, _mesa_PrioritizeTextures);
+ SET_TexCoordPointer(exec, _mesa_TexCoordPointer);
+ }
SET_TexSubImage1D(exec, _mesa_TexSubImage1D);
SET_TexSubImage2D(exec, _mesa_TexSubImage2D);
- SET_VertexPointer(exec, _mesa_VertexPointer);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_VertexPointer(exec, _mesa_VertexPointer);
+ }
#endif
/* 1.2 */
@@ -327,31 +374,37 @@ _mesa_create_exec_table(void)
/* 11. GL_EXT_histogram */
#if 0
- SET_GetHistogramEXT(exec, _mesa_GetHistogram);
- SET_GetHistogramParameterfvEXT(exec, _mesa_GetHistogramParameterfv);
- SET_GetHistogramParameterivEXT(exec, _mesa_GetHistogramParameteriv);
- SET_GetMinmaxEXT(exec, _mesa_GetMinmax);
- SET_GetMinmaxParameterfvEXT(exec, _mesa_GetMinmaxParameterfv);
- SET_GetMinmaxParameterivEXT(exec, _mesa_GetMinmaxParameteriv);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_GetHistogramEXT(exec, _mesa_GetHistogram);
+ SET_GetHistogramParameterfvEXT(exec, _mesa_GetHistogramParameterfv);
+ SET_GetHistogramParameterivEXT(exec, _mesa_GetHistogramParameteriv);
+ SET_GetMinmaxEXT(exec, _mesa_GetMinmax);
+ SET_GetMinmaxParameterfvEXT(exec, _mesa_GetMinmaxParameterfv);
+ SET_GetMinmaxParameterivEXT(exec, _mesa_GetMinmaxParameteriv);
+ }
#endif
/* 14. SGI_color_table */
#if 0
- SET_ColorTableSGI(exec, _mesa_ColorTable);
- SET_ColorSubTableSGI(exec, _mesa_ColorSubTable);
- SET_GetColorTableSGI(exec, _mesa_GetColorTable);
- SET_GetColorTableParameterfvSGI(exec, _mesa_GetColorTableParameterfv);
- SET_GetColorTableParameterivSGI(exec, _mesa_GetColorTableParameteriv);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_ColorTableSGI(exec, _mesa_ColorTable);
+ SET_ColorSubTableSGI(exec, _mesa_ColorSubTable);
+ SET_GetColorTableSGI(exec, _mesa_GetColorTable);
+ SET_GetColorTableParameterfvSGI(exec, _mesa_GetColorTableParameterfv);
+ SET_GetColorTableParameterivSGI(exec, _mesa_GetColorTableParameteriv);
+ }
#endif
/* 30. GL_EXT_vertex_array */
#if _HAVE_FULL_GL
- SET_ColorPointerEXT(exec, _mesa_ColorPointerEXT);
- SET_EdgeFlagPointerEXT(exec, _mesa_EdgeFlagPointerEXT);
- SET_IndexPointerEXT(exec, _mesa_IndexPointerEXT);
- SET_NormalPointerEXT(exec, _mesa_NormalPointerEXT);
- SET_TexCoordPointerEXT(exec, _mesa_TexCoordPointerEXT);
- SET_VertexPointerEXT(exec, _mesa_VertexPointerEXT);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_ColorPointerEXT(exec, _mesa_ColorPointerEXT);
+ SET_EdgeFlagPointerEXT(exec, _mesa_EdgeFlagPointerEXT);
+ SET_IndexPointerEXT(exec, _mesa_IndexPointerEXT);
+ SET_NormalPointerEXT(exec, _mesa_NormalPointerEXT);
+ SET_TexCoordPointerEXT(exec, _mesa_TexCoordPointerEXT);
+ SET_VertexPointerEXT(exec, _mesa_VertexPointerEXT);
+ }
#endif
/* 37. GL_EXT_blend_minmax */
@@ -483,10 +536,12 @@ _mesa_create_exec_table(void)
/* ARB 3. GL_ARB_transpose_matrix */
#if _HAVE_FULL_GL
- SET_LoadTransposeMatrixdARB(exec, _mesa_LoadTransposeMatrixdARB);
- SET_LoadTransposeMatrixfARB(exec, _mesa_LoadTransposeMatrixfARB);
- SET_MultTransposeMatrixdARB(exec, _mesa_MultTransposeMatrixdARB);
- SET_MultTransposeMatrixfARB(exec, _mesa_MultTransposeMatrixfARB);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_LoadTransposeMatrixdARB(exec, _mesa_LoadTransposeMatrixdARB);
+ SET_LoadTransposeMatrixfARB(exec, _mesa_LoadTransposeMatrixfARB);
+ SET_MultTransposeMatrixdARB(exec, _mesa_MultTransposeMatrixdARB);
+ SET_MultTransposeMatrixfARB(exec, _mesa_MultTransposeMatrixfARB);
+ }
#endif
/* ARB 5. GL_ARB_multisample */
diff --git a/mesalib/src/mesa/main/api_exec.h b/mesalib/src/mesa/main/api_exec.h
index 29c953f31..100e97273 100644
--- a/mesalib/src/mesa/main/api_exec.h
+++ b/mesalib/src/mesa/main/api_exec.h
@@ -28,12 +28,13 @@
struct _glapi_table;
+struct gl_context;
extern struct _glapi_table *
_mesa_alloc_dispatch_table(int size);
extern struct _glapi_table *
-_mesa_create_exec_table(void);
+_mesa_create_exec_table(struct gl_context *ctx);
extern struct _glapi_table *
_mesa_create_exec_table_es1(void);
diff --git a/mesalib/src/mesa/main/api_validate.c b/mesalib/src/mesa/main/api_validate.c
index ece0a2b4a..eaf614bdc 100644
--- a/mesalib/src/mesa/main/api_validate.c
+++ b/mesalib/src/mesa/main/api_validate.c
@@ -128,6 +128,7 @@ check_valid_to_render(struct gl_context *ctx, const char *function)
#if FEATURE_GL
case API_OPENGL:
+ case API_OPENGL_CORE:
{
const struct gl_shader_program *vsProg =
ctx->Shader.CurrentVertexProgram;
diff --git a/mesalib/src/mesa/main/arbprogram.c b/mesalib/src/mesa/main/arbprogram.c
index b83369d9e..ae91fd5a3 100644
--- a/mesalib/src/mesa/main/arbprogram.c
+++ b/mesalib/src/mesa/main/arbprogram.c
@@ -138,12 +138,12 @@ _mesa_BindProgram(GLenum target, GLuint id)
/* bind newProg */
if (target == GL_VERTEX_PROGRAM_ARB) { /* == GL_VERTEX_PROGRAM_NV */
_mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current,
- (struct gl_vertex_program *) newProg);
+ gl_vertex_program(newProg));
}
else if (target == GL_FRAGMENT_PROGRAM_NV ||
target == GL_FRAGMENT_PROGRAM_ARB) {
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current,
- (struct gl_fragment_program *) newProg);
+ gl_fragment_program(newProg));
}
/* Never null pointers */
diff --git a/mesalib/src/mesa/main/arrayobj.h b/mesalib/src/mesa/main/arrayobj.h
index e5270fa2c..4f89064bb 100644
--- a/mesalib/src/mesa/main/arrayobj.h
+++ b/mesalib/src/mesa/main/arrayobj.h
@@ -30,6 +30,7 @@
#include "glheader.h"
#include "mtypes.h"
+#include "glformats.h"
struct gl_context;
diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c
index d5ccce076..7616eb78b 100644
--- a/mesalib/src/mesa/main/context.c
+++ b/mesalib/src/mesa/main/context.c
@@ -404,8 +404,6 @@ one_time_init( struct gl_context *ctx )
_mesa_get_cpu_features();
- _mesa_init_sqrt_table();
-
/* context dependence is never a one-time thing... */
_mesa_init_get_hash(ctx);
@@ -433,7 +431,7 @@ one_time_init( struct gl_context *ctx )
* when an app is linked to libGLES*, there are not enough dynamic
* entries.
*/
- if (ctx->API == API_OPENGL)
+ if (_mesa_is_desktop_gl(ctx))
_mesa_init_remap_table();
}
@@ -628,7 +626,7 @@ _mesa_init_constants(struct gl_context *ctx)
#endif
/* Shading language version */
- if (ctx->API == API_OPENGL) {
+ if (_mesa_is_desktop_gl(ctx)) {
ctx->Const.GLSLVersion = 120;
_mesa_override_glsl_version(ctx);
}
@@ -844,7 +842,10 @@ update_default_objects(struct gl_context *ctx)
static int
generic_nop(void)
{
- _mesa_warning(NULL, "User called no-op dispatch function (an unsupported extension function?)");
+ GET_CURRENT_CONTEXT(ctx);
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "unsupported function called "
+ "(unsupported extension or deprecated function?)");
return 0;
}
@@ -961,7 +962,8 @@ _mesa_initialize_context(struct gl_context *ctx,
switch (ctx->API) {
#if FEATURE_GL
case API_OPENGL:
- ctx->Exec = _mesa_create_exec_table();
+ case API_OPENGL_CORE:
+ ctx->Exec = _mesa_create_exec_table(ctx);
break;
#endif
#if FEATURE_ES1
@@ -1006,6 +1008,7 @@ _mesa_initialize_context(struct gl_context *ctx,
switch (ctx->API) {
case API_OPENGL:
+ case API_OPENGL_CORE:
#if FEATURE_dlist
ctx->Save = _mesa_create_save_table();
if (!ctx->Save) {
@@ -1455,8 +1458,8 @@ _mesa_make_current( struct gl_context *newCtx,
_glapi_set_dispatch(newCtx->CurrentDispatch);
if (drawBuffer && readBuffer) {
- ASSERT(drawBuffer->Name == 0);
- ASSERT(readBuffer->Name == 0);
+ ASSERT(_mesa_is_winsys_fbo(drawBuffer));
+ ASSERT(_mesa_is_winsys_fbo(readBuffer));
_mesa_reference_framebuffer(&newCtx->WinSysDrawBuffer, drawBuffer);
_mesa_reference_framebuffer(&newCtx->WinSysReadBuffer, readBuffer);
@@ -1464,7 +1467,7 @@ _mesa_make_current( struct gl_context *newCtx,
* Only set the context's Draw/ReadBuffer fields if they're NULL
* or not bound to a user-created FBO.
*/
- if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) {
+ if (!newCtx->DrawBuffer || _mesa_is_winsys_fbo(newCtx->DrawBuffer)) {
_mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer);
/* Update the FBO's list of drawbuffers/renderbuffers.
* For winsys FBOs this comes from the GL state (which may have
@@ -1472,7 +1475,7 @@ _mesa_make_current( struct gl_context *newCtx,
*/
_mesa_update_draw_buffers(newCtx);
}
- if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) {
+ if (!newCtx->ReadBuffer || _mesa_is_winsys_fbo(newCtx->ReadBuffer)) {
_mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer);
}
diff --git a/mesalib/src/mesa/main/context.h b/mesalib/src/mesa/main/context.h
index a66dd5076..6b7dafa78 100644
--- a/mesalib/src/mesa/main/context.h
+++ b/mesalib/src/mesa/main/context.h
@@ -290,6 +290,26 @@ do { \
/*@}*/
+/**
+ * Checks if the context is for Desktop GL (Compatibility or Core)
+ */
+static inline GLboolean
+_mesa_is_desktop_gl(const struct gl_context *ctx)
+{
+ return ctx->API == API_OPENGL || ctx->API == API_OPENGL_CORE;
+}
+
+
+/**
+ * Checks if the context is for any GLES version
+ */
+static inline GLboolean
+_mesa_is_gles(const struct gl_context *ctx)
+{
+ return ctx->API == API_OPENGLES || ctx->API == API_OPENGLES2;
+}
+
+
#ifdef __cplusplus
}
#endif
diff --git a/mesalib/src/mesa/main/dlist.c b/mesalib/src/mesa/main/dlist.c
index 40961b15c..510fd1e18 100644
--- a/mesalib/src/mesa/main/dlist.c
+++ b/mesalib/src/mesa/main/dlist.c
@@ -51,6 +51,7 @@
#endif
#include "framebuffer.h"
#include "glapi/glapi.h"
+#include "glformats.h"
#include "hash.h"
#include "image.h"
#include "light.h"
diff --git a/mesalib/src/mesa/main/drawpix.c b/mesalib/src/mesa/main/drawpix.c
index fdcbcccde..bd9837fdd 100644
--- a/mesalib/src/mesa/main/drawpix.c
+++ b/mesalib/src/mesa/main/drawpix.c
@@ -35,6 +35,8 @@
#include "pbo.h"
#include "state.h"
#include "dispatch.h"
+#include "glformats.h"
+#include "fbobject.h"
#if FEATURE_drawpix
@@ -89,7 +91,7 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
* input), NVIDIA's implementation also just returns this error despite
* exposing GL_EXT_texture_integer, just return an error regardless.
*/
- if (_mesa_is_integer_format(format)) {
+ if (_mesa_is_enum_format_integer(format)) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels(integer format)");
goto end;
}
@@ -239,7 +241,8 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height,
goto end;
}
- if (ctx->ReadBuffer->Name != 0 && ctx->ReadBuffer->Visual.samples > 0) {
+ if (_mesa_is_user_fbo(ctx->ReadBuffer) &&
+ ctx->ReadBuffer->Visual.samples > 0) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glCopyPixels(multisample FBO)");
goto end;
diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c
index 0675ce75d..a7b481ca7 100644
--- a/mesalib/src/mesa/main/extensions.c
+++ b/mesalib/src/mesa/main/extensions.c
@@ -41,7 +41,9 @@
enum {
DISABLE = 0,
- GL = 1 << API_OPENGL,
+ GLL = 1 << API_OPENGL, /* GL Legacy / Compatibility */
+ GLC = 1 << API_OPENGL_CORE, /* GL Core */
+ GL = (1 << API_OPENGL) | (1 << API_OPENGL_CORE),
ES1 = 1 << API_OPENGLES,
ES2 = 1 << API_OPENGLES2,
};
diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c
index 4370c7218..eb03b0918 100644
--- a/mesalib/src/mesa/main/fbobject.c
+++ b/mesalib/src/mesa/main/fbobject.c
@@ -38,8 +38,8 @@
#include "fbobject.h"
#include "formats.h"
#include "framebuffer.h"
+#include "glformats.h"
#include "hash.h"
-#include "image.h"
#include "macros.h"
#include "mfeatures.h"
#include "mtypes.h"
@@ -164,10 +164,10 @@ get_framebuffer_target(struct gl_context *ctx, GLenum target)
{
switch (target) {
case GL_DRAW_FRAMEBUFFER:
- return ctx->Extensions.EXT_framebuffer_blit && ctx->API == API_OPENGL
+ return ctx->Extensions.EXT_framebuffer_blit && _mesa_is_desktop_gl(ctx)
? ctx->DrawBuffer : NULL;
case GL_READ_FRAMEBUFFER:
- return ctx->Extensions.EXT_framebuffer_blit && ctx->API == API_OPENGL
+ return ctx->Extensions.EXT_framebuffer_blit && _mesa_is_desktop_gl(ctx)
? ctx->ReadBuffer : NULL;
case GL_FRAMEBUFFER_EXT:
return ctx->DrawBuffer;
@@ -221,7 +221,7 @@ _mesa_get_attachment(struct gl_context *ctx, struct gl_framebuffer *fb,
}
return &fb->Attachment[BUFFER_COLOR0 + i];
case GL_DEPTH_STENCIL_ATTACHMENT:
- if (ctx->API != API_OPENGL)
+ if (!_mesa_is_desktop_gl(ctx))
return NULL;
/* fall-through */
case GL_DEPTH_ATTACHMENT_EXT:
@@ -817,7 +817,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
}
#if FEATURE_GL
- if (ctx->API == API_OPENGL && !ctx->Extensions.ARB_ES2_compatibility) {
+ if (_mesa_is_desktop_gl(ctx) && !ctx->Extensions.ARB_ES2_compatibility) {
/* Check that all DrawBuffers are present */
for (j = 0; j < ctx->Const.MaxDrawBuffers; j++) {
if (fb->ColorDrawBuffer[j] != GL_NONE) {
@@ -2289,7 +2289,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
ASSERT_OUTSIDE_BEGIN_END(ctx);
/* The error differs in GL and GLES. */
- err = ctx->API == API_OPENGL ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
+ err = _mesa_is_desktop_gl(ctx) ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
buffer = get_framebuffer_target(ctx, target);
if (!buffer) {
@@ -2309,7 +2309,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
* OES_framebuffer_object spec refers to the EXT_framebuffer_object
* spec.
*/
- if (ctx->API != API_OPENGL || !ctx->Extensions.ARB_framebuffer_object) {
+ if (!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_framebuffer_object) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetFramebufferAttachmentParameteriv(bound FBO = 0)");
return;
@@ -2357,7 +2357,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
}
else {
assert(att->Type == GL_NONE);
- if (ctx->API == API_OPENGL) {
+ if (_mesa_is_desktop_gl(ctx)) {
*params = 0;
} else {
_mesa_error(ctx, GL_INVALID_ENUM,
@@ -2633,6 +2633,116 @@ compatible_color_datatypes(gl_format srcFormat, gl_format dstFormat)
/**
+ * Return the equivalent non-generic internal format.
+ * This is useful for comparing whether two internal formats are semantically
+ * equivalent.
+ */
+static GLenum
+get_nongeneric_internalformat(GLenum format)
+{
+ switch (format) {
+ /* GL 1.1 formats. */
+ case 4:
+ case GL_RGBA:
+ return GL_RGBA8;
+
+ case 3:
+ case GL_RGB:
+ return GL_RGB8;
+
+ case 2:
+ case GL_LUMINANCE_ALPHA:
+ return GL_LUMINANCE8_ALPHA8;
+
+ case 1:
+ case GL_LUMINANCE:
+ return GL_LUMINANCE8;
+
+ case GL_ALPHA:
+ return GL_ALPHA8;
+
+ case GL_INTENSITY:
+ return GL_INTENSITY8;
+
+ /* GL_ARB_texture_rg */
+ case GL_RED:
+ return GL_R8;
+
+ case GL_RG:
+ return GL_RG8;
+
+ /* GL_EXT_texture_sRGB */
+ case GL_SRGB:
+ return GL_SRGB8;
+
+ case GL_SRGB_ALPHA:
+ return GL_SRGB8_ALPHA8;
+
+ case GL_SLUMINANCE:
+ return GL_SLUMINANCE8;
+
+ case GL_SLUMINANCE_ALPHA:
+ return GL_SLUMINANCE8_ALPHA8;
+
+ /* GL_EXT_texture_snorm */
+ case GL_RGBA_SNORM:
+ return GL_RGBA8_SNORM;
+
+ case GL_RGB_SNORM:
+ return GL_RGB8_SNORM;
+
+ case GL_RG_SNORM:
+ return GL_RG8_SNORM;
+
+ case GL_RED_SNORM:
+ return GL_R8_SNORM;
+
+ case GL_LUMINANCE_ALPHA_SNORM:
+ return GL_LUMINANCE8_ALPHA8_SNORM;
+
+ case GL_LUMINANCE_SNORM:
+ return GL_LUMINANCE8_SNORM;
+
+ case GL_ALPHA_SNORM:
+ return GL_ALPHA8_SNORM;
+
+ case GL_INTENSITY_SNORM:
+ return GL_INTENSITY8_SNORM;
+
+ default:
+ return format;
+ }
+}
+
+
+static GLboolean
+compatible_resolve_formats(const struct gl_renderbuffer *colorReadRb,
+ const struct gl_renderbuffer *colorDrawRb)
+{
+ /* The simple case where we know the backing formats are the same.
+ */
+ if (colorReadRb->Format == colorDrawRb->Format) {
+ return GL_TRUE;
+ }
+
+ /* The Mesa formats are different, so we must check whether the internal
+ * formats are compatible.
+ *
+ * Under some circumstances, the user may request e.g. two GL_RGBA8
+ * textures and get two entirely different Mesa formats like RGBA8888 and
+ * ARGB8888. Drivers behaving like that should be able to cope with
+ * non-matching formats by themselves, because it's not the user's fault.
+ */
+ if (get_nongeneric_internalformat(colorReadRb->InternalFormat) ==
+ get_nongeneric_internalformat(colorDrawRb->InternalFormat)) {
+ return GL_TRUE;
+ }
+
+ return GL_FALSE;
+}
+
+
+/**
* Blit rectangular region, optionally from one framebuffer to another.
*
* Note, if the src buffer is multisampled and the dest is not, this is
@@ -2798,7 +2908,7 @@ _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
/* color formats must match */
if (colorReadRb &&
colorDrawRb &&
- colorReadRb->Format != colorDrawRb->Format) {
+ !compatible_resolve_formats(colorReadRb, colorDrawRb)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glBlitFramebufferEXT(bad src/dst multisample pixel formats)");
return;
diff --git a/mesalib/src/mesa/main/ffvertex_prog.c b/mesalib/src/mesa/main/ffvertex_prog.c
index 557768311..e5ab20145 100644
--- a/mesalib/src/mesa/main/ffvertex_prog.c
+++ b/mesalib/src/mesa/main/ffvertex_prog.c
@@ -1572,7 +1572,7 @@ static void build_array_pointsize( struct tnl_program *p )
static void build_tnl_program( struct tnl_program *p )
{
- /* Emit the program, starting with modelviewproject:
+ /* Emit the program, starting with the modelview, projection transforms:
*/
build_hpos(p);
@@ -1658,7 +1658,6 @@ create_new_program( const struct state_key *key,
/**
* Return a vertex program which implements the current fixed-function
* transform/lighting/texgen operations.
- * XXX move this into core mesa (main/)
*/
struct gl_vertex_program *
_mesa_get_fixed_func_vertex_program(struct gl_context *ctx)
@@ -1672,16 +1671,15 @@ _mesa_get_fixed_func_vertex_program(struct gl_context *ctx)
/* Look for an already-prepared program for this state:
*/
- prog = (struct gl_vertex_program *)
- _mesa_search_program_cache(ctx->VertexProgram.Cache, &key, sizeof(key));
+ prog = gl_vertex_program(
+ _mesa_search_program_cache(ctx->VertexProgram.Cache, &key, sizeof(key)));
if (!prog) {
/* OK, we'll have to build a new one */
if (0)
printf("Build new TNL program\n");
- prog = (struct gl_vertex_program *)
- ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
+ prog = gl_vertex_program(ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0));
if (!prog)
return NULL;
diff --git a/mesalib/src/mesa/main/format_pack.c b/mesalib/src/mesa/main/format_pack.c
index 7f0bda127..be6c026e8 100644
--- a/mesalib/src/mesa/main/format_pack.c
+++ b/mesalib/src/mesa/main/format_pack.c
@@ -1005,6 +1005,32 @@ pack_float_ARGB2101010(const GLfloat src[4], void *dst)
}
+/* MESA_FORMAT_ABGR2101010_UINT */
+
+static void
+pack_ubyte_ABGR2101010_UINT(const GLubyte src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLushort r = UBYTE_TO_USHORT(src[RCOMP]);
+ GLushort g = UBYTE_TO_USHORT(src[GCOMP]);
+ GLushort b = UBYTE_TO_USHORT(src[BCOMP]);
+ GLushort a = UBYTE_TO_USHORT(src[ACOMP]);
+ *d = PACK_COLOR_2101010_US(a, b, g, r);
+}
+
+static void
+pack_float_ABGR2101010_UINT(const GLfloat src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLushort r, g, b, a;
+ UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(a, src[ACOMP]);
+ *d = PACK_COLOR_2101010_US(a, b, g, r);
+}
+
+
/* MESA_FORMAT_SRGB8 */
static void
@@ -1696,6 +1722,7 @@ _mesa_get_pack_ubyte_rgba_function(gl_format format)
table[MESA_FORMAT_RG1616] = pack_ubyte_RG1616;
table[MESA_FORMAT_RG1616_REV] = pack_ubyte_RG1616_REV;
table[MESA_FORMAT_ARGB2101010] = pack_ubyte_ARGB2101010;
+ table[MESA_FORMAT_ABGR2101010_UINT] = pack_ubyte_ABGR2101010_UINT;
/* should never convert RGBA to these formats */
table[MESA_FORMAT_Z24_S8] = NULL;
@@ -1841,6 +1868,7 @@ _mesa_get_pack_float_rgba_function(gl_format format)
table[MESA_FORMAT_RG1616] = pack_float_RG1616;
table[MESA_FORMAT_RG1616_REV] = pack_float_RG1616_REV;
table[MESA_FORMAT_ARGB2101010] = pack_float_ARGB2101010;
+ table[MESA_FORMAT_ABGR2101010_UINT] = pack_float_ABGR2101010_UINT;
/* should never convert RGBA to these formats */
table[MESA_FORMAT_Z24_S8] = NULL;
diff --git a/mesalib/src/mesa/main/format_unpack.c b/mesalib/src/mesa/main/format_unpack.c
index c42bac19c..529c416a8 100644
--- a/mesalib/src/mesa/main/format_unpack.c
+++ b/mesalib/src/mesa/main/format_unpack.c
@@ -610,6 +610,20 @@ unpack_ARGB2101010(const void *src, GLfloat dst[][4], GLuint n)
static void
+unpack_ABGR2101010_UINT(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLuint *s = ((const GLuint *) src);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] = (GLfloat)((s[i] >> 0) & 0x3ff);
+ dst[i][GCOMP] = (GLfloat)((s[i] >> 10) & 0x3ff);
+ dst[i][BCOMP] = (GLfloat)((s[i] >> 20) & 0x3ff);
+ dst[i][ACOMP] = (GLfloat)((s[i] >> 30) & 0x03);
+ }
+}
+
+
+static void
unpack_Z24_S8(const void *src, GLfloat dst[][4], GLuint n)
{
/* only return Z, not stencil data */
@@ -1499,6 +1513,7 @@ get_unpack_rgba_function(gl_format format)
table[MESA_FORMAT_RG1616] = unpack_RG1616;
table[MESA_FORMAT_RG1616_REV] = unpack_RG1616_REV;
table[MESA_FORMAT_ARGB2101010] = unpack_ARGB2101010;
+ table[MESA_FORMAT_ABGR2101010_UINT] = unpack_ABGR2101010_UINT;
table[MESA_FORMAT_Z24_S8] = unpack_Z24_S8;
table[MESA_FORMAT_S8_Z24] = unpack_S8_Z24;
table[MESA_FORMAT_Z16] = unpack_Z16;
@@ -2139,6 +2154,32 @@ unpack_int_rgba_RGBA_INT8(const GLbyte *src, GLuint dst[][4], GLuint n)
}
static void
+unpack_int_rgba_ARGB8888(const GLbyte *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] = (GLubyte) src[i * 4 + 2];
+ dst[i][GCOMP] = (GLubyte) src[i * 4 + 1];
+ dst[i][BCOMP] = (GLubyte) src[i * 4 + 0];
+ dst[i][ACOMP] = (GLubyte) src[i * 4 + 3];
+ }
+}
+
+static void
+unpack_int_rgba_XRGB8888(const GLbyte *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] = (GLubyte) src[i * 4 + 2];
+ dst[i][GCOMP] = (GLubyte) src[i * 4 + 1];
+ dst[i][BCOMP] = (GLubyte) src[i * 4 + 0];
+ dst[i][ACOMP] = (GLubyte) 0xff;
+ }
+}
+
+static void
unpack_int_rgba_RGB_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
{
unsigned int i;
@@ -2563,6 +2604,20 @@ unpack_int_rgba_ARGB2101010_UINT(const GLuint *src, GLuint dst[][4], GLuint n)
}
}
+static void
+unpack_int_rgba_ABGR2101010_UINT(const GLuint *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ GLuint tmp = src[i];
+ dst[i][0] = (tmp >> 0) & 0x3ff;
+ dst[i][1] = (tmp >> 10) & 0x3ff;
+ dst[i][2] = (tmp >> 20) & 0x3ff;
+ dst[i][3] = (tmp >> 30) & 0x3;
+ }
+}
+
void
_mesa_unpack_uint_rgba_row(gl_format format, GLuint n,
const void *src, GLuint dst[][4])
@@ -2590,6 +2645,14 @@ _mesa_unpack_uint_rgba_row(gl_format format, GLuint n,
unpack_int_rgba_RGBA_INT8(src, dst, n);
break;
+ case MESA_FORMAT_ARGB8888:
+ unpack_int_rgba_ARGB8888(src, dst, n);
+ break;
+
+ case MESA_FORMAT_XRGB8888:
+ unpack_int_rgba_XRGB8888(src, dst, n);
+ break;
+
case MESA_FORMAT_RGB_UINT32:
case MESA_FORMAT_RGB_INT32:
unpack_int_rgba_RGB_UINT32(src, dst, n);
@@ -2725,6 +2788,11 @@ _mesa_unpack_uint_rgba_row(gl_format format, GLuint n,
case MESA_FORMAT_ARGB2101010_UINT:
unpack_int_rgba_ARGB2101010_UINT(src, dst, n);
break;
+
+ case MESA_FORMAT_ABGR2101010_UINT:
+ unpack_int_rgba_ABGR2101010_UINT(src, dst, n);
+ break;
+
default:
_mesa_problem(NULL, "%s: bad format %s", __FUNCTION__,
_mesa_get_format_name(format));
diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c
index c65c9c2e1..1fa641c92 100644
--- a/mesalib/src/mesa/main/formats.c
+++ b/mesalib/src/mesa/main/formats.c
@@ -28,6 +28,7 @@
#include "formats.h"
#include "mfeatures.h"
#include "macros.h"
+#include "glformats.h"
/**
@@ -1519,6 +1520,15 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
0, 0, 0, 0, 0,
1, 1, 4
},
+ {
+ MESA_FORMAT_ABGR2101010_UINT,
+ "MESA_FORMAT_ABGR2101010_UINT",
+ GL_RGBA,
+ GL_UNSIGNED_INT,
+ 10, 10, 10, 2,
+ 0, 0, 0, 0, 0,
+ 1, 1, 4
+ },
};
@@ -1712,6 +1722,17 @@ _mesa_is_format_integer_color(gl_format format)
/**
+ * Is the given format an unsigned integer format?
+ */
+GLboolean
+_mesa_is_format_unsigned(gl_format format)
+{
+ const struct gl_format_info *info = _mesa_get_format_info(format);
+ return _mesa_is_type_unsigned(info->DataType);
+}
+
+
+/**
* Return color encoding for given format.
* \return GL_LINEAR or GL_SRGB
*/
@@ -2491,6 +2512,7 @@ _mesa_format_to_type_and_comps(gl_format format,
return;
case MESA_FORMAT_ARGB2101010_UINT:
+ case MESA_FORMAT_ABGR2101010_UINT:
*datatype = GL_UNSIGNED_INT_2_10_10_10_REV;
*comps = 4;
return;
@@ -2916,6 +2938,11 @@ _mesa_format_matches_format_and_type(gl_format gl_format,
type == GL_UNSIGNED_INT_2_10_10_10_REV &&
!swapBytes);
+ case MESA_FORMAT_ABGR2101010_UINT:
+ return (format == GL_RGBA_INTEGER_EXT &&
+ type == GL_UNSIGNED_INT_2_10_10_10_REV &&
+ !swapBytes);
+
case MESA_FORMAT_RGB9_E5_FLOAT:
return format == GL_RGB && type == GL_UNSIGNED_INT_5_9_9_9_REV &&
!swapBytes;
@@ -2933,3 +2960,4 @@ _mesa_format_matches_format_and_type(gl_format gl_format,
return GL_FALSE;
}
+
diff --git a/mesalib/src/mesa/main/formats.h b/mesalib/src/mesa/main/formats.h
index 3a694a813..1843eb6fc 100644
--- a/mesalib/src/mesa/main/formats.h
+++ b/mesalib/src/mesa/main/formats.h
@@ -276,6 +276,7 @@ typedef enum
MESA_FORMAT_Z32_FLOAT_X24S8,
MESA_FORMAT_ARGB2101010_UINT,
+ MESA_FORMAT_ABGR2101010_UINT,
MESA_FORMAT_COUNT
} gl_format;
@@ -311,6 +312,9 @@ _mesa_is_format_packed_depth_stencil(gl_format format);
extern GLboolean
_mesa_is_format_integer_color(gl_format format);
+extern GLboolean
+_mesa_is_format_unsigned(gl_format format);
+
extern GLenum
_mesa_get_format_color_encoding(gl_format format);
@@ -346,7 +350,6 @@ _mesa_format_matches_format_and_type(gl_format gl_format,
GLenum format, GLenum type,
GLboolean swapBytes);
-
#ifdef __cplusplus
}
#endif
diff --git a/mesalib/src/mesa/main/framebuffer.c b/mesalib/src/mesa/main/framebuffer.c
index ea14148de..13887f8f5 100644
--- a/mesalib/src/mesa/main/framebuffer.c
+++ b/mesalib/src/mesa/main/framebuffer.c
@@ -347,7 +347,7 @@ _mesa_resizebuffers( struct gl_context *ctx )
GLuint newWidth, newHeight;
struct gl_framebuffer *buffer = ctx->WinSysDrawBuffer;
- assert(buffer->Name == 0);
+ assert(_mesa_is_winsys_fbo(buffer));
/* ask device driver for size of output buffer */
ctx->Driver.GetBufferSize( buffer, &newWidth, &newHeight );
@@ -364,7 +364,7 @@ _mesa_resizebuffers( struct gl_context *ctx )
GLuint newWidth, newHeight;
struct gl_framebuffer *buffer = ctx->WinSysReadBuffer;
- assert(buffer->Name == 0);
+ assert(_mesa_is_winsys_fbo(buffer));
/* ask device driver for size of read buffer */
ctx->Driver.GetBufferSize( buffer, &newWidth, &newHeight );
@@ -444,7 +444,7 @@ _mesa_update_draw_buffer_bounds(struct gl_context *ctx)
if (!buffer)
return;
- if (buffer->Name) {
+ if (_mesa_is_user_fbo(buffer)) {
/* user-created framebuffer size depends on the renderbuffers */
update_framebuffer_size(ctx, buffer);
}
@@ -517,6 +517,13 @@ _mesa_update_framebuffer_visual(struct gl_context *ctx,
const GLenum baseFormat = _mesa_get_format_base_format(rb->Format);
const gl_format fmt = rb->Format;
+ /* Grab samples and sampleBuffers from any attachment point (assuming
+ * the framebuffer is complete, we'll get the same answer from all
+ * attachments).
+ */
+ fb->Visual.samples = rb->NumSamples;
+ fb->Visual.sampleBuffers = rb->NumSamples > 0 ? 1 : 0;
+
if (_mesa_is_legal_color_format(ctx, baseFormat)) {
fb->Visual.redBits = _mesa_get_format_bits(fmt, GL_RED_BITS);
fb->Visual.greenBits = _mesa_get_format_bits(fmt, GL_GREEN_BITS);
@@ -524,8 +531,6 @@ _mesa_update_framebuffer_visual(struct gl_context *ctx,
fb->Visual.alphaBits = _mesa_get_format_bits(fmt, GL_ALPHA_BITS);
fb->Visual.rgbBits = fb->Visual.redBits
+ fb->Visual.greenBits + fb->Visual.blueBits;
- fb->Visual.samples = rb->NumSamples;
- fb->Visual.sampleBuffers = rb->NumSamples > 0 ? 1 : 0;
if (_mesa_get_format_color_encoding(fmt) == GL_SRGB)
fb->Visual.sRGBCapable = ctx->Extensions.EXT_framebuffer_sRGB;
break;
diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c
index 15de321e4..b9c98fb22 100644
--- a/mesalib/src/mesa/main/get.c
+++ b/mesalib/src/mesa/main/get.c
@@ -391,6 +391,7 @@ extra_NV_read_buffer_api_gl[] = {
#define API_OPENGL_BIT (1 << API_OPENGL)
#define API_OPENGLES_BIT (1 << API_OPENGLES)
#define API_OPENGLES2_BIT (1 << API_OPENGLES2)
+#define API_OPENGL_CORE_BIT (1 << API_OPENGL_CORE)
/* This is the big table describing all the enums we accept in
* glGet*v(). The table is partitioned into six parts: enums
@@ -405,7 +406,9 @@ extra_NV_read_buffer_api_gl[] = {
static const struct value_desc values[] = {
/* Enums shared between OpenGL, GLES1 and GLES2 */
{ 0, 0, TYPE_API_MASK,
- API_OPENGL_BIT | API_OPENGLES_BIT | API_OPENGLES2_BIT, NO_EXTRA},
+ API_OPENGL_BIT | API_OPENGLES_BIT | API_OPENGLES2_BIT |
+ API_OPENGL_CORE_BIT,
+ NO_EXTRA},
{ GL_ALPHA_BITS, BUFFER_INT(Visual.alphaBits), extra_new_buffers },
{ GL_BLEND, CONTEXT_BIT0(Color.BlendEnabled), NO_EXTRA },
{ GL_BLEND_SRC, CONTEXT_ENUM(Color.Blend[0].SrcRGB), NO_EXTRA },
@@ -534,7 +537,7 @@ static const struct value_desc values[] = {
#if FEATURE_GL || FEATURE_ES1
/* Enums in OpenGL and GLES1 */
- { 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGLES_BIT, NO_EXTRA },
+ { 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGLES_BIT | API_OPENGL_CORE_BIT, NO_EXTRA },
{ GL_MAX_LIGHTS, CONTEXT_INT(Const.MaxLights), NO_EXTRA },
{ GL_LIGHT0, CONTEXT_BOOL(Light.Light[0].Enabled), NO_EXTRA },
{ GL_LIGHT1, CONTEXT_BOOL(Light.Light[1].Enabled), NO_EXTRA },
@@ -796,7 +799,7 @@ static const struct value_desc values[] = {
#if FEATURE_GL
/* Remaining enums are only in OpenGL */
- { 0, 0, TYPE_API_MASK, API_OPENGL_BIT, NO_EXTRA },
+ { 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGL_CORE_BIT, NO_EXTRA },
{ GL_ACCUM_RED_BITS, BUFFER_INT(Visual.accumRedBits), NO_EXTRA },
{ GL_ACCUM_GREEN_BITS, BUFFER_INT(Visual.accumGreenBits), NO_EXTRA },
{ GL_ACCUM_BLUE_BITS, BUFFER_INT(Visual.accumBlueBits), NO_EXTRA },
@@ -1887,7 +1890,7 @@ check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d
}
break;
case EXTRA_API_GL:
- if (ctx->API == API_OPENGL) {
+ if (_mesa_is_desktop_gl(ctx)) {
total++;
enabled++;
}
diff --git a/mesalib/src/mesa/main/getstring.c b/mesalib/src/mesa/main/getstring.c
index 2f445aaf9..c6f400af5 100644
--- a/mesalib/src/mesa/main/getstring.c
+++ b/mesalib/src/mesa/main/getstring.c
@@ -41,6 +41,7 @@ shading_language_version(struct gl_context *ctx)
{
switch (ctx->API) {
case API_OPENGL:
+ case API_OPENGL_CORE:
if (!ctx->Extensions.ARB_shader_objects) {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetString");
return (const GLubyte *) 0;
diff --git a/mesalib/src/mesa/main/glformats.c b/mesalib/src/mesa/main/glformats.c
new file mode 100644
index 000000000..4fe0ae078
--- /dev/null
+++ b/mesalib/src/mesa/main/glformats.c
@@ -0,0 +1,1329 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
+ * Copyright (c) 2008-2009 VMware, Inc.
+ * Copyright (c) 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 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 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 "context.h"
+#include "glformats.h"
+
+
+/**
+ * \return GL_TRUE if type is packed pixel type, GL_FALSE otherwise.
+ */
+GLboolean
+_mesa_type_is_packed(GLenum type)
+{
+ switch (type) {
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ case MESA_UNSIGNED_BYTE_4_4:
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ case GL_UNSIGNED_SHORT_8_8_MESA:
+ case GL_UNSIGNED_SHORT_8_8_REV_MESA:
+ case GL_UNSIGNED_INT_24_8_EXT:
+ case GL_UNSIGNED_INT_5_9_9_9_REV:
+ case GL_UNSIGNED_INT_10F_11F_11F_REV:
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ return GL_TRUE;
+ }
+
+ return GL_FALSE;
+}
+
+
+/**
+ * Get the size of a GL data type.
+ *
+ * \param type GL data type.
+ *
+ * \return the size, in bytes, of the given data type, 0 if a GL_BITMAP, or -1
+ * if an invalid type enum.
+ */
+GLint
+_mesa_sizeof_type(GLenum type)
+{
+ switch (type) {
+ case GL_BITMAP:
+ return 0;
+ case GL_UNSIGNED_BYTE:
+ return sizeof(GLubyte);
+ case GL_BYTE:
+ return sizeof(GLbyte);
+ case GL_UNSIGNED_SHORT:
+ return sizeof(GLushort);
+ case GL_SHORT:
+ return sizeof(GLshort);
+ case GL_UNSIGNED_INT:
+ return sizeof(GLuint);
+ case GL_INT:
+ return sizeof(GLint);
+ case GL_FLOAT:
+ return sizeof(GLfloat);
+ case GL_DOUBLE:
+ return sizeof(GLdouble);
+ case GL_HALF_FLOAT_ARB:
+ return sizeof(GLhalfARB);
+ case GL_FIXED:
+ return sizeof(GLfixed);
+ default:
+ return -1;
+ }
+}
+
+
+/**
+ * Same as _mesa_sizeof_type() but also accepting the packed pixel
+ * format data types.
+ */
+GLint
+_mesa_sizeof_packed_type(GLenum type)
+{
+ switch (type) {
+ case GL_BITMAP:
+ return 0;
+ case GL_UNSIGNED_BYTE:
+ return sizeof(GLubyte);
+ case GL_BYTE:
+ return sizeof(GLbyte);
+ case GL_UNSIGNED_SHORT:
+ return sizeof(GLushort);
+ case GL_SHORT:
+ return sizeof(GLshort);
+ case GL_UNSIGNED_INT:
+ return sizeof(GLuint);
+ case GL_INT:
+ return sizeof(GLint);
+ case GL_HALF_FLOAT_ARB:
+ return sizeof(GLhalfARB);
+ case GL_FLOAT:
+ return sizeof(GLfloat);
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ case MESA_UNSIGNED_BYTE_4_4:
+ return sizeof(GLubyte);
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ case GL_UNSIGNED_SHORT_8_8_MESA:
+ case GL_UNSIGNED_SHORT_8_8_REV_MESA:
+ return sizeof(GLushort);
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ case GL_UNSIGNED_INT_24_8_EXT:
+ case GL_UNSIGNED_INT_5_9_9_9_REV:
+ case GL_UNSIGNED_INT_10F_11F_11F_REV:
+ return sizeof(GLuint);
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ return 8;
+ default:
+ return -1;
+ }
+}
+
+
+/**
+ * Get the number of components in a pixel format.
+ *
+ * \param format pixel format.
+ *
+ * \return the number of components in the given format, or -1 if a bad format.
+ */
+GLint
+_mesa_components_in_format(GLenum format)
+{
+ switch (format) {
+ case GL_COLOR_INDEX:
+ case GL_STENCIL_INDEX:
+ case GL_DEPTH_COMPONENT:
+ case GL_RED:
+ case GL_RED_INTEGER_EXT:
+ case GL_GREEN:
+ case GL_GREEN_INTEGER_EXT:
+ case GL_BLUE:
+ case GL_BLUE_INTEGER_EXT:
+ case GL_ALPHA:
+ case GL_ALPHA_INTEGER_EXT:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE_INTEGER_EXT:
+ case GL_INTENSITY:
+ return 1;
+
+ case GL_LUMINANCE_ALPHA:
+ case GL_LUMINANCE_ALPHA_INTEGER_EXT:
+ case GL_RG:
+ case GL_YCBCR_MESA:
+ case GL_DEPTH_STENCIL_EXT:
+ case GL_DUDV_ATI:
+ case GL_DU8DV8_ATI:
+ case GL_RG_INTEGER:
+ return 2;
+
+ case GL_RGB:
+ case GL_BGR:
+ case GL_RGB_INTEGER_EXT:
+ case GL_BGR_INTEGER_EXT:
+ return 3;
+
+ case GL_RGBA:
+ case GL_BGRA:
+ case GL_ABGR_EXT:
+ case GL_RGBA_INTEGER_EXT:
+ case GL_BGRA_INTEGER_EXT:
+ return 4;
+
+ default:
+ return -1;
+ }
+}
+
+
+/**
+ * Get the bytes per pixel of pixel format type pair.
+ *
+ * \param format pixel format.
+ * \param type pixel type.
+ *
+ * \return bytes per pixel, or -1 if a bad format or type was given.
+ */
+GLint
+_mesa_bytes_per_pixel(GLenum format, GLenum type)
+{
+ GLint comps = _mesa_components_in_format(format);
+ if (comps < 0)
+ return -1;
+
+ switch (type) {
+ case GL_BITMAP:
+ return 0; /* special case */
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ return comps * sizeof(GLubyte);
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ return comps * sizeof(GLshort);
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ return comps * sizeof(GLint);
+ case GL_FLOAT:
+ return comps * sizeof(GLfloat);
+ case GL_HALF_FLOAT_ARB:
+ return comps * sizeof(GLhalfARB);
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ if (format == GL_RGB || format == GL_BGR ||
+ format == GL_RGB_INTEGER_EXT || format == GL_BGR_INTEGER_EXT)
+ return sizeof(GLubyte);
+ else
+ return -1; /* error */
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ if (format == GL_RGB || format == GL_BGR ||
+ format == GL_RGB_INTEGER_EXT || format == GL_BGR_INTEGER_EXT)
+ return sizeof(GLushort);
+ else
+ return -1; /* error */
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT ||
+ format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT)
+ return sizeof(GLushort);
+ else
+ return -1;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT ||
+ format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT)
+ return sizeof(GLuint);
+ else
+ return -1;
+ case GL_UNSIGNED_SHORT_8_8_MESA:
+ case GL_UNSIGNED_SHORT_8_8_REV_MESA:
+ if (format == GL_YCBCR_MESA)
+ return sizeof(GLushort);
+ else
+ return -1;
+ case GL_UNSIGNED_INT_24_8_EXT:
+ if (format == GL_DEPTH_STENCIL_EXT)
+ return sizeof(GLuint);
+ else
+ return -1;
+ case GL_UNSIGNED_INT_5_9_9_9_REV:
+ if (format == GL_RGB)
+ return sizeof(GLuint);
+ else
+ return -1;
+ case GL_UNSIGNED_INT_10F_11F_11F_REV:
+ if (format == GL_RGB)
+ return sizeof(GLuint);
+ else
+ return -1;
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ if (format == GL_DEPTH_STENCIL)
+ return 8;
+ else
+ return -1;
+ default:
+ return -1;
+ }
+}
+
+
+/**
+ * Test if the given format is an integer (non-normalized) format.
+ */
+GLboolean
+_mesa_is_enum_format_integer(GLenum format)
+{
+ switch (format) {
+ /* generic integer formats */
+ case GL_RED_INTEGER_EXT:
+ case GL_GREEN_INTEGER_EXT:
+ case GL_BLUE_INTEGER_EXT:
+ case GL_ALPHA_INTEGER_EXT:
+ case GL_RGB_INTEGER_EXT:
+ case GL_RGBA_INTEGER_EXT:
+ case GL_BGR_INTEGER_EXT:
+ case GL_BGRA_INTEGER_EXT:
+ case GL_LUMINANCE_INTEGER_EXT:
+ case GL_LUMINANCE_ALPHA_INTEGER_EXT:
+ case GL_RG_INTEGER:
+ /* specific integer formats */
+ case GL_RGBA32UI_EXT:
+ case GL_RGB32UI_EXT:
+ case GL_RG32UI:
+ case GL_R32UI:
+ case GL_ALPHA32UI_EXT:
+ case GL_INTENSITY32UI_EXT:
+ case GL_LUMINANCE32UI_EXT:
+ case GL_LUMINANCE_ALPHA32UI_EXT:
+ case GL_RGBA16UI_EXT:
+ case GL_RGB16UI_EXT:
+ case GL_RG16UI:
+ case GL_R16UI:
+ case GL_ALPHA16UI_EXT:
+ case GL_INTENSITY16UI_EXT:
+ case GL_LUMINANCE16UI_EXT:
+ case GL_LUMINANCE_ALPHA16UI_EXT:
+ case GL_RGBA8UI_EXT:
+ case GL_RGB8UI_EXT:
+ case GL_RG8UI:
+ case GL_R8UI:
+ case GL_ALPHA8UI_EXT:
+ case GL_INTENSITY8UI_EXT:
+ case GL_LUMINANCE8UI_EXT:
+ case GL_LUMINANCE_ALPHA8UI_EXT:
+ case GL_RGBA32I_EXT:
+ case GL_RGB32I_EXT:
+ case GL_RG32I:
+ case GL_R32I:
+ case GL_ALPHA32I_EXT:
+ case GL_INTENSITY32I_EXT:
+ case GL_LUMINANCE32I_EXT:
+ case GL_LUMINANCE_ALPHA32I_EXT:
+ case GL_RGBA16I_EXT:
+ case GL_RGB16I_EXT:
+ case GL_RG16I:
+ case GL_R16I:
+ case GL_ALPHA16I_EXT:
+ case GL_INTENSITY16I_EXT:
+ case GL_LUMINANCE16I_EXT:
+ case GL_LUMINANCE_ALPHA16I_EXT:
+ case GL_RGBA8I_EXT:
+ case GL_RGB8I_EXT:
+ case GL_RG8I:
+ case GL_R8I:
+ case GL_ALPHA8I_EXT:
+ case GL_INTENSITY8I_EXT:
+ case GL_LUMINANCE8I_EXT:
+ case GL_LUMINANCE_ALPHA8I_EXT:
+ case GL_RGB10_A2UI:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if the given type is an integer (non-normalized) format.
+ */
+GLboolean
+_mesa_is_type_integer(GLenum type)
+{
+ switch (type) {
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if the given format or type is an integer (non-normalized) format.
+ */
+extern GLboolean
+_mesa_is_enum_format_or_type_integer(GLenum format, GLenum type)
+{
+ return _mesa_is_enum_format_integer(format) || _mesa_is_type_integer(type);
+}
+
+
+GLboolean
+_mesa_is_type_unsigned(GLenum type)
+{
+ switch (type) {
+ case GL_UNSIGNED_INT:
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+
+ case GL_UNSIGNED_SHORT:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ case GL_UNSIGNED_SHORT_8_8_MESA:
+ case GL_UNSIGNED_SHORT_8_8_REV_MESA:
+
+ case GL_UNSIGNED_BYTE:
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ return GL_TRUE;
+
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if the given image format is a color/RGBA format (i.e., not color
+ * index, depth, stencil, etc).
+ * \param format the image format value (may by an internal texture format)
+ * \return GL_TRUE if its a color/RGBA format, GL_FALSE otherwise.
+ */
+GLboolean
+_mesa_is_color_format(GLenum format)
+{
+ switch (format) {
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ case 1:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE4:
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ case 2:
+ case GL_LUMINANCE_ALPHA:
+ case GL_LUMINANCE4_ALPHA4:
+ case GL_LUMINANCE6_ALPHA2:
+ case GL_LUMINANCE8_ALPHA8:
+ case GL_LUMINANCE12_ALPHA4:
+ case GL_LUMINANCE12_ALPHA12:
+ case GL_LUMINANCE16_ALPHA16:
+ case GL_INTENSITY:
+ case GL_INTENSITY4:
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ case GL_R8:
+ case GL_R16:
+ case GL_RG:
+ case GL_RG8:
+ case GL_RG16:
+ case 3:
+ case GL_RGB:
+ case GL_BGR:
+ case GL_R3_G3_B2:
+ case GL_RGB4:
+ case GL_RGB5:
+ case GL_RGB565:
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ case 4:
+ case GL_ABGR_EXT:
+ case GL_RGBA:
+ case GL_BGRA:
+ case GL_RGBA2:
+ case GL_RGBA4:
+ case GL_RGB5_A1:
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ /* float texture formats */
+ case GL_ALPHA16F_ARB:
+ case GL_ALPHA32F_ARB:
+ case GL_LUMINANCE16F_ARB:
+ case GL_LUMINANCE32F_ARB:
+ case GL_LUMINANCE_ALPHA16F_ARB:
+ case GL_LUMINANCE_ALPHA32F_ARB:
+ case GL_INTENSITY16F_ARB:
+ case GL_INTENSITY32F_ARB:
+ case GL_R16F:
+ case GL_R32F:
+ case GL_RG16F:
+ case GL_RG32F:
+ case GL_RGB16F_ARB:
+ case GL_RGB32F_ARB:
+ case GL_RGBA16F_ARB:
+ case GL_RGBA32F_ARB:
+ /* compressed formats */
+ case GL_COMPRESSED_ALPHA:
+ case GL_COMPRESSED_LUMINANCE:
+ case GL_COMPRESSED_LUMINANCE_ALPHA:
+ case GL_COMPRESSED_INTENSITY:
+ case GL_COMPRESSED_RED:
+ case GL_COMPRESSED_RG:
+ case GL_COMPRESSED_RGB:
+ case GL_COMPRESSED_RGBA:
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
+#if FEATURE_EXT_texture_sRGB
+ case GL_SRGB_EXT:
+ case GL_SRGB8_EXT:
+ case GL_SRGB_ALPHA_EXT:
+ case GL_SRGB8_ALPHA8_EXT:
+ case GL_SLUMINANCE_ALPHA_EXT:
+ case GL_SLUMINANCE8_ALPHA8_EXT:
+ case GL_SLUMINANCE_EXT:
+ case GL_SLUMINANCE8_EXT:
+ case GL_COMPRESSED_SRGB_EXT:
+ case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
+ case GL_COMPRESSED_SLUMINANCE_EXT:
+ case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
+#endif /* FEATURE_EXT_texture_sRGB */
+ case GL_COMPRESSED_RED_RGTC1:
+ case GL_COMPRESSED_SIGNED_RED_RGTC1:
+ case GL_COMPRESSED_RG_RGTC2:
+ case GL_COMPRESSED_SIGNED_RG_RGTC2:
+ case GL_COMPRESSED_LUMINANCE_LATC1_EXT:
+ case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT:
+ case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:
+ case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:
+ case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
+ case GL_ETC1_RGB8_OES:
+ /* generic integer formats */
+ case GL_RED_INTEGER_EXT:
+ case GL_GREEN_INTEGER_EXT:
+ case GL_BLUE_INTEGER_EXT:
+ case GL_ALPHA_INTEGER_EXT:
+ case GL_RGB_INTEGER_EXT:
+ case GL_RGBA_INTEGER_EXT:
+ case GL_BGR_INTEGER_EXT:
+ case GL_BGRA_INTEGER_EXT:
+ case GL_RG_INTEGER:
+ case GL_LUMINANCE_INTEGER_EXT:
+ case GL_LUMINANCE_ALPHA_INTEGER_EXT:
+ /* sized integer formats */
+ case GL_RGBA32UI_EXT:
+ case GL_RGB32UI_EXT:
+ case GL_RG32UI:
+ case GL_R32UI:
+ case GL_ALPHA32UI_EXT:
+ case GL_INTENSITY32UI_EXT:
+ case GL_LUMINANCE32UI_EXT:
+ case GL_LUMINANCE_ALPHA32UI_EXT:
+ case GL_RGBA16UI_EXT:
+ case GL_RGB16UI_EXT:
+ case GL_RG16UI:
+ case GL_R16UI:
+ case GL_ALPHA16UI_EXT:
+ case GL_INTENSITY16UI_EXT:
+ case GL_LUMINANCE16UI_EXT:
+ case GL_LUMINANCE_ALPHA16UI_EXT:
+ case GL_RGBA8UI_EXT:
+ case GL_RGB8UI_EXT:
+ case GL_RG8UI:
+ case GL_R8UI:
+ case GL_ALPHA8UI_EXT:
+ case GL_INTENSITY8UI_EXT:
+ case GL_LUMINANCE8UI_EXT:
+ case GL_LUMINANCE_ALPHA8UI_EXT:
+ case GL_RGBA32I_EXT:
+ case GL_RGB32I_EXT:
+ case GL_RG32I:
+ case GL_R32I:
+ case GL_ALPHA32I_EXT:
+ case GL_INTENSITY32I_EXT:
+ case GL_LUMINANCE32I_EXT:
+ case GL_LUMINANCE_ALPHA32I_EXT:
+ case GL_RGBA16I_EXT:
+ case GL_RGB16I_EXT:
+ case GL_RG16I:
+ case GL_R16I:
+ case GL_ALPHA16I_EXT:
+ case GL_INTENSITY16I_EXT:
+ case GL_LUMINANCE16I_EXT:
+ case GL_LUMINANCE_ALPHA16I_EXT:
+ case GL_RGBA8I_EXT:
+ case GL_RGB8I_EXT:
+ case GL_RG8I:
+ case GL_R8I:
+ case GL_ALPHA8I_EXT:
+ case GL_INTENSITY8I_EXT:
+ case GL_LUMINANCE8I_EXT:
+ case GL_LUMINANCE_ALPHA8I_EXT:
+ /* signed, normalized texture formats */
+ case GL_RED_SNORM:
+ case GL_R8_SNORM:
+ case GL_R16_SNORM:
+ case GL_RG_SNORM:
+ case GL_RG8_SNORM:
+ case GL_RG16_SNORM:
+ case GL_RGB_SNORM:
+ case GL_RGB8_SNORM:
+ case GL_RGB16_SNORM:
+ case GL_RGBA_SNORM:
+ case GL_RGBA8_SNORM:
+ case GL_RGBA16_SNORM:
+ case GL_ALPHA_SNORM:
+ case GL_ALPHA8_SNORM:
+ case GL_ALPHA16_SNORM:
+ case GL_LUMINANCE_SNORM:
+ case GL_LUMINANCE8_SNORM:
+ case GL_LUMINANCE16_SNORM:
+ case GL_LUMINANCE_ALPHA_SNORM:
+ case GL_LUMINANCE8_ALPHA8_SNORM:
+ case GL_LUMINANCE16_ALPHA16_SNORM:
+ case GL_INTENSITY_SNORM:
+ case GL_INTENSITY8_SNORM:
+ case GL_INTENSITY16_SNORM:
+ case GL_RGB9_E5:
+ case GL_R11F_G11F_B10F:
+ case GL_RGB10_A2UI:
+ return GL_TRUE;
+ case GL_YCBCR_MESA: /* not considered to be RGB */
+ /* fall-through */
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if the given image format is a depth component format.
+ */
+GLboolean
+_mesa_is_depth_format(GLenum format)
+{
+ switch (format) {
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_COMPONENT16:
+ case GL_DEPTH_COMPONENT24:
+ case GL_DEPTH_COMPONENT32:
+ case GL_DEPTH_COMPONENT32F:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if the given image format is a stencil format.
+ */
+GLboolean
+_mesa_is_stencil_format(GLenum format)
+{
+ switch (format) {
+ case GL_STENCIL_INDEX:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if the given image format is a YCbCr format.
+ */
+GLboolean
+_mesa_is_ycbcr_format(GLenum format)
+{
+ switch (format) {
+ case GL_YCBCR_MESA:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if the given image format is a depth+stencil format.
+ */
+GLboolean
+_mesa_is_depthstencil_format(GLenum format)
+{
+ switch (format) {
+ case GL_DEPTH24_STENCIL8_EXT:
+ case GL_DEPTH_STENCIL_EXT:
+ case GL_DEPTH32F_STENCIL8:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if the given image format is a depth or stencil format.
+ */
+GLboolean
+_mesa_is_depth_or_stencil_format(GLenum format)
+{
+ switch (format) {
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_COMPONENT16:
+ case GL_DEPTH_COMPONENT24:
+ case GL_DEPTH_COMPONENT32:
+ case GL_STENCIL_INDEX:
+ case GL_STENCIL_INDEX1_EXT:
+ case GL_STENCIL_INDEX4_EXT:
+ case GL_STENCIL_INDEX8_EXT:
+ case GL_STENCIL_INDEX16_EXT:
+ case GL_DEPTH_STENCIL_EXT:
+ case GL_DEPTH24_STENCIL8_EXT:
+ case GL_DEPTH_COMPONENT32F:
+ case GL_DEPTH32F_STENCIL8:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if the given image format is a dudv format.
+ */
+GLboolean
+_mesa_is_dudv_format(GLenum format)
+{
+ switch (format) {
+ case GL_DUDV_ATI:
+ case GL_DU8DV8_ATI:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if an image format is a supported compressed format.
+ * \param format the internal format token provided by the user.
+ * \return GL_TRUE if compressed, GL_FALSE if uncompressed
+ */
+GLboolean
+_mesa_is_compressed_format(struct gl_context *ctx, GLenum format)
+{
+ switch (format) {
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ return ctx->Extensions.EXT_texture_compression_s3tc;
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ return ctx->Extensions.S3_s3tc;
+ case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
+ return ctx->Extensions.EXT_texture_sRGB
+ && ctx->Extensions.EXT_texture_compression_s3tc;
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ return ctx->Extensions.TDFX_texture_compression_FXT1;
+ case GL_COMPRESSED_RED_RGTC1:
+ case GL_COMPRESSED_SIGNED_RED_RGTC1:
+ case GL_COMPRESSED_RG_RGTC2:
+ case GL_COMPRESSED_SIGNED_RG_RGTC2:
+ return ctx->Extensions.ARB_texture_compression_rgtc;
+ case GL_COMPRESSED_LUMINANCE_LATC1_EXT:
+ case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT:
+ case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:
+ case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:
+ return ctx->Extensions.EXT_texture_compression_latc;
+ case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
+ return ctx->Extensions.ATI_texture_compression_3dc;
+ case GL_ETC1_RGB8_OES:
+ return ctx->Extensions.OES_compressed_ETC1_RGB8_texture;
+#if FEATURE_ES
+ case GL_PALETTE4_RGB8_OES:
+ case GL_PALETTE4_RGBA8_OES:
+ case GL_PALETTE4_R5_G6_B5_OES:
+ case GL_PALETTE4_RGBA4_OES:
+ case GL_PALETTE4_RGB5_A1_OES:
+ case GL_PALETTE8_RGB8_OES:
+ case GL_PALETTE8_RGBA8_OES:
+ case GL_PALETTE8_R5_G6_B5_OES:
+ case GL_PALETTE8_RGBA4_OES:
+ case GL_PALETTE8_RGB5_A1_OES:
+ return ctx->API == API_OPENGLES;
+#endif
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Convert various base formats to the cooresponding integer format.
+ */
+GLenum
+_mesa_base_format_to_integer_format(GLenum format)
+{
+ switch(format) {
+ case GL_RED:
+ return GL_RED_INTEGER;
+ case GL_GREEN:
+ return GL_GREEN_INTEGER;
+ case GL_BLUE:
+ return GL_BLUE_INTEGER;
+ case GL_RG:
+ return GL_RG_INTEGER;
+ case GL_RGB:
+ return GL_RGB_INTEGER;
+ case GL_RGBA:
+ return GL_RGBA_INTEGER;
+ case GL_BGR:
+ return GL_BGR_INTEGER;
+ case GL_BGRA:
+ return GL_BGRA_INTEGER;
+ case GL_ALPHA:
+ return GL_ALPHA_INTEGER;
+ case GL_LUMINANCE:
+ return GL_LUMINANCE_INTEGER_EXT;
+ case GL_LUMINANCE_ALPHA:
+ return GL_LUMINANCE_ALPHA_INTEGER_EXT;
+ }
+
+ return format;
+}
+
+
+/**
+ * Does the given base texture/renderbuffer format have the channel
+ * named by 'pname'?
+ */
+GLboolean
+_mesa_base_format_has_channel(GLenum base_format, GLenum pname)
+{
+ switch (pname) {
+ case GL_TEXTURE_RED_SIZE:
+ case GL_TEXTURE_RED_TYPE:
+ case GL_RENDERBUFFER_RED_SIZE_EXT:
+ case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
+ if (base_format == GL_RED ||
+ base_format == GL_RG ||
+ base_format == GL_RGB ||
+ base_format == GL_RGBA) {
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+ case GL_TEXTURE_GREEN_SIZE:
+ case GL_TEXTURE_GREEN_TYPE:
+ case GL_RENDERBUFFER_GREEN_SIZE_EXT:
+ case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
+ if (base_format == GL_RG ||
+ base_format == GL_RGB ||
+ base_format == GL_RGBA) {
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+ case GL_TEXTURE_BLUE_SIZE:
+ case GL_TEXTURE_BLUE_TYPE:
+ case GL_RENDERBUFFER_BLUE_SIZE_EXT:
+ case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
+ if (base_format == GL_RGB ||
+ base_format == GL_RGBA) {
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+ case GL_TEXTURE_ALPHA_SIZE:
+ case GL_TEXTURE_ALPHA_TYPE:
+ case GL_RENDERBUFFER_ALPHA_SIZE_EXT:
+ case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
+ if (base_format == GL_RGBA ||
+ base_format == GL_ALPHA ||
+ base_format == GL_LUMINANCE_ALPHA) {
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+ case GL_TEXTURE_LUMINANCE_SIZE:
+ case GL_TEXTURE_LUMINANCE_TYPE:
+ if (base_format == GL_LUMINANCE ||
+ base_format == GL_LUMINANCE_ALPHA) {
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+ case GL_TEXTURE_INTENSITY_SIZE:
+ case GL_TEXTURE_INTENSITY_TYPE:
+ if (base_format == GL_INTENSITY) {
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+ case GL_TEXTURE_DEPTH_SIZE:
+ case GL_TEXTURE_DEPTH_TYPE:
+ case GL_RENDERBUFFER_DEPTH_SIZE_EXT:
+ case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
+ if (base_format == GL_DEPTH_STENCIL ||
+ base_format == GL_DEPTH_COMPONENT) {
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+ case GL_RENDERBUFFER_STENCIL_SIZE_EXT:
+ case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
+ if (base_format == GL_DEPTH_STENCIL ||
+ base_format == GL_STENCIL_INDEX) {
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+ default:
+ _mesa_warning(NULL, "%s: Unexpected channel token 0x%x\n",
+ __FUNCTION__, pname);
+ return GL_FALSE;
+ }
+
+ return GL_FALSE;
+}
+
+
+/**
+ * Do error checking of format/type combinations for glReadPixels,
+ * glDrawPixels and glTex[Sub]Image. Note that depending on the format
+ * and type values, we may either generate GL_INVALID_OPERATION or
+ * GL_INVALID_ENUM.
+ *
+ * \param format pixel format.
+ * \param type pixel type.
+ *
+ * \return GL_INVALID_ENUM, GL_INVALID_OPERATION or GL_NO_ERROR
+ */
+GLenum
+_mesa_error_check_format_and_type(const struct gl_context *ctx,
+ GLenum format, GLenum type)
+{
+ /* special type-based checks (see glReadPixels, glDrawPixels error lists) */
+ switch (type) {
+ case GL_BITMAP:
+ if (format != GL_COLOR_INDEX && format != GL_STENCIL_INDEX) {
+ return GL_INVALID_ENUM;
+ }
+ break;
+
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ if (format == GL_RGB) {
+ break; /* OK */
+ }
+ if (format == GL_RGB_INTEGER_EXT &&
+ ctx->Extensions.ARB_texture_rgb10_a2ui) {
+ break; /* OK */
+ }
+ return GL_INVALID_OPERATION;
+
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ if (format == GL_RGBA ||
+ format == GL_BGRA ||
+ format == GL_ABGR_EXT) {
+ break; /* OK */
+ }
+ if ((format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT) &&
+ ctx->Extensions.ARB_texture_rgb10_a2ui) {
+ break; /* OK */
+ }
+ return GL_INVALID_OPERATION;
+
+ case GL_UNSIGNED_INT_24_8:
+ if (!ctx->Extensions.EXT_packed_depth_stencil) {
+ return GL_INVALID_ENUM;
+ }
+ if (format != GL_DEPTH_STENCIL) {
+ return GL_INVALID_OPERATION;
+ }
+ return GL_NO_ERROR;
+
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ if (!ctx->Extensions.ARB_depth_buffer_float) {
+ return GL_INVALID_ENUM;
+ }
+ if (format != GL_DEPTH_STENCIL) {
+ return GL_INVALID_OPERATION;
+ }
+ return GL_NO_ERROR;
+
+ case GL_UNSIGNED_INT_10F_11F_11F_REV:
+ if (!ctx->Extensions.EXT_packed_float) {
+ return GL_INVALID_ENUM;
+ }
+ if (format != GL_RGB) {
+ return GL_INVALID_OPERATION;
+ }
+ return GL_NO_ERROR;
+
+ default:
+ ; /* fall-through */
+ }
+
+ /* now, for each format, check the type for compatibility */
+ switch (format) {
+ case GL_COLOR_INDEX:
+ case GL_STENCIL_INDEX:
+ switch (type) {
+ case GL_BITMAP:
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ return GL_NO_ERROR;
+ case GL_HALF_FLOAT:
+ return ctx->Extensions.ARB_half_float_pixel
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
+ default:
+ return GL_INVALID_ENUM;
+ }
+
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+#if 0 /* not legal! see table 3.6 of the 1.5 spec */
+ case GL_INTENSITY:
+#endif
+ case GL_LUMINANCE:
+ case GL_LUMINANCE_ALPHA:
+ case GL_DEPTH_COMPONENT:
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ return GL_NO_ERROR;
+ case GL_HALF_FLOAT:
+ return ctx->Extensions.ARB_half_float_pixel
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
+ default:
+ return GL_INVALID_ENUM;
+ }
+
+ case GL_RG:
+ if (!ctx->Extensions.ARB_texture_rg)
+ return GL_INVALID_ENUM;
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ return GL_NO_ERROR;
+ case GL_HALF_FLOAT:
+ return ctx->Extensions.ARB_half_float_pixel
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
+ default:
+ return GL_INVALID_ENUM;
+ }
+
+ case GL_RGB:
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ return GL_NO_ERROR;
+ case GL_HALF_FLOAT:
+ return ctx->Extensions.ARB_half_float_pixel
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
+ case GL_UNSIGNED_INT_5_9_9_9_REV:
+ return ctx->Extensions.EXT_texture_shared_exponent
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
+ case GL_UNSIGNED_INT_10F_11F_11F_REV:
+ return ctx->Extensions.EXT_packed_float
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
+ default:
+ return GL_INVALID_ENUM;
+ }
+
+ case GL_BGR:
+ switch (type) {
+ /* NOTE: no packed types are supported with BGR. That's
+ * intentional, according to the GL spec.
+ */
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ return GL_NO_ERROR;
+ case GL_HALF_FLOAT:
+ return ctx->Extensions.ARB_half_float_pixel
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
+ default:
+ return GL_INVALID_ENUM;
+ }
+
+ case GL_RGBA:
+ case GL_BGRA:
+ case GL_ABGR_EXT:
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ return GL_NO_ERROR;
+ case GL_HALF_FLOAT:
+ return ctx->Extensions.ARB_half_float_pixel
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
+ default:
+ return GL_INVALID_ENUM;
+ }
+
+ case GL_YCBCR_MESA:
+ if (!ctx->Extensions.MESA_ycbcr_texture)
+ return GL_INVALID_ENUM;
+ if (type == GL_UNSIGNED_SHORT_8_8_MESA ||
+ type == GL_UNSIGNED_SHORT_8_8_REV_MESA)
+ return GL_NO_ERROR;
+ else
+ return GL_INVALID_OPERATION;
+
+ case GL_DEPTH_STENCIL_EXT:
+ if (ctx->Extensions.EXT_packed_depth_stencil &&
+ type == GL_UNSIGNED_INT_24_8)
+ return GL_NO_ERROR;
+ else if (ctx->Extensions.ARB_depth_buffer_float &&
+ type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV)
+ return GL_NO_ERROR;
+ else
+ return GL_INVALID_ENUM;
+
+ case GL_DUDV_ATI:
+ case GL_DU8DV8_ATI:
+ if (!ctx->Extensions.ATI_envmap_bumpmap)
+ return GL_INVALID_ENUM;
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ return GL_NO_ERROR;
+ default:
+ return GL_INVALID_ENUM;
+ }
+
+ /* integer-valued formats */
+ case GL_RED_INTEGER_EXT:
+ case GL_GREEN_INTEGER_EXT:
+ case GL_BLUE_INTEGER_EXT:
+ case GL_ALPHA_INTEGER_EXT:
+ case GL_RG_INTEGER:
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ return (ctx->VersionMajor >= 3 ||
+ ctx->Extensions.EXT_texture_integer)
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
+ default:
+ return GL_INVALID_ENUM;
+ }
+
+ case GL_RGB_INTEGER_EXT:
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ return (ctx->VersionMajor >= 3 ||
+ ctx->Extensions.EXT_texture_integer)
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ return ctx->Extensions.ARB_texture_rgb10_a2ui
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
+ default:
+ return GL_INVALID_ENUM;
+ }
+
+ case GL_BGR_INTEGER_EXT:
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ /* NOTE: no packed formats w/ BGR format */
+ return (ctx->VersionMajor >= 3 ||
+ ctx->Extensions.EXT_texture_integer)
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
+ default:
+ return GL_INVALID_ENUM;
+ }
+
+ case GL_RGBA_INTEGER_EXT:
+ case GL_BGRA_INTEGER_EXT:
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ return (ctx->VersionMajor >= 3 ||
+ ctx->Extensions.EXT_texture_integer)
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ return ctx->Extensions.ARB_texture_rgb10_a2ui
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
+ default:
+ return GL_INVALID_ENUM;
+ }
+
+ case GL_LUMINANCE_INTEGER_EXT:
+ case GL_LUMINANCE_ALPHA_INTEGER_EXT:
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ return ctx->Extensions.EXT_texture_integer
+ ? GL_NO_ERROR : GL_INVALID_ENUM;
+ default:
+ return GL_INVALID_ENUM;
+ }
+
+ default:
+ return GL_INVALID_ENUM;
+ }
+ return GL_NO_ERROR;
+}
diff --git a/mesalib/src/mesa/main/glformats.h b/mesalib/src/mesa/main/glformats.h
new file mode 100644
index 000000000..d553eae0a
--- /dev/null
+++ b/mesalib/src/mesa/main/glformats.h
@@ -0,0 +1,103 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
+ * Copyright (c) 2008-2009 VMware, Inc.
+ * Copyright (c) 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 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 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef GLFORMATS_H
+#define GLFORMATS_H
+
+
+#include <GL/gl.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern GLboolean
+_mesa_type_is_packed(GLenum type);
+
+extern GLint
+_mesa_sizeof_type( GLenum type );
+
+extern GLint
+_mesa_sizeof_packed_type( GLenum type );
+
+extern GLint
+_mesa_components_in_format( GLenum format );
+
+extern GLint
+_mesa_bytes_per_pixel( GLenum format, GLenum type );
+
+extern GLboolean
+_mesa_is_type_integer(GLenum type);
+
+extern GLboolean
+_mesa_is_type_unsigned(GLenum type);
+
+extern GLboolean
+_mesa_is_enum_format_integer(GLenum format);
+
+extern GLboolean
+_mesa_is_enum_format_or_type_integer(GLenum format, GLenum type);
+
+extern GLboolean
+_mesa_is_color_format(GLenum format);
+
+extern GLboolean
+_mesa_is_depth_format(GLenum format);
+
+extern GLboolean
+_mesa_is_stencil_format(GLenum format);
+
+extern GLboolean
+_mesa_is_ycbcr_format(GLenum format);
+
+extern GLboolean
+_mesa_is_depthstencil_format(GLenum format);
+
+extern GLboolean
+_mesa_is_depth_or_stencil_format(GLenum format);
+
+extern GLboolean
+_mesa_is_dudv_format(GLenum format);
+
+extern GLboolean
+_mesa_is_compressed_format(struct gl_context *ctx, GLenum format);
+
+extern GLenum
+_mesa_base_format_to_integer_format(GLenum format);
+
+extern GLboolean
+_mesa_base_format_has_channel(GLenum base_format, GLenum pname);
+
+extern GLenum
+_mesa_error_check_format_and_type(const struct gl_context *ctx,
+ GLenum format, GLenum type);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GLFORMATS_H */
diff --git a/mesalib/src/mesa/main/image.c b/mesalib/src/mesa/main/image.c
index 678dfeb2b..91b720373 100644
--- a/mesalib/src/mesa/main/image.c
+++ b/mesalib/src/mesa/main/image.c
@@ -32,6 +32,7 @@
#include "glheader.h"
#include "colormac.h"
+#include "glformats.h"
#include "image.h"
#include "imports.h"
#include "macros.h"
@@ -41,40 +42,6 @@
/**
- * \return GL_TRUE if type is packed pixel type, GL_FALSE otherwise.
- */
-GLboolean
-_mesa_type_is_packed(GLenum type)
-{
- switch (type) {
- case GL_UNSIGNED_BYTE_3_3_2:
- case GL_UNSIGNED_BYTE_2_3_3_REV:
- case MESA_UNSIGNED_BYTE_4_4:
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- case GL_UNSIGNED_INT_8_8_8_8:
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- case GL_UNSIGNED_INT_10_10_10_2:
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- case GL_UNSIGNED_SHORT_8_8_MESA:
- case GL_UNSIGNED_SHORT_8_8_REV_MESA:
- case GL_UNSIGNED_INT_24_8_EXT:
- case GL_UNSIGNED_INT_5_9_9_9_REV:
- case GL_UNSIGNED_INT_10F_11F_11F_REV:
- case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
- return GL_TRUE;
- }
-
- return GL_FALSE;
-}
-
-
-
-/**
* Flip the order of the 2 bytes in each word in the given array.
*
* \param p array.
@@ -110,1178 +77,6 @@ _mesa_swap4( GLuint *p, GLuint n )
/**
- * Get the size of a GL data type.
- *
- * \param type GL data type.
- *
- * \return the size, in bytes, of the given data type, 0 if a GL_BITMAP, or -1
- * if an invalid type enum.
- */
-GLint
-_mesa_sizeof_type( GLenum type )
-{
- switch (type) {
- case GL_BITMAP:
- return 0;
- case GL_UNSIGNED_BYTE:
- return sizeof(GLubyte);
- case GL_BYTE:
- return sizeof(GLbyte);
- case GL_UNSIGNED_SHORT:
- return sizeof(GLushort);
- case GL_SHORT:
- return sizeof(GLshort);
- case GL_UNSIGNED_INT:
- return sizeof(GLuint);
- case GL_INT:
- return sizeof(GLint);
- case GL_FLOAT:
- return sizeof(GLfloat);
- case GL_DOUBLE:
- return sizeof(GLdouble);
- case GL_HALF_FLOAT_ARB:
- return sizeof(GLhalfARB);
- case GL_FIXED:
- return sizeof(GLfixed);
- default:
- return -1;
- }
-}
-
-
-/**
- * Same as _mesa_sizeof_type() but also accepting the packed pixel
- * format data types.
- */
-GLint
-_mesa_sizeof_packed_type( GLenum type )
-{
- switch (type) {
- case GL_BITMAP:
- return 0;
- case GL_UNSIGNED_BYTE:
- return sizeof(GLubyte);
- case GL_BYTE:
- return sizeof(GLbyte);
- case GL_UNSIGNED_SHORT:
- return sizeof(GLushort);
- case GL_SHORT:
- return sizeof(GLshort);
- case GL_UNSIGNED_INT:
- return sizeof(GLuint);
- case GL_INT:
- return sizeof(GLint);
- case GL_HALF_FLOAT_ARB:
- return sizeof(GLhalfARB);
- case GL_FLOAT:
- return sizeof(GLfloat);
- case GL_UNSIGNED_BYTE_3_3_2:
- case GL_UNSIGNED_BYTE_2_3_3_REV:
- case MESA_UNSIGNED_BYTE_4_4:
- return sizeof(GLubyte);
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- case GL_UNSIGNED_SHORT_8_8_MESA:
- case GL_UNSIGNED_SHORT_8_8_REV_MESA:
- return sizeof(GLushort);
- case GL_UNSIGNED_INT_8_8_8_8:
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- case GL_UNSIGNED_INT_10_10_10_2:
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- case GL_UNSIGNED_INT_24_8_EXT:
- case GL_UNSIGNED_INT_5_9_9_9_REV:
- case GL_UNSIGNED_INT_10F_11F_11F_REV:
- return sizeof(GLuint);
- case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
- return 8;
- default:
- return -1;
- }
-}
-
-
-/**
- * Get the number of components in a pixel format.
- *
- * \param format pixel format.
- *
- * \return the number of components in the given format, or -1 if a bad format.
- */
-GLint
-_mesa_components_in_format( GLenum format )
-{
- switch (format) {
- case GL_COLOR_INDEX:
- case GL_STENCIL_INDEX:
- case GL_DEPTH_COMPONENT:
- case GL_RED:
- case GL_RED_INTEGER_EXT:
- case GL_GREEN:
- case GL_GREEN_INTEGER_EXT:
- case GL_BLUE:
- case GL_BLUE_INTEGER_EXT:
- case GL_ALPHA:
- case GL_ALPHA_INTEGER_EXT:
- case GL_LUMINANCE:
- case GL_LUMINANCE_INTEGER_EXT:
- case GL_INTENSITY:
- return 1;
-
- case GL_LUMINANCE_ALPHA:
- case GL_LUMINANCE_ALPHA_INTEGER_EXT:
- case GL_RG:
- case GL_YCBCR_MESA:
- case GL_DEPTH_STENCIL_EXT:
- case GL_DUDV_ATI:
- case GL_DU8DV8_ATI:
- case GL_RG_INTEGER:
- return 2;
-
- case GL_RGB:
- case GL_BGR:
- case GL_RGB_INTEGER_EXT:
- case GL_BGR_INTEGER_EXT:
- return 3;
-
- case GL_RGBA:
- case GL_BGRA:
- case GL_ABGR_EXT:
- case GL_RGBA_INTEGER_EXT:
- case GL_BGRA_INTEGER_EXT:
- return 4;
-
- default:
- return -1;
- }
-}
-
-
-/**
- * Get the bytes per pixel of pixel format type pair.
- *
- * \param format pixel format.
- * \param type pixel type.
- *
- * \return bytes per pixel, or -1 if a bad format or type was given.
- */
-GLint
-_mesa_bytes_per_pixel( GLenum format, GLenum type )
-{
- GLint comps = _mesa_components_in_format( format );
- if (comps < 0)
- return -1;
-
- switch (type) {
- case GL_BITMAP:
- return 0; /* special case */
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- return comps * sizeof(GLubyte);
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- return comps * sizeof(GLshort);
- case GL_INT:
- case GL_UNSIGNED_INT:
- return comps * sizeof(GLint);
- case GL_FLOAT:
- return comps * sizeof(GLfloat);
- case GL_HALF_FLOAT_ARB:
- return comps * sizeof(GLhalfARB);
- case GL_UNSIGNED_BYTE_3_3_2:
- case GL_UNSIGNED_BYTE_2_3_3_REV:
- if (format == GL_RGB || format == GL_BGR ||
- format == GL_RGB_INTEGER_EXT || format == GL_BGR_INTEGER_EXT)
- return sizeof(GLubyte);
- else
- return -1; /* error */
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- if (format == GL_RGB || format == GL_BGR ||
- format == GL_RGB_INTEGER_EXT || format == GL_BGR_INTEGER_EXT)
- return sizeof(GLushort);
- else
- return -1; /* error */
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT ||
- format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT)
- return sizeof(GLushort);
- else
- return -1;
- case GL_UNSIGNED_INT_8_8_8_8:
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- case GL_UNSIGNED_INT_10_10_10_2:
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT ||
- format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT)
- return sizeof(GLuint);
- else
- return -1;
- case GL_UNSIGNED_SHORT_8_8_MESA:
- case GL_UNSIGNED_SHORT_8_8_REV_MESA:
- if (format == GL_YCBCR_MESA)
- return sizeof(GLushort);
- else
- return -1;
- case GL_UNSIGNED_INT_24_8_EXT:
- if (format == GL_DEPTH_STENCIL_EXT)
- return sizeof(GLuint);
- else
- return -1;
- case GL_UNSIGNED_INT_5_9_9_9_REV:
- if (format == GL_RGB)
- return sizeof(GLuint);
- else
- return -1;
- case GL_UNSIGNED_INT_10F_11F_11F_REV:
- if (format == GL_RGB)
- return sizeof(GLuint);
- else
- return -1;
- case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
- if (format == GL_DEPTH_STENCIL)
- return 8;
- else
- return -1;
- default:
- return -1;
- }
-}
-
-
-/**
- * Do error checking of format/type combinations for glReadPixels,
- * glDrawPixels and glTex[Sub]Image. Note that depending on the format
- * and type values, we may either generate GL_INVALID_OPERATION or
- * GL_INVALID_ENUM.
- *
- * \param format pixel format.
- * \param type pixel type.
- *
- * \return GL_INVALID_ENUM, GL_INVALID_OPERATION or GL_NO_ERROR
- */
-GLenum
-_mesa_error_check_format_and_type(const struct gl_context *ctx,
- GLenum format, GLenum type)
-{
- /* special type-based checks (see glReadPixels, glDrawPixels error lists) */
- switch (type) {
- case GL_BITMAP:
- if (format != GL_COLOR_INDEX && format != GL_STENCIL_INDEX) {
- return GL_INVALID_ENUM;
- }
- break;
-
- case GL_UNSIGNED_BYTE_3_3_2:
- case GL_UNSIGNED_BYTE_2_3_3_REV:
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- if (format == GL_RGB) {
- break; /* OK */
- }
- if (format == GL_RGB_INTEGER_EXT &&
- ctx->Extensions.ARB_texture_rgb10_a2ui) {
- break; /* OK */
- }
- return GL_INVALID_OPERATION;
-
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- case GL_UNSIGNED_INT_8_8_8_8:
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- case GL_UNSIGNED_INT_10_10_10_2:
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- if (format == GL_RGBA ||
- format == GL_BGRA ||
- format == GL_ABGR_EXT) {
- break; /* OK */
- }
- if ((format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT) &&
- ctx->Extensions.ARB_texture_rgb10_a2ui) {
- break; /* OK */
- }
- return GL_INVALID_OPERATION;
-
- case GL_UNSIGNED_INT_24_8:
- if (!ctx->Extensions.EXT_packed_depth_stencil) {
- return GL_INVALID_ENUM;
- }
- if (format != GL_DEPTH_STENCIL) {
- return GL_INVALID_OPERATION;
- }
- return GL_NO_ERROR;
-
- case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
- if (!ctx->Extensions.ARB_depth_buffer_float) {
- return GL_INVALID_ENUM;
- }
- if (format != GL_DEPTH_STENCIL) {
- return GL_INVALID_OPERATION;
- }
- return GL_NO_ERROR;
-
- case GL_UNSIGNED_INT_10F_11F_11F_REV:
- if (!ctx->Extensions.EXT_packed_float) {
- return GL_INVALID_ENUM;
- }
- if (format != GL_RGB) {
- return GL_INVALID_OPERATION;
- }
- return GL_NO_ERROR;
-
- default:
- ; /* fall-through */
- }
-
- /* now, for each format, check the type for compatibility */
- switch (format) {
- case GL_COLOR_INDEX:
- case GL_STENCIL_INDEX:
- switch (type) {
- case GL_BITMAP:
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- return GL_NO_ERROR;
- case GL_HALF_FLOAT:
- return ctx->Extensions.ARB_half_float_pixel
- ? GL_NO_ERROR : GL_INVALID_ENUM;
- default:
- return GL_INVALID_ENUM;
- }
-
- case GL_RED:
- case GL_GREEN:
- case GL_BLUE:
- case GL_ALPHA:
-#if 0 /* not legal! see table 3.6 of the 1.5 spec */
- case GL_INTENSITY:
-#endif
- case GL_LUMINANCE:
- case GL_LUMINANCE_ALPHA:
- case GL_DEPTH_COMPONENT:
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- return GL_NO_ERROR;
- case GL_HALF_FLOAT:
- return ctx->Extensions.ARB_half_float_pixel
- ? GL_NO_ERROR : GL_INVALID_ENUM;
- default:
- return GL_INVALID_ENUM;
- }
-
- case GL_RG:
- if (!ctx->Extensions.ARB_texture_rg)
- return GL_INVALID_ENUM;
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- return GL_NO_ERROR;
- case GL_HALF_FLOAT:
- return ctx->Extensions.ARB_half_float_pixel
- ? GL_NO_ERROR : GL_INVALID_ENUM;
- default:
- return GL_INVALID_ENUM;
- }
-
- case GL_RGB:
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- case GL_UNSIGNED_BYTE_3_3_2:
- case GL_UNSIGNED_BYTE_2_3_3_REV:
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- return GL_NO_ERROR;
- case GL_HALF_FLOAT:
- return ctx->Extensions.ARB_half_float_pixel
- ? GL_NO_ERROR : GL_INVALID_ENUM;
- case GL_UNSIGNED_INT_5_9_9_9_REV:
- return ctx->Extensions.EXT_texture_shared_exponent
- ? GL_NO_ERROR : GL_INVALID_ENUM;
- case GL_UNSIGNED_INT_10F_11F_11F_REV:
- return ctx->Extensions.EXT_packed_float
- ? GL_NO_ERROR : GL_INVALID_ENUM;
- default:
- return GL_INVALID_ENUM;
- }
-
- case GL_BGR:
- switch (type) {
- /* NOTE: no packed types are supported with BGR. That's
- * intentional, according to the GL spec.
- */
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- return GL_NO_ERROR;
- case GL_HALF_FLOAT:
- return ctx->Extensions.ARB_half_float_pixel
- ? GL_NO_ERROR : GL_INVALID_ENUM;
- default:
- return GL_INVALID_ENUM;
- }
-
- case GL_RGBA:
- case GL_BGRA:
- case GL_ABGR_EXT:
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- case GL_UNSIGNED_INT_8_8_8_8:
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- case GL_UNSIGNED_INT_10_10_10_2:
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- return GL_NO_ERROR;
- case GL_HALF_FLOAT:
- return ctx->Extensions.ARB_half_float_pixel
- ? GL_NO_ERROR : GL_INVALID_ENUM;
- default:
- return GL_INVALID_ENUM;
- }
-
- case GL_YCBCR_MESA:
- if (!ctx->Extensions.MESA_ycbcr_texture)
- return GL_INVALID_ENUM;
- if (type == GL_UNSIGNED_SHORT_8_8_MESA ||
- type == GL_UNSIGNED_SHORT_8_8_REV_MESA)
- return GL_NO_ERROR;
- else
- return GL_INVALID_OPERATION;
-
- case GL_DEPTH_STENCIL_EXT:
- if (ctx->Extensions.EXT_packed_depth_stencil &&
- type == GL_UNSIGNED_INT_24_8)
- return GL_NO_ERROR;
- else if (ctx->Extensions.ARB_depth_buffer_float &&
- type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV)
- return GL_NO_ERROR;
- else
- return GL_INVALID_ENUM;
-
- case GL_DUDV_ATI:
- case GL_DU8DV8_ATI:
- if (!ctx->Extensions.ATI_envmap_bumpmap)
- return GL_INVALID_ENUM;
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- return GL_NO_ERROR;
- default:
- return GL_INVALID_ENUM;
- }
-
- /* integer-valued formats */
- case GL_RED_INTEGER_EXT:
- case GL_GREEN_INTEGER_EXT:
- case GL_BLUE_INTEGER_EXT:
- case GL_ALPHA_INTEGER_EXT:
- case GL_RG_INTEGER:
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- return (ctx->VersionMajor >= 3 ||
- ctx->Extensions.EXT_texture_integer)
- ? GL_NO_ERROR : GL_INVALID_ENUM;
- default:
- return GL_INVALID_ENUM;
- }
-
- case GL_RGB_INTEGER_EXT:
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- return (ctx->VersionMajor >= 3 ||
- ctx->Extensions.EXT_texture_integer)
- ? GL_NO_ERROR : GL_INVALID_ENUM;
- case GL_UNSIGNED_BYTE_3_3_2:
- case GL_UNSIGNED_BYTE_2_3_3_REV:
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- return ctx->Extensions.ARB_texture_rgb10_a2ui
- ? GL_NO_ERROR : GL_INVALID_ENUM;
- default:
- return GL_INVALID_ENUM;
- }
-
- case GL_BGR_INTEGER_EXT:
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- /* NOTE: no packed formats w/ BGR format */
- return (ctx->VersionMajor >= 3 ||
- ctx->Extensions.EXT_texture_integer)
- ? GL_NO_ERROR : GL_INVALID_ENUM;
- default:
- return GL_INVALID_ENUM;
- }
-
- case GL_RGBA_INTEGER_EXT:
- case GL_BGRA_INTEGER_EXT:
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- return (ctx->VersionMajor >= 3 ||
- ctx->Extensions.EXT_texture_integer)
- ? GL_NO_ERROR : GL_INVALID_ENUM;
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- case GL_UNSIGNED_INT_8_8_8_8:
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- case GL_UNSIGNED_INT_10_10_10_2:
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- return ctx->Extensions.ARB_texture_rgb10_a2ui
- ? GL_NO_ERROR : GL_INVALID_ENUM;
- default:
- return GL_INVALID_ENUM;
- }
-
- case GL_LUMINANCE_INTEGER_EXT:
- case GL_LUMINANCE_ALPHA_INTEGER_EXT:
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- return ctx->Extensions.EXT_texture_integer
- ? GL_NO_ERROR : GL_INVALID_ENUM;
- default:
- return GL_INVALID_ENUM;
- }
-
- default:
- return GL_INVALID_ENUM;
- }
- return GL_NO_ERROR;
-}
-
-
-/**
- * Test if the given image format is a color/RGBA format (i.e., not color
- * index, depth, stencil, etc).
- * \param format the image format value (may by an internal texture format)
- * \return GL_TRUE if its a color/RGBA format, GL_FALSE otherwise.
- */
-GLboolean
-_mesa_is_color_format(GLenum format)
-{
- switch (format) {
- case GL_RED:
- case GL_GREEN:
- case GL_BLUE:
- case GL_ALPHA:
- case GL_ALPHA4:
- case GL_ALPHA8:
- case GL_ALPHA12:
- case GL_ALPHA16:
- case 1:
- case GL_LUMINANCE:
- case GL_LUMINANCE4:
- case GL_LUMINANCE8:
- case GL_LUMINANCE12:
- case GL_LUMINANCE16:
- case 2:
- case GL_LUMINANCE_ALPHA:
- case GL_LUMINANCE4_ALPHA4:
- case GL_LUMINANCE6_ALPHA2:
- case GL_LUMINANCE8_ALPHA8:
- case GL_LUMINANCE12_ALPHA4:
- case GL_LUMINANCE12_ALPHA12:
- case GL_LUMINANCE16_ALPHA16:
- case GL_INTENSITY:
- case GL_INTENSITY4:
- case GL_INTENSITY8:
- case GL_INTENSITY12:
- case GL_INTENSITY16:
- case GL_R8:
- case GL_R16:
- case GL_RG:
- case GL_RG8:
- case GL_RG16:
- case 3:
- case GL_RGB:
- case GL_BGR:
- case GL_R3_G3_B2:
- case GL_RGB4:
- case GL_RGB5:
- case GL_RGB565:
- case GL_RGB8:
- case GL_RGB10:
- case GL_RGB12:
- case GL_RGB16:
- case 4:
- case GL_ABGR_EXT:
- case GL_RGBA:
- case GL_BGRA:
- case GL_RGBA2:
- case GL_RGBA4:
- case GL_RGB5_A1:
- case GL_RGBA8:
- case GL_RGB10_A2:
- case GL_RGBA12:
- case GL_RGBA16:
- /* float texture formats */
- case GL_ALPHA16F_ARB:
- case GL_ALPHA32F_ARB:
- case GL_LUMINANCE16F_ARB:
- case GL_LUMINANCE32F_ARB:
- case GL_LUMINANCE_ALPHA16F_ARB:
- case GL_LUMINANCE_ALPHA32F_ARB:
- case GL_INTENSITY16F_ARB:
- case GL_INTENSITY32F_ARB:
- case GL_R16F:
- case GL_R32F:
- case GL_RG16F:
- case GL_RG32F:
- case GL_RGB16F_ARB:
- case GL_RGB32F_ARB:
- case GL_RGBA16F_ARB:
- case GL_RGBA32F_ARB:
- /* compressed formats */
- case GL_COMPRESSED_ALPHA:
- case GL_COMPRESSED_LUMINANCE:
- case GL_COMPRESSED_LUMINANCE_ALPHA:
- case GL_COMPRESSED_INTENSITY:
- case GL_COMPRESSED_RED:
- case GL_COMPRESSED_RG:
- case GL_COMPRESSED_RGB:
- case GL_COMPRESSED_RGBA:
- case GL_RGB_S3TC:
- case GL_RGB4_S3TC:
- case GL_RGBA_S3TC:
- case GL_RGBA4_S3TC:
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- case GL_COMPRESSED_RGB_FXT1_3DFX:
- case GL_COMPRESSED_RGBA_FXT1_3DFX:
-#if FEATURE_EXT_texture_sRGB
- case GL_SRGB_EXT:
- case GL_SRGB8_EXT:
- case GL_SRGB_ALPHA_EXT:
- case GL_SRGB8_ALPHA8_EXT:
- case GL_SLUMINANCE_ALPHA_EXT:
- case GL_SLUMINANCE8_ALPHA8_EXT:
- case GL_SLUMINANCE_EXT:
- case GL_SLUMINANCE8_EXT:
- case GL_COMPRESSED_SRGB_EXT:
- case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
- case GL_COMPRESSED_SRGB_ALPHA_EXT:
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
- case GL_COMPRESSED_SLUMINANCE_EXT:
- case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
-#endif /* FEATURE_EXT_texture_sRGB */
- case GL_COMPRESSED_RED_RGTC1:
- case GL_COMPRESSED_SIGNED_RED_RGTC1:
- case GL_COMPRESSED_RG_RGTC2:
- case GL_COMPRESSED_SIGNED_RG_RGTC2:
- case GL_COMPRESSED_LUMINANCE_LATC1_EXT:
- case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT:
- case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:
- case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:
- case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
- case GL_ETC1_RGB8_OES:
- /* generic integer formats */
- case GL_RED_INTEGER_EXT:
- case GL_GREEN_INTEGER_EXT:
- case GL_BLUE_INTEGER_EXT:
- case GL_ALPHA_INTEGER_EXT:
- case GL_RGB_INTEGER_EXT:
- case GL_RGBA_INTEGER_EXT:
- case GL_BGR_INTEGER_EXT:
- case GL_BGRA_INTEGER_EXT:
- case GL_RG_INTEGER:
- case GL_LUMINANCE_INTEGER_EXT:
- case GL_LUMINANCE_ALPHA_INTEGER_EXT:
- /* sized integer formats */
- case GL_RGBA32UI_EXT:
- case GL_RGB32UI_EXT:
- case GL_RG32UI:
- case GL_R32UI:
- case GL_ALPHA32UI_EXT:
- case GL_INTENSITY32UI_EXT:
- case GL_LUMINANCE32UI_EXT:
- case GL_LUMINANCE_ALPHA32UI_EXT:
- case GL_RGBA16UI_EXT:
- case GL_RGB16UI_EXT:
- case GL_RG16UI:
- case GL_R16UI:
- case GL_ALPHA16UI_EXT:
- case GL_INTENSITY16UI_EXT:
- case GL_LUMINANCE16UI_EXT:
- case GL_LUMINANCE_ALPHA16UI_EXT:
- case GL_RGBA8UI_EXT:
- case GL_RGB8UI_EXT:
- case GL_RG8UI:
- case GL_R8UI:
- case GL_ALPHA8UI_EXT:
- case GL_INTENSITY8UI_EXT:
- case GL_LUMINANCE8UI_EXT:
- case GL_LUMINANCE_ALPHA8UI_EXT:
- case GL_RGBA32I_EXT:
- case GL_RGB32I_EXT:
- case GL_RG32I:
- case GL_R32I:
- case GL_ALPHA32I_EXT:
- case GL_INTENSITY32I_EXT:
- case GL_LUMINANCE32I_EXT:
- case GL_LUMINANCE_ALPHA32I_EXT:
- case GL_RGBA16I_EXT:
- case GL_RGB16I_EXT:
- case GL_RG16I:
- case GL_R16I:
- case GL_ALPHA16I_EXT:
- case GL_INTENSITY16I_EXT:
- case GL_LUMINANCE16I_EXT:
- case GL_LUMINANCE_ALPHA16I_EXT:
- case GL_RGBA8I_EXT:
- case GL_RGB8I_EXT:
- case GL_RG8I:
- case GL_R8I:
- case GL_ALPHA8I_EXT:
- case GL_INTENSITY8I_EXT:
- case GL_LUMINANCE8I_EXT:
- case GL_LUMINANCE_ALPHA8I_EXT:
- /* signed, normalized texture formats */
- case GL_RED_SNORM:
- case GL_R8_SNORM:
- case GL_R16_SNORM:
- case GL_RG_SNORM:
- case GL_RG8_SNORM:
- case GL_RG16_SNORM:
- case GL_RGB_SNORM:
- case GL_RGB8_SNORM:
- case GL_RGB16_SNORM:
- case GL_RGBA_SNORM:
- case GL_RGBA8_SNORM:
- case GL_RGBA16_SNORM:
- case GL_ALPHA_SNORM:
- case GL_ALPHA8_SNORM:
- case GL_ALPHA16_SNORM:
- case GL_LUMINANCE_SNORM:
- case GL_LUMINANCE8_SNORM:
- case GL_LUMINANCE16_SNORM:
- case GL_LUMINANCE_ALPHA_SNORM:
- case GL_LUMINANCE8_ALPHA8_SNORM:
- case GL_LUMINANCE16_ALPHA16_SNORM:
- case GL_INTENSITY_SNORM:
- case GL_INTENSITY8_SNORM:
- case GL_INTENSITY16_SNORM:
- case GL_RGB9_E5:
- case GL_R11F_G11F_B10F:
- case GL_RGB10_A2UI:
- return GL_TRUE;
- case GL_YCBCR_MESA: /* not considered to be RGB */
- /* fall-through */
- default:
- return GL_FALSE;
- }
-}
-
-
-/**
- * Test if the given image format is a depth component format.
- */
-GLboolean
-_mesa_is_depth_format(GLenum format)
-{
- switch (format) {
- case GL_DEPTH_COMPONENT:
- case GL_DEPTH_COMPONENT16:
- case GL_DEPTH_COMPONENT24:
- case GL_DEPTH_COMPONENT32:
- case GL_DEPTH_COMPONENT32F:
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
-}
-
-
-/**
- * Test if the given image format is a stencil format.
- */
-GLboolean
-_mesa_is_stencil_format(GLenum format)
-{
- switch (format) {
- case GL_STENCIL_INDEX:
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
-}
-
-
-/**
- * Test if the given image format is a YCbCr format.
- */
-GLboolean
-_mesa_is_ycbcr_format(GLenum format)
-{
- switch (format) {
- case GL_YCBCR_MESA:
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
-}
-
-
-/**
- * Test if the given image format is a depth+stencil format.
- */
-GLboolean
-_mesa_is_depthstencil_format(GLenum format)
-{
- switch (format) {
- case GL_DEPTH24_STENCIL8_EXT:
- case GL_DEPTH_STENCIL_EXT:
- case GL_DEPTH32F_STENCIL8:
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
-}
-
-
-/**
- * Test if the given image format is a depth or stencil format.
- */
-GLboolean
-_mesa_is_depth_or_stencil_format(GLenum format)
-{
- switch (format) {
- case GL_DEPTH_COMPONENT:
- case GL_DEPTH_COMPONENT16:
- case GL_DEPTH_COMPONENT24:
- case GL_DEPTH_COMPONENT32:
- case GL_STENCIL_INDEX:
- case GL_STENCIL_INDEX1_EXT:
- case GL_STENCIL_INDEX4_EXT:
- case GL_STENCIL_INDEX8_EXT:
- case GL_STENCIL_INDEX16_EXT:
- case GL_DEPTH_STENCIL_EXT:
- case GL_DEPTH24_STENCIL8_EXT:
- case GL_DEPTH_COMPONENT32F:
- case GL_DEPTH32F_STENCIL8:
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
-}
-
-
-/**
- * Test if the given image format is a dudv format.
- */
-GLboolean
-_mesa_is_dudv_format(GLenum format)
-{
- switch (format) {
- case GL_DUDV_ATI:
- case GL_DU8DV8_ATI:
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
-}
-
-
-/**
- * Test if the given format is an integer (non-normalized) format.
- */
-GLboolean
-_mesa_is_integer_format(GLenum format)
-{
- switch (format) {
- /* generic integer formats */
- case GL_RED_INTEGER_EXT:
- case GL_GREEN_INTEGER_EXT:
- case GL_BLUE_INTEGER_EXT:
- case GL_ALPHA_INTEGER_EXT:
- case GL_RGB_INTEGER_EXT:
- case GL_RGBA_INTEGER_EXT:
- case GL_BGR_INTEGER_EXT:
- case GL_BGRA_INTEGER_EXT:
- case GL_LUMINANCE_INTEGER_EXT:
- case GL_LUMINANCE_ALPHA_INTEGER_EXT:
- case GL_RG_INTEGER:
- /* specific integer formats */
- case GL_RGBA32UI_EXT:
- case GL_RGB32UI_EXT:
- case GL_RG32UI:
- case GL_R32UI:
- case GL_ALPHA32UI_EXT:
- case GL_INTENSITY32UI_EXT:
- case GL_LUMINANCE32UI_EXT:
- case GL_LUMINANCE_ALPHA32UI_EXT:
- case GL_RGBA16UI_EXT:
- case GL_RGB16UI_EXT:
- case GL_RG16UI:
- case GL_R16UI:
- case GL_ALPHA16UI_EXT:
- case GL_INTENSITY16UI_EXT:
- case GL_LUMINANCE16UI_EXT:
- case GL_LUMINANCE_ALPHA16UI_EXT:
- case GL_RGBA8UI_EXT:
- case GL_RGB8UI_EXT:
- case GL_RG8UI:
- case GL_R8UI:
- case GL_ALPHA8UI_EXT:
- case GL_INTENSITY8UI_EXT:
- case GL_LUMINANCE8UI_EXT:
- case GL_LUMINANCE_ALPHA8UI_EXT:
- case GL_RGBA32I_EXT:
- case GL_RGB32I_EXT:
- case GL_RG32I:
- case GL_R32I:
- case GL_ALPHA32I_EXT:
- case GL_INTENSITY32I_EXT:
- case GL_LUMINANCE32I_EXT:
- case GL_LUMINANCE_ALPHA32I_EXT:
- case GL_RGBA16I_EXT:
- case GL_RGB16I_EXT:
- case GL_RG16I:
- case GL_R16I:
- case GL_ALPHA16I_EXT:
- case GL_INTENSITY16I_EXT:
- case GL_LUMINANCE16I_EXT:
- case GL_LUMINANCE_ALPHA16I_EXT:
- case GL_RGBA8I_EXT:
- case GL_RGB8I_EXT:
- case GL_RG8I:
- case GL_R8I:
- case GL_ALPHA8I_EXT:
- case GL_INTENSITY8I_EXT:
- case GL_LUMINANCE8I_EXT:
- case GL_LUMINANCE_ALPHA8I_EXT:
- case GL_RGB10_A2UI:
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
-}
-
-
-/**
- * Test if an image format is a supported compressed format.
- * \param format the internal format token provided by the user.
- * \return GL_TRUE if compressed, GL_FALSE if uncompressed
- */
-GLboolean
-_mesa_is_compressed_format(struct gl_context *ctx, GLenum format)
-{
- switch (format) {
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- return ctx->Extensions.EXT_texture_compression_s3tc;
- case GL_RGB_S3TC:
- case GL_RGB4_S3TC:
- case GL_RGBA_S3TC:
- case GL_RGBA4_S3TC:
- return ctx->Extensions.S3_s3tc;
- case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
- return ctx->Extensions.EXT_texture_sRGB
- && ctx->Extensions.EXT_texture_compression_s3tc;
- case GL_COMPRESSED_RGB_FXT1_3DFX:
- case GL_COMPRESSED_RGBA_FXT1_3DFX:
- return ctx->Extensions.TDFX_texture_compression_FXT1;
- case GL_COMPRESSED_RED_RGTC1:
- case GL_COMPRESSED_SIGNED_RED_RGTC1:
- case GL_COMPRESSED_RG_RGTC2:
- case GL_COMPRESSED_SIGNED_RG_RGTC2:
- return ctx->Extensions.ARB_texture_compression_rgtc;
- case GL_COMPRESSED_LUMINANCE_LATC1_EXT:
- case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT:
- case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:
- case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:
- return ctx->Extensions.EXT_texture_compression_latc;
- case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
- return ctx->Extensions.ATI_texture_compression_3dc;
- case GL_ETC1_RGB8_OES:
- return ctx->Extensions.OES_compressed_ETC1_RGB8_texture;
-#if FEATURE_ES
- case GL_PALETTE4_RGB8_OES:
- case GL_PALETTE4_RGBA8_OES:
- case GL_PALETTE4_R5_G6_B5_OES:
- case GL_PALETTE4_RGBA4_OES:
- case GL_PALETTE4_RGB5_A1_OES:
- case GL_PALETTE8_RGB8_OES:
- case GL_PALETTE8_RGBA8_OES:
- case GL_PALETTE8_R5_G6_B5_OES:
- case GL_PALETTE8_RGBA4_OES:
- case GL_PALETTE8_RGB5_A1_OES:
- return ctx->API == API_OPENGLES;
-#endif
- default:
- return GL_FALSE;
- }
-}
-
-
-/**
- * Does the given base texture/renderbuffer format have the channel
- * named by 'pname'?
- */
-GLboolean
-_mesa_base_format_has_channel(GLenum base_format, GLenum pname)
-{
- switch (pname) {
- case GL_TEXTURE_RED_SIZE:
- case GL_TEXTURE_RED_TYPE:
- case GL_RENDERBUFFER_RED_SIZE_EXT:
- case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
- if (base_format == GL_RED ||
- base_format == GL_RG ||
- base_format == GL_RGB ||
- base_format == GL_RGBA) {
- return GL_TRUE;
- }
- return GL_FALSE;
- case GL_TEXTURE_GREEN_SIZE:
- case GL_TEXTURE_GREEN_TYPE:
- case GL_RENDERBUFFER_GREEN_SIZE_EXT:
- case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
- if (base_format == GL_RG ||
- base_format == GL_RGB ||
- base_format == GL_RGBA) {
- return GL_TRUE;
- }
- return GL_FALSE;
- case GL_TEXTURE_BLUE_SIZE:
- case GL_TEXTURE_BLUE_TYPE:
- case GL_RENDERBUFFER_BLUE_SIZE_EXT:
- case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
- if (base_format == GL_RGB ||
- base_format == GL_RGBA) {
- return GL_TRUE;
- }
- return GL_FALSE;
- case GL_TEXTURE_ALPHA_SIZE:
- case GL_TEXTURE_ALPHA_TYPE:
- case GL_RENDERBUFFER_ALPHA_SIZE_EXT:
- case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
- if (base_format == GL_RGBA ||
- base_format == GL_ALPHA ||
- base_format == GL_LUMINANCE_ALPHA) {
- return GL_TRUE;
- }
- return GL_FALSE;
- case GL_TEXTURE_LUMINANCE_SIZE:
- case GL_TEXTURE_LUMINANCE_TYPE:
- if (base_format == GL_LUMINANCE ||
- base_format == GL_LUMINANCE_ALPHA) {
- return GL_TRUE;
- }
- return GL_FALSE;
- case GL_TEXTURE_INTENSITY_SIZE:
- case GL_TEXTURE_INTENSITY_TYPE:
- if (base_format == GL_INTENSITY) {
- return GL_TRUE;
- }
- return GL_FALSE;
- case GL_TEXTURE_DEPTH_SIZE:
- case GL_TEXTURE_DEPTH_TYPE:
- case GL_RENDERBUFFER_DEPTH_SIZE_EXT:
- case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
- if (base_format == GL_DEPTH_STENCIL ||
- base_format == GL_DEPTH_COMPONENT) {
- return GL_TRUE;
- }
- return GL_FALSE;
- case GL_RENDERBUFFER_STENCIL_SIZE_EXT:
- case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
- if (base_format == GL_DEPTH_STENCIL ||
- base_format == GL_STENCIL_INDEX) {
- return GL_TRUE;
- }
- return GL_FALSE;
- default:
- _mesa_warning(NULL, "%s: Unexpected channel token 0x%x\n",
- __FUNCTION__, pname);
- return GL_FALSE;
- }
-
- return GL_FALSE;
-}
-
-
-/**
* Return the byte offset of a specific pixel in an image (1D, 2D or 3D).
*
* Pixel unpacking/packing parameters are observed according to \p packing.
diff --git a/mesalib/src/mesa/main/image.h b/mesalib/src/mesa/main/image.h
index f1ed88379..7e92790b7 100644
--- a/mesalib/src/mesa/main/image.h
+++ b/mesalib/src/mesa/main/image.h
@@ -38,55 +38,6 @@ _mesa_swap2( GLushort *p, GLuint n );
extern void
_mesa_swap4( GLuint *p, GLuint n );
-extern GLboolean
-_mesa_type_is_packed(GLenum type);
-
-extern GLint
-_mesa_sizeof_type( GLenum type );
-
-extern GLint
-_mesa_sizeof_packed_type( GLenum type );
-
-extern GLint
-_mesa_components_in_format( GLenum format );
-
-extern GLint
-_mesa_bytes_per_pixel( GLenum format, GLenum type );
-
-extern GLenum
-_mesa_error_check_format_and_type(const struct gl_context *ctx,
- GLenum format, GLenum type);
-
-extern GLboolean
-_mesa_is_color_format(GLenum format);
-
-extern GLboolean
-_mesa_is_depth_format(GLenum format);
-
-extern GLboolean
-_mesa_is_stencil_format(GLenum format);
-
-extern GLboolean
-_mesa_is_ycbcr_format(GLenum format);
-
-extern GLboolean
-_mesa_is_depthstencil_format(GLenum format);
-
-extern GLboolean
-_mesa_is_depth_or_stencil_format(GLenum format);
-
-extern GLboolean
-_mesa_is_dudv_format(GLenum format);
-
-extern GLboolean
-_mesa_is_integer_format(GLenum format);
-
-extern GLboolean
-_mesa_is_compressed_format(struct gl_context *ctx, GLenum format);
-
-extern GLboolean
-_mesa_base_format_has_channel(GLenum base_format, GLenum pname);
-
extern GLintptr
_mesa_image_offset( GLuint dimensions,
const struct gl_pixelstore_attrib *packing,
diff --git a/mesalib/src/mesa/main/imports.c b/mesalib/src/mesa/main/imports.c
index 2d592a68e..0d6b56a51 100644
--- a/mesalib/src/mesa/main/imports.c
+++ b/mesalib/src/mesa/main/imports.c
@@ -223,19 +223,6 @@ _mesa_realloc(void *oldBuffer, size_t oldSize, size_t newSize)
return newBuffer;
}
-/**
- * Fill memory with a constant 16bit word.
- * \param dst destination pointer.
- * \param val value.
- * \param n number of words.
- */
-void
-_mesa_memset16( unsigned short *dst, unsigned short val, size_t n )
-{
- while (n-- > 0)
- *dst++ = val;
-}
-
/*@}*/
@@ -243,213 +230,6 @@ _mesa_memset16( unsigned short *dst, unsigned short val, size_t n )
/** \name Math */
/*@{*/
-/** Wrapper around sqrt() */
-double
-_mesa_sqrtd(double x)
-{
- return sqrt(x);
-}
-
-
-/*
- * A High Speed, Low Precision Square Root
- * by Paul Lalonde and Robert Dawson
- * from "Graphics Gems", Academic Press, 1990
- *
- * SPARC implementation of a fast square root by table
- * lookup.
- * SPARC floating point format is as follows:
- *
- * BIT 31 30 23 22 0
- * sign exponent mantissa
- */
-static short sqrttab[0x100]; /* declare table of square roots */
-
-void
-_mesa_init_sqrt_table(void)
-{
-#if defined(USE_IEEE) && !defined(DEBUG)
- unsigned short i;
- fi_type fi; /* to access the bits of a float in C quickly */
- /* we use a union defined in glheader.h */
-
- for(i=0; i<= 0x7f; i++) {
- fi.i = 0;
-
- /*
- * Build a float with the bit pattern i as mantissa
- * and an exponent of 0, stored as 127
- */
-
- fi.i = (i << 16) | (127 << 23);
- fi.f = _mesa_sqrtd(fi.f);
-
- /*
- * Take the square root then strip the first 7 bits of
- * the mantissa into the table
- */
-
- sqrttab[i] = (fi.i & 0x7fffff) >> 16;
-
- /*
- * Repeat the process, this time with an exponent of
- * 1, stored as 128
- */
-
- fi.i = 0;
- fi.i = (i << 16) | (128 << 23);
- fi.f = sqrt(fi.f);
- sqrttab[i+0x80] = (fi.i & 0x7fffff) >> 16;
- }
-#else
- (void) sqrttab; /* silence compiler warnings */
-#endif /*HAVE_FAST_MATH*/
-}
-
-
-/**
- * Single precision square root.
- */
-float
-_mesa_sqrtf( float x )
-{
-#if defined(USE_IEEE) && !defined(DEBUG)
- fi_type num;
- /* to access the bits of a float in C
- * we use a union from glheader.h */
-
- short e; /* the exponent */
- if (x == 0.0F) return 0.0F; /* check for square root of 0 */
- num.f = x;
- e = (num.i >> 23) - 127; /* get the exponent - on a SPARC the */
- /* exponent is stored with 127 added */
- num.i &= 0x7fffff; /* leave only the mantissa */
- if (e & 0x01) num.i |= 0x800000;
- /* the exponent is odd so we have to */
- /* look it up in the second half of */
- /* the lookup table, so we set the */
- /* high bit */
- e >>= 1; /* divide the exponent by two */
- /* note that in C the shift */
- /* operators are sign preserving */
- /* for signed operands */
- /* Do the table lookup, based on the quaternary mantissa,
- * then reconstruct the result back into a float
- */
- num.i = ((sqrttab[num.i >> 16]) << 16) | ((e + 127) << 23);
-
- return num.f;
-#else
- return (float) _mesa_sqrtd((double) x);
-#endif
-}
-
-
-/**
- inv_sqrt - A single precision 1/sqrt routine for IEEE format floats.
- written by Josh Vanderhoof, based on newsgroup posts by James Van Buskirk
- and Vesa Karvonen.
-*/
-float
-_mesa_inv_sqrtf(float n)
-{
-#if defined(USE_IEEE) && !defined(DEBUG)
- float r0, x0, y0;
- float r1, x1, y1;
- float r2, x2, y2;
-#if 0 /* not used, see below -BP */
- float r3, x3, y3;
-#endif
- fi_type u;
- unsigned int magic;
-
- /*
- Exponent part of the magic number -
-
- We want to:
- 1. subtract the bias from the exponent,
- 2. negate it
- 3. divide by two (rounding towards -inf)
- 4. add the bias back
-
- Which is the same as subtracting the exponent from 381 and dividing
- by 2.
-
- floor(-(x - 127) / 2) + 127 = floor((381 - x) / 2)
- */
-
- magic = 381 << 23;
-
- /*
- Significand part of magic number -
-
- With the current magic number, "(magic - u.i) >> 1" will give you:
-
- for 1 <= u.f <= 2: 1.25 - u.f / 4
- for 2 <= u.f <= 4: 1.00 - u.f / 8
-
- This isn't a bad approximation of 1/sqrt. The maximum difference from
- 1/sqrt will be around .06. After three Newton-Raphson iterations, the
- maximum difference is less than 4.5e-8. (Which is actually close
- enough to make the following bias academic...)
-
- To get a better approximation you can add a bias to the magic
- number. For example, if you subtract 1/2 of the maximum difference in
- the first approximation (.03), you will get the following function:
-
- for 1 <= u.f <= 2: 1.22 - u.f / 4
- for 2 <= u.f <= 3.76: 0.97 - u.f / 8
- for 3.76 <= u.f <= 4: 0.72 - u.f / 16
- (The 3.76 to 4 range is where the result is < .5.)
-
- This is the closest possible initial approximation, but with a maximum
- error of 8e-11 after three NR iterations, it is still not perfect. If
- you subtract 0.0332281 instead of .03, the maximum error will be
- 2.5e-11 after three NR iterations, which should be about as close as
- is possible.
-
- for 1 <= u.f <= 2: 1.2167719 - u.f / 4
- for 2 <= u.f <= 3.73: 0.9667719 - u.f / 8
- for 3.73 <= u.f <= 4: 0.7167719 - u.f / 16
-
- */
-
- magic -= (int)(0.0332281 * (1 << 25));
-
- u.f = n;
- u.i = (magic - u.i) >> 1;
-
- /*
- Instead of Newton-Raphson, we use Goldschmidt's algorithm, which
- allows more parallelism. From what I understand, the parallelism
- comes at the cost of less precision, because it lets error
- accumulate across iterations.
- */
- x0 = 1.0f;
- y0 = 0.5f * n;
- r0 = u.f;
-
- x1 = x0 * r0;
- y1 = y0 * r0 * r0;
- r1 = 1.5f - y1;
-
- x2 = x1 * r1;
- y2 = y1 * r1 * r1;
- r2 = 1.5f - y2;
-
-#if 1
- return x2 * r2; /* we can stop here, and be conformant -BP */
-#else
- x3 = x2 * r2;
- y3 = y2 * r2 * r2;
- r3 = 1.5f - y3;
-
- return x3 * r3;
-#endif
-#else
- return (float) (1.0 / sqrt(n));
-#endif
-}
#ifndef __GNUC__
/**
@@ -762,7 +542,7 @@ float
_mesa_strtof( const char *s, char **end )
{
#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \
- !defined(ANDROID) && !defined(__HAIKU__)
+ !defined(ANDROID) && !defined(__HAIKU__) && !defined(__UCLIBC__)
static locale_t loc = NULL;
if (!loc) {
loc = newlocale(LC_CTYPE_MASK, "C", NULL);
diff --git a/mesalib/src/mesa/main/imports.h b/mesalib/src/mesa/main/imports.h
index c0b6cecea..73913b5ab 100644
--- a/mesalib/src/mesa/main/imports.h
+++ b/mesalib/src/mesa/main/imports.h
@@ -99,21 +99,13 @@ typedef union { GLfloat f; GLint i; } fi_type;
/***
*** SQRTF: single-precision square root
***/
-#if 0 /* _mesa_sqrtf() not accurate enough - temporarily disabled */
-# define SQRTF(X) _mesa_sqrtf(X)
-#else
-# define SQRTF(X) (float) sqrt((float) (X))
-#endif
+#define SQRTF(X) (float) sqrt((float) (X))
/***
*** INV_SQRTF: single-precision inverse square root
***/
-#if 0
-#define INV_SQRTF(X) _mesa_inv_sqrt(X)
-#else
-#define INV_SQRTF(X) (1.0F / SQRTF(X)) /* this is faster on a P4 */
-#endif
+#define INV_SQRTF(X) (1.0F / SQRTF(X))
/**
@@ -127,7 +119,7 @@ typedef union { GLfloat f; GLint i; } fi_type;
#define asinf(f) ((float) asin(f))
#define atan2f(x,y) ((float) atan2(x,y))
#define atanf(f) ((float) atan(f))
-#define cielf(f) ((float) ciel(f))
+#define ceilf(f) ((float) ceil(f))
#define cosf(f) ((float) cos(f))
#define coshf(f) ((float) cosh(f))
#define expf(f) ((float) exp(f))
@@ -566,21 +558,6 @@ _mesa_exec_free( void *addr );
extern void *
_mesa_realloc( void *oldBuffer, size_t oldSize, size_t newSize );
-extern void
-_mesa_memset16( unsigned short *dst, unsigned short val, size_t n );
-
-extern double
-_mesa_sqrtd(double x);
-
-extern float
-_mesa_sqrtf(float x);
-
-extern float
-_mesa_inv_sqrtf(float x);
-
-extern void
-_mesa_init_sqrt_table(void);
-
#ifndef FFS_DEFINED
#define FFS_DEFINED 1
diff --git a/mesalib/src/mesa/main/matrix.c b/mesalib/src/mesa/main/matrix.c
index f479a22b0..b09fa4d3d 100644
--- a/mesalib/src/mesa/main/matrix.c
+++ b/mesalib/src/mesa/main/matrix.c
@@ -658,8 +658,7 @@ void _mesa_update_modelview_project( struct gl_context *ctx, GLuint new_state )
* \param dirtyFlag dirty flag.
*
* Allocates an array of \p maxDepth elements for the matrix stack and calls
- * _math_matrix_ctr() and _math_matrix_alloc_inv() for each element to
- * initialize it.
+ * _math_matrix_ctr() for each element to initialize it.
*/
static void
init_matrix_stack( struct gl_matrix_stack *stack,
@@ -674,7 +673,6 @@ init_matrix_stack( struct gl_matrix_stack *stack,
stack->Stack = (GLmatrix *) CALLOC(maxDepth * sizeof(GLmatrix));
for (i = 0; i < maxDepth; i++) {
_math_matrix_ctr(&stack->Stack[i]);
- _math_matrix_alloc_inv(&stack->Stack[i]);
}
stack->Top = stack->Stack;
}
diff --git a/mesalib/src/mesa/main/mipmap.c b/mesalib/src/mesa/main/mipmap.c
index 250d3c6dc..9f531ae20 100644
--- a/mesalib/src/mesa/main/mipmap.c
+++ b/mesalib/src/mesa/main/mipmap.c
@@ -29,6 +29,7 @@
#include "imports.h"
#include "formats.h"
+#include "glformats.h"
#include "mipmap.h"
#include "mtypes.h"
#include "teximage.h"
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index 1f74e6a83..7d7213f4d 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -2011,6 +2011,7 @@ struct gl_fragment_program
{
struct gl_program Base; /**< base class */
GLboolean UsesKill; /**< shader uses KIL instruction */
+ GLboolean UsesDFdy; /**< shader uses DDY instruction */
GLboolean OriginUpperLeft;
GLboolean PixelCenterInteger;
enum gl_frag_depth_layout FragDepthLayout;
@@ -2215,6 +2216,15 @@ struct gl_shader
*/
unsigned num_uniform_components;
+ /**
+ * This shader's uniform block information.
+ *
+ * The offsets of the variables are assigned only for shaders in a program's
+ * _LinkedShaders[].
+ */
+ struct gl_uniform_block *UniformBlocks;
+ unsigned NumUniformBlocks;
+
struct exec_list *ir;
struct glsl_symbol_table *symbols;
@@ -2236,6 +2246,37 @@ typedef enum
MESA_SHADER_TYPES = 3
} gl_shader_type;
+struct gl_uniform_buffer_variable
+{
+ char *Name;
+ const struct glsl_type *Type;
+ unsigned int Buffer;
+ unsigned int Offset;
+ GLboolean RowMajor;
+};
+
+struct gl_uniform_block
+{
+ /** Declared name of the uniform block */
+ char *Name;
+
+ /** Array of supplemental information about UBO ir_variables. */
+ struct gl_uniform_buffer_variable *Uniforms;
+ GLuint NumUniforms;
+
+ /**
+ * Index (GL_UNIFORM_BLOCK_BINDING) into ctx->UniformBufferBindings[] to use
+ * with glBindBufferBase to bind a buffer object to this uniform block. When
+ * updated in the program, _NEW_BUFFER_OBJECT will be set.
+ */
+ GLuint Binding;
+
+ /**
+ * Minimum size of a buffer object to back this uniform buffer
+ * (GL_UNIFORM_BLOCK_DATA_SIZE).
+ */
+ GLuint UniformBufferSize;
+};
/**
* A GLSL program object.
@@ -2319,6 +2360,18 @@ struct gl_shader_program
unsigned NumUserUniformStorage;
struct gl_uniform_storage *UniformStorage;
+ struct gl_uniform_block *UniformBlocks;
+ unsigned NumUniformBlocks;
+
+ /**
+ * Indices into the _LinkedShaders's UniformBlocks[] array for each stage
+ * they're used in, or -1.
+ *
+ * This is used to maintain the Binding values of the stage's UniformBlocks[]
+ * and to answer the GL_UNIFORM_BLOCK_REFERENCED_BY_*_SHADER queries.
+ */
+ int *UniformBlockStageIndex[MESA_SHADER_TYPES];
+
/**
* Map of active uniform names to locations
*
@@ -3281,9 +3334,10 @@ struct gl_debug_state
*/
typedef enum
{
- API_OPENGL,
+ API_OPENGL, /* legacy / compatibility contexts */
API_OPENGLES,
- API_OPENGLES2
+ API_OPENGLES2,
+ API_OPENGL_CORE,
} gl_api;
/**
diff --git a/mesalib/src/mesa/main/nvprogram.c b/mesalib/src/mesa/main/nvprogram.c
index dae11566e..fc5749afc 100644
--- a/mesalib/src/mesa/main/nvprogram.c
+++ b/mesalib/src/mesa/main/nvprogram.c
@@ -71,7 +71,7 @@ _mesa_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params)
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
- vprog = (struct gl_vertex_program *) _mesa_lookup_program(ctx, id);
+ vprog = gl_vertex_program(_mesa_lookup_program(ctx, id));
if (!vprog || vprog->Base.Target != GL_VERTEX_STATE_PROGRAM_NV) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glExecuteProgramNV");
@@ -627,10 +627,9 @@ _mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
if ((target == GL_VERTEX_PROGRAM_NV ||
target == GL_VERTEX_STATE_PROGRAM_NV)
&& ctx->Extensions.NV_vertex_program) {
- struct gl_vertex_program *vprog = (struct gl_vertex_program *) prog;
+ struct gl_vertex_program *vprog = gl_vertex_program(prog);
if (!vprog || prog == &_mesa_DummyProgram) {
- vprog = (struct gl_vertex_program *)
- ctx->Driver.NewProgram(ctx, target, id);
+ vprog = gl_vertex_program(ctx->Driver.NewProgram(ctx, target, id));
if (!vprog) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
return;
@@ -647,10 +646,9 @@ _mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
}
else if (target == GL_FRAGMENT_PROGRAM_NV
&& ctx->Extensions.NV_fragment_program) {
- struct gl_fragment_program *fprog = (struct gl_fragment_program *) prog;
+ struct gl_fragment_program *fprog = gl_fragment_program(prog);
if (!fprog || prog == &_mesa_DummyProgram) {
- fprog = (struct gl_fragment_program *)
- ctx->Driver.NewProgram(ctx, target, id);
+ fprog = gl_fragment_program(ctx->Driver.NewProgram(ctx, target, id));
if (!fprog) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
return;
@@ -661,10 +659,9 @@ _mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
}
else if (target == GL_FRAGMENT_PROGRAM_ARB
&& ctx->Extensions.ARB_fragment_program) {
- struct gl_fragment_program *fprog = (struct gl_fragment_program *) prog;
+ struct gl_fragment_program *fprog = gl_fragment_program(prog);
if (!fprog || prog == &_mesa_DummyProgram) {
- fprog = (struct gl_fragment_program *)
- ctx->Driver.NewProgram(ctx, target, id);
+ fprog = gl_fragment_program(ctx->Driver.NewProgram(ctx, target, id));
if (!fprog) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
return;
@@ -830,7 +827,7 @@ _mesa_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name,
return;
}
- fragProg = (struct gl_fragment_program *) prog;
+ fragProg = gl_fragment_program(prog);
v = _mesa_lookup_parameter_value(fragProg->Base.Parameters, len,
(char *) name);
if (v) {
@@ -895,7 +892,7 @@ _mesa_GetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte *name,
return;
}
- fragProg = (struct gl_fragment_program *) prog;
+ fragProg = gl_fragment_program(prog);
v = _mesa_lookup_parameter_value(fragProg->Base.Parameters,
len, (char *) name);
if (v) {
diff --git a/mesalib/src/mesa/main/pack.c b/mesalib/src/mesa/main/pack.c
index c25a02e85..83192c157 100644
--- a/mesalib/src/mesa/main/pack.c
+++ b/mesalib/src/mesa/main/pack.c
@@ -29,6 +29,19 @@
*/
+/*
+ * XXX: MSVC takes forever to compile this module for x86_64 unless we disable
+ * this global optimization.
+ *
+ * See also:
+ * - http://msdn.microsoft.com/en-us/library/1yk3ydd7.aspx
+ * - http://msdn.microsoft.com/en-us/library/chh3fb0k.aspx
+ */
+#if defined(_MSC_VER) && defined(_M_X64)
+# pragma optimize( "g", off )
+#endif
+
+
#include "glheader.h"
#include "colormac.h"
#include "enums.h"
@@ -39,6 +52,7 @@
#include "pack.h"
#include "pixeltransfer.h"
#include "imports.h"
+#include "glformats.h"
#include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
#include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
@@ -500,26 +514,29 @@ _mesa_pack_rgba_span_int(struct gl_context *ctx, GLuint n, GLuint rgba[][4],
{
switch(dstType) {
case GL_UNSIGNED_INT:
- pack_uint_from_uint_rgba(dstAddr, dstFormat, rgba, n);
+ pack_uint_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
break;
case GL_INT:
/* No conversion necessary. */
- pack_uint_from_uint_rgba(dstAddr, dstFormat, rgba, n);
+ pack_uint_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
break;
case GL_UNSIGNED_SHORT:
- pack_ushort_from_uint_rgba(dstAddr, dstFormat, rgba, n);
+ pack_ushort_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
break;
case GL_SHORT:
- pack_short_from_uint_rgba(dstAddr, dstFormat, rgba, n);
+ pack_short_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
break;
case GL_UNSIGNED_BYTE:
- pack_ubyte_from_uint_rgba(dstAddr, dstFormat, rgba, n);
+ pack_ubyte_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
break;
case GL_BYTE:
- pack_byte_from_uint_rgba(dstAddr, dstFormat, rgba, n);
+ pack_byte_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
break;
default:
- assert(0);
+ _mesa_problem(ctx,
+ "Unsupported type (%s) for format (%s)",
+ _mesa_lookup_enum_by_nr(dstType),
+ _mesa_lookup_enum_by_nr(dstFormat));
return;
}
}
@@ -545,7 +562,7 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4],
{
GLfloat *luminance;
const GLint comps = _mesa_components_in_format(dstFormat);
- const GLboolean intDstFormat = _mesa_is_integer_format(dstFormat);
+ const GLboolean intDstFormat = _mesa_is_enum_format_integer(dstFormat);
GLuint i;
if (dstFormat == GL_LUMINANCE ||
@@ -2476,7 +2493,7 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
stride = _mesa_components_in_format(srcFormat);
- intFormat = _mesa_is_integer_format(srcFormat);
+ intFormat = _mesa_is_enum_format_integer(srcFormat);
#define PROCESS(SRC_INDEX, DST_INDEX, DEFAULT_FLT, DEFAULT_INT, TYPE, CONVERSION) \
if ((SRC_INDEX) < 0) { \
@@ -3531,7 +3548,7 @@ _mesa_unpack_color_span_ubyte(struct gl_context *ctx,
const struct gl_pixelstore_attrib *srcPacking,
GLbitfield transferOps )
{
- GLboolean intFormat = _mesa_is_integer_format(srcFormat);
+ GLboolean intFormat = _mesa_is_enum_format_integer(srcFormat);
ASSERT(dstFormat == GL_ALPHA ||
dstFormat == GL_LUMINANCE ||
dstFormat == GL_LUMINANCE_ALPHA ||
@@ -3838,7 +3855,7 @@ _mesa_unpack_color_span_float( struct gl_context *ctx,
GLint dstComponents;
GLint rDst, gDst, bDst, aDst, lDst, iDst;
GLfloat (*rgba)[4] = (GLfloat (*)[4]) malloc(4 * n * sizeof(GLfloat));
- GLboolean intFormat = _mesa_is_integer_format(srcFormat);
+ GLboolean intFormat = _mesa_is_enum_format_integer(srcFormat);
if (!rgba) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking");
diff --git a/mesalib/src/mesa/main/pack_tmp.h b/mesalib/src/mesa/main/pack_tmp.h
index 83b655729..0d4eb387d 100644
--- a/mesalib/src/mesa/main/pack_tmp.h
+++ b/mesalib/src/mesa/main/pack_tmp.h
@@ -22,7 +22,8 @@
*/
static void
-FN_NAME(DST_TYPE *dst,
+FN_NAME(struct gl_context *ctx,
+ DST_TYPE *dst,
GLenum dstFormat,
SRC_TYPE rgba[][4],
int n)
@@ -111,5 +112,11 @@ FN_NAME(DST_TYPE *dst,
dst[i*2+1] = SRC_CONVERT(rgba[i][ACOMP]);
}
break;
+
+ default:
+ _mesa_problem(ctx,
+ "Unsupported format (%s)",
+ _mesa_lookup_enum_by_nr(dstFormat));
+ break;
}
}
diff --git a/mesalib/src/mesa/main/pbo.c b/mesalib/src/mesa/main/pbo.c
index d8fa9191d..c73d7492f 100644
--- a/mesalib/src/mesa/main/pbo.c
+++ b/mesalib/src/mesa/main/pbo.c
@@ -32,6 +32,7 @@
#include "glheader.h"
#include "bufferobj.h"
+#include "glformats.h"
#include "image.h"
#include "imports.h"
#include "mtypes.h"
@@ -172,11 +173,12 @@ _mesa_map_pbo_source(struct gl_context *ctx,
*/
const GLvoid *
_mesa_map_validate_pbo_source(struct gl_context *ctx,
- GLuint dimensions,
- const struct gl_pixelstore_attrib *unpack,
- GLsizei width, GLsizei height, GLsizei depth,
- GLenum format, GLenum type, GLsizei clientMemSize,
- const GLvoid *ptr, const char *where)
+ GLuint dimensions,
+ const struct gl_pixelstore_attrib *unpack,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type,
+ GLsizei clientMemSize,
+ const GLvoid *ptr, const char *where)
{
ASSERT(dimensions == 1 || dimensions == 2 || dimensions == 3);
@@ -268,11 +270,11 @@ _mesa_map_pbo_dest(struct gl_context *ctx,
*/
GLvoid *
_mesa_map_validate_pbo_dest(struct gl_context *ctx,
- GLuint dimensions,
- const struct gl_pixelstore_attrib *unpack,
- GLsizei width, GLsizei height, GLsizei depth,
- GLenum format, GLenum type, GLsizei clientMemSize,
- GLvoid *ptr, const char *where)
+ GLuint dimensions,
+ const struct gl_pixelstore_attrib *unpack,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type, GLsizei clientMemSize,
+ GLvoid *ptr, const char *where)
{
ASSERT(dimensions == 1 || dimensions == 2 || dimensions == 3);
@@ -339,12 +341,13 @@ _mesa_validate_pbo_teximage(struct gl_context *ctx, GLuint dimensions,
return pixels;
}
if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth,
- format, type, INT_MAX, pixels)) {
+ format, type, INT_MAX, pixels)) {
_mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access)");
return NULL;
}
- buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0, unpack->BufferObj->Size,
+ buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0,
+ unpack->BufferObj->Size,
GL_MAP_READ_BIT,
unpack->BufferObj);
if (!buf) {
@@ -407,5 +410,3 @@ _mesa_unmap_teximage_pbo(struct gl_context *ctx,
ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj);
}
}
-
-
diff --git a/mesalib/src/mesa/main/readpix.c b/mesalib/src/mesa/main/readpix.c
index 138111049..7ac877497 100644
--- a/mesalib/src/mesa/main/readpix.c
+++ b/mesalib/src/mesa/main/readpix.c
@@ -36,6 +36,8 @@
#include "pack.h"
#include "pbo.h"
#include "state.h"
+#include "glformats.h"
+#include "fbobject.h"
/**
@@ -337,7 +339,7 @@ slow_read_rgba_pixels( struct gl_context *ctx,
goto done;
for (j = 0; j < height; j++) {
- if (_mesa_is_integer_format(format)) {
+ if (_mesa_is_enum_format_integer(format)) {
_mesa_unpack_uint_rgba_row(rbFormat, width, map, (GLuint (*)[4]) rgba);
_mesa_rebase_rgba_uint(width, (GLuint (*)[4]) rgba,
rb->_BaseFormat);
@@ -378,7 +380,7 @@ read_rgba_pixels( struct gl_context *ctx,
return;
if ((ctx->Color._ClampReadColor == GL_TRUE || type != GL_FLOAT) &&
- !_mesa_is_integer_format(format)) {
+ !_mesa_is_enum_format_integer(format)) {
transferOps |= IMAGE_CLAMP_BIT;
}
@@ -713,7 +715,7 @@ _mesa_ReadnPixelsARB( GLint x, GLint y, GLsizei width, GLsizei height,
if (ctx->Extensions.EXT_texture_integer && _mesa_is_color_format(format)) {
const struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
const GLboolean srcInteger = _mesa_is_format_integer_color(rb->Format);
- const GLboolean dstInteger = _mesa_is_integer_format(format);
+ const GLboolean dstInteger = _mesa_is_enum_format_integer(format);
if (dstInteger != srcInteger) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glReadPixels(integer / non-integer format mismatch");
@@ -721,7 +723,8 @@ _mesa_ReadnPixelsARB( GLint x, GLint y, GLsizei width, GLsizei height,
}
}
- if (ctx->ReadBuffer->Name != 0 && ctx->ReadBuffer->Visual.samples > 0) {
+ if (_mesa_is_user_fbo(ctx->ReadBuffer) &&
+ ctx->ReadBuffer->Visual.samples > 0) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(multisample FBO)");
return;
}
diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c
index 6927368de..7c97a6359 100644
--- a/mesalib/src/mesa/main/shaderapi.c
+++ b/mesalib/src/mesa/main/shaderapi.c
@@ -346,10 +346,12 @@ delete_shader(struct gl_context *ctx, GLuint shader)
if (!sh)
return;
- sh->DeletePending = GL_TRUE;
+ if (!sh->DeletePending) {
+ sh->DeletePending = GL_TRUE;
- /* effectively, decr sh's refcount */
- _mesa_reference_shader(ctx, &sh, NULL);
+ /* effectively, decr sh's refcount */
+ _mesa_reference_shader(ctx, &sh, NULL);
+ }
}
diff --git a/mesalib/src/mesa/main/shared.c b/mesalib/src/mesa/main/shared.c
index 226947638..58cbc5250 100644
--- a/mesalib/src/mesa/main/shared.c
+++ b/mesalib/src/mesa/main/shared.c
@@ -71,13 +71,15 @@ _mesa_alloc_shared_state(struct gl_context *ctx)
shared->Programs = _mesa_NewHashTable();
#if FEATURE_ARB_vertex_program
- shared->DefaultVertexProgram = (struct gl_vertex_program *)
- ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
+ shared->DefaultVertexProgram =
+ gl_vertex_program(ctx->Driver.NewProgram(ctx,
+ GL_VERTEX_PROGRAM_ARB, 0));
#endif
#if FEATURE_ARB_fragment_program
- shared->DefaultFragmentProgram = (struct gl_fragment_program *)
- ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0);
+ shared->DefaultFragmentProgram =
+ gl_fragment_program(ctx->Driver.NewProgram(ctx,
+ GL_FRAGMENT_PROGRAM_ARB, 0));
#endif
#if FEATURE_ATI_fragment_shader
diff --git a/mesalib/src/mesa/main/state.c b/mesalib/src/mesa/main/state.c
index db0cc30ec..76946bd93 100644
--- a/mesalib/src/mesa/main/state.c
+++ b/mesalib/src/mesa/main/state.c
@@ -134,8 +134,7 @@ update_program(struct gl_context *ctx)
&ctx->Shader._CurrentFragmentProgram,
fsProg);
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
- (struct gl_fragment_program *)
- fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program);
+ gl_fragment_program(fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program));
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram,
NULL);
}
@@ -157,11 +156,9 @@ update_program(struct gl_context *ctx)
&ctx->Shader._CurrentFragmentProgram,
f);
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
- (struct gl_fragment_program *)
- f->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program);
+ gl_fragment_program(f->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program));
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram,
- (struct gl_fragment_program *)
- f->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program);
+ gl_fragment_program(f->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program));
}
else {
/* No fragment program */
@@ -174,8 +171,7 @@ update_program(struct gl_context *ctx)
&& gsProg->_LinkedShaders[MESA_SHADER_GEOMETRY]) {
/* Use GLSL geometry shader */
_mesa_reference_geomprog(ctx, &ctx->GeometryProgram._Current,
- (struct gl_geometry_program *)
- gsProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program);
+ gl_geometry_program(gsProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program));
} else {
/* No geometry program */
_mesa_reference_geomprog(ctx, &ctx->GeometryProgram._Current, NULL);
@@ -189,8 +185,7 @@ update_program(struct gl_context *ctx)
&& vsProg->_LinkedShaders[MESA_SHADER_VERTEX]) {
/* Use GLSL vertex shader */
_mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
- (struct gl_vertex_program *)
- vsProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program);
+ gl_vertex_program(vsProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program));
}
else if (ctx->VertexProgram._Enabled) {
/* Use user-defined vertex program */
diff --git a/mesalib/src/mesa/main/texformat.c b/mesalib/src/mesa/main/texformat.c
index 26bcbc10a..d360f0e22 100644
--- a/mesalib/src/mesa/main/texformat.c
+++ b/mesalib/src/mesa/main/texformat.c
@@ -887,6 +887,7 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
switch (internalFormat) {
case GL_RGB10_A2UI:
RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB2101010_UINT);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_ABGR2101010_UINT);
break;
default:
break;
@@ -894,7 +895,7 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
}
/* GL_BGRA can be an internal format *only* in OpenGL ES (1.x or 2.0).
*/
- if (ctx->API != API_OPENGL) {
+ if (_mesa_is_gles(ctx)) {
switch (internalFormat) {
case GL_BGRA:
RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888);
diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c
index 05b052a01..0ba3ff5b3 100644
--- a/mesalib/src/mesa/main/texgetimage.c
+++ b/mesalib/src/mesa/main/texgetimage.c
@@ -35,6 +35,7 @@
#include "context.h"
#include "formats.h"
#include "format_unpack.h"
+#include "glformats.h"
#include "image.h"
#include "mfeatures.h"
#include "mtypes.h"
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c
index 64b25a82d..d2746c6f3 100644
--- a/mesalib/src/mesa/main/teximage.c
+++ b/mesalib/src/mesa/main/teximage.c
@@ -47,6 +47,7 @@
#include "texstate.h"
#include "texpal.h"
#include "mtypes.h"
+#include "glformats.h"
/**
@@ -129,7 +130,7 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
/* GL_BGRA can be an internal format *only* in OpenGL ES (1.x or 2.0).
*/
- if (ctx->API != API_OPENGL) {
+ if (_mesa_is_gles(ctx)) {
switch (internalFormat) {
case GL_BGRA:
return GL_RGBA;
@@ -1764,8 +1765,8 @@ texture_error_check( struct gl_context *ctx,
/* additional checks for integer textures */
if ((ctx->VersionMajor >= 3 || ctx->Extensions.EXT_texture_integer) &&
- (_mesa_is_integer_format(format) !=
- _mesa_is_integer_format(internalFormat))) {
+ (_mesa_is_enum_format_integer(format) !=
+ _mesa_is_enum_format_integer(internalFormat))) {
if (!isProxy) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glTexImage%dD(integer/non-integer format mismatch)",
@@ -1939,7 +1940,7 @@ subtexture_error_check2( struct gl_context *ctx, GLuint dimensions,
if (ctx->VersionMajor >= 3 || ctx->Extensions.EXT_texture_integer) {
/* both source and dest must be integer-valued, or neither */
if (_mesa_is_format_integer_color(destTex->TexFormat) !=
- _mesa_is_integer_format(format)) {
+ _mesa_is_enum_format_integer(format)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glTexSubImage%dD(integer/non-integer format mismatch)",
dimensions);
@@ -2042,8 +2043,8 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions,
if (_mesa_is_color_format(internalFormat)) {
struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
- if (_mesa_is_integer_format(rb->InternalFormat) !=
- _mesa_is_integer_format(internalFormat)) {
+ if (_mesa_is_enum_format_integer(rb->InternalFormat) !=
+ _mesa_is_enum_format_integer(internalFormat)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glCopyTexImage%dD(integer vs non-integer)", dimensions);
return GL_TRUE;
diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c
index 9abc503e3..1376219d7 100644
--- a/mesalib/src/mesa/main/texparam.c
+++ b/mesalib/src/mesa/main/texparam.c
@@ -35,7 +35,7 @@
#include "main/context.h"
#include "main/enums.h"
#include "main/formats.h"
-#include "main/image.h"
+#include "main/glformats.h"
#include "main/macros.h"
#include "main/mfeatures.h"
#include "main/mtypes.h"
diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c
index 1ced8aac9..ab9fdf26d 100644
--- a/mesalib/src/mesa/main/texstore.c
+++ b/mesalib/src/mesa/main/texstore.c
@@ -37,9 +37,8 @@
* However, most device drivers will be able to use the fallback functions
* in this file. That is, most drivers will have the following bit of
* code:
- * ctx->Driver.TexImage1D = _mesa_store_teximage1d;
- * ctx->Driver.TexImage2D = _mesa_store_teximage2d;
- * ctx->Driver.TexImage3D = _mesa_store_teximage3d;
+ * ctx->Driver.TexImage = _mesa_store_teximage;
+ * ctx->Driver.TexSubImage = _mesa_store_texsubimage;
* etc...
*
* Texture image processing is actually kind of complicated. We have to do:
@@ -72,6 +71,7 @@
#include "teximage.h"
#include "texstore.h"
#include "enums.h"
+#include "glformats.h"
#include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
#include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
@@ -3892,6 +3892,72 @@ _mesa_texstore_argb2101010_uint(TEXSTORE_PARAMS)
}
static GLboolean
+_mesa_texstore_abgr2101010_uint(TEXSTORE_PARAMS)
+{
+ const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+
+ ASSERT(dstFormat == MESA_FORMAT_ABGR2101010_UINT);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
+
+ if (baseInternalFormat == GL_RGBA &&
+ _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType,
+ srcPacking->SwapBytes)) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat,
+ dstRowStride, dstSlices,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLuint *tempImage = make_temp_uint_image(ctx, dims,
+ baseInternalFormat,
+ baseFormat,
+ srcWidth, srcHeight,
+ srcDepth, srcFormat,
+ srcType, srcAddr,
+ srcPacking);
+ const GLuint *src = tempImage;
+ GLint img, row, col;
+ GLboolean is_unsigned = _mesa_is_type_unsigned(srcType);
+ if (!tempImage)
+ return GL_FALSE;
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstSlices[img];
+
+ for (row = 0; row < srcHeight; row++) {
+ GLuint *dstUI = (GLuint *) dstRow;
+ if (is_unsigned) {
+ for (col = 0; col < srcWidth; col++) {
+ GLushort a,r,g,b;
+ r = MIN2(src[RCOMP], 0x3ff);
+ g = MIN2(src[GCOMP], 0x3ff);
+ b = MIN2(src[BCOMP], 0x3ff);
+ a = MIN2(src[ACOMP], 0x003);
+ dstUI[col] = (a << 30) | (b << 20) | (g << 10) | (r);
+ src += 4;
+ }
+ } else {
+ for (col = 0; col < srcWidth; col++) {
+ GLushort a,r,g,b;
+ r = CLAMP((GLint) src[RCOMP], 0, 0x3ff);
+ g = CLAMP((GLint) src[GCOMP], 0, 0x3ff);
+ b = CLAMP((GLint) src[BCOMP], 0, 0x3ff);
+ a = CLAMP((GLint) src[ACOMP], 0, 0x003);
+ dstUI[col] = (a << 30) | (b << 20) | (g << 10) | (r);
+ src += 4;
+ }
+ }
+ dstRow += dstRowStride;
+ }
+ }
+ free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+static GLboolean
_mesa_texstore_null(TEXSTORE_PARAMS)
{
(void) ctx; (void) dims;
@@ -4085,6 +4151,7 @@ _mesa_get_texstore_func(gl_format format)
table[MESA_FORMAT_RGBA_UINT32] = _mesa_texstore_rgba_uint32;
table[MESA_FORMAT_ARGB2101010_UINT] = _mesa_texstore_argb2101010_uint;
+ table[MESA_FORMAT_ABGR2101010_UINT] = _mesa_texstore_abgr2101010_uint;
initialized = GL_TRUE;
}
diff --git a/mesalib/src/mesa/main/uniform_query.cpp b/mesalib/src/mesa/main/uniform_query.cpp
index f5d998ffb..816c2779c 100644
--- a/mesalib/src/mesa/main/uniform_query.cpp
+++ b/mesalib/src/mesa/main/uniform_query.cpp
@@ -74,6 +74,79 @@ _mesa_GetActiveUniformARB(GLhandleARB program, GLuint index,
}
}
+extern "C" void GLAPIENTRY
+_mesa_GetActiveUniformsiv(GLuint program,
+ GLsizei uniformCount,
+ const GLuint *uniformIndices,
+ GLenum pname,
+ GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_shader_program *shProg;
+ GLsizei i;
+
+ shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveUniform");
+ if (!shProg)
+ return;
+
+ if (uniformCount < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetUniformIndices(uniformCount < 0)");
+ return;
+ }
+
+ for (i = 0; i < uniformCount; i++) {
+ GLuint index = uniformIndices[i];
+ const struct gl_uniform_storage *uni = &shProg->UniformStorage[index];
+
+ if (index >= shProg->NumUserUniformStorage) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveUniformsiv(index)");
+ return;
+ }
+
+ switch (pname) {
+ case GL_UNIFORM_TYPE:
+ params[i] = uni->type->gl_type;
+ break;
+
+ case GL_UNIFORM_SIZE:
+ /* array_elements is zero for non-arrays, but the API requires that 1 be
+ * returned.
+ */
+ params[i] = MAX2(1, uni->array_elements);
+ break;
+
+ case GL_UNIFORM_NAME_LENGTH:
+ params[i] = strlen(uni->name) + 1;
+ break;
+
+ case GL_UNIFORM_BLOCK_INDEX:
+ params[i] = uni->block_index;
+ break;
+
+ case GL_UNIFORM_OFFSET:
+ params[i] = uni->offset;
+ break;
+
+ case GL_UNIFORM_ARRAY_STRIDE:
+ params[i] = uni->array_stride;
+ break;
+
+ case GL_UNIFORM_MATRIX_STRIDE:
+ params[i] = uni->matrix_stride;
+ break;
+
+ case GL_UNIFORM_IS_ROW_MAJOR:
+ params[i] = uni->row_major;
+ break;
+
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetActiveUniformsiv(pname)");
+ return;
+ }
+ }
+}
+
static bool
validate_uniform_parameters(struct gl_context *ctx,
struct gl_shader_program *shProg,
@@ -852,13 +925,17 @@ _mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg,
/**
* Called via glGetUniformLocation().
*
- * The return value will encode two values, the uniform location and an
- * offset (used for arrays, structs).
+ * Returns the uniform index into UniformStorage (also the
+ * glGetActiveUniformsiv uniform index), and stores the referenced
+ * array offset in *offset, or GL_INVALID_INDEX (-1). Those two
+ * return values can be encoded into a uniform location for
+ * glUniform* using _mesa_uniform_merge_location_offset(index, offset).
*/
-extern "C" GLint
+extern "C" unsigned
_mesa_get_uniform_location(struct gl_context *ctx,
struct gl_shader_program *shProg,
- const GLchar *name)
+ const GLchar *name,
+ unsigned *out_offset)
{
const size_t len = strlen(name);
long offset;
@@ -901,13 +978,13 @@ _mesa_get_uniform_location(struct gl_context *ctx,
* (or other non-digit characters) before the opening '['.
*/
if ((i == 0) || name[i-1] != '[')
- return -1;
+ return GL_INVALID_INDEX;
/* Return an error if there are no digits between the opening '[' to
* match the closing ']'.
*/
if (i == (len - 1))
- return -1;
+ return GL_INVALID_INDEX;
/* Make a new string that is a copy of the old string up to (but not
* including) the '[' character.
@@ -919,7 +996,7 @@ _mesa_get_uniform_location(struct gl_context *ctx,
offset = strtol(&name[i], NULL, 10);
if (offset < 0) {
free(name_copy);
- return -1;
+ return GL_INVALID_INDEX;
}
array_lookup = true;
@@ -941,16 +1018,17 @@ _mesa_get_uniform_location(struct gl_context *ctx,
free(name_copy);
if (!found)
- return -1;
+ return GL_INVALID_INDEX;
/* Since array_elements is 0 for non-arrays, this causes look-ups of 'a[0]'
* to (correctly) fail if 'a' is not an array.
*/
if (array_lookup && shProg->UniformStorage[location].array_elements == 0) {
- return -1;
+ return GL_INVALID_INDEX;
}
- return _mesa_uniform_merge_location_offset(location, offset);
+ *out_offset = offset;
+ return location;
}
extern "C" bool
diff --git a/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c
index e6604b1a4..ccbd753db 100644
--- a/mesalib/src/mesa/main/uniforms.c
+++ b/mesalib/src/mesa/main/uniforms.c
@@ -497,6 +497,7 @@ GLint GLAPIENTRY
_mesa_GetUniformLocationARB(GLhandleARB programObj, const GLcharARB *name)
{
struct gl_shader_program *shProg;
+ GLuint index, offset;
GET_CURRENT_CONTEXT(ctx);
@@ -516,9 +517,71 @@ _mesa_GetUniformLocationARB(GLhandleARB programObj, const GLcharARB *name)
return -1;
}
- return _mesa_get_uniform_location(ctx, shProg, name);
+ index = _mesa_get_uniform_location(ctx, shProg, name, &offset);
+ if (index == GL_INVALID_INDEX)
+ return -1;
+
+ return _mesa_uniform_merge_location_offset(index, offset);
}
+static GLuint GLAPIENTRY
+_mesa_GetUniformBlockIndex(GLuint program,
+ const GLchar *uniformBlockName)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint i;
+ struct gl_shader_program *shProg;
+
+ if (!ctx->Extensions.ARB_uniform_buffer_object) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformBlockIndex");
+ return GL_INVALID_INDEX;
+ }
+
+ shProg = _mesa_lookup_shader_program_err(ctx, program,
+ "glGetUniformBlockIndex");
+ if (!shProg)
+ return GL_INVALID_INDEX;
+
+ for (i = 0; i < shProg->NumUniformBlocks; i++) {
+ if (!strcmp(shProg->UniformBlocks[i].Name, uniformBlockName))
+ return i;
+ }
+
+ return GL_INVALID_INDEX;
+}
+
+static void GLAPIENTRY
+_mesa_GetUniformIndices(GLuint program,
+ GLsizei uniformCount,
+ const GLchar * const *uniformNames,
+ GLuint *uniformIndices)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLsizei i;
+ struct gl_shader_program *shProg;
+
+ if (!ctx->Extensions.ARB_uniform_buffer_object) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformIndices");
+ return;
+ }
+
+ shProg = _mesa_lookup_shader_program_err(ctx, program,
+ "glGetUniformIndices");
+ if (!shProg)
+ return;
+
+ if (uniformCount < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetUniformIndices(uniformCount < 0)");
+ return;
+ }
+
+ for (i = 0; i < uniformCount; i++) {
+ unsigned offset;
+ uniformIndices[i] = _mesa_get_uniform_location(ctx, shProg,
+ uniformNames[i], &offset);
+ }
+}
/**
* Plug in shader uniform-related functions into API dispatch table.
@@ -577,5 +640,10 @@ _mesa_init_shader_uniform_dispatch(struct _glapi_table *exec)
SET_GetnUniformuivARB(exec, _mesa_GetnUniformuivARB);
SET_GetnUniformdvARB(exec, _mesa_GetnUniformdvARB); /* GL 4.0 */
+ /* GL_ARB_uniform_buffer_object / GL 3.1 */
+ SET_GetUniformBlockIndex(exec, _mesa_GetUniformBlockIndex);
+ SET_GetUniformIndices(exec, _mesa_GetUniformIndices);
+ SET_GetActiveUniformsiv(exec, _mesa_GetActiveUniformsiv);
+
#endif /* FEATURE_GL */
}
diff --git a/mesalib/src/mesa/main/uniforms.h b/mesalib/src/mesa/main/uniforms.h
index 7b512a527..bb0552476 100644
--- a/mesalib/src/mesa/main/uniforms.h
+++ b/mesalib/src/mesa/main/uniforms.h
@@ -150,6 +150,13 @@ _mesa_GetActiveUniformARB(GLhandleARB, GLuint, GLsizei, GLsizei *,
GLint *, GLenum *, GLcharARB *);
extern void GLAPIENTRY
+_mesa_GetActiveUniformsiv(GLuint program,
+ GLsizei uniformCount,
+ const GLuint *uniformIndices,
+ GLenum pname,
+ GLint *params);
+
+extern void GLAPIENTRY
_mesa_GetUniformfvARB(GLhandleARB, GLint, GLfloat *);
extern void GLAPIENTRY
@@ -176,9 +183,9 @@ _mesa_GetnUniformdvARB(GLhandleARB, GLint, GLsizei, GLdouble *);
extern GLint GLAPIENTRY
_mesa_GetUniformLocationARB(GLhandleARB, const GLcharARB *);
-GLint
+unsigned
_mesa_get_uniform_location(struct gl_context *ctx, struct gl_shader_program *shProg,
- const GLchar *name);
+ const GLchar *name, unsigned *offset);
void
_mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shader_program,
diff --git a/mesalib/src/mesa/main/varray.c b/mesalib/src/mesa/main/varray.c
index efa63b07c..7ec7cfee6 100644
--- a/mesalib/src/mesa/main/varray.c
+++ b/mesalib/src/mesa/main/varray.c
@@ -92,7 +92,7 @@ type_to_bit(const struct gl_context *ctx, GLenum type)
case GL_DOUBLE:
return DOUBLE_BIT;
case GL_FIXED:
- return ctx->API == API_OPENGL ? FIXED_GL_BIT : FIXED_ES_BIT;
+ return _mesa_is_desktop_gl(ctx) ? FIXED_GL_BIT : FIXED_ES_BIT;
case GL_UNSIGNED_INT_2_10_10_10_REV:
return UNSIGNED_INT_2_10_10_10_REV_BIT;
case GL_INT_2_10_10_10_REV:
diff --git a/mesalib/src/mesa/main/version.c b/mesalib/src/mesa/main/version.c
index 38d2b3398..0fe3a8412 100644
--- a/mesalib/src/mesa/main/version.c
+++ b/mesalib/src/mesa/main/version.c
@@ -315,6 +315,7 @@ _mesa_compute_version(struct gl_context *ctx)
switch (ctx->API) {
case API_OPENGL:
+ case API_OPENGL_CORE:
compute_version(ctx);
break;
case API_OPENGLES:
diff --git a/mesalib/src/mesa/main/vtxfmt.c b/mesalib/src/mesa/main/vtxfmt.c
index bf7a54c0a..ce490ed9e 100644
--- a/mesalib/src/mesa/main/vtxfmt.c
+++ b/mesalib/src/mesa/main/vtxfmt.c
@@ -45,57 +45,64 @@
* API dispatch table.
*/
static void
-install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt )
+install_vtxfmt(struct gl_context *ctx, struct _glapi_table *tab,
+ const GLvertexformat *vfmt)
{
_mesa_install_arrayelt_vtxfmt(tab, vfmt);
- SET_Color3f(tab, vfmt->Color3f);
- SET_Color3fv(tab, vfmt->Color3fv);
- SET_Color4f(tab, vfmt->Color4f);
- SET_Color4fv(tab, vfmt->Color4fv);
- SET_EdgeFlag(tab, vfmt->EdgeFlag);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_Color3f(tab, vfmt->Color3f);
+ SET_Color3fv(tab, vfmt->Color3fv);
+ SET_Color4f(tab, vfmt->Color4f);
+ SET_Color4fv(tab, vfmt->Color4fv);
+ SET_EdgeFlag(tab, vfmt->EdgeFlag);
+ }
_mesa_install_eval_vtxfmt(tab, vfmt);
- SET_FogCoordfEXT(tab, vfmt->FogCoordfEXT);
- SET_FogCoordfvEXT(tab, vfmt->FogCoordfvEXT);
- SET_Indexf(tab, vfmt->Indexf);
- SET_Indexfv(tab, vfmt->Indexfv);
- SET_Materialfv(tab, vfmt->Materialfv);
- SET_MultiTexCoord1fARB(tab, vfmt->MultiTexCoord1fARB);
- SET_MultiTexCoord1fvARB(tab, vfmt->MultiTexCoord1fvARB);
- SET_MultiTexCoord2fARB(tab, vfmt->MultiTexCoord2fARB);
- SET_MultiTexCoord2fvARB(tab, vfmt->MultiTexCoord2fvARB);
- SET_MultiTexCoord3fARB(tab, vfmt->MultiTexCoord3fARB);
- SET_MultiTexCoord3fvARB(tab, vfmt->MultiTexCoord3fvARB);
- SET_MultiTexCoord4fARB(tab, vfmt->MultiTexCoord4fARB);
- SET_MultiTexCoord4fvARB(tab, vfmt->MultiTexCoord4fvARB);
- SET_Normal3f(tab, vfmt->Normal3f);
- SET_Normal3fv(tab, vfmt->Normal3fv);
- SET_SecondaryColor3fEXT(tab, vfmt->SecondaryColor3fEXT);
- SET_SecondaryColor3fvEXT(tab, vfmt->SecondaryColor3fvEXT);
- SET_TexCoord1f(tab, vfmt->TexCoord1f);
- SET_TexCoord1fv(tab, vfmt->TexCoord1fv);
- SET_TexCoord2f(tab, vfmt->TexCoord2f);
- SET_TexCoord2fv(tab, vfmt->TexCoord2fv);
- SET_TexCoord3f(tab, vfmt->TexCoord3f);
- SET_TexCoord3fv(tab, vfmt->TexCoord3fv);
- SET_TexCoord4f(tab, vfmt->TexCoord4f);
- SET_TexCoord4fv(tab, vfmt->TexCoord4fv);
- SET_Vertex2f(tab, vfmt->Vertex2f);
- SET_Vertex2fv(tab, vfmt->Vertex2fv);
- SET_Vertex3f(tab, vfmt->Vertex3f);
- SET_Vertex3fv(tab, vfmt->Vertex3fv);
- SET_Vertex4f(tab, vfmt->Vertex4f);
- SET_Vertex4fv(tab, vfmt->Vertex4fv);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_FogCoordfEXT(tab, vfmt->FogCoordfEXT);
+ SET_FogCoordfvEXT(tab, vfmt->FogCoordfvEXT);
+ SET_Indexf(tab, vfmt->Indexf);
+ SET_Indexfv(tab, vfmt->Indexfv);
+ SET_Materialfv(tab, vfmt->Materialfv);
+ SET_MultiTexCoord1fARB(tab, vfmt->MultiTexCoord1fARB);
+ SET_MultiTexCoord1fvARB(tab, vfmt->MultiTexCoord1fvARB);
+ SET_MultiTexCoord2fARB(tab, vfmt->MultiTexCoord2fARB);
+ SET_MultiTexCoord2fvARB(tab, vfmt->MultiTexCoord2fvARB);
+ SET_MultiTexCoord3fARB(tab, vfmt->MultiTexCoord3fARB);
+ SET_MultiTexCoord3fvARB(tab, vfmt->MultiTexCoord3fvARB);
+ SET_MultiTexCoord4fARB(tab, vfmt->MultiTexCoord4fARB);
+ SET_MultiTexCoord4fvARB(tab, vfmt->MultiTexCoord4fvARB);
+ SET_Normal3f(tab, vfmt->Normal3f);
+ SET_Normal3fv(tab, vfmt->Normal3fv);
+ SET_SecondaryColor3fEXT(tab, vfmt->SecondaryColor3fEXT);
+ SET_SecondaryColor3fvEXT(tab, vfmt->SecondaryColor3fvEXT);
+ SET_TexCoord1f(tab, vfmt->TexCoord1f);
+ SET_TexCoord1fv(tab, vfmt->TexCoord1fv);
+ SET_TexCoord2f(tab, vfmt->TexCoord2f);
+ SET_TexCoord2fv(tab, vfmt->TexCoord2fv);
+ SET_TexCoord3f(tab, vfmt->TexCoord3f);
+ SET_TexCoord3fv(tab, vfmt->TexCoord3fv);
+ SET_TexCoord4f(tab, vfmt->TexCoord4f);
+ SET_TexCoord4fv(tab, vfmt->TexCoord4fv);
+ SET_Vertex2f(tab, vfmt->Vertex2f);
+ SET_Vertex2fv(tab, vfmt->Vertex2fv);
+ SET_Vertex3f(tab, vfmt->Vertex3f);
+ SET_Vertex3fv(tab, vfmt->Vertex3fv);
+ SET_Vertex4f(tab, vfmt->Vertex4f);
+ SET_Vertex4fv(tab, vfmt->Vertex4fv);
+ }
_mesa_install_dlist_vtxfmt(tab, vfmt); /* glCallList / glCallLists */
- SET_Begin(tab, vfmt->Begin);
- SET_End(tab, vfmt->End);
- SET_PrimitiveRestartNV(tab, vfmt->PrimitiveRestartNV);
+ if (ctx->API != API_OPENGL_CORE) {
+ SET_Begin(tab, vfmt->Begin);
+ SET_End(tab, vfmt->End);
+ SET_PrimitiveRestartNV(tab, vfmt->PrimitiveRestartNV);
- SET_Rectf(tab, vfmt->Rectf);
+ SET_Rectf(tab, vfmt->Rectf);
+ }
SET_DrawArrays(tab, vfmt->DrawArrays);
SET_DrawElements(tab, vfmt->DrawElements);
@@ -154,42 +161,44 @@ install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt )
SET_VertexAttribI3uivEXT(tab, vfmt->VertexAttribI3uiv);
SET_VertexAttribI4uivEXT(tab, vfmt->VertexAttribI4uiv);
- /* GL_ARB_vertex_type_10_10_10_2_rev / GL 3.3 */
- SET_VertexP2ui(tab, vfmt->VertexP2ui);
- SET_VertexP2uiv(tab, vfmt->VertexP2uiv);
- SET_VertexP3ui(tab, vfmt->VertexP3ui);
- SET_VertexP3uiv(tab, vfmt->VertexP3uiv);
- SET_VertexP4ui(tab, vfmt->VertexP4ui);
- SET_VertexP4uiv(tab, vfmt->VertexP4uiv);
-
- SET_TexCoordP1ui(tab, vfmt->TexCoordP1ui);
- SET_TexCoordP1uiv(tab, vfmt->TexCoordP1uiv);
- SET_TexCoordP2ui(tab, vfmt->TexCoordP2ui);
- SET_TexCoordP2uiv(tab, vfmt->TexCoordP2uiv);
- SET_TexCoordP3ui(tab, vfmt->TexCoordP3ui);
- SET_TexCoordP3uiv(tab, vfmt->TexCoordP3uiv);
- SET_TexCoordP4ui(tab, vfmt->TexCoordP4ui);
- SET_TexCoordP4uiv(tab, vfmt->TexCoordP4uiv);
-
- SET_MultiTexCoordP1ui(tab, vfmt->MultiTexCoordP1ui);
- SET_MultiTexCoordP2ui(tab, vfmt->MultiTexCoordP2ui);
- SET_MultiTexCoordP3ui(tab, vfmt->MultiTexCoordP3ui);
- SET_MultiTexCoordP4ui(tab, vfmt->MultiTexCoordP4ui);
- SET_MultiTexCoordP1uiv(tab, vfmt->MultiTexCoordP1uiv);
- SET_MultiTexCoordP2uiv(tab, vfmt->MultiTexCoordP2uiv);
- SET_MultiTexCoordP3uiv(tab, vfmt->MultiTexCoordP3uiv);
- SET_MultiTexCoordP4uiv(tab, vfmt->MultiTexCoordP4uiv);
-
- SET_NormalP3ui(tab, vfmt->NormalP3ui);
- SET_NormalP3uiv(tab, vfmt->NormalP3uiv);
-
- SET_ColorP3ui(tab, vfmt->ColorP3ui);
- SET_ColorP4ui(tab, vfmt->ColorP4ui);
- SET_ColorP3uiv(tab, vfmt->ColorP3uiv);
- SET_ColorP4uiv(tab, vfmt->ColorP4uiv);
-
- SET_SecondaryColorP3ui(tab, vfmt->SecondaryColorP3ui);
- SET_SecondaryColorP3uiv(tab, vfmt->SecondaryColorP3uiv);
+ if (ctx->API != API_OPENGL_CORE) {
+ /* GL_ARB_vertex_type_10_10_10_2_rev / GL 3.3 */
+ SET_VertexP2ui(tab, vfmt->VertexP2ui);
+ SET_VertexP2uiv(tab, vfmt->VertexP2uiv);
+ SET_VertexP3ui(tab, vfmt->VertexP3ui);
+ SET_VertexP3uiv(tab, vfmt->VertexP3uiv);
+ SET_VertexP4ui(tab, vfmt->VertexP4ui);
+ SET_VertexP4uiv(tab, vfmt->VertexP4uiv);
+
+ SET_TexCoordP1ui(tab, vfmt->TexCoordP1ui);
+ SET_TexCoordP1uiv(tab, vfmt->TexCoordP1uiv);
+ SET_TexCoordP2ui(tab, vfmt->TexCoordP2ui);
+ SET_TexCoordP2uiv(tab, vfmt->TexCoordP2uiv);
+ SET_TexCoordP3ui(tab, vfmt->TexCoordP3ui);
+ SET_TexCoordP3uiv(tab, vfmt->TexCoordP3uiv);
+ SET_TexCoordP4ui(tab, vfmt->TexCoordP4ui);
+ SET_TexCoordP4uiv(tab, vfmt->TexCoordP4uiv);
+
+ SET_MultiTexCoordP1ui(tab, vfmt->MultiTexCoordP1ui);
+ SET_MultiTexCoordP2ui(tab, vfmt->MultiTexCoordP2ui);
+ SET_MultiTexCoordP3ui(tab, vfmt->MultiTexCoordP3ui);
+ SET_MultiTexCoordP4ui(tab, vfmt->MultiTexCoordP4ui);
+ SET_MultiTexCoordP1uiv(tab, vfmt->MultiTexCoordP1uiv);
+ SET_MultiTexCoordP2uiv(tab, vfmt->MultiTexCoordP2uiv);
+ SET_MultiTexCoordP3uiv(tab, vfmt->MultiTexCoordP3uiv);
+ SET_MultiTexCoordP4uiv(tab, vfmt->MultiTexCoordP4uiv);
+
+ SET_NormalP3ui(tab, vfmt->NormalP3ui);
+ SET_NormalP3uiv(tab, vfmt->NormalP3uiv);
+
+ SET_ColorP3ui(tab, vfmt->ColorP3ui);
+ SET_ColorP4ui(tab, vfmt->ColorP4ui);
+ SET_ColorP3uiv(tab, vfmt->ColorP3uiv);
+ SET_ColorP4uiv(tab, vfmt->ColorP4uiv);
+
+ SET_SecondaryColorP3ui(tab, vfmt->SecondaryColorP3ui);
+ SET_SecondaryColorP3uiv(tab, vfmt->SecondaryColorP3uiv);
+ }
SET_VertexAttribP1ui(tab, vfmt->VertexAttribP1ui);
SET_VertexAttribP2ui(tab, vfmt->VertexAttribP2ui);
@@ -209,8 +218,8 @@ install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt )
void
_mesa_install_exec_vtxfmt(struct gl_context *ctx, const GLvertexformat *vfmt)
{
- if (ctx->API == API_OPENGL)
- install_vtxfmt( ctx->Exec, vfmt );
+ if (_mesa_is_desktop_gl(ctx))
+ install_vtxfmt( ctx, ctx->Exec, vfmt );
}
@@ -221,8 +230,8 @@ _mesa_install_exec_vtxfmt(struct gl_context *ctx, const GLvertexformat *vfmt)
void
_mesa_install_save_vtxfmt(struct gl_context *ctx, const GLvertexformat *vfmt)
{
- if (ctx->API == API_OPENGL)
- install_vtxfmt( ctx->Save, vfmt );
+ if (_mesa_is_desktop_gl(ctx))
+ install_vtxfmt( ctx, ctx->Save, vfmt );
}
diff --git a/mesalib/src/mesa/math/m_debug_norm.c b/mesalib/src/mesa/math/m_debug_norm.c
index 02eb1f989..dc768f306 100644
--- a/mesalib/src/mesa/math/m_debug_norm.c
+++ b/mesalib/src/mesa/math/m_debug_norm.c
@@ -165,7 +165,7 @@ static void ref_norm_transform_normalize( const GLmatrix *mat,
/* Hmmm, don't know how we could test the precalculated
* length case...
*/
- scale = 1.0 / SQRTF( len );
+ scale = INV_SQRTF( len );
SCALE_SCALAR_3V( out[i], scale, t );
} else {
out[i][0] = out[i][1] = out[i][2] = 0;
@@ -241,7 +241,7 @@ static int test_norm_function( normal_func func, int mtype, long *cycles )
ASSIGN_3V( d2[i], 0.0, 0.0, 0.0 );
for ( j = 0 ; j < 3 ; j++ )
s[i][j] = rnd();
- length[i] = 1 / SQRTF( LEN_SQUARED_3FV( s[i] ) );
+ length[i] = INV_SQRTF( LEN_SQUARED_3FV( s[i] ) );
}
source->data = (GLfloat(*)[4]) s;
diff --git a/mesalib/src/mesa/math/m_matrix.c b/mesalib/src/mesa/math/m_matrix.c
index 02aedbad8..00a6c814f 100644
--- a/mesalib/src/mesa/math/m_matrix.c
+++ b/mesalib/src/mesa/math/m_matrix.c
@@ -45,7 +45,6 @@
* \defgroup MatFlags MAT_FLAG_XXX-flags
*
* Bitmasks to indicate different kinds of 4x4 matrices in GLmatrix::flags
- * It would be nice to make all these flags private to m_matrix.c
*/
/*@{*/
#define MAT_FLAG_IDENTITY 0 /**< is an identity matrix flag.
@@ -296,19 +295,15 @@ static void print_matrix_floats( const GLfloat m[16] )
void
_math_matrix_print( const GLmatrix *m )
{
+ GLfloat prod[16];
+
_mesa_debug(NULL, "Matrix type: %s, flags: %x\n", types[m->type], m->flags);
print_matrix_floats(m->m);
_mesa_debug(NULL, "Inverse: \n");
- if (m->inv) {
- GLfloat prod[16];
- print_matrix_floats(m->inv);
- matmul4(prod, m->m, m->inv);
- _mesa_debug(NULL, "Mat * Inverse:\n");
- print_matrix_floats(prod);
- }
- else {
- _mesa_debug(NULL, " - not available\n");
- }
+ print_matrix_floats(m->inv);
+ matmul4(prod, m->m, m->inv);
+ _mesa_debug(NULL, "Mat * Inverse:\n");
+ print_matrix_floats(prod);
}
/*@}*/
@@ -333,7 +328,7 @@ _math_matrix_print( const GLmatrix *m )
/*@{*/
/**
- * Swaps the values of two floating pointer variables.
+ * Swaps the values of two floating point variables.
*
* Used by invert_matrix_general() to swap the row pointers.
*/
@@ -513,7 +508,7 @@ static GLboolean invert_matrix_3d_general( GLmatrix *mat )
det = pos + neg;
- if (det*det < 1e-25)
+ if (FABSF(det) < 1e-25)
return GL_FALSE;
det = 1.0F / det;
@@ -1141,9 +1136,7 @@ void
_math_matrix_set_identity( GLmatrix *mat )
{
memcpy( mat->m, Identity, 16*sizeof(GLfloat) );
-
- if (mat->inv)
- memcpy( mat->inv, Identity, 16*sizeof(GLfloat) );
+ memcpy( mat->inv, Identity, 16*sizeof(GLfloat) );
mat->type = MATRIX_IDENTITY;
mat->flags &= ~(MAT_DIRTY_FLAGS|
@@ -1444,17 +1437,9 @@ void
_math_matrix_copy( GLmatrix *to, const GLmatrix *from )
{
memcpy( to->m, from->m, sizeof(Identity) );
+ memcpy(to->inv, from->inv, 16 * sizeof(GLfloat));
to->flags = from->flags;
to->type = from->type;
-
- if (to->inv != 0) {
- if (from->inv == 0) {
- matrix_invert( to );
- }
- else {
- memcpy(to->inv, from->inv, sizeof(GLfloat)*16);
- }
- }
}
/**
@@ -1486,7 +1471,9 @@ _math_matrix_ctr( GLmatrix *m )
m->m = (GLfloat *) _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
if (m->m)
memcpy( m->m, Identity, sizeof(Identity) );
- m->inv = NULL;
+ m->inv = (GLfloat *) _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
+ if (m->inv)
+ memcpy( m->inv, Identity, sizeof(Identity) );
m->type = MATRIX_IDENTITY;
m->flags = 0;
}
@@ -1511,23 +1498,6 @@ _math_matrix_dtr( GLmatrix *m )
}
}
-/**
- * Allocate a matrix inverse.
- *
- * \param m matrix.
- *
- * Allocates the matrix inverse, GLmatrix::inv, and sets it to Identity.
- */
-void
-_math_matrix_alloc_inv( GLmatrix *m )
-{
- if (!m->inv) {
- m->inv = (GLfloat *) _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
- if (m->inv)
- memcpy( m->inv, Identity, 16 * sizeof(GLfloat) );
- }
-}
-
/*@}*/
diff --git a/mesalib/src/mesa/math/m_matrix.h b/mesalib/src/mesa/math/m_matrix.h
index e8e48aab7..9f4ea2586 100644
--- a/mesalib/src/mesa/math/m_matrix.h
+++ b/mesalib/src/mesa/math/m_matrix.h
@@ -74,7 +74,7 @@ enum GLmatrixtype {
*/
typedef struct {
GLfloat *m; /**< 16 matrix elements (16-byte aligned) */
- GLfloat *inv; /**< optional 16-element inverse (16-byte aligned) */
+ GLfloat *inv; /**< 16-element inverse (16-byte aligned) */
GLuint flags; /**< possible values determined by (of \link
* MatFlags MAT_FLAG_* flags\endlink)
*/
@@ -91,9 +91,6 @@ extern void
_math_matrix_dtr( GLmatrix *m );
extern void
-_math_matrix_alloc_inv( GLmatrix *m );
-
-extern void
_math_matrix_mul_matrix( GLmatrix *dest, const GLmatrix *a, const GLmatrix *b );
extern void
diff --git a/mesalib/src/mesa/program/arbprogparse.c b/mesalib/src/mesa/program/arbprogparse.c
index dffc8abf7..72e51dd0f 100644
--- a/mesalib/src/mesa/program/arbprogparse.c
+++ b/mesalib/src/mesa/program/arbprogparse.c
@@ -120,6 +120,7 @@ _mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target,
program->PixelCenterInteger = state.option.PixelCenterInteger;
program->UsesKill = state.fragment.UsesKill;
+ program->UsesDFdy = state.fragment.UsesDFdy;
if (program->Base.Instructions)
free(program->Base.Instructions);
diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp
index 217a26455..baa317204 100644
--- a/mesalib/src/mesa/program/ir_to_mesa.cpp
+++ b/mesalib/src/mesa/program/ir_to_mesa.cpp
@@ -2157,8 +2157,6 @@ ir_to_mesa_visitor::visit(ir_return *ir)
void
ir_to_mesa_visitor::visit(ir_discard *ir)
{
- struct gl_fragment_program *fp = (struct gl_fragment_program *)this->prog;
-
if (ir->condition) {
ir->condition->accept(this);
this->result.negate = ~this->result.negate;
@@ -2166,8 +2164,6 @@ ir_to_mesa_visitor::visit(ir_discard *ir)
} else {
emit(ir, OPCODE_KIL_NV);
}
-
- fp->UsesKill = GL_TRUE;
}
void
@@ -3119,6 +3115,12 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader)
}
}
+ if (shader->UniformBlocks)
+ ralloc_free(shader->UniformBlocks);
+ shader->NumUniformBlocks = state->num_uniform_blocks;
+ shader->UniformBlocks = state->uniform_blocks;
+ ralloc_steal(shader, shader->UniformBlocks);
+
/* Retain any live IR, but trash the rest. */
reparent_ir(shader->ir, shader->ir);
diff --git a/mesalib/src/mesa/program/prog_statevars.c b/mesalib/src/mesa/program/prog_statevars.c
index 98ab9d003..3d1338674 100644
--- a/mesalib/src/mesa/program/prog_statevars.c
+++ b/mesalib/src/mesa/program/prog_statevars.c
@@ -34,6 +34,7 @@
#include "main/imports.h"
#include "main/macros.h"
#include "main/mtypes.h"
+#include "main/fbobject.h"
#include "prog_statevars.h"
#include "prog_parameter.h"
@@ -322,7 +323,6 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
modifier == STATE_MATRIX_INVTRANS) {
/* Be sure inverse is up to date:
*/
- _math_matrix_alloc_inv( (GLmatrix *) matrix );
_math_matrix_analyse( (GLmatrix*) matrix );
m = matrix->inv;
}
@@ -574,7 +574,7 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
case STATE_FB_WPOS_Y_TRANSFORM:
/* A driver may negate this conditional by using ZW swizzle
* instead of XY (based on e.g. some other state). */
- if (ctx->DrawBuffer->Name != 0) {
+ if (_mesa_is_user_fbo(ctx->DrawBuffer)) {
/* Identity (XY) followed by flipping Y upside down (ZW). */
value[0] = 1.0F;
value[1] = 0.0F;
diff --git a/mesalib/src/mesa/program/program.c b/mesalib/src/mesa/program/program.c
index 582cbccf8..15337f4d8 100644
--- a/mesalib/src/mesa/program/program.c
+++ b/mesalib/src/mesa/program/program.c
@@ -169,22 +169,19 @@ _mesa_update_default_objects_program(struct gl_context *ctx)
{
#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
_mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current,
- (struct gl_vertex_program *)
ctx->Shared->DefaultVertexProgram);
assert(ctx->VertexProgram.Current);
#endif
#if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current,
- (struct gl_fragment_program *)
ctx->Shared->DefaultFragmentProgram);
assert(ctx->FragmentProgram.Current);
#endif
#if FEATURE_ARB_geometry_shader4
_mesa_reference_geomprog(ctx, &ctx->GeometryProgram.Current,
- (struct gl_geometry_program *)
- ctx->Shared->DefaultGeometryProgram);
+ ctx->Shared->DefaultGeometryProgram);
#endif
/* XXX probably move this stuff */
@@ -538,28 +535,26 @@ _mesa_clone_program(struct gl_context *ctx, const struct gl_program *prog)
switch (prog->Target) {
case GL_VERTEX_PROGRAM_ARB:
{
- const struct gl_vertex_program *vp
- = (const struct gl_vertex_program *) prog;
- struct gl_vertex_program *vpc = (struct gl_vertex_program *) clone;
+ const struct gl_vertex_program *vp = gl_vertex_program_const(prog);
+ struct gl_vertex_program *vpc = gl_vertex_program(clone);
vpc->IsPositionInvariant = vp->IsPositionInvariant;
vpc->IsNVProgram = vp->IsNVProgram;
}
break;
case GL_FRAGMENT_PROGRAM_ARB:
{
- const struct gl_fragment_program *fp
- = (const struct gl_fragment_program *) prog;
- struct gl_fragment_program *fpc = (struct gl_fragment_program *) clone;
+ const struct gl_fragment_program *fp = gl_fragment_program_const(prog);
+ struct gl_fragment_program *fpc = gl_fragment_program(clone);
fpc->UsesKill = fp->UsesKill;
+ fpc->UsesDFdy = fp->UsesDFdy;
fpc->OriginUpperLeft = fp->OriginUpperLeft;
fpc->PixelCenterInteger = fp->PixelCenterInteger;
}
break;
case MESA_GEOMETRY_PROGRAM:
{
- const struct gl_geometry_program *gp
- = (const struct gl_geometry_program *) prog;
- struct gl_geometry_program *gpc = (struct gl_geometry_program *) clone;
+ const struct gl_geometry_program *gp = gl_geometry_program_const(prog);
+ struct gl_geometry_program *gpc = gl_geometry_program(clone);
gpc->VerticesOut = gp->VerticesOut;
gpc->InputType = gp->InputType;
gpc->OutputType = gp->OutputType;
@@ -763,15 +758,17 @@ _mesa_combine_programs(struct gl_context *ctx,
usedTemps, MAX_PROGRAM_TEMPS);
if (newProg->Target == GL_FRAGMENT_PROGRAM_ARB) {
- struct gl_fragment_program *fprogA, *fprogB, *newFprog;
+ const struct gl_fragment_program *fprogA, *fprogB;
+ struct gl_fragment_program *newFprog;
GLbitfield progB_inputsRead = progB->InputsRead;
GLint progB_colorFile, progB_colorIndex;
- fprogA = (struct gl_fragment_program *) progA;
- fprogB = (struct gl_fragment_program *) progB;
- newFprog = (struct gl_fragment_program *) newProg;
+ fprogA = gl_fragment_program_const(progA);
+ fprogB = gl_fragment_program_const(progB);
+ newFprog = gl_fragment_program(newProg);
newFprog->UsesKill = fprogA->UsesKill || fprogB->UsesKill;
+ newFprog->UsesDFdy = fprogA->UsesDFdy || fprogB->UsesDFdy;
/* We'll do a search and replace for instances
* of progB_colorFile/progB_colorIndex below...
diff --git a/mesalib/src/mesa/program/program.h b/mesalib/src/mesa/program/program.h
index 9cd1780b8..c5650c519 100644
--- a/mesalib/src/mesa/program/program.h
+++ b/mesalib/src/mesa/program/program.h
@@ -183,13 +183,11 @@ _mesa_valid_register_index(const struct gl_context *ctx,
extern void
_mesa_postprocess_program(struct gl_context *ctx, struct gl_program *prog);
-/* keep these in the same order as TGSI_PROCESSOR_* */
static inline GLuint
_mesa_program_target_to_index(GLenum v)
{
- switch(v)
- {
+ switch (v) {
case GL_VERTEX_PROGRAM_ARB:
return MESA_SHADER_VERTEX;
case GL_FRAGMENT_PROGRAM_ARB:
@@ -205,10 +203,10 @@ _mesa_program_target_to_index(GLenum v)
static inline GLenum
_mesa_program_index_to_target(GLuint i)
{
- GLenum enums[MESA_SHADER_TYPES] = {
- GL_VERTEX_PROGRAM_ARB,
- GL_FRAGMENT_PROGRAM_ARB,
- GL_GEOMETRY_PROGRAM_NV,
+ static const GLenum enums[MESA_SHADER_TYPES] = {
+ GL_VERTEX_PROGRAM_ARB,
+ GL_FRAGMENT_PROGRAM_ARB,
+ GL_GEOMETRY_PROGRAM_NV,
};
if(i >= MESA_SHADER_TYPES)
return 0;
@@ -216,4 +214,46 @@ _mesa_program_index_to_target(GLuint i)
return enums[i];
}
+
+/* Cast wrappers from gl_program to gl_vertex/geometry/fragment_program */
+
+static inline struct gl_fragment_program *
+gl_fragment_program(struct gl_program *prog)
+{
+ return (struct gl_fragment_program *) prog;
+}
+
+static inline const struct gl_fragment_program *
+gl_fragment_program_const(const struct gl_program *prog)
+{
+ return (const struct gl_fragment_program *) prog;
+}
+
+
+static inline struct gl_vertex_program *
+gl_vertex_program(struct gl_program *prog)
+{
+ return (struct gl_vertex_program *) prog;
+}
+
+static inline const struct gl_vertex_program *
+gl_vertex_program_const(const struct gl_program *prog)
+{
+ return (const struct gl_vertex_program *) prog;
+}
+
+
+static inline struct gl_geometry_program *
+gl_geometry_program(struct gl_program *prog)
+{
+ return (struct gl_geometry_program *) prog;
+}
+
+static inline const struct gl_geometry_program *
+gl_geometry_program_const(const struct gl_program *prog)
+{
+ return (const struct gl_geometry_program *) prog;
+}
+
+
#endif /* PROGRAM_H */
diff --git a/mesalib/src/mesa/program/program_parse.y b/mesalib/src/mesa/program/program_parse.y
index 4f958a993..54b17314a 100644
--- a/mesalib/src/mesa/program/program_parse.y
+++ b/mesalib/src/mesa/program/program_parse.y
@@ -382,6 +382,8 @@ ARL_instruction: ARL maskedAddrReg ',' scalarSrcReg
VECTORop_instruction: VECTOR_OP maskedDstReg ',' swizzleSrcReg
{
+ if ($1.Opcode == OPCODE_DDY)
+ state->fragment.UsesDFdy = 1;
$$ = asm_instruction_copy_ctor(& $1, & $2, & $4, NULL, NULL);
}
;
diff --git a/mesalib/src/mesa/program/program_parser.h b/mesalib/src/mesa/program/program_parser.h
index bc756148a..ca36bb6dc 100644
--- a/mesalib/src/mesa/program/program_parser.h
+++ b/mesalib/src/mesa/program/program_parser.h
@@ -214,6 +214,7 @@ struct asm_parser_state {
struct {
unsigned UsesKill:1;
+ unsigned UsesDFdy:1;
} fragment;
};
diff --git a/mesalib/src/mesa/sources.mak b/mesalib/src/mesa/sources.mak
index d22f0595c..ce248dea1 100644
--- a/mesalib/src/mesa/sources.mak
+++ b/mesalib/src/mesa/sources.mak
@@ -1,319 +1,321 @@
### Lists of source files, included by Makefiles
-SRCDIR ?= .
+# This file is among different build systems. SRCDIR must be defined with
+# a trailing slash because the Android build system leaves it undefined.
# this is part of MAIN_FILES
MAIN_ES_FILES = \
- $(SRCDIR)/main/api_exec_es1.c \
- $(SRCDIR)/main/api_exec_es2.c
+ $(SRCDIR)main/api_exec_es1.c \
+ $(SRCDIR)main/api_exec_es2.c
MAIN_FILES = \
- $(SRCDIR)/main/api_arrayelt.c \
- $(SRCDIR)/main/api_exec.c \
- $(SRCDIR)/main/api_loopback.c \
- $(SRCDIR)/main/api_validate.c \
- $(SRCDIR)/main/accum.c \
- $(SRCDIR)/main/arbprogram.c \
- $(SRCDIR)/main/atifragshader.c \
- $(SRCDIR)/main/attrib.c \
- $(SRCDIR)/main/arrayobj.c \
- $(SRCDIR)/main/blend.c \
- $(SRCDIR)/main/bufferobj.c \
- $(SRCDIR)/main/buffers.c \
- $(SRCDIR)/main/clear.c \
- $(SRCDIR)/main/clip.c \
- $(SRCDIR)/main/colortab.c \
- $(SRCDIR)/main/condrender.c \
- $(SRCDIR)/main/context.c \
- $(SRCDIR)/main/convolve.c \
- $(SRCDIR)/main/cpuinfo.c \
- $(SRCDIR)/main/debug.c \
- $(SRCDIR)/main/depth.c \
- $(SRCDIR)/main/dlist.c \
- $(SRCDIR)/main/dlopen.c \
- $(SRCDIR)/main/drawpix.c \
- $(SRCDIR)/main/drawtex.c \
- $(SRCDIR)/main/enable.c \
- $(SRCDIR)/main/enums.c \
- $(SRCDIR)/main/errors.c \
- $(SRCDIR)/main/eval.c \
- $(SRCDIR)/main/execmem.c \
- $(SRCDIR)/main/extensions.c \
- $(SRCDIR)/main/fbobject.c \
- $(SRCDIR)/main/feedback.c \
- $(SRCDIR)/main/ffvertex_prog.c \
- $(SRCDIR)/main/fog.c \
- $(SRCDIR)/main/formats.c \
- $(SRCDIR)/main/format_pack.c \
- $(SRCDIR)/main/format_unpack.c \
- $(SRCDIR)/main/framebuffer.c \
- $(SRCDIR)/main/get.c \
- $(SRCDIR)/main/getstring.c \
- $(SRCDIR)/main/hash.c \
- $(SRCDIR)/main/hint.c \
- $(SRCDIR)/main/histogram.c \
- $(SRCDIR)/main/image.c \
- $(SRCDIR)/main/imports.c \
- $(SRCDIR)/main/light.c \
- $(SRCDIR)/main/lines.c \
- $(SRCDIR)/main/matrix.c \
- $(SRCDIR)/main/mipmap.c \
- $(SRCDIR)/main/mm.c \
- $(SRCDIR)/main/multisample.c \
- $(SRCDIR)/main/nvprogram.c \
- $(SRCDIR)/main/pack.c \
- $(SRCDIR)/main/pbo.c \
- $(SRCDIR)/main/pixel.c \
- $(SRCDIR)/main/pixelstore.c \
- $(SRCDIR)/main/pixeltransfer.c \
- $(SRCDIR)/main/points.c \
- $(SRCDIR)/main/polygon.c \
- $(SRCDIR)/main/queryobj.c \
- $(SRCDIR)/main/querymatrix.c \
- $(SRCDIR)/main/rastpos.c \
- $(SRCDIR)/main/readpix.c \
- $(SRCDIR)/main/remap.c \
- $(SRCDIR)/main/renderbuffer.c \
- $(SRCDIR)/main/samplerobj.c \
- $(SRCDIR)/main/scissor.c \
- $(SRCDIR)/main/shaderapi.c \
- $(SRCDIR)/main/shaderobj.c \
- $(SRCDIR)/main/shared.c \
- $(SRCDIR)/main/state.c \
- $(SRCDIR)/main/stencil.c \
- $(SRCDIR)/main/syncobj.c \
- $(SRCDIR)/main/texcompress.c \
- $(SRCDIR)/main/texcompress_rgtc.c \
- $(SRCDIR)/main/texcompress_s3tc.c \
- $(SRCDIR)/main/texcompress_fxt1.c \
- $(SRCDIR)/main/texcompress_etc.c \
- $(SRCDIR)/main/texenv.c \
- $(SRCDIR)/main/texformat.c \
- $(SRCDIR)/main/texgen.c \
- $(SRCDIR)/main/texgetimage.c \
- $(SRCDIR)/main/teximage.c \
- $(SRCDIR)/main/texobj.c \
- $(SRCDIR)/main/texpal.c \
- $(SRCDIR)/main/texparam.c \
- $(SRCDIR)/main/texstate.c \
- $(SRCDIR)/main/texstorage.c \
- $(SRCDIR)/main/texstore.c \
- $(SRCDIR)/main/texturebarrier.c \
- $(SRCDIR)/main/transformfeedback.c \
- $(SRCDIR)/main/uniforms.c \
- $(SRCDIR)/main/varray.c \
- $(SRCDIR)/main/version.c \
- $(SRCDIR)/main/viewport.c \
- $(SRCDIR)/main/vtxfmt.c \
+ $(SRCDIR)main/api_arrayelt.c \
+ $(SRCDIR)main/api_exec.c \
+ $(SRCDIR)main/api_loopback.c \
+ $(SRCDIR)main/api_validate.c \
+ $(SRCDIR)main/accum.c \
+ $(SRCDIR)main/arbprogram.c \
+ $(SRCDIR)main/atifragshader.c \
+ $(SRCDIR)main/attrib.c \
+ $(SRCDIR)main/arrayobj.c \
+ $(SRCDIR)main/blend.c \
+ $(SRCDIR)main/bufferobj.c \
+ $(SRCDIR)main/buffers.c \
+ $(SRCDIR)main/clear.c \
+ $(SRCDIR)main/clip.c \
+ $(SRCDIR)main/colortab.c \
+ $(SRCDIR)main/condrender.c \
+ $(SRCDIR)main/context.c \
+ $(SRCDIR)main/convolve.c \
+ $(SRCDIR)main/cpuinfo.c \
+ $(SRCDIR)main/debug.c \
+ $(SRCDIR)main/depth.c \
+ $(SRCDIR)main/dlist.c \
+ $(SRCDIR)main/dlopen.c \
+ $(SRCDIR)main/drawpix.c \
+ $(SRCDIR)main/drawtex.c \
+ $(SRCDIR)main/enable.c \
+ $(SRCDIR)main/enums.c \
+ $(SRCDIR)main/errors.c \
+ $(SRCDIR)main/eval.c \
+ $(SRCDIR)main/execmem.c \
+ $(SRCDIR)main/extensions.c \
+ $(SRCDIR)main/fbobject.c \
+ $(SRCDIR)main/feedback.c \
+ $(SRCDIR)main/ffvertex_prog.c \
+ $(SRCDIR)main/fog.c \
+ $(SRCDIR)main/formats.c \
+ $(SRCDIR)main/format_pack.c \
+ $(SRCDIR)main/format_unpack.c \
+ $(SRCDIR)main/framebuffer.c \
+ $(SRCDIR)main/get.c \
+ $(SRCDIR)main/getstring.c \
+ $(SRCDIR)main/glformats.c \
+ $(SRCDIR)main/hash.c \
+ $(SRCDIR)main/hint.c \
+ $(SRCDIR)main/histogram.c \
+ $(SRCDIR)main/image.c \
+ $(SRCDIR)main/imports.c \
+ $(SRCDIR)main/light.c \
+ $(SRCDIR)main/lines.c \
+ $(SRCDIR)main/matrix.c \
+ $(SRCDIR)main/mipmap.c \
+ $(SRCDIR)main/mm.c \
+ $(SRCDIR)main/multisample.c \
+ $(SRCDIR)main/nvprogram.c \
+ $(SRCDIR)main/pack.c \
+ $(SRCDIR)main/pbo.c \
+ $(SRCDIR)main/pixel.c \
+ $(SRCDIR)main/pixelstore.c \
+ $(SRCDIR)main/pixeltransfer.c \
+ $(SRCDIR)main/points.c \
+ $(SRCDIR)main/polygon.c \
+ $(SRCDIR)main/queryobj.c \
+ $(SRCDIR)main/querymatrix.c \
+ $(SRCDIR)main/rastpos.c \
+ $(SRCDIR)main/readpix.c \
+ $(SRCDIR)main/remap.c \
+ $(SRCDIR)main/renderbuffer.c \
+ $(SRCDIR)main/samplerobj.c \
+ $(SRCDIR)main/scissor.c \
+ $(SRCDIR)main/shaderapi.c \
+ $(SRCDIR)main/shaderobj.c \
+ $(SRCDIR)main/shared.c \
+ $(SRCDIR)main/state.c \
+ $(SRCDIR)main/stencil.c \
+ $(SRCDIR)main/syncobj.c \
+ $(SRCDIR)main/texcompress.c \
+ $(SRCDIR)main/texcompress_rgtc.c \
+ $(SRCDIR)main/texcompress_s3tc.c \
+ $(SRCDIR)main/texcompress_fxt1.c \
+ $(SRCDIR)main/texcompress_etc.c \
+ $(SRCDIR)main/texenv.c \
+ $(SRCDIR)main/texformat.c \
+ $(SRCDIR)main/texgen.c \
+ $(SRCDIR)main/texgetimage.c \
+ $(SRCDIR)main/teximage.c \
+ $(SRCDIR)main/texobj.c \
+ $(SRCDIR)main/texpal.c \
+ $(SRCDIR)main/texparam.c \
+ $(SRCDIR)main/texstate.c \
+ $(SRCDIR)main/texstorage.c \
+ $(SRCDIR)main/texstore.c \
+ $(SRCDIR)main/texturebarrier.c \
+ $(SRCDIR)main/transformfeedback.c \
+ $(SRCDIR)main/uniforms.c \
+ $(SRCDIR)main/varray.c \
+ $(SRCDIR)main/version.c \
+ $(SRCDIR)main/viewport.c \
+ $(SRCDIR)main/vtxfmt.c \
$(MAIN_ES_FILES)
MAIN_CXX_FILES = \
- $(SRCDIR)/main/ff_fragment_shader.cpp \
- $(SRCDIR)/main/shader_query.cpp \
- $(SRCDIR)/main/uniform_query.cpp
+ $(SRCDIR)main/ff_fragment_shader.cpp \
+ $(SRCDIR)main/shader_query.cpp \
+ $(SRCDIR)main/uniform_query.cpp
MATH_FILES = \
- $(SRCDIR)/math/m_debug_clip.c \
- $(SRCDIR)/math/m_debug_norm.c \
- $(SRCDIR)/math/m_debug_xform.c \
- $(SRCDIR)/math/m_eval.c \
- $(SRCDIR)/math/m_matrix.c \
- $(SRCDIR)/math/m_translate.c \
- $(SRCDIR)/math/m_vector.c
+ $(SRCDIR)math/m_debug_clip.c \
+ $(SRCDIR)math/m_debug_norm.c \
+ $(SRCDIR)math/m_debug_xform.c \
+ $(SRCDIR)math/m_eval.c \
+ $(SRCDIR)math/m_matrix.c \
+ $(SRCDIR)math/m_translate.c \
+ $(SRCDIR)math/m_vector.c
MATH_XFORM_FILES = \
- $(SRCDIR)/math/m_xform.c
+ $(SRCDIR)math/m_xform.c
SWRAST_FILES = \
- $(SRCDIR)/swrast/s_aaline.c \
- $(SRCDIR)/swrast/s_aatriangle.c \
- $(SRCDIR)/swrast/s_alpha.c \
- $(SRCDIR)/swrast/s_atifragshader.c \
- $(SRCDIR)/swrast/s_bitmap.c \
- $(SRCDIR)/swrast/s_blend.c \
- $(SRCDIR)/swrast/s_blit.c \
- $(SRCDIR)/swrast/s_clear.c \
- $(SRCDIR)/swrast/s_copypix.c \
- $(SRCDIR)/swrast/s_context.c \
- $(SRCDIR)/swrast/s_depth.c \
- $(SRCDIR)/swrast/s_drawpix.c \
- $(SRCDIR)/swrast/s_feedback.c \
- $(SRCDIR)/swrast/s_fog.c \
- $(SRCDIR)/swrast/s_fragprog.c \
- $(SRCDIR)/swrast/s_lines.c \
- $(SRCDIR)/swrast/s_logic.c \
- $(SRCDIR)/swrast/s_masking.c \
- $(SRCDIR)/swrast/s_points.c \
- $(SRCDIR)/swrast/s_renderbuffer.c \
- $(SRCDIR)/swrast/s_span.c \
- $(SRCDIR)/swrast/s_stencil.c \
- $(SRCDIR)/swrast/s_texcombine.c \
- $(SRCDIR)/swrast/s_texfetch.c \
- $(SRCDIR)/swrast/s_texfilter.c \
- $(SRCDIR)/swrast/s_texrender.c \
- $(SRCDIR)/swrast/s_texture.c \
- $(SRCDIR)/swrast/s_triangle.c \
- $(SRCDIR)/swrast/s_zoom.c
+ $(SRCDIR)swrast/s_aaline.c \
+ $(SRCDIR)swrast/s_aatriangle.c \
+ $(SRCDIR)swrast/s_alpha.c \
+ $(SRCDIR)swrast/s_atifragshader.c \
+ $(SRCDIR)swrast/s_bitmap.c \
+ $(SRCDIR)swrast/s_blend.c \
+ $(SRCDIR)swrast/s_blit.c \
+ $(SRCDIR)swrast/s_clear.c \
+ $(SRCDIR)swrast/s_copypix.c \
+ $(SRCDIR)swrast/s_context.c \
+ $(SRCDIR)swrast/s_depth.c \
+ $(SRCDIR)swrast/s_drawpix.c \
+ $(SRCDIR)swrast/s_feedback.c \
+ $(SRCDIR)swrast/s_fog.c \
+ $(SRCDIR)swrast/s_fragprog.c \
+ $(SRCDIR)swrast/s_lines.c \
+ $(SRCDIR)swrast/s_logic.c \
+ $(SRCDIR)swrast/s_masking.c \
+ $(SRCDIR)swrast/s_points.c \
+ $(SRCDIR)swrast/s_renderbuffer.c \
+ $(SRCDIR)swrast/s_span.c \
+ $(SRCDIR)swrast/s_stencil.c \
+ $(SRCDIR)swrast/s_texcombine.c \
+ $(SRCDIR)swrast/s_texfetch.c \
+ $(SRCDIR)swrast/s_texfilter.c \
+ $(SRCDIR)swrast/s_texrender.c \
+ $(SRCDIR)swrast/s_texture.c \
+ $(SRCDIR)swrast/s_triangle.c \
+ $(SRCDIR)swrast/s_zoom.c
SWRAST_SETUP_FILES = \
- $(SRCDIR)/swrast_setup/ss_context.c \
- $(SRCDIR)/swrast_setup/ss_triangle.c
+ $(SRCDIR)swrast_setup/ss_context.c \
+ $(SRCDIR)swrast_setup/ss_triangle.c
TNL_FILES = \
- $(SRCDIR)/tnl/t_context.c \
- $(SRCDIR)/tnl/t_pipeline.c \
- $(SRCDIR)/tnl/t_draw.c \
- $(SRCDIR)/tnl/t_rasterpos.c \
- $(SRCDIR)/tnl/t_vb_program.c \
- $(SRCDIR)/tnl/t_vb_render.c \
- $(SRCDIR)/tnl/t_vb_texgen.c \
- $(SRCDIR)/tnl/t_vb_texmat.c \
- $(SRCDIR)/tnl/t_vb_vertex.c \
- $(SRCDIR)/tnl/t_vb_fog.c \
- $(SRCDIR)/tnl/t_vb_light.c \
- $(SRCDIR)/tnl/t_vb_normals.c \
- $(SRCDIR)/tnl/t_vb_points.c \
- $(SRCDIR)/tnl/t_vp_build.c \
- $(SRCDIR)/tnl/t_vertex.c \
- $(SRCDIR)/tnl/t_vertex_sse.c \
- $(SRCDIR)/tnl/t_vertex_generic.c
+ $(SRCDIR)tnl/t_context.c \
+ $(SRCDIR)tnl/t_pipeline.c \
+ $(SRCDIR)tnl/t_draw.c \
+ $(SRCDIR)tnl/t_rasterpos.c \
+ $(SRCDIR)tnl/t_vb_program.c \
+ $(SRCDIR)tnl/t_vb_render.c \
+ $(SRCDIR)tnl/t_vb_texgen.c \
+ $(SRCDIR)tnl/t_vb_texmat.c \
+ $(SRCDIR)tnl/t_vb_vertex.c \
+ $(SRCDIR)tnl/t_vb_fog.c \
+ $(SRCDIR)tnl/t_vb_light.c \
+ $(SRCDIR)tnl/t_vb_normals.c \
+ $(SRCDIR)tnl/t_vb_points.c \
+ $(SRCDIR)tnl/t_vp_build.c \
+ $(SRCDIR)tnl/t_vertex.c \
+ $(SRCDIR)tnl/t_vertex_sse.c \
+ $(SRCDIR)tnl/t_vertex_generic.c
VBO_FILES = \
- $(SRCDIR)/vbo/vbo_context.c \
- $(SRCDIR)/vbo/vbo_exec.c \
- $(SRCDIR)/vbo/vbo_exec_api.c \
- $(SRCDIR)/vbo/vbo_exec_array.c \
- $(SRCDIR)/vbo/vbo_exec_draw.c \
- $(SRCDIR)/vbo/vbo_exec_eval.c \
- $(SRCDIR)/vbo/vbo_noop.c \
- $(SRCDIR)/vbo/vbo_primitive_restart.c \
- $(SRCDIR)/vbo/vbo_rebase.c \
- $(SRCDIR)/vbo/vbo_split.c \
- $(SRCDIR)/vbo/vbo_split_copy.c \
- $(SRCDIR)/vbo/vbo_split_inplace.c \
- $(SRCDIR)/vbo/vbo_save.c \
- $(SRCDIR)/vbo/vbo_save_api.c \
- $(SRCDIR)/vbo/vbo_save_draw.c \
- $(SRCDIR)/vbo/vbo_save_loopback.c
+ $(SRCDIR)vbo/vbo_context.c \
+ $(SRCDIR)vbo/vbo_exec.c \
+ $(SRCDIR)vbo/vbo_exec_api.c \
+ $(SRCDIR)vbo/vbo_exec_array.c \
+ $(SRCDIR)vbo/vbo_exec_draw.c \
+ $(SRCDIR)vbo/vbo_exec_eval.c \
+ $(SRCDIR)vbo/vbo_noop.c \
+ $(SRCDIR)vbo/vbo_primitive_restart.c \
+ $(SRCDIR)vbo/vbo_rebase.c \
+ $(SRCDIR)vbo/vbo_split.c \
+ $(SRCDIR)vbo/vbo_split_copy.c \
+ $(SRCDIR)vbo/vbo_split_inplace.c \
+ $(SRCDIR)vbo/vbo_save.c \
+ $(SRCDIR)vbo/vbo_save_api.c \
+ $(SRCDIR)vbo/vbo_save_draw.c \
+ $(SRCDIR)vbo/vbo_save_loopback.c
STATETRACKER_FILES = \
- $(SRCDIR)/state_tracker/st_atom.c \
- $(SRCDIR)/state_tracker/st_atom_array.c \
- $(SRCDIR)/state_tracker/st_atom_blend.c \
- $(SRCDIR)/state_tracker/st_atom_clip.c \
- $(SRCDIR)/state_tracker/st_atom_constbuf.c \
- $(SRCDIR)/state_tracker/st_atom_depth.c \
- $(SRCDIR)/state_tracker/st_atom_framebuffer.c \
- $(SRCDIR)/state_tracker/st_atom_msaa.c \
- $(SRCDIR)/state_tracker/st_atom_pixeltransfer.c \
- $(SRCDIR)/state_tracker/st_atom_sampler.c \
- $(SRCDIR)/state_tracker/st_atom_scissor.c \
- $(SRCDIR)/state_tracker/st_atom_shader.c \
- $(SRCDIR)/state_tracker/st_atom_rasterizer.c \
- $(SRCDIR)/state_tracker/st_atom_stipple.c \
- $(SRCDIR)/state_tracker/st_atom_texture.c \
- $(SRCDIR)/state_tracker/st_atom_viewport.c \
- $(SRCDIR)/state_tracker/st_cb_bitmap.c \
- $(SRCDIR)/state_tracker/st_cb_blit.c \
- $(SRCDIR)/state_tracker/st_cb_bufferobjects.c \
- $(SRCDIR)/state_tracker/st_cb_clear.c \
- $(SRCDIR)/state_tracker/st_cb_condrender.c \
- $(SRCDIR)/state_tracker/st_cb_flush.c \
- $(SRCDIR)/state_tracker/st_cb_drawpixels.c \
- $(SRCDIR)/state_tracker/st_cb_drawtex.c \
- $(SRCDIR)/state_tracker/st_cb_eglimage.c \
- $(SRCDIR)/state_tracker/st_cb_fbo.c \
- $(SRCDIR)/state_tracker/st_cb_feedback.c \
- $(SRCDIR)/state_tracker/st_cb_program.c \
- $(SRCDIR)/state_tracker/st_cb_queryobj.c \
- $(SRCDIR)/state_tracker/st_cb_rasterpos.c \
- $(SRCDIR)/state_tracker/st_cb_readpixels.c \
- $(SRCDIR)/state_tracker/st_cb_syncobj.c \
- $(SRCDIR)/state_tracker/st_cb_strings.c \
- $(SRCDIR)/state_tracker/st_cb_texture.c \
- $(SRCDIR)/state_tracker/st_cb_texturebarrier.c \
- $(SRCDIR)/state_tracker/st_cb_viewport.c \
- $(SRCDIR)/state_tracker/st_cb_xformfb.c \
- $(SRCDIR)/state_tracker/st_context.c \
- $(SRCDIR)/state_tracker/st_debug.c \
- $(SRCDIR)/state_tracker/st_draw.c \
- $(SRCDIR)/state_tracker/st_draw_feedback.c \
- $(SRCDIR)/state_tracker/st_extensions.c \
- $(SRCDIR)/state_tracker/st_format.c \
- $(SRCDIR)/state_tracker/st_gen_mipmap.c \
- $(SRCDIR)/state_tracker/st_manager.c \
- $(SRCDIR)/state_tracker/st_mesa_to_tgsi.c \
- $(SRCDIR)/state_tracker/st_program.c \
- $(SRCDIR)/state_tracker/st_texture.c
+ $(SRCDIR)state_tracker/st_atom.c \
+ $(SRCDIR)state_tracker/st_atom_array.c \
+ $(SRCDIR)state_tracker/st_atom_blend.c \
+ $(SRCDIR)state_tracker/st_atom_clip.c \
+ $(SRCDIR)state_tracker/st_atom_constbuf.c \
+ $(SRCDIR)state_tracker/st_atom_depth.c \
+ $(SRCDIR)state_tracker/st_atom_framebuffer.c \
+ $(SRCDIR)state_tracker/st_atom_msaa.c \
+ $(SRCDIR)state_tracker/st_atom_pixeltransfer.c \
+ $(SRCDIR)state_tracker/st_atom_sampler.c \
+ $(SRCDIR)state_tracker/st_atom_scissor.c \
+ $(SRCDIR)state_tracker/st_atom_shader.c \
+ $(SRCDIR)state_tracker/st_atom_rasterizer.c \
+ $(SRCDIR)state_tracker/st_atom_stipple.c \
+ $(SRCDIR)state_tracker/st_atom_texture.c \
+ $(SRCDIR)state_tracker/st_atom_viewport.c \
+ $(SRCDIR)state_tracker/st_cb_bitmap.c \
+ $(SRCDIR)state_tracker/st_cb_blit.c \
+ $(SRCDIR)state_tracker/st_cb_bufferobjects.c \
+ $(SRCDIR)state_tracker/st_cb_clear.c \
+ $(SRCDIR)state_tracker/st_cb_condrender.c \
+ $(SRCDIR)state_tracker/st_cb_flush.c \
+ $(SRCDIR)state_tracker/st_cb_drawpixels.c \
+ $(SRCDIR)state_tracker/st_cb_drawtex.c \
+ $(SRCDIR)state_tracker/st_cb_eglimage.c \
+ $(SRCDIR)state_tracker/st_cb_fbo.c \
+ $(SRCDIR)state_tracker/st_cb_feedback.c \
+ $(SRCDIR)state_tracker/st_cb_program.c \
+ $(SRCDIR)state_tracker/st_cb_queryobj.c \
+ $(SRCDIR)state_tracker/st_cb_rasterpos.c \
+ $(SRCDIR)state_tracker/st_cb_readpixels.c \
+ $(SRCDIR)state_tracker/st_cb_syncobj.c \
+ $(SRCDIR)state_tracker/st_cb_strings.c \
+ $(SRCDIR)state_tracker/st_cb_texture.c \
+ $(SRCDIR)state_tracker/st_cb_texturebarrier.c \
+ $(SRCDIR)state_tracker/st_cb_viewport.c \
+ $(SRCDIR)state_tracker/st_cb_xformfb.c \
+ $(SRCDIR)state_tracker/st_context.c \
+ $(SRCDIR)state_tracker/st_debug.c \
+ $(SRCDIR)state_tracker/st_draw.c \
+ $(SRCDIR)state_tracker/st_draw_feedback.c \
+ $(SRCDIR)state_tracker/st_extensions.c \
+ $(SRCDIR)state_tracker/st_format.c \
+ $(SRCDIR)state_tracker/st_gen_mipmap.c \
+ $(SRCDIR)state_tracker/st_manager.c \
+ $(SRCDIR)state_tracker/st_mesa_to_tgsi.c \
+ $(SRCDIR)state_tracker/st_program.c \
+ $(SRCDIR)state_tracker/st_texture.c
PROGRAM_FILES = \
- $(SRCDIR)/program/arbprogparse.c \
- $(SRCDIR)/program/hash_table.c \
- $(SRCDIR)/program/lex.yy.c \
- $(SRCDIR)/program/nvfragparse.c \
- $(SRCDIR)/program/nvvertparse.c \
- $(SRCDIR)/program/program.c \
- $(SRCDIR)/program/program_parse.tab.c \
- $(SRCDIR)/program/program_parse_extra.c \
- $(SRCDIR)/program/prog_cache.c \
- $(SRCDIR)/program/prog_execute.c \
- $(SRCDIR)/program/prog_instruction.c \
- $(SRCDIR)/program/prog_noise.c \
- $(SRCDIR)/program/prog_optimize.c \
- $(SRCDIR)/program/prog_opt_constant_fold.c \
- $(SRCDIR)/program/prog_parameter.c \
- $(SRCDIR)/program/prog_parameter_layout.c \
- $(SRCDIR)/program/prog_print.c \
- $(SRCDIR)/program/prog_statevars.c \
- $(SRCDIR)/program/programopt.c \
- $(SRCDIR)/program/register_allocate.c \
- $(SRCDIR)/program/symbol_table.c
+ $(SRCDIR)program/arbprogparse.c \
+ $(SRCDIR)program/hash_table.c \
+ $(SRCDIR)program/lex.yy.c \
+ $(SRCDIR)program/nvfragparse.c \
+ $(SRCDIR)program/nvvertparse.c \
+ $(SRCDIR)program/program.c \
+ $(SRCDIR)program/program_parse.tab.c \
+ $(SRCDIR)program/program_parse_extra.c \
+ $(SRCDIR)program/prog_cache.c \
+ $(SRCDIR)program/prog_execute.c \
+ $(SRCDIR)program/prog_instruction.c \
+ $(SRCDIR)program/prog_noise.c \
+ $(SRCDIR)program/prog_optimize.c \
+ $(SRCDIR)program/prog_opt_constant_fold.c \
+ $(SRCDIR)program/prog_parameter.c \
+ $(SRCDIR)program/prog_parameter_layout.c \
+ $(SRCDIR)program/prog_print.c \
+ $(SRCDIR)program/prog_statevars.c \
+ $(SRCDIR)program/programopt.c \
+ $(SRCDIR)program/register_allocate.c \
+ $(SRCDIR)program/symbol_table.c
SHADER_CXX_FILES = \
- $(SRCDIR)/program/ir_to_mesa.cpp \
- $(SRCDIR)/program/sampler.cpp \
- $(SRCDIR)/program/string_to_uint_map.cpp
+ $(SRCDIR)program/ir_to_mesa.cpp \
+ $(SRCDIR)program/sampler.cpp \
+ $(SRCDIR)program/string_to_uint_map.cpp
ASM_C_FILES = \
- $(SRCDIR)/x86/common_x86.c \
- $(SRCDIR)/x86/x86_xform.c \
- $(SRCDIR)/x86/3dnow.c \
- $(SRCDIR)/x86/sse.c \
- $(SRCDIR)/x86/rtasm/x86sse.c \
- $(SRCDIR)/sparc/sparc.c \
- $(SRCDIR)/x86-64/x86-64.c
+ $(SRCDIR)x86/common_x86.c \
+ $(SRCDIR)x86/x86_xform.c \
+ $(SRCDIR)x86/3dnow.c \
+ $(SRCDIR)x86/sse.c \
+ $(SRCDIR)x86/rtasm/x86sse.c \
+ $(SRCDIR)sparc/sparc.c \
+ $(SRCDIR)x86-64/x86-64.c
X86_FILES = \
- $(SRCDIR)/x86/common_x86_asm.S \
- $(SRCDIR)/x86/x86_xform2.S \
- $(SRCDIR)/x86/x86_xform3.S \
- $(SRCDIR)/x86/x86_xform4.S \
- $(SRCDIR)/x86/x86_cliptest.S \
- $(SRCDIR)/x86/mmx_blend.S \
- $(SRCDIR)/x86/3dnow_xform1.S \
- $(SRCDIR)/x86/3dnow_xform2.S \
- $(SRCDIR)/x86/3dnow_xform3.S \
- $(SRCDIR)/x86/3dnow_xform4.S \
- $(SRCDIR)/x86/3dnow_normal.S \
- $(SRCDIR)/x86/sse_xform1.S \
- $(SRCDIR)/x86/sse_xform2.S \
- $(SRCDIR)/x86/sse_xform3.S \
- $(SRCDIR)/x86/sse_xform4.S \
- $(SRCDIR)/x86/sse_normal.S \
- $(SRCDIR)/x86/read_rgba_span_x86.S
+ $(SRCDIR)x86/common_x86_asm.S \
+ $(SRCDIR)x86/x86_xform2.S \
+ $(SRCDIR)x86/x86_xform3.S \
+ $(SRCDIR)x86/x86_xform4.S \
+ $(SRCDIR)x86/x86_cliptest.S \
+ $(SRCDIR)x86/mmx_blend.S \
+ $(SRCDIR)x86/3dnow_xform1.S \
+ $(SRCDIR)x86/3dnow_xform2.S \
+ $(SRCDIR)x86/3dnow_xform3.S \
+ $(SRCDIR)x86/3dnow_xform4.S \
+ $(SRCDIR)x86/3dnow_normal.S \
+ $(SRCDIR)x86/sse_xform1.S \
+ $(SRCDIR)x86/sse_xform2.S \
+ $(SRCDIR)x86/sse_xform3.S \
+ $(SRCDIR)x86/sse_xform4.S \
+ $(SRCDIR)x86/sse_normal.S \
+ $(SRCDIR)x86/read_rgba_span_x86.S
X86_64_FILES = \
- $(SRCDIR)/x86-64/xform4.S
+ $(SRCDIR)x86-64/xform4.S
SPARC_FILES = \
- $(SRCDIR)/sparc/sparc_clip.S \
- $(SRCDIR)/sparc/norm.S \
- $(SRCDIR)/sparc/xform.S
+ $(SRCDIR)sparc/sparc_clip.S \
+ $(SRCDIR)sparc/norm.S \
+ $(SRCDIR)sparc/xform.S
COMMON_DRIVER_FILES = \
- $(SRCDIR)/drivers/common/driverfuncs.c \
- $(SRCDIR)/drivers/common/meta.c
+ $(SRCDIR)drivers/common/driverfuncs.c \
+ $(SRCDIR)drivers/common/meta.c
# Sources for building non-Gallium drivers
@@ -340,11 +342,11 @@ MESA_GALLIUM_FILES = \
$(VBO_FILES) \
$(STATETRACKER_FILES) \
$(PROGRAM_FILES) \
- $(SRCDIR)/x86/common_x86.c
+ $(SRCDIR)x86/common_x86.c
MESA_GALLIUM_CXX_FILES = \
$(MESA_CXX_FILES) \
- $(SRCDIR)/state_tracker/st_glsl_to_tgsi.cpp
+ $(SRCDIR)state_tracker/st_glsl_to_tgsi.cpp
# All the core C sources, for dependency checking
ALL_FILES = \
diff --git a/mesalib/src/mesa/state_tracker/st_atom_array.c b/mesalib/src/mesa/state_tracker/st_atom_array.c
index d60b0d7a9..ab46f1188 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_array.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_array.c
@@ -1,3 +1,4 @@
+
/**************************************************************************
*
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
@@ -45,7 +46,7 @@
#include "util/u_math.h"
#include "main/bufferobj.h"
-#include "main/image.h"
+#include "main/glformats.h"
static GLuint double_types[4] = {
diff --git a/mesalib/src/mesa/state_tracker/st_atom_clip.c b/mesalib/src/mesa/state_tracker/st_atom_clip.c
index 2a5110098..a1a7e003a 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_clip.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_clip.c
@@ -47,7 +47,7 @@ static void update_clip( struct st_context *st )
const struct gl_context *ctx = st->ctx;
bool use_eye = FALSE;
- assert(sizeof(clip.ucp) <= sizeof(ctx->Transform._ClipUserPlane));
+ STATIC_ASSERT(sizeof(clip.ucp) <= sizeof(ctx->Transform._ClipUserPlane));
/* if we have a vertex shader that writes clip vertex we need to pass
the pre-projection transformed coordinates into the driver. */
diff --git a/mesalib/src/mesa/state_tracker/st_atom_depth.c b/mesalib/src/mesa/state_tracker/st_atom_depth.c
index 6c51b1ac1..c76a6d8c6 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_depth.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_depth.c
@@ -49,14 +49,14 @@ GLuint
st_compare_func_to_pipe(GLenum func)
{
/* Same values, just biased */
- assert(PIPE_FUNC_NEVER == GL_NEVER - GL_NEVER);
- assert(PIPE_FUNC_LESS == GL_LESS - GL_NEVER);
- assert(PIPE_FUNC_EQUAL == GL_EQUAL - GL_NEVER);
- assert(PIPE_FUNC_LEQUAL == GL_LEQUAL - GL_NEVER);
- assert(PIPE_FUNC_GREATER == GL_GREATER - GL_NEVER);
- assert(PIPE_FUNC_NOTEQUAL == GL_NOTEQUAL - GL_NEVER);
- assert(PIPE_FUNC_GEQUAL == GL_GEQUAL - GL_NEVER);
- assert(PIPE_FUNC_ALWAYS == GL_ALWAYS - GL_NEVER);
+ STATIC_ASSERT(PIPE_FUNC_NEVER == GL_NEVER - GL_NEVER);
+ STATIC_ASSERT(PIPE_FUNC_LESS == GL_LESS - GL_NEVER);
+ STATIC_ASSERT(PIPE_FUNC_EQUAL == GL_EQUAL - GL_NEVER);
+ STATIC_ASSERT(PIPE_FUNC_LEQUAL == GL_LEQUAL - GL_NEVER);
+ STATIC_ASSERT(PIPE_FUNC_GREATER == GL_GREATER - GL_NEVER);
+ STATIC_ASSERT(PIPE_FUNC_NOTEQUAL == GL_NOTEQUAL - GL_NEVER);
+ STATIC_ASSERT(PIPE_FUNC_GEQUAL == GL_GEQUAL - GL_NEVER);
+ STATIC_ASSERT(PIPE_FUNC_ALWAYS == GL_ALWAYS - GL_NEVER);
assert(func >= GL_NEVER);
assert(func <= GL_ALWAYS);
return func - GL_NEVER;
diff --git a/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c b/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c
index a8907c157..a10dbfbd0 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c
@@ -33,6 +33,7 @@
#include "st_context.h"
#include "st_atom.h"
+#include "st_cb_bitmap.h"
#include "st_cb_fbo.h"
#include "st_texture.h"
#include "pipe/p_context.h"
@@ -52,7 +53,7 @@ update_renderbuffer_surface(struct st_context *st,
struct st_renderbuffer *strb)
{
struct pipe_context *pipe = st->pipe;
- struct pipe_resource *resource = strb->rtt->pt;
+ struct pipe_resource *resource = strb->rtt ? strb->rtt->pt : strb->texture;
int rtt_width = strb->Base.Width;
int rtt_height = strb->Base.Height;
enum pipe_format format = st->ctx->Color.sRGBEnabled ? resource->format : util_format_linear(resource->format);
@@ -103,6 +104,9 @@ update_framebuffer_state( struct st_context *st )
struct st_renderbuffer *strb;
GLuint i;
+ st_flush_bitmap_cache(st);
+
+ st->state.fb_orientation = st_fb_orientation(fb);
framebuffer->width = fb->Width;
framebuffer->height = fb->Height;
@@ -117,7 +121,8 @@ update_framebuffer_state( struct st_context *st )
if (strb) {
/*printf("--------- framebuffer surface rtt %p\n", strb->rtt);*/
- if (strb->rtt) {
+ if (strb->rtt ||
+ (strb->texture && util_format_is_srgb(strb->texture->format))) {
/* rendering to a GL texture, may have to update surface */
update_renderbuffer_surface(st, strb);
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_bitmap.c b/mesalib/src/mesa/state_tracker/st_cb_bitmap.c
index 09152c79a..c26058874 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_bitmap.c
@@ -335,9 +335,8 @@ setup_bitmap_vertex_data(struct st_context *st, bool normalized,
struct pipe_resource **vbuf,
unsigned *vbuf_offset)
{
- const struct gl_framebuffer *fb = st->ctx->DrawBuffer;
- const GLfloat fb_width = (GLfloat)fb->Width;
- const GLfloat fb_height = (GLfloat)fb->Height;
+ const GLfloat fb_width = (GLfloat)st->state.framebuffer.width;
+ const GLfloat fb_height = (GLfloat)st->state.framebuffer.height;
const GLfloat x0 = (GLfloat)x;
const GLfloat x1 = (GLfloat)(x + width);
const GLfloat y0 = (GLfloat)y;
@@ -502,10 +501,9 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
/* viewport state: viewport matching window dims */
{
- const struct gl_framebuffer *fb = st->ctx->DrawBuffer;
- const GLboolean invert = (st_fb_orientation(fb) == Y_0_TOP);
- const GLfloat width = (GLfloat)fb->Width;
- const GLfloat height = (GLfloat)fb->Height;
+ const GLboolean invert = st->state.fb_orientation == Y_0_TOP;
+ const GLfloat width = (GLfloat)st->state.framebuffer.width;
+ const GLfloat height = (GLfloat)st->state.framebuffer.height;
struct pipe_viewport_state vp;
vp.scale[0] = 0.5f * width;
vp.scale[1] = height * (invert ? -0.5f : 0.5f);
@@ -636,43 +634,41 @@ st_flush_bitmap_cache(struct st_context *st)
if (!st->bitmap.cache->empty) {
struct bitmap_cache *cache = st->bitmap.cache;
- if (st->ctx->DrawBuffer) {
- struct pipe_context *pipe = st->pipe;
- struct pipe_sampler_view *sv;
+ struct pipe_context *pipe = st->pipe;
+ struct pipe_sampler_view *sv;
- assert(cache->xmin <= cache->xmax);
-
-/* printf("flush size %d x %d at %d, %d\n",
- cache->xmax - cache->xmin,
- cache->ymax - cache->ymin,
- cache->xpos, cache->ypos);
+ assert(cache->xmin <= cache->xmax);
+
+/* printf("flush size %d x %d at %d, %d\n",
+ cache->xmax - cache->xmin,
+ cache->ymax - cache->ymin,
+ cache->xpos, cache->ypos);
*/
- /* The texture transfer has been mapped until now.
+ /* The texture transfer has been mapped until now.
* So unmap and release the texture transfer before drawing.
*/
- if (cache->trans) {
- if (0)
- print_cache(cache);
- pipe_transfer_unmap(pipe, cache->trans);
- cache->buffer = NULL;
-
- pipe->transfer_destroy(pipe, cache->trans);
- cache->trans = NULL;
- }
-
- sv = st_create_texture_sampler_view(st->pipe, cache->texture);
- if (sv) {
- draw_bitmap_quad(st->ctx,
- cache->xpos,
- cache->ypos,
- cache->zpos,
- BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT,
- sv,
- cache->color);
-
- pipe_sampler_view_reference(&sv, NULL);
- }
+ if (cache->trans) {
+ if (0)
+ print_cache(cache);
+ pipe_transfer_unmap(pipe, cache->trans);
+ cache->buffer = NULL;
+
+ pipe->transfer_destroy(pipe, cache->trans);
+ cache->trans = NULL;
+ }
+
+ sv = st_create_texture_sampler_view(st->pipe, cache->texture);
+ if (sv) {
+ draw_bitmap_quad(st->ctx,
+ cache->xpos,
+ cache->ypos,
+ cache->zpos,
+ BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT,
+ sv,
+ cache->color);
+
+ pipe_sampler_view_reference(&sv, NULL);
}
/* release/free the texture */
@@ -684,16 +680,6 @@ st_flush_bitmap_cache(struct st_context *st)
/**
- * Flush bitmap cache.
- */
-void
-st_flush_bitmap( struct st_context *st )
-{
- st_flush_bitmap_cache(st);
-}
-
-
-/**
* Try to accumulate this glBitmap call in the bitmap cache.
* \return GL_TRUE for success, GL_FALSE if bitmap is too large, etc.
*/
diff --git a/mesalib/src/mesa/state_tracker/st_cb_bitmap.h b/mesalib/src/mesa/state_tracker/st_cb_bitmap.h
index ed1415803..25410e503 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_bitmap.h
+++ b/mesalib/src/mesa/state_tracker/st_cb_bitmap.h
@@ -58,12 +58,6 @@ st_make_bitmap_fragment_program(struct st_context *st,
extern void
st_flush_bitmap_cache(struct st_context *st);
-/* Flush bitmap cache and release vertex buffer. Needed at end of
- * frame to avoid synchronous rendering.
- */
-extern void
-st_flush_bitmap(struct st_context *st);
-
#else
static INLINE void
diff --git a/mesalib/src/mesa/state_tracker/st_cb_blit.c b/mesalib/src/mesa/state_tracker/st_cb_blit.c
index 1486779fd..b189cb406 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_blit.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_blit.c
@@ -80,9 +80,8 @@ st_BlitFramebuffer_resolve(struct gl_context *ctx,
info->src.res = srcRb->texture;
info->src.layer = srcRb->surface->u.tex.first_layer;
- info->dst.res = dstRb->texture;
- info->dst.level = dstRb->surface->u.tex.level;
- info->dst.layer = dstRb->surface->u.tex.first_layer;
+
+ info->dst.surface = dstRb->surface;
st->pipe->resource_resolve(st->pipe, info);
}
@@ -114,9 +113,8 @@ st_BlitFramebuffer_resolve(struct gl_context *ctx,
info->src.res = srcRb->texture;
info->src.layer = srcRb->surface->u.tex.first_layer;
- info->dst.res = dstRb->texture;
- info->dst.level = dstRb->surface->u.tex.level;
- info->dst.layer = dstRb->surface->u.tex.first_layer;
+
+ info->dst.surface = dstRb->surface;
st->pipe->resource_resolve(st->pipe, info);
}
@@ -130,9 +128,8 @@ st_BlitFramebuffer_resolve(struct gl_context *ctx,
info->src.res = srcRb->texture;
info->src.layer = srcRb->surface->u.tex.first_layer;
- info->dst.res = dstRb->texture;
- info->dst.level = dstRb->surface->u.tex.level;
- info->dst.layer = dstRb->surface->u.tex.first_layer;
+
+ info->dst.surface = dstRb->surface;
st->pipe->resource_resolve(st->pipe, info);
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
index c5f36316b..f288a9632 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -43,6 +43,7 @@
#include "main/texformat.h"
#include "main/teximage.h"
#include "main/texstore.h"
+#include "main/glformats.h"
#include "program/program.h"
#include "program/prog_print.h"
#include "program/prog_instruction.h"
@@ -368,7 +369,7 @@ internal_format(struct gl_context *ctx, GLenum format, GLenum type)
return GL_STENCIL_INDEX;
default:
- if (_mesa_is_integer_format(format)) {
+ if (_mesa_is_enum_format_integer(format)) {
switch (type) {
case GL_BYTE:
return GL_RGBA8I;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.c b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
index e1818abb9..7eef5c659 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_fbo.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
@@ -291,13 +291,21 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw)
case PIPE_FORMAT_R8G8B8A8_UNORM:
case PIPE_FORMAT_B8G8R8A8_UNORM:
case PIPE_FORMAT_A8R8G8B8_UNORM:
+ strb->Base.InternalFormat = GL_RGBA8;
+ break;
case PIPE_FORMAT_R8G8B8X8_UNORM:
case PIPE_FORMAT_B8G8R8X8_UNORM:
case PIPE_FORMAT_X8R8G8B8_UNORM:
+ strb->Base.InternalFormat = GL_RGB8;
+ break;
case PIPE_FORMAT_B5G5R5A1_UNORM:
+ strb->Base.InternalFormat = GL_RGB5_A1;
+ break;
case PIPE_FORMAT_B4G4R4A4_UNORM:
+ strb->Base.InternalFormat = GL_RGBA4;
+ break;
case PIPE_FORMAT_B5G6R5_UNORM:
- strb->Base.InternalFormat = GL_RGBA;
+ strb->Base.InternalFormat = GL_RGB565;
break;
case PIPE_FORMAT_Z16_UNORM:
strb->Base.InternalFormat = GL_DEPTH_COMPONENT16;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_flush.c b/mesalib/src/mesa/state_tracker/st_cb_flush.c
index 4e40a93f5..b4372ae7c 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_flush.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_flush.c
@@ -81,7 +81,7 @@ void st_flush( struct st_context *st,
{
FLUSH_CURRENT(st->ctx, 0);
- st_flush_bitmap(st);
+ st_flush_bitmap_cache(st);
st->pipe->flush( st->pipe, fence );
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_viewport.c b/mesalib/src/mesa/state_tracker/st_cb_viewport.c
index d4742eb89..d654ed6e7 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_viewport.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_viewport.c
@@ -43,7 +43,9 @@ static INLINE struct st_framebuffer *
st_ws_framebuffer(struct gl_framebuffer *fb)
{
/* FBO cannot be casted. See st_new_framebuffer */
- return (struct st_framebuffer *) ((fb && !fb->Name) ? fb : NULL);
+ if (fb && _mesa_is_winsys_fbo(fb))
+ return (struct st_framebuffer *) fb;
+ return NULL;
}
static void st_viewport(struct gl_context * ctx, GLint x, GLint y,
diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c
index 117ea90f8..6b7c047ed 100644
--- a/mesalib/src/mesa/state_tracker/st_context.c
+++ b/mesalib/src/mesa/state_tracker/st_context.c
@@ -211,9 +211,9 @@ struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
struct dd_function_table funcs;
/* Sanity checks */
- assert(MESA_SHADER_VERTEX == PIPE_SHADER_VERTEX);
- assert(MESA_SHADER_FRAGMENT == PIPE_SHADER_FRAGMENT);
- assert(MESA_SHADER_GEOMETRY == PIPE_SHADER_GEOMETRY);
+ STATIC_ASSERT(MESA_SHADER_VERTEX == PIPE_SHADER_VERTEX);
+ STATIC_ASSERT(MESA_SHADER_FRAGMENT == PIPE_SHADER_FRAGMENT);
+ STATIC_ASSERT(MESA_SHADER_GEOMETRY == PIPE_SHADER_GEOMETRY);
memset(&funcs, 0, sizeof(funcs));
st_init_driver_functions(&funcs);
diff --git a/mesalib/src/mesa/state_tracker/st_context.h b/mesalib/src/mesa/state_tracker/st_context.h
index a3f44b3ab..cdac5a1c7 100644
--- a/mesalib/src/mesa/state_tracker/st_context.h
+++ b/mesalib/src/mesa/state_tracker/st_context.h
@@ -31,6 +31,7 @@
#include "main/mtypes.h"
#include "pipe/p_state.h"
#include "state_tracker/st_api.h"
+#include "main/fbobject.h"
struct bitmap_cache;
struct blit_state;
@@ -117,6 +118,8 @@ struct st_context
GLuint num_vertex_textures;
GLuint poly_stipple[32]; /**< In OpenGL's bottom-to-top order */
+
+ GLuint fb_orientation;
} state;
char vendor[100];
@@ -236,7 +239,7 @@ void st_invalidate_state(struct gl_context * ctx, GLuint new_state);
static INLINE GLuint
st_fb_orientation(const struct gl_framebuffer *fb)
{
- if (fb && fb->Name == 0) {
+ if (fb && _mesa_is_winsys_fbo(fb)) {
/* Drawing into a window (on-screen buffer).
*
* Negate Y scale to flip image vertically.
diff --git a/mesalib/src/mesa/state_tracker/st_draw.c b/mesalib/src/mesa/state_tracker/st_draw.c
index 4dc09e7fb..9dc4822cc 100644
--- a/mesalib/src/mesa/state_tracker/st_draw.c
+++ b/mesalib/src/mesa/state_tracker/st_draw.c
@@ -153,9 +153,9 @@ static unsigned
translate_prim(const struct gl_context *ctx, unsigned prim)
{
/* GL prims should match Gallium prims, spot-check a few */
- assert(GL_POINTS == PIPE_PRIM_POINTS);
- assert(GL_QUADS == PIPE_PRIM_QUADS);
- assert(GL_TRIANGLE_STRIP_ADJACENCY == PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY);
+ STATIC_ASSERT(GL_POINTS == PIPE_PRIM_POINTS);
+ STATIC_ASSERT(GL_QUADS == PIPE_PRIM_QUADS);
+ STATIC_ASSERT(GL_TRIANGLE_STRIP_ADJACENCY == PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY);
/* Avoid quadstrips if it's easy to do so:
* Note: it's important to do the correct trimming if we change the
diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c
index 57d34411f..962b09250 100644
--- a/mesalib/src/mesa/state_tracker/st_format.c
+++ b/mesalib/src/mesa/state_tracker/st_format.c
@@ -34,6 +34,7 @@
#include "main/imports.h"
#include "main/context.h"
+#include "main/glformats.h"
#include "main/texstore.h"
#include "main/image.h"
#include "main/macros.h"
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 1d91e3661..fcd69b18d 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -1448,9 +1448,29 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
emit(ir, TGSI_OPCODE_DDX, result_dst, op[0]);
break;
case ir_unop_dFdy:
- op[0].negate = ~op[0].negate;
- emit(ir, TGSI_OPCODE_DDY, result_dst, op[0]);
+ {
+ /* The X component contains 1 or -1 depending on whether the framebuffer
+ * is a FBO or the window system buffer, respectively.
+ * It is then multiplied with the source operand of DDY.
+ */
+ static const gl_state_index transform_y_state[STATE_LENGTH]
+ = { STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM };
+
+ unsigned transform_y_index =
+ _mesa_add_state_reference(this->prog->Parameters,
+ transform_y_state);
+
+ st_src_reg transform_y = st_src_reg(PROGRAM_STATE_VAR,
+ transform_y_index,
+ glsl_type::vec4_type);
+ transform_y.swizzle = SWIZZLE_XXXX;
+
+ st_src_reg temp = get_temp(glsl_type::vec4_type);
+
+ emit(ir, TGSI_OPCODE_MUL, st_dst_reg(temp), transform_y, op[0]);
+ emit(ir, TGSI_OPCODE_DDY, result_dst, temp);
break;
+ }
case ir_unop_noise: {
/* At some point, a motivated person could add a better
@@ -2758,8 +2778,6 @@ glsl_to_tgsi_visitor::visit(ir_return *ir)
void
glsl_to_tgsi_visitor::visit(ir_discard *ir)
{
- struct gl_fragment_program *fp = (struct gl_fragment_program *)this->prog;
-
if (ir->condition) {
ir->condition->accept(this);
this->result.negate = ~this->result.negate;
@@ -2767,8 +2785,6 @@ glsl_to_tgsi_visitor::visit(ir_discard *ir)
} else {
emit(ir, TGSI_OPCODE_KILP);
}
-
- fp->UsesKill = GL_TRUE;
}
void
@@ -2893,13 +2909,15 @@ set_uniform_initializer(struct gl_context *ctx, void *mem_ctx,
return;
}
- int loc = _mesa_get_uniform_location(ctx, shader_program, name);
-
- if (loc == -1) {
+ unsigned offset;
+ unsigned index = _mesa_get_uniform_location(ctx, shader_program, name,
+ &offset);
+ if (offset == GL_INVALID_INDEX) {
fail_link(shader_program,
"Couldn't find uniform for initializer %s\n", name);
return;
}
+ int loc = _mesa_uniform_merge_location_offset(index, offset);
for (unsigned int i = 0; i < (type->is_array() ? type->length : 1); i++) {
ir_constant *element;
@@ -4483,6 +4501,7 @@ st_translate_program(
const ubyte inputSemanticName[],
const ubyte inputSemanticIndex[],
const GLuint interpMode[],
+ const GLboolean is_centroid[],
GLuint numOutputs,
const GLuint outputMapping[],
const ubyte outputSemanticName[],
@@ -4524,10 +4543,11 @@ st_translate_program(
*/
if (procType == TGSI_PROCESSOR_FRAGMENT) {
for (i = 0; i < numInputs; i++) {
- t->inputs[i] = ureg_DECL_fs_input(ureg,
- inputSemanticName[i],
- inputSemanticIndex[i],
- interpMode[i]);
+ t->inputs[i] = ureg_DECL_fs_input_cyl_centroid(ureg,
+ inputSemanticName[i],
+ inputSemanticIndex[i],
+ interpMode[i], 0,
+ is_centroid[i]);
}
if (proginfo->InputsRead & FRAG_BIT_WPOS) {
diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.h b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.h
index 55d59d571..a3fe91f7e 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.h
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.h
@@ -45,6 +45,7 @@ enum pipe_error st_translate_program(
const ubyte inputSemanticName[],
const ubyte inputSemanticIndex[],
const GLuint interpMode[],
+ const GLboolean is_centroid[],
GLuint numOutputs,
const GLuint outputMapping[],
const ubyte outputSemanticName[],
diff --git a/mesalib/src/mesa/state_tracker/st_manager.c b/mesalib/src/mesa/state_tracker/st_manager.c
index 748624f3d..875e0c44a 100644
--- a/mesalib/src/mesa/state_tracker/st_manager.c
+++ b/mesalib/src/mesa/state_tracker/st_manager.c
@@ -64,7 +64,9 @@ static INLINE struct st_framebuffer *
st_ws_framebuffer(struct gl_framebuffer *fb)
{
/* FBO cannot be casted. See st_new_framebuffer */
- return (struct st_framebuffer *) ((fb && !fb->Name) ? fb : NULL);
+ if (fb && _mesa_is_winsys_fbo(fb))
+ return (struct st_framebuffer *) fb;
+ return NULL;
}
/**
diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c
index 9f98298b4..36015f69a 100644
--- a/mesalib/src/mesa/state_tracker/st_program.c
+++ b/mesalib/src/mesa/state_tracker/st_program.c
@@ -347,6 +347,7 @@ st_translate_vertex_program(struct st_context *st,
NULL, /* input semantic name */
NULL, /* input semantic index */
NULL, /* interp mode */
+ NULL, /* is centroid */
/* outputs */
stvp->num_outputs,
stvp->result_to_output,
@@ -484,6 +485,7 @@ st_translate_fragment_program(struct st_context *st,
ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS];
ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS];
+ GLboolean is_centroid[PIPE_MAX_SHADER_INPUTS];
uint fs_num_inputs = 0;
ubyte fs_output_semantic_name[PIPE_MAX_SHADER_OUTPUTS];
@@ -537,6 +539,7 @@ st_translate_fragment_program(struct st_context *st,
const GLuint slot = fs_num_inputs++;
inputMapping[attr] = slot;
+ is_centroid[slot] = (stfp->Base.IsCentroid & BITFIELD64_BIT(attr)) != 0;
switch (attr) {
case FRAG_ATTRIB_WPOS:
@@ -716,6 +719,7 @@ st_translate_fragment_program(struct st_context *st,
input_semantic_name,
input_semantic_index,
interpMode,
+ is_centroid,
/* outputs */
fs_num_outputs,
outputMapping,
diff --git a/mesalib/src/mesa/swrast/s_texfetch.c b/mesalib/src/mesa/swrast/s_texfetch.c
index 8529ff08d..12ee47963 100644
--- a/mesalib/src/mesa/swrast/s_texfetch.c
+++ b/mesalib/src/mesa/swrast/s_texfetch.c
@@ -1104,7 +1104,13 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
NULL,
NULL,
NULL
- }
+ },
+ {
+ MESA_FORMAT_ABGR2101010_UINT,
+ NULL,
+ NULL,
+ NULL
+ },
};
diff --git a/mesalib/src/mesa/tnl/t_rasterpos.c b/mesalib/src/mesa/tnl/t_rasterpos.c
index 50b5fcb4c..a28ad0daf 100644
--- a/mesalib/src/mesa/tnl/t_rasterpos.c
+++ b/mesalib/src/mesa/tnl/t_rasterpos.c
@@ -271,7 +271,7 @@ compute_texgen(struct gl_context *ctx, const GLfloat vObj[4], const GLfloat vEye
rz = u[2] - normal[2] * two_nu;
m = rx * rx + ry * ry + (rz + 1.0F) * (rz + 1.0F);
if (m > 0.0F)
- mInv = 0.5F * _mesa_inv_sqrtf(m);
+ mInv = 0.5F * INV_SQRTF(m);
else
mInv = 0.0F;
diff --git a/mesalib/src/mesa/tnl/t_vb_points.c b/mesalib/src/mesa/tnl/t_vb_points.c
index 9edbbc708..0e33b691e 100644
--- a/mesalib/src/mesa/tnl/t_vb_points.c
+++ b/mesalib/src/mesa/tnl/t_vb_points.c
@@ -64,7 +64,7 @@ run_point_stage(struct gl_context *ctx, struct tnl_pipeline_stage *stage)
for (i = 0; i < VB->Count; i++) {
const GLfloat dist = FABSF(*eyeCoord);
const GLfloat q = p0 + dist * (p1 + dist * p2);
- const GLfloat atten = (q != 0.0F) ? SQRTF(1.0F / q) : 1.0F;
+ const GLfloat atten = (q != 0.0F) ? INV_SQRTF(q) : 1.0F;
size[i][0] = pointSize * atten; /* clamping done in rasterization */
eyeCoord += eyeCoordStride;
}
diff --git a/mesalib/src/mesa/tnl/t_vb_texgen.c b/mesalib/src/mesa/tnl/t_vb_texgen.c
index 61430c396..d4c788523 100644
--- a/mesalib/src/mesa/tnl/t_vb_texgen.c
+++ b/mesalib/src/mesa/tnl/t_vb_texgen.c
@@ -117,7 +117,7 @@ static void build_m3( GLfloat f[][3], GLfloat m[],
fz = f[i][2] = u[2] - norm[2] * two_nu;
m[i] = fx * fx + fy * fy + (fz + 1.0F) * (fz + 1.0F);
if (m[i] != 0.0F) {
- m[i] = 0.5F * _mesa_inv_sqrtf(m[i]);
+ m[i] = 0.5F * INV_SQRTF(m[i]);
}
}
}
@@ -146,7 +146,7 @@ static void build_m2( GLfloat f[][3], GLfloat m[],
fz = f[i][2] = u[2] - norm[2] * two_nu;
m[i] = fx * fx + fy * fy + (fz + 1.0F) * (fz + 1.0F);
if (m[i] != 0.0F) {
- m[i] = 0.5F * _mesa_inv_sqrtf(m[i]);
+ m[i] = 0.5F * INV_SQRTF(m[i]);
}
}
}
diff --git a/mesalib/src/mesa/vbo/vbo_split_copy.c b/mesalib/src/mesa/vbo/vbo_split_copy.c
index 528fcfd7f..a917f39ca 100644
--- a/mesalib/src/mesa/vbo/vbo_split_copy.c
+++ b/mesalib/src/mesa/vbo/vbo_split_copy.c
@@ -32,7 +32,7 @@
#include "main/glheader.h"
#include "main/bufferobj.h"
#include "main/imports.h"
-#include "main/image.h"
+#include "main/glformats.h"
#include "main/macros.h"
#include "main/mtypes.h"
diff --git a/mesalib/src/mesa/vbo/vbo_split_inplace.c b/mesalib/src/mesa/vbo/vbo_split_inplace.c
index 686b30a76..8a3830805 100644
--- a/mesalib/src/mesa/vbo/vbo_split_inplace.c
+++ b/mesalib/src/mesa/vbo/vbo_split_inplace.c
@@ -30,7 +30,7 @@
#include "main/mtypes.h"
#include "main/macros.h"
#include "main/enums.h"
-#include "main/image.h"
+#include "main/glformats.h"
#include "vbo_split.h"
diff --git a/pixman/.gitignore b/pixman/.gitignore
index b9853b117..a4d9f99a7 100644
--- a/pixman/.gitignore
+++ b/pixman/.gitignore
@@ -36,12 +36,14 @@ demos/gradient-test
demos/quad2quad
demos/radial-test
demos/screen-test
+demos/srgb-test
demos/trap-test
demos/tri-test
pixman/pixman-combine32.c
pixman/pixman-combine32.h
pixman/pixman-combine64.c
pixman/pixman-combine64.h
+pixman/pixman-srgb.c
pixman/pixman-version.h
test/a1-trap-test
test/affine-test
diff --git a/pixman/demos/Makefile.am b/pixman/demos/Makefile.am
index 9aac1f5e9..d8fb0dab2 100644
--- a/pixman/demos/Makefile.am
+++ b/pixman/demos/Makefile.am
@@ -20,7 +20,8 @@ DEMOS = \
trap-test \
tri-test \
quad2quad \
- checkerboard
+ checkerboard \
+ srgb-test
EXTRA_DIST = parrot.c parrot.jpg
@@ -35,6 +36,7 @@ convolution_test_SOURCES = convolution-test.c $(GTK_UTILS)
radial_test_SOURCES = radial-test.c $(GTK_UTILS)
tri_test_SOURCES = tri-test.c $(GTK_UTILS)
checkerboard_SOURCES = checkerboard.c $(GTK_UTILS)
+srgb_test_SOURCES = srgb-test.c $(GTK_UTILS)
noinst_PROGRAMS = $(DEMOS)
diff --git a/pixman/demos/srgb-test.c b/pixman/demos/srgb-test.c
new file mode 100644
index 000000000..bc073491e
--- /dev/null
+++ b/pixman/demos/srgb-test.c
@@ -0,0 +1,96 @@
+#include <math.h>
+
+#include "pixman.h"
+#include "gtk-utils.h"
+
+static uint32_t
+linear_argb_to_premult_argb (float a,
+ float r,
+ float g,
+ float b)
+{
+ r *= a;
+ g *= a;
+ b *= a;
+ return (uint32_t) (a * 255.0f + 0.5f) << 24
+ | (uint32_t) (r * 255.0f + 0.5f) << 16
+ | (uint32_t) (g * 255.0f + 0.5f) << 8
+ | (uint32_t) (b * 255.0f + 0.5f) << 0;
+}
+
+static float
+lin2srgb (float linear)
+{
+ if (linear < 0.0031308f)
+ return linear * 12.92f;
+ else
+ return 1.055f * powf (linear, 1.0f/2.4f) - 0.055f;
+}
+
+static uint32_t
+linear_argb_to_premult_srgb_argb (float a,
+ float r,
+ float g,
+ float b)
+{
+ r = lin2srgb (r * a);
+ g = lin2srgb (g * a);
+ b = lin2srgb (b * a);
+ return (uint32_t) (a * 255.0f + 0.5f) << 24
+ | (uint32_t) (r * 255.0f + 0.5f) << 16
+ | (uint32_t) (g * 255.0f + 0.5f) << 8
+ | (uint32_t) (b * 255.0f + 0.5f) << 0;
+}
+
+int
+main (int argc, char **argv)
+{
+#define WIDTH 400
+#define HEIGHT 200
+ int y, x, p;
+ float alpha;
+
+ uint32_t *dest = malloc (WIDTH * HEIGHT * 4);
+ uint32_t *src1 = malloc (WIDTH * HEIGHT * 4);
+ pixman_image_t *dest_img, *src1_img;
+
+ dest_img = pixman_image_create_bits (PIXMAN_a8r8g8b8_sRGB,
+ WIDTH, HEIGHT,
+ dest,
+ WIDTH * 4);
+ src1_img = pixman_image_create_bits (PIXMAN_a8r8g8b8,
+ WIDTH, HEIGHT,
+ src1,
+ WIDTH * 4);
+
+ for (y = 0; y < HEIGHT; y ++)
+ {
+ p = WIDTH * y;
+ for (x = 0; x < WIDTH; x ++)
+ {
+ alpha = (float) x / WIDTH;
+ src1[p + x] = linear_argb_to_premult_argb (alpha, 1, 0, 1);
+ dest[p + x] = linear_argb_to_premult_srgb_argb (1-alpha, 0, 1, 0);
+ }
+ }
+
+ pixman_image_composite (PIXMAN_OP_ADD, src1_img, NULL, dest_img,
+ 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
+ pixman_image_unref (src1_img);
+ free (src1);
+
+ pixman_image_unref (dest_img);
+
+ /* Now that the picture has been correctly constructed,
+ * we hand it over to our support library as argb which it
+ * knows how to handle (it doesn't understand _sRGB format). */
+ dest_img = pixman_image_create_bits (PIXMAN_a8r8g8b8,
+ WIDTH, HEIGHT,
+ dest,
+ WIDTH * 4);
+ show_image (dest_img);
+ pixman_image_unref (dest_img);
+ free (dest);
+
+ return 0;
+}
diff --git a/pixman/pixman/Makefile.sources b/pixman/pixman/Makefile.sources
index 6472994c4..cf7040f33 100644
--- a/pixman/pixman/Makefile.sources
+++ b/pixman/pixman/Makefile.sources
@@ -25,6 +25,7 @@ libpixman_sources = \
pixman-region16.c \
pixman-region32.c \
pixman-solid-fill.c \
+ pixman-srgb.c \
pixman-timer.c \
pixman-trap.c \
pixman-utils.c \
@@ -46,8 +47,12 @@ BUILT_SOURCES = \
pixman-combine32.h \
pixman-combine64.c \
pixman-combine64.h \
+ pixman-srgb.c \
$(NULL)
+pixman-srgb.c: make-srgb.pl
+ $(PERL) $< > $@ || ($(RM) $@; exit 1)
+
pixman-combine32.c: pixman-combine.c.template make-combine.pl
$(PERL) $(lastword $+) 8 < $< > $@ || ($(RM) $@; exit 1)
pixman-combine32.h: pixman-combine.h.template make-combine.pl
diff --git a/pixman/pixman/make-srgb.pl b/pixman/pixman/make-srgb.pl
new file mode 100644
index 000000000..ebde2eac6
--- /dev/null
+++ b/pixman/pixman/make-srgb.pl
@@ -0,0 +1,112 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+sub linear_to_srgb
+{
+ my ($c) = @_;
+
+ if ($c < 0.0031308)
+ {
+ return $c * 12.92;
+ }
+ else
+ {
+ return 1.055 * $c ** (1.0/2.4) - 0.055;
+ }
+}
+
+sub srgb_to_linear
+{
+ my ($c) = @_;
+
+ if ($c < 0.04045)
+ {
+ return $c / 12.92;
+ }
+ else
+ {
+ return (($c + 0.055) / 1.055) ** 2.4
+ }
+}
+
+my @linear_to_srgb;
+for my $linear (0 .. 4095)
+{
+ my $srgb = int(linear_to_srgb($linear / 4095.0) * 255.0 + 0.5);
+ push @linear_to_srgb, $srgb;
+}
+
+my @srgb_to_linear;
+for my $srgb (0 .. 255)
+{
+ my $linear = int(srgb_to_linear($srgb / 255.0) * 65535.0 + 0.5);
+ push @srgb_to_linear, $linear;
+}
+
+# Ensure that we have a lossless sRGB and back conversion loop.
+# some of the darkest shades need a little bias -- maximum is just
+# 5 increments out of 16. This gives us useful property with
+# least amount of error in the sRGB-to-linear table, and keeps the actual
+# table lookup in the other direction as simple as possible.
+for my $srgb (0 .. $#srgb_to_linear)
+{
+ my $add = 0;
+ while (1)
+ {
+ my $linear = $srgb_to_linear[$srgb];
+ my $srgb_lossy = $linear_to_srgb[$linear >> 4];
+ last if $srgb == $srgb_lossy;
+
+ # Add slight bias to this component until it rounds correctly
+ $srgb_to_linear[$srgb] ++;
+ $add ++;
+ }
+ die "Too many adds at $srgb" if $add > 5;
+}
+
+print <<"PROLOG";
+/* WARNING: This file is generated by $0.
+ * Please edit that file instead of this one.
+ */
+
+#include <stdint.h>
+
+#include "config.h"
+#include "pixman-private.h"
+
+PROLOG
+
+print "const uint8_t linear_to_srgb[" . @linear_to_srgb . "] =\n";
+print "{\n";
+for my $linear (0 .. $#linear_to_srgb)
+{
+ if (($linear % 10) == 0)
+ {
+ print "\t";
+ }
+ print sprintf("%d, ", $linear_to_srgb[$linear]);
+ if (($linear % 10) == 9)
+ {
+ print "\n";
+ }
+}
+print "\n};\n";
+print "\n";
+
+print "const uint16_t srgb_to_linear[" . @srgb_to_linear . "] =\n";
+print "{\n";
+for my $srgb (0 .. $#srgb_to_linear)
+{
+ if (($srgb % 10) == 0)
+ {
+ print "\t";
+ }
+ print sprintf("%d, ", $srgb_to_linear[$srgb]);
+ if (($srgb % 10) == 9)
+ {
+ print "\n";
+ }
+}
+print "\n};\n";
+
diff --git a/pixman/pixman/pixman-access.c b/pixman/pixman/pixman-access.c
index 6743887d0..9feafc49d 100644
--- a/pixman/pixman/pixman-access.c
+++ b/pixman/pixman/pixman-access.c
@@ -32,8 +32,8 @@
#include <string.h>
#include <assert.h>
-#include "pixman-private.h"
#include "pixman-accessor.h"
+#include "pixman-private.h"
#define CONVERT_RGB24_TO_Y15(s) \
(((((s) >> 16) & 0xff) * 153 + \
@@ -210,6 +210,7 @@ get_shifts (pixman_format_code_t format,
break;
case PIXMAN_TYPE_ARGB:
+ case PIXMAN_TYPE_ARGB_SRGB:
*b = 0;
*g = *b + PIXMAN_FORMAT_B (format);
*r = *g + PIXMAN_FORMAT_G (format);
@@ -1027,6 +1028,130 @@ fetch_pixel_generic_64 (bits_image_t *image,
return result;
}
+/* The 32_sRGB paths should be deleted after narrow processing
+ * is no longer invoked for formats that are considered wide.
+ * (Also see fetch_pixel_generic_lossy_32) */
+static void
+fetch_scanline_a8r8g8b8_32_sRGB (pixman_image_t *image,
+ int x,
+ int y,
+ int width,
+ uint32_t *buffer,
+ const uint32_t *mask)
+{
+ const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
+ const uint32_t *pixel = (uint32_t *)bits + x;
+ const uint32_t *end = pixel + width;
+ uint32_t tmp;
+
+ while (pixel < end)
+ {
+ tmp = READ (image, pixel++);
+ *buffer++ = (tmp >> 24) << 24
+ | (srgb_to_linear[(tmp >> 16) & 0xff] >> 8) << 16
+ | (srgb_to_linear[(tmp >> 8) & 0xff] >> 8) << 8
+ | (srgb_to_linear[(tmp >> 0) & 0xff] >> 8) << 0;
+ }
+}
+
+static void
+fetch_scanline_a8r8g8b8_64_sRGB (pixman_image_t *image,
+ int x,
+ int y,
+ int width,
+ uint32_t *b,
+ const uint32_t *mask)
+{
+ const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
+ const uint32_t *pixel = (uint32_t *)bits + x;
+ const uint32_t *end = pixel + width;
+ uint64_t *buffer = (uint64_t *)b;
+ uint32_t tmp;
+
+ while (pixel < end)
+ {
+ tmp = READ (image, pixel++);
+ *buffer++ = (uint64_t) ((tmp >> 24) * 257) << 48
+ | (uint64_t) srgb_to_linear[(tmp >> 16) & 0xff] << 32
+ | (uint64_t) srgb_to_linear[(tmp >> 8) & 0xff] << 16
+ | (uint64_t) srgb_to_linear[(tmp >> 0) & 0xff] << 0;
+ }
+}
+
+static uint32_t
+fetch_pixel_a8r8g8b8_32_sRGB (bits_image_t *image,
+ int offset,
+ int line)
+{
+ uint32_t *bits = image->bits + line * image->rowstride;
+ uint32_t tmp = READ (image, bits + offset);
+ return (tmp >> 24) << 24
+ | (srgb_to_linear[(tmp >> 16) & 0xff] >> 8) << 16
+ | (srgb_to_linear[(tmp >> 8) & 0xff] >> 8) << 8
+ | (srgb_to_linear[(tmp >> 0) & 0xff] >> 8) << 0;
+}
+
+static uint64_t
+fetch_pixel_a8r8g8b8_64_sRGB (bits_image_t *image,
+ int offset,
+ int line)
+{
+ uint32_t *bits = image->bits + line * image->rowstride;
+ uint32_t tmp = READ (image, bits + offset);
+ return (uint64_t) ((tmp >> 24) * 257) << 48
+ | (uint64_t) srgb_to_linear[(tmp >> 16) & 0xff] << 32
+ | (uint64_t) srgb_to_linear[(tmp >> 8) & 0xff] << 16
+ | (uint64_t) srgb_to_linear[(tmp >> 0) & 0xff] << 0;
+}
+
+static void
+store_scanline_a8r8g8b8_32_sRGB (bits_image_t *image,
+ int x,
+ int y,
+ int width,
+ const uint32_t *v)
+{
+ uint32_t *bits = image->bits + image->rowstride * y;
+ uint64_t *values = (uint64_t *)v;
+ uint32_t *pixel = bits + x;
+ uint64_t tmp;
+ int i;
+
+ for (i = 0; i < width; ++i)
+ {
+ tmp = values[i];
+ WRITE (image, pixel++,
+ ((uint32_t) (tmp >> 24 ) << 24)
+ | (linear_to_srgb[(tmp >> 16 << 4) & 0xfff] << 16)
+ | (linear_to_srgb[(tmp >> 8 << 4) & 0xfff] << 8)
+ | (linear_to_srgb[(tmp >> 0 << 4) & 0xfff] << 0));
+ }
+}
+
+static void
+store_scanline_a8r8g8b8_64_sRGB (bits_image_t *image,
+ int x,
+ int y,
+ int width,
+ const uint32_t *v)
+{
+ uint32_t *bits = image->bits + image->rowstride * y;
+ uint64_t *values = (uint64_t *)v;
+ uint32_t *pixel = bits + x;
+ uint64_t tmp;
+ int i;
+
+ for (i = 0; i < width; ++i)
+ {
+ tmp = values[i];
+ WRITE (image, pixel++,
+ ((uint32_t) (tmp >> 56) << 24)
+ | (linear_to_srgb[(tmp >> 36) & 0xfff] << 16)
+ | (linear_to_srgb[(tmp >> 20) & 0xfff] << 8)
+ | (linear_to_srgb[(tmp >> 4) & 0xfff] << 0));
+ }
+}
+
/*
* XXX: The transformed fetch path only works at 32-bpp so far. When all
* paths have wide versions, this can be removed.
@@ -1079,6 +1204,13 @@ static const format_info_t accessors[] =
FORMAT_INFO (r8g8b8x8),
FORMAT_INFO (x14r6g6b6),
+/* sRGB formats */
+ { PIXMAN_a8r8g8b8_sRGB,
+ fetch_scanline_a8r8g8b8_32_sRGB,
+ fetch_scanline_a8r8g8b8_64_sRGB,
+ fetch_pixel_a8r8g8b8_32_sRGB, fetch_pixel_a8r8g8b8_64_sRGB,
+ store_scanline_a8r8g8b8_32_sRGB, store_scanline_a8r8g8b8_64_sRGB },
+
/* 24bpp formats */
FORMAT_INFO (r8g8b8),
FORMAT_INFO (b8g8r8),
diff --git a/pixman/pixman/pixman-image.c b/pixman/pixman/pixman-image.c
index 8b634a7dc..15597bd61 100644
--- a/pixman/pixman/pixman-image.c
+++ b/pixman/pixman/pixman-image.c
@@ -909,7 +909,8 @@ _pixman_image_get_solid (pixman_implementation_t *imp,
}
/* If necessary, convert RGB <--> BGR. */
- if (PIXMAN_FORMAT_TYPE (format) != PIXMAN_TYPE_ARGB)
+ if (PIXMAN_FORMAT_TYPE (format) != PIXMAN_TYPE_ARGB
+ && PIXMAN_FORMAT_TYPE (format) != PIXMAN_TYPE_ARGB_SRGB)
{
result = (((result & 0xff000000) >> 0) |
((result & 0x00ff0000) >> 16) |
diff --git a/pixman/pixman/pixman-private.h b/pixman/pixman/pixman-private.h
index 4d8f64d3b..d5e6a72ee 100644
--- a/pixman/pixman/pixman-private.h
+++ b/pixman/pixman/pixman-private.h
@@ -887,7 +887,8 @@ pixman_list_move_to_front (pixman_list_t *list, pixman_link_t *link)
(PIXMAN_FORMAT_A (f) > 8 || \
PIXMAN_FORMAT_R (f) > 8 || \
PIXMAN_FORMAT_G (f) > 8 || \
- PIXMAN_FORMAT_B (f) > 8)
+ PIXMAN_FORMAT_B (f) > 8 || \
+ PIXMAN_FORMAT_TYPE (f) == PIXMAN_TYPE_ARGB_SRGB)
#ifdef WORDS_BIGENDIAN
# define SCREEN_SHIFT_LEFT(x,n) ((x) << (n))
@@ -1083,6 +1084,18 @@ void pixman_timer_register (pixman_timer_t *timer);
#endif /* PIXMAN_TIMERS */
+/* sRGB<->linear conversion tables. Linear color space is the same
+ * as sRGB but the components are in linear light (gamma 1.0).
+ *
+ * linear_to_srgb maps linear value from 0 to 4095 ([0.0, 1.0])
+ * and returns 8-bit sRGB value.
+ *
+ * srgb_to_linear maps 8-bit sRGB value to 16-bit linear value
+ * with range 0 to 65535 ([0.0, 1.0]).
+ */
+extern const uint8_t linear_to_srgb[4096];
+extern const uint16_t srgb_to_linear[256];
+
#endif /* __ASSEMBLER__ */
#endif /* PIXMAN_PRIVATE_H */
diff --git a/pixman/pixman/pixman.c b/pixman/pixman/pixman.c
index 0137c3cab..994ef388c 100644
--- a/pixman/pixman/pixman.c
+++ b/pixman/pixman/pixman.c
@@ -1017,6 +1017,7 @@ pixman_format_supported_source (pixman_format_code_t format)
case PIXMAN_a2r10g10b10:
case PIXMAN_x2r10g10b10:
case PIXMAN_a8r8g8b8:
+ case PIXMAN_a8r8g8b8_sRGB:
case PIXMAN_x8r8g8b8:
case PIXMAN_a8b8g8r8:
case PIXMAN_x8b8g8r8:
diff --git a/pixman/pixman/pixman.h b/pixman/pixman/pixman.h
index 7233ceb8a..e1cb90a7d 100644
--- a/pixman/pixman/pixman.h
+++ b/pixman/pixman/pixman.h
@@ -653,6 +653,7 @@ struct pixman_indexed
#define PIXMAN_TYPE_YV12 7
#define PIXMAN_TYPE_BGRA 8
#define PIXMAN_TYPE_RGBA 9
+#define PIXMAN_TYPE_ARGB_SRGB 10
#define PIXMAN_FORMAT_COLOR(f) \
(PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_ARGB || \
@@ -676,6 +677,9 @@ typedef enum {
PIXMAN_x2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,10,10,10),
PIXMAN_a2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,2,10,10,10),
+/* sRGB formats */
+ PIXMAN_a8r8g8b8_sRGB = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB_SRGB,8,8,8,8),
+
/* 24bpp formats */
PIXMAN_r8g8b8 = PIXMAN_FORMAT(24,PIXMAN_TYPE_ARGB,0,8,8,8),
PIXMAN_b8g8r8 = PIXMAN_FORMAT(24,PIXMAN_TYPE_ABGR,0,8,8,8),
diff --git a/pixman/test/composite.c b/pixman/test/composite.c
index bdecd75a7..2930fb75b 100644
--- a/pixman/test/composite.c
+++ b/pixman/test/composite.c
@@ -99,6 +99,9 @@ static const format_t formats[] =
P(x2b10g10r10),
P(a2r10g10b10),
P(a2b10g10r10),
+
+ /* sRGB formats */
+ P(a8r8g8b8_sRGB),
/* 24 bpp formats */
P(r8g8b8),
@@ -524,17 +527,8 @@ composite_test (image_t *dst,
pixman_bool_t component_alpha,
int testno)
{
- pixman_color_t fill;
color_t expected, tdst, tsrc, tmsk;
pixel_checker_t checker;
- pixman_image_t *solid;
-
- /* Initialize dst */
- compute_pixman_color (dst->color, &fill);
- solid = pixman_image_create_solid_fill (&fill);
- pixman_image_composite32 (PIXMAN_OP_SRC, solid, NULL, dst->image,
- 0, 0, 0, 0, 0, 0, dst->size, dst->size);
- pixman_image_unref (solid);
if (mask)
{
@@ -553,17 +547,56 @@ composite_test (image_t *dst,
}
tdst = *dst->color;
- round_color (dst->format->format, &tdst);
-
tsrc = *src->color;
- if (src->size)
- round_color (src->format->format, &tsrc);
if (mask)
{
tmsk = *mask->color;
- if (mask->size)
+ }
+
+ /* It turns out that by construction all source, mask etc. colors are
+ * linear because they are made from fills, and fills are always in linear
+ * color space. However, if they have been converted to bitmaps, we need
+ * to simulate the sRGB approximation to pass the test cases.
+ */
+ if (src->size)
+ {
+ if (PIXMAN_FORMAT_TYPE (src->format->format) == PIXMAN_TYPE_ARGB_SRGB)
+ {
+ tsrc.r = convert_linear_to_srgb (tsrc.r);
+ tsrc.g = convert_linear_to_srgb (tsrc.g);
+ tsrc.b = convert_linear_to_srgb (tsrc.b);
+ round_color (src->format->format, &tsrc);
+ tsrc.r = convert_srgb_to_linear (tsrc.r);
+ tsrc.g = convert_srgb_to_linear (tsrc.g);
+ tsrc.b = convert_srgb_to_linear (tsrc.b);
+ }
+ else
+ {
+ round_color (src->format->format, &tsrc);
+ }
+ }
+
+ if (mask && mask->size)
+ {
+ if (PIXMAN_FORMAT_TYPE (mask->format->format) == PIXMAN_TYPE_ARGB_SRGB)
+ {
+ tmsk.r = convert_linear_to_srgb (tmsk.r);
+ tmsk.g = convert_linear_to_srgb (tmsk.g);
+ tmsk.b = convert_linear_to_srgb (tmsk.b);
round_color (mask->format->format, &tmsk);
+ tmsk.r = convert_srgb_to_linear (tmsk.r);
+ tmsk.g = convert_srgb_to_linear (tmsk.g);
+ tmsk.b = convert_srgb_to_linear (tmsk.b);
+ }
+ else
+ {
+ round_color (mask->format->format, &tmsk);
+ }
+ }
+
+ if (mask)
+ {
if (component_alpha && PIXMAN_FORMAT_R (mask->format->format) == 0)
{
/* Ax component-alpha masks expand alpha into
@@ -573,6 +606,21 @@ composite_test (image_t *dst,
}
}
+ if (PIXMAN_FORMAT_TYPE (dst->format->format) == PIXMAN_TYPE_ARGB_SRGB)
+ {
+ tdst.r = convert_linear_to_srgb (tdst.r);
+ tdst.g = convert_linear_to_srgb (tdst.g);
+ tdst.b = convert_linear_to_srgb (tdst.b);
+ round_color (dst->format->format, &tdst);
+ tdst.r = convert_srgb_to_linear (tdst.r);
+ tdst.g = convert_srgb_to_linear (tdst.g);
+ tdst.b = convert_srgb_to_linear (tdst.b);
+ }
+ else
+ {
+ round_color (dst->format->format, &tdst);
+ }
+
do_composite (op->op,
&tsrc,
mask? &tmsk : NULL,
diff --git a/pixman/test/stress-test.c b/pixman/test/stress-test.c
index 9280802bd..54ab1c5a9 100644
--- a/pixman/test/stress-test.c
+++ b/pixman/test/stress-test.c
@@ -25,6 +25,7 @@ static const pixman_format_code_t image_formats[] =
PIXMAN_x14r6g6b6,
PIXMAN_r8g8b8,
PIXMAN_b8g8r8,
+ PIXMAN_a8r8g8b8_sRGB,
PIXMAN_r5g6b5,
PIXMAN_b5g6r5,
PIXMAN_x2r10g10b10,
diff --git a/pixman/test/utils.c b/pixman/test/utils.c
index 563b33d52..85b58d038 100644
--- a/pixman/test/utils.c
+++ b/pixman/test/utils.c
@@ -1,6 +1,7 @@
#define _GNU_SOURCE
#include "utils.h"
+#include <math.h>
#include <signal.h>
#include <stdlib.h>
@@ -765,6 +766,24 @@ aligned_malloc (size_t align, size_t size)
(((c) >> 8) & 0xff) * 301 + \
(((c) ) & 0xff) * 58) >> 2))
+double
+convert_srgb_to_linear (double c)
+{
+ if (c <= 0.04045)
+ return c / 12.92;
+ else
+ return powf ((c + 0.055) / 1.055, 2.4);
+}
+
+double
+convert_linear_to_srgb (double c)
+{
+ if (c <= 0.0031308)
+ return c * 12.92;
+ else
+ return 1.055 * powf (c, 1.0/2.4) - 0.055;
+}
+
void
initialize_palette (pixman_indexed_t *palette, uint32_t depth, int is_rgb)
{
@@ -868,6 +887,7 @@ pixel_checker_init (pixel_checker_t *checker, pixman_format_code_t format)
break;
case PIXMAN_TYPE_ARGB:
+ case PIXMAN_TYPE_ARGB_SRGB:
checker->bs = 0;
checker->gs = checker->bs + PIXMAN_FORMAT_B (format);
checker->rs = checker->gs + PIXMAN_FORMAT_G (format);
@@ -968,11 +988,25 @@ pixel_checker_get_min (const pixel_checker_t *checker, color_t *color,
pixman_bool_t
pixel_checker_check (const pixel_checker_t *checker, uint32_t pixel,
- color_t *color)
+ color_t *color_in)
{
int32_t a_lo, a_hi, r_lo, r_hi, g_lo, g_hi, b_lo, b_hi;
int32_t ai, ri, gi, bi;
pixman_bool_t result;
+ color_t tmp, *color;
+
+ if (PIXMAN_FORMAT_TYPE (checker->format) == PIXMAN_TYPE_ARGB_SRGB)
+ {
+ tmp.a = color_in->a;
+ tmp.r = convert_linear_to_srgb (color_in->r);
+ tmp.g = convert_linear_to_srgb (color_in->g);
+ tmp.b = convert_linear_to_srgb (color_in->b);
+ color = &tmp;
+ }
+ else
+ {
+ color = color_in;
+ }
pixel_checker_get_min (checker, color, &a_lo, &r_lo, &g_lo, &b_lo);
pixel_checker_get_max (checker, color, &a_hi, &r_hi, &g_hi, &b_hi);
diff --git a/pixman/test/utils.h b/pixman/test/utils.h
index ac2decd11..faf427f0a 100644
--- a/pixman/test/utils.h
+++ b/pixman/test/utils.h
@@ -163,6 +163,12 @@ write_png (pixman_image_t *image, const char *filename);
void *
aligned_malloc (size_t align, size_t size);
+double
+convert_srgb_to_linear (double component);
+
+double
+convert_linear_to_srgb (double component);
+
void
initialize_palette (pixman_indexed_t *palette, uint32_t depth, int is_rgb);
diff --git a/xorg-server/configure.ac b/xorg-server/configure.ac
index bf6868e00..12fb28e60 100644
--- a/xorg-server/configure.ac
+++ b/xorg-server/configure.ac
@@ -26,8 +26,8 @@ dnl
dnl Process this file with autoconf to create configure.
AC_PREREQ(2.60)
-AC_INIT([xorg-server], 1.12.99.902, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="2012-07-17"
+AC_INIT([xorg-server], 1.12.99.903, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="2012-07-25"
AC_CONFIG_SRCDIR([Makefile.am])
AM_INIT_AUTOMAKE([foreign dist-bzip2])
AM_MAINTAINER_MODE
@@ -2222,7 +2222,6 @@ miext/Makefile
miext/sync/Makefile
miext/damage/Makefile
miext/shadow/Makefile
-miext/cw/Makefile
miext/rootless/Makefile
os/Makefile
randr/Makefile
diff --git a/xorg-server/hw/xfree86/common/xaarop.h b/xorg-server/hw/xfree86/common/xaarop.h
index f2acde075..84aa9baba 100644
--- a/xorg-server/hw/xfree86/common/xaarop.h
+++ b/xorg-server/hw/xfree86/common/xaarop.h
@@ -1,30 +1,3 @@
-/*
-
- int XAAHelpSolidROP(ScrnInfoPtr pScrn, int *fg, int pm, int *rop)
-
- For use with solid fills emulated by solid 8x8 patterns. You
- give it the foreground, planemask and X rop and it will replace
- the foreground with a new one and the rop with the appropriate
- MS triadic raster op. The function will return which components
- (S-P) need to be enabled.
-
- int XAAHelpPatternROP(ScrnInfoPtr pScrn, int *fg, int *bg, int pm, int *rop)
-
- For use with 8x8 opaque pattern fills. You give it the foreground,
- and background, planemask and X rop and it will replace the
- foreground and background with new ones and the rop with the
- appropriate MS triadic raster op. The function will return which
- components (S-P) need to be enabled.
-
- ROP_PAT - Means to enable 8x8 mono patterns (all bits
- set for solid patterns). Set the foreground and
- background as returned by the function.
-
- ROP_SRC - Means a source of color == planemask should be used.
-
-
-*/
-
#ifndef _XAAROP_H
#define _XAAROP_H
@@ -292,20 +265,4 @@
#define NO_SRC_ROP(rop) \
((rop == GXnoop) || (rop == GXset) || (rop == GXclear) || (rop == GXinvert))
-extern _X_EXPORT int XAAHelpSolidROP(ScrnInfoPtr pScrn, int *fg, int pm,
- int *rop);
-extern _X_EXPORT int XAAHelpPatternROP(ScrnInfoPtr pScrn, int *fg, int *bg,
- int pm, int *rop);
-
-/* XXX These four should be static, but it breaks the 6.7.0 ABI. */
-extern _X_EXPORT int XAACopyROP[16];
-extern _X_EXPORT int XAACopyROP_PM[16];
-extern _X_EXPORT int XAAPatternROP[16];
-extern _X_EXPORT int XAAPatternROP_PM[16];
-
-extern _X_EXPORT int XAAGetCopyROP(int i);
-extern _X_EXPORT int XAAGetCopyROP_PM(int i);
-extern _X_EXPORT int XAAGetPatternROP(int i);
-extern _X_EXPORT int XAAGetPatternROP_PM(int i);
-
#endif /* _XAAROP_H */
diff --git a/xorg-server/hw/xfree86/man/xorg.conf.man b/xorg-server/hw/xfree86/man/xorg.conf.man
index da67f59c9..5d92bbe8b 100644
--- a/xorg-server/hw/xfree86/man/xorg.conf.man
+++ b/xorg-server/hw/xfree86/man/xorg.conf.man
@@ -1894,8 +1894,7 @@ Others are driver\-independent, and will eventually be described here.
.\" XXX These should really be in an xaa man page.
.TP 7
.BI "Option \*qAccel\*q"
-Enables XAA (X Acceleration Architecture), a mechanism that makes video cards'
-2D hardware acceleration available to the Xorg server.
+Enables 2D hardware acceleration.
This option is on by default, but it may be necessary to turn it off if
there are bugs in the driver.
There are many options to disable specific accelerated operations, listed
@@ -1920,73 +1919,6 @@ Disables MTRR (Memory Type Range Register) support, a feature of modern
processors which can improve video performance by a factor of up to 2.5.
Some hardware has buggy MTRR support, and some video drivers have been
known to exhibit problems when MTRR's are used.
-.TP 7
-.BI "Option \*qXaaNoCPUToScreenColorExpandFill\*q"
-Disables accelerated rectangular expansion blits from source patterns
-stored in system memory (using a memory\-mapped aperture).
-.TP 7
-.BI "Option \*qXaaNoColor8x8PatternFillRect\*q"
-Disables accelerated fills of a rectangular region with a full\-color
-pattern.
-.TP 7
-.BI "Option \*qXaaNoColor8x8PatternFillTrap\*q"
-Disables accelerated fills of a trapezoidal region with a full\-color
-pattern.
-.TP 7
-.BI "Option \*qXaaNoDashedBresenhamLine\*q"
-Disables accelerated dashed Bresenham line draws.
-.TP 7
-.BI "Option \*qXaaNoDashedTwoPointLine\*q"
-Disables accelerated dashed line draws between two arbitrary points.
-.TP 7
-.BI "Option \*qXaaNoImageWriteRect\*q"
-Disables accelerated transfers of full\-color rectangular patterns from
-system memory to video memory (using a memory\-mapped aperture).
-.TP 7
-.BI "Option \*qXaaNoMono8x8PatternFillRect\*q"
-Disables accelerated fills of a rectangular region with a monochrome
-pattern.
-.TP 7
-.BI "Option \*qXaaNoMono8x8PatternFillTrap\*q"
-Disables accelerated fills of a trapezoidal region with a monochrome
-pattern.
-.TP 7
-.BI "Option \*qXaaNoOffscreenPixmaps\*q"
-Disables accelerated draws into pixmaps stored in offscreen video memory.
-.TP 7
-.BI "Option \*qXaaNoPixmapCache\*q"
-Disables caching of patterns in offscreen video memory.
-.TP 7
-.BI "Option \*qXaaNoScanlineCPUToScreenColorExpandFill\*q"
-Disables accelerated rectangular expansion blits from source patterns
-stored in system memory (one scan line at a time).
-.TP 7
-.BI "Option \*qXaaNoScanlineImageWriteRect\*q"
-Disables accelerated transfers of full\-color rectangular patterns from
-system memory to video memory (one scan line at a time).
-.TP 7
-.BI "Option \*qXaaNoScreenToScreenColorExpandFill\*q"
-Disables accelerated rectangular expansion blits from source patterns
-stored in offscreen video memory.
-.TP 7
-.BI "Option \*qXaaNoScreenToScreenCopy\*q"
-Disables accelerated copies of rectangular regions from one part of
-video memory to another part of video memory.
-.TP 7
-.BI "Option \*qXaaNoSolidBresenhamLine\*q"
-Disables accelerated solid Bresenham line draws.
-.TP 7
-.BI "Option \*qXaaNoSolidFillRect\*q"
-Disables accelerated solid\-color fills of rectangles.
-.TP 7
-.BI "Option \*qXaaNoSolidFillTrap\*q"
-Disables accelerated solid\-color fills of Bresenham trapezoids.
-.TP 7
-.BI "Option \*qXaaNoSolidHorVertLine\*q"
-Disables accelerated solid horizontal and vertical line draws.
-.TP 7
-.BI "Option \*qXaaNoSolidTwoPointLine\*q"
-Disables accelerated solid line draws between two arbitrary points.
.PP
Each
.B Screen
diff --git a/xorg-server/hw/xquartz/GL/indirect.c b/xorg-server/hw/xquartz/GL/indirect.c
index d9dc2a15b..c4999b5ff 100644
--- a/xorg-server/hw/xquartz/GL/indirect.c
+++ b/xorg-server/hw/xquartz/GL/indirect.c
@@ -135,12 +135,20 @@ struct __GLXAquaDrawable {
static __GLXcontext *
__glXAquaScreenCreateContext(__GLXscreen *screen,
__GLXconfig *conf,
- __GLXcontext *baseShareContext)
+ __GLXcontext *baseShareContext,
+ unsigned num_attribs,
+ const uint32_t *attribs,
+ int *error)
{
__GLXAquaContext *context;
__GLXAquaContext *shareContext = (__GLXAquaContext *)baseShareContext;
CGLError gl_err;
+ /* Unused (for now?) */
+ (void)num_attribs;
+ (void)attribs;
+ (void)error;
+
GLAQUA_DEBUG_MSG("glXAquaScreenCreateContext\n");
context = calloc(1, sizeof(__GLXAquaContext));
diff --git a/xorg-server/hw/xquartz/quartz.c b/xorg-server/hw/xquartz/quartz.c
index 3de223bf4..d74fc6446 100644
--- a/xorg-server/hw/xquartz/quartz.c
+++ b/xorg-server/hw/xquartz/quartz.c
@@ -144,15 +144,21 @@ QuartzSetupScreen(int index,
return TRUE;
}
-static const ExtensionModule quartzExtensions[] = {
- { PseudoramiXExtensionInit, "PseudoramiX", &noPseudoramiXExtension, NULL },
+static ExtensionModule quartzExtensions[] = {
+ /* PseudoramiX needs to be done before RandR, so
+ * it is in miinitext.c until it can be reordered.
+ * { PseudoramiXExtensionInit, "PseudoramiX", &noPseudoramiXExtension },
+ */
+#ifdef GLXEXT
+ {GlxExtensionInit, "GLX", &noGlxExtension},
+#endif
};
/*
* QuartzExtensionInit
* Initialises XQuartz-specific extensions.
*/
-void QuartzExtensionInit(void)
+static void QuartzExtensionInit(void)
{
int i;
diff --git a/xorg-server/hw/xquartz/xpr/xprEvent.c b/xorg-server/hw/xquartz/xpr/xprEvent.c
index 106a91931..73bcc930d 100644
--- a/xorg-server/hw/xquartz/xpr/xprEvent.c
+++ b/xorg-server/hw/xquartz/xpr/xprEvent.c
@@ -52,9 +52,20 @@
#include <sys/uio.h>
#include <unistd.h>
+#ifdef HAVE_LIBDISPATCH
+#include <dispatch/dispatch.h>
+#endif
+
#include "rootlessWindow.h"
#include "xprEvent.h"
+/* This is important enough to declare here if building against an old
+ * libXplugin, so we pick it up whenever libXplugin starts to support it.
+ */
+#if !defined(XPLUGIN_VERSION) || XPLUGIN_VERSION < 6
+extern xp_error xp_window_bring_all_to_front(void) __attribute__((weak_import));
+#endif
+
Bool
QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev)
{
@@ -72,7 +83,28 @@ QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev)
case kXquartzBringAllToFront:
DEBUG_LOG("kXquartzBringAllToFront\n");
+ /* There's no need to do xp_window_bring_all_to_front on Leopard,
+ * and we don't care about the result, so just do it async.
+ */
+#if defined(HAVE_LIBDISPATCH)
+#if (defined(XPLUGIN_VERSION_MIN_REQUIRED) && XPLUGIN_VERSION_MIN_REQUIRED >= 6) || \
+ (!defined(XPLUGIN_VERSION_MIN_REQUIRED) && defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 6)
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+ xp_window_bring_all_to_front();
+ });
+#else
+ if (&xp_window_bring_all_to_front) {
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+ xp_window_bring_all_to_front();
+ });
+ } else {
+ RootlessOrderAllWindows(e->data[0]);
+ }
+#endif
+#else
RootlessOrderAllWindows(e->data[0]);
+#endif
+
return TRUE;
default:
diff --git a/xorg-server/include/screenint.h b/xorg-server/include/screenint.h
index e36b4d8d4..e61cd33ed 100644
--- a/xorg-server/include/screenint.h
+++ b/xorg-server/include/screenint.h
@@ -72,18 +72,18 @@ extern _X_EXPORT int AddGPUScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ ,
extern _X_EXPORT void RemoveGPUScreen(ScreenPtr pScreen);
extern _X_EXPORT void
-AttachUnboundGPU(ScreenPtr pScreen, ScreenPtr new);
+AttachUnboundGPU(ScreenPtr pScreen, ScreenPtr newScreen);
extern _X_EXPORT void
DetachUnboundGPU(ScreenPtr unbound);
extern _X_EXPORT void
-AttachOutputGPU(ScreenPtr pScreen, ScreenPtr new);
+AttachOutputGPU(ScreenPtr pScreen, ScreenPtr newScreen);
extern _X_EXPORT void
DetachOutputGPU(ScreenPtr output);
extern _X_EXPORT void
-AttachOffloadGPU(ScreenPtr pScreen, ScreenPtr new);
+AttachOffloadGPU(ScreenPtr pScreen, ScreenPtr newScreen);
extern _X_EXPORT void
DetachOffloadGPU(ScreenPtr slave);
diff --git a/xorg-server/mi/miinitext.c b/xorg-server/mi/miinitext.c
index ba593526c..014939c80 100644
--- a/xorg-server/mi/miinitext.c
+++ b/xorg-server/mi/miinitext.c
@@ -254,6 +254,12 @@ static const ExtensionModule staticExtensions[] = {
#ifdef PANORAMIX
{PanoramiXExtensionInit, PANORAMIX_PROTOCOL_NAME, &noPanoramiXExtension},
#endif
+#ifdef INXQUARTZ
+ /* PseudoramiXExtensionInit must be done before RRExtensionInit, or
+ * XQuartz will render windows offscreen.
+ */
+ {PseudoramiXExtensionInit, "PseudoramiX", &noPseudoramiXExtension},
+#endif
#ifdef XFIXES
/* must be before Render to layer DisplayCursor correctly */
{XFixesExtensionInit, "XFIXES", &noXFixesExtension},
diff --git a/xorg-server/miext/Makefile.am b/xorg-server/miext/Makefile.am
index 850c41c66..b84adc12b 100644
--- a/xorg-server/miext/Makefile.am
+++ b/xorg-server/miext/Makefile.am
@@ -1,11 +1,8 @@
-SUBDIRS = sync damage shadow
-if COMPOSITE
-SUBDIRS += cw
-endif
-if XQUARTZ
-SUBDIRS += rootless
-endif
-if XWIN_MULTIWINDOWEXTWM
-SUBDIRS += rootless
-endif
-DIST_SUBDIRS = sync damage shadow cw rootless
+SUBDIRS = sync damage shadow
+if XQUARTZ
+SUBDIRS += rootless
+endif
+if XWIN_MULTIWINDOWEXTWM
+SUBDIRS += rootless
+endif
+DIST_SUBDIRS = sync damage shadow rootless
diff --git a/xorg-server/miext/cw/Makefile.am b/xorg-server/miext/cw/Makefile.am
deleted file mode 100644
index cb6cea725..000000000
--- a/xorg-server/miext/cw/Makefile.am
+++ /dev/null
@@ -1,11 +0,0 @@
-noinst_LTLIBRARIES = libcw.la
-
-AM_CFLAGS = $(DIX_CFLAGS)
-
-INCLUDES = -I$(top_srcdir)/hw/xfree86/os-support
-
-libcw_la_SOURCES = \
- cw.c \
- cw_ops.c \
- cw_render.c \
- cw.h
diff --git a/xorg-server/miext/cw/cw.c b/xorg-server/miext/cw/cw.c
deleted file mode 100644
index 7543affb0..000000000
--- a/xorg-server/miext/cw/cw.c
+++ /dev/null
@@ -1,524 +0,0 @@
-/*
- * Copyright © 2004 Eric Anholt
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Eric Anholt not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Eric Anholt makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <string.h>
-
-#include "gcstruct.h"
-#include "windowstr.h"
-#include "cw.h"
-
-#define CW_DEBUG 1
-
-#if CW_DEBUG
-#define CW_ASSERT(x) do { \
- if (!(x)) { \
- ErrorF("composite wrapper: assertion failed at %s:%d\n", __FUNC__, \
- __LINE__); \
- } \
-} while (0)
-#else
-#define CW_ASSERT(x) do {} while (0)
-#endif
-
-DevPrivateKeyRec cwGCKeyRec;
-DevPrivateKeyRec cwScreenKeyRec;
-DevPrivateKeyRec cwWindowKeyRec;
-DevPrivateKeyRec cwPictureKeyRec;
-
-extern GCOps cwGCOps;
-
-static Bool
- cwCloseScreen(ScreenPtr pScreen);
-
-static void
- cwValidateGC(GCPtr pGC, unsigned long stateChanges, DrawablePtr pDrawable);
-static void
- cwChangeGC(GCPtr pGC, unsigned long mask);
-static void
- cwCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
-static void
- cwDestroyGC(GCPtr pGC);
-static void
- cwChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects);
-static void
- cwCopyClip(GCPtr pgcDst, GCPtr pgcSrc);
-static void
- cwDestroyClip(GCPtr pGC);
-
-GCFuncs cwGCFuncs = {
- cwValidateGC,
- cwChangeGC,
- cwCopyGC,
- cwDestroyGC,
- cwChangeClip,
- cwDestroyClip,
- cwCopyClip,
-};
-
-/* Find the real drawable to draw to, and provide offsets that will translate
- * window coordinates to backing pixmap coordinates.
- */
-DrawablePtr
-cwGetBackingDrawable(DrawablePtr pDrawable, int *x_off, int *y_off)
-{
- PixmapPtr pPixmap;
-
- if (pDrawable->type == DRAWABLE_WINDOW &&
- (pPixmap = getCwPixmap((WindowPtr) pDrawable))) {
- *x_off = pDrawable->x - pPixmap->screen_x;
- *y_off = pDrawable->y - pPixmap->screen_y;
- return &pPixmap->drawable;
- }
- else {
- *x_off = *y_off = 0;
- return pDrawable;
- }
-}
-
-#define FUNC_PROLOGUE(pGC, pPriv) do { \
- (pGC)->funcs = (pPriv)->wrapFuncs; \
- (pGC)->ops = (pPriv)->wrapOps; \
-} while (0)
-
-#define FUNC_EPILOGUE(pGC, pPriv) do { \
- (pPriv)->wrapFuncs = (pGC)->funcs; \
- (pPriv)->wrapOps = (pGC)->ops; \
- (pGC)->funcs = &cwGCFuncs; \
- (pGC)->ops = &cwGCOps; \
-} while (0)
-
-static Bool
-cwCreateBackingGC(GCPtr pGC, DrawablePtr pDrawable)
-{
- cwGCRec *pPriv = getCwGC(pGC);
- int status, x_off, y_off;
- XID noexpose = xFalse;
- DrawablePtr pBackingDrawable;
-
- pBackingDrawable = cwGetBackingDrawable(pDrawable, &x_off, &y_off);
- pPriv->pBackingGC = CreateGC(pBackingDrawable, GCGraphicsExposures,
- &noexpose, &status, (XID) 0, serverClient);
- if (status != Success)
- return FALSE;
-
- pPriv->serialNumber = 0;
- pPriv->stateChanges = GCAllBits;
-
- return TRUE;
-}
-
-static void
-cwDestroyBackingGC(GCPtr pGC)
-{
- cwGCPtr pPriv;
-
- pPriv = (cwGCPtr) getCwGC(pGC);
-
- if (pPriv->pBackingGC) {
- FreeGC(pPriv->pBackingGC, (XID) 0);
- pPriv->pBackingGC = NULL;
- }
-}
-
-static void
-cwValidateGC(GCPtr pGC, unsigned long stateChanges, DrawablePtr pDrawable)
-{
- GCPtr pBackingGC;
- cwGCPtr pPriv;
- DrawablePtr pBackingDrawable;
- int x_off, y_off;
-
- pPriv = (cwGCPtr) getCwGC(pGC);
-
- FUNC_PROLOGUE(pGC, pPriv);
-
- /*
- * Must call ValidateGC to ensure pGC->pCompositeClip is valid
- */
- (*pGC->funcs->ValidateGC) (pGC, stateChanges, pDrawable);
-
- if (!cwDrawableIsRedirWindow(pDrawable)) {
- cwDestroyBackingGC(pGC);
- FUNC_EPILOGUE(pGC, pPriv);
- return;
- }
- else {
- if (!pPriv->pBackingGC && !cwCreateBackingGC(pGC, pDrawable)) {
- FUNC_EPILOGUE(pGC, pPriv);
- return;
- }
- }
-
- pBackingGC = pPriv->pBackingGC;
- pBackingDrawable = cwGetBackingDrawable(pDrawable, &x_off, &y_off);
-
- pPriv->stateChanges |= stateChanges;
-
- /*
- * Copy the composite clip into the backing GC if either
- * the drawable clip list has changed or the client has changed
- * the client clip data
- */
- if (pDrawable->serialNumber != pPriv->serialNumber ||
- (pPriv->stateChanges & (GCClipXOrigin | GCClipYOrigin | GCClipMask))) {
- ChangeGCVal vals[2];
- RegionPtr pCompositeClip;
-
- pCompositeClip = RegionCreate(NULL, 0);
- RegionCopy(pCompositeClip, pGC->pCompositeClip);
-
- /* Either the drawable has changed, or the clip list in the drawable has
- * changed. Copy the new clip list over and set the new translated
- * offset for it.
- */
-
- (*pBackingGC->funcs->ChangeClip) (pBackingGC, CT_REGION,
- (pointer) pCompositeClip, 0);
-
- vals[0].val = x_off - pDrawable->x;
- vals[1].val = y_off - pDrawable->y;
- ChangeGC(NullClient, pBackingGC, (GCClipXOrigin | GCClipYOrigin), vals);
-
- pPriv->serialNumber = pDrawable->serialNumber;
- /*
- * Mask off any client clip changes to make sure
- * the clip list set above remains in effect
- */
- pPriv->stateChanges &= ~(GCClipXOrigin | GCClipYOrigin | GCClipMask);
- }
-
- if (pPriv->stateChanges) {
- CopyGC(pGC, pBackingGC, pPriv->stateChanges);
- pPriv->stateChanges = 0;
- }
-
- if ((pGC->patOrg.x + x_off) != pBackingGC->patOrg.x ||
- (pGC->patOrg.y + y_off) != pBackingGC->patOrg.y) {
- ChangeGCVal vals[2];
-
- vals[0].val = pGC->patOrg.x + x_off;
- vals[1].val = pGC->patOrg.y + y_off;
- ChangeGC(NullClient, pBackingGC,
- (GCTileStipXOrigin | GCTileStipYOrigin), vals);
- }
-
- ValidateGC(pBackingDrawable, pBackingGC);
-
- FUNC_EPILOGUE(pGC, pPriv);
-}
-
-static void
-cwChangeGC(GCPtr pGC, unsigned long mask)
-{
- cwGCPtr pPriv = (cwGCPtr) dixLookupPrivate(&pGC->devPrivates, cwGCKey);
-
- FUNC_PROLOGUE(pGC, pPriv);
-
- (*pGC->funcs->ChangeGC) (pGC, mask);
-
- FUNC_EPILOGUE(pGC, pPriv);
-}
-
-static void
-cwCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
-{
- cwGCPtr pPriv = (cwGCPtr) dixLookupPrivate(&pGCDst->devPrivates, cwGCKey);
-
- FUNC_PROLOGUE(pGCDst, pPriv);
-
- (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
-
- FUNC_EPILOGUE(pGCDst, pPriv);
-}
-
-static void
-cwDestroyGC(GCPtr pGC)
-{
- cwGCPtr pPriv = (cwGCPtr) dixLookupPrivate(&pGC->devPrivates, cwGCKey);
-
- FUNC_PROLOGUE(pGC, pPriv);
-
- cwDestroyBackingGC(pGC);
-
- (*pGC->funcs->DestroyGC) (pGC);
-
- /* leave it unwrapped */
-}
-
-static void
-cwChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects)
-{
- cwGCPtr pPriv = (cwGCPtr) dixLookupPrivate(&pGC->devPrivates, cwGCKey);
-
- FUNC_PROLOGUE(pGC, pPriv);
-
- (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
-
- FUNC_EPILOGUE(pGC, pPriv);
-}
-
-static void
-cwCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
-{
- cwGCPtr pPriv = (cwGCPtr) dixLookupPrivate(&pgcDst->devPrivates, cwGCKey);
-
- FUNC_PROLOGUE(pgcDst, pPriv);
-
- (*pgcDst->funcs->CopyClip) (pgcDst, pgcSrc);
-
- FUNC_EPILOGUE(pgcDst, pPriv);
-}
-
-static void
-cwDestroyClip(GCPtr pGC)
-{
- cwGCPtr pPriv = (cwGCPtr) dixLookupPrivate(&pGC->devPrivates, cwGCKey);
-
- FUNC_PROLOGUE(pGC, pPriv);
-
- (*pGC->funcs->DestroyClip) (pGC);
-
- FUNC_EPILOGUE(pGC, pPriv);
-}
-
-/*
- * Screen wrappers.
- */
-
-#define SCREEN_PROLOGUE(pScreen, field) \
- ((pScreen)->field = getCwScreen(pScreen)->field)
-
-#define SCREEN_EPILOGUE(pScreen, field, wrapper) do { \
- getCwScreen(pScreen)->field = (pScreen)->field; \
- (pScreen)->field = (wrapper); \
-} while (0)
-
-static Bool
-cwCreateGC(GCPtr pGC)
-{
- cwGCPtr pPriv = getCwGC(pGC);
- ScreenPtr pScreen = pGC->pScreen;
- Bool ret;
-
- SCREEN_PROLOGUE(pScreen, CreateGC);
-
- if ((ret = (*pScreen->CreateGC) (pGC)))
- FUNC_EPILOGUE(pGC, pPriv);
-
- SCREEN_EPILOGUE(pScreen, CreateGC, cwCreateGC);
-
- return ret;
-}
-
-static void
-cwGetImage(DrawablePtr pSrc, int x, int y, int w, int h, unsigned int format,
- unsigned long planemask, char *pdstLine)
-{
- ScreenPtr pScreen = pSrc->pScreen;
- DrawablePtr pBackingDrawable;
- int src_off_x, src_off_y;
-
- SCREEN_PROLOGUE(pScreen, GetImage);
-
- pBackingDrawable = cwGetBackingDrawable(pSrc, &src_off_x, &src_off_y);
-
- CW_OFFSET_XY_SRC(x, y);
-
- (*pScreen->GetImage) (pBackingDrawable, x, y, w, h, format, planemask,
- pdstLine);
-
- SCREEN_EPILOGUE(pScreen, GetImage, cwGetImage);
-}
-
-static void
-cwGetSpans(DrawablePtr pSrc, int wMax, DDXPointPtr ppt, int *pwidth,
- int nspans, char *pdstStart)
-{
- ScreenPtr pScreen = pSrc->pScreen;
- DrawablePtr pBackingDrawable;
- int i;
- int src_off_x, src_off_y;
-
- SCREEN_PROLOGUE(pScreen, GetSpans);
-
- pBackingDrawable = cwGetBackingDrawable(pSrc, &src_off_x, &src_off_y);
-
- for (i = 0; i < nspans; i++)
- CW_OFFSET_XY_SRC(ppt[i].x, ppt[i].y);
-
- (*pScreen->GetSpans) (pBackingDrawable, wMax, ppt, pwidth, nspans,
- pdstStart);
-
- SCREEN_EPILOGUE(pScreen, GetSpans, cwGetSpans);
-}
-
-static void
-cwCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
-
- SCREEN_PROLOGUE(pScreen, CopyWindow);
-
- if (!cwDrawableIsRedirWindow((DrawablePtr) pWin)) {
- (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
- }
- else {
- GCPtr pGC;
- BoxPtr pExtents;
- int x_off, y_off;
- int dx, dy;
- PixmapPtr pBackingPixmap;
- RegionPtr pClip;
- int src_x, src_y, dst_x, dst_y, w, h;
-
- dx = ptOldOrg.x - pWin->drawable.x;
- dy = ptOldOrg.y - pWin->drawable.y;
-
- pExtents = RegionExtents(prgnSrc);
-
- pBackingPixmap = (PixmapPtr) cwGetBackingDrawable((DrawablePtr) pWin,
- &x_off, &y_off);
-
- src_x = pExtents->x1 - pBackingPixmap->screen_x;
- src_y = pExtents->y1 - pBackingPixmap->screen_y;
- w = pExtents->x2 - pExtents->x1;
- h = pExtents->y2 - pExtents->y1;
- dst_x = src_x - dx;
- dst_y = src_y - dy;
-
- /* Translate region (as required by API) */
- RegionTranslate(prgnSrc, -dx, -dy);
-
- pGC = GetScratchGC(pBackingPixmap->drawable.depth, pScreen);
- /*
- * Copy region to GC as clip, aligning as dest clip
- */
- pClip = RegionCreate(NULL, 0);
- RegionIntersect(pClip, &pWin->borderClip, prgnSrc);
- RegionTranslate(pClip,
- -pBackingPixmap->screen_x, -pBackingPixmap->screen_y);
-
- (*pGC->funcs->ChangeClip) (pGC, CT_REGION, pClip, 0);
-
- ValidateGC(&pBackingPixmap->drawable, pGC);
-
- (*pGC->ops->CopyArea) (&pBackingPixmap->drawable,
- &pBackingPixmap->drawable, pGC,
- src_x, src_y, w, h, dst_x, dst_y);
-
- (*pGC->funcs->DestroyClip) (pGC);
-
- FreeScratchGC(pGC);
- }
-
- SCREEN_EPILOGUE(pScreen, CopyWindow, cwCopyWindow);
-}
-
-static PixmapPtr
-cwGetWindowPixmap(WindowPtr pWin)
-{
- PixmapPtr pPixmap = getCwPixmap(pWin);
-
- if (!pPixmap) {
- ScreenPtr pScreen = pWin->drawable.pScreen;
-
- SCREEN_PROLOGUE(pScreen, GetWindowPixmap);
- if (pScreen->GetWindowPixmap)
- pPixmap = (*pScreen->GetWindowPixmap) (pWin);
- SCREEN_EPILOGUE(pScreen, GetWindowPixmap, cwGetWindowPixmap);
- }
- return pPixmap;
-}
-
-static void
-cwSetWindowPixmap(WindowPtr pWindow, PixmapPtr pPixmap)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
-
- if (pPixmap == (*pScreen->GetScreenPixmap) (pScreen))
- pPixmap = NULL;
- setCwPixmap(pWindow, pPixmap);
-}
-
-/* Screen initialization/teardown */
-void
-miInitializeCompositeWrapper(ScreenPtr pScreen)
-{
- cwScreenPtr pScreenPriv;
- Bool has_render = GetPictureScreenIfSet(pScreen) != NULL;
-
- if (!dixRegisterPrivateKey(&cwScreenKeyRec, PRIVATE_SCREEN, 0))
- return;
-
- if (!dixRegisterPrivateKey(&cwGCKeyRec, PRIVATE_GC, sizeof(cwGCRec)))
- return;
-
- if (!dixRegisterPrivateKey(&cwWindowKeyRec, PRIVATE_WINDOW, 0))
- return;
-
- if (!dixRegisterPrivateKey(&cwPictureKeyRec, PRIVATE_PICTURE, 0))
- return;
-
- pScreenPriv = malloc(sizeof(cwScreenRec));
- if (!pScreenPriv)
- return;
-
- dixSetPrivate(&pScreen->devPrivates, cwScreenKey, pScreenPriv);
-
- SCREEN_EPILOGUE(pScreen, CloseScreen, cwCloseScreen);
- SCREEN_EPILOGUE(pScreen, GetImage, cwGetImage);
- SCREEN_EPILOGUE(pScreen, GetSpans, cwGetSpans);
- SCREEN_EPILOGUE(pScreen, CreateGC, cwCreateGC);
- SCREEN_EPILOGUE(pScreen, CopyWindow, cwCopyWindow);
-
- SCREEN_EPILOGUE(pScreen, SetWindowPixmap, cwSetWindowPixmap);
- SCREEN_EPILOGUE(pScreen, GetWindowPixmap, cwGetWindowPixmap);
-
- if (has_render)
- cwInitializeRender(pScreen);
-}
-
-static Bool
-cwCloseScreen(ScreenPtr pScreen)
-{
- cwScreenPtr pScreenPriv;
- PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
-
- pScreenPriv = (cwScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
- cwScreenKey);
- pScreen->CloseScreen = pScreenPriv->CloseScreen;
- pScreen->GetImage = pScreenPriv->GetImage;
- pScreen->GetSpans = pScreenPriv->GetSpans;
- pScreen->CreateGC = pScreenPriv->CreateGC;
- pScreen->CopyWindow = pScreenPriv->CopyWindow;
-
- if (ps)
- cwFiniRender(pScreen);
-
- free((pointer) pScreenPriv);
-
- return (*pScreen->CloseScreen) (pScreen);
-}
diff --git a/xorg-server/miext/cw/cw.h b/xorg-server/miext/cw/cw.h
deleted file mode 100644
index 9f880f7f5..000000000
--- a/xorg-server/miext/cw/cw.h
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright © 2004 Eric Anholt
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Eric Anholt not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Eric Anholt makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "gcstruct.h"
-#include "picturestr.h"
-#include "privates.h"
-
-/*
- * One of these structures is allocated per GC that gets used with a window with
- * backing pixmap.
- */
-
-typedef struct {
- GCPtr pBackingGC; /* Copy of the GC but with graphicsExposures
- * set FALSE and the clientClip set to
- * clip output to the valid regions of the
- * backing pixmap. */
- unsigned long serialNumber; /* clientClip computed time */
- unsigned long stateChanges; /* changes in parent gc since last copy */
- GCOps *wrapOps; /* wrapped ops */
- GCFuncs *wrapFuncs; /* wrapped funcs */
-} cwGCRec, *cwGCPtr;
-
-extern _X_EXPORT DevPrivateKeyRec cwGCKeyRec;
-
-#define cwGCKey (&cwGCKeyRec)
-
-#define getCwGC(pGC) ((cwGCPtr)dixLookupPrivate(&(pGC)->devPrivates, cwGCKey))
-#define setCwGC(pGC,p) dixSetPrivate(&(pGC)->devPrivates, cwGCKey, p)
-
-/*
- * One of these structures is allocated per Picture that gets used with a
- * window with a backing pixmap
- */
-
-typedef struct {
- PicturePtr pBackingPicture;
- unsigned long serialNumber;
- unsigned long stateChanges;
-} cwPictureRec, *cwPicturePtr;
-
-extern _X_EXPORT DevPrivateKeyRec cwPictureKeyRec;
-
-#define cwPictureKey (&cwPictureKeyRec)
-
-#define getCwPicture(pPicture) (pPicture->pDrawable ? \
- (cwPicturePtr)dixLookupPrivate(&(pPicture)->devPrivates, cwPictureKey) : 0)
-#define setCwPicture(pPicture,p) dixSetPrivate(&(pPicture)->devPrivates, cwPictureKey, p)
-
-extern _X_EXPORT DevPrivateKeyRec cwWindowKeyRec;
-
-#define cwWindowKey (&cwWindowKeyRec)
-
-#define cwWindowPrivate(pWin) dixLookupPrivate(&(pWin)->devPrivates, cwWindowKey)
-#define getCwPixmap(pWindow) ((PixmapPtr) cwWindowPrivate(pWindow))
-#define setCwPixmap(pWindow,pPixmap) \
- dixSetPrivate(&(pWindow)->devPrivates, cwWindowKey, pPixmap)
-
-#define cwDrawableIsRedirWindow(pDraw) \
- ((pDraw)->type == DRAWABLE_WINDOW && \
- getCwPixmap((WindowPtr) (pDraw)) != NULL)
-
-typedef struct {
- /*
- * screen func wrappers
- */
- CloseScreenProcPtr CloseScreen;
- GetImageProcPtr GetImage;
- GetSpansProcPtr GetSpans;
- CreateGCProcPtr CreateGC;
-
- CopyWindowProcPtr CopyWindow;
-
- GetWindowPixmapProcPtr GetWindowPixmap;
- SetWindowPixmapProcPtr SetWindowPixmap;
-
- DestroyPictureProcPtr DestroyPicture;
- ChangePictureClipProcPtr ChangePictureClip;
- DestroyPictureClipProcPtr DestroyPictureClip;
-
- ChangePictureProcPtr ChangePicture;
- ValidatePictureProcPtr ValidatePicture;
-
- CompositeProcPtr Composite;
- CompositeRectsProcPtr CompositeRects;
-
- TrapezoidsProcPtr Trapezoids;
- TrianglesProcPtr Triangles;
-
- RasterizeTrapezoidProcPtr RasterizeTrapezoid;
-} cwScreenRec, *cwScreenPtr;
-
-extern _X_EXPORT DevPrivateKeyRec cwScreenKeyRec;
-
-#define cwScreenKey (&cwScreenKeyRec)
-
-#define getCwScreen(pScreen) ((cwScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, cwScreenKey))
-#define setCwScreen(pScreen,p) dixSetPrivate(&(pScreen)->devPrivates, cwScreenKey, p)
-
-#define CW_OFFSET_XYPOINTS(ppt, npt) do { \
- DDXPointPtr _ppt = (DDXPointPtr)(ppt); \
- int _i; \
- for (_i = 0; _i < npt; _i++) { \
- _ppt[_i].x += dst_off_x; \
- _ppt[_i].y += dst_off_y; \
- } \
-} while (0)
-
-#define CW_OFFSET_RECTS(prect, nrect) do { \
- int _i; \
- for (_i = 0; _i < nrect; _i++) { \
- (prect)[_i].x += dst_off_x; \
- (prect)[_i].y += dst_off_y; \
- } \
-} while (0)
-
-#define CW_OFFSET_ARCS(parc, narc) do { \
- int _i; \
- for (_i = 0; _i < narc; _i++) { \
- (parc)[_i].x += dst_off_x; \
- (parc)[_i].y += dst_off_y; \
- } \
-} while (0)
-
-#define CW_OFFSET_XY_DST(x, y) do { \
- (x) = (x) + dst_off_x; \
- (y) = (y) + dst_off_y; \
-} while (0)
-
-#define CW_OFFSET_XY_SRC(x, y) do { \
- (x) = (x) + src_off_x; \
- (y) = (y) + src_off_y; \
-} while (0)
-
-/* cw.c */
-extern _X_EXPORT DrawablePtr
- cwGetBackingDrawable(DrawablePtr pDrawable, int *x_off, int *y_off);
-
-/* cw_render.c */
-
-extern _X_EXPORT void
- cwInitializeRender(ScreenPtr pScreen);
-
-extern _X_EXPORT void
- cwFiniRender(ScreenPtr pScreen);
-
-/* cw.c */
-
-extern _X_EXPORT void
- miInitializeCompositeWrapper(ScreenPtr pScreen);
diff --git a/xorg-server/miext/cw/cw_ops.c b/xorg-server/miext/cw/cw_ops.c
deleted file mode 100644
index ccc558074..000000000
--- a/xorg-server/miext/cw/cw_ops.c
+++ /dev/null
@@ -1,477 +0,0 @@
-/*
- * Copyright © 2004 Eric Anholt
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Eric Anholt not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Eric Anholt makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <stdlib.h>
-
-#include "gcstruct.h"
-#include "pixmapstr.h"
-#include "cw.h"
-#include "mi.h"
-
-#define SETUP_BACKING_DST(_pDst, _pGC) \
- cwGCPtr pGCPrivate = getCwGC (_pGC); \
- int dst_off_x, dst_off_y; \
- DrawablePtr pBackingDst = cwGetBackingDrawable(pDst, &dst_off_x, \
- &dst_off_y); \
- GCPtr pBackingGC = pGCPrivate->pBackingGC ? pGCPrivate->pBackingGC : _pGC
-
-#define SETUP_BACKING_SRC(pSrc, pGC) \
- int src_off_x, src_off_y; \
- DrawablePtr pBackingSrc = cwGetBackingDrawable(pSrc, &src_off_x, \
- &src_off_y)
-
-#define PROLOGUE(pGC) do { \
- if (pBackingGC->serialNumber != pBackingDst->serialNumber) { \
- ValidateGC(pBackingDst, pBackingGC); \
- } \
- pGC->funcs = pGCPrivate->wrapFuncs;\
- pGC->ops = pGCPrivate->wrapOps;\
-} while (0)
-
-#define EPILOGUE(pGC) do { \
- pGCPrivate->wrapFuncs = (pGC)->funcs; \
- pGCPrivate->wrapOps = (pGC)->ops; \
- (pGC)->funcs = &cwGCFuncs; \
- (pGC)->ops = &cwGCOps; \
-} while (0)
-
-extern GCFuncs cwGCFuncs;
-
-/*
- * GC ops -- wrap each GC operation with our own function
- */
-
-static void cwFillSpans(DrawablePtr pDst, GCPtr pGC, int nInit,
- DDXPointPtr pptInit, int *pwidthInit, int fSorted);
-static void cwSetSpans(DrawablePtr pDst, GCPtr pGC, char *psrc,
- DDXPointPtr ppt, int *pwidth, int nspans, int fSorted);
-static void cwPutImage(DrawablePtr pDst, GCPtr pGC, int depth,
- int x, int y, int w, int h, int leftPad, int format,
- char *pBits);
-static RegionPtr cwCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
- int srcx, int srcy, int w, int h,
- int dstx, int dsty);
-static RegionPtr cwCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
- int srcx, int srcy, int w, int h,
- int dstx, int dsty, unsigned long plane);
-static void cwPolyPoint(DrawablePtr pDst, GCPtr pGC, int mode, int npt,
- xPoint * pptInit);
-static void cwPolylines(DrawablePtr pDst, GCPtr pGC, int mode, int npt,
- DDXPointPtr pptInit);
-static void cwPolySegment(DrawablePtr pDst, GCPtr pGC, int nseg,
- xSegment * pSegs);
-static void cwPolyRectangle(DrawablePtr pDst, GCPtr pGC,
- int nrects, xRectangle *pRects);
-static void cwPolyArc(DrawablePtr pDst, GCPtr pGC, int narcs, xArc * parcs);
-static void cwFillPolygon(DrawablePtr pDst, GCPtr pGC, int shape, int mode,
- int count, DDXPointPtr pPts);
-static void cwPolyFillRect(DrawablePtr pDst, GCPtr pGC,
- int nrectFill, xRectangle *prectInit);
-static void cwPolyFillArc(DrawablePtr pDst, GCPtr pGC, int narcs, xArc * parcs);
-static int cwPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
- int count, char *chars);
-static int cwPolyText16(DrawablePtr pDst, GCPtr pGC, int x, int y,
- int count, unsigned short *chars);
-static void cwImageText8(DrawablePtr pDst, GCPtr pGC, int x, int y,
- int count, char *chars);
-static void cwImageText16(DrawablePtr pDst, GCPtr pGC, int x, int y,
- int count, unsigned short *chars);
-static void cwImageGlyphBlt(DrawablePtr pDst, GCPtr pGC, int x, int y,
- unsigned int nglyph, CharInfoPtr * ppci,
- pointer pglyphBase);
-static void cwPolyGlyphBlt(DrawablePtr pDst, GCPtr pGC, int x, int y,
- unsigned int nglyph, CharInfoPtr * ppci,
- pointer pglyphBase);
-static void cwPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst,
- int w, int h, int x, int y);
-
-GCOps cwGCOps = {
- cwFillSpans,
- cwSetSpans,
- cwPutImage,
- cwCopyArea,
- cwCopyPlane,
- cwPolyPoint,
- cwPolylines,
- cwPolySegment,
- cwPolyRectangle,
- cwPolyArc,
- cwFillPolygon,
- cwPolyFillRect,
- cwPolyFillArc,
- cwPolyText8,
- cwPolyText16,
- cwImageText8,
- cwImageText16,
- cwImageGlyphBlt,
- cwPolyGlyphBlt,
- cwPushPixels
-};
-
-static void
-cwFillSpans(DrawablePtr pDst, GCPtr pGC, int nspans, DDXPointPtr ppt,
- int *pwidth, int fSorted)
-{
- SETUP_BACKING_DST(pDst, pGC);
-
- PROLOGUE(pGC);
-
- CW_OFFSET_XYPOINTS(ppt, nspans);
-
- (*pBackingGC->ops->FillSpans) (pBackingDst, pBackingGC, nspans, ppt,
- pwidth, fSorted);
-
- EPILOGUE(pGC);
-}
-
-static void
-cwSetSpans(DrawablePtr pDst, GCPtr pGC, char *psrc, DDXPointPtr ppt,
- int *pwidth, int nspans, int fSorted)
-{
- SETUP_BACKING_DST(pDst, pGC);
-
- PROLOGUE(pGC);
-
- CW_OFFSET_XYPOINTS(ppt, nspans);
-
- (*pBackingGC->ops->SetSpans) (pBackingDst, pBackingGC, psrc, ppt, pwidth,
- nspans, fSorted);
-
- EPILOGUE(pGC);
-}
-
-static void
-cwPutImage(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y, int w, int h,
- int leftPad, int format, char *pBits)
-{
- SETUP_BACKING_DST(pDst, pGC);
-
- PROLOGUE(pGC);
-
- CW_OFFSET_XY_DST(x, y);
-
- (*pBackingGC->ops->PutImage) (pBackingDst, pBackingGC, depth, x, y, w, h,
- leftPad, format, pBits);
-
- EPILOGUE(pGC);
-}
-
-static RegionPtr
-cwCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy,
- int w, int h, int dstx, int dsty)
-{
- int odstx, odsty;
- int osrcx, osrcy;
-
- SETUP_BACKING_DST(pDst, pGC);
- SETUP_BACKING_SRC(pSrc, pGC);
-
- PROLOGUE(pGC);
-
- odstx = dstx;
- odsty = dsty;
- osrcx = srcx;
- osrcy = srcy;
- CW_OFFSET_XY_DST(dstx, dsty);
- CW_OFFSET_XY_SRC(srcx, srcy);
-
- (*pBackingGC->ops->CopyArea) (pBackingSrc, pBackingDst,
- pBackingGC, srcx, srcy, w, h, dstx, dsty);
-
- EPILOGUE(pGC);
-
- return miHandleExposures(pSrc, pDst, pGC,
- osrcx, osrcy, w, h, odstx, odsty, 0);
-}
-
-static RegionPtr
-cwCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy,
- int w, int h, int dstx, int dsty, unsigned long plane)
-{
- int odstx, odsty;
- int osrcx, osrcy;
-
- SETUP_BACKING_DST(pDst, pGC);
- SETUP_BACKING_SRC(pSrc, pGC);
-
- PROLOGUE(pGC);
-
- odstx = dstx;
- odsty = dsty;
- osrcx = srcx;
- osrcy = srcy;
- CW_OFFSET_XY_DST(dstx, dsty);
- CW_OFFSET_XY_SRC(srcx, srcy);
-
- (*pBackingGC->ops->CopyPlane) (pBackingSrc, pBackingDst,
- pBackingGC, srcx, srcy, w, h,
- dstx, dsty, plane);
-
- EPILOGUE(pGC);
-
- return miHandleExposures(pSrc, pDst, pGC,
- osrcx, osrcy, w, h, odstx, odsty, plane);
-}
-
-static void
-cwPolyPoint(DrawablePtr pDst, GCPtr pGC, int mode, int npt, xPoint * ppt)
-{
- SETUP_BACKING_DST(pDst, pGC);
-
- PROLOGUE(pGC);
-
- if (mode == CoordModeOrigin)
- CW_OFFSET_XYPOINTS(ppt, npt);
- else
- CW_OFFSET_XYPOINTS(ppt, 1);
-
- (*pBackingGC->ops->PolyPoint) (pBackingDst, pBackingGC, mode, npt, ppt);
-
- EPILOGUE(pGC);
-}
-
-static void
-cwPolylines(DrawablePtr pDst, GCPtr pGC, int mode, int npt, DDXPointPtr ppt)
-{
- SETUP_BACKING_DST(pDst, pGC);
-
- PROLOGUE(pGC);
-
- if (mode == CoordModeOrigin)
- CW_OFFSET_XYPOINTS(ppt, npt);
- else
- CW_OFFSET_XYPOINTS(ppt, 1);
-
- (*pBackingGC->ops->Polylines) (pBackingDst, pBackingGC, mode, npt, ppt);
-
- EPILOGUE(pGC);
-}
-
-static void
-cwPolySegment(DrawablePtr pDst, GCPtr pGC, int nseg, xSegment * pSegs)
-{
- SETUP_BACKING_DST(pDst, pGC);
-
- PROLOGUE(pGC);
-
- CW_OFFSET_XYPOINTS(pSegs, nseg * 2);
-
- (*pBackingGC->ops->PolySegment) (pBackingDst, pBackingGC, nseg, pSegs);
-
- EPILOGUE(pGC);
-}
-
-static void
-cwPolyRectangle(DrawablePtr pDst, GCPtr pGC, int nrects, xRectangle *pRects)
-{
- SETUP_BACKING_DST(pDst, pGC);
-
- PROLOGUE(pGC);
-
- CW_OFFSET_RECTS(pRects, nrects);
-
- (*pBackingGC->ops->PolyRectangle) (pBackingDst, pBackingGC, nrects, pRects);
-
- EPILOGUE(pGC);
-}
-
-static void
-cwPolyArc(DrawablePtr pDst, GCPtr pGC, int narcs, xArc * pArcs)
-{
- SETUP_BACKING_DST(pDst, pGC);
-
- PROLOGUE(pGC);
-
- CW_OFFSET_RECTS(pArcs, narcs);
-
- (*pBackingGC->ops->PolyArc) (pBackingDst, pBackingGC, narcs, pArcs);
-
- EPILOGUE(pGC);
-}
-
-static void
-cwFillPolygon(DrawablePtr pDst, GCPtr pGC, int shape, int mode, int npt,
- DDXPointPtr ppt)
-{
- SETUP_BACKING_DST(pDst, pGC);
-
- PROLOGUE(pGC);
-
- if (mode == CoordModeOrigin)
- CW_OFFSET_XYPOINTS(ppt, npt);
- else
- CW_OFFSET_XYPOINTS(ppt, 1);
-
- (*pBackingGC->ops->FillPolygon) (pBackingDst, pBackingGC, shape, mode, npt,
- ppt);
-
- EPILOGUE(pGC);
-}
-
-static void
-cwPolyFillRect(DrawablePtr pDst, GCPtr pGC, int nrects, xRectangle *pRects)
-{
- SETUP_BACKING_DST(pDst, pGC);
-
- PROLOGUE(pGC);
-
- CW_OFFSET_RECTS(pRects, nrects);
-
- (*pBackingGC->ops->PolyFillRect) (pBackingDst, pBackingGC, nrects, pRects);
-
- EPILOGUE(pGC);
-}
-
-static void
-cwPolyFillArc(DrawablePtr pDst, GCPtr pGC, int narcs, xArc * parcs)
-{
- SETUP_BACKING_DST(pDst, pGC);
-
- PROLOGUE(pGC);
-
- CW_OFFSET_RECTS(parcs, narcs);
-
- (*pBackingGC->ops->PolyFillArc) (pBackingDst, pBackingGC, narcs, parcs);
-
- EPILOGUE(pGC);
-}
-
-static int
-cwPolyText8(DrawablePtr pDst, GCPtr pGC, int x, int y, int count, char *chars)
-{
- int result;
-
- SETUP_BACKING_DST(pDst, pGC);
-
- PROLOGUE(pGC);
-
- CW_OFFSET_XY_DST(x, y);
-
- result = (*pBackingGC->ops->PolyText8) (pBackingDst, pBackingGC, x, y,
- count, chars);
-
- EPILOGUE(pGC);
-
- return result;
-}
-
-static int
-cwPolyText16(DrawablePtr pDst, GCPtr pGC, int x, int y, int count,
- unsigned short *chars)
-{
- int result;
-
- SETUP_BACKING_DST(pDst, pGC);
-
- PROLOGUE(pGC);
-
- CW_OFFSET_XY_DST(x, y);
-
- result = (*pBackingGC->ops->PolyText16) (pBackingDst, pBackingGC, x, y,
- count, chars);
-
- EPILOGUE(pGC);
- return result;
-}
-
-static void
-cwImageText8(DrawablePtr pDst, GCPtr pGC, int x, int y, int count, char *chars)
-{
- SETUP_BACKING_DST(pDst, pGC);
-
- PROLOGUE(pGC);
-
- CW_OFFSET_XY_DST(x, y);
-
- (*pBackingGC->ops->ImageText8) (pBackingDst, pBackingGC, x, y, count,
- chars);
-
- EPILOGUE(pGC);
-}
-
-static void
-cwImageText16(DrawablePtr pDst, GCPtr pGC, int x, int y, int count,
- unsigned short *chars)
-{
- SETUP_BACKING_DST(pDst, pGC);
-
- PROLOGUE(pGC);
-
- CW_OFFSET_XY_DST(x, y);
-
- (*pBackingGC->ops->ImageText16) (pBackingDst, pBackingGC, x, y, count,
- chars);
-
- EPILOGUE(pGC);
-}
-
-static void
-cwImageGlyphBlt(DrawablePtr pDst, GCPtr pGC, int x, int y, unsigned int nglyph,
- CharInfoPtr * ppci, pointer pglyphBase)
-{
- SETUP_BACKING_DST(pDst, pGC);
-
- PROLOGUE(pGC);
-
- CW_OFFSET_XY_DST(x, y);
-
- (*pBackingGC->ops->ImageGlyphBlt) (pBackingDst, pBackingGC, x, y, nglyph,
- ppci, pglyphBase);
-
- EPILOGUE(pGC);
-}
-
-static void
-cwPolyGlyphBlt(DrawablePtr pDst, GCPtr pGC, int x, int y, unsigned int nglyph,
- CharInfoPtr * ppci, pointer pglyphBase)
-{
- SETUP_BACKING_DST(pDst, pGC);
-
- PROLOGUE(pGC);
-
- CW_OFFSET_XY_DST(x, y);
-
- (*pBackingGC->ops->PolyGlyphBlt) (pBackingDst, pBackingGC, x, y, nglyph,
- ppci, pglyphBase);
-
- EPILOGUE(pGC);
-}
-
-static void
-cwPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst, int w, int h,
- int x, int y)
-{
- SETUP_BACKING_DST(pDst, pGC);
-
- PROLOGUE(pGC);
-
- CW_OFFSET_XY_DST(x, y);
-
- (*pBackingGC->ops->PushPixels) (pBackingGC, pBitMap, pBackingDst, w, h,
- x, y);
-
- EPILOGUE(pGC);
-}
diff --git a/xorg-server/miext/cw/cw_render.c b/xorg-server/miext/cw/cw_render.c
deleted file mode 100644
index 059d686fb..000000000
--- a/xorg-server/miext/cw/cw_render.c
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- * Copyright © 2004 Eric Anholt
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Eric Anholt not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Eric Anholt makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <string.h>
-
-#include "gcstruct.h"
-#include "windowstr.h"
-#include "cw.h"
-
-#define cwPsDecl(pScreen) \
- PictureScreenPtr ps = GetPictureScreen (pScreen); \
- cwScreenPtr pCwScreen = getCwScreen (pScreen)
-
-#define cwPicturePrivate \
- cwPicturePtr pPicturePrivate = getCwPicture(pPicture)
-
-#define cwSrcPictureDecl \
- int src_picture_x_off, src_picture_y_off; \
- PicturePtr pBackingSrcPicture = cwGetBackingPicture(pSrcPicture, \
- &src_picture_x_off,\
- &src_picture_y_off)
-
-#define cwDstPictureDecl \
- int dst_picture_x_off, dst_picture_y_off; \
- PicturePtr pBackingDstPicture = cwGetBackingPicture(pDstPicture, \
- &dst_picture_x_off,\
- &dst_picture_y_off)
-
-#define cwMskPictureDecl \
- int msk_picture_x_off = 0, msk_picture_y_off = 0; \
- PicturePtr pBackingMskPicture = (!pMskPicture ? 0 : \
- cwGetBackingPicture(pMskPicture, \
- &msk_picture_x_off,\
- &msk_picture_y_off))
-
-#define cwPsUnwrap(elt) { \
- ps->elt = pCwScreen->elt; \
-}
-
-#define cwPsWrap(elt,func) { \
- pCwScreen->elt = ps->elt; \
- ps->elt = func; \
-}
-
-static cwPicturePtr
-cwCreatePicturePrivate(PicturePtr pPicture)
-{
- WindowPtr pWindow = (WindowPtr) pPicture->pDrawable;
- PixmapPtr pPixmap = getCwPixmap(pWindow);
- int error;
- cwPicturePtr pPicturePrivate;
-
- pPicturePrivate = malloc(sizeof(cwPictureRec));
- if (!pPicturePrivate)
- return NULL;
-
- pPicturePrivate->pBackingPicture = CreatePicture(0, &pPixmap->drawable,
- pPicture->pFormat,
- 0, 0, serverClient,
- &error);
- if (!pPicturePrivate->pBackingPicture) {
- free(pPicturePrivate);
- return NULL;
- }
-
- /*
- * Ensure that this serial number does not match the window's
- */
- pPicturePrivate->serialNumber = pPixmap->drawable.serialNumber;
- pPicturePrivate->stateChanges = (1 << (CPLastBit + 1)) - 1;
-
- setCwPicture(pPicture, pPicturePrivate);
-
- return pPicturePrivate;
-}
-
-static void
-cwDestroyPicturePrivate(PicturePtr pPicture)
-{
- cwPicturePrivate;
-
- if (pPicturePrivate) {
- if (pPicturePrivate->pBackingPicture)
- FreePicture(pPicturePrivate->pBackingPicture, 0);
- free(pPicturePrivate);
- setCwPicture(pPicture, NULL);
- }
-}
-
-static PicturePtr
-cwGetBackingPicture(PicturePtr pPicture, int *x_off, int *y_off)
-{
- cwPicturePrivate;
-
- if (pPicturePrivate) {
- DrawablePtr pDrawable = pPicture->pDrawable;
- WindowPtr pWindow = (WindowPtr) pDrawable;
- PixmapPtr pPixmap = getCwPixmap(pWindow);
-
- *x_off = pDrawable->x - pPixmap->screen_x;
- *y_off = pDrawable->y - pPixmap->screen_y;
-
- return pPicturePrivate->pBackingPicture;
- }
- else {
- *x_off = *y_off = 0;
- return pPicture;
- }
-}
-
-static void
-cwDestroyPicture(PicturePtr pPicture)
-{
- ScreenPtr pScreen = pPicture->pDrawable->pScreen;
-
- cwPsDecl(pScreen);
-
- cwPsUnwrap(DestroyPicture);
- cwDestroyPicturePrivate(pPicture);
- (*ps->DestroyPicture) (pPicture);
- cwPsWrap(DestroyPicture, cwDestroyPicture);
-}
-
-static void
-cwChangePicture(PicturePtr pPicture, Mask mask)
-{
- ScreenPtr pScreen = pPicture->pDrawable->pScreen;
-
- cwPsDecl(pScreen);
- cwPicturePtr pPicturePrivate = getCwPicture(pPicture);
-
- cwPsUnwrap(ChangePicture);
- (*ps->ChangePicture) (pPicture, mask);
- if (pPicturePrivate)
- pPicturePrivate->stateChanges |= mask;
- cwPsWrap(ChangePicture, cwChangePicture);
-}
-
-static void
-cwValidatePicture(PicturePtr pPicture, Mask mask)
-{
- DrawablePtr pDrawable = pPicture->pDrawable;
- ScreenPtr pScreen = pDrawable->pScreen;
-
- cwPsDecl(pScreen);
- cwPicturePrivate;
-
- cwPsUnwrap(ValidatePicture);
-
- /*
- * Must call ValidatePicture to ensure pPicture->pCompositeClip is valid
- */
- (*ps->ValidatePicture) (pPicture, mask);
-
- if (!cwDrawableIsRedirWindow(pDrawable)) {
- if (pPicturePrivate)
- cwDestroyPicturePrivate(pPicture);
- }
- else {
- PicturePtr pBackingPicture;
- DrawablePtr pBackingDrawable;
- int x_off, y_off;
-
- pBackingDrawable = cwGetBackingDrawable(pDrawable, &x_off, &y_off);
-
- if (pPicturePrivate &&
- pPicturePrivate->pBackingPicture->pDrawable != pBackingDrawable) {
- cwDestroyPicturePrivate(pPicture);
- pPicturePrivate = 0;
- }
-
- if (!pPicturePrivate) {
- pPicturePrivate = cwCreatePicturePrivate(pPicture);
- if (!pPicturePrivate) {
- cwPsWrap(ValidatePicture, cwValidatePicture);
- return;
- }
- }
-
- pBackingPicture = pPicturePrivate->pBackingPicture;
-
- /*
- * Always copy transform and filters because there's no
- * indication of when they've changed
- */
- SetPictureTransform(pBackingPicture, pPicture->transform);
-
- if (pBackingPicture->filter != pPicture->filter ||
- pPicture->filter_nparams > 0) {
- char *filter = PictureGetFilterName(pPicture->filter);
-
- SetPictureFilter(pBackingPicture,
- filter, strlen(filter),
- pPicture->filter_params, pPicture->filter_nparams);
- }
-
- pPicturePrivate->stateChanges |= mask;
-
- if (pPicturePrivate->serialNumber != pDrawable->serialNumber ||
- (pPicturePrivate->
- stateChanges & (CPClipXOrigin | CPClipYOrigin | CPClipMask))) {
- SetPictureClipRegion(pBackingPicture, x_off - pDrawable->x,
- y_off - pDrawable->y,
- pPicture->pCompositeClip);
-
- pPicturePrivate->serialNumber = pDrawable->serialNumber;
- pPicturePrivate->stateChanges &=
- ~(CPClipXOrigin | CPClipYOrigin | CPClipMask);
- }
-
- CopyPicture(pPicture, pPicturePrivate->stateChanges, pBackingPicture);
-
- ValidatePicture(pBackingPicture);
- }
- cwPsWrap(ValidatePicture, cwValidatePicture);
-}
-
-static void
-cwComposite(CARD8 op,
- PicturePtr pSrcPicture,
- PicturePtr pMskPicture,
- PicturePtr pDstPicture,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMsk,
- INT16 yMsk, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
-{
- ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
-
- cwPsDecl(pScreen);
- cwSrcPictureDecl;
- cwMskPictureDecl;
- cwDstPictureDecl;
-
- cwPsUnwrap(Composite);
- (*ps->Composite) (op, pBackingSrcPicture, pBackingMskPicture,
- pBackingDstPicture, xSrc + src_picture_x_off,
- ySrc + src_picture_y_off, xMsk + msk_picture_x_off,
- yMsk + msk_picture_y_off, xDst + dst_picture_x_off,
- yDst + dst_picture_y_off, width, height);
- cwPsWrap(Composite, cwComposite);
-}
-
-static void
-cwCompositeRects(CARD8 op,
- PicturePtr pDstPicture,
- xRenderColor * color, int nRect, xRectangle *rects)
-{
- ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
-
- cwPsDecl(pScreen);
- cwDstPictureDecl;
- int i;
-
- cwPsUnwrap(CompositeRects);
- for (i = 0; i < nRect; i++) {
- rects[i].x += dst_picture_x_off;
- rects[i].y += dst_picture_y_off;
- }
- (*ps->CompositeRects) (op, pBackingDstPicture, color, nRect, rects);
- cwPsWrap(CompositeRects, cwCompositeRects);
-}
-
-static void
-cwTrapezoids(CARD8 op,
- PicturePtr pSrcPicture,
- PicturePtr pDstPicture,
- PictFormatPtr maskFormat,
- INT16 xSrc, INT16 ySrc, int ntrap, xTrapezoid * traps)
-{
- ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
-
- cwPsDecl(pScreen);
- cwSrcPictureDecl;
- cwDstPictureDecl;
- int i;
-
- cwPsUnwrap(Trapezoids);
- if (dst_picture_x_off || dst_picture_y_off) {
- for (i = 0; i < ntrap; i++) {
- traps[i].top += dst_picture_y_off << 16;
- traps[i].bottom += dst_picture_y_off << 16;
- traps[i].left.p1.x += dst_picture_x_off << 16;
- traps[i].left.p1.y += dst_picture_y_off << 16;
- traps[i].left.p2.x += dst_picture_x_off << 16;
- traps[i].left.p2.y += dst_picture_y_off << 16;
- traps[i].right.p1.x += dst_picture_x_off << 16;
- traps[i].right.p1.y += dst_picture_y_off << 16;
- traps[i].right.p2.x += dst_picture_x_off << 16;
- traps[i].right.p2.y += dst_picture_y_off << 16;
- }
- }
- (*ps->Trapezoids) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat,
- xSrc + src_picture_x_off, ySrc + src_picture_y_off,
- ntrap, traps);
- cwPsWrap(Trapezoids, cwTrapezoids);
-}
-
-static void
-cwTriangles(CARD8 op,
- PicturePtr pSrcPicture,
- PicturePtr pDstPicture,
- PictFormatPtr maskFormat,
- INT16 xSrc, INT16 ySrc, int ntri, xTriangle * tris)
-{
- ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
-
- cwPsDecl(pScreen);
- cwSrcPictureDecl;
- cwDstPictureDecl;
- int i;
-
- cwPsUnwrap(Triangles);
- if (dst_picture_x_off || dst_picture_y_off) {
- for (i = 0; i < ntri; i++) {
- tris[i].p1.x += dst_picture_x_off << 16;
- tris[i].p1.y += dst_picture_y_off << 16;
- tris[i].p2.x += dst_picture_x_off << 16;
- tris[i].p2.y += dst_picture_y_off << 16;
- tris[i].p3.x += dst_picture_x_off << 16;
- tris[i].p3.y += dst_picture_y_off << 16;
- }
- }
- (*ps->Triangles) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat,
- xSrc + src_picture_x_off, ySrc + src_picture_y_off,
- ntri, tris);
- cwPsWrap(Triangles, cwTriangles);
-}
-
-void
-cwInitializeRender(ScreenPtr pScreen)
-{
- cwPsDecl(pScreen);
-
- cwPsWrap(DestroyPicture, cwDestroyPicture);
- cwPsWrap(ChangePicture, cwChangePicture);
- cwPsWrap(ValidatePicture, cwValidatePicture);
- cwPsWrap(Composite, cwComposite);
- cwPsWrap(CompositeRects, cwCompositeRects);
- cwPsWrap(Trapezoids, cwTrapezoids);
- cwPsWrap(Triangles, cwTriangles);
- /* There is no need to wrap AddTraps as far as we can tell. AddTraps can
- * only be done on alpha-only pictures, and we won't be getting
- * alpha-only window pictures, so there's no need to translate.
- */
-}
-
-void
-cwFiniRender(ScreenPtr pScreen)
-{
- cwPsDecl(pScreen);
-
- cwPsUnwrap(DestroyPicture);
- cwPsUnwrap(ChangePicture);
- cwPsUnwrap(ValidatePicture);
- cwPsUnwrap(Composite);
- cwPsUnwrap(CompositeRects);
- cwPsUnwrap(Trapezoids);
- cwPsUnwrap(Triangles);
-}
diff --git a/xorg-server/miext/damage/damage.c b/xorg-server/miext/damage/damage.c
index 8000517e8..445602253 100644
--- a/xorg-server/miext/damage/damage.c
+++ b/xorg-server/miext/damage/damage.c
@@ -38,9 +38,6 @@
#include "gcstruct.h"
#include "damage.h"
#include "damagestr.h"
-#ifdef COMPOSITE
-#include "cw.h"
-#endif
#define wrap(priv, real, mem, func) {\
priv->mem = real->mem; \
diff --git a/xorg-server/xkeyboard-config/rules/base.xml.in b/xorg-server/xkeyboard-config/rules/base.xml.in
index e0c1b4e58..49a2aeddf 100644
--- a/xorg-server/xkeyboard-config/rules/base.xml.in
+++ b/xorg-server/xkeyboard-config/rules/base.xml.in
@@ -3877,6 +3877,12 @@
<_description>Norwegian (Macintosh, eliminate dead keys)</_description>
</configItem>
</variant>
+ <variant>
+ <configItem>
+ <name>colemak</name>
+ <_description>Norwegian (Colemak)</_description>
+ </configItem>
+ </variant>
</variantList>
</layout>
<layout>
diff --git a/xorg-server/xkeyboard-config/symbols/no b/xorg-server/xkeyboard-config/symbols/no
index 53c83da62..8012570d5 100644
--- a/xorg-server/xkeyboard-config/symbols/no
+++ b/xorg-server/xkeyboard-config/symbols/no
@@ -212,7 +212,6 @@ xkb_symbols "mac" {
key <BKSL> { [ at, asterisk ] };
};
-
partial alphanumeric_keys
xkb_symbols "mac_nodeadkeys" {
@@ -223,3 +222,32 @@ xkb_symbols "mac_nodeadkeys" {
key <AE12> { [ grave, acute, acute, ogonek ] };
key <AD12> { [ diaeresis, asciicircum, asciitilde, macron ] };
};
+
+partial alphanumeric_keys
+xkb_symbols "colemak" {
+
+ // Colemak layout - http://colemak.com/
+ // Q W F P G J L U Y Ø Å ¨
+ // A R S T D H N E I O Æ '
+ // < Z X C V B K M , . -
+ include "no(basic)"
+ name[Group1]= "Norwegian (Colemak)";
+
+ key <AB06> { [ k, K, kra, ampersand ] };
+ key <AC02> { [ r, R, registered, trademark ] };
+ key <AC03> { [ s, S, ssharp, section ] };
+ key <AC04> { [ t, T, thorn, THORN ] };
+ key <AC05> { [ d, D, eth, ETH ] };
+ key <AC07> { [ n, N ] };
+ key <AC08> { [ e, E, EuroSign, cent ] };
+ key <AC09> { [ i, I, rightarrow, idotless ] };
+ key <AC10> { [ o, O, oe, OE ] };
+ key <AD03> { [ f, F, dstroke, ordfeminine ] };
+ key <AD04> { [ p, P, Greek_pi, Greek_PI ] };
+ key <AD05> { [ g, G, eng, ENG ] };
+ key <AD06> { [ j, J ] };
+ key <AD07> { [ l, L, lstroke, Lstroke ] };
+ key <AD08> { [ u, U, downarrow, uparrow ] };
+ key <AD09> { [ y, Y, leftarrow, yen ] };
+ key <AD10> { [ oslash, Ooblique, dead_acute, dead_doubleacute ] };
+};