aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2014-09-21 18:11:28 +0200
committermarha <marha@users.sourceforge.net>2014-09-21 18:11:28 +0200
commit438af0c7d4bf60b408b259c88205ff2193195466 (patch)
tree46fd6465cb7431f64a3cb475a40587a261983af4 /mesalib/src
parentd0f70707dde032e662dbd5bc70df6ac915403abe (diff)
downloadvcxsrv-438af0c7d4bf60b408b259c88205ff2193195466.tar.gz
vcxsrv-438af0c7d4bf60b408b259c88205ff2193195466.tar.bz2
vcxsrv-438af0c7d4bf60b408b259c88205ff2193195466.zip
libxtrans xkeyboard-config xserver mesa plink glproto git update 21 Sep 2014
plink revision 10233 xserver commit 28337cb14e4347e1dd7936c5393a22e042866687 xkeyboard-config commit 48e1c0b351b6711edc0f167cbb81e4424b75291a glproto commit bd3d751e1eb17efb39f65093271bb4ac071aa9e0 libxtrans commit fb7f198c88e97d22c8c89e76e9cd06b2b2720a96 mesa commit 4eb2bbefd2bf0359aff7ebbb8e931a1c7833606f
Diffstat (limited to 'mesalib/src')
-rw-r--r--mesalib/src/gallium/Makefile.am4
-rw-r--r--mesalib/src/gallium/auxiliary/Makefile.am4
-rw-r--r--mesalib/src/gallium/auxiliary/Makefile.sources2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_cpu_detect.c2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format.c17
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format.csv80
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format.h2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_latc.c72
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_parse.py9
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_rgtc.c92
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_math.h1
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_sampler.c1
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_vbuf.c3
-rw-r--r--mesalib/src/glsl/Makefile.sources1
-rw-r--r--mesalib/src/glsl/ast_to_hir.cpp77
-rw-r--r--mesalib/src/glsl/ir_optimization.h2
-rw-r--r--mesalib/src/glsl/linker.cpp25
-rw-r--r--mesalib/src/glsl/linker.h3
-rw-r--r--mesalib/src/glsl/loop_analysis.h9
-rw-r--r--mesalib/src/glsl/lower_vertex_id.cpp144
-rw-r--r--mesalib/src/glsl/opt_constant_folding.cpp5
-rw-r--r--mesalib/src/mesa/drivers/dri/common/xmlconfig.c4
-rw-r--r--mesalib/src/mesa/drivers/dri/swrast/swrast.c3
-rw-r--r--mesalib/src/mesa/main/api_validate.c66
-rw-r--r--mesalib/src/mesa/main/arrayobj.c46
-rw-r--r--mesalib/src/mesa/main/arrayobj.h4
-rw-r--r--mesalib/src/mesa/main/attrib.c1
-rw-r--r--mesalib/src/mesa/main/buffers.c1
-rw-r--r--mesalib/src/mesa/main/clear.c1
-rw-r--r--mesalib/src/mesa/main/context.c12
-rw-r--r--mesalib/src/mesa/main/convolve.c5
-rw-r--r--mesalib/src/mesa/main/eval.c1
-rw-r--r--mesalib/src/mesa/main/feedback.c1
-rw-r--r--mesalib/src/mesa/main/fog.c1
-rw-r--r--mesalib/src/mesa/main/format_pack.c99
-rw-r--r--mesalib/src/mesa/main/format_unpack.c77
-rw-r--r--mesalib/src/mesa/main/format_utils.c1102
-rw-r--r--mesalib/src/mesa/main/formats.c26
-rw-r--r--mesalib/src/mesa/main/formats.csv5
-rw-r--r--mesalib/src/mesa/main/formats.h5
-rw-r--r--mesalib/src/mesa/main/histogram.c4
-rw-r--r--mesalib/src/mesa/main/macros.h8
-rw-r--r--mesalib/src/mesa/main/mtypes.h101
-rw-r--r--mesalib/src/mesa/main/pipelineobj.c4
-rw-r--r--mesalib/src/mesa/main/shader_query.cpp18
-rw-r--r--mesalib/src/mesa/main/state.c5
-rw-r--r--mesalib/src/mesa/main/texcompress_rgtc.c79
-rw-r--r--mesalib/src/mesa/main/texformat.c13
-rw-r--r--mesalib/src/mesa/main/uniform_query.cpp16
-rw-r--r--mesalib/src/mesa/main/varray.c9
-rw-r--r--mesalib/src/mesa/main/varray.h33
-rw-r--r--mesalib/src/mesa/program/ir_to_mesa.cpp7
-rw-r--r--mesalib/src/mesa/program/prog_optimize.c9
-rw-r--r--mesalib/src/mesa/program/register_allocate.c1
-rw-r--r--mesalib/src/mesa/program/register_allocate.h5
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_texture.c30
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_fbo.c10
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_texture.c62
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.c82
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c1
-rw-r--r--mesalib/src/mesa/state_tracker/st_format.c121
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp3
-rw-r--r--mesalib/src/mesa/state_tracker/st_texture.c15
-rw-r--r--mesalib/src/mesa/swrast/s_texfetch.c5
-rw-r--r--mesalib/src/mesa/swrast/s_texfetch_tmp.h54
-rw-r--r--mesalib/src/mesa/vbo/vbo_exec_array.c26
-rw-r--r--mesalib/src/mesa/vbo/vbo_exec_draw.c2
-rw-r--r--mesalib/src/mesa/vbo/vbo_save_draw.c1
-rw-r--r--mesalib/src/mesa/vbo/vbo_split_copy.c1
-rw-r--r--mesalib/src/util/Makefile.sources3
-rw-r--r--mesalib/src/util/rgtc.c61
-rw-r--r--mesalib/src/util/rgtc.h39
-rw-r--r--mesalib/src/util/texcompress_rgtc_tmp.h (renamed from mesalib/src/mesa/main/texcompress_rgtc_tmp.h)14
73 files changed, 1731 insertions, 1126 deletions
diff --git a/mesalib/src/gallium/Makefile.am b/mesalib/src/gallium/Makefile.am
index 32a5dc709..6018e9f72 100644
--- a/mesalib/src/gallium/Makefile.am
+++ b/mesalib/src/gallium/Makefile.am
@@ -105,9 +105,7 @@ if HAVE_EGL_PLATFORM_WAYLAND
SUBDIRS += winsys/sw/wayland
endif
-if NEED_WINSYS_WRAPPER
SUBDIRS += winsys/sw/wrapper
-endif
##
## Don't forget to bundle the remaining (non autotools) winsys'
@@ -123,7 +121,7 @@ EXTRA_DIST = \
## Gallium state trackers and their users (targets)
##
-if NEED_GALLIUM_LOADER
+if HAVE_LOADER_GALLIUM
SUBDIRS += targets/pipe-loader
endif
diff --git a/mesalib/src/gallium/auxiliary/Makefile.am b/mesalib/src/gallium/auxiliary/Makefile.am
index 493d306f6..4d8ba89cc 100644
--- a/mesalib/src/gallium/auxiliary/Makefile.am
+++ b/mesalib/src/gallium/auxiliary/Makefile.am
@@ -1,5 +1,9 @@
AUTOMAKE_OPTIONS = subdir-objects
+if HAVE_LOADER_GALLIUM
+SUBDIRS := pipe-loader
+endif
+
include Makefile.sources
include $(top_srcdir)/src/gallium/Automake.inc
diff --git a/mesalib/src/gallium/auxiliary/Makefile.sources b/mesalib/src/gallium/auxiliary/Makefile.sources
index 9bfaa0eab..58d8af71f 100644
--- a/mesalib/src/gallium/auxiliary/Makefile.sources
+++ b/mesalib/src/gallium/auxiliary/Makefile.sources
@@ -1,5 +1,3 @@
-SUBDIRS := pipe-loader
-
C_SOURCES := \
cso_cache/cso_cache.c \
cso_cache/cso_context.c \
diff --git a/mesalib/src/gallium/auxiliary/util/u_cpu_detect.c b/mesalib/src/gallium/auxiliary/util/u_cpu_detect.c
index d2d1313f8..5d9db59d1 100644
--- a/mesalib/src/gallium/auxiliary/util/u_cpu_detect.c
+++ b/mesalib/src/gallium/auxiliary/util/u_cpu_detect.c
@@ -369,7 +369,7 @@ util_cpu_detect(void)
util_cpu_caps.has_avx = ((regs2[2] >> 28) & 1) && // AVX
((regs2[2] >> 27) & 1) && // OSXSAVE
((xgetbv() & 6) == 6); // XMM & YMM
- util_cpu_caps.has_f16c = (regs2[2] >> 29) & 1;
+ util_cpu_caps.has_f16c = ((regs2[2] >> 29) & 1) && util_cpu_caps.has_avx;
util_cpu_caps.has_mmx2 = util_cpu_caps.has_sse; /* SSE cpus supports mmxext too */
#if defined(PIPE_ARCH_X86_64)
util_cpu_caps.has_daz = 1;
diff --git a/mesalib/src/gallium/auxiliary/util/u_format.c b/mesalib/src/gallium/auxiliary/util/u_format.c
index d53dd7884..c1ce40811 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format.c
+++ b/mesalib/src/gallium/auxiliary/util/u_format.c
@@ -92,6 +92,23 @@ util_format_is_luminance(enum pipe_format format)
}
boolean
+util_format_is_alpha(enum pipe_format format)
+{
+ const struct util_format_description *desc =
+ util_format_description(format);
+
+ if ((desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB ||
+ desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) &&
+ desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_0 &&
+ desc->swizzle[1] == UTIL_FORMAT_SWIZZLE_0 &&
+ desc->swizzle[2] == UTIL_FORMAT_SWIZZLE_0 &&
+ desc->swizzle[3] == UTIL_FORMAT_SWIZZLE_X) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+boolean
util_format_is_pure_integer(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
diff --git a/mesalib/src/gallium/auxiliary/util/u_format.csv b/mesalib/src/gallium/auxiliary/util/u_format.csv
index 17034049d..a71aaf15d 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format.csv
+++ b/mesalib/src/gallium/auxiliary/util/u_format.csv
@@ -46,6 +46,8 @@
# - number of bits
# - channel swizzle
# - color space: rgb, yub, sz
+# - (optional) channel encoding for big-endian targets
+# - (optional) channel swizzle for big-endian targets
#
# See also:
# - http://msdn.microsoft.com/en-us/library/bb172558.aspx (D3D9)
@@ -70,20 +72,20 @@ PIPE_FORMAT_A8B8G8R8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, r
PIPE_FORMAT_X8B8G8R8_UNORM , plain, 1, 1, x8 , un8 , un8 , un8 , wzy1, rgb
# PIPE_FORMAT_R8G8B8A8_UNORM is below
PIPE_FORMAT_R8G8B8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , x8 , xyz1, rgb
-PIPE_FORMAT_B5G5R5X1_UNORM , plain, 1, 1, un5 , un5 , un5 , x1 , zyx1, rgb
-PIPE_FORMAT_B5G5R5A1_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb
-PIPE_FORMAT_B4G4R4A4_UNORM , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb
-PIPE_FORMAT_B4G4R4X4_UNORM , plain, 1, 1, un4 , un4 , un4 , x4 , zyx1, rgb
-PIPE_FORMAT_B5G6R5_UNORM , plain, 1, 1, un5 , un6 , un5 , , zyx1, rgb
-PIPE_FORMAT_R10G10B10A2_UNORM , plain, 1, 1, un10, un10, un10, un2 , xyzw, rgb
-PIPE_FORMAT_B10G10R10A2_UNORM , plain, 1, 1, un10, un10, un10, un2 , zyxw, rgb
-PIPE_FORMAT_B2G3R3_UNORM , plain, 1, 1, un2 , un3 , un3 , , zyx1, rgb
+PIPE_FORMAT_B5G5R5X1_UNORM , plain, 1, 1, un5 , un5 , un5 , x1 , zyx1, rgb, x1 , un5 , un5 , un5 , yzw1
+PIPE_FORMAT_B5G5R5A1_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb, un1 , un5 , un5 , un5 , yzwx
+PIPE_FORMAT_B4G4R4A4_UNORM , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb, un4 , un4 , un4 , un4 , yzwx
+PIPE_FORMAT_B4G4R4X4_UNORM , plain, 1, 1, un4 , un4 , un4 , x4 , zyx1, rgb, x4 , un4 , un4 , un4 , yzw1
+PIPE_FORMAT_B5G6R5_UNORM , plain, 1, 1, un5 , un6 , un5 , , zyx1, rgb, un5 , un6 , un5 , , xyz1
+PIPE_FORMAT_R10G10B10A2_UNORM , plain, 1, 1, un10, un10, un10, un2 , xyzw, rgb, un2 , un10, un10, un10, wzyx
+PIPE_FORMAT_B10G10R10A2_UNORM , plain, 1, 1, un10, un10, un10, un2 , zyxw, rgb, un2 , un10, un10, un10, yzwx
+PIPE_FORMAT_B2G3R3_UNORM , plain, 1, 1, un2 , un3 , un3 , , zyx1, rgb, un3 , un3 , un2 , , xyz1
# Luminance/Intensity/Alpha formats
PIPE_FORMAT_L8_UNORM , plain, 1, 1, un8 , , , , xxx1, rgb
PIPE_FORMAT_A8_UNORM , plain, 1, 1, un8 , , , , 000x, rgb
PIPE_FORMAT_I8_UNORM , plain, 1, 1, un8 , , , , xxxx, rgb
-PIPE_FORMAT_L4A4_UNORM , plain, 1, 1, un4 , un4 , , , xxxy, rgb
+PIPE_FORMAT_L4A4_UNORM , plain, 1, 1, un4 , un4 , , , xxxy, rgb, un4 , un4 , , , yyyx
PIPE_FORMAT_L8A8_UNORM , plain, 1, 1, un8 , un8 , , , xxxy, rgb
PIPE_FORMAT_L16_UNORM , plain, 1, 1, un16, , , , xxx1, rgb
PIPE_FORMAT_A16_UNORM , plain, 1, 1, un16, , , , 000x, rgb
@@ -120,22 +122,22 @@ PIPE_FORMAT_X8R8G8B8_SRGB , plain, 1, 1, x8 , un8 , un8 , un8 , yzw1, s
# Mixed-sign formats (typically used for bump map textures)
PIPE_FORMAT_R8SG8SB8UX8U_NORM , plain, 1, 1, sn8 , sn8 , un8 , x8 , xyz1, rgb
-PIPE_FORMAT_R10SG10SB10SA2U_NORM , plain, 1, 1, sn10, sn10, sn10, un2 , xyzw, rgb
-PIPE_FORMAT_R5SG5SB6U_NORM , plain, 1, 1, sn5 , sn5 , un6 , , xyz1, rgb
+PIPE_FORMAT_R10SG10SB10SA2U_NORM , plain, 1, 1, sn10, sn10, sn10, un2 , xyzw, rgb, un2 , sn10, sn10, sn10, wzyx
+PIPE_FORMAT_R5SG5SB6U_NORM , plain, 1, 1, sn5 , sn5 , un6 , , xyz1, rgb, un6 , sn5 , sn5 , , zyx1
# Depth-stencil formats
PIPE_FORMAT_S8_UINT , plain, 1, 1, up8 , , , , _x__, zs
PIPE_FORMAT_Z16_UNORM , plain, 1, 1, un16, , , , x___, zs
PIPE_FORMAT_Z32_UNORM , plain, 1, 1, un32, , , , x___, zs
PIPE_FORMAT_Z32_FLOAT , plain, 1, 1, f32 , , , , x___, zs
-PIPE_FORMAT_Z24_UNORM_S8_UINT , plain, 1, 1, un24, up8 , , , xy__, zs
-PIPE_FORMAT_S8_UINT_Z24_UNORM , plain, 1, 1, up8 , un24, , , yx__, zs
-PIPE_FORMAT_X24S8_UINT , plain, 1, 1, x24 , up8 , , , _y__, zs
-PIPE_FORMAT_S8X24_UINT , plain, 1, 1, up8 , x24 , , , _x__, zs
-PIPE_FORMAT_Z24X8_UNORM , plain, 1, 1, un24, x8 , , , x___, zs
-PIPE_FORMAT_X8Z24_UNORM , plain, 1, 1, x8 , un24, , , y___, zs
-PIPE_FORMAT_Z32_FLOAT_S8X24_UINT , plain, 1, 1, f32 , up8 , x24, , xy__, zs
-PIPE_FORMAT_X32_S8X24_UINT , plain, 1, 1, x32 , up8 , x24, , _y__, zs
+PIPE_FORMAT_Z24_UNORM_S8_UINT , plain, 1, 1, un24, up8 , , , xy__, zs, up8 , un24, , , yx__
+PIPE_FORMAT_S8_UINT_Z24_UNORM , plain, 1, 1, up8 , un24, , , yx__, zs, un24, up8 , , , xy__
+PIPE_FORMAT_X24S8_UINT , plain, 1, 1, x24 , up8 , , , _y__, zs, up8 , x24 , , , _x__
+PIPE_FORMAT_S8X24_UINT , plain, 1, 1, up8 , x24 , , , _x__, zs, x24 , up8 , , , _y__
+PIPE_FORMAT_Z24X8_UNORM , plain, 1, 1, un24, x8 , , , x___, zs, x8 , un24, , , y___
+PIPE_FORMAT_X8Z24_UNORM , plain, 1, 1, x8 , un24, , , y___, zs, un24, x8 , , , x___
+PIPE_FORMAT_Z32_FLOAT_S8X24_UINT , plain, 1, 1, f32 , up8 , x24, , xy__, zs, f32 , x24 , up8, , xz__
+PIPE_FORMAT_X32_S8X24_UINT , plain, 1, 1, x32 , up8 , x24, , _y__, zs, x32 , x24 , up8, , _z__
# YUV formats
# http://www.fourcc.org/yuv.php#UYVY
@@ -267,9 +269,9 @@ PIPE_FORMAT_R32G32B32A32_FIXED , plain, 1, 1, h32 , h32 , h32 , h32 , xyzw, r
# See also:
# - http://msdn.microsoft.com/en-us/library/bb172533.aspx
# A.k.a. D3DDECLTYPE_UDEC3
-PIPE_FORMAT_R10G10B10X2_USCALED , plain, 1, 1, u10 , u10 , u10 , x2 , xyz1, rgb
+PIPE_FORMAT_R10G10B10X2_USCALED , plain, 1, 1, u10 , u10 , u10 , x2 , xyz1, rgb, x2 , u10 , u10 , u10 , wzy1
# A.k.a. D3DDECLTYPE_DEC3N
-PIPE_FORMAT_R10G10B10X2_SNORM , plain, 1, 1, sn10, sn10, sn10 , x2 , xyz1, rgb
+PIPE_FORMAT_R10G10B10X2_SNORM , plain, 1, 1, sn10, sn10, sn10 , x2 , xyz1, rgb, x2 , sn10, sn10, sn10, wzy1
PIPE_FORMAT_YV12 , other, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
PIPE_FORMAT_YV16 , other, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
@@ -278,18 +280,18 @@ PIPE_FORMAT_NV12 , other, 1, 1, x8 , x8 , x8 , x8 , xyzw, y
PIPE_FORMAT_NV21 , other, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
# Usually used to implement IA44 and AI44 formats in video decoding
-PIPE_FORMAT_A4R4_UNORM , plain, 1, 1, un4 , un4 , , , y00x, rgb
-PIPE_FORMAT_R4A4_UNORM , plain, 1, 1, un4 , un4 , , , x00y, rgb
+PIPE_FORMAT_A4R4_UNORM , plain, 1, 1, un4 , un4 , , , y00x, rgb, un4, un4 , , , x00y
+PIPE_FORMAT_R4A4_UNORM , plain, 1, 1, un4 , un4 , , , x00y, rgb, un4, un4 , , , y00x
PIPE_FORMAT_R8A8_UNORM , plain, 1, 1, un8 , un8 , , , x00y, rgb
PIPE_FORMAT_A8R8_UNORM , plain, 1, 1, un8 , un8 , , , y00x, rgb
# ARB_vertex_type_10_10_10_2_REV
-PIPE_FORMAT_R10G10B10A2_USCALED , plain, 1, 1, u10, u10, u10, u2, xyzw, rgb
-PIPE_FORMAT_R10G10B10A2_SSCALED , plain, 1, 1, s10, s10, s10, s2, xyzw, rgb
-PIPE_FORMAT_R10G10B10A2_SNORM , plain, 1, 1, sn10, sn10, sn10, sn2, xyzw, rgb
-PIPE_FORMAT_B10G10R10A2_USCALED , plain, 1, 1, u10, u10, u10, u2, zyxw, rgb
-PIPE_FORMAT_B10G10R10A2_SSCALED , plain, 1, 1, s10, s10, s10, s2, zyxw, rgb
-PIPE_FORMAT_B10G10R10A2_SNORM , plain, 1, 1, sn10, sn10, sn10, sn2, zyxw, rgb
+PIPE_FORMAT_R10G10B10A2_USCALED , plain, 1, 1, u10 , u10 , u10 , u2 , xyzw, rgb, u2 , u10 , u10 , u10 , wzyx
+PIPE_FORMAT_R10G10B10A2_SSCALED , plain, 1, 1, s10 , s10 , s10 , s2 , xyzw, rgb, s2 , s10 , s10 , s10 , wzyx
+PIPE_FORMAT_R10G10B10A2_SNORM , plain, 1, 1, sn10, sn10, sn10, sn2 , xyzw, rgb, sn2 , sn10, sn10, sn10, wzyx
+PIPE_FORMAT_B10G10R10A2_USCALED , plain, 1, 1, u10 , u10 , u10 , u2 , zyxw, rgb, u2 , u10 , u10 , u10 , yzwx
+PIPE_FORMAT_B10G10R10A2_SSCALED , plain, 1, 1, s10 , s10 , s10 , s2 , zyxw, rgb, s2 , s10 , s10 , s10 , yzwx
+PIPE_FORMAT_B10G10R10A2_SNORM , plain, 1, 1, sn10, sn10, sn10, sn2 , zyxw, rgb, sn2 , sn10, sn10, sn10, yzwx
PIPE_FORMAT_R8_UINT , plain, 1, 1, up8, , , , x001, rgb
PIPE_FORMAT_R8G8_UINT , plain, 1, 1, up8, up8, , , xy01, rgb
@@ -351,13 +353,13 @@ PIPE_FORMAT_I32_SINT , plain, 1, 1, sp32, , , , xxxx, rgb
PIPE_FORMAT_L32_SINT , plain, 1, 1, sp32, , , , xxx1, rgb
PIPE_FORMAT_L32A32_SINT , plain, 1, 1, sp32, sp32, , , xxxy, rgb
-PIPE_FORMAT_B10G10R10A2_UINT , plain, 1, 1, up10, up10, up10, up2, zyxw, rgb
+PIPE_FORMAT_B10G10R10A2_UINT , plain, 1, 1, up10, up10, up10, up2, zyxw, rgb, up2 , up10, up10, up10, yzwx
PIPE_FORMAT_R8G8B8X8_SNORM , plain, 1, 1, sn8, sn8, sn8, x8, xyz1, rgb
PIPE_FORMAT_R8G8B8X8_SRGB , plain, 1, 1, un8, un8, un8, x8, xyz1, srgb
PIPE_FORMAT_R8G8B8X8_UINT , plain, 1, 1, up8, up8, up8, x8, xyz1, rgb
PIPE_FORMAT_R8G8B8X8_SINT , plain, 1, 1, sp8, sp8, sp8, x8, xyz1, rgb
-PIPE_FORMAT_B10G10R10X2_UNORM , plain, 1, 1, un10, un10, un10, x2, zyx1, rgb
+PIPE_FORMAT_B10G10R10X2_UNORM , plain, 1, 1, un10, un10, un10, x2, zyx1, rgb, x2 , un10, un10, un10, yzw1
PIPE_FORMAT_R16G16B16X16_UNORM , plain, 1, 1, un16, un16, un16, x16, xyz1, rgb
PIPE_FORMAT_R16G16B16X16_SNORM , plain, 1, 1, sn16, sn16, sn16, x16, xyz1, rgb
PIPE_FORMAT_R16G16B16X16_FLOAT , plain, 1, 1, f16, f16, f16, x16, xyz1, rgb
@@ -378,7 +380,19 @@ PIPE_FORMAT_R16A16_UINT , plain, 1, 1, up16 , up16 , , , x00
PIPE_FORMAT_R16A16_SINT , plain, 1, 1, sp16 , sp16 , , , x00y, rgb
PIPE_FORMAT_R32A32_UINT , plain, 1, 1, up32 , up32 , , , x00y, rgb
PIPE_FORMAT_R32A32_SINT , plain, 1, 1, sp32 , sp32 , , , x00y, rgb
-PIPE_FORMAT_R10G10B10A2_UINT , plain, 1, 1, up10 , up10 , up10, up2 , xyzw, rgb
+PIPE_FORMAT_R10G10B10A2_UINT , plain, 1, 1, up10 , up10 , up10, up2 , xyzw, rgb, up2 , up10, up10, up10, wzyx
-PIPE_FORMAT_B5G6R5_SRGB , plain, 1, 1, un5 , un6 , un5 , , zyx1, srgb
+PIPE_FORMAT_B5G6R5_SRGB , plain, 1, 1, un5 , un6 , un5 , , zyx1, srgb, un5 , un6 , un5 , , xyz1
+PIPE_FORMAT_A8L8_UNORM , plain, 1, 1, un8 , un8 , , , yyyx, rgb
+PIPE_FORMAT_A8L8_SNORM , plain, 1, 1, sn8 , sn8 , , , yyyx, rgb
+PIPE_FORMAT_A8L8_SRGB , plain, 1, 1, un8 , un8 , , , yyyx, srgb
+PIPE_FORMAT_A16L16_UNORM , plain, 1, 1, un16, un16, , , yyyx, rgb
+
+PIPE_FORMAT_G8R8_UNORM , plain, 1, 1, un8 , un8 , , , yx01, rgb
+PIPE_FORMAT_G8R8_SNORM , plain, 1, 1, sn8 , sn8 , , , yx01, rgb
+PIPE_FORMAT_G16R16_UNORM , plain, 1, 1, un16, un16, , , yx01, rgb
+PIPE_FORMAT_G16R16_SNORM , plain, 1, 1, sn16, sn16, , , yx01, rgb
+
+PIPE_FORMAT_A8B8G8R8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , sn8 , wzyx, rgb
+PIPE_FORMAT_X8B8G8R8_SNORM , plain, 1, 1, x8, sn8, sn8, sn8, wzy1, rgb
diff --git a/mesalib/src/gallium/auxiliary/util/u_format.h b/mesalib/src/gallium/auxiliary/util/u_format.h
index df31400af..621574c96 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format.h
+++ b/mesalib/src/gallium/auxiliary/util/u_format.h
@@ -661,6 +661,8 @@ util_format_has_alpha(enum pipe_format format);
boolean
util_format_is_luminance(enum pipe_format format);
+boolean
+util_format_is_alpha(enum pipe_format format);
boolean
util_format_is_luminance_alpha(enum pipe_format format);
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_latc.c b/mesalib/src/gallium/auxiliary/util/u_format_latc.c
index caab7e87a..31d72b5a0 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_latc.c
+++ b/mesalib/src/gallium/auxiliary/util/u_format_latc.c
@@ -27,27 +27,16 @@
#include "u_format.h"
#include "u_format_rgtc.h"
#include "u_format_latc.h"
-
-static void u_format_unsigned_encode_rgtc_ubyte(uint8_t *blkaddr, uint8_t srccolors[4][4],
- int numxpixels, int numypixels);
-
-static void u_format_unsigned_fetch_texel_rgtc(unsigned srcRowStride, const uint8_t *pixdata,
- unsigned i, unsigned j, uint8_t *value, unsigned comps);
-
-static void u_format_signed_encode_rgtc_ubyte(int8_t *blkaddr, int8_t srccolors[4][4],
- int numxpixels, int numypixels);
-
-static void u_format_signed_fetch_texel_rgtc(unsigned srcRowStride, const int8_t *pixdata,
- unsigned i, unsigned j, int8_t *value, unsigned comps);
+#include "util/rgtc.h"
void
util_format_latc1_unorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
{
/* Fix warnings here: */
- (void) u_format_unsigned_encode_rgtc_ubyte;
- (void) u_format_signed_encode_rgtc_ubyte;
+ (void) util_format_unsigned_encode_rgtc_ubyte;
+ (void) util_format_signed_encode_rgtc_ubyte;
- u_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 1);
+ util_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 1);
dst[1] = dst[0];
dst[2] = dst[0];
dst[3] = 255;
@@ -79,7 +68,7 @@ util_format_latc1_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, c
for(i = 0; i < 4; ++i) {
float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
uint8_t tmp_r;
- u_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 1);
+ util_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 1);
dst[0] =
dst[1] =
dst[2] = ubyte_to_float(tmp_r);
@@ -103,7 +92,7 @@ util_format_latc1_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigne
{
uint8_t tmp_r;
- u_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 1);
+ util_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 1);
dst[0] =
dst[1] =
dst[2] = ubyte_to_float(tmp_r);
@@ -147,7 +136,7 @@ util_format_latc1_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, c
for(i = 0; i < 4; ++i) {
float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
int8_t tmp_r;
- u_format_signed_fetch_texel_rgtc(0, src, i, j, &tmp_r, 1);
+ util_format_signed_fetch_texel_rgtc(0, src, i, j, &tmp_r, 1);
dst[0] =
dst[1] =
dst[2] = byte_to_float_tex(tmp_r);
@@ -165,7 +154,7 @@ util_format_latc1_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigne
{
int8_t tmp_r;
- u_format_signed_fetch_texel_rgtc(0, (int8_t *)src, i, j, &tmp_r, 1);
+ util_format_signed_fetch_texel_rgtc(0, (int8_t *)src, i, j, &tmp_r, 1);
dst[0] =
dst[1] =
dst[2] = byte_to_float_tex(tmp_r);
@@ -176,10 +165,10 @@ util_format_latc1_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigne
void
util_format_latc2_unorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
{
- u_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 2);
+ util_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 2);
dst[1] = dst[0];
dst[2] = dst[0];
- u_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, dst + 3, 2);
+ util_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, dst + 3, 2);
}
void
@@ -213,8 +202,8 @@ util_format_latc2_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, c
for(i = 0; i < 4; ++i) {
float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
uint8_t tmp_r, tmp_g;
- u_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 2);
- u_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, &tmp_g, 2);
+ util_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 2);
+ util_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, &tmp_g, 2);
dst[0] =
dst[1] =
dst[2] = ubyte_to_float(tmp_r);
@@ -232,8 +221,8 @@ util_format_latc2_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigne
{
uint8_t tmp_r, tmp_g;
- u_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 2);
- u_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, &tmp_g, 2);
+ util_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 2);
+ util_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, &tmp_g, 2);
dst[0] =
dst[1] =
dst[2] = ubyte_to_float(tmp_r);
@@ -272,8 +261,8 @@ util_format_latc2_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, c
for(i = 0; i < 4; ++i) {
float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
int8_t tmp_r, tmp_g;
- u_format_signed_fetch_texel_rgtc(0, src, i, j, &tmp_r, 2);
- u_format_signed_fetch_texel_rgtc(0, src + 8, i, j, &tmp_g, 2);
+ util_format_signed_fetch_texel_rgtc(0, src, i, j, &tmp_r, 2);
+ util_format_signed_fetch_texel_rgtc(0, src + 8, i, j, &tmp_g, 2);
dst[0] =
dst[1] =
dst[2] = byte_to_float_tex(tmp_r);
@@ -297,36 +286,11 @@ util_format_latc2_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigne
{
int8_t tmp_r, tmp_g;
- u_format_signed_fetch_texel_rgtc(0, (int8_t *)src, i, j, &tmp_r, 2);
- u_format_signed_fetch_texel_rgtc(0, (int8_t *)src + 8, i, j, &tmp_g, 2);
+ util_format_signed_fetch_texel_rgtc(0, (int8_t *)src, i, j, &tmp_r, 2);
+ util_format_signed_fetch_texel_rgtc(0, (int8_t *)src + 8, i, j, &tmp_g, 2);
dst[0] =
dst[1] =
dst[2] = byte_to_float_tex(tmp_r);
dst[3] = byte_to_float_tex(tmp_g);
}
-
-#define TAG(x) u_format_unsigned_##x
-#define TYPE uint8_t
-#define T_MIN 0
-#define T_MAX 255
-
-#include "../../../mesa/main/texcompress_rgtc_tmp.h"
-
-#undef TYPE
-#undef TAG
-#undef T_MIN
-#undef T_MAX
-
-
-#define TAG(x) u_format_signed_##x
-#define TYPE int8_t
-#define T_MIN (int8_t)-128
-#define T_MAX (int8_t)127
-
-#include "../../../mesa/main/texcompress_rgtc_tmp.h"
-
-#undef TYPE
-#undef TAG
-#undef T_MIN
-#undef T_MAX
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_parse.py b/mesalib/src/gallium/auxiliary/util/u_format_parse.py
index 15cc6d4fe..929017a44 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_parse.py
+++ b/mesalib/src/gallium/auxiliary/util/u_format_parse.py
@@ -330,6 +330,9 @@ def parse(filename):
continue
fields = [field.strip() for field in line.split(',')]
+ if len (fields) == 10:
+ fields += fields[4:9]
+ assert len (fields) == 15
name = fields[0]
layout = fields[1]
@@ -339,8 +342,8 @@ def parse(filename):
le_swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[8]]
le_channels = _parse_channels(fields[4:8], layout, colorspace, le_swizzles)
- be_swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[8]]
- be_channels = _parse_channels(fields[4:8], layout, colorspace, be_swizzles)
+ be_swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[14]]
+ be_channels = _parse_channels(fields[10:14], layout, colorspace, be_swizzles)
le_shift = 0
for channel in le_channels:
@@ -353,6 +356,8 @@ def parse(filename):
be_shift += channel.size
assert le_shift == be_shift
+ for i in range(4):
+ assert (le_swizzles[i] != SWIZZLE_NONE) == (be_swizzles[i] != SWIZZLE_NONE)
format = Format(name, layout, block_width, block_height, le_channels, le_swizzles, be_channels, be_swizzles, colorspace)
formats.append(format)
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_rgtc.c b/mesalib/src/gallium/auxiliary/util/u_format_rgtc.c
index 758e33774..159691743 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_rgtc.c
+++ b/mesalib/src/gallium/auxiliary/util/u_format_rgtc.c
@@ -26,23 +26,12 @@
#include "u_math.h"
#include "u_format.h"
#include "u_format_rgtc.h"
-
-static void u_format_unsigned_encode_rgtc_ubyte(uint8_t *blkaddr, uint8_t srccolors[4][4],
- int numxpixels, int numypixels);
-
-static void u_format_unsigned_fetch_texel_rgtc(unsigned srcRowStride, const uint8_t *pixdata,
- unsigned i, unsigned j, uint8_t *value, unsigned comps);
-
-static void u_format_signed_encode_rgtc_ubyte(int8_t *blkaddr, int8_t srccolors[4][4],
- int numxpixels, int numypixels);
-
-static void u_format_signed_fetch_texel_rgtc(unsigned srcRowStride, const int8_t *pixdata,
- unsigned i, unsigned j, int8_t *value, unsigned comps);
+#include "util/rgtc.h"
void
util_format_rgtc1_unorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
{
- u_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 1);
+ util_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 1);
dst[1] = 0;
dst[2] = 0;
dst[3] = 255;
@@ -61,7 +50,7 @@ util_format_rgtc1_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride
for(j = 0; j < bh; ++j) {
for(i = 0; i < bw; ++i) {
uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*comps;
- u_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 1);
+ util_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 1);
dst[1] = 0;
dst[2] = 0;
dst[3] = 255;
@@ -89,7 +78,7 @@ util_format_rgtc1_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
tmp[j][i] = src_row[(y + j)*src_stride/sizeof(*src_row) + (x + i)*4];
}
}
- u_format_unsigned_encode_rgtc_ubyte(dst, tmp, 4, 4);
+ util_format_unsigned_encode_rgtc_ubyte(dst, tmp, 4, 4);
dst += bytes_per_block;
}
dst_row += dst_stride / sizeof(*dst_row);
@@ -108,7 +97,7 @@ util_format_rgtc1_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, c
for(i = 0; i < 4; ++i) {
float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
uint8_t tmp_r;
- u_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 1);
+ util_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 1);
dst[0] = ubyte_to_float(tmp_r);
dst[1] = 0.0;
dst[2] = 0.0;
@@ -136,7 +125,7 @@ util_format_rgtc1_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, c
tmp[j][i] = float_to_ubyte(src_row[(y + j)*src_stride/sizeof(*src_row) + (x + i)*4]);
}
}
- u_format_unsigned_encode_rgtc_ubyte(dst, tmp, 4, 4);
+ util_format_unsigned_encode_rgtc_ubyte(dst, tmp, 4, 4);
dst += bytes_per_block;
}
dst_row += dst_stride / sizeof(*dst_row);
@@ -147,7 +136,7 @@ void
util_format_rgtc1_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t tmp_r;
- u_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 1);
+ util_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 1);
dst[0] = ubyte_to_float(tmp_r);
dst[1] = 0.0;
dst[2] = 0.0;
@@ -187,7 +176,7 @@ util_format_rgtc1_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, c
tmp[j][i] = float_to_byte_tex(src_row[(y + j)*src_stride/sizeof(*src_row) + (x + i)*4]);
}
}
- u_format_signed_encode_rgtc_ubyte(dst, tmp, 4, 4);
+ util_format_signed_encode_rgtc_ubyte(dst, tmp, 4, 4);
dst += bytes_per_block;
}
dst_row += dst_stride / sizeof(*dst_row);
@@ -206,7 +195,7 @@ util_format_rgtc1_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, c
for(i = 0; i < 4; ++i) {
float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
int8_t tmp_r;
- u_format_signed_fetch_texel_rgtc(0, src, i, j, &tmp_r, 1);
+ util_format_signed_fetch_texel_rgtc(0, src, i, j, &tmp_r, 1);
dst[0] = byte_to_float_tex(tmp_r);
dst[1] = 0.0;
dst[2] = 0.0;
@@ -223,7 +212,7 @@ void
util_format_rgtc1_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
int8_t tmp_r;
- u_format_signed_fetch_texel_rgtc(0, (int8_t *)src, i, j, &tmp_r, 1);
+ util_format_signed_fetch_texel_rgtc(0, (int8_t *)src, i, j, &tmp_r, 1);
dst[0] = byte_to_float_tex(tmp_r);
dst[1] = 0.0;
dst[2] = 0.0;
@@ -234,8 +223,8 @@ util_format_rgtc1_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigne
void
util_format_rgtc2_unorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
{
- u_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 2);
- u_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, dst + 1, 2);
+ util_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 2);
+ util_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, dst + 1, 2);
dst[2] = 0;
dst[3] = 255;
}
@@ -253,8 +242,8 @@ util_format_rgtc2_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride
for(j = 0; j < bh; ++j) {
for(i = 0; i < bw; ++i) {
uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*comps;
- u_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 2);
- u_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, dst + 1, 2);
+ util_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 2);
+ util_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, dst + 1, 2);
dst[2] = 0;
dst[3] = 255;
}
@@ -282,8 +271,8 @@ util_format_rgtc2_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
tmp_g[j][i] = src_row[((y + j)*src_stride/sizeof(*src_row) + (x + i)*4) + 1];
}
}
- u_format_unsigned_encode_rgtc_ubyte(dst, tmp_r, 4, 4);
- u_format_unsigned_encode_rgtc_ubyte(dst + 8, tmp_g, 4, 4);
+ util_format_unsigned_encode_rgtc_ubyte(dst, tmp_r, 4, 4);
+ util_format_unsigned_encode_rgtc_ubyte(dst + 8, tmp_g, 4, 4);
dst += bytes_per_block;
}
dst_row += dst_stride / sizeof(*dst_row);
@@ -307,8 +296,8 @@ util_format_rxtc2_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, c
tmp_g[j][i] = float_to_ubyte(src_row[(y + j)*src_stride/sizeof(*src_row) + (x + i)*4 + chan2off]);
}
}
- u_format_unsigned_encode_rgtc_ubyte(dst, tmp_r, 4, 4);
- u_format_unsigned_encode_rgtc_ubyte(dst + 8, tmp_g, 4, 4);
+ util_format_unsigned_encode_rgtc_ubyte(dst, tmp_r, 4, 4);
+ util_format_unsigned_encode_rgtc_ubyte(dst + 8, tmp_g, 4, 4);
dst += bytes_per_block;
}
dst_row += dst_stride / sizeof(*dst_row);
@@ -333,8 +322,8 @@ util_format_rgtc2_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, c
for(i = 0; i < 4; ++i) {
float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
uint8_t tmp_r, tmp_g;
- u_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 2);
- u_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, &tmp_g, 2);
+ util_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 2);
+ util_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, &tmp_g, 2);
dst[0] = ubyte_to_float(tmp_r);
dst[1] = ubyte_to_float(tmp_g);
dst[2] = 0.0;
@@ -351,8 +340,8 @@ void
util_format_rgtc2_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
uint8_t tmp_r, tmp_g;
- u_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 2);
- u_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, &tmp_g, 2);
+ util_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 2);
+ util_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, &tmp_g, 2);
dst[0] = ubyte_to_float(tmp_r);
dst[1] = ubyte_to_float(tmp_g);
dst[2] = 0.0;
@@ -390,8 +379,8 @@ util_format_rgtc2_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, c
for(i = 0; i < 4; ++i) {
float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
int8_t tmp_r, tmp_g;
- u_format_signed_fetch_texel_rgtc(0, src, i, j, &tmp_r, 2);
- u_format_signed_fetch_texel_rgtc(0, src + 8, i, j, &tmp_g, 2);
+ util_format_signed_fetch_texel_rgtc(0, src, i, j, &tmp_r, 2);
+ util_format_signed_fetch_texel_rgtc(0, src + 8, i, j, &tmp_g, 2);
dst[0] = byte_to_float_tex(tmp_r);
dst[1] = byte_to_float_tex(tmp_g);
dst[2] = 0.0;
@@ -421,8 +410,8 @@ util_format_rxtc2_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, c
tmp_g[j][i] = float_to_byte_tex(src_row[(y + j)*src_stride/sizeof(*src_row) + (x + i)*4 + chan2off]);
}
}
- u_format_signed_encode_rgtc_ubyte(dst, tmp_r, 4, 4);
- u_format_signed_encode_rgtc_ubyte(dst + 8, tmp_g, 4, 4);
+ util_format_signed_encode_rgtc_ubyte(dst, tmp_r, 4, 4);
+ util_format_signed_encode_rgtc_ubyte(dst + 8, tmp_g, 4, 4);
dst += bytes_per_block;
}
dst_row += dst_stride / sizeof(*dst_row);
@@ -439,36 +428,11 @@ void
util_format_rgtc2_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
int8_t tmp_r, tmp_g;
- u_format_signed_fetch_texel_rgtc(0, (int8_t *)src, i, j, &tmp_r, 2);
- u_format_signed_fetch_texel_rgtc(0, (int8_t *)src + 8, i, j, &tmp_g, 2);
+ util_format_signed_fetch_texel_rgtc(0, (int8_t *)src, i, j, &tmp_r, 2);
+ util_format_signed_fetch_texel_rgtc(0, (int8_t *)src + 8, i, j, &tmp_g, 2);
dst[0] = byte_to_float_tex(tmp_r);
dst[1] = byte_to_float_tex(tmp_g);
dst[2] = 0.0;
dst[3] = 1.0;
}
-
-#define TAG(x) u_format_unsigned_##x
-#define TYPE uint8_t
-#define T_MIN 0
-#define T_MAX 255
-
-#include "../../../mesa/main/texcompress_rgtc_tmp.h"
-
-#undef TYPE
-#undef TAG
-#undef T_MIN
-#undef T_MAX
-
-
-#define TAG(x) u_format_signed_##x
-#define TYPE int8_t
-#define T_MIN (int8_t)-128
-#define T_MAX (int8_t)127
-
-#include "../../../mesa/main/texcompress_rgtc_tmp.h"
-
-#undef TYPE
-#undef TAG
-#undef T_MIN
-#undef T_MAX
diff --git a/mesalib/src/gallium/auxiliary/util/u_math.h b/mesalib/src/gallium/auxiliary/util/u_math.h
index 25bcfb57d..39bd40fa1 100644
--- a/mesalib/src/gallium/auxiliary/util/u_math.h
+++ b/mesalib/src/gallium/auxiliary/util/u_math.h
@@ -40,6 +40,7 @@
#include "pipe/p_compiler.h"
+#include "util/u_debug.h"
#ifdef __cplusplus
diff --git a/mesalib/src/gallium/auxiliary/util/u_sampler.c b/mesalib/src/gallium/auxiliary/util/u_sampler.c
index 227641bda..86799fdd5 100644
--- a/mesalib/src/gallium/auxiliary/util/u_sampler.c
+++ b/mesalib/src/gallium/auxiliary/util/u_sampler.c
@@ -45,6 +45,7 @@ default_template(struct pipe_sampler_view *view,
/* XXX: Check if format is compatible with texture->format.
*/
+ view->target = texture->target;
view->format = format;
view->u.tex.first_level = 0;
view->u.tex.last_level = texture->last_level;
diff --git a/mesalib/src/gallium/auxiliary/util/u_vbuf.c b/mesalib/src/gallium/auxiliary/util/u_vbuf.c
index 650df9f6a..b1b89bf1b 100644
--- a/mesalib/src/gallium/auxiliary/util/u_vbuf.c
+++ b/mesalib/src/gallium/auxiliary/util/u_vbuf.c
@@ -357,7 +357,8 @@ u_vbuf_set_vertex_elements_internal(struct u_vbuf *mgr, unsigned count,
assert(ve);
if (ve != mgr->ve)
- pipe->bind_vertex_elements_state(pipe, ve->driver_cso);
+ pipe->bind_vertex_elements_state(pipe, ve->driver_cso);
+
return ve;
}
diff --git a/mesalib/src/glsl/Makefile.sources b/mesalib/src/glsl/Makefile.sources
index 2131ddafb..cb8d5a6f7 100644
--- a/mesalib/src/glsl/Makefile.sources
+++ b/mesalib/src/glsl/Makefile.sources
@@ -76,6 +76,7 @@ LIBGLSL_FILES = \
$(GLSL_SRCDIR)/lower_vec_index_to_swizzle.cpp \
$(GLSL_SRCDIR)/lower_vector.cpp \
$(GLSL_SRCDIR)/lower_vector_insert.cpp \
+ $(GLSL_SRCDIR)/lower_vertex_id.cpp \
$(GLSL_SRCDIR)/lower_output_reads.cpp \
$(GLSL_SRCDIR)/lower_ubo_reference.cpp \
$(GLSL_SRCDIR)/opt_algebraic.cpp \
diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp
index 897505c60..5ec1614be 100644
--- a/mesalib/src/glsl/ast_to_hir.cpp
+++ b/mesalib/src/glsl/ast_to_hir.cpp
@@ -3202,6 +3202,41 @@ validate_identifier(const char *identifier, YYLTYPE loc,
}
}
+static bool
+precision_qualifier_allowed(const glsl_type *type)
+{
+ /* Precision qualifiers apply to floating point, integer and sampler
+ * types.
+ *
+ * Section 4.5.2 (Precision Qualifiers) of the GLSL 1.30 spec says:
+ * "Any floating point or any integer declaration can have the type
+ * preceded by one of these precision qualifiers [...] Literal
+ * constants do not have precision qualifiers. Neither do Boolean
+ * variables.
+ *
+ * Section 4.5 (Precision and Precision Qualifiers) of the GLSL 1.30
+ * spec also says:
+ *
+ * "Precision qualifiers are added for code portability with OpenGL
+ * ES, not for functionality. They have the same syntax as in OpenGL
+ * ES."
+ *
+ * Section 8 (Built-In Functions) of the GLSL ES 1.00 spec says:
+ *
+ * "uniform lowp sampler2D sampler;
+ * highp vec2 coord;
+ * ...
+ * lowp vec4 col = texture2D (sampler, coord);
+ * // texture2D returns lowp"
+ *
+ * From this, we infer that GLSL 1.30 (and later) should allow precision
+ * qualifiers on sampler types just like float and integer types.
+ */
+ return type->is_float()
+ || type->is_integer()
+ || type->is_record()
+ || type->is_sampler();
+}
ir_rvalue *
ast_declarator_list::hir(exec_list *instructions,
@@ -3689,41 +3724,13 @@ ast_declarator_list::hir(exec_list *instructions,
}
- /* Precision qualifiers apply to floating point, integer and sampler
- * types.
- *
- * Section 4.5.2 (Precision Qualifiers) of the GLSL 1.30 spec says:
- * "Any floating point or any integer declaration can have the type
- * preceded by one of these precision qualifiers [...] Literal
- * constants do not have precision qualifiers. Neither do Boolean
- * variables.
- *
- * Section 4.5 (Precision and Precision Qualifiers) of the GLSL 1.30
- * spec also says:
- *
- * "Precision qualifiers are added for code portability with OpenGL
- * ES, not for functionality. They have the same syntax as in OpenGL
- * ES."
- *
- * Section 8 (Built-In Functions) of the GLSL ES 1.00 spec says:
- *
- * "uniform lowp sampler2D sampler;
- * highp vec2 coord;
- * ...
- * lowp vec4 col = texture2D (sampler, coord);
- * // texture2D returns lowp"
- *
- * From this, we infer that GLSL 1.30 (and later) should allow precision
- * qualifiers on sampler types just like float and integer types.
+ /* If a precision qualifier is allowed on a type, it is allowed on
+ * an array of that type.
*/
- if (this->type->qualifier.precision != ast_precision_none
- && !var->type->is_float()
- && !var->type->is_integer()
- && !var->type->is_record()
- && !var->type->is_sampler()
- && !(var->type->is_array()
- && (var->type->fields.array->is_float()
- || var->type->fields.array->is_integer()))) {
+ if (!(this->type->qualifier.precision == ast_precision_none
+ || precision_qualifier_allowed(var->type)
+ || (var->type->is_array()
+ && precision_qualifier_allowed(var->type->fields.array)))) {
_mesa_glsl_error(&loc, state,
"precision qualifiers apply only to floating point"
@@ -5455,7 +5462,7 @@ ast_interface_block::hir(exec_list *instructions,
}
if (this->instance_name != NULL) {
_mesa_glsl_error(&loc, state,
- "gl_PerVertex input may not be redeclared with "
+ "gl_PerVertex output may not be redeclared with "
"an instance name");
}
break;
diff --git a/mesalib/src/glsl/ir_optimization.h b/mesalib/src/glsl/ir_optimization.h
index 1c6f72b54..369dcd15b 100644
--- a/mesalib/src/glsl/ir_optimization.h
+++ b/mesalib/src/glsl/ir_optimization.h
@@ -126,6 +126,8 @@ bool optimize_redundant_jumps(exec_list *instructions);
bool optimize_split_arrays(exec_list *instructions, bool linked);
bool lower_offset_arrays(exec_list *instructions);
+bool lower_vertex_id(gl_shader *shader);
+
ir_rvalue *
compare_index_block(exec_list *instructions, ir_variable *index,
unsigned base, unsigned components, void *mem_ctx);
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index 57be4931d..7689198b0 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -559,14 +559,21 @@ validate_vertex_shader_executable(struct gl_shader_program *prog,
* 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.
+ * All GLSL ES Versions are similar to GLSL 1.40--failing to write to
+ * gl_Position is not an error.
*/
if (prog->Version < (prog->IsES ? 300 : 140)) {
find_assignment_visitor find("gl_Position");
find.run(shader->ir);
if (!find.variable_found()) {
- linker_error(prog, "vertex shader does not write to `gl_Position'\n");
+ if (prog->IsES) {
+ linker_warning(prog,
+ "vertex shader does not write to `gl_Position'."
+ "It's value is undefined. \n");
+ } else {
+ linker_error(prog,
+ "vertex shader does not write to `gl_Position'. \n");
+ }
return;
}
}
@@ -1115,8 +1122,8 @@ move_non_declarations(exec_list *instructions, exec_node *last,
/**
* Get the function signature for main from a shader
*/
-static ir_function_signature *
-get_main_function_signature(gl_shader *sh)
+ir_function_signature *
+link_get_main_function_signature(gl_shader *sh)
{
ir_function *const f = sh->symbols->get_function("main");
if (f != NULL) {
@@ -1644,7 +1651,7 @@ link_intrastage_shaders(void *mem_ctx,
*/
gl_shader *main = NULL;
for (unsigned i = 0; i < num_shaders; i++) {
- if (get_main_function_signature(shader_list[i]) != NULL) {
+ if (link_get_main_function_signature(shader_list[i]) != NULL) {
main = shader_list[i];
break;
}
@@ -1673,7 +1680,8 @@ link_intrastage_shaders(void *mem_ctx,
/* The a pointer to the main function in the final linked shader (i.e., the
* copy of the original shader that contained the main function).
*/
- ir_function_signature *const main_sig = get_main_function_signature(linked);
+ ir_function_signature *const main_sig =
+ link_get_main_function_signature(linked);
/* Move any instructions other than variable declarations or function
* declarations into main.
@@ -1736,6 +1744,9 @@ link_intrastage_shaders(void *mem_ctx,
}
}
+ if (ctx->Const.VertexID_is_zero_based)
+ lower_vertex_id(linked);
+
/* Make a pass over all variable declarations to ensure that arrays with
* unspecified sizes have a size specified. The size is inferred from the
* max_array_access field.
diff --git a/mesalib/src/glsl/linker.h b/mesalib/src/glsl/linker.h
index beb9bb216..9440794e2 100644
--- a/mesalib/src/glsl/linker.h
+++ b/mesalib/src/glsl/linker.h
@@ -26,6 +26,9 @@
#ifndef GLSL_LINKER_H
#define GLSL_LINKER_H
+ir_function_signature *
+link_get_main_function_signature(gl_shader *sh);
+
extern bool
link_function_calls(gl_shader_program *prog, gl_shader *main,
gl_shader **shader_list, unsigned num_shaders);
diff --git a/mesalib/src/glsl/loop_analysis.h b/mesalib/src/glsl/loop_analysis.h
index 295dc797c..31be4f3cf 100644
--- a/mesalib/src/glsl/loop_analysis.h
+++ b/mesalib/src/glsl/loop_analysis.h
@@ -205,10 +205,10 @@ public:
inline bool is_loop_constant() const
{
const bool is_const = (this->num_assignments == 0)
- || ((this->num_assignments == 1)
+ || (((this->num_assignments == 1)
&& !this->conditional_or_nested_assignment
&& !this->read_before_write
- && this->rhs_clean);
+ && this->rhs_clean) || this->var->data.read_only);
/* If the RHS of *the* assignment is clean, then there must be exactly
* one assignment of the variable.
@@ -216,11 +216,6 @@ public:
assert((this->rhs_clean && (this->num_assignments == 1))
|| !this->rhs_clean);
- /* Variables that are marked read-only *MUST* be loop constant.
- */
- assert(!this->var->data.read_only
- || (this->var->data.read_only && is_const));
-
return is_const;
}
diff --git a/mesalib/src/glsl/lower_vertex_id.cpp b/mesalib/src/glsl/lower_vertex_id.cpp
new file mode 100644
index 000000000..fc90bc8e6
--- /dev/null
+++ b/mesalib/src/glsl/lower_vertex_id.cpp
@@ -0,0 +1,144 @@
+/*
+ * Copyright © 2014 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.
+ */
+
+/**
+ * \file lower_vertex_id.cpp
+ *
+ * There exists hardware, such as i965, that does not implement the OpenGL
+ * semantic for gl_VertexID. Instead, that hardware does not include the
+ * value of basevertex in the gl_VertexID value. To implement the OpenGL
+ * semantic, we'll have to convert gl_Vertex_ID to
+ * gl_VertexIDMESA+gl_BaseVertexMESA.
+ */
+
+#include "glsl_symbol_table.h"
+#include "ir_hierarchical_visitor.h"
+#include "ir.h"
+#include "ir_builder.h"
+#include "linker.h"
+#include "program/prog_statevars.h"
+
+namespace {
+
+class lower_vertex_id_visitor : public ir_hierarchical_visitor {
+public:
+ explicit lower_vertex_id_visitor(ir_function_signature *main_sig,
+ exec_list *ir_list)
+ : progress(false), VertexID(NULL), gl_VertexID(NULL),
+ gl_BaseVertex(NULL), main_sig(main_sig), ir_list(ir_list)
+ {
+ foreach_in_list(ir_instruction, ir, ir_list) {
+ ir_variable *const var = ir->as_variable();
+
+ if (var != NULL && var->data.mode == ir_var_system_value &&
+ var->data.location == SYSTEM_VALUE_BASE_VERTEX) {
+ gl_BaseVertex = var;
+ break;
+ }
+ }
+ }
+
+ virtual ir_visitor_status visit(ir_dereference_variable *);
+
+ bool progress;
+
+private:
+ ir_variable *VertexID;
+ ir_variable *gl_VertexID;
+ ir_variable *gl_BaseVertex;
+
+ ir_function_signature *main_sig;
+ exec_list *ir_list;
+};
+
+} /* anonymous namespace */
+
+ir_visitor_status
+lower_vertex_id_visitor::visit(ir_dereference_variable *ir)
+{
+ if (ir->var->data.mode != ir_var_system_value ||
+ ir->var->data.location != SYSTEM_VALUE_VERTEX_ID)
+ return visit_continue;
+
+ if (VertexID == NULL) {
+ const glsl_type *const int_t = glsl_type::int_type;
+ void *const mem_ctx = ralloc_parent(ir);
+
+ VertexID = new(mem_ctx) ir_variable(int_t, "__VertexID",
+ ir_var_temporary);
+ ir_list->push_head(VertexID);
+
+ gl_VertexID = new(mem_ctx) ir_variable(int_t, "gl_VertexIDMESA",
+ ir_var_system_value);
+ gl_VertexID->data.how_declared = ir_var_declared_implicitly;
+ gl_VertexID->data.read_only = true;
+ gl_VertexID->data.location = SYSTEM_VALUE_VERTEX_ID_ZERO_BASE;
+ gl_VertexID->data.explicit_location = true;
+ gl_VertexID->data.explicit_index = 0;
+ ir_list->push_head(gl_VertexID);
+
+ if (gl_BaseVertex == NULL) {
+ gl_BaseVertex = new(mem_ctx) ir_variable(int_t, "gl_BaseVertex",
+ ir_var_system_value);
+ gl_BaseVertex->data.how_declared = ir_var_declared_implicitly;
+ gl_BaseVertex->data.read_only = true;
+ gl_BaseVertex->data.location = SYSTEM_VALUE_BASE_VERTEX;
+ gl_BaseVertex->data.explicit_location = true;
+ gl_BaseVertex->data.explicit_index = 0;
+ ir_list->push_head(gl_BaseVertex);
+ }
+
+ ir_instruction *const inst =
+ ir_builder::assign(VertexID,
+ ir_builder::add(gl_VertexID, gl_BaseVertex));
+
+ main_sig->body.push_head(inst);
+ }
+
+ ir->var = VertexID;
+ progress = true;
+
+ return visit_continue;
+}
+
+bool
+lower_vertex_id(gl_shader *shader)
+{
+ /* gl_VertexID only exists in the vertex shader.
+ */
+ if (shader->Stage != MESA_SHADER_VERTEX)
+ return false;
+
+ ir_function_signature *const main_sig =
+ link_get_main_function_signature(shader);
+ if (main_sig == NULL) {
+ assert(main_sig != NULL);
+ return false;
+ }
+
+ lower_vertex_id_visitor v(main_sig, shader->ir);
+
+ v.run(shader->ir);
+
+ return v.progress;
+}
diff --git a/mesalib/src/glsl/opt_constant_folding.cpp b/mesalib/src/glsl/opt_constant_folding.cpp
index d0e575460..74b855e5e 100644
--- a/mesalib/src/glsl/opt_constant_folding.cpp
+++ b/mesalib/src/glsl/opt_constant_folding.cpp
@@ -79,6 +79,11 @@ ir_constant_folding_visitor::handle_rvalue(ir_rvalue **rvalue)
}
}
+ /* Ditto for swizzles. */
+ ir_swizzle *swiz = (*rvalue)->as_swizzle();
+ if (swiz && !swiz->val->as_constant())
+ return;
+
ir_constant *constant = (*rvalue)->constant_expression_value();
if (constant) {
*rvalue = constant;
diff --git a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c
index ce376475c..8e48522e2 100644
--- a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c
+++ b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c
@@ -429,8 +429,10 @@ static void
__driUtilMessage(const char *f, ...)
{
va_list args;
+ const char *libgl_debug;
- if (getenv("LIBGL_DEBUG")) {
+ libgl_debug=getenv("LIBGL_DEBUG");
+ if (libgl_debug && !strstr(libgl_debug, "quiet")) {
fprintf(stderr, "libGL: ");
va_start(args, f);
vfprintf(stderr, f, args);
diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast.c b/mesalib/src/mesa/drivers/dri/swrast/swrast.c
index e28991b0c..e8a2c12d7 100644
--- a/mesalib/src/mesa/drivers/dri/swrast/swrast.c
+++ b/mesalib/src/mesa/drivers/dri/swrast/swrast.c
@@ -772,9 +772,6 @@ dri_create_context(gl_api api,
driContextSetFlags(mesaCtx, flags);
- /* do bounds checking to prevent segfaults and server crashes! */
- mesaCtx->Const.CheckArrayBounds = GL_TRUE;
-
/* create module contexts */
_swrast_CreateContext( mesaCtx );
_vbo_CreateContext( mesaCtx );
diff --git a/mesalib/src/mesa/main/api_validate.c b/mesalib/src/mesa/main/api_validate.c
index 8f0b1998d..51a3d1f01 100644
--- a/mesalib/src/mesa/main/api_validate.c
+++ b/mesalib/src/mesa/main/api_validate.c
@@ -160,47 +160,6 @@ check_valid_to_render(struct gl_context *ctx, const char *function)
/**
- * Do bounds checking on array element indexes. Check that the vertices
- * pointed to by the indices don't lie outside buffer object bounds.
- * \return GL_TRUE if OK, GL_FALSE if any indexed vertex goes is out of bounds
- */
-static GLboolean
-check_index_bounds(struct gl_context *ctx, GLsizei count, GLenum type,
- const GLvoid *indices, GLint basevertex)
-{
- struct _mesa_prim prim;
- struct _mesa_index_buffer ib;
- GLuint min, max;
-
- /* Only the X Server needs to do this -- otherwise, accessing outside
- * array/BO bounds allows application termination.
- */
- if (!ctx->Const.CheckArrayBounds)
- return GL_TRUE;
-
- memset(&prim, 0, sizeof(prim));
- prim.count = count;
-
- memset(&ib, 0, sizeof(ib));
- ib.type = type;
- ib.ptr = indices;
- ib.obj = ctx->Array.VAO->IndexBufferObj;
-
- vbo_get_minmax_indices(ctx, &prim, &ib, &min, &max, 1);
-
- if ((int)(min + basevertex) < 0 ||
- max + basevertex >= ctx->Array.VAO->_MaxElement) {
- /* the max element is out of bounds of one or more enabled arrays */
- _mesa_warning(ctx, "glDrawElements() index=%u is out of bounds (max=%u)",
- max, ctx->Array.VAO->_MaxElement);
- return GL_FALSE;
- }
-
- return GL_TRUE;
-}
-
-
-/**
* Is 'mode' a valid value for glBegin(), glDrawArrays(), glDrawElements(),
* etc? The set of legal values depends on whether geometry shaders/programs
* are supported.
@@ -453,9 +412,6 @@ _mesa_validate_DrawElements(struct gl_context *ctx,
return GL_FALSE;
}
- if (!check_index_bounds(ctx, count, type, indices, basevertex))
- return GL_FALSE;
-
if (count == 0)
return GL_FALSE;
@@ -517,12 +473,6 @@ _mesa_validate_MultiDrawElements(struct gl_context *ctx,
}
}
- for (i = 0; i < primcount; i++) {
- if (!check_index_bounds(ctx, count[i], type, indices[i],
- basevertex ? basevertex[i] : 0))
- return GL_FALSE;
- }
-
return GL_TRUE;
}
@@ -588,9 +538,6 @@ _mesa_validate_DrawRangeElements(struct gl_context *ctx, GLenum mode,
return GL_FALSE;
}
- if (!check_index_bounds(ctx, count, type, indices, basevertex))
- return GL_FALSE;
-
if (count == 0)
return GL_FALSE;
@@ -623,11 +570,6 @@ _mesa_validate_DrawArrays(struct gl_context *ctx,
if (!check_valid_to_render(ctx, "glDrawArrays"))
return GL_FALSE;
- if (ctx->Const.CheckArrayBounds) {
- if (start + count > (GLint) ctx->Array.VAO->_MaxElement)
- return GL_FALSE;
- }
-
/* From the GLES3 specification, section 2.14.2 (Transform Feedback
* Primitive Capture):
*
@@ -692,11 +634,6 @@ _mesa_validate_DrawArraysInstanced(struct gl_context *ctx, GLenum mode, GLint fi
if (!check_valid_to_render(ctx, "glDrawArraysInstanced(invalid to render)"))
return GL_FALSE;
- if (ctx->Const.CheckArrayBounds) {
- if (first + count > (GLint) ctx->Array.VAO->_MaxElement)
- return GL_FALSE;
- }
-
/* From the GLES3 specification, section 2.14.2 (Transform Feedback
* Primitive Capture):
*
@@ -791,9 +728,6 @@ _mesa_validate_DrawElementsInstanced(struct gl_context *ctx,
if (count == 0)
return GL_FALSE;
- if (!check_index_bounds(ctx, count, type, indices, basevertex))
- return GL_FALSE;
-
return GL_TRUE;
}
diff --git a/mesalib/src/mesa/main/arrayobj.c b/mesalib/src/mesa/main/arrayobj.c
index 1ea319a74..0d77b112b 100644
--- a/mesalib/src/mesa/main/arrayobj.c
+++ b/mesalib/src/mesa/main/arrayobj.c
@@ -291,52 +291,6 @@ remove_array_object( struct gl_context *ctx, struct gl_vertex_array_object *obj
}
-
-/**
- * Helper for _mesa_update_vao_max_element().
- * \return min(vao->_VertexAttrib[*]._MaxElement).
- */
-static GLuint
-compute_max_element(struct gl_vertex_array_object *vao, GLbitfield64 enabled)
-{
- GLuint min = ~((GLuint)0);
-
- while (enabled) {
- struct gl_client_array *client_array;
- GLint attrib = ffsll(enabled) - 1;
- enabled ^= BITFIELD64_BIT(attrib);
-
- client_array = &vao->_VertexAttrib[attrib];
- assert(client_array->Enabled);
- _mesa_update_array_max_element(client_array);
- min = MIN2(min, client_array->_MaxElement);
- }
-
- return min;
-}
-
-
-/**
- * Examine vertex arrays to update the gl_vertex_array_object::_MaxElement field.
- */
-void
-_mesa_update_vao_max_element(struct gl_context *ctx,
- struct gl_vertex_array_object *vao)
-{
- GLbitfield64 enabled;
-
- if (!ctx->VertexProgram._Current ||
- ctx->VertexProgram._Current == ctx->VertexProgram._TnlProgram) {
- enabled = _mesa_array_object_get_enabled_ff(vao);
- } else {
- enabled = _mesa_array_object_get_enabled_arb(vao);
- }
-
- /* _MaxElement is one past the last legal array element */
- vao->_MaxElement = compute_max_element(vao, enabled);
-}
-
-
/**
* Updates the derived gl_client_arrays when a gl_vertex_attrib_array
* or a gl_vertex_buffer_binding has changed.
diff --git a/mesalib/src/mesa/main/arrayobj.h b/mesalib/src/mesa/main/arrayobj.h
index d72761db1..1819cd12a 100644
--- a/mesalib/src/mesa/main/arrayobj.h
+++ b/mesalib/src/mesa/main/arrayobj.h
@@ -75,10 +75,6 @@ _mesa_initialize_vao(struct gl_context *ctx,
extern void
-_mesa_update_vao_max_element(struct gl_context *ctx,
- struct gl_vertex_array_object *vao);
-
-extern void
_mesa_update_vao_client_arrays(struct gl_context *ctx,
struct gl_vertex_array_object *vao);
diff --git a/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c
index 2e289b6f1..ef98ba7fd 100644
--- a/mesalib/src/mesa/main/attrib.c
+++ b/mesalib/src/mesa/main/attrib.c
@@ -1458,7 +1458,6 @@ copy_array_object(struct gl_context *ctx,
/* _Enabled must be the same than on push */
dest->_Enabled = src->_Enabled;
dest->NewArrays = src->NewArrays;
- dest->_MaxElement = src->_MaxElement;
}
/**
diff --git a/mesalib/src/mesa/main/buffers.c b/mesalib/src/mesa/main/buffers.c
index 8a0852c42..1ee20098d 100644
--- a/mesalib/src/mesa/main/buffers.c
+++ b/mesalib/src/mesa/main/buffers.c
@@ -32,7 +32,6 @@
#include "glheader.h"
#include "buffers.h"
-#include "colormac.h"
#include "context.h"
#include "enums.h"
#include "fbobject.h"
diff --git a/mesalib/src/mesa/main/clear.c b/mesalib/src/mesa/main/clear.c
index cf93418d1..f7f15cf59 100644
--- a/mesalib/src/mesa/main/clear.c
+++ b/mesalib/src/mesa/main/clear.c
@@ -33,7 +33,6 @@
#include "glheader.h"
#include "clear.h"
#include "context.h"
-#include "colormac.h"
#include "enums.h"
#include "macros.h"
#include "mtypes.h"
diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c
index 8b5693e37..682b9c797 100644
--- a/mesalib/src/mesa/main/context.c
+++ b/mesalib/src/mesa/main/context.c
@@ -622,8 +622,11 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api)
consts->MaxProgramMatrices = MAX_PROGRAM_MATRICES;
consts->MaxProgramMatrixStackDepth = MAX_PROGRAM_MATRIX_STACK_DEPTH;
- /* CheckArrayBounds is overriden by drivers/x11 for X server */
- consts->CheckArrayBounds = GL_FALSE;
+ /* Assume that if GLSL 1.30+ (or GLSL ES 3.00+) is supported that
+ * gl_VertexID is implemented using a native hardware register with OpenGL
+ * semantics.
+ */
+ consts->VertexID_is_zero_based = false;
/* GL_ARB_draw_buffers */
consts->MaxDrawBuffers = MAX_DRAW_BUFFERS;
@@ -1501,7 +1504,10 @@ handle_first_current(struct gl_context *ctx)
GLenum buffer;
GLint bufferIndex;
- assert(ctx->Version > 0);
+ if (ctx->Version == 0) {
+ /* probably in the process of tearing down the context */
+ return;
+ }
ctx->Extensions.String = _mesa_make_extension_string(ctx);
diff --git a/mesalib/src/mesa/main/convolve.c b/mesalib/src/mesa/main/convolve.c
index b13b89535..83d590f4a 100644
--- a/mesalib/src/mesa/main/convolve.c
+++ b/mesalib/src/mesa/main/convolve.c
@@ -32,11 +32,8 @@
#include "glheader.h"
-#include "bufferobj.h"
-#include "colormac.h"
+#include "context.h"
#include "convolve.h"
-#include "macros.h"
-#include "mtypes.h"
#include "main/dispatch.h"
diff --git a/mesalib/src/mesa/main/eval.c b/mesalib/src/mesa/main/eval.c
index 42793ff4c..84cd7563b 100644
--- a/mesalib/src/mesa/main/eval.c
+++ b/mesalib/src/mesa/main/eval.c
@@ -39,7 +39,6 @@
#include "glheader.h"
#include "imports.h"
-#include "colormac.h"
#include "context.h"
#include "eval.h"
#include "macros.h"
diff --git a/mesalib/src/mesa/main/feedback.c b/mesalib/src/mesa/main/feedback.c
index e751a3c1e..9ea0b92f3 100644
--- a/mesalib/src/mesa/main/feedback.c
+++ b/mesalib/src/mesa/main/feedback.c
@@ -30,7 +30,6 @@
#include "glheader.h"
-#include "colormac.h"
#include "context.h"
#include "enums.h"
#include "feedback.h"
diff --git a/mesalib/src/mesa/main/fog.c b/mesalib/src/mesa/main/fog.c
index 89153912e..3bce289e7 100644
--- a/mesalib/src/mesa/main/fog.c
+++ b/mesalib/src/mesa/main/fog.c
@@ -24,7 +24,6 @@
#include "glheader.h"
-#include "colormac.h"
#include "context.h"
#include "fog.h"
#include "macros.h"
diff --git a/mesalib/src/mesa/main/format_pack.c b/mesalib/src/mesa/main/format_pack.c
index 6cbf8593b..31c9f7767 100644
--- a/mesalib/src/mesa/main/format_pack.c
+++ b/mesalib/src/mesa/main/format_pack.c
@@ -1076,6 +1076,31 @@ pack_float_B8G8R8A8_SRGB(const GLfloat src[4], void *dst)
}
+/* MESA_FORMAT_A8R8G8B8_SRGB */
+
+static void
+pack_ubyte_A8R8G8B8_SRGB(const GLubyte src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLubyte r = util_format_linear_to_srgb_8unorm(src[RCOMP]);
+ GLubyte g = util_format_linear_to_srgb_8unorm(src[GCOMP]);
+ GLubyte b = util_format_linear_to_srgb_8unorm(src[BCOMP]);
+ *d = PACK_COLOR_8888(b, g, r, src[ACOMP]);
+}
+
+static void
+pack_float_A8R8G8B8_SRGB(const GLfloat src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLubyte r, g, b, a;
+ r = util_format_linear_float_to_srgb_8unorm(src[RCOMP]);
+ g = util_format_linear_float_to_srgb_8unorm(src[GCOMP]);
+ b = util_format_linear_float_to_srgb_8unorm(src[BCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(a, src[ACOMP]);
+ *d = PACK_COLOR_8888(b, g, r, a);
+}
+
+
/* MESA_FORMAT_R8G8B8A8_SRGB */
static void
@@ -1129,6 +1154,16 @@ pack_ubyte_L8A8_SRGB(const GLubyte src[4], void *dst)
*d = PACK_COLOR_88(src[ACOMP], l);
}
+/* MESA_FORMAT_A8L8_SRGB */
+
+static void
+pack_ubyte_A8L8_SRGB(const GLubyte src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ GLubyte l = util_format_linear_to_srgb_8unorm(src[RCOMP]);
+ *d = PACK_COLOR_88(l, src[ACOMP]);
+}
+
static void
pack_float_L8A8_SRGB(const GLfloat src[4], void *dst)
{
@@ -1138,6 +1173,15 @@ pack_float_L8A8_SRGB(const GLfloat src[4], void *dst)
*d = PACK_COLOR_88(a, l);
}
+static void
+pack_float_A8L8_SRGB(const GLfloat src[4], void *dst)
+{
+ GLushort *d = ((GLushort *) dst);
+ GLubyte a, l = util_format_linear_float_to_srgb_8unorm(src[RCOMP]);
+ CLAMPED_FLOAT_TO_UBYTE(a, src[ACOMP]);
+ *d = PACK_COLOR_88(l, a);
+}
+
/* MESA_FORMAT_RGBA_FLOAT32 */
@@ -1563,6 +1607,20 @@ pack_float_L8A8_SNORM(const GLfloat src[4], void *dst)
/*
+ * MESA_FORMAT_A8L8_SNORM
+ */
+
+static void
+pack_float_A8L8_SNORM(const GLfloat src[4], void *dst)
+{
+ GLushort *d = (GLushort *) dst;
+ GLbyte l = FLOAT_TO_BYTE(CLAMP(src[RCOMP], -1.0f, 1.0f));
+ GLbyte a = FLOAT_TO_BYTE(CLAMP(src[ACOMP], -1.0f, 1.0f));
+ *d = (l << 8) | a;
+}
+
+
+/*
* MESA_FORMAT_A_SNORM16
*/
@@ -1713,7 +1771,22 @@ pack_float_R8G8B8X8_SRGB(const GLfloat src[4], void *dst)
GLubyte r = util_format_linear_float_to_srgb_8unorm(src[RCOMP]);
GLubyte g = util_format_linear_float_to_srgb_8unorm(src[GCOMP]);
GLubyte b = util_format_linear_float_to_srgb_8unorm(src[BCOMP]);
- *d = PACK_COLOR_8888(127, b, g, r);
+ *d = PACK_COLOR_8888(255, b, g, r);
+}
+
+
+/*
+ * MESA_FORMAT_X8B8G8R8_SRGB
+ */
+
+static void
+pack_float_X8B8G8R8_SRGB(const GLfloat src[4], void *dst)
+{
+ GLuint *d = (GLuint *) dst;
+ GLubyte r = util_format_linear_float_to_srgb_8unorm(src[RCOMP]);
+ GLubyte g = util_format_linear_float_to_srgb_8unorm(src[GCOMP]);
+ GLubyte b = util_format_linear_float_to_srgb_8unorm(src[BCOMP]);
+ *d = PACK_COLOR_8888(r, g, b, 255);
}
@@ -1866,6 +1939,20 @@ pack_float_B8G8R8X8_SRGB(const GLfloat src[4], void *dst)
*d = PACK_COLOR_8888(127, r, g, b);
}
+/*
+ * MESA_FORMAT_X8R8G8B8_SRGB
+ */
+
+static void
+pack_float_X8R8G8B8_SRGB(const GLfloat src[4], void *dst)
+{
+ GLuint *d = (GLuint *) dst;
+ GLubyte r = util_format_linear_float_to_srgb_8unorm(src[RCOMP]);
+ GLubyte g = util_format_linear_float_to_srgb_8unorm(src[GCOMP]);
+ GLubyte b = util_format_linear_float_to_srgb_8unorm(src[BCOMP]);
+ *d = PACK_COLOR_8888(b, g, r, 255);
+}
+
/**
* Return a function that can pack a GLubyte rgba[4] color.
*/
@@ -1933,9 +2020,11 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format format)
table[MESA_FORMAT_BGR_SRGB8] = pack_ubyte_BGR_SRGB8;
table[MESA_FORMAT_A8B8G8R8_SRGB] = pack_ubyte_A8B8G8R8_SRGB;
table[MESA_FORMAT_B8G8R8A8_SRGB] = pack_ubyte_B8G8R8A8_SRGB;
+ table[MESA_FORMAT_A8R8G8B8_SRGB] = pack_ubyte_A8R8G8B8_SRGB;
table[MESA_FORMAT_R8G8B8A8_SRGB] = pack_ubyte_R8G8B8A8_SRGB;
table[MESA_FORMAT_L_SRGB8] = pack_ubyte_L_SRGB8;
table[MESA_FORMAT_L8A8_SRGB] = pack_ubyte_L8A8_SRGB;
+ table[MESA_FORMAT_A8L8_SRGB] = pack_ubyte_A8L8_SRGB;
/* n/a */
table[MESA_FORMAT_SRGB_DXT1] = NULL; /* pack_ubyte_SRGB_DXT1; */
table[MESA_FORMAT_SRGBA_DXT1] = NULL; /* pack_ubyte_SRGBA_DXT1; */
@@ -1989,6 +2078,7 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format format)
table[MESA_FORMAT_A_SNORM8] = NULL;
table[MESA_FORMAT_L_SNORM8] = NULL;
table[MESA_FORMAT_L8A8_SNORM] = NULL;
+ table[MESA_FORMAT_A8L8_SNORM] = NULL;
table[MESA_FORMAT_I_SNORM8] = NULL;
table[MESA_FORMAT_A_SNORM16] = NULL;
table[MESA_FORMAT_L_SNORM16] = NULL;
@@ -2005,6 +2095,7 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format format)
table[MESA_FORMAT_B5G5R5X1_UNORM] = pack_ubyte_XRGB1555_UNORM;
table[MESA_FORMAT_R8G8B8X8_SNORM] = NULL;
table[MESA_FORMAT_R8G8B8X8_SRGB] = NULL;
+ table[MESA_FORMAT_X8B8G8R8_SRGB] = NULL;
table[MESA_FORMAT_RGBX_UINT8] = NULL;
table[MESA_FORMAT_RGBX_SINT8] = NULL;
table[MESA_FORMAT_B10G10R10X2_UNORM] = pack_ubyte_B10G10R10X2_UNORM;
@@ -2020,6 +2111,7 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format format)
table[MESA_FORMAT_R10G10B10A2_UNORM] = pack_ubyte_R10G10B10A2_UNORM;
table[MESA_FORMAT_B8G8R8X8_SRGB] = NULL;
+ table[MESA_FORMAT_X8R8G8B8_SRGB] = NULL;
initialized = GL_TRUE;
}
@@ -2096,9 +2188,11 @@ _mesa_get_pack_float_rgba_function(mesa_format format)
table[MESA_FORMAT_BGR_SRGB8] = pack_float_BGR_SRGB8;
table[MESA_FORMAT_A8B8G8R8_SRGB] = pack_float_A8B8G8R8_SRGB;
table[MESA_FORMAT_B8G8R8A8_SRGB] = pack_float_B8G8R8A8_SRGB;
+ table[MESA_FORMAT_A8R8G8B8_SRGB] = pack_float_A8R8G8B8_SRGB;
table[MESA_FORMAT_R8G8B8A8_SRGB] = pack_float_R8G8B8A8_SRGB;
table[MESA_FORMAT_L_SRGB8] = pack_float_L_SRGB8;
table[MESA_FORMAT_L8A8_SRGB] = pack_float_L8A8_SRGB;
+ table[MESA_FORMAT_A8L8_SRGB] = pack_float_A8L8_SRGB;
/* n/a */
table[MESA_FORMAT_SRGB_DXT1] = NULL;
@@ -2153,6 +2247,7 @@ _mesa_get_pack_float_rgba_function(mesa_format format)
table[MESA_FORMAT_A_SNORM8] = pack_float_A_SNORM8;
table[MESA_FORMAT_L_SNORM8] = pack_float_L_SNORM8;
table[MESA_FORMAT_L8A8_SNORM] = pack_float_L8A8_SNORM;
+ table[MESA_FORMAT_A8L8_SNORM] = pack_float_A8L8_SNORM;
table[MESA_FORMAT_I_SNORM8] = pack_float_L_SNORM8; /* reused */
table[MESA_FORMAT_A_SNORM16] = pack_float_A_SNORM16;
table[MESA_FORMAT_L_SNORM16] = pack_float_L_SNORM16;
@@ -2166,6 +2261,7 @@ _mesa_get_pack_float_rgba_function(mesa_format format)
table[MESA_FORMAT_B5G5R5X1_UNORM] = pack_float_XRGB1555_UNORM;
table[MESA_FORMAT_R8G8B8X8_SNORM] = pack_float_XBGR8888_SNORM;
table[MESA_FORMAT_R8G8B8X8_SRGB] = pack_float_R8G8B8X8_SRGB;
+ table[MESA_FORMAT_X8B8G8R8_SRGB] = pack_float_X8B8G8R8_SRGB;
table[MESA_FORMAT_RGBX_UINT8] = NULL;
table[MESA_FORMAT_RGBX_SINT8] = NULL;
table[MESA_FORMAT_B10G10R10X2_UNORM] = pack_float_B10G10R10X2_UNORM;
@@ -2184,6 +2280,7 @@ _mesa_get_pack_float_rgba_function(mesa_format format)
table[MESA_FORMAT_G16R16_SNORM] = pack_float_G16R16_SNORM;
table[MESA_FORMAT_B8G8R8X8_SRGB] = pack_float_B8G8R8X8_SRGB;
+ table[MESA_FORMAT_X8R8G8B8_SRGB] = pack_float_X8R8G8B8_SRGB;
initialized = GL_TRUE;
}
diff --git a/mesalib/src/mesa/main/format_unpack.c b/mesalib/src/mesa/main/format_unpack.c
index b84ed0248..d5628a9e7 100644
--- a/mesalib/src/mesa/main/format_unpack.c
+++ b/mesalib/src/mesa/main/format_unpack.c
@@ -770,6 +770,19 @@ unpack_B8G8R8A8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
}
static void
+unpack_A8R8G8B8_SRGB(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] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 8) & 0xff );
+ dst[i][GCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 16) & 0xff );
+ dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 24) );
+ dst[i][ACOMP] = UBYTE_TO_FLOAT( s[i] & 0xff ); /* linear! */
+ }
+}
+
+static void
unpack_R8G8B8A8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
{
const GLuint *s = ((const GLuint *) src);
@@ -809,6 +822,19 @@ unpack_L8A8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
}
static void
+unpack_A8L8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLushort *s = (const GLushort *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] =
+ dst[i][GCOMP] =
+ dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float(s[i] >> 8);
+ dst[i][ACOMP] = UBYTE_TO_FLOAT(s[i] & 0xff); /* linear! */
+ }
+}
+
+static void
unpack_SRGB_DXT1(const void *src, GLfloat dst[][4], GLuint n)
{
}
@@ -1965,6 +1991,20 @@ unpack_L8A8_SNORM(const void *src, GLfloat dst[][4], GLuint n)
}
}
+
+static void
+unpack_A8L8_SNORM(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLshort *s = ((const GLshort *) src);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] =
+ dst[i][GCOMP] =
+ dst[i][BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s[i] >> 8) );
+ dst[i][ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s[i] & 0xff) );
+ }
+}
+
static void
unpack_I_SNORM8(const void *src, GLfloat dst[][4], GLuint n)
{
@@ -2079,7 +2119,7 @@ unpack_XRGB1555_UNORM(const void *src, GLfloat dst[][4], GLuint n)
}
static void
-unpack_XBGR8888_SNORM(const void *src, GLfloat dst[][4], GLuint n)
+unpack_R8G8B8X8_SNORM(const void *src, GLfloat dst[][4], GLuint n)
{
const GLuint *s = ((const GLuint *) src);
GLuint i;
@@ -2100,7 +2140,20 @@ unpack_R8G8B8X8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
dst[i][RCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] ) & 0xff );
dst[i][GCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 8) & 0xff );
dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 16) & 0xff );
- dst[i][ACOMP] = UBYTE_TO_FLOAT( s[i] >> 24 ); /* linear! */
+ dst[i][ACOMP] = 1.0f;
+ }
+}
+
+static void
+unpack_X8B8G8R8_SRGB(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] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 24) );
+ dst[i][GCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 16) & 0xff );
+ dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 8) & 0xff );
+ dst[i][ACOMP] = 1.0f;
}
}
@@ -2299,6 +2352,19 @@ unpack_B8G8R8X8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
}
}
+static void
+unpack_X8R8G8B8_SRGB(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] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 8) & 0xff );
+ dst[i][GCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 16) & 0xff );
+ dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 24) );
+ dst[i][ACOMP] = 1.0F;
+ }
+}
+
/**
* Return the unpacker function for the given format.
*/
@@ -2361,9 +2427,11 @@ get_unpack_rgba_function(mesa_format format)
table[MESA_FORMAT_BGR_SRGB8] = unpack_BGR_SRGB8;
table[MESA_FORMAT_A8B8G8R8_SRGB] = unpack_A8B8G8R8_SRGB;
table[MESA_FORMAT_B8G8R8A8_SRGB] = unpack_B8G8R8A8_SRGB;
+ table[MESA_FORMAT_A8R8G8B8_SRGB] = unpack_A8R8G8B8_SRGB;
table[MESA_FORMAT_R8G8B8A8_SRGB] = unpack_R8G8B8A8_SRGB;
table[MESA_FORMAT_L_SRGB8] = unpack_L_SRGB8;
table[MESA_FORMAT_L8A8_SRGB] = unpack_L8A8_SRGB;
+ table[MESA_FORMAT_A8L8_SRGB] = unpack_A8L8_SRGB;
table[MESA_FORMAT_SRGB_DXT1] = unpack_SRGB_DXT1;
table[MESA_FORMAT_SRGBA_DXT1] = unpack_SRGBA_DXT1;
table[MESA_FORMAT_SRGBA_DXT3] = unpack_SRGBA_DXT3;
@@ -2483,6 +2551,7 @@ get_unpack_rgba_function(mesa_format format)
table[MESA_FORMAT_A_SNORM8] = unpack_A_SNORM8;
table[MESA_FORMAT_L_SNORM8] = unpack_L_SNORM8;
table[MESA_FORMAT_L8A8_SNORM] = unpack_L8A8_SNORM;
+ table[MESA_FORMAT_A8L8_SNORM] = unpack_A8L8_SNORM;
table[MESA_FORMAT_I_SNORM8] = unpack_I_SNORM8;
table[MESA_FORMAT_A_SNORM16] = unpack_A_SNORM16;
table[MESA_FORMAT_L_SNORM16] = unpack_L_SNORM16;
@@ -2497,8 +2566,9 @@ get_unpack_rgba_function(mesa_format format)
table[MESA_FORMAT_B4G4R4X4_UNORM] = unpack_XRGB4444_UNORM;
table[MESA_FORMAT_B5G5R5X1_UNORM] = unpack_XRGB1555_UNORM;
- table[MESA_FORMAT_R8G8B8X8_SNORM] = unpack_XBGR8888_SNORM;
+ table[MESA_FORMAT_R8G8B8X8_SNORM] = unpack_R8G8B8X8_SNORM;
table[MESA_FORMAT_R8G8B8X8_SRGB] = unpack_R8G8B8X8_SRGB;
+ table[MESA_FORMAT_X8B8G8R8_SRGB] = unpack_X8B8G8R8_SRGB;
table[MESA_FORMAT_RGBX_UINT8] = unpack_XBGR8888_UINT;
table[MESA_FORMAT_RGBX_SINT8] = unpack_XBGR8888_SINT;
table[MESA_FORMAT_B10G10R10X2_UNORM] = unpack_B10G10R10X2_UNORM;
@@ -2517,6 +2587,7 @@ get_unpack_rgba_function(mesa_format format)
table[MESA_FORMAT_G16R16_SNORM] = unpack_G16R16_SNORM;
table[MESA_FORMAT_B8G8R8X8_SRGB] = unpack_B8G8R8X8_SRGB;
+ table[MESA_FORMAT_X8R8G8B8_SRGB] = unpack_X8R8G8B8_SRGB;
initialized = GL_TRUE;
}
diff --git a/mesalib/src/mesa/main/format_utils.c b/mesalib/src/mesa/main/format_utils.c
index 240e3bc0c..93a0ceac0 100644
--- a/mesalib/src/mesa/main/format_utils.c
+++ b/mesalib/src/mesa/main/format_utils.c
@@ -312,25 +312,28 @@ swizzle_convert_try_memcpy(void *dst, GLenum dst_type, int num_dst_channels,
* format
*/
#define SWIZZLE_CONVERT_LOOP(DST_TYPE, DST_CHANS, SRC_TYPE, SRC_CHANS, CONV) \
- for (s = 0; s < count; ++s) { \
- for (j = 0; j < SRC_CHANS; ++j) { \
- SRC_TYPE src = typed_src[j]; \
- tmp[j] = CONV; \
- } \
- \
- typed_dst[0] = tmp[swizzle_x]; \
- if (DST_CHANS > 1) { \
- typed_dst[1] = tmp[swizzle_y]; \
- if (DST_CHANS > 2) { \
- typed_dst[2] = tmp[swizzle_z]; \
- if (DST_CHANS > 3) { \
- typed_dst[3] = tmp[swizzle_w]; \
- } \
- } \
- } \
- typed_src += SRC_CHANS; \
- typed_dst += DST_CHANS; \
- } \
+ do { \
+ int s, j; \
+ for (s = 0; s < count; ++s) { \
+ for (j = 0; j < SRC_CHANS; ++j) { \
+ SRC_TYPE src = typed_src[j]; \
+ tmp[j] = CONV; \
+ } \
+ \
+ typed_dst[0] = tmp[swizzle_x]; \
+ if (DST_CHANS > 1) { \
+ typed_dst[1] = tmp[swizzle_y]; \
+ if (DST_CHANS > 2) { \
+ typed_dst[2] = tmp[swizzle_z]; \
+ if (DST_CHANS > 3) { \
+ typed_dst[3] = tmp[swizzle_w]; \
+ } \
+ } \
+ } \
+ typed_src += SRC_CHANS; \
+ typed_dst += DST_CHANS; \
+ } \
+ } while (0)
/**
* Represents a single swizzle-and-convert operation
@@ -352,6 +355,10 @@ swizzle_convert_try_memcpy(void *dst, GLenum dst_type, int num_dst_channels,
*/
#define SWIZZLE_CONVERT(DST_TYPE, SRC_TYPE, CONV) \
do { \
+ const uint8_t swizzle_x = swizzle[0]; \
+ const uint8_t swizzle_y = swizzle[1]; \
+ const uint8_t swizzle_z = swizzle[2]; \
+ const uint8_t swizzle_w = swizzle[3]; \
const SRC_TYPE *typed_src = void_src; \
DST_TYPE *typed_dst = void_dst; \
DST_TYPE tmp[7]; \
@@ -361,69 +368,589 @@ swizzle_convert_try_memcpy(void *dst, GLenum dst_type, int num_dst_channels,
case 1: \
switch (num_src_channels) { \
case 1: \
- SWIZZLE_CONVERT_LOOP(DST_TYPE, 1, SRC_TYPE, 1, CONV) \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 1, SRC_TYPE, 1, CONV); \
break; \
case 2: \
- SWIZZLE_CONVERT_LOOP(DST_TYPE, 1, SRC_TYPE, 2, CONV) \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 1, SRC_TYPE, 2, CONV); \
break; \
case 3: \
- SWIZZLE_CONVERT_LOOP(DST_TYPE, 1, SRC_TYPE, 3, CONV) \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 1, SRC_TYPE, 3, CONV); \
break; \
case 4: \
- SWIZZLE_CONVERT_LOOP(DST_TYPE, 1, SRC_TYPE, 4, CONV) \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 1, SRC_TYPE, 4, CONV); \
break; \
} \
break; \
case 2: \
switch (num_src_channels) { \
case 1: \
- SWIZZLE_CONVERT_LOOP(DST_TYPE, 2, SRC_TYPE, 1, CONV) \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 2, SRC_TYPE, 1, CONV); \
break; \
case 2: \
- SWIZZLE_CONVERT_LOOP(DST_TYPE, 2, SRC_TYPE, 2, CONV) \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 2, SRC_TYPE, 2, CONV); \
break; \
case 3: \
- SWIZZLE_CONVERT_LOOP(DST_TYPE, 2, SRC_TYPE, 3, CONV) \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 2, SRC_TYPE, 3, CONV); \
break; \
case 4: \
- SWIZZLE_CONVERT_LOOP(DST_TYPE, 2, SRC_TYPE, 4, CONV) \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 2, SRC_TYPE, 4, CONV); \
break; \
} \
break; \
case 3: \
switch (num_src_channels) { \
case 1: \
- SWIZZLE_CONVERT_LOOP(DST_TYPE, 3, SRC_TYPE, 1, CONV) \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 3, SRC_TYPE, 1, CONV); \
break; \
case 2: \
- SWIZZLE_CONVERT_LOOP(DST_TYPE, 3, SRC_TYPE, 2, CONV) \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 3, SRC_TYPE, 2, CONV); \
break; \
case 3: \
- SWIZZLE_CONVERT_LOOP(DST_TYPE, 3, SRC_TYPE, 3, CONV) \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 3, SRC_TYPE, 3, CONV); \
break; \
case 4: \
- SWIZZLE_CONVERT_LOOP(DST_TYPE, 3, SRC_TYPE, 4, CONV) \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 3, SRC_TYPE, 4, CONV); \
break; \
} \
break; \
case 4: \
switch (num_src_channels) { \
case 1: \
- SWIZZLE_CONVERT_LOOP(DST_TYPE, 4, SRC_TYPE, 1, CONV) \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 4, SRC_TYPE, 1, CONV); \
break; \
case 2: \
- SWIZZLE_CONVERT_LOOP(DST_TYPE, 4, SRC_TYPE, 2, CONV) \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 4, SRC_TYPE, 2, CONV); \
break; \
case 3: \
- SWIZZLE_CONVERT_LOOP(DST_TYPE, 4, SRC_TYPE, 3, CONV) \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 4, SRC_TYPE, 3, CONV); \
break; \
case 4: \
- SWIZZLE_CONVERT_LOOP(DST_TYPE, 4, SRC_TYPE, 4, CONV) \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 4, SRC_TYPE, 4, CONV); \
break; \
} \
break; \
} \
- } while (0);
+ } while (0)
+
+
+static void
+convert_float(void *void_dst, int num_dst_channels,
+ const void *void_src, GLenum src_type, int num_src_channels,
+ const uint8_t swizzle[4], bool normalized, int count)
+{
+ const float one = 1.0f;
+
+ switch (src_type) {
+ case GL_FLOAT:
+ SWIZZLE_CONVERT(float, float, src);
+ break;
+ case GL_HALF_FLOAT:
+ SWIZZLE_CONVERT(float, uint16_t, _mesa_half_to_float(src));
+ break;
+ case GL_UNSIGNED_BYTE:
+ if (normalized) {
+ SWIZZLE_CONVERT(float, uint8_t, unorm_to_float(src, 8));
+ } else {
+ SWIZZLE_CONVERT(float, uint8_t, src);
+ }
+ break;
+ case GL_BYTE:
+ if (normalized) {
+ SWIZZLE_CONVERT(float, int8_t, snorm_to_float(src, 8));
+ } else {
+ SWIZZLE_CONVERT(float, int8_t, src);
+ }
+ break;
+ case GL_UNSIGNED_SHORT:
+ if (normalized) {
+ SWIZZLE_CONVERT(float, uint16_t, unorm_to_float(src, 16));
+ } else {
+ SWIZZLE_CONVERT(float, uint16_t, src);
+ }
+ break;
+ case GL_SHORT:
+ if (normalized) {
+ SWIZZLE_CONVERT(float, int16_t, snorm_to_float(src, 16));
+ } else {
+ SWIZZLE_CONVERT(float, int16_t, src);
+ }
+ break;
+ case GL_UNSIGNED_INT:
+ if (normalized) {
+ SWIZZLE_CONVERT(float, uint32_t, unorm_to_float(src, 32));
+ } else {
+ SWIZZLE_CONVERT(float, uint32_t, src);
+ }
+ break;
+ case GL_INT:
+ if (normalized) {
+ SWIZZLE_CONVERT(float, int32_t, snorm_to_float(src, 32));
+ } else {
+ SWIZZLE_CONVERT(float, int32_t, src);
+ }
+ break;
+ default:
+ assert(!"Invalid channel type combination");
+ }
+}
+
+
+static void
+convert_half_float(void *void_dst, int num_dst_channels,
+ const void *void_src, GLenum src_type, int num_src_channels,
+ const uint8_t swizzle[4], bool normalized, int count)
+{
+ const uint16_t one = _mesa_float_to_half(1.0f);
+
+ switch (src_type) {
+ case GL_FLOAT:
+ SWIZZLE_CONVERT(uint16_t, float, _mesa_float_to_half(src));
+ break;
+ case GL_HALF_FLOAT:
+ SWIZZLE_CONVERT(uint16_t, uint16_t, src);
+ break;
+ case GL_UNSIGNED_BYTE:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint16_t, uint8_t, unorm_to_half(src, 8));
+ } else {
+ SWIZZLE_CONVERT(uint16_t, uint8_t, _mesa_float_to_half(src));
+ }
+ break;
+ case GL_BYTE:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint16_t, int8_t, snorm_to_half(src, 8));
+ } else {
+ SWIZZLE_CONVERT(uint16_t, int8_t, _mesa_float_to_half(src));
+ }
+ break;
+ case GL_UNSIGNED_SHORT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint16_t, uint16_t, unorm_to_half(src, 16));
+ } else {
+ SWIZZLE_CONVERT(uint16_t, uint16_t, _mesa_float_to_half(src));
+ }
+ break;
+ case GL_SHORT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint16_t, int16_t, snorm_to_half(src, 16));
+ } else {
+ SWIZZLE_CONVERT(uint16_t, int16_t, _mesa_float_to_half(src));
+ }
+ break;
+ case GL_UNSIGNED_INT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint16_t, uint32_t, unorm_to_half(src, 32));
+ } else {
+ SWIZZLE_CONVERT(uint16_t, uint32_t, _mesa_float_to_half(src));
+ }
+ break;
+ case GL_INT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint16_t, int32_t, snorm_to_half(src, 32));
+ } else {
+ SWIZZLE_CONVERT(uint16_t, int32_t, _mesa_float_to_half(src));
+ }
+ break;
+ default:
+ assert(!"Invalid channel type combination");
+ }
+}
+
+
+static void
+convert_ubyte(void *void_dst, int num_dst_channels,
+ const void *void_src, GLenum src_type, int num_src_channels,
+ const uint8_t swizzle[4], bool normalized, int count)
+{
+ const uint8_t one = normalized ? UINT8_MAX : 1;
+
+ switch (src_type) {
+ case GL_FLOAT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint8_t, float, float_to_unorm(src, 8));
+ } else {
+ SWIZZLE_CONVERT(uint8_t, float, (src < 0) ? 0 : src);
+ }
+ break;
+ case GL_HALF_FLOAT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint8_t, uint16_t, half_to_unorm(src, 8));
+ } else {
+ SWIZZLE_CONVERT(uint8_t, uint16_t, half_to_uint(src));
+ }
+ break;
+ case GL_UNSIGNED_BYTE:
+ SWIZZLE_CONVERT(uint8_t, uint8_t, src);
+ break;
+ case GL_BYTE:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint8_t, int8_t, snorm_to_unorm(src, 8, 8));
+ } else {
+ SWIZZLE_CONVERT(uint8_t, int8_t, (src < 0) ? 0 : src);
+ }
+ break;
+ case GL_UNSIGNED_SHORT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint8_t, uint16_t, unorm_to_unorm(src, 16, 8));
+ } else {
+ SWIZZLE_CONVERT(uint8_t, uint16_t, src);
+ }
+ break;
+ case GL_SHORT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint8_t, int16_t, snorm_to_unorm(src, 16, 8));
+ } else {
+ SWIZZLE_CONVERT(uint8_t, int16_t, (src < 0) ? 0 : src);
+ }
+ break;
+ case GL_UNSIGNED_INT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint8_t, uint32_t, unorm_to_unorm(src, 32, 8));
+ } else {
+ SWIZZLE_CONVERT(uint8_t, uint32_t, src);
+ }
+ break;
+ case GL_INT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint8_t, int32_t, snorm_to_unorm(src, 32, 8));
+ } else {
+ SWIZZLE_CONVERT(uint8_t, int32_t, (src < 0) ? 0 : src);
+ }
+ break;
+ default:
+ assert(!"Invalid channel type combination");
+ }
+}
+
+
+static void
+convert_byte(void *void_dst, int num_dst_channels,
+ const void *void_src, GLenum src_type, int num_src_channels,
+ const uint8_t swizzle[4], bool normalized, int count)
+{
+ const int8_t one = normalized ? INT8_MAX : 1;
+
+ switch (src_type) {
+ case GL_FLOAT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint8_t, float, float_to_snorm(src, 8));
+ } else {
+ SWIZZLE_CONVERT(uint8_t, float, src);
+ }
+ break;
+ case GL_HALF_FLOAT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint8_t, uint16_t, half_to_snorm(src, 8));
+ } else {
+ SWIZZLE_CONVERT(uint8_t, uint16_t, _mesa_half_to_float(src));
+ }
+ break;
+ case GL_UNSIGNED_BYTE:
+ if (normalized) {
+ SWIZZLE_CONVERT(int8_t, uint8_t, unorm_to_snorm(src, 8, 8));
+ } else {
+ SWIZZLE_CONVERT(int8_t, uint8_t, src);
+ }
+ break;
+ case GL_BYTE:
+ SWIZZLE_CONVERT(int8_t, int8_t, src);
+ break;
+ case GL_UNSIGNED_SHORT:
+ if (normalized) {
+ SWIZZLE_CONVERT(int8_t, uint16_t, unorm_to_snorm(src, 16, 8));
+ } else {
+ SWIZZLE_CONVERT(int8_t, uint16_t, src);
+ }
+ break;
+ case GL_SHORT:
+ if (normalized) {
+ SWIZZLE_CONVERT(int8_t, int16_t, snorm_to_snorm(src, 16, 8));
+ } else {
+ SWIZZLE_CONVERT(int8_t, int16_t, src);
+ }
+ break;
+ case GL_UNSIGNED_INT:
+ if (normalized) {
+ SWIZZLE_CONVERT(int8_t, uint32_t, unorm_to_snorm(src, 32, 8));
+ } else {
+ SWIZZLE_CONVERT(int8_t, uint32_t, src);
+ }
+ break;
+ case GL_INT:
+ if (normalized) {
+ SWIZZLE_CONVERT(int8_t, int32_t, snorm_to_snorm(src, 32, 8));
+ } else {
+ SWIZZLE_CONVERT(int8_t, int32_t, src);
+ }
+ break;
+ default:
+ assert(!"Invalid channel type combination");
+ }
+}
+
+
+static void
+convert_ushort(void *void_dst, int num_dst_channels,
+ const void *void_src, GLenum src_type, int num_src_channels,
+ const uint8_t swizzle[4], bool normalized, int count)
+{
+ const uint16_t one = normalized ? UINT16_MAX : 1;
+
+ switch (src_type) {
+ case GL_FLOAT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint16_t, float, float_to_unorm(src, 16));
+ } else {
+ SWIZZLE_CONVERT(uint16_t, float, (src < 0) ? 0 : src);
+ }
+ break;
+ case GL_HALF_FLOAT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint16_t, uint16_t, half_to_unorm(src, 16));
+ } else {
+ SWIZZLE_CONVERT(uint16_t, uint16_t, half_to_uint(src));
+ }
+ break;
+ case GL_UNSIGNED_BYTE:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint16_t, uint8_t, unorm_to_unorm(src, 8, 16));
+ } else {
+ SWIZZLE_CONVERT(uint16_t, uint8_t, src);
+ }
+ break;
+ case GL_BYTE:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint16_t, int8_t, snorm_to_unorm(src, 8, 16));
+ } else {
+ SWIZZLE_CONVERT(uint16_t, int8_t, (src < 0) ? 0 : src);
+ }
+ break;
+ case GL_UNSIGNED_SHORT:
+ SWIZZLE_CONVERT(uint16_t, uint16_t, src);
+ break;
+ case GL_SHORT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint16_t, int16_t, snorm_to_unorm(src, 16, 16));
+ } else {
+ SWIZZLE_CONVERT(uint16_t, int16_t, (src < 0) ? 0 : src);
+ }
+ break;
+ case GL_UNSIGNED_INT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint16_t, uint32_t, unorm_to_unorm(src, 32, 16));
+ } else {
+ SWIZZLE_CONVERT(uint16_t, uint32_t, src);
+ }
+ break;
+ case GL_INT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint16_t, int32_t, snorm_to_unorm(src, 32, 16));
+ } else {
+ SWIZZLE_CONVERT(uint16_t, int32_t, (src < 0) ? 0 : src);
+ }
+ break;
+ default:
+ assert(!"Invalid channel type combination");
+ }
+}
+
+
+static void
+convert_short(void *void_dst, int num_dst_channels,
+ const void *void_src, GLenum src_type, int num_src_channels,
+ const uint8_t swizzle[4], bool normalized, int count)
+{
+ const int16_t one = normalized ? INT16_MAX : 1;
+
+ switch (src_type) {
+ case GL_FLOAT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint16_t, float, float_to_snorm(src, 16));
+ } else {
+ SWIZZLE_CONVERT(uint16_t, float, src);
+ }
+ break;
+ case GL_HALF_FLOAT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint16_t, uint16_t, half_to_snorm(src, 16));
+ } else {
+ SWIZZLE_CONVERT(uint16_t, uint16_t, _mesa_half_to_float(src));
+ }
+ break;
+ case GL_UNSIGNED_BYTE:
+ if (normalized) {
+ SWIZZLE_CONVERT(int16_t, uint8_t, unorm_to_snorm(src, 8, 16));
+ } else {
+ SWIZZLE_CONVERT(int16_t, uint8_t, src);
+ }
+ break;
+ case GL_BYTE:
+ if (normalized) {
+ SWIZZLE_CONVERT(int16_t, int8_t, snorm_to_snorm(src, 8, 16));
+ } else {
+ SWIZZLE_CONVERT(int16_t, int8_t, src);
+ }
+ break;
+ case GL_UNSIGNED_SHORT:
+ if (normalized) {
+ SWIZZLE_CONVERT(int16_t, uint16_t, unorm_to_snorm(src, 16, 16));
+ } else {
+ SWIZZLE_CONVERT(int16_t, uint16_t, src);
+ }
+ break;
+ case GL_SHORT:
+ SWIZZLE_CONVERT(int16_t, int16_t, src);
+ break;
+ case GL_UNSIGNED_INT:
+ if (normalized) {
+ SWIZZLE_CONVERT(int16_t, uint32_t, unorm_to_snorm(src, 32, 16));
+ } else {
+ SWIZZLE_CONVERT(int16_t, uint32_t, src);
+ }
+ break;
+ case GL_INT:
+ if (normalized) {
+ SWIZZLE_CONVERT(int16_t, int32_t, snorm_to_snorm(src, 32, 16));
+ } else {
+ SWIZZLE_CONVERT(int16_t, int32_t, src);
+ }
+ break;
+ default:
+ assert(!"Invalid channel type combination");
+ }
+}
+
+static void
+convert_uint(void *void_dst, int num_dst_channels,
+ const void *void_src, GLenum src_type, int num_src_channels,
+ const uint8_t swizzle[4], bool normalized, int count)
+{
+ const uint32_t one = normalized ? UINT32_MAX : 1;
+
+ switch (src_type) {
+ case GL_FLOAT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint32_t, float, float_to_unorm(src, 32));
+ } else {
+ SWIZZLE_CONVERT(uint32_t, float, (src < 0) ? 0 : src);
+ }
+ break;
+ case GL_HALF_FLOAT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint32_t, uint16_t, half_to_unorm(src, 32));
+ } else {
+ SWIZZLE_CONVERT(uint32_t, uint16_t, half_to_uint(src));
+ }
+ break;
+ case GL_UNSIGNED_BYTE:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint32_t, uint8_t, unorm_to_unorm(src, 8, 32));
+ } else {
+ SWIZZLE_CONVERT(uint32_t, uint8_t, src);
+ }
+ break;
+ case GL_BYTE:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint32_t, int8_t, snorm_to_unorm(src, 8, 32));
+ } else {
+ SWIZZLE_CONVERT(uint32_t, int8_t, (src < 0) ? 0 : src);
+ }
+ break;
+ case GL_UNSIGNED_SHORT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint32_t, uint16_t, unorm_to_unorm(src, 16, 32));
+ } else {
+ SWIZZLE_CONVERT(uint32_t, uint16_t, src);
+ }
+ break;
+ case GL_SHORT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint32_t, int16_t, snorm_to_unorm(src, 16, 32));
+ } else {
+ SWIZZLE_CONVERT(uint32_t, int16_t, (src < 0) ? 0 : src);
+ }
+ break;
+ case GL_UNSIGNED_INT:
+ SWIZZLE_CONVERT(uint32_t, uint32_t, src);
+ break;
+ case GL_INT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint32_t, int32_t, snorm_to_unorm(src, 32, 32));
+ } else {
+ SWIZZLE_CONVERT(uint32_t, int32_t, (src < 0) ? 0 : src);
+ }
+ break;
+ default:
+ assert(!"Invalid channel type combination");
+ }
+}
+
+
+static void
+convert_int(void *void_dst, int num_dst_channels,
+ const void *void_src, GLenum src_type, int num_src_channels,
+ const uint8_t swizzle[4], bool normalized, int count)
+{
+ const int32_t one = normalized ? INT32_MAX : 12;
+
+ switch (src_type) {
+ case GL_FLOAT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint32_t, float, float_to_snorm(src, 32));
+ } else {
+ SWIZZLE_CONVERT(uint32_t, float, src);
+ }
+ break;
+ case GL_HALF_FLOAT:
+ if (normalized) {
+ SWIZZLE_CONVERT(uint32_t, uint16_t, half_to_snorm(src, 32));
+ } else {
+ SWIZZLE_CONVERT(uint32_t, uint16_t, _mesa_half_to_float(src));
+ }
+ break;
+ case GL_UNSIGNED_BYTE:
+ if (normalized) {
+ SWIZZLE_CONVERT(int32_t, uint8_t, unorm_to_snorm(src, 8, 32));
+ } else {
+ SWIZZLE_CONVERT(int32_t, uint8_t, src);
+ }
+ break;
+ case GL_BYTE:
+ if (normalized) {
+ SWIZZLE_CONVERT(int32_t, int8_t, snorm_to_snorm(src, 8, 32));
+ } else {
+ SWIZZLE_CONVERT(int32_t, int8_t, src);
+ }
+ break;
+ case GL_UNSIGNED_SHORT:
+ if (normalized) {
+ SWIZZLE_CONVERT(int32_t, uint16_t, unorm_to_snorm(src, 16, 32));
+ } else {
+ SWIZZLE_CONVERT(int32_t, uint16_t, src);
+ }
+ break;
+ case GL_SHORT:
+ if (normalized) {
+ SWIZZLE_CONVERT(int32_t, int16_t, snorm_to_snorm(src, 16, 32));
+ } else {
+ SWIZZLE_CONVERT(int32_t, int16_t, src);
+ }
+ break;
+ case GL_UNSIGNED_INT:
+ if (normalized) {
+ SWIZZLE_CONVERT(int32_t, uint32_t, unorm_to_snorm(src, 32, 32));
+ } else {
+ SWIZZLE_CONVERT(int32_t, uint32_t, src);
+ }
+ break;
+ case GL_INT:
+ SWIZZLE_CONVERT(int32_t, int32_t, src);
+ break;
+ default:
+ assert(!"Invalid channel type combination");
+ }
+}
+
/**
* Convert between array-based color formats.
@@ -478,499 +1005,44 @@ _mesa_swizzle_and_convert(void *void_dst, GLenum dst_type, int num_dst_channels,
const void *void_src, GLenum src_type, int num_src_channels,
const uint8_t swizzle[4], bool normalized, int count)
{
- int s, j;
- register uint8_t swizzle_x, swizzle_y, swizzle_z, swizzle_w;
-
if (swizzle_convert_try_memcpy(void_dst, dst_type, num_dst_channels,
void_src, src_type, num_src_channels,
swizzle, normalized, count))
return;
- swizzle_x = swizzle[0];
- swizzle_y = swizzle[1];
- swizzle_z = swizzle[2];
- swizzle_w = swizzle[3];
-
switch (dst_type) {
case GL_FLOAT:
- {
- const float one = 1.0f;
- switch (src_type) {
- case GL_FLOAT:
- SWIZZLE_CONVERT(float, float, src)
- break;
- case GL_HALF_FLOAT:
- SWIZZLE_CONVERT(float, uint16_t, _mesa_half_to_float(src))
- break;
- case GL_UNSIGNED_BYTE:
- if (normalized) {
- SWIZZLE_CONVERT(float, uint8_t, unorm_to_float(src, 8))
- } else {
- SWIZZLE_CONVERT(float, uint8_t, src)
- }
- break;
- case GL_BYTE:
- if (normalized) {
- SWIZZLE_CONVERT(float, int8_t, snorm_to_float(src, 8))
- } else {
- SWIZZLE_CONVERT(float, int8_t, src)
- }
- break;
- case GL_UNSIGNED_SHORT:
- if (normalized) {
- SWIZZLE_CONVERT(float, uint16_t, unorm_to_float(src, 16))
- } else {
- SWIZZLE_CONVERT(float, uint16_t, src)
- }
- break;
- case GL_SHORT:
- if (normalized) {
- SWIZZLE_CONVERT(float, int16_t, snorm_to_float(src, 16))
- } else {
- SWIZZLE_CONVERT(float, int16_t, src)
- }
- break;
- case GL_UNSIGNED_INT:
- if (normalized) {
- SWIZZLE_CONVERT(float, uint32_t, unorm_to_float(src, 32))
- } else {
- SWIZZLE_CONVERT(float, uint32_t, src)
- }
- break;
- case GL_INT:
- if (normalized) {
- SWIZZLE_CONVERT(float, int32_t, snorm_to_float(src, 32))
- } else {
- SWIZZLE_CONVERT(float, int32_t, src)
- }
- break;
- default:
- assert(!"Invalid channel type combination");
- }
- }
- break;
+ convert_float(void_dst, num_dst_channels, void_src, src_type,
+ num_src_channels, swizzle, normalized, count);
+ break;
case GL_HALF_FLOAT:
- {
- const uint16_t one = _mesa_float_to_half(1.0f);
- switch (src_type) {
- case GL_FLOAT:
- SWIZZLE_CONVERT(uint16_t, float, _mesa_float_to_half(src))
- break;
- case GL_HALF_FLOAT:
- SWIZZLE_CONVERT(uint16_t, uint16_t, src)
- break;
- case GL_UNSIGNED_BYTE:
- if (normalized) {
- SWIZZLE_CONVERT(uint16_t, uint8_t, unorm_to_half(src, 8))
- } else {
- SWIZZLE_CONVERT(uint16_t, uint8_t, _mesa_float_to_half(src))
- }
- break;
- case GL_BYTE:
- if (normalized) {
- SWIZZLE_CONVERT(uint16_t, int8_t, snorm_to_half(src, 8))
- } else {
- SWIZZLE_CONVERT(uint16_t, int8_t, _mesa_float_to_half(src))
- }
- break;
- case GL_UNSIGNED_SHORT:
- if (normalized) {
- SWIZZLE_CONVERT(uint16_t, uint16_t, unorm_to_half(src, 16))
- } else {
- SWIZZLE_CONVERT(uint16_t, uint16_t, _mesa_float_to_half(src))
- }
- break;
- case GL_SHORT:
- if (normalized) {
- SWIZZLE_CONVERT(uint16_t, int16_t, snorm_to_half(src, 16))
- } else {
- SWIZZLE_CONVERT(uint16_t, int16_t, _mesa_float_to_half(src))
- }
- break;
- case GL_UNSIGNED_INT:
- if (normalized) {
- SWIZZLE_CONVERT(uint16_t, uint32_t, unorm_to_half(src, 32))
- } else {
- SWIZZLE_CONVERT(uint16_t, uint32_t, _mesa_float_to_half(src))
- }
- break;
- case GL_INT:
- if (normalized) {
- SWIZZLE_CONVERT(uint16_t, int32_t, snorm_to_half(src, 32))
- } else {
- SWIZZLE_CONVERT(uint16_t, int32_t, _mesa_float_to_half(src))
- }
- break;
- default:
- assert(!"Invalid channel type combination");
- }
- }
- break;
+ convert_half_float(void_dst, num_dst_channels, void_src, src_type,
+ num_src_channels, swizzle, normalized, count);
+ break;
case GL_UNSIGNED_BYTE:
- {
- const uint8_t one = normalized ? UINT8_MAX : 1;
- switch (src_type) {
- case GL_FLOAT:
- if (normalized) {
- SWIZZLE_CONVERT(uint8_t, float, float_to_unorm(src, 8))
- } else {
- SWIZZLE_CONVERT(uint8_t, float, (src < 0) ? 0 : src)
- }
- break;
- case GL_HALF_FLOAT:
- if (normalized) {
- SWIZZLE_CONVERT(uint8_t, uint16_t, half_to_unorm(src, 8))
- } else {
- SWIZZLE_CONVERT(uint8_t, uint16_t, half_to_uint(src))
- }
- break;
- case GL_UNSIGNED_BYTE:
- SWIZZLE_CONVERT(uint8_t, uint8_t, src)
- break;
- case GL_BYTE:
- if (normalized) {
- SWIZZLE_CONVERT(uint8_t, int8_t, snorm_to_unorm(src, 8, 8))
- } else {
- SWIZZLE_CONVERT(uint8_t, int8_t, (src < 0) ? 0 : src)
- }
- break;
- case GL_UNSIGNED_SHORT:
- if (normalized) {
- SWIZZLE_CONVERT(uint8_t, uint16_t, unorm_to_unorm(src, 16, 8))
- } else {
- SWIZZLE_CONVERT(uint8_t, uint16_t, src)
- }
- break;
- case GL_SHORT:
- if (normalized) {
- SWIZZLE_CONVERT(uint8_t, int16_t, snorm_to_unorm(src, 16, 8))
- } else {
- SWIZZLE_CONVERT(uint8_t, int16_t, (src < 0) ? 0 : src)
- }
- break;
- case GL_UNSIGNED_INT:
- if (normalized) {
- SWIZZLE_CONVERT(uint8_t, uint32_t, unorm_to_unorm(src, 32, 8))
- } else {
- SWIZZLE_CONVERT(uint8_t, uint32_t, src)
- }
- break;
- case GL_INT:
- if (normalized) {
- SWIZZLE_CONVERT(uint8_t, int32_t, snorm_to_unorm(src, 32, 8))
- } else {
- SWIZZLE_CONVERT(uint8_t, int32_t, (src < 0) ? 0 : src)
- }
- break;
- default:
- assert(!"Invalid channel type combination");
- }
- }
- break;
+ convert_ubyte(void_dst, num_dst_channels, void_src, src_type,
+ num_src_channels, swizzle, normalized, count);
+ break;
case GL_BYTE:
- {
- const int8_t one = normalized ? INT8_MAX : 1;
- switch (src_type) {
- case GL_FLOAT:
- if (normalized) {
- SWIZZLE_CONVERT(uint8_t, float, float_to_snorm(src, 8))
- } else {
- SWIZZLE_CONVERT(uint8_t, float, src)
- }
- break;
- case GL_HALF_FLOAT:
- if (normalized) {
- SWIZZLE_CONVERT(uint8_t, uint16_t, half_to_snorm(src, 8))
- } else {
- SWIZZLE_CONVERT(uint8_t, uint16_t, _mesa_half_to_float(src))
- }
- break;
- case GL_UNSIGNED_BYTE:
- if (normalized) {
- SWIZZLE_CONVERT(int8_t, uint8_t, unorm_to_snorm(src, 8, 8))
- } else {
- SWIZZLE_CONVERT(int8_t, uint8_t, src)
- }
- break;
- case GL_BYTE:
- SWIZZLE_CONVERT(int8_t, int8_t, src)
- break;
- case GL_UNSIGNED_SHORT:
- if (normalized) {
- SWIZZLE_CONVERT(int8_t, uint16_t, unorm_to_snorm(src, 16, 8))
- } else {
- SWIZZLE_CONVERT(int8_t, uint16_t, src)
- }
- break;
- case GL_SHORT:
- if (normalized) {
- SWIZZLE_CONVERT(int8_t, int16_t, snorm_to_snorm(src, 16, 8))
- } else {
- SWIZZLE_CONVERT(int8_t, int16_t, src)
- }
- break;
- case GL_UNSIGNED_INT:
- if (normalized) {
- SWIZZLE_CONVERT(int8_t, uint32_t, unorm_to_snorm(src, 32, 8))
- } else {
- SWIZZLE_CONVERT(int8_t, uint32_t, src)
- }
- break;
- case GL_INT:
- if (normalized) {
- SWIZZLE_CONVERT(int8_t, int32_t, snorm_to_snorm(src, 32, 8))
- } else {
- SWIZZLE_CONVERT(int8_t, int32_t, src)
- }
- break;
- default:
- assert(!"Invalid channel type combination");
- }
- }
- break;
+ convert_byte(void_dst, num_dst_channels, void_src, src_type,
+ num_src_channels, swizzle, normalized, count);
+ break;
case GL_UNSIGNED_SHORT:
- {
- const uint16_t one = normalized ? UINT16_MAX : 1;
- switch (src_type) {
- case GL_FLOAT:
- if (normalized) {
- SWIZZLE_CONVERT(uint16_t, float, float_to_unorm(src, 16))
- } else {
- SWIZZLE_CONVERT(uint16_t, float, (src < 0) ? 0 : src)
- }
- break;
- case GL_HALF_FLOAT:
- if (normalized) {
- SWIZZLE_CONVERT(uint16_t, uint16_t, half_to_unorm(src, 16))
- } else {
- SWIZZLE_CONVERT(uint16_t, uint16_t, half_to_uint(src))
- }
- break;
- case GL_UNSIGNED_BYTE:
- if (normalized) {
- SWIZZLE_CONVERT(uint16_t, uint8_t, unorm_to_unorm(src, 8, 16))
- } else {
- SWIZZLE_CONVERT(uint16_t, uint8_t, src)
- }
- break;
- case GL_BYTE:
- if (normalized) {
- SWIZZLE_CONVERT(uint16_t, int8_t, snorm_to_unorm(src, 8, 16))
- } else {
- SWIZZLE_CONVERT(uint16_t, int8_t, (src < 0) ? 0 : src)
- }
- break;
- case GL_UNSIGNED_SHORT:
- SWIZZLE_CONVERT(uint16_t, uint16_t, src)
- break;
- case GL_SHORT:
- if (normalized) {
- SWIZZLE_CONVERT(uint16_t, int16_t, snorm_to_unorm(src, 16, 16))
- } else {
- SWIZZLE_CONVERT(uint16_t, int16_t, (src < 0) ? 0 : src)
- }
- break;
- case GL_UNSIGNED_INT:
- if (normalized) {
- SWIZZLE_CONVERT(uint16_t, uint32_t, unorm_to_unorm(src, 32, 16))
- } else {
- SWIZZLE_CONVERT(uint16_t, uint32_t, src)
- }
- break;
- case GL_INT:
- if (normalized) {
- SWIZZLE_CONVERT(uint16_t, int32_t, snorm_to_unorm(src, 32, 16))
- } else {
- SWIZZLE_CONVERT(uint16_t, int32_t, (src < 0) ? 0 : src)
- }
- break;
- default:
- assert(!"Invalid channel type combination");
- }
- }
- break;
+ convert_ushort(void_dst, num_dst_channels, void_src, src_type,
+ num_src_channels, swizzle, normalized, count);
+ break;
case GL_SHORT:
- {
- const int16_t one = normalized ? INT16_MAX : 1;
- switch (src_type) {
- case GL_FLOAT:
- if (normalized) {
- SWIZZLE_CONVERT(uint16_t, float, float_to_snorm(src, 16))
- } else {
- SWIZZLE_CONVERT(uint16_t, float, src)
- }
- break;
- case GL_HALF_FLOAT:
- if (normalized) {
- SWIZZLE_CONVERT(uint16_t, uint16_t, half_to_snorm(src, 16))
- } else {
- SWIZZLE_CONVERT(uint16_t, uint16_t, _mesa_half_to_float(src))
- }
- break;
- case GL_UNSIGNED_BYTE:
- if (normalized) {
- SWIZZLE_CONVERT(int16_t, uint8_t, unorm_to_snorm(src, 8, 16))
- } else {
- SWIZZLE_CONVERT(int16_t, uint8_t, src)
- }
- break;
- case GL_BYTE:
- if (normalized) {
- SWIZZLE_CONVERT(int16_t, int8_t, snorm_to_snorm(src, 8, 16))
- } else {
- SWIZZLE_CONVERT(int16_t, int8_t, src)
- }
- break;
- case GL_UNSIGNED_SHORT:
- if (normalized) {
- SWIZZLE_CONVERT(int16_t, uint16_t, unorm_to_snorm(src, 16, 16))
- } else {
- SWIZZLE_CONVERT(int16_t, uint16_t, src)
- }
- break;
- case GL_SHORT:
- SWIZZLE_CONVERT(int16_t, int16_t, src)
- break;
- case GL_UNSIGNED_INT:
- if (normalized) {
- SWIZZLE_CONVERT(int16_t, uint32_t, unorm_to_snorm(src, 32, 16))
- } else {
- SWIZZLE_CONVERT(int16_t, uint32_t, src)
- }
- break;
- case GL_INT:
- if (normalized) {
- SWIZZLE_CONVERT(int16_t, int32_t, snorm_to_snorm(src, 32, 16))
- } else {
- SWIZZLE_CONVERT(int16_t, int32_t, src)
- }
- break;
- default:
- assert(!"Invalid channel type combination");
- }
- }
- break;
+ convert_short(void_dst, num_dst_channels, void_src, src_type,
+ num_src_channels, swizzle, normalized, count);
+ break;
case GL_UNSIGNED_INT:
- {
- const uint32_t one = normalized ? UINT32_MAX : 1;
- switch (src_type) { case GL_FLOAT:
- if (normalized) {
- SWIZZLE_CONVERT(uint32_t, float, float_to_unorm(src, 32))
- } else {
- SWIZZLE_CONVERT(uint32_t, float, (src < 0) ? 0 : src)
- }
- break;
- case GL_HALF_FLOAT:
- if (normalized) {
- SWIZZLE_CONVERT(uint32_t, uint16_t, half_to_unorm(src, 32))
- } else {
- SWIZZLE_CONVERT(uint32_t, uint16_t, half_to_uint(src))
- }
- break;
- case GL_UNSIGNED_BYTE:
- if (normalized) {
- SWIZZLE_CONVERT(uint32_t, uint8_t, unorm_to_unorm(src, 8, 32))
- } else {
- SWIZZLE_CONVERT(uint32_t, uint8_t, src)
- }
- break;
- case GL_BYTE:
- if (normalized) {
- SWIZZLE_CONVERT(uint32_t, int8_t, snorm_to_unorm(src, 8, 32))
- } else {
- SWIZZLE_CONVERT(uint32_t, int8_t, (src < 0) ? 0 : src)
- }
- break;
- case GL_UNSIGNED_SHORT:
- if (normalized) {
- SWIZZLE_CONVERT(uint32_t, uint16_t, unorm_to_unorm(src, 16, 32))
- } else {
- SWIZZLE_CONVERT(uint32_t, uint16_t, src)
- }
- break;
- case GL_SHORT:
- if (normalized) {
- SWIZZLE_CONVERT(uint32_t, int16_t, snorm_to_unorm(src, 16, 32))
- } else {
- SWIZZLE_CONVERT(uint32_t, int16_t, (src < 0) ? 0 : src)
- }
- break;
- case GL_UNSIGNED_INT:
- SWIZZLE_CONVERT(uint32_t, uint32_t, src)
- break;
- case GL_INT:
- if (normalized) {
- SWIZZLE_CONVERT(uint32_t, int32_t, snorm_to_unorm(src, 32, 32))
- } else {
- SWIZZLE_CONVERT(uint32_t, int32_t, (src < 0) ? 0 : src)
- }
- break;
- default:
- assert(!"Invalid channel type combination");
- }
- }
- break;
+ convert_uint(void_dst, num_dst_channels, void_src, src_type,
+ num_src_channels, swizzle, normalized, count);
+ break;
case GL_INT:
- {
- const int32_t one = normalized ? INT32_MAX : 1;
- switch (src_type) {
- case GL_FLOAT:
- if (normalized) {
- SWIZZLE_CONVERT(uint32_t, float, float_to_snorm(src, 32))
- } else {
- SWIZZLE_CONVERT(uint32_t, float, src)
- }
- break;
- case GL_HALF_FLOAT:
- if (normalized) {
- SWIZZLE_CONVERT(uint32_t, uint16_t, half_to_snorm(src, 32))
- } else {
- SWIZZLE_CONVERT(uint32_t, uint16_t, _mesa_half_to_float(src))
- }
- break;
- case GL_UNSIGNED_BYTE:
- if (normalized) {
- SWIZZLE_CONVERT(int32_t, uint8_t, unorm_to_snorm(src, 8, 32))
- } else {
- SWIZZLE_CONVERT(int32_t, uint8_t, src)
- }
- break;
- case GL_BYTE:
- if (normalized) {
- SWIZZLE_CONVERT(int32_t, int8_t, snorm_to_snorm(src, 8, 32))
- } else {
- SWIZZLE_CONVERT(int32_t, int8_t, src)
- }
- break;
- case GL_UNSIGNED_SHORT:
- if (normalized) {
- SWIZZLE_CONVERT(int32_t, uint16_t, unorm_to_snorm(src, 16, 32))
- } else {
- SWIZZLE_CONVERT(int32_t, uint16_t, src)
- }
- break;
- case GL_SHORT:
- if (normalized) {
- SWIZZLE_CONVERT(int32_t, int16_t, snorm_to_snorm(src, 16, 32))
- } else {
- SWIZZLE_CONVERT(int32_t, int16_t, src)
- }
- break;
- case GL_UNSIGNED_INT:
- if (normalized) {
- SWIZZLE_CONVERT(int32_t, uint32_t, unorm_to_snorm(src, 32, 32))
- } else {
- SWIZZLE_CONVERT(int32_t, uint32_t, src)
- }
- break;
- case GL_INT:
- SWIZZLE_CONVERT(int32_t, int32_t, src)
- break;
- default:
- assert(!"Invalid channel type combination");
- }
- }
- break;
+ convert_int(void_dst, num_dst_channels, void_src, src_type,
+ num_src_channels, swizzle, normalized, count);
+ break;
default:
assert(!"Invalid channel type");
}
diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c
index db22a45c4..58c32e23b 100644
--- a/mesalib/src/mesa/main/formats.c
+++ b/mesalib/src/mesa/main/formats.c
@@ -357,9 +357,11 @@ _mesa_get_format_color_encoding(mesa_format format)
case MESA_FORMAT_BGR_SRGB8:
case MESA_FORMAT_A8B8G8R8_SRGB:
case MESA_FORMAT_B8G8R8A8_SRGB:
+ case MESA_FORMAT_A8R8G8B8_SRGB:
case MESA_FORMAT_R8G8B8A8_SRGB:
case MESA_FORMAT_L_SRGB8:
case MESA_FORMAT_L8A8_SRGB:
+ case MESA_FORMAT_A8L8_SRGB:
case MESA_FORMAT_SRGB_DXT1:
case MESA_FORMAT_SRGBA_DXT1:
case MESA_FORMAT_SRGBA_DXT3:
@@ -419,6 +421,9 @@ _mesa_get_srgb_format_linear(mesa_format format)
case MESA_FORMAT_B8G8R8A8_SRGB:
format = MESA_FORMAT_B8G8R8A8_UNORM;
break;
+ case MESA_FORMAT_A8R8G8B8_SRGB:
+ format = MESA_FORMAT_A8R8G8B8_UNORM;
+ break;
case MESA_FORMAT_R8G8B8A8_SRGB:
format = MESA_FORMAT_R8G8B8A8_UNORM;
break;
@@ -428,6 +433,9 @@ _mesa_get_srgb_format_linear(mesa_format format)
case MESA_FORMAT_L8A8_SRGB:
format = MESA_FORMAT_L8A8_UNORM;
break;
+ case MESA_FORMAT_A8L8_SRGB:
+ format = MESA_FORMAT_A8L8_UNORM;
+ break;
case MESA_FORMAT_SRGB_DXT1:
format = MESA_FORMAT_RGB_DXT1;
break;
@@ -443,6 +451,9 @@ _mesa_get_srgb_format_linear(mesa_format format)
case MESA_FORMAT_R8G8B8X8_SRGB:
format = MESA_FORMAT_R8G8B8X8_UNORM;
break;
+ case MESA_FORMAT_X8B8G8R8_SRGB:
+ format = MESA_FORMAT_X8B8G8R8_UNORM;
+ break;
case MESA_FORMAT_ETC2_SRGB8:
format = MESA_FORMAT_ETC2_RGB8;
break;
@@ -458,6 +469,9 @@ _mesa_get_srgb_format_linear(mesa_format format)
case MESA_FORMAT_B8G8R8X8_SRGB:
format = MESA_FORMAT_B8G8R8X8_UNORM;
break;
+ case MESA_FORMAT_X8R8G8B8_SRGB:
+ format = MESA_FORMAT_X8R8G8B8_UNORM;
+ break;
default:
break;
}
@@ -919,6 +933,7 @@ _mesa_format_to_type_and_comps(mesa_format format,
return;
case MESA_FORMAT_R8G8_SNORM:
case MESA_FORMAT_L8A8_SNORM:
+ case MESA_FORMAT_A8L8_SNORM:
*datatype = GL_BYTE;
*comps = 2;
return;
@@ -961,6 +976,7 @@ _mesa_format_to_type_and_comps(mesa_format format,
return;
case MESA_FORMAT_A8B8G8R8_SRGB:
case MESA_FORMAT_B8G8R8A8_SRGB:
+ case MESA_FORMAT_A8R8G8B8_SRGB:
case MESA_FORMAT_R8G8B8A8_SRGB:
*datatype = GL_UNSIGNED_BYTE;
*comps = 4;
@@ -970,6 +986,7 @@ _mesa_format_to_type_and_comps(mesa_format format,
*comps = 1;
return;
case MESA_FORMAT_L8A8_SRGB:
+ case MESA_FORMAT_A8L8_SRGB:
*datatype = GL_UNSIGNED_BYTE;
*comps = 2;
return;
@@ -1235,6 +1252,7 @@ _mesa_format_to_type_and_comps(mesa_format format,
return;
case MESA_FORMAT_R8G8B8X8_SRGB:
+ case MESA_FORMAT_X8B8G8R8_SRGB:
case MESA_FORMAT_RGBX_UINT8:
*datatype = GL_UNSIGNED_BYTE;
*comps = 4;
@@ -1299,6 +1317,7 @@ _mesa_format_to_type_and_comps(mesa_format format,
return;
case MESA_FORMAT_B8G8R8X8_SRGB:
+ case MESA_FORMAT_X8R8G8B8_SRGB:
*datatype = GL_UNSIGNED_BYTE;
*comps = 4;
return;
@@ -1414,6 +1433,7 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format,
return GL_FALSE;
case MESA_FORMAT_A8R8G8B8_UNORM:
+ case MESA_FORMAT_A8R8G8B8_SRGB:
if (format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8 && !swapBytes)
return GL_TRUE;
@@ -1475,6 +1495,7 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format,
case MESA_FORMAT_L8A8_SRGB:
return format == GL_LUMINANCE_ALPHA && type == GL_UNSIGNED_BYTE && littleEndian;
case MESA_FORMAT_A8L8_UNORM:
+ case MESA_FORMAT_A8L8_SRGB:
return GL_FALSE;
case MESA_FORMAT_L16A16_UNORM:
@@ -1797,6 +1818,9 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format,
case MESA_FORMAT_L8A8_SNORM:
return format == GL_LUMINANCE_ALPHA && type == GL_BYTE &&
littleEndian && !swapBytes;
+ case MESA_FORMAT_A8L8_SNORM:
+ return format == GL_LUMINANCE_ALPHA && type == GL_BYTE &&
+ !littleEndian && !swapBytes;
case MESA_FORMAT_I_SNORM8:
return format == GL_RED && type == GL_BYTE;
case MESA_FORMAT_A_SNORM16:
@@ -1839,6 +1863,7 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format,
case MESA_FORMAT_B5G5R5X1_UNORM:
case MESA_FORMAT_R8G8B8X8_SNORM:
case MESA_FORMAT_R8G8B8X8_SRGB:
+ case MESA_FORMAT_X8B8G8R8_SRGB:
case MESA_FORMAT_RGBX_UINT8:
case MESA_FORMAT_RGBX_SINT8:
case MESA_FORMAT_B10G10R10X2_UNORM:
@@ -1865,6 +1890,7 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format,
!swapBytes;
case MESA_FORMAT_B8G8R8X8_SRGB:
+ case MESA_FORMAT_X8R8G8B8_SRGB:
return GL_FALSE;
}
diff --git a/mesalib/src/mesa/main/formats.csv b/mesalib/src/mesa/main/formats.csv
index 4d542b7c6..39bcdbdd2 100644
--- a/mesalib/src/mesa/main/formats.csv
+++ b/mesalib/src/mesa/main/formats.csv
@@ -119,6 +119,7 @@ MESA_FORMAT_G16R16_SNORM , packed, 1, 1, sn16, sn16, ,
MESA_FORMAT_R8G8_SNORM , packed, 1, 1, sn8 , sn8 , , , xy01, rgb
MESA_FORMAT_G8R8_SNORM , packed, 1, 1, sn8 , sn8 , , , yx01, rgb
MESA_FORMAT_L8A8_SNORM , packed, 1, 1, sn8 , sn8 , , , xxxy, rgb
+MESA_FORMAT_A8L8_SNORM , packed, 1, 1, sn8 , sn8 , , , yyyx, rgb
# Array signed/normalized formats
MESA_FORMAT_A_SNORM8 , array , 1, 1, sn8 , , , , 000x, rgb
@@ -137,10 +138,14 @@ MESA_FORMAT_RGBX_SNORM16 , array , 1, 1, sn16, sn16, sn16, x16
# Packed sRGB formats
MESA_FORMAT_A8B8G8R8_SRGB , packed, 1, 1, un8 , un8 , un8 , un8 , wzyx, srgb
MESA_FORMAT_B8G8R8A8_SRGB , packed, 1, 1, un8 , un8 , un8 , un8 , zyxw, srgb
+MESA_FORMAT_A8R8G8B8_SRGB , packed, 1, 1, un8 , un8 , un8 , un8 , yzwx, srgb
MESA_FORMAT_B8G8R8X8_SRGB , packed, 1, 1, un8 , un8 , un8 , x8 , zyx1, srgb
+MESA_FORMAT_X8R8G8B8_SRGB , packed, 1, 1, x8 , un8 , un8 , un8 , yzw1, srgb
MESA_FORMAT_R8G8B8A8_SRGB , packed, 1, 1, un8 , un8 , un8 , un8 , xyzw, srgb
MESA_FORMAT_R8G8B8X8_SRGB , packed, 1, 1, un8 , un8 , un8 , x8 , xyz1, srgb
+MESA_FORMAT_X8B8G8R8_SRGB , packed, 1, 1, x8 , un8 , un8 , un8 , wzy1, srgb
MESA_FORMAT_L8A8_SRGB , packed, 1, 1, un8 , un8 , , , xxxy, srgb
+MESA_FORMAT_A8L8_SRGB , packed, 1, 1, un8 , un8 , , , yyyx, srgb
# Array sRGB formats
MESA_FORMAT_L_SRGB8 , array , 1, 1, un8 , , , , xxx1, srgb
diff --git a/mesalib/src/mesa/main/formats.h b/mesalib/src/mesa/main/formats.h
index d6253bf86..213ab563d 100644
--- a/mesalib/src/mesa/main/formats.h
+++ b/mesalib/src/mesa/main/formats.h
@@ -265,6 +265,7 @@ typedef enum
MESA_FORMAT_R8G8_SNORM, /* GGGG GGGG RRRR RRRR */
MESA_FORMAT_G8R8_SNORM, /* RRRR RRRR GGGG GGGG */
MESA_FORMAT_L8A8_SNORM, /* AAAA AAAA LLLL LLLL */
+ MESA_FORMAT_A8L8_SNORM, /* LLLL LLLL AAAA AAAA */
/* Array signed/normalized formats */
MESA_FORMAT_A_SNORM8, /* byte[i] = A */
@@ -283,10 +284,14 @@ typedef enum
/* Packed sRGB formats */
MESA_FORMAT_A8B8G8R8_SRGB, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */
MESA_FORMAT_B8G8R8A8_SRGB, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
+ MESA_FORMAT_A8R8G8B8_SRGB, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
MESA_FORMAT_B8G8R8X8_SRGB, /* xxxx xxxx RRRR RRRR GGGG GGGG BBBB BBBB */
+ MESA_FORMAT_X8R8G8B8_SRGB, /* BBBB BBBB GGGG GGGG RRRR RRRR xxxx xxxx */
MESA_FORMAT_R8G8B8A8_SRGB, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
MESA_FORMAT_R8G8B8X8_SRGB, /* xxxx xxxx BBBB BBBB GGGG GGGG RRRR RRRR */
+ MESA_FORMAT_X8B8G8R8_SRGB, /* RRRR RRRR GGGG GGGG BBBB BBBB xxxx xxxx */
MESA_FORMAT_L8A8_SRGB, /* AAAA AAAA LLLL LLLL */
+ MESA_FORMAT_A8L8_SRGB, /* LLLL LLLL AAAA AAAA */
/* Array sRGB formats */
MESA_FORMAT_L_SRGB8, /* ubyte[i] = L */
diff --git a/mesalib/src/mesa/main/histogram.c b/mesalib/src/mesa/main/histogram.c
index e6e6a6fd1..5759763d4 100644
--- a/mesalib/src/mesa/main/histogram.c
+++ b/mesalib/src/mesa/main/histogram.c
@@ -24,10 +24,8 @@
#include "glheader.h"
-#include "bufferobj.h"
-#include "colormac.h"
+#include "context.h"
#include "histogram.h"
-#include "macros.h"
#include "main/dispatch.h"
diff --git a/mesalib/src/mesa/main/macros.h b/mesalib/src/mesa/main/macros.h
index 7b6148d09..712699f75 100644
--- a/mesalib/src/mesa/main/macros.h
+++ b/mesalib/src/mesa/main/macros.h
@@ -144,10 +144,10 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256];
/* This function/macro is sensitive to precision. Test very carefully
* if you change it!
*/
-#define UNCLAMPED_FLOAT_TO_UBYTE(UB, F) \
+#define UNCLAMPED_FLOAT_TO_UBYTE(UB, FLT) \
do { \
fi_type __tmp; \
- __tmp.f = (F); \
+ __tmp.f = (FLT); \
if (__tmp.i < 0) \
UB = (GLubyte) 0; \
else if (__tmp.i >= IEEE_ONE) \
@@ -157,10 +157,10 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256];
UB = (GLubyte) __tmp.i; \
} \
} while (0)
-#define CLAMPED_FLOAT_TO_UBYTE(UB, F) \
+#define CLAMPED_FLOAT_TO_UBYTE(UB, FLT) \
do { \
fi_type __tmp; \
- __tmp.f = (F) * (255.0F/256.0F) + 32768.0F; \
+ __tmp.f = (FLT) * (255.0F/256.0F) + 32768.0F; \
UB = (GLubyte) __tmp.i; \
} while (0)
#else
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index 4fb30ffba..553a21667 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -1526,7 +1526,6 @@ struct gl_client_array
GLuint _ElementSize; /**< size of each element in bytes */
struct gl_buffer_object *BufferObj;/**< GL_ARB_vertex_buffer_object */
- GLuint _MaxElement; /**< max element index into array buffer + 1 */
};
@@ -1629,12 +1628,6 @@ struct gl_vertex_array_object
/** Mask of VERT_BIT_* values indicating changed/dirty arrays */
GLbitfield64 NewArrays;
- /**
- * Min of all enabled arrays' _MaxElement. When arrays reside inside VBOs
- * we can determine the max legal (in bounds) glDrawElements array index.
- */
- GLuint _MaxElement;
-
/** The index buffer (also known as the element array buffer in OpenGL). */
struct gl_buffer_object *IndexBufferObj;
};
@@ -2055,8 +2048,90 @@ typedef enum
* \name Vertex shader system values
*/
/*@{*/
+ /**
+ * OpenGL-style vertex ID.
+ *
+ * Section 2.11.7 (Shader Execution), subsection Shader Inputs, of the
+ * OpenGL 3.3 core profile spec says:
+ *
+ * "gl_VertexID holds the integer index i implicitly passed by
+ * DrawArrays or one of the other drawing commands defined in section
+ * 2.8.3."
+ *
+ * Section 2.8.3 (Drawing Commands) of the same spec says:
+ *
+ * "The commands....are equivalent to the commands with the same base
+ * name (without the BaseVertex suffix), except that the ith element
+ * transferred by the corresponding draw call will be taken from
+ * element indices[i] + basevertex of each enabled array."
+ *
+ * Additionally, the overview in the GL_ARB_shader_draw_parameters spec
+ * says:
+ *
+ * "In unextended GL, vertex shaders have inputs named gl_VertexID and
+ * gl_InstanceID, which contain, respectively the index of the vertex
+ * and instance. The value of gl_VertexID is the implicitly passed
+ * index of the vertex being processed, which includes the value of
+ * baseVertex, for those commands that accept it."
+ *
+ * gl_VertexID gets basevertex added in. This differs from DirectX where
+ * SV_VertexID does \b not get basevertex added in.
+ *
+ * \note
+ * If all system values are available, \c SYSTEM_VALUE_VERTEX_ID will be
+ * equal to \c SYSTEM_VALUE_VERTEX_ID_ZERO_BASE plus
+ * \c SYSTEM_VALUE_BASE_VERTEX.
+ *
+ * \sa SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, SYSTEM_VALUE_BASE_VERTEX
+ */
SYSTEM_VALUE_VERTEX_ID,
+
+ /**
+ * Instanced ID as supplied to gl_InstanceID
+ *
+ * Values assigned to gl_InstanceID always begin with zero, regardless of
+ * the value of baseinstance.
+ *
+ * Section 11.1.3.9 (Shader Inputs) of the OpenGL 4.4 core profile spec
+ * says:
+ *
+ * "gl_InstanceID holds the integer instance number of the current
+ * primitive in an instanced draw call (see section 10.5)."
+ *
+ * Through a big chain of pseudocode, section 10.5 describes that
+ * baseinstance is not counted by gl_InstanceID. In that section, notice
+ *
+ * "If an enabled vertex attribute array is instanced (it has a
+ * non-zero divisor as specified by VertexAttribDivisor), the element
+ * index that is transferred to the GL, for all vertices, is given by
+ *
+ * floor(instance/divisor) + baseinstance
+ *
+ * If an array corresponding to an attribute required by a vertex
+ * shader is not enabled, then the corresponding element is taken from
+ * the current attribute state (see section 10.2)."
+ *
+ * Note that baseinstance is \b not included in the value of instance.
+ */
SYSTEM_VALUE_INSTANCE_ID,
+
+ /**
+ * DirectX-style vertex ID.
+ *
+ * Unlike \c SYSTEM_VALUE_VERTEX_ID, this system value does \b not include
+ * the value of basevertex.
+ *
+ * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_BASE_VERTEX
+ */
+ SYSTEM_VALUE_VERTEX_ID_ZERO_BASE,
+
+ /**
+ * Value of \c basevertex passed to \c glDrawElementsBaseVertex and similar
+ * functions.
+ *
+ * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_VERTEX_ID_ZERO_BASE
+ */
+ SYSTEM_VALUE_BASE_VERTEX,
/*@}*/
/**
@@ -3350,9 +3425,6 @@ struct gl_constants
GLuint PrimitivesWritten;
} QueryCounterBits;
- /** vertex array / buffer object bounds checking */
- GLboolean CheckArrayBounds;
-
GLuint MaxDrawBuffers; /**< GL_ARB_draw_buffers */
GLuint MaxColorAttachments; /**< GL_EXT_framebuffer_object */
@@ -3406,6 +3478,15 @@ struct gl_constants
GLboolean NativeIntegers;
/**
+ * Does VertexID count from zero or from base vertex?
+ *
+ * \note
+ * If desktop GLSL 1.30 or GLSL ES 3.00 are not supported, this field is
+ * ignored and need not be set.
+ */
+ bool VertexID_is_zero_based;
+
+ /**
* If the driver supports real 32-bit integers, what integer value should be
* used for boolean true in uniform uploads? (Usually 1 or ~0.)
*/
diff --git a/mesalib/src/mesa/main/pipelineobj.c b/mesalib/src/mesa/main/pipelineobj.c
index 017d4257e..b713d956f 100644
--- a/mesalib/src/mesa/main/pipelineobj.c
+++ b/mesalib/src/mesa/main/pipelineobj.c
@@ -120,12 +120,12 @@ delete_pipelineobj_cb(GLuint id, void *data, void *userData)
void
_mesa_free_pipeline_data(struct gl_context *ctx)
{
+ _mesa_reference_pipeline_object(ctx, &ctx->_Shader, NULL);
+
_mesa_HashDeleteAll(ctx->Pipeline.Objects, delete_pipelineobj_cb, ctx);
_mesa_DeleteHashTable(ctx->Pipeline.Objects);
- _mesa_reference_pipeline_object(ctx, &ctx->_Shader, NULL);
_mesa_delete_pipeline_object(ctx, ctx->Pipeline.Default);
-
}
/**
diff --git a/mesalib/src/mesa/main/shader_query.cpp b/mesalib/src/mesa/main/shader_query.cpp
index 426774316..766ad2965 100644
--- a/mesalib/src/mesa/main/shader_query.cpp
+++ b/mesalib/src/mesa/main/shader_query.cpp
@@ -92,8 +92,9 @@ is_active_attrib(const ir_variable *var)
* are enumerated, including the special built-in inputs gl_VertexID
* and gl_InstanceID."
*/
- return !strcmp(var->name, "gl_VertexID") ||
- !strcmp(var->name, "gl_InstanceID");
+ return var->data.location == SYSTEM_VALUE_VERTEX_ID ||
+ var->data.location == SYSTEM_VALUE_VERTEX_ID_ZERO_BASE ||
+ var->data.location == SYSTEM_VALUE_INSTANCE_ID;
default:
return false;
@@ -133,7 +134,18 @@ _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index,
continue;
if (current_index == desired_index) {
- _mesa_copy_string(name, maxLength, length, var->name);
+ const char *var_name = var->name;
+
+ /* Since gl_VertexID may be lowered to gl_VertexIDMESA, we need to
+ * consider gl_VertexIDMESA as gl_VertexID for purposes of checking
+ * active attributes.
+ */
+ if (var->data.mode == ir_var_system_value &&
+ var->data.location == SYSTEM_VALUE_VERTEX_ID_ZERO_BASE) {
+ var_name = "gl_VertexID";
+ }
+
+ _mesa_copy_string(name, maxLength, length, var_name);
if (size)
*size = (var->type->is_array()) ? var->type->length : 1;
diff --git a/mesalib/src/mesa/main/state.c b/mesalib/src/mesa/main/state.c
index c122c16aa..80287c470 100644
--- a/mesalib/src/mesa/main/state.c
+++ b/mesalib/src/mesa/main/state.c
@@ -419,11 +419,6 @@ _mesa_update_state_locked( struct gl_context *ctx )
if (new_state & _NEW_ARRAY)
_mesa_update_vao_client_arrays(ctx, ctx->Array.VAO);
- if (ctx->Const.CheckArrayBounds &&
- new_state & (_NEW_ARRAY | _NEW_PROGRAM | _NEW_BUFFER_OBJECT)) {
- _mesa_update_vao_max_element(ctx, ctx->Array.VAO);
- }
-
out:
new_prog_state |= update_program_constants(ctx);
diff --git a/mesalib/src/mesa/main/texcompress_rgtc.c b/mesalib/src/mesa/main/texcompress_rgtc.c
index 1012699f5..f7ee24d47 100644
--- a/mesalib/src/mesa/main/texcompress_rgtc.c
+++ b/mesalib/src/mesa/main/texcompress_rgtc.c
@@ -40,23 +40,10 @@
#include "macros.h"
#include "mipmap.h"
#include "texcompress.h"
+#include "util/rgtc.h"
#include "texcompress_rgtc.h"
#include "texstore.h"
-
-#define RGTC_DEBUG 0
-
-static void unsigned_encode_rgtc_ubyte(GLubyte *blkaddr, GLubyte srccolors[4][4],
- GLint numxpixels, GLint numypixels);
-static void signed_encode_rgtc_ubyte(GLbyte *blkaddr, GLbyte srccolors[4][4],
- GLint numxpixels, GLint numypixels);
-
-static void unsigned_fetch_texel_rgtc(unsigned srcRowStride, const GLubyte *pixdata,
- unsigned i, unsigned j, GLubyte *value, unsigned comps);
-
-static void signed_fetch_texel_rgtc(unsigned srcRowStride, const GLbyte *pixdata,
- unsigned i, unsigned j, GLbyte *value, unsigned comps);
-
static void extractsrc_u( GLubyte srcpixels[4][4], const GLubyte *srcaddr,
GLint srcRowStride, GLint numxpixels, GLint numypixels, GLint comps)
{
@@ -121,7 +108,7 @@ _mesa_texstore_red_rgtc1(TEXSTORE_PARAMS)
if (srcWidth > i + 3) numxpixels = 4;
else numxpixels = srcWidth - i;
extractsrc_u(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 1);
- unsigned_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels);
+ util_format_unsigned_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels);
srcaddr += numxpixels;
blkaddr += 8;
}
@@ -168,7 +155,7 @@ _mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS)
if (srcWidth > i + 3) numxpixels = 4;
else numxpixels = srcWidth - i;
extractsrc_s(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 1);
- signed_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels);
+ util_format_signed_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels);
srcaddr += numxpixels;
blkaddr += 8;
}
@@ -216,11 +203,11 @@ _mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS)
if (srcWidth > i + 3) numxpixels = 4;
else numxpixels = srcWidth - i;
extractsrc_u(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 2);
- unsigned_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels);
+ util_format_unsigned_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels);
blkaddr += 8;
extractsrc_u(srcpixels, (GLubyte *)srcaddr + 1, srcWidth, numxpixels, numypixels, 2);
- unsigned_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels);
+ util_format_unsigned_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels);
blkaddr += 8;
@@ -271,11 +258,11 @@ _mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS)
else numxpixels = srcWidth - i;
extractsrc_s(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 2);
- signed_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels);
+ util_format_signed_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels);
blkaddr += 8;
extractsrc_s(srcpixels, srcaddr + 1, srcWidth, numxpixels, numypixels, 2);
- signed_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels);
+ util_format_signed_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels);
blkaddr += 8;
srcaddr += numxpixels * 2;
@@ -289,40 +276,12 @@ _mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS)
return GL_TRUE;
}
-
-#define TAG(x) unsigned_##x
-
-#define TYPE GLubyte
-#define T_MIN 0
-#define T_MAX 0xff
-
-#include "texcompress_rgtc_tmp.h"
-
-#undef TAG
-#undef TYPE
-#undef T_MIN
-#undef T_MAX
-
-#define TAG(x) signed_##x
-#define TYPE GLbyte
-#define T_MIN (GLbyte)-128
-#define T_MAX (GLbyte)127
-
-#include "texcompress_rgtc_tmp.h"
-
-#undef TAG
-#undef TYPE
-#undef T_MIN
-#undef T_MAX
-
-
-
static void
fetch_red_rgtc1(const GLubyte *map,
GLint rowStride, GLint i, GLint j, GLfloat *texel)
{
GLubyte red;
- unsigned_fetch_texel_rgtc(rowStride, map, i, j, &red, 1);
+ util_format_unsigned_fetch_texel_rgtc(rowStride, map, i, j, &red, 1);
texel[RCOMP] = UBYTE_TO_FLOAT(red);
texel[GCOMP] = 0.0;
texel[BCOMP] = 0.0;
@@ -334,7 +293,7 @@ fetch_l_latc1(const GLubyte *map,
GLint rowStride, GLint i, GLint j, GLfloat *texel)
{
GLubyte red;
- unsigned_fetch_texel_rgtc(rowStride, map, i, j, &red, 1);
+ util_format_unsigned_fetch_texel_rgtc(rowStride, map, i, j, &red, 1);
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = UBYTE_TO_FLOAT(red);
@@ -346,7 +305,7 @@ fetch_signed_red_rgtc1(const GLubyte *map,
GLint rowStride, GLint i, GLint j, GLfloat *texel)
{
GLbyte red;
- signed_fetch_texel_rgtc(rowStride, (const GLbyte *) map,
+ util_format_signed_fetch_texel_rgtc(rowStride, (const GLbyte *) map,
i, j, &red, 1);
texel[RCOMP] = BYTE_TO_FLOAT_TEX(red);
texel[GCOMP] = 0.0;
@@ -359,7 +318,7 @@ fetch_signed_l_latc1(const GLubyte *map,
GLint rowStride, GLint i, GLint j, GLfloat *texel)
{
GLbyte red;
- signed_fetch_texel_rgtc(rowStride, (GLbyte *) map,
+ util_format_signed_fetch_texel_rgtc(rowStride, (GLbyte *) map,
i, j, &red, 1);
texel[RCOMP] =
texel[GCOMP] =
@@ -372,10 +331,10 @@ fetch_rg_rgtc2(const GLubyte *map,
GLint rowStride, GLint i, GLint j, GLfloat *texel)
{
GLubyte red, green;
- unsigned_fetch_texel_rgtc(rowStride,
+ util_format_unsigned_fetch_texel_rgtc(rowStride,
map,
i, j, &red, 2);
- unsigned_fetch_texel_rgtc(rowStride,
+ util_format_unsigned_fetch_texel_rgtc(rowStride,
map + 8,
i, j, &green, 2);
texel[RCOMP] = UBYTE_TO_FLOAT(red);
@@ -389,10 +348,10 @@ fetch_la_latc2(const GLubyte *map,
GLint rowStride, GLint i, GLint j, GLfloat *texel)
{
GLubyte red, green;
- unsigned_fetch_texel_rgtc(rowStride,
+ util_format_unsigned_fetch_texel_rgtc(rowStride,
map,
i, j, &red, 2);
- unsigned_fetch_texel_rgtc(rowStride,
+ util_format_unsigned_fetch_texel_rgtc(rowStride,
map + 8,
i, j, &green, 2);
texel[RCOMP] =
@@ -407,10 +366,10 @@ fetch_signed_rg_rgtc2(const GLubyte *map,
GLint rowStride, GLint i, GLint j, GLfloat *texel)
{
GLbyte red, green;
- signed_fetch_texel_rgtc(rowStride,
+ util_format_signed_fetch_texel_rgtc(rowStride,
(GLbyte *) map,
i, j, &red, 2);
- signed_fetch_texel_rgtc(rowStride,
+ util_format_signed_fetch_texel_rgtc(rowStride,
(GLbyte *) map + 8,
i, j, &green, 2);
texel[RCOMP] = BYTE_TO_FLOAT_TEX(red);
@@ -425,10 +384,10 @@ fetch_signed_la_latc2(const GLubyte *map,
GLint rowStride, GLint i, GLint j, GLfloat *texel)
{
GLbyte red, green;
- signed_fetch_texel_rgtc(rowStride,
+ util_format_signed_fetch_texel_rgtc(rowStride,
(GLbyte *) map,
i, j, &red, 2);
- signed_fetch_texel_rgtc(rowStride,
+ util_format_signed_fetch_texel_rgtc(rowStride,
(GLbyte *) map + 8,
i, j, &green, 2);
texel[RCOMP] =
diff --git a/mesalib/src/mesa/main/texformat.c b/mesalib/src/mesa/main/texformat.c
index 6d3b80556..832e66128 100644
--- a/mesalib/src/mesa/main/texformat.c
+++ b/mesalib/src/mesa/main/texformat.c
@@ -485,6 +485,7 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
case GL_LUMINANCE_ALPHA_SNORM:
case GL_LUMINANCE8_ALPHA8_SNORM:
RETURN_IF_SUPPORTED(MESA_FORMAT_L8A8_SNORM);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_A8L8_SNORM);
RETURN_IF_SUPPORTED(MESA_FORMAT_A8B8G8R8_SNORM);
RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8A8_SNORM);
break;
@@ -539,6 +540,9 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
RETURN_IF_SUPPORTED(MESA_FORMAT_BGR_SRGB8);
RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
+
+ RETURN_IF_SUPPORTED(MESA_FORMAT_X8B8G8R8_SRGB);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
break;
case GL_SRGB_ALPHA_EXT:
case GL_SRGB8_ALPHA8_EXT:
@@ -546,36 +550,45 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
RETURN_IF_SUPPORTED(MESA_FORMAT_A8B8G8R8_SRGB);
RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
break;
case GL_SLUMINANCE_EXT:
case GL_SLUMINANCE8_EXT:
RETURN_IF_SUPPORTED(MESA_FORMAT_L_SRGB8);
RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
break;
case GL_SLUMINANCE_ALPHA_EXT:
case GL_SLUMINANCE8_ALPHA8_EXT:
RETURN_IF_SUPPORTED(MESA_FORMAT_L8A8_SRGB);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_A8L8_SRGB);
RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
break;
case GL_COMPRESSED_SLUMINANCE_EXT:
RETURN_IF_SUPPORTED(MESA_FORMAT_L_SRGB8);
RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
break;
case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
RETURN_IF_SUPPORTED(MESA_FORMAT_L8A8_SRGB);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_A8L8_SRGB);
RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
break;
case GL_COMPRESSED_SRGB_EXT:
if (ctx->Mesa_DXTn)
RETURN_IF_SUPPORTED(MESA_FORMAT_SRGB_DXT1);
RETURN_IF_SUPPORTED(MESA_FORMAT_BGR_SRGB8);
RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
break;
case GL_COMPRESSED_SRGB_ALPHA_EXT:
if (ctx->Mesa_DXTn)
RETURN_IF_SUPPORTED(MESA_FORMAT_SRGBA_DXT3); /* Not srgba_dxt1, see spec */
RETURN_IF_SUPPORTED(MESA_FORMAT_A8B8G8R8_SRGB);
RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
break;
case GL_ALPHA8UI_EXT:
diff --git a/mesalib/src/mesa/main/uniform_query.cpp b/mesalib/src/mesa/main/uniform_query.cpp
index 4cd2bca01..1592c9bfd 100644
--- a/mesalib/src/mesa/main/uniform_query.cpp
+++ b/mesalib/src/mesa/main/uniform_query.cpp
@@ -226,6 +226,13 @@ validate_uniform_parameters(struct gl_context *ctx,
return NULL;
}
+ /* Check that the given location is in bounds of uniform remap table. */
+ if (location >= (GLint) shProg->NumUniformRemapTable) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)",
+ caller, location);
+ return NULL;
+ }
+
/* Page 82 (page 96 of the PDF) of the OpenGL 2.1 spec says:
*
* "If any of the following conditions occur, an INVALID_OPERATION
@@ -239,19 +246,12 @@ validate_uniform_parameters(struct gl_context *ctx,
* - if count is greater than one, and the uniform declared in the
* shader is not an array variable,
*/
- if (location < -1) {
+ if (location < -1 || !shProg->UniformRemapTable[location]) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)",
caller, location);
return NULL;
}
- /* Check that the given location is in bounds of uniform remap table. */
- if (location >= (GLint) shProg->NumUniformRemapTable) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)",
- caller, location);
- return NULL;
- }
-
/* If the driver storage pointer in remap table is -1, we ignore silently.
*
* GL_ARB_explicit_uniform_location spec says:
diff --git a/mesalib/src/mesa/main/varray.c b/mesalib/src/mesa/main/varray.c
index 7d169f9d4..ead78649d 100644
--- a/mesalib/src/mesa/main/varray.c
+++ b/mesalib/src/mesa/main/varray.c
@@ -1867,7 +1867,6 @@ _mesa_copy_client_array(struct gl_context *ctx,
dst->InstanceDivisor = src->InstanceDivisor;
dst->_ElementSize = src->_ElementSize;
_mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj);
- dst->_MaxElement = src->_MaxElement;
}
void
@@ -1911,11 +1910,10 @@ print_array(const char *name, GLint index, const struct gl_client_array *array)
printf(" %s[%d]: ", name, index);
else
printf(" %s: ", name);
- printf("Ptr=%p, Type=0x%x, Size=%d, ElemSize=%u, Stride=%d, Buffer=%u(Size %lu), MaxElem=%u\n",
+ printf("Ptr=%p, Type=0x%x, Size=%d, ElemSize=%u, Stride=%d, Buffer=%u(Size %lu)\n",
array->Ptr, array->Type, array->Size,
array->_ElementSize, array->StrideB,
- array->BufferObj->Name, (unsigned long) array->BufferObj->Size,
- array->_MaxElement);
+ array->BufferObj->Name, (unsigned long) array->BufferObj->Size);
}
@@ -1928,8 +1926,6 @@ _mesa_print_arrays(struct gl_context *ctx)
struct gl_vertex_array_object *vao = ctx->Array.VAO;
GLuint i;
- _mesa_update_vao_max_element(ctx, vao);
-
printf("Array Object %u\n", vao->Name);
if (vao->_VertexAttrib[VERT_ATTRIB_POS].Enabled)
print_array("Vertex", -1, &vao->_VertexAttrib[VERT_ATTRIB_POS]);
@@ -1943,7 +1939,6 @@ _mesa_print_arrays(struct gl_context *ctx)
for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++)
if (vao->_VertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled)
print_array("Attrib", i, &vao->_VertexAttrib[VERT_ATTRIB_GENERIC(i)]);
- printf(" _MaxElement = %u\n", vao->_MaxElement);
}
diff --git a/mesalib/src/mesa/main/varray.h b/mesalib/src/mesa/main/varray.h
index d5d8b363d..4e4bd5f80 100644
--- a/mesalib/src/mesa/main/varray.h
+++ b/mesalib/src/mesa/main/varray.h
@@ -34,39 +34,6 @@
struct gl_client_array;
struct gl_context;
-
-/**
- * Compute the index of the last array element that can be safely accessed in
- * a vertex array. We can really only do this when the array lives in a VBO.
- * The array->_MaxElement field will be updated.
- * Later in glDrawArrays/Elements/etc we can do some bounds checking.
- */
-static inline void
-_mesa_update_array_max_element(struct gl_client_array *array)
-{
- assert(array->Enabled);
-
- if (array->BufferObj->Name) {
- GLsizeiptrARB offset = (GLsizeiptrARB) array->Ptr;
- GLsizeiptrARB bufSize = (GLsizeiptrARB) array->BufferObj->Size;
-
- if (offset < bufSize) {
- const GLuint stride = array->StrideB ?
- array->StrideB : array->_ElementSize;
- array->_MaxElement = (bufSize - offset + stride
- - array->_ElementSize) / stride;
- }
- else {
- array->_MaxElement = 0;
- }
- }
- else {
- /* user-space array, no idea how big it is */
- array->_MaxElement = 2 * 1000 * 1000 * 1000; /* just a big number */
- }
-}
-
-
/**
* Returns a pointer to the vertex attribute data in a client array,
* or the offset into the vertex buffer for an array that resides in
diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp
index 49e4a7a40..293fe34b9 100644
--- a/mesalib/src/mesa/program/ir_to_mesa.cpp
+++ b/mesalib/src/mesa/program/ir_to_mesa.cpp
@@ -2505,12 +2505,7 @@ _mesa_associate_uniform_storage(struct gl_context *ctx,
columns = storage->type->matrix_columns;
break;
case GLSL_TYPE_BOOL:
- if (ctx->Const.NativeIntegers) {
- format = (ctx->Const.UniformBooleanTrue == 1)
- ? uniform_bool_int_0_1 : uniform_bool_int_0_not0;
- } else {
- format = uniform_bool_float;
- }
+ format = uniform_native;
columns = 1;
break;
case GLSL_TYPE_SAMPLER:
diff --git a/mesalib/src/mesa/program/prog_optimize.c b/mesalib/src/mesa/program/prog_optimize.c
index 08c1c3046..60530ebf0 100644
--- a/mesalib/src/mesa/program/prog_optimize.c
+++ b/mesalib/src/mesa/program/prog_optimize.c
@@ -114,7 +114,6 @@ get_src_arg_mask(const struct prog_instruction *inst,
read_mask = 0x0;
for (comp = 0; comp < 4; ++comp) {
const GLuint coord = GET_SWZ(inst->SrcReg[arg].Swizzle, comp);
- ASSERT(coord < 4);
if (channel_mask & (1 << comp) && coord <= SWIZZLE_W)
read_mask |= 1 << coord;
}
@@ -284,11 +283,11 @@ _mesa_remove_dead_code_global(struct gl_program *prog)
for (comp = 0; comp < 4; comp++) {
const GLuint swz = GET_SWZ(inst->SrcReg[j].Swizzle, comp);
- ASSERT(swz < 4);
- if ((read_mask & (1 << swz)) == 0)
- continue;
- if (swz <= SWIZZLE_W)
+ if (swz <= SWIZZLE_W) {
+ if ((read_mask & (1 << swz)) == 0)
+ continue;
tempRead[index][swz] = GL_TRUE;
+ }
}
}
}
diff --git a/mesalib/src/mesa/program/register_allocate.c b/mesalib/src/mesa/program/register_allocate.c
index db2be5dfa..7faf67215 100644
--- a/mesalib/src/mesa/program/register_allocate.c
+++ b/mesalib/src/mesa/program/register_allocate.c
@@ -434,6 +434,7 @@ decrement_q(struct ra_graph *g, unsigned int n)
unsigned int n2_class = g->nodes[n2].class;
if (n != n2 && !g->nodes[n2].in_stack) {
+ assert(g->nodes[n2].q_total >= g->regs->classes[n2_class]->q[n_class]);
g->nodes[n2].q_total -= g->regs->classes[n2_class]->q[n_class];
}
}
diff --git a/mesalib/src/mesa/program/register_allocate.h b/mesalib/src/mesa/program/register_allocate.h
index bfc9190dc..dc6874495 100644
--- a/mesalib/src/mesa/program/register_allocate.h
+++ b/mesalib/src/mesa/program/register_allocate.h
@@ -56,7 +56,10 @@ void ra_set_finalize(struct ra_regs *regs, unsigned int **conflicts);
* Each interference graph node is a virtual variable in the IL. It
* is up to the user to ra_set_node_class() for the virtual variable,
* and compute live ranges and ra_node_interfere() between conflicting
- * live ranges.
+ * live ranges. Note that an interference *must not* be added between
+ * two nodes if their classes haven't been assigned yet. The user
+ * should set the class of each node before building the interference
+ * graph.
*/
struct ra_graph *ra_alloc_interference_graph(struct ra_regs *regs,
unsigned int count);
diff --git a/mesalib/src/mesa/state_tracker/st_atom_texture.c b/mesalib/src/mesa/state_tracker/st_atom_texture.c
index 03d05932a..ed9a44429 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_texture.c
@@ -192,9 +192,9 @@ get_texture_format_swizzle(const struct st_texture_object *stObj)
return swizzle_swizzle(stObj->base._Swizzle, tex_swizzle);
}
-
+
/**
- * Return TRUE if the texture's sampler view swizzle is equal to
+ * Return TRUE if the texture's sampler view swizzle is not equal to
* the texture's swizzle.
*
* \param stObj the st texture object,
@@ -214,9 +214,20 @@ check_sampler_swizzle(const struct st_texture_object *stObj,
static unsigned last_level(struct st_texture_object *stObj)
{
- return MIN2(stObj->base._MaxLevel, stObj->pt->last_level);
+ unsigned ret = MIN2(stObj->base.MinLevel + stObj->base._MaxLevel,
+ stObj->pt->last_level);
+ if (stObj->base.Immutable)
+ ret = MIN2(ret, stObj->base.MinLevel + stObj->base.NumLevels - 1);
+ return ret;
}
+static unsigned last_layer(struct st_texture_object *stObj)
+{
+ if (stObj->base.Immutable)
+ return MIN2(stObj->base.MinLayer + stObj->base.NumLayers - 1,
+ stObj->pt->array_size - 1);
+ return stObj->pt->array_size - 1;
+}
static struct pipe_sampler_view *
st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe,
@@ -249,9 +260,13 @@ st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe,
templ.u.buf.first_element = f;
templ.u.buf.last_element = f + (n - 1);
} else {
- templ.u.tex.first_level = stObj->base.BaseLevel;
+ templ.u.tex.first_level = stObj->base.MinLevel + stObj->base.BaseLevel;
templ.u.tex.last_level = last_level(stObj);
assert(templ.u.tex.first_level <= templ.u.tex.last_level);
+ templ.u.tex.first_layer = stObj->base.MinLayer;
+ templ.u.tex.last_layer = last_layer(stObj);
+ assert(templ.u.tex.first_layer <= templ.u.tex.last_layer);
+ templ.target = gl_target_to_pipe(stObj->base.Target);
}
if (swizzle != SWIZZLE_NOOP) {
@@ -287,8 +302,11 @@ st_get_texture_sampler_view_from_stobj(struct st_context *st,
if (*sv) {
if (check_sampler_swizzle(stObj, *sv) ||
(format != (*sv)->format) ||
- stObj->base.BaseLevel != (*sv)->u.tex.first_level ||
- last_level(stObj) != (*sv)->u.tex.last_level) {
+ gl_target_to_pipe(stObj->base.Target) != (*sv)->target ||
+ stObj->base.MinLevel + stObj->base.BaseLevel != (*sv)->u.tex.first_level ||
+ last_level(stObj) != (*sv)->u.tex.last_level ||
+ stObj->base.MinLayer != (*sv)->u.tex.first_layer ||
+ last_layer(stObj) != (*sv)->u.tex.last_layer) {
pipe_sampler_view_reference(sv, NULL);
}
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.c b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
index 7cfd3dade..470ab278b 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_fbo.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
@@ -450,6 +450,16 @@ st_update_renderbuffer_surface(struct st_context *st,
last_layer = strb->rtt_face + strb->rtt_slice;
}
+ /* Adjust for texture views */
+ if (strb->is_rtt) {
+ struct gl_texture_object *tex = strb->Base.TexImage->TexObject;
+ first_layer += tex->MinLayer;
+ if (!strb->rtt_layered)
+ last_layer += tex->MinLayer;
+ else
+ last_layer = MIN2(first_layer + tex->NumLayers - 1, last_layer);
+ }
+
if (!strb->surface ||
strb->surface->texture->nr_samples != strb->Base.NumSamples ||
strb->surface->format != format ||
diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c
index ad14bd939..dfa188a3f 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c
@@ -829,12 +829,12 @@ st_TexSubImage(struct gl_context *ctx, GLuint dims,
blit.src.level = 0;
blit.src.format = src_format;
blit.dst.resource = dst;
- blit.dst.level = stObj->pt != stImage->pt ? 0 : texImage->Level;
+ blit.dst.level = stObj->pt != stImage->pt ? 0 : texImage->TexObject->MinLevel + texImage->Level;
blit.dst.format = dst_format;
blit.src.box.x = blit.src.box.y = blit.src.box.z = 0;
blit.dst.box.x = xoffset;
blit.dst.box.y = yoffset;
- blit.dst.box.z = zoffset + texImage->Face;
+ blit.dst.box.z = zoffset + texImage->Face + texImage->TexObject->MinLayer;
blit.src.box.width = blit.dst.box.width = width;
blit.src.box.height = blit.dst.box.height = height;
blit.src.box.depth = blit.dst.box.depth = depth;
@@ -916,7 +916,8 @@ st_GetTexImage(struct gl_context * ctx,
GLuint height = texImage->Height;
GLuint depth = texImage->Depth;
struct st_texture_image *stImage = st_texture_image(texImage);
- struct pipe_resource *src = st_texture_object(texImage->TexObject)->pt;
+ struct st_texture_object *stObj = st_texture_object(texImage->TexObject);
+ struct pipe_resource *src = stObj->pt;
struct pipe_resource *dst = NULL;
struct pipe_resource dst_templ;
enum pipe_format dst_format, src_format;
@@ -970,7 +971,10 @@ st_GetTexImage(struct gl_context * ctx,
* - Luminance alpha must be returned as (L,0,0,A).
* - Intensity must be returned as (I,0,0,1)
*/
- src_format = util_format_linear(src->format);
+ if (stObj->surface_based)
+ src_format = util_format_linear(stObj->surface_format);
+ else
+ src_format = util_format_linear(src->format);
src_format = util_format_luminance_to_red(src_format);
src_format = util_format_intensity_to_red(src_format);
@@ -1069,14 +1073,14 @@ st_GetTexImage(struct gl_context * ctx,
memset(&blit, 0, sizeof(blit));
blit.src.resource = src;
- blit.src.level = texImage->Level;
+ blit.src.level = texImage->Level + texImage->TexObject->MinLevel;
blit.src.format = src_format;
blit.dst.resource = dst;
blit.dst.level = 0;
blit.dst.format = dst->format;
blit.src.box.x = blit.dst.box.x = 0;
blit.src.box.y = blit.dst.box.y = 0;
- blit.src.box.z = texImage->Face;
+ blit.src.box.z = texImage->Face + texImage->TexObject->MinLayer;
blit.dst.box.z = 0;
blit.src.box.width = blit.dst.box.width = width;
blit.src.box.height = blit.dst.box.height = height;
@@ -1441,10 +1445,10 @@ st_CopyTexSubImage(struct gl_context *ctx, GLuint dims,
blit.src.box.depth = 1;
blit.dst.resource = stImage->pt;
blit.dst.format = dst_format;
- blit.dst.level = stObj->pt != stImage->pt ? 0 : texImage->Level;
+ blit.dst.level = stObj->pt != stImage->pt ? 0 : texImage->Level + texImage->TexObject->MinLevel;
blit.dst.box.x = destX;
blit.dst.box.y = destY;
- blit.dst.box.z = stImage->base.Face + slice;
+ blit.dst.box.z = stImage->base.Face + slice + texImage->TexObject->MinLayer;
blit.dst.box.width = width;
blit.dst.box.height = height;
blit.dst.box.depth = 1;
@@ -1545,6 +1549,9 @@ st_finalize_texture(struct gl_context *ctx,
enum pipe_format firstImageFormat;
GLuint ptWidth, ptHeight, ptDepth, ptLayers, ptNumSamples;
+ if (tObj->Immutable)
+ return GL_TRUE;
+
if (_mesa_is_texture_complete(tObj, &tObj->Sampler)) {
/* The texture is complete and we know exactly how many mipmap levels
* are present/needed. This is conditional because we may be called
@@ -1824,6 +1831,44 @@ st_TestProxyTexImage(struct gl_context *ctx, GLenum target,
}
}
+static GLboolean
+st_TextureView(struct gl_context *ctx,
+ struct gl_texture_object *texObj,
+ struct gl_texture_object *origTexObj)
+{
+ struct st_texture_object *orig = st_texture_object(origTexObj);
+ struct st_texture_object *tex = st_texture_object(texObj);
+ struct gl_texture_image *image = texObj->Image[0][0];
+
+ const int numFaces = _mesa_num_tex_faces(texObj->Target);
+ const int numLevels = texObj->NumLevels;
+
+ int face;
+ int level;
+
+ pipe_resource_reference(&tex->pt, orig->pt);
+
+ /* Set image resource pointers */
+ for (level = 0; level < numLevels; level++) {
+ for (face = 0; face < numFaces; face++) {
+ struct st_texture_image *stImage =
+ st_texture_image(texObj->Image[face][level]);
+ pipe_resource_reference(&stImage->pt, tex->pt);
+ }
+ }
+
+ tex->surface_based = GL_TRUE;
+ tex->surface_format =
+ st_mesa_format_to_pipe_format(st_context(ctx), image->TexFormat);
+
+ tex->width0 = image->Width;
+ tex->height0 = image->Height;
+ tex->depth0 = image->Depth;
+ tex->lastLevel = numLevels - 1;
+
+ return GL_TRUE;
+}
+
void
st_init_texture_functions(struct dd_function_table *functions)
@@ -1855,4 +1900,5 @@ st_init_texture_functions(struct dd_function_table *functions)
functions->TestProxyTexImage = st_TestProxyTexImage;
functions->AllocTextureStorage = st_AllocTextureStorage;
+ functions->TextureView = st_TextureView;
}
diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c
index 09b615465..768a66790 100644
--- a/mesalib/src/mesa/state_tracker/st_context.c
+++ b/mesalib/src/mesa/state_tracker/st_context.c
@@ -104,6 +104,42 @@ void st_invalidate_state(struct gl_context * ctx, GLuint new_state)
_vbo_InvalidateState(ctx, new_state);
}
+
+static void
+st_destroy_context_priv(struct st_context *st)
+{
+ uint shader, i;
+
+ st_destroy_atoms( st );
+ st_destroy_draw( st );
+ st_destroy_clear(st);
+ st_destroy_bitmap(st);
+ st_destroy_drawpix(st);
+ st_destroy_drawtex(st);
+
+ for (shader = 0; shader < Elements(st->state.sampler_views); shader++) {
+ for (i = 0; i < Elements(st->state.sampler_views[0]); i++) {
+ pipe_sampler_view_release(st->pipe,
+ &st->state.sampler_views[shader][i]);
+ }
+ }
+
+ if (st->default_texture) {
+ st->ctx->Driver.DeleteTexture(st->ctx, st->default_texture);
+ st->default_texture = NULL;
+ }
+
+ u_upload_destroy(st->uploader);
+ if (st->indexbuf_uploader) {
+ u_upload_destroy(st->indexbuf_uploader);
+ }
+ if (st->constbuf_uploader) {
+ u_upload_destroy(st->constbuf_uploader);
+ }
+ free( st );
+}
+
+
static struct st_context *
st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe,
const struct st_config_options *options)
@@ -238,6 +274,14 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe,
_mesa_compute_version(ctx);
+ if (ctx->Version == 0) {
+ /* This can happen when a core profile was requested, but the driver
+ * does not support some features of GL 3.1 or later.
+ */
+ st_destroy_context_priv(st);
+ return NULL;
+ }
+
_mesa_initialize_dispatch_tables(ctx);
_mesa_initialize_vbo_vtxfmt(ctx);
@@ -259,6 +303,7 @@ struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
struct gl_context *ctx;
struct gl_context *shareCtx = share ? share->ctx : NULL;
struct dd_function_table funcs;
+ struct st_context *st;
memset(&funcs, 0, sizeof(funcs));
st_init_driver_functions(&funcs);
@@ -276,41 +321,12 @@ struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
if (debug_get_option_mesa_mvp_dp4())
ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS = GL_TRUE;
- return st_create_context_priv(ctx, pipe, options);
-}
-
-
-static void st_destroy_context_priv( struct st_context *st )
-{
- uint shader, i;
-
- st_destroy_atoms( st );
- st_destroy_draw( st );
- st_destroy_clear(st);
- st_destroy_bitmap(st);
- st_destroy_drawpix(st);
- st_destroy_drawtex(st);
-
- for (shader = 0; shader < Elements(st->state.sampler_views); shader++) {
- for (i = 0; i < Elements(st->state.sampler_views[0]); i++) {
- pipe_sampler_view_release(st->pipe,
- &st->state.sampler_views[shader][i]);
- }
+ st = st_create_context_priv(ctx, pipe, options);
+ if (!st) {
+ _mesa_destroy_context(ctx);
}
- if (st->default_texture) {
- st->ctx->Driver.DeleteTexture(st->ctx, st->default_texture);
- st->default_texture = NULL;
- }
-
- u_upload_destroy(st->uploader);
- if (st->indexbuf_uploader) {
- u_upload_destroy(st->indexbuf_uploader);
- }
- if (st->constbuf_uploader) {
- u_upload_destroy(st->constbuf_uploader);
- }
- free( st );
+ return st;
}
diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index 07bd12567..c7bc0ca50 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -463,6 +463,7 @@ void st_init_extensions(struct pipe_screen *screen,
{ o(ARB_draw_indirect), PIPE_CAP_DRAW_INDIRECT },
{ o(ARB_derivative_control), PIPE_CAP_TGSI_FS_FINE_DERIVATIVE },
{ o(ARB_conditional_render_inverted), PIPE_CAP_CONDITIONAL_RENDER_INVERTED },
+ { o(ARB_texture_view), PIPE_CAP_SAMPLER_VIEW_TARGET },
};
/* Required: render target and sampler support */
diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c
index b5e03b0f8..6c53567fc 100644
--- a/mesalib/src/mesa/state_tracker/st_format.c
+++ b/mesalib/src/mesa/state_tracker/st_format.c
@@ -88,9 +88,13 @@ st_mesa_format_to_pipe_format(struct st_context *st, mesa_format mesaFormat)
case MESA_FORMAT_L4A4_UNORM:
return PIPE_FORMAT_L4A4_UNORM;
case MESA_FORMAT_L8A8_UNORM:
- return PIPE_FORMAT_L8A8_UNORM;
+ return PIPE_FORMAT_LA88_UNORM;
+ case MESA_FORMAT_A8L8_UNORM:
+ return PIPE_FORMAT_AL88_UNORM;
case MESA_FORMAT_L16A16_UNORM:
- return PIPE_FORMAT_L16A16_UNORM;
+ return PIPE_FORMAT_LA1616_UNORM;
+ case MESA_FORMAT_A16L16_UNORM:
+ return PIPE_FORMAT_AL1616_UNORM;
case MESA_FORMAT_A_UNORM8:
return PIPE_FORMAT_A8_UNORM;
case MESA_FORMAT_A_UNORM16:
@@ -142,17 +146,21 @@ st_mesa_format_to_pipe_format(struct st_context *st, mesa_format mesaFormat)
case MESA_FORMAT_SRGBA_DXT5:
return PIPE_FORMAT_DXT5_SRGBA;
case MESA_FORMAT_L8A8_SRGB:
- return PIPE_FORMAT_L8A8_SRGB;
+ return PIPE_FORMAT_LA88_SRGB;
+ case MESA_FORMAT_A8L8_SRGB:
+ return PIPE_FORMAT_AL88_SRGB;
case MESA_FORMAT_L_SRGB8:
return PIPE_FORMAT_L8_SRGB;
case MESA_FORMAT_BGR_SRGB8:
return PIPE_FORMAT_R8G8B8_SRGB;
case MESA_FORMAT_A8B8G8R8_SRGB:
- return PIPE_FORMAT_A8B8G8R8_SRGB;
- case MESA_FORMAT_B8G8R8A8_SRGB:
- return PIPE_FORMAT_B8G8R8A8_SRGB;
+ return PIPE_FORMAT_ABGR8888_SRGB;
case MESA_FORMAT_R8G8B8A8_SRGB:
- return PIPE_FORMAT_R8G8B8A8_SRGB;
+ return PIPE_FORMAT_RGBA8888_SRGB;
+ case MESA_FORMAT_B8G8R8A8_SRGB:
+ return PIPE_FORMAT_BGRA8888_SRGB;
+ case MESA_FORMAT_A8R8G8B8_SRGB:
+ return PIPE_FORMAT_ARGB8888_SRGB;
case MESA_FORMAT_RGBA_FLOAT32:
return PIPE_FORMAT_R32G32B32A32_FLOAT;
case MESA_FORMAT_RGBA_FLOAT16:
@@ -191,9 +199,13 @@ st_mesa_format_to_pipe_format(struct st_context *st, mesa_format mesaFormat)
case MESA_FORMAT_R_UNORM16:
return PIPE_FORMAT_R16_UNORM;
case MESA_FORMAT_R8G8_UNORM:
- return PIPE_FORMAT_R8G8_UNORM;
+ return PIPE_FORMAT_RG88_UNORM;
+ case MESA_FORMAT_G8R8_UNORM:
+ return PIPE_FORMAT_GR88_UNORM;
case MESA_FORMAT_R16G16_UNORM:
- return PIPE_FORMAT_R16G16_UNORM;
+ return PIPE_FORMAT_RG1616_UNORM;
+ case MESA_FORMAT_G16R16_UNORM:
+ return PIPE_FORMAT_GR1616_UNORM;
case MESA_FORMAT_RGBA_UNORM16:
return PIPE_FORMAT_R16G16B16A16_UNORM;
@@ -341,23 +353,31 @@ st_mesa_format_to_pipe_format(struct st_context *st, mesa_format mesaFormat)
case MESA_FORMAT_R_SNORM8:
return PIPE_FORMAT_R8_SNORM;
case MESA_FORMAT_R8G8_SNORM:
- return PIPE_FORMAT_R8G8_SNORM;
+ return PIPE_FORMAT_RG88_SNORM;
+ case MESA_FORMAT_G8R8_SNORM:
+ return PIPE_FORMAT_GR88_SNORM;
case MESA_FORMAT_R8G8B8A8_SNORM:
- return PIPE_FORMAT_R8G8B8A8_SNORM;
+ return PIPE_FORMAT_RGBA8888_SNORM;
+ case MESA_FORMAT_A8B8G8R8_SNORM:
+ return PIPE_FORMAT_ABGR8888_SNORM;
case MESA_FORMAT_A_SNORM8:
return PIPE_FORMAT_A8_SNORM;
case MESA_FORMAT_L_SNORM8:
return PIPE_FORMAT_L8_SNORM;
case MESA_FORMAT_L8A8_SNORM:
- return PIPE_FORMAT_L8A8_SNORM;
+ return PIPE_FORMAT_LA88_SNORM;
+ case MESA_FORMAT_A8L8_SNORM:
+ return PIPE_FORMAT_AL88_SNORM;
case MESA_FORMAT_I_SNORM8:
return PIPE_FORMAT_I8_SNORM;
case MESA_FORMAT_R_SNORM16:
return PIPE_FORMAT_R16_SNORM;
case MESA_FORMAT_R16G16_SNORM:
- return PIPE_FORMAT_R16G16_SNORM;
+ return PIPE_FORMAT_RG1616_SNORM;
+ case MESA_FORMAT_G16R16_SNORM:
+ return PIPE_FORMAT_GR1616_SNORM;
case MESA_FORMAT_RGBA_SNORM16:
return PIPE_FORMAT_R16G16B16A16_SNORM;
@@ -384,9 +404,13 @@ st_mesa_format_to_pipe_format(struct st_context *st, mesa_format mesaFormat)
case MESA_FORMAT_B5G5R5X1_UNORM:
return PIPE_FORMAT_B5G5R5X1_UNORM;
case MESA_FORMAT_R8G8B8X8_SNORM:
- return PIPE_FORMAT_R8G8B8X8_SNORM;
+ return PIPE_FORMAT_RGBX8888_SNORM;
+ case MESA_FORMAT_X8B8G8R8_SNORM:
+ return PIPE_FORMAT_XBGR8888_SNORM;
case MESA_FORMAT_R8G8B8X8_SRGB:
- return PIPE_FORMAT_R8G8B8X8_SRGB;
+ return PIPE_FORMAT_RGBX8888_SRGB;
+ case MESA_FORMAT_X8B8G8R8_SRGB:
+ return PIPE_FORMAT_XBGR8888_SRGB;
case MESA_FORMAT_RGBX_UINT8:
return PIPE_FORMAT_R8G8B8X8_UINT;
case MESA_FORMAT_RGBX_SINT8:
@@ -411,7 +435,9 @@ st_mesa_format_to_pipe_format(struct st_context *st, mesa_format mesaFormat)
return PIPE_FORMAT_R32G32B32X32_SINT;
case MESA_FORMAT_B8G8R8X8_SRGB:
- return PIPE_FORMAT_B8G8R8X8_SRGB;
+ return PIPE_FORMAT_BGRX8888_SRGB;
+ case MESA_FORMAT_X8R8G8B8_SRGB:
+ return PIPE_FORMAT_XRGB8888_SRGB;
/* ETC2 formats are emulated as uncompressed ones.
* The destination formats mustn't be changed, because they are also
@@ -476,10 +502,14 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
return MESA_FORMAT_R10G10B10A2_UNORM;
case PIPE_FORMAT_L4A4_UNORM:
return MESA_FORMAT_L4A4_UNORM;
- case PIPE_FORMAT_L8A8_UNORM:
+ case PIPE_FORMAT_LA88_UNORM:
return MESA_FORMAT_L8A8_UNORM;
- case PIPE_FORMAT_L16A16_UNORM:
+ case PIPE_FORMAT_AL88_UNORM:
+ return MESA_FORMAT_A8L8_UNORM;
+ case PIPE_FORMAT_LA1616_UNORM:
return MESA_FORMAT_L16A16_UNORM;
+ case PIPE_FORMAT_AL1616_UNORM:
+ return MESA_FORMAT_A16L16_UNORM;
case PIPE_FORMAT_A8_UNORM:
return MESA_FORMAT_A_UNORM8;
case PIPE_FORMAT_A16_UNORM:
@@ -536,16 +566,22 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
return MESA_FORMAT_SRGBA_DXT3;
case PIPE_FORMAT_DXT5_SRGBA:
return MESA_FORMAT_SRGBA_DXT5;
- case PIPE_FORMAT_L8A8_SRGB:
+ case PIPE_FORMAT_LA88_SRGB:
return MESA_FORMAT_L8A8_SRGB;
+ case PIPE_FORMAT_AL88_SRGB:
+ return MESA_FORMAT_A8L8_SRGB;
case PIPE_FORMAT_L8_SRGB:
return MESA_FORMAT_L_SRGB8;
case PIPE_FORMAT_R8G8B8_SRGB:
return MESA_FORMAT_BGR_SRGB8;
- case PIPE_FORMAT_A8B8G8R8_SRGB:
+ case PIPE_FORMAT_ABGR8888_SRGB:
return MESA_FORMAT_A8B8G8R8_SRGB;
- case PIPE_FORMAT_B8G8R8A8_SRGB:
+ case PIPE_FORMAT_RGBA8888_SRGB:
+ return MESA_FORMAT_R8G8B8A8_SRGB;
+ case PIPE_FORMAT_BGRA8888_SRGB:
return MESA_FORMAT_B8G8R8A8_SRGB;
+ case PIPE_FORMAT_ARGB8888_SRGB:
+ return MESA_FORMAT_A8R8G8B8_SRGB;
case PIPE_FORMAT_R32G32B32A32_FLOAT:
return MESA_FORMAT_RGBA_FLOAT32;
case PIPE_FORMAT_R16G16B16A16_FLOAT:
@@ -583,10 +619,14 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
return MESA_FORMAT_R_UNORM8;
case PIPE_FORMAT_R16_UNORM:
return MESA_FORMAT_R_UNORM16;
- case PIPE_FORMAT_R8G8_UNORM:
+ case PIPE_FORMAT_RG88_UNORM:
return MESA_FORMAT_R8G8_UNORM;
- case PIPE_FORMAT_R16G16_UNORM:
+ case PIPE_FORMAT_GR88_UNORM:
+ return MESA_FORMAT_G8R8_UNORM;
+ case PIPE_FORMAT_RG1616_UNORM:
return MESA_FORMAT_R16G16_UNORM;
+ case PIPE_FORMAT_GR1616_UNORM:
+ return MESA_FORMAT_G16R16_UNORM;
case PIPE_FORMAT_A8_UINT:
return MESA_FORMAT_A_UINT8;
@@ -728,24 +768,32 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
/* signed normalized formats */
case PIPE_FORMAT_R8_SNORM:
return MESA_FORMAT_R_SNORM8;
- case PIPE_FORMAT_R8G8_SNORM:
+ case PIPE_FORMAT_RG88_SNORM:
return MESA_FORMAT_R8G8_SNORM;
- case PIPE_FORMAT_R8G8B8A8_SNORM:
+ case PIPE_FORMAT_GR88_SNORM:
+ return MESA_FORMAT_G8R8_SNORM;
+ case PIPE_FORMAT_RGBA8888_SNORM:
return MESA_FORMAT_R8G8B8A8_SNORM;
+ case PIPE_FORMAT_ABGR8888_SNORM:
+ return MESA_FORMAT_A8B8G8R8_SNORM;
case PIPE_FORMAT_A8_SNORM:
return MESA_FORMAT_A_SNORM8;
case PIPE_FORMAT_L8_SNORM:
return MESA_FORMAT_L_SNORM8;
- case PIPE_FORMAT_L8A8_SNORM:
+ case PIPE_FORMAT_LA88_SNORM:
return MESA_FORMAT_L8A8_SNORM;
+ case PIPE_FORMAT_AL88_SNORM:
+ return MESA_FORMAT_A8L8_SNORM;
case PIPE_FORMAT_I8_SNORM:
return MESA_FORMAT_I_SNORM8;
case PIPE_FORMAT_R16_SNORM:
return MESA_FORMAT_R_SNORM16;
- case PIPE_FORMAT_R16G16_SNORM:
+ case PIPE_FORMAT_RG1616_SNORM:
return MESA_FORMAT_R16G16_SNORM;
+ case PIPE_FORMAT_GR1616_SNORM:
+ return MESA_FORMAT_G16R16_SNORM;
case PIPE_FORMAT_R16G16B16A16_SNORM:
return MESA_FORMAT_RGBA_SNORM16;
@@ -772,10 +820,14 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
return MESA_FORMAT_B4G4R4X4_UNORM;
case PIPE_FORMAT_B5G5R5X1_UNORM:
return MESA_FORMAT_B5G5R5X1_UNORM;
- case PIPE_FORMAT_R8G8B8X8_SNORM:
+ case PIPE_FORMAT_RGBX8888_SNORM:
return MESA_FORMAT_R8G8B8X8_SNORM;
- case PIPE_FORMAT_R8G8B8X8_SRGB:
+ case PIPE_FORMAT_XBGR8888_SNORM:
+ return MESA_FORMAT_X8B8G8R8_SNORM;
+ case PIPE_FORMAT_RGBX8888_SRGB:
return MESA_FORMAT_R8G8B8X8_SRGB;
+ case PIPE_FORMAT_XBGR8888_SRGB:
+ return MESA_FORMAT_X8B8G8R8_SRGB;
case PIPE_FORMAT_R8G8B8X8_UINT:
return MESA_FORMAT_RGBX_UINT8;
case PIPE_FORMAT_R8G8B8X8_SINT:
@@ -799,10 +851,10 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
case PIPE_FORMAT_R32G32B32X32_SINT:
return MESA_FORMAT_RGBX_SINT32;
- case PIPE_FORMAT_B8G8R8X8_SRGB:
+ case PIPE_FORMAT_BGRX8888_SRGB:
return MESA_FORMAT_B8G8R8X8_SRGB;
- case PIPE_FORMAT_R8G8B8A8_SRGB:
- return MESA_FORMAT_R8G8B8A8_SRGB;
+ case PIPE_FORMAT_XRGB8888_SRGB:
+ return MESA_FORMAT_X8R8G8B8_SRGB;
default:
return MESA_FORMAT_NONE;
@@ -879,6 +931,7 @@ struct format_mapping
#define DEFAULT_SRGBA_FORMATS \
PIPE_FORMAT_B8G8R8A8_SRGB, \
+ PIPE_FORMAT_R8G8B8A8_SRGB, \
PIPE_FORMAT_A8R8G8B8_SRGB, \
PIPE_FORMAT_A8B8G8R8_SRGB, \
0
@@ -919,11 +972,11 @@ static const struct format_mapping format_map[] = {
},
{
{ 4, GL_RGBA, GL_RGBA8, 0 },
- { PIPE_FORMAT_R8G8B8A8_UNORM, DEFAULT_RGBA_FORMATS }
+ { DEFAULT_RGBA_FORMATS }
},
{
{ GL_BGRA, 0 },
- { PIPE_FORMAT_B8G8R8A8_UNORM, DEFAULT_RGBA_FORMATS }
+ { DEFAULT_RGBA_FORMATS }
},
{
{ 3, GL_RGB, GL_RGB8, 0 },
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 62e4101d1..b338a9836 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -3172,6 +3172,7 @@ glsl_to_tgsi_visitor::glsl_to_tgsi_visitor()
shader_program = NULL;
shader = NULL;
options = NULL;
+ have_sqrt = false;
}
glsl_to_tgsi_visitor::~glsl_to_tgsi_visitor()
@@ -4167,6 +4168,8 @@ const unsigned _mesa_sysval_to_semantic[SYSTEM_VALUE_MAX] = {
*/
TGSI_SEMANTIC_VERTEXID,
TGSI_SEMANTIC_INSTANCEID,
+ 0,
+ 0,
/* Geometry shader
*/
diff --git a/mesalib/src/mesa/state_tracker/st_texture.c b/mesalib/src/mesa/state_tracker/st_texture.c
index af9b7675f..c84aa4566 100644
--- a/mesalib/src/mesa/state_tracker/st_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_texture.c
@@ -260,6 +260,12 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage,
else
level = stImage->base.Level;
+ if (stObj->base.Immutable) {
+ level += stObj->base.MinLevel;
+ z += stObj->base.MinLayer;
+ d = MIN2(d, stObj->base.NumLayers);
+ }
+
z += stImage->base.Face;
map = pipe_transfer_map_3d(st->pipe, stImage->pt, level, usage,
@@ -289,8 +295,13 @@ st_texture_image_unmap(struct st_context *st,
struct st_texture_image *stImage, unsigned slice)
{
struct pipe_context *pipe = st->pipe;
- struct pipe_transfer **transfer =
- &stImage->transfer[slice + stImage->base.Face].transfer;
+ struct st_texture_object *stObj =
+ st_texture_object(stImage->base.TexObject);
+ struct pipe_transfer **transfer;
+
+ if (stObj->base.Immutable)
+ slice += stObj->base.MinLayer;
+ transfer = &stImage->transfer[slice + stImage->base.Face].transfer;
DBG("%s\n", __FUNCTION__);
diff --git a/mesalib/src/mesa/swrast/s_texfetch.c b/mesalib/src/mesa/swrast/s_texfetch.c
index 38d71caa3..0f6da919d 100644
--- a/mesalib/src/mesa/swrast/s_texfetch.c
+++ b/mesalib/src/mesa/swrast/s_texfetch.c
@@ -210,6 +210,7 @@ texfetch_funcs[] =
FETCH_FUNCS(R8G8_SNORM),
FETCH_NULL(G8R8_SNORM),
FETCH_FUNCS(L8A8_SNORM),
+ FETCH_FUNCS(A8L8_SNORM),
/* Array signed/normalized formats */
FETCH_FUNCS(A_SNORM8),
@@ -228,10 +229,14 @@ texfetch_funcs[] =
/* Packed sRGB formats */
FETCH_FUNCS(A8B8G8R8_SRGB),
FETCH_FUNCS(B8G8R8A8_SRGB),
+ FETCH_FUNCS(A8R8G8B8_SRGB),
FETCH_NULL(B8G8R8X8_SRGB),
+ FETCH_NULL(X8R8G8B8_SRGB),
FETCH_FUNCS(R8G8B8A8_SRGB),
FETCH_FUNCS(R8G8B8X8_SRGB),
+ FETCH_FUNCS(X8B8G8R8_SRGB),
FETCH_FUNCS(L8A8_SRGB),
+ FETCH_FUNCS(A8L8_SRGB),
/* Array sRGB formats */
FETCH_FUNCS(L_SRGB8),
diff --git a/mesalib/src/mesa/swrast/s_texfetch_tmp.h b/mesalib/src/mesa/swrast/s_texfetch_tmp.h
index 72037ec00..7ff30f6b4 100644
--- a/mesalib/src/mesa/swrast/s_texfetch_tmp.h
+++ b/mesalib/src/mesa/swrast/s_texfetch_tmp.h
@@ -769,6 +769,18 @@ FETCH(B8G8R8A8_SRGB)(const struct swrast_texture_image *texImage,
static void
+FETCH(A8R8G8B8_SRGB)(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ texel[RCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 8) & 0xff );
+ texel[GCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 16) & 0xff );
+ texel[BCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 24) );
+ texel[ACOMP] = UBYTE_TO_FLOAT( s & 0xff ); /* linear! */
+}
+
+
+static void
FETCH(R8G8B8A8_SRGB)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
@@ -793,6 +805,18 @@ FETCH(R8G8B8X8_SRGB)(const struct swrast_texture_image *texImage,
static void
+FETCH(X8B8G8R8_SRGB)(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ texel[RCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 24) );
+ texel[GCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 16) & 0xff );
+ texel[BCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 8) & 0xff );
+ texel[ACOMP] = 1.0f;
+}
+
+
+static void
FETCH(L_SRGB8)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
@@ -808,11 +832,23 @@ static void
FETCH(L8A8_SRGB)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
- const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 2);
+ const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
texel[RCOMP] =
texel[GCOMP] =
- texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(src[0]);
- texel[ACOMP] = UBYTE_TO_FLOAT(src[1]); /* linear */
+ texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(s & 0xff);
+ texel[ACOMP] = UBYTE_TO_FLOAT(s >> 8); /* linear */
+}
+
+
+static void
+FETCH(A8L8_SRGB)(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 2);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(s >> 8);
+ texel[ACOMP] = UBYTE_TO_FLOAT(s & 0xff); /* linear */
}
@@ -961,6 +997,18 @@ FETCH(L8A8_SNORM)(const struct swrast_texture_image *texImage,
static void
+FETCH(A8L8_SNORM)(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ const GLushort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
+ texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s & 0xff) );
+}
+
+
+static void
FETCH(X8B8G8R8_SNORM)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
diff --git a/mesalib/src/mesa/vbo/vbo_exec_array.c b/mesalib/src/mesa/vbo/vbo_exec_array.c
index 22557e168..111321bd7 100644
--- a/mesalib/src/mesa/vbo/vbo_exec_array.c
+++ b/mesalib/src/mesa/vbo/vbo_exec_array.c
@@ -1032,7 +1032,12 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
{
static GLuint warnCount = 0;
GLboolean index_bounds_valid = GL_TRUE;
- GLuint max_element;
+
+ /* This is only useful to catch invalid values in the "end" parameter
+ * like ~0.
+ */
+ GLuint max_element = 2 * 1000 * 1000 * 1000; /* just a big number */
+
GET_CURRENT_CONTEXT(ctx);
if (MESA_VERBOSE & VERBOSE_DRAW)
@@ -1045,25 +1050,6 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
type, indices, basevertex ))
return;
- if (ctx->Const.CheckArrayBounds) {
- /* _MaxElement was computed, so we can use it.
- * This path is used for drivers which need strict bounds checking.
- */
- max_element = ctx->Array.VAO->_MaxElement;
- }
- else {
- /* Generally, hardware drivers don't need to know the buffer bounds
- * if all vertex attributes are in VBOs.
- * However, if none of vertex attributes are in VBOs, _MaxElement
- * is always set to some random big number anyway, so bounds checking
- * is mostly useless.
- *
- * This is only useful to catch invalid values in the "end" parameter
- * like ~0.
- */
- max_element = 2 * 1000 * 1000 * 1000; /* just a big number */
- }
-
if ((int) end + basevertex < 0 ||
start + basevertex >= max_element) {
/* The application requested we draw using a range of indices that's
diff --git a/mesalib/src/mesa/vbo/vbo_exec_draw.c b/mesalib/src/mesa/vbo/vbo_exec_draw.c
index c454c6943..362cc1040 100644
--- a/mesalib/src/mesa/vbo/vbo_exec_draw.c
+++ b/mesalib/src/mesa/vbo/vbo_exec_draw.c
@@ -159,7 +159,6 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
struct vbo_context *vbo = vbo_context(ctx);
struct vbo_exec_context *exec = &vbo->exec;
struct gl_client_array *arrays = exec->vtx.arrays;
- const GLuint count = exec->vtx.vert_count;
const GLuint *map;
GLuint attr;
GLbitfield64 varying_inputs = 0x0;
@@ -241,7 +240,6 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
_mesa_reference_buffer_object(ctx,
&arrays[attr].BufferObj,
exec->vtx.bufferobj);
- arrays[attr]._MaxElement = count; /* ??? */
varying_inputs |= VERT_BIT(attr);
}
diff --git a/mesalib/src/mesa/vbo/vbo_save_draw.c b/mesalib/src/mesa/vbo/vbo_save_draw.c
index 89fd30e0f..d0521d794 100644
--- a/mesalib/src/mesa/vbo/vbo_save_draw.c
+++ b/mesalib/src/mesa/vbo/vbo_save_draw.c
@@ -203,7 +203,6 @@ static void vbo_bind_vertex_list(struct gl_context *ctx,
_mesa_reference_buffer_object(ctx,
&arrays[attr].BufferObj,
node->vertex_store->bufferobj);
- arrays[attr]._MaxElement = node->count; /* ??? */
assert(arrays[attr].BufferObj->Name);
diff --git a/mesalib/src/mesa/vbo/vbo_split_copy.c b/mesalib/src/mesa/vbo/vbo_split_copy.c
index 719ad651a..ca752e810 100644
--- a/mesalib/src/mesa/vbo/vbo_split_copy.c
+++ b/mesalib/src/mesa/vbo/vbo_split_copy.c
@@ -533,7 +533,6 @@ replay_init( struct copy_context *copy )
dst->Integer = src->Integer;
dst->BufferObj = ctx->Shared->NullBufferObj;
dst->_ElementSize = src->_ElementSize;
- dst->_MaxElement = copy->dstbuf_size; /* may be less! */
offset += copy->varying[i].size;
}
diff --git a/mesalib/src/util/Makefile.sources b/mesalib/src/util/Makefile.sources
index b99aa25e8..c34475a84 100644
--- a/mesalib/src/util/Makefile.sources
+++ b/mesalib/src/util/Makefile.sources
@@ -1,6 +1,7 @@
MESA_UTIL_FILES := \
hash_table.c \
- ralloc.c
+ ralloc.c \
+ rgtc.c
MESA_UTIL_GENERATED_FILES = \
format_srgb.c
diff --git a/mesalib/src/util/rgtc.c b/mesalib/src/util/rgtc.c
new file mode 100644
index 000000000..6886ac071
--- /dev/null
+++ b/mesalib/src/util/rgtc.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2011 Red Hat Inc.
+ *
+ * block compression parts are:
+ * Copyright (C) 2004 Roland Scheidegger 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, 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.
+ *
+ * Author:
+ * Dave Airlie
+ */
+
+#include <inttypes.h>
+#include "macros.h"
+
+#include "rgtc.h"
+
+#define RGTC_DEBUG 0
+
+#define TAG(x) util_format_unsigned_##x
+
+#define TYPE unsigned char
+#define T_MIN 0
+#define T_MAX 0xff
+
+#include "texcompress_rgtc_tmp.h"
+
+#undef TAG
+#undef TYPE
+#undef T_MIN
+#undef T_MAX
+
+#define TAG(x) util_format_signed_##x
+#define TYPE signed char
+#define T_MIN (signed char)-128
+#define T_MAX (signed char)127
+
+#include "texcompress_rgtc_tmp.h"
+
+#undef TAG
+#undef TYPE
+#undef T_MIN
+#undef T_MAX
+
diff --git a/mesalib/src/util/rgtc.h b/mesalib/src/util/rgtc.h
new file mode 100644
index 000000000..6bba9f2ec
--- /dev/null
+++ b/mesalib/src/util/rgtc.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright © 2014 Red Hat
+ *
+ * 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.
+ *
+ */
+
+#ifndef _RGTC_H
+#define _RGTC_H
+
+void util_format_unsigned_fetch_texel_rgtc(unsigned srcRowStride, const unsigned char *pixdata,
+ unsigned i, unsigned j, unsigned char *value, unsigned comps);
+
+void util_format_signed_fetch_texel_rgtc(unsigned srcRowStride, const signed char *pixdata,
+ unsigned i, unsigned j, signed char *value, unsigned comps);
+
+void util_format_unsigned_encode_rgtc_ubyte(unsigned char *blkaddr, unsigned char srccolors[4][4],
+ int numxpixels, int numypixels);
+
+void util_format_signed_encode_rgtc_ubyte(signed char *blkaddr, signed char srccolors[4][4],
+ int numxpixels, int numypixels);
+#endif /* _RGTC_H */
diff --git a/mesalib/src/mesa/main/texcompress_rgtc_tmp.h b/mesalib/src/util/texcompress_rgtc_tmp.h
index 5fa9de630..6bbae5ead 100644
--- a/mesalib/src/mesa/main/texcompress_rgtc_tmp.h
+++ b/mesalib/src/util/texcompress_rgtc_tmp.h
@@ -29,8 +29,8 @@
/* included by texcompress_rgtc to define byte/ubyte compressors */
-static void TAG(fetch_texel_rgtc)(unsigned srcRowStride, const TYPE *pixdata,
- unsigned i, unsigned j, TYPE *value, unsigned comps)
+void TAG(fetch_texel_rgtc)(unsigned srcRowStride, const TYPE *pixdata,
+ unsigned i, unsigned j, TYPE *value, unsigned comps)
{
TYPE decode;
const TYPE *blksrc = (pixdata + ((srcRowStride + 3) / 4 * (j / 4) + (i / 4)) * 8 * comps);
@@ -59,9 +59,9 @@ static void TAG(fetch_texel_rgtc)(unsigned srcRowStride, const TYPE *pixdata,
}
static void TAG(write_rgtc_encoded_channel)(TYPE *blkaddr,
- TYPE alphabase1,
- TYPE alphabase2,
- TYPE alphaenc[16])
+ TYPE alphabase1,
+ TYPE alphabase2,
+ TYPE alphaenc[16])
{
*blkaddr++ = alphabase1;
*blkaddr++ = alphabase2;
@@ -73,8 +73,8 @@ static void TAG(write_rgtc_encoded_channel)(TYPE *blkaddr,
*blkaddr++ = (alphaenc[13] >> 1) | (alphaenc[14] << 2) | (alphaenc[15] << 5);
}
-static void TAG(encode_rgtc_ubyte)(TYPE *blkaddr, TYPE srccolors[4][4],
- int numxpixels, int numypixels)
+void TAG(encode_rgtc_ubyte)(TYPE *blkaddr, TYPE srccolors[4][4],
+ int numxpixels, int numypixels)
{
TYPE alphabase[2], alphause[2];
short alphatest[2] = { 0 };