aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-07-19 08:30:15 +0200
committermarha <marha@users.sourceforge.net>2013-07-19 08:30:15 +0200
commit89bc3ee988b62eb5e10284bac32a176955546410 (patch)
tree186769abb7a48a7b04463706dee116795e07485f /mesalib/src
parentf5e157731e6b51421ac89cfefb666b8bbf971b03 (diff)
downloadvcxsrv-89bc3ee988b62eb5e10284bac32a176955546410.tar.gz
vcxsrv-89bc3ee988b62eb5e10284bac32a176955546410.tar.bz2
vcxsrv-89bc3ee988b62eb5e10284bac32a176955546410.zip
mesa xkbcomp git update 19 Jul 2013
xkbcomp commit 0ebdf47fd4bc434ac3d2339544c022a869510738 esa commit 9f07ca11c1797ac12de1e1c6aef13cf58824b5f5
Diffstat (limited to 'mesalib/src')
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_s3tc.c434
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_srgb.h5
-rw-r--r--mesalib/src/glsl/ast.h49
-rw-r--r--mesalib/src/glsl/ast_to_hir.cpp135
-rw-r--r--mesalib/src/glsl/ast_type.cpp39
-rw-r--r--mesalib/src/glsl/builtin_compiler/Makefile.am13
-rw-r--r--mesalib/src/glsl/glsl_lexer.ll3
-rw-r--r--mesalib/src/glsl/glsl_parser.yy247
-rw-r--r--mesalib/src/glsl/ir.h15
-rw-r--r--mesalib/src/glsl/ir_clone.cpp2
-rw-r--r--mesalib/src/glsl/ir_optimization.h2
-rw-r--r--mesalib/src/glsl/link_uniform_initializers.cpp75
-rw-r--r--mesalib/src/glsl/linker.cpp21
-rw-r--r--mesalib/src/mapi/glapi/gen/ARB_framebuffer_object.xml4
-rw-r--r--mesalib/src/mapi/glapi/gen/EXT_framebuffer_object.xml6
-rw-r--r--mesalib/src/mesa/drivers/dri/common/utils.c6
-rw-r--r--mesalib/src/mesa/main/fbobject.c14
-rw-r--r--mesalib/src/mesa/main/fbobject.h6
-rw-r--r--mesalib/src/mesa/main/mtypes.h8
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c1
-rw-r--r--mesalib/src/mesa/x86/Makefile.am10
-rw-r--r--mesalib/src/mesa/x86/gen_matypes.c35
22 files changed, 799 insertions, 331 deletions
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 c0350e735..d98f1a39b 100644
--- a/mesalib/src/glsl/ast.h
+++ b/mesalib/src/glsl/ast.h
@@ -413,6 +413,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;
@@ -437,6 +443,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
*
@@ -453,11 +462,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
@@ -518,8 +550,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 */
}
@@ -527,8 +559,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 */
}
@@ -536,8 +568,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 */
}
@@ -556,9 +588,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 )