aboutsummaryrefslogtreecommitdiff
path: root/mesalib
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-12-10 08:33:13 +0100
committermarha <marha@users.sourceforge.net>2012-12-10 08:33:13 +0100
commit0328076efb5ff6e62152c09e38d0d11f7931d07b (patch)
treece71cf0fe95186671dc75862c2ced47f4735214f /mesalib
parente82692e521240c5f8592f9ce56c9d5b3d68870ec (diff)
downloadvcxsrv-0328076efb5ff6e62152c09e38d0d11f7931d07b.tar.gz
vcxsrv-0328076efb5ff6e62152c09e38d0d11f7931d07b.tar.bz2
vcxsrv-0328076efb5ff6e62152c09e38d0d11f7931d07b.zip
fontconfig libX11 mesa pixman git update 10 dec 2012
libX11 9833489e6c3829a1e835bc0a11f028fc180809e4 mesa 17f5dc57306b8f5079304701e455bf4b927d3cae pixman 8ca4e144724ba2041bc5ef077ccf6d24e7cf4d1f fontconfig 608c5b590bd3428dfcd30f3d68ee8b7131e2f019
Diffstat (limited to 'mesalib')
-rw-r--r--mesalib/.dir-locals.el11
-rw-r--r--mesalib/include/GL/gl.h12
-rw-r--r--mesalib/scons/gallium.py2
-rw-r--r--mesalib/src/gallium/auxiliary/Makefile.sources1
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_blitter.h6
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_rect.c158
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_rect.h30
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_surface.c179
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_surface.h24
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_transfer.c28
-rw-r--r--mesalib/src/glsl/Makefile.am6
-rw-r--r--mesalib/src/glsl/SConscript6
-rw-r--r--mesalib/src/glsl/ast_function.cpp23
-rw-r--r--mesalib/src/glsl/ast_to_hir.cpp153
-rw-r--r--mesalib/src/glsl/builtin_compiler/Makefile.am3
-rw-r--r--mesalib/src/glsl/builtin_types.h5
-rw-r--r--mesalib/src/glsl/builtin_variables.cpp193
-rw-r--r--mesalib/src/glsl/glcpp/Makefile.am2
-rw-r--r--mesalib/src/glsl/glcpp/glcpp-parse.y62
-rw-r--r--mesalib/src/glsl/glsl_lexer.ll315
-rw-r--r--mesalib/src/glsl/glsl_parser.yy86
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.cpp172
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.h77
-rw-r--r--mesalib/src/glsl/glsl_symbol_table.cpp6
-rw-r--r--mesalib/src/glsl/glsl_symbol_table.h3
-rw-r--r--mesalib/src/glsl/glsl_types.cpp140
-rw-r--r--mesalib/src/glsl/glsl_types.h11
-rw-r--r--mesalib/src/glsl/hir_field_selection.cpp3
-rw-r--r--mesalib/src/glsl/ir_variable_refcount.cpp35
-rw-r--r--mesalib/src/glsl/ir_variable_refcount.h17
-rw-r--r--mesalib/src/glsl/linker.cpp37
-rw-r--r--mesalib/src/glsl/lower_output_reads.cpp1
-rw-r--r--mesalib/src/glsl/main.cpp2
-rw-r--r--mesalib/src/glsl/opt_dead_code.cpp6
-rw-r--r--mesalib/src/glsl/standalone_scaffolding.cpp1
-rw-r--r--mesalib/src/mesa/Android.libmesa_glsl_utils.mk6
-rw-r--r--mesalib/src/mesa/SConscript3
-rw-r--r--mesalib/src/mesa/drivers/common/meta.c80
-rw-r--r--mesalib/src/mesa/drivers/dri/common/drisw_util.c16
-rw-r--r--mesalib/src/mesa/main/bufferobj.c22
-rw-r--r--mesalib/src/mesa/main/extensions.c1
-rw-r--r--mesalib/src/mesa/main/ff_fragment_shader.cpp1
-rw-r--r--mesalib/src/mesa/main/format_unpack.c101
-rw-r--r--mesalib/src/mesa/main/format_unpack.h3
-rw-r--r--mesalib/src/mesa/main/formats.c133
-rw-r--r--mesalib/src/mesa/main/formats.h10
-rw-r--r--mesalib/src/mesa/main/glformats.c21
-rw-r--r--mesalib/src/mesa/main/mtypes.h9
-rw-r--r--mesalib/src/mesa/main/set.c348
-rw-r--r--mesalib/src/mesa/main/set.h94
-rw-r--r--mesalib/src/mesa/main/shared.c12
-rw-r--r--mesalib/src/mesa/main/syncobj.c31
-rw-r--r--mesalib/src/mesa/main/texcompress.c100
-rw-r--r--mesalib/src/mesa/main/texcompress_etc.c1376
-rw-r--r--mesalib/src/mesa/main/texcompress_etc.h79
-rw-r--r--mesalib/src/mesa/main/texcompress_s3tc.c52
-rw-r--r--mesalib/src/mesa/main/texformat.c37
-rw-r--r--mesalib/src/mesa/main/teximage.c21
-rw-r--r--mesalib/src/mesa/main/texstore.c12
-rw-r--r--mesalib/src/mesa/program/Android.mk3
-rw-r--r--mesalib/src/mesa/program/prog_hash_table.c (renamed from mesalib/src/mesa/program/hash_table.c)0
-rw-r--r--mesalib/src/mesa/sources.mak3
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom.h2
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_constbuf.c68
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_texture.c18
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c6
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_texture.c194
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c25
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp94
-rw-r--r--mesalib/src/mesa/state_tracker/st_manager.c6
-rw-r--r--mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c1
-rw-r--r--mesalib/src/mesa/swrast/s_texfetch.c60
73 files changed, 3981 insertions, 885 deletions
diff --git a/mesalib/.dir-locals.el b/mesalib/.dir-locals.el
new file mode 100644
index 000000000..4f0ad7ac8
--- /dev/null
+++ b/mesalib/.dir-locals.el
@@ -0,0 +1,11 @@
+((nil
+ (indent-tabs-mode . nil)
+ (tab-width . 8)
+ (c-basic-offset . 3)
+ (c-file-style . "stroustrup")
+ (fill-column . 78)
+ (eval . (progn
+ (c-set-offset 'innamespace '0)
+ (c-set-offset 'inline-open '0)))
+ )
+ )
diff --git a/mesalib/include/GL/gl.h b/mesalib/include/GL/gl.h
index e65e1bc8a..97094fc59 100644
--- a/mesalib/include/GL/gl.h
+++ b/mesalib/include/GL/gl.h
@@ -169,8 +169,8 @@ typedef double GLclampd; /* double precision float in [0,1] */
*/
/* Boolean values */
-#define GL_FALSE 0x0
-#define GL_TRUE 0x1
+#define GL_FALSE 0
+#define GL_TRUE 1
/* Data types */
#define GL_BYTE 0x1400
@@ -370,8 +370,8 @@ typedef double GLclampd; /* double precision float in [0,1] */
#define GL_BLEND 0x0BE2
#define GL_BLEND_SRC 0x0BE1
#define GL_BLEND_DST 0x0BE0
-#define GL_ZERO 0x0
-#define GL_ONE 0x1
+#define GL_ZERO 0
+#define GL_ONE 1
#define GL_SRC_COLOR 0x0300
#define GL_ONE_MINUS_SRC_COLOR 0x0301
#define GL_SRC_ALPHA 0x0302
@@ -461,7 +461,7 @@ typedef double GLclampd; /* double precision float in [0,1] */
#define GL_DECR 0x1E03
/* Buffers, Pixel Drawing/Reading */
-#define GL_NONE 0x0
+#define GL_NONE 0
#define GL_LEFT 0x0406
#define GL_RIGHT 0x0407
/*GL_FRONT 0x0404 */
@@ -689,7 +689,7 @@ typedef double GLclampd; /* double precision float in [0,1] */
#define GL_EXTENSIONS 0x1F03
/* Errors */
-#define GL_NO_ERROR 0x0
+#define GL_NO_ERROR 0
#define GL_INVALID_ENUM 0x0500
#define GL_INVALID_VALUE 0x0501
#define GL_INVALID_OPERATION 0x0502
diff --git a/mesalib/scons/gallium.py b/mesalib/scons/gallium.py
index 66ccaea73..98671f75d 100644
--- a/mesalib/scons/gallium.py
+++ b/mesalib/scons/gallium.py
@@ -500,7 +500,7 @@ def generate(env):
libs = []
if env['platform'] in ('darwin', 'freebsd', 'linux', 'posix', 'sunos'):
libs += ['m', 'pthread', 'dl']
- if env['platform'] in 'linux':
+ if env['platform'] in ('linux',):
libs += ['rt']
env.Append(LIBS = libs)
diff --git a/mesalib/src/gallium/auxiliary/Makefile.sources b/mesalib/src/gallium/auxiliary/Makefile.sources
index 6258861f0..724178535 100644
--- a/mesalib/src/gallium/auxiliary/Makefile.sources
+++ b/mesalib/src/gallium/auxiliary/Makefile.sources
@@ -124,7 +124,6 @@ C_SOURCES := \
util/u_math.c \
util/u_mm.c \
util/u_pstipple.c \
- util/u_rect.c \
util/u_ringbuffer.c \
util/u_sampler.c \
util/u_simple_shaders.c \
diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.h b/mesalib/src/gallium/auxiliary/util/u_blitter.h
index b96e68e93..99175409b 100644
--- a/mesalib/src/gallium/auxiliary/util/u_blitter.h
+++ b/mesalib/src/gallium/auxiliary/util/u_blitter.h
@@ -29,10 +29,14 @@
#include "util/u_framebuffer.h"
#include "util/u_inlines.h"
-#include "util/u_memory.h"
#include "pipe/p_state.h"
+/* u_memory.h conflicts with st/mesa */
+#ifndef Elements
+#define Elements(x) (sizeof(x)/sizeof((x)[0]))
+#endif
+
#ifdef __cplusplus
extern "C" {
diff --git a/mesalib/src/gallium/auxiliary/util/u_rect.c b/mesalib/src/gallium/auxiliary/util/u_rect.c
deleted file mode 100644
index d00568f1f..000000000
--- a/mesalib/src/gallium/auxiliary/util/u_rect.c
+++ /dev/null
@@ -1,158 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * Rectangle-related helper functions.
- */
-
-
-#include "util/u_format.h"
-#include "util/u_rect.h"
-#include "util/u_pack_color.h"
-
-
-/**
- * Copy 2D rect from one place to another.
- * Position and sizes are in pixels.
- * src_stride may be negative to do vertical flip of pixels from source.
- */
-void
-util_copy_rect(ubyte * dst,
- enum pipe_format format,
- unsigned dst_stride,
- unsigned dst_x,
- unsigned dst_y,
- unsigned width,
- unsigned height,
- const ubyte * src,
- int src_stride,
- unsigned src_x,
- unsigned src_y)
-{
- unsigned i;
- int src_stride_pos = src_stride < 0 ? -src_stride : src_stride;
- int blocksize = util_format_get_blocksize(format);
- int blockwidth = util_format_get_blockwidth(format);
- int blockheight = util_format_get_blockheight(format);
-
- assert(blocksize > 0);
- assert(blockwidth > 0);
- assert(blockheight > 0);
-
- dst_x /= blockwidth;
- dst_y /= blockheight;
- width = (width + blockwidth - 1)/blockwidth;
- height = (height + blockheight - 1)/blockheight;
- src_x /= blockwidth;
- src_y /= blockheight;
-
- dst += dst_x * blocksize;
- src += src_x * blocksize;
- dst += dst_y * dst_stride;
- src += src_y * src_stride_pos;
- width *= blocksize;
-
- if (width == dst_stride && width == src_stride)
- memcpy(dst, src, height * width);
- else {
- for (i = 0; i < height; i++) {
- memcpy(dst, src, width);
- dst += dst_stride;
- src += src_stride;
- }
- }
-}
-
-void
-util_fill_rect(ubyte * dst,
- enum pipe_format format,
- unsigned dst_stride,
- unsigned dst_x,
- unsigned dst_y,
- unsigned width,
- unsigned height,
- union util_color *uc)
-{
- const struct util_format_description *desc = util_format_description(format);
- unsigned i, j;
- unsigned width_size;
- int blocksize = desc->block.bits / 8;
- int blockwidth = desc->block.width;
- int blockheight = desc->block.height;
-
- assert(blocksize > 0);
- assert(blockwidth > 0);
- assert(blockheight > 0);
-
- dst_x /= blockwidth;
- dst_y /= blockheight;
- width = (width + blockwidth - 1)/blockwidth;
- height = (height + blockheight - 1)/blockheight;
-
- dst += dst_x * blocksize;
- dst += dst_y * dst_stride;
- width_size = width * blocksize;
-
- switch (blocksize) {
- case 1:
- if(dst_stride == width_size)
- memset(dst, uc->ub, height * width_size);
- else {
- for (i = 0; i < height; i++) {
- memset(dst, uc->ub, width_size);
- dst += dst_stride;
- }
- }
- break;
- case 2:
- for (i = 0; i < height; i++) {
- uint16_t *row = (uint16_t *)dst;
- for (j = 0; j < width; j++)
- *row++ = uc->us;
- dst += dst_stride;
- }
- break;
- case 4:
- for (i = 0; i < height; i++) {
- uint32_t *row = (uint32_t *)dst;
- for (j = 0; j < width; j++)
- *row++ = uc->ui;
- dst += dst_stride;
- }
- break;
- default:
- for (i = 0; i < height; i++) {
- ubyte *row = dst;
- for (j = 0; j < width; j++) {
- memcpy(row, uc, blocksize);
- row += blocksize;
- }
- dst += dst_stride;
- }
- break;
- }
-}
diff --git a/mesalib/src/gallium/auxiliary/util/u_rect.h b/mesalib/src/gallium/auxiliary/util/u_rect.h
index 8fccae8c4..10909b202 100644
--- a/mesalib/src/gallium/auxiliary/util/u_rect.h
+++ b/mesalib/src/gallium/auxiliary/util/u_rect.h
@@ -83,36 +83,10 @@ u_rect_possible_intersection(const struct u_rect *a,
}
#endif
-#include "pipe/p_format.h"
-#include "util/u_pack_color.h"
-
-
-/**********************************************************************
- * Pipe copy/fill rect helpers.
- */
-
-/* These really should move to a different file:
+/* Include pipe copy/fill rect helpers declarations for backwards compatibility
*/
-#include "pipe/p_format.h"
+#include "util/u_surface.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern void
-util_copy_rect(ubyte * dst, enum pipe_format format,
- unsigned dst_stride, unsigned dst_x, unsigned dst_y,
- unsigned width, unsigned height, const ubyte * src,
- int src_stride, unsigned src_x, unsigned src_y);
-
-extern void
-util_fill_rect(ubyte * dst, enum pipe_format format,
- unsigned dst_stride, unsigned dst_x, unsigned dst_y,
- unsigned width, unsigned height, union util_color *uc);
-
-#ifdef __cplusplus
-}
-#endif
#endif /* U_RECT_H */
diff --git a/mesalib/src/gallium/auxiliary/util/u_surface.c b/mesalib/src/gallium/auxiliary/util/u_surface.c
index 5b42afd0d..2c197c3df 100644
--- a/mesalib/src/gallium/auxiliary/util/u_surface.c
+++ b/mesalib/src/gallium/auxiliary/util/u_surface.c
@@ -116,6 +116,163 @@ util_create_rgba_texture(struct pipe_context *pipe,
/**
+ * Copy 2D rect from one place to another.
+ * Position and sizes are in pixels.
+ * src_stride may be negative to do vertical flip of pixels from source.
+ */
+void
+util_copy_rect(ubyte * dst,
+ enum pipe_format format,
+ unsigned dst_stride,
+ unsigned dst_x,
+ unsigned dst_y,
+ unsigned width,
+ unsigned height,
+ const ubyte * src,
+ int src_stride,
+ unsigned src_x,
+ unsigned src_y)
+{
+ unsigned i;
+ int src_stride_pos = src_stride < 0 ? -src_stride : src_stride;
+ int blocksize = util_format_get_blocksize(format);
+ int blockwidth = util_format_get_blockwidth(format);
+ int blockheight = util_format_get_blockheight(format);
+
+ assert(blocksize > 0);
+ assert(blockwidth > 0);
+ assert(blockheight > 0);
+
+ dst_x /= blockwidth;
+ dst_y /= blockheight;
+ width = (width + blockwidth - 1)/blockwidth;
+ height = (height + blockheight - 1)/blockheight;
+ src_x /= blockwidth;
+ src_y /= blockheight;
+
+ dst += dst_x * blocksize;
+ src += src_x * blocksize;
+ dst += dst_y * dst_stride;
+ src += src_y * src_stride_pos;
+ width *= blocksize;
+
+ if (width == dst_stride && width == src_stride)
+ memcpy(dst, src, height * width);
+ else {
+ for (i = 0; i < height; i++) {
+ memcpy(dst, src, width);
+ dst += dst_stride;
+ src += src_stride;
+ }
+ }
+}
+
+
+/**
+ * Copy 3D box from one place to another.
+ * Position and sizes are in pixels.
+ */
+void
+util_copy_box(ubyte * dst,
+ enum pipe_format format,
+ unsigned dst_stride, unsigned dst_slice_stride,
+ unsigned dst_x, unsigned dst_y, unsigned dst_z,
+ unsigned width, unsigned height, unsigned depth,
+ const ubyte * src,
+ int src_stride, unsigned src_slice_stride,
+ unsigned src_x, unsigned src_y, unsigned src_z)
+{
+ unsigned z;
+ dst += dst_z * dst_slice_stride;
+ src += src_z * src_slice_stride;
+ for (z = 0; z < depth; ++z) {
+ util_copy_rect(dst,
+ format,
+ dst_stride,
+ dst_x, dst_y,
+ width, height,
+ src,
+ src_stride,
+ src_x, src_y);
+
+ dst += dst_slice_stride;
+ src += src_slice_stride;
+ }
+}
+
+
+void
+util_fill_rect(ubyte * dst,
+ enum pipe_format format,
+ unsigned dst_stride,
+ unsigned dst_x,
+ unsigned dst_y,
+ unsigned width,
+ unsigned height,
+ union util_color *uc)
+{
+ const struct util_format_description *desc = util_format_description(format);
+ unsigned i, j;
+ unsigned width_size;
+ int blocksize = desc->block.bits / 8;
+ int blockwidth = desc->block.width;
+ int blockheight = desc->block.height;
+
+ assert(blocksize > 0);
+ assert(blockwidth > 0);
+ assert(blockheight > 0);
+
+ dst_x /= blockwidth;
+ dst_y /= blockheight;
+ width = (width + blockwidth - 1)/blockwidth;
+ height = (height + blockheight - 1)/blockheight;
+
+ dst += dst_x * blocksize;
+ dst += dst_y * dst_stride;
+ width_size = width * blocksize;
+
+ switch (blocksize) {
+ case 1:
+ if(dst_stride == width_size)
+ memset(dst, uc->ub, height * width_size);
+ else {
+ for (i = 0; i < height; i++) {
+ memset(dst, uc->ub, width_size);
+ dst += dst_stride;
+ }
+ }
+ break;
+ case 2:
+ for (i = 0; i < height; i++) {
+ uint16_t *row = (uint16_t *)dst;
+ for (j = 0; j < width; j++)
+ *row++ = uc->us;
+ dst += dst_stride;
+ }
+ break;
+ case 4:
+ for (i = 0; i < height; i++) {
+ uint32_t *row = (uint32_t *)dst;
+ for (j = 0; j < width; j++)
+ *row++ = uc->ui;
+ dst += dst_stride;
+ }
+ break;
+ default:
+ for (i = 0; i < height; i++) {
+ ubyte *row = dst;
+ for (j = 0; j < width; j++) {
+ memcpy(row, uc, blocksize);
+ row += blocksize;
+ }
+ dst += dst_stride;
+ }
+ break;
+ }
+}
+
+
+/**
* Fallback function for pipe->resource_copy_region().
* Note: (X,Y)=(0,0) is always the upper-left corner.
*/
@@ -133,7 +290,6 @@ util_resource_copy_region(struct pipe_context *pipe,
const uint8_t *src_map;
enum pipe_format src_format, dst_format;
struct pipe_box dst_box;
- int z;
assert(src && dst);
if (!src || !dst)
@@ -181,19 +337,14 @@ util_resource_copy_region(struct pipe_context *pipe,
assert(src_box->depth == 1);
memcpy(dst_map, src_map, src_box->width);
} else {
- for (z = 0; z < src_box->depth; ++z) {
- util_copy_rect(dst_map,
- dst_format,
- dst_trans->stride,
- 0, 0,
- src_box->width, src_box->height,
- src_map,
- src_trans->stride,
- 0, 0);
-
- dst_map += dst_trans->layer_stride;
- src_map += src_trans->layer_stride;
- }
+ util_copy_box(dst_map,
+ dst_format,
+ dst_trans->stride, dst_trans->layer_stride,
+ 0, 0, 0,
+ src_box->width, src_box->height, src_box->depth,
+ src_map,
+ src_trans->stride, src_trans->layer_stride,
+ 0, 0, 0);
}
pipe->transfer_unmap(pipe, dst_trans);
diff --git a/mesalib/src/gallium/auxiliary/util/u_surface.h b/mesalib/src/gallium/auxiliary/util/u_surface.h
index 6bcb63f3d..dd4d5785e 100644
--- a/mesalib/src/gallium/auxiliary/util/u_surface.h
+++ b/mesalib/src/gallium/auxiliary/util/u_surface.h
@@ -32,6 +32,8 @@
#include "pipe/p_compiler.h"
#include "pipe/p_state.h"
+#include "util/u_pack_color.h"
+
#ifdef __cplusplus
extern "C" {
@@ -50,6 +52,28 @@ util_create_rgba_texture(struct pipe_context *ctx,
extern void
+util_copy_rect(ubyte * dst, enum pipe_format format,
+ unsigned dst_stride, unsigned dst_x, unsigned dst_y,
+ unsigned width, unsigned height, const ubyte * src,
+ int src_stride, unsigned src_x, unsigned src_y);
+
+extern void
+util_copy_box(ubyte * dst,
+ enum pipe_format format,
+ unsigned dst_stride, unsigned dst_slice_stride,
+ unsigned dst_x, unsigned dst_y, unsigned dst_z,
+ unsigned width, unsigned height, unsigned depth,
+ const ubyte * src,
+ int src_stride, unsigned src_slice_stride,
+ unsigned src_x, unsigned src_y, unsigned src_z);
+
+extern void
+util_fill_rect(ubyte * dst, enum pipe_format format,
+ unsigned dst_stride, unsigned dst_x, unsigned dst_y,
+ unsigned width, unsigned height, union util_color *uc);
+
+
+extern void
util_resource_copy_region(struct pipe_context *pipe,
struct pipe_resource *dst,
unsigned dst_level,
diff --git a/mesalib/src/gallium/auxiliary/util/u_transfer.c b/mesalib/src/gallium/auxiliary/util/u_transfer.c
index 8b4c36592..861682553 100644
--- a/mesalib/src/gallium/auxiliary/util/u_transfer.c
+++ b/mesalib/src/gallium/auxiliary/util/u_transfer.c
@@ -1,5 +1,5 @@
#include "pipe/p_context.h"
-#include "util/u_rect.h"
+#include "util/u_surface.h"
#include "util/u_inlines.h"
#include "util/u_transfer.h"
#include "util/u_memory.h"
@@ -47,21 +47,19 @@ void u_default_transfer_inline_write( struct pipe_context *pipe,
}
else {
const uint8_t *src_data = data;
- unsigned i;
- for (i = 0; i < box->depth; i++) {
- util_copy_rect(map,
- resource->format,
- transfer->stride, /* bytes */
- 0, 0,
- box->width,
- box->height,
- src_data,
- stride, /* bytes */
- 0, 0);
- map += transfer->layer_stride;
- src_data += layer_stride;
- }
+ util_copy_box(map,
+ resource->format,
+ transfer->stride, /* bytes */
+ transfer->layer_stride, /* bytes */
+ 0, 0, 0,
+ box->width,
+ box->height,
+ box->depth,
+ src_data,
+ stride, /* bytes */
+ layer_stride, /* bytes */
+ 0, 0, 0);
}
pipe_transfer_unmap(pipe, transfer);
diff --git a/mesalib/src/glsl/Makefile.am b/mesalib/src/glsl/Makefile.am
index ea7617685..aff1559e0 100644
--- a/mesalib/src/glsl/Makefile.am
+++ b/mesalib/src/glsl/Makefile.am
@@ -49,14 +49,16 @@ libglsl_la_LIBADD = glcpp/libglcpp.la
libglsl_la_LDFLAGS =
glsl_compiler_SOURCES = \
- $(top_srcdir)/src/mesa/program/hash_table.c \
+ $(top_srcdir)/src/mesa/main/hash_table.c \
+ $(top_srcdir)/src/mesa/program/prog_hash_table.c \
$(top_srcdir)/src/mesa/program/symbol_table.c \
$(GLSL_COMPILER_CXX_FILES)
glsl_compiler_LDADD = libglsl.la
glsl_test_SOURCES = \
- $(top_srcdir)/src/mesa/program/hash_table.c \
+ $(top_srcdir)/src/mesa/main/hash_table.c \
+ $(top_srcdir)/src/mesa/program/prog_hash_table.c \
$(top_srcdir)/src/mesa/program/symbol_table.c \
$(GLSL_SRCDIR)/standalone_scaffolding.cpp \
test.cpp \
diff --git a/mesalib/src/glsl/SConscript b/mesalib/src/glsl/SConscript
index 0cf25c07b..6abba2a24 100644
--- a/mesalib/src/glsl/SConscript
+++ b/mesalib/src/glsl/SConscript
@@ -57,14 +57,18 @@ if env['crosscompile'] and not env['embedded']:
Import('builtin_glsl_function')
else:
# Copy these files to avoid generation object files into src/mesa/program
+ env.Prepend(CPPPATH = ['#src/mesa/main'])
+ env.Command('hash_table.c', '#src/mesa/main/hash_table.c', Copy('$TARGET', '$SOURCE'))
+ # Copy these files to avoid generation object files into src/mesa/program
env.Prepend(CPPPATH = ['#src/mesa/program'])
- env.Command('hash_table.c', '#src/mesa/program/hash_table.c', Copy('$TARGET', '$SOURCE'))
+ env.Command('prog_hash_table.c', '#src/mesa/program/prog_hash_table.c', Copy('$TARGET', '$SOURCE'))
env.Command('symbol_table.c', '#src/mesa/program/symbol_table.c', Copy('$TARGET', '$SOURCE'))
compiler_objs = env.StaticObject(source_lists['GLSL_COMPILER_CXX_FILES'])
mesa_objs = env.StaticObject([
'hash_table.c',
+ 'prog_hash_table.c',
'symbol_table.c',
])
diff --git a/mesalib/src/glsl/ast_function.cpp b/mesalib/src/glsl/ast_function.cpp
index ea3282c5f..b56a3c723 100644
--- a/mesalib/src/glsl/ast_function.cpp
+++ b/mesalib/src/glsl/ast_function.cpp
@@ -275,9 +275,10 @@ generate_call(exec_list *instructions, ir_function_signature *sig,
/* If the function call is a constant expression, don't generate any
* instructions; just generate an ir_constant.
*
- * Function calls were first allowed to be constant expressions in GLSL 1.20.
+ * Function calls were first allowed to be constant expressions in GLSL
+ * 1.20 and GLSL ES 3.00.
*/
- if (state->language_version >= 120) {
+ if (state->is_version(120, 300)) {
ir_constant *value = sig->constant_expression_value(actual_parameters, NULL);
if (value != NULL) {
return value;
@@ -324,7 +325,8 @@ match_function_by_name(const char *name,
goto done; /* no match */
/* Is the function hidden by a variable (impossible in 1.10)? */
- if (state->language_version != 110 && state->symbols->get_variable(name))
+ if (!state->symbols->separate_function_namespace
+ && state->symbols->get_variable(name))
goto done; /* no match */
if (f != NULL) {
@@ -1242,9 +1244,8 @@ ast_function_expression::hir(exec_list *instructions,
}
if (constructor_type->is_array()) {
- if (state->language_version <= 110) {
- _mesa_glsl_error(& loc, state,
- "array constructors forbidden in GLSL 1.10");
+ if (!state->check_version(120, 300, &loc,
+ "array constructors forbidden")) {
return ir_rvalue::error_value(ctx);
}
@@ -1367,11 +1368,11 @@ ast_function_expression::hir(exec_list *instructions,
* "It is an error to construct matrices from other matrices. This
* is reserved for future use."
*/
- if (state->language_version == 110 && matrix_parameters > 0
- && constructor_type->is_matrix()) {
- _mesa_glsl_error(& loc, state, "cannot construct `%s' from a "
- "matrix in GLSL 1.10",
- constructor_type->name);
+ if (matrix_parameters > 0
+ && constructor_type->is_matrix()
+ && !state->check_version(120, 100, &loc,
+ "cannot construct `%s' from a matrix",
+ constructor_type->name)) {
return ir_rvalue::error_value(ctx);
}
diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp
index d450aa1e4..94b63f682 100644
--- a/mesalib/src/glsl/ast_to_hir.cpp
+++ b/mesalib/src/glsl/ast_to_hir.cpp
@@ -66,7 +66,7 @@ _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state)
{
_mesa_glsl_initialize_variables(instructions, state);
- state->symbols->language_version = state->language_version;
+ state->symbols->separate_function_namespace = state->language_version == 110;
state->current_function = NULL;
@@ -121,7 +121,7 @@ apply_implicit_conversion(const glsl_type *to, ir_rvalue * &from,
/* This conversion was added in GLSL 1.20. If the compilation mode is
* GLSL 1.10, the conversion is skipped.
*/
- if (state->language_version < 120)
+ if (!state->is_version(120, 0))
return false;
/* From page 27 (page 33 of the PDF) of the GLSL 1.50 spec:
@@ -390,8 +390,7 @@ bit_logic_result_type(const struct glsl_type *type_a,
ast_operators op,
struct _mesa_glsl_parse_state *state, YYLTYPE *loc)
{
- if (state->language_version < 130) {
- _mesa_glsl_error(loc, state, "bit operations require GLSL 1.30");
+ if (!state->check_bitwise_operations_allowed(loc)) {
return glsl_type::error_type;
}
@@ -446,10 +445,7 @@ modulus_result_type(const struct glsl_type *type_a,
const struct glsl_type *type_b,
struct _mesa_glsl_parse_state *state, YYLTYPE *loc)
{
- if (state->language_version < 130) {
- _mesa_glsl_error(loc, state,
- "operator '%%' is reserved in %s",
- state->version_string);
+ if (!state->check_version(130, 300, loc, "operator '%%' is reserved")) {
return glsl_type::error_type;
}
@@ -553,8 +549,7 @@ shift_result_type(const struct glsl_type *type_a,
ast_operators op,
struct _mesa_glsl_parse_state *state, YYLTYPE *loc)
{
- if (state->language_version < 130) {
- _mesa_glsl_error(loc, state, "bit operations require GLSL 1.30");
+ if (!state->check_bitwise_operations_allowed(loc)) {
return glsl_type::error_type;
}
@@ -694,15 +689,17 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state,
lhs->variable_referenced()->name);
error_emitted = true;
- } else if (state->language_version <= 110 && lhs->type->is_array()) {
+ } else if (lhs->type->is_array() &&
+ !state->check_version(120, 300, &lhs_loc,
+ "whole array assignment forbidden")) {
/* From page 32 (page 38 of the PDF) of the GLSL 1.10 spec:
*
* "Other binary or unary expressions, non-dereferenced
* arrays, function names, swizzles with repeated fields,
* and constants cannot be l-values."
+ *
+ * The restriction on arrays is lifted in GLSL 1.20 and GLSL ES 3.00.
*/
- _mesa_glsl_error(&lhs_loc, state, "whole array assignment is not "
- "allowed in GLSL 1.10 or GLSL ES 1.00.");
error_emitted = true;
} else if (!lhs->is_lvalue()) {
_mesa_glsl_error(& lhs_loc, state, "non-lvalue in assignment");
@@ -1099,9 +1096,7 @@ ast_expression::hir(exec_list *instructions,
case ast_lshift:
case ast_rshift:
- if (state->language_version < 130) {
- _mesa_glsl_error(&loc, state, "operator %s requires GLSL 1.30",
- operator_string(this->oper));
+ if (!state->check_bitwise_operations_allowed(&loc)) {
error_emitted = true;
}
@@ -1155,10 +1150,9 @@ ast_expression::hir(exec_list *instructions,
_mesa_glsl_error(& loc, state, "operands of `%s' must have the same "
"type", (this->oper == ast_equal) ? "==" : "!=");
error_emitted = true;
- } else if ((state->language_version <= 110)
- && (op[0]->type->is_array() || op[1]->type->is_array())) {
- _mesa_glsl_error(& loc, state, "array comparisons forbidden in "
- "GLSL 1.10");
+ } else if ((op[0]->type->is_array() || op[1]->type->is_array()) &&
+ !state->check_version(120, 300, &loc,
+ "array comparisons forbidden")) {
error_emitted = true;
}
@@ -1185,8 +1179,7 @@ ast_expression::hir(exec_list *instructions,
case ast_bit_not:
op[0] = this->subexpressions[0]->hir(instructions, state);
- if (state->language_version < 130) {
- _mesa_glsl_error(&loc, state, "bit-wise operations require GLSL 1.30");
+ if (!state->check_bitwise_operations_allowed(&loc)) {
error_emitted = true;
}
@@ -1424,9 +1417,10 @@ ast_expression::hir(exec_list *instructions,
* "The second and third expressions must be the same type, but can
* be of any type other than an array."
*/
- if ((state->language_version <= 110) && type->is_array()) {
- _mesa_glsl_error(& loc, state, "Second and third operands of ?: "
- "operator must not be arrays.");
+ if (type->is_array() &&
+ !state->check_version(120, 300, &loc,
+ "Second and third operands of ?: operator "
+ "cannot be arrays")) {
error_emitted = true;
}
@@ -1660,15 +1654,18 @@ ast_expression::hir(exec_list *instructions,
array->type->element_type()->is_sampler() &&
const_index == NULL) {
- if (state->language_version == 100) {
- _mesa_glsl_warning(&loc, state,
- "sampler arrays indexed with non-constant "
- "expressions is optional in GLSL ES 1.00");
- } else if (state->language_version < 130) {
- _mesa_glsl_warning(&loc, state,
- "sampler arrays indexed with non-constant "
- "expressions is forbidden in GLSL 1.30 and "
- "later");
+ if (!state->is_version(130, 100)) {
+ if (state->es_shader) {
+ _mesa_glsl_warning(&loc, state,
+ "sampler arrays indexed with non-constant "
+ "expressions is optional in %s",
+ state->get_version_string());
+ } else {
+ _mesa_glsl_warning(&loc, state,
+ "sampler arrays indexed with non-constant "
+ "expressions will be forbidden in GLSL 1.30 and "
+ "later");
+ }
} else {
_mesa_glsl_error(&loc, state,
"sampler arrays indexed with non-constant "
@@ -2288,7 +2285,7 @@ get_variable_being_redeclared(ir_variable *var, ast_declaration *decl,
* * gl_Color
* * gl_SecondaryColor
*/
- } else if (state->language_version >= 130
+ } else if (state->is_version(130, 0)
&& (strcmp(var->name, "gl_FrontColor") == 0
|| strcmp(var->name, "gl_BackColor") == 0
|| strcmp(var->name, "gl_FrontSecondaryColor") == 0
@@ -2355,10 +2352,9 @@ process_initializer(ir_variable *var, ast_declaration *decl,
* directly by an application via API commands, or indirectly by
* OpenGL."
*/
- if ((state->language_version <= 110)
- && (var->mode == ir_var_uniform)) {
- _mesa_glsl_error(& initializer_loc, state,
- "cannot initialize uniforms in GLSL 1.10");
+ if (var->mode == ir_var_uniform) {
+ state->check_version(120, 0, &initializer_loc,
+ "cannot initialize uniforms");
}
if (var->type->is_sampler()) {
@@ -2608,23 +2604,23 @@ ast_declarator_list::hir(exec_list *instructions,
*
* Local variables can only use the qualifier const."
*
- * This is relaxed in GLSL 1.30. It is also relaxed by any extension
- * that adds the 'layout' keyword.
+ * This is relaxed in GLSL 1.30 and GLSL ES 3.00. It is also relaxed by
+ * any extension that adds the 'layout' keyword.
*/
- if ((state->language_version < 130)
+ if (!state->is_version(130, 300)
&& !state->ARB_explicit_attrib_location_enable
&& !state->ARB_fragment_coord_conventions_enable) {
if (this->type->qualifier.flags.q.out) {
_mesa_glsl_error(& loc, state,
"`out' qualifier in declaration of `%s' "
"only valid for function parameters in %s.",
- decl->identifier, state->version_string);
+ decl->identifier, state->get_version_string());
}
if (this->type->qualifier.flags.q.in) {
_mesa_glsl_error(& loc, state,
"`in' qualifier in declaration of `%s' "
"only valid for function parameters in %s.",
- decl->identifier, state->version_string);
+ decl->identifier, state->get_version_string());
}
/* FINISHME: Test for other invalid qualifiers. */
}
@@ -2703,6 +2699,13 @@ ast_declarator_list::hir(exec_list *instructions,
* "The attribute qualifier can be used only with float,
* floating-point vectors, and matrices. Attribute variables
* cannot be declared as arrays or structures."
+ *
+ * From page 33 (page 39 of the PDF) of the GLSL ES 3.00 spec:
+ *
+ * "Vertex shader inputs can only be float, floating-point
+ * vectors, matrices, signed and unsigned integers and integer
+ * vectors. Vertex shader inputs cannot be arrays or
+ * structures."
*/
const glsl_type *check_type = var->type->is_array()
? var->type->fields.array : var->type;
@@ -2712,7 +2715,7 @@ ast_declarator_list::hir(exec_list *instructions,
break;
case GLSL_TYPE_UINT:
case GLSL_TYPE_INT:
- if (state->language_version > 120)
+ if (state->is_version(120, 300))
break;
/* FALLTHROUGH */
default:
@@ -2724,11 +2727,10 @@ ast_declarator_list::hir(exec_list *instructions,
error_emitted = true;
}
- if (!error_emitted && (state->language_version <= 130)
- && var->type->is_array()) {
- _mesa_glsl_error(& loc, state,
- "vertex shader input / attribute cannot have "
- "array type");
+ if (!error_emitted && var->type->is_array() &&
+ !state->check_version(140, 0, &loc,
+ "vertex shader input / attribute "
+ "cannot have array type")) {
error_emitted = true;
}
}
@@ -2740,8 +2742,16 @@ ast_declarator_list::hir(exec_list *instructions,
* "If a vertex output is a signed or unsigned integer or integer
* vector, then it must be qualified with the interpolation qualifier
* flat."
+ *
+ * From section 4.3.4 of the GLSL 3.00 ES spec:
+ * "Fragment shader inputs that are signed or unsigned integers or
+ * integer vectors must be qualified with the interpolation qualifier
+ * flat."
+ *
+ * Since vertex outputs and fragment inputs must have matching
+ * qualifiers, these two requirements are equivalent.
*/
- if (state->language_version >= 130
+ if (state->is_version(130, 300)
&& state->target == vertex_shader
&& state->current_function == NULL
&& var->type->is_integer()
@@ -2760,8 +2770,10 @@ ast_declarator_list::hir(exec_list *instructions,
* "interpolation qualifiers may only precede the qualifiers in,
* centroid in, out, or centroid out in a declaration. They do not apply
* to the deprecated storage qualifiers varying or centroid varying."
+ *
+ * These deprecated storage qualifiers do not exist in GLSL ES 3.00.
*/
- if (state->language_version >= 130
+ if (state->is_version(130, 0)
&& this->type->qualifier.has_interpolation()
&& this->type->qualifier.flags.q.varying) {
@@ -2786,8 +2798,14 @@ ast_declarator_list::hir(exec_list *instructions,
* "Outputs from a vertex shader (out) and inputs to a fragment
* shader (in) can be further qualified with one or more of these
* interpolation qualifiers"
+ *
+ * From page 31 (page 37 of the PDF) of the GLSL ES 3.00 spec:
+ * "These interpolation qualifiers may only precede the qualifiers
+ * in, centroid in, out, or centroid out in a declaration. They do
+ * not apply to inputs into a vertex shader or outputs from a
+ * fragment shader."
*/
- if (state->language_version >= 130
+ if (state->is_version(130, 300)
&& this->type->qualifier.has_interpolation()) {
const char *i = this->type->qualifier.interpolation_string();
@@ -2816,8 +2834,12 @@ ast_declarator_list::hir(exec_list *instructions,
/* From section 4.3.4 of the GLSL 1.30 spec:
* "It is an error to use centroid in in a vertex shader."
+ *
+ * From section 4.3.4 of the GLSL ES 3.00 spec:
+ * "It is an error to use centroid in or interpolation qualifiers in
+ * a vertex shader input."
*/
- if (state->language_version >= 130
+ if (state->is_version(130, 300)
&& this->type->qualifier.flags.q.centroid
&& this->type->qualifier.flags.q.in
&& state->target == vertex_shader) {
@@ -2829,13 +2851,8 @@ 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
- && state->language_version != 100
- && state->language_version < 130) {
-
- _mesa_glsl_error(&loc, state,
- "precision qualifiers are supported only in GLSL ES "
- "1.00, and GLSL 1.30 and later");
+ if (this->type->specifier->precision != ast_precision_none) {
+ state->check_precision_qualifiers_allowed(&loc);
}
@@ -3077,8 +3094,9 @@ ast_parameter_declarator::hir(exec_list *instructions,
* allowed. This restriction is removed in GLSL 1.20, and in GLSL ES.
*/
if ((var->mode == ir_var_inout || var->mode == ir_var_out)
- && type->is_array() && state->language_version == 110) {
- _mesa_glsl_error(&loc, state, "Arrays cannot be out or inout parameters in GLSL 1.10");
+ && type->is_array()
+ && !state->check_version(120, 100, &loc,
+ "Arrays cannot be out or inout parameters")) {
type = glsl_type::error_type;
}
@@ -3161,7 +3179,8 @@ ast_function::hir(exec_list *instructions,
*
* Note that this language does not appear in GLSL 1.10.
*/
- if ((state->current_function != NULL) && (state->language_version != 110)) {
+ if ((state->current_function != NULL) &&
+ state->is_version(120, 100)) {
YYLTYPE loc = this->get_location();
_mesa_glsl_error(&loc, state,
"declaration of function `%s' not allowed within "
@@ -3872,11 +3891,7 @@ ast_type_specifier::hir(exec_list *instructions,
YYLTYPE loc = this->get_location();
if (this->precision != ast_precision_none
- && state->language_version != 100
- && state->language_version < 130) {
- _mesa_glsl_error(&loc, state,
- "precision qualifiers exist only in "
- "GLSL ES 1.00, and GLSL 1.30 and later");
+ && !state->check_precision_qualifiers_allowed(&loc)) {
return NULL;
}
if (this->precision != ast_precision_none
diff --git a/mesalib/src/glsl/builtin_compiler/Makefile.am b/mesalib/src/glsl/builtin_compiler/Makefile.am
index d6f85a7f4..d27aca555 100644
--- a/mesalib/src/glsl/builtin_compiler/Makefile.am
+++ b/mesalib/src/glsl/builtin_compiler/Makefile.am
@@ -55,7 +55,8 @@ builtin_compiler_SOURCES = \
$(GLSL_BUILDDIR)/glsl_parser.cc \
$(LIBGLSL_FILES) \
$(LIBGLSL_CXX_FILES) \
- $(top_srcdir)/src/mesa/program/hash_table.c \
+ $(top_srcdir)/src/mesa/main/hash_table.c \
+ $(top_srcdir)/src/mesa/program/prog_hash_table.c \
$(top_srcdir)/src/mesa/program/symbol_table.c \
$(GLSL_COMPILER_CXX_FILES) \
builtin_stubs.cpp
diff --git a/mesalib/src/glsl/builtin_types.h b/mesalib/src/glsl/builtin_types.h
index 92427d8e7..a4c995fd1 100644
--- a/mesalib/src/glsl/builtin_types.h
+++ b/mesalib/src/glsl/builtin_types.h
@@ -31,6 +31,11 @@ const glsl_type glsl_type::_sampler3D_type =
glsl_type(GL_SAMPLER_3D, GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_FLOAT,
"sampler3D");
+const glsl_type glsl_type::_samplerCubeShadow_type =
+ glsl_type(GL_SAMPLER_CUBE_SHADOW,
+ GLSL_SAMPLER_DIM_CUBE, 1, 0, GLSL_TYPE_FLOAT,
+ "samplerCubeShadow");
+
const glsl_type *const glsl_type::error_type = & glsl_type::_error_type;
const glsl_type *const glsl_type::void_type = & glsl_type::_void_type;
diff --git a/mesalib/src/glsl/builtin_variables.cpp b/mesalib/src/glsl/builtin_variables.cpp
index 353805b7f..e7769419f 100644
--- a/mesalib/src/glsl/builtin_variables.cpp
+++ b/mesalib/src/glsl/builtin_variables.cpp
@@ -61,6 +61,17 @@ static const builtin_variable builtin_100ES_fs_variables[] = {
{ ir_var_in, FRAG_ATTRIB_PNTC, "vec2", "gl_PointCoord" },
};
+static const builtin_variable builtin_300ES_vs_variables[] = {
+ { ir_var_system_value, SYSTEM_VALUE_VERTEX_ID, "int", "gl_VertexID" },
+};
+
+static const builtin_variable builtin_300ES_fs_variables[] = {
+ { ir_var_in, FRAG_ATTRIB_WPOS, "vec4", "gl_FragCoord" },
+ { ir_var_in, FRAG_ATTRIB_FACE, "bool", "gl_FrontFacing" },
+ { ir_var_out, FRAG_RESULT_DEPTH, "float", "gl_FragDepth" },
+ { ir_var_in, FRAG_ATTRIB_PNTC, "vec2", "gl_PointCoord" },
+};
+
static const builtin_variable builtin_110_fs_variables[] = {
{ ir_var_out, FRAG_RESULT_DEPTH, "float", "gl_FragDepth" },
};
@@ -499,12 +510,15 @@ add_builtin_constant(exec_list *instructions, glsl_symbol_table *symtab,
return var;
}
-/* Several constants in GLSL ES have different names than normal desktop GLSL.
+/**
+ * Uniforms that are common to all GLSL ES implementations.
+ *
+ * Several constants in GLSL ES have different names than normal desktop GLSL.
* Therefore, this function should only be called on the ES path.
*/
static void
-generate_100ES_uniforms(exec_list *instructions,
- struct _mesa_glsl_parse_state *state)
+generate_common_ES_uniforms(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state)
{
glsl_symbol_table *const symtab = state->symbols;
@@ -512,8 +526,6 @@ generate_100ES_uniforms(exec_list *instructions,
state->Const.MaxVertexAttribs);
add_builtin_constant(instructions, symtab, "gl_MaxVertexUniformVectors",
state->Const.MaxVertexUniformComponents);
- add_builtin_constant(instructions, symtab, "gl_MaxVaryingVectors",
- state->Const.MaxVaryingFloats / 4);
add_builtin_constant(instructions, symtab, "gl_MaxVertexTextureImageUnits",
state->Const.MaxVertexTextureImageUnits);
add_builtin_constant(instructions, symtab, "gl_MaxCombinedTextureImageUnits",
@@ -528,6 +540,36 @@ generate_100ES_uniforms(exec_list *instructions,
}
static void
+generate_100ES_uniforms(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state)
+{
+ generate_common_ES_uniforms(instructions, state);
+
+ glsl_symbol_table *const symtab = state->symbols;
+
+ add_builtin_constant(instructions, symtab, "gl_MaxVaryingVectors",
+ state->Const.MaxVaryingFloats / 4);
+}
+
+static void
+generate_300ES_uniforms(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state)
+{
+ generate_common_ES_uniforms(instructions, state);
+
+ glsl_symbol_table *const symtab = state->symbols;
+
+ add_builtin_constant(instructions, symtab, "gl_MaxVertexOutputVectors",
+ state->Const.MaxVaryingFloats / 4);
+ add_builtin_constant(instructions, symtab, "gl_MaxFragmentInputVectors",
+ state->Const.MaxVaryingFloats / 4);
+ add_builtin_constant(instructions, symtab, "gl_MinProgramTexelOffset",
+ state->Const.MinProgramTexelOffset);
+ add_builtin_constant(instructions, symtab, "gl_MaxProgramTexelOffset",
+ state->Const.MaxProgramTexelOffset);
+}
+
+static void
generate_110_uniforms(exec_list *instructions,
struct _mesa_glsl_parse_state *state,
bool add_deprecated)
@@ -657,6 +699,26 @@ generate_100ES_vs_variables(exec_list *instructions,
vertex_shader);
}
+static void
+generate_300ES_vs_variables(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state)
+{
+ for (unsigned i = 0; i < Elements(builtin_core_vs_variables); i++) {
+ add_builtin_variable(instructions, state->symbols,
+ & builtin_core_vs_variables[i]);
+ }
+
+ for (unsigned i = 0; i < Elements(builtin_300ES_vs_variables); i++) {
+ add_builtin_variable(instructions, state->symbols,
+ & builtin_300ES_vs_variables[i]);
+ }
+
+ generate_300ES_uniforms(instructions, state);
+
+ generate_ARB_draw_buffers_variables(instructions, state, false,
+ vertex_shader);
+}
+
static void
generate_110_vs_variables(exec_list *instructions,
@@ -760,23 +822,36 @@ static void
initialize_vs_variables(exec_list *instructions,
struct _mesa_glsl_parse_state *state)
{
-
- switch (state->language_version) {
- case 100:
- generate_100ES_vs_variables(instructions, state);
- break;
- case 110:
- generate_110_vs_variables(instructions, state, true);
- break;
- case 120:
- generate_120_vs_variables(instructions, state, true);
- break;
- case 130:
- generate_130_vs_variables(instructions, state, true);
- break;
- case 140:
- generate_130_vs_variables(instructions, state, false);
- break;
+ if (state->es_shader) {
+ switch (state->language_version) {
+ case 100:
+ generate_100ES_vs_variables(instructions, state);
+ break;
+ case 300:
+ generate_300ES_vs_variables(instructions, state);
+ break;
+ default:
+ assert(!"Unexpected language version");
+ break;
+ }
+ } else {
+ switch (state->language_version) {
+ case 110:
+ generate_110_vs_variables(instructions, state, true);
+ break;
+ case 120:
+ generate_120_vs_variables(instructions, state, true);
+ break;
+ case 130:
+ generate_130_vs_variables(instructions, state, true);
+ break;
+ case 140:
+ generate_130_vs_variables(instructions, state, false);
+ break;
+ default:
+ assert(!"Unexpected language version");
+ break;
+ }
}
generate_ARB_draw_instanced_variables(instructions, state, false,
@@ -806,6 +881,25 @@ generate_100ES_fs_variables(exec_list *instructions,
}
static void
+generate_300ES_fs_variables(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state)
+{
+ /* Note: we don't add builtin_core_fs_variables, because it contains
+ * gl_FragColor, which is not in GLSL 3.00 ES.
+ */
+
+ for (unsigned i = 0; i < Elements(builtin_300ES_fs_variables); i++) {
+ add_builtin_variable(instructions, state->symbols,
+ & builtin_300ES_fs_variables[i]);
+ }
+
+ generate_300ES_uniforms(instructions, state);
+
+ generate_ARB_draw_buffers_variables(instructions, state, false,
+ fragment_shader);
+}
+
+static void
generate_110_fs_variables(exec_list *instructions,
struct _mesa_glsl_parse_state *state,
bool add_deprecated)
@@ -865,8 +959,9 @@ generate_ARB_draw_buffers_variables(exec_list *instructions,
mdb->warn_extension = "GL_ARB_draw_buffers";
/* gl_FragData is only available in the fragment shader.
+ * It is not present in GLSL 3.00 ES.
*/
- if (target == fragment_shader) {
+ if (target == fragment_shader && !state->is_version(0, 300)) {
const glsl_type *const vec4_array_type =
glsl_type::get_array_instance(glsl_type::vec4_type,
state->Const.MaxDrawBuffers);
@@ -903,7 +998,8 @@ generate_ARB_draw_instanced_variables(exec_list *instructions,
inst->warn_extension = "GL_ARB_draw_instanced";
}
- if (state->ARB_draw_instanced_enable || state->language_version >= 140) {
+ bool available_in_core = state->is_version(140, 300);
+ if (state->ARB_draw_instanced_enable || available_in_core) {
/* Originally ARB_draw_instanced only specified that ARB decorated name.
* Since no vendor actually implemented that behavior and some apps use
* the undecorated name, the extension now specifies that both names are
@@ -914,7 +1010,7 @@ generate_ARB_draw_instanced_variables(exec_list *instructions,
"gl_InstanceID", glsl_type::int_type,
ir_var_system_value, SYSTEM_VALUE_INSTANCE_ID);
- if (state->language_version < 140 && warn)
+ if (!available_in_core && warn)
inst->warn_extension = "GL_ARB_draw_instanced";
}
}
@@ -1016,23 +1112,36 @@ static void
initialize_fs_variables(exec_list *instructions,
struct _mesa_glsl_parse_state *state)
{
-
- switch (state->language_version) {
- case 100:
- generate_100ES_fs_variables(instructions, state);
- break;
- case 110:
- generate_110_fs_variables(instructions, state, true);
- break;
- case 120:
- generate_120_fs_variables(instructions, state, true);
- break;
- case 130:
- generate_130_fs_variables(instructions, state);
- break;
- case 140:
- generate_140_fs_variables(instructions, state);
- break;
+ if (state->es_shader) {
+ switch (state->language_version) {
+ case 100:
+ generate_100ES_fs_variables(instructions, state);
+ break;
+ case 300:
+ generate_300ES_fs_variables(instructions, state);
+ break;
+ default:
+ assert(!"Unexpected language version");
+ break;
+ }
+ } else {
+ switch (state->language_version) {
+ case 110:
+ generate_110_fs_variables(instructions, state, true);
+ break;
+ case 120:
+ generate_120_fs_variables(instructions, state, true);
+ break;
+ case 130:
+ generate_130_fs_variables(instructions, state);
+ break;
+ case 140:
+ generate_140_fs_variables(instructions, state);
+ break;
+ default:
+ assert(!"Unexpected language version");
+ break;
+ }
}
if (state->ARB_shader_stencil_export_enable)
diff --git a/mesalib/src/glsl/glcpp/Makefile.am b/mesalib/src/glsl/glcpp/Makefile.am
index 04d8cda01..d8d39d295 100644
--- a/mesalib/src/glsl/glcpp/Makefile.am
+++ b/mesalib/src/glsl/glcpp/Makefile.am
@@ -46,7 +46,7 @@ libglcpp_la_SOURCES = \
glcpp_SOURCES = \
../ralloc.c \
- $(top_srcdir)/src/mesa/program/hash_table.c \
+ $(top_srcdir)/src/mesa/program/prog_hash_table.c \
glcpp.c
glcpp_LDADD = libglcpp.la
diff --git a/mesalib/src/glsl/glcpp/glcpp-parse.y b/mesalib/src/glsl/glcpp/glcpp-parse.y
index e7daf7fea..380a1d99c 100644
--- a/mesalib/src/glsl/glcpp/glcpp-parse.y
+++ b/mesalib/src/glsl/glcpp/glcpp-parse.y
@@ -133,6 +133,10 @@ _glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc,
static void
_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc);
+static void
+_glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t version,
+ const char *ident);
+
static int
glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser);
@@ -334,25 +338,10 @@ control_line:
_glcpp_parser_skip_stack_pop (parser, & @1);
} NEWLINE
| HASH_VERSION integer_constant NEWLINE {
- macro_t *macro = hash_table_find (parser->defines, "__VERSION__");
- if (macro) {
- hash_table_remove (parser->defines, "__VERSION__");
- ralloc_free (macro);
- }
- add_builtin_define (parser, "__VERSION__", $2);
-
- if ($2 == 100)
- add_builtin_define (parser, "GL_ES", 1);
-
- /* Currently, all ES2 implementations support highp in the
- * fragment shader, so we always define this macro in ES2.
- * If we ever get a driver that doesn't support highp, we'll
- * need to add a flag to the gl_context and check that here.
- */
- if ($2 >= 130 || $2 == 100)
- add_builtin_define (parser, "GL_FRAGMENT_PRECISION_HIGH", 1);
-
- ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "#version %" PRIiMAX, $2);
+ _glcpp_parser_handle_version_declaration(parser, $2, NULL);
+ }
+| HASH_VERSION integer_constant IDENTIFIER NEWLINE {
+ _glcpp_parser_handle_version_declaration(parser, $2, $3);
}
| HASH NEWLINE
;
@@ -2032,3 +2021,38 @@ _glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc)
parser->skip_stack = node->next;
ralloc_free (node);
}
+
+static void
+_glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t version,
+ const char *es_identifier)
+{
+ /* Note: We assume that if any identifier is present, it means ES.
+ * The GLSL parser will double-check that the identifier is correct.
+ */
+ bool is_es = es_identifier != NULL;
+
+ macro_t *macro = hash_table_find (parser->defines, "__VERSION__");
+ if (macro) {
+ hash_table_remove (parser->defines, "__VERSION__");
+ ralloc_free (macro);
+ }
+ add_builtin_define (parser, "__VERSION__", version);
+
+ if (version == 100)
+ is_es = true;
+ if (is_es)
+ add_builtin_define (parser, "GL_ES", 1);
+
+ /* Currently, all ES2/ES3 implementations support highp in the
+ * fragment shader, so we always define this macro in ES2/ES3.
+ * If we ever get a driver that doesn't support highp, we'll
+ * need to add a flag to the gl_context and check that here.
+ */
+ if (version >= 130 || is_es)
+ add_builtin_define (parser, "GL_FRAGMENT_PRECISION_HIGH", 1);
+
+ ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length,
+ "#version %" PRIiMAX "%s%s", version,
+ es_identifier ? " " : "",
+ es_identifier ? es_identifier : "");
+}
diff --git a/mesalib/src/glsl/glsl_lexer.ll b/mesalib/src/glsl/glsl_lexer.ll
index c538d7d8e..2f66c5828 100644
--- a/mesalib/src/glsl/glsl_lexer.ll
+++ b/mesalib/src/glsl/glsl_lexer.ll
@@ -48,20 +48,34 @@ static int classify_identifier(struct _mesa_glsl_parse_state *, const char *);
*
* Certain words start out as identifiers, become reserved words in
* later language revisions, and finally become language keywords.
+ * This may happen at different times in desktop GLSL and GLSL ES.
*
* For example, consider the following lexer rule:
- * samplerBuffer KEYWORD(130, 140, SAMPLERBUFFER)
+ * samplerBuffer KEYWORD(130, 0, 140, 0, SAMPLERBUFFER)
*
* This means that "samplerBuffer" will be treated as:
* - a keyword (SAMPLERBUFFER token) ...in GLSL >= 1.40
* - a reserved word - error ...in GLSL >= 1.30
- * - an identifier ...in GLSL < 1.30
+ * - an identifier ...in GLSL < 1.30 or GLSL ES
*/
-#define KEYWORD(reserved_version, allowed_version, token) \
+#define KEYWORD(reserved_glsl, reserved_glsl_es, \
+ allowed_glsl, allowed_glsl_es, token) \
+ KEYWORD_WITH_ALT(reserved_glsl, reserved_glsl_es, \
+ allowed_glsl, allowed_glsl_es, false, token)
+
+/**
+ * Like the KEYWORD macro, but the word is also treated as a keyword
+ * if the given boolean expression is true.
+ */
+#define KEYWORD_WITH_ALT(reserved_glsl, reserved_glsl_es, \
+ allowed_glsl, allowed_glsl_es, \
+ alt_expr, token) \
do { \
- if (yyextra->language_version >= allowed_version) { \
+ if (yyextra->is_version(allowed_glsl, allowed_glsl_es) \
+ || alt_expr) { \
return token; \
- } else if (yyextra->language_version >= reserved_version) { \
+ } else if (yyextra->is_version(reserved_glsl, \
+ reserved_glsl_es)) { \
_mesa_glsl_error(yylloc, yyextra, \
"Illegal use of reserved word `%s'", yytext); \
return ERROR_TOK; \
@@ -71,15 +85,20 @@ static int classify_identifier(struct _mesa_glsl_parse_state *, const char *);
} \
} while (0)
-/* The ES macro can be used in KEYWORD checks:
- *
- * word KEYWORD(110 || ES, 400, TOKEN)
- * ...means the word is reserved in GLSL ES 1.00, while
- *
- * word KEYWORD(110, 130 || ES, TOKEN)
- * ...means the word is a legal keyword in GLSL ES 1.00.
+/**
+ * A macro for handling keywords that have been present in GLSL since
+ * its origin, but were changed into reserved words in GLSL 3.00 ES.
*/
-#define ES yyextra->es_shader
+#define DEPRECATED_ES_KEYWORD(token) \
+ do { \
+ if (yyextra->is_version(0, 300)) { \
+ _mesa_glsl_error(yylloc, yyextra, \
+ "Illegal use of reserved word `%s'", yytext); \
+ return ERROR_TOK; \
+ } else { \
+ return token; \
+ } \
+ } while (0)
static int
literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state,
@@ -103,7 +122,7 @@ literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state,
if (value > UINT_MAX) {
/* Note that signed 0xffffffff is valid, not out of range! */
- if (state->language_version >= 130) {
+ if (state->is_version(130, 300)) {
_mesa_glsl_error(lloc, state,
"Literal value `%s' out of range", text);
} else {
@@ -219,12 +238,12 @@ HASH ^{SPC}#{SPC}
\n { yylineno++; yycolumn = 0; }
-attribute return ATTRIBUTE;
+attribute DEPRECATED_ES_KEYWORD(ATTRIBUTE);
const return CONST_TOK;
bool return BOOL_TOK;
float return FLOAT_TOK;
int return INT_TOK;
-uint KEYWORD(130, 130, UINT_TOK);
+uint KEYWORD(130, 300, 130, 300, UINT_TOK);
break return BREAK;
continue return CONTINUE;
@@ -242,59 +261,59 @@ bvec4 return BVEC4;
ivec2 return IVEC2;
ivec3 return IVEC3;
ivec4 return IVEC4;
-uvec2 KEYWORD(130, 130, UVEC2);
-uvec3 KEYWORD(130, 130, UVEC3);
-uvec4 KEYWORD(130, 130, UVEC4);
+uvec2 KEYWORD(130, 300, 130, 300, UVEC2);
+uvec3 KEYWORD(130, 300, 130, 300, UVEC3);
+uvec4 KEYWORD(130, 300, 130, 300, UVEC4);
vec2 return VEC2;
vec3 return VEC3;
vec4 return VEC4;
mat2 return MAT2X2;
mat3 return MAT3X3;
mat4 return MAT4X4;
-mat2x2 KEYWORD(120, 120, MAT2X2);
-mat2x3 KEYWORD(120, 120, MAT2X3);
-mat2x4 KEYWORD(120, 120, MAT2X4);
-mat3x2 KEYWORD(120, 120, MAT3X2);
-mat3x3 KEYWORD(120, 120, MAT3X3);
-mat3x4 KEYWORD(120, 120, MAT3X4);
-mat4x2 KEYWORD(120, 120, MAT4X2);
-mat4x3 KEYWORD(120, 120, MAT4X3);
-mat4x4 KEYWORD(120, 120, MAT4X4);
+mat2x2 KEYWORD(120, 300, 120, 300, MAT2X2);
+mat2x3 KEYWORD(120, 300, 120, 300, MAT2X3);
+mat2x4 KEYWORD(120, 300, 120, 300, MAT2X4);
+mat3x2 KEYWORD(120, 300, 120, 300, MAT3X2);
+mat3x3 KEYWORD(120, 300, 120, 300, MAT3X3);
+mat3x4 KEYWORD(120, 300, 120, 300, MAT3X4);
+mat4x2 KEYWORD(120, 300, 120, 300, MAT4X2);
+mat4x3 KEYWORD(120, 300, 120, 300, MAT4X3);
+mat4x4 KEYWORD(120, 300, 120, 300, MAT4X4);
in return IN_TOK;
out return OUT_TOK;
inout return INOUT_TOK;
uniform return UNIFORM;
-varying return VARYING;
-centroid KEYWORD(120, 120, CENTROID);
-invariant KEYWORD(120 || ES, 120 || ES, INVARIANT);
-flat KEYWORD(130 || ES, 130, FLAT);
-smooth KEYWORD(130, 130, SMOOTH);
-noperspective KEYWORD(130, 130, NOPERSPECTIVE);
-
-sampler1D return SAMPLER1D;
+varying DEPRECATED_ES_KEYWORD(VARYING);
+centroid KEYWORD(120, 300, 120, 300, CENTROID);
+invariant KEYWORD(120, 100, 120, 100, INVARIANT);
+flat KEYWORD(130, 100, 130, 300, FLAT);
+smooth KEYWORD(130, 300, 130, 300, SMOOTH);
+noperspective KEYWORD(130, 300, 130, 0, NOPERSPECTIVE);
+
+sampler1D DEPRECATED_ES_KEYWORD(SAMPLER1D);
sampler2D return SAMPLER2D;
sampler3D return SAMPLER3D;
samplerCube return SAMPLERCUBE;
-sampler1DArray KEYWORD(130, 130, SAMPLER1DARRAY);
-sampler2DArray KEYWORD(130, 130, SAMPLER2DARRAY);
-sampler1DShadow return SAMPLER1DSHADOW;
+sampler1DArray KEYWORD(130, 300, 130, 0, SAMPLER1DARRAY);
+sampler2DArray KEYWORD(130, 300, 130, 300, SAMPLER2DARRAY);
+sampler1DShadow DEPRECATED_ES_KEYWORD(SAMPLER1DSHADOW);
sampler2DShadow return SAMPLER2DSHADOW;
-samplerCubeShadow KEYWORD(130, 130, SAMPLERCUBESHADOW);
-sampler1DArrayShadow KEYWORD(130, 130, SAMPLER1DARRAYSHADOW);
-sampler2DArrayShadow KEYWORD(130, 130, SAMPLER2DARRAYSHADOW);
-isampler1D KEYWORD(130, 130, ISAMPLER1D);
-isampler2D KEYWORD(130, 130, ISAMPLER2D);
-isampler3D KEYWORD(130, 130, ISAMPLER3D);
-isamplerCube KEYWORD(130, 130, ISAMPLERCUBE);
-isampler1DArray KEYWORD(130, 130, ISAMPLER1DARRAY);
-isampler2DArray KEYWORD(130, 130, ISAMPLER2DARRAY);
-usampler1D KEYWORD(130, 130, USAMPLER1D);
-usampler2D KEYWORD(130, 130, USAMPLER2D);
-usampler3D KEYWORD(130, 130, USAMPLER3D);
-usamplerCube KEYWORD(130, 130, USAMPLERCUBE);
-usampler1DArray KEYWORD(130, 130, USAMPLER1DARRAY);
-usampler2DArray KEYWORD(130, 130, USAMPLER2DARRAY);
+samplerCubeShadow KEYWORD(130, 300, 130, 300, SAMPLERCUBESHADOW);
+sampler1DArrayShadow KEYWORD(130, 300, 130, 0, SAMPLER1DARRAYSHADOW);
+sampler2DArrayShadow KEYWORD(130, 300, 130, 300, SAMPLER2DARRAYSHADOW);
+isampler1D KEYWORD(130, 300, 130, 0, ISAMPLER1D);
+isampler2D KEYWORD(130, 300, 130, 300, ISAMPLER2D);
+isampler3D KEYWORD(130, 300, 130, 300, ISAMPLER3D);
+isamplerCube KEYWORD(130, 300, 130, 300, ISAMPLERCUBE);
+isampler1DArray KEYWORD(130, 300, 130, 0, ISAMPLER1DARRAY);
+isampler2DArray KEYWORD(130, 300, 130, 300, ISAMPLER2DARRAY);
+usampler1D KEYWORD(130, 300, 130, 0, USAMPLER1D);
+usampler2D KEYWORD(130, 300, 130, 300, USAMPLER2D);
+usampler3D KEYWORD(130, 300, 130, 300, USAMPLER3D);
+usamplerCube KEYWORD(130, 300, 130, 300, USAMPLERCUBE);
+usampler1DArray KEYWORD(130, 300, 130, 0, USAMPLER1DARRAY);
+usampler2DArray KEYWORD(130, 300, 130, 300, USAMPLER2DARRAY);
samplerCubeArray {
if (yyextra->ARB_texture_cube_map_array_enable)
@@ -333,7 +352,7 @@ struct return STRUCT;
void return VOID_TOK;
layout {
- if ((yyextra->language_version >= 140)
+ if ((yyextra->is_version(140, 300))
|| yyextra->AMD_conservative_depth_enable
|| yyextra->ARB_conservative_depth_enable
|| yyextra->ARB_explicit_attrib_location_enable
@@ -411,96 +430,114 @@ false {
/* Reserved words in GLSL 1.10. */
-asm KEYWORD(110 || ES, 999, ASM);
-class KEYWORD(110 || ES, 999, CLASS);
-union KEYWORD(110 || ES, 999, UNION);
-enum KEYWORD(110 || ES, 999, ENUM);
-typedef KEYWORD(110 || ES, 999, TYPEDEF);
-template KEYWORD(110 || ES, 999, TEMPLATE);
-this KEYWORD(110 || ES, 999, THIS);
-packed KEYWORD(110 || ES, 140 || yyextra->ARB_uniform_buffer_object_enable, PACKED_TOK);
-goto KEYWORD(110 || ES, 999, GOTO);
-switch KEYWORD(110 || ES, 130, SWITCH);
-default KEYWORD(110 || ES, 130, DEFAULT);
-inline KEYWORD(110 || ES, 999, INLINE_TOK);
-noinline KEYWORD(110 || ES, 999, NOINLINE);
-volatile KEYWORD(110 || ES, 999, VOLATILE);
-public KEYWORD(110 || ES, 999, PUBLIC_TOK);
-static KEYWORD(110 || ES, 999, STATIC);
-extern KEYWORD(110 || ES, 999, EXTERN);
-external KEYWORD(110 || ES, 999, EXTERNAL);
-interface KEYWORD(110 || ES, 999, INTERFACE);
-long KEYWORD(110 || ES, 999, LONG_TOK);
-short KEYWORD(110 || ES, 999, SHORT_TOK);
-double KEYWORD(110 || ES, 400, DOUBLE_TOK);
-half KEYWORD(110 || ES, 999, HALF);
-fixed KEYWORD(110 || ES, 999, FIXED_TOK);
-unsigned KEYWORD(110 || ES, 999, UNSIGNED);
-input KEYWORD(110 || ES, 999, INPUT_TOK);
-output KEYWORD(110 || ES, 999, OUTPUT);
-hvec2 KEYWORD(110 || ES, 999, HVEC2);
-hvec3 KEYWORD(110 || ES, 999, HVEC3);
-hvec4 KEYWORD(110 || ES, 999, HVEC4);
-dvec2 KEYWORD(110 || ES, 400, DVEC2);
-dvec3 KEYWORD(110 || ES, 400, DVEC3);
-dvec4 KEYWORD(110 || ES, 400, DVEC4);
-fvec2 KEYWORD(110 || ES, 999, FVEC2);
-fvec3 KEYWORD(110 || ES, 999, FVEC3);
-fvec4 KEYWORD(110 || ES, 999, FVEC4);
-sampler2DRect return SAMPLER2DRECT;
-sampler3DRect KEYWORD(110 || ES, 999, SAMPLER3DRECT);
-sampler2DRectShadow return SAMPLER2DRECTSHADOW;
-sizeof KEYWORD(110 || ES, 999, SIZEOF);
-cast KEYWORD(110 || ES, 999, CAST);
-namespace KEYWORD(110 || ES, 999, NAMESPACE);
-using KEYWORD(110 || ES, 999, USING);
+asm KEYWORD(110, 100, 0, 0, ASM);
+class KEYWORD(110, 100, 0, 0, CLASS);
+union KEYWORD(110, 100, 0, 0, UNION);
+enum KEYWORD(110, 100, 0, 0, ENUM);
+typedef KEYWORD(110, 100, 0, 0, TYPEDEF);
+template KEYWORD(110, 100, 0, 0, TEMPLATE);
+this KEYWORD(110, 100, 0, 0, THIS);
+packed KEYWORD_WITH_ALT(110, 100, 140, 300, yyextra->ARB_uniform_buffer_object_enable, PACKED_TOK);
+goto KEYWORD(110, 100, 0, 0, GOTO);
+switch KEYWORD(110, 100, 130, 300, SWITCH);
+default KEYWORD(110, 100, 130, 300, DEFAULT);
+inline KEYWORD(110, 100, 0, 0, INLINE_TOK);
+noinline KEYWORD(110, 100, 0, 0, NOINLINE);
+volatile KEYWORD(110, 100, 0, 0, VOLATILE);
+public KEYWORD(110, 100, 0, 0, PUBLIC_TOK);
+static KEYWORD(110, 100, 0, 0, STATIC);
+extern KEYWORD(110, 100, 0, 0, EXTERN);
+external KEYWORD(110, 100, 0, 0, EXTERNAL);
+interface KEYWORD(110, 100, 0, 0, INTERFACE);
+long KEYWORD(110, 100, 0, 0, LONG_TOK);
+short KEYWORD(110, 100, 0, 0, SHORT_TOK);
+double KEYWORD(110, 100, 400, 0, DOUBLE_TOK);
+half KEYWORD(110, 100, 0, 0, HALF);
+fixed KEYWORD(110, 100, 0, 0, FIXED_TOK);
+unsigned KEYWORD(110, 100, 0, 0, UNSIGNED);
+input KEYWORD(110, 100, 0, 0, INPUT_TOK);
+output KEYWORD(110, 100, 0, 0, OUTPUT);
+hvec2 KEYWORD(110, 100, 0, 0, HVEC2);
+hvec3 KEYWORD(110, 100, 0, 0, HVEC3);
+hvec4 KEYWORD(110, 100, 0, 0, HVEC4);
+dvec2 KEYWORD(110, 100, 400, 0, DVEC2);
+dvec3 KEYWORD(110, 100, 400, 0, DVEC3);
+dvec4 KEYWORD(110, 100, 400, 0, DVEC4);
+fvec2 KEYWORD(110, 100, 0, 0, FVEC2);
+fvec3 KEYWORD(110, 100, 0, 0, FVEC3);
+fvec4 KEYWORD(110, 100, 0, 0, FVEC4);
+sampler2DRect DEPRECATED_ES_KEYWORD(SAMPLER2DRECT);
+sampler3DRect KEYWORD(110, 100, 0, 0, SAMPLER3DRECT);
+sampler2DRectShadow DEPRECATED_ES_KEYWORD(SAMPLER2DRECTSHADOW);
+sizeof KEYWORD(110, 100, 0, 0, SIZEOF);
+cast KEYWORD(110, 100, 0, 0, CAST);
+namespace KEYWORD(110, 100, 0, 0, NAMESPACE);
+using KEYWORD(110, 100, 0, 0, USING);
/* Additional reserved words in GLSL 1.20. */
-lowp KEYWORD(120, 130 || ES, LOWP);
-mediump KEYWORD(120, 130 || ES, MEDIUMP);
-highp KEYWORD(120, 130 || ES, HIGHP);
-precision KEYWORD(120, 130 || ES, PRECISION);
+lowp KEYWORD(120, 100, 130, 100, LOWP);
+mediump KEYWORD(120, 100, 130, 100, MEDIUMP);
+highp KEYWORD(120, 100, 130, 100, HIGHP);
+precision KEYWORD(120, 100, 130, 100, PRECISION);
/* Additional reserved words in GLSL 1.30. */
-case KEYWORD(130, 130, CASE);
-common KEYWORD(130, 999, COMMON);
-partition KEYWORD(130, 999, PARTITION);
-active KEYWORD(130, 999, ACTIVE);
-superp KEYWORD(130 || ES, 999, SUPERP);
-samplerBuffer KEYWORD(130, 140, SAMPLERBUFFER);
-filter KEYWORD(130, 999, FILTER);
-image1D KEYWORD(130, 999, IMAGE1D);
-image2D KEYWORD(130, 999, IMAGE2D);
-image3D KEYWORD(130, 999, IMAGE3D);
-imageCube KEYWORD(130, 999, IMAGECUBE);
-iimage1D KEYWORD(130, 999, IIMAGE1D);
-iimage2D KEYWORD(130, 999, IIMAGE2D);
-iimage3D KEYWORD(130, 999, IIMAGE3D);
-iimageCube KEYWORD(130, 999, IIMAGECUBE);
-uimage1D KEYWORD(130, 999, UIMAGE1D);
-uimage2D KEYWORD(130, 999, UIMAGE2D);
-uimage3D KEYWORD(130, 999, UIMAGE3D);
-uimageCube KEYWORD(130, 999, UIMAGECUBE);
-image1DArray KEYWORD(130, 999, IMAGE1DARRAY);
-image2DArray KEYWORD(130, 999, IMAGE2DARRAY);
-iimage1DArray KEYWORD(130, 999, IIMAGE1DARRAY);
-iimage2DArray KEYWORD(130, 999, IIMAGE2DARRAY);
-uimage1DArray KEYWORD(130, 999, UIMAGE1DARRAY);
-uimage2DArray KEYWORD(130, 999, UIMAGE2DARRAY);
-image1DShadow KEYWORD(130, 999, IMAGE1DSHADOW);
-image2DShadow KEYWORD(130, 999, IMAGE2DSHADOW);
-image1DArrayShadow KEYWORD(130, 999, IMAGE1DARRAYSHADOW);
-image2DArrayShadow KEYWORD(130, 999, IMAGE2DARRAYSHADOW);
-imageBuffer KEYWORD(130, 999, IMAGEBUFFER);
-iimageBuffer KEYWORD(130, 999, IIMAGEBUFFER);
-uimageBuffer KEYWORD(130, 999, UIMAGEBUFFER);
-row_major KEYWORD(130, 140 || yyextra->ARB_uniform_buffer_object_enable, ROW_MAJOR);
+case KEYWORD(130, 300, 130, 300, CASE);
+common KEYWORD(130, 300, 0, 0, COMMON);
+partition KEYWORD(130, 300, 0, 0, PARTITION);
+active KEYWORD(130, 300, 0, 0, ACTIVE);
+superp KEYWORD(130, 100, 0, 0, SUPERP);
+samplerBuffer KEYWORD(130, 300, 140, 0, SAMPLERBUFFER);
+filter KEYWORD(130, 300, 0, 0, FILTER);
+image1D KEYWORD(130, 300, 0, 0, IMAGE1D);
+image2D KEYWORD(130, 300, 0, 0, IMAGE2D);
+image3D KEYWORD(130, 300, 0, 0, IMAGE3D);
+imageCube KEYWORD(130, 300, 0, 0, IMAGECUBE);
+iimage1D KEYWORD(130, 300, 0, 0, IIMAGE1D);
+iimage2D KEYWORD(130, 300, 0, 0, IIMAGE2D);
+iimage3D KEYWORD(130, 300, 0, 0, IIMAGE3D);
+iimageCube KEYWORD(130, 300, 0, 0, IIMAGECUBE);
+uimage1D KEYWORD(130, 300, 0, 0, UIMAGE1D);
+uimage2D KEYWORD(130, 300, 0, 0, UIMAGE2D);
+uimage3D KEYWORD(130, 300, 0, 0, UIMAGE3D);
+uimageCube KEYWORD(130, 300, 0, 0, UIMAGECUBE);
+image1DArray KEYWORD(130, 300, 0, 0, IMAGE1DARRAY);
+image2DArray KEYWORD(130, 300, 0, 0, IMAGE2DARRAY);
+iimage1DArray KEYWORD(130, 300, 0, 0, IIMAGE1DARRAY);
+iimage2DArray KEYWORD(130, 300, 0, 0, IIMAGE2DARRAY);
+uimage1DArray KEYWORD(130, 300, 0, 0, UIMAGE1DARRAY);
+uimage2DArray KEYWORD(130, 300, 0, 0, UIMAGE2DARRAY);
+image1DShadow KEYWORD(130, 300, 0, 0, IMAGE1DSHADOW);
+image2DShadow KEYWORD(130, 300, 0, 0, IMAGE2DSHADOW);
+image1DArrayShadow KEYWORD(130, 300, 0, 0, IMAGE1DARRAYSHADOW);
+image2DArrayShadow KEYWORD(130, 300, 0, 0, IMAGE2DARRAYSHADOW);
+imageBuffer KEYWORD(130, 300, 0, 0, IMAGEBUFFER);
+iimageBuffer KEYWORD(130, 300, 0, 0, IIMAGEBUFFER);
+uimageBuffer KEYWORD(130, 300, 0, 0, UIMAGEBUFFER);
+row_major KEYWORD_WITH_ALT(130, 0, 140, 0, yyextra->ARB_uniform_buffer_object_enable, ROW_MAJOR);
/* Additional reserved words in GLSL 1.40 */
-isampler2DRect KEYWORD(140, 140, ISAMPLER2DRECT);
-usampler2DRect KEYWORD(140, 140, USAMPLER2DRECT);
-isamplerBuffer KEYWORD(140, 140, ISAMPLERBUFFER);
-usamplerBuffer KEYWORD(140, 140, USAMPLERBUFFER);
+isampler2DRect KEYWORD(140, 300, 140, 0, ISAMPLER2DRECT);
+usampler2DRect KEYWORD(140, 300, 140, 0, USAMPLER2DRECT);
+isamplerBuffer KEYWORD(140, 300, 140, 0, ISAMPLERBUFFER);
+usamplerBuffer KEYWORD(140, 300, 140, 0, USAMPLERBUFFER);
+
+ /* Additional reserved words in GLSL ES 3.00 */
+coherent KEYWORD(0, 300, 0, 0, COHERENT);
+restrict KEYWORD(0, 300, 0, 0, RESTRICT);
+readonly KEYWORD(0, 300, 0, 0, READONLY);
+writeonly KEYWORD(0, 300, 0, 0, WRITEONLY);
+resource KEYWORD(0, 300, 0, 0, RESOURCE);
+atomic_uint KEYWORD(0, 300, 0, 0, ATOMIC_UINT);
+patch KEYWORD(0, 300, 0, 0, PATCH);
+sample KEYWORD(0, 300, 0, 0, SAMPLE);
+subroutine KEYWORD(0, 300, 0, 0, SUBROUTINE);
+sampler2DMS KEYWORD(0, 300, 0, 0, SAMPLER2DMS);
+isampler2DMS KEYWORD(0, 300, 0, 0, ISAMPLER2DMS);
+usampler2DMS KEYWORD(0, 300, 0, 0, USAMPLER2DMS);
+sampler2DMSArray KEYWORD(0, 300, 0, 0, SAMPLER2DMSARRAY);
+isampler2DMSArray KEYWORD(0, 300, 0, 0, ISAMPLER2DMSARRAY);
+usampler2DMSArray KEYWORD(0, 300, 0, 0, USAMPLER2DMSARRAY);
+
[_a-zA-Z][_a-zA-Z0-9]* {
struct _mesa_glsl_parse_state *state = yyextra;
diff --git a/mesalib/src/glsl/glsl_parser.yy b/mesalib/src/glsl/glsl_parser.yy
index 407dbbeeb..d8494667b 100644
--- a/mesalib/src/glsl/glsl_parser.yy
+++ b/mesalib/src/glsl/glsl_parser.yy
@@ -137,6 +137,9 @@ static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg)
%token HVEC2 HVEC3 HVEC4 DVEC2 DVEC3 DVEC4 FVEC2 FVEC3 FVEC4
%token SAMPLER3DRECT
%token SIZEOF CAST NAMESPACE USING
+%token COHERENT RESTRICT READONLY WRITEONLY RESOURCE ATOMIC_UINT PATCH SAMPLE
+%token SUBROUTINE SAMPLER2DMS ISAMPLER2DMS USAMPLER2DMS SAMPLER2DMSARRAY
+%token ISAMPLER2DMSARRAY USAMPLER2DMSARRAY
%token ERROR_TOK
@@ -258,54 +261,12 @@ version_statement:
/* blank - no #version specified: defaults are already set */
| VERSION_TOK INTCONSTANT EOL
{
- bool supported = false;
-
- switch ($2) {
- case 100:
- state->es_shader = true;
- supported = state->ctx->API == API_OPENGLES2 ||
- state->ctx->Extensions.ARB_ES2_compatibility;
- break;
- case 110:
- case 120:
- /* FINISHME: Once the OpenGL 3.0 'forward compatible' context or
- * the OpenGL 3.2 Core context is supported, this logic will need
- * change. Older versions of GLSL are no longer supported
- * outside the compatibility contexts of 3.x.
- */
- case 130:
- case 140:
- case 150:
- case 330:
- case 400:
- case 410:
- case 420:
- supported = _mesa_is_desktop_gl(state->ctx) &&
- ((unsigned) $2) <= state->ctx->Const.GLSLVersion;
- break;
- default:
- supported = false;
- break;
- }
-
- state->language_version = $2;
- state->version_string =
- ralloc_asprintf(state, "GLSL%s %d.%02d",
- state->es_shader ? " ES" : "",
- state->language_version / 100,
- state->language_version % 100);
-
- if (!supported) {
- _mesa_glsl_error(& @2, state, "%s is not supported. "
- "Supported versions are: %s\n",
- state->version_string,
- state->supported_version_string);
- }
-
- if (state->language_version >= 140) {
- state->ARB_uniform_buffer_object_enable = true;
- }
+ state->process_version_directive(&@2, $2, NULL);
}
+ | VERSION_TOK INTCONSTANT any_identifier EOL
+ {
+ state->process_version_directive(&@2, $2, $3);
+ }
;
pragma_statement:
@@ -315,10 +276,11 @@ pragma_statement:
| PRAGMA_OPTIMIZE_OFF EOL
| PRAGMA_INVARIANT_ALL EOL
{
- if (state->language_version == 110) {
+ if (!state->is_version(120, 100)) {
_mesa_glsl_warning(& @1, state,
- "pragma `invariant(all)' not supported in %s",
- state->version_string);
+ "pragma `invariant(all)' not supported in %s "
+ "(GLSL ES 1.00 or GLSL 1.20 required).",
+ state->get_version_string());
} else {
state->all_invariant = true;
}
@@ -1126,6 +1088,7 @@ layout_qualifier_id_list:
integer_constant:
INTCONSTANT { $$ = $1; }
| UINTCONSTANT { $$ = $1; }
+ ;
layout_qualifier_id:
any_identifier
@@ -1181,6 +1144,8 @@ layout_qualifier_id:
$$.flags.q.shared = 1;
} else if (strcmp($1, "column_major") == 0) {
$$.flags.q.column_major = 1;
+ } else if (strcmp($1, "row_major") == 0) {
+ $$.flags.q.row_major = 1;
}
if ($$.flags.i && state->ARB_uniform_buffer_object_warn) {
@@ -1498,32 +1463,17 @@ basic_type_specifier_nonarray:
precision_qualifier:
HIGHP {
- if (!state->es_shader && state->language_version < 130)
- _mesa_glsl_error(& @1, state,
- "precision qualifier forbidden "
- "in %s (1.30 or later "
- "required)\n",
- state->version_string);
+ state->check_precision_qualifiers_allowed(&@1);
$$ = ast_precision_high;
}
| MEDIUMP {
- if (!state->es_shader && state->language_version < 130)
- _mesa_glsl_error(& @1, state,
- "precision qualifier forbidden "
- "in %s (1.30 or later "
- "required)\n",
- state->version_string);
+ state->check_precision_qualifiers_allowed(&@1);
$$ = ast_precision_medium;
}
| LOWP {
- if (!state->es_shader && state->language_version < 130)
- _mesa_glsl_error(& @1, state,
- "precision qualifier forbidden "
- "in %s (1.30 or later "
- "required)\n",
- state->version_string);
+ state->check_precision_qualifiers_allowed(&@1);
$$ = ast_precision_low;
}
diff --git a/mesalib/src/glsl/glsl_parser_extras.cpp b/mesalib/src/glsl/glsl_parser_extras.cpp
index f1fdd3a47..d36089226 100644
--- a/mesalib/src/glsl/glsl_parser_extras.cpp
+++ b/mesalib/src/glsl/glsl_parser_extras.cpp
@@ -37,6 +37,16 @@ extern "C" {
#include "ir_optimization.h"
#include "loop_analysis.h"
+/**
+ * Format a short human-readable description of the given GLSL version.
+ */
+const char *
+glsl_compute_version_string(void *mem_ctx, bool is_es, unsigned version)
+{
+ return ralloc_asprintf(mem_ctx, "GLSL%s %d.%02d", is_es ? " ES" : "",
+ version / 100, version % 100);
+}
+
_mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
GLenum target, void *mem_ctx)
: ctx(_ctx)
@@ -82,6 +92,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
this->Const.MaxCombinedTextureImageUnits = ctx->Const.MaxCombinedTextureImageUnits;
this->Const.MaxTextureImageUnits = ctx->Const.MaxTextureImageUnits;
this->Const.MaxFragmentUniformComponents = ctx->Const.FragmentProgram.MaxUniformComponents;
+ this->Const.MinProgramTexelOffset = ctx->Const.MinProgramTexelOffset;
+ this->Const.MaxProgramTexelOffset = ctx->Const.MaxProgramTexelOffset;
this->Const.MaxDrawBuffers = ctx->Const.MaxDrawBuffers;
@@ -113,6 +125,166 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
this->default_uniform_qualifier->flags.q.column_major = 1;
}
+/**
+ * Determine whether the current GLSL version is sufficiently high to support
+ * a certain feature, and generate an error message if it isn't.
+ *
+ * \param required_glsl_version and \c required_glsl_es_version are
+ * interpreted as they are in _mesa_glsl_parse_state::is_version().
+ *
+ * \param locp is the parser location where the error should be reported.
+ *
+ * \param fmt (and additional arguments) constitute a printf-style error
+ * message to report if the version check fails. Information about the
+ * current and required GLSL versions will be appended. So, for example, if
+ * the GLSL version being compiled is 1.20, and check_version(130, 300, locp,
+ * "foo unsupported") is called, the error message will be "foo unsupported in
+ * GLSL 1.20 (GLSL 1.30 or GLSL 3.00 ES required)".
+ */
+bool
+_mesa_glsl_parse_state::check_version(unsigned required_glsl_version,
+ unsigned required_glsl_es_version,
+ YYLTYPE *locp, const char *fmt, ...)
+{
+ if (this->is_version(required_glsl_version, required_glsl_es_version))
+ return true;
+
+ va_list args;
+ va_start(args, fmt);
+ char *problem = ralloc_vasprintf(ctx, fmt, args);
+ va_end(args);
+ const char *glsl_version_string
+ = glsl_compute_version_string(ctx, false, required_glsl_version);
+ const char *glsl_es_version_string
+ = glsl_compute_version_string(ctx, true, required_glsl_es_version);
+ const char *requirement_string = "";
+ if (required_glsl_version && required_glsl_es_version) {
+ requirement_string = ralloc_asprintf(ctx, " (%s or %s required)",
+ glsl_version_string,
+ glsl_es_version_string);
+ } else if (required_glsl_version) {
+ requirement_string = ralloc_asprintf(ctx, " (%s required)",
+ glsl_version_string);
+ } else if (required_glsl_es_version) {
+ requirement_string = ralloc_asprintf(ctx, " (%s required)",
+ glsl_es_version_string);
+ }
+ _mesa_glsl_error(locp, this, "%s in %s%s.",
+ problem, this->get_version_string(),
+ requirement_string);
+
+ return false;
+}
+
+/**
+ * Process a GLSL #version directive.
+ *
+ * \param version is the integer that follows the #version token.
+ *
+ * \param ident is a string identifier that follows the integer, if any is
+ * present. Otherwise NULL.
+ */
+void
+_mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version,
+ const char *ident)
+{
+ bool es_token_present = false;
+ if (ident) {
+ if (strcmp(ident, "es") == 0) {
+ es_token_present = true;
+ } else {
+ _mesa_glsl_error(locp, this,
+ "Illegal text following version number\n");
+ }
+ }
+
+ bool supported = false;
+
+ if (es_token_present) {
+ this->es_shader = true;
+ switch (version) {
+ case 100:
+ _mesa_glsl_error(locp, this,
+ "GLSL 1.00 ES should be selected using "
+ "`#version 100'\n");
+ supported = this->ctx->API == API_OPENGLES2 ||
+ this->ctx->Extensions.ARB_ES2_compatibility;
+ break;
+ case 300:
+ supported = _mesa_is_gles3(this->ctx) ||
+ this->ctx->Extensions.ARB_ES3_compatibility;
+ break;
+ default:
+ supported = false;
+ break;
+ }
+ } else {
+ switch (version) {
+ case 100:
+ this->es_shader = true;
+ supported = this->ctx->API == API_OPENGLES2 ||
+ this->ctx->Extensions.ARB_ES2_compatibility;
+ break;
+ case 110:
+ case 120:
+ /* FINISHME: Once the OpenGL 3.0 'forward compatible' context or
+ * the OpenGL 3.2 Core context is supported, this logic will need
+ * change. Older versions of GLSL are no longer supported
+ * outside the compatibility contexts of 3.x.
+ */
+ case 130:
+ case 140:
+ case 150:
+ case 330:
+ case 400:
+ case 410:
+ case 420:
+ supported = _mesa_is_desktop_gl(this->ctx) &&
+ ((unsigned) version) <= this->ctx->Const.GLSLVersion;
+ break;
+ default:
+ supported = false;
+ break;
+ }
+ }
+
+ this->language_version = version;
+
+ if (!supported) {
+ _mesa_glsl_error(locp, this, "%s is not supported. "
+ "Supported versions are: %s\n",
+ this->get_version_string(),
+ this->supported_version_string);
+
+ /* On exit, the language_version must be set to a valid value.
+ * Later calls to _mesa_glsl_initialize_types will misbehave if
+ * the version is invalid.
+ */
+ switch (this->ctx->API) {
+ case API_OPENGL_COMPAT:
+ case API_OPENGL_CORE:
+ this->language_version = this->ctx->Const.GLSLVersion;
+ break;
+
+ case API_OPENGLES:
+ assert(!"Should not get here.");
+ /* FALLTHROUGH */
+
+ case API_OPENGLES2:
+ this->language_version = 100;
+ break;
+ }
+ }
+
+ if (this->language_version >= 140) {
+ this->ARB_uniform_buffer_object_enable = true;
+ }
+
+ if (this->language_version == 300 && this->es_shader) {
+ this->ARB_explicit_attrib_location_enable = true;
+ }
+}
+
const char *
_mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target)
{
diff --git a/mesalib/src/glsl/glsl_parser_extras.h b/mesalib/src/glsl/glsl_parser_extras.h
index 0b208f6ca..46e0784ba 100644
--- a/mesalib/src/glsl/glsl_parser_extras.h
+++ b/mesalib/src/glsl/glsl_parser_extras.h
@@ -56,6 +56,19 @@ struct glsl_switch_state {
bool is_switch_innermost; // if switch stmt is closest to break, ...
};
+const char *
+glsl_compute_version_string(void *mem_ctx, bool is_es, unsigned version);
+
+typedef struct YYLTYPE {
+ int first_line;
+ int first_column;
+ int last_line;
+ int last_column;
+ unsigned source;
+} YYLTYPE;
+# define YYLTYPE_IS_DECLARED 1
+# define YYLTYPE_IS_TRIVIAL 1
+
struct _mesa_glsl_parse_state {
_mesa_glsl_parse_state(struct gl_context *_ctx, GLenum target,
void *mem_ctx);
@@ -77,6 +90,55 @@ struct _mesa_glsl_parse_state {
ralloc_free(mem);
}
+ /**
+ * Generate a string representing the GLSL version currently being compiled
+ * (useful for error messages).
+ */
+ const char *get_version_string()
+ {
+ return glsl_compute_version_string(this, this->es_shader,
+ this->language_version);
+ }
+
+ /**
+ * Determine whether the current GLSL version is sufficiently high to
+ * support a certain feature.
+ *
+ * \param required_glsl_version is the desktop GLSL version that is
+ * required to support the feature, or 0 if no version of desktop GLSL
+ * supports the feature.
+ *
+ * \param required_glsl_es_version is the GLSL ES version that is required
+ * to support the feature, or 0 if no version of GLSL ES suports the
+ * feature.
+ */
+ bool is_version(unsigned required_glsl_version,
+ unsigned required_glsl_es_version)
+ {
+ unsigned required_version = this->es_shader ?
+ required_glsl_es_version : required_glsl_version;
+ return required_version != 0
+ && this->language_version >= required_version;
+ }
+
+ bool check_version(unsigned required_glsl_version,
+ unsigned required_glsl_es_version,
+ YYLTYPE *locp, const char *fmt, ...) PRINTFLIKE(5, 6);
+
+ bool check_precision_qualifiers_allowed(YYLTYPE *locp)
+ {
+ return check_version(130, 100, locp,
+ "precision qualifiers are forbidden");
+ }
+
+ bool check_bitwise_operations_allowed(YYLTYPE *locp)
+ {
+ return check_version(130, 300, locp, "bit-wise operations are forbidden");
+ }
+
+ void process_version_directive(YYLTYPE *locp, int version,
+ const char *ident);
+
struct gl_context *const ctx;
void *scanner;
exec_list translation_unit;
@@ -88,7 +150,6 @@ struct _mesa_glsl_parse_state {
bool es_shader;
unsigned language_version;
- const char *version_string;
enum _mesa_glsl_parser_targets target;
/**
@@ -129,6 +190,10 @@ struct _mesa_glsl_parse_state {
/* ARB_draw_buffers */
unsigned MaxDrawBuffers;
+
+ /* 3.00 ES */
+ int MinProgramTexelOffset;
+ int MaxProgramTexelOffset;
} Const;
/**
@@ -217,16 +282,6 @@ struct _mesa_glsl_parse_state {
unsigned num_builtins_to_link;
};
-typedef struct YYLTYPE {
- int first_line;
- int first_column;
- int last_line;
- int last_column;
- unsigned source;
-} YYLTYPE;
-# define YYLTYPE_IS_DECLARED 1
-# define YYLTYPE_IS_TRIVIAL 1
-
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do { \
if (N) \
diff --git a/mesalib/src/glsl/glsl_symbol_table.cpp b/mesalib/src/glsl/glsl_symbol_table.cpp
index bcb65d301..f934ea865 100644
--- a/mesalib/src/glsl/glsl_symbol_table.cpp
+++ b/mesalib/src/glsl/glsl_symbol_table.cpp
@@ -52,7 +52,7 @@ public:
glsl_symbol_table::glsl_symbol_table()
{
- this->language_version = 120;
+ this->separate_function_namespace = false;
this->table = _mesa_symbol_table_ctor();
this->mem_ctx = ralloc_context(NULL);
}
@@ -80,7 +80,7 @@ bool glsl_symbol_table::name_declared_this_scope(const char *name)
bool glsl_symbol_table::add_variable(ir_variable *v)
{
- if (this->language_version == 110) {
+ if (this->separate_function_namespace) {
/* In 1.10, functions and variables have separate namespaces. */
symbol_table_entry *existing = get_entry(v->name);
if (name_declared_this_scope(v->name)) {
@@ -120,7 +120,7 @@ bool glsl_symbol_table::add_type(const char *name, const glsl_type *t)
bool glsl_symbol_table::add_function(ir_function *f)
{
- if (this->language_version == 110 && name_declared_this_scope(f->name)) {
+ if (this->separate_function_namespace && name_declared_this_scope(f->name)) {
/* In 1.10, functions and variables have separate namespaces. */
symbol_table_entry *existing = get_entry(f->name);
if ((existing->f == NULL) && (existing->t == NULL)) {
diff --git a/mesalib/src/glsl/glsl_symbol_table.h b/mesalib/src/glsl/glsl_symbol_table.h
index 637bc033b..9f5602787 100644
--- a/mesalib/src/glsl/glsl_symbol_table.h
+++ b/mesalib/src/glsl/glsl_symbol_table.h
@@ -77,7 +77,8 @@ public:
glsl_symbol_table();
~glsl_symbol_table();
- unsigned int language_version;
+ /* In 1.10, functions and variables have separate namespaces. */
+ bool separate_function_namespace;
void push_scope();
void pop_scope();
diff --git a/mesalib/src/glsl/glsl_types.cpp b/mesalib/src/glsl/glsl_types.cpp
index 3940a12a5..71b185027 100644
--- a/mesalib/src/glsl/glsl_types.cpp
+++ b/mesalib/src/glsl/glsl_types.cpp
@@ -102,11 +102,16 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
static void
add_types_to_symbol_table(glsl_symbol_table *symtab,
const struct glsl_type *types,
- unsigned num_types, bool warn)
+ unsigned num_types, bool warn,
+ bool skip_1d)
{
(void) warn;
for (unsigned i = 0; i < num_types; i++) {
+ if (skip_1d && types[i].base_type == GLSL_TYPE_SAMPLER
+ && types[i].sampler_dimensionality == GLSL_SAMPLER_DIM_1D)
+ continue;
+
symtab->add_type(types[i].name, & types[i]);
}
}
@@ -158,49 +163,68 @@ glsl_type::sampler_index() const
void
glsl_type::generate_100ES_types(glsl_symbol_table *symtab)
{
+ bool skip_1d = false;
add_types_to_symbol_table(symtab, builtin_core_types,
Elements(builtin_core_types),
- false);
+ false, skip_1d);
add_types_to_symbol_table(symtab, builtin_structure_types,
Elements(builtin_structure_types),
- false);
- add_types_to_symbol_table(symtab, void_type, 1, false);
+ false, skip_1d);
+ add_types_to_symbol_table(symtab, void_type, 1, false, skip_1d);
+}
+
+void
+glsl_type::generate_300ES_types(glsl_symbol_table *symtab)
+{
+ /* GLSL 3.00 ES types are the same as GLSL 1.30 types, except that 1D
+ * samplers are skipped, and samplerCubeShadow is added.
+ */
+ bool add_deprecated = false;
+ bool skip_1d = true;
+
+ generate_130_types(symtab, add_deprecated, skip_1d);
+
+ add_types_to_symbol_table(symtab, &_samplerCubeShadow_type, 1, false,
+ skip_1d);
}
void
-glsl_type::generate_110_types(glsl_symbol_table *symtab, bool add_deprecated)
+glsl_type::generate_110_types(glsl_symbol_table *symtab, bool add_deprecated,
+ bool skip_1d)
{
generate_100ES_types(symtab);
add_types_to_symbol_table(symtab, builtin_110_types,
Elements(builtin_110_types),
- false);
- add_types_to_symbol_table(symtab, &_sampler3D_type, 1, false);
+ false, skip_1d);
+ add_types_to_symbol_table(symtab, &_sampler3D_type, 1, false, skip_1d);
if (add_deprecated) {
add_types_to_symbol_table(symtab, builtin_110_deprecated_structure_types,
Elements(builtin_110_deprecated_structure_types),
- false);
+ false, skip_1d);
}
}
void
-glsl_type::generate_120_types(glsl_symbol_table *symtab, bool add_deprecated)
+glsl_type::generate_120_types(glsl_symbol_table *symtab, bool add_deprecated,
+ bool skip_1d)
{
- generate_110_types(symtab, add_deprecated);
+ generate_110_types(symtab, add_deprecated, skip_1d);
add_types_to_symbol_table(symtab, builtin_120_types,
- Elements(builtin_120_types), false);
+ Elements(builtin_120_types), false, skip_1d);
}
void
-glsl_type::generate_130_types(glsl_symbol_table *symtab, bool add_deprecated)
+glsl_type::generate_130_types(glsl_symbol_table *symtab, bool add_deprecated,
+ bool skip_1d)
{
- generate_120_types(symtab, add_deprecated);
+ generate_120_types(symtab, add_deprecated, skip_1d);
add_types_to_symbol_table(symtab, builtin_130_types,
- Elements(builtin_130_types), false);
+ Elements(builtin_130_types), false, skip_1d);
generate_EXT_texture_array_types(symtab, false);
}
@@ -208,14 +232,16 @@ glsl_type::generate_130_types(glsl_symbol_table *symtab, bool add_deprecated)
void
glsl_type::generate_140_types(glsl_symbol_table *symtab)
{
- generate_130_types(symtab, false);
+ bool skip_1d = false;
+
+ generate_130_types(symtab, false, skip_1d);
add_types_to_symbol_table(symtab, builtin_140_types,
- Elements(builtin_140_types), false);
+ Elements(builtin_140_types), false, skip_1d);
add_types_to_symbol_table(symtab, builtin_EXT_texture_buffer_object_types,
Elements(builtin_EXT_texture_buffer_object_types),
- false);
+ false, skip_1d);
}
@@ -223,9 +249,11 @@ void
glsl_type::generate_ARB_texture_rectangle_types(glsl_symbol_table *symtab,
bool warn)
{
+ bool skip_1d = false;
+
add_types_to_symbol_table(symtab, builtin_ARB_texture_rectangle_types,
Elements(builtin_ARB_texture_rectangle_types),
- warn);
+ warn, skip_1d);
}
@@ -233,16 +261,20 @@ void
glsl_type::generate_EXT_texture_array_types(glsl_symbol_table *symtab,
bool warn)
{
+ bool skip_1d = false;
+
add_types_to_symbol_table(symtab, builtin_EXT_texture_array_types,
Elements(builtin_EXT_texture_array_types),
- warn);
+ warn, skip_1d);
}
void
glsl_type::generate_OES_texture_3D_types(glsl_symbol_table *symtab, bool warn)
{
- add_types_to_symbol_table(symtab, &_sampler3D_type, 1, warn);
+ bool skip_1d = false;
+
+ add_types_to_symbol_table(symtab, &_sampler3D_type, 1, warn, skip_1d);
}
@@ -250,56 +282,74 @@ void
glsl_type::generate_OES_EGL_image_external_types(glsl_symbol_table *symtab,
bool warn)
{
+ bool skip_1d = false;
+
add_types_to_symbol_table(symtab, builtin_OES_EGL_image_external_types,
Elements(builtin_OES_EGL_image_external_types),
- warn);
+ warn, skip_1d);
}
void
glsl_type::generate_ARB_texture_cube_map_array_types(glsl_symbol_table *symtab,
bool warn)
{
+ bool skip_1d = false;
+
add_types_to_symbol_table(symtab, builtin_ARB_texture_cube_map_array_types,
Elements(builtin_ARB_texture_cube_map_array_types),
- warn);
+ warn, skip_1d);
}
void
_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
{
- switch (state->language_version) {
- case 100:
- assert(state->es_shader);
- glsl_type::generate_100ES_types(state->symbols);
- break;
- case 110:
- glsl_type::generate_110_types(state->symbols, true);
- break;
- case 120:
- glsl_type::generate_120_types(state->symbols, true);
- break;
- case 130:
- glsl_type::generate_130_types(state->symbols, true);
- break;
- case 140:
- glsl_type::generate_140_types(state->symbols);
- break;
- default:
- /* error */
- break;
+ if (state->es_shader) {
+ switch (state->language_version) {
+ case 100:
+ assert(state->es_shader);
+ glsl_type::generate_100ES_types(state->symbols);
+ break;
+ case 300:
+ glsl_type::generate_300ES_types(state->symbols);
+ break;
+ default:
+ assert(!"Unexpected language version");
+ break;
+ }
+ } else {
+ bool skip_1d = false;
+ switch (state->language_version) {
+ case 110:
+ glsl_type::generate_110_types(state->symbols, true, skip_1d);
+ break;
+ case 120:
+ glsl_type::generate_120_types(state->symbols, true, skip_1d);
+ break;
+ case 130:
+ glsl_type::generate_130_types(state->symbols, true, skip_1d);
+ break;
+ case 140:
+ glsl_type::generate_140_types(state->symbols);
+ break;
+ default:
+ assert(!"Unexpected language version");
+ break;
+ }
}
if (state->ARB_texture_rectangle_enable ||
- state->language_version >= 140) {
+ state->is_version(140, 0)) {
glsl_type::generate_ARB_texture_rectangle_types(state->symbols,
state->ARB_texture_rectangle_warn);
}
- if (state->OES_texture_3D_enable && state->language_version == 100) {
+ if (state->OES_texture_3D_enable
+ && state->is_version(0, 100)) {
glsl_type::generate_OES_texture_3D_types(state->symbols,
state->OES_texture_3D_warn);
}
- if (state->EXT_texture_array_enable && state->language_version < 130) {
+ if (state->EXT_texture_array_enable
+ && !state->is_version(130, 0)) {
// These are already included in 130; don't create twice.
glsl_type::generate_EXT_texture_array_types(state->symbols,
state->EXT_texture_array_warn);
diff --git a/mesalib/src/glsl/glsl_types.h b/mesalib/src/glsl/glsl_types.h
index cf954a256..d6f5c105e 100644
--- a/mesalib/src/glsl/glsl_types.h
+++ b/mesalib/src/glsl/glsl_types.h
@@ -510,6 +510,7 @@ private:
static const glsl_type _error_type;
static const glsl_type _void_type;
static const glsl_type _sampler3D_type;
+ static const glsl_type _samplerCubeShadow_type;
static const glsl_type builtin_core_types[];
static const glsl_type builtin_structure_types[];
static const glsl_type builtin_110_deprecated_structure_types[];
@@ -534,9 +535,13 @@ private:
*/
/*@{*/
static void generate_100ES_types(glsl_symbol_table *);
- static void generate_110_types(glsl_symbol_table *, bool add_deprecated);
- static void generate_120_types(glsl_symbol_table *, bool add_deprecated);
- static void generate_130_types(glsl_symbol_table *, bool add_deprecated);
+ static void generate_300ES_types(glsl_symbol_table *);
+ static void generate_110_types(glsl_symbol_table *, bool add_deprecated,
+ bool skip_1d);
+ static void generate_120_types(glsl_symbol_table *, bool add_deprecated,
+ bool skip_1d);
+ static void generate_130_types(glsl_symbol_table *, bool add_deprecated,
+ bool skip_1d);
static void generate_140_types(glsl_symbol_table *);
static void generate_ARB_texture_rectangle_types(glsl_symbol_table *, bool);
static void generate_EXT_texture_array_types(glsl_symbol_table *, bool);
diff --git a/mesalib/src/glsl/hir_field_selection.cpp b/mesalib/src/glsl/hir_field_selection.cpp
index 260b415a8..ac416d5da 100644
--- a/mesalib/src/glsl/hir_field_selection.cpp
+++ b/mesalib/src/glsl/hir_field_selection.cpp
@@ -72,8 +72,7 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr,
}
} else if (expr->subexpressions[1] != NULL) {
/* Handle "method calls" in GLSL 1.20 - namely, array.length() */
- if (state->language_version < 120)
- _mesa_glsl_error(&loc, state, "Methods not supported in GLSL 1.10.");
+ state->check_version(120, 300, &loc, "Methods not supported");
ast_expression *call = expr->subexpressions[1];
assert(call->oper == ast_function_call);
diff --git a/mesalib/src/glsl/ir_variable_refcount.cpp b/mesalib/src/glsl/ir_variable_refcount.cpp
index 1633a7357..923eb1a82 100644
--- a/mesalib/src/glsl/ir_variable_refcount.cpp
+++ b/mesalib/src/glsl/ir_variable_refcount.cpp
@@ -33,7 +33,26 @@
#include "ir_visitor.h"
#include "ir_variable_refcount.h"
#include "glsl_types.h"
+#include "main/hash_table.h"
+ir_variable_refcount_visitor::ir_variable_refcount_visitor()
+{
+ this->mem_ctx = ralloc_context(NULL);
+ this->ht = _mesa_hash_table_create(NULL, _mesa_key_pointer_equal);
+}
+
+static void
+free_entry(struct hash_entry *entry)
+{
+ ir_variable_refcount_entry *ivre = (ir_variable_refcount_entry *) entry->data;
+ delete ivre;
+}
+
+ir_variable_refcount_visitor::~ir_variable_refcount_visitor()
+{
+ ralloc_free(this->mem_ctx);
+ _mesa_hash_table_destroy(this->ht, free_entry);
+}
// constructor
ir_variable_refcount_entry::ir_variable_refcount_entry(ir_variable *var)
@@ -50,15 +69,17 @@ ir_variable_refcount_entry *
ir_variable_refcount_visitor::get_variable_entry(ir_variable *var)
{
assert(var);
- foreach_iter(exec_list_iterator, iter, this->variable_list) {
- ir_variable_refcount_entry *entry = (ir_variable_refcount_entry *)iter.get();
- if (entry->var == var)
- return entry;
- }
- ir_variable_refcount_entry *entry = new(mem_ctx) ir_variable_refcount_entry(var);
+ struct hash_entry *e = _mesa_hash_table_search(this->ht,
+ _mesa_hash_pointer(var),
+ var);
+ if (e)
+ return (ir_variable_refcount_entry *)e->data;
+
+ ir_variable_refcount_entry *entry = new ir_variable_refcount_entry(var);
assert(entry->referenced_count == 0);
- this->variable_list.push_tail(entry);
+ _mesa_hash_table_insert(this->ht, _mesa_hash_pointer(var), var, entry);
+
return entry;
}
diff --git a/mesalib/src/glsl/ir_variable_refcount.h b/mesalib/src/glsl/ir_variable_refcount.h
index 51a4945a1..c15e8110d 100644
--- a/mesalib/src/glsl/ir_variable_refcount.h
+++ b/mesalib/src/glsl/ir_variable_refcount.h
@@ -33,7 +33,7 @@
#include "ir_visitor.h"
#include "glsl_types.h"
-class ir_variable_refcount_entry : public exec_node
+class ir_variable_refcount_entry
{
public:
ir_variable_refcount_entry(ir_variable *var);
@@ -52,16 +52,8 @@ public:
class ir_variable_refcount_visitor : public ir_hierarchical_visitor {
public:
- ir_variable_refcount_visitor(void)
- {
- this->mem_ctx = ralloc_context(NULL);
- this->variable_list.make_empty();
- }
-
- ~ir_variable_refcount_visitor(void)
- {
- ralloc_free(this->mem_ctx);
- }
+ ir_variable_refcount_visitor(void);
+ ~ir_variable_refcount_visitor(void);
virtual ir_visitor_status visit(ir_variable *);
virtual ir_visitor_status visit(ir_dereference_variable *);
@@ -71,8 +63,7 @@ public:
ir_variable_refcount_entry *get_variable_entry(ir_variable *var);
- /* List of ir_variable_refcount_entry */
- exec_list variable_list;
+ struct hash_table *ht;
void *mem_ctx;
};
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index 3b2ab962b..29fc5d841 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -289,8 +289,11 @@ validate_vertex_shader_executable(struct gl_shader_program *prog,
* operations, if present, that operate on primitives after
* vertex processing has occurred. Its value is undefined if
* the vertex shader executable does not write gl_Position."
+ *
+ * GLSL ES 3.00 is similar to GLSL 1.40--failing to write to gl_Position is
+ * not an error.
*/
- if (prog->Version < 140) {
+ if (prog->Version < (prog->IsES ? 300 : 140)) {
find_assignment_visitor find("gl_Position");
find.run(shader->ir);
if (!find.variable_found()) {
@@ -301,12 +304,15 @@ validate_vertex_shader_executable(struct gl_shader_program *prog,
prog->Vert.ClipDistanceArraySize = 0;
- if (prog->Version >= 130) {
+ if (!prog->IsES && prog->Version >= 130) {
/* From section 7.1 (Vertex Shader Special Variables) of the
* GLSL 1.30 spec:
*
* "It is an error for a shader to statically write both
* gl_ClipVertex and gl_ClipDistance."
+ *
+ * This does not apply to GLSL ES shaders, since GLSL ES defines neither
+ * gl_ClipVertex nor gl_ClipDistance.
*/
find_assignment_visitor clip_vertex("gl_ClipVertex");
find_assignment_visitor clip_distance("gl_ClipDistance");
@@ -2144,7 +2150,7 @@ assign_varying_locations(struct gl_context *ctx,
}
}
- if (ctx->API == API_OPENGLES2 || prog->Version == 100) {
+ if (ctx->API == API_OPENGLES2 || prog->IsES) {
if (varying_vectors > ctx->Const.MaxVarying) {
if (ctx->Const.GLSLSkipStrictMaxVaryingLimitCheck) {
linker_warning(prog, "shader uses too many varying vectors "
@@ -2421,10 +2427,18 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
unsigned min_version = UINT_MAX;
unsigned max_version = 0;
+ const bool is_es_prog =
+ (prog->NumShaders > 0 && prog->Shaders[0]->IsES) ? true : false;
for (unsigned i = 0; i < prog->NumShaders; i++) {
min_version = MIN2(min_version, prog->Shaders[i]->Version);
max_version = MAX2(max_version, prog->Shaders[i]->Version);
+ if (prog->Shaders[i]->IsES != is_es_prog) {
+ linker_error(prog, "all shaders must use same shading "
+ "language version\n");
+ goto done;
+ }
+
switch (prog->Shaders[i]->Type) {
case GL_VERTEX_SHADER:
vert_shader_list[num_vert_shaders] = prog->Shaders[i];
@@ -2444,10 +2458,10 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
/* Previous to GLSL version 1.30, different compilation units could mix and
* match shading language versions. With GLSL 1.30 and later, the versions
* of all shaders must match.
+ *
+ * GLSL ES has never allowed mixing of shading language versions.
*/
- assert(min_version >= 100);
- assert(max_version <= 140);
- if ((max_version >= 130 || min_version == 100)
+ if ((is_es_prog || max_version >= 130)
&& min_version != max_version) {
linker_error(prog, "all shaders must use same shading "
"language version\n");
@@ -2455,6 +2469,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
}
prog->Version = max_version;
+ prog->IsES = is_es_prog;
for (unsigned int i = 0; i < MESA_SHADER_TYPES; i++) {
if (prog->_LinkedShaders[i] != NULL)
@@ -2528,8 +2543,10 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
/* Implement the GLSL 1.30+ rule for discard vs infinite loops Do
* it before optimization because we want most of the checks to get
* dropped thanks to constant propagation.
+ *
+ * This rule also applies to GLSL ES 3.00.
*/
- if (max_version >= 130) {
+ if (max_version >= (is_es_prog ? 300 : 130)) {
struct gl_shader *sh = prog->_LinkedShaders[MESA_SHADER_FRAGMENT];
if (sh) {
lower_discard_flow(sh->ir);
@@ -2673,11 +2690,11 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
goto done;
/* OpenGL ES requires that a vertex shader and a fragment shader both be
- * present in a linked program. By checking for use of shading language
- * version 1.00, we also catch the GL_ARB_ES2_compatibility case.
+ * present in a linked program. By checking prog->IsES, we also
+ * catch the GL_ARB_ES2_compatibility case.
*/
if (!prog->InternalSeparateShader &&
- (ctx->API == API_OPENGLES2 || prog->Version == 100)) {
+ (ctx->API == API_OPENGLES2 || prog->IsES)) {
if (prog->_LinkedShaders[MESA_SHADER_VERTEX] == NULL) {
linker_error(prog, "program lacks a vertex shader\n");
} else if (prog->_LinkedShaders[MESA_SHADER_FRAGMENT] == NULL) {
diff --git a/mesalib/src/glsl/lower_output_reads.cpp b/mesalib/src/glsl/lower_output_reads.cpp
index 90d71b04a..a6192a517 100644
--- a/mesalib/src/glsl/lower_output_reads.cpp
+++ b/mesalib/src/glsl/lower_output_reads.cpp
@@ -97,6 +97,7 @@ output_read_remover::visit(ir_dereference_variable *ir)
temp = new(var_ctx) ir_variable(ir->var->type, ir->var->name,
ir_var_temporary);
hash_table_insert(replacements, temp, ir->var);
+ ir->var->insert_after(temp);
}
/* Update the dereference to use the temporary */
diff --git a/mesalib/src/glsl/main.cpp b/mesalib/src/glsl/main.cpp
index 33cd79c85..a84d010f4 100644
--- a/mesalib/src/glsl/main.cpp
+++ b/mesalib/src/glsl/main.cpp
@@ -48,6 +48,7 @@ initialize_context(struct gl_context *ctx, gl_api api)
* everything in order to compile the built-in functions.
*/
ctx->Const.GLSLVersion = 140;
+ ctx->Extensions.ARB_ES3_compatibility = true;
ctx->Const.MaxClipPlanes = 8;
ctx->Const.MaxDrawBuffers = 2;
@@ -190,6 +191,7 @@ compile_shader(struct gl_context *ctx, struct gl_shader *shader)
shader->symbols = state->symbols;
shader->CompileStatus = !state->error;
shader->Version = state->language_version;
+ shader->IsES = state->es_shader;
memcpy(shader->builtins_to_link, state->builtins_to_link,
sizeof(shader->builtins_to_link[0]) * state->num_builtins_to_link);
shader->num_builtins_to_link = state->num_builtins_to_link;
diff --git a/mesalib/src/glsl/opt_dead_code.cpp b/mesalib/src/glsl/opt_dead_code.cpp
index de8475f95..47247e20d 100644
--- a/mesalib/src/glsl/opt_dead_code.cpp
+++ b/mesalib/src/glsl/opt_dead_code.cpp
@@ -31,6 +31,7 @@
#include "ir_visitor.h"
#include "ir_variable_refcount.h"
#include "glsl_types.h"
+#include "main/hash_table.h"
static bool debug = false;
@@ -49,8 +50,9 @@ do_dead_code(exec_list *instructions, bool uniform_locations_assigned)
v.run(instructions);
- foreach_iter(exec_list_iterator, iter, v.variable_list) {
- ir_variable_refcount_entry *entry = (ir_variable_refcount_entry *)iter.get();
+ struct hash_entry *e;
+ hash_table_foreach(v.ht, e) {
+ ir_variable_refcount_entry *entry = (ir_variable_refcount_entry *)e->data;
/* Since each assignment is a reference, the refereneced count must be
* greater than or equal to the assignment count. If they are equal,
diff --git a/mesalib/src/glsl/standalone_scaffolding.cpp b/mesalib/src/glsl/standalone_scaffolding.cpp
index 120ee9534..33d3804c6 100644
--- a/mesalib/src/glsl/standalone_scaffolding.cpp
+++ b/mesalib/src/glsl/standalone_scaffolding.cpp
@@ -73,6 +73,7 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api)
ctx->Extensions.dummy_false = false;
ctx->Extensions.dummy_true = true;
ctx->Extensions.ARB_ES2_compatibility = true;
+ ctx->Extensions.ARB_ES3_compatibility = false;
ctx->Extensions.ARB_draw_instanced = true;
ctx->Extensions.ARB_fragment_coord_conventions = true;
ctx->Extensions.EXT_texture_array = true;
diff --git a/mesalib/src/mesa/Android.libmesa_glsl_utils.mk b/mesalib/src/mesa/Android.libmesa_glsl_utils.mk
index 480275795..9beeda57f 100644
--- a/mesalib/src/mesa/Android.libmesa_glsl_utils.mk
+++ b/mesalib/src/mesa/Android.libmesa_glsl_utils.mk
@@ -36,7 +36,8 @@ include $(CLEAR_VARS)
LOCAL_MODULE := libmesa_glsl_utils
LOCAL_SRC_FILES := \
- program/hash_table.c \
+ main/hash_table.c \
+ program/prog_hash_table.c \
program/symbol_table.c
include $(MESA_COMMON_MK)
@@ -52,7 +53,8 @@ LOCAL_MODULE := libmesa_glsl_utils
LOCAL_IS_HOST_MODULE := true
LOCAL_SRC_FILES := \
- program/hash_table.c \
+ main/hash_table.c \
+ program/prog_hash_table.c \
program/symbol_table.c
include $(MESA_COMMON_MK)
diff --git a/mesalib/src/mesa/SConscript b/mesalib/src/mesa/SConscript
index be1ed5f60..a2492f771 100644
--- a/mesalib/src/mesa/SConscript
+++ b/mesalib/src/mesa/SConscript
@@ -107,6 +107,7 @@ main_sources = [
'main/renderbuffer.c',
'main/samplerobj.c',
'main/scissor.c',
+ 'main/set.c',
'main/shaderapi.c',
'main/shaderobj.c',
'main/shader_query.cpp',
@@ -293,7 +294,7 @@ env.Append(CPPPATH = [Dir('.').abspath])
program_sources = [
'program/arbprogparse.c',
- 'program/hash_table.c',
+ 'program/prog_hash_table.c',
'program/ir_to_mesa.cpp',
'program/program.c',
'program/program_parse_extra.c',
diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c
index d5e8af3c0..ac036eaac 100644
--- a/mesalib/src/mesa/drivers/common/meta.c
+++ b/mesalib/src/mesa/drivers/common/meta.c
@@ -133,6 +133,7 @@ struct save_state
struct gl_vertex_program *VertexProgram;
GLboolean FragmentProgramEnabled;
struct gl_fragment_program *FragmentProgram;
+ GLboolean ATIFragmentShaderEnabled;
struct gl_shader_program *VertexShader;
struct gl_shader_program *GeometryShader;
struct gl_shader_program *FragmentShader;
@@ -594,6 +595,11 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
_mesa_set_enable(ctx, GL_FRAGMENT_PROGRAM_ARB, GL_FALSE);
}
+ if (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ATI_fragment_shader) {
+ save->ATIFragmentShaderEnabled = ctx->ATIFragmentShader.Enabled;
+ _mesa_set_enable(ctx, GL_FRAGMENT_SHADER_ATI, GL_FALSE);
+ }
+
if (ctx->Extensions.ARB_shader_objects) {
_mesa_reference_shader_program(ctx, &save->VertexShader,
ctx->Shader.CurrentVertexProgram);
@@ -914,6 +920,11 @@ _mesa_meta_end(struct gl_context *ctx)
_mesa_reference_fragprog(ctx, &save->FragmentProgram, NULL);
}
+ if (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ATI_fragment_shader) {
+ _mesa_set_enable(ctx, GL_FRAGMENT_SHADER_ATI,
+ save->ATIFragmentShaderEnabled);
+ }
+
if (ctx->Extensions.ARB_vertex_shader)
_mesa_use_shader_program(ctx, GL_VERTEX_SHADER, save->VertexShader);
@@ -1844,23 +1855,8 @@ meta_glsl_clear_init(struct gl_context *ctx, struct clear_state *clear)
"{\n"
" gl_FragColor = color;\n"
"}\n";
- const char *vs_int_source =
- "#version 130\n"
- "in vec4 position;\n"
- "void main()\n"
- "{\n"
- " gl_Position = position;\n"
- "}\n";
- const char *fs_int_source =
- "#version 130\n"
- "uniform ivec4 color;\n"
- "out ivec4 out_color;\n"
- "\n"
- "void main()\n"
- "{\n"
- " out_color = color;\n"
- "}\n";
GLuint vs, fs;
+ bool has_integer_textures;
if (clear->ArrayObj != 0)
return;
@@ -1896,9 +1892,35 @@ meta_glsl_clear_init(struct gl_context *ctx, struct clear_state *clear)
clear->ColorLocation = _mesa_GetUniformLocation(clear->ShaderProg,
"color");
- if (_mesa_is_desktop_gl(ctx) && ctx->Const.GLSLVersion >= 130) {
+ has_integer_textures = _mesa_is_gles3(ctx) ||
+ (_mesa_is_desktop_gl(ctx) && ctx->Const.GLSLVersion >= 130);
+
+ if (has_integer_textures) {
+ void *shader_source_mem_ctx = ralloc_context(NULL);
+ const char *vs_int_source =
+ ralloc_asprintf(shader_source_mem_ctx,
+ "#version %s\n"
+ "in vec4 position;\n"
+ "void main()\n"
+ "{\n"
+ " gl_Position = position;\n"
+ "}\n",
+ _mesa_is_desktop_gl(ctx) ? "130" : "300 es");
+ const char *fs_int_source =
+ ralloc_asprintf(shader_source_mem_ctx,
+ "#version %s\n"
+ "uniform ivec4 color;\n"
+ "out ivec4 out_color;\n"
+ "\n"
+ "void main()\n"
+ "{\n"
+ " out_color = color;\n"
+ "}\n",
+ _mesa_is_desktop_gl(ctx) ? "130" : "300 es");
+
vs = compile_shader_with_debug(ctx, GL_VERTEX_SHADER, vs_int_source);
fs = compile_shader_with_debug(ctx, GL_FRAGMENT_SHADER, fs_int_source);
+ ralloc_free(shader_source_mem_ctx);
clear->IntegerShaderProg = _mesa_CreateProgramObjectARB();
_mesa_AttachShader(clear->IntegerShaderProg, fs);
@@ -3101,18 +3123,19 @@ setup_glsl_generate_mipmap(struct gl_context *ctx,
sampler->func, sampler->texcoords);
}
else {
- vs_source =
- "#version 130\n"
- "in vec2 position;\n"
- "in vec3 textureCoords;\n"
- "out vec3 texCoords;\n"
- "void main()\n"
- "{\n"
- " texCoords = textureCoords;\n"
- " gl_Position = vec4(position, 0.0, 1.0);\n"
- "}\n";
+ vs_source = ralloc_asprintf(mem_ctx,
+ "#version %s\n"
+ "in vec2 position;\n"
+ "in vec3 textureCoords;\n"
+ "out vec3 texCoords;\n"
+ "void main()\n"
+ "{\n"
+ " texCoords = textureCoords;\n"
+ " gl_Position = vec4(position, 0.0, 1.0);\n"
+ "}\n",
+ _mesa_is_desktop_gl(ctx) ? "130" : "300 es");
fs_source = ralloc_asprintf(mem_ctx,
- "#version 130\n"
+ "#version %s\n"
"uniform %s texSampler;\n"
"in vec3 texCoords;\n"
"out vec4 out_color;\n"
@@ -3121,6 +3144,7 @@ setup_glsl_generate_mipmap(struct gl_context *ctx,
"{\n"
" out_color = texture(texSampler, %s);\n"
"}\n",
+ _mesa_is_desktop_gl(ctx) ? "130" : "300 es",
sampler->type,
sampler->texcoords);
}
diff --git a/mesalib/src/mesa/drivers/dri/common/drisw_util.c b/mesalib/src/mesa/drivers/dri/common/drisw_util.c
index 8fdb05ec3..cd5a39a37 100644
--- a/mesalib/src/mesa/drivers/dri/common/drisw_util.c
+++ b/mesalib/src/mesa/drivers/dri/common/drisw_util.c
@@ -126,7 +126,10 @@ driCreateContextAttribs(__DRIscreen *screen, int api,
mesa_api = API_OPENGLES2;
break;
case __DRI_API_OPENGL_CORE:
+ mesa_api = API_OPENGL_CORE;
+ break;
default:
+ *error = __DRI_CTX_ERROR_BAD_API;
return NULL;
}
@@ -149,6 +152,19 @@ driCreateContextAttribs(__DRIscreen *screen, int api,
}
}
+ /* Mesa does not support the GL_ARB_compatibilty extension or the
+ * compatibility profile. This means that we treat a API_OPENGL_COMPAT 3.1 as
+ * API_OPENGL_CORE and reject API_OPENGL_COMPAT 3.2+.
+ */
+ if (mesa_api == API_OPENGL_COMPAT && major_version == 3 && minor_version == 1)
+ mesa_api = API_OPENGL_CORE;
+
+ if (mesa_api == API_OPENGL_COMPAT
+ && ((major_version > 3)
+ || (major_version == 3 && minor_version >= 2))) {
+ *error = __DRI_CTX_ERROR_BAD_API;
+ return NULL;
+ }
/* There are no forward-compatible contexts before OpenGL 3.0. The
* GLX_ARB_create_context spec says:
*
diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c
index 5521617f1..6733644b6 100644
--- a/mesalib/src/mesa/main/bufferobj.c
+++ b/mesalib/src/mesa/main/bufferobj.c
@@ -2160,17 +2160,19 @@ _mesa_BindBufferRange(GLenum target, GLuint index,
return;
}
- if (size <= 0) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(size=%d)",
- (int) size);
- return;
- }
+ if (buffer != 0) {
+ if (size <= 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(size=%d)",
+ (int) size);
+ return;
+ }
- if (offset + size > bufObj->Size) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glBindBufferRange(offset + size %d > buffer size %d)",
- (int) (offset + size), (int) (bufObj->Size));
- return;
+ if (offset + size > bufObj->Size) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glBindBufferRange(offset + size %d > buffer size %d)",
+ (int) (offset + size), (int) (bufObj->Size));
+ return;
+ }
}
switch (target) {
diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c
index 150d41e04..11cbea2b4 100644
--- a/mesalib/src/mesa/main/extensions.c
+++ b/mesalib/src/mesa/main/extensions.c
@@ -80,6 +80,7 @@ struct extension {
static const struct extension extension_table[] = {
/* ARB Extensions */
{ "GL_ARB_ES2_compatibility", o(ARB_ES2_compatibility), GL, 2009 },
+ { "GL_ARB_ES3_compatibility", o(ARB_ES3_compatibility), GL, 2012 },
{ "GL_ARB_base_instance", o(ARB_base_instance), GL, 2011 },
{ "GL_ARB_blend_func_extended", o(ARB_blend_func_extended), GL, 2009 },
{ "GL_ARB_color_buffer_float", o(ARB_color_buffer_float), GL, 2004 },
diff --git a/mesalib/src/mesa/main/ff_fragment_shader.cpp b/mesalib/src/mesa/main/ff_fragment_shader.cpp
index 3a80ab7f3..02b4707f0 100644
--- a/mesalib/src/mesa/main/ff_fragment_shader.cpp
+++ b/mesalib/src/mesa/main/ff_fragment_shader.cpp
@@ -1309,6 +1309,7 @@ create_new_program(struct gl_context *ctx, struct state_key *key)
p.shader_program->InternalSeparateShader = GL_TRUE;
state->language_version = 130;
+ state->es_shader = false;
if (ctx->Extensions.OES_EGL_image_external)
state->OES_EGL_image_external_enable = true;
_mesa_glsl_initialize_types(state);
diff --git a/mesalib/src/mesa/main/format_unpack.c b/mesalib/src/mesa/main/format_unpack.c
index 04fd1d698..d34a27b82 100644
--- a/mesalib/src/mesa/main/format_unpack.c
+++ b/mesalib/src/mesa/main/format_unpack.c
@@ -57,8 +57,8 @@ struct z32f_x24s8
* linear RGB value in [0, 1].
* Implemented with a 256-entry lookup table.
*/
-static inline GLfloat
-nonlinear_to_linear(GLubyte cs8)
+GLfloat
+_mesa_nonlinear_to_linear(GLubyte cs8)
{
static GLfloat table[256];
static GLboolean tableReady = GL_FALSE;
@@ -742,9 +742,9 @@ unpack_SRGB8(const void *src, GLfloat dst[][4], GLuint n)
const GLubyte *s = (const GLubyte *) src;
GLuint i;
for (i = 0; i < n; i++) {
- dst[i][RCOMP] = nonlinear_to_linear(s[i*3+2]);
- dst[i][GCOMP] = nonlinear_to_linear(s[i*3+1]);
- dst[i][BCOMP] = nonlinear_to_linear(s[i*3+0]);
+ dst[i][RCOMP] = _mesa_nonlinear_to_linear(s[i*3+2]);
+ dst[i][GCOMP] = _mesa_nonlinear_to_linear(s[i*3+1]);
+ dst[i][BCOMP] = _mesa_nonlinear_to_linear(s[i*3+0]);
dst[i][ACOMP] = 1.0F;
}
}
@@ -755,9 +755,9 @@ unpack_SRGBA8(const void *src, GLfloat dst[][4], GLuint n)
const GLuint *s = ((const GLuint *) src);
GLuint i;
for (i = 0; i < n; i++) {
- dst[i][RCOMP] = nonlinear_to_linear( (s[i] >> 24) );
- dst[i][GCOMP] = nonlinear_to_linear( (s[i] >> 16) & 0xff );
- dst[i][BCOMP] = nonlinear_to_linear( (s[i] >> 8) & 0xff );
+ dst[i][RCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 24) );
+ dst[i][GCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 16) & 0xff );
+ dst[i][BCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 8) & 0xff );
dst[i][ACOMP] = UBYTE_TO_FLOAT( s[i] & 0xff ); /* linear! */
}
}
@@ -768,9 +768,9 @@ unpack_SARGB8(const void *src, GLfloat dst[][4], GLuint n)
const GLuint *s = ((const GLuint *) src);
GLuint i;
for (i = 0; i < n; i++) {
- dst[i][RCOMP] = nonlinear_to_linear( (s[i] >> 16) & 0xff );
- dst[i][GCOMP] = nonlinear_to_linear( (s[i] >> 8) & 0xff );
- dst[i][BCOMP] = nonlinear_to_linear( (s[i] ) & 0xff );
+ dst[i][RCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 16) & 0xff );
+ dst[i][GCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 8) & 0xff );
+ dst[i][BCOMP] = _mesa_nonlinear_to_linear( (s[i] ) & 0xff );
dst[i][ACOMP] = UBYTE_TO_FLOAT( s[i] >> 24 ); /* linear! */
}
}
@@ -783,7 +783,7 @@ unpack_SL8(const void *src, GLfloat dst[][4], GLuint n)
for (i = 0; i < n; i++) {
dst[i][RCOMP] =
dst[i][GCOMP] =
- dst[i][BCOMP] = nonlinear_to_linear(s[i]);
+ dst[i][BCOMP] = _mesa_nonlinear_to_linear(s[i]);
dst[i][ACOMP] = 1.0F;
}
}
@@ -796,7 +796,7 @@ unpack_SLA8(const void *src, GLfloat dst[][4], GLuint n)
for (i = 0; i < n; i++) {
dst[i][RCOMP] =
dst[i][GCOMP] =
- dst[i][BCOMP] = nonlinear_to_linear(s[i] & 0xff);
+ dst[i][BCOMP] = _mesa_nonlinear_to_linear(s[i] & 0xff);
dst[i][ACOMP] = UBYTE_TO_FLOAT(s[i] >> 8); /* linear! */
}
}
@@ -1337,6 +1337,68 @@ unpack_ETC1_RGB8(const void *src, GLfloat dst[][4], GLuint n)
}
static void
+unpack_ETC2_RGB8(const void *src, GLfloat dst[][4], GLuint n)
+{
+ /* XXX to do */
+}
+
+static void
+unpack_ETC2_SRGB8(const void *src, GLfloat dst[][4], GLuint n)
+{
+ /* XXX to do */
+}
+
+static void
+unpack_ETC2_RGBA8_EAC(const void *src, GLfloat dst[][4], GLuint n)
+{
+ /* XXX to do */
+}
+
+static void
+unpack_ETC2_SRGB8_ALPHA8_EAC(const void *src, GLfloat dst[][4], GLuint n)
+{
+ /* XXX to do */
+}
+
+static void
+unpack_ETC2_R11_EAC(const void *src, GLfloat dst[][4], GLuint n)
+{
+ /* XXX to do */
+}
+
+static void
+unpack_ETC2_RG11_EAC(const void *src, GLfloat dst[][4], GLuint n)
+{
+ /* XXX to do */
+}
+
+static void
+unpack_ETC2_SIGNED_R11_EAC(const void *src, GLfloat dst[][4], GLuint n)
+{
+ /* XXX to do */
+}
+
+static void
+unpack_ETC2_SIGNED_RG11_EAC(const void *src, GLfloat dst[][4], GLuint n)
+{
+ /* XXX to do */
+}
+
+static void
+unpack_ETC2_RGB8_PUNCHTHROUGH_ALPHA1(const void *src, GLfloat dst[][4],
+ GLuint n)
+{
+ /* XXX to do */
+}
+
+static void
+unpack_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1(const void *src, GLfloat dst[][4],
+ GLuint n)
+{
+ /* XXX to do */
+}
+
+static void
unpack_SIGNED_A8(const void *src, GLfloat dst[][4], GLuint n)
{
const GLbyte *s = ((const GLbyte *) src);
@@ -1585,7 +1647,18 @@ get_unpack_rgba_function(gl_format format)
table[MESA_FORMAT_SIGNED_LA_LATC2] = unpack_SIGNED_LA_LATC2;
table[MESA_FORMAT_ETC1_RGB8] = unpack_ETC1_RGB8;
-
+ table[MESA_FORMAT_ETC2_RGB8] = unpack_ETC2_RGB8;
+ table[MESA_FORMAT_ETC2_SRGB8] = unpack_ETC2_SRGB8;
+ table[MESA_FORMAT_ETC2_RGBA8_EAC] = unpack_ETC2_RGBA8_EAC;
+ table[MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC] = unpack_ETC2_SRGB8_ALPHA8_EAC;
+ table[MESA_FORMAT_ETC2_R11_EAC] = unpack_ETC2_R11_EAC;
+ table[MESA_FORMAT_ETC2_RG11_EAC] = unpack_ETC2_RG11_EAC;
+ table[MESA_FORMAT_ETC2_SIGNED_R11_EAC] = unpack_ETC2_SIGNED_R11_EAC;
+ table[MESA_FORMAT_ETC2_SIGNED_RG11_EAC] = unpack_ETC2_SIGNED_RG11_EAC;
+ table[MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1] =
+ unpack_ETC2_RGB8_PUNCHTHROUGH_ALPHA1;
+ table[MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1] =
+ unpack_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1;
table[MESA_FORMAT_SIGNED_A8] = unpack_SIGNED_A8;
table[MESA_FORMAT_SIGNED_L8] = unpack_SIGNED_L8;
table[MESA_FORMAT_SIGNED_AL88] = unpack_SIGNED_AL88;
diff --git a/mesalib/src/mesa/main/format_unpack.h b/mesalib/src/mesa/main/format_unpack.h
index aad800dd1..29c526319 100644
--- a/mesalib/src/mesa/main/format_unpack.h
+++ b/mesalib/src/mesa/main/format_unpack.h
@@ -24,6 +24,9 @@
#ifndef FORMAT_UNPACK_H
#define FORMAT_UNPACK_H
+extern GLfloat
+_mesa_nonlinear_to_linear(GLubyte cs8);
+
extern void
_mesa_unpack_rgba_row(gl_format format, GLuint n,
const void *src, GLfloat dst[][4]);
diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c
index df23af1dd..47a1d6802 100644
--- a/mesalib/src/mesa/main/formats.c
+++ b/mesalib/src/mesa/main/formats.c
@@ -1398,6 +1398,106 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
4, 4, 8 /* 8 bytes per 4x4 block */
},
+ {
+ MESA_FORMAT_ETC2_RGB8,
+ "MESA_FORMAT_ETC2_RGB8",
+ GL_RGB,
+ GL_UNSIGNED_NORMALIZED,
+ 8, 8, 8, 0,
+ 0, 0, 0, 0, 0,
+ 4, 4, 8 /* 8 bytes per 4x4 block */
+ },
+
+ {
+ MESA_FORMAT_ETC2_SRGB8,
+ "MESA_FORMAT_ETC2_SRGB8",
+ GL_RGB,
+ GL_UNSIGNED_NORMALIZED,
+ 8, 8, 8, 0,
+ 0, 0, 0, 0, 0,
+ 4, 4, 8 /* 8 bytes per 4x4 block */
+ },
+
+ {
+ MESA_FORMAT_ETC2_RGBA8_EAC,
+ "MESA_FORMAT_ETC2_RGBA8_EAC",
+ GL_RGBA,
+ GL_UNSIGNED_NORMALIZED,
+ 8, 8, 8, 8,
+ 0, 0, 0, 0, 0,
+ 4, 4, 16 /* 16 bytes per 4x4 block */
+ },
+
+ {
+ MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC,
+ "MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC",
+ GL_RGBA,
+ GL_UNSIGNED_NORMALIZED,
+ 8, 8, 8, 8,
+ 0, 0, 0, 0, 0,
+ 4, 4, 16 /* 16 bytes per 4x4 block */
+ },
+
+ {
+ MESA_FORMAT_ETC2_R11_EAC,
+ "MESA_FORMAT_ETC2_R11_EAC",
+ GL_RED,
+ GL_UNSIGNED_NORMALIZED,
+ 11, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 4, 4, 8 /* 8 bytes per 4x4 block */
+ },
+
+ {
+ MESA_FORMAT_ETC2_RG11_EAC,
+ "MESA_FORMAT_ETC2_RG11_EAC",
+ GL_RG,
+ GL_UNSIGNED_NORMALIZED,
+ 11, 11, 0, 0,
+ 0, 0, 0, 0, 0,
+ 4, 4, 16 /* 16 bytes per 4x4 block */
+ },
+
+ {
+ MESA_FORMAT_ETC2_SIGNED_R11_EAC,
+ "MESA_FORMAT_ETC2_SIGNED_R11_EAC",
+ GL_RED,
+ GL_SIGNED_NORMALIZED,
+ 11, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 4, 4, 8 /* 8 bytes per 4x4 block */
+ },
+
+ {
+ MESA_FORMAT_ETC2_SIGNED_RG11_EAC,
+ "MESA_FORMAT_ETC2_SIGNED_RG11_EAC",
+ GL_RG,
+ GL_SIGNED_NORMALIZED,
+ 11, 11, 0, 0,
+ 0, 0, 0, 0, 0,
+ 4, 4, 16 /* 16 bytes per 4x4 block */
+ },
+
+ {
+ MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1,
+ "MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1",
+ GL_RGBA,
+ GL_UNSIGNED_NORMALIZED,
+ 8, 8, 8, 1,
+ 0, 0, 0, 0, 0,
+ 4, 4, 8 /* 8 bytes per 4x4 block */
+ },
+
+ {
+ MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1,
+ "MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1",
+ GL_RGBA,
+ GL_UNSIGNED_NORMALIZED,
+ 8, 8, 8, 1,
+ 0, 0, 0, 0, 0,
+ 4, 4, 8 /* 8 bytes per 4x4 block */
+ },
+
/* Signed formats from EXT_texture_snorm that are not in GL3.1 */
{
MESA_FORMAT_SIGNED_A8,
@@ -1840,7 +1940,20 @@ _mesa_get_uncompressed_format(gl_format format)
case MESA_FORMAT_SIGNED_LA_LATC2:
return MESA_FORMAT_SIGNED_AL88;
case MESA_FORMAT_ETC1_RGB8:
+ case MESA_FORMAT_ETC2_RGB8:
+ case MESA_FORMAT_ETC2_SRGB8:
return MESA_FORMAT_RGB888;
+ case MESA_FORMAT_ETC2_RGBA8_EAC:
+ case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC:
+ case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1:
+ case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:
+ return MESA_FORMAT_RGBA8888;
+ case MESA_FORMAT_ETC2_R11_EAC:
+ case MESA_FORMAT_ETC2_SIGNED_R11_EAC:
+ return MESA_FORMAT_R16;
+ case MESA_FORMAT_ETC2_RG11_EAC:
+ case MESA_FORMAT_ETC2_SIGNED_RG11_EAC:
+ return MESA_FORMAT_RG1616;
default:
#ifdef DEBUG
assert(!_mesa_is_format_compressed(format));
@@ -2282,6 +2395,16 @@ _mesa_format_to_type_and_comps(gl_format format,
case MESA_FORMAT_LA_LATC2:
case MESA_FORMAT_SIGNED_LA_LATC2:
case MESA_FORMAT_ETC1_RGB8:
+ case MESA_FORMAT_ETC2_RGB8:
+ case MESA_FORMAT_ETC2_SRGB8:
+ case MESA_FORMAT_ETC2_RGBA8_EAC:
+ case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC:
+ case MESA_FORMAT_ETC2_R11_EAC:
+ case MESA_FORMAT_ETC2_RG11_EAC:
+ case MESA_FORMAT_ETC2_SIGNED_R11_EAC:
+ case MESA_FORMAT_ETC2_SIGNED_RG11_EAC:
+ case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1:
+ case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:
/* XXX generate error instead? */
*datatype = GL_UNSIGNED_BYTE;
*comps = 0;
@@ -2912,6 +3035,16 @@ _mesa_format_matches_format_and_type(gl_format gl_format,
return GL_FALSE;
case MESA_FORMAT_ETC1_RGB8:
+ case MESA_FORMAT_ETC2_RGB8:
+ case MESA_FORMAT_ETC2_SRGB8:
+ case MESA_FORMAT_ETC2_RGBA8_EAC:
+ case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC:
+ case MESA_FORMAT_ETC2_R11_EAC:
+ case MESA_FORMAT_ETC2_RG11_EAC:
+ case MESA_FORMAT_ETC2_SIGNED_R11_EAC:
+ case MESA_FORMAT_ETC2_SIGNED_RG11_EAC:
+ case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1:
+ case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:
return GL_FALSE;
case MESA_FORMAT_SIGNED_A8:
diff --git a/mesalib/src/mesa/main/formats.h b/mesalib/src/mesa/main/formats.h
index 1843eb6fc..050fce96c 100644
--- a/mesalib/src/mesa/main/formats.h
+++ b/mesalib/src/mesa/main/formats.h
@@ -259,6 +259,16 @@ typedef enum
/*@}*/
MESA_FORMAT_ETC1_RGB8,
+ MESA_FORMAT_ETC2_RGB8,
+ MESA_FORMAT_ETC2_SRGB8,
+ MESA_FORMAT_ETC2_RGBA8_EAC,
+ MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC,
+ MESA_FORMAT_ETC2_R11_EAC,
+ MESA_FORMAT_ETC2_RG11_EAC,
+ MESA_FORMAT_ETC2_SIGNED_R11_EAC,
+ MESA_FORMAT_ETC2_SIGNED_RG11_EAC,
+ MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1,
+ MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1,
MESA_FORMAT_SIGNED_A8, /* AAAA AAAA */
MESA_FORMAT_SIGNED_L8, /* LLLL LLLL */
diff --git a/mesalib/src/mesa/main/glformats.c b/mesalib/src/mesa/main/glformats.c
index 69caef70b..fefa9c441 100644
--- a/mesalib/src/mesa/main/glformats.c
+++ b/mesalib/src/mesa/main/glformats.c
@@ -570,6 +570,16 @@ _mesa_is_color_format(GLenum format)
case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:
case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
case GL_ETC1_RGB8_OES:
+ case GL_COMPRESSED_RGB8_ETC2:
+ case GL_COMPRESSED_SRGB8_ETC2:
+ case GL_COMPRESSED_RGBA8_ETC2_EAC:
+ case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
+ case GL_COMPRESSED_R11_EAC:
+ case GL_COMPRESSED_RG11_EAC:
+ case GL_COMPRESSED_SIGNED_R11_EAC:
+ case GL_COMPRESSED_SIGNED_RG11_EAC:
+ case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+ case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
/* generic integer formats */
case GL_RED_INTEGER_EXT:
case GL_GREEN_INTEGER_EXT:
@@ -829,6 +839,17 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format)
case GL_ETC1_RGB8_OES:
return _mesa_is_gles(ctx)
&& ctx->Extensions.OES_compressed_ETC1_RGB8_texture;
+ case GL_COMPRESSED_RGB8_ETC2:
+ case GL_COMPRESSED_SRGB8_ETC2:
+ case GL_COMPRESSED_RGBA8_ETC2_EAC:
+ case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
+ case GL_COMPRESSED_R11_EAC:
+ case GL_COMPRESSED_RG11_EAC:
+ case GL_COMPRESSED_SIGNED_R11_EAC:
+ case GL_COMPRESSED_SIGNED_RG11_EAC:
+ case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+ case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+ return _mesa_is_gles3(ctx);
case GL_PALETTE4_RGB8_OES:
case GL_PALETTE4_RGBA8_OES:
case GL_PALETTE4_R5_G6_B5_OES:
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index 5bfae69c8..b353e7026 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -79,6 +79,8 @@ struct st_context;
struct gl_uniform_storage;
struct prog_instruction;
struct gl_program_parameter_list;
+struct set;
+struct set_entry;
/*@}*/
@@ -2184,6 +2186,7 @@ struct gl_shader
struct gl_sl_pragmas Pragmas;
unsigned Version; /**< GLSL version used for linking */
+ GLboolean IsES; /**< True if this shader uses GLSL ES */
/**
* \name Sampler tracking
@@ -2386,6 +2389,7 @@ struct gl_shader_program
GLchar *InfoLog;
unsigned Version; /**< GLSL version used for linking */
+ GLboolean IsES; /**< True if this program uses GLSL ES */
/**
* Per-stage shaders resulting from the first stage of linking.
@@ -2509,7 +2513,7 @@ struct gl_query_state
/** Sync object state */
struct gl_sync_object
{
- struct simple_node link;
+ struct set_entry *SetEntry;
GLenum Type; /**< GL_SYNC_FENCE */
GLuint Name; /**< Fence name */
GLint RefCount; /**< Reference count */
@@ -2576,7 +2580,7 @@ struct gl_shared_state
struct _mesa_HashTable *FrameBuffers;
/* GL_ARB_sync */
- struct simple_node SyncObjects;
+ struct set *SyncObjects;
/** GL_ARB_sampler_objects */
struct _mesa_HashTable *SamplerObjects;
@@ -2939,6 +2943,7 @@ struct gl_extensions
GLboolean dummy_false; /* Set false by _mesa_init_extensions(). */
GLboolean ANGLE_texture_compression_dxt;
GLboolean ARB_ES2_compatibility;
+ GLboolean ARB_ES3_compatibility;
GLboolean ARB_base_instance;
GLboolean ARB_blend_func_extended;
GLboolean ARB_color_buffer_float;
diff --git a/mesalib/src/mesa/main/set.c b/mesalib/src/mesa/main/set.c
new file mode 100644
index 000000000..736841fc9
--- /dev/null
+++ b/mesalib/src/mesa/main/set.c
@@ -0,0 +1,348 @@
+/*
+ * Copyright © 2009-2012 Intel Corporation
+ * Copyright © 1988-2004 Keith Packard and Bart Massey.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the authors
+ * or their institutions shall not be used in advertising or
+ * otherwise to promote the sale, use or other dealings in this
+ * Software without prior written authorization from the
+ * authors.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ * Keith Packard <keithp@keithp.com>
+ */
+
+#include <stdlib.h>
+
+#include "set.h"
+#include "ralloc.h"
+
+#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
+
+/*
+ * From Knuth -- a good choice for hash/rehash values is p, p-2 where
+ * p and p-2 are both prime. These tables are sized to have an extra 10%
+ * free to avoid exponential performance degradation as the hash table fills
+ */
+
+uint32_t deleted_key_value;
+const void *deleted_key = &deleted_key_value;
+
+static const struct {
+ uint32_t max_entries, size, rehash;
+} hash_sizes[] = {
+ { 2, 5, 3 },
+ { 4, 7, 5 },
+ { 8, 13, 11 },
+ { 16, 19, 17 },
+ { 32, 43, 41 },
+ { 64, 73, 71 },
+ { 128, 151, 149 },
+ { 256, 283, 281 },
+ { 512, 571, 569 },
+ { 1024, 1153, 1151 },
+ { 2048, 2269, 2267 },
+ { 4096, 4519, 4517 },
+ { 8192, 9013, 9011 },
+ { 16384, 18043, 18041 },
+ { 32768, 36109, 36107 },
+ { 65536, 72091, 72089 },
+ { 131072, 144409, 144407 },
+ { 262144, 288361, 288359 },
+ { 524288, 576883, 576881 },
+ { 1048576, 1153459, 1153457 },
+ { 2097152, 2307163, 2307161 },
+ { 4194304, 4613893, 4613891 },
+ { 8388608, 9227641, 9227639 },
+ { 16777216, 18455029, 18455027 },
+ { 33554432, 36911011, 36911009 },
+ { 67108864, 73819861, 73819859 },
+ { 134217728, 147639589, 147639587 },
+ { 268435456, 295279081, 295279079 },
+ { 536870912, 590559793, 590559791 },
+ { 1073741824, 1181116273, 1181116271 },
+ { 2147483648ul, 2362232233ul, 2362232231ul }
+};
+
+static int
+entry_is_free(struct set_entry *entry)
+{
+ return entry->key == NULL;
+}
+
+static int
+entry_is_deleted(struct set_entry *entry)
+{
+ return entry->key == deleted_key;
+}
+
+static int
+entry_is_present(struct set_entry *entry)
+{
+ return entry->key != NULL && entry->key != deleted_key;
+}
+
+struct set *
+_mesa_set_create(void *mem_ctx,
+ bool key_equals_function(const void *a,
+ const void *b))
+{
+ struct set *ht;
+
+ ht = ralloc(mem_ctx, struct set);
+ if (ht == NULL)
+ return NULL;
+
+ ht->mem_ctx = mem_ctx;
+ ht->size_index = 0;
+ ht->size = hash_sizes[ht->size_index].size;
+ ht->rehash = hash_sizes[ht->size_index].rehash;
+ ht->max_entries = hash_sizes[ht->size_index].max_entries;
+ ht->key_equals_function = key_equals_function;
+ ht->table = rzalloc_array(ht, struct set_entry, ht->size);
+ ht->entries = 0;
+ ht->deleted_entries = 0;
+
+ if (ht->table == NULL) {
+ ralloc_free(ht);
+ return NULL;
+ }
+
+ return ht;
+}
+
+/**
+ * Frees the given set.
+ *
+ * If delete_function is passed, it gets called on each entry present before
+ * freeing.
+ */
+void
+_mesa_set_destroy(struct set *ht, void (*delete_function)(struct set_entry *entry))
+{
+ if (!ht)
+ return;
+
+ if (delete_function) {
+ struct set_entry *entry;
+
+ set_foreach (ht, entry) {
+ delete_function(entry);
+ }
+ }
+ ralloc_free(ht->table);
+ ralloc_free(ht);
+}
+
+/**
+ * Finds a set entry with the given key and hash of that key.
+ *
+ * Returns NULL if no entry is found.
+ */
+struct set_entry *
+_mesa_set_search(const struct set *ht, uint32_t hash, const void *key)
+{
+ uint32_t hash_address;
+
+ hash_address = hash % ht->size;
+ do {
+ uint32_t double_hash;
+
+ struct set_entry *entry = ht->table + hash_address;
+
+ if (entry_is_free(entry)) {
+ return NULL;
+ } else if (entry_is_present(entry) && entry->hash == hash) {
+ if (ht->key_equals_function(key, entry->key)) {
+ return entry;
+ }
+ }
+
+ double_hash = 1 + hash % ht->rehash;
+
+ hash_address = (hash_address + double_hash) % ht->size;
+ } while (hash_address != hash % ht->size);
+
+ return NULL;
+}
+
+static void
+set_rehash(struct set *ht, int new_size_index)
+{
+ struct set old_ht;
+ struct set_entry *table, *entry;
+
+ if (new_size_index >= ARRAY_SIZE(hash_sizes))
+ return;
+
+ table = rzalloc_array(ht, struct set_entry,
+ hash_sizes[new_size_index].size);
+ if (table == NULL)
+ return;
+
+ old_ht = *ht;
+
+ ht->table = table;
+ ht->size_index = new_size_index;
+ ht->size = hash_sizes[ht->size_index].size;
+ ht->rehash = hash_sizes[ht->size_index].rehash;
+ ht->max_entries = hash_sizes[ht->size_index].max_entries;
+ ht->entries = 0;
+ ht->deleted_entries = 0;
+
+ for (entry = old_ht.table;
+ entry != old_ht.table + old_ht.size;
+ entry++) {
+ if (entry_is_present(entry)) {
+ _mesa_set_add(ht, entry->hash, entry->key);
+ }
+ }
+
+ ralloc_free(old_ht.table);
+}
+
+/**
+ * Inserts the key with the given hash into the table.
+ *
+ * Note that insertion may rearrange the table on a resize or rehash,
+ * so previously found hash_entries are no longer valid after this function.
+ */
+struct set_entry *
+_mesa_set_add(struct set *ht, uint32_t hash, const void *key)
+{
+ uint32_t hash_address;
+
+ if (ht->entries >= ht->max_entries) {
+ set_rehash(ht, ht->size_index + 1);
+ } else if (ht->deleted_entries + ht->entries >= ht->max_entries) {
+ set_rehash(ht, ht->size_index);
+ }
+
+ hash_address = hash % ht->size;
+ do {
+ struct set_entry *entry = ht->table + hash_address;
+ uint32_t double_hash;
+
+ if (!entry_is_present(entry)) {
+ if (entry_is_deleted(entry))
+ ht->deleted_entries--;
+ entry->hash = hash;
+ entry->key = key;
+ ht->entries++;
+ return entry;
+ }
+
+ /* Implement replacement when another insert happens
+ * with a matching key. This is a relatively common
+ * feature of hash tables, with the alternative
+ * generally being "insert the new value as well, and
+ * return it first when the key is searched for".
+ *
+ * Note that the hash table doesn't have a delete callback.
+ * If freeing of old keys is required to avoid memory leaks,
+ * perform a search before inserting.
+ */
+ if (entry->hash == hash &&
+ ht->key_equals_function(key, entry->key)) {
+ entry->key = key;
+ return entry;
+ }
+
+ double_hash = 1 + hash % ht->rehash;
+
+ hash_address = (hash_address + double_hash) % ht->size;
+ } while (hash_address != hash % ht->size);
+
+ /* We could hit here if a required resize failed. An unchecked-malloc
+ * application could ignore this result.
+ */
+ return NULL;
+}
+
+/**
+ * This function deletes the given hash table entry.
+ *
+ * Note that deletion doesn't otherwise modify the table, so an iteration over
+ * the table deleting entries is safe.
+ */
+void
+_mesa_set_remove(struct set *ht, struct set_entry *entry)
+{
+ if (!entry)
+ return;
+
+ entry->key = deleted_key;
+ ht->entries--;
+ ht->deleted_entries++;
+}
+
+/**
+ * This function is an iterator over the hash table.
+ *
+ * Pass in NULL for the first entry, as in the start of a for loop. Note that
+ * an iteration over the table is O(table_size) not O(entries).
+ */
+struct set_entry *
+_mesa_set_next_entry(const struct set *ht, struct set_entry *entry)
+{
+ if (entry == NULL)
+ entry = ht->table;
+ else
+ entry = entry + 1;
+
+ for (; entry != ht->table + ht->size; entry++) {
+ if (entry_is_present(entry)) {
+ return entry;
+ }
+ }
+
+ return NULL;
+}
+
+struct set_entry *
+_mesa_set_random_entry(struct set *ht,
+ int (*predicate)(struct set_entry *entry))
+{
+ struct set_entry *entry;
+ uint32_t i = rand() % ht->size;
+
+ if (ht->entries == 0)
+ return NULL;
+
+ for (entry = ht->table + i; entry != ht->table + ht->size; entry++) {
+ if (entry_is_present(entry) &&
+ (!predicate || predicate(entry))) {
+ return entry;
+ }
+ }
+
+ for (entry = ht->table; entry != ht->table + i; entry++) {
+ if (entry_is_present(entry) &&
+ (!predicate || predicate(entry))) {
+ return entry;
+ }
+ }
+
+ return NULL;
+}
+
diff --git a/mesalib/src/mesa/main/set.h b/mesalib/src/mesa/main/set.h
new file mode 100644
index 000000000..206d0c4d2
--- /dev/null
+++ b/mesalib/src/mesa/main/set.h
@@ -0,0 +1,94 @@
+/*
+ * Copyright © 2009-2012 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+
+#ifndef _SET_H
+#define _SET_H
+
+#include <inttypes.h>
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct set_entry {
+ uint32_t hash;
+ const void *key;
+};
+
+struct set {
+ void *mem_ctx;
+ struct set_entry *table;
+ bool (*key_equals_function)(const void *a, const void *b);
+ uint32_t size;
+ uint32_t rehash;
+ uint32_t max_entries;
+ uint32_t size_index;
+ uint32_t entries;
+ uint32_t deleted_entries;
+};
+
+struct set *
+_mesa_set_create(void *mem_ctx,
+ bool (*key_equals_function)(const void *a,
+ const void *b));
+void
+_mesa_set_destroy(struct set *set,
+ void (*delete_function)(struct set_entry *entry));
+
+struct set_entry *
+_mesa_set_add(struct set *set, uint32_t hash, const void *key);
+
+struct set_entry *
+_mesa_set_search(const struct set *set, uint32_t hash,
+ const void *key);
+
+void
+_mesa_set_remove(struct set *set, struct set_entry *entry);
+
+struct set_entry *
+_mesa_set_next_entry(const struct set *set, struct set_entry *entry);
+
+struct set_entry *
+_mesa_set_random_entry(struct set *set,
+ int (*predicate)(struct set_entry *entry));
+
+/**
+ * This foreach function is safe against deletion, but not against
+ * insertion (which may rehash the set, making entry a dangling
+ * pointer).
+ */
+#define set_foreach(set, entry) \
+ for (entry = _mesa_set_next_entry(set, NULL); \
+ entry != NULL; \
+ entry = _mesa_set_next_entry(set, entry))
+
+#ifdef __cplusplus
+} /* extern C */
+#endif
+
+#endif /* _SET_H */
diff --git a/mesalib/src/mesa/main/shared.c b/mesalib/src/mesa/main/shared.c
index eaf9f8de1..a98a45c75 100644
--- a/mesalib/src/mesa/main/shared.c
+++ b/mesalib/src/mesa/main/shared.c
@@ -31,12 +31,14 @@
#include "mfeatures.h"
#include "mtypes.h"
#include "hash.h"
+#include "hash_table.h"
#include "atifragshader.h"
#include "bufferobj.h"
#include "shared.h"
#include "program/program.h"
#include "dlist.h"
#include "samplerobj.h"
+#include "set.h"
#include "shaderobj.h"
#include "syncobj.h"
@@ -115,7 +117,7 @@ _mesa_alloc_shared_state(struct gl_context *ctx)
shared->FrameBuffers = _mesa_NewHashTable();
shared->RenderBuffers = _mesa_NewHashTable();
- make_empty_list(& shared->SyncObjects);
+ shared->SyncObjects = _mesa_set_create(NULL, _mesa_key_pointer_equal);
return shared;
}
@@ -327,13 +329,13 @@ free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared)
_mesa_reference_buffer_object(ctx, &shared->NullBufferObj, NULL);
{
- struct simple_node *node;
- struct simple_node *temp;
+ struct set_entry *entry;
- foreach_s(node, temp, & shared->SyncObjects) {
- _mesa_unref_sync_object(ctx, (struct gl_sync_object *) node);
+ set_foreach(shared->SyncObjects, entry) {
+ _mesa_unref_sync_object(ctx, (struct gl_sync_object *) entry->key);
}
}
+ _mesa_set_destroy(shared->SyncObjects, NULL);
_mesa_HashDeleteAll(shared->SamplerObjects, delete_sampler_object_cb, ctx);
_mesa_DeleteHashTable(shared->SamplerObjects);
diff --git a/mesalib/src/mesa/main/syncobj.c b/mesalib/src/mesa/main/syncobj.c
index cc541c834..f599982bd 100644
--- a/mesalib/src/mesa/main/syncobj.c
+++ b/mesalib/src/mesa/main/syncobj.c
@@ -64,6 +64,8 @@
#include "get.h"
#include "dispatch.h"
#include "mtypes.h"
+#include "set.h"
+#include "hash_table.h"
#include "syncobj.h"
@@ -174,9 +176,12 @@ _mesa_free_sync_data(struct gl_context *ctx)
static int
-_mesa_validate_sync(struct gl_sync_object *syncObj)
+_mesa_validate_sync(struct gl_context *ctx, struct gl_sync_object *syncObj)
{
return (syncObj != NULL)
+ && _mesa_set_search(ctx->Shared->SyncObjects,
+ _mesa_hash_pointer(syncObj),
+ syncObj) != NULL
&& (syncObj->Type == GL_SYNC_FENCE)
&& !syncObj->DeletePending;
}
@@ -197,7 +202,7 @@ _mesa_unref_sync_object(struct gl_context *ctx, struct gl_sync_object *syncObj)
_glthread_LOCK_MUTEX(ctx->Shared->Mutex);
syncObj->RefCount--;
if (syncObj->RefCount == 0) {
- remove_from_list(& syncObj->link);
+ _mesa_set_remove(ctx->Shared->SyncObjects, syncObj->SetEntry);
_glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
ctx->Driver.DeleteSyncObject(ctx, syncObj);
@@ -214,7 +219,7 @@ _mesa_IsSync(GLsync sync)
struct gl_sync_object *const syncObj = (struct gl_sync_object *) sync;
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
- return _mesa_validate_sync(syncObj) ? GL_TRUE : GL_FALSE;
+ return _mesa_validate_sync(ctx, syncObj) ? GL_TRUE : GL_FALSE;
}
@@ -235,8 +240,8 @@ _mesa_DeleteSync(GLsync sync)
return;
}
- if (!_mesa_validate_sync(syncObj)) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glDeleteSync");
+ if (!_mesa_validate_sync(ctx, syncObj)) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteSync (not a valid sync object)");
return;
}
@@ -285,7 +290,9 @@ _mesa_FenceSync(GLenum condition, GLbitfield flags)
ctx->Driver.FenceSync(ctx, syncObj, condition, flags);
_glthread_LOCK_MUTEX(ctx->Shared->Mutex);
- insert_at_tail(& ctx->Shared->SyncObjects, & syncObj->link);
+ syncObj->SetEntry = _mesa_set_add(ctx->Shared->SyncObjects,
+ _mesa_hash_pointer(syncObj),
+ syncObj);
_glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
return (GLsync) syncObj;
@@ -303,8 +310,8 @@ _mesa_ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
GLenum ret;
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_WAIT_FAILED);
- if (!_mesa_validate_sync(syncObj)) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glClientWaitSync");
+ if (!_mesa_validate_sync(ctx, syncObj)) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glClientWaitSync (not a valid sync object)");
return GL_WAIT_FAILED;
}
@@ -347,8 +354,8 @@ _mesa_WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
struct gl_sync_object *const syncObj = (struct gl_sync_object *) sync;
ASSERT_OUTSIDE_BEGIN_END(ctx);
- if (!_mesa_validate_sync(syncObj)) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glWaitSync");
+ if (!_mesa_validate_sync(ctx, syncObj)) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glWaitSync (not a valid sync object)");
return;
}
@@ -377,8 +384,8 @@ _mesa_GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length,
GLint v[1];
ASSERT_OUTSIDE_BEGIN_END(ctx);
- if (!_mesa_validate_sync(syncObj)) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glGetSynciv");
+ if (!_mesa_validate_sync(ctx, syncObj)) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetSynciv (not a valid sync object)");
return;
}
diff --git a/mesalib/src/mesa/main/texcompress.c b/mesalib/src/mesa/main/texcompress.c
index 957cc6df6..372a483fa 100644
--- a/mesalib/src/mesa/main/texcompress.c
+++ b/mesalib/src/mesa/main/texcompress.c
@@ -33,6 +33,7 @@
#include "glheader.h"
#include "imports.h"
#include "colormac.h"
+#include "context.h"
#include "formats.h"
#include "mfeatures.h"
#include "mtypes.h"
@@ -77,12 +78,16 @@ _mesa_gl_compressed_format_base_format(GLenum format)
{
switch (format) {
case GL_COMPRESSED_RED:
+ case GL_COMPRESSED_R11_EAC:
case GL_COMPRESSED_RED_RGTC1:
+ case GL_COMPRESSED_SIGNED_R11_EAC:
case GL_COMPRESSED_SIGNED_RED_RGTC1:
return GL_RED;
case GL_COMPRESSED_RG:
+ case GL_COMPRESSED_RG11_EAC:
case GL_COMPRESSED_RG_RGTC2:
+ case GL_COMPRESSED_SIGNED_RG11_EAC:
case GL_COMPRESSED_SIGNED_RG_RGTC2:
return GL_RG;
@@ -92,6 +97,8 @@ _mesa_gl_compressed_format_base_format(GLenum format)
case GL_COMPRESSED_RGB_FXT1_3DFX:
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
case GL_ETC1_RGB8_OES:
+ case GL_COMPRESSED_RGB8_ETC2:
+ case GL_COMPRESSED_SRGB8_ETC2:
return GL_RGB;
case GL_COMPRESSED_RGBA:
@@ -107,6 +114,10 @@ _mesa_gl_compressed_format_base_format(GLenum format)
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
+ case GL_COMPRESSED_RGBA8_ETC2_EAC:
+ case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
+ case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+ case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
return GL_RGBA;
case GL_COMPRESSED_ALPHA:
@@ -293,6 +304,23 @@ _mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats)
}
}
+ if (_mesa_is_gles3(ctx)) {
+ if (formats) {
+ formats[n++] = GL_COMPRESSED_RGB8_ETC2;
+ formats[n++] = GL_COMPRESSED_SRGB8_ETC2;
+ formats[n++] = GL_COMPRESSED_RGBA8_ETC2_EAC;
+ formats[n++] = GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;
+ formats[n++] = GL_COMPRESSED_R11_EAC;
+ formats[n++] = GL_COMPRESSED_RG11_EAC;
+ formats[n++] = GL_COMPRESSED_SIGNED_R11_EAC;
+ formats[n++] = GL_COMPRESSED_SIGNED_RG11_EAC;
+ formats[n++] = GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;
+ formats[n++] = GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;
+ }
+ else {
+ n += 10;
+ }
+ }
return n;
}
@@ -352,6 +380,26 @@ _mesa_glenum_to_compressed_format(GLenum format)
case GL_ETC1_RGB8_OES:
return MESA_FORMAT_ETC1_RGB8;
+ case GL_COMPRESSED_RGB8_ETC2:
+ return MESA_FORMAT_ETC2_RGB8;
+ case GL_COMPRESSED_SRGB8_ETC2:
+ return MESA_FORMAT_ETC2_SRGB8;
+ case GL_COMPRESSED_RGBA8_ETC2_EAC:
+ return MESA_FORMAT_ETC2_RGBA8_EAC;
+ case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
+ return MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC;
+ case GL_COMPRESSED_R11_EAC:
+ return MESA_FORMAT_ETC2_R11_EAC;
+ case GL_COMPRESSED_RG11_EAC:
+ return MESA_FORMAT_ETC2_RG11_EAC;
+ case GL_COMPRESSED_SIGNED_R11_EAC:
+ return MESA_FORMAT_ETC2_SIGNED_R11_EAC;
+ case GL_COMPRESSED_SIGNED_RG11_EAC:
+ return MESA_FORMAT_ETC2_SIGNED_RG11_EAC;
+ case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+ return MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1;
+ case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+ return MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1;
default:
return MESA_FORMAT_NONE;
@@ -413,6 +461,26 @@ _mesa_compressed_format_to_glenum(struct gl_context *ctx, gl_format mesaFormat)
case MESA_FORMAT_ETC1_RGB8:
return GL_ETC1_RGB8_OES;
+ case MESA_FORMAT_ETC2_RGB8:
+ return GL_COMPRESSED_RGB8_ETC2;
+ case MESA_FORMAT_ETC2_SRGB8:
+ return GL_COMPRESSED_SRGB8_ETC2;
+ case MESA_FORMAT_ETC2_RGBA8_EAC:
+ return GL_COMPRESSED_RGBA8_ETC2_EAC;
+ case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC:
+ return GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;
+ case MESA_FORMAT_ETC2_R11_EAC:
+ return GL_COMPRESSED_R11_EAC;
+ case MESA_FORMAT_ETC2_RG11_EAC:
+ return GL_COMPRESSED_RG11_EAC;
+ case MESA_FORMAT_ETC2_SIGNED_R11_EAC:
+ return GL_COMPRESSED_SIGNED_R11_EAC;
+ case MESA_FORMAT_ETC2_SIGNED_RG11_EAC:
+ return GL_COMPRESSED_SIGNED_RG11_EAC;
+ case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1:
+ return GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;
+ case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:
+ return GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;
default:
_mesa_problem(ctx, "Unexpected mesa texture format in"
@@ -538,6 +606,38 @@ _mesa_decompress_image(gl_format format, GLuint width, GLuint height,
fetch = _mesa_fetch_texel_2d_f_etc1_rgb8;
break;
+ /* ETC2 formats */
+ case MESA_FORMAT_ETC2_RGB8:
+ fetch = _mesa_fetch_texel_2d_f_etc2_rgb8;
+ break;
+ case MESA_FORMAT_ETC2_SRGB8:
+ fetch = _mesa_fetch_texel_2d_f_etc2_srgb8;
+ break;
+ case MESA_FORMAT_ETC2_RGBA8_EAC:
+ fetch = _mesa_fetch_texel_2d_f_etc2_rgba8_eac;
+ break;
+ case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC:
+ fetch = _mesa_fetch_texel_2d_f_etc2_srgb8_alpha8_eac;
+ break;
+ case MESA_FORMAT_ETC2_R11_EAC:
+ fetch = _mesa_fetch_texel_2d_f_etc2_r11_eac;
+ break;
+ case MESA_FORMAT_ETC2_RG11_EAC:
+ fetch = _mesa_fetch_texel_2d_f_etc2_rg11_eac;
+ break;
+ case MESA_FORMAT_ETC2_SIGNED_R11_EAC:
+ fetch = _mesa_fetch_texel_2d_f_etc2_signed_r11_eac;
+ break;
+ case MESA_FORMAT_ETC2_SIGNED_RG11_EAC:
+ fetch = _mesa_fetch_texel_2d_f_etc2_signed_rg11_eac;
+ break;
+ case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1:
+ fetch = _mesa_fetch_texel_2d_f_etc2_rgb8_punchthrough_alpha1;
+ break;
+ case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:
+ fetch = _mesa_fetch_texel_2d_f_etc2_srgb8_punchthrough_alpha1;
+ break;
+
default:
_mesa_problem(NULL, "Unexpected format in _mesa_decompress_image()");
return;
diff --git a/mesalib/src/mesa/main/texcompress_etc.c b/mesalib/src/mesa/main/texcompress_etc.c
index c645f52b9..73d2fa4fe 100644
--- a/mesalib/src/mesa/main/texcompress_etc.c
+++ b/mesalib/src/mesa/main/texcompress_etc.c
@@ -24,24 +24,78 @@
/**
* \file texcompress_etc.c
* GL_OES_compressed_ETC1_RGB8_texture support.
+ * Supported ETC2 texture formats are:
+ * GL_COMPRESSED_RGB8_ETC2
+ * GL_COMPRESSED_SRGB8_ETC2
+ * GL_COMPRESSED_RGBA8_ETC2_EAC
+ * GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC
+ * GL_COMPRESSED_R11_EAC
+ * GL_COMPRESSED_RG11_EAC
+ * GL_COMPRESSED_SIGNED_R11_EAC
+ * GL_COMPRESSED_SIGNED_RG11_EAC
+ * MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
+ * MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
*/
-
+#include <stdbool.h>
#include "mfeatures.h"
#include "texcompress.h"
#include "texcompress_etc.h"
#include "texstore.h"
#include "macros.h"
#include "swrast/s_context.h"
+#include "format_unpack.h"
-GLboolean
-_mesa_texstore_etc1_rgb8(TEXSTORE_PARAMS)
-{
- /* GL_ETC1_RGB8_OES is only valid in glCompressedTexImage2D */
- ASSERT(0);
+struct etc2_block {
+ int distance;
+ uint64_t pixel_indices[2];
+ const int *modifier_tables[2];
+ bool flipped;
+ bool opaque;
+ bool is_ind_mode;
+ bool is_diff_mode;
+ bool is_t_mode;
+ bool is_h_mode;
+ bool is_planar_mode;
+ uint8_t base_colors[3][3];
+ uint8_t paint_colors[4][3];
+ uint8_t base_codeword;
+ uint8_t multiplier;
+ uint8_t table_index;
+};
- return GL_FALSE;
-}
+static const int etc2_distance_table[8] = {
+ 3, 6, 11, 16, 23, 32, 41, 64 };
+
+static const int etc2_modifier_tables[16][8] = {
+ { -3, -6, -9, -15, 2, 5, 8, 14},
+ { -3, -7, -10, -13, 2, 6, 9, 12},
+ { -2, -5, -8, -13, 1, 4, 7, 12},
+ { -2, -4, -6, -13, 1, 3, 5, 12},
+ { -3, -6, -8, -12, 2, 5, 7, 11},
+ { -3, -7, -9, -11, 2, 6, 8, 10},
+ { -4, -7, -8, -11, 3, 6, 7, 10},
+ { -3, -5, -8, -11, 2, 4, 7, 10},
+ { -2, -6, -8, -10, 1, 5, 7, 9},
+ { -2, -5, -8, -10, 1, 4, 7, 9},
+ { -2, -4, -8, -10, 1, 3, 7, 9},
+ { -2, -5, -7, -10, 1, 4, 6, 9},
+ { -3, -4, -7, -10, 2, 3, 6, 9},
+ { -1, -2, -3, -10, 0, 1, 2, 9},
+ { -4, -6, -8, -9, 3, 5, 7, 8},
+ { -3, -5, -7, -9, 2, 4, 6, 8},
+};
+
+static const int etc2_modifier_tables_non_opaque[8][4] = {
+ { 0, 8, 0, -8},
+ { 0, 17, 0, -17},
+ { 0, 29, 0, -29},
+ { 0, 42, 0, -42},
+ { 0, 60, 0, -60},
+ { 0, 80, 0, -80},
+ { 0, 106, 0, -106},
+ { 0, 183, 0, -183}
+};
/* define etc1_parse_block and etc. */
#define UINT8_TYPE GLubyte
@@ -50,6 +104,15 @@ _mesa_texstore_etc1_rgb8(TEXSTORE_PARAMS)
#undef TAG
#undef UINT8_TYPE
+GLboolean
+_mesa_texstore_etc1_rgb8(TEXSTORE_PARAMS)
+{
+ /* GL_ETC1_RGB8_OES is only valid in glCompressedTexImage2D */
+ ASSERT(0);
+
+ return GL_FALSE;
+}
+
void
_mesa_fetch_texel_2d_f_etc1_rgb8(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
@@ -101,3 +164,1300 @@ _mesa_etc1_unpack_rgba8888(uint8_t *dst_row,
src_row, src_stride,
src_width, src_height);
}
+
+static uint8_t
+etc2_base_color1_t_mode(const uint8_t *in, GLuint index)
+{
+ uint8_t R1a = 0, x = 0;
+ /* base col 1 = extend_4to8bits( (R1a << 2) | R1b, G1, B1) */
+ switch(index) {
+ case 0:
+ R1a = (in[0] >> 3) & 0x3;
+ x = ((R1a << 2) | (in[0] & 0x3));
+ break;
+ case 1:
+ x = ((in[1] >> 4) & 0xf);
+ break;
+ case 2:
+ x = (in[1] & 0xf);
+ break;
+ default:
+ /* invalid index */
+ break;
+ }
+ return ((x << 4) | (x & 0xf));
+}
+
+static uint8_t
+etc2_base_color2_t_mode(const uint8_t *in, GLuint index)
+{
+ uint8_t x = 0;
+ /*extend 4to8bits(R2, G2, B2)*/
+ switch(index) {
+ case 0:
+ x = ((in[2] >> 4) & 0xf );
+ break;
+ case 1:
+ x = (in[2] & 0xf);
+ break;
+ case 2:
+ x = ((in[3] >> 4) & 0xf);
+ break;
+ default:
+ /* invalid index */
+ break;
+ }
+ return ((x << 4) | (x & 0xf));
+}
+
+static uint8_t
+etc2_base_color1_h_mode(const uint8_t *in, GLuint index)
+{
+ uint8_t x = 0;
+ /* base col 1 = extend 4to8bits(R1, (G1a << 1) | G1b, (B1a << 3) | B1b) */
+ switch(index) {
+ case 0:
+ x = ((in[0] >> 3) & 0xf);
+ break;
+ case 1:
+ x = (((in[0] & 0x7) << 1) | ((in[1] >> 4) & 0x1));
+ break;
+ case 2:
+ x = ((in[1] & 0x8) |
+ (((in[1] & 0x3) << 1) | ((in[2] >> 7) & 0x1)));
+ break;
+ default:
+ /* invalid index */
+ break;
+ }
+ return ((x << 4) | (x & 0xf));
+ }
+
+static uint8_t
+etc2_base_color2_h_mode(const uint8_t *in, GLuint index)
+{
+ uint8_t x = 0;
+ /* base col 2 = extend 4to8bits(R2, G2, B2) */
+ switch(index) {
+ case 0:
+ x = ((in[2] >> 3) & 0xf );
+ break;
+ case 1:
+ x = (((in[2] & 0x7) << 1) | ((in[3] >> 7) & 0x1));
+ break;
+ case 2:
+ x = ((in[3] >> 3) & 0xf);
+ break;
+ default:
+ /* invalid index */
+ break;
+ }
+ return ((x << 4) | (x & 0xf));
+ }
+
+static uint8_t
+etc2_base_color_o_planar(const uint8_t *in, GLuint index)
+{
+ GLuint tmp;
+ switch(index) {
+ case 0:
+ tmp = ((in[0] >> 1) & 0x3f); /* RO */
+ return ((tmp << 2) | (tmp >> 4));
+ case 1:
+ tmp = (((in[0] & 0x1) << 6) | /* GO1 */
+ ((in[1] >> 1) & 0x3f)); /* GO2 */
+ return ((tmp << 1) | (tmp >> 6));
+ case 2:
+ tmp = (((in[1] & 0x1) << 5) | /* BO1 */
+ (in[2] & 0x18) | /* BO2 */
+ (((in[2] & 0x3) << 1) | ((in[3] >> 7) & 0x1))); /* BO3 */
+ return ((tmp << 2) | (tmp >> 4));
+ default:
+ /* invalid index */
+ return 0;
+ }
+}
+
+static uint8_t
+etc2_base_color_h_planar(const uint8_t *in, GLuint index)
+{
+ GLuint tmp;
+ switch(index) {
+ case 0:
+ tmp = (((in[3] & 0x7c) >> 1) | /* RH1 */
+ (in[3] & 0x1)); /* RH2 */
+ return ((tmp << 2) | (tmp >> 4));
+ case 1:
+ tmp = (in[4] >> 1) & 0x7f; /* GH */
+ return ((tmp << 1) | (tmp >> 6));
+ case 2:
+ tmp = (((in[4] & 0x1) << 5) |
+ ((in[5] >> 3) & 0x1f)); /* BH */
+ return ((tmp << 2) | (tmp >> 4));
+ default:
+ /* invalid index */
+ return 0;
+ }
+}
+
+static uint8_t
+etc2_base_color_v_planar(const uint8_t *in, GLuint index)
+{
+ GLuint tmp;
+ switch(index) {
+ case 0:
+ tmp = (((in[5] & 0x7) << 0x3) |
+ ((in[6] >> 5) & 0x7)); /* RV */
+ return ((tmp << 2) | (tmp >> 4));
+ case 1:
+ tmp = (((in[6] & 0x1f) << 2) |
+ ((in[7] >> 6) & 0x3)); /* GV */
+ return ((tmp << 1) | (tmp >> 6));
+ case 2:
+ tmp = in[7] & 0x3f; /* BV */
+ return ((tmp << 2) | (tmp >> 4));
+ default:
+ /* invalid index */
+ return 0;
+ }
+}
+
+static GLint
+etc2_get_pixel_index(const struct etc2_block *block, int x, int y)
+{
+ int bit = ((3 - y) + (3 - x) * 4) * 3;
+ int idx = (block->pixel_indices[1] >> bit) & 0x7;
+ return idx;
+}
+
+static uint8_t
+etc2_clamp(int color)
+{
+ /* CLAMP(color, 0, 255) */
+ return (uint8_t) CLAMP(color, 0, 255);
+}
+
+static GLushort
+etc2_clamp2(int color)
+{
+ /* CLAMP(color, 0, 2047) */
+ return (GLushort) CLAMP(color, 0, 2047);
+}
+
+static GLshort
+etc2_clamp3(int color)
+{
+ /* CLAMP(color, -1023, 1023) */
+ return (GLshort) CLAMP(color, -1023, 1023);
+}
+
+static void
+etc2_rgb8_parse_block(struct etc2_block *block,
+ const uint8_t *src,
+ GLboolean punchthrough_alpha)
+{
+ unsigned i;
+ GLboolean diffbit = false;
+ static const int lookup[8] = { 0, 1, 2, 3, -4, -3, -2, -1 };
+
+ const int R_plus_dR = (src[0] >> 3) + lookup[src[0] & 0x7];
+ const int G_plus_dG = (src[1] >> 3) + lookup[src[1] & 0x7];
+ const int B_plus_dB = (src[2] >> 3) + lookup[src[2] & 0x7];
+
+ /* Reset the mode flags */
+ block->is_ind_mode = false;
+ block->is_diff_mode = false;
+ block->is_t_mode = false;
+ block->is_h_mode = false;
+ block->is_planar_mode = false;
+
+ if (punchthrough_alpha)
+ block->opaque = src[3] & 0x2;
+ else
+ diffbit = src[3] & 0x2;
+
+ if (!diffbit && !punchthrough_alpha) {
+ /* individual mode */
+ block->is_ind_mode = true;
+
+ for (i = 0; i < 3; i++) {
+ /* Texture decode algorithm is same for individual mode in etc1
+ * & etc2.
+ */
+ block->base_colors[0][i] = etc1_base_color_ind_hi(src[i]);
+ block->base_colors[1][i] = etc1_base_color_ind_lo(src[i]);
+ }
+ }
+ else if (R_plus_dR < 0 || R_plus_dR > 31){
+ /* T mode */
+ block->is_t_mode = true;
+
+ for(i = 0; i < 3; i++) {
+ block->base_colors[0][i] = etc2_base_color1_t_mode(src, i);
+ block->base_colors[1][i] = etc2_base_color2_t_mode(src, i);
+ }
+ /* pick distance */
+ block->distance =
+ etc2_distance_table[(((src[3] >> 2) & 0x3) << 1) |
+ (src[3] & 0x1)];
+
+ for (i = 0; i < 3; i++) {
+ block->paint_colors[0][i] = etc2_clamp(block->base_colors[0][i]);
+ block->paint_colors[1][i] = etc2_clamp(block->base_colors[1][i] +
+ block->distance);
+ block->paint_colors[2][i] = etc2_clamp(block->base_colors[1][i]);
+ block->paint_colors[3][i] = etc2_clamp(block->base_colors[1][i] -
+ block->distance);
+ }
+ }
+ else if (G_plus_dG < 0 || G_plus_dG > 31){
+ int base_color_1_value, base_color_2_value;
+
+ /* H mode */
+ block->is_h_mode = true;
+
+ for(i = 0; i < 3; i++) {
+ block->base_colors[0][i] = etc2_base_color1_h_mode(src, i);
+ block->base_colors[1][i] = etc2_base_color2_h_mode(src, i);
+ }
+
+ base_color_1_value = (block->base_colors[0][0] << 16) +
+ (block->base_colors[0][1] << 8) +
+ block->base_colors[0][2];
+ base_color_2_value = (block->base_colors[1][0] << 16) +
+ (block->base_colors[1][1] << 8) +
+ block->base_colors[1][2];
+ /* pick distance */
+ block->distance =
+ etc2_distance_table[(src[3] & 0x4) |
+ ((src[3] & 0x1) << 1) |
+ (base_color_1_value >= base_color_2_value)];
+
+ for (i = 0; i < 3; i++) {
+ block->paint_colors[0][i] = etc2_clamp(block->base_colors[0][i] +
+ block->distance);
+ block->paint_colors[1][i] = etc2_clamp(block->base_colors[0][i] -
+ block->distance);
+ block->paint_colors[2][i] = etc2_clamp(block->base_colors[1][i] +
+ block->distance);
+ block->paint_colors[3][i] = etc2_clamp(block->base_colors[1][i] -
+ block->distance);
+ }
+ }
+ else if (B_plus_dB < 0 || B_plus_dB > 31) {
+ /* Planar mode */
+ block->is_planar_mode = true;
+
+ /* opaque bit must be set in planar mode */
+ if (!block->opaque)
+ block->opaque = true;
+
+ for (i = 0; i < 3; i++) {
+ block->base_colors[0][i] = etc2_base_color_o_planar(src, i);
+ block->base_colors[1][i] = etc2_base_color_h_planar(src, i);
+ block->base_colors[2][i] = etc2_base_color_v_planar(src, i);
+ }
+ }
+ else if (diffbit || punchthrough_alpha) {
+ /* differential mode */
+ block->is_diff_mode = true;
+
+ for (i = 0; i < 3; i++) {
+ /* Texture decode algorithm is same for differential mode in etc1
+ * & etc2.
+ */
+ block->base_colors[0][i] = etc1_base_color_diff_hi(src[i]);
+ block->base_colors[1][i] = etc1_base_color_diff_lo(src[i]);
+ }
+ }
+
+ if (block->is_ind_mode || block->is_diff_mode) {
+ int table1_idx = (src[3] >> 5) & 0x7;
+ int table2_idx = (src[3] >> 2) & 0x7;
+
+ /* Use same modifier tables as for etc1 textures if opaque bit is set
+ * or if non punchthrough texture format
+ */
+ block->modifier_tables[0] = (block->opaque || !punchthrough_alpha) ?
+ etc1_modifier_tables[table1_idx] :
+ etc2_modifier_tables_non_opaque[table1_idx];
+ block->modifier_tables[1] = (block->opaque || !punchthrough_alpha) ?
+ etc1_modifier_tables[table2_idx] :
+ etc2_modifier_tables_non_opaque[table2_idx];
+
+ block->flipped = (src[3] & 0x1);
+ }
+
+ block->pixel_indices[0] =
+ (src[4] << 24) | (src[5] << 16) | (src[6] << 8) | src[7];
+}
+
+static void
+etc2_rgb8_fetch_texel(const struct etc2_block *block,
+ int x, int y, uint8_t *dst,
+ GLboolean punchthrough_alpha)
+{
+ const uint8_t *base_color;
+ int modifier, bit, idx, blk;
+
+ /* get pixel index */
+ bit = y + x * 4;
+ idx = ((block->pixel_indices[0] >> (15 + bit)) & 0x2) |
+ ((block->pixel_indices[0] >> (bit)) & 0x1);
+
+ if (block->is_ind_mode || block->is_diff_mode) {
+ /* check for punchthrough_alpha format */
+ if (punchthrough_alpha) {
+ if (!block->opaque && idx == 2) {
+ dst[0] = dst[1] = dst[2] = dst[3] = 0;
+ return;
+ }
+ else
+ dst[3] = 255;
+ }
+
+ /* Use pixel index and subblock to get the modifier */
+ blk = (block->flipped) ? (y >= 2) : (x >= 2);
+ base_color = block->base_colors[blk];
+ modifier = block->modifier_tables[blk][idx];
+
+ dst[0] = etc2_clamp(base_color[0] + modifier);
+ dst[1] = etc2_clamp(base_color[1] + modifier);
+ dst[2] = etc2_clamp(base_color[2] + modifier);
+ }
+ else if (block->is_t_mode || block->is_h_mode) {
+ /* check for punchthrough_alpha format */
+ if (punchthrough_alpha) {
+ if (!block->opaque && idx == 2) {
+ dst[0] = dst[1] = dst[2] = dst[3] = 0;
+ return;
+ }
+ else
+ dst[3] = 255;
+ }
+
+ /* Use pixel index to pick one of the paint colors */
+ dst[0] = block->paint_colors[idx][0];
+ dst[1] = block->paint_colors[idx][1];
+ dst[2] = block->paint_colors[idx][2];
+ }
+ else if (block->is_planar_mode) {
+ /* {R(x, y) = clamp255((x × (RH − RO) + y × (RV − RO) + 4 × RO + 2) >> 2)
+ * {G(x, y) = clamp255((x × (GH − GO) + y × (GV − GO) + 4 × GO + 2) >> 2)
+ * {B(x, y) = clamp255((x × (BH − BO) + y × (BV − BO) + 4 × BO + 2) >> 2)
+ */
+ int red, green, blue;
+ red = (x * (block->base_colors[1][0] - block->base_colors[0][0]) +
+ y * (block->base_colors[2][0] - block->base_colors[0][0]) +
+ 4 * block->base_colors[0][0] + 2) >> 2;
+
+ green = (x * (block->base_colors[1][1] - block->base_colors[0][1]) +
+ y * (block->base_colors[2][1] - block->base_colors[0][1]) +
+ 4 * block->base_colors[0][1] + 2) >> 2;
+
+ blue = (x * (block->base_colors[1][2] - block->base_colors[0][2]) +
+ y * (block->base_colors[2][2] - block->base_colors[0][2]) +
+ 4 * block->base_colors[0][2] + 2) >> 2;
+
+ dst[0] = etc2_clamp(red);
+ dst[1] = etc2_clamp(green);
+ dst[2] = etc2_clamp(blue);
+
+ /* check for punchthrough_alpha format */
+ if (punchthrough_alpha)
+ dst[3] = 255;
+ }
+}
+
+static void
+etc2_alpha8_fetch_texel(const struct etc2_block *block,
+ int x, int y, uint8_t *dst)
+{
+ int modifier, alpha, idx;
+ /* get pixel index */
+ idx = etc2_get_pixel_index(block, x, y);
+ modifier = etc2_modifier_tables[block->table_index][idx];
+ alpha = block->base_codeword + modifier * block->multiplier;
+ dst[3] = etc2_clamp(alpha);
+}
+
+static void
+etc2_r11_fetch_texel(const struct etc2_block *block,
+ int x, int y, uint8_t *dst)
+{
+ GLint modifier, idx;
+ GLshort color;
+ /* Get pixel index */
+ idx = etc2_get_pixel_index(block, x, y);
+ modifier = etc2_modifier_tables[block->table_index][idx];
+
+ if (block->multiplier != 0)
+ /* clamp2(base codeword × 8 + 4 + modifier × multiplier × 8) */
+ color = etc2_clamp2(((block->base_codeword << 3) | 0x4) +
+ ((modifier * block->multiplier) << 3));
+ else
+ color = etc2_clamp2(((block->base_codeword << 3) | 0x4) + modifier);
+
+ /* Extend 11 bits color value to 16 bits. OpenGL ES 3.0 specification
+ * allows extending the color value to any number of bits. But, an
+ * implementation is not allowed to truncate the 11-bit value to less than
+ * 11 bits."
+ */
+ color = (color << 5) | (color >> 6);
+ ((GLushort *)dst)[0] = color;
+}
+
+static void
+etc2_signed_r11_fetch_texel(const struct etc2_block *block,
+ int x, int y, uint8_t *dst)
+{
+ GLint modifier, idx;
+ GLshort color;
+ GLbyte base_codeword = (GLbyte) block->base_codeword;
+
+ if (base_codeword == -128)
+ base_codeword = -127;
+
+ /* Get pixel index */
+ idx = etc2_get_pixel_index(block, x, y);
+ modifier = etc2_modifier_tables[block->table_index][idx];
+
+ if (block->multiplier != 0)
+ /* clamp3(base codeword × 8 + modifier × multiplier × 8) */
+ color = etc2_clamp3((base_codeword << 3) +
+ ((modifier * block->multiplier) << 3));
+ else
+ color = etc2_clamp3((base_codeword << 3) + modifier);
+
+ /* Extend 11 bits color value to 16 bits. OpenGL ES 3.0 specification
+ * allows extending the color value to any number of bits. But, an
+ * implementation is not allowed to truncate the 11-bit value to less than
+ * 11 bits. A negative 11-bit value must first be made positive before bit
+ * replication, and then made negative again
+ */
+ if (color >= 0)
+ color = (color << 5) | (color >> 5);
+ else {
+ color = -color;
+ color = (color << 5) | (color >> 5);
+ color = -color;
+ }
+ ((GLshort *)dst)[0] = color;
+}
+
+static void
+etc2_alpha8_parse_block(struct etc2_block *block, const uint8_t *src)
+{
+ block->base_codeword = src[0];
+ block->multiplier = (src[1] >> 4) & 0xf;
+ block->table_index = src[1] & 0xf;
+ block->pixel_indices[1] = (((uint64_t)src[2] << 40) |
+ ((uint64_t)src[3] << 32) |
+ ((uint64_t)src[4] << 24) |
+ ((uint64_t)src[5] << 16) |
+ ((uint64_t)src[6] << 8) |
+ ((uint64_t)src[7]));
+}
+
+static void
+etc2_r11_parse_block(struct etc2_block *block, const uint8_t *src)
+{
+ /* Parsing logic remains same as for etc2_alpha8_parse_block */
+ etc2_alpha8_parse_block(block, src);
+}
+
+static void
+etc2_rgba8_parse_block(struct etc2_block *block, const uint8_t *src)
+{
+ /* RGB component is parsed the same way as for MESA_FORMAT_ETC2_RGB8 */
+ etc2_rgb8_parse_block(block, src + 8,
+ false /* punchthrough_alpha */);
+ /* Parse Alpha component */
+ etc2_alpha8_parse_block(block, src);
+}
+
+static void
+etc2_rgba8_fetch_texel(const struct etc2_block *block,
+ int x, int y, uint8_t *dst)
+{
+ etc2_rgb8_fetch_texel(block, x, y, dst,
+ false /* punchthrough_alpha */);
+ etc2_alpha8_fetch_texel(block, x, y, dst);
+}
+
+static void
+etc2_unpack_rgb8(uint8_t *dst_row,
+ unsigned dst_stride,
+ const uint8_t *src_row,
+ unsigned src_stride,
+ unsigned width,
+ unsigned height)
+{
+ const unsigned bw = 4, bh = 4, bs = 8, comps = 4;
+ struct etc2_block block;
+ unsigned x, y, i, j;
+
+ for (y = 0; y < height; y += bh) {
+ const uint8_t *src = src_row;
+
+ for (x = 0; x < width; x+= bw) {
+ etc2_rgb8_parse_block(&block, src,
+ false /* punchthrough_alpha */);
+
+ for (j = 0; j < bh; j++) {
+ uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
+ for (i = 0; i < bw; i++) {
+ etc2_rgb8_fetch_texel(&block, i, j, dst,
+ false /* punchthrough_alpha */);
+ dst[3] = 255;
+ dst += comps;
+ }
+ }
+
+ src += bs;
+ }
+
+ src_row += src_stride;
+ }
+}
+
+static void
+etc2_unpack_srgb8(uint8_t *dst_row,
+ unsigned dst_stride,
+ const uint8_t *src_row,
+ unsigned src_stride,
+ unsigned width,
+ unsigned height)
+{
+ const unsigned bw = 4, bh = 4, bs = 8, comps = 4;
+ struct etc2_block block;
+ unsigned x, y, i, j;
+ uint8_t tmp;
+
+ for (y = 0; y < height; y += bh) {
+ const uint8_t *src = src_row;
+
+ for (x = 0; x < width; x+= bw) {
+ etc2_rgb8_parse_block(&block, src,
+ false /* punchthrough_alpha */);
+
+ for (j = 0; j < bh; j++) {
+ uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
+ for (i = 0; i < bw; i++) {
+ etc2_rgb8_fetch_texel(&block, i, j, dst,
+ false /* punchthrough_alpha */);
+ /* Convert to MESA_FORMAT_SARGB8 */
+ tmp = dst[0];
+ dst[0] = dst[2];
+ dst[2] = tmp;
+ dst[3] = 255;
+
+ dst += comps;
+ }
+ }
+ src += bs;
+ }
+
+ src_row += src_stride;
+ }
+}
+
+static void
+etc2_unpack_rgba8(uint8_t *dst_row,
+ unsigned dst_stride,
+ const uint8_t *src_row,
+ unsigned src_stride,
+ unsigned width,
+ unsigned height)
+{
+ /* If internalformat is COMPRESSED_RGBA8_ETC2_EAC, each 4 × 4 block of
+ * RGBA8888 information is compressed to 128 bits. To decode a block, the
+ * two 64-bit integers int64bitAlpha and int64bitColor are calculated.
+ */
+ const unsigned bw = 4, bh = 4, bs = 16, comps = 4;
+ struct etc2_block block;
+ unsigned x, y, i, j;
+
+ for (y = 0; y < height; y += bh) {
+ const uint8_t *src = src_row;
+
+ for (x = 0; x < width; x+= bw) {
+ etc2_rgba8_parse_block(&block, src);
+
+ for (j = 0; j < bh; j++) {
+ uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
+ for (i = 0; i < bw; i++) {
+ etc2_rgba8_fetch_texel(&block, i, j, dst);
+ dst += comps;
+ }
+ }
+ src += bs;
+ }
+
+ src_row += src_stride;
+ }
+}
+
+static void
+etc2_unpack_srgb8_alpha8(uint8_t *dst_row,
+ unsigned dst_stride,
+ const uint8_t *src_row,
+ unsigned src_stride,
+ unsigned width,
+ unsigned height)
+{
+ /* If internalformat is COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, each 4 × 4 block
+ * of RGBA8888 information is compressed to 128 bits. To decode a block, the
+ * two 64-bit integers int64bitAlpha and int64bitColor are calculated.
+ */
+ const unsigned bw = 4, bh = 4, bs = 16, comps = 4;
+ struct etc2_block block;
+ unsigned x, y, i, j;
+ uint8_t tmp;
+
+ for (y = 0; y < height; y += bh) {
+ const uint8_t *src = src_row;
+
+ for (x = 0; x < width; x+= bw) {
+ etc2_rgba8_parse_block(&block, src);
+
+ for (j = 0; j < bh; j++) {
+ uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
+ for (i = 0; i < bw; i++) {
+ etc2_rgba8_fetch_texel(&block, i, j, dst);
+
+ /* Convert to MESA_FORMAT_SARGB8 */
+ tmp = dst[0];
+ dst[0] = dst[2];
+ dst[2] = tmp;
+ dst[3] = dst[3];
+
+ dst += comps;
+ }
+ }
+ src += bs;
+ }
+
+ src_row += src_stride;
+ }
+}
+
+static void
+etc2_unpack_r11(uint8_t *dst_row,
+ unsigned dst_stride,
+ const uint8_t *src_row,
+ unsigned src_stride,
+ unsigned width,
+ unsigned height)
+{
+ /* If internalformat is COMPRESSED_R11_EAC, each 4 × 4 block of
+ color information is compressed to 64 bits.
+ */
+ const unsigned bw = 4, bh = 4, bs = 8, comps = 1, comp_size = 2;
+ struct etc2_block block;
+ unsigned x, y, i, j;
+
+ for (y = 0; y < height; y += bh) {
+ const uint8_t *src = src_row;
+
+ for (x = 0; x < width; x+= bw) {
+ etc2_r11_parse_block(&block, src);
+
+ for (j = 0; j < bh; j++) {
+ uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps * comp_size;
+ for (i = 0; i < bw; i++) {
+ etc2_r11_fetch_texel(&block, i, j, dst);
+ dst += comps * comp_size;
+ }
+ }
+ src += bs;
+ }
+
+ src_row += src_stride;
+ }
+}
+
+static void
+etc2_unpack_rg11(uint8_t *dst_row,
+ unsigned dst_stride,
+ const uint8_t *src_row,
+ unsigned src_stride,
+ unsigned width,
+ unsigned height)
+{
+ /* If internalformat is COMPRESSED_RG11_EAC, each 4 × 4 block of
+ RG color information is compressed to 128 bits.
+ */
+ const unsigned bw = 4, bh = 4, bs = 16, comps = 2, comp_size = 2;
+ struct etc2_block block;
+ unsigned x, y, i, j;
+
+ for (y = 0; y < height; y += bh) {
+ const uint8_t *src = src_row;
+
+ for (x = 0; x < width; x+= bw) {
+ /* red component */
+ etc2_r11_parse_block(&block, src);
+
+ for (j = 0; j < bh; j++) {
+ uint8_t *dst = dst_row + (y + j) * dst_stride +
+ x * comps * comp_size;
+ for (i = 0; i < bw; i++) {
+ etc2_r11_fetch_texel(&block, i, j, dst);
+ dst += comps * comp_size;
+ }
+ }
+ /* green component */
+ etc2_r11_parse_block(&block, src + 8);
+
+ for (j = 0; j < bh; j++) {
+ uint8_t *dst = dst_row + (y + j) * dst_stride +
+ x * comps * comp_size;
+ for (i = 0; i < bw; i++) {
+ etc2_r11_fetch_texel(&block, i, j, dst + comp_size);
+ dst += comps * comp_size;
+ }
+ }
+ src += bs;
+ }
+
+ src_row += src_stride;
+ }
+}
+
+static void
+etc2_unpack_signed_r11(uint8_t *dst_row,
+ unsigned dst_stride,
+ const uint8_t *src_row,
+ unsigned src_stride,
+ unsigned width,
+ unsigned height)
+{
+ /* If internalformat is COMPRESSED_SIGNED_R11_EAC, each 4 × 4 block of
+ red color information is compressed to 64 bits.
+ */
+ const unsigned bw = 4, bh = 4, bs = 8, comps = 1, comp_size = 2;
+ struct etc2_block block;
+ unsigned x, y, i, j;
+
+ for (y = 0; y < height; y += bh) {
+ const uint8_t *src = src_row;
+
+ for (x = 0; x < width; x+= bw) {
+ etc2_r11_parse_block(&block, src);
+
+ for (j = 0; j < bh; j++) {
+ uint8_t *dst = dst_row + (y + j) * dst_stride +
+ x * comps * comp_size;
+ for (i = 0; i < bw; i++) {
+ etc2_signed_r11_fetch_texel(&block, i, j, dst);
+ dst += comps * comp_size;
+ }
+ }
+ src += bs;
+ }
+
+ src_row += src_stride;
+ }
+}
+
+static void
+etc2_unpack_signed_rg11(uint8_t *dst_row,
+ unsigned dst_stride,
+ const uint8_t *src_row,
+ unsigned src_stride,
+ unsigned width,
+ unsigned height)
+{
+ /* If internalformat is COMPRESSED_SIGNED_RG11_EAC, each 4 × 4 block of
+ RG color information is compressed to 128 bits.
+ */
+ const unsigned bw = 4, bh = 4, bs = 16, comps = 2, comp_size = 2;
+ struct etc2_block block;
+ unsigned x, y, i, j;
+
+ for (y = 0; y < height; y += bh) {
+ const uint8_t *src = src_row;
+
+ for (x = 0; x < width; x+= bw) {
+ /* red component */
+ etc2_r11_parse_block(&block, src);
+
+ for (j = 0; j < bh; j++) {
+ uint8_t *dst = dst_row + (y + j) * dst_stride +
+ x * comps * comp_size;
+ for (i = 0; i < bw; i++) {
+ etc2_signed_r11_fetch_texel(&block, i, j, dst);
+ dst += comps * comp_size;
+ }
+ }
+ /* green component */
+ etc2_r11_parse_block(&block, src + 8);
+
+ for (j = 0; j < bh; j++) {
+ uint8_t *dst = dst_row + (y + j) * dst_stride +
+ x * comps * comp_size;
+ for (i = 0; i < bw; i++) {
+ etc2_signed_r11_fetch_texel(&block, i, j, dst + comp_size);
+ dst += comps * comp_size;
+ }
+ }
+ src += bs;
+ }
+
+ src_row += src_stride;
+ }
+}
+
+static void
+etc2_unpack_rgb8_punchthrough_alpha1(uint8_t *dst_row,
+ unsigned dst_stride,
+ const uint8_t *src_row,
+ unsigned src_stride,
+ unsigned width,
+ unsigned height)
+{
+ const unsigned bw = 4, bh = 4, bs = 8, comps = 4;
+ struct etc2_block block;
+ unsigned x, y, i, j;
+
+ for (y = 0; y < height; y += bh) {
+ const uint8_t *src = src_row;
+
+ for (x = 0; x < width; x+= bw) {
+ etc2_rgb8_parse_block(&block, src,
+ true /* punchthrough_alpha */);
+ for (j = 0; j < bh; j++) {
+ uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
+ for (i = 0; i < bw; i++) {
+ etc2_rgb8_fetch_texel(&block, i, j, dst,
+ true /* punchthrough_alpha */);
+ dst += comps;
+ }
+ }
+
+ src += bs;
+ }
+
+ src_row += src_stride;
+ }
+}
+
+static void
+etc2_unpack_srgb8_punchthrough_alpha1(uint8_t *dst_row,
+ unsigned dst_stride,
+ const uint8_t *src_row,
+ unsigned src_stride,
+ unsigned width,
+ unsigned height)
+{
+ const unsigned bw = 4, bh = 4, bs = 8, comps = 4;
+ struct etc2_block block;
+ unsigned x, y, i, j;
+ uint8_t tmp;
+
+ for (y = 0; y < height; y += bh) {
+ const uint8_t *src = src_row;
+
+ for (x = 0; x < width; x+= bw) {
+ etc2_rgb8_parse_block(&block, src,
+ true /* punchthrough_alpha */);
+ for (j = 0; j < bh; j++) {
+ uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
+ for (i = 0; i < bw; i++) {
+ etc2_rgb8_fetch_texel(&block, i, j, dst,
+ true /* punchthrough_alpha */);
+ /* Convert to MESA_FORMAT_SARGB8 */
+ tmp = dst[0];
+ dst[0] = dst[2];
+ dst[2] = tmp;
+ dst[3] = dst[3];
+
+ dst += comps;
+ }
+ }
+
+ src += bs;
+ }
+
+ src_row += src_stride;
+ }
+}
+
+/* ETC2 texture formats are valid in glCompressedTexImage2D and
+ * glCompressedTexSubImage2D functions */
+GLboolean
+_mesa_texstore_etc2_rgb8(TEXSTORE_PARAMS)
+{
+ ASSERT(0);
+
+ return GL_FALSE;
+}
+
+GLboolean
+_mesa_texstore_etc2_srgb8(TEXSTORE_PARAMS)
+{
+ ASSERT(0);
+
+ return GL_FALSE;
+}
+
+GLboolean
+_mesa_texstore_etc2_rgba8_eac(TEXSTORE_PARAMS)
+{
+ ASSERT(0);
+
+ return GL_FALSE;
+}
+
+GLboolean
+_mesa_texstore_etc2_srgb8_alpha8_eac(TEXSTORE_PARAMS)
+{
+ ASSERT(0);
+
+ return GL_FALSE;
+}
+
+GLboolean
+_mesa_texstore_etc2_r11_eac(TEXSTORE_PARAMS)
+{
+ ASSERT(0);
+
+ return GL_FALSE;
+}
+
+GLboolean
+_mesa_texstore_etc2_signed_r11_eac(TEXSTORE_PARAMS)
+{
+ ASSERT(0);
+
+ return GL_FALSE;
+}
+
+GLboolean
+_mesa_texstore_etc2_rg11_eac(TEXSTORE_PARAMS)
+{
+ ASSERT(0);
+
+ return GL_FALSE;
+}
+
+GLboolean
+_mesa_texstore_etc2_signed_rg11_eac(TEXSTORE_PARAMS)
+{
+ ASSERT(0);
+
+ return GL_FALSE;
+}
+
+GLboolean
+_mesa_texstore_etc2_rgb8_punchthrough_alpha1(TEXSTORE_PARAMS)
+{
+ ASSERT(0);
+
+ return GL_FALSE;
+}
+
+GLboolean
+_mesa_texstore_etc2_srgb8_punchthrough_alpha1(TEXSTORE_PARAMS)
+{
+ ASSERT(0);
+
+ return GL_FALSE;
+}
+
+void
+_mesa_fetch_texel_2d_f_etc2_rgb8(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ struct etc2_block block;
+ uint8_t dst[3];
+ const uint8_t *src;
+
+ src = texImage->Map +
+ (((texImage->RowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
+
+ etc2_rgb8_parse_block(&block, src,
+ false /* punchthrough_alpha */);
+ etc2_rgb8_fetch_texel(&block, i % 4, j % 4, dst,
+ false /* punchthrough_alpha */);
+
+ texel[RCOMP] = UBYTE_TO_FLOAT(dst[0]);
+ texel[GCOMP] = UBYTE_TO_FLOAT(dst[1]);
+ texel[BCOMP] = UBYTE_TO_FLOAT(dst[2]);
+ texel[ACOMP] = 1.0f;
+}
+
+void
+_mesa_fetch_texel_2d_f_etc2_srgb8(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ struct etc2_block block;
+ uint8_t dst[3];
+ const uint8_t *src;
+
+ src = texImage->Map +
+ (((texImage->RowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
+
+ etc2_rgb8_parse_block(&block, src,
+ false /* punchthrough_alpha */);
+ etc2_rgb8_fetch_texel(&block, i % 4, j % 4, dst,
+ false /* punchthrough_alpha */);
+
+ texel[RCOMP] = _mesa_nonlinear_to_linear(dst[0]);
+ texel[GCOMP] = _mesa_nonlinear_to_linear(dst[1]);
+ texel[BCOMP] = _mesa_nonlinear_to_linear(dst[2]);
+ texel[ACOMP] = 1.0f;
+}
+
+void
+_mesa_fetch_texel_2d_f_etc2_rgba8_eac(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ struct etc2_block block;
+ uint8_t dst[4];
+ const uint8_t *src;
+
+ src = texImage->Map +
+ (((texImage->RowStride + 3) / 4) * (j / 4) + (i / 4)) * 16;
+
+ etc2_rgba8_parse_block(&block, src);
+ etc2_rgba8_fetch_texel(&block, i % 4, j % 4, dst);
+
+ texel[RCOMP] = UBYTE_TO_FLOAT(dst[0]);
+ texel[GCOMP] = UBYTE_TO_FLOAT(dst[1]);
+ texel[BCOMP] = UBYTE_TO_FLOAT(dst[2]);
+ texel[ACOMP] = UBYTE_TO_FLOAT(dst[3]);
+}
+
+void
+_mesa_fetch_texel_2d_f_etc2_srgb8_alpha8_eac(const struct
+ swrast_texture_image *texImage,
+ GLint i, GLint j,
+ GLint k, GLfloat *texel)
+{
+ struct etc2_block block;
+ uint8_t dst[4];
+ const uint8_t *src;
+
+ src = texImage->Map +
+ (((texImage->RowStride + 3) / 4) * (j / 4) + (i / 4)) * 16;
+
+ etc2_rgba8_parse_block(&block, src);
+ etc2_rgba8_fetch_texel(&block, i % 4, j % 4, dst);
+
+ texel[RCOMP] = _mesa_nonlinear_to_linear(dst[0]);
+ texel[GCOMP] = _mesa_nonlinear_to_linear(dst[1]);
+ texel[BCOMP] = _mesa_nonlinear_to_linear(dst[2]);
+ texel[ACOMP] = UBYTE_TO_FLOAT(dst[3]);
+}
+
+void
+_mesa_fetch_texel_2d_f_etc2_r11_eac(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ struct etc2_block block;
+ GLushort dst;
+ const uint8_t *src;
+
+ src = texImage->Map +
+ (((texImage->RowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
+
+ etc2_r11_parse_block(&block, src);
+ etc2_r11_fetch_texel(&block, i % 4, j % 4, (uint8_t *)&dst);
+
+ texel[RCOMP] = USHORT_TO_FLOAT(dst);
+ texel[GCOMP] = 0.0f;
+ texel[BCOMP] = 0.0f;
+ texel[ACOMP] = 1.0f;
+}
+
+void
+_mesa_fetch_texel_2d_f_etc2_rg11_eac(const struct
+ swrast_texture_image *texImage,
+ GLint i, GLint j,
+ GLint k, GLfloat *texel)
+{
+ struct etc2_block block;
+ GLushort dst[2];
+ const uint8_t *src;
+
+ src = texImage->Map +
+ (((texImage->RowStride + 3) / 4) * (j / 4) + (i / 4)) * 16;
+
+ /* red component */
+ etc2_r11_parse_block(&block, src);
+ etc2_r11_fetch_texel(&block, i % 4, j % 4, (uint8_t *)dst);
+
+ /* green component */
+ etc2_r11_parse_block(&block, src + 8);
+ etc2_r11_fetch_texel(&block, i % 4, j % 4, (uint8_t *)(dst + 1));
+
+ texel[RCOMP] = USHORT_TO_FLOAT(dst[0]);
+ texel[GCOMP] = USHORT_TO_FLOAT(dst[1]);
+ texel[BCOMP] = 0.0f;
+ texel[ACOMP] = 1.0f;
+}
+
+void
+_mesa_fetch_texel_2d_f_etc2_signed_r11_eac(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ struct etc2_block block;
+ GLushort dst;
+ const uint8_t *src;
+
+ src = texImage->Map +
+ (((texImage->RowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
+
+ etc2_r11_parse_block(&block, src);
+ etc2_signed_r11_fetch_texel(&block, i % 4, j % 4, (uint8_t *)&dst);
+
+ texel[RCOMP] = SHORT_TO_FLOAT(dst);
+ texel[GCOMP] = 0.0f;
+ texel[BCOMP] = 0.0f;
+ texel[ACOMP] = 1.0f;
+}
+
+void
+_mesa_fetch_texel_2d_f_etc2_signed_rg11_eac(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ struct etc2_block block;
+ GLushort dst[2];
+ const uint8_t *src;
+
+ src = texImage->Map +
+ (((texImage->RowStride + 3) / 4) * (j / 4) + (i / 4)) * 16;
+
+ /* red component */
+ etc2_r11_parse_block(&block, src);
+ etc2_signed_r11_fetch_texel(&block, i % 4, j % 4, (uint8_t *)dst);
+
+ /* green component */
+ etc2_r11_parse_block(&block, src + 8);
+ etc2_signed_r11_fetch_texel(&block, i % 4, j % 4, (uint8_t *)(dst + 1));
+
+ texel[RCOMP] = SHORT_TO_FLOAT(dst[0]);
+ texel[GCOMP] = SHORT_TO_FLOAT(dst[1]);
+ texel[BCOMP] = 0.0f;
+ texel[ACOMP] = 1.0f;
+}
+
+void
+_mesa_fetch_texel_2d_f_etc2_rgb8_punchthrough_alpha1(
+ const struct swrast_texture_image *texImage,
+ GLint i, GLint j,
+ GLint k, GLfloat *texel)
+{
+ struct etc2_block block;
+ uint8_t dst[4];
+ const uint8_t *src;
+
+ src = texImage->Map +
+ (((texImage->RowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
+
+ etc2_rgb8_parse_block(&block, src,
+ true /* punchthrough alpha */);
+ etc2_rgb8_fetch_texel(&block, i % 4, j % 4, dst,
+ true /* punchthrough alpha */);
+ texel[RCOMP] = UBYTE_TO_FLOAT(dst[0]);
+ texel[GCOMP] = UBYTE_TO_FLOAT(dst[1]);
+ texel[BCOMP] = UBYTE_TO_FLOAT(dst[2]);
+ texel[ACOMP] = UBYTE_TO_FLOAT(dst[3]);
+}
+
+void
+_mesa_fetch_texel_2d_f_etc2_srgb8_punchthrough_alpha1(
+ const struct swrast_texture_image *texImage,
+ GLint i, GLint j,
+ GLint k, GLfloat *texel)
+{
+ struct etc2_block block;
+ uint8_t dst[4];
+ const uint8_t *src;
+
+ src = texImage->Map +
+ (((texImage->RowStride + 3) / 4) * (j / 4) + (i / 4)) * 8;
+
+ etc2_rgb8_parse_block(&block, src,
+ true /* punchthrough alpha */);
+ etc2_rgb8_fetch_texel(&block, i % 4, j % 4, dst,
+ true /* punchthrough alpha */);
+ texel[RCOMP] = _mesa_nonlinear_to_linear(dst[0]);
+ texel[GCOMP] = _mesa_nonlinear_to_linear(dst[1]);
+ texel[BCOMP] = _mesa_nonlinear_to_linear(dst[2]);
+ texel[ACOMP] = UBYTE_TO_FLOAT(dst[3]);
+}
+
+/**
+ * Decode texture data in any one of following formats:
+ * `MESA_FORMAT_ETC2_RGB8`
+ * `MESA_FORMAT_ETC2_SRGB8`
+ * `MESA_FORMAT_ETC2_RGBA8_EAC`
+ * `MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC`
+ * `MESA_FORMAT_ETC2_R11_EAC`
+ * `MESA_FORMAT_ETC2_RG11_EAC`
+ * `MESA_FORMAT_ETC2_SIGNED_R11_EAC`
+ * `MESA_FORMAT_ETC2_SIGNED_RG11_EAC`
+ * `MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1`
+ * `MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1`
+ *
+ * The size of the source data must be a multiple of the ETC2 block size
+ * even if the texture image's dimensions are not aligned to 4.
+ *
+ * \param src_width in pixels
+ * \param src_height in pixels
+ * \param dst_stride in bytes
+ */
+
+void
+_mesa_unpack_etc2_format(uint8_t *dst_row,
+ unsigned dst_stride,
+ const uint8_t *src_row,
+ unsigned src_stride,
+ unsigned src_width,
+ unsigned src_height,
+ gl_format format)
+{
+ if (format == MESA_FORMAT_ETC2_RGB8)
+ etc2_unpack_rgb8(dst_row, dst_stride,
+ src_row, src_stride,
+ src_width, src_height);
+ else if (format == MESA_FORMAT_ETC2_SRGB8)
+ etc2_unpack_srgb8(dst_row, dst_stride,
+ src_row, src_stride,
+ src_width, src_height);
+ else if (format == MESA_FORMAT_ETC2_RGBA8_EAC)
+ etc2_unpack_rgba8(dst_row, dst_stride,
+ src_row, src_stride,
+ src_width, src_height);
+ else if (format == MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC)
+ etc2_unpack_srgb8_alpha8(dst_row, dst_stride,
+ src_row, src_stride,
+ src_width, src_height);
+ else if (format == MESA_FORMAT_ETC2_R11_EAC)
+ etc2_unpack_r11(dst_row, dst_stride,
+ src_row, src_stride,
+ src_width, src_height);
+ else if (format == MESA_FORMAT_ETC2_RG11_EAC)
+ etc2_unpack_rg11(dst_row, dst_stride,
+ src_row, src_stride,
+ src_width, src_height);
+ else if (format == MESA_FORMAT_ETC2_SIGNED_R11_EAC)
+ etc2_unpack_signed_r11(dst_row, dst_stride,
+ src_row, src_stride,
+ src_width, src_height);
+ else if (format == MESA_FORMAT_ETC2_SIGNED_RG11_EAC)
+ etc2_unpack_signed_rg11(dst_row, dst_stride,
+ src_row, src_stride,
+ src_width, src_height);
+ else if (format == MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1)
+ etc2_unpack_rgb8_punchthrough_alpha1(dst_row, dst_stride,
+ src_row, src_stride,
+ src_width, src_height);
+ else if (format == MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1)
+ etc2_unpack_srgb8_punchthrough_alpha1(dst_row, dst_stride,
+ src_row, src_stride,
+ src_width, src_height);
+}
diff --git a/mesalib/src/mesa/main/texcompress_etc.h b/mesalib/src/mesa/main/texcompress_etc.h
index 411e1540d..5e086d4e7 100644
--- a/mesalib/src/mesa/main/texcompress_etc.h
+++ b/mesalib/src/mesa/main/texcompress_etc.h
@@ -34,16 +34,93 @@ struct swrast_texture_image;
GLboolean
_mesa_texstore_etc1_rgb8(TEXSTORE_PARAMS);
+GLboolean
+_mesa_texstore_etc2_rgb8(TEXSTORE_PARAMS);
+
+GLboolean
+_mesa_texstore_etc2_srgb8(TEXSTORE_PARAMS);
+
+GLboolean
+_mesa_texstore_etc2_rgba8_eac(TEXSTORE_PARAMS);
+
+GLboolean
+_mesa_texstore_etc2_srgb8_alpha8_eac(TEXSTORE_PARAMS);
+
+GLboolean
+_mesa_texstore_etc2_r11_eac(TEXSTORE_PARAMS);
+
+GLboolean
+_mesa_texstore_etc2_rg11_eac(TEXSTORE_PARAMS);
+
+GLboolean
+_mesa_texstore_etc2_signed_r11_eac(TEXSTORE_PARAMS);
+
+GLboolean
+_mesa_texstore_etc2_signed_rg11_eac(TEXSTORE_PARAMS);
+
+GLboolean
+_mesa_texstore_etc2_rgb8_punchthrough_alpha1(TEXSTORE_PARAMS);
+
+GLboolean
+_mesa_texstore_etc2_srgb8_punchthrough_alpha1(TEXSTORE_PARAMS);
+
void
_mesa_fetch_texel_2d_f_etc1_rgb8(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel);
+void
+_mesa_fetch_texel_2d_f_etc2_rgb8(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
+void
+_mesa_fetch_texel_2d_f_etc2_srgb8(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
void
+_mesa_fetch_texel_2d_f_etc2_rgba8_eac(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
+void
+_mesa_fetch_texel_2d_f_etc2_srgb8_alpha8_eac(const struct
+ swrast_texture_image *texImage,
+ GLint i, GLint j,
+ GLint k, GLfloat *texel);
+void
+_mesa_fetch_texel_2d_f_etc2_r11_eac(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
+void
+_mesa_fetch_texel_2d_f_etc2_rg11_eac(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
+void
+_mesa_fetch_texel_2d_f_etc2_signed_r11_eac(const struct
+ swrast_texture_image *texImage,
+ GLint i, GLint j,
+ GLint k, GLfloat *texel);
+void
+_mesa_fetch_texel_2d_f_etc2_signed_rg11_eac(const struct
+ swrast_texture_image *texImage,
+ GLint i, GLint j,
+ GLint k, GLfloat *texel);
+void
+_mesa_fetch_texel_2d_f_etc2_rgb8_punchthrough_alpha1(
+ const struct swrast_texture_image *texImage,
+ GLint i, GLint j,
+ GLint k, GLfloat *texel);
+void
+_mesa_fetch_texel_2d_f_etc2_srgb8_punchthrough_alpha1(
+ const struct swrast_texture_image *texImage,
+ GLint i, GLint j,
+ GLint k, GLfloat *texel);
+void
_mesa_etc1_unpack_rgba8888(uint8_t *dst_row,
unsigned dst_stride,
const uint8_t *src_row,
unsigned src_stride,
unsigned src_width,
unsigned src_height);
-
+void
+_mesa_unpack_etc2_format(uint8_t *dst_row,
+ unsigned dst_stride,
+ const uint8_t *src_row,
+ unsigned src_stride,
+ unsigned src_width,
+ unsigned src_height,
+ gl_format format);
#endif
diff --git a/mesalib/src/mesa/main/texcompress_s3tc.c b/mesalib/src/mesa/main/texcompress_s3tc.c
index da7725964..476b998e0 100644
--- a/mesalib/src/mesa/main/texcompress_s3tc.c
+++ b/mesalib/src/mesa/main/texcompress_s3tc.c
@@ -45,6 +45,7 @@
#include "texcompress_s3tc.h"
#include "texstore.h"
#include "swrast/s_context.h"
+#include "format_unpack.h"
#if defined(_WIN32) || defined(WIN32)
@@ -57,33 +58,6 @@
#define DXTN_LIBNAME "libtxc_dxtn.so"
#endif
-/**
- * Convert an 8-bit sRGB value from non-linear space to a
- * linear RGB value in [0, 1].
- * Implemented with a 256-entry lookup table.
- */
-static inline GLfloat
-nonlinear_to_linear(GLubyte cs8)
-{
- static GLfloat table[256];
- static GLboolean tableReady = GL_FALSE;
- if (!tableReady) {
- /* compute lookup table now */
- GLuint i;
- for (i = 0; i < 256; i++) {
- const GLfloat cs = UBYTE_TO_FLOAT(i);
- if (cs <= 0.04045) {
- table[i] = cs / 12.92f;
- }
- else {
- table[i] = (GLfloat) pow((cs + 0.055) / 1.055, 2.4);
- }
- }
- tableReady = GL_TRUE;
- }
- return table[cs8];
-}
-
typedef void (*dxtFetchTexelFuncExt)( GLint srcRowstride, GLubyte *pixdata, GLint col, GLint row, GLvoid *texelOut );
static dxtFetchTexelFuncExt fetch_ext_rgb_dxt1 = NULL;
@@ -476,9 +450,9 @@ _mesa_fetch_texel_srgb_dxt1(const struct swrast_texture_image *texImage,
/* just sample as GLubyte and convert to float here */
GLubyte rgba[4];
fetch_texel_2d_rgb_dxt1(texImage, i, j, k, rgba);
- texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]);
- texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]);
- texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]);
+ texel[RCOMP] = _mesa_nonlinear_to_linear(rgba[RCOMP]);
+ texel[GCOMP] = _mesa_nonlinear_to_linear(rgba[GCOMP]);
+ texel[BCOMP] = _mesa_nonlinear_to_linear(rgba[BCOMP]);
texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
}
@@ -489,9 +463,9 @@ _mesa_fetch_texel_srgba_dxt1(const struct swrast_texture_image *texImage,
/* just sample as GLubyte and convert to float here */
GLubyte rgba[4];
fetch_texel_2d_rgba_dxt1(texImage, i, j, k, rgba);
- texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]);
- texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]);
- texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]);
+ texel[RCOMP] = _mesa_nonlinear_to_linear(rgba[RCOMP]);
+ texel[GCOMP] = _mesa_nonlinear_to_linear(rgba[GCOMP]);
+ texel[BCOMP] = _mesa_nonlinear_to_linear(rgba[BCOMP]);
texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
}
@@ -502,9 +476,9 @@ _mesa_fetch_texel_srgba_dxt3(const struct swrast_texture_image *texImage,
/* just sample as GLubyte and convert to float here */
GLubyte rgba[4];
fetch_texel_2d_rgba_dxt3(texImage, i, j, k, rgba);
- texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]);
- texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]);
- texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]);
+ texel[RCOMP] = _mesa_nonlinear_to_linear(rgba[RCOMP]);
+ texel[GCOMP] = _mesa_nonlinear_to_linear(rgba[GCOMP]);
+ texel[BCOMP] = _mesa_nonlinear_to_linear(rgba[BCOMP]);
texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
}
@@ -515,8 +489,8 @@ _mesa_fetch_texel_srgba_dxt5(const struct swrast_texture_image *texImage,
/* just sample as GLubyte and convert to float here */
GLubyte rgba[4];
fetch_texel_2d_rgba_dxt5(texImage, i, j, k, rgba);
- texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]);
- texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]);
- texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]);
+ texel[RCOMP] = _mesa_nonlinear_to_linear(rgba[RCOMP]);
+ texel[GCOMP] = _mesa_nonlinear_to_linear(rgba[GCOMP]);
+ texel[BCOMP] = _mesa_nonlinear_to_linear(rgba[BCOMP]);
texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
}
diff --git a/mesalib/src/mesa/main/texformat.c b/mesalib/src/mesa/main/texformat.c
index f0bc7fdb9..b3ffc6c51 100644
--- a/mesalib/src/mesa/main/texformat.c
+++ b/mesalib/src/mesa/main/texformat.c
@@ -972,6 +972,43 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
}
}
+ if (_mesa_is_gles3(ctx)) {
+ switch (internalFormat) {
+ case GL_COMPRESSED_RGB8_ETC2:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_ETC2_RGB8);
+ break;
+ case GL_COMPRESSED_SRGB8_ETC2:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_ETC2_SRGB8);
+ break;
+ case GL_COMPRESSED_RGBA8_ETC2_EAC:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_ETC2_RGBA8_EAC);
+ break;
+ case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC);
+ break;
+ case GL_COMPRESSED_R11_EAC:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_ETC2_R11_EAC);
+ break;
+ case GL_COMPRESSED_RG11_EAC:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_ETC2_RG11_EAC);
+ break;
+ case GL_COMPRESSED_SIGNED_R11_EAC:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_ETC2_SIGNED_R11_EAC);
+ break;
+ case GL_COMPRESSED_SIGNED_RG11_EAC:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_ETC2_SIGNED_RG11_EAC);
+ break;
+ case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1);
+ break;
+ case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1);
+ break;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
_mesa_problem(ctx, "unexpected format %s in _mesa_choose_tex_format()",
_mesa_lookup_enum_by_nr(internalFormat));
return MESA_FORMAT_NONE;
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c
index a720c38b8..83b7e1488 100644
--- a/mesalib/src/mesa/main/teximage.c
+++ b/mesalib/src/mesa/main/teximage.c
@@ -529,6 +529,27 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
}
}
+ if (_mesa_is_gles3(ctx)) {
+ switch (internalFormat) {
+ case GL_COMPRESSED_RGB8_ETC2:
+ case GL_COMPRESSED_SRGB8_ETC2:
+ return GL_RGB;
+ case GL_COMPRESSED_RGBA8_ETC2_EAC:
+ case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
+ case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+ case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+ return GL_RGBA;
+ case GL_COMPRESSED_R11_EAC:
+ case GL_COMPRESSED_SIGNED_R11_EAC:
+ return GL_RED;
+ case GL_COMPRESSED_RG11_EAC:
+ case GL_COMPRESSED_SIGNED_RG11_EAC:
+ return GL_RG;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
if (ctx->API == API_OPENGLES) {
switch (internalFormat) {
case GL_PALETTE4_RGB8_OES:
diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c
index 1c088106f..26c5b6703 100644
--- a/mesalib/src/mesa/main/texstore.c
+++ b/mesalib/src/mesa/main/texstore.c
@@ -4124,6 +4124,18 @@ _mesa_get_texstore_func(gl_format format)
table[MESA_FORMAT_LA_LATC2] = _mesa_texstore_rg_rgtc2;
table[MESA_FORMAT_SIGNED_LA_LATC2] = _mesa_texstore_signed_rg_rgtc2;
table[MESA_FORMAT_ETC1_RGB8] = _mesa_texstore_etc1_rgb8;
+ table[MESA_FORMAT_ETC2_RGB8] = _mesa_texstore_etc2_rgb8;
+ table[MESA_FORMAT_ETC2_SRGB8] = _mesa_texstore_etc2_srgb8;
+ table[MESA_FORMAT_ETC2_RGBA8_EAC] = _mesa_texstore_etc2_rgba8_eac;
+ table[MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC] = _mesa_texstore_etc2_srgb8_alpha8_eac;
+ table[MESA_FORMAT_ETC2_R11_EAC] = _mesa_texstore_etc2_r11_eac;
+ table[MESA_FORMAT_ETC2_RG11_EAC] = _mesa_texstore_etc2_rg11_eac;
+ table[MESA_FORMAT_ETC2_SIGNED_R11_EAC] = _mesa_texstore_etc2_signed_r11_eac;
+ table[MESA_FORMAT_ETC2_SIGNED_RG11_EAC] = _mesa_texstore_etc2_signed_rg11_eac;
+ table[MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1] =
+ _mesa_texstore_etc2_rgb8_punchthrough_alpha1;
+ table[MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1] =
+ _mesa_texstore_etc2_srgb8_punchthrough_alpha1;
table[MESA_FORMAT_SIGNED_A8] = _mesa_texstore_snorm8;
table[MESA_FORMAT_SIGNED_L8] = _mesa_texstore_snorm8;
table[MESA_FORMAT_SIGNED_AL88] = _mesa_texstore_snorm88;
diff --git a/mesalib/src/mesa/program/Android.mk b/mesalib/src/mesa/program/Android.mk
index 712506129..51362e0eb 100644
--- a/mesalib/src/mesa/program/Android.mk
+++ b/mesalib/src/mesa/program/Android.mk
@@ -65,6 +65,9 @@ LOCAL_GENERATED_SOURCES := \
$(intermediates)/program/program_parse.tab.c: $(LOCAL_PATH)/program_parse.y
$(mesa_local-y-to-c-and-h)
+$(intermediates)/program/program_parse.tab.h: $(intermediates)/program/program_parse.tab.c
+ @
+
$(intermediates)/program/lex.yy.c: $(LOCAL_PATH)/program_lexer.l
$(local-l-to-c)
diff --git a/mesalib/src/mesa/program/hash_table.c b/mesalib/src/mesa/program/prog_hash_table.c
index f45ed46af..f45ed46af 100644
--- a/mesalib/src/mesa/program/hash_table.c
+++ b/mesalib/src/mesa/program/prog_hash_table.c
diff --git a/mesalib/src/mesa/sources.mak b/mesalib/src/mesa/sources.mak
index 54e58c21b..8cde2c4cf 100644
--- a/mesalib/src/mesa/sources.mak
+++ b/mesalib/src/mesa/sources.mak
@@ -76,6 +76,7 @@ MAIN_FILES = \
$(SRCDIR)main/renderbuffer.c \
$(SRCDIR)main/samplerobj.c \
$(SRCDIR)main/scissor.c \
+ $(SRCDIR)main/set.c \
$(SRCDIR)main/shaderapi.c \
$(SRCDIR)main/shaderobj.c \
$(SRCDIR)main/shader_query.cpp \
@@ -247,7 +248,7 @@ STATETRACKER_FILES = \
PROGRAM_FILES = \
$(SRCDIR)program/arbprogparse.c \
- $(SRCDIR)program/hash_table.c \
+ $(SRCDIR)program/prog_hash_table.c \
$(SRCDIR)program/ir_to_mesa.cpp \
$(SRCDIR)program/program.c \
$(SRCDIR)program/program_parse_extra.c \
diff --git a/mesalib/src/mesa/state_tracker/st_atom.c b/mesalib/src/mesa/state_tracker/st_atom.c
index 102fee93b..32bcc266a 100644
--- a/mesalib/src/mesa/state_tracker/st_atom.c
+++ b/mesalib/src/mesa/state_tracker/st_atom.c
@@ -64,6 +64,8 @@ static const struct st_tracked_state *atoms[] =
&st_update_vs_constants,
&st_update_gs_constants,
&st_update_fs_constants,
+ &st_bind_vs_ubos,
+ &st_bind_fs_ubos,
&st_update_pixel_transfer,
/* this must be done after the vertex program update */
diff --git a/mesalib/src/mesa/state_tracker/st_atom.h b/mesalib/src/mesa/state_tracker/st_atom.h
index 6c7d09fba..101a3a6bd 100644
--- a/mesalib/src/mesa/state_tracker/st_atom.h
+++ b/mesalib/src/mesa/state_tracker/st_atom.h
@@ -67,6 +67,8 @@ extern const struct st_tracked_state st_finalize_textures;
extern const struct st_tracked_state st_update_fs_constants;
extern const struct st_tracked_state st_update_gs_constants;
extern const struct st_tracked_state st_update_vs_constants;
+extern const struct st_tracked_state st_bind_fs_ubos;
+extern const struct st_tracked_state st_bind_vs_ubos;
extern const struct st_tracked_state st_update_pixel_transfer;
diff --git a/mesalib/src/mesa/state_tracker/st_atom_constbuf.c b/mesalib/src/mesa/state_tracker/st_atom_constbuf.c
index 580393e60..961fb28a9 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_constbuf.c
@@ -45,7 +45,7 @@
#include "st_atom.h"
#include "st_atom_constbuf.h"
#include "st_program.h"
-
+#include "st_cb_bufferobjects.h"
/**
* Pass the given program parameters to the graphics pipe as a
@@ -175,3 +175,69 @@ const struct st_tracked_state st_update_gs_constants = {
},
update_gs_constants /* update */
};
+
+static void st_bind_ubos(struct st_context *st,
+ struct gl_shader *shader,
+ unsigned shader_type)
+{
+ unsigned i;
+ struct pipe_constant_buffer cb = { 0 };
+
+ if (!shader)
+ return;
+
+ for (i = 0; i < shader->NumUniformBlocks; i++) {
+ struct gl_uniform_buffer_binding *binding;
+ struct st_buffer_object *st_obj;
+
+ binding = &st->ctx->UniformBufferBindings[shader->UniformBlocks[i].Binding];
+ st_obj = st_buffer_object(binding->BufferObject);
+ pipe_resource_reference(&cb.buffer, st_obj->buffer);
+
+ cb.buffer_size = st_obj->buffer->width0 - binding->Offset;
+
+ st->pipe->set_constant_buffer(st->pipe, shader_type, 1 + i, &cb);
+ pipe_resource_reference(&cb.buffer, NULL);
+ }
+}
+
+static void bind_vs_ubos(struct st_context *st)
+{
+ struct gl_shader_program *prog = st->ctx->Shader.CurrentVertexProgram;
+
+ if (!prog)
+ return;
+
+ st_bind_ubos(st, prog->_LinkedShaders[MESA_SHADER_VERTEX], PIPE_SHADER_VERTEX);
+}
+
+const struct st_tracked_state st_bind_vs_ubos = {
+ "st_bind_vs_ubos",
+ {
+ (_NEW_PROGRAM | _NEW_BUFFER_OBJECT),
+ ST_NEW_VERTEX_PROGRAM,
+ },
+ bind_vs_ubos
+};
+
+static void bind_fs_ubos(struct st_context *st)
+{
+ struct gl_shader_program *prog = st->ctx->Shader.CurrentFragmentProgram;
+
+ if (!prog)
+ return;
+
+ st_bind_ubos(st, prog->_LinkedShaders[MESA_SHADER_FRAGMENT], PIPE_SHADER_FRAGMENT);
+
+}
+
+const struct st_tracked_state st_bind_fs_ubos = {
+ "st_bind_fs_ubos",
+ {
+ (_NEW_PROGRAM | _NEW_BUFFER_OBJECT),
+ ST_NEW_FRAGMENT_PROGRAM,
+ },
+ bind_fs_ubos
+};
+
+
diff --git a/mesalib/src/mesa/state_tracker/st_atom_texture.c b/mesalib/src/mesa/state_tracker/st_atom_texture.c
index df05e83c2..dba1d829c 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_texture.c
@@ -215,13 +215,19 @@ update_single_texture(struct st_context *st,
/* Determine the format of the texture sampler view */
st_view_format = stObj->pt->format;
- {
- const struct st_texture_image *firstImage =
- st_texture_image(stObj->base.Image[0][stObj->base.BaseLevel]);
- const gl_format texFormat = firstImage->base.TexFormat;
- enum pipe_format firstImageFormat =
- st_mesa_format_to_pipe_format(texFormat);
+ {
+ gl_format texFormat;
+ enum pipe_format firstImageFormat;
+
+ if (texObj->Target == GL_TEXTURE_BUFFER) {
+ texFormat = stObj->base._BufferObjectFormat;
+ } else {
+ const struct st_texture_image *firstImage =
+ st_texture_image(stObj->base.Image[0][stObj->base.BaseLevel]);
+ texFormat = firstImage->base.TexFormat;
+ }
+ firstImageFormat = st_mesa_format_to_pipe_format(texFormat);
if ((samp->sRGBDecode == GL_SKIP_DECODE_EXT) &&
(_mesa_get_format_color_encoding(texFormat) == GL_SRGB)) {
/* Don't do sRGB->RGB conversion. Interpret the texture data as
diff --git a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
index ac38128df..cf291c1c1 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -195,9 +195,15 @@ st_bufferobj_data(struct gl_context *ctx,
case GL_ELEMENT_ARRAY_BUFFER_ARB:
bind = PIPE_BIND_INDEX_BUFFER;
break;
+ case GL_TEXTURE_BUFFER:
+ bind = PIPE_BIND_SAMPLER_VIEW;
+ break;
case GL_TRANSFORM_FEEDBACK_BUFFER:
bind = PIPE_BIND_STREAM_OUTPUT;
break;
+ case GL_UNIFORM_BUFFER:
+ bind = PIPE_BIND_CONSTANT_BUFFER;
+ break;
default:
bind = 0;
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c
index f06814f9c..ae069eb2c 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c
@@ -48,6 +48,7 @@
#include "state_tracker/st_cb_fbo.h"
#include "state_tracker/st_cb_flush.h"
#include "state_tracker/st_cb_texture.h"
+#include "state_tracker/st_cb_bufferobjects.h"
#include "state_tracker/st_format.h"
#include "state_tracker/st_texture.h"
#include "state_tracker/st_gen_mipmap.h"
@@ -59,6 +60,7 @@
#include "pipe/p_shader_tokens.h"
#include "util/u_tile.h"
#include "util/u_blit.h"
+#include "util/u_blitter.h"
#include "util/u_format.h"
#include "util/u_surface.h"
#include "util/u_sampler.h"
@@ -922,12 +924,12 @@ st_CopyTexSubImage(struct gl_context *ctx, GLuint dims,
struct pipe_context *pipe = st->pipe;
struct pipe_screen *screen = pipe->screen;
enum pipe_format dest_format, src_format;
- GLboolean matching_base_formats;
- GLuint color_writemask, zs_writemask, sample_count;
+ GLuint color_writemask;
struct pipe_surface *dest_surface = NULL;
GLboolean do_flip = (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP);
struct pipe_surface surf_tmpl;
- unsigned int dst_usage;
+ unsigned dst_usage;
+ unsigned blit_mask;
GLint srcY0, srcY1;
/* make sure finalize_textures has been called?
@@ -939,12 +941,6 @@ st_CopyTexSubImage(struct gl_context *ctx, GLuint dims,
return;
}
- sample_count = strb->surface->texture->nr_samples;
- /* I believe this would be legal, presumably would need to do a resolve
- for color, and for depth/stencil spec says to just use one of the
- depth/stencil samples per pixel? Need some transfer clarifications. */
- assert(sample_count < 2);
-
assert(strb);
assert(strb->surface);
assert(stImage->pt);
@@ -952,22 +948,24 @@ st_CopyTexSubImage(struct gl_context *ctx, GLuint dims,
src_format = strb->surface->format;
dest_format = stImage->pt->format;
- /*
- * Determine if the src framebuffer and dest texture have the same
- * base format. We need this to detect a case such as the framebuffer
- * being GL_RGBA but the texture being GL_RGB. If the actual hardware
- * texture format stores RGBA we need to set A=1 (overriding the
- * framebuffer's alpha values). We can't do that with the blit or
- * textured-quad paths.
- */
- matching_base_formats =
- (_mesa_get_format_base_format(strb->Base.Format) ==
- _mesa_get_format_base_format(texImage->TexFormat));
+ if (do_flip) {
+ srcY1 = strb->Base.Height - srcY - height;
+ srcY0 = srcY1 + height;
+ }
+ else {
+ srcY0 = srcY;
+ srcY1 = srcY0 + height;
+ }
if (ctx->_ImageTransferState) {
goto fallback;
}
+ /* Compressed and subsampled textures aren't supported for blitting. */
+ if (!util_format_is_plain(dest_format)) {
+ goto fallback;
+ }
+
if (texImage->TexObject->Target == GL_TEXTURE_1D_ARRAY) {
/* 1D arrays might be thought of as 2D images but the actual layout
* might not be that way. At some points, we convert OpenGL's 1D
@@ -978,53 +976,112 @@ st_CopyTexSubImage(struct gl_context *ctx, GLuint dims,
goto fallback;
}
- if (matching_base_formats &&
- src_format == dest_format &&
- !do_flip) {
- /* use surface_copy() / blit */
- struct pipe_box src_box;
- unsigned dstLevel;
+ /* Set the blit writemask. */
+ switch (texBaseFormat) {
+ case GL_DEPTH_STENCIL:
+ switch (strb->Base._BaseFormat) {
+ case GL_DEPTH_STENCIL:
+ blit_mask = PIPE_MASK_ZS;
+ break;
+ case GL_DEPTH_COMPONENT:
+ blit_mask = PIPE_MASK_Z;
+ break;
+ case GL_STENCIL_INDEX:
+ blit_mask = PIPE_MASK_S;
+ break;
+ default:
+ assert(0);
+ return;
+ }
+ dst_usage = PIPE_BIND_DEPTH_STENCIL;
+ break;
+
+ case GL_DEPTH_COMPONENT:
+ blit_mask = PIPE_MASK_Z;
+ dst_usage = PIPE_BIND_DEPTH_STENCIL;
+ break;
- u_box_2d_zslice(srcX, srcY, strb->surface->u.tex.first_layer,
- width, height, &src_box);
+ default:
+ /* Colorbuffers.
+ *
+ * Determine if the src framebuffer and dest texture have the same
+ * base format. We need this to detect a case such as the framebuffer
+ * being GL_RGBA but the texture being GL_RGB. If the actual hardware
+ * texture format stores RGBA we need to set A=1 (overriding the
+ * framebuffer's alpha values).
+ *
+ * XXX util_blit_pixels doesn't support MSAA resolve, so always use
+ * pipe->blit
+ */
+ if (texBaseFormat == strb->Base._BaseFormat ||
+ strb->texture->nr_samples > 1) {
+ blit_mask = PIPE_MASK_RGBA;
+ }
+ else {
+ blit_mask = 0;
+ }
+ dst_usage = PIPE_BIND_RENDER_TARGET;
+ }
+ /* Blit the texture.
+ * This supports flipping, format conversions, and downsampling.
+ */
+ if (blit_mask) {
/* If stImage->pt is an independent image (not a pointer into a full
* mipmap) stImage->pt.last_level will be zero and we need to use that
* as the dest level.
*/
- dstLevel = MIN2(stImage->base.Level, stImage->pt->last_level);
-
- /* for resource_copy_region(), y=0=top, always */
- pipe->resource_copy_region(pipe,
- /* dest */
- stImage->pt,
- dstLevel,
- destX, destY, destZ + stImage->base.Face,
- /* src */
- strb->texture,
- strb->surface->u.tex.level,
- &src_box);
- return;
- }
+ unsigned dstLevel = MIN2(stImage->base.Level, stImage->pt->last_level);
+ struct pipe_blit_info blit;
+
+ memset(&blit, 0, sizeof(blit));
+ blit.src.resource = strb->texture;
+ blit.src.format = src_format;
+ blit.src.level = strb->surface->u.tex.level;
+ blit.src.box.x = srcX;
+ blit.src.box.y = srcY0;
+ blit.src.box.z = strb->surface->u.tex.first_layer;
+ blit.src.box.width = width;
+ blit.src.box.height = srcY1 - srcY0;
+ blit.src.box.depth = 1;
+ blit.dst.resource = stImage->pt;
+ blit.dst.format = dest_format;
+ blit.dst.level = dstLevel;
+ blit.dst.box.x = destX;
+ blit.dst.box.y = destY;
+ blit.dst.box.z = stImage->base.Face + destZ;
+ blit.dst.box.width = width;
+ blit.dst.box.height = height;
+ blit.dst.box.depth = 1;
+ blit.mask = blit_mask;
+ blit.filter = PIPE_TEX_FILTER_NEAREST;
+
+ /* try resource_copy_region in case the format is not supported
+ * for rendering */
+ if (util_try_blit_via_copy_region(pipe, &blit)) {
+ return; /* done */
+ }
- if (texBaseFormat == GL_DEPTH_STENCIL) {
- goto fallback;
- }
+ /* check the format support */
+ if (!screen->is_format_supported(screen, src_format,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_SAMPLER_VIEW) ||
+ !screen->is_format_supported(screen, dest_format,
+ PIPE_TEXTURE_2D, 0,
+ dst_usage)) {
+ goto fallback;
+ }
- if (texBaseFormat == GL_DEPTH_COMPONENT) {
- color_writemask = 0;
- zs_writemask = BLIT_WRITEMASK_Z;
- dst_usage = PIPE_BIND_DEPTH_STENCIL;
- }
- else {
- color_writemask = compatible_src_dst_formats(ctx, &strb->Base, texImage);
- zs_writemask = 0;
- dst_usage = PIPE_BIND_RENDER_TARGET;
+ pipe->blit(pipe, &blit);
+ return;
}
- if ((!color_writemask && !zs_writemask) ||
+ /* try u_blit */
+ color_writemask = compatible_src_dst_formats(ctx, &strb->Base, texImage);
+
+ if (!color_writemask ||
!screen->is_format_supported(screen, src_format,
- PIPE_TEXTURE_2D, sample_count,
+ PIPE_TEXTURE_2D, 0,
PIPE_BIND_SAMPLER_VIEW) ||
!screen->is_format_supported(screen, dest_format,
PIPE_TEXTURE_2D, 0,
@@ -1032,15 +1089,6 @@ st_CopyTexSubImage(struct gl_context *ctx, GLuint dims,
goto fallback;
}
- if (do_flip) {
- srcY1 = strb->Base.Height - srcY - height;
- srcY0 = srcY1 + height;
- }
- else {
- srcY0 = srcY;
- srcY1 = srcY0 + height;
- }
-
/* Disable conditional rendering. */
if (st->render_condition) {
pipe->render_condition(pipe, NULL, 0);
@@ -1065,7 +1113,7 @@ st_CopyTexSubImage(struct gl_context *ctx, GLuint dims,
destX, destY,
destX + width, destY + height,
0.0, PIPE_TEX_MIPFILTER_NEAREST,
- color_writemask, zs_writemask);
+ color_writemask, 0);
pipe_surface_reference(&dest_surface, NULL);
/* Restore conditional rendering state. */
@@ -1182,6 +1230,20 @@ st_finalize_texture(struct gl_context *ctx,
stObj->lastLevel = stObj->base._MaxLevel;
}
+ if (tObj->Target == GL_TEXTURE_BUFFER) {
+ struct st_buffer_object *st_obj = st_buffer_object(tObj->BufferObject);
+
+ if (st_obj->buffer != stObj->pt) {
+ pipe_resource_reference(&stObj->pt, st_obj->buffer);
+ pipe_sampler_view_release(st->pipe, &stObj->sampler_view);
+ stObj->width0 = stObj->pt->width0 / _mesa_get_format_bytes(tObj->_BufferObjectFormat);
+ stObj->height0 = 1;
+ stObj->depth0 = 1;
+ }
+ return GL_TRUE;
+
+ }
+
firstImage = st_texture_image(stObj->base.Image[0][stObj->base.BaseLevel]);
assert(firstImage);
diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index 62a736bb6..93ef7a91c 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -70,6 +70,8 @@ void st_init_limits(struct st_context *st)
struct pipe_screen *screen = st->pipe->screen;
struct gl_constants *c = &st->ctx->Const;
gl_shader_type sh;
+ boolean can_ubo = TRUE;
+ int max_const_buffers;
c->MaxTextureLevels
= _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS),
@@ -218,6 +220,17 @@ void st_init_limits(struct st_context *st)
options->EmitNoIndirectUniform = !screen->get_shader_param(screen, sh,
PIPE_SHADER_CAP_INDIRECT_CONST_ADDR);
+ if (pc->MaxNativeInstructions) {
+ if (options->EmitNoIndirectUniform)
+ can_ubo = FALSE;
+
+ max_const_buffers = screen->get_shader_param(screen, sh,
+ PIPE_SHADER_CAP_MAX_CONST_BUFFERS);
+ /* we need 13 buffers - 1 constant, 12 UBO */
+ if (max_const_buffers < 13)
+ can_ubo = FALSE;
+ }
+
if (options->EmitNoLoops)
options->MaxUnrollIterations = MIN2(screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INSTRUCTIONS), 65536);
else
@@ -251,6 +264,9 @@ void st_init_limits(struct st_context *st)
c->GLSLSkipStrictMaxVaryingLimitCheck =
screen->get_param(screen, PIPE_CAP_TGSI_CAN_COMPACT_VARYINGS);
+
+ if (can_ubo)
+ st->ctx->Extensions.ARB_uniform_buffer_object = GL_TRUE;
}
@@ -553,7 +569,12 @@ void st_init_extensions(struct st_context *st)
/* Figure out GLSL support. */
glsl_feature_level = screen->get_param(screen, PIPE_CAP_GLSL_FEATURE_LEVEL);
- if (glsl_feature_level >= 130) {
+ if (glsl_feature_level >= 140) {
+ if (ctx->API == API_OPENGL_CORE)
+ ctx->Const.GLSLVersion = 140;
+ else
+ ctx->Const.GLSLVersion = 130;
+ } else if (glsl_feature_level >= 130) {
ctx->Const.GLSLVersion = 130;
} else {
ctx->Const.GLSLVersion = 120;
@@ -643,4 +664,6 @@ void st_init_extensions(struct st_context *st)
if (ctx->Const.MinMapBufferAlignment >= 64) {
ctx->Extensions.ARB_map_buffer_alignment = GL_TRUE;
}
+ if (screen->get_param(screen, PIPE_CAP_TEXTURE_BUFFER_OBJECTS))
+ ctx->Extensions.ARB_texture_buffer_object = GL_TRUE;
}
diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index c030a6b37..a4df4e5fa 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -107,6 +107,7 @@ public:
else
this->swizzle = SWIZZLE_XYZW;
this->negate = 0;
+ this->index2D = 0;
this->type = type ? type->base_type : GLSL_TYPE_ERROR;
this->reladdr = NULL;
}
@@ -116,6 +117,18 @@ public:
this->type = type;
this->file = file;
this->index = index;
+ this->index2D = 0;
+ this->swizzle = SWIZZLE_XYZW;
+ this->negate = 0;
+ this->reladdr = NULL;
+ }
+
+ st_src_reg(gl_register_file file, int index, int type, int index2D)
+ {
+ this->type = type;
+ this->file = file;
+ this->index = index;
+ this->index2D = index2D;
this->swizzle = SWIZZLE_XYZW;
this->negate = 0;
this->reladdr = NULL;
@@ -126,6 +139,7 @@ public:
this->type = GLSL_TYPE_ERROR;
this->file = PROGRAM_UNDEFINED;
this->index = 0;
+ this->index2D = 0;
this->swizzle = 0;
this->negate = 0;
this->reladdr = NULL;
@@ -135,6 +149,7 @@ public:
gl_register_file file; /**< PROGRAM_* from Mesa */
int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */
+ int index2D;
GLuint swizzle; /**< SWIZZLE_XYZWONEZERO swizzles from Mesa. */
int negate; /**< NEGATE_XYZW mask from mesa */
int type; /** GLSL_TYPE_* from GLSL IR (enum glsl_base_type) */
@@ -183,6 +198,7 @@ st_src_reg::st_src_reg(st_dst_reg reg)
this->swizzle = SWIZZLE_XYZW;
this->negate = 0;
this->reladdr = reg.reladdr;
+ this->index2D = 0;
}
st_dst_reg::st_dst_reg(st_src_reg reg)
@@ -1873,10 +1889,46 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
assert(!"GLSL 1.30 features unsupported");
break;
- case ir_binop_ubo_load:
- assert(!"not yet supported");
- break;
+ case ir_binop_ubo_load: {
+ ir_constant *uniform_block = ir->operands[0]->as_constant();
+ ir_constant *const_offset_ir = ir->operands[1]->as_constant();
+ unsigned const_offset = const_offset_ir ? const_offset_ir->value.u[0] : 0;
+ st_src_reg index_reg = get_temp(glsl_type::uint_type);
+ st_src_reg cbuf;
+
+ cbuf.type = glsl_type::vec4_type->base_type;
+ cbuf.file = PROGRAM_CONSTANT;
+ cbuf.index = 0;
+ cbuf.index2D = uniform_block->value.u[0] + 1;
+ cbuf.reladdr = NULL;
+ cbuf.negate = 0;
+
+ assert(ir->type->is_vector() || ir->type->is_scalar());
+
+ if (const_offset_ir) {
+ index_reg = st_src_reg_for_int(const_offset / 16);
+ } else {
+ emit(ir, TGSI_OPCODE_USHR, st_dst_reg(index_reg), op[1], st_src_reg_for_int(4));
+ }
+ cbuf.swizzle = swizzle_for_size(ir->type->vector_elements);
+ cbuf.swizzle += MAKE_SWIZZLE4(const_offset % 16 / 4,
+ const_offset % 16 / 4,
+ const_offset % 16 / 4,
+ const_offset % 16 / 4);
+
+ cbuf.reladdr = ralloc(mem_ctx, st_src_reg);
+ memcpy(cbuf.reladdr, &index_reg, sizeof(index_reg));
+
+ if (ir->type->base_type == GLSL_TYPE_BOOL) {
+ emit(ir, TGSI_OPCODE_USNE, result_dst, cbuf, st_src_reg_for_int(0));
+ result_src.negate = 1;
+ emit(ir, TGSI_OPCODE_UCMP, result_dst, result_src, st_src_reg_for_int(~0), st_src_reg_for_int(0));
+ } else {
+ emit(ir, TGSI_OPCODE_MOV, result_dst, cbuf);
+ }
+ break;
+ }
case ir_quadop_vector:
/* This operation should have already been handled.
*/
@@ -2776,7 +2828,7 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
inst->tex_target = TEXTURE_RECT_INDEX;
break;
case GLSL_SAMPLER_DIM_BUF:
- assert(!"FINISHME: Implement ARB_texture_buffer_object");
+ inst->tex_target = TEXTURE_BUFFER_INDEX;
break;
case GLSL_SAMPLER_DIM_EXTERNAL:
inst->tex_target = TEXTURE_EXTERNAL_INDEX;
@@ -4061,7 +4113,7 @@ dst_register(struct st_translate *t,
static struct ureg_src
src_register(struct st_translate *t,
gl_register_file file,
- GLint index)
+ GLint index, GLint index2D)
{
switch(file) {
case PROGRAM_UNDEFINED:
@@ -4081,7 +4133,13 @@ src_register(struct st_translate *t,
return t->constants[index];
case PROGRAM_STATE_VAR:
case PROGRAM_CONSTANT: /* ie, immediate */
- if (index < 0)
+ if (index2D) {
+ struct ureg_src src;
+ src = ureg_src_register(TGSI_FILE_CONSTANT, 0);
+ src.Dimension = 1;
+ src.DimensionIndex = index2D;
+ return src;
+ } else if (index < 0)
return ureg_DECL_constant(t->ureg, 0);
else
return t->constants[index];
@@ -4160,7 +4218,7 @@ translate_dst(struct st_translate *t,
static struct ureg_src
translate_src(struct st_translate *t, const st_src_reg *src_reg)
{
- struct ureg_src src = src_register(t, src_reg->file, src_reg->index);
+ struct ureg_src src = src_register(t, src_reg->file, src_reg->index, src_reg->index2D);
src = ureg_swizzle(src,
GET_SWZ(src_reg->swizzle, 0) & 0x3,
@@ -4202,14 +4260,17 @@ translate_tex_offset(struct st_translate *t,
const struct tgsi_texture_offset *in_offset)
{
struct tgsi_texture_offset offset;
+ struct ureg_src imm_src;
assert(in_offset->File == PROGRAM_IMMEDIATE);
+ imm_src = t->immediates[in_offset->Index];
+ offset.File = imm_src.File;
+ offset.Index = imm_src.Index;
+ offset.SwizzleX = imm_src.SwizzleX;
+ offset.SwizzleY = imm_src.SwizzleY;
+ offset.SwizzleZ = imm_src.SwizzleZ;
offset.File = TGSI_FILE_IMMEDIATE;
- offset.Index = in_offset->Index;
- offset.SwizzleX = in_offset->SwizzleX;
- offset.SwizzleY = in_offset->SwizzleY;
- offset.SwizzleZ = in_offset->SwizzleZ;
offset.Padding = 0;
return offset;
@@ -4754,6 +4815,14 @@ st_translate_program(
}
}
}
+
+ if (program->shader_program) {
+ unsigned num_ubos = program->shader_program->NumUniformBlocks;
+
+ for (i = 0; i < num_ubos; i++) {
+ ureg_DECL_constant2D(t->ureg, 0, program->shader_program->UniformBlocks[i].UniformBufferSize / 4, i + 1);
+ }
+ }
/* Emit immediate values.
*/
@@ -5060,6 +5129,8 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
do_mat_op_to_vec(ir);
lower_instructions(ir, what_to_lower);
+ lower_ubo_reference(prog->_LinkedShaders[i], ir);
+
progress = do_lower_jumps(ir, true, true, options->EmitNoMainReturn, options->EmitNoCont, options->EmitNoLoops) || progress;
progress = do_common_optimization(ir, true, true,
@@ -5090,6 +5161,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|| progress;
progress = do_vec_index_to_cond_assign(ir) || progress;
+
} while (progress);
validate_ir_tree(ir);
diff --git a/mesalib/src/mesa/state_tracker/st_manager.c b/mesalib/src/mesa/state_tracker/st_manager.c
index 0b9add95e..b065db0ac 100644
--- a/mesalib/src/mesa/state_tracker/st_manager.c
+++ b/mesalib/src/mesa/state_tracker/st_manager.c
@@ -398,7 +398,7 @@ st_visual_to_context_mode(const struct st_visual *visual,
UTIL_FORMAT_COLORSPACE_RGB, 3);
}
- if (visual->samples) {
+ if (visual->samples > 1) {
mode->sampleBuffers = 1;
mode->samples = visual->samples;
}
@@ -789,7 +789,7 @@ st_manager_flush_frontbuffer(struct st_context *st)
/* never a dummy fb */
assert(&stfb->Base != _mesa_get_incomplete_framebuffer());
- stfb->iface->flush_front(stfb->iface, ST_ATTACHMENT_FRONT_LEFT);
+ stfb->iface->flush_front(&st->iface, stfb->iface, ST_ATTACHMENT_FRONT_LEFT);
}
/**
@@ -899,7 +899,7 @@ static const struct st_api st_gl_api = {
ST_PROFILE_OPENGL_ES2_MASK |
#endif
0,
- 0,
+ ST_API_FEATURE_MS_VISUALS_MASK,
st_api_destroy,
st_api_get_proc_address,
st_api_create_context,
diff --git a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
index 81a870f86..e326bcc70 100644
--- a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -269,6 +269,7 @@ st_translate_texture_target( GLuint textarget,
}
switch( textarget ) {
+ case TEXTURE_BUFFER_INDEX: return TGSI_TEXTURE_BUFFER;
case TEXTURE_1D_INDEX: return TGSI_TEXTURE_1D;
case TEXTURE_2D_INDEX: return TGSI_TEXTURE_2D;
case TEXTURE_3D_INDEX: return TGSI_TEXTURE_3D;
diff --git a/mesalib/src/mesa/swrast/s_texfetch.c b/mesalib/src/mesa/swrast/s_texfetch.c
index 7bfe3b941..86b01a0b3 100644
--- a/mesalib/src/mesa/swrast/s_texfetch.c
+++ b/mesalib/src/mesa/swrast/s_texfetch.c
@@ -1029,6 +1029,66 @@ texfetch_funcs[] =
NULL
},
{
+ MESA_FORMAT_ETC2_RGB8,
+ NULL,
+ _mesa_fetch_texel_2d_f_etc2_rgb8,
+ NULL
+ },
+ {
+ MESA_FORMAT_ETC2_SRGB8,
+ NULL,
+ _mesa_fetch_texel_2d_f_etc2_srgb8,
+ NULL
+ },
+ {
+ MESA_FORMAT_ETC2_RGBA8_EAC,
+ NULL,
+ _mesa_fetch_texel_2d_f_etc2_rgba8_eac,
+ NULL
+ },
+ {
+ MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC,
+ NULL,
+ _mesa_fetch_texel_2d_f_etc2_srgb8_alpha8_eac,
+ NULL
+ },
+ {
+ MESA_FORMAT_ETC2_R11_EAC,
+ NULL,
+ _mesa_fetch_texel_2d_f_etc2_r11_eac,
+ NULL
+ },
+ {
+ MESA_FORMAT_ETC2_RG11_EAC,
+ NULL,
+ _mesa_fetch_texel_2d_f_etc2_rg11_eac,
+ NULL
+ },
+ {
+ MESA_FORMAT_ETC2_SIGNED_R11_EAC,
+ NULL,
+ _mesa_fetch_texel_2d_f_etc2_signed_r11_eac,
+ NULL
+ },
+ {
+ MESA_FORMAT_ETC2_SIGNED_RG11_EAC,
+ NULL,
+ _mesa_fetch_texel_2d_f_etc2_signed_rg11_eac,
+ NULL
+ },
+ {
+ MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1,
+ NULL,
+ _mesa_fetch_texel_2d_f_etc2_rgb8_punchthrough_alpha1,
+ NULL
+ },
+ {
+ MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1,
+ NULL,
+ _mesa_fetch_texel_2d_f_etc2_srgb8_punchthrough_alpha1,
+ NULL
+ },
+ {
MESA_FORMAT_SIGNED_A8,
fetch_texel_1d_signed_a8,
fetch_texel_2d_signed_a8,