aboutsummaryrefslogtreecommitdiff
path: root/mesalib
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib')
-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
120 files changed, 3768 insertions, 2427 deletions
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 4438b85bb..de3f2dfeb 100644
--- a/mesalib/src/glsl/ast.h
+++ b/mesalib/src/glsl/ast.h
@@ -513,6 +513,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 d97217ef9..fc5d11cb9 100644
--- a/mesalib/src/glsl/glsl_parser_extras.h
+++ b/mesalib/src/glsl/glsl_parser_extras.h
@@ -82,6 +82,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 92e2a1fa5..d7ef5d4d2 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 efaaf58de..91ef2dff4 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"