aboutsummaryrefslogtreecommitdiff
path: root/mesalib
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-10-16 11:30:08 +0200
committermarha <marha@users.sourceforge.net>2013-10-16 11:30:08 +0200
commit56e12b1310b1b52d00bc27e919d915255af5bf03 (patch)
tree19379a18fe9a678a109397837339820892101e4b /mesalib
parentc5883f8af060c0a300a29e732e8bb893bc8e0eca (diff)
parent9e23b44bfe1e6e85231b1c07d945cadf0c868648 (diff)
downloadvcxsrv-56e12b1310b1b52d00bc27e919d915255af5bf03.tar.gz
vcxsrv-56e12b1310b1b52d00bc27e919d915255af5bf03.tar.bz2
vcxsrv-56e12b1310b1b52d00bc27e919d915255af5bf03.zip
Merge remote-tracking branch 'origin/released'
* origin/released: fontconfig libxcb libxcb/xcb-proto xserver mesa pixman xkbcomp git update 16 oct 2013 Conflicts: mesalib/src/mesa/drivers/dri/common/drisw_util.c pixman/pixman/pixman-mmx.c
Diffstat (limited to 'mesalib')
-rw-r--r--mesalib/VERSION2
-rw-r--r--mesalib/configure.ac25
-rw-r--r--mesalib/docs/relnotes.html2
-rw-r--r--mesalib/docs/relnotes/10.0.html (renamed from mesalib/docs/relnotes/9.3.html)14
-rw-r--r--mesalib/include/GL/internal/dri_interface.h2
-rw-r--r--mesalib/scons/llvm.py6
-rw-r--r--mesalib/src/gallium/auxiliary/Makefile.am6
-rw-r--r--mesalib/src/gallium/auxiliary/SConscript2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_math.h2
-rw-r--r--mesalib/src/glsl/.dir-locals.el3
-rw-r--r--mesalib/src/glsl/Makefile.am11
-rw-r--r--mesalib/src/glsl/SConscript6
-rw-r--r--mesalib/src/glsl/ast_array_index.cpp84
-rw-r--r--mesalib/src/glsl/ast_to_hir.cpp311
-rw-r--r--mesalib/src/glsl/builtin_functions.cpp73
-rw-r--r--mesalib/src/glsl/builtin_types.cpp74
-rw-r--r--mesalib/src/glsl/builtin_variables.cpp113
-rw-r--r--mesalib/src/glsl/glsl_parser.yy6
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.cpp11
-rwxr-xr-xmesalib/src/glsl/glsl_parser_extras.h11
-rwxr-xr-xmesalib/src/glsl/glsl_symbol_table.cpp15
-rw-r--r--mesalib/src/glsl/glsl_symbol_table.h8
-rw-r--r--mesalib/src/glsl/glsl_types.cpp13
-rw-r--r--mesalib/src/glsl/glsl_types.h11
-rw-r--r--mesalib/src/glsl/ir.cpp9
-rw-r--r--mesalib/src/glsl/ir.h91
-rw-r--r--mesalib/src/glsl/ir_builder.cpp15
-rw-r--r--mesalib/src/glsl/ir_builder.h3
-rw-r--r--mesalib/src/glsl/ir_clone.cpp6
-rw-r--r--mesalib/src/glsl/ir_validate.cpp33
-rw-r--r--mesalib/src/glsl/link_functions.cpp37
-rw-r--r--mesalib/src/glsl/link_interface_blocks.cpp17
-rw-r--r--mesalib/src/glsl/link_uniform_block_active_visitor.cpp12
-rw-r--r--mesalib/src/glsl/link_uniforms.cpp13
-rw-r--r--mesalib/src/glsl/link_varyings.cpp113
-rw-r--r--mesalib/src/glsl/link_varyings.h11
-rw-r--r--mesalib/src/glsl/linker.cpp167
-rw-r--r--mesalib/src/glsl/lower_clip_distance.cpp253
-rw-r--r--mesalib/src/glsl/lower_named_interface_blocks.cpp7
-rw-r--r--mesalib/src/glsl/lower_ubo_reference.cpp3
-rw-r--r--mesalib/src/glsl/main.cpp197
-rw-r--r--mesalib/src/glsl/standalone_scaffolding.cpp28
-rwxr-xr-xmesalib/src/mapi/glapi/gen/gl_API.xml2
-rwxr-xr-xmesalib/src/mapi/glapi/gen/gl_gentable.py2
-rw-r--r--mesalib/src/mesa/drivers/SConscript2
-rw-r--r--mesalib/src/mesa/drivers/dri/Makefile.am2
-rw-r--r--mesalib/src/mesa/drivers/dri/common/dri_util.c171
-rw-r--r--mesalib/src/mesa/drivers/dri/common/dri_util.h11
-rw-r--r--mesalib/src/mesa/drivers/dri/common/drisw_util.c376
-rw-r--r--mesalib/src/mesa/drivers/dri/common/utils.c10
-rw-r--r--mesalib/src/mesa/drivers/dri/swrast/Makefile.am1
-rw-r--r--mesalib/src/mesa/drivers/dri/swrast/Makefile.sources3
-rw-r--r--mesalib/src/mesa/drivers/dri/swrast/swrast.c20
-rw-r--r--mesalib/src/mesa/main/api_validate.c53
-rw-r--r--mesalib/src/mesa/main/dd.h3
-rw-r--r--mesalib/src/mesa/main/fbobject.c1
-rw-r--r--mesalib/src/mesa/main/imports.c3
-rw-r--r--mesalib/src/mesa/main/macros.h36
-rw-r--r--mesalib/src/mesa/main/shaderapi.c6
-rw-r--r--mesalib/src/mesa/main/texgetimage.c2
-rw-r--r--mesalib/src/mesa/main/texgetimage.h3
-rw-r--r--mesalib/src/mesa/main/texstore.c1
-rw-r--r--mesalib/src/mesa/program/ir_to_mesa.cpp3
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c26
-rw-r--r--mesalib/src/mesa/state_tracker/st_format.c36
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp6
-rw-r--r--mesalib/src/mesa/vbo/vbo_exec.c2
-rw-r--r--mesalib/src/mesa/vbo/vbo_exec_eval.c2
-rw-r--r--mesalib/src/mesa/vbo/vbo_save.h2
-rw-r--r--mesalib/src/mesa/vbo/vbo_save_api.c22
70 files changed, 1827 insertions, 806 deletions
diff --git a/mesalib/VERSION b/mesalib/VERSION
index b26064902..8e92e8350 100644
--- a/mesalib/VERSION
+++ b/mesalib/VERSION
@@ -1 +1 @@
-9.3.0-devel
+10.0.0-devel
diff --git a/mesalib/configure.ac b/mesalib/configure.ac
index 954616318..08344c501 100644
--- a/mesalib/configure.ac
+++ b/mesalib/configure.ac
@@ -1025,8 +1025,6 @@ if test "x$enable_dri" = xyes; then
if test "x$have_libdrm" != xyes; then
AC_MSG_ERROR([DRI drivers requires libdrm >= $LIBDRM_REQUIRED])
fi
- # ... and build dricommon
- HAVE_COMMON_DRI=yes
fi
# put all the necessary libs together
@@ -1256,19 +1254,7 @@ dnl
dnl XA configuration
dnl
if test "x$enable_xa" = xyes; then
-AC_PROG_AWK
-AC_PROG_GREP
-AC_CHECK_PROG(NM, nm, "nm")
-if test "x$AWK" = x || test "x$GREP" = x || test "x$NM" = x; then
-AC_MSG_WARN([Missing one of nm, grep or awk. Disabling xa.])
-enable_xa=no
-fi
-fi
-if test "x$enable_xa" = xyes; then
GALLIUM_STATE_TRACKERS_DIRS="xa $GALLIUM_STATE_TRACKERS_DIRS"
- AC_SUBST(AWK)
- AC_SUBST(GREP)
- AC_SUBST(NM)
fi
AM_CONDITIONAL(HAVE_ST_XA, test "x$enable_xa" = xyes)
@@ -1532,8 +1518,9 @@ AC_ARG_WITH([llvm-shared-libs],
[with_llvm_shared_libs=no])
AS_IF([test x$enable_opencl = xyes],
[
- AC_MSG_WARN([OpenCL required, forcing LLVM shared libraries])
- with_llvm_shared_libs=yes
+ if test "x$with_llvm_shared_libs" != xyes; then
+ AC_MSG_ERROR([OpenCL requires LLVM shared libraries])
+ fi
])
AC_ARG_WITH([llvm-prefix],
@@ -1680,7 +1667,6 @@ gallium_check_st() {
fi
if test "x$enable_dri" = xyes && test "x$2" != x; then
GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $2"
- HAVE_COMMON_DRI=yes
fi
if test "x$enable_xorg" = xyes && test "x$3" != x; then
GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $3"
@@ -1823,7 +1809,6 @@ if test "x$with_gallium_drivers" != x; then
if test "x$enable_dri" = xyes; then
GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-swrast"
- HAVE_COMMON_DRI=yes
fi
if test "x$enable_vdpau" = xyes; then
GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS vdpau-softpipe"
@@ -1927,7 +1912,6 @@ AM_CONDITIONAL(HAVE_NOUVEAU_DRI, test x$HAVE_NOUVEAU_DRI = xyes)
AM_CONDITIONAL(HAVE_R200_DRI, test x$HAVE_R200_DRI = xyes)
AM_CONDITIONAL(HAVE_RADEON_DRI, test x$HAVE_RADEON_DRI = xyes)
AM_CONDITIONAL(HAVE_SWRAST_DRI, test x$HAVE_SWRAST_DRI = xyes)
-AM_CONDITIONAL(HAVE_COMMON_DRI, test x$HAVE_COMMON_DRI = xyes)
AM_CONDITIONAL(NEED_RADEON_DRM_WINSYS, test "x$NEED_NONNULL_WINSYS" = xyes -a \
"x$HAVE_GALLIUM_R300" = xyes -o \
@@ -1942,7 +1926,6 @@ AM_CONDITIONAL(HAVE_LOADER_GALLIUM, test x$enable_gallium_loader = xyes)
AM_CONDITIONAL(HAVE_DRM_LOADER_GALLIUM, test x$enable_gallium_drm_loader = xyes)
AM_CONDITIONAL(HAVE_GALLIUM_COMPUTE, test x$enable_opencl = xyes)
AM_CONDITIONAL(HAVE_MESA_LLVM, test x$MESA_LLVM = x1)
-AM_CONDITIONAL(LLVM_NEEDS_FNORTTI, test $LLVM_VERSION_INT -ge 302)
AC_SUBST([ELF_LIB])
@@ -1958,8 +1941,6 @@ AM_CONDITIONAL(HAVE_X86_ASM, echo "$DEFINES" | grep 'X86_ASM' >/dev/null 2>&1)
AM_CONDITIONAL(HAVE_X86_64_ASM, echo "$DEFINES" | grep 'X86_64_ASM' >/dev/null 2>&1)
AM_CONDITIONAL(HAVE_SPARC_ASM, echo "$DEFINES" | grep 'SPARC_ASM' >/dev/null 2>&1)
-AM_CONDITIONAL(CROSS_COMPILING, test "x$cross_compiling" = xyes)
-
AC_SUBST([VDPAU_MAJOR], 1)
AC_SUBST([VDPAU_MINOR], 0)
diff --git a/mesalib/docs/relnotes.html b/mesalib/docs/relnotes.html
index 5929359e0..82072ddfa 100644
--- a/mesalib/docs/relnotes.html
+++ b/mesalib/docs/relnotes.html
@@ -21,7 +21,7 @@ The release notes summarize what's new or changed in each Mesa release.
</p>
<ul>
-<li><a href="relnotes/9.3.html">9.3 release notes</a>
+<li><a href="relnotes/10.0.html">10.0 release notes</a>
<li><a href="relnotes/9.2.1.html">9.2.1 release notes</a>
<li><a href="relnotes/9.2.html">9.2 release notes</a>
<li><a href="relnotes/9.1.7.html">9.1.7 release notes</a>
diff --git a/mesalib/docs/relnotes/9.3.html b/mesalib/docs/relnotes/10.0.html
index 58a88b036..8f97921b0 100644
--- a/mesalib/docs/relnotes/9.3.html
+++ b/mesalib/docs/relnotes/10.0.html
@@ -14,20 +14,20 @@
<iframe src="../contents.html"></iframe>
<div class="content">
-<h1>Mesa 9.3 Release Notes / TBD</h1>
+<h1>Mesa 10.0 Release Notes / TBD</h1>
<p>
-Mesa 9.3 is a new development release.
+Mesa 10.0 is a new development release.
People who are concerned with stability and reliability should stick
-with a previous release or wait for Mesa 9.3.1.
+with a previous release or wait for Mesa 10.0.1.
</p>
<p>
-Mesa 9.3 implements the OpenGL 3.1 API, but the version reported by
+Mesa 10.0 implements the OpenGL 3.2 API, but the version reported by
glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) /
glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver being used.
-Some drivers don't support all the features required in OpenGL 3.1. OpenGL
-3.1 is <strong>only</strong> available if requested at context creation
-because GL_ARB_compatibility is not supported.
+Some drivers don't support all the features required in OpenGL 3.2. OpenGL
+3.2 is <strong>only</strong> available if requested at context creation
+because compatibility contexts are not supported.
</p>
diff --git a/mesalib/include/GL/internal/dri_interface.h b/mesalib/include/GL/internal/dri_interface.h
index 738d3b609..1fd02ebf5 100644
--- a/mesalib/include/GL/internal/dri_interface.h
+++ b/mesalib/include/GL/internal/dri_interface.h
@@ -968,6 +968,8 @@ struct __DRIdri2ExtensionRec {
#define __DRI_IMAGE_FORMAT_R8 0x1006 /* Since version 5 */
#define __DRI_IMAGE_FORMAT_GR88 0x1007
#define __DRI_IMAGE_FORMAT_NONE 0x1008
+#define __DRI_IMAGE_FORMAT_XRGB2101010 0x1009
+#define __DRI_IMAGE_FORMAT_ARGB2101010 0x100a
#define __DRI_IMAGE_USE_SHARE 0x0001
#define __DRI_IMAGE_USE_SCANOUT 0x0002
diff --git a/mesalib/scons/llvm.py b/mesalib/scons/llvm.py
index 7cd609c20..34b58910a 100644
--- a/mesalib/scons/llvm.py
+++ b/mesalib/scons/llvm.py
@@ -190,14 +190,14 @@ def generate(env):
pass
env.MergeFlags(cppflags)
+ cxxflags = env.backtick('llvm-config --cxxflags').rstrip()
+ env.Append(LLVM_CXXFLAGS = cxxflags)
+
components = ['engine', 'bitwriter', 'x86asmprinter']
if llvm_version >= distutils.version.LooseVersion('3.1'):
components.append('mcjit')
- if llvm_version >= distutils.version.LooseVersion('3.2'):
- env.Append(CXXFLAGS = ('-fno-rtti',))
-
env.ParseConfig('llvm-config --libs ' + ' '.join(components))
env.ParseConfig('llvm-config --ldflags')
except OSError:
diff --git a/mesalib/src/gallium/auxiliary/Makefile.am b/mesalib/src/gallium/auxiliary/Makefile.am
index 670e1248d..2d2d8d484 100644
--- a/mesalib/src/gallium/auxiliary/Makefile.am
+++ b/mesalib/src/gallium/auxiliary/Makefile.am
@@ -25,12 +25,6 @@ AM_CXXFLAGS += \
$(GALLIUM_CFLAGS) \
$(LLVM_CXXFLAGS)
-if LLVM_NEEDS_FNORTTI
-
-AM_CXXFLAGS += -fno-rtti
-
-endif
-
libgallium_la_SOURCES += \
$(GALLIVM_SOURCES) \
$(GALLIVM_CPP_SOURCES)
diff --git a/mesalib/src/gallium/auxiliary/SConscript b/mesalib/src/gallium/auxiliary/SConscript
index 31dfed316..3ac311225 100644
--- a/mesalib/src/gallium/auxiliary/SConscript
+++ b/mesalib/src/gallium/auxiliary/SConscript
@@ -46,6 +46,8 @@ source = env.ParseSourceList('Makefile.sources', [
])
if env['llvm']:
+ env.Append(CXXFLAGS = env['LLVM_CXXFLAGS'])
+
source += env.ParseSourceList('Makefile.sources', [
'GALLIVM_SOURCES',
'GALLIVM_CPP_SOURCES'
diff --git a/mesalib/src/gallium/auxiliary/util/u_math.h b/mesalib/src/gallium/auxiliary/util/u_math.h
index 478a4aa4d..f5c14ef8d 100644
--- a/mesalib/src/gallium/auxiliary/util/u_math.h
+++ b/mesalib/src/gallium/auxiliary/util/u_math.h
@@ -162,7 +162,7 @@ float log2f(float f)
#endif
-#if __STDC_VERSION__ < 199901L && !defined(__cplusplus)
+#if __STDC_VERSION__ < 199901L && (!defined(__cplusplus) || defined(_MSC_VER))
static INLINE long int
lrint(double d)
{
diff --git a/mesalib/src/glsl/.dir-locals.el b/mesalib/src/glsl/.dir-locals.el
deleted file mode 100644
index be19e29a5..000000000
--- a/mesalib/src/glsl/.dir-locals.el
+++ /dev/null
@@ -1,3 +0,0 @@
-((c-mode . ((c-basic-offset . 3)))
- (c++-mode . ((c-basic-offset . 3)))
-)
diff --git a/mesalib/src/glsl/Makefile.am b/mesalib/src/glsl/Makefile.am
index 2e161b844..cbf253cb5 100644
--- a/mesalib/src/glsl/Makefile.am
+++ b/mesalib/src/glsl/Makefile.am
@@ -49,6 +49,8 @@ check_PROGRAMS = \
tests/sampler-types-test \
tests/uniform-initializer-test
+noinst_PROGRAMS = glsl_compiler
+
tests_uniform_initializer_test_SOURCES = \
$(top_srcdir)/src/mesa/main/hash_table.c \
$(top_srcdir)/src/mesa/main/imports.c \
@@ -99,6 +101,15 @@ libglsl_la_SOURCES = \
glsl_parser.cpp \
$(LIBGLSL_FILES)
+glsl_compiler_SOURCES = \
+ $(top_srcdir)/src/mesa/main/hash_table.c \
+ $(top_srcdir)/src/mesa/main/imports.c \
+ $(top_srcdir)/src/mesa/program/prog_hash_table.c \
+ $(top_srcdir)/src/mesa/program/symbol_table.c \
+ $(GLSL_COMPILER_CXX_FILES)
+
+glsl_compiler_LDADD = libglsl.la
+
glsl_test_SOURCES = \
$(top_srcdir)/src/mesa/main/hash_table.c \
$(top_srcdir)/src/mesa/main/imports.c \
diff --git a/mesalib/src/glsl/SConscript b/mesalib/src/glsl/SConscript
index e386bdfb1..fe9d50732 100644
--- a/mesalib/src/glsl/SConscript
+++ b/mesalib/src/glsl/SConscript
@@ -98,11 +98,11 @@ if env['platform'] == 'windows':
env.Prepend(LIBS = [glsl])
-glsl2 = env.Program(
- target = 'glsl2',
+glsl_compiler = env.Program(
+ target = 'glsl_compiler',
source = compiler_objs,
)
-env.Alias('glsl2', glsl2)
+env.Alias('glsl_compiler', glsl_compiler)
glcpp = env.Program(
target = 'glcpp/glcpp',
diff --git a/mesalib/src/glsl/ast_array_index.cpp b/mesalib/src/glsl/ast_array_index.cpp
index 51f6b10f3..da96cc10e 100644
--- a/mesalib/src/glsl/ast_array_index.cpp
+++ b/mesalib/src/glsl/ast_array_index.cpp
@@ -25,6 +25,71 @@
#include "glsl_types.h"
#include "ir.h"
+
+/**
+ * If \c ir is a reference to an array for which we are tracking the max array
+ * element accessed, track that the given element has been accessed.
+ * Otherwise do nothing.
+ *
+ * This function also checks whether the array is a built-in array whose
+ * maximum size is too small to accommodate the given index, and if so uses
+ * loc and state to report the error.
+ */
+static void
+update_max_array_access(ir_rvalue *ir, unsigned idx, YYLTYPE *loc,
+ struct _mesa_glsl_parse_state *state)
+{
+ if (ir_dereference_variable *deref_var = ir->as_dereference_variable()) {
+ ir_variable *var = deref_var->var;
+ if (idx > var->max_array_access) {
+ var->max_array_access = idx;
+
+ /* Check whether this access will, as a side effect, implicitly cause
+ * the size of a built-in array to be too large.
+ */
+ check_builtin_array_max_size(var->name, idx+1, *loc, state);
+ }
+ } else if (ir_dereference_record *deref_record =
+ ir->as_dereference_record()) {
+ /* There are two possibilities we need to consider:
+ *
+ * - Accessing an element of an array that is a member of a named
+ * interface block (e.g. ifc.foo[i])
+ *
+ * - Accessing an element of an array that is a member of a named
+ * interface block array (e.g. ifc[j].foo[i]).
+ */
+ ir_dereference_variable *deref_var =
+ deref_record->record->as_dereference_variable();
+ if (deref_var == NULL) {
+ if (ir_dereference_array *deref_array =
+ deref_record->record->as_dereference_array()) {
+ deref_var = deref_array->array->as_dereference_variable();
+ }
+ }
+
+ if (deref_var != NULL) {
+ const glsl_type *interface_type =
+ deref_var->var->get_interface_type();
+ if (interface_type != NULL) {
+ unsigned field_index =
+ deref_record->record->type->field_index(deref_record->field);
+ assert(field_index < interface_type->length);
+ if (idx > deref_var->var->max_ifc_array_access[field_index]) {
+ deref_var->var->max_ifc_array_access[field_index] = idx;
+
+ /* Check whether this access will, as a side effect, implicitly
+ * cause the size of a built-in array to be too large.
+ */
+ check_builtin_array_max_size(deref_record->field, idx+1, *loc,
+ state);
+ }
+ }
+ }
+ }
+}
+
+
ir_rvalue *
_mesa_ast_array_index_to_hir(void *mem_ctx,
struct _mesa_glsl_parse_state *state,
@@ -97,23 +162,8 @@ _mesa_ast_array_index_to_hir(void *mem_ctx,
type_name);
}
- if (array->type->is_array()) {
- /* If the array is a variable dereference, it dereferences the
- * whole array, by definition. Use this to get the variable.
- *
- * FINISHME: Should some methods for getting / setting / testing
- * FINISHME: array access limits be added to ir_dereference?
- */
- ir_variable *const v = array->whole_variable_referenced();
- if ((v != NULL) && (unsigned(idx) > v->max_array_access)) {
- v->max_array_access = idx;
-
- /* Check whether this access will, as a side effect, implicitly
- * cause the size of a built-in array to be too large.
- */
- check_builtin_array_max_size(v->name, idx+1, loc, state);
- }
- }
+ if (array->type->is_array())
+ update_max_array_access(array, idx, &loc, state);
} else if (const_index == NULL && array->type->is_array()) {
if (array->type->array_size() == 0) {
_mesa_glsl_error(&loc, state, "unsized array index must be constant");
diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp
index 0859d9e00..dfa32d920 100644
--- a/mesalib/src/glsl/ast_to_hir.cpp
+++ b/mesalib/src/glsl/ast_to_hir.cpp
@@ -2326,9 +2326,10 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
* A pointer to an existing variable in the current scope if the declaration
* is a redeclaration, \c NULL otherwise.
*/
-ir_variable *
-get_variable_being_redeclared(ir_variable *var, ast_declaration *decl,
- struct _mesa_glsl_parse_state *state)
+static ir_variable *
+get_variable_being_redeclared(ir_variable *var, YYLTYPE loc,
+ struct _mesa_glsl_parse_state *state,
+ bool allow_all_redeclarations)
{
/* Check if this declaration is actually a re-declaration, either to
* resize an array or add qualifiers to an existing variable.
@@ -2336,16 +2337,14 @@ get_variable_being_redeclared(ir_variable *var, ast_declaration *decl,
* This is allowed for variables in the current scope, or when at
* global scope (for built-ins in the implicit outer scope).
*/
- ir_variable *earlier = state->symbols->get_variable(decl->identifier);
+ ir_variable *earlier = state->symbols->get_variable(var->name);
if (earlier == NULL ||
(state->current_function != NULL &&
- !state->symbols->name_declared_this_scope(decl->identifier))) {
+ !state->symbols->name_declared_this_scope(var->name))) {
return NULL;
}
- YYLTYPE loc = decl->get_location();
-
/* From page 24 (page 30 of the PDF) of the GLSL 1.50 spec,
*
* "It is legal to declare an array without a size and then
@@ -2433,8 +2432,18 @@ get_variable_being_redeclared(ir_variable *var, ast_declaration *decl,
earlier->depth_layout = var->depth_layout;
+ } else if (allow_all_redeclarations) {
+ if (earlier->mode != var->mode) {
+ _mesa_glsl_error(&loc, state,
+ "redeclaration of `%s' with incorrect qualifiers",
+ var->name);
+ } else if (earlier->type != var->type) {
+ _mesa_glsl_error(&loc, state,
+ "redeclaration of `%s' has incorrect type",
+ var->name);
+ }
} else {
- _mesa_glsl_error(&loc, state, "`%s' redeclared", decl->identifier);
+ _mesa_glsl_error(&loc, state, "`%s' redeclared", var->name);
}
return earlier;
@@ -2649,6 +2658,36 @@ handle_geometry_shader_input_decl(struct _mesa_glsl_parse_state *state,
}
}
+
+void
+validate_identifier(const char *identifier, YYLTYPE loc,
+ struct _mesa_glsl_parse_state *state)
+{
+ /* From page 15 (page 21 of the PDF) of the GLSL 1.10 spec,
+ *
+ * "Identifiers starting with "gl_" are reserved for use by
+ * OpenGL, and may not be declared in a shader as either a
+ * variable or a function."
+ */
+ if (strncmp(identifier, "gl_", 3) == 0) {
+ _mesa_glsl_error(&loc, state,
+ "identifier `%s' uses reserved `gl_' prefix",
+ identifier);
+ } else if (strstr(identifier, "__")) {
+ /* From page 14 (page 20 of the PDF) of the GLSL 1.10
+ * spec:
+ *
+ * "In addition, all identifiers containing two
+ * consecutive underscores (__) are reserved as
+ * possible future keywords."
+ */
+ _mesa_glsl_error(&loc, state,
+ "identifier `%s' uses reserved `__' string",
+ identifier);
+ }
+}
+
+
ir_rvalue *
ast_declarator_list::hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state)
@@ -3191,7 +3230,9 @@ ast_declarator_list::hir(exec_list *instructions,
* instruction stream.
*/
exec_list initializer_instructions;
- ir_variable *earlier = get_variable_being_redeclared(var, decl, state);
+ ir_variable *earlier =
+ get_variable_being_redeclared(var, decl->get_location(), state,
+ false /* allow_all_redeclarations */);
if (decl->initializer != NULL) {
result = process_initializer((earlier == NULL) ? var : earlier,
@@ -3243,28 +3284,7 @@ ast_declarator_list::hir(exec_list *instructions,
* created for the declaration should be added to the IR stream.
*/
if (earlier == NULL) {
- /* From page 15 (page 21 of the PDF) of the GLSL 1.10 spec,
- *
- * "Identifiers starting with "gl_" are reserved for use by
- * OpenGL, and may not be declared in a shader as either a
- * variable or a function."
- */
- if (strncmp(decl->identifier, "gl_", 3) == 0)
- _mesa_glsl_error(& loc, state,
- "identifier `%s' uses reserved `gl_' prefix",
- decl->identifier);
- else if (strstr(decl->identifier, "__")) {
- /* From page 14 (page 20 of the PDF) of the GLSL 1.10
- * spec:
- *
- * "In addition, all identifiers containing two
- * consecutive underscores (__) are reserved as
- * possible future keywords."
- */
- _mesa_glsl_error(& loc, state,
- "identifier `%s' uses reserved `__' string",
- decl->identifier);
- }
+ validate_identifier(decl->identifier, loc, state);
/* Add the variable to the symbol table. Note that the initializer's
* IR was already processed earlier (though it hasn't been emitted
@@ -3505,17 +3525,7 @@ ast_function::hir(exec_list *instructions,
"function body", name);
}
- /* From page 15 (page 21 of the PDF) of the GLSL 1.10 spec,
- *
- * "Identifiers starting with "gl_" are reserved for use by
- * OpenGL, and may not be declared in a shader as either a
- * variable or a function."
- */
- if (strncmp(name, "gl_", 3) == 0) {
- YYLTYPE loc = this->get_location();
- _mesa_glsl_error(&loc, state,
- "identifier `%s' uses reserved `gl_' prefix", name);
- }
+ validate_identifier(name, this->get_location(), state);
/* Convert the list of function parameters to HIR now so that they can be
* used below to compare this function's signature with previously seen
@@ -4411,7 +4421,8 @@ ast_process_structure_or_interface_block(exec_list *instructions,
YYLTYPE &loc,
glsl_struct_field **fields_ret,
bool is_interface,
- bool block_row_major)
+ bool block_row_major,
+ bool allow_reserved_names)
{
unsigned decl_count = 0;
@@ -4453,6 +4464,9 @@ ast_process_structure_or_interface_block(exec_list *instructions,
foreach_list_typed (ast_declaration, decl, link,
&decl_list->declarations) {
+ if (!allow_reserved_names)
+ validate_identifier(decl->identifier, loc, state);
+
/* From the GL_ARB_uniform_buffer_object spec:
*
* "Sampler types are not allowed inside of uniform
@@ -4491,6 +4505,7 @@ ast_process_structure_or_interface_block(exec_list *instructions,
}
fields[i].type = field_type;
fields[i].name = decl->identifier;
+ fields[i].location = -1;
if (qual->flags.q.row_major || qual->flags.q.column_major) {
if (!qual->flags.q.uniform) {
@@ -4568,7 +4583,10 @@ ast_struct_specifier::hir(exec_list *instructions,
loc,
&fields,
false,
- false);
+ false,
+ false /* allow_reserved_names */);
+
+ validate_identifier(this->name, loc, state);
const glsl_type *t =
glsl_type::get_record_instance(fields, decl_count, this->name);
@@ -4593,6 +4611,39 @@ ast_struct_specifier::hir(exec_list *instructions,
return NULL;
}
+
+/**
+ * Visitor class which detects whether a given interface block has been used.
+ */
+class interface_block_usage_visitor : public ir_hierarchical_visitor
+{
+public:
+ interface_block_usage_visitor(ir_variable_mode mode, const glsl_type *block)
+ : mode(mode), block(block), found(false)
+ {
+ }
+
+ virtual ir_visitor_status visit(ir_dereference_variable *ir)
+ {
+ if (ir->var->mode == mode && ir->var->get_interface_type() == block) {
+ found = true;
+ return visit_stop;
+ }
+ return visit_continue;
+ }
+
+ bool usage_found() const
+ {
+ return this->found;
+ }
+
+private:
+ ir_variable_mode mode;
+ const glsl_type *block;
+ bool found;
+};
+
+
ir_rvalue *
ast_interface_block::hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state)
@@ -4614,6 +4665,7 @@ ast_interface_block::hir(exec_list *instructions,
packing = GLSL_INTERFACE_PACKING_STD140;
}
+ bool redeclaring_per_vertex = strcmp(this->block_name, "gl_PerVertex") == 0;
bool block_row_major = this->layout.flags.q.row_major;
exec_list declared_variables;
glsl_struct_field *fields;
@@ -4624,7 +4676,8 @@ ast_interface_block::hir(exec_list *instructions,
loc,
&fields,
true,
- block_row_major);
+ block_row_major,
+ redeclaring_per_vertex);
ir_variable_mode var_mode;
const char *iface_type_name;
@@ -4643,6 +4696,102 @@ ast_interface_block::hir(exec_list *instructions,
assert(!"interface block layout qualifier not found!");
}
+ if (!redeclaring_per_vertex)
+ validate_identifier(this->block_name, loc, state);
+
+ const glsl_type *earlier_per_vertex = NULL;
+ if (redeclaring_per_vertex) {
+ /* Find the previous declaration of gl_PerVertex. If we're redeclaring
+ * the named interface block gl_in, we can find it by looking at the
+ * previous declaration of gl_in. Otherwise we can find it by looking
+ * at the previous decalartion of any of the built-in outputs,
+ * e.g. gl_Position.
+ *
+ * Also check that the instance name and array-ness of the redeclaration
+ * are correct.
+ */
+ switch (var_mode) {
+ case ir_var_shader_in:
+ if (ir_variable *earlier_gl_in =
+ state->symbols->get_variable("gl_in")) {
+ earlier_per_vertex = earlier_gl_in->get_interface_type();
+ } else {
+ _mesa_glsl_error(&loc, state,
+ "redeclaration of gl_PerVertex input not allowed "
+ "in the %s shader",
+ _mesa_glsl_shader_target_name(state->target));
+ }
+ if (this->instance_name == NULL ||
+ strcmp(this->instance_name, "gl_in") != 0 || !this->is_array) {
+ _mesa_glsl_error(&loc, state,
+ "gl_PerVertex input must be redeclared as "
+ "gl_in[]");
+ }
+ break;
+ case ir_var_shader_out:
+ if (ir_variable *earlier_gl_Position =
+ state->symbols->get_variable("gl_Position")) {
+ earlier_per_vertex = earlier_gl_Position->get_interface_type();
+ } else {
+ _mesa_glsl_error(&loc, state,
+ "redeclaration of gl_PerVertex output not "
+ "allowed in the %s shader",
+ _mesa_glsl_shader_target_name(state->target));
+ }
+ if (this->instance_name != NULL) {
+ _mesa_glsl_error(&loc, state,
+ "gl_PerVertex input may not be redeclared with "
+ "an instance name");
+ }
+ break;
+ default:
+ _mesa_glsl_error(&loc, state,
+ "gl_PerVertex must be declared as an input or an "
+ "output");
+ break;
+ }
+
+ if (earlier_per_vertex == NULL) {
+ /* An error has already been reported. Bail out to avoid null
+ * dereferences later in this function.
+ */
+ return NULL;
+ }
+
+ /* Copy locations from the old gl_PerVertex interface block. */
+ for (unsigned i = 0; i < num_variables; i++) {
+ int j = earlier_per_vertex->field_index(fields[i].name);
+ if (j == -1) {
+ _mesa_glsl_error(&loc, state,
+ "redeclaration of gl_PerVertex must be a subset "
+ "of the built-in members of gl_PerVertex");
+ } else {
+ fields[i].location =
+ earlier_per_vertex->fields.structure[j].location;
+ }
+ }
+
+ /* From section 7.1 ("Built-in Language Variables") of the GLSL 4.10
+ * spec:
+ *
+ * If a built-in interface block is redeclared, it must appear in
+ * the shader before any use of any member included in the built-in
+ * declaration, or a compilation error will result.
+ *
+ * This appears to be a clarification to the behaviour established for
+ * gl_PerVertex by GLSL 1.50, therefore we implement this behaviour
+ * regardless of GLSL version.
+ */
+ interface_block_usage_visitor v(var_mode, earlier_per_vertex);
+ v.run(instructions);
+ if (v.usage_found()) {
+ _mesa_glsl_error(&loc, state,
+ "redeclaration of a built-in interface block must "
+ "appear before any use of any member of the "
+ "interface block");
+ }
+ }
+
const glsl_type *block_type =
glsl_type::get_interface_instance(fields,
num_variables,
@@ -4682,6 +4831,9 @@ ast_interface_block::hir(exec_list *instructions,
* field selector ( . ) operator (analogously to structures)."
*/
if (this->instance_name) {
+ if (!redeclaring_per_vertex)
+ validate_identifier(this->instance_name, loc, state);
+
ir_variable *var;
if (this->is_array) {
@@ -4724,11 +4876,23 @@ ast_interface_block::hir(exec_list *instructions,
var_mode);
}
- var->interface_type = block_type;
+ var->init_interface_type(block_type);
if (state->target == geometry_shader && var_mode == ir_var_shader_in)
handle_geometry_shader_input_decl(state, loc, var);
- state->symbols->add_variable(var);
- instructions->push_tail(var);
+
+ if (ir_variable *earlier =
+ state->symbols->get_variable(this->instance_name)) {
+ if (!redeclaring_per_vertex) {
+ _mesa_glsl_error(&loc, state, "`%s' redeclared",
+ this->instance_name);
+ }
+ earlier->type = var->type;
+ earlier->reinit_interface_type(block_type);
+ delete var;
+ } else {
+ state->symbols->add_variable(var);
+ instructions->push_tail(var);
+ }
} else {
/* In order to have an array size, the block must also be declared with
* an instane name.
@@ -4740,7 +4904,24 @@ ast_interface_block::hir(exec_list *instructions,
new(state) ir_variable(fields[i].type,
ralloc_strdup(state, fields[i].name),
var_mode);
- var->interface_type = block_type;
+ var->init_interface_type(block_type);
+
+ if (redeclaring_per_vertex) {
+ ir_variable *earlier =
+ get_variable_being_redeclared(var, loc, state,
+ true /* allow_all_redeclarations */);
+ if (strncmp(var->name, "gl_", 3) != 0 || earlier == NULL) {
+ _mesa_glsl_error(&loc, state,
+ "redeclaration of gl_PerVertex can only "
+ "include built-in variables");
+ } else {
+ earlier->reinit_interface_type(block_type);
+ }
+ continue;
+ }
+
+ if (state->symbols->get_variable(var->name) != NULL)
+ _mesa_glsl_error(&loc, state, "`%s' redeclared", var->name);
/* Propagate the "binding" keyword into this UBO's fields;
* the UBO declaration itself doesn't get an ir_variable unless it
@@ -4752,6 +4933,38 @@ ast_interface_block::hir(exec_list *instructions,
state->symbols->add_variable(var);
instructions->push_tail(var);
}
+
+ if (redeclaring_per_vertex && block_type != earlier_per_vertex) {
+ /* From section 7.1 ("Built-in Language Variables") of the GLSL 4.10 spec:
+ *
+ * It is also a compilation error ... to redeclare a built-in
+ * block and then use a member from that built-in block that was
+ * not included in the redeclaration.
+ *
+ * This appears to be a clarification to the behaviour established
+ * for gl_PerVertex by GLSL 1.50, therefore we implement this
+ * behaviour regardless of GLSL version.
+ *
+ * To prevent the shader from using a member that was not included in
+ * the redeclaration, we disable any ir_variables that are still
+ * associated with the old declaration of gl_PerVertex (since we've
+ * already updated all of the variables contained in the new
+ * gl_PerVertex to point to it).
+ *
+ * As a side effect this will prevent
+ * validate_intrastage_interface_blocks() from getting confused and
+ * thinking there are conflicting definitions of gl_PerVertex in the
+ * shader.
+ */
+ foreach_list_safe(node, instructions) {
+ ir_variable *const var = ((ir_instruction *) node)->as_variable();
+ if (var != NULL &&
+ var->get_interface_type() == earlier_per_vertex) {
+ state->symbols->disable_variable(var->name);
+ var->remove();
+ }
+ }
+ }
}
return NULL;
diff --git a/mesalib/src/glsl/builtin_functions.cpp b/mesalib/src/glsl/builtin_functions.cpp
index b6451089c..d40888d38 100644
--- a/mesalib/src/glsl/builtin_functions.cpp
+++ b/mesalib/src/glsl/builtin_functions.cpp
@@ -531,6 +531,9 @@ private:
B1(fma)
B2(ldexp)
B2(frexp)
+ B1(uaddCarry)
+ B1(usubBorrow)
+ B1(mulExtended)
#undef B0
#undef B1
#undef B2
@@ -1947,6 +1950,30 @@ builtin_builder::create_builtins()
_frexp(glsl_type::vec3_type, glsl_type::ivec3_type),
_frexp(glsl_type::vec4_type, glsl_type::ivec4_type),
NULL);
+ add_function("uaddCarry",
+ _uaddCarry(glsl_type::uint_type),
+ _uaddCarry(glsl_type::uvec2_type),
+ _uaddCarry(glsl_type::uvec3_type),
+ _uaddCarry(glsl_type::uvec4_type),
+ NULL);
+ add_function("usubBorrow",
+ _usubBorrow(glsl_type::uint_type),
+ _usubBorrow(glsl_type::uvec2_type),
+ _usubBorrow(glsl_type::uvec3_type),
+ _usubBorrow(glsl_type::uvec4_type),
+ NULL);
+ add_function("imulExtended",
+ _mulExtended(glsl_type::int_type),
+ _mulExtended(glsl_type::ivec2_type),
+ _mulExtended(glsl_type::ivec3_type),
+ _mulExtended(glsl_type::ivec4_type),
+ NULL);
+ add_function("umulExtended",
+ _mulExtended(glsl_type::uint_type),
+ _mulExtended(glsl_type::uvec2_type),
+ _mulExtended(glsl_type::uvec3_type),
+ _mulExtended(glsl_type::uvec4_type),
+ NULL);
#undef F
#undef FI
#undef FIU
@@ -3720,6 +3747,52 @@ builtin_builder::_frexp(const glsl_type *x_type, const glsl_type *exp_type)
return sig;
}
+
+ir_function_signature *
+builtin_builder::_uaddCarry(const glsl_type *type)
+{
+ ir_variable *x = in_var(type, "x");
+ ir_variable *y = in_var(type, "y");
+ ir_variable *carry = out_var(type, "carry");
+ MAKE_SIG(type, gpu_shader5, 3, x, y, carry);
+
+ body.emit(assign(carry, ir_builder::carry(x, y)));
+ body.emit(ret(add(x, y)));
+
+ return sig;
+}
+
+ir_function_signature *
+builtin_builder::_usubBorrow(const glsl_type *type)
+{
+ ir_variable *x = in_var(type, "x");
+ ir_variable *y = in_var(type, "y");
+ ir_variable *borrow = out_var(type, "borrow");
+ MAKE_SIG(type, gpu_shader5, 3, x, y, borrow);
+
+ body.emit(assign(borrow, ir_builder::borrow(x, y)));
+ body.emit(ret(sub(x, y)));
+
+ return sig;
+}
+
+/**
+ * For both imulExtended() and umulExtended() built-ins.
+ */
+ir_function_signature *
+builtin_builder::_mulExtended(const glsl_type *type)
+{
+ ir_variable *x = in_var(type, "x");
+ ir_variable *y = in_var(type, "y");
+ ir_variable *msb = out_var(type, "msb");
+ ir_variable *lsb = out_var(type, "lsb");
+ MAKE_SIG(glsl_type::void_type, gpu_shader5, 4, x, y, msb, lsb);
+
+ body.emit(assign(msb, imul_high(x, y)));
+ body.emit(assign(lsb, mul(x, y)));
+
+ return sig;
+}
/** @} */
/******************************************************************************/
diff --git a/mesalib/src/glsl/builtin_types.cpp b/mesalib/src/glsl/builtin_types.cpp
index 722eda2da..1a5e5a190 100644
--- a/mesalib/src/glsl/builtin_types.cpp
+++ b/mesalib/src/glsl/builtin_types.cpp
@@ -53,64 +53,64 @@
&glsl_type::_struct_##NAME##_type;
static const struct glsl_struct_field gl_DepthRangeParameters_fields[] = {
- { glsl_type::float_type, "near", false },
- { glsl_type::float_type, "far", false },
- { glsl_type::float_type, "diff", false },
+ { glsl_type::float_type, "near", false, -1 },
+ { glsl_type::float_type, "far", false, -1 },
+ { glsl_type::float_type, "diff", false, -1 },
};
static const struct glsl_struct_field gl_PointParameters_fields[] = {
- { glsl_type::float_type, "size", false },
- { glsl_type::float_type, "sizeMin", false },
- { glsl_type::float_type, "sizeMax", false },
- { glsl_type::float_type, "fadeThresholdSize", false },
- { glsl_type::float_type, "distanceConstantAttenuation", false },
- { glsl_type::float_type, "distanceLinearAttenuation", false },
- { glsl_type::float_type, "distanceQuadraticAttenuation", false },
+ { glsl_type::float_type, "size", false, -1 },
+ { glsl_type::float_type, "sizeMin", false, -1 },
+ { glsl_type::float_type, "sizeMax", false, -1 },
+ { glsl_type::float_type, "fadeThresholdSize", false, -1 },
+ { glsl_type::float_type, "distanceConstantAttenuation", false, -1 },
+ { glsl_type::float_type, "distanceLinearAttenuation", false, -1 },
+ { glsl_type::float_type, "distanceQuadraticAttenuation", false, -1 },
};
static const struct glsl_struct_field gl_MaterialParameters_fields[] = {
- { glsl_type::vec4_type, "emission", false },
- { glsl_type::vec4_type, "ambient", false },
- { glsl_type::vec4_type, "diffuse", false },
- { glsl_type::vec4_type, "specular", false },
- { glsl_type::float_type, "shininess", false },
+ { glsl_type::vec4_type, "emission", false, -1 },
+ { glsl_type::vec4_type, "ambient", false, -1 },
+ { glsl_type::vec4_type, "diffuse", false, -1 },
+ { glsl_type::vec4_type, "specular", false, -1 },
+ { glsl_type::float_type, "shininess", false, -1 },
};
static const struct glsl_struct_field gl_LightSourceParameters_fields[] = {
- { glsl_type::vec4_type, "ambient", false },
- { glsl_type::vec4_type, "diffuse", false },
- { glsl_type::vec4_type, "specular", false },
- { glsl_type::vec4_type, "position", false },
- { glsl_type::vec4_type, "halfVector", false },
- { glsl_type::vec3_type, "spotDirection", false },
- { glsl_type::float_type, "spotExponent", false },
- { glsl_type::float_type, "spotCutoff", false },
- { glsl_type::float_type, "spotCosCutoff", false },
- { glsl_type::float_type, "constantAttenuation", false },
- { glsl_type::float_type, "linearAttenuation", false },
- { glsl_type::float_type, "quadraticAttenuation", false },
+ { glsl_type::vec4_type, "ambient", false, -1 },
+ { glsl_type::vec4_type, "diffuse", false, -1 },
+ { glsl_type::vec4_type, "specular", false, -1 },
+ { glsl_type::vec4_type, "position", false, -1 },
+ { glsl_type::vec4_type, "halfVector", false, -1 },
+ { glsl_type::vec3_type, "spotDirection", false, -1 },
+ { glsl_type::float_type, "spotExponent", false, -1 },
+ { glsl_type::float_type, "spotCutoff", false, -1 },
+ { glsl_type::float_type, "spotCosCutoff", false, -1 },
+ { glsl_type::float_type, "constantAttenuation", false, -1 },
+ { glsl_type::float_type, "linearAttenuation", false, -1 },
+ { glsl_type::float_type, "quadraticAttenuation", false, -1 },
};
static const struct glsl_struct_field gl_LightModelParameters_fields[] = {
- { glsl_type::vec4_type, "ambient", false },
+ { glsl_type::vec4_type, "ambient", false, -1 },
};
static const struct glsl_struct_field gl_LightModelProducts_fields[] = {
- { glsl_type::vec4_type, "sceneColor", false },
+ { glsl_type::vec4_type, "sceneColor", false, -1 },
};
static const struct glsl_struct_field gl_LightProducts_fields[] = {
- { glsl_type::vec4_type, "ambient", false },
- { glsl_type::vec4_type, "diffuse", false },
- { glsl_type::vec4_type, "specular", false },
+ { glsl_type::vec4_type, "ambient", false, -1 },
+ { glsl_type::vec4_type, "diffuse", false, -1 },
+ { glsl_type::vec4_type, "specular", false, -1 },
};
static const struct glsl_struct_field gl_FogParameters_fields[] = {
- { glsl_type::vec4_type, "color", false },
- { glsl_type::float_type, "density", false },
- { glsl_type::float_type, "start", false },
- { glsl_type::float_type, "end", false },
- { glsl_type::float_type, "scale", false },
+ { glsl_type::vec4_type, "color", false, -1 },
+ { glsl_type::float_type, "density", false, -1 },
+ { glsl_type::float_type, "start", false, -1 },
+ { glsl_type::float_type, "end", false, -1 },
+ { glsl_type::float_type, "scale", false, -1 },
};
#include "builtin_type_macros.h"
diff --git a/mesalib/src/glsl/builtin_variables.cpp b/mesalib/src/glsl/builtin_variables.cpp
index 6a808c072..f06d2ab05 100644
--- a/mesalib/src/glsl/builtin_variables.cpp
+++ b/mesalib/src/glsl/builtin_variables.cpp
@@ -293,6 +293,51 @@ static const struct gl_builtin_uniform_desc _mesa_builtin_uniform_desc[] = {
namespace {
+/**
+ * Data structure that accumulates fields for the gl_PerVertex interface
+ * block.
+ */
+class per_vertex_accumulator
+{
+public:
+ per_vertex_accumulator();
+ void add_field(int slot, const glsl_type *type, const char *name);
+ const glsl_type *construct_interface_instance() const;
+
+private:
+ glsl_struct_field fields[10];
+ unsigned num_fields;
+};
+
+
+per_vertex_accumulator::per_vertex_accumulator()
+ : num_fields(0)
+{
+}
+
+
+void
+per_vertex_accumulator::add_field(int slot, const glsl_type *type,
+ const char *name)
+{
+ assert(this->num_fields < ARRAY_SIZE(this->fields));
+ this->fields[this->num_fields].type = type;
+ this->fields[this->num_fields].name = name;
+ this->fields[this->num_fields].row_major = false;
+ this->fields[this->num_fields].location = slot;
+ this->num_fields++;
+}
+
+
+const glsl_type *
+per_vertex_accumulator::construct_interface_instance() const
+{
+ return glsl_type::get_interface_instance(this->fields, this->num_fields,
+ GLSL_INTERFACE_PACKING_STD140,
+ "gl_PerVertex");
+}
+
+
class builtin_variable_generator
{
public:
@@ -358,6 +403,9 @@ private:
const glsl_type * const vec4_t;
const glsl_type * const mat3_t;
const glsl_type * const mat4_t;
+
+ per_vertex_accumulator per_vertex_in;
+ per_vertex_accumulator per_vertex_out;
};
@@ -497,11 +545,12 @@ builtin_variable_generator::generate_constants()
*/
if (state->is_version(0, 300)) {
add_const("gl_MaxVertexOutputVectors",
- state->Const.MaxVaryingFloats / 4);
+ state->ctx->Const.VertexProgram.MaxOutputComponents / 4);
add_const("gl_MaxFragmentInputVectors",
- state->Const.MaxVaryingFloats / 4);
+ state->ctx->Const.FragmentProgram.MaxInputComponents / 4);
} else {
- add_const("gl_MaxVaryingVectors", state->Const.MaxVaryingFloats / 4);
+ add_const("gl_MaxVaryingVectors",
+ state->ctx->Const.MaxVarying);
}
} else {
add_const("gl_MaxVertexUniformComponents",
@@ -510,7 +559,7 @@ builtin_variable_generator::generate_constants()
/* Note: gl_MaxVaryingFloats was deprecated in GLSL 1.30+, but not
* removed
*/
- add_const("gl_MaxVaryingFloats", state->Const.MaxVaryingFloats);
+ add_const("gl_MaxVaryingFloats", state->ctx->Const.MaxVarying * 4);
add_const("gl_MaxFragmentUniformComponents",
state->Const.MaxFragmentUniformComponents);
@@ -531,7 +580,38 @@ builtin_variable_generator::generate_constants()
if (state->is_version(130, 0)) {
add_const("gl_MaxClipDistances", state->Const.MaxClipPlanes);
- add_const("gl_MaxVaryingComponents", state->Const.MaxVaryingFloats);
+ add_const("gl_MaxVaryingComponents", state->ctx->Const.MaxVarying * 4);
+ }
+
+ if (state->is_version(150, 0)) {
+ add_const("gl_MaxVertexOutputComponents",
+ state->Const.MaxVertexOutputComponents);
+ add_const("gl_MaxGeometryInputComponents",
+ state->Const.MaxGeometryInputComponents);
+ add_const("gl_MaxGeometryOutputComponents",
+ state->Const.MaxGeometryOutputComponents);
+ add_const("gl_MaxFragmentInputComponents",
+ state->Const.MaxFragmentInputComponents);
+ add_const("gl_MaxGeometryTextureImageUnits",
+ state->Const.MaxGeometryTextureImageUnits);
+ add_const("gl_MaxGeometryOutputVertices",
+ state->Const.MaxGeometryOutputVertices);
+ add_const("gl_MaxGeometryTotalOutputComponents",
+ state->Const.MaxGeometryTotalOutputComponents);
+ add_const("gl_MaxGeometryUniformComponents",
+ state->Const.MaxGeometryUniformComponents);
+
+ /* Note: the GLSL 1.50-4.40 specs require
+ * gl_MaxGeometryVaryingComponents to be present, and to be at least 64.
+ * But they do not define what it means (and there does not appear to be
+ * any corresponding constant in the GL specs). However,
+ * ARB_geometry_shader4 defines MAX_GEOMETRY_VARYING_COMPONENTS_ARB to
+ * be the maximum number of components available for use as geometry
+ * outputs. So we assume this is a synonym for
+ * gl_MaxGeometryOutputComponents.
+ */
+ add_const("gl_MaxGeometryVaryingComponents",
+ state->Const.MaxGeometryOutputComponents);
}
if (compatibility) {
@@ -756,10 +836,10 @@ builtin_variable_generator::add_varying(int slot, const glsl_type *type,
{
switch (state->target) {
case geometry_shader:
- add_input(slot, array(type, 0), name_as_gs_input);
+ this->per_vertex_in.add_field(slot, type, name);
/* FALLTHROUGH */
case vertex_shader:
- add_output(slot, type, name);
+ this->per_vertex_out.add_field(slot, type, name);
break;
case fragment_shader:
add_input(slot, type, name);
@@ -803,6 +883,25 @@ builtin_variable_generator::generate_varyings()
ADD_VARYING(VARYING_SLOT_BFC1, vec4_t, "gl_BackSecondaryColor");
}
}
+
+ if (state->target == geometry_shader) {
+ const glsl_type *per_vertex_in_type =
+ this->per_vertex_in.construct_interface_instance();
+ ir_variable *var = add_variable("gl_in", array(per_vertex_in_type, 0),
+ ir_var_shader_in, -1);
+ var->init_interface_type(per_vertex_in_type);
+ }
+ if (state->target == vertex_shader || state->target == geometry_shader) {
+ const glsl_type *per_vertex_out_type =
+ this->per_vertex_out.construct_interface_instance();
+ const glsl_struct_field *fields = per_vertex_out_type->fields.structure;
+ for (unsigned i = 0; i < per_vertex_out_type->length; i++) {
+ ir_variable *var =
+ add_variable(fields[i].name, fields[i].type, ir_var_shader_out,
+ fields[i].location);
+ var->init_interface_type(per_vertex_out_type);
+ }
+ }
}
diff --git a/mesalib/src/glsl/glsl_parser.yy b/mesalib/src/glsl/glsl_parser.yy
index 912931a47..a1d593fab 100644
--- a/mesalib/src/glsl/glsl_parser.yy
+++ b/mesalib/src/glsl/glsl_parser.yy
@@ -1752,6 +1752,12 @@ struct_declarator:
$$ = new(ctx) ast_declaration($1, false, NULL, NULL);
$$->set_location(yylloc);
}
+ | any_identifier '[' ']'
+ {
+ void *ctx = state;
+ $$ = new(ctx) ast_declaration($1, true, NULL, NULL);
+ $$->set_location(yylloc);
+ }
| any_identifier '[' constant_expression ']'
{
void *ctx = state;
diff --git a/mesalib/src/glsl/glsl_parser_extras.cpp b/mesalib/src/glsl/glsl_parser_extras.cpp
index ad85db9e3..be17109e1 100644
--- a/mesalib/src/glsl/glsl_parser_extras.cpp
+++ b/mesalib/src/glsl/glsl_parser_extras.cpp
@@ -99,7 +99,6 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
this->Const.MaxTextureCoords = ctx->Const.MaxTextureCoordUnits;
this->Const.MaxVertexAttribs = ctx->Const.VertexProgram.MaxAttribs;
this->Const.MaxVertexUniformComponents = ctx->Const.VertexProgram.MaxUniformComponents;
- this->Const.MaxVaryingFloats = ctx->Const.MaxVarying * 4;
this->Const.MaxVertexTextureImageUnits = ctx->Const.VertexProgram.MaxTextureImageUnits;
this->Const.MaxCombinedTextureImageUnits = ctx->Const.MaxCombinedTextureImageUnits;
this->Const.MaxTextureImageUnits = ctx->Const.FragmentProgram.MaxTextureImageUnits;
@@ -109,6 +108,16 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
this->Const.MaxDrawBuffers = ctx->Const.MaxDrawBuffers;
+ /* 1.50 constants */
+ this->Const.MaxVertexOutputComponents = ctx->Const.VertexProgram.MaxOutputComponents;
+ this->Const.MaxGeometryInputComponents = ctx->Const.GeometryProgram.MaxInputComponents;
+ this->Const.MaxGeometryOutputComponents = ctx->Const.GeometryProgram.MaxOutputComponents;
+ this->Const.MaxFragmentInputComponents = ctx->Const.FragmentProgram.MaxInputComponents;
+ this->Const.MaxGeometryTextureImageUnits = ctx->Const.GeometryProgram.MaxTextureImageUnits;
+ this->Const.MaxGeometryOutputVertices = ctx->Const.MaxGeometryOutputVertices;
+ this->Const.MaxGeometryTotalOutputComponents = ctx->Const.MaxGeometryTotalOutputComponents;
+ this->Const.MaxGeometryUniformComponents = ctx->Const.GeometryProgram.MaxUniformComponents;
+
this->current_function = NULL;
this->toplevel_ir = NULL;
this->found_return = false;
diff --git a/mesalib/src/glsl/glsl_parser_extras.h b/mesalib/src/glsl/glsl_parser_extras.h
index 4754b1654..01000b445 100755
--- a/mesalib/src/glsl/glsl_parser_extras.h
+++ b/mesalib/src/glsl/glsl_parser_extras.h
@@ -212,7 +212,6 @@ struct _mesa_glsl_parse_state {
unsigned MaxTextureCoords;
unsigned MaxVertexAttribs;
unsigned MaxVertexUniformComponents;
- unsigned MaxVaryingFloats;
unsigned MaxVertexTextureImageUnits;
unsigned MaxCombinedTextureImageUnits;
unsigned MaxTextureImageUnits;
@@ -224,6 +223,16 @@ struct _mesa_glsl_parse_state {
/* 3.00 ES */
int MinProgramTexelOffset;
int MaxProgramTexelOffset;
+
+ /* 1.50 */
+ unsigned MaxVertexOutputComponents;
+ unsigned MaxGeometryInputComponents;
+ unsigned MaxGeometryOutputComponents;
+ unsigned MaxFragmentInputComponents;
+ unsigned MaxGeometryTextureImageUnits;
+ unsigned MaxGeometryOutputVertices;
+ unsigned MaxGeometryTotalOutputComponents;
+ unsigned MaxGeometryUniformComponents;
} Const;
/**
diff --git a/mesalib/src/glsl/glsl_symbol_table.cpp b/mesalib/src/glsl/glsl_symbol_table.cpp
index 0eabc23d8..6ec4f534b 100755
--- a/mesalib/src/glsl/glsl_symbol_table.cpp
+++ b/mesalib/src/glsl/glsl_symbol_table.cpp
@@ -260,3 +260,18 @@ symbol_table_entry *glsl_symbol_table::get_entry(const char *name)
return (symbol_table_entry *)
_mesa_symbol_table_find_symbol(table, -1, name);
}
+
+void
+glsl_symbol_table::disable_variable(const char *name)
+{
+ /* Ideally we would remove the variable's entry from the symbol table, but
+ * that would be difficult. Fortunately, since this is only used for
+ * built-in variables, it won't be possible for the shader to re-introduce
+ * the variable later, so all we really need to do is to make sure that
+ * further attempts to access it using get_variable() will return NULL.
+ */
+ symbol_table_entry *entry = get_entry(name);
+ if (entry != NULL) {
+ entry->v = NULL;
+ }
+}
diff --git a/mesalib/src/glsl/glsl_symbol_table.h b/mesalib/src/glsl/glsl_symbol_table.h
index 46fd3fc5f..89d832125 100644
--- a/mesalib/src/glsl/glsl_symbol_table.h
+++ b/mesalib/src/glsl/glsl_symbol_table.h
@@ -126,6 +126,14 @@ public:
enum ir_variable_mode mode);
/*@}*/
+ /**
+ * Disable a previously-added variable so that it no longer appears to be
+ * in the symbol table. This is necessary when gl_PerVertex is redeclared,
+ * to ensure that previously-available built-in variables are no longer
+ * available.
+ */
+ void disable_variable(const char *name);
+
private:
symbol_table_entry *get_entry(const char *name);
diff --git a/mesalib/src/glsl/glsl_types.cpp b/mesalib/src/glsl/glsl_types.cpp
index 3c396dd89..80a6e71a7 100644
--- a/mesalib/src/glsl/glsl_types.cpp
+++ b/mesalib/src/glsl/glsl_types.cpp
@@ -100,6 +100,7 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
this->fields.structure[i].type = fields[i].type;
this->fields.structure[i].name = ralloc_strdup(this->fields.structure,
fields[i].name);
+ this->fields.structure[i].location = fields[i].location;
this->fields.structure[i].row_major = fields[i].row_major;
}
}
@@ -124,6 +125,7 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
this->fields.structure[i].type = fields[i].type;
this->fields.structure[i].name = ralloc_strdup(this->fields.structure,
fields[i].name);
+ this->fields.structure[i].location = fields[i].location;
this->fields.structure[i].row_major = fields[i].row_major;
}
}
@@ -450,6 +452,9 @@ glsl_type::record_key_compare(const void *a, const void *b)
if (key1->fields.structure[i].row_major
!= key2->fields.structure[i].row_major)
return 1;
+ if (key1->fields.structure[i].location
+ != key2->fields.structure[i].location)
+ return 1;
}
return 0;
@@ -507,9 +512,9 @@ const glsl_type *
glsl_type::get_interface_instance(const glsl_struct_field *fields,
unsigned num_fields,
enum glsl_interface_packing packing,
- const char *name)
+ const char *block_name)
{
- const glsl_type key(fields, num_fields, packing, name);
+ const glsl_type key(fields, num_fields, packing, block_name);
if (interface_types == NULL) {
interface_types = hash_table_ctor(64, record_key_hash, record_key_compare);
@@ -517,14 +522,14 @@ glsl_type::get_interface_instance(const glsl_struct_field *fields,
const glsl_type *t = (glsl_type *) hash_table_find(interface_types, & key);
if (t == NULL) {
- t = new glsl_type(fields, num_fields, packing, name);
+ t = new glsl_type(fields, num_fields, packing, block_name);
hash_table_insert(interface_types, (void *) t, t);
}
assert(t->base_type == GLSL_TYPE_INTERFACE);
assert(t->length == num_fields);
- assert(strcmp(t->name, name) == 0);
+ assert(strcmp(t->name, block_name) == 0);
return t;
}
diff --git a/mesalib/src/glsl/glsl_types.h b/mesalib/src/glsl/glsl_types.h
index 9f61eee78..e60c19132 100644
--- a/mesalib/src/glsl/glsl_types.h
+++ b/mesalib/src/glsl/glsl_types.h
@@ -234,7 +234,7 @@ struct glsl_type {
static const glsl_type *get_interface_instance(const glsl_struct_field *fields,
unsigned num_fields,
enum glsl_interface_packing packing,
- const char *name);
+ const char *block_name);
/**
* Query the total number of scalars that make up a scalar, vector or matrix
@@ -581,6 +581,15 @@ struct glsl_struct_field {
const struct glsl_type *type;
const char *name;
bool row_major;
+
+ /**
+ * For interface blocks, gl_varying_slot corresponding to the input/output
+ * if this is a built-in input/output (i.e. a member of the built-in
+ * gl_PerVertex interface block); -1 otherwise.
+ *
+ * Ignored for structs.
+ */
+ int location;
};
static inline unsigned int
diff --git a/mesalib/src/glsl/ir.cpp b/mesalib/src/glsl/ir.cpp
index ae67d6bdd..de9613e8f 100644
--- a/mesalib/src/glsl/ir.cpp
+++ b/mesalib/src/glsl/ir.cpp
@@ -398,6 +398,9 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1)
this->type = glsl_type::uint_type;
break;
+ case ir_binop_imul_high:
+ case ir_binop_carry:
+ case ir_binop_borrow:
case ir_binop_lshift:
case ir_binop_rshift:
case ir_binop_bfm:
@@ -527,7 +530,10 @@ static const char *const operator_strs[] = {
"+",
"-",
"*",
+ "imul_high",
"/",
+ "carry",
+ "borrow",
"%",
"<",
">",
@@ -1578,7 +1584,8 @@ ir_swizzle::variable_referenced() const
ir_variable::ir_variable(const struct glsl_type *type, const char *name,
ir_variable_mode mode)
- : max_array_access(0), read_only(false), centroid(false), invariant(false),
+ : max_array_access(0), max_ifc_array_access(NULL),
+ read_only(false), centroid(false), invariant(false),
mode(mode), interpolation(INTERP_QUALIFIER_NONE)
{
this->ir_type = ir_type_variable;
diff --git a/mesalib/src/glsl/ir.h b/mesalib/src/glsl/ir.h
index 1a4a3a2e3..aac8cbb7d 100644
--- a/mesalib/src/glsl/ir.h
+++ b/mesalib/src/glsl/ir.h
@@ -392,6 +392,65 @@ public:
}
/**
+ * Set this->interface_type on a newly created variable.
+ */
+ void init_interface_type(const struct glsl_type *type)
+ {
+ assert(this->interface_type == NULL);
+ this->interface_type = type;
+ if (this->is_interface_instance()) {
+ this->max_ifc_array_access =
+ rzalloc_array(this, unsigned, type->length);
+ }
+ }
+
+ /**
+ * Change this->interface_type on a variable that previously had a
+ * different, but compatible, interface_type. This is used during linking
+ * to set the size of arrays in interface blocks.
+ */
+ void change_interface_type(const struct glsl_type *type)
+ {
+ if (this->max_ifc_array_access != NULL) {
+ /* max_ifc_array_access has already been allocated, so make sure the
+ * new interface has the same number of fields as the old one.
+ */
+ assert(this->interface_type->length == type->length);
+ }
+ this->interface_type = type;
+ }
+
+ /**
+ * Change this->interface_type on a variable that previously had a
+ * different, and incompatible, interface_type. This is used during
+ * compilation to handle redeclaration of the built-in gl_PerVertex
+ * interface block.
+ */
+ void reinit_interface_type(const struct glsl_type *type)
+ {
+ if (this->max_ifc_array_access != NULL) {
+#ifndef _NDEBUG
+ /* Redeclaring gl_PerVertex is only allowed if none of the built-ins
+ * it defines have been accessed yet; so it's safe to throw away the
+ * old max_ifc_array_access pointer, since all of its values are
+ * zero.
+ */
+ for (unsigned i = 0; i < this->interface_type->length; i++)
+ assert(this->max_ifc_array_access[i] == 0);
+#endif
+ ralloc_free(this->max_ifc_array_access);
+ this->max_ifc_array_access = NULL;
+ }
+ this->interface_type = NULL;
+ init_interface_type(type);
+ }
+
+ const glsl_type *get_interface_type() const
+ {
+ return this->interface_type;
+ }
+
+ /**
* Declared type of the variable
*/
const struct glsl_type *type;
@@ -409,6 +468,19 @@ public:
unsigned max_array_access;
/**
+ * For variables which satisfy the is_interface_instance() predicate, this
+ * points to an array of integers such that if the ith member of the
+ * interface block is an array, max_ifc_array_access[i] is the maximum
+ * array element of that member that has been accessed. If the ith member
+ * of the interface block is not an array, max_ifc_array_access[i] is
+ * unused.
+ *
+ * For variables whose type is not an interface block, this pointer is
+ * NULL.
+ */
+ unsigned *max_ifc_array_access;
+
+ /**
* Is the variable read-only?
*
* This is set for variables declared as \c const, shader inputs,
@@ -582,6 +654,7 @@ public:
*/
ir_constant *constant_initializer;
+private:
/**
* For variables that are in an interface block or are an instance of an
* interface block, this is the \c GLSL_TYPE_INTERFACE type for that block.
@@ -1091,10 +1164,26 @@ enum ir_expression_operation {
ir_binop_add,
ir_binop_sub,
- ir_binop_mul,
+ ir_binop_mul, /**< Floating-point or low 32-bit integer multiply. */
+ ir_binop_imul_high, /**< Calculates the high 32-bits of a 64-bit multiply. */
ir_binop_div,
/**
+ * Returns the carry resulting from the addition of the two arguments.
+ */
+ /*@{*/
+ ir_binop_carry,
+ /*@}*/
+
+ /**
+ * Returns the borrow resulting from the subtraction of the second argument
+ * from the first argument.
+ */
+ /*@{*/
+ ir_binop_borrow,
+ /*@}*/
+
+ /**
* Takes one of two combinations of arguments:
*
* - mod(vecN, vecN)
diff --git a/mesalib/src/glsl/ir_builder.cpp b/mesalib/src/glsl/ir_builder.cpp
index 98b432295..6c49734be 100644
--- a/mesalib/src/glsl/ir_builder.cpp
+++ b/mesalib/src/glsl/ir_builder.cpp
@@ -216,11 +216,26 @@ ir_expression *mul(operand a, operand b)
return expr(ir_binop_mul, a, b);
}
+ir_expression *imul_high(operand a, operand b)
+{
+ return expr(ir_binop_imul_high, a, b);
+}
+
ir_expression *div(operand a, operand b)
{
return expr(ir_binop_div, a, b);
}
+ir_expression *carry(operand a, operand b)
+{
+ return expr(ir_binop_carry, a, b);
+}
+
+ir_expression *borrow(operand a, operand b)
+{
+ return expr(ir_binop_borrow, a, b);
+}
+
ir_expression *round_even(operand a)
{
return expr(ir_unop_round_even, a);
diff --git a/mesalib/src/glsl/ir_builder.h b/mesalib/src/glsl/ir_builder.h
index 6a5f77119..1f0778870 100644
--- a/mesalib/src/glsl/ir_builder.h
+++ b/mesalib/src/glsl/ir_builder.h
@@ -133,7 +133,10 @@ ir_expression *expr(ir_expression_operation op, operand a, operand b, operand c)
ir_expression *add(operand a, operand b);
ir_expression *sub(operand a, operand b);
ir_expression *mul(operand a, operand b);
+ir_expression *imul_high(operand a, operand b);
ir_expression *div(operand a, operand b);
+ir_expression *carry(operand a, operand b);
+ir_expression *borrow(operand a, operand b);
ir_expression *round_even(operand a);
ir_expression *dot(operand a, operand b);
ir_expression *dotlike(operand a, operand b);
diff --git a/mesalib/src/glsl/ir_clone.cpp b/mesalib/src/glsl/ir_clone.cpp
index dde22e018..105f9063a 100644
--- a/mesalib/src/glsl/ir_clone.cpp
+++ b/mesalib/src/glsl/ir_clone.cpp
@@ -44,6 +44,12 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) const
(ir_variable_mode) this->mode);
var->max_array_access = this->max_array_access;
+ if (this->is_interface_instance()) {
+ var->max_ifc_array_access =
+ rzalloc_array(var, unsigned, this->interface_type->length);
+ memcpy(var->max_ifc_array_access, this->max_ifc_array_access,
+ this->interface_type->length * sizeof(unsigned));
+ }
var->read_only = this->read_only;
var->centroid = this->centroid;
var->invariant = this->invariant;
diff --git a/mesalib/src/glsl/ir_validate.cpp b/mesalib/src/glsl/ir_validate.cpp
index 2c64f4e58..13e41a089 100644
--- a/mesalib/src/glsl/ir_validate.cpp
+++ b/mesalib/src/glsl/ir_validate.cpp
@@ -429,6 +429,19 @@ ir_validate::visit_leave(ir_expression *ir)
}
break;
+ case ir_binop_imul_high:
+ assert(ir->type == ir->operands[0]->type);
+ assert(ir->type == ir->operands[1]->type);
+ assert(ir->type->is_integer());
+ break;
+
+ case ir_binop_carry:
+ case ir_binop_borrow:
+ assert(ir->type == ir->operands[0]->type);
+ assert(ir->type == ir->operands[1]->type);
+ assert(ir->type->base_type == GLSL_TYPE_UINT);
+ break;
+
case ir_binop_less:
case ir_binop_greater:
case ir_binop_lequal:
@@ -674,6 +687,26 @@ ir_validate::visit(ir_variable *ir)
}
}
+ /* If a variable is an interface block (or an array of interface blocks),
+ * verify that the maximum array index for each interface member is in
+ * bounds.
+ */
+ if (ir->is_interface_instance()) {
+ const glsl_struct_field *fields =
+ ir->get_interface_type()->fields.structure;
+ for (unsigned i = 0; i < ir->get_interface_type()->length; i++) {
+ if (fields[i].type->array_size() > 0) {
+ if (ir->max_ifc_array_access[i] >= fields[i].type->length) {
+ printf("ir_variable has maximum access out of bounds for "
+ "field %s (%d vs %d)\n", fields[i].name,
+ ir->max_ifc_array_access[i], fields[i].type->length);
+ ir->print();
+ abort();
+ }
+ }
+ }
+ }
+
if (ir->constant_initializer != NULL && !ir->has_initializer) {
printf("ir_variable didn't have an initializer, but has a constant "
"initializer value.\n");
diff --git a/mesalib/src/glsl/link_functions.cpp b/mesalib/src/glsl/link_functions.cpp
index b1a68fd55..fd8009998 100644
--- a/mesalib/src/glsl/link_functions.cpp
+++ b/mesalib/src/glsl/link_functions.cpp
@@ -223,18 +223,31 @@ public:
var = ir->var->clone(linked, NULL);
linked->symbols->add_variable(var);
linked->ir->push_head(var);
- } else if (var->type->is_array()) {
- /* It is possible to have a global array declared in multiple
- * shaders without a size. The array is implicitly sized by the
- * maximal access to it in *any* shader. Because of this, we
- * need to track the maximal access to the array as linking pulls
- * more functions in that access the array.
- */
- var->max_array_access =
- MAX2(var->max_array_access, ir->var->max_array_access);
-
- if (var->type->length == 0 && ir->var->type->length != 0)
- var->type = ir->var->type;
+ } else {
+ if (var->type->is_array()) {
+ /* It is possible to have a global array declared in multiple
+ * shaders without a size. The array is implicitly sized by
+ * the maximal access to it in *any* shader. Because of this,
+ * we need to track the maximal access to the array as linking
+ * pulls more functions in that access the array.
+ */
+ var->max_array_access =
+ MAX2(var->max_array_access, ir->var->max_array_access);
+
+ if (var->type->length == 0 && ir->var->type->length != 0)
+ var->type = ir->var->type;
+ }
+ if (var->is_interface_instance()) {
+ /* Similarly, we need implicit sizes of arrays within interface
+ * blocks to be sized by the maximal access in *any* shader.
+ */
+ for (unsigned i = 0; i < var->get_interface_type()->length;
+ i++) {
+ var->max_ifc_array_access[i] =
+ MAX2(var->max_ifc_array_access[i],
+ ir->var->max_ifc_array_access[i]);
+ }
+ }
}
ir->var = var;
diff --git a/mesalib/src/glsl/link_interface_blocks.cpp b/mesalib/src/glsl/link_interface_blocks.cpp
index 928a88ee2..4f1c9d396 100644
--- a/mesalib/src/glsl/link_interface_blocks.cpp
+++ b/mesalib/src/glsl/link_interface_blocks.cpp
@@ -47,7 +47,7 @@ validate_intrastage_interface_blocks(struct gl_shader_program *prog,
if (!var)
continue;
- const glsl_type *iface_type = var->interface_type;
+ const glsl_type *iface_type = var->get_interface_type();
if (iface_type == NULL)
continue;
@@ -81,32 +81,33 @@ validate_interstage_interface_blocks(struct gl_shader_program *prog,
/* Add non-output interfaces from the consumer to the symbol table. */
foreach_list(node, consumer->ir) {
ir_variable *var = ((ir_instruction *) node)->as_variable();
- if (!var || !var->interface_type || var->mode == ir_var_shader_out)
+ if (!var || !var->get_interface_type() || var->mode == ir_var_shader_out)
continue;
- interfaces.add_interface(var->interface_type->name,
- var->interface_type,
+ interfaces.add_interface(var->get_interface_type()->name,
+ var->get_interface_type(),
(enum ir_variable_mode) var->mode);
}
/* Verify that the producer's interfaces match. */
foreach_list(node, producer->ir) {
ir_variable *var = ((ir_instruction *) node)->as_variable();
- if (!var || !var->interface_type || var->mode == ir_var_shader_in)
+ if (!var || !var->get_interface_type() || var->mode == ir_var_shader_in)
continue;
enum ir_variable_mode consumer_mode =
var->mode == ir_var_uniform ? ir_var_uniform : ir_var_shader_in;
const glsl_type *expected_type =
- interfaces.get_interface(var->interface_type->name, consumer_mode);
+ interfaces.get_interface(var->get_interface_type()->name,
+ consumer_mode);
/* The consumer doesn't use this output block. Ignore it. */
if (expected_type == NULL)
continue;
- if (var->interface_type != expected_type) {
+ if (var->get_interface_type() != expected_type) {
linker_error(prog, "definitions of interface block `%s' do not "
- "match\n", var->interface_type->name);
+ "match\n", var->get_interface_type()->name);
return;
}
}
diff --git a/mesalib/src/glsl/link_uniform_block_active_visitor.cpp b/mesalib/src/glsl/link_uniform_block_active_visitor.cpp
index 56a8384e9..f2f46a211 100644
--- a/mesalib/src/glsl/link_uniform_block_active_visitor.cpp
+++ b/mesalib/src/glsl/link_uniform_block_active_visitor.cpp
@@ -27,12 +27,12 @@
link_uniform_block_active *
process_block(void *mem_ctx, struct hash_table *ht, ir_variable *var)
{
- const uint32_t h = _mesa_hash_string(var->interface_type->name);
+ const uint32_t h = _mesa_hash_string(var->get_interface_type()->name);
const hash_entry *const existing_block =
- _mesa_hash_table_search(ht, h, var->interface_type->name);
+ _mesa_hash_table_search(ht, h, var->get_interface_type()->name);
const glsl_type *const block_type = var->is_interface_instance()
- ? var->type : var->interface_type;
+ ? var->type : var->get_interface_type();
/* If a block with this block-name has not previously been seen, add it.
@@ -46,7 +46,7 @@ process_block(void *mem_ctx, struct hash_table *ht, ir_variable *var)
b->type = block_type;
b->has_instance_name = var->is_interface_instance();
- _mesa_hash_table_insert(ht, h, var->interface_type->name,
+ _mesa_hash_table_insert(ht, h, var->get_interface_type()->name,
(void *) b);
return b;
} else {
@@ -90,7 +90,7 @@ link_uniform_block_active_visitor::visit_enter(ir_dereference_array *ir)
if (b == NULL) {
linker_error(prog,
"uniform block `%s' has mismatching definitions",
- var->interface_type->name);
+ var->get_interface_type()->name);
this->success = false;
return visit_stop;
}
@@ -149,7 +149,7 @@ link_uniform_block_active_visitor::visit(ir_dereference_variable *ir)
if (b == NULL) {
linker_error(this->prog,
"uniform block `%s' has mismatching definitions",
- var->interface_type->name);
+ var->get_interface_type()->name);
this->success = false;
return visit_stop;
}
diff --git a/mesalib/src/glsl/link_uniforms.cpp b/mesalib/src/glsl/link_uniforms.cpp
index 21ab78ecb..baea837b5 100644
--- a/mesalib/src/glsl/link_uniforms.cpp
+++ b/mesalib/src/glsl/link_uniforms.cpp
@@ -199,8 +199,8 @@ public:
{
this->is_ubo_var = var->is_in_uniform_block();
if (var->is_interface_instance())
- program_resource_visitor::process(var->interface_type,
- var->interface_type->name);
+ program_resource_visitor::process(var->get_interface_type(),
+ var->get_interface_type()->name);
else
program_resource_visitor::process(var);
}
@@ -317,10 +317,10 @@ public:
ubo_block_index = -1;
if (var->is_in_uniform_block()) {
if (var->is_interface_instance() && var->type->is_array()) {
- unsigned l = strlen(var->interface_type->name);
+ unsigned l = strlen(var->get_interface_type()->name);
for (unsigned i = 0; i < prog->NumUniformBlocks; i++) {
- if (strncmp(var->interface_type->name,
+ if (strncmp(var->get_interface_type()->name,
prog->UniformBlocks[i].Name,
l) == 0
&& prog->UniformBlocks[i].Name[l] == '[') {
@@ -330,7 +330,7 @@ public:
}
} else {
for (unsigned i = 0; i < prog->NumUniformBlocks; i++) {
- if (strcmp(var->interface_type->name,
+ if (strcmp(var->get_interface_type()->name,
prog->UniformBlocks[i].Name) == 0) {
ubo_block_index = i;
break;
@@ -362,7 +362,8 @@ public:
}
if (var->is_interface_instance())
- process(var->interface_type, var->interface_type->name);
+ process(var->get_interface_type(),
+ var->get_interface_type()->name);
else
process(var);
} else
diff --git a/mesalib/src/glsl/link_varyings.cpp b/mesalib/src/glsl/link_varyings.cpp
index 905621daf..4ba6d8a20 100644
--- a/mesalib/src/glsl/link_varyings.cpp
+++ b/mesalib/src/glsl/link_varyings.cpp
@@ -972,8 +972,8 @@ public:
this->toplevel_var = var;
this->varying_floats = 0;
if (var->is_interface_instance())
- program_resource_visitor::process(var->interface_type,
- var->interface_type->name);
+ program_resource_visitor::process(var->get_interface_type(),
+ var->get_interface_type()->name);
else
program_resource_visitor::process(var);
}
@@ -1083,10 +1083,10 @@ assign_varying_locations(struct gl_context *ctx,
((ir_instruction *) node)->as_variable();
if ((input_var != NULL) && (input_var->mode == ir_var_shader_in)) {
- if (input_var->interface_type != NULL) {
+ if (input_var->get_interface_type() != NULL) {
char *const iface_field_name =
ralloc_asprintf(mem_ctx, "%s.%s",
- input_var->interface_type->name,
+ input_var->get_interface_type()->name,
input_var->name);
hash_table_insert(consumer_interface_inputs, input_var,
iface_field_name);
@@ -1108,10 +1108,10 @@ assign_varying_locations(struct gl_context *ctx,
g.process(output_var);
ir_variable *input_var;
- if (output_var->interface_type != NULL) {
+ if (output_var->get_interface_type() != NULL) {
char *const iface_field_name =
ralloc_asprintf(mem_ctx, "%s.%s",
- output_var->interface_type->name,
+ output_var->get_interface_type()->name,
output_var->name);
input_var =
(ir_variable *) hash_table_find(consumer_interface_inputs,
@@ -1220,39 +1220,98 @@ assign_varying_locations(struct gl_context *ctx,
}
bool
-check_against_varying_limit(struct gl_context *ctx,
- struct gl_shader_program *prog,
- gl_shader *consumer)
+check_against_output_limit(struct gl_context *ctx,
+ struct gl_shader_program *prog,
+ gl_shader *producer)
{
- unsigned varying_vectors = 0;
+ unsigned output_vectors = 0;
+
+ foreach_list(node, producer->ir) {
+ ir_variable *const var = ((ir_instruction *) node)->as_variable();
+
+ if (var && var->mode == ir_var_shader_out &&
+ is_varying_var(producer->Type, var)) {
+ output_vectors += var->type->count_attribute_slots();
+ }
+ }
+
+ unsigned max_output_components;
+ switch (producer->Type) {
+ case GL_VERTEX_SHADER:
+ max_output_components = ctx->Const.VertexProgram.MaxOutputComponents;
+ break;
+ case GL_GEOMETRY_SHADER:
+ max_output_components = ctx->Const.GeometryProgram.MaxOutputComponents;
+ break;
+ case GL_FRAGMENT_SHADER:
+ default:
+ assert(!"Should not get here.");
+ return false;
+ }
+
+ const unsigned output_components = output_vectors * 4;
+ if (output_components > max_output_components) {
+ if (ctx->API == API_OPENGLES2 || prog->IsES)
+ linker_error(prog, "shader uses too many output vectors "
+ "(%u > %u)\n",
+ output_vectors,
+ max_output_components / 4);
+ else
+ linker_error(prog, "shader uses too many output components "
+ "(%u > %u)\n",
+ output_components,
+ max_output_components);
+
+ return false;
+ }
+
+ return true;
+}
+
+bool
+check_against_input_limit(struct gl_context *ctx,
+ struct gl_shader_program *prog,
+ gl_shader *consumer)
+{
+ unsigned input_vectors = 0;
foreach_list(node, consumer->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
if (var && var->mode == ir_var_shader_in &&
is_varying_var(consumer->Type, var)) {
- /* The packing rules used for vertex shader inputs are also
- * used for fragment shader inputs.
- */
- varying_vectors += var->type->count_attribute_slots();
+ input_vectors += var->type->count_attribute_slots();
}
}
- if (ctx->API == API_OPENGLES2 || prog->IsES) {
- if (varying_vectors > ctx->Const.MaxVarying) {
- linker_error(prog, "shader uses too many varying vectors "
+ unsigned max_input_components;
+ switch (consumer->Type) {
+ case GL_GEOMETRY_SHADER:
+ max_input_components = ctx->Const.GeometryProgram.MaxInputComponents;
+ break;
+ case GL_FRAGMENT_SHADER:
+ max_input_components = ctx->Const.FragmentProgram.MaxInputComponents;
+ break;
+ case GL_VERTEX_SHADER:
+ default:
+ assert(!"Should not get here.");
+ return false;
+ }
+
+ const unsigned input_components = input_vectors * 4;
+ if (input_components > max_input_components) {
+ if (ctx->API == API_OPENGLES2 || prog->IsES)
+ linker_error(prog, "shader uses too many input vectors "
"(%u > %u)\n",
- varying_vectors, ctx->Const.MaxVarying);
- return false;
- }
- } else {
- const unsigned float_components = varying_vectors * 4;
- if (float_components > ctx->Const.MaxVarying * 4) {
- linker_error(prog, "shader uses too many varying components "
+ input_vectors,
+ max_input_components / 4);
+ else
+ linker_error(prog, "shader uses too many input components "
"(%u > %u)\n",
- float_components, ctx->Const.MaxVarying * 4);
- return false;
- }
+ input_components,
+ max_input_components);
+
+ return false;
}
return true;
diff --git a/mesalib/src/glsl/link_varyings.h b/mesalib/src/glsl/link_varyings.h
index 6264ef05b..6fa268176 100644
--- a/mesalib/src/glsl/link_varyings.h
+++ b/mesalib/src/glsl/link_varyings.h
@@ -237,8 +237,13 @@ assign_varying_locations(struct gl_context *ctx,
unsigned gs_input_vertices);
bool
-check_against_varying_limit(struct gl_context *ctx,
- struct gl_shader_program *prog,
- gl_shader *consumer);
+check_against_output_limit(struct gl_context *ctx,
+ struct gl_shader_program *prog,
+ gl_shader *producer);
+
+bool
+check_against_input_limit(struct gl_context *ctx,
+ struct gl_shader_program *prog,
+ gl_shader *consumer);
#endif /* GLSL_LINK_VARYINGS_H */
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index c54b7049b..9095a4015 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -1033,17 +1033,167 @@ get_main_function_signature(gl_shader *sh)
*/
class array_sizing_visitor : public ir_hierarchical_visitor {
public:
+ array_sizing_visitor()
+ : mem_ctx(ralloc_context(NULL)),
+ unnamed_interfaces(hash_table_ctor(0, hash_table_pointer_hash,
+ hash_table_pointer_compare))
+ {
+ }
+
+ ~array_sizing_visitor()
+ {
+ hash_table_dtor(this->unnamed_interfaces);
+ ralloc_free(this->mem_ctx);
+ }
+
virtual ir_visitor_status visit(ir_variable *var)
{
- if (var->type->is_array() && (var->type->length == 0)) {
- const glsl_type *type =
- glsl_type::get_array_instance(var->type->fields.array,
- var->max_array_access + 1);
- assert(type != NULL);
- var->type = type;
+ fixup_type(&var->type, var->max_array_access);
+ if (var->type->is_interface()) {
+ if (interface_contains_unsized_arrays(var->type)) {
+ const glsl_type *new_type =
+ resize_interface_members(var->type, var->max_ifc_array_access);
+ var->type = new_type;
+ var->change_interface_type(new_type);
+ }
+ } else if (var->type->is_array() &&
+ var->type->fields.array->is_interface()) {
+ if (interface_contains_unsized_arrays(var->type->fields.array)) {
+ const glsl_type *new_type =
+ resize_interface_members(var->type->fields.array,
+ var->max_ifc_array_access);
+ var->change_interface_type(new_type);
+ var->type =
+ glsl_type::get_array_instance(new_type, var->type->length);
+ }
+ } else if (const glsl_type *ifc_type = var->get_interface_type()) {
+ /* Store a pointer to the variable in the unnamed_interfaces
+ * hashtable.
+ */
+ ir_variable **interface_vars = (ir_variable **)
+ hash_table_find(this->unnamed_interfaces, ifc_type);
+ if (interface_vars == NULL) {
+ interface_vars = rzalloc_array(mem_ctx, ir_variable *,
+ ifc_type->length);
+ hash_table_insert(this->unnamed_interfaces, interface_vars,
+ ifc_type);
+ }
+ unsigned index = ifc_type->field_index(var->name);
+ assert(index < ifc_type->length);
+ assert(interface_vars[index] == NULL);
+ interface_vars[index] = var;
}
return visit_continue;
}
+
+ /**
+ * For each unnamed interface block that was discovered while running the
+ * visitor, adjust the interface type to reflect the newly assigned array
+ * sizes, and fix up the ir_variable nodes to point to the new interface
+ * type.
+ */
+ void fixup_unnamed_interface_types()
+ {
+ hash_table_call_foreach(this->unnamed_interfaces,
+ fixup_unnamed_interface_type, NULL);
+ }
+
+private:
+ /**
+ * If the type pointed to by \c type represents an unsized array, replace
+ * it with a sized array whose size is determined by max_array_access.
+ */
+ static void fixup_type(const glsl_type **type, unsigned max_array_access)
+ {
+ if ((*type)->is_array() && (*type)->length == 0) {
+ *type = glsl_type::get_array_instance((*type)->fields.array,
+ max_array_access + 1);
+ assert(*type != NULL);
+ }
+ }
+
+ /**
+ * Determine whether the given interface type contains unsized arrays (if
+ * it doesn't, array_sizing_visitor doesn't need to process it).
+ */
+ static bool interface_contains_unsized_arrays(const glsl_type *type)
+ {
+ for (unsigned i = 0; i < type->length; i++) {
+ const glsl_type *elem_type = type->fields.structure[i].type;
+ if (elem_type->is_array() && elem_type->length == 0)
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Create a new interface type based on the given type, with unsized arrays
+ * replaced by sized arrays whose size is determined by
+ * max_ifc_array_access.
+ */
+ static const glsl_type *
+ resize_interface_members(const glsl_type *type,
+ const unsigned *max_ifc_array_access)
+ {
+ unsigned num_fields = type->length;
+ glsl_struct_field *fields = new glsl_struct_field[num_fields];
+ memcpy(fields, type->fields.structure,
+ num_fields * sizeof(*fields));
+ for (unsigned i = 0; i < num_fields; i++) {
+ fixup_type(&fields[i].type, max_ifc_array_access[i]);
+ }
+ glsl_interface_packing packing =
+ (glsl_interface_packing) type->interface_packing;
+ const glsl_type *new_ifc_type =
+ glsl_type::get_interface_instance(fields, num_fields,
+ packing, type->name);
+ delete [] fields;
+ return new_ifc_type;
+ }
+
+ static void fixup_unnamed_interface_type(const void *key, void *data,
+ void *)
+ {
+ const glsl_type *ifc_type = (const glsl_type *) key;
+ ir_variable **interface_vars = (ir_variable **) data;
+ unsigned num_fields = ifc_type->length;
+ glsl_struct_field *fields = new glsl_struct_field[num_fields];
+ memcpy(fields, ifc_type->fields.structure,
+ num_fields * sizeof(*fields));
+ bool interface_type_changed = false;
+ for (unsigned i = 0; i < num_fields; i++) {
+ if (interface_vars[i] != NULL &&
+ fields[i].type != interface_vars[i]->type) {
+ fields[i].type = interface_vars[i]->type;
+ interface_type_changed = true;
+ }
+ }
+ if (!interface_type_changed) {
+ delete [] fields;
+ return;
+ }
+ glsl_interface_packing packing =
+ (glsl_interface_packing) ifc_type->interface_packing;
+ const glsl_type *new_ifc_type =
+ glsl_type::get_interface_instance(fields, num_fields, packing,
+ ifc_type->name);
+ delete [] fields;
+ for (unsigned i = 0; i < num_fields; i++) {
+ if (interface_vars[i] != NULL)
+ interface_vars[i]->change_interface_type(new_ifc_type);
+ }
+ }
+
+ /**
+ * Memory context used to allocate the data in \c unnamed_interfaces.
+ */
+ void *mem_ctx;
+
+ /**
+ * Hash table from const glsl_type * to an array of ir_variable *'s
+ * pointing to the ir_variables constituting each unnamed interface block.
+ */
+ hash_table *unnamed_interfaces;
};
/**
@@ -1318,6 +1468,7 @@ link_intrastage_shaders(void *mem_ctx,
*/
array_sizing_visitor v;
v.run(linked->ir);
+ v.fixup_unnamed_interface_types();
return linked;
}
@@ -2203,7 +2354,9 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
;
/* This must be done after all dead varyings are eliminated. */
- if (!check_against_varying_limit(ctx, prog, sh_next))
+ if (!check_against_output_limit(ctx, prog, sh_i))
+ goto done;
+ if (!check_against_input_limit(ctx, prog, sh_next))
goto done;
next = i;
diff --git a/mesalib/src/glsl/lower_clip_distance.cpp b/mesalib/src/glsl/lower_clip_distance.cpp
index 9ddd64603..682c8fdcd 100644
--- a/mesalib/src/glsl/lower_clip_distance.cpp
+++ b/mesalib/src/glsl/lower_clip_distance.cpp
@@ -54,14 +54,17 @@ namespace {
class lower_clip_distance_visitor : public ir_rvalue_visitor {
public:
- lower_clip_distance_visitor()
- : progress(false), old_clip_distance_var(NULL),
- new_clip_distance_var(NULL)
+ explicit lower_clip_distance_visitor(GLenum shader_type)
+ : progress(false), old_clip_distance_1d_var(NULL),
+ old_clip_distance_2d_var(NULL), new_clip_distance_1d_var(NULL),
+ new_clip_distance_2d_var(NULL), shader_type(shader_type)
{
}
virtual ir_visitor_status visit(ir_variable *);
void create_indices(ir_rvalue*, ir_rvalue *&, ir_rvalue *&);
+ bool is_clip_distance_vec8(ir_rvalue *ir);
+ ir_rvalue *lower_clip_distance_vec8(ir_rvalue *ir);
virtual ir_visitor_status visit_leave(ir_assignment *);
void visit_new_assignment(ir_assignment *ir);
virtual ir_visitor_status visit_leave(ir_call *);
@@ -74,13 +77,28 @@ public:
/**
* Pointer to the declaration of gl_ClipDistance, if found.
+ *
+ * Note:
+ *
+ * - the 2d_var is for geometry shader input only.
+ *
+ * - since gl_ClipDistance is available in geometry shaders as both an
+ * input and an output, it's possible for both old_clip_distance_1d_var
+ * and old_clip_distance_2d_var to be non-null.
*/
- ir_variable *old_clip_distance_var;
+ ir_variable *old_clip_distance_1d_var;
+ ir_variable *old_clip_distance_2d_var;
/**
* Pointer to the newly-created gl_ClipDistanceMESA variable.
*/
- ir_variable *new_clip_distance_var;
+ ir_variable *new_clip_distance_1d_var;
+ ir_variable *new_clip_distance_2d_var;
+
+ /**
+ * Type of shader we are compiling (e.g. GL_VERTEX_SHADER)
+ */
+ const GLenum shader_type;
};
} /* anonymous namespace */
@@ -92,30 +110,61 @@ public:
ir_visitor_status
lower_clip_distance_visitor::visit(ir_variable *ir)
{
- /* No point in looking for the declaration of gl_ClipDistance if
- * we've already found it.
- */
- if (this->old_clip_distance_var)
+ if (!ir->name || strcmp(ir->name, "gl_ClipDistance") != 0)
return visit_continue;
+ assert (ir->type->is_array());
+
+ if (!ir->type->element_type()->is_array()) {
+ /* 1D gl_ClipDistance (used for vertex and geometry output, and fragment
+ * input).
+ */
+ if (this->old_clip_distance_1d_var)
+ return visit_continue;
- if (ir->name && strcmp(ir->name, "gl_ClipDistance") == 0) {
this->progress = true;
- this->old_clip_distance_var = ir;
- assert (ir->type->is_array());
+ this->old_clip_distance_1d_var = ir;
assert (ir->type->element_type() == glsl_type::float_type);
unsigned new_size = (ir->type->array_size() + 3) / 4;
/* Clone the old var so that we inherit all of its properties */
- this->new_clip_distance_var = ir->clone(ralloc_parent(ir), NULL);
+ this->new_clip_distance_1d_var = ir->clone(ralloc_parent(ir), NULL);
/* And change the properties that we need to change */
- this->new_clip_distance_var->name
- = ralloc_strdup(this->new_clip_distance_var, "gl_ClipDistanceMESA");
- this->new_clip_distance_var->type
+ this->new_clip_distance_1d_var->name
+ = ralloc_strdup(this->new_clip_distance_1d_var,
+ "gl_ClipDistanceMESA");
+ this->new_clip_distance_1d_var->type
= glsl_type::get_array_instance(glsl_type::vec4_type, new_size);
- this->new_clip_distance_var->max_array_access = ir->max_array_access / 4;
+ this->new_clip_distance_1d_var->max_array_access
+ = ir->max_array_access / 4;
+
+ ir->replace_with(this->new_clip_distance_1d_var);
+ } else {
+ /* 2D gl_ClipDistance (used for geometry input). */
+ assert(ir->mode == ir_var_shader_in &&
+ this->shader_type == GL_GEOMETRY_SHADER_ARB);
+ if (this->old_clip_distance_2d_var)
+ return visit_continue;
+
+ this->progress = true;
+ this->old_clip_distance_2d_var = ir;
+ assert (ir->type->element_type()->element_type() == glsl_type::float_type);
+ unsigned new_size = (ir->type->element_type()->array_size() + 3) / 4;
+
+ /* Clone the old var so that we inherit all of its properties */
+ this->new_clip_distance_2d_var = ir->clone(ralloc_parent(ir), NULL);
- ir->replace_with(this->new_clip_distance_var);
+ /* And change the properties that we need to change */
+ this->new_clip_distance_2d_var->name
+ = ralloc_strdup(this->new_clip_distance_2d_var, "gl_ClipDistanceMESA");
+ this->new_clip_distance_2d_var->type = glsl_type::get_array_instance(
+ glsl_type::get_array_instance(glsl_type::vec4_type,
+ new_size),
+ ir->type->array_size());
+ this->new_clip_distance_2d_var->max_array_access
+ = ir->max_array_access / 4;
+
+ ir->replace_with(this->new_clip_distance_2d_var);
}
return visit_continue;
}
@@ -180,39 +229,111 @@ lower_clip_distance_visitor::create_indices(ir_rvalue *old_index,
}
+/**
+ * Determine whether the given rvalue describes an array of 8 floats that
+ * needs to be lowered to an array of 2 vec4's; that is, determine whether it
+ * matches one of the following patterns:
+ *
+ * - gl_ClipDistance (if gl_ClipDistance is 1D)
+ * - gl_ClipDistance[i] (if gl_ClipDistance is 2D)
+ */
+bool
+lower_clip_distance_visitor::is_clip_distance_vec8(ir_rvalue *ir)
+{
+ /* Note that geometry shaders contain gl_ClipDistance both as an input
+ * (which is a 2D array) and an output (which is a 1D array), so it's
+ * possible for both this->old_clip_distance_1d_var and
+ * this->old_clip_distance_2d_var to be non-NULL in the same shader.
+ */
+
+ if (this->old_clip_distance_1d_var) {
+ ir_dereference_variable *var_ref = ir->as_dereference_variable();
+ if (var_ref && var_ref->var == this->old_clip_distance_1d_var)
+ return true;
+ }
+ if (this->old_clip_distance_2d_var) {
+ /* 2D clip distance is only possible as a geometry input */
+ assert(this->shader_type == GL_GEOMETRY_SHADER_ARB);
+
+ ir_dereference_array *array_ref = ir->as_dereference_array();
+ if (array_ref) {
+ ir_dereference_variable *var_ref =
+ array_ref->array->as_dereference_variable();
+ if (var_ref && var_ref->var == this->old_clip_distance_2d_var)
+ return true;
+ }
+ }
+ return false;
+}
+
+
+/**
+ * If the given ir satisfies is_clip_distance_vec8(), return new ir
+ * representing its lowered equivalent. That is, map:
+ *
+ * - gl_ClipDistance => gl_ClipDistanceMESA (if gl_ClipDistance is 1D)
+ * - gl_ClipDistance[i] => gl_ClipDistanceMESA[i] (if gl_ClipDistance is 2D)
+ *
+ * Otherwise return NULL.
+ */
+ir_rvalue *
+lower_clip_distance_visitor::lower_clip_distance_vec8(ir_rvalue *ir)
+{
+ if (this->old_clip_distance_1d_var) {
+ ir_dereference_variable *var_ref = ir->as_dereference_variable();
+ if (var_ref && var_ref->var == this->old_clip_distance_1d_var) {
+ return new(ralloc_parent(ir))
+ ir_dereference_variable(this->new_clip_distance_1d_var);
+ }
+ }
+ if (this->old_clip_distance_2d_var) {
+ /* 2D clip distance is only possible as a geometry input */
+ assert(this->shader_type == GL_GEOMETRY_SHADER_ARB);
+
+ ir_dereference_array *array_ref = ir->as_dereference_array();
+ if (array_ref) {
+ ir_dereference_variable *var_ref =
+ array_ref->array->as_dereference_variable();
+ if (var_ref && var_ref->var == this->old_clip_distance_2d_var) {
+ return new(ralloc_parent(ir))
+ ir_dereference_array(this->new_clip_distance_2d_var,
+ array_ref->array_index);
+ }
+ }
+ }
+ return NULL;
+}
+
+
void
lower_clip_distance_visitor::handle_rvalue(ir_rvalue **rv)
{
- /* If the gl_ClipDistance var hasn't been declared yet, then
- * there's no way this deref can refer to it.
- */
- if (!this->old_clip_distance_var || *rv == NULL)
+ if (*rv == NULL)
return;
ir_dereference_array *const array_deref = (*rv)->as_dereference_array();
if (array_deref == NULL)
return;
- /* Replace any expression that indexes into the gl_ClipDistance array
+ /* Replace any expression that indexes one of the floats in gl_ClipDistance
* with an expression that indexes into one of the vec4's in
* gl_ClipDistanceMESA and accesses the appropriate component.
*/
- ir_dereference_variable *old_var_ref =
- array_deref->array->as_dereference_variable();
- if (old_var_ref && old_var_ref->var == this->old_clip_distance_var) {
+ ir_rvalue *lowered_vec8 =
+ this->lower_clip_distance_vec8(array_deref->array);
+ if (lowered_vec8 != NULL) {
this->progress = true;
ir_rvalue *array_index;
ir_rvalue *swizzle_index;
this->create_indices(array_deref->array_index, array_index, swizzle_index);
void *mem_ctx = ralloc_parent(array_deref);
- ir_dereference_array *const ClipDistanceMESA_deref =
- new(mem_ctx) ir_dereference_array(this->new_clip_distance_var,
- array_index);
+ ir_dereference_array *const new_array_deref =
+ new(mem_ctx) ir_dereference_array(lowered_vec8, array_index);
ir_expression *const expr =
new(mem_ctx) ir_expression(ir_binop_vector_extract,
- ClipDistanceMESA_deref,
+ new_array_deref,
swizzle_index);
*rv = expr;
@@ -246,30 +367,34 @@ lower_clip_distance_visitor::fix_lhs(ir_assignment *ir)
}
/**
- * Replace any assignment having gl_ClipDistance (undereferenced) as its LHS
- * or RHS with a sequence of assignments, one for each component of the array.
- * Each of these assignments is lowered to refer to gl_ClipDistanceMESA as
- * appropriate.
+ * Replace any assignment having the 1D gl_ClipDistance (undereferenced) as
+ * its LHS or RHS with a sequence of assignments, one for each component of
+ * the array. Each of these assignments is lowered to refer to
+ * gl_ClipDistanceMESA as appropriate.
+ *
+ * We need to do a similar replacement for 2D gl_ClipDistance, however since
+ * it's an input, the only case we need to address is where a 1D slice of it
+ * is the entire RHS of an assignment, e.g.:
+ *
+ * foo = gl_in[i].gl_ClipDistance
*/
ir_visitor_status
lower_clip_distance_visitor::visit_leave(ir_assignment *ir)
{
- ir_dereference_variable *lhs_var = ir->lhs->as_dereference_variable();
- ir_dereference_variable *rhs_var = ir->rhs->as_dereference_variable();
- if ((lhs_var && lhs_var->var == this->old_clip_distance_var)
- || (rhs_var && rhs_var->var == this->old_clip_distance_var)) {
- /* LHS or RHS of the assignment is the entire gl_ClipDistance array.
- * Since we are reshaping gl_ClipDistance from an array of floats to an
- * array of vec4's, this isn't going to work as a bulk assignment
- * anymore, so unroll it to element-by-element assignments and lower
- * each of them.
+ if (this->is_clip_distance_vec8(ir->lhs) ||
+ this->is_clip_distance_vec8(ir->rhs)) {
+ /* LHS or RHS of the assignment is the entire 1D gl_ClipDistance array
+ * (or a 1D slice of a 2D gl_ClipDistance input array). Since we are
+ * reshaping gl_ClipDistance from an array of floats to an array of
+ * vec4's, this isn't going to work as a bulk assignment anymore, so
+ * unroll it to element-by-element assignments and lower each of them.
*
* Note: to unroll into element-by-element assignments, we need to make
* clones of the LHS and RHS. This is safe because expressions and
* l-values are side-effect free.
*/
void *ctx = ralloc_parent(ir);
- int array_size = this->old_clip_distance_var->type->array_size();
+ int array_size = ir->lhs->type->array_size();
for (int i = 0; i < array_size; ++i) {
ir_dereference_array *new_lhs = new(ctx) ir_dereference_array(
ir->lhs->clone(ctx, NULL), new(ctx) ir_constant(i));
@@ -329,11 +454,17 @@ lower_clip_distance_visitor::visit_new_assignment(ir_assignment *ir)
/**
- * If gl_ClipDistance appears as an argument in an ir_call expression, replace
- * it with a temporary variable, and make sure the ir_call is preceded and/or
- * followed by assignments that copy the contents of the temporary variable to
- * and/or from gl_ClipDistance. Each of these assignments is then lowered to
- * refer to gl_ClipDistanceMESA.
+ * If a 1D gl_ClipDistance variable appears as an argument in an ir_call
+ * expression, replace it with a temporary variable, and make sure the ir_call
+ * is preceded and/or followed by assignments that copy the contents of the
+ * temporary variable to and/or from gl_ClipDistance. Each of these
+ * assignments is then lowered to refer to gl_ClipDistanceMESA.
+ *
+ * We need to do a similar replacement for 2D gl_ClipDistance, however since
+ * it's an input, the only case we need to address is where a 1D slice of it
+ * is passed as an "in" parameter to an ir_call, e.g.:
+ *
+ * foo(gl_in[i].gl_ClipDistance)
*/
ir_visitor_status
lower_clip_distance_visitor::visit_leave(ir_call *ir)
@@ -352,12 +483,12 @@ lower_clip_distance_visitor::visit_leave(ir_call *ir)
formal_param_node = formal_param_node->next;
actual_param_node = actual_param_node->next;
- ir_dereference_variable *deref = actual_param->as_dereference_variable();
- if (deref && deref->var == this->old_clip_distance_var) {
- /* User is trying to pass the whole gl_ClipDistance array to a
- * function call. Since we are reshaping gl_ClipDistance from an
- * array of floats to an array of vec4's, this isn't going to work
- * anymore, so use a temporary array instead.
+ if (this->is_clip_distance_vec8(actual_param)) {
+ /* User is trying to pass the whole 1D gl_ClipDistance array (or a 1D
+ * slice of a 2D gl_ClipDistance array) to a function call. Since we
+ * are reshaping gl_ClipDistance from an array of floats to an array
+ * of vec4's, this isn't going to work anymore, so use a temporary
+ * array instead.
*/
ir_variable *temp_clip_distance = new(ctx) ir_variable(
actual_param->type, "temp_clip_distance", ir_var_temporary);
@@ -373,7 +504,7 @@ lower_clip_distance_visitor::visit_leave(ir_call *ir)
*/
ir_assignment *new_assignment = new(ctx) ir_assignment(
new(ctx) ir_dereference_variable(temp_clip_distance),
- new(ctx) ir_dereference_variable(old_clip_distance_var));
+ actual_param->clone(ctx, NULL));
this->base_ir->insert_before(new_assignment);
this->visit_new_assignment(new_assignment);
}
@@ -385,7 +516,7 @@ lower_clip_distance_visitor::visit_leave(ir_call *ir)
* afterwards to make sure it gets lowered.
*/
ir_assignment *new_assignment = new(ctx) ir_assignment(
- new(ctx) ir_dereference_variable(old_clip_distance_var),
+ actual_param->clone(ctx, NULL),
new(ctx) ir_dereference_variable(temp_clip_distance));
this->base_ir->insert_after(new_assignment);
this->visit_new_assignment(new_assignment);
@@ -400,12 +531,14 @@ lower_clip_distance_visitor::visit_leave(ir_call *ir)
bool
lower_clip_distance(gl_shader *shader)
{
- lower_clip_distance_visitor v;
+ lower_clip_distance_visitor v(shader->Type);
visit_list_elements(&v, shader->ir);
- if (v.new_clip_distance_var)
- shader->symbols->add_variable(v.new_clip_distance_var);
+ if (v.new_clip_distance_1d_var)
+ shader->symbols->add_variable(v.new_clip_distance_1d_var);
+ if (v.new_clip_distance_2d_var)
+ shader->symbols->add_variable(v.new_clip_distance_2d_var);
return v.progress;
}
diff --git a/mesalib/src/glsl/lower_named_interface_blocks.cpp b/mesalib/src/glsl/lower_named_interface_blocks.cpp
index 7019185a2..f415252ba 100644
--- a/mesalib/src/glsl/lower_named_interface_blocks.cpp
+++ b/mesalib/src/glsl/lower_named_interface_blocks.cpp
@@ -150,8 +150,9 @@ flatten_named_interface_blocks_declarations::run(exec_list *instructions)
var_name,
(ir_variable_mode) var->mode);
}
+ new_var->location = iface_t->fields.structure[i].location;
- new_var->interface_type = iface_t;
+ new_var->init_interface_type(iface_t);
hash_table_insert(interface_namespace, new_var,
iface_field_name);
insert_pos->insert_after(new_var);
@@ -207,9 +208,9 @@ flatten_named_interface_blocks_declarations::handle_rvalue(ir_rvalue **rvalue)
if (var->mode == ir_var_uniform)
return;
- if (var->interface_type != NULL) {
+ if (var->get_interface_type() != NULL) {
char *iface_field_name =
- ralloc_asprintf(mem_ctx, "%s.%s", var->interface_type->name,
+ ralloc_asprintf(mem_ctx, "%s.%s", var->get_interface_type()->name,
ir->field);
/* Find the variable in the set of flattened interface blocks */
ir_variable *found_var =
diff --git a/mesalib/src/glsl/lower_ubo_reference.cpp b/mesalib/src/glsl/lower_ubo_reference.cpp
index aade203e7..16b6801b8 100644
--- a/mesalib/src/glsl/lower_ubo_reference.cpp
+++ b/mesalib/src/glsl/lower_ubo_reference.cpp
@@ -132,7 +132,8 @@ lower_ubo_reference_visitor::handle_rvalue(ir_rvalue **rvalue)
mem_ctx = ralloc_parent(*rvalue);
const char *const field_name =
- interface_field_name(mem_ctx, (char *) var->interface_type->name, deref);
+ interface_field_name(mem_ctx, (char *) var->get_interface_type()->name,
+ deref);
this->uniform_block = -1;
for (unsigned i = 0; i < shader->NumUniformBlocks; i++) {
diff --git a/mesalib/src/glsl/main.cpp b/mesalib/src/glsl/main.cpp
index b4df1d055..4a5570608 100644
--- a/mesalib/src/glsl/main.cpp
+++ b/mesalib/src/glsl/main.cpp
@@ -49,6 +49,8 @@
#include "loop_analysis.h"
#include "standalone_scaffolding.h"
+static int glsl_version = 330;
+
static void
initialize_context(struct gl_context *ctx, gl_api api)
{
@@ -57,16 +59,150 @@ initialize_context(struct gl_context *ctx, gl_api api)
/* The standalone compiler needs to claim support for almost
* everything in order to compile the built-in functions.
*/
- ctx->Const.GLSLVersion = 330;
+ ctx->Const.GLSLVersion = glsl_version;
ctx->Extensions.ARB_ES3_compatibility = true;
- ctx->Const.MaxClipPlanes = 8;
- ctx->Const.MaxDrawBuffers = 2;
-
- /* More than the 1.10 minimum to appease parser tests taken from
- * apps that (hopefully) already checked the number of coords.
- */
- ctx->Const.MaxTextureCoordUnits = 4;
+ switch (ctx->Const.GLSLVersion) {
+ case 100:
+ ctx->Const.MaxClipPlanes = 0;
+ ctx->Const.MaxCombinedTextureImageUnits = 8;
+ ctx->Const.MaxDrawBuffers = 2;
+ ctx->Const.MinProgramTexelOffset = 0;
+ ctx->Const.MaxProgramTexelOffset = 0;
+ ctx->Const.MaxLights = 0;
+ ctx->Const.MaxTextureCoordUnits = 0;
+ ctx->Const.MaxTextureUnits = 8;
+
+ ctx->Const.VertexProgram.MaxAttribs = 8;
+ ctx->Const.VertexProgram.MaxTextureImageUnits = 0;
+ ctx->Const.VertexProgram.MaxUniformComponents = 128 * 4;
+ ctx->Const.VertexProgram.MaxInputComponents = 0; /* not used */
+ ctx->Const.VertexProgram.MaxOutputComponents = 32;
+
+ ctx->Const.FragmentProgram.MaxTextureImageUnits =
+ ctx->Const.MaxCombinedTextureImageUnits;
+ ctx->Const.FragmentProgram.MaxUniformComponents = 16 * 4;
+ ctx->Const.FragmentProgram.MaxInputComponents =
+ ctx->Const.VertexProgram.MaxOutputComponents;
+ ctx->Const.FragmentProgram.MaxOutputComponents = 0; /* not used */
+
+ ctx->Const.MaxVarying = ctx->Const.VertexProgram.MaxOutputComponents / 4;
+ break;
+ case 110:
+ case 120:
+ ctx->Const.MaxClipPlanes = 6;
+ ctx->Const.MaxCombinedTextureImageUnits = 2;
+ ctx->Const.MaxDrawBuffers = 1;
+ ctx->Const.MinProgramTexelOffset = 0;
+ ctx->Const.MaxProgramTexelOffset = 0;
+ ctx->Const.MaxLights = 8;
+ ctx->Const.MaxTextureCoordUnits = 2;
+ ctx->Const.MaxTextureUnits = 2;
+
+ ctx->Const.VertexProgram.MaxAttribs = 16;
+ ctx->Const.VertexProgram.MaxTextureImageUnits = 0;
+ ctx->Const.VertexProgram.MaxUniformComponents = 512;
+ ctx->Const.VertexProgram.MaxInputComponents = 0; /* not used */
+ ctx->Const.VertexProgram.MaxOutputComponents = 32;
+
+ ctx->Const.FragmentProgram.MaxTextureImageUnits =
+ ctx->Const.MaxCombinedTextureImageUnits;
+ ctx->Const.FragmentProgram.MaxUniformComponents = 64;
+ ctx->Const.FragmentProgram.MaxInputComponents =
+ ctx->Const.VertexProgram.MaxOutputComponents;
+ ctx->Const.FragmentProgram.MaxOutputComponents = 0; /* not used */
+
+ ctx->Const.MaxVarying = ctx->Const.VertexProgram.MaxOutputComponents / 4;
+ break;
+ case 130:
+ case 140:
+ ctx->Const.MaxClipPlanes = 8;
+ ctx->Const.MaxCombinedTextureImageUnits = 16;
+ ctx->Const.MaxDrawBuffers = 8;
+ ctx->Const.MinProgramTexelOffset = -8;
+ ctx->Const.MaxProgramTexelOffset = 7;
+ ctx->Const.MaxLights = 8;
+ ctx->Const.MaxTextureCoordUnits = 8;
+ ctx->Const.MaxTextureUnits = 2;
+
+ ctx->Const.VertexProgram.MaxAttribs = 16;
+ ctx->Const.VertexProgram.MaxTextureImageUnits = 16;
+ ctx->Const.VertexProgram.MaxUniformComponents = 1024;
+ ctx->Const.VertexProgram.MaxInputComponents = 0; /* not used */
+ ctx->Const.VertexProgram.MaxOutputComponents = 64;
+
+ ctx->Const.FragmentProgram.MaxTextureImageUnits = 16;
+ ctx->Const.FragmentProgram.MaxUniformComponents = 1024;
+ ctx->Const.FragmentProgram.MaxInputComponents =
+ ctx->Const.VertexProgram.MaxOutputComponents;
+ ctx->Const.FragmentProgram.MaxOutputComponents = 0; /* not used */
+
+ ctx->Const.MaxVarying = ctx->Const.VertexProgram.MaxOutputComponents / 4;
+ break;
+ case 150:
+ case 330:
+ ctx->Const.MaxClipPlanes = 8;
+ ctx->Const.MaxDrawBuffers = 8;
+ ctx->Const.MinProgramTexelOffset = -8;
+ ctx->Const.MaxProgramTexelOffset = 7;
+ ctx->Const.MaxLights = 8;
+ ctx->Const.MaxTextureCoordUnits = 8;
+ ctx->Const.MaxTextureUnits = 2;
+
+ ctx->Const.VertexProgram.MaxAttribs = 16;
+ ctx->Const.VertexProgram.MaxTextureImageUnits = 16;
+ ctx->Const.VertexProgram.MaxUniformComponents = 1024;
+ ctx->Const.VertexProgram.MaxInputComponents = 0; /* not used */
+ ctx->Const.VertexProgram.MaxOutputComponents = 64;
+
+ ctx->Const.GeometryProgram.MaxTextureImageUnits = 16;
+ ctx->Const.GeometryProgram.MaxUniformComponents = 1024;
+ ctx->Const.GeometryProgram.MaxInputComponents =
+ ctx->Const.VertexProgram.MaxOutputComponents;
+ ctx->Const.GeometryProgram.MaxOutputComponents = 128;
+
+ ctx->Const.FragmentProgram.MaxTextureImageUnits = 16;
+ ctx->Const.FragmentProgram.MaxUniformComponents = 1024;
+ ctx->Const.FragmentProgram.MaxInputComponents =
+ ctx->Const.GeometryProgram.MaxOutputComponents;
+ ctx->Const.FragmentProgram.MaxOutputComponents = 0; /* not used */
+
+ ctx->Const.MaxCombinedTextureImageUnits =
+ ctx->Const.VertexProgram.MaxTextureImageUnits
+ + ctx->Const.GeometryProgram.MaxTextureImageUnits
+ + ctx->Const.FragmentProgram.MaxTextureImageUnits;
+
+ ctx->Const.MaxGeometryOutputVertices = 256;
+ ctx->Const.MaxGeometryTotalOutputComponents = 1024;
+
+// ctx->Const.MaxGeometryVaryingComponents = 64;
+
+ ctx->Const.MaxVarying = 60 / 4;
+ break;
+ case 300:
+ ctx->Const.MaxClipPlanes = 8;
+ ctx->Const.MaxCombinedTextureImageUnits = 32;
+ ctx->Const.MaxDrawBuffers = 4;
+ ctx->Const.MinProgramTexelOffset = -8;
+ ctx->Const.MaxProgramTexelOffset = 7;
+ ctx->Const.MaxLights = 0;
+ ctx->Const.MaxTextureCoordUnits = 0;
+ ctx->Const.MaxTextureUnits = 0;
+
+ ctx->Const.VertexProgram.MaxAttribs = 16;
+ ctx->Const.VertexProgram.MaxTextureImageUnits = 16;
+ ctx->Const.VertexProgram.MaxUniformComponents = 1024;
+ ctx->Const.VertexProgram.MaxInputComponents = 0; /* not used */
+ ctx->Const.VertexProgram.MaxOutputComponents = 16 * 4;
+
+ ctx->Const.FragmentProgram.MaxTextureImageUnits = 16;
+ ctx->Const.FragmentProgram.MaxUniformComponents = 224;
+ ctx->Const.FragmentProgram.MaxInputComponents = 15 * 4;
+ ctx->Const.FragmentProgram.MaxOutputComponents = 0; /* not used */
+
+ ctx->Const.MaxVarying = ctx->Const.FragmentProgram.MaxInputComponents / 4;
+ break;
+ }
ctx->Driver.NewShader = _mesa_new_shader;
}
@@ -114,18 +250,17 @@ load_text_file(void *ctx, const char *file_name)
return text;
}
-int glsl_es = 0;
int dump_ast = 0;
int dump_hir = 0;
int dump_lir = 0;
int do_link = 0;
const struct option compiler_opts[] = {
- { "glsl-es", 0, &glsl_es, 1 },
- { "dump-ast", 0, &dump_ast, 1 },
- { "dump-hir", 0, &dump_hir, 1 },
- { "dump-lir", 0, &dump_lir, 1 },
- { "link", 0, &do_link, 1 },
+ { "dump-ast", no_argument, &dump_ast, 1 },
+ { "dump-hir", no_argument, &dump_hir, 1 },
+ { "dump-lir", no_argument, &dump_lir, 1 },
+ { "link", no_argument, &do_link, 1 },
+ { "version", required_argument, NULL, 'v' },
{ NULL, 0, NULL, 0 }
};
@@ -170,11 +305,37 @@ main(int argc, char **argv)
int status = EXIT_SUCCESS;
struct gl_context local_ctx;
struct gl_context *ctx = &local_ctx;
+ bool glsl_es = false;
int c;
int idx = 0;
- while ((c = getopt_long(argc, argv, "", compiler_opts, &idx)) != -1)
- /* empty */ ;
+ while ((c = getopt_long(argc, argv, "", compiler_opts, &idx)) != -1) {
+ switch (c) {
+ case 'v':
+ glsl_version = strtol(optarg, NULL, 10);
+ switch (glsl_version) {
+ case 100:
+ case 300:
+ glsl_es = true;
+ break;
+ case 110:
+ case 120:
+ case 130:
+ case 140:
+ case 150:
+ case 330:
+ glsl_es = false;
+ break;
+ default:
+ fprintf(stderr, "Unrecognized GLSL version `%s'\n", optarg);
+ usage_fail(argv[0]);
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ }
if (argc <= optind)
@@ -221,8 +382,10 @@ main(int argc, char **argv)
compile_shader(ctx, shader);
- if (!shader->CompileStatus) {
+ if (strlen(shader->InfoLog) > 0)
printf("Info log for %s:\n%s\n", argv[optind], shader->InfoLog);
+
+ if (!shader->CompileStatus) {
status = EXIT_FAILURE;
break;
}
diff --git a/mesalib/src/glsl/standalone_scaffolding.cpp b/mesalib/src/glsl/standalone_scaffolding.cpp
index 3b64f2cfc..7a1cf6877 100644
--- a/mesalib/src/glsl/standalone_scaffolding.cpp
+++ b/mesalib/src/glsl/standalone_scaffolding.cpp
@@ -90,23 +90,33 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api)
ctx->Extensions.dummy_false = false;
ctx->Extensions.dummy_true = true;
- ctx->Extensions.ARB_ES2_compatibility = true;
- ctx->Extensions.ARB_ES3_compatibility = false;
+ ctx->Extensions.ARB_conservative_depth = true;
ctx->Extensions.ARB_draw_instanced = true;
+ ctx->Extensions.ARB_ES2_compatibility = true;
+ ctx->Extensions.ARB_ES3_compatibility = true;
+ ctx->Extensions.ARB_explicit_attrib_location = true;
ctx->Extensions.ARB_fragment_coord_conventions = true;
- ctx->Extensions.EXT_texture_array = true;
- ctx->Extensions.NV_texture_rectangle = true;
- ctx->Extensions.EXT_texture3D = true;
- ctx->Extensions.OES_EGL_image_external = true;
+ ctx->Extensions.ARB_gpu_shader5 = true;
ctx->Extensions.ARB_shader_bit_encoding = true;
+ ctx->Extensions.ARB_shader_stencil_export = true;
+ ctx->Extensions.ARB_shader_texture_lod = true;
+ ctx->Extensions.ARB_shading_language_420pack = true;
ctx->Extensions.ARB_shading_language_packing = true;
- ctx->Extensions.OES_standard_derivatives = true;
ctx->Extensions.ARB_texture_cube_map_array = true;
+ ctx->Extensions.ARB_texture_gather = true;
ctx->Extensions.ARB_texture_multisample = true;
ctx->Extensions.ARB_texture_query_levels = true;
ctx->Extensions.ARB_texture_query_lod = true;
- ctx->Extensions.ARB_gpu_shader5 = true;
- ctx->Extensions.ARB_texture_gather = true;
+ ctx->Extensions.ARB_uniform_buffer_object = true;
+
+ ctx->Extensions.OES_EGL_image_external = true;
+ ctx->Extensions.OES_standard_derivatives = true;
+
+ ctx->Extensions.EXT_shader_integer_mix = true;
+ ctx->Extensions.EXT_texture3D = true;
+ ctx->Extensions.EXT_texture_array = true;
+
+ ctx->Extensions.NV_texture_rectangle = true;
ctx->Const.GLSLVersion = 120;
diff --git a/mesalib/src/mapi/glapi/gen/gl_API.xml b/mesalib/src/mapi/glapi/gen/gl_API.xml
index c78d7b9bb..0c78c5208 100755
--- a/mesalib/src/mapi/glapi/gen/gl_API.xml
+++ b/mesalib/src/mapi/glapi/gen/gl_API.xml
@@ -5495,7 +5495,7 @@
<function name="GetProgramiv" offset="assign" es2="2.0">
<param name="program" type="GLuint"/>
<param name="pname" type="GLenum"/>
- <param name="params" type="GLint *"/>
+ <param name="params" type="GLint *" output="true"/>
<glx ignore="true"/>
</function>
diff --git a/mesalib/src/mapi/glapi/gen/gl_gentable.py b/mesalib/src/mapi/glapi/gen/gl_gentable.py
index ee7d63f5f..fb0228939 100755
--- a/mesalib/src/mapi/glapi/gen/gl_gentable.py
+++ b/mesalib/src/mapi/glapi/gen/gl_gentable.py
@@ -42,7 +42,7 @@ header = """/* GLXEXT is the define used in the xserver when the GLX extension i
#endif
#if (defined(GLXEXT) && defined(HAVE_BACKTRACE)) \\
- || (!defined(GLXEXT) && defined(DEBUG) && !defined(_WIN32_WCE) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__OpenBSD__))
+ || (!defined(GLXEXT) && defined(DEBUG) && !defined(_WIN32_WCE) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__OpenBSD__) && !defined(__NetBSD__))
#define USE_BACKTRACE
#endif
diff --git a/mesalib/src/mesa/drivers/SConscript b/mesalib/src/mesa/drivers/SConscript
index 6dcc50655..355e6807a 100644
--- a/mesalib/src/mesa/drivers/SConscript
+++ b/mesalib/src/mesa/drivers/SConscript
@@ -5,7 +5,7 @@ SConscript('osmesa/SConscript')
if env['x11']:
SConscript('x11/SConscript')
-if env['drm']:
+if env['dri']:
SConscript('dri/common/xmlpool/SConscript')
if env['platform'] == 'windows':
diff --git a/mesalib/src/mesa/drivers/dri/Makefile.am b/mesalib/src/mesa/drivers/dri/Makefile.am
index 48d36858b..7fa0ad73d 100644
--- a/mesalib/src/mesa/drivers/dri/Makefile.am
+++ b/mesalib/src/mesa/drivers/dri/Makefile.am
@@ -1,8 +1,6 @@
SUBDIRS =
-if HAVE_COMMON_DRI
SUBDIRS+=common
-endif
if HAVE_I915_DRI
SUBDIRS+=i915
diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.c b/mesalib/src/mesa/drivers/dri/common/dri_util.c
index fa520ea90..db44eede6 100644
--- a/mesalib/src/mesa/drivers/dri/common/dri_util.c
+++ b/mesalib/src/mesa/drivers/dri/common/dri_util.c
@@ -39,11 +39,17 @@
*/
+#include <stdbool.h>
+#ifndef __NOT_HAVE_DRM_H
#include <xf86drm.h>
+#endif
#include "dri_util.h"
#include "utils.h"
#include "xmlpool.h"
#include "../glsl/glsl_parser_extras.h"
+#include "main/mtypes.h"
+#include "main/version.h"
+#include "main/macros.h"
PUBLIC const char __dri2ConfigOptions[] =
DRI_CONF_BEGIN
@@ -70,9 +76,18 @@ setupLoaderExtensions(__DRIscreen *psp,
psp->dri2.image = (__DRIimageLookupExtension *) extensions[i];
if (strcmp(extensions[i]->name, __DRI_USE_INVALIDATE) == 0)
psp->dri2.useInvalidate = (__DRIuseInvalidateExtension *) extensions[i];
+ if (strcmp(extensions[i]->name, __DRI_SWRAST_LOADER) == 0)
+ psp->swrast_loader = (__DRIswrastLoaderExtension *) extensions[i];
}
}
+/**
+ * This is the first entrypoint in the driver called by the DRI driver loader
+ * after dlopen()ing it.
+ *
+ * It's used to create global state for the driver across contexts on the same
+ * Display.
+ */
static __DRIscreen *
dri2CreateNewScreen(int scrn, int fd,
const __DRIextension **extensions,
@@ -80,21 +95,26 @@ dri2CreateNewScreen(int scrn, int fd,
{
static const __DRIextension *emptyExtensionList[] = { NULL };
__DRIscreen *psp;
- drmVersionPtr version;
psp = calloc(1, sizeof(*psp));
if (!psp)
return NULL;
+ psp->driver = &driDriverAPI;
+
setupLoaderExtensions(psp, extensions);
- version = drmGetVersion(fd);
- if (version) {
- psp->drm_version.major = version->version_major;
- psp->drm_version.minor = version->version_minor;
- psp->drm_version.patch = version->version_patchlevel;
- drmFreeVersion(version);
+#ifndef __NOT_HAVE_DRM_H
+ if (fd != -1) {
+ drmVersionPtr version = drmGetVersion(fd);
+ if (version) {
+ psp->drm_version.major = version->version_major;
+ psp->drm_version.minor = version->version_minor;
+ psp->drm_version.patch = version->version_patchlevel;
+ drmFreeVersion(version);
+ }
}
+#endif
psp->loaderPrivate = data;
@@ -102,20 +122,46 @@ dri2CreateNewScreen(int scrn, int fd,
psp->fd = fd;
psp->myNum = scrn;
- psp->api_mask = (1 << __DRI_API_OPENGL);
-
- *driver_configs = driDriverAPI.InitScreen(psp);
+ *driver_configs = psp->driver->InitScreen(psp);
if (*driver_configs == NULL) {
free(psp);
return NULL;
}
+ int gl_version_override = _mesa_get_gl_version_override();
+ if (gl_version_override >= 31) {
+ psp->max_gl_core_version = MAX2(psp->max_gl_core_version,
+ gl_version_override);
+ } else {
+ psp->max_gl_compat_version = MAX2(psp->max_gl_compat_version,
+ gl_version_override);
+ }
+
+ psp->api_mask = (1 << __DRI_API_OPENGL);
+ if (psp->max_gl_core_version > 0)
+ psp->api_mask |= (1 << __DRI_API_OPENGL_CORE);
+ if (psp->max_gl_es1_version > 0)
+ psp->api_mask |= (1 << __DRI_API_GLES);
+ if (psp->max_gl_es2_version > 0)
+ psp->api_mask |= (1 << __DRI_API_GLES2);
+ if (psp->max_gl_es2_version >= 30)
+ psp->api_mask |= (1 << __DRI_API_GLES3);
+
driParseOptionInfo(&psp->optionInfo, __dri2ConfigOptions);
driParseConfigFiles(&psp->optionCache, &psp->optionInfo, psp->myNum, "dri2");
+
return psp;
}
+/** swrast driver createNewScreen entrypoint. */
+static __DRIscreen *
+driCreateNewScreen(int scrn, const __DRIextension **extensions,
+ const __DRIconfig ***driver_configs, void *data)
+{
+ return dri2CreateNewScreen(scrn, -1, extensions, driver_configs, data);
+}
+
/**
* Destroy the per-screen private information.
*
@@ -133,7 +179,7 @@ static void driDestroyScreen(__DRIscreen *psp)
_mesa_destroy_shader_compiler();
- driDriverAPI.DestroyScreen(psp);
+ psp->driver->DestroyScreen(psp);
driDestroyOptionCache(&psp->optionCache);
driDestroyOptionInfo(&psp->optionInfo);
@@ -150,6 +196,45 @@ static const __DRIextension **driGetExtensions(__DRIscreen *psp)
/*@}*/
+static bool
+validate_context_version(__DRIscreen *screen,
+ int mesa_api,
+ unsigned major_version,
+ unsigned minor_version,
+ unsigned *dri_ctx_error)
+{
+ unsigned req_version = 10 * major_version + minor_version;
+ unsigned max_version = 0;
+
+ switch (mesa_api) {
+ case API_OPENGL_COMPAT:
+ max_version = screen->max_gl_compat_version;
+ break;
+ case API_OPENGL_CORE:
+ max_version = screen->max_gl_core_version;
+ break;
+ case API_OPENGLES:
+ max_version = screen->max_gl_es1_version;
+ break;
+ case API_OPENGLES2:
+ max_version = screen->max_gl_es2_version;
+ break;
+ default:
+ max_version = 0;
+ break;
+ }
+
+ if (max_version == 0) {
+ *dri_ctx_error = __DRI_CTX_ERROR_BAD_API;
+ return false;
+ } else if (req_version > max_version) {
+ *dri_ctx_error = __DRI_CTX_ERROR_BAD_VERSION;
+ return false;
+ }
+
+ return true;
+}
+
/*****************************************************************/
/** \name Context handling functions */
/*****************************************************************/
@@ -271,6 +356,10 @@ dri2CreateContextAttribs(__DRIscreen *screen, int api,
return NULL;
}
+ if (!validate_context_version(screen, mesa_api,
+ major_version, minor_version, error))
+ return NULL;
+
context = calloc(1, sizeof *context);
if (!context) {
*error = __DRI_CTX_ERROR_NO_MEMORY;
@@ -283,13 +372,21 @@ dri2CreateContextAttribs(__DRIscreen *screen, int api,
context->driDrawablePriv = NULL;
context->driReadablePriv = NULL;
- if (!driDriverAPI.CreateContext(mesa_api, modes, context,
- major_version, minor_version,
- flags, error, shareCtx) ) {
+ if (!screen->driver->CreateContext(mesa_api, modes, context,
+ major_version, minor_version,
+ flags, error, shareCtx) ) {
free(context);
return NULL;
}
+ struct gl_context *ctx = context->driverPrivate;
+ if ((flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0)
+ ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
+ if ((flags & __DRI_CTX_FLAG_DEBUG) != 0) {
+ ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_DEBUG_BIT;
+ ctx->Debug.DebugOutput = GL_TRUE;
+ }
+
*error = __DRI_CTX_ERROR_SUCCESS;
return context;
}
@@ -324,7 +421,7 @@ static void
driDestroyContext(__DRIcontext *pcp)
{
if (pcp) {
- driDriverAPI.DestroyContext(pcp);
+ pcp->driScreenPriv->driver->DestroyContext(pcp);
free(pcp);
}
}
@@ -377,7 +474,7 @@ static int driBindContext(__DRIcontext *pcp,
dri_get_drawable(prp);
}
- return driDriverAPI.MakeCurrent(pcp, pdp, prp);
+ return pcp->driScreenPriv->driver->MakeCurrent(pcp, pdp, prp);
}
/**
@@ -416,7 +513,7 @@ static int driUnbindContext(__DRIcontext *pcp)
if (!pdp && !prp)
return GL_TRUE;
- driDriverAPI.UnbindContext(pcp);
+ pcp->driScreenPriv->driver->UnbindContext(pcp);
assert(pdp);
if (pdp->refcount == 0) {
@@ -435,10 +532,6 @@ static int driUnbindContext(__DRIcontext *pcp)
dri_put_drawable(prp);
}
- /* XXX this is disabled so that if we call SwapBuffers on an unbound
- * window we can determine the last context bound to the window and
- * use that context's lock. (BrianP, 2-Dec-2000)
- */
pcp->driDrawablePriv = NULL;
pcp->driReadablePriv = NULL;
@@ -460,7 +553,7 @@ static void dri_put_drawable(__DRIdrawable *pdp)
if (pdp->refcount)
return;
- driDriverAPI.DestroyBuffer(pdp);
+ pdp->driScreenPriv->driver->DestroyBuffer(pdp);
free(pdp);
}
}
@@ -487,7 +580,8 @@ dri2CreateNewDrawable(__DRIscreen *screen,
dri_get_drawable(pdraw);
- if (!driDriverAPI.CreateBuffer(screen, pdraw, &config->modes, GL_FALSE)) {
+ if (!screen->driver->CreateBuffer(screen, pdraw, &config->modes,
+ GL_FALSE)) {
free(pdraw);
return NULL;
}
@@ -508,14 +602,14 @@ dri2AllocateBuffer(__DRIscreen *screen,
unsigned int attachment, unsigned int format,
int width, int height)
{
- return driDriverAPI.AllocateBuffer(screen, attachment, format,
- width, height);
+ return screen->driver->AllocateBuffer(screen, attachment, format,
+ width, height);
}
static void
dri2ReleaseBuffer(__DRIscreen *screen, __DRIbuffer *buffer)
{
- driDriverAPI.ReleaseBuffer(screen, buffer);
+ screen->driver->ReleaseBuffer(screen, buffer);
}
@@ -559,6 +653,19 @@ dri2GetAPIMask(__DRIscreen *screen)
return screen->api_mask;
}
+/**
+ * swrast swapbuffers entrypoint.
+ *
+ * DRI2 implements this inside the loader with only flushes handled by the
+ * driver.
+ */
+static void
+driSwapBuffers(__DRIdrawable *pdp)
+{
+ assert(pdp->driScreenPriv->swrast_loader);
+
+ pdp->driScreenPriv->driver->SwapBuffers(pdp);
+}
/** Core interface */
const __DRIcoreExtension driCoreExtension = {
@@ -571,8 +678,8 @@ const __DRIcoreExtension driCoreExtension = {
.indexConfigAttrib = driIndexConfigAttrib,
.createNewDrawable = NULL,
.destroyDrawable = driDestroyDrawable,
- .swapBuffers = NULL,
- .createNewContext = NULL,
+ .swapBuffers = driSwapBuffers, /* swrast */
+ .createNewContext = dri2CreateNewContext, /* swrast */
.copyContext = driCopyContext,
.destroyContext = driDestroyContext,
.bindContext = driBindContext,
@@ -593,6 +700,14 @@ const __DRIdri2Extension driDRI2Extension = {
.createContextAttribs = dri2CreateContextAttribs
};
+const __DRIswrastExtension driSWRastExtension = {
+ { __DRI_SWRAST, __DRI_SWRAST_VERSION },
+ driCreateNewScreen,
+ dri2CreateNewDrawable,
+ dri2CreateNewContextForAPI,
+ dri2CreateContextAttribs
+};
+
const __DRI2configQueryExtension dri2ConfigQueryExtension = {
.base = { __DRI2_CONFIG_QUERY, __DRI2_CONFIG_QUERY_VERSION },
diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.h b/mesalib/src/mesa/drivers/dri/common/dri_util.h
index 900f04853..61c80bc45 100644
--- a/mesalib/src/mesa/drivers/dri/common/dri_util.h
+++ b/mesalib/src/mesa/drivers/dri/common/dri_util.h
@@ -123,6 +123,12 @@ extern const struct __DriverAPIRec driDriverAPI;
*/
struct __DRIscreenRec {
/**
+ * Driver-specific entrypoints provided by the driver's
+ * __DRIDriverVtableExtensionRec.
+ */
+ const struct __DriverAPIRec *driver;
+
+ /**
* Current screen's number
*/
int myNum;
@@ -151,6 +157,11 @@ struct __DRIscreenRec {
void *loaderPrivate;
+ int max_gl_core_version;
+ int max_gl_compat_version;
+ int max_gl_es1_version;
+ int max_gl_es2_version;
+
const __DRIextension **extensions;
const __DRIswrastLoaderExtension *swrast_loader;
diff --git a/mesalib/src/mesa/drivers/dri/common/drisw_util.c b/mesalib/src/mesa/drivers/dri/common/drisw_util.c
deleted file mode 100644
index e8bac6414..000000000
--- a/mesalib/src/mesa/drivers/dri/common/drisw_util.c
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- * Copyright 2010 George Sapountzis <gsapountzis@gmail.com>
- *
- * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * \file drisw_util.c
- *
- * DRISW utility functions, i.e. dri_util.c stripped from drm-specific bits.
- */
-
-#include "dri_util.h"
-#include "utils.h"
-
-
-/**
- * Screen functions
- */
-
-static void
-setupLoaderExtensions(__DRIscreen *psp,
- const __DRIextension **extensions)
-{
- int i;
-
- for (i = 0; extensions[i]; i++) {
- if (strcmp(extensions[i]->name, __DRI_SWRAST_LOADER) == 0)
- psp->swrast_loader = (__DRIswrastLoaderExtension *) extensions[i];
- }
-}
-
-static __DRIscreen *
-driCreateNewScreen(int scrn, const __DRIextension **extensions,
- const __DRIconfig ***driver_configs, void *data)
-{
- static const __DRIextension *emptyExtensionList[] = { NULL };
- __DRIscreen *psp;
-
- psp = CALLOC_STRUCT(__DRIscreenRec);
- if (!psp)
- return NULL;
-
- setupLoaderExtensions(psp, extensions);
-
- psp->loaderPrivate = data;
-
- psp->extensions = emptyExtensionList;
- psp->fd = -1;
- psp->myNum = scrn;
-
- *driver_configs = driDriverAPI.InitScreen(psp);
- if (*driver_configs == NULL) {
- free(psp);
- return NULL;
- }
-
- return psp;
-}
-
-static void driDestroyScreen(__DRIscreen *psp)
-{
- if (psp) {
- driDriverAPI.DestroyScreen(psp);
- free(psp);
- }
-}
-
-static const __DRIextension **driGetExtensions(__DRIscreen *psp)
-{
- return psp->extensions;
-}
-
-
-/**
- * Context functions
- */
-
-static __DRIcontext *
-driCreateContextAttribs(__DRIscreen *screen, int api,
- const __DRIconfig *config,
- __DRIcontext *shared,
- unsigned num_attribs,
- const uint32_t *attribs,
- unsigned *error,
- void *data)
-{
- __DRIcontext *pcp;
- const struct gl_config *modes = (config != NULL) ? &config->modes : NULL;
- void * const shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;
- gl_api mesa_api;
- unsigned major_version = 1;
- unsigned minor_version = 0;
- uint32_t flags = 0;
- unsigned i;
-
- /* Either num_attribs is zero and attribs is NULL, or num_attribs is not
- * zero and attribs is not NULL.
- */
- assert((num_attribs == 0) == (attribs == NULL));
-
- switch (api) {
- case __DRI_API_OPENGL:
- mesa_api = API_OPENGL_COMPAT;
- break;
- case __DRI_API_GLES:
- mesa_api = API_OPENGLES;
- break;
- case __DRI_API_GLES2:
- case __DRI_API_GLES3:
- mesa_api = API_OPENGLES2;
- break;
- case __DRI_API_OPENGL_CORE:
- mesa_api = API_OPENGL_CORE;
- break;
- default:
- *error = __DRI_CTX_ERROR_BAD_API;
- return NULL;
- }
-
- for (i = 0; i < num_attribs; i++) {
- switch (attribs[i * 2]) {
- case __DRI_CTX_ATTRIB_MAJOR_VERSION:
- major_version = attribs[i * 2 + 1];
- break;
- case __DRI_CTX_ATTRIB_MINOR_VERSION:
- minor_version = attribs[i * 2 + 1];
- break;
- case __DRI_CTX_ATTRIB_FLAGS:
- flags = attribs[i * 2 + 1];
- break;
- default:
- /* We can't create a context that satisfies the requirements of an
- * attribute that we don't understand. Return failure.
- */
- return NULL;
- }
- }
-
- /* Mesa does not support the GL_ARB_compatibilty extension or the
- * compatibility profile. This means that we treat a API_OPENGL_COMPAT 3.1 as
- * API_OPENGL_CORE and reject API_OPENGL_COMPAT 3.2+.
- */
- if (mesa_api == API_OPENGL_COMPAT && major_version == 3 && minor_version == 1)
- mesa_api = API_OPENGL_CORE;
-
- if (mesa_api == API_OPENGL_COMPAT
- && ((major_version > 3)
- || (major_version == 3 && minor_version >= 2))) {
- *error = __DRI_CTX_ERROR_BAD_API;
- return NULL;
- }
- /* There are no forward-compatible contexts before OpenGL 3.0. The
- * GLX_ARB_create_context spec says:
- *
- * "Forward-compatible contexts are defined only for OpenGL versions
- * 3.0 and later."
- *
- * Moreover, Mesa can't fulfill the requirements of a forward-looking
- * context. Return failure if a forward-looking context is requested.
- *
- * In Mesa, a debug context is the same as a regular context.
- */
- if (major_version >= 3) {
- if ((flags & ~__DRI_CTX_FLAG_DEBUG) != 0)
- return NULL;
- }
-
- pcp = CALLOC_STRUCT(__DRIcontextRec);
- if (!pcp)
- return NULL;
-
- pcp->loaderPrivate = data;
-
- pcp->driScreenPriv = screen;
- pcp->driDrawablePriv = NULL;
- pcp->driReadablePriv = NULL;
-
- if (!driDriverAPI.CreateContext(mesa_api, modes, pcp,
- major_version, minor_version,
- flags, error, shareCtx)) {
- free(pcp);
- return NULL;
- }
-
- return pcp;
-}
-
-static __DRIcontext *
-driCreateNewContextForAPI(__DRIscreen *psp, int api,
- const __DRIconfig *config,
- __DRIcontext *shared, void *data)
-{
- unsigned error;
-
- return driCreateContextAttribs(psp, api, config, shared, 0, NULL,
- &error, data);
-}
-
-static __DRIcontext *
-driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config,
- __DRIcontext *shared, void *data)
-{
- return driCreateNewContextForAPI(psp, __DRI_API_OPENGL,
- config, shared, data);
-}
-
-static void
-driDestroyContext(__DRIcontext *pcp)
-{
- if (pcp) {
- driDriverAPI.DestroyContext(pcp);
- free(pcp);
- }
-}
-
-static int
-driCopyContext(__DRIcontext *dst, __DRIcontext *src, unsigned long mask)
-{
- return GL_FALSE;
-}
-
-static void dri_get_drawable(__DRIdrawable *pdp);
-static void dri_put_drawable(__DRIdrawable *pdp);
-
-static int driBindContext(__DRIcontext *pcp,
- __DRIdrawable *pdp,
- __DRIdrawable *prp)
-{
- /* Bind the drawable to the context */
- if (pcp) {
- pcp->driDrawablePriv = pdp;
- pcp->driReadablePriv = prp;
- if (pdp) {
- pdp->driContextPriv = pcp;
- dri_get_drawable(pdp);
- }
- if (prp && pdp != prp) {
- dri_get_drawable(prp);
- }
- }
-
- return driDriverAPI.MakeCurrent(pcp, pdp, prp);
-}
-
-static int driUnbindContext(__DRIcontext *pcp)
-{
- __DRIdrawable *pdp;
- __DRIdrawable *prp;
-
- if (pcp == NULL)
- return GL_FALSE;
-
- pdp = pcp->driDrawablePriv;
- prp = pcp->driReadablePriv;
-
- /* already unbound */
- if (!pdp && !prp)
- return GL_TRUE;
-
- driDriverAPI.UnbindContext(pcp);
-
- dri_put_drawable(pdp);
-
- if (prp != pdp) {
- dri_put_drawable(prp);
- }
-
- pcp->driDrawablePriv = NULL;
- pcp->driReadablePriv = NULL;
-
- return GL_TRUE;
-}
-
-
-/**
- * Drawable functions
- */
-
-static void dri_get_drawable(__DRIdrawable *pdp)
-{
- pdp->refcount++;
-}
-
-static void dri_put_drawable(__DRIdrawable *pdp)
-{
- if (pdp) {
- pdp->refcount--;
- if (pdp->refcount)
- return;
-
- driDriverAPI.DestroyBuffer(pdp);
- free(pdp);
- }
-}
-
-static __DRIdrawable *
-driCreateNewDrawable(__DRIscreen *psp,
- const __DRIconfig *config, void *data)
-{
- __DRIdrawable *pdp;
-
- pdp = CALLOC_STRUCT(__DRIdrawableRec);
- if (!pdp)
- return NULL;
-
- pdp->loaderPrivate = data;
-
- pdp->driScreenPriv = psp;
- pdp->driContextPriv = NULL;
-
- dri_get_drawable(pdp);
-
- if (!driDriverAPI.CreateBuffer(psp, pdp, &config->modes, GL_FALSE)) {
- free(pdp);
- return NULL;
- }
-
- pdp->lastStamp = 1; /* const */
-
- return pdp;
-}
-
-static void
-driDestroyDrawable(__DRIdrawable *pdp)
-{
- dri_put_drawable(pdp);
-}
-
-static void driSwapBuffers(__DRIdrawable *pdp)
-{
- driDriverAPI.SwapBuffers(pdp);
-}
-
-const __DRIcoreExtension driCoreExtension = {
- { __DRI_CORE, __DRI_CORE_VERSION },
- NULL, /* driCreateNewScreen */
- driDestroyScreen,
- driGetExtensions,
- driGetConfigAttrib,
- driIndexConfigAttrib,
- NULL, /* driCreateNewDrawable */
- driDestroyDrawable,
- driSwapBuffers,
- driCreateNewContext,
- driCopyContext,
- driDestroyContext,
- driBindContext,
- driUnbindContext
-};
-
-const __DRIswrastExtension driSWRastExtension = {
- { __DRI_SWRAST, __DRI_SWRAST_VERSION },
- driCreateNewScreen,
- driCreateNewDrawable,
- driCreateNewContextForAPI,
- driCreateContextAttribs
-};
diff --git a/mesalib/src/mesa/drivers/dri/common/utils.c b/mesalib/src/mesa/drivers/dri/common/utils.c
index c9fc21891..f3780d9b6 100644
--- a/mesalib/src/mesa/drivers/dri/common/utils.c
+++ b/mesalib/src/mesa/drivers/dri/common/utils.c
@@ -189,6 +189,10 @@ driCreateConfigs(gl_format format,
{ 0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000 },
/* MESA_FORMAT_ARGB8888 */
{ 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000 },
+ /* MESA_FORMAT_XRGB2101010_UNORM */
+ { 0x3FF00000, 0x000FFC00, 0x000003FF, 0x00000000 },
+ /* MESA_FORMAT_ARGB2101010 */
+ { 0x3FF00000, 0x000FFC00, 0x000003FF, 0xC0000000 },
};
const uint32_t * masks;
@@ -214,6 +218,12 @@ driCreateConfigs(gl_format format,
case MESA_FORMAT_SARGB8:
masks = masks_table[2];
break;
+ case MESA_FORMAT_XRGB2101010_UNORM:
+ masks = masks_table[3];
+ break;
+ case MESA_FORMAT_ARGB2101010:
+ masks = masks_table[4];
+ break;
default:
fprintf(stderr, "[%s:%u] Unknown framebuffer type %s (%d).\n",
__FUNCTION__, __LINE__,
diff --git a/mesalib/src/mesa/drivers/dri/swrast/Makefile.am b/mesalib/src/mesa/drivers/dri/swrast/Makefile.am
index 9652583f2..c51ad2d87 100644
--- a/mesalib/src/mesa/drivers/dri/swrast/Makefile.am
+++ b/mesalib/src/mesa/drivers/dri/swrast/Makefile.am
@@ -30,6 +30,7 @@ AM_CFLAGS = \
-I$(top_srcdir)/src/mapi \
-I$(top_srcdir)/src/mesa/ \
-I$(top_srcdir)/src/mesa/drivers/dri/common \
+ -I$(top_builddir)/src/mesa/drivers/dri/common \
$(DEFINES) \
$(VISIBILITY_CFLAGS)
diff --git a/mesalib/src/mesa/drivers/dri/swrast/Makefile.sources b/mesalib/src/mesa/drivers/dri/swrast/Makefile.sources
index 7630dba4b..fc7ef32db 100644
--- a/mesalib/src/mesa/drivers/dri/swrast/Makefile.sources
+++ b/mesalib/src/mesa/drivers/dri/swrast/Makefile.sources
@@ -3,7 +3,8 @@ SWRAST_DRIVER_FILES = \
SWRAST_COMMON_FILES = \
../common/utils.c \
- ../common/drisw_util.c
+ ../common/dri_util.c \
+ ../common/xmlconfig.c
SWRAST_C_FILES = \
$(SWRAST_COMMON_FILES) \
diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast.c b/mesalib/src/mesa/drivers/dri/swrast/swrast.c
index 945f8f5e1..dde868864 100644
--- a/mesalib/src/mesa/drivers/dri/swrast/swrast.c
+++ b/mesalib/src/mesa/drivers/dri/swrast/swrast.c
@@ -205,6 +205,10 @@ dri_init_screen(__DRIscreen * psp)
TRACE;
+ psp->max_gl_compat_version = 21;
+ psp->max_gl_es1_version = 11;
+ psp->max_gl_es2_version = 20;
+
psp->extensions = dri_screen_extensions;
configs16 = swrastFillInModes(psp, 16, 16, 0, 1);
@@ -679,22 +683,6 @@ dri_create_context(gl_api api,
*/
(void) flags;
- switch (api) {
- case API_OPENGL_COMPAT:
- if (major_version > 2
- || (major_version == 2 && minor_version > 1)) {
- *error = __DRI_CTX_ERROR_BAD_VERSION;
- return GL_FALSE;
- }
- break;
- case API_OPENGLES:
- case API_OPENGLES2:
- break;
- case API_OPENGL_CORE:
- *error = __DRI_CTX_ERROR_BAD_API;
- return GL_FALSE;
- }
-
ctx = CALLOC_STRUCT(dri_context);
if (ctx == NULL) {
*error = __DRI_CTX_ERROR_NO_MEMORY;
diff --git a/mesalib/src/mesa/main/api_validate.c b/mesalib/src/mesa/main/api_validate.c
index 002992186..f285c9748 100644
--- a/mesalib/src/mesa/main/api_validate.c
+++ b/mesalib/src/mesa/main/api_validate.c
@@ -330,26 +330,43 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
if (_mesa_is_xfb_active_and_unpaused(ctx)) {
GLboolean pass = GL_TRUE;
- switch (mode) {
- case GL_POINTS:
- pass = ctx->TransformFeedback.Mode == GL_POINTS;
- break;
- case GL_LINES:
- case GL_LINE_STRIP:
- case GL_LINE_LOOP:
- pass = ctx->TransformFeedback.Mode == GL_LINES;
- break;
- default:
- pass = ctx->TransformFeedback.Mode == GL_TRIANGLES;
- break;
+ if(ctx->Shader.CurrentGeometryProgram) {
+ switch (ctx->Shader.CurrentGeometryProgram->Geom.OutputType) {
+ case GL_POINTS:
+ pass = ctx->TransformFeedback.Mode == GL_POINTS;
+ break;
+ case GL_LINE_STRIP:
+ pass = ctx->TransformFeedback.Mode == GL_LINES;
+ break;
+ case GL_TRIANGLE_STRIP:
+ pass = ctx->TransformFeedback.Mode == GL_TRIANGLES;
+ break;
+ default:
+ pass = GL_FALSE;
+ }
+ }
+ else {
+ switch (mode) {
+ case GL_POINTS:
+ pass = ctx->TransformFeedback.Mode == GL_POINTS;
+ break;
+ case GL_LINES:
+ case GL_LINE_STRIP:
+ case GL_LINE_LOOP:
+ pass = ctx->TransformFeedback.Mode == GL_LINES;
+ break;
+ default:
+ pass = ctx->TransformFeedback.Mode == GL_TRIANGLES;
+ break;
+ }
}
if (!pass) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(mode=%s vs transform feedback %s)",
- name,
- _mesa_lookup_prim_by_nr(mode),
- _mesa_lookup_prim_by_nr(ctx->TransformFeedback.Mode));
- return GL_FALSE;
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(mode=%s vs transform feedback %s)",
+ name,
+ _mesa_lookup_prim_by_nr(mode),
+ _mesa_lookup_prim_by_nr(ctx->TransformFeedback.Mode));
+ return GL_FALSE;
}
}
diff --git a/mesalib/src/mesa/main/dd.h b/mesalib/src/mesa/main/dd.h
index 0806e41a0..29469ce33 100644
--- a/mesalib/src/mesa/main/dd.h
+++ b/mesalib/src/mesa/main/dd.h
@@ -575,7 +575,8 @@ struct dd_function_table {
GLintptr readOffset, GLintptr writeOffset,
GLsizeiptr size );
- /* May return NULL if MESA_MAP_NOWAIT_BIT is set in access:
+ /* Returns pointer to the start of the mapped range.
+ * May return NULL if MESA_MAP_NOWAIT_BIT is set in access:
*/
void * (*MapBufferRange)( struct gl_context *ctx, GLintptr offset,
GLsizeiptr length, GLbitfield access,
diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c
index 1034c7a71..9dd71612f 100644
--- a/mesalib/src/mesa/main/fbobject.c
+++ b/mesalib/src/mesa/main/fbobject.c
@@ -3585,6 +3585,7 @@ invalidate_framebuffer_storage(GLenum target, GLsizei numAttachments,
"%s(attachment >= max. color attachments)", name);
return;
}
+ break;
}
default:
goto invalid_enum;
diff --git a/mesalib/src/mesa/main/imports.c b/mesalib/src/mesa/main/imports.c
index ca6b1d53e..277e9476a 100644
--- a/mesalib/src/mesa/main/imports.c
+++ b/mesalib/src/mesa/main/imports.c
@@ -566,7 +566,8 @@ float
_mesa_strtof( const char *s, char **end )
{
#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \
- !defined(ANDROID) && !defined(__HAIKU__) && !defined(__UCLIBC__)
+ !defined(ANDROID) && !defined(__HAIKU__) && !defined(__UCLIBC__) && \
+ !defined(__NetBSD__)
static locale_t loc = NULL;
if (!loc) {
loc = newlocale(LC_CTYPE_MASK, "C", NULL);
diff --git a/mesalib/src/mesa/main/macros.h b/mesalib/src/mesa/main/macros.h
index 1052f7560..880c6564e 100644
--- a/mesalib/src/mesa/main/macros.h
+++ b/mesalib/src/mesa/main/macros.h
@@ -184,6 +184,28 @@ static inline GLfloat UINT_AS_FLT(GLuint u)
return tmp.f;
}
+/**
+ * Convert a floating point value to an unsigned fixed point value.
+ *
+ * \param frac_bits The number of bits used to store the fractional part.
+ */
+static INLINE uint32_t
+U_FIXED(float value, uint32_t frac_bits)
+{
+ value *= (1 << frac_bits);
+ return value < 0 ? 0 : value;
+}
+
+/**
+ * Convert a floating point value to an signed fixed point value.
+ *
+ * \param frac_bits The number of bits used to store the fractional part.
+ */
+static INLINE uint32_t
+S_FIXED(float value, uint32_t frac_bits)
+{
+ return value * (1 << frac_bits);
+}
/*@}*/
@@ -673,8 +695,20 @@ minify(unsigned value, unsigned levels)
*
* \sa ROUND_DOWN_TO()
*/
-#define ALIGN(value, alignment) (((value) + alignment - 1) & ~(alignment - 1))
+#define ALIGN(value, alignment) (((value) + (alignment) - 1) & ~((alignment) - 1))
+/**
+ * Align a value down to an alignment value
+ *
+ * If \c value is not already aligned to the requested alignment value, it
+ * will be rounded down.
+ *
+ * \param value Value to be rounded
+ * \param alignment Alignment value to be used. This must be a power of two.
+ *
+ * \sa ALIGN()
+ */
+#define ROUND_DOWN_TO(value, alignment) ((value) & ~(alignment - 1))
/** Cross product of two 3-element vectors */
diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c
index 4c0484aaf..d3677c851 100644
--- a/mesalib/src/mesa/main/shaderapi.c
+++ b/mesalib/src/mesa/main/shaderapi.c
@@ -743,12 +743,6 @@ compile_shader(struct gl_context *ctx, GLuint shaderObj)
if (!sh)
return;
- /* Geometry shaders are not yet fully supported, so issue a warning message
- * if we're compiling one.
- */
- if (sh->Type == GL_GEOMETRY_SHADER)
- printf("WARNING: Geometry shader support is currently experimental.\n");
-
options = &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(sh->Type)];
/* set default pragma state for shader */
diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c
index 7050f1080..d66ca1abc 100644
--- a/mesalib/src/mesa/main/texgetimage.c
+++ b/mesalib/src/mesa/main/texgetimage.c
@@ -319,7 +319,7 @@ get_tex_rgba_compressed(struct gl_context *ctx, GLuint dimensions,
* Return a base GL format given the user-requested format
* for glGetTexImage().
*/
-static GLenum
+GLenum
_mesa_base_pack_format(GLenum format)
{
switch (format) {
diff --git a/mesalib/src/mesa/main/texgetimage.h b/mesalib/src/mesa/main/texgetimage.h
index 91ae6e2e9..a292fabc0 100644
--- a/mesalib/src/mesa/main/texgetimage.h
+++ b/mesalib/src/mesa/main/texgetimage.h
@@ -33,6 +33,9 @@ struct gl_context;
struct gl_texture_image;
struct gl_texture_object;
+extern GLenum
+_mesa_base_pack_format(GLenum format);
+
extern void
_mesa_get_teximage(struct gl_context *ctx,
GLenum format, GLenum type, GLvoid *pixels,
diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c
index 04385e1e9..76d8d9ba3 100644
--- a/mesalib/src/mesa/main/texstore.c
+++ b/mesalib/src/mesa/main/texstore.c
@@ -3961,6 +3961,7 @@ store_texsubimage(struct gl_context *ctx,
case GL_TEXTURE_2D:
case GL_TEXTURE_RECTANGLE:
case GL_TEXTURE_CUBE_MAP:
+ case GL_TEXTURE_EXTERNAL_OES:
/* one image slice, nothing special needs to be done */
break;
case GL_TEXTURE_1D:
diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp
index 6b22b5074..cfad91bc4 100644
--- a/mesalib/src/mesa/program/ir_to_mesa.cpp
+++ b/mesalib/src/mesa/program/ir_to_mesa.cpp
@@ -1497,6 +1497,9 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
case ir_quadop_bitfield_insert:
case ir_binop_ldexp:
case ir_triop_csel:
+ case ir_binop_carry:
+ case ir_binop_borrow:
+ case ir_binop_imul_high:
assert(!"not supported");
break;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
index 25cc61aef..7fa4cbdc4 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -1,8 +1,8 @@
/**************************************************************************
- *
+ *
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
- *
+ *
* 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
@@ -10,11 +10,11 @@
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
- *
+ *
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
@@ -22,7 +22,7 @@
* 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.
- *
+ *
**************************************************************************/
@@ -78,7 +78,7 @@ st_bufferobj_free(struct gl_context *ctx, struct gl_buffer_object *obj)
assert(obj->RefCount == 0);
assert(st_obj->transfer == NULL);
- if (st_obj->buffer)
+ if (st_obj->buffer)
pipe_resource_reference(&st_obj->buffer, NULL);
free(st_obj->Base.Label);
@@ -175,7 +175,7 @@ st_bufferobj_data(struct gl_context *ctx,
GLenum target,
GLsizeiptrARB size,
const GLvoid * data,
- GLenum usage,
+ GLenum usage,
struct gl_buffer_object *obj)
{
struct st_context *st = st_context(ctx);
@@ -200,8 +200,8 @@ st_bufferobj_data(struct gl_context *ctx,
st_obj->Base.Size = size;
st_obj->Base.Usage = usage;
-
- switch(target) {
+
+ switch (target) {
case GL_PIXEL_PACK_BUFFER_ARB:
case GL_PIXEL_UNPACK_BUFFER_ARB:
bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
@@ -302,7 +302,7 @@ st_bufferobj_map_range(struct gl_context *ctx,
else
flags |= PIPE_TRANSFER_DISCARD_RANGE;
}
-
+
if (access & GL_MAP_UNSYNCHRONIZED_BIT)
flags |= PIPE_TRANSFER_UNSYNCHRONIZED;
@@ -348,11 +348,11 @@ st_bufferobj_flush_mapped_range(struct gl_context *ctx,
assert(length >= 0);
assert(offset + length <= obj->Length);
assert(obj->Pointer);
-
+
if (!length)
return;
- pipe_buffer_flush_mapped_range(pipe, st_obj->transfer,
+ pipe_buffer_flush_mapped_range(pipe, st_obj->transfer,
obj->Offset + offset, length);
}
@@ -392,7 +392,7 @@ st_copy_buffer_subdata(struct gl_context *ctx,
struct st_buffer_object *dstObj = st_buffer_object(dst);
struct pipe_box box;
- if(!size)
+ if (!size)
return;
/* buffer should not already be mapped */
diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c
index 64bfd1faa..33c2ca661 100644
--- a/mesalib/src/mesa/state_tracker/st_format.c
+++ b/mesalib/src/mesa/state_tracker/st_format.c
@@ -35,6 +35,8 @@
#include "main/imports.h"
#include "main/context.h"
#include "main/glformats.h"
+#include "main/texgetimage.h"
+#include "main/teximage.h"
#include "main/texstore.h"
#include "main/image.h"
#include "main/macros.h"
@@ -1745,6 +1747,40 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target,
bindings |= PIPE_BIND_RENDER_TARGET;
}
+ /* GLES allows the driver to choose any format which matches
+ * the format+type combo, because GLES only supports unsized internal
+ * formats and expects the driver to choose whatever suits it.
+ */
+ if (_mesa_is_gles(ctx)) {
+ GLenum baseFormat = _mesa_base_tex_format(ctx, internalFormat);
+ GLenum basePackFormat = _mesa_base_pack_format(format);
+ GLenum iformat = internalFormat;
+
+ /* Treat GL_BGRA as GL_RGBA. */
+ if (iformat == GL_BGRA)
+ iformat = GL_RGBA;
+
+ /* Check if the internalformat is unsized and compatible
+ * with the "format".
+ */
+ if (iformat == baseFormat && iformat == basePackFormat) {
+ pFormat = st_choose_matching_format(st->pipe->screen, bindings,
+ format, type,
+ ctx->Unpack.SwapBytes);
+
+ if (pFormat != PIPE_FORMAT_NONE)
+ return st_pipe_format_to_mesa_format(pFormat);
+
+ /* try choosing format again, this time without render target bindings */
+ pFormat = st_choose_matching_format(st->pipe->screen,
+ PIPE_BIND_SAMPLER_VIEW,
+ format, type,
+ ctx->Unpack.SwapBytes);
+ if (pFormat != PIPE_FORMAT_NONE)
+ return st_pipe_format_to_mesa_format(pFormat);
+ }
+ }
+
pFormat = st_choose_format(st, internalFormat, format, type,
PIPE_TEXTURE_2D, 0, bindings, ctx->Mesa_DXTn);
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 d1706ca27..8d06ac6f7 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -1978,6 +1978,9 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
case ir_binop_vector_extract:
case ir_triop_vector_insert:
case ir_binop_ldexp:
+ case ir_binop_carry:
+ case ir_binop_borrow:
+ case ir_binop_imul_high:
/* This operation is not supported, or should have already been handled.
*/
assert(!"Invalid ir opcode in glsl_to_tgsi_visitor::visit()");
@@ -2791,6 +2794,9 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
case ir_tg4:
assert(!"Unexpected ir_tg4 opcode");
break;
+ case ir_query_levels:
+ assert(!"Unexpected ir_query_levels opcode");
+ break;
}
if (ir->projector) {
diff --git a/mesalib/src/mesa/vbo/vbo_exec.c b/mesalib/src/mesa/vbo/vbo_exec.c
index aa2c7b07b..2f05e00c8 100644
--- a/mesalib/src/mesa/vbo/vbo_exec.c
+++ b/mesalib/src/mesa/vbo/vbo_exec.c
@@ -100,7 +100,7 @@ void vbo_exec_invalidate_state( struct gl_context *ctx, GLuint new_state )
}
if (new_state & _NEW_EVAL)
- exec->eval.recalculate_maps = 1;
+ exec->eval.recalculate_maps = GL_TRUE;
_ae_invalidate_state(ctx, new_state);
}
diff --git a/mesalib/src/mesa/vbo/vbo_exec_eval.c b/mesalib/src/mesa/vbo/vbo_exec_eval.c
index 71155ce77..2bd1b2150 100644
--- a/mesalib/src/mesa/vbo/vbo_exec_eval.c
+++ b/mesalib/src/mesa/vbo/vbo_exec_eval.c
@@ -117,7 +117,7 @@ void vbo_exec_eval_update( struct vbo_exec_context *exec )
else if (ctx->Eval.Map2Vertex3)
set_active_eval2( exec, VBO_ATTRIB_POS, 3, &ctx->EvalMap.Map2Vertex3 );
- exec->eval.recalculate_maps = 0;
+ exec->eval.recalculate_maps = GL_FALSE;
}
diff --git a/mesalib/src/mesa/vbo/vbo_save.h b/mesalib/src/mesa/vbo/vbo_save.h
index aa075bb31..a810bef57 100644
--- a/mesalib/src/mesa/vbo/vbo_save.h
+++ b/mesalib/src/mesa/vbo/vbo_save.h
@@ -63,7 +63,7 @@ struct vbo_save_copied_vtx {
struct vbo_save_vertex_list {
GLubyte attrsz[VBO_ATTRIB_MAX];
GLenum attrtype[VBO_ATTRIB_MAX];
- GLuint vertex_size;
+ GLuint vertex_size; /**< size in GLfloats */
/* Copy of the final vertex from node->vertex_store->bufferobj.
* Keep this in regular (non-VBO) memory to avoid repeated
diff --git a/mesalib/src/mesa/vbo/vbo_save_api.c b/mesalib/src/mesa/vbo/vbo_save_api.c
index 2028d8b2c..b5f951787 100644
--- a/mesalib/src/mesa/vbo/vbo_save_api.c
+++ b/mesalib/src/mesa/vbo/vbo_save_api.c
@@ -41,7 +41,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
* example by building a list that consists of one very long primitive
* (eg Begin(Triangles), 1000 vertices, End), and calling that list
* from inside a different begin/end object (Begin(Lines), CallList,
- * End).
+ * End).
*
* In that case the code will have to replay the list as individual
* commands through the Exec dispatch table, or fix up the copied
@@ -60,7 +60,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* The list compiler currently doesn't attempt to compile lists
* containing EvalCoord or EvalPoint commands. On encountering one of
- * these, compilation falls back to opcodes.
+ * these, compilation falls back to opcodes.
*
* This could be improved to fallback only when a mix of EvalCoord and
* Vertex commands are issued within a single primitive.
@@ -289,15 +289,15 @@ _save_reset_counters(struct gl_context *ctx)
assert(save->buffer == save->buffer_ptr);
if (save->vertex_size)
- save->max_vert = ((VBO_SAVE_BUFFER_SIZE - save->vertex_store->used) /
- save->vertex_size);
+ save->max_vert = (VBO_SAVE_BUFFER_SIZE - save->vertex_store->used) /
+ save->vertex_size;
else
save->max_vert = 0;
save->vert_count = 0;
save->prim_count = 0;
save->prim_max = VBO_SAVE_PRIM_SIZE - save->prim_store->used;
- save->dangling_attr_ref = 0;
+ save->dangling_attr_ref = GL_FALSE;
}
/**
@@ -410,7 +410,7 @@ _save_compile_vertex_list(struct gl_context *ctx)
save->vertex_store->used += save->vertex_size * node->count;
save->prim_store->used += node->prim_count;
- /* Copy duplicated vertices
+ /* Copy duplicated vertices
*/
save->copied.nr = _save_copy_vertices(ctx, node, save->buffer);
@@ -514,7 +514,7 @@ _save_wrap_buffers(struct gl_context *ctx)
/**
* Called only when buffers are wrapped as the result of filling the
- * vertex_store struct.
+ * vertex_store struct.
*/
static void
_save_wrap_filled_vertex(struct gl_context *ctx)
@@ -603,7 +603,7 @@ _save_upgrade_vertex(struct gl_context *ctx, GLuint attr, GLuint newsz)
/* Do a COPY_TO_CURRENT to ensure back-copying works for the case
* when the attribute already exists in the vertex and is having
- * its size increased.
+ * its size increased.
*/
_save_copy_to_current(ctx);
@@ -856,7 +856,7 @@ dlist_fallback(struct gl_context *ctx)
* unfortunately, otherwise this primitive won't be handled
* properly:
*/
- save->dangling_attr_ref = 1;
+ save->dangling_attr_ref = GL_TRUE;
_save_compile_vertex_list(ctx);
}
@@ -1433,13 +1433,13 @@ vbo_save_EndList(struct gl_context *ctx)
GLint i = save->prim_count - 1;
ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END;
save->prim[i].end = 0;
- save->prim[i].count = (save->vert_count - save->prim[i].start);
+ save->prim[i].count = save->vert_count - save->prim[i].start;
}
/* Make sure this vertex list gets replayed by the "loopback"
* mechanism:
*/
- save->dangling_attr_ref = 1;
+ save->dangling_attr_ref = GL_TRUE;
vbo_save_SaveFlushVertices(ctx);
/* Swap out this vertex format while outside begin/end. Any color,