diff options
Diffstat (limited to 'mesalib')
28 files changed, 965 insertions, 344 deletions
diff --git a/mesalib/configure.ac b/mesalib/configure.ac index 0026613cc..35f6797ee 100644 --- a/mesalib/configure.ac +++ b/mesalib/configure.ac @@ -100,6 +100,7 @@ AC_MSG_RESULT([$acv_mesa_CLANG]) dnl If we're using GCC, make sure that it is at least version 3.3.0. Older dnl versions are explictly not supported. +GEN_ASM_OFFSETS=no if test "x$GCC" = xyes -a "x$acv_mesa_CLANG" = xno; then AC_MSG_CHECKING([whether gcc version is sufficient]) major=0 @@ -117,7 +118,12 @@ if test "x$GCC" = xyes -a "x$acv_mesa_CLANG" = xno; then else AC_MSG_RESULT([yes]) fi + + if test "x$cross_compiling" = xyes; then + GEN_ASM_OFFSETS=yes + fi fi +AM_CONDITIONAL([GEN_ASM_OFFSETS], test "x$GEN_ASM_OFFSETS" = xyes) dnl Make sure the pkg-config macros are defined m4_ifndef([PKG_PROG_PKG_CONFIG], @@ -438,7 +444,7 @@ test "x$enable_asm" = xno && AC_MSG_RESULT([no]) # disable if cross compiling on x86/x86_64 since we must run gen_matypes if test "x$enable_asm" = xyes && test "x$cross_compiling" = xyes; then case "$host_cpu" in - i?86 | x86_64) + i?86 | x86_64 | amd64) enable_asm=no AC_MSG_RESULT([no, cross compiling]) ;; @@ -449,7 +455,7 @@ if test "x$enable_asm" = xyes; then case "$host_cpu" in i?86) case "$host_os" in - linux* | *freebsd* | dragonfly* | *netbsd*) + linux* | *freebsd* | dragonfly* | *netbsd* | openbsd*) test "x$enable_64bit" = xyes && asm_arch=x86_64 || asm_arch=x86 ;; gnu*) @@ -457,9 +463,9 @@ if test "x$enable_asm" = xyes; then ;; esac ;; - x86_64) + x86_64|amd64) case "$host_os" in - linux* | *freebsd* | dragonfly* | *netbsd*) + linux* | *freebsd* | dragonfly* | *netbsd* | openbsd*) test "x$enable_32bit" = xyes && asm_arch=x86 || asm_arch=x86_64 ;; esac @@ -478,7 +484,7 @@ if test "x$enable_asm" = xyes; then DEFINES="$DEFINES -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM" AC_MSG_RESULT([yes, x86]) ;; - x86_64) + x86_64|amd64) DEFINES="$DEFINES -DUSE_X86_64_ASM" AC_MSG_RESULT([yes, x86_64]) ;; @@ -966,7 +972,7 @@ if test "x$enable_dri" = xyes; then DEFINES="$DEFINES -DHAVE_ALIAS" case "$host_cpu" in - x86_64) + x86_64|amd64) if test "x$DRI_DIRS" = "xyes"; then DRI_DIRS="i915 i965 nouveau r200 radeon swrast" fi @@ -985,7 +991,7 @@ if test "x$enable_dri" = xyes; then ;; esac ;; - freebsd* | dragonfly* | *netbsd*) + freebsd* | dragonfly* | *netbsd* | openbsd*) DEFINES="$DEFINES -DHAVE_PTHREAD -DUSE_EXTERNAL_DXTN_LIB=1" DEFINES="$DEFINES -DHAVE_ALIAS" @@ -1573,7 +1579,7 @@ if test "x$with_gallium_drivers" = x; then fi if test "x$enable_gallium_llvm" = xauto; then case "$host_cpu" in - i*86|x86_64) enable_gallium_llvm=yes;; + i*86|x86_64|amd64) enable_gallium_llvm=yes;; esac fi if test "x$enable_gallium_llvm" = xyes; then @@ -1605,14 +1611,14 @@ if test "x$enable_gallium_llvm" = xyes; then fi LLVM_COMPONENTS="engine bitwriter" - if $LLVM_CONFIG --components | grep -q '\<mcjit\>'; then + if $LLVM_CONFIG --components | grep -qw 'mcjit'; then LLVM_COMPONENTS="${LLVM_COMPONENTS} mcjit" fi if test "x$enable_opencl" = xyes; then LLVM_COMPONENTS="${LLVM_COMPONENTS} ipo linker instrumentation" # LLVM 3.3 >= 177971 requires IRReader - if $LLVM_CONFIG --components | grep -q '\<irreader\>'; then + if $LLVM_CONFIG --components | grep -qw 'irreader'; then LLVM_COMPONENTS="${LLVM_COMPONENTS} irreader" fi fi @@ -1705,7 +1711,7 @@ gallium_check_st() { gallium_require_llvm() { if test "x$MESA_LLVM" = x0; then case "$host_cpu" in - i*86|x86_64) AC_MSG_ERROR([LLVM is required to build $1 on x86 and x86_64]);; + i*86|x86_64|amd64) AC_MSG_ERROR([LLVM is required to build $1 on x86 and x86_64]);; esac fi } @@ -1727,7 +1733,7 @@ radeon_llvm_check() { if test "$LLVM_VERSION_INT" -lt "${LLVM_REQUIRED_VERSION_MAJOR}0${LLVM_REQUIRED_VERSION_MINOR}"; then AC_MSG_ERROR([LLVM $LLVM_REQUIRED_VERSION_MAJOR.$LLVM_REQUIRED_VERSION_MINOR or newer is required for r600g and radeonsi.]) fi - if test true && $LLVM_CONFIG --targets-built | grep -qv '\<R600\>' ; then + if test true && $LLVM_CONFIG --targets-built | grep -qvw 'R600' ; then AC_MSG_ERROR([LLVM R600 Target not enabled. You can enable it when building the LLVM sources with the --enable-experimental-targets=R600 configure flag]) diff --git a/mesalib/docs/index.html b/mesalib/docs/index.html index d85081d50..f0c51703f 100644 --- a/mesalib/docs/index.html +++ b/mesalib/docs/index.html @@ -16,6 +16,12 @@ <h1>News</h1> +<h2>July 17, 2013</h2> +<p> +<a href="relnotes/9.1.5.html">Mesa 9.1.5</a> is released. +This is a bug fix release. +</p> + <h2>July 1, 2013</h2> <p> <a href="relnotes/9.1.4.html">Mesa 9.1.4</a> is released. diff --git a/mesalib/docs/relnotes.html b/mesalib/docs/relnotes.html index bc5ad3c20..3d391c061 100644 --- a/mesalib/docs/relnotes.html +++ b/mesalib/docs/relnotes.html @@ -22,6 +22,7 @@ The release notes summarize what's new or changed in each Mesa release. <ul> <li><a href="relnotes/9.2.html">9.2 release notes</a> +<li><a href="relnotes/9.1.5.html">9.1.5 release notes</a> <li><a href="relnotes/9.1.4.html">9.1.4 release notes</a> <li><a href="relnotes/9.1.3.html">9.1.3 release notes</a> <li><a href="relnotes/9.1.2.html">9.1.2 release notes</a> diff --git a/mesalib/docs/relnotes/9.1.5.html b/mesalib/docs/relnotes/9.1.5.html new file mode 100644 index 000000000..fcc47c4f4 --- /dev/null +++ b/mesalib/docs/relnotes/9.1.5.html @@ -0,0 +1,138 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html lang="en"> +<head> + <meta http-equiv="content-type" content="text/html; charset=utf-8"> + <title>Mesa Release Notes</title> + <link rel="stylesheet" type="text/css" href="../mesa.css"> +</head> +<body> + +<div class="header"> + <h1>The Mesa 3D Graphics Library</h1> +</div> + +<iframe src="../contents.html"></iframe> +<div class="content"> + +<h1>Mesa 9.1.5 Release Notes / July 17, 2013</h1> + +<p> +Mesa 9.1.5 is a bug fix release which fixes bugs found since the 9.1.4 release. +</p> +<p> +Mesa 9.1 implements the OpenGL 3.1 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. +</p> + +<h2>MD5 checksums</h2> +<pre> +TBD +</pre> + +<h2>New features</h2> +<p>None.</p> + +<h2>Bug fixes</h2> + +<p>This list is likely incomplete.</p> + +<ul> + +<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=58384">Bug 58384</a> - [i965 Bisected]Oglc max_values(advanced.fragmentProgram.GL_MAX_PROGRAM_ENV_PARAMETERS_ARB) segfault</li> + +<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=62647">Bug 62647</a> - Wrong rendering of Dota 2 on Wine (apitrace attached) - Intel IVB HD4000</li> + +<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=63674">Bug 63674</a> - [IVB]frozen at the first frame when run Unigine-heaven 4.0</li> + +<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=65910">Bug 65910</a> - Killing weston-launch causes segv in desktop-shell</li> + +</ul> + +<h2>Changes</h2> +<p>The full set of changes can be viewed by using the following GIT command:</p> + +<pre> + git log mesa-9.1.4..mesa-9.1.5 +</pre> + +<p>Anuj Phogat (1):</p> +<ul> + <li>mesa: Return ZeroVec/dummyReg instead of NULL pointer</li> +</ul> + +<p>Brian Paul (1):</p> +<ul> + <li>svga: check for NaN shader immediates</li> +</ul> + +<p>Carl Worth (3):</p> +<ul> + <li>cherry-ignore: Ignore previously backported patch</li> + <li>cherry-ignore: Drop two patches which we've decided not to include</li> + <li>mesa: Bump version to 9.1.5</li> +</ul> + +<p>Chris Forbes (1):</p> +<ul> + <li>i965: fix alpha test for MRT</li> +</ul> + +<p>Christoph Bumiller (1):</p> +<ul> + <li>r600g: x/y coordinates must be divided by block dim in dma blit</li> +</ul> + +<p>Eric Anholt (1):</p> +<ul> + <li>ra: Fix register spilling.</li> +</ul> + +<p>Ian Romanick (6):</p> +<ul> + <li>docs: Add 9.1.4 release md5sums</li> + <li>glsl: Add a gl_shader_program parameter to _mesa_uniform_{merge,split}_location_offset</li> + <li>glsl: Add gl_shader_program::UniformLocationBaseScale</li> + <li>glsl: Generate smaller values for uniform locations</li> + <li>i965: Be more careful with the interleaved user array upload optimization</li> + <li>glsl: Move all var decls to the front of the IR list in reverse order</li> +</ul> + +<p>Kenneth Graunke (1):</p> +<ul> + <li>glsl/builtins: Fix ARB_texture_cube_map_array built-in availability.</li> +</ul> + +<p>Kristian Høgsberg (1):</p> +<ul> + <li>wayland: Handle global_remove event as well</li> +</ul> + +<p>Matt Turner (1):</p> +<ul> + <li>register_allocate: Fix the type of best_benefit.</li> +</ul> + +<p>Paul Berry (1):</p> +<ul> + <li>glsl ES: Fix magnitude of gl_MaxVertexUniformVectors.</li> +</ul> + +<p>Richard Sandiford (3):</p> +<ul> + <li>st/xlib Fix XIMage bytes-per-pixel calculation</li> + <li>st/xlib: Fix XImage stride calculation</li> + <li>st/dri/sw: Fix pitch calculation in drisw_update_tex_buffer</li> +</ul> + +<p>Vinson Lee (1):</p> +<ul> + <li>swrast: Fix memory leak.</li> +</ul> + +</div> +</body> +</html> diff --git a/mesalib/include/GL/internal/dri_interface.h b/mesalib/include/GL/internal/dri_interface.h index add2fe60c..279e9f003 100644 --- a/mesalib/include/GL/internal/dri_interface.h +++ b/mesalib/include/GL/internal/dri_interface.h @@ -556,6 +556,8 @@ struct __DRIuseInvalidateExtensionRec { #define __DRI_ATTRIB_RGBA_BIT 0x01 #define __DRI_ATTRIB_COLOR_INDEX_BIT 0x02 #define __DRI_ATTRIB_LUMINANCE_BIT 0x04 +#define __DRI_ATTRIB_FLOAT_BIT 0x08 +#define __DRI_ATTRIB_UNSIGNED_FLOAT_BIT 0x10 /* __DRI_ATTRIB_CONFIG_CAVEAT */ #define __DRI_ATTRIB_SLOW_BIT 0x01 diff --git a/mesalib/m4/ax_prog_flex.m4 b/mesalib/m4/ax_prog_flex.m4 index 117f8fe67..82fbc30c3 100644 --- a/mesalib/m4/ax_prog_flex.m4 +++ b/mesalib/m4/ax_prog_flex.m4 @@ -53,7 +53,7 @@ AC_DEFUN([AX_PROG_FLEX], [ AC_REQUIRE([AC_PROG_EGREP]) AC_CACHE_CHECK([if flex is the lexer generator],[ax_cv_prog_flex],[ - AS_IF([$LEX --version 2>/dev/null | $EGREP -q '^flex '], + AS_IF([$LEX --version 2>/dev/null | $EGREP -q '^\<flex\>'], [ax_cv_prog_flex=yes], [ax_cv_prog_flex=no]) ]) AS_IF([test "$ax_cv_prog_flex" = "yes"], diff --git a/mesalib/src/gallium/auxiliary/util/u_format_s3tc.c b/mesalib/src/gallium/auxiliary/util/u_format_s3tc.c index 35e3d3445..fd628157b 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_s3tc.c +++ b/mesalib/src/gallium/auxiliary/util/u_format_s3tc.c @@ -27,6 +27,7 @@ #include "u_math.h" #include "u_format.h" #include "u_format_s3tc.h" +#include "u_format_srgb.h" #if defined(_WIN32) || defined(WIN32) @@ -247,7 +248,7 @@ util_format_dxtn_rgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height, util_format_dxtn_fetch_t fetch, - unsigned block_size) + unsigned block_size, boolean srgb) { const unsigned bw = 4, bh = 4, comps = 4; unsigned x, y, i, j; @@ -258,6 +259,11 @@ util_format_dxtn_rgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, for(i = 0; i < bw; ++i) { uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*comps; fetch(0, src, i, j, dst); + if (srgb) { + dst[0] = util_format_srgb_to_linear_8unorm(dst[0]); + dst[1] = util_format_srgb_to_linear_8unorm(dst[1]); + dst[2] = util_format_srgb_to_linear_8unorm(dst[2]); + } } } src += block_size; @@ -274,7 +280,8 @@ util_format_dxt1_rgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height, - util_format_dxt1_rgb_fetch, 8); + util_format_dxt1_rgb_fetch, + 8, FALSE); } void @@ -285,7 +292,8 @@ util_format_dxt1_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height, - util_format_dxt1_rgba_fetch, 8); + util_format_dxt1_rgba_fetch, + 8, FALSE); } void @@ -296,7 +304,8 @@ util_format_dxt3_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height, - util_format_dxt3_rgba_fetch, 16); + util_format_dxt3_rgba_fetch, + 16, FALSE); } void @@ -307,7 +316,8 @@ util_format_dxt5_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height, - util_format_dxt5_rgba_fetch, 16); + util_format_dxt5_rgba_fetch, + 16, FALSE); } static INLINE void @@ -315,7 +325,7 @@ util_format_dxtn_rgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height, util_format_dxtn_fetch_t fetch, - unsigned block_size) + unsigned block_size, boolean srgb) { unsigned x, y, i, j; for(y = 0; y < height; y += 4) { @@ -326,9 +336,16 @@ util_format_dxtn_rgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; uint8_t tmp[4]; fetch(0, src, i, j, tmp); - dst[0] = ubyte_to_float(tmp[0]); - dst[1] = ubyte_to_float(tmp[1]); - dst[2] = ubyte_to_float(tmp[2]); + if (srgb) { + dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]); + dst[1] = util_format_srgb_8unorm_to_linear_float(tmp[1]); + dst[2] = util_format_srgb_8unorm_to_linear_float(tmp[2]); + } + else { + dst[0] = ubyte_to_float(tmp[0]); + dst[1] = ubyte_to_float(tmp[1]); + dst[2] = ubyte_to_float(tmp[2]); + } dst[3] = ubyte_to_float(tmp[3]); } } @@ -346,7 +363,8 @@ util_format_dxt1_rgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height, - util_format_dxt1_rgb_fetch, 8); + util_format_dxt1_rgb_fetch, + 8, FALSE); } void @@ -357,7 +375,8 @@ util_format_dxt1_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height, - util_format_dxt1_rgba_fetch, 8); + util_format_dxt1_rgba_fetch, + 8, FALSE); } void @@ -368,7 +387,8 @@ util_format_dxt3_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height, - util_format_dxt3_rgba_fetch, 16); + util_format_dxt3_rgba_fetch, + 16, FALSE); } void @@ -379,7 +399,8 @@ util_format_dxt5_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height, - util_format_dxt5_rgba_fetch, 16); + util_format_dxt5_rgba_fetch, + 16, FALSE); } @@ -387,29 +408,52 @@ util_format_dxt5_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, * Block compression. */ -void -util_format_dxt1_rgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src, unsigned src_stride, - unsigned width, unsigned height) +static INLINE void +util_format_dxtn_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, + const uint8_t *src, unsigned src_stride, + unsigned width, unsigned height, + enum util_format_dxtn format, + unsigned block_size, boolean srgb) { - const unsigned bw = 4, bh = 4, bytes_per_block = 8; + const unsigned bw = 4, bh = 4, comps = 4; unsigned x, y, i, j, k; for(y = 0; y < height; y += bh) { uint8_t *dst = dst_row; for(x = 0; x < width; x += bw) { - uint8_t tmp[4][4][3]; /* [bh][bw][comps] */ + uint8_t tmp[4][4][4]; /* [bh][bw][comps] */ for(j = 0; j < bh; ++j) { for(i = 0; i < bw; ++i) { + uint8_t src_tmp; for(k = 0; k < 3; ++k) { - tmp[j][i][k] = src[(y + j)*src_stride/sizeof(*src) + (x + i)*4 + k]; + src_tmp = src[(y + j)*src_stride/sizeof(*src) + (x+i)*comps + k]; + if (srgb) { + tmp[j][i][k] = util_format_linear_to_srgb_8unorm(src_tmp); + } + else { + tmp[j][i][k] = src_tmp; + } } + /* for sake of simplicity there's an unneeded 4th component for dxt1_rgb */ + tmp[j][i][3] = src[(y + j)*src_stride/sizeof(*src) + (x+i)*comps + 3]; } } - util_format_dxtn_pack(3, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT1_RGB, dst, 0); - dst += bytes_per_block; + /* even for dxt1_rgb have 4 src comps */ + util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], format, dst, 0); + dst += block_size; } dst_row += dst_stride / sizeof(*dst_row); } + +} + +void +util_format_dxt1_rgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, + const uint8_t *src, unsigned src_stride, + unsigned width, unsigned height) +{ + util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src, src_stride, + width, height, UTIL_FORMAT_DXT1_RGB, + 8, FALSE); } void @@ -417,24 +461,9 @@ util_format_dxt1_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src, unsigned src_stride, unsigned width, unsigned height) { - const unsigned bw = 4, bh = 4, comps = 4, bytes_per_block = 8; - unsigned x, y, i, j, k; - for(y = 0; y < height; y += bh) { - uint8_t *dst = dst_row; - for(x = 0; x < width; x += bw) { - uint8_t tmp[4][4][4]; /* [bh][bw][comps] */ - for(j = 0; j < bh; ++j) { - for(i = 0; i < bw; ++i) { - for(k = 0; k < comps; ++k) { - tmp[j][i][k] = src[(y + j)*src_stride/sizeof(*src) + (x + i)*comps + k]; - } - } - } - util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT1_RGBA, dst, 0); - dst += bytes_per_block; - } - dst_row += dst_stride / sizeof(*dst_row); - } + util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src, src_stride, + width, height, UTIL_FORMAT_DXT1_RGBA, + 8, FALSE); } void @@ -442,24 +471,9 @@ util_format_dxt3_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src, unsigned src_stride, unsigned width, unsigned height) { - const unsigned bw = 4, bh = 4, comps = 4, bytes_per_block = 16; - unsigned x, y, i, j, k; - for(y = 0; y < height; y += bh) { - uint8_t *dst = dst_row; - for(x = 0; x < width; x += bw) { - uint8_t tmp[4][4][4]; /* [bh][bw][comps] */ - for(j = 0; j < bh; ++j) { - for(i = 0; i < bw; ++i) { - for(k = 0; k < comps; ++k) { - tmp[j][i][k] = src[(y + j)*src_stride/sizeof(*src) + (x + i)*comps + k]; - } - } - } - util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT3_RGBA, dst, 0); - dst += bytes_per_block; - } - dst_row += dst_stride / sizeof(*dst_row); - } + util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src, src_stride, + width, height, UTIL_FORMAT_DXT3_RGBA, + 16, FALSE); } void @@ -467,73 +481,65 @@ util_format_dxt5_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src, unsigned src_stride, unsigned width, unsigned height) { - const unsigned bw = 4, bh = 4, comps = 4, bytes_per_block = 16; - unsigned x, y, i, j, k; - - for(y = 0; y < height; y += bh) { - uint8_t *dst = dst_row; - for(x = 0; x < width; x += bw) { - uint8_t tmp[4][4][4]; /* [bh][bw][comps] */ - for(j = 0; j < bh; ++j) { - for(i = 0; i < bw; ++i) { - for(k = 0; k < comps; ++k) { - tmp[j][i][k] = src[(y + j)*src_stride/sizeof(*src) + (x + i)*comps + k]; - } - } - } - util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT5_RGBA, dst, 0); - dst += bytes_per_block; - } - dst_row += dst_stride / sizeof(*dst_row); - } + util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src, src_stride, + width, height, UTIL_FORMAT_DXT5_RGBA, + 16, FALSE); } -void -util_format_dxt1_rgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src, unsigned src_stride, - unsigned width, unsigned height) +static INLINE void +util_format_dxtn_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, + const float *src, unsigned src_stride, + unsigned width, unsigned height, + enum util_format_dxtn format, + unsigned block_size, boolean srgb) { unsigned x, y, i, j, k; for(y = 0; y < height; y += 4) { uint8_t *dst = dst_row; for(x = 0; x < width; x += 4) { - uint8_t tmp[4][4][3]; + uint8_t tmp[4][4][4]; for(j = 0; j < 4; ++j) { for(i = 0; i < 4; ++i) { + float src_tmp; for(k = 0; k < 3; ++k) { - tmp[j][i][k] = float_to_ubyte(src[(y + j)*src_stride/sizeof(*src) + (x+i)*4 + k]); + src_tmp = src[(y + j)*src_stride/sizeof(*src) + (x+i)*4 + k]; + if (srgb) { + tmp[j][i][k] = util_format_linear_float_to_srgb_8unorm(src_tmp); + } + else { + tmp[j][i][k] = float_to_ubyte(src_tmp); + } } + /* for sake of simplicity there's an unneeded 4th component for dxt1_rgb */ + src_tmp = src[(y + j)*src_stride/sizeof(*src) + (x+i)*4 + 3]; + tmp[j][i][3] = float_to_ubyte(src_tmp); } } - util_format_dxtn_pack(3, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT1_RGB, dst, 0); - dst += 8; + util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], format, dst, 0); + dst += block_size; } dst_row += 4*dst_stride/sizeof(*dst_row); } } void +util_format_dxt1_rgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, + const float *src, unsigned src_stride, + unsigned width, unsigned height) +{ + util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src, src_stride, + width, height, UTIL_FORMAT_DXT1_RGB, + 8, FALSE); +} + +void util_format_dxt1_rgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src, unsigned src_stride, unsigned width, unsigned height) { - unsigned x, y, i, j, k; - for(y = 0; y < height; y += 4) { - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 4) { - uint8_t tmp[4][4][4]; - for(j = 0; j < 4; ++j) { - for(i = 0; i < 4; ++i) { - for(k = 0; k < 4; ++k) { - tmp[j][i][k] = float_to_ubyte(src[(y + j)*src_stride/sizeof(*src) + (x+i)*4 + k]); - } - } - } - util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT1_RGBA, dst, 0); - dst += 8; - } - dst_row += 4*dst_stride/sizeof(*dst_row); - } + util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src, src_stride, + width, height, UTIL_FORMAT_DXT1_RGBA, + 8, FALSE); } void @@ -541,23 +547,9 @@ util_format_dxt3_rgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src, unsigned src_stride, unsigned width, unsigned height) { - unsigned x, y, i, j, k; - for(y = 0; y < height; y += 4) { - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 4) { - uint8_t tmp[4][4][4]; - for(j = 0; j < 4; ++j) { - for(i = 0; i < 4; ++i) { - for(k = 0; k < 4; ++k) { - tmp[j][i][k] = float_to_ubyte(src[(y + j)*src_stride/sizeof(*src) + (x+i)*4 + k]); - } - } - } - util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT3_RGBA, dst, 0); - dst += 16; - } - dst_row += 4*dst_stride/sizeof(*dst_row); - } + util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src, src_stride, + width, height, UTIL_FORMAT_DXT3_RGBA, + 16, FALSE); } void @@ -565,173 +557,245 @@ util_format_dxt5_rgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src, unsigned src_stride, unsigned width, unsigned height) { - unsigned x, y, i, j, k; - for(y = 0; y < height; y += 4) { - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 4) { - uint8_t tmp[4][4][4]; - for(j = 0; j < 4; ++j) { - for(i = 0; i < 4; ++i) { - for(k = 0; k < 4; ++k) { - tmp[j][i][k] = float_to_ubyte(src[(y + j)*src_stride/sizeof(*src) + (x+i)*4 + k]); - } - } - } - util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], UTIL_FORMAT_DXT5_RGBA, dst, 0); - dst += 16; - } - dst_row += 4*dst_stride/sizeof(*dst_row); - } + util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src, src_stride, + width, height, UTIL_FORMAT_DXT5_RGBA, + 16, FALSE); } /* * SRGB variants. - * - * FIXME: shunts to RGB for now */ void -util_format_dxt1_srgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt1_srgb_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) { - util_format_dxt1_rgb_unpack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height); + uint8_t tmp[4]; + util_format_dxt1_rgb_fetch(0, src, i, j, tmp); + dst[0] = util_format_srgb_to_linear_8unorm(tmp[0]); + dst[1] = util_format_srgb_to_linear_8unorm(tmp[1]); + dst[2] = util_format_srgb_to_linear_8unorm(tmp[2]); + dst[3] = 255; } void -util_format_dxt1_srgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt1_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) { - util_format_dxt1_rgb_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height); + uint8_t tmp[4]; + util_format_dxt1_rgba_fetch(0, src, i, j, tmp); + dst[0] = util_format_srgb_to_linear_8unorm(tmp[0]); + dst[1] = util_format_srgb_to_linear_8unorm(tmp[1]); + dst[2] = util_format_srgb_to_linear_8unorm(tmp[2]); + dst[3] = tmp[3]; } void -util_format_dxt1_srgb_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) +util_format_dxt3_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) { - util_format_dxt1_rgb_fetch_rgba_8unorm(dst, src, i, j); + uint8_t tmp[4]; + util_format_dxt3_rgba_fetch(0, src, i, j, tmp); + dst[0] = util_format_srgb_to_linear_8unorm(tmp[0]); + dst[1] = util_format_srgb_to_linear_8unorm(tmp[1]); + dst[2] = util_format_srgb_to_linear_8unorm(tmp[2]); + dst[3] = tmp[3]; } void -util_format_dxt1_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt5_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) { - util_format_dxt1_rgba_unpack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height); + uint8_t tmp[4]; + util_format_dxt5_rgba_fetch(0, src, i, j, tmp); + dst[0] = util_format_srgb_to_linear_8unorm(tmp[0]); + dst[1] = util_format_srgb_to_linear_8unorm(tmp[1]); + dst[2] = util_format_srgb_to_linear_8unorm(tmp[2]); + dst[3] = tmp[3]; } void -util_format_dxt1_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt1_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) { - util_format_dxt1_rgba_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height); + uint8_t tmp[4]; + util_format_dxt1_rgb_fetch(0, src, i, j, tmp); + dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]); + dst[1] = util_format_srgb_8unorm_to_linear_float(tmp[1]); + dst[2] = util_format_srgb_8unorm_to_linear_float(tmp[2]); + dst[3] = 1.0f; } void -util_format_dxt1_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) +util_format_dxt1_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) { - util_format_dxt1_rgba_fetch_rgba_8unorm(dst, src, i, j); + uint8_t tmp[4]; + util_format_dxt1_rgba_fetch(0, src, i, j, tmp); + dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]); + dst[1] = util_format_srgb_8unorm_to_linear_float(tmp[1]); + dst[2] = util_format_srgb_8unorm_to_linear_float(tmp[2]); + dst[3] = ubyte_to_float(tmp[3]); } void -util_format_dxt3_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt3_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) { - util_format_dxt3_rgba_unpack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height); + uint8_t tmp[4]; + util_format_dxt3_rgba_fetch(0, src, i, j, tmp); + dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]); + dst[1] = util_format_srgb_8unorm_to_linear_float(tmp[1]); + dst[2] = util_format_srgb_8unorm_to_linear_float(tmp[2]); + dst[3] = ubyte_to_float(tmp[3]); } void -util_format_dxt3_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt5_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) { - util_format_dxt3_rgba_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height); + uint8_t tmp[4]; + util_format_dxt5_rgba_fetch(0, src, i, j, tmp); + dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]); + dst[1] = util_format_srgb_8unorm_to_linear_float(tmp[1]); + dst[2] = util_format_srgb_8unorm_to_linear_float(tmp[2]); + dst[3] = ubyte_to_float(tmp[3]); } void -util_format_dxt3_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) +util_format_dxt1_srgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { - util_format_dxt3_rgba_fetch_rgba_8unorm(dst, src, i, j); + util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride, + src_row, src_stride, + width, height, + util_format_dxt1_rgb_fetch, + 8, TRUE); } void -util_format_dxt5_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt1_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { - util_format_dxt5_rgba_unpack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height); + util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride, + src_row, src_stride, + width, height, + util_format_dxt1_rgba_fetch, + 8, TRUE); } void -util_format_dxt5_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt3_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { - util_format_dxt5_rgba_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, width, height); + util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride, + src_row, src_stride, + width, height, + util_format_dxt3_rgba_fetch, + 16, TRUE); } void -util_format_dxt5_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) +util_format_dxt5_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { - util_format_dxt5_rgba_fetch_rgba_8unorm(dst, src, i, j); + util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride, + src_row, src_stride, + width, height, + util_format_dxt5_rgba_fetch, + 16, TRUE); } void util_format_dxt1_srgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { - util_format_dxt1_rgb_unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height); + util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, + src_row, src_stride, + width, height, + util_format_dxt1_rgb_fetch, + 8, TRUE); } void -util_format_dxt1_srgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt1_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { - util_format_dxt1_rgb_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height); + util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, + src_row, src_stride, + width, height, + util_format_dxt1_rgba_fetch, + 8, TRUE); } void -util_format_dxt1_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) +util_format_dxt3_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { - util_format_dxt1_rgb_fetch_rgba_float(dst, src, i, j); + util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, + src_row, src_stride, + width, height, + util_format_dxt3_rgba_fetch, + 16, TRUE); } void -util_format_dxt1_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt5_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { - util_format_dxt1_rgba_unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height); + util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, + src_row, src_stride, + width, height, + util_format_dxt5_rgba_fetch, + 16, TRUE); } void -util_format_dxt1_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt1_srgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { - util_format_dxt1_rgba_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height); + util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, + width, height, UTIL_FORMAT_DXT1_RGB, + 8, TRUE); } void -util_format_dxt1_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) +util_format_dxt1_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { - util_format_dxt1_rgba_fetch_rgba_float(dst, src, i, j); + util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, + width, height, UTIL_FORMAT_DXT1_RGBA, + 8, TRUE); } void -util_format_dxt3_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt3_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { - util_format_dxt3_rgba_unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height); + util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, + width, height, UTIL_FORMAT_DXT3_RGBA, + 16, TRUE); } void -util_format_dxt3_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt5_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) { - util_format_dxt3_rgba_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height); + util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, + width, height, UTIL_FORMAT_DXT5_RGBA, + 16, TRUE); } void -util_format_dxt3_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) +util_format_dxt1_srgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) { - util_format_dxt3_rgba_fetch_rgba_float(dst, src, i, j); + util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, + width, height, UTIL_FORMAT_DXT1_RGB, + 8, TRUE); } void -util_format_dxt5_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt1_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) { - util_format_dxt5_rgba_unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height); + util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, + width, height, UTIL_FORMAT_DXT1_RGBA, + 8, TRUE); } void -util_format_dxt5_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt3_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) { - util_format_dxt5_rgba_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height); + util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, + width, height, UTIL_FORMAT_DXT3_RGBA, + 16, TRUE); } void -util_format_dxt5_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) +util_format_dxt5_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) { - util_format_dxt5_rgba_fetch_rgba_float(dst, src, i, j); + util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, + width, height, UTIL_FORMAT_DXT5_RGBA, + 16, TRUE); } diff --git a/mesalib/src/gallium/auxiliary/util/u_format_srgb.h b/mesalib/src/gallium/auxiliary/util/u_format_srgb.h index 43213fbeb..82ed9575d 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_srgb.h +++ b/mesalib/src/gallium/auxiliary/util/u_format_srgb.h @@ -83,6 +83,11 @@ util_format_srgb_8unorm_to_linear_float(uint8_t x) } +/* + * XXX These 2 functions probably don't make a lot of sense (but lots + * of potential callers which most likely all don't make sense neither) + */ + /** * Convert a 8bit normalized value from linear to srgb. */ diff --git a/mesalib/src/glsl/ast.h b/mesalib/src/glsl/ast.h index ff603b352..5f2d5b1e4 100644 --- a/mesalib/src/glsl/ast.h +++ b/mesalib/src/glsl/ast.h @@ -417,6 +417,12 @@ struct ast_type_qualifier { */ unsigned explicit_index:1; + /** + * Flag set if GL_ARB_shading_language_420pack "binding" layout + * qualifier is used. + */ + unsigned explicit_binding:1; + /** \name Layout qualifiers for GL_AMD_conservative_depth */ /** \{ */ unsigned depth_any:1; @@ -441,6 +447,9 @@ struct ast_type_qualifier { unsigned i; } flags; + /** Precision of the type (highp/medium/lowp). */ + unsigned precision:2; + /** * Location specified via GL_ARB_explicit_attrib_location layout * @@ -457,11 +466,34 @@ struct ast_type_qualifier { int index; /** + * Binding specified via GL_ARB_shading_language_420pack's "binding" keyword. + * + * \note + * This field is only valid if \c explicit_binding is set. + */ + int binding; + + /** * Return true if and only if an interpolation qualifier is present. */ bool has_interpolation() const; /** + * Return whether a layout qualifier is present. + */ + bool has_layout() const; + + /** + * Return whether a storage qualifier is present. + */ + bool has_storage() const; + + /** + * Return whether an auxiliary storage qualifier is present. + */ + bool has_auxiliary_storage() const; + + /** * \brief Return string representation of interpolation qualifier. * * If an interpolation qualifier is present, then return that qualifier's @@ -522,8 +554,8 @@ public: ast_type_specifier(const ast_type_specifier *that, bool is_array, ast_expression *array_size) : ast_node(), type_name(that->type_name), structure(that->structure), - is_array(is_array), array_size(array_size), precision(that->precision), - is_precision_statement(that->is_precision_statement) + is_array(is_array), array_size(array_size), + default_precision(that->default_precision) { /* empty */ } @@ -531,8 +563,8 @@ public: /** Construct a type specifier from a type name */ ast_type_specifier(const char *name) : type_name(name), structure(NULL), - is_array(false), array_size(NULL), precision(ast_precision_none), - is_precision_statement(false) + is_array(false), array_size(NULL), + default_precision(ast_precision_none) { /* empty */ } @@ -540,8 +572,8 @@ public: /** Construct a type specifier from a structure definition */ ast_type_specifier(ast_struct_specifier *s) : type_name(s->name), structure(s), - is_array(false), array_size(NULL), precision(ast_precision_none), - is_precision_statement(false) + is_array(false), array_size(NULL), + default_precision(ast_precision_none) { /* empty */ } @@ -560,9 +592,8 @@ public: bool is_array; ast_expression *array_size; - unsigned precision:2; - - bool is_precision_statement; + /** For precision statements, this is the given precision; otherwise none. */ + unsigned default_precision:2; }; diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp index 28ccf7288..bfd5fda8f 100644 --- a/mesalib/src/glsl/ast_to_hir.cpp +++ b/mesalib/src/glsl/ast_to_hir.cpp @@ -1850,6 +1850,84 @@ validate_matrix_layout_for_type(struct _mesa_glsl_parse_state *state, } } +static bool +validate_binding_qualifier(struct _mesa_glsl_parse_state *state, + YYLTYPE *loc, + ir_variable *var, + const ast_type_qualifier *qual) +{ + if (var->mode != ir_var_uniform) { + _mesa_glsl_error(loc, state, + "the \"binding\" qualifier only applies to uniforms.\n"); + return false; + } + + if (qual->binding < 0) { + _mesa_glsl_error(loc, state, "binding values must be >= 0.\n"); + return false; + } + + const struct gl_context *const ctx = state->ctx; + unsigned elements = var->type->is_array() ? var->type->length : 1; + unsigned max_index = qual->binding + elements - 1; + + if (var->type->is_interface()) { + /* UBOs. From page 60 of the GLSL 4.20 specification: + * "If the binding point for any uniform block instance is less than zero, + * or greater than or equal to the implementation-dependent maximum + * number of uniform buffer bindings, a compilation error will occur. + * When the binding identifier is used with a uniform block instanced as + * an array of size N, all elements of the array from binding through + * binding + N – 1 must be within this range." + * + * The implementation-dependent maximum is GL_MAX_UNIFORM_BUFFER_BINDINGS. + */ + if (max_index >= ctx->Const.MaxUniformBufferBindings) { + _mesa_glsl_error(loc, state, "layout(binding = %d) for %d UBOs exceeds " + "the maximum number of UBO binding points (%d).\n", + qual->binding, elements, + ctx->Const.MaxUniformBufferBindings); + return false; + } + } else if (var->type->is_sampler() || + (var->type->is_array() && var->type->fields.array->is_sampler())) { + /* Samplers. From page 63 of the GLSL 4.20 specification: + * "If the binding is less than zero, or greater than or equal to the + * implementation-dependent maximum supported number of units, a + * compilation error will occur. When the binding identifier is used + * with an array of size N, all elements of the array from binding + * through binding + N - 1 must be within this range." + */ + unsigned limit; + switch (state->target) { + case vertex_shader: + limit = ctx->Const.VertexProgram.MaxTextureImageUnits; + break; + case geometry_shader: + limit = ctx->Const.GeometryProgram.MaxTextureImageUnits; + break; + case fragment_shader: + limit = ctx->Const.FragmentProgram.MaxTextureImageUnits; + break; + } + + if (max_index >= limit) { + _mesa_glsl_error(loc, state, "layout(binding = %d) for %d samplers " + "exceeds the maximum number of texture image units " + "(%d).\n", qual->binding, elements, limit); + + return false; + } + } else { + _mesa_glsl_error(loc, state, + "the \"binding\" qualifier only applies to uniform " + "blocks, samplers, or arrays of samplers.\n"); + return false; + } + + return true; +} + static void apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, ir_variable *var, @@ -2080,11 +2158,11 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, "explicit index requires explicit location\n"); } - /* Does the declaration use the 'layout' keyword? - */ - const bool uses_layout = qual->flags.q.pixel_center_integer - || qual->flags.q.origin_upper_left - || qual->flags.q.explicit_location; /* no need for index since it relies on location */ + if (qual->flags.q.explicit_binding && + validate_binding_qualifier(state, loc, var, qual)) { + var->explicit_binding = true; + var->binding = qual->binding; + } /* Does the declaration use the deprecated 'attribute' or 'varying' * keywords? @@ -2115,7 +2193,7 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, const bool relaxed_layout_qualifier_checking = state->ARB_fragment_coord_conventions_enable; - if (uses_layout && uses_deprecated_qualifier) { + if (qual->has_layout() && uses_deprecated_qualifier) { if (relaxed_layout_qualifier_checking) { _mesa_glsl_warning(loc, state, "`layout' qualifier may not be used with " @@ -2544,6 +2622,12 @@ ast_declarator_list::hir(exec_list *instructions, type_name); } } + + if (this->type->qualifier.precision != ast_precision_none && + this->type->specifier->structure != NULL) { + _mesa_glsl_error(&loc, state, "Precision qualifiers can't be applied " + "to structures.\n"); + } } foreach_list_typed (ast_declaration, decl, link, &this->declarations) { @@ -2846,7 +2930,7 @@ ast_declarator_list::hir(exec_list *instructions, /* Precision qualifiers exists only in GLSL versions 1.00 and >= 1.30. */ - if (this->type->specifier->precision != ast_precision_none) { + if (this->type->qualifier.precision != ast_precision_none) { state->check_precision_qualifiers_allowed(&loc); } @@ -2864,9 +2948,10 @@ ast_declarator_list::hir(exec_list *instructions, * From page 87 of the GLSL ES spec: * "RESOLUTION: Allow sampler types to take a precision qualifier." */ - if (this->type->specifier->precision != ast_precision_none + if (this->type->qualifier.precision != ast_precision_none && !var->type->is_float() && !var->type->is_integer() + && !var->type->is_record() && !(var->type->is_sampler() && state->es_shader) && !(var->type->is_array() && (var->type->fields.array->is_float() @@ -3958,22 +4043,11 @@ ir_rvalue * ast_type_specifier::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { - if (!this->is_precision_statement && this->structure == NULL) + if (this->default_precision == ast_precision_none && this->structure == NULL) return NULL; YYLTYPE loc = this->get_location(); - if (this->precision != ast_precision_none - && !state->check_precision_qualifiers_allowed(&loc)) { - return NULL; - } - if (this->precision != ast_precision_none - && this->structure != NULL) { - _mesa_glsl_error(&loc, state, - "precision qualifiers do not apply to structures"); - return NULL; - } - /* If this is a precision statement, check that the type to which it is * applied is either float or int. * @@ -3984,10 +4058,16 @@ ast_type_specifier::hir(exec_list *instructions, * field can be either int or float [...]. Any other types or * qualifiers will result in an error. */ - if (this->is_precision_statement) { - assert(this->precision != ast_precision_none); - assert(this->structure == NULL); /* The check for structures was - * performed above. */ + if (this->default_precision != ast_precision_none) { + if (!state->check_precision_qualifiers_allowed(&loc)) + return NULL; + + if (this->structure != NULL) { + _mesa_glsl_error(&loc, state, + "precision qualifiers do not apply to structures"); + return NULL; + } + if (this->is_array) { _mesa_glsl_error(&loc, state, "default precision statements do not apply to " @@ -4307,6 +4387,13 @@ ast_interface_block::hir(exec_list *instructions, var_mode); var->interface_type = block_type; + /* Propagate the "binding" keyword into this UBO's fields; + * the UBO declaration itself doesn't get an ir_variable unless it + * has an instance name. This is ugly. + */ + var->explicit_binding = this->layout.flags.q.explicit_binding; + var->binding = this->layout.binding; + state->symbols->add_variable(var); instructions->push_tail(var); } diff --git a/mesalib/src/glsl/ast_type.cpp b/mesalib/src/glsl/ast_type.cpp index be84550da..275b2a1d0 100644 --- a/mesalib/src/glsl/ast_type.cpp +++ b/mesalib/src/glsl/ast_type.cpp @@ -56,6 +56,42 @@ bool ast_type_qualifier::has_interpolation() const || this->flags.q.noperspective; } +bool +ast_type_qualifier::has_layout() const +{ + return this->flags.q.origin_upper_left + || this->flags.q.pixel_center_integer + || this->flags.q.depth_any + || this->flags.q.depth_greater + || this->flags.q.depth_less + || this->flags.q.depth_unchanged + || this->flags.q.std140 + || this->flags.q.shared + || this->flags.q.column_major + || this->flags.q.row_major + || this->flags.q.packed + || this->flags.q.explicit_location + || this->flags.q.explicit_index + || this->flags.q.explicit_binding; +} + +bool +ast_type_qualifier::has_storage() const +{ + return this->flags.q.constant + || this->flags.q.attribute + || this->flags.q.varying + || this->flags.q.in + || this->flags.q.out + || this->flags.q.uniform; +} + +bool +ast_type_qualifier::has_auxiliary_storage() const +{ + return this->flags.q.centroid; +} + const char* ast_type_qualifier::interpolation_string() const { @@ -110,6 +146,9 @@ ast_type_qualifier::merge_qualifier(YYLTYPE *loc, if (q.flags.q.explicit_index) this->index = q.index; + if (q.flags.q.explicit_binding) + this->binding = q.binding; + return true; } diff --git a/mesalib/src/glsl/builtin_compiler/Makefile.am b/mesalib/src/glsl/builtin_compiler/Makefile.am index 823d546e1..5f1a995c3 100644 --- a/mesalib/src/glsl/builtin_compiler/Makefile.am +++ b/mesalib/src/glsl/builtin_compiler/Makefile.am @@ -65,6 +65,8 @@ AM_CXXFLAGS = $(AM_CFLAGS) include ../Makefile.sources noinst_PROGRAMS = builtin_compiler + +if !CROSS_COMPILING noinst_LTLIBRARIES = libglslcore.la libglcpp.la libglcpp_la_SOURCES = \ @@ -74,6 +76,7 @@ libglcpp_la_SOURCES = \ libglslcore_la_SOURCES = \ $(BUILTIN_COMPILER_GENERATED_CXX_FILES) \ $(LIBGLSL_FILES) +endif builtin_compiler_SOURCES = \ $(top_srcdir)/src/mesa/main/hash_table.c \ @@ -82,4 +85,14 @@ builtin_compiler_SOURCES = \ $(top_srcdir)/src/mesa/program/symbol_table.c \ $(BUILTIN_COMPILER_CXX_FILES) \ $(GLSL_COMPILER_CXX_FILES) + +if CROSS_COMPILING +builtin_compiler_SOURCES += \ + $(LIBGLCPP_GENERATED_FILES) \ + $(LIBGLCPP_FILES) \ + $(BUILTIN_COMPILER_GENERATED_CXX_FILES) \ + $(LIBGLSL_FILES) +builtin_compiler_CPPFLAGS = $(AM_CPPFLAGS) +else builtin_compiler_LDADD = libglslcore.la libglcpp.la +endif diff --git a/mesalib/src/glsl/glsl_lexer.ll b/mesalib/src/glsl/glsl_lexer.ll index e66ce7bee..dbc8154e4 100644 --- a/mesalib/src/glsl/glsl_lexer.ll +++ b/mesalib/src/glsl/glsl_lexer.ll @@ -366,7 +366,8 @@ layout { || yyextra->ARB_conservative_depth_enable || yyextra->ARB_explicit_attrib_location_enable || yyextra->ARB_uniform_buffer_object_enable - || yyextra->ARB_fragment_coord_conventions_enable) { + || yyextra->ARB_fragment_coord_conventions_enable + || yyextra->ARB_shading_language_420pack_enable) { return LAYOUT_TOK; } else { yylval->identifier = strdup(yytext); diff --git a/mesalib/src/glsl/glsl_parser.yy b/mesalib/src/glsl/glsl_parser.yy index b8f3df90e..cbd94b41f 100644 --- a/mesalib/src/glsl/glsl_parser.yy +++ b/mesalib/src/glsl/glsl_parser.yy @@ -162,6 +162,7 @@ static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg) %type <node> simple_statement %type <n> precision_qualifier %type <type_qualifier> type_qualifier +%type <type_qualifier> auxiliary_storage_qualifier %type <type_qualifier> storage_qualifier %type <type_qualifier> interpolation_qualifier %type <type_qualifier> layout_qualifier @@ -169,7 +170,6 @@ static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg) %type <type_qualifier> interface_block_layout_qualifier %type <type_qualifier> interface_qualifier %type <type_specifier> type_specifier -%type <type_specifier> type_specifier_no_prec %type <type_specifier> type_specifier_nonarray %type <identifier> basic_type_specifier_nonarray %type <fully_specified_type> fully_specified_type @@ -180,7 +180,7 @@ static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg) %type <parameter_declarator> parameter_declarator %type <parameter_declarator> parameter_declaration %type <type_qualifier> parameter_qualifier -%type <type_qualifier> parameter_type_qualifier +%type <type_qualifier> parameter_direction_qualifier %type <type_specifier> parameter_type_specifier %type <function_definition> function_definition %type <compound_statement> compound_statement_no_new_scope @@ -790,10 +790,9 @@ declaration: { $$ = $1; } - | PRECISION precision_qualifier type_specifier_no_prec ';' + | PRECISION precision_qualifier type_specifier ';' { - $3->precision = $2; - $3->is_precision_statement = true; + $3->default_precision = $2; $$ = $3; } | interface_block @@ -864,29 +863,11 @@ parameter_declarator: ; parameter_declaration: - parameter_type_qualifier parameter_qualifier parameter_declarator - { - $1.flags.i |= $2.flags.i; - - $$ = $3; - $$->type->qualifier = $1; - } - | parameter_qualifier parameter_declarator + parameter_qualifier parameter_declarator { $$ = $2; $$->type->qualifier = $1; } - | parameter_type_qualifier parameter_qualifier parameter_type_specifier - { - void *ctx = state; - $1.flags.i |= $2.flags.i; - - $$ = new(ctx) ast_parameter_declarator(); - $$->set_location(yylloc); - $$->type = new(ctx) ast_fully_specified_type(); - $$->type->qualifier = $1; - $$->type->specifier = $3; - } | parameter_qualifier parameter_type_specifier { void *ctx = state; @@ -903,7 +884,40 @@ parameter_qualifier: { memset(& $$, 0, sizeof($$)); } - | IN_TOK + | CONST_TOK parameter_qualifier + { + if ($2.flags.q.constant) + _mesa_glsl_error(&@1, state, "duplicate const qualifier.\n"); + + $$ = $2; + $$.flags.q.constant = 1; + } + | parameter_direction_qualifier parameter_qualifier + { + if (($1.flags.q.in || $1.flags.q.out) && ($2.flags.q.in || $2.flags.q.out)) + _mesa_glsl_error(&@1, state, "duplicate in/out/inout qualifier\n"); + + if (!state->ARB_shading_language_420pack_enable && $2.flags.q.constant) + _mesa_glsl_error(&@1, state, "const must be specified before " + "in/out/inout.\n"); + + $$ = $1; + $$.merge_qualifier(&@1, state, $2); + } + | precision_qualifier parameter_qualifier + { + if ($2.precision != ast_precision_none) + _mesa_glsl_error(&@1, state, "Duplicate precision qualifier.\n"); + + if (!state->ARB_shading_language_420pack_enable && $2.flags.i != 0) + _mesa_glsl_error(&@1, state, "Precision qualifiers must come last.\n"); + + $$ = $2; + $$.precision = $1; + } + +parameter_direction_qualifier: + IN_TOK { memset(& $$, 0, sizeof($$)); $$.flags.q.in = 1; @@ -1240,6 +1254,12 @@ layout_qualifier_id: } } + if (state->ARB_shading_language_420pack_enable && + strcmp("binding", $1) == 0) { + $$.flags.q.explicit_binding = 1; + $$.binding = $3; + } + /* If the identifier didn't match any known layout identifiers, * emit an error. */ @@ -1305,45 +1325,154 @@ interpolation_qualifier: } ; -parameter_type_qualifier: - CONST_TOK +type_qualifier: + /* Single qualifiers */ + INVARIANT { memset(& $$, 0, sizeof($$)); - $$.flags.q.constant = 1; + $$.flags.q.invariant = 1; } - ; - -type_qualifier: - storage_qualifier + | auxiliary_storage_qualifier + | storage_qualifier + | interpolation_qualifier | layout_qualifier - | layout_qualifier storage_qualifier + | precision_qualifier + { + memset(&$$, 0, sizeof($$)); + $$.precision = $1; + } + + /* Multiple qualifiers: + * In GLSL 4.20, these can be specified in any order. In earlier versions, + * they appear in this order (see GLSL 1.50 section 4.7 & comments below): + * + * invariant interpolation auxiliary storage precision ...or... + * layout storage precision + * + * Each qualifier's rule ensures that the accumulated qualifiers on the right + * side don't contain any that must appear on the left hand side. + * For example, when processing a storage qualifier, we check that there are + * no auxiliary, interpolation, layout, or invariant qualifiers to the right. + */ + | INVARIANT type_qualifier + { + if ($2.flags.q.invariant) + _mesa_glsl_error(&@1, state, "Duplicate \"invariant\" qualifier.\n"); + + if ($2.has_layout()) { + _mesa_glsl_error(&@1, state, + "\"invariant\" cannot be used with layout(...).\n"); + } + + $$ = $2; + $$.flags.q.invariant = 1; + } + | interpolation_qualifier type_qualifier + { + /* Section 4.3 of the GLSL 1.40 specification states: + * "...qualified with one of these interpolation qualifiers" + * + * GLSL 1.30 claims to allow "one or more", but insists that: + * "These interpolation qualifiers may only precede the qualifiers in, + * centroid in, out, or centroid out in a declaration." + * + * ...which means that e.g. smooth can't precede smooth, so there can be + * only one after all, and the 1.40 text is a clarification, not a change. + */ + if ($2.has_interpolation()) + _mesa_glsl_error(&@1, state, "Duplicate interpolation qualifier.\n"); + + if ($2.has_layout()) { + _mesa_glsl_error(&@1, state, "Interpolation qualifiers cannot be used " + "with layout(...).\n"); + } + + if (!state->ARB_shading_language_420pack_enable && $2.flags.q.invariant) { + _mesa_glsl_error(&@1, state, "Interpolation qualifiers must come " + "after \"invariant\".\n"); + } + + $$ = $1; + $$.merge_qualifier(&@1, state, $2); + } + | layout_qualifier type_qualifier { + /* The GLSL 1.50 grammar indicates that a layout(...) declaration can be + * used standalone or immediately before a storage qualifier. It cannot + * be used with interpolation qualifiers or invariant. There does not + * appear to be any text indicating that it must come before the storage + * qualifier, but always seems to in examples. + */ + if (!state->ARB_shading_language_420pack_enable && $2.has_layout()) + _mesa_glsl_error(&@1, state, "Duplicate layout(...) qualifiers.\n"); + + if ($2.flags.q.invariant) + _mesa_glsl_error(&@1, state, "layout(...) cannot be used with " + "the \"invariant\" qualifier\n"); + + if ($2.has_interpolation()) { + _mesa_glsl_error(&@1, state, "layout(...) cannot be used with " + "interpolation qualifiers.\n"); + } + $$ = $1; - $$.flags.i |= $2.flags.i; + $$.merge_qualifier(&@1, state, $2); } - | interpolation_qualifier - | interpolation_qualifier storage_qualifier + | auxiliary_storage_qualifier type_qualifier { + if ($2.has_auxiliary_storage()) { + _mesa_glsl_error(&@1, state, + "Duplicate auxiliary storage qualifier (centroid).\n"); + } + + if (!state->ARB_shading_language_420pack_enable && + ($2.flags.q.invariant || $2.has_interpolation() || $2.has_layout())) { + _mesa_glsl_error(&@1, state, "Auxiliary storage qualifiers must come " + "just before storage qualifiers.\n"); + } $$ = $1; $$.flags.i |= $2.flags.i; } - | INVARIANT storage_qualifier + | storage_qualifier type_qualifier { - $$ = $2; - $$.flags.q.invariant = 1; + /* Section 4.3 of the GLSL 1.20 specification states: + * "Variable declarations may have a storage qualifier specified..." + * 1.30 clarifies this to "may have one storage qualifier". + */ + if ($2.has_storage()) + _mesa_glsl_error(&@1, state, "Duplicate storage qualifier.\n"); + + if (!state->ARB_shading_language_420pack_enable && + ($2.flags.q.invariant || $2.has_interpolation() || $2.has_layout() || + $2.has_auxiliary_storage())) { + _mesa_glsl_error(&@1, state, "Storage qualifiers must come after " + "invariant, interpolation, layout and auxiliary " + "storage qualifiers.\n"); + } + + $$ = $1; + $$.merge_qualifier(&@1, state, $2); } - | INVARIANT interpolation_qualifier storage_qualifier + | precision_qualifier type_qualifier { + if ($2.precision != ast_precision_none) + _mesa_glsl_error(&@1, state, "Duplicate precision qualifier.\n"); + + if (!state->ARB_shading_language_420pack_enable && $2.flags.i != 0) + _mesa_glsl_error(&@1, state, "Precision qualifiers must come last.\n"); + $$ = $2; - $$.flags.i |= $3.flags.i; - $$.flags.q.invariant = 1; + $$.precision = $1; } - | INVARIANT + ; + +auxiliary_storage_qualifier: + CENTROID { memset(& $$, 0, sizeof($$)); - $$.flags.q.invariant = 1; + $$.flags.q.centroid = 1; } - ; + /* TODO: "sample" and "patch" also go here someday. */ storage_qualifier: CONST_TOK @@ -1361,12 +1490,6 @@ storage_qualifier: memset(& $$, 0, sizeof($$)); $$.flags.q.varying = 1; } - | CENTROID VARYING - { - memset(& $$, 0, sizeof($$)); - $$.flags.q.centroid = 1; - $$.flags.q.varying = 1; - } | IN_TOK { memset(& $$, 0, sizeof($$)); @@ -1377,16 +1500,6 @@ storage_qualifier: memset(& $$, 0, sizeof($$)); $$.flags.q.out = 1; } - | CENTROID IN_TOK - { - memset(& $$, 0, sizeof($$)); - $$.flags.q.centroid = 1; $$.flags.q.in = 1; - } - | CENTROID OUT_TOK - { - memset(& $$, 0, sizeof($$)); - $$.flags.q.centroid = 1; $$.flags.q.out = 1; - } | UNIFORM { memset(& $$, 0, sizeof($$)); @@ -1395,18 +1508,6 @@ storage_qualifier: ; type_specifier: - type_specifier_no_prec - { - $$ = $1; - } - | precision_qualifier type_specifier_no_prec - { - $$ = $2; - $$->precision = $1; - } - ; - -type_specifier_no_prec: type_specifier_nonarray | type_specifier_nonarray '[' ']' { diff --git a/mesalib/src/glsl/ir.h b/mesalib/src/glsl/ir.h index 1f0dc0906..7ac291cf4 100644 --- a/mesalib/src/glsl/ir.h +++ b/mesalib/src/glsl/ir.h @@ -471,6 +471,14 @@ public: unsigned explicit_index:1; /** + * Was an initial binding explicitly set in the shader? + * + * If so, constant_value contains an integer ir_constant representing the + * initial binding point. + */ + unsigned explicit_binding:1; + + /** * Does this variable have an initializer? * * This is used by the linker to cross-validiate initializers of global @@ -528,6 +536,13 @@ public: int index; /** + * Initial binding point for a sampler or UBO. + * + * For array types, this represents the binding point for the first element. + */ + int binding; + + /** * Built-in state that backs this uniform * * Once set at variable creation, \c state_slots must remain invariant. diff --git a/mesalib/src/glsl/ir_clone.cpp b/mesalib/src/glsl/ir_clone.cpp index 5b42935f8..9d4178de8 100644 --- a/mesalib/src/glsl/ir_clone.cpp +++ b/mesalib/src/glsl/ir_clone.cpp @@ -50,11 +50,13 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) const var->interpolation = this->interpolation; var->location = this->location; var->index = this->index; + var->binding = this->binding; var->warn_extension = this->warn_extension; var->origin_upper_left = this->origin_upper_left; var->pixel_center_integer = this->pixel_center_integer; var->explicit_location = this->explicit_location; var->explicit_index = this->explicit_index; + var->explicit_binding = this->explicit_binding; var->has_initializer = this->has_initializer; var->depth_layout = this->depth_layout; diff --git a/mesalib/src/glsl/ir_optimization.h b/mesalib/src/glsl/ir_optimization.h index fad6f1bfe..2c1479ff4 100644 --- a/mesalib/src/glsl/ir_optimization.h +++ b/mesalib/src/glsl/ir_optimization.h @@ -61,7 +61,7 @@ enum lower_packing_builtins_op { LOWER_UNPACK_SNORM_4x8 = 0x0200, LOWER_PACK_UNORM_4x8 = 0x0400, - LOWER_UNPACK_UNORM_4x8 = 0x0800, + LOWER_UNPACK_UNORM_4x8 = 0x0800 }; bool do_common_optimization(exec_list *ir, bool linked, diff --git a/mesalib/src/glsl/link_uniform_initializers.cpp b/mesalib/src/glsl/link_uniform_initializers.cpp index 54d9bf1f5..3f6671047 100644 --- a/mesalib/src/glsl/link_uniform_initializers.cpp +++ b/mesalib/src/glsl/link_uniform_initializers.cpp @@ -82,6 +82,56 @@ copy_constant_to_storage(union gl_constant_value *storage, } void +set_uniform_binding(void *mem_ctx, gl_shader_program *prog, + const char *name, const glsl_type *type, int binding) +{ + struct gl_uniform_storage *const storage = + get_storage(prog->UniformStorage, prog->NumUserUniformStorage, name); + + if (storage == NULL) { + assert(storage != NULL); + return; + } + + if (storage->type->is_sampler()) { + unsigned elements = MAX2(storage->array_elements, 1); + + /* From section 4.4.4 of the GLSL 4.20 specification: + * "If the binding identifier is used with an array, the first element + * of the array takes the specified unit and each subsequent element + * takes the next consecutive unit." + */ + for (unsigned int i = 0; i < elements; i++) { + storage->storage[i].i = binding + i; + } + + for (int sh = 0; sh < MESA_SHADER_TYPES; sh++) { + gl_shader *shader = prog->_LinkedShaders[sh]; + + if (shader && storage->sampler[sh].active) { + for (unsigned i = 0; i < elements; i++) { + unsigned index = storage->sampler[sh].index + i; + + shader->SamplerUnits[index] = storage->storage[i].i; + } + } + } + } else if (storage->block_index != -1) { + /* This is a field of a UBO. val is the binding index. */ + for (int i = 0; i < MESA_SHADER_TYPES; i++) { + int stage_index = prog->UniformBlockStageIndex[i][storage->block_index]; + + if (stage_index != -1) { + struct gl_shader *sh = prog->_LinkedShaders[i]; + sh->UniformBlocks[stage_index].Binding = binding; + } + } + } + + storage->initialized = true; +} + +void set_uniform_initializer(void *mem_ctx, gl_shader_program *prog, const char *name, const glsl_type *type, ir_constant *val) @@ -136,20 +186,6 @@ set_uniform_initializer(void *mem_ctx, gl_shader_program *prog, idx += elements; } - - if (base_type == GLSL_TYPE_SAMPLER) { - for (int sh = 0; sh < MESA_SHADER_TYPES; sh++) { - gl_shader *shader = prog->_LinkedShaders[sh]; - - if (shader && storage->sampler[sh].active) { - for (unsigned i = 0; i < storage->array_elements; i++) { - unsigned index = storage->sampler[sh].index + i; - - shader->SamplerUnits[index] = storage->storage[i].i; - } - } - } - } } else { copy_constant_to_storage(storage->storage, val, @@ -187,14 +223,19 @@ link_set_uniform_initializers(struct gl_shader_program *prog) foreach_list(node, shader->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if (!var || var->mode != ir_var_uniform || !var->constant_value) + if (!var || var->mode != ir_var_uniform) continue; if (!mem_ctx) mem_ctx = ralloc_context(NULL); - linker::set_uniform_initializer(mem_ctx, prog, var->name, - var->type, var->constant_value); + if (var->explicit_binding) { + linker::set_uniform_binding(mem_ctx, prog, var->name, + var->type, var->binding); + } else if (var->constant_value) { + linker::set_uniform_initializer(mem_ctx, prog, var->name, + var->type, var->constant_value); + } } } diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp index ba97ade25..ac010cfbb 100644 --- a/mesalib/src/glsl/linker.cpp +++ b/mesalib/src/glsl/linker.cpp @@ -541,6 +541,25 @@ cross_validate_globals(struct gl_shader_program *prog, existing->explicit_location = true; } + /* From the GLSL 4.20 specification: + * "A link error will result if two compilation units in a program + * specify different integer-constant bindings for the same + * opaque-uniform name. However, it is not an error to specify a + * binding on some but not all declarations for the same name" + */ + if (var->explicit_binding) { + if (existing->explicit_binding && + var->binding != existing->binding) { + linker_error(prog, "explicit bindings for %s " + "`%s' have differing values\n", + mode_string(var), var->name); + return false; + } + + existing->binding = var->binding; + existing->explicit_binding = true; + } + /* Validate layout qualifiers for gl_FragDepth. * * From the AMD/ARB_conservative_depth specs: @@ -1147,7 +1166,7 @@ update_array_sizes(struct gl_shader_program *prog) } } - if (size + 1 != var->type->fields.array->length) { + if (size + 1 != var->type->length) { /* If this is a built-in uniform (i.e., it's backed by some * fixed-function state), adjust the number of state slots to * match the new array size. The number of slots per array entry diff --git a/mesalib/src/mapi/glapi/gen/ARB_framebuffer_object.xml b/mesalib/src/mapi/glapi/gen/ARB_framebuffer_object.xml index 87eda93eb..7c547c167 100644 --- a/mesalib/src/mapi/glapi/gen/ARB_framebuffer_object.xml +++ b/mesalib/src/mapi/glapi/gen/ARB_framebuffer_object.xml @@ -149,7 +149,7 @@ <function name="BindRenderbuffer" es2="2.0" offset="assign"> <param name="target" type="GLenum"/> <param name="renderbuffer" type="GLuint"/> - <glx rop="4316"/> + <glx rop="235"/> </function> <function name="DeleteRenderbuffers" @@ -199,7 +199,7 @@ <function name="BindFramebuffer" es2="2.0" offset="assign"> <param name="target" type="GLenum"/> <param name="framebuffer" type="GLuint"/> - <glx rop="4319"/> + <glx rop="236"/> </function> <function name="DeleteFramebuffers" diff --git a/mesalib/src/mapi/glapi/gen/EXT_framebuffer_object.xml b/mesalib/src/mapi/glapi/gen/EXT_framebuffer_object.xml index 85a05f6ed..16c82a4a2 100644 --- a/mesalib/src/mapi/glapi/gen/EXT_framebuffer_object.xml +++ b/mesalib/src/mapi/glapi/gen/EXT_framebuffer_object.xml @@ -78,9 +78,10 @@ <return type="GLboolean"/> </function> - <function name="BindRenderbufferEXT" alias="BindRenderbuffer"> + <function name="BindRenderbufferEXT" offset="assign"> <param name="target" type="GLenum"/> <param name="renderbuffer" type="GLuint"/> + <glx rop="4316"/> </function> <function name="DeleteRenderbuffersEXT" alias="DeleteRenderbuffers"> @@ -111,9 +112,10 @@ <return type="GLboolean"/> </function> - <function name="BindFramebufferEXT" alias="BindFramebuffer"> + <function name="BindFramebufferEXT" offset="assign"> <param name="target" type="GLenum"/> <param name="framebuffer" type="GLuint"/> + <glx rop="4319"/> </function> <function name="DeleteFramebuffersEXT" alias="DeleteFramebuffers"> diff --git a/mesalib/src/mesa/drivers/dri/common/utils.c b/mesalib/src/mesa/drivers/dri/common/utils.c index ac0773b0d..c9fc21891 100644 --- a/mesalib/src/mesa/drivers/dri/common/utils.c +++ b/mesalib/src/mesa/drivers/dri/common/utils.c @@ -366,7 +366,6 @@ static const struct { unsigned int attrib, offset; } attribMap[] = { __ATTRIB(__DRI_ATTRIB_TRANSPARENT_GREEN_VALUE, transparentGreen), __ATTRIB(__DRI_ATTRIB_TRANSPARENT_BLUE_VALUE, transparentBlue), __ATTRIB(__DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE, transparentAlpha), - __ATTRIB(__DRI_ATTRIB_FLOAT_MODE, floatMode), __ATTRIB(__DRI_ATTRIB_RED_MASK, redMask), __ATTRIB(__DRI_ATTRIB_GREEN_MASK, greenMask), __ATTRIB(__DRI_ATTRIB_BLUE_MASK, blueMask), @@ -418,11 +417,6 @@ driGetConfigAttribIndex(const __DRIconfig *config, /* XXX no return value??? */ break; - case __DRI_ATTRIB_FLOAT_MODE: - /* this field is not int-sized */ - *value = config->modes.floatMode; - break; - default: /* any other int-sized field */ *value = *(unsigned int *) diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c index f59fdb12d..a29f1ab13 100644 --- a/mesalib/src/mesa/main/fbobject.c +++ b/mesalib/src/mesa/main/fbobject.c @@ -1155,6 +1155,13 @@ _mesa_BindRenderbuffer(GLenum target, GLuint renderbuffer) } +void GLAPIENTRY +_mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer) +{ + _mesa_BindRenderbuffer(target, renderbuffer); +} + + /** * If the given renderbuffer is anywhere attached to the framebuffer, detach * the renderbuffer. @@ -2025,6 +2032,13 @@ _mesa_BindFramebuffer(GLenum target, GLuint framebuffer) } } +void GLAPIENTRY +_mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) +{ + _mesa_BindFramebuffer(target, framebuffer); +} + + void GLAPIENTRY _mesa_DeleteFramebuffers(GLsizei n, const GLuint *framebuffers) diff --git a/mesalib/src/mesa/main/fbobject.h b/mesalib/src/mesa/main/fbobject.h index 4066ea65b..0a2a5cc59 100644 --- a/mesalib/src/mesa/main/fbobject.h +++ b/mesalib/src/mesa/main/fbobject.h @@ -120,6 +120,9 @@ extern void GLAPIENTRY _mesa_BindRenderbuffer(GLenum target, GLuint renderbuffer); extern void GLAPIENTRY +_mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer); + +extern void GLAPIENTRY _mesa_DeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers); extern void GLAPIENTRY @@ -152,6 +155,9 @@ extern void GLAPIENTRY _mesa_BindFramebuffer(GLenum target, GLuint framebuffer); extern void GLAPIENTRY +_mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer); + +extern void GLAPIENTRY _mesa_DeleteFramebuffers(GLsizei n, const GLuint *framebuffers); extern void GLAPIENTRY diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index ea139ea58..aba7d845b 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -3283,7 +3283,7 @@ enum mesa_debug_source { MESA_DEBUG_SOURCE_THIRD_PARTY, MESA_DEBUG_SOURCE_APPLICATION, MESA_DEBUG_SOURCE_OTHER, - MESA_DEBUG_SOURCE_COUNT, + MESA_DEBUG_SOURCE_COUNT }; enum mesa_debug_type { @@ -3293,14 +3293,14 @@ enum mesa_debug_type { MESA_DEBUG_TYPE_PORTABILITY, MESA_DEBUG_TYPE_PERFORMANCE, MESA_DEBUG_TYPE_OTHER, - MESA_DEBUG_TYPE_COUNT, + MESA_DEBUG_TYPE_COUNT }; enum mesa_debug_severity { MESA_DEBUG_SEVERITY_LOW, MESA_DEBUG_SEVERITY_MEDIUM, MESA_DEBUG_SEVERITY_HIGH, - MESA_DEBUG_SEVERITY_COUNT, + MESA_DEBUG_SEVERITY_COUNT }; /** @} */ @@ -3353,7 +3353,7 @@ typedef enum API_OPENGLES, API_OPENGLES2, API_OPENGL_CORE, - API_OPENGL_LAST = API_OPENGL_CORE, + API_OPENGL_LAST = API_OPENGL_CORE } gl_api; /** diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c index 32348ef73..d01942967 100644 --- a/mesalib/src/mesa/state_tracker/st_extensions.c +++ b/mesalib/src/mesa/state_tracker/st_extensions.c @@ -615,6 +615,7 @@ void st_init_extensions(struct st_context *st) ctx->Extensions.ARB_shader_bit_encoding = GL_TRUE; ctx->Extensions.ARB_shading_language_packing = GL_TRUE; ctx->Extensions.OES_depth_texture_cube_map = GL_TRUE; + ctx->Extensions.ARB_shading_language_420pack = GL_TRUE; } else { /* Optional integer support for GLSL 1.2. */ if (screen->get_shader_param(screen, PIPE_SHADER_VERTEX, diff --git a/mesalib/src/mesa/x86/Makefile.am b/mesalib/src/mesa/x86/Makefile.am index 21ce3607a..167857684 100644 --- a/mesalib/src/mesa/x86/Makefile.am +++ b/mesalib/src/mesa/x86/Makefile.am @@ -33,7 +33,17 @@ gen_matypes_SOURCES = gen_matypes.c BUILT_SOURCES = matypes.h CLEANFILES = matypes.h +if GEN_ASM_OFFSETS + +matypes.h: $(gen_matypes_SOURCES) + $(AM_V_GEN)$(COMPILE) $< -DASM_OFFSETS -S -o - | \ + sed -n '/^->/{s:^->::;/[$$]/{s:^:#define :;s:[$$]::};p}' > $@ + +else + matypes.h: gen_matypes $(AM_V_GEN)./gen_matypes > $@ endif + +endif diff --git a/mesalib/src/mesa/x86/gen_matypes.c b/mesalib/src/mesa/x86/gen_matypes.c index 80ee61aa8..1e904aa0b 100644 --- a/mesalib/src/mesa/x86/gen_matypes.c +++ b/mesalib/src/mesa/x86/gen_matypes.c @@ -52,7 +52,7 @@ do { \ printf( "\n" ); \ printf( "/* =====================================================" \ "========\n" ); \ - printf( " * Offsets for %s\n", x ); \ + printf( " * Offsets for " x "\n" ); \ printf( " */\n" ); \ printf( "\n" ); \ } while (0) @@ -61,20 +61,43 @@ do { \ do { \ printf( "\n" ); \ printf( "/*\n" ); \ - printf( " * Flags for %s\n", x ); \ + printf( " * Flags for " x "\n" ); \ printf( " */\n" ); \ printf( "\n" ); \ } while (0) -#define OFFSET( s, t, m ) \ - printf( "#define %s\t%lu\n", s, (unsigned long) offsetof( t, m ) ); +#ifdef ASM_OFFSETS -#define SIZEOF( s, t ) \ - printf( "#define %s\t%lu\n", s, (unsigned long) sizeof(t) ); +/* + * Format the asm output in a special way that we can manipulate + * after the fact and turn into the final header for the target. + */ + +#define DEFINE_UL( s, ul ) \ + __asm__ __volatile__ ( "\n->" s " %0" : : "i" (ul) ) + +#define DEFINE( s, d ) \ + DEFINE_UL( s, d ) + +#define printf( x ) \ + __asm__ __volatile__ ( "\n->" x ) + +#else + +#define DEFINE_UL( s, ul ) \ + printf( "#define %s\t%lu\n", s, (unsigned long) (ul) ); #define DEFINE( s, d ) \ printf( "#define %s\t0x%" PRIx64 "\n", s, (uint64_t) d ); +#endif + +#define OFFSET( s, t, m ) \ + DEFINE_UL( s, offsetof( t, m ) ) + +#define SIZEOF( s, t ) \ + DEFINE_UL( s, sizeof(t) ) + int main( int argc, char **argv ) |